org.opengis.example.util
Class SimpleName

Object
  extended by SimpleName
All Implemented Interfaces:
Serializable, Comparable<GenericName>, GenericName
Direct Known Subclasses:
SimpleName.Local, SimpleName.Scoped

public class SimpleName
extends Object
implements GenericName, Serializable

A GenericName backed by a JNDI Name instance. This name can be the basis of LocalName or ScopedName implementations, depending on whether the size of the wrapped JNDI name is 1 or more, respectively.

This implementation is a view: any change applied on the wrapped JNDI object will be immediately reflected in the SimpleName wrapper. Note however that GenericName are usually expected to be immutable, so users are advised to not modify the wrapped JNDI name.

See Also:
jndiName(), Serialized Form

Nested Class Summary
static class SimpleName.Local
          A LocalName specialization of SimpleName.
static class SimpleName.Member
          A MemberName specialization of SimpleName.Local.
static class SimpleName.Scoped
          A ScopedName specialization of SimpleName.
static class SimpleName.Type
          A TypeName specialization of SimpleName.Local.
 
Field Summary
protected  Name name
          The JNDI name wrapped by this SimpleName.
 
Constructor Summary
protected SimpleName(SimpleNameSpace scope, Name name)
          Creates a new instance backed by the given JNDI name.
 
Method Summary
 int compareTo(GenericName other)
          Compares this name with the given object for lexicographical order.
 int depth()
          Returns the number of levels specified by this name.
 boolean equals(Object other)
          Compares the given object to this name for equality.
 List<LocalName> getParsedNames()
          Returns the sequence of local names making this generic name.
 int hashCode()
          Returns a hash code value for this name.
 LocalName head()
          Returns the first element in the sequence of parsed names.
 Name jndiName()
          Returns a clone of the JNDI name wrapped by this object.
 ScopedName push(GenericName scope)
          Returns this name expanded with the specified scope.
 NameSpace scope()
          Returns the scope (name space) in which this name is local.
 LocalName tip()
          Returns the last element in the sequence of parsed names.
 GenericName toFullyQualifiedName()
          Returns a view of this name as a fully-qualified name.
 InternationalString toInternationalString()
          Returns a local-dependent string representation of this generic name.
 String toString()
          Returns a string representation of this generic name.
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected final Name name
The JNDI name wrapped by this SimpleName. While JNDI names are mutable, GenericName are expected to be immutable. Consequently users are advised to not modify this object.

See Also:
jndiName()
Constructor Detail

SimpleName

protected SimpleName(SimpleNameSpace scope,
                     Name name)
Creates a new instance backed by the given JNDI name. This constructor does not clone the given JNDI name. While this implementation is robust to change in the wrapped object, it is a better practice to keep the JNDI name unmodified after SimpleName construction.

Parameters:
scope - The scope (name space) in which the given name is local, or null.
name - The JNDI name wrapped by this SimpleName (not cloned).
Method Detail

jndiName

public Name jndiName()
Returns a clone of the JNDI name wrapped by this object.

Returns:
A clone of name.

scope

public NameSpace scope()
Returns the scope (name space) in which this name is local. The scope of a name determines where a name starts. The scope is set on creation and is not modifiable.

Specified by:
scope in interface GenericName

depth

public int depth()
Returns the number of levels specified by this name. The default implementation returns the size of the wrapped JNDI name.

Specified by:
depth in interface GenericName
See Also:
Name.size()

getParsedNames

public List<LocalName> getParsedNames()
Returns the sequence of local names making this generic name. The length of this sequence is the depth. It does not include the scope.

Specified by:
getParsedNames in interface GenericName
See Also:
Name.getAll()

head

public LocalName head()
Returns the first element in the sequence of parsed names.

Specified by:
head in interface GenericName
See Also:
Name.get(int)

tip

public LocalName tip()
Returns the last element in the sequence of parsed names.

Specified by:
tip in interface GenericName
See Also:
Name.get(int)

toFullyQualifiedName

public GenericName toFullyQualifiedName()
Returns a view of this name as a fully-qualified name. The scope of a fully qualified name will be global. If the scope of this name is already global, then this method returns this.

Specified by:
toFullyQualifiedName in interface GenericName
Returns:
The fully-qualified name (never null).

push

public ScopedName push(GenericName scope)
Returns this name expanded with the specified scope. One may represent this operation as a concatenation of the specified scope with this.

Specified by:
push in interface GenericName
Parameters:
scope - The name to use as prefix.
Returns:
A concatenation of the given name with this name.
See Also:
Name.addAll(Name)

toString

public String toString()
Returns a string representation of this generic name. Note that the scope is not part of this string representation.

Specified by:
toString in interface GenericName
Overrides:
toString in class Object
Returns:
A string representation of this name.

toInternationalString

public InternationalString toInternationalString()
Returns a local-dependent string representation of this generic name. The default implementation wraps the toString() value.

Specified by:
toInternationalString in interface GenericName
Returns:
A localizable string representation of this name.

compareTo

public int compareTo(GenericName other)
Compares this name with the given object for lexicographical order. Note that the scope is not part of this comparison.

Specified by:
compareTo in interface Comparable<GenericName>
Parameters:
other - The other object to compare to this name.

equals

public boolean equals(Object other)
Compares the given object to this name for equality. This method compares both the scope and the name given to the constructor.

Overrides:
equals in class Object
Parameters:
other - The other object to compare to this name.

hashCode

public int hashCode()
Returns a hash code value for this name.

Overrides:
hashCode in class Object


Copyright © 1994–2014 Open Geospatial Consortium. All rights reserved.