org.objectweb.jonathan.libs.helpers
Class NameHelpers

java.lang.Object
  extended by org.objectweb.jonathan.libs.helpers.NameHelpers

public final class NameHelpers
extends java.lang.Object

Somme helper functions on names.


Constructor Summary
NameHelpers()
           
 
Method Summary
static Name append(Name _name1, Name _name2)
          Appends _name1 and _name2.
static Name append(Name _name1, java.lang.String _id, char _separator)
           
static Name getPrefix(Name _name)
          Returns the prefix of _name.
static Name getSuffix(Name _name)
          Returns the suffix of _name.
static Name newName(java.lang.String _name, char separator)
          Creates a new name by parsing the provided string.
static Name newName(java.lang.String _id, Name _subname)
          Returns a new Name, using _id as identifier, and _subname as subname.
static java.lang.String toString(Name _name, char _separator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NameHelpers

public NameHelpers()
Method Detail

getSuffix

public static Name getSuffix(Name _name)
Returns the suffix of _name.

If _name may be represented as "a/b/c", with '/' as a separator, then getSuffix returns "c".

Parameters:
_name - a name;
Returns:
the last component of name.

getPrefix

public static Name getPrefix(Name _name)
Returns the prefix of _name.

If _name may be represented as "a/b/c", with '/' as a separator, then getPrefix returns "a/b".

Parameters:
_name - a name;
Returns:
the prefix composed of all the name components but the last one.

append

public static Name append(Name _name1,
                          Name _name2)
Appends _name1 and _name2.

Parameters:
_name1 - a name;
_name2 - another name;
Returns:
the concatenation of both names.

append

public static Name append(Name _name1,
                          java.lang.String _id,
                          char _separator)

toString

public static java.lang.String toString(Name _name,
                                        char _separator)

newName

public static Name newName(java.lang.String _id,
                           Name _subname)
Returns a new Name, using _id as identifier, and _subname as subname.

Parameters:
_id - a String identifier;
_subname - a name;
Returns:
a new Name, using _id as identifier, and _subname as subname.

newName

public static Name newName(java.lang.String _name,
                           char separator)
Creates a new name by parsing the provided string.

If separator == 0, _name is considered as a simple identifier, and this call returns newName(_name,null). If the name begins with the separator, the name is an absolute name (this only makes sense if contexts with a tree structure); otherwise, the name is relative.

Parameters:
_name - a string representing a name;
separator - a separator to parse it.
Returns:
a Name.