public final class Names extends Static
DefaultNameFactory,
but makes some tasks easier by avoiding the need to find a factory, and by creating name and
their namespace in a single step.
QName class and in the Java Content Repository (JCR) specification,
a name is an ordered pair of (namespace, localPart) strings. A JCR name can take two lexical forms:
expanded form and qualified form. Those names are mapped to generic names as below:
Equivalence between JCR name and GenericNameJCR name GeoAPI equivalence ExpandedName ::= '{' Namespace '}' LocalPartGenericName.scope().name().toString()= JCR NamespaceGenericName.toString()= JCR LocalPartQualifiedName ::= [Prefix ':'] LocalPartScopedName.scope()= global namespace ScopedName.head().toString()= JCR PrefixScopedName.tail().toString()= JCR LocalPart
DefaultNameFactory,
DefaultNameSpace,
DefaultScopedName,
DefaultLocalName,
DefaultTypeName,
DefaultMemberNameDefined in the sis-utility module
| Modifier and Type | Method and Description |
|---|---|
static LocalName |
createLocalName(CharSequence namespace,
String separator,
CharSequence localPart)
Creates a name which is local in the given namespace.
|
static MemberName |
createMemberName(CharSequence namespace,
String separator,
CharSequence localPart,
Class<?> valueClass)
Creates a member name for values of the given class.
|
static ScopedName |
createScopedName(GenericName scope,
String separator,
CharSequence name)
Constructs a scoped name as the concatenation of the given generic name with a single character sequence.
|
static TypeName |
createTypeName(CharSequence namespace,
String separator,
CharSequence localPart)
Creates a type name which is local in the given namespace.
|
static GenericName |
parseGenericName(CharSequence namespace,
String separator,
CharSequence scopedName)
Creates a local or scoped name in the given namespace.
|
static Class<?> |
toClass(TypeName type)
Returns the Java class associated to the given type name.
|
static String |
toExpandedString(GenericName name)
Formats the given name in expanded form close to the Java Content Repository (JCR) definition.
|
public static GenericName parseGenericName(CharSequence namespace, String separator, CharSequence scopedName)
String or InternationalString instances.
The namespace character sequences is taken verbatim, while scopedName is splitted
around the default separator, which is ":".namespace - the namespace, or null for the global namespace.separator - the separator between the namespace and the scoped name, or null
for the default separator.scopedName - the name to parse using ':' as the separator between components.DefaultNameFactory.parseGenericName(NameSpace, CharSequence)public static ScopedName createScopedName(GenericName scope, String separator, CharSequence name)
path argument.
The tail is a local name created from the given character sequence.scope - the first part to concatenate.separator - the separator between the head and the tail,
or null for inheriting the same separator than the given scope.name - the second part to concatenate.public static LocalName createLocalName(CharSequence namespace, String separator, CharSequence localPart)
String or InternationalString instances.
Those character sequences are taken verbatim; they are not parsed into their components.
namespace and localPart
strings into smaller name components (e.g. namespaces contained in other namespaces). If such finer
grain control is desired, one can use DefaultNameFactory instead of this Names class.
Mapping from arguments to name components Argument Mapped to namespacename.scope().name().toString()localPartname.toString()
createLocalName("http://www.opengis.net/gml/srs/epsg.xml", "#", "4326"):
• name.toString()returns the "4326"string.• name.scope()returns the "http://www.opengis.net/gml/srs/epsg.xml"namespace.• name.toFullyQualifiedName()returns the "http://www.opengis.net/gml/srs/epsg.xml#4326"name.• toExpandedString(name)returns the "{http://www.opengis.net/gml/srs/epsg.xml}4326"string.
DefaultNameFactory.createLocalName(NameSpace, CharSequence)
is more efficient since it allows to create the NameSpace object only once.namespace - the namespace, or null for the global namespace.separator - the separator between the namespace and the local part, or null
for the default separator.localPart - the name which is locale in the given namespace.DefaultNameFactory.createLocalName(NameSpace, CharSequence)public static TypeName createTypeName(CharSequence namespace, String separator, CharSequence localPart)
String or InternationalString instances.
Those character sequences are taken verbatim; they are not parsed into their components.
createTypeName("gco", ":", "Integer") returns a name
which can be used for representing the type of <gco:Integer> elements in XML files.DefaultNameFactory.createTypeName(NameSpace, CharSequence)
is more efficient since it allows to create the NameSpace object only once.namespace - the namespace, or null for the global namespace.separator - the separator between the namespace and the local part, or null
for the default separator.localPart - the name which is locale in the given namespace.DefaultNameFactory.createTypeName(NameSpace, CharSequence)public static MemberName createMemberName(CharSequence namespace, String separator, CharSequence localPart, Class<?> valueClass)
TypeName will be inferred
from the given valueClass as documented in the DefaultTypeName javadoc.
DefaultNameFactory.createMemberName(NameSpace, CharSequence, TypeName)
is more efficient since it allows to create the NameSpace and TypeName objects only once.namespace - the namespace, or null for the global namespace.separator - the separator between the namespace and the local part, or null
for the default separator.localPart - the name which is locale in the given namespace.valueClass - the type of values, used for inferring a TypeName instance.DefaultNameFactory.createMemberName(NameSpace, CharSequence, TypeName)public static Class<?> toClass(TypeName type) throws UnknownNameException
null, then this method returns null.DefaultTypeName,
then this method delegates to DefaultTypeName.toClass()."OGC", then:
"CharacterString", "Integer", "Real" or other recognized names
(see DefaultTypeName javadoc), then the corresponding class is returned.UnknownNameException is thrown."class", then:
Class.forName(String), then that class is returned.UnknownNameException is thrown."OGC" scope (see above),
then the corresponding class is returned.null is returned. No exception is thrown because names in the global namespace
could be anything, so we can not be sure that the given name was wrong.null is returned, since this method can not check the validity of names in other
namespaces.type - the type name from which to infer a Java class.TypeName,
or null if there is no mapping from the given name to a Java class.UnknownNameException - if a mapping from the given name to a Java class was expected to exist
(typically because of the scope) but the operation failed.DefaultTypeName.toClass(),
DefaultNameFactory.toTypeName(Class)public static String toExpandedString(GenericName name)
ExpandedName ::= '{' NameSpace '}' LocalPart
NameSpace ::= name.scope().name().toString()
LocalPart ::= name.toString()name - the generic name to format in expanded form, or null.null if the given name was null.DefaultNameSpace.toString()Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.