| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.s9api; |
| 9 |
|
| 10 |
import net.sf.saxon.lib.ConversionRules; |
| 11 |
import net.sf.saxon.lib.NamespaceConstant; |
| 12 |
import net.sf.saxon.lib.StandardURIChecker; |
| 13 |
import net.sf.saxon.ma.arrays.ArrayItem; |
| 14 |
import net.sf.saxon.ma.arrays.ArrayItemType; |
| 15 |
import net.sf.saxon.ma.map.MapItem; |
| 16 |
import net.sf.saxon.ma.map.MapType; |
| 17 |
import net.sf.saxon.om.Function; |
| 18 |
import net.sf.saxon.om.Item; |
| 19 |
import net.sf.saxon.om.NodeInfo; |
| 20 |
import net.sf.saxon.om.StructuredQName; |
| 21 |
import net.sf.saxon.pattern.AnyNodeTest; |
| 22 |
import net.sf.saxon.pattern.NodeKindTest; |
| 23 |
import net.sf.saxon.pattern.NodeTest; |
| 24 |
import net.sf.saxon.type.*; |
| 25 |
import net.sf.saxon.value.AtomicValue; |
| 26 |
import net.sf.saxon.value.NumericValue; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public abstract class ItemType { |
| 41 |
|
| 42 |
private static ConversionRules defaultConversionRules = new ConversionRules(); |
| 43 |
|
| 44 |
static { |
| 45 |
defaultConversionRules.setStringToDoubleConverter(StringToDouble.getInstance()); |
| 46 |
defaultConversionRules.setNotationSet(null); |
| 47 |
defaultConversionRules.setURIChecker(StandardURIChecker.getInstance()); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public static ItemType ANY_ITEM = new ItemType() { |
| 55 |
|
| 56 |
public ConversionRules getConversionRules() { |
| 57 |
return defaultConversionRules; |
| 58 |
} |
| 59 |
|
| 60 |
public boolean matches(XdmItem item) { |
| 61 |
return true; |
| 62 |
} |
| 63 |
|
| 64 |
public boolean subsumes(ItemType other) { |
| 65 |
return true; |
| 66 |
} |
| 67 |
|
| 68 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 69 |
return AnyItemType.getInstance(); |
| 70 |
} |
| 71 |
}; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
public static ItemType ANY_FUNCTION = new ItemType() { |
| 79 |
|
| 80 |
public boolean matches(XdmItem item) { |
| 81 |
return item.getUnderlyingValue() instanceof Function; |
| 82 |
} |
| 83 |
|
| 84 |
public boolean subsumes(ItemType other) { |
| 85 |
return other.getUnderlyingItemType() instanceof FunctionItemType; |
| 86 |
} |
| 87 |
|
| 88 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 89 |
return AnyFunctionType.getInstance(); |
| 90 |
} |
| 91 |
}; |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public static final ItemType ANY_NODE = new ItemType() { |
| 98 |
|
| 99 |
public boolean matches(XdmItem item) { |
| 100 |
return item.getUnderlyingValue() instanceof NodeInfo; |
| 101 |
} |
| 102 |
|
| 103 |
public boolean subsumes(ItemType other) { |
| 104 |
return other.getUnderlyingItemType() instanceof NodeTest; |
| 105 |
} |
| 106 |
|
| 107 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 108 |
return AnyNodeTest.getInstance(); |
| 109 |
} |
| 110 |
}; |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
public static final ItemType ATTRIBUTE_NODE = new ItemType() { |
| 118 |
|
| 119 |
public boolean matches(XdmItem item) { |
| 120 |
Item<?> it = item.getUnderlyingValue(); |
| 121 |
return it instanceof NodeInfo && ((NodeInfo) it).getNodeKind() == Type.ATTRIBUTE; |
| 122 |
} |
| 123 |
|
| 124 |
public boolean subsumes(ItemType other) { |
| 125 |
return other.getUnderlyingItemType().getUType() == UType.ATTRIBUTE; |
| 126 |
} |
| 127 |
|
| 128 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 129 |
return NodeKindTest.ATTRIBUTE; |
| 130 |
} |
| 131 |
}; |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
public static final ItemType COMMENT_NODE = new ItemType() { |
| 139 |
|
| 140 |
public boolean matches(XdmItem item) { |
| 141 |
Item<?> it = item.getUnderlyingValue(); |
| 142 |
return it instanceof NodeInfo && ((NodeInfo) it).getNodeKind() == Type.COMMENT; |
| 143 |
} |
| 144 |
|
| 145 |
public boolean subsumes(ItemType other) { |
| 146 |
return other.getUnderlyingItemType().getUType() == UType.COMMENT; |
| 147 |
} |
| 148 |
|
| 149 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 150 |
return NodeKindTest.COMMENT; |
| 151 |
} |
| 152 |
}; |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
public static final ItemType TEXT_NODE = new ItemType() { |
| 160 |
|
| 161 |
public boolean matches(XdmItem item) { |
| 162 |
Item<?> it = item.getUnderlyingValue(); |
| 163 |
return it instanceof NodeInfo && ((NodeInfo) it).getNodeKind() == Type.TEXT; |
| 164 |
} |
| 165 |
|
| 166 |
public boolean subsumes(ItemType other) { |
| 167 |
return other.getUnderlyingItemType().getUType() == UType.TEXT; |
| 168 |
} |
| 169 |
|
| 170 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 171 |
return NodeKindTest.TEXT; |
| 172 |
} |
| 173 |
}; |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
public static final ItemType ELEMENT_NODE = new ItemType() { |
| 181 |
|
| 182 |
public boolean matches(XdmItem item) { |
| 183 |
Item<?> it = item.getUnderlyingValue(); |
| 184 |
return it instanceof NodeInfo && ((NodeInfo) it).getNodeKind() == Type.ELEMENT; |
| 185 |
} |
| 186 |
|
| 187 |
public boolean subsumes(ItemType other) { |
| 188 |
return other.getUnderlyingItemType().getUType() == UType.ELEMENT; |
| 189 |
} |
| 190 |
|
| 191 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 192 |
return NodeKindTest.ELEMENT; |
| 193 |
} |
| 194 |
}; |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
public static final ItemType DOCUMENT_NODE = new ItemType() { |
| 201 |
|
| 202 |
public boolean matches(XdmItem item) { |
| 203 |
Item<?> it = item.getUnderlyingValue(); |
| 204 |
return it instanceof NodeInfo && ((NodeInfo) it).getNodeKind() == Type.DOCUMENT; |
| 205 |
} |
| 206 |
|
| 207 |
public boolean subsumes(ItemType other) { |
| 208 |
return other.getUnderlyingItemType().getUType() == UType.DOCUMENT; |
| 209 |
} |
| 210 |
|
| 211 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 212 |
return NodeKindTest.DOCUMENT; |
| 213 |
} |
| 214 |
}; |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
public static final ItemType NAMESPACE_NODE = new ItemType() { |
| 222 |
|
| 223 |
public boolean matches(XdmItem item) { |
| 224 |
Item<?> it = item.getUnderlyingValue(); |
| 225 |
return it instanceof NodeInfo && ((NodeInfo) it).getNodeKind() == Type.NAMESPACE; |
| 226 |
} |
| 227 |
|
| 228 |
public boolean subsumes(ItemType other) { |
| 229 |
return other.getUnderlyingItemType().getUType() == UType.NAMESPACE; |
| 230 |
} |
| 231 |
|
| 232 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 233 |
return NodeKindTest.NAMESPACE; |
| 234 |
} |
| 235 |
}; |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
public static final ItemType PROCESSING_INSTRUCTION_NODE = new ItemType() { |
| 243 |
|
| 244 |
public boolean matches(XdmItem item) { |
| 245 |
Item<?> it = item.getUnderlyingValue(); |
| 246 |
return it instanceof NodeInfo && ((NodeInfo) it).getNodeKind() == Type.PROCESSING_INSTRUCTION; |
| 247 |
} |
| 248 |
|
| 249 |
public boolean subsumes(ItemType other) { |
| 250 |
return other.getUnderlyingItemType().getUType() == UType.PI; |
| 251 |
} |
| 252 |
|
| 253 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 254 |
return NodeKindTest.PROCESSING_INSTRUCTION; |
| 255 |
} |
| 256 |
}; |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
public static final ItemType ANY_MAP = new ItemType() { |
| 264 |
|
| 265 |
public boolean matches(XdmItem item) { |
| 266 |
return item.getUnderlyingValue() instanceof MapItem; |
| 267 |
} |
| 268 |
|
| 269 |
public boolean subsumes(ItemType other) { |
| 270 |
return other.getUnderlyingItemType() instanceof MapType; |
| 271 |
} |
| 272 |
|
| 273 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 274 |
return MapType.ANY_MAP_TYPE; |
| 275 |
} |
| 276 |
}; |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
public static final ItemType ANY_ARRAY = new ItemType() { |
| 283 |
|
| 284 |
public boolean matches(XdmItem item) { |
| 285 |
return item.getUnderlyingValue() instanceof ArrayItem; |
| 286 |
} |
| 287 |
|
| 288 |
public boolean subsumes(ItemType other) { |
| 289 |
return other.getUnderlyingItemType() instanceof ArrayItemType; |
| 290 |
} |
| 291 |
|
| 292 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 293 |
return ArrayItemType.ANY_ARRAY_TYPE; |
| 294 |
} |
| 295 |
}; |
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
public static final ItemType ANY_ATOMIC_VALUE = new ItemType() { |
| 303 |
|
| 304 |
public boolean matches(XdmItem item) { |
| 305 |
return item.getUnderlyingValue() instanceof AtomicValue; |
| 306 |
} |
| 307 |
|
| 308 |
public boolean subsumes(ItemType other) { |
| 309 |
return other.getUnderlyingItemType() instanceof AtomicType; |
| 310 |
} |
| 311 |
|
| 312 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 313 |
return BuiltInAtomicType.ANY_ATOMIC; |
| 314 |
} |
| 315 |
}; |
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
static class BuiltInAtomicItemType extends ItemType { |
| 322 |
|
| 323 |
private BuiltInAtomicType underlyingType; |
| 324 |
private ConversionRules conversionRules; |
| 325 |
|
| 326 |
public BuiltInAtomicItemType(BuiltInAtomicType underlyingType, ConversionRules conversionRules) { |
| 327 |
this.underlyingType = underlyingType; |
| 328 |
this.conversionRules = conversionRules; |
| 329 |
} |
| 330 |
|
| 331 |
public static BuiltInAtomicItemType makeVariant(BuiltInAtomicItemType type, ConversionRules conversionRules) { |
| 332 |
return new BuiltInAtomicItemType(type.underlyingType, conversionRules); |
| 333 |
} |
| 334 |
|
| 335 |
public ConversionRules getConversionRules() { |
| 336 |
return conversionRules; |
| 337 |
} |
| 338 |
|
| 339 |
public boolean matches(XdmItem item) { |
| 340 |
Item value = item.getUnderlyingValue(); |
| 341 |
if (!(value instanceof AtomicValue)) { |
| 342 |
return false; |
| 343 |
} |
| 344 |
AtomicType type = ((AtomicValue) value).getItemType(); |
| 345 |
return subsumesUnderlyingType(type); |
| 346 |
} |
| 347 |
|
| 348 |
public boolean subsumes(ItemType other) { |
| 349 |
net.sf.saxon.type.ItemType otherType = other.getUnderlyingItemType(); |
| 350 |
if (!otherType.isPlainType()) { |
| 351 |
return false; |
| 352 |
} |
| 353 |
AtomicType type = (AtomicType) otherType; |
| 354 |
return subsumesUnderlyingType(type); |
| 355 |
} |
| 356 |
|
| 357 |
private boolean subsumesUnderlyingType(AtomicType type) { |
| 358 |
BuiltInAtomicType builtIn = |
| 359 |
type instanceof BuiltInAtomicType ? (BuiltInAtomicType) type : (BuiltInAtomicType) type.getBuiltInBaseType(); |
| 360 |
while (true) { |
| 361 |
if (builtIn.isSameType(underlyingType)) { |
| 362 |
return true; |
| 363 |
} |
| 364 |
SchemaType base = builtIn.getBaseType(); |
| 365 |
if (!(base instanceof BuiltInAtomicType)) { |
| 366 |
return false; |
| 367 |
} |
| 368 |
builtIn = (BuiltInAtomicType) base; |
| 369 |
} |
| 370 |
} |
| 371 |
|
| 372 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 373 |
return underlyingType; |
| 374 |
} |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
public static final ItemType STRING = atomic(BuiltInAtomicType.STRING, defaultConversionRules); |
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
public static final ItemType BOOLEAN = atomic(BuiltInAtomicType.BOOLEAN, defaultConversionRules); |
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
public static final ItemType DURATION = atomic(BuiltInAtomicType.DURATION, defaultConversionRules); |
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
public static final ItemType DATE_TIME = atomic(BuiltInAtomicType.DATE_TIME, defaultConversionRules); |
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
public static final ItemType DATE = atomic(BuiltInAtomicType.DATE, defaultConversionRules); |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
public static final ItemType TIME = atomic(BuiltInAtomicType.TIME, defaultConversionRules); |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
public static final ItemType G_YEAR_MONTH = atomic(BuiltInAtomicType.G_YEAR_MONTH, defaultConversionRules); |
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
public static final ItemType G_MONTH = atomic(BuiltInAtomicType.G_MONTH, defaultConversionRules); |
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
public static final ItemType G_MONTH_DAY = atomic(BuiltInAtomicType.G_MONTH_DAY, defaultConversionRules); |
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
public static final ItemType G_YEAR = atomic(BuiltInAtomicType.G_YEAR, defaultConversionRules); |
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
public static final ItemType G_DAY = atomic(BuiltInAtomicType.G_DAY, defaultConversionRules); |
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
public static final ItemType HEX_BINARY = atomic(BuiltInAtomicType.HEX_BINARY, defaultConversionRules); |
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
public static final ItemType BASE64_BINARY = atomic(BuiltInAtomicType.BASE64_BINARY, defaultConversionRules); |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
public static final ItemType ANY_URI = atomic(BuiltInAtomicType.ANY_URI, defaultConversionRules); |
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
public static final ItemType QNAME = atomic(BuiltInAtomicType.QNAME, defaultConversionRules); |
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
public static final ItemType NOTATION = atomic(BuiltInAtomicType.NOTATION, defaultConversionRules); |
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
public static final ItemType UNTYPED_ATOMIC = atomic(BuiltInAtomicType.UNTYPED_ATOMIC, defaultConversionRules); |
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
public static final ItemType DECIMAL = atomic(BuiltInAtomicType.DECIMAL, defaultConversionRules); |
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
public static final ItemType FLOAT = atomic(BuiltInAtomicType.FLOAT, defaultConversionRules); |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
public static final ItemType DOUBLE = atomic(BuiltInAtomicType.DOUBLE, defaultConversionRules); |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
public static final ItemType INTEGER = atomic(BuiltInAtomicType.INTEGER, defaultConversionRules); |
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
public static final ItemType NON_POSITIVE_INTEGER = atomic(BuiltInAtomicType.NON_POSITIVE_INTEGER, defaultConversionRules); |
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
public static final ItemType NEGATIVE_INTEGER = atomic(BuiltInAtomicType.NEGATIVE_INTEGER, defaultConversionRules); |
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
public static final ItemType LONG = atomic(BuiltInAtomicType.LONG, defaultConversionRules); |
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
public static final ItemType INT = atomic(BuiltInAtomicType.INT, defaultConversionRules); |
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
public static final ItemType SHORT = atomic(BuiltInAtomicType.SHORT, defaultConversionRules); |
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
public static final ItemType BYTE = atomic(BuiltInAtomicType.BYTE, defaultConversionRules); |
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
public static final ItemType NON_NEGATIVE_INTEGER = atomic(BuiltInAtomicType.NON_NEGATIVE_INTEGER, defaultConversionRules); |
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
public static final ItemType POSITIVE_INTEGER = atomic(BuiltInAtomicType.POSITIVE_INTEGER, defaultConversionRules); |
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
public static final ItemType UNSIGNED_LONG = atomic(BuiltInAtomicType.UNSIGNED_LONG, defaultConversionRules); |
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
public static final ItemType UNSIGNED_INT = atomic(BuiltInAtomicType.UNSIGNED_INT, defaultConversionRules); |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
public static final ItemType UNSIGNED_SHORT = atomic(BuiltInAtomicType.UNSIGNED_SHORT, defaultConversionRules); |
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
public static final ItemType UNSIGNED_BYTE = atomic(BuiltInAtomicType.UNSIGNED_BYTE, defaultConversionRules); |
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
public static final ItemType YEAR_MONTH_DURATION = atomic(BuiltInAtomicType.YEAR_MONTH_DURATION, defaultConversionRules); |
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
public static final ItemType DAY_TIME_DURATION = atomic(BuiltInAtomicType.DAY_TIME_DURATION, defaultConversionRules); |
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
public static final ItemType NORMALIZED_STRING = atomic(BuiltInAtomicType.NORMALIZED_STRING, defaultConversionRules); |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
public static final ItemType TOKEN = atomic(BuiltInAtomicType.TOKEN, defaultConversionRules); |
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
public static final ItemType LANGUAGE = atomic(BuiltInAtomicType.LANGUAGE, defaultConversionRules); |
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
public static final ItemType NAME = atomic(BuiltInAtomicType.NAME, defaultConversionRules); |
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
public static final ItemType NMTOKEN = atomic(BuiltInAtomicType.NMTOKEN, defaultConversionRules); |
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
public static final ItemType NCNAME = atomic(BuiltInAtomicType.NCNAME, defaultConversionRules); |
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
public static final ItemType ID = atomic(BuiltInAtomicType.ID, defaultConversionRules); |
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
public static final ItemType IDREF = atomic(BuiltInAtomicType.IDREF, defaultConversionRules); |
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
public static final ItemType ENTITY = atomic(BuiltInAtomicType.ENTITY, defaultConversionRules); |
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
public static final ItemType DATE_TIME_STAMP = atomic(BuiltInAtomicType.DATE_TIME_STAMP, defaultConversionRules); |
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
private static ItemType atomic(BuiltInAtomicType underlyingType, ConversionRules conversionRules) { |
| 657 |
return new BuiltInAtomicItemType(underlyingType, conversionRules); |
| 658 |
} |
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
public static final ItemType NUMERIC = new ItemType() { |
| 665 |
@Override |
| 666 |
public ConversionRules getConversionRules() { |
| 667 |
return defaultConversionRules; |
| 668 |
} |
| 669 |
|
| 670 |
@Override |
| 671 |
public boolean matches(XdmItem item) { |
| 672 |
return item.getUnderlyingValue() instanceof NumericValue; |
| 673 |
} |
| 674 |
|
| 675 |
@Override |
| 676 |
public boolean subsumes(ItemType other) { |
| 677 |
return DECIMAL.subsumes(other) || DOUBLE.subsumes(other) || FLOAT.subsumes(other); |
| 678 |
} |
| 679 |
|
| 680 |
@Override |
| 681 |
public net.sf.saxon.type.ItemType getUnderlyingItemType() { |
| 682 |
return NumericType.getInstance(); |
| 683 |
} |
| 684 |
}; |
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
public ConversionRules getConversionRules() { |
| 696 |
return defaultConversionRules; |
| 697 |
} |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
public abstract boolean matches(XdmItem item); |
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
public abstract boolean subsumes(ItemType other); |
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
public abstract net.sf.saxon.type.ItemType getUnderlyingItemType(); |
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
public QName getTypeName() { |
| 739 |
net.sf.saxon.type.ItemType type = getUnderlyingItemType(); |
| 740 |
if (type instanceof SchemaType) { |
| 741 |
StructuredQName name = ((SchemaType) type).getStructuredQName(); |
| 742 |
return name == null ? null : new QName(name); |
| 743 |
} else { |
| 744 |
return null; |
| 745 |
} |
| 746 |
} |
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
public final boolean equals(Object other) { |
| 757 |
return other instanceof ItemType && getUnderlyingItemType().equals(((ItemType) other).getUnderlyingItemType()); |
| 758 |
} |
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
public final int hashCode() { |
| 768 |
return getUnderlyingItemType().hashCode(); |
| 769 |
} |
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
public String toString() { |
| 782 |
net.sf.saxon.type.ItemType type = getUnderlyingItemType(); |
| 783 |
if (type instanceof SchemaType) { |
| 784 |
String marker = ""; |
| 785 |
SchemaType st = (SchemaType) type; |
| 786 |
StructuredQName name = null; |
| 787 |
while (true) { |
| 788 |
name = st.getStructuredQName(); |
| 789 |
if (name != null) { |
| 790 |
return marker + name.getEQName(); |
| 791 |
} else { |
| 792 |
marker = "<"; |
| 793 |
st = st.getBaseType(); |
| 794 |
if (st == null) { |
| 795 |
return "Q{" + NamespaceConstant.SCHEMA + "}anyType"; |
| 796 |
} |
| 797 |
} |
| 798 |
} |
| 799 |
} else { |
| 800 |
return type.toString(); |
| 801 |
} |
| 802 |
} |
| 803 |
|
| 804 |
|
| 805 |
} |
| 806 |
|