Package org.apache.sis.util.iso
Class DefaultTypeName
Object
AbstractName
DefaultLocalName
DefaultTypeName
- All Implemented Interfaces:
- Serializable,- Comparable<GenericName>,- GenericName,- LocalName,- TypeName
The name of an attribute type associated to a member name.
 
   
 The mapping defined by Apache SIS may change in any future version depending on standardization progress.
 To protect against such changes, users are encouraged to rely on methods or constructors like
 
DefaultTypeName can be instantiated by any of the following methods:
 - DefaultNameFactory.createTypeName(NameSpace, CharSequence)
- DefaultNameFactory.toTypeName(Class)
Mapping Java classes to type names
A bidirectional mapping is defined betweenTypeName and Java Class.
 When an UML identifier from an OGC standard exists for a given Class,
 Apache SIS uses that identifier prefixed by the "OGC" namespace.
 Note that this is not a standard practice.
 A more standard practice would be to use the
 data type URN standard values
 (third column in the table below), but the set of data type identifiers defined by OGC is currently
 small and is sometimes not an exact match.
 | Java class | Scoped type name | Data type URN standard values | URL in Web Services | 
|---|---|---|---|
| InternationalString | OGC:FreeText | ||
| String | OGC:CharacterString | urn:ogc:def:dataType:OGC::string | http://www.w3.org/2001/XMLSchema#string | 
| URI | OGC:URI | urn:ogc:def:dataType:OGC::anyURI | |
| Boolean | OGC:Boolean | urn:ogc:def:dataType:OGC::boolean | http://www.w3.org/2001/XMLSchema#boolean | 
| Integer | OGC:Integer | urn:ogc:def:dataType:OGC::nonNegativeInteger | http://www.w3.org/2001/XMLSchema#integer | 
| BigDecimal | OGC:Decimal | http://www.w3.org/2001/XMLSchema#decimal | |
| Double | OGC:Real | http://www.w3.org/2001/XMLSchema#double | |
| Float | OGC:Real | http://www.w3.org/2001/XMLSchema#float | |
| Date | OGC:DateTime | ||
| Locale | OGC:PT_Locale | ||
| Metadata | OGC:MD_Metadata | ||
| Unknown Java class | class:<the class name> | 
toJavaType() or DefaultNameFactory.toTypeName(Class) instead of parsing the name.
 Immutability and thread safety
This class is immutable and thus inherently thread-safe if theNameSpace and CharSequence
 arguments given to the constructor are also immutable. Subclasses shall make sure that any overridden methods
 remain safe to call from multiple threads and do not change any public TypeName state.- Since:
- 0.3
- See Also:
Defined in the sis-metadata module
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedDefaultTypeName(NameSpace scope, CharSequence name) Constructs a type name from the given character sequence and infers automatically a Java type.protectedDefaultTypeName(NameSpace scope, CharSequence name, Type javaType) Constructs a type name from the given character sequence and explicit Java type.
- 
Method SummaryModifier and TypeMethodDescriptionstatic DefaultTypeNamecastOrCopy(TypeName object) Returns a SIS type name implementation with the values of the given arbitrary implementation.booleanCompares this type name with the specified object for equality.Class<?>toClass()Deprecated.Returns the Java type represented by this name.Methods inherited from class DefaultLocalNamecastOrCopy, compareTo, depth, getParsedNames, head, scope, tip, toInternationalString, toStringMethods inherited from class AbstractNamecastOrCopy, hashCode, push, toFullyQualifiedNameMethods inherited from class Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ComparablecompareToMethods inherited from interface GenericNamepush, scope, toFullyQualifiedName, toInternationalString
- 
Constructor Details- 
DefaultTypeNameConstructs a type name from the given character sequence and infers automatically a Java type. The scope and name arguments are given unchanged to the super-class constructor. Then the Java type is inferred in a way that depends on the specified scope:- If the scope is "OGC", then:- If the name is "CharacterString","Integer","Real"or other recognized names (see class javadoc), then the corresponding Java class is associated to this type name.
- Otherwise UnknownNameExceptionis thrown.
 
- If the name is 
- Else if the scope is "class", then:- If the name is accepted by Class.forName(String), then that Java class is associated to this type name.
- Otherwise UnknownNameExceptionis thrown.
 
- If the name is accepted by 
- Else if the scope is global, then:
     - If the name is one of the names recognized in "OGC"scope (see above), then the corresponding class is associated to this type name.
- Otherwise no Java class is associated to this type name. No exception is thrown because names in the global namespace could be anything; this constructor cannot know if the given name was wrong.
 
- If the name is one of the names recognized in 
- Otherwise no Java class is associated to this type name, because this method cannot check the validity of names in other namespaces.
 - Parameters:
- scope- the scope of this name, or- nullfor a global scope.
- name- the local name (never- null).
- Throws:
- UnknownNameException- if a mapping from this name to a Java class was expected to exist (because the specified scope is "OGC" or "class") but the associated Java class cannot be found.
- See Also:
 
- If the scope is 
- 
DefaultTypeNameConstructs a type name from the given character sequence and explicit Java type. The scope and name arguments are given unchanged to the super-class constructor.- Parameters:
- scope- the scope of this name, or- nullfor a global scope.
- name- the local name (never- null).
- javaType- the value type to be returned by- toJavaType(), or- nullif none.
- Since:
- 1.3
- See Also:
 
 
- 
- 
Method Details- 
castOrCopyReturns a SIS type name implementation with the values of the given arbitrary implementation. This method performs the first applicable action in the following choices:- If the given object is null, then this method returnsnull.
- Otherwise if the given object is already an instance of DefaultTypeName, then it is returned unchanged.
- Otherwise a new DefaultTypeNameinstance is created with the same values than the given name.
 - Parameters:
- object- the object to get as a SIS implementation, or- nullif none.
- Returns:
- a SIS implementation containing the values of the given object (may be the
         given object itself), or nullif the argument was null.
- Since:
- 0.5
 
- If the given object is 
- 
toJavaTypeReturns the Java type represented by this name. This is the type either specified explicitly at construction time or inferred from the type name.- Returns:
- the Java type (usually a Class) for this type name.
- Since:
- 1.3
- See Also:
 
- 
toClassDeprecated.Replaced bytoJavaType().Returns the Java class associated to this type name.- Returns:
- the Java class associated to this TypeName, ornullif there is no mapping from this name to a Java class.
- Since:
- 0.5
 
- 
equalsCompares this type name with the specified object for equality.- Overrides:
- equalsin class- DefaultLocalName
- Parameters:
- object- the object to compare with this type for equality.
- Returns:
- trueif the given object is equal to this name.
 
 
- 
toJavaType().