Package org.apache.sis.util.iso
Class DefaultNameSpace
- Object
-
- DefaultNameSpace
-
- All Implemented Interfaces:
Serializable,NameSpace
public class DefaultNameSpace extends Object implements NameSpace, Serializable
A domain in which names given by character strings are defined. This implementation does not support localization in order to avoid ambiguity when testing two namespaces for equality.DefaultNameSpacecan be instantiated by any of the following methods:Immutability and thread safetyThis class is immutable and thus inherently thread-safe if theNameSpaceandCharSequencearguments 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 publicNameSpacestate.- Since:
- 0.3
- See Also:
DefaultScopedName,DefaultLocalName,DefaultTypeName,DefaultMemberName,DefaultNameFactory, Serialized Form
Defined in the
sis-metadatamodule
-
-
Field Summary
Fields Modifier and Type Field Description static charDEFAULT_SEPARATORThe default separator, which is':'.
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultNameSpace(DefaultNameSpace parent, CharSequence name, String headSeparator, String separator)Creates a new namespace with the given separator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object object)Returnstrueif this namespace is equal to the given object.inthashCode()Returns a hash code value for this namespace.booleanisGlobal()Indicates whether this namespace is a "top level" namespace.GenericNamename()Represents the identifier of this namespace.StringtoString()Returns a JCR-like lexical form representation of this namespace.
-
-
-
Field Detail
-
DEFAULT_SEPARATOR
public static final char DEFAULT_SEPARATOR
The default separator, which is':'. The separator is inserted between the namespace and any generic name in that namespace.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultNameSpace
protected DefaultNameSpace(DefaultNameSpace parent, CharSequence name, String headSeparator, String separator)
Creates a new namespace with the given separator.- Parameters:
parent- the parent namespace, ornullif none.name- the name of the new namespace, usually as aStringor anInternationalString.headSeparator- the separator to insert between the namespace and the head of any name in that namespace.separator- the separator to insert between the parsed names of any name in that namespace.
-
-
Method Detail
-
isGlobal
public boolean isGlobal()
Indicates whether this namespace is a "top level" namespace. Global, or top-level namespaces are not contained within another namespace. The global namespace has no parent.- Specified by:
isGlobalin interfaceNameSpace- Returns:
trueif this namespace is the global namespace.
-
name
public GenericName name()
Represents the identifier of this namespace. Namespace identifiers shall be fully-qualified names where the following condition holds:assert name.scope().isGlobal() == true;
- Specified by:
namein interfaceNameSpace- Returns:
- the identifier of this namespace.
-
toString
public String toString()
Returns a JCR-like lexical form representation of this namespace. Following the Java Content Repository (JCR) convention, this method returns the string representation of name() between curly brackets.Example: if the name of this namespace is “org.apache.sis”, then this method returns “{org.apache.sis}”.UsageWith this convention, it would be possible to create an expanded form of a generic name (except for escaping of illegal characters) with a simple concatenation as in the following code example:
However the convention followed by thisGenericName name = ...; // A name println("Expanded form = " + name.scope() + name);DefaultNameSpaceimplementation is not specified in theNameSpacecontract. This implementation follows the JCR convention for debugging convenience, but applications needing better guarantees should useNames.toExpandedString(GenericName)instead.- Overrides:
toStringin classObject- Returns:
- a JCR-like lexical form of this namespace.
- See Also:
Names.toExpandedString(GenericName)
-
equals
public boolean equals(Object object)
Returnstrueif this namespace is equal to the given object.
-
-