Package org.apache.sis.util.iso
Class TypeNames
java.lang.Object
org.apache.sis.util.iso.TypeNames
- Since:
- 0.5
- Version:
- 1.3
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTypeNames(org.opengis.util.NameFactory factory) Creates a new factory of type names. -
Method Summary
Modifier and TypeMethodDescription(package private) static booleanEnsures that the given class is non-null and notVoid.TYPE.(package private) static Stringnamespace(org.opengis.util.NameSpace ns) Null-safe getter for the namespace argument to be given totoClass(String, String).(package private) static Class<?>Returns the class for aTypeNamemade of the given scope and name.(package private) final org.opengis.util.TypeNametoTypeName(org.opengis.util.NameFactory factory, Class<?> valueClass) Infers the type name from the given class.(package private) static Stringunknown(org.opengis.util.GenericName name) Formats the error message for an unknown type.
-
Field Details
-
MAPPING
The mapping betweenTypeNameandClassas documented inDefaultTypeName. When searching for a name from a class, the values will be tested in iteration order.toTypeName(NameFactory, Class)will not iterate over all entries. Numbers and character strings are handled in a special way, so we do not need to iterate on them. We arbitrarily useBoolean.classas the sentinel value for detecting when to stop iteration.This map shall not be modified after construction.
-
ogcNS
private final org.opengis.util.NameSpace ogcNSThe "OGC" namespace. -
classNS
private final org.opengis.util.NameSpace classNSThe "class" namespace.
-
-
Constructor Details
-
TypeNames
TypeNames(org.opengis.util.NameFactory factory) Creates a new factory of type names.
-
-
Method Details
-
toTypeName
final org.opengis.util.TypeName toTypeName(org.opengis.util.NameFactory factory, Class<?> valueClass) Infers the type name from the given class.- Parameters:
factory- the same factory than the one given to the constructor.valueClass- the value class for which to get a type name.- Returns:
- a type name for the given class (never
null).
-
toClass
Returns the class for aTypeNamemade of the given scope and name. This method is the converse oftoTypeName(NameFactory, Class). There is 3 kinds of return value:nullif the namespace or the name is unrecognized, without considering that as an error.Void.TYPEifnamespaceis recognized, but not thename. This is a sentinel value to be considered as an error byDefaultTypeNameconstructor.- Otherwise the class for the given name.
- Parameters:
namespace- the namespace, case-insensitive. Can be any value, but this method recognizes only"OGC","class"andnull. Other namespaces will be ignored.name- the type name, case-sensitive.- Returns:
- the class, or
nullif the given namespace is not recognized, orVoid.TYPEif the namespace is recognized but not the type name. - Throws:
ClassNotFoundException- ifnamespaceis"class"butnameis not the name of a reachable class.
-
isValid
Ensures that the given class is non-null and notVoid.TYPE. This is a helper method for callers oftoTypeName(NameFactory, Class). -
namespace
Null-safe getter for the namespace argument to be given totoClass(String, String). -
unknown
Formats the error message for an unknown type. This is a helper method for callers oftoClass(String, String).
-