public class Types extends Object
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
Constructor and Description |
---|
Types() |
Modifier and Type | Method and Description |
---|---|
static void |
assertNameAssignable(FeatureType expected,
FeatureType actual)
FeatureType comparison indicating if the description provided by two FeatureTypes is similar
to the point data can be exchanged.
|
static void |
assertOrderAssignable(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 Name |
degloseName(String prefixedName,
NamespaceSupport namespaces)
Takes a prefixed attribute name and returns an
Name by looking which namespace
belongs the prefix to in AppSchemaDataAccessDTO#getNamespaces() . |
static PropertyDescriptor |
descriptor(ComplexType type,
Name name)
Returns the first descriptor matching the given name within the given type.
|
static PropertyDescriptor |
descriptor(ComplexType type,
String name)
Returns the first descriptor matching the given local name within the given type.
|
static PropertyDescriptor |
descriptor(ComplexType type,
String name,
String namespace)
Returns the first descriptor matching the given name + namespace 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 |
descriptors(ComplexType type,
Name name)
Returns the set of descriptors matching the given name.
|
static List |
descriptors(ComplexType type,
String name)
Returns the set of descriptors matching the given local name within the given type.
|
static boolean |
equals(Name name,
QName qName) |
static PropertyDescriptor |
findDescriptor(ComplexType parentType,
Name name)
Find a descriptor, taking in to account supertypes AND substitution groups
|
static PropertyDescriptor |
findDescriptor(ComplexType parentType,
String name)
Find a descriptor, taking in to account supertypes AND substitution groups
|
static String[] |
fromNames(Name[] attributeNames)
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 boolean |
isSuperType(PropertyType type,
PropertyType parent)
Determines if
parent is a super type of type |
static boolean |
isValid(Attribute attribute)
Ensures 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 Object |
parse(AttributeDescriptor descriptor,
Object value)
Do our best to make the provided value line up with the needs of descriptor.
|
static Object |
parse(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 |
toName(QName name)
Deprecated.
use
#toTypeName(QName |
static Name[] |
toNames(String[] names)
Creates a set of attribute names from a set of strings.
|
static String |
toPrefixedName(Name name,
NamespaceSupport ns)
Converts a
Name to a prefixed name (i.e. p:Foo), by looking up the right prefix in
the provided NamespaceSupport . |
static QName |
toQName(Name featurePath) |
static QName |
toQName(Name featurePath,
NamespaceSupport ns) |
static Name |
toTypeName(QName name) |
static Name[] |
toTypeNames(String[] names)
Creates a set of type names from a set of strings.
|
static Name |
typeName(Name name)
Creates a type name from another name.
|
static Name |
typeName(String name)
Creates a type name from a single non-qualified string.
|
static Name |
typeName(String namespace,
String name)
Creates an attribute name from a single non-qualified string.
|
static void |
validate(Attribute attribute)
Validates anattribute.
|
static void |
validate(AttributeDescriptor descriptor,
Object value)
Ensure that attributeContent is a good value for descriptor.
|
static void |
validate(Attribute attribute,
Object attributeContent)
Validates content against an attribute.
|
static void |
validate(AttributeType type,
Attribute attribute,
Object attributeContent) |
protected static void |
validate(AttributeType type,
Attribute attribute,
Object attributeContent,
boolean isSuper) |
protected static void |
validate(AttributeType type,
Object value,
boolean isSuper) |
static void |
validate(ComplexAttribute attribute) |
static void |
validate(ComplexAttribute attribute,
Collection content) |
protected static void |
validate(ComplexType type,
ComplexAttribute attribute,
Collection content) |
public static boolean isValid(Attribute attribute)
attribute
- public static void validate(Attribute attribute, Object attributeContent) throws IllegalAttributeException
attribute
- The attribute.attributeContent
- Content of attribute (often attribute.getValue()IllegalAttributeException
- In the event that content violates any restrictions
specified by the attribute.public static void validate(AttributeType type, Attribute attribute, Object attributeContent) throws IllegalAttributeException
type
- AttributeType (often attribute.getType() )attribute
- Attribute being testedattributeContent
- Content of the attribute (often attribute.getValue() )IllegalAttributeException
protected static void validate(AttributeType type, Attribute attribute, Object attributeContent, boolean isSuper) throws IllegalAttributeException
type
- AttributeType (often attribute.getType() )attribute
- Attribute being testedattributeContent
- Content of the attribute (often attribute.getValue() )isSuper
- True if super type is being checkedIllegalAttributeException
public static void validate(AttributeDescriptor descriptor, Object value) throws IllegalAttributeException
IllegalAttributeException
public static Object parse(AttributeDescriptor descriptor, Object value) throws IllegalArgumentException
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.
descriptor
- Attribute descriptor we need to supply a value for.value
- The provided valueIllegalArgumentException
- if we really could not do it.protected static void validate(AttributeType type, Object value, boolean isSuper) throws IllegalAttributeException
IllegalAttributeException
public static void assertNameAssignable(FeatureType expected, FeatureType actual)
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:
for( Property property : feature.getProperties() ){
Object value = property.getValue();
Property target = newFeature.getProperty( property.getName().getLocalPart() );
target.setValue( value );
}
Specifically this says that between the two feature types data is assignable on a name by
name basis.expected
- Expected FeatureType being used to compare againstactual
- Actual FeatureTypepublic static void assertOrderAssignable(SimpleFeatureType expected, SimpleFeatureType actual)
After assertOrderCovered returns without error the following code will work:
List
expected
- actual
- public static Name[] names(ComplexType type)
type
- The type.public static Name typeName(String name)
name
- The name, may be nullpublic static Name typeName(String namespace, String name)
name
- The name, may be nullnamespace
- The scope or namespace, may be null.public static Name typeName(Name name)
name
- The other name.public static Name[] toNames(String[] names)
This method returns null if names == null.
The ith name has getLocalPart() == names[i] and getNamespaceURI() == null
public static Name[] toTypeNames(String[] names)
This method returns null if names == null.
The ith name has getLocalPart() == names[i] and getNamespaceURI() == null
public static String[] fromNames(Name[] attributeNames)
public static String[] fromTypeNames(Name[] typeNames)
public static Name degloseName(String prefixedName, NamespaceSupport namespaces) throws IllegalArgumentException
Name
by looking which namespace
belongs the prefix to in AppSchemaDataAccessDTO#getNamespaces()
.prefixedName
- , namespacesIllegalArgumentException
- if prefixedName
has no declared namespace in
app-schema config file.public static QName toQName(Name featurePath, NamespaceSupport ns)
public static String toPrefixedName(Name name, NamespaceSupport ns)
Name
to a prefixed name (i.e. p:Foo), by looking up the right prefix in
the provided NamespaceSupport
. If no prefix is found, the return value will be the
same as that of Name.getLocalPart()
.name
- the name to translate in prefixed formns
- namespace context, relates namespaces to prefixespublic static Name toName(QName name)
#toTypeName(QName
name
- public static Object parse(AttributeType type, Object content) throws IllegalArgumentException
value
- the object to attempt parsing of.IllegalArgumentException
- if parsing is attempted and is unsuccessful.public static void validate(Attribute attribute) throws IllegalAttributeException
Same result as calling:
<code> validate(attribute.type(), attribute) </code>
attribute
- The attribute.IllegalAttributeException
- In the event that content violates any restrictions
specified by the attribute.public static void validate(ComplexAttribute attribute) throws IllegalArgumentException
IllegalArgumentException
public static void validate(ComplexAttribute attribute, Collection content) throws IllegalArgumentException
IllegalArgumentException
protected static void validate(ComplexType type, ComplexAttribute attribute, Collection content) throws IllegalAttributeException
IllegalAttributeException
public static boolean isSuperType(PropertyType type, PropertyType parent)
parent
is a super type of type
type
- The type in question.parent
- The possible parent type.public static PropertyDescriptor descriptor(ComplexType type, String name)
type
- The type, non null.name
- The name, non null.public static PropertyDescriptor descriptor(ComplexType type, String name, String namespace)
type
- The type, non null.name
- The name, non null.namespace
- The namespace, non null.public static PropertyDescriptor descriptor(ComplexType type, Name name)
type
- The type, non null.name
- The name, non null.public static List descriptors(ComplexType type, String name)
type
- The type, non null.name
- The name, non null.public static List descriptors(ComplexType type, Name name)
type
- The type, non null.name
- The name, non null.public static List<PropertyDescriptor> descriptors(ComplexType type)
type
- The type, non null.public static PropertyDescriptor findDescriptor(ComplexType parentType, Name name)
parentType
- typename
- name of descriptorpublic static PropertyDescriptor findDescriptor(ComplexType parentType, String name)
parentType
- typename
- name of descriptorCopyright © 1996–2019 Geotools. All rights reserved.