org.geotools.util
Class GenericName

Object
  extended by GenericName
All Implemented Interfaces:
Serializable, Comparable<GenericName>, GenericName
Direct Known Subclasses:
LocalName, ScopedName

public abstract class GenericName
extends Object
implements GenericName, 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
Author:
Martin Desruisseaux (IRD)
See Also:
NameFactory, Serialized Form
Module:

Field Summary
static char DEFAULT_SEPARATOR
          The default separator character.
 
Constructor Summary
protected GenericName()
          Creates a new instance of generic name.
 
Method Summary
 LocalName asLocalName()
          Deprecated. Renamed as name().
abstract  ScopedName asScopedName()
          Deprecated. Replaced by GenericName.toFullyQualifiedName().
 int compareTo(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(Object object)
          Compares this generic name with the specified object for equality.
abstract  List<LocalName> getParsedNames()
          Returns the sequence of local names making this generic name.
abstract  GenericName getScope()
          Deprecated. Replaced by scope().
 int hashCode()
          Returns a hash code value for this generic name.
 LocalName head()
          Returns the first element in the sequence of parsed names.
abstract  LocalName name()
          Deprecated. Renamed as tip().
 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.
 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
 
Methods inherited from interface 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 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 GenericName
Returns:
The name space.
Since:
2.3

getScope

@Deprecated
public abstract 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.

Specified by:
getScope in interface GenericName
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 GenericName
Returns:
The depth of this name.
Since:
2.3

getParsedNames

public abstract List<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 GenericName
Returns:
The sequence of local names.

asLocalName

@Deprecated
public LocalName asLocalName()
Deprecated. Renamed as name().

Returns a view of this object as a local name.

Specified by:
asLocalName in interface GenericName
Returns:
The local part of this name.

name

public abstract LocalName name()
Deprecated. Renamed as tip().

Returns the last element in the sequence of parsed names. For any LocalName, this is always this.

Specified by:
name in interface GenericName
Returns:
The last element of this name.
Since:
2.3
See Also:
LocalName.name, ScopedName.name

tip

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

Returns:
The last element of this name.
Since:
2.5

head

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

Returns:
The first element of this name.
Since:
2.5

asScopedName

@Deprecated
public abstract 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.

Specified by:
asScopedName in interface GenericName
Returns:
The fully-qualified name.

toString

public 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 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. 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 GenericName
Returns:
A localizable string representation of this name.

compareTo

public int compareTo(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 Comparable<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(Object object)
Compares this generic name with the specified object for equality.

Overrides:
equals in class 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 Object


Copyright © 1996-2009 Geotools. All Rights Reserved.