edu.stanford.rt.credential
Class DomainSpecification

java.lang.Object
  |
  +--edu.stanford.rt.credential.DomainSpecification
Direct Known Subclasses:
ApplicationDomain, CredentialDomain

public class DomainSpecification
extends java.lang.Object

Author:
Ninghui Li, Sandra Qiu
This class stores the common information about an ApplicationDomain or a CredentialDomain. The info includes the following: principal type, imported application domains, type declarations, role declarations, hash id, RTML context, and the parsing status.

Field Summary
private  boolean completeState
          A flag indicates the parsing status of the domain.
private  RTContext context
          RTML Context
private  HashID hashID
          The hash value of the domain.
private  OrderedMap importedDomains
          Stores all imported domains in this domain, mapping string (domain name) to ApplicationDomain object.
private  SimpleType principalType
          Principal type
private  OrderedMap roleDeclarations
          Stores all role declarations in this domain, mapping string(role name) to role declaration object.
private  OrderedMap typeDeclarations
          Stores all type decalarations in this domain, mapping string(type name) to type declaration object.
 
Constructor Summary
(package private) DomainSpecification(RTContext context)
          Constuctor for DomainSpecification.
 
Method Summary
 void addRole(RoleDeclaration role)
          Method addRole.
 void addType(DataType type)
          Method addType.
 void addType(java.lang.String typeName)
          Method addType.
 RTContext getContext()
          Method getContext.
 HashID getHashID()
          Returns the hashID.
 OrderedMap getImportedDomains()
          Method getImportedDomains.
 SimpleType getPrincipalType()
          Method getPrincipalType.
 OrderedMap getRoleDeclarations()
          Method getRoleDeclarations.
 OrderedMap getTypeDeclarations()
          Method getTypeDeclarations.
 void importDomain(java.lang.String name, ApplicationDomain spec)
          Method importDomain.
 boolean isComplete()
          Method isComplete.
 DomainSpecification lookupImportedDomain(java.lang.String domainRef)
          Method lookupImportedDomain.
 RoleDeclaration lookupRoleDeclaration(java.lang.String roleName)
          Method lookupRoleDeclaration.
 RoleDeclaration lookupRoleDeclaration(java.lang.String domainRef, java.lang.String roleName)
          Method lookupRoleDeclaration.
 DataType lookupType(java.lang.String typeName)
          Method lookupType.
 DataType lookupType(java.lang.String domainRef, java.lang.String typeName)
          Method lookupType.
private  boolean roleExistsInSystemDomain(java.lang.String roleName)
          Method roleExistsInSystemDomain.
 void setComplete()
          Method setComplete.
 void setHashID(HashID hashID)
          Sets the hashID.
 void setPrincipalType(SimpleType prinType)
          Method setPrincipalType.
private  boolean typeExistsInSystemDomain(java.lang.String typeName)
          Method typeExistsInSystemDomain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

principalType

private SimpleType principalType
Principal type


importedDomains

private OrderedMap importedDomains
Stores all imported domains in this domain, mapping string (domain name) to ApplicationDomain object.


typeDeclarations

private OrderedMap typeDeclarations
Stores all type decalarations in this domain, mapping string(type name) to type declaration object.


roleDeclarations

private OrderedMap roleDeclarations
Stores all role declarations in this domain, mapping string(role name) to role declaration object.


completeState

private boolean completeState
A flag indicates the parsing status of the domain.


hashID

private HashID hashID
The hash value of the domain.


context

private RTContext context
RTML Context

Constructor Detail

DomainSpecification

DomainSpecification(RTContext context)
              throws DomainSpecException
Constuctor for DomainSpecification. Contructs a DomainSpecification object with the specific uri. Include System DomainSpecification for non-system DomainSpecification object.

Parameters:
context -
Throws:
DomainSpecException
Method Detail

importDomain

public void importDomain(java.lang.String name,
                         ApplicationDomain spec)
                  throws DomainSpecException
Method importDomain. Add a newly imported domain map.

Parameters:
name - the short name to refer to spec with the domain.
spec -
Throws:
DomainSpecException

addType

public void addType(DataType type)
             throws DomainSpecException
Method addType. Add a new type declaration to the domain.

Parameters:
type -
Throws:
DomainSpecException - DomainSpecException when a duplicated type declaration, i.e. a type declaration with the same name and same data type, is added.

addType

public void addType(java.lang.String typeName)
             throws DomainSpecException
Method addType. Add XML built-in type.

Parameters:
typeName -
Throws:
DomainSpecException

addRole

public void addRole(RoleDeclaration role)
             throws DomainSpecException
Method addRole. Add a new role declaration to the domain.

Parameters:
role -
Throws:
DomainSpecException

setPrincipalType

public void setPrincipalType(SimpleType prinType)
                      throws DomainSpecException
Method setPrincipalType.

Parameters:
prinType -
Throws:
DomainSpecException

isComplete

public boolean isComplete()
Method isComplete. checks whether the parsing is completed.

Returns:
boolean

setComplete

public void setComplete()
Method setComplete. marks the parsing status as complete, so no modification is allowed for imported domains, type declarations , and role declarations maps.


lookupImportedDomain

public DomainSpecification lookupImportedDomain(java.lang.String domainRef)
                                         throws DomainSpecException
Method lookupImportedDomain. Lookup an imported domain by the given domainRef in the currnt domain.

Parameters:
domainRef -
Returns:
DomainSpecification
Throws:
DomainSpecException - if cannot find one

lookupType

public DataType lookupType(java.lang.String typeName)
                    throws DomainSpecException
Method lookupType. Look up the DataType declaration by given typeName in the current domain.

Parameters:
typeName -
Returns:
DataType returns null if cannot find one.
Throws:
DomainSpecException - if cannot find a DataType declaration by the given name.

lookupType

public DataType lookupType(java.lang.String domainRef,
                           java.lang.String typeName)
                    throws DomainSpecException
Method lookupType. Look up the DataType declaration by given typeName in the given domain.

Parameters:
domainRef - specifies which domain to look up in. If domainRef is null or an empty string, then look up in the current domain.
typeName -
Returns:
DataType
Throws:
DomainSpecException - if cannot find a DataType with given name.

lookupRoleDeclaration

public RoleDeclaration lookupRoleDeclaration(java.lang.String roleName)
                                      throws DomainSpecException
Method lookupRoleDeclaration. Look up the role declaration by given roleName in the current domain.

Parameters:
roleName -
Returns:
RoleDeclaration returns null if cannot find one.
Throws:
DomainSpecException - if cannot find one.

lookupRoleDeclaration

public RoleDeclaration lookupRoleDeclaration(java.lang.String domainRef,
                                             java.lang.String roleName)
                                      throws DomainSpecException
Method lookupRoleDeclaration. looks up a role declaration by given roleName in the given domain.

Parameters:
domainRef - specifies which domain to look up in. If domainRef is null or an empty string, then look up in the current domain.
roleName -
Returns:
RoleDeclaration
Throws:
DomainSpecException - if cannot find a one.

getContext

public RTContext getContext()
Method getContext.

Returns:
RTContext

getTypeDeclarations

public OrderedMap getTypeDeclarations()
                               throws DomainSpecException
Method getTypeDeclarations.

Returns:
OrderedMap
Throws:
DomainSpecException - when parsing is not completed.

getRoleDeclarations

public OrderedMap getRoleDeclarations()
                               throws DomainSpecException
Method getRoleDeclarations.

Returns:
OrderedMap
Throws:
DomainSpecException - when parsing is not completed.

getImportedDomains

public OrderedMap getImportedDomains()
                              throws DomainSpecException
Method getImportedDomains.

Returns:
OrderedMap
Throws:
DomainSpecException - when parsing is not completed.

getPrincipalType

public SimpleType getPrincipalType()
Method getPrincipalType.

Returns:
SimpleType

getHashID

public HashID getHashID()
Returns the hashID.

Returns:
ApplicationDomainHashID

setHashID

public void setHashID(HashID hashID)
               throws DomainSpecException
Sets the hashID.

Parameters:
hashID - The hashID to set
DomainSpecException

typeExistsInSystemDomain

private boolean typeExistsInSystemDomain(java.lang.String typeName)
Method typeExistsInSystemDomain. checks whether a DataType with given typeName is already declcared in system domain.

Parameters:
typeName -
Returns:
boolean

roleExistsInSystemDomain

private boolean roleExistsInSystemDomain(java.lang.String roleName)
Method roleExistsInSystemDomain. checks whether a RoleDeclaration with given roleName is already declcared in system domain.

Parameters:
roleName -
Returns:
boolean