ARoad0.gBaseInterface
Interface ImmutableName

All Superinterfaces:
java.lang.Cloneable, java.lang.Comparable
All Known Subinterfaces:
Name
All Known Implementing Classes:
NameImpl

public interface ImmutableName
extends java.lang.Cloneable, java.lang.Comparable

This interface is responsible for managing the names for all the database objects. Examples of real name are "http://accbee.com", "c:\program files\access road", "net/users/john". The separator character depends on the ACS. All the real names are converted in Access Road names implemented by this class. The single separator in all the Access Road names is ':: '. Every ImmutableName instance must be a Name instance. The name is an list of components in a java.util.ArrayList. Each component is a string that may be null. Case must be respected. component(int) and lastComponent() return only copies of the component, as the others methods which return new objects, no linked to the current name. compareTo() allows an immutable name to be a key in a sorted map.


Method Summary
 java.lang.Object clone()
           
 int compareTo(java.lang.Object o)
           
 java.lang.String component(int _i)
          No exception thrown.
 java.util.List<java.lang.String> components()
           
 boolean contains(ImmutableName _name)
           
 Name context()
          Get a copy of the current name less the last component.
 Name context(int _end)
          Get a copy of the current name less some last components.
 boolean equals(java.lang.Object _obj)
           
 long getSerialVersionUID()
           
 int hashCode()
           
 java.util.List immutableComponents()
           
 boolean isEmpty()
           
 java.lang.String lastComponent()
           
 int noOfComponents()
           
 Name subname(int _start, int _end)
           
 

Method Detail

isEmpty

boolean isEmpty()
Returns:
true if the name has no component, or if all components are null or equal to empty Strings.

context

Name context()
Get a copy of the current name less the last component.

Returns:
a copy of the current name less than the last component. The context returned is not backed by the current name, so modify the context doesn't modify the current name. May be null.

context

Name context(int _end)
Get a copy of the current name less some last components.

Parameters:
_end - is the _inclusive_ index of the last component to be returned
Returns:
the context (from 0 to _end) of the current name in a new Name, this name if _end = (size of the name) - 1, this name.context() if _end = (size of the name) - 2, the first name component if _end = 0. The context is not backed by the first components of the current name. Return is null if the name is empty, or if _end is equal or superior to the name size.

subname

Name subname(int _start,
             int _end)
Parameters:
_start - inclusive fromIndex
_end - exclusive toIndex
Returns:
an extract of the current name that is copied in a new Name. May be null.

components

java.util.List<java.lang.String> components()
Returns:
List of the components (strings) that is backed by the list of the current name. Then, the returned name is modifiable but the only proprietary of the returned list is the current name. So, to avoid any bug, use the returned list as a transient object, for a limited time. Never delete it directly. May be null.

immutableComponents

java.util.List immutableComponents()
Returns:
List of the components (strings) in the name. is immutable. may be null.

noOfComponents

int noOfComponents()
Returns:
int number of components in the name.

component

java.lang.String component(int _i)
No exception thrown.

Parameters:
_i - index of the component. No limit on the value.
Returns:
the component at _i in the name. May be null.

lastComponent

java.lang.String lastComponent()
Returns:
String the last component in the name (may be null)

contains

boolean contains(ImmutableName _name)
Parameters:
_name - Never null.
Returns:
true if _name components are all there in the instance, but not always in the same order

clone

java.lang.Object clone()
Returns:
a cloned and no-backed instance of mutable name that may be cast as a Name or an ImmutableName. May be null.

equals

boolean equals(java.lang.Object _obj)
Overrides:
equals in class java.lang.Object
Parameters:
_obj - the object to compare
Returns:
true if the list of strings is equal - not only identical - even if the two objects are instances of the same class that implementes Name (and not only ImmutableName)

hashCode

int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode value for this instance of Name. May be null.

compareTo

int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Object to compare must be an ImmutableName (true for Name)
Returns:
0 is the names are equals, a negative integer if this Name object is lesser than the argument, and a positive integer if this Name object is greater than the argument. The comparison is based on the Unicode value of each character in each Name component (starting from the first one) and the number of components (negative return if all strings of this Name are equals but with less components, or if the argument is null).
Throws:
java.lang.ClassCastException - - if the specified object's type prevents it from being compared to this current Object

getSerialVersionUID

long getSerialVersionUID()
Returns:
long serial version UID for serialization of the class