public interface PropertyType
A property type defines information about the value of a property. This includes:
getBinding()
method returns the java class of which the value of the property is an
instance of.
Property property = ...; property.getType().getBinding().isAssignableFrom(property.getValue().getClass());
getRestrictions()
method returns a set of Filter
objects which define
additional restrictions on the value of the property.
Property property = ...; for ( Filter restriction : property.getType().getRestrictions() ) { restriction.evaluate( property ) == true; }
< simpleType name="number"/> < simpleType name="integer"/> < complexType name="myComplexType"/> <element name="foo" type="integer"/> </complexType>
ComplexAttribute complexAttribute = ...; ComplexType complexType = complexAttribute.getType(); complexType.getName().getLocalPart() == "myComplexType"; //the property descriptor PropertyDescriptor propertyDescriptor = complexType.getProperty( "foo" ); propertyDescriptor.getName().getLocalPart() == "foo"; //the property type PropertyType propertyType = propertyDescriptor.getType(); propertyType.getName().getLocalPart() == "integer"; propertyType.getBinding() == Integer.class; propertyType.getSuper().getName().getLocalPart() == "number"; propertyType.getSuper().getBinding() == Number.class; //the property Property property = complexAttribute.getProperty( "foo" ); property.getDescriptor() == propertyDescriptor; property.getType() == propertyType; property.getName().getLocalPart() == "foo"; property.getValue() instanceof Integer;
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other)
Equality based on property
getName() . |
Class<?> |
getBinding()
The java class that values of properties of the property type are bound to.
|
InternationalString |
getDescription()
Human readable description of this property type.
|
Name |
getName()
The name of the property type.
|
List<Filter> |
getRestrictions()
List of restrictions used define valid values for properties of this property type.
|
PropertyType |
getSuper()
The parent type of the property type.
|
Map<Object,Object> |
getUserData()
A map of "user data" which enables applications to store "application-specific" information
against a property type.
|
int |
hashCode()
Hashcode override based on
getName() . |
boolean |
isAbstract()
Flag indicating if the type is abstract or not.
|
Name getName()
Note that this is not the same name as Property.getName()
, which is the name of
the instance of the type, not the type itself.
The returned name is a qualified name made up of two parts. The first a namespace uri
(Name.getNamespaceURI()
, and the second a local part (Name.getLocalPart()
.
This value is never null
.
Class<?> getBinding()
This value is never null
.
PropertyType getSuper()
This method returns null
if no super type is defined.
The super type may contain additional restrictions to be considered against properties of the the property type.
null
.boolean isAbstract()
true
if the type is abstract, otherwise false
.List<Filter> getRestrictions()
Each restriction is a Filter
object in which the property is passed through. If
Filter.evaluate(Object)
returns true
the restriction is met. If
false
is returned then the restriction has not been met and the property should be
considered invalid. Remember to check getSuper().getRestrictions() as well.
This method returns an empty set in the case of no restrictions and should not return
null
.
InternationalString getDescription()
Map<Object,Object> getUserData()
As an example, consider an application that builds a PropertyType from an xml schema. A useful bit of information to attach to the PropertyType is the original schema itself, in whatever construct it might be stored in:
XSDComplexTypeDefinition complexTypeDef = ...;
PropertyType type = buildPropertyType( complexTypeDef );
type.getUserData().put( XSDComplexTypeDefintion.class, complexTypeDef );
Copyright © 1996–2019 Geotools. All rights reserved.