astcentric.structure.basic.id
Class ID

java.lang.Object
  extended by astcentric.structure.basic.id.ID

public final class ID
extends java.lang.Object

Immutable class for an interAST ID. The first part is an ASTID and the second part is an InternalID. Two instances are equal if both AST IDs and internal IDs are equal.


Constructor Summary
ID(ASTID astID, InternalID internalID)
          Creates a new instance with the specified IDs.
 
Method Summary
static ID create(ASTID astID, AliasASTIDMapping mapping, java.lang.String stringRepresentation)
          Creates a new ID based on the string representation created by the toString() method.
static int createAliasASTID(java.lang.String stringRepresentationOfAliasID)
          Creates an alias AST ID from its string representation.
static java.lang.String createStringRepresentationOfAliasASTID(int aliasID)
          Returns the string representation of the specified alias AST ID.
 boolean equals(java.lang.Object obj)
           
 ASTID getAstID()
           
 InternalID getInternalID()
           
 int hashCode()
           
 java.lang.String toString()
          Returns a string representation suitable for recreating a new instance which is equal to this one.
 java.lang.String toString(ASTID astID, AliasASTIDMapping mapping)
          Returns a compact string representation suitable for recreating a new instance which is equal to this one if the mappings compatible.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ID

public ID(ASTID astID,
          InternalID internalID)
Creates a new instance with the specified IDs.

Throws:
java.lang.IllegalArgumentException - if one of the arguments is null.
Method Detail

create

public static ID create(ASTID astID,
                        AliasASTIDMapping mapping,
                        java.lang.String stringRepresentation)
Creates a new ID based on the string representation created by the toString() method. That is, for any instance id of ID the following expressions are always true:
 id.equals(ID.create(null, id.toString())
 id.equals(ID.create(astID, id.toString(astID))
If the AST ID part is missed in the string representation the specified AST ID will be used.

Parameters:
astID - AST ID used in cases where only the internal ID is present. Can be null if stringRepresentation has an AST ID part.
mapping - Mapping for alias AST IDs to real AST IDs. Can be null
stringRepresentation - A non-null string representation.
Throws:
java.lang.IllegalArgumentException - in case of an invalid argument.

createAliasASTID

public static int createAliasASTID(java.lang.String stringRepresentationOfAliasID)
Creates an alias AST ID from its string representation.

Throws:
java.lang.IllegalArgumentException - if the argument is not valid.

createStringRepresentationOfAliasASTID

public static java.lang.String createStringRepresentationOfAliasASTID(int aliasID)
Returns the string representation of the specified alias AST ID.


getAstID

public ASTID getAstID()

getInternalID

public InternalID getInternalID()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation suitable for recreating a new instance which is equal to this one. The returned value has the following form:
<AST ID>~<internal ID>
where <AST ID> and <internal ID> are the string representations created by ASTID.toString() and InternalID.toString(), respectively.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(ASTID astID,
                                 AliasASTIDMapping mapping)
Returns a compact string representation suitable for recreating a new instance which is equal to this one if the mappings compatible.