spki
Class Name

java.lang.Object
  |
  +--spki.BaseObj
        |
        +--spki.Name
Direct Known Subclasses:
FQName, RelativeName

public abstract class Name
extends BaseObj

SPKI Name abstract class.

Version:
$Id: Name.java,v 1.16 2002/07/07 17:02:53 tep Exp $
Author:
Tep Narula <tep@win.trlabs.ca>, adapted from SPKI.SPKIName by Per Harald Myrvang <perm@pasta.cs.uit.no>
See Also:
FQName, LocalName, RelativeName

Field Summary
private static String __ME
          This class's full name.
private  boolean dirty
          Do we need to re-build the SExpression?
private  boolean isFQName
          Is this a fully-qualified name? true if principal is not null.
private  boolean isLocalName
          Is this a local name? true if this is a fully-qualified name with one-level name.
private  boolean isRelativeName
          Is this a relative name? true if principal is null and the name is onle-level deep.
private  Vector names
          The list of names.
private  Principal principal
          The principal anchoring this name, may be null.
static String SEXP_NAME
          This class S-Expression type name, used by toSExpression() and other methods.
 
Fields inherited from class spki.BaseObj
__ME, cache_sexp, cached_sexp, DEFAULT_HASH_ALG, locked, SEXP_NAME
 
Constructor Summary
protected Name()
          Don't use me.
protected Name(SExpression sexp)
          Create an immutable Name object from an S-Expression.
 
Method Summary
(package private)  void addName(byte[] name)
          Add a name byte array.
(package private)  void addName(Sexp name)
          Add a name Sexp.
(package private)  void addName(String name)
          Add a name String.
static Name getInstance(SExpression sexp)
          Get an instance of a Name from given S-Expression.
 Sexp getName(int index)
          Get a name with specified index.
 int getNameDepth()
          Get the number of level of names in this object.
 Principal getPrincipal()
          Get the principal anchoring this object, if available.
 boolean isFQName()
          Is this a fully-qualified name?
 boolean isLocalName()
          Is this a local name?
 boolean isRelativeName()
          Is this a relative name?
(package private)  void setPrincipal(Principal principal)
          Set the principal anchoring this object.
 SExpression toSExpression()
          Build an SExpression representing this object, with the hash principal anchoring the name, if available.
(package private)  void verify()
           
 
Methods inherited from class spki.BaseObj
disableSExpressionCaching, enableSExpressionCaching, extractHashAlgId, getCachedSExpression, isLocked, isSListOfType, lock, providerToSPKI, setCachedSExpression, spkiToProvider, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

__ME

private static final String __ME
This class's full name.

SEXP_NAME

public static final String SEXP_NAME
This class S-Expression type name, used by toSExpression() and other methods.
See Also:
toSExpression()

principal

private Principal principal
The principal anchoring this name, may be null.

names

private Vector names
The list of names.

isFQName

private boolean isFQName
Is this a fully-qualified name? true if principal is not null.
See Also:
principal, FQName

isLocalName

private boolean isLocalName
Is this a local name? true if this is a fully-qualified name with one-level name.
See Also:
isFQName, LocalName

isRelativeName

private boolean isRelativeName
Is this a relative name? true if principal is null and the name is onle-level deep.
See Also:
principal, RelativeName

dirty

private boolean dirty
Do we need to re-build the SExpression?
See Also:
addName(Sexp), addName(String), addName(byte[]), toSExpression()
Constructor Detail

Name

protected Name()
Don't use me. To be called by each subclass' equivalent constructor.
See Also:
Name(SExpression)

Name

protected Name(SExpression sexp)
        throws SPKIException,
               ParseException
Create an immutable Name object from an S-Expression.
See Also:
BaseObj.BaseObj(SExpression)
Method Detail

toSExpression

public SExpression toSExpression()
                          throws SPKIException
Build an SExpression representing this object, with the hash principal anchoring the name, if available.
Overrides:
toSExpression in class BaseObj
See Also:
principal, BaseObj.toSExpression()

isFQName

public boolean isFQName()
Is this a fully-qualified name?
Returns:
true if this object contains a fully-qualified name.

isLocalName

public boolean isLocalName()
Is this a local name?
Returns:
true if this object contains a local name.

isRelativeName

public boolean isRelativeName()
Is this a relative name?
Returns:
true if this object contains a relative name.

getPrincipal

public Principal getPrincipal()
Get the principal anchoring this object, if available.
Returns:
Principal object, or null.

getNameDepth

public int getNameDepth()
Get the number of level of names in this object.
Returns:
number of names in this object.

getName

public Sexp getName(int index)
             throws SPKIException
Get a name with specified index.
Parameters:
index - index of the name required.
Returns:
A copy of the name Sexp object at specified index, or null if such object doesn't exist.

getInstance

public static final Name getInstance(SExpression sexp)
                              throws SPKIException,
                                     ParseException
Get an instance of a Name from given S-Expression.
Parameters:
sexp - SExpression containing a Name.
Returns:
An instance of Name.
Throws:
ParseException - if the argument doesn't contain a Name.
SPKIException - if something went wrong.
See Also:
FQName, LocalName, RelativeName

verify

void verify()
      throws SPKIException

setPrincipal

void setPrincipal(Principal principal)
            throws IllegalStateException,
                   SPKIException
Set the principal anchoring this object.
Parameters:
principal - a Principal object anchoring this name, maybe null.
Throws:
IllegalStateException - if the object is immutable.
SPKIException - if something went wrong.

addName

void addName(Sexp name)
       throws IllegalStateException,
              SPKIException
Add a name Sexp.
Parameters:
name - a byte-string (Sexp) object containing a name.
Throws:
IllegalStateException - if the object is immutable.
SPKIException - if something went wrong.

addName

void addName(String name)
       throws IllegalStateException,
              SPKIException
Add a name String. It's simply a front-end to the add(Sexp) method.
Parameters:
name - String containing a name.
Throws:
IllegalStateException - if the object is immutable.
SPKIException - if something went wrong.
See Also:
addName(Sexp)

addName

void addName(byte[] name)
       throws IllegalStateException,
              SPKIException
Add a name byte array. It's simply a front-end to the add(Sexp) method.
Parameters:
name - byte-array containing a name.
Throws:
IllegalStateException - if the object is immutable.
SPKIException - if something went wrong.
See Also:
addName(Sexp)