org.sapia.archie
Class Name

java.lang.Object
  extended by org.sapia.archie.Name
All Implemented Interfaces:
java.io.Serializable

public class Name
extends java.lang.Object
implements java.io.Serializable

This interface provides an object reprentation of a "name". A Name is composed of potentially multiple NameParts.

A Name instance is typically obtained from a string representation, using a NameParser.

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site
See Also:
NamePart, NameParser, Serialized Form

Constructor Summary
  Name()
           
protected Name(java.util.List parts)
           
 
Method Summary
 Name add(Name n)
           
 Name add(NamePart part)
          Adds a NamePart to this instance.
 Name addAt(int pos, NamePart part)
           
 NamePart chopFirst()
          Chops the first part from this instance and returns it.
 NamePart chopLast()
          Chops the last part from this instance and returns it.
 java.lang.Object clone()
           
 int count()
          Returns the number of NameParts in this name.
 boolean endsWith(Name other)
           
 boolean equals(java.lang.Object o)
           
 NamePart first()
          Returns the first part in this name.
 NamePart get(int i)
          Returns the NamePart at the given index.
 int getCurrentIndex()
          Returns the internal iteration index.
 Name getFrom(int from)
          Returns all the NameParts that this name holds, starting from the given index (inclusively).
 Name getTo(int to)
          Returns all the NameParts that this name holds, up to the given index (exclusively).
 boolean hasNextPart()
          Returns true if this instance has another part to iterate on.
 NamePart last()
          Returns the last part in this name.
 NamePart nextPart()
          Iterates on the next NamePart.
 NamePart removeAt(int pos)
           
 void reset()
          Resets the internal iteration index.
 void setCurrentIndex(int i)
          Sets the internal iteration index.
 boolean startsWith(Name other)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Name

protected Name(java.util.List parts)

Name

public Name()
Method Detail

count

public int count()
Returns the number of NameParts in this name.

Returns:
a count.

getCurrentIndex

public int getCurrentIndex()
Returns the internal iteration index.

Returns:
an index.

setCurrentIndex

public void setCurrentIndex(int i)
Sets the internal iteration index.

Parameters:
i - an index.

reset

public void reset()
Resets the internal iteration index.


hasNextPart

public boolean hasNextPart()
Returns true if this instance has another part to iterate on.

See Also:
reset(), getCurrentIndex(), nextPart()

nextPart

public NamePart nextPart()
Iterates on the next NamePart.

See Also:
hasNextPart()

get

public NamePart get(int i)
Returns the NamePart at the given index.

Returns:
a NamePart.

add

public Name add(NamePart part)
Adds a NamePart to this instance.

Parameters:
part - a NamePart
Returns:
this instance (to allow chained invocations).

addAt

public Name addAt(int pos,
                  NamePart part)

removeAt

public NamePart removeAt(int pos)

endsWith

public boolean endsWith(Name other)

startsWith

public boolean startsWith(Name other)

add

public Name add(Name n)
Parameters:
n - adds the given Name to this instance (actually appends the NameParts of the given name to this instance).
Returns:
this instance.

getTo

public Name getTo(int to)
Returns all the NameParts that this name holds, up to the given index (exclusively). Returns the NameParts in a Name instance.

Parameters:
to - an upperbound index.
Returns:
a Name.

getFrom

public Name getFrom(int from)
Returns all the NameParts that this name holds, starting from the given index (inclusively). Returns the NameParts in a Name instance.

Parameters:
from - a lowerbound index.
Returns:
a Name.

first

public NamePart first()
Returns the first part in this name.

Returns:
a NamePart.

last

public NamePart last()
Returns the last part in this name.

Returns:
a NamePart.

chopLast

public NamePart chopLast()
Chops the last part from this instance and returns it.

Returns:
a NamePart.

chopFirst

public NamePart chopFirst()
Chops the first part from this instance and returns it.

Returns:
a NamePart.

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the string representation of this instance.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object


Copyright © 2010 Sapia OSS. All Rights Reserved.