Methods Summary |
---|
private java.lang.String | createPartialNameString(int beginIndex, int endIndex)
boolean isInputValid = (beginIndex <= endIndex) &&
(endIndex < mNameParts.size()) &&
(beginIndex >= 0);
//ArgChecker.check(isInputValid, "indices are invalid");
StringBuffer nameBuffer = new StringBuffer();
for(int i = beginIndex ; i < endIndex ; i++)
{
String aPart = (String)mNameParts.elementAt(i);
nameBuffer.append(aPart);
if(i < endIndex - 1)
{
nameBuffer.append(Tokens.kDelimiterChar);
}
}
return ( nameBuffer.toString() );
|
public boolean | equals(java.lang.Object other)Checks if the given Object is same as this name. It returns true if
and only if the argument is non null and represents same character
sequence as that in this name. It is guaranteed that two objects that
are equal in this way, will always return equal Strings when toString()
is called on them.
boolean isSame = false;
if (other instanceof Name)
{
Name otherName = (Name) other;
if (this.mString.equals(otherName.mString))
{
isSame = true;
}
}
return ( isSame );
|
public int | getIndex()Returns the index beginning at 0 for a Name that is Indexed. It returns
Name.kInvalidIndex for a name i.e. not indexed.
(e.g. a.b.c or a.b[0].c, as none of these is indexed).
In general, index of an indexed name a.b.c[n] is n.
Calling methods have to compare the return value with Name.kInvalidIndex
int index = kInvalidIndex;
String indexString = null;
int startPos, endPos;
if (isIndexed())
{
/*
Note that a[3].b[7].c.d[4] has an index of 4 and that's why
we have to taken last index of '[' and ']'. If the name parses
correct, then the string between last '[' and last ']' is
bound to be the index of this name.
*/
startPos = mString.lastIndexOf(Tokens.kSubScriptBeginnerChar);
endPos = mString.lastIndexOf(Tokens.kSubScriptEnderChar);
//Assert.assert(endPos > startPos, "this should not be indexed!");
indexString = mString.substring(startPos + 1, endPos);
try
{
index = Integer.parseInt(indexString);
}
catch(NumberFormatException e)
{
//ExceptionUtil.ignoreException(e); // this should NEVER happen
}
}
return index;
|
public com.sun.enterprise.admin.common.Name | getNamePart(int partNum)Returns a Name instance that represents mth part of Name such that,
0 <= m <= n,
where n is the number of delimiters (excludig escaped ones)in the string.
0 is applied for the first part.
e.g. For a name "abc.xy.c[5].d",
name-part with partNum = 0 is "abc".
name-part with partNum = 1 is "xy".
name-part with partNum = 2 is "c[5]" and so on.
if there are no delimiters, then this name itself is returned.
Name namePart = null;
String namePartString = null;
int lowerLimit = -1; //lower limit on index
int upperLimit = mNameParts.size(); //upper limit on index
//ArgChecker.check(partNum, lowerLimit, upperLimit, "number is invalid");
namePartString = (String)mNameParts.elementAt(partNum);
try
{
namePart = new Name(namePartString);
}
catch(Exception e)
{
//ExceptionUtil.ignoreException(e); // this is actually assertion
}
return namePart;
|
public int | getNumParts()Returns the number of name-parts in this name. A valid name contains
at least one name-part, in which case it is this name itself. Every
name-part is delimited by Tokens.kDelimiterChar.
return ( mNameParts.size() );
|
public com.sun.enterprise.admin.common.Name | getParent()Returns the Parent Name of this Name. This method is particularly
useful in determining location of this Name in hierarchy of Names.
Following are the rules applied to determine parent of a Name:
a.b.c is always parent of a.b.c.d
a.b.c is always parent of a.b.c[n], where n is any valid index
a.b.c is always parent of a.b.c.*
a.b.c[n] is always the parent of a.b.c[n].d
null is always the parent of any string that does not contain
any delimiter.
Name parentName = null;
//Assert.assert(! mNameParts.isEmpty(), "Vector of name-parts can't be empty");
int size = mNameParts.size();
if(size > 1)
{
String nameSubstring = createPartialNameString(0, size - 1);
try
{
parentName = new Name(nameSubstring);
}
catch(MalformedNameException e)
{
//ExceptionUtil.ignoreException(e);
//this is actually assertion and should never happen
}
}
return ( parentName );
|
public int | hashCode()Instances of this class can be used as keys in a Hashtable. Since the
equals() method is overridden by this class, it is necessary that
hashCode() is also overridden, to guarantee that equal instances of
this class guarantee to produce equal hashcodes.
return ( mString.length() * 2 + 1 );
|
public boolean | isIndexed()A method to determine whether this Name represents an Indexed Name. An
Indexed name represents a collection of other Names. Each indexed
Name can refer to other Names using different values for the index.
An example of an Indexed Name is a.b.c[10].
Note that a.b[0].c is not an Indexed Name.
An Indexed Name is different than Name of an Attribute that has multiple
values. e.g. a.b.c can have 3 values, none of which can be independently
referred to as e.g. a.b.c[1].
boolean indexed = false;
/* It is already made sure that the length will be greater than zero */
if(mString.charAt(mString.length() - 1) == Tokens.kSubScriptEnderChar)
{
indexed = true;
}
return ( indexed );
|
public java.lang.String | toString()Returns a string that represents this name. Guarantees to return
non null String.
return ( mString );
|