Package ru.ispras.fortress.expression
Class Node
- java.lang.Object
-
- ru.ispras.fortress.expression.Node
-
- Direct Known Subclasses:
NodeBinding
,NodeOperation
,NodeValue
,NodeVariable
public abstract class Node extends java.lang.Object
TheNode
class is a base class for all kinds of classes describing nodes in an expression tree. It includes declarations and implementations of methods common for all node kinds.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Node
deepCopy()
Creates a deep copy of the current objects.Node
deepestCopy()
Creates a deep copy of the current object referencing user data.abstract DataType
getDataType()
Returns an object that describes the type of the value referred by the node.DataTypeId
getDataTypeId()
Returns a data type identifier describing the type of the value referred by the node.Node.Kind
getKind()
Returns the identifier that specifies the kind of the node.java.lang.Object
getUserData()
Returns user data.boolean
isType(DataType type)
Checks whether the stored value has the specified type (types are compared on theDataType
level).boolean
isType(DataType... types)
Checks whether the expression has one of the specified types (types are compared on theDataType
level).boolean
isType(DataTypeId typeId)
Checks whether the expression has the specified type (types are compared on theDataTypeId
level).boolean
isType(DataTypeId... typeIds)
Checks whether the expression has one of the specified types (types are compared on theDataTypeId
level).void
setUserData(java.lang.Object obj)
Associates a user data object with the current node
-
-
-
Constructor Detail
-
Node
protected Node(Node.Kind kind)
Creates a node of the specified kind.- Parameters:
kind
- Node kind identifier.- Throws:
java.lang.IllegalArgumentException
- if the parameter equalsnull
.
-
Node
protected Node(Node node)
Constructor for making copies. The fields are copied by reference because the kind field is immutable and the userData field is of an unknown type (there is no way to know how to clone it).- Parameters:
node
- Node object to be copied.- Throws:
java.lang.IllegalArgumentException
- if the parameter equalsnull
.
-
-
Method Detail
-
deepestCopy
public Node deepestCopy()
Creates a deep copy of the current object referencing user data. All aggregated objects that are not readonly must be cloned.- Returns:
- Full copy of the current node object.
-
deepCopy
public abstract Node deepCopy()
Creates a deep copy of the current objects. All aggregated objects that are not readonly must be cloned. This excludes user data as its type is unknown.- Returns:
- Full copy of the current node object.
-
getKind
public final Node.Kind getKind()
Returns the identifier that specifies the kind of the node.- Returns:
- A node kind identifier.
-
getDataType
public abstract DataType getDataType()
Returns an object that describes the type of the value referred by the node.- Returns:
- A data type object.
-
getDataTypeId
public final DataTypeId getDataTypeId()
Returns a data type identifier describing the type of the value referred by the node.- Returns:
- Data type identifier.
-
isType
public final boolean isType(DataTypeId typeId)
Checks whether the expression has the specified type (types are compared on theDataTypeId
level).- Parameters:
typeId
-DataTypeId
object the data type is to be compared to.- Returns:
true
if the expression type matches the type specified by thetypeId
argument orfalse
otherwise.
-
isType
public final boolean isType(DataTypeId... typeIds)
Checks whether the expression has one of the specified types (types are compared on theDataTypeId
level).- Parameters:
typeIds
- List of type identifiers (DataTypeId
objects) the expression type is to be compared to.- Returns:
true
if the expression type matches one of the type identifiers specified by thetypeIds
argument orfalse
otherwise.- Throws:
java.lang.IllegalArgumentException
- if the type identifier collection is empty.
-
isType
public final boolean isType(DataType type)
Checks whether the stored value has the specified type (types are compared on theDataType
level).- Parameters:
type
-DataType
object the data type is to be compared to.- Returns:
true
if the expression type matches the type specified by thetype
argument orfalse
otherwise.
-
isType
public final boolean isType(DataType... types)
Checks whether the expression has one of the specified types (types are compared on theDataType
level).- Parameters:
types
- List of types (DataType
objects) the expression type is to be compared to.- Returns:
true
if the expression type matches one of the types specified by thetypes
argument orfalse
otherwise.- Throws:
java.lang.IllegalArgumentException
- if the type collection is empty.
-
setUserData
public final void setUserData(java.lang.Object obj)
Associates a user data object with the current node- Parameters:
obj
- User data object.
-
getUserData
public final java.lang.Object getUserData()
Returns user data.- Returns:
- User data object.
-
-