cgp.runtime
Class StringType

java.lang.Object
  |
  +--cgp.runtime.Type
        |
        +--cgp.runtime.StringType

public class StringType
extends Type


Field Summary
private  java.lang.String value
           
 
Fields inherited from class cgp.runtime.Type
kbStack, scopeStack, type
 
Constructor Summary
StringType(java.lang.String s)
           
 
Method Summary
 Type addOp(Type other)
          Concatenation of this string to any other object to form a new string.
 Type eqOp(Type other)
           
 boolean equals(java.lang.Object other)
           
 Type geOp(Type other)
           
 NumberType getLength()
          Getter and setter methods for pCG attributes.
 java.lang.String getValue()
           
 Type gtOp(Type other)
           
 NumberType index(StringType s)
          Returns the index (>= 1) of the first occurrence of s in this string, or -1 if it is not found.
 Type leOp(Type other)
           
 Type ltOp(Type other)
           
 Type neOp(Type other)
           
 StringType replace(StringType s, StringType t)
          Replace all occurrences of the single-character string s with the single-character string t in this string.
 Type substring(NumberType start)
          Returns a substring of this string from start to the end of the string, where start is >= 1.
 Type substring(NumberType start, NumberType end)
          Returns a substring of this string where start and end are >= 1 and <= length of string.
 BooleanType toBoolean()
           
 GraphType toGraph()
           
 Type toNumber()
           
 java.lang.String toString()
           
 
Methods inherited from class cgp.runtime.Type
andOp, divideOp, getAttr, getKBStack, getNthOp, getScopeStack, getType, invokeMemberFunc, isOp, modulusOp, multiplyOp, negateOp, notOp, operationError, orOp, setAttr, setKBStack, setNthOp, setScopeStack, setType, subtractOp
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

value

private java.lang.String value
Constructor Detail

StringType

public StringType(java.lang.String s)
Method Detail

getValue

public java.lang.String getValue()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

gtOp

public Type gtOp(Type other)
Overrides:
gtOp in class Type

ltOp

public Type ltOp(Type other)
Overrides:
ltOp in class Type

geOp

public Type geOp(Type other)
Overrides:
geOp in class Type

leOp

public Type leOp(Type other)
Overrides:
leOp in class Type

eqOp

public Type eqOp(Type other)
Overrides:
eqOp in class Type

neOp

public Type neOp(Type other)
Overrides:
neOp in class Type

addOp

public Type addOp(Type other)
Concatenation of this string to any other object to form a new string. This handles the case where in the expression x + y, x is a string and y is any type.
Overrides:
addOp in class Type

getLength

public NumberType getLength()
Getter and setter methods for pCG attributes.

substring

public Type substring(NumberType start,
                      NumberType end)
Returns a substring of this string where start and end are >= 1 and <= length of string. When indices are out of bounds, the returned value is undefined.

substring

public Type substring(NumberType start)
Returns a substring of this string from start to the end of the string, where start is >= 1. When indices are out of bounds, the returned value is undefined.

index

public NumberType index(StringType s)
Returns the index (>= 1) of the first occurrence of s in this string, or -1 if it is not found.

replace

public StringType replace(StringType s,
                          StringType t)
Replace all occurrences of the single-character string s with the single-character string t in this string. Any error leaves the string unchanged.

toBoolean

public BooleanType toBoolean()

toNumber

public Type toNumber()

toGraph

public GraphType toGraph()