org.quasiliteral.astro
Class AstroTag

java.lang.Object
  |
  +--org.quasiliteral.astro.AstroTag
All Implemented Interfaces:
DeepPassByCopy, Marker, PassByConstruction, Persistent, Selfless, Serializable

public class AstroTag
extends Object
implements Persistent, DeepPassByCopy

Untamed:

See Also:
Serialized Form

Field Summary
private static StaticMaker AstroTagMaker
           
private  Class myOptDataType
           
private  short myOptTagCode
           
private  String myTagName
           
(package private) static long serialVersionUID
           
 
Fields inherited from interface org.erights.e.elib.serial.Persistent
HONORARY, HONORED_NAMES
 
Fields inherited from interface org.erights.e.elib.serial.DeepPassByCopy
HONORARY, HONORED_NAMES
 
Constructor Summary
AstroTag(short optTagCode, String tagName, Class optDataType)
          Enabled:
 
Method Summary
 double compareTo(AstroTag other)
          Enabled: Compare on tag names regardless of schema or tag codes
static StaticMaker getAstroTagMaker()
          Enabled:
 Class getOptDataType()
          Enabled: Indicates the type of data literally represented by this tag.
 short getOptTagCode()
          Enabled: The enumerated tag code, or -1.
 Object[] getSpreadUncall()
          Enabled: Uses 'AstroMaker(myOptTagCode, myTagName, myOptDataType)'
 String getTagName()
          Enabled: The interned name of the enumerated tag code.
 boolean isTagForData(Object optData)
          Enabled: Is this the tag implied by the type of optData?
static Astro optAttribute(Astro root, String rootName, String attrName)
          Enabled: Given that root is tagged with rootName, get its first argument that's tagged with attrName
static Astro optFirstAttribute(Astro root, String rootName, String attrName)
          Enabled: Like optAttribute/3, but only checks args[0].
static Object optPromoteData(Object optData)
          Enabled: If optData is a data that's promotable to data that's representable literally, then return that literally representable; otherwise null.
static Class optPromoteType(Class optDataType)
          Enabled: If optDataType is a class of data that's promotable to one that's representable literally, then return the class that represents that literally-representable data type; otherwise null.
static int tagCode2typeCode(short tagCode)
          Enabled: The type-code for use by Antlr, which is the tag-code +1.
 String toString()
          Suppressed:
static short typeCode2tagCode(int typeCode)
          Enabled:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID

AstroTagMaker

private static StaticMaker AstroTagMaker

myOptTagCode

private final short myOptTagCode

myTagName

private final String myTagName

myOptDataType

private final Class myOptDataType
Constructor Detail

AstroTag

public AstroTag(short optTagCode,
                String tagName,
                Class optDataType)
Enabled:

Parameters:
optTagCode - The enumerated tag code, or -1.
tagName - The name of the enumerated tag code.
optDataType - Either null, or the kind of data labeled by this tag.
Method Detail

getAstroTagMaker

public static StaticMaker getAstroTagMaker()
Enabled:


tagCode2typeCode

public static int tagCode2typeCode(short tagCode)
Enabled: The type-code for use by Antlr, which is the tag-code +1.

If the tag-code is -1, the returned type code will be Token#INVALID_TYPE


typeCode2tagCode

public static short typeCode2tagCode(int typeCode)
Enabled:


optPromoteType

public static Class optPromoteType(Class optDataType)
Enabled: If optDataType is a class of data that's promotable to one that's representable literally, then return the class that represents that literally-representable data type; otherwise null.

Parameters:
optDataType - null or the data type of some data we with to promote to a literal representation.
Returns:
null, or one of the classes Character,

optPromoteData

public static Object optPromoteData(Object optData)
Enabled: If optData is a data that's promotable to data that's representable literally, then return that literally representable; otherwise null.

The obvious correctness criteria must hold between optPromoteData and optPromoteType. If p := optPromoteData(d), then

     p.getClass() == optPromoteType(d.getClass())
 

Parameters:
optData - null or some data we with to promote to a literal representation.
Returns:
null, or a Character,

getSpreadUncall

public Object[] getSpreadUncall()
Enabled: Uses 'AstroMaker(myOptTagCode, myTagName, myOptDataType)'

Specified by:
getSpreadUncall in interface Selfless

toString

public String toString()
Suppressed:

Overrides:
toString in class Object
Returns:
a string representation of the object.

getOptTagCode

public short getOptTagCode()
Enabled: The enumerated tag code, or -1.


getTagName

public String getTagName()
Enabled: The interned name of the enumerated tag code.


getOptDataType

public Class getOptDataType()
Enabled: Indicates the type of data literally represented by this tag.

If this tag is a normal symbolic tag, this is null. If it's a tag for a literal data type, this is the canonical class for that data type -- one of Character.class, BigInteger.class, Double.class, or Twine.class.


isTagForData

public boolean isTagForData(Object optData)
Enabled: Is this the tag implied by the type of optData?

If optData is null, the answer is true.


compareTo

public double compareTo(AstroTag other)
Enabled: Compare on tag names regardless of schema or tag codes


optAttribute

public static Astro optAttribute(Astro root,
                                 String rootName,
                                 String attrName)
Enabled: Given that root is tagged with rootName, get its first argument that's tagged with attrName


optFirstAttribute

public static Astro optFirstAttribute(Astro root,
                                      String rootName,
                                      String attrName)
Enabled: Like optAttribute/3, but only checks args[0].

If you know the arg you're looking for may only be first or absent, this is a nice little optimization. But it does make your format more position dependent, and therefore more brittle.



comments?