org.geotools.util
Class GenericName

java.lang.Object
  extended by org.geotools.util.GenericName
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<org.opengis.util.GenericName>, org.opengis.util.GenericName
Direct Known Subclasses:
LocalName, ScopedName

public abstract class GenericName
extends java.lang.Object
implements org.opengis.util.GenericName, java.io.Serializable

Base class for generic scoped and local name structure for type and attribute name in the context of name spaces.

Note: this class has a natural ordering that is inconsistent with equals. The natural ordering may be case-insensitive and ignores the character separator between name elements.

Since:
2.1
Version:
$Id: GenericName.java 31557 2008-09-19 20:02:35Z desruisseaux $
Author:
Martin Desruisseaux (IRD)
See Also:
NameFactory, Serialized Form

Field Summary
static char DEFAULT_SEPARATOR
          The default separator character.
 
Constructor Summary
protected GenericName()
          Creates a new instance of generic name.
 
Method Summary
 org.opengis.util.LocalName asLocalName()
          Deprecated. Renamed as tip().
abstract  org.opengis.util.ScopedName asScopedName()
          Deprecated. Replaced by GenericName.toFullyQualifiedName().
 int compareTo(org.opengis.util.GenericName that)
          Compares this name with the specified object for order.
 int depth()
          Returns the depth of this name within the namespace hierarchy.
 boolean equals(java.lang.Object object)
          Compares this generic name with the specified object for equality.
abstract  java.util.List<org.opengis.util.LocalName> getParsedNames()
          Returns the sequence of local names making this generic name.
abstract  org.opengis.util.GenericName getScope()
          Deprecated. Replaced by scope().
 int hashCode()
          Returns a hash code value for this generic name.
 org.opengis.util.LocalName head()
          Returns the first element in the sequence of parsed names.
 org.opengis.util.LocalName name()
          Deprecated. Renamed as tip().
 org.opengis.util.NameSpace scope()
          Returns the scope (name space) in which this name is local.
 org.opengis.util.LocalName tip()
          Returns the last element in the sequence of parsed names.
 org.opengis.util.InternationalString toInternationalString()
          Returns a local-dependent string representation of this generic name.
 java.lang.String toString()
          Returns a string representation of this generic name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.util.GenericName
push, toFullyQualifiedName
 

Field Detail

DEFAULT_SEPARATOR

public static final char DEFAULT_SEPARATOR
The default separator character.

See Also:
Constant Field Values
Constructor Detail

GenericName

protected GenericName()
Creates a new instance of generic name.

Method Detail

scope

public org.opengis.util.NameSpace scope()
Returns the scope (name space) in which this name is local. The scope is set on creation and is not modifiable. The scope of a name determines where a name "starts". For instance, if a name has a depth of two ("util.GenericName") and is associated with a name space having the name "org.opengis", then the fully qualified name would be "org.opengis.util.GenericName".

Specified by:
scope in interface org.opengis.util.GenericName
Returns:
The name space.
Since:
2.3

getScope

@Deprecated
public abstract org.opengis.util.GenericName getScope()
Deprecated. Replaced by scope().

Returns the scope (name space) of this generic name. If this name has no scope (e.g. is the root), then this method returns null.

Returns:
The name space of this name.

depth

public int depth()
Returns the depth of this name within the namespace hierarchy. This indicates the number of levels specified by this name. For any LocalName, it is always one. For a ScopedName it is some number greater than or equal to 2.

The depth is the length of the list returned by the getParsedNames() method. As such it is a derived parameter.

Specified by:
depth in interface org.opengis.util.GenericName
Returns:
The depth of this name.
Since:
2.3

getParsedNames

public abstract java.util.List<org.opengis.util.LocalName> getParsedNames()
Returns the sequence of local names making this generic name. Each element in this list is like a directory name in a file path name. The length of this sequence is the generic name depth.

Specified by:
getParsedNames in interface org.opengis.util.GenericName
Returns:
The sequence of local names.

head

public org.opengis.util.LocalName head()
Returns the first element in the sequence of parsed names. For any LocalName, this is always this.

Specified by:
head in interface org.opengis.util.GenericName
Returns:
The first element of this name.
Since:
2.6

tip

public org.opengis.util.LocalName tip()
Returns the last element in the sequence of parsed names. For any LocalName, this is always this.

Specified by:
tip in interface org.opengis.util.GenericName
Returns:
The last element of this name.
Since:
2.6

asLocalName

@Deprecated
public org.opengis.util.LocalName asLocalName()
Deprecated. Renamed as tip().

Returns a view of this object as a local name.

Returns:
The local part of this name.

name

@Deprecated
public org.opengis.util.LocalName name()
Deprecated. Renamed as tip().

Specified by:
name in interface org.opengis.util.GenericName
Since:
2.3

asScopedName

@Deprecated
public abstract org.opengis.util.ScopedName asScopedName()
Deprecated. Replaced by GenericName.toFullyQualifiedName().

Returns a view of this name as a fully-qualified name, or null if none. The scope of a fully qualified name must be global.

If this name is a local name and the scope is already global, returns null since it is not possible to derive a scoped name.

Returns:
The fully-qualified name.

toString

public java.lang.String toString()
Returns a string representation of this generic name. This string representation is local-independant. It contains all elements listed by getParsedNames() separated by an arbitrary character (usually : or /). This rule implies that the toString() method for a scoped name will contains the scope, while the toString() method for the local version of the same name will not contains the scope.

Specified by:
toString in interface org.opengis.util.GenericName
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this name.

toInternationalString

public org.opengis.util.InternationalString toInternationalString()
Returns a local-dependent string representation of this generic name. This string is similar to the one returned by toString() except that each element has been localized in the specified locale. If no international string is available, then this method should returns an implementation mapping to toString() for all locales.

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

compareTo

public int compareTo(org.opengis.util.GenericName that)
Compares this name with the specified object for order. Returns a negative integer, zero, or a positive integer as this name lexicographically precedes, is equals to, or follows the specified object. The comparaison is performed in the following order:

Specified by:
compareTo in interface java.lang.Comparable<org.opengis.util.GenericName>
Parameters:
that - The name to compare with this name.
Returns:
-1 if this name precedes the given one, +1 if it follows, 0 if equals.

equals

public boolean equals(java.lang.Object object)
Compares this generic name with the specified object for equality.

Overrides:
equals in class java.lang.Object
Parameters:
object - The object to compare with this name.
Returns:
true if the given object is equals to this one.

hashCode

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

Overrides:
hashCode in class java.lang.Object


Copyright © 1996-2010 Geotools. All Rights Reserved.