public class Variable extends java.util.AbstractList<Variable> implements java.lang.Comparable<Variable>, java.lang.Cloneable, java.lang.CharSequence
Constructor and Description |
---|
Variable(java.lang.String name)
Construct Variable Object.
|
Variable(java.lang.String name,
java.lang.String type,
java.lang.Object value)
Construct Variable Object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(Variable e)
Appends the specified element to the end of this list.
|
char |
charAt(int index)
Convert variable into String and returns the
char value at the specified index. |
java.lang.Object |
clone()
Creates and returns a copy of this object.
|
int |
compareTo(Variable o)
Compares this object with the specified object for order.
|
boolean |
contains(java.lang.String name)
Returns
true if this variable contains the specified child variable. |
boolean |
contains(Variable var)
Returns
true if this variable contains the specified child variable. |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one or equals to its value.
|
Variable |
get(int index)
Returns the child variable at the specified position in this list.
|
Variable |
get(java.lang.String name)
Returns the child variable referred to by this name.
|
Variable |
getFirstChild()
Return the first child of this variable.
|
Variable |
getLastChild()
Return the last child of this variable.
|
java.lang.String |
getName()
Get name of variable object.
|
Variable |
getParent()
Get parent variable.
|
java.lang.String |
getType()
Return the type of the value.
|
java.lang.Object |
getValue()
Return a value object.
|
int |
hashCode()
Returns a hash code value for the object.
|
int |
indexOf(java.lang.String name)
Returns the index of the first occurrence of the specified child variable in this variable, or -1 if this
variable does not contain the child variable.
|
int |
indexOf(Variable var)
Returns the index of the first occurrence of the specified child variable in this variable, or -1 if this
variable does not contain the child variable.
|
boolean |
isEmpty()
Returns
true if this list contains no child variable. |
int |
length()
Convert variable into String and returns the length of this character sequence.
|
void |
setName(java.lang.String name)
Set name of variable.
|
void |
setType(java.lang.String type)
Set a type.
|
void |
setValue(java.lang.Object value)
Set the value of Variable.
|
int |
size()
Returns the number of child variable in this variable.
|
java.lang.CharSequence |
subSequence(int start,
int end)
Convert variable into String and returns a new
CharSequence that is a subsequence of this
sequence. |
java.lang.String |
toString()
Returns a string representation of this variable.
|
add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray
finalize, getClass, notify, notifyAll, wait, wait, wait
public Variable(java.lang.String name)
name
- name of variable objectpublic Variable(java.lang.String name, java.lang.String type, java.lang.Object value)
name
- name of variable objecttype
- type of variable objectvalue
- value of variable objectpublic void setName(java.lang.String name)
name
- namepublic java.lang.String getName()
public void setValue(java.lang.Object value)
value
- a valuepublic java.lang.Object getValue()
public java.lang.String getType()
public void setType(java.lang.String type)
type
- the type to setpublic Variable getParent()
public Variable get(int index)
get
in interface java.util.List<Variable>
get
in class java.util.AbstractList<Variable>
index
- index of variable to return.java.lang.IndexOutOfBoundsException
- if the given index is out of range.public Variable get(java.lang.String name)
name
- the name of the variablepublic Variable getFirstChild()
null
.public Variable getLastChild()
null
.public boolean add(Variable e)
public boolean contains(Variable var)
true
if this variable contains the specified child variable.var
- variable whose presence in this variable is to be testedtrue
if this variable contains the specified child variablepublic boolean contains(java.lang.String name)
true
if this variable contains the specified child variable.name
- variable name whose presence in this variable is to be testedtrue
if this variable contains the specified child variable namepublic int indexOf(Variable var)
var
- variable to search forpublic int indexOf(java.lang.String name)
name
- variable name to search forpublic int size()
public boolean isEmpty()
true
if this list contains no child variable.public int compareTo(Variable o)
compareTo
in interface java.lang.Comparable<Variable>
o
- the Object to be compared.public int hashCode()
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Collection<Variable>
equals
in interface java.util.List<Variable>
equals
in class java.util.AbstractList<Variable>
obj
- the reference object with which to compare.true
if this object is the same as the obj argument; false
otherwise.public java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.util.AbstractCollection<Variable>
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if the object's class does not support the Cloneable
interface. Subclasses that override the clone
method can also throw this
exception to indicate that an instance cannot be cloned.Cloneable
public char charAt(int index)
char
value at the specified index. An index ranges
from zero to length() - 1.charAt
in interface java.lang.CharSequence
index
- the index of the char
value to be returnedchar
valuejava.lang.IndexOutOfBoundsException
- if the index argument is negative or not less than
length()public int length()
char
s in the sequence.length
in interface java.lang.CharSequence
char
s in this sequencepublic java.lang.CharSequence subSequence(int start, int end)
CharSequence
that is a subsequence of this
sequence. The subsequence starts with the char
value at the specified index and ends with the
char
value at index end - 1. The length (in char
s) of the returned
sequence is end - start, so if start == end then an empty sequence is returned.subSequence
in interface java.lang.CharSequence
start
- the start index, inclusiveend
- the end index, exclusivejava.lang.IndexOutOfBoundsException
- if start or end are negative, if end is greater
than length(), or if start is greater than end