org.jtool.jxplatform.wrapper
Class JxVariable

java.lang.Object
  extended byorg.jtool.jxplatform.wrapper.JxElement
      extended byorg.jtool.jxplatform.wrapper.JxDefUseExpression
          extended byorg.jtool.jxplatform.wrapper.JxExpression
              extended byorg.jtool.jxplatform.wrapper.JxVariable
Direct Known Subclasses:
JxFieldAccess, JxSpecialVariable

public class JxVariable
extends JxExpression

An object wrapping the Expr elment with the sort="VarRef" attribute.

Author:
Katsuhisa Maruyama

Field Summary
protected  java.lang.String binding
          The binding information about this variable or field access.
protected  org.w3c.dom.Element declaration
          The declaration's element referenced by this varaible.
protected  java.lang.String defid
          The identifier string of the declaration's element referenced by this variable.
protected static int FIELD
          The constant indicating that this varaible is a field variable.
protected  java.lang.String fqn
          The fully-qualified type of this variable.
protected static int LOCAL
          The constant indicating that this varaible is a local varaible.
protected  java.lang.String name
          The name of this variable.
protected static int PARAMETER
          The constant indicating that this varaible is a parameter.
protected  int sort
          The sort of this variable.
 
Fields inherited from class org.jtool.jxplatform.wrapper.JxDefUseExpression
defs, expressions, uses
 
Fields inherited from class org.jtool.jxplatform.wrapper.JxElement
element
 
Constructor Summary
protected JxVariable()
          Creates a new, empty object.
protected JxVariable(org.w3c.dom.Element elem)
          Creates a new object wrapping a Expr element with the sort="VarRef" or sort="FieldRef" attribute.
protected JxVariable(org.w3c.dom.Element elem, org.w3c.dom.Element decl)
          Creates a new object wrapping a Expr element with the sort="VarRef" or sort="FieldRef" attribute.
 
Method Summary
 boolean equals(JxVariable jvar)
          Tests if a given variable wrapper equals to this one.
 java.lang.String getBindingName()
          Returns the binding string of this variable.
 org.w3c.dom.Element getDeclaration()
          Returns the declaration element for the referenced variable.
 java.lang.String getDefId()
          Returns the identifier of the referenced variable (not the identifier of the variable reference).
 java.lang.String getFqn()
          Returns the fully-qualified name of this variable.
 java.lang.String getName()
          Returns the name of the referenced variable.
 org.w3c.dom.Element getStatementElement()
          Obtains an element of a statement enclosing this variable.
 java.lang.String getTypeFqn()
          Returns the fully-qualified name of this variable or casted type.
 boolean isDeclarationVariable()
          Tests if this varibale is a variable declaration.
 boolean isDefinedVariable()
          Tests if this variable is defined.
 boolean isField()
          Tests if this element is a field variable.
 boolean isLocal()
          Tests if this element is a local variable.
 boolean isNonDefUseVariable()
          Tests if this variable is neither defined nor used.
 boolean isParameter()
          Tests if this element is a parameter.
 boolean isUsedVariable()
          Tests if this variable is used.
static boolean isVariable(org.w3c.dom.Element elem)
          Tests if a given element equals to Expr with sort="VarRef" or sort="FieldRef".
 void print()
          Displays information about this variable wrapper for debugging.
 
Methods inherited from class org.jtool.jxplatform.wrapper.JxExpression
equals, getCastedTypeFqn, getCastedTypeName, getDotPrefix, getJavaStatement, getSort, isArrayCreation, isAssign, isConstructorCall, isDotOperator, isExpression, isFieldAccess, isInSimpleAssignment, isInstanceCreation, isMethodCall, isOpAssign, isParenthesis, isPostAssignment, isPostDecrement, isPostIncrement, isPreAssignment, isPreDecrement, isPreIncement, isSuperConstructorCall, isSuperReference, isThisConstructorCall, isThisReference, isVariableAccess
 
Methods inherited from class org.jtool.jxplatform.wrapper.JxDefUseExpression
addDefinedVariable, addDefinedVariableFirst, addUsedVariable, addUsedVariableFirst, clearDefinedVariable, clearUsedVariable, definesVariable, getDefinedVariables, getExpressions, getUsedVariables, removeDefinedVariable, removeUsedVariable, usesVariable
 
Methods inherited from class org.jtool.jxplatform.wrapper.JxElement
equals, existInTheSameClass, existInTheSameField, existInTheSameFile, existInTheSameMethod, existsInTheSameClass, existsInTheSameFile, existsInTheSameMethod, existsInTheSamePackage, getArrayOfElements, getChildElement, getChildElement, getChildElements, getChildElements, getChildNodes, getChildNodes, getClassElement, getDescendantElements, getDescendantElements, getDescendantElements, getDescendantElements, getElement, getElementById, getExpressionElements, getFieldElement, getFileElement, getFirstChildElement, getFirstChildElement, getId, getId, getIdentName, getIdentName, getJxClass, getJxField, getJxFile, getJxMethod, getJxStaticInit, getKeyword, getLine, getMethodElement, getStaticInitElement, getTypeElement, getTypeElements, getTypeName, indexOf, indexOf, isBinary, isClass, isClassOrInterface, isConstructor, isExpression, isFile, isImport, isInterface, isInTheSameField, isMethod, isMethodOrConstructor, isPackage, isStatement, isStaticInit, isTerminalElement, isType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The name of this variable.


fqn

protected java.lang.String fqn
The fully-qualified type of this variable.


defid

protected java.lang.String defid
The identifier string of the declaration's element referenced by this variable.


binding

protected java.lang.String binding
The binding information about this variable or field access.


declaration

protected org.w3c.dom.Element declaration
The declaration's element referenced by this varaible.


sort

protected int sort
The sort of this variable.


FIELD

protected static final int FIELD
The constant indicating that this varaible is a field variable.

See Also:
Constant Field Values

LOCAL

protected static final int LOCAL
The constant indicating that this varaible is a local varaible.

See Also:
Constant Field Values

PARAMETER

protected static final int PARAMETER
The constant indicating that this varaible is a parameter.

See Also:
Constant Field Values
Constructor Detail

JxVariable

protected JxVariable()
Creates a new, empty object.


JxVariable

protected JxVariable(org.w3c.dom.Element elem,
                     org.w3c.dom.Element decl)
              throws JxWrapperException
Creates a new object wrapping a Expr element with the sort="VarRef" or sort="FieldRef" attribute.

Parameters:
elem - A DOM element to be wrapped.
decl - The declaration's element referenced by this varaible. The kind of this variable is undecided if this parameter is null.
Throws:
JxWrapperException - if the specified element is not valid.

JxVariable

protected JxVariable(org.w3c.dom.Element elem)
              throws JxWrapperException
Creates a new object wrapping a Expr element with the sort="VarRef" or sort="FieldRef" attribute.

Parameters:
elem - A DOM element to be wrapped.
Throws:
JxWrapperException - if the specified element is not valid.
Method Detail

getName

public java.lang.String getName()
Returns the name of the referenced variable.

Overrides:
getName in class JxExpression
Returns:
The name string of the referenced variable.

getFqn

public java.lang.String getFqn()
Returns the fully-qualified name of this variable.

Returns:
The fully-qualified name string.

getTypeFqn

public java.lang.String getTypeFqn()
Returns the fully-qualified name of this variable or casted type.

Overrides:
getTypeFqn in class JxExpression
Returns:
The fully-qualified name ot casted string.

getDefId

public java.lang.String getDefId()
Returns the identifier of the referenced variable (not the identifier of the variable reference).

Returns:
The identifier of the referenced variable.

getBindingName

public java.lang.String getBindingName()
Returns the binding string of this variable.

Returns:
The name string of the referenced method.

getDeclaration

public org.w3c.dom.Element getDeclaration()
Returns the declaration element for the referenced variable.

Returns:
The declaration element Local or Param.

isVariable

public static boolean isVariable(org.w3c.dom.Element elem)
Tests if a given element equals to Expr with sort="VarRef" or sort="FieldRef".

Parameters:
elem - An element of the DOM.
Returns:
true if the element equals to a variable, otherwise false.

isField

public boolean isField()
Tests if this element is a field variable.

Overrides:
isField in class JxElement
Returns:
true if this element is a field.

isLocal

public boolean isLocal()
Tests if this element is a local variable.

Overrides:
isLocal in class JxElement
Returns:
true if this element is a local variable.

isParameter

public boolean isParameter()
Tests if this element is a parameter.

Overrides:
isParameter in class JxElement
Returns:
true if this element is a parameter.

isDefinedVariable

public boolean isDefinedVariable()
Tests if this variable is defined.

Returns:
true if this variable is defined in a statement.

isUsedVariable

public boolean isUsedVariable()
Tests if this variable is used.

Returns:
true if this variable is used in a statement.

isNonDefUseVariable

public boolean isNonDefUseVariable()
Tests if this variable is neither defined nor used.

Returns:
true if this variable is neither defined nor used in a statement.

equals

public boolean equals(JxVariable jvar)
Tests if a given variable wrapper equals to this one.

Parameters:
jvar - A variable wrapper.
Returns:
true if the variable wrapper equals to this one, otherwise false. Returns false although the declaration of two variable wrappers is the same.

isDeclarationVariable

public boolean isDeclarationVariable()
Tests if this varibale is a variable declaration.

Returns:
true if this variable is a variable declaration.

getStatementElement

public org.w3c.dom.Element getStatementElement()
Obtains an element of a statement enclosing this variable.

Overrides:
getStatementElement in class JxElement
Returns:
The element of a statement enclosing this variable.

print

public void print()
Displays information about this variable wrapper for debugging.

Overrides:
print in class JxExpression