| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.type; |
| 9 | |
| 10 | import net.sf.saxon.om.Item; |
| 11 | import net.sf.saxon.om.StructuredQName; |
| 12 | |
| 13 | /** |
| 14 | * A "plain type" is either an atomic type, or a union type that (a) imposes no restrictions other |
| 15 | * than those imposed by its member types, and (b) has exclusively plain types as its member types |
| 16 | */ |
| 17 | |
| 18 | public interface PlainType extends ItemType { |
| 19 | |
| 20 | /** |
| 21 | * Get the name of this type as a structured QName |
| 22 | * @return the name of this type. If the type is anonymous, an internally-generated type name is returned |
| 23 | */ |
| 24 | |
| 25 | StructuredQName getTypeName(); |
| 26 | |
| 27 | /** |
| 28 | * Ask whether this is an external type, that is, the type of a Java or .NET external object |
| 29 | * @return true if this is an external type |
| 30 | */ |
| 31 | |
| 32 | boolean isExternalType(); |
| 33 | |
| 34 | /** |
| 35 | * Get the list of plain types that are subsumed by this type |
| 36 | * |
| 37 | * @return for an atomic type, the type itself; for a plain union type, the list of plain types |
| 38 | * in its transitive membership |
| 39 | */ |
| 40 | |
| 41 | Iterable<? extends PlainType> getPlainMemberTypes() throws MissingComponentException; |
| 42 | |
| 43 | /** |
| 44 | * Test whether a given item conforms to this type |
| 45 | * |
| 46 | * @param item The item to be tested |
| 47 | * @param th The type hierarchy cache. Currently used only when matching function items. |
| 48 | * @return true if the item is an instance of this type; false otherwise |
| 49 | */ |
| 50 | |
| 51 | boolean matches(Item item, TypeHierarchy th); |
| 52 | |
| 53 | /** |
| 54 | * Redeclare getPrimitiveItemType() to return a more specific result type |
| 55 | * Get the primitive item type corresponding to this item type. |
| 56 | * For anyAtomicValue and union types it is Type.ATOMIC_VALUE. For numeric it is Type.NUMBER. |
| 57 | * For other atomic types it is the primitive type as defined in XML Schema, |
| 58 | * except that integer, xs:dayTimeDuration, and xs:yearMonthDuration |
| 59 | * are considered to be primitive types. |
| 60 | * |
| 61 | * @return the corresponding primitive type (this is an instance of BuiltInAtomicType in all cases |
| 62 | * except where this type is xs:error. The class ErrorType does not inherit from BuiltInAtomicType |
| 63 | * because of multiple inheritance problems). |
| 64 | */ |
| 65 | AtomicType getPrimitiveItemType(); |
| 66 | } |
| 67 |