Class Types
- Direct Known Subclasses:
- Types
This set of classes captures the all important how does it work questions, particularly with respect to super types. FIXME: These methods need a Q&A check to confirm correct use of Super TODO: Cannot tell the difference in intent from FeatureTypes
- Author:
- Jody Garnett, LISAsoft, Justin Deoliveira, The Open Planning Project
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringKey for AppSchema declared namespaces on FeatureType user data Map.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidassertNameAssignable(FeatureType expected, FeatureType actual) FeatureType comparison indicating if the description provided by two FeatureTypes is similar to the point data can be exchanged.static voidassertOrderAssignable(SimpleFeatureType expected, SimpleFeatureType actual) SimpleFeatureType comparison indicating that data from one FeatureType can be exchanged with another - specifically ensuring that the order / value is a reasonable match with the expected number of attributes on each side and the values correctly assignable.static NamedegloseName(String prefixedName, NamespaceSupport namespaces) Takes a prefixed attribute name and returns anNameby looking which namespace belongs the prefix to inAppSchemaDataAccessDTO#getNamespaces().static PropertyDescriptordescriptor(ComplexType type, String name) Returns the first descriptor matching the given local name within the given type.static PropertyDescriptordescriptor(ComplexType type, String name, String namespace) Returns the first descriptor matching the given name + namespace within the given type.static PropertyDescriptordescriptor(ComplexType type, Name name) Returns the first descriptor matching the given name within the given type.static List<PropertyDescriptor>descriptors(ComplexType type) Returns the set of all descriptors of a complex type, including from supertypes.static List<PropertyDescriptor>descriptors(ComplexType type, String name) Returns the set of descriptors matching the given local name within the given type.static List<PropertyDescriptor>descriptors(ComplexType type, Name name) Returns the set of descriptors matching the given name.static booleanstatic PropertyDescriptorfindDescriptor(ComplexType parentType, String name) Find a descriptor, taking in to account supertypes AND substitution groupsstatic PropertyDescriptorfindDescriptor(ComplexType parentType, Name name) Find a descriptor, taking in to account supertypes AND substitution groupsstatic String[]Convenience method for turning an array of qualified names into a list of non qualified names.static String[]fromTypeNames(Name... typeNames) Convenience method for turning an array of qualified names into a list of non qualified names.static booleanisSuperType(PropertyType type, PropertyType parent) Determines ifparentis a super type oftypestatic booleanEnsures an attribute value is withing the restrictions of the AttributeDescriptor and AttributeType.static Name[]names(ComplexType type) Returns The name of attributes defined in the type.static Objectparse(AttributeDescriptor descriptor, Object value) Do our best to make the provided value line up with the needs of descriptor.static Objectparse(AttributeType type, Object content) Converts content into a format which is used to store it internally within an attribute of a specific type.static Name[]Creates a set of attribute names from a set of strings.static StringtoPrefixedName(Name name, NamespaceSupport ns) Converts aNameto a prefixed name (i.e. p:Foo), by looking up the right prefix in the providedNamespaceSupport.static QNamestatic QNametoQName(Name featurePath, NamespaceSupport ns) static NametoTypeName(QName name) static Name[]toTypeNames(String... names) Creates a set of type names from a set of strings.static NameCreates a type name from a single non-qualified string.static NameCreates an attribute name from a single non-qualified string.static NameCreates a type name from another name.static voidValidates attribute.static voidValidates content against an attribute.static voidvalidate(ComplexAttribute attribute) Validate complex attribute, including all properties.static voidvalidate(ComplexAttribute attribute, Collection<Attribute> content) Validate content using complex attribute restrictions.static voidvalidate(AttributeDescriptor descriptor, Object value) Ensure that attributeContent is a good value for descriptor.protected static voidvalidate(AttributeType type, Object value, boolean isSuper) static voidvalidate(AttributeType type, Attribute attribute, Object attributeContent) Validates content against attribute (using the supplied attribute type).protected static voidvalidate(AttributeType type, Attribute attribute, Object attributeContent, boolean isSuper) Validates content against attribute (using the supplied attribute type).protected static voidvalidate(ComplexType type, ComplexAttribute attribute, Collection<Attribute> content) Validate content using complex attribute and type restrictions.
- 
Field Details- 
DECLARED_NAMESPACES_MAPKey for AppSchema declared namespaces on FeatureType user data Map. Value is aMap<String, String>- See Also:
 
 
- 
- 
Constructor Details- 
Typespublic Types()
 
- 
- 
Method Details- 
isValidEnsures an attribute value is withing the restrictions of the AttributeDescriptor and AttributeType.- Returns:
- true if the attribute value is valid.
 
- 
validatepublic static void validate(Attribute attribute, Object attributeContent) throws IllegalAttributeException Validates content against an attribute.Same result as calling: validate(attribute.getType(), attribute, attributeContent)- Parameters:
- attribute- The attribute.
- attributeContent- Content of attribute (often attribute.getValue()
- Throws:
- IllegalAttributeException- In the event that content violates any restrictions specified by the attribute.
 
- 
validatepublic static void validate(AttributeType type, Attribute attribute, Object attributeContent) throws IllegalAttributeException Validates content against attribute (using the supplied attribute type).- Parameters:
- type- AttributeType (often attribute.getType() )
- attribute- Attribute being tested
- attributeContent- Content of the attribute (often attribute.getValue() )
- Throws:
- IllegalAttributeException
 
- 
validateprotected static void validate(AttributeType type, Attribute attribute, Object attributeContent, boolean isSuper) throws IllegalAttributeException Validates content against attribute (using the supplied attribute type).- Parameters:
- type- AttributeType (often attribute.getType() )
- attribute- Attribute being tested
- attributeContent- Content of the attribute (often attribute.getValue() )
- isSuper- True if super type is being checked
- Throws:
- IllegalAttributeException
 
- 
validatepublic static void validate(AttributeDescriptor descriptor, Object value) throws IllegalAttributeException Ensure that attributeContent is a good value for descriptor.- Throws:
- IllegalAttributeException
 
- 
parsepublic static Object parse(AttributeDescriptor descriptor, Object value) throws IllegalArgumentException Do our best to make the provided value line up with the needs of descriptor.This helper method uses the Coverters api to convert the provided value into the required class. If the value is null (and the attribute is not nillable) a default value will be returned. - Parameters:
- descriptor- Attribute descriptor we need to supply a value for.
- value- The provided value
- Returns:
- Our best attempt to make a valid value
- Throws:
- IllegalArgumentException- if we really could not do it.
 
- 
validateprotected static void validate(AttributeType type, Object value, boolean isSuper) throws IllegalAttributeException - Throws:
- IllegalAttributeException
 
- 
assertNameAssignableFeatureType comparison indicating if the description provided by two FeatureTypes is similar to the point data can be exchanged. This comparison is really very focused on the name / value contract and is willing to overlook details like length restrictions.When creating compatible FeatureTypes you will find some systems have different abilities which is reflected in how well they support a given FeatureType. As an example databases traditionally support variable length strings with a limit of 32 k; while a shapefile is limited to 256 characters. When working with data from both these data sources you will need to make adjustments based on these abilities. If true is returned data conforming to the expected FeatureType can be used with the actual FeatureType. After assertOrderCovered returns without error the following code will work: 
 Specifically this says that between the two feature types data is assignable on a name by name basis.for( Property property : feature.getProperties() ){ Object value = property.getValue(); Property target = newFeature.getProperty( property.getName().getLocalPart() ); target.setValue( value ); }- Parameters:
- expected- Expected FeatureType being used to compare against
- actual- Actual FeatureType
 
- 
assertOrderAssignableSimpleFeatureType comparison indicating that data from one FeatureType can be exchanged with another - specifically ensuring that the order / value is a reasonable match with the expected number of attributes on each side and the values correctly assignable.After assertOrderCovered returns without error the following code will work: List
- 
namesReturns The name of attributes defined in the type.- Parameters:
- type- The type.
 
- 
typeNameCreates a type name from a single non-qualified string.- Parameters:
- name- The name, may be null
- Returns:
- The name in which getLocalPart() == name and getNamespaceURI() == null. Or null if name == null.
 
- 
typeNameCreates an attribute name from a single non-qualified string.- Parameters:
- name- The name, may be null
- namespace- The scope or namespace, may be null.
- Returns:
- The name in which getLocalPart() == name and getNamespaceURI() == namespace.
 
- 
typeNameCreates a type name from another name.- Parameters:
- name- The other name.
 
- 
toNamesCreates a set of attribute names from a set of strings.This method returns null if names == null. The ith name has getLocalPart() == names[i] and getNamespaceURI() == null 
- 
toTypeNamesCreates a set of type names from a set of strings.This method returns null if names == null. The ith name has getLocalPart() == names[i] and getNamespaceURI() == null 
- 
fromNamesConvenience method for turning an array of qualified names into a list of non qualified names.
- 
fromTypeNamesConvenience method for turning an array of qualified names into a list of non qualified names.
- 
toTypeName
- 
equals
- 
degloseNamepublic static Name degloseName(String prefixedName, NamespaceSupport namespaces) throws IllegalArgumentException Takes a prefixed attribute name and returns anNameby looking which namespace belongs the prefix to inAppSchemaDataAccessDTO#getNamespaces().- Parameters:
- prefixedName- , namespaces
- Throws:
- IllegalArgumentException- if- prefixedNamehas no declared namespace in app-schema config file.
 
- 
toQName
- 
toQName
- 
toPrefixedNameConverts aNameto a prefixed name (i.e. p:Foo), by looking up the right prefix in the providedNamespaceSupport. If no prefix is found, the return value will be the same as that ofName.getLocalPart().- Parameters:
- name- the name to translate in prefixed form
- ns- namespace context, relates namespaces to prefixes
 
- 
parseConverts content into a format which is used to store it internally within an attribute of a specific type.- Parameters:
- content- the object to attempt parsing of.
- Throws:
- IllegalArgumentException- if parsing is attempted and is unsuccessful.
 
- 
validateValidates attribute.
 Same result as calling: validate(attribute, attribute.getValue())- Parameters:
- attribute- The attribute.
- Throws:
- IllegalAttributeException- In the event that content violates any restrictions specified by the attribute.
 
- 
validateValidate complex attribute, including all properties.Same result as calling: validate(attribute,attribute.getProperties())- Parameters:
- attribute-
- Throws:
- IllegalArgumentException
 
- 
validatepublic static void validate(ComplexAttribute attribute, Collection<Attribute> content) throws IllegalArgumentException Validate content using complex attribute restrictions.Same result as calling: validate(attribute.type(), attribute)- Parameters:
- attribute-
- Throws:
- IllegalArgumentException
 
- 
validateprotected static void validate(ComplexType type, ComplexAttribute attribute, Collection<Attribute> content) throws IllegalAttributeException Validate content using complex attribute and type restrictions.- Parameters:
- type-
- attribute-
- content-
- Throws:
- IllegalAttributeException
 
- 
isSuperTypeDetermines ifparentis a super type oftype- Parameters:
- type- The type in question.
- parent- The possible parent type.
 
- 
descriptorReturns the first descriptor matching the given local name within the given type.- Parameters:
- type- The type, non null.
- name- The name, non null.
- Returns:
- The first descriptor, or null if no match.
 
- 
descriptorReturns the first descriptor matching the given name + namespace within the given type.- Parameters:
- type- The type, non null.
- name- The name, non null.
- namespace- The namespace, non null.
- Returns:
- The first descriptor, or null if no match.
 
- 
descriptorReturns the first descriptor matching the given name within the given type.- Parameters:
- type- The type, non null.
- name- The name, non null.
- Returns:
- The first descriptor, or null if no match.
 
- 
descriptorsReturns the set of descriptors matching the given local name within the given type.- Parameters:
- type- The type, non null.
- name- The name, non null.
- Returns:
- The list of descriptors named 'name', or an empty list if none such match.
 
- 
descriptorsReturns the set of descriptors matching the given name.- Parameters:
- type- The type, non null.
- name- The name, non null.
- Returns:
- The list of descriptors named 'name', or an empty list if none such match.
 
- 
descriptorsReturns the set of all descriptors of a complex type, including from supertypes.- Parameters:
- type- The type, non null.
- Returns:
- The list of all descriptors.
 
- 
findDescriptorFind a descriptor, taking in to account supertypes AND substitution groups- Parameters:
- parentType- type
- name- name of descriptor
- Returns:
- descriptor, null if not found
 
- 
findDescriptorFind a descriptor, taking in to account supertypes AND substitution groups- Parameters:
- parentType- type
- name- name of descriptor
- Returns:
- descriptor, null if not found
 
 
-