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 boolean
Ensures that the given class is non-null and notVoid.TYPE
.(package private) static String
namespace
(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 aTypeName
made of the given scope and name.(package private) final org.opengis.util.TypeName
toTypeName
(org.opengis.util.NameFactory factory, Class<?> valueClass) Infers the type name from the given class.(package private) static String
unknown
(org.opengis.util.GenericName name) Formats the error message for an unknown type.
-
Field Details
-
MAPPING
The mapping betweenTypeName
andClass
as 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.class
as 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 aTypeName
made of the given scope and name. This method is the converse oftoTypeName(NameFactory, Class)
. There is 3 kinds of return value:null
if the namespace or the name is unrecognized, without considering that as an error.Void.TYPE
ifnamespace
is recognized, but not thename
. This is a sentinel value to be considered as an error byDefaultTypeName
constructor.- 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
null
if the given namespace is not recognized, orVoid.TYPE
if the namespace is recognized but not the type name. - Throws:
ClassNotFoundException
- ifnamespace
is"class"
butname
is 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)
.
-