TypeUse from simple types.
This code consists of two main portions. The compose(XSSimpleType) method
and composer forms an outer cycle, which gradually ascends the type
inheritance chain until it finds the suitable binding. When it does this
initiatingType is set to the type which started binding, so that we can refer
to the actual constraint facets and such that are applicable on the type.
For each intermediate type in the chain, the find(XSSimpleType) method
is used to find the binding on that type, sine the outer loop is doing the ascending,
this method only sees if the current type has some binding available.
There is at least one ugly code that you need to aware of when you are modifying the code. See the documentation about "simple type customization at the point of reference."
| Modifier and Type | Field and Description |
|---|---|
| private final Set | acknowledgedXmimeContentTypes
Records what xmime:expectedContentTypes annotations we honored and processed, so that we can later check if the user had these annotations in the places where we didn't anticipate them. |
| protected final BGMBuilder | |
| public static final Map | builtinConversions
|
| private static final Set | |
| public final XSSimpleTypeFunction | |
| private XSSimpleType | initiatingType
The type that was originally passed to this |
| private static final BigInteger | |
| private static final BigInteger | |
| private static final BigInteger | |
| private static final BigInteger | |
| private final Model | |
| public final Stack | refererStack
The component that is refering to the simple type which we are building. |
| private static Set |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private TypeUse | bindToTypeSafeEnum(XSRestrictionSimpleType type, String
The class name of the type-safe enum. Or null to
create a default name. className, String Additional javadoc that will be added at the beginning of the
class, or null if none is necessary. javadoc, Map<String, BIEnumMember> A map from enumeration values (as String) to BIEnumMember objects.
if some of the value names need to be overrided.
Cannot be null, but the map may not contain entries
for all enumeration values. members, EnumMemberMode mode, Locator The source location where the above customizations are
specified, or null if none is available. loc)Builds a type-safe enum conversion from a simple type with enumeration facets. |
| public TypeUse | |
| private List | buildCEnumConstants(XSRestrictionSimpleType type, boolean needsToGenerateMemberName, Map<String, BIEnumMember> members, XSFacet[]
if constant names couldn't be generated, return a reference to that enum facet. errorRef)Returns: null if unable to generate names for some of the constants. |
| public TypeUse | buildDef(XSSimpleType type)
A version of the |
| public static boolean | canBeMappedToTypeSafeEnum(XSSimpleType type)
Returns true if the given simple type can be mapped to a type-safe enum class. |
| private CEnumConstant[] | Returns: if there's a collision, return twoCEnumConstants that collided.
otherwise return null.Returns non-null if |
| private TypeUse | checkRefererCustomization(XSSimpleType type)
Checks if the referer has a conversion customization or not. |
| pack-priv TypeUse | |
| private void | detectJavaTypeCustomization()
Detect "javaType" customizations placed directly on simple types, rather than being enclosed by "property" and "baseType" customizations (see sec 6.8.1 of the spec). |
| private TypeUse | Returns: null if not (which causes thecompose(XSSimpleType) method
to do ascending.Checks if there's any binding available on the given type. |
| private EnumMemberMode | |
| public XSComponent | |
| private BIConversion | Returns: can be null.Returns a javaType customization specified to the referer, if present. |
| public boolean | |
| private boolean | |
| private boolean | |
| private TypeUse | |
| private TypeUse | |
| private BigInteger | |
| private BigInteger | |
| private BigInteger | |
| private boolean | shouldBeMappedToTypeSafeEnumByDefault(XSRestrictionSimpleType type)
Returns true if a type-safe enum should be created from
the given simple type by default without an explicit |
| acknowledgedXmimeContentTypes | back to summary |
|---|---|
| private final Set<XSComponent> acknowledgedXmimeContentTypes Records what xmime:expectedContentTypes annotations we honored and processed, so that we can later check if the user had these annotations in the places where we didn't anticipate them. | |
| builder | back to summary |
|---|---|
| protected final BGMBuilder builder | |
| builtinConversions | back to summary |
|---|---|
| public static final Map<String, TypeUse> builtinConversions
| |
| builtinTypeSafeEnumCapableTypes | back to summary |
|---|---|
| private static final Set<String> builtinTypeSafeEnumCapableTypes | |
| composer | back to summary |
|---|---|
| public final XSSimpleTypeFunction<TypeUse> composer | |
| initiatingType | back to summary |
|---|---|
| private XSSimpleType initiatingType The type that was originally passed to this | |
| INT_MAX | back to summary |
|---|---|
| private static final BigInteger INT_MAX | |
| INT_MIN | back to summary |
|---|---|
| private static final BigInteger INT_MIN | |
| LONG_MAX | back to summary |
|---|---|
| private static final BigInteger LONG_MAX | |
| LONG_MIN | back to summary |
|---|---|
| private static final BigInteger LONG_MIN | |
| model | back to summary |
|---|---|
| private final Model model | |
| refererStack | back to summary |
|---|---|
| public final Stack<XSComponent> refererStack The component that is refering to the simple type which we are building. This is ugly but necessary to support the customization of simple types at its point of reference. See my comment at the header of this class for details. UGLY: Implemented as a Stack of XSComponent to fix a bug | |
| reportedEnumMemberSizeWarnings | back to summary |
|---|---|
| private static Set<XSRestrictionSimpleType> reportedEnumMemberSizeWarnings | |
| SimpleTypeBuilder | back to summary |
|---|---|
| public SimpleTypeBuilder() Default constructor. | |
| bindToTypeSafeEnum | back to summary |
|---|---|
| private TypeUse bindToTypeSafeEnum(XSRestrictionSimpleType type, String className, String javadoc, Map<String, BIEnumMember> members, EnumMemberMode mode, Locator loc) Builds a type-safe enum conversion from a simple type with enumeration facets.
| |
| build | back to summary |
|---|---|
| public TypeUse build(XSSimpleType type) Entry point from outside. Builds a BGM type expression from a simple type schema component.
| |
| buildCEnumConstants | back to summary |
|---|---|
private List
| |
| buildDef | back to summary |
|---|---|
| public TypeUse buildDef(XSSimpleType type) A version of the | |
| canBeMappedToTypeSafeEnum | back to summary |
|---|---|
| public static boolean canBeMappedToTypeSafeEnum(XSSimpleType type) Returns true if the given simple type can be mapped to a type-safe enum class. JAXB spec places a restrictrion as to what type can be mapped to a type-safe enum. This method enforces this constraint. | |
| checkMemberNameCollision | back to summary |
|---|---|
| private CEnumConstant[] checkMemberNameCollision(List<CEnumConstant> memberList) Returns non-null if
| |
| checkRefererCustomization | back to summary |
|---|---|
| private TypeUse checkRefererCustomization(XSSimpleType type) Checks if the referer has a conversion customization or not. If it does, use it to bind this simple type. Otherwise return null; | |
| compose | back to summary |
|---|---|
| pack-priv TypeUse compose(XSSimpleType t) Recursively decend the type inheritance chain to find a binding. | |
| detectJavaTypeCustomization | back to summary |
|---|---|
| private void detectJavaTypeCustomization() Detect "javaType" customizations placed directly on simple types, rather than being enclosed by "property" and "baseType" customizations (see sec 6.8.1 of the spec). Report an error if any exist. | |
| find | back to summary |
|---|---|
| private TypeUse find(XSSimpleType type) Checks if there's any binding available on the given type.
| |
| getEnumMemberMode | back to summary |
|---|---|
| private EnumMemberMode getEnumMemberMode() | |
| getReferer | back to summary |
|---|---|
| public XSComponent getReferer() | |
| getRefererCustomization | back to summary |
|---|---|
| private BIConversion getRefererCustomization() Returns a javaType customization specified to the referer, if present.
| |
| isAcknowledgedXmimeContentTypes | back to summary |
|---|---|
| public boolean isAcknowledgedXmimeContentTypes(XSComponent c) | |
| isRestrictedTo0And1 | back to summary |
|---|---|
| private boolean isRestrictedTo0And1() Returns true if the | |
| isXml | back to summary |
|---|---|
| private boolean isXml(String subType) Returns true if the specified sub-type is an XML type. | |
| lookupBinaryTypeBinding | back to summary |
|---|---|
| private TypeUse lookupBinaryTypeBinding() Decides the way xs:base64Binary binds. This method checks the expected media type. | |
| lookupBuiltin | back to summary |
|---|---|
| private TypeUse lookupBuiltin(String typeLocalName) | |
| max | back to summary |
|---|---|
| private BigInteger max(BigInteger a, BigInteger b) | |
| min | back to summary |
|---|---|
| private BigInteger min(BigInteger a, BigInteger b) | |
| readFacet | back to summary |
|---|---|
| private BigInteger readFacet(String facetName, int offset) | |
| shouldBeMappedToTypeSafeEnumByDefault | back to summary |
|---|---|
| private boolean shouldBeMappedToTypeSafeEnumByDefault(XSRestrictionSimpleType type) Returns true if a type-safe enum should be created from
the given simple type by default without an explicit | |