org.geotools.feature
Class NameImpl

Object
  extended by NameImpl
All Implemented Interfaces:
Serializable, Comparable<NameImpl>, Name

public class NameImpl
extends Object
implements Name, Serializable, Comparable<NameImpl>

Simple implementation of Name.

This class emulates QName, and is used as the implementation of both AttributeName and TypeName (so when the API settles down we should have a quick fix.

Its is advantageous to us to be able to:

The ISO interface move towards combining the AttributeName and Attribute classes, and TypeName and Type classes, while we understand the attractiveness of this on a UML diagram it is very helpful to keep these concepts separate when playing with a strongly typed language like java.

It case it is not obvious this is a value object and equality is based on namespace and name.

Author:
Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
See Also:
Serialized Form

Field Summary
protected  String local
          local part
protected  String namespace
          namespace / scope
 
Constructor Summary
NameImpl(QName qName)
          Constract an instance from the provided QName.
NameImpl(String local)
          Constructs an instance with the local part set.
NameImpl(String namespace, String local)
          Constructs an instance with the local part and namespace set.
NameImpl(String namespace, String separator, String local)
          Constructs an instance with the local part and namespace set.
 
Method Summary
 int compareTo(NameImpl other)
           
 boolean equals(Object obj)
          value object with equality based on name and namespace.
 String getLocalPart()
          Retrieve the "local" name.
 String getNamespaceURI()
          Returns the URI of the namespace for this name.
 String getSeparator()
          Separator to use between getNamespaceURI() and getLocalPart() when constructing getURI().
 String getURI()
          Convert this name to a complete URI.
 int hashCode()
          Returns a hash code value for this operand.
 boolean isGlobal()
          Returns true if getNamespaceURI is null
 String toString()
          name or namespace:name
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

namespace

protected String namespace
namespace / scope


local

protected String local
local part

Constructor Detail

NameImpl

public NameImpl(String local)
Constructs an instance with the local part set. Namespace / scope is set to null.

Parameters:
local - The local part of the name.

NameImpl

public NameImpl(String namespace,
                String local)
Constructs an instance with the local part and namespace set.

Parameters:
namespace - The namespace or scope of the name.
local - The local part of the name.

NameImpl

public NameImpl(String namespace,
                String separator,
                String local)
Constructs an instance with the local part and namespace set.

Parameters:
namespace - The namespace or scope of the name.
local - The local part of the name.

NameImpl

public NameImpl(QName qName)
Constract an instance from the provided QName.

Method Detail

isGlobal

public boolean isGlobal()
Description copied from interface: Name
Returns true if getNamespaceURI is null

Specified by:
isGlobal in interface Name
Returns:
Returns true if getNamespaceURI is null

getSeparator

public String getSeparator()
Description copied from interface: Name
Separator to use between getNamespaceURI() and getLocalPart() when constructing getURI().

This separator is only used to construct a visually pleasing getURI() result. The value to use as a separator depends on the registry or namespace you are working with. JNDI naming services have been known to use "/" and ":". Referring to an element in an XMLSchema document has been represented with a "#" symbol.

Specified by:
getSeparator in interface Name
Returns:
A separator (such as "/" or ":").

getNamespaceURI

public String getNamespaceURI()
Description copied from interface: Name
Returns the URI of the namespace for this name.

In ISO 19103 this is known as scope and containes a backpointer to the containing namespace. This solution is too heavy for our purposes, and we expect applications to provide their own lookup mechanism through which they can use this URI.

The namespace URI does serve to make this name unique and is checked as part of the equals operation.

Specified by:
getNamespaceURI in interface Name

getLocalPart

public String getLocalPart()
Description copied from interface: Name
Retrieve the "local" name.

This mechanism captures the following ISO 19103 concerns:

Specified by:
getLocalPart in interface Name
Returns:
local name (can be used in namespace lookup)

getURI

public String getURI()
Description copied from interface: Name
Convert this name to a complete URI.

This URI is constructed with the getNamespaceURI(), getSeparator() and getLocalPart().

This method captures the following concerns of ISO 19103 concerns:

As an example:

Both return: "gopher://localhost/example/name" as they indicate the same entry in the namespace system (such as a Registry or JNDI naming service).

Specified by:
getURI in interface Name
Returns:
a complete URI constructed of namespace URI and the local part.

hashCode

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

Specified by:
hashCode in interface Name
Overrides:
hashCode in class Object
Returns:
a hascode based on getURI()

equals

public boolean equals(Object obj)
value object with equality based on name and namespace.

Specified by:
equals in interface Name
Overrides:
equals in class Object
Returns:
true if getURI is equal.

toString

public String toString()
name or namespace:name

Specified by:
toString in interface Name
Overrides:
toString in class Object

compareTo

public int compareTo(NameImpl other)
Specified by:
compareTo in interface Comparable<NameImpl>


Copyright © 1996-2014 Geotools. All Rights Reserved.