se.sics.prologbeans
Class PBString
java.lang.Object
|
+--se.sics.prologbeans.Term
|
+--se.sics.prologbeans.PBCompound
|
+--se.sics.prologbeans.PBList
|
+--se.sics.prologbeans.PBString
- public class PBString
- extends PBList
PBString
is the Java representation of Prolog strings
(e.g. lists of integers that are interpretable as characters).
Fields inherited from class se.sics.prologbeans.Term |
name |
Method Summary |
Term |
getArgument(int index)
Returns the first or second argument of this list node. |
int |
getArity()
Returns the number of arguments of this compound term or 0 if this
term is not a compound term. |
char |
getCharAt(int index)
Returns the character at the specified index in this
string. |
int |
getLength()
Returns the number of characters in this string. |
java.lang.String |
getString()
Returns the string value of this term. |
Term |
getTermAt(int index)
Returns the element at the specified index in this list. |
boolean |
isString()
Returns true if this term is an instance
of PBString (which can be used for fast string access) and
false otherwise. |
java.lang.String |
toString()
Returns a string description of this term. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
isString
public boolean isString()
- Description copied from class:
Term
- Returns
true
if this term is an instance
of PBString
(which can be used for fast string access) and
false
otherwise.
- Overrides:
isString
in class Term
getArgument
public Term getArgument(int index)
- Returns the first or second argument of this list node. Only
non-empty lists have arguments. Note: the arguments are indexed
from 1 to 2.
Due to performance reasons this should be avoided if not 100%
necessary. Please use getCharAt(int index)
or
getString() for accessing the value of strings.
- Overrides:
getArgument
in class PBList
- Parameters:
index
- the (one based) index of the argument- Returns:
- the argument as a Term
- Throws:
java.lang.IllegalStateException
- if this term is not compound
getArity
public int getArity()
- Description copied from class:
Term
- Returns the number of arguments of this compound term or 0 if this
term is not a compound term.
- Overrides:
getArity
in class PBList
getString
public java.lang.String getString()
- Returns the string value of this term.
getLength
public int getLength()
- Returns the number of characters in this string.
- Overrides:
getLength
in class PBList
getTermAt
public Term getTermAt(int index)
- Returns the element at the specified index in this list. Note:
the elements are indexed from 1 to length.
Due to performance reasons this should be avoided if not 100%
necessary. Please use getCharAt(int index)
or
getString() for accessing the value of strings.
- Overrides:
getTermAt
in class PBList
- Parameters:
index
- the (one based) index of the element in this list- Returns:
- the element as a Term
- See Also:
getLength()
,
getCharAt(int)
,
getString()
getCharAt
public char getCharAt(int index)
- Returns the character at the specified index in this
string. Note: characters are indexed from 1 to length
- Parameters:
index
- the (one based) index of the character in this string- Returns:
- the character
- See Also:
getLength()
toString
public java.lang.String toString()
- Description copied from class:
Term
- Returns a string description of this term.
- Overrides:
toString
in class PBList