|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectARoad0.gBase.NameImpl
public final class NameImpl
This class 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 ':: '. Name follows the OMG CORBA Object Services Specification (OMG-COSS) for a naming service which names an object for later retrieval. Methods added to the OMG specification are extended(ImmutableName), extended(String), clone(), equals(), hashCode(), getSerialVersion(), getNameFromString(). It does NOT follow the JNDI name interface.
The name is an ordered list of components in a java.util.ArrayList. Each component is a string that may be null. Case must be respected. ':: ' is a forbidden component. It is controlled in every creating or updating method. The usual struture of an entity name is (IS name).(ACS name).(entity name) Normally, the usual name of an instance of Name is equals to name.lastComponent(). To remove any component, use without(). To add a component at the end, use an extended() method. To modify the last component, use without() then extended(). For more complex modifying operations, use the list returned by components().
With threads, the calls to the Name methods should be done in a block synchronized on the Name instance. If the name is used as a key in a map, it is much safer to avoid a mutable name. Use then the ImmutableName interface to construct the key. But the update will remain possible by casting the ImmutableName in Name. The hashcode() and equals() methods are coherent over serialization, then a map with a name key handles the same values.
Field Summary | |
---|---|
static NameImpl |
EMPTY_INSTANCE
A reusable empty instance for initialization, to avoid the use of 'new' for temporary values. |
private java.util.ArrayList |
fCompo_
fCompo_ is an ArrayList that stores the name components. |
private static int |
INCREMENT_CAPACITY
|
private static int |
INITIAL_CAPACITY
|
private static int |
PRIME
|
static java.io.ObjectStreamField[] |
serialPersistentFields
|
private static long |
serialVersionUID__
|
Constructor Summary | |
---|---|
NameImpl()
|
|
NameImpl(java.util.ArrayList _components)
The returned instance is empty if a component contains ':: '. |
|
NameImpl(java.lang.String _st)
Returns a new empty name if the parameter is null or contains ':: '. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Get a clone of name. |
int |
compareTo(java.lang.Object o)
|
java.lang.String |
component(int _i)
Gets the component at a given position. |
java.util.List<java.lang.String> |
components()
Faster than immutableComponents(). |
boolean |
contains(ImmutableName _name)
|
Name |
context()
Get a copy of the current name less the last component. |
Name |
context(int _end)
Gets a copy of the current name less some last components. |
boolean |
equals(java.lang.Object _obj)
Compares the two names. |
Name |
extended(ImmutableName _name)
For extending the current name. |
Name |
extended(java.lang.String _nc)
For extending the current name. |
static Name |
getNameFromString(java.lang.String _text)
Gets the name from the string returned by toString(). |
long |
getSerialVersionUID()
|
int |
hashCode()
|
java.util.List |
immutableComponents()
|
boolean |
isEmpty()
|
java.lang.String |
lastComponent()
Gets the last component of the name. |
int |
noOfComponents()
|
Name |
subname(int _start,
int _end)
Returns a new Name instance. |
java.lang.String |
toString()
Gets a String representation with one leading whitespace and ':: ' at the end, or gets ' null '. |
Name |
without(Name _name)
Caution: this method changes the instance. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID__
private static final int INITIAL_CAPACITY
private static final int INCREMENT_CAPACITY
private static final int PRIME
private java.util.ArrayList fCompo_
public static final NameImpl EMPTY_INSTANCE
public static final java.io.ObjectStreamField[] serialPersistentFields
Constructor Detail |
---|
public NameImpl()
public NameImpl(java.util.ArrayList _components)
_components
- contains only strings, without ':: '. _components is copied.public NameImpl(java.lang.String _st)
_st
- is the string name.Method Detail |
---|
public final boolean isEmpty()
isEmpty
in interface ImmutableName
public final Name context()
ImmutableName
context
in interface ImmutableName
public final Name without(Name _name)
without
in interface Name
_name
- is removed from the current name. _name may be at the start,
the end or the middle of the current name.
If there are several sections of the current name that are strictly
identical to _name, without() removes the last matched part,
at the end of the current name.
public final Name extended(java.lang.String _nc)
extended
in interface Name
_nc
- adds a new component to the current instance
public final Name extended(ImmutableName _name)
extended
in interface Name
_name
- adds a new name at the end of the current instance
public final Name context(int _end)
context
in interface ImmutableName
_end
- is the _inclusive_ index of the last component to be returned
public final Name subname(int _start, int _end)
subname
in interface ImmutableName
subname
in interface Name
_start
- inclusive fromIndex_end
- exclusive toIndex
public final java.util.List<java.lang.String> components()
components
in interface ImmutableName
public final java.util.List immutableComponents()
immutableComponents
in interface ImmutableName
public final int noOfComponents()
noOfComponents
in interface ImmutableName
public final java.lang.String component(int _i)
component
in interface ImmutableName
_i
- index of the component. No limit on the value.
public final java.lang.String lastComponent()
lastComponent
in interface ImmutableName
public final boolean contains(ImmutableName _name)
contains
in interface ImmutableName
_name
- never null.
public final java.lang.Object clone()
clone
in interface ImmutableName
clone
in class java.lang.Object
java.lang.InternalError
- if CloneNotSupportedExceptionpublic final boolean equals(java.lang.Object _obj)
equals
in interface ImmutableName
equals
in class java.lang.Object
_obj
- the object to compare
public final int hashCode()
hashCode
in interface ImmutableName
hashCode
in class java.lang.Object
public final int compareTo(java.lang.Object o) throws java.lang.ClassCastException
compareTo
in interface ImmutableName
compareTo
in interface java.lang.Comparable
o
- Object to compare must be an ImmutableName (true for Name)
java.lang.ClassCastException
- - if the specified object's type
prevents it from being compared to this current Objectpublic final long getSerialVersionUID()
getSerialVersionUID
in interface ImmutableName
public final java.lang.String toString()
toString
in class java.lang.Object
public static final Name getNameFromString(java.lang.String _text) throws BaseError
_text
- name, as get through toString()
BaseError
- if the string argument is null or empty,
or if the string does not start with ' ' or is not ended by ':: '.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |