org.objectweb.jonathan.libs.helpers

Class NameHelpers


public final class NameHelpers
extends java.lang.Object

Somme helper functions on names.

Method Summary

static Name
append(Name _name1, String _id, char _separator)
static Name
append(Name _name1, Name _name2)
Appends _name1 and _name2.
static Name
getPrefix(Name _name)
Returns the prefix of _name.
static Name
getSuffix(Name _name)
Returns the suffix of _name.
static Name
newName(String _name, char separator)
Creates a new name by parsing the provided string.
static Name
newName(String _id, Name _subname)
Returns a new Name, using _id as identifier, and _subname as subname.
static String
toString(Name _name, char _separator)

Method Details

append

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


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.


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.


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.


newName

public static Name newName(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.


newName

public static Name newName(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.


toString

public static String toString(Name _name,
                              char _separator)