org.jclarion.clarion
Class ClarionString

java.lang.Object
  extended by org.jclarion.clarion.ClarionMemoryModel
      extended by org.jclarion.clarion.ClarionObject
          extended by org.jclarion.clarion.ClarionString
All Implemented Interfaces:
Threaded
Direct Known Subclasses:
ClarionBlob

public class ClarionString
extends ClarionObject

Model a string in clarion Internal storage of string uses following parameters: lState.string - String lState.chararray - chararray lState.chararray_len - string len in char array lState.chararry is the accurate representation. and lState.string is non null when requested and chararray has not subsequently mutated it is possible for string to be defined by chararray not to be defined when first mutation is needed - chararray is retrieved from the string

Author:
barney

Nested Class Summary
static class ClarionString.State
           
 
Field Summary
static int ASTRING
           
static int CSTRING
           
static int PSTRING
           
static int STRING
           
 
Constructor Summary
ClarionString()
          Create undefined string
ClarionString(char[] content)
          Create string of given size defaulted to specified content.
ClarionString(ClarionString base, java.lang.Thread lock)
           
ClarionString(int size)
          Create empty string of specified size.
ClarionString(java.lang.String content)
          Create string of given size defaulted to specified content.
 
Method Summary
 ClarionObject add(ClarionObject object)
          Do a numeric add.
 ClarionString all()
          Return source string repeated upto 255 characters
 ClarionString all(int src)
          Return this string repeated upto src characters long
 int allowedSize()
           
 boolean boolValue()
          Return boolen representation of the object
static java.lang.String capitalize(java.lang.String input)
           
 ClarionString center()
          Return center justified string
 ClarionString center(int offset)
          Return center justified string
static ClarionString chr(int ascii)
          Convert ascii code into a string
 void clear(int method)
          Clear object value.
 ClarionString clip()
          return clipped string - trailing whitespace removed.
 int compareTo(ClarionObject object)
          Do a Comparison.
 java.lang.String concat(java.lang.Object... obj)
          Do string concatination
 void concatSegment(java.lang.StringBuilder target)
           
 ClarionString deformat(java.lang.String aFormat)
          Remove formatting characters from format For numeric - remove everything but numeric formatters For date, convert back to date format For time, convert back to time format For picture/key tokens return placeholder tokens
 void deserialize(java.io.InputStream is)
          Read object from memory as clarion would represent object in memory
 ClarionString[] dim(int size)
          return 1d array clone of the object based on size.
 ClarionString[][] dim(int s1, int s2)
          return 2d array clone of the object based on size.
 ClarionString[][][] dim(int s1, int s2, int s3)
          return 3d array clone of the object based on size.
 ClarionObject divide(ClarionObject object)
          Do a numeric divide.
 ClarionString format(java.lang.String aFormat)
          Format string as per specified picture formatter
 ClarionObject genericLike()
           
 ClarionBool getBool()
          Convert to bool object
static java.util.regex.Pattern getClarionRegEx(java.lang.String pattern, boolean ignoreCase)
           
static java.util.regex.Pattern getClarionWildCardEx(java.lang.String pattern, boolean ignoreCase)
           
 ClarionDecimal getDecimal()
          Convert to decimal object
 java.lang.Object getLockedObject(java.lang.Thread t)
           
 ClarionNumber getNumber()
          Convert to number object
 ClarionReal getReal()
          Convert to real object
 int getSize()
          Return max size of the object when represented as a string Used mainly by ASCII file driver
 ClarionString getString()
          Convert to string object
 void initThread()
           
 int inString(java.lang.String search)
          Find position of string in another string
 int inString(java.lang.String search, int step, int ofs)
          find position of a string in another string
 int intValue()
          Return integer representation of the object
 boolean isAlpha()
          return true if string is only alpha characters.If string length>1 then only test first char
 boolean isConstrained()
           
 boolean isDecimal()
           
 boolean isNumeric()
          Return true is string encodes a legitimate numeric
 boolean isUpper()
          return true if string is upper case.
 ClarionString left()
          return left(len())
 ClarionString left(int offset)
          Return string left shifted.
 int len()
          Get string length - result dependent upon encoding system used
 ClarionString like()
          clone string
 ClarionString lower()
          Return lower cased string
 boolean match(java.lang.String regex)
           
 boolean match(java.lang.String regex, int mode)
           
 ClarionObject modulus(ClarionObject object)
          Do a numeric modulus.
 ClarionObject multiply(ClarionObject object)
          Do a numeric multiply.
 ClarionObject negate()
          Do a numeric negation.
 void notifyChange()
           
 ClarionObject power(ClarionObject object)
          Do a numeric power.
 java.lang.String quote()
           
 java.lang.String quote(boolean mode)
          Quote.
 ClarionString right()
          return right justified string
 ClarionString right(int offset)
          Return string right justified
static java.lang.String rtrim(java.lang.String in)
           
 void serialize(java.io.OutputStream is)
          Write java object to memory as clarion would represent object in memory
 ClarionString setEncoding(int encoding)
          Set string encoding.
 ClarionString setName(java.lang.String name)
          Set external name for the object - used by external systems like SQL driver
 ClarionString setOver(ClarionMemoryModel o)
          Overlay string onto another clarion object
 ClarionString setOver(ClarionMemoryModel[] o)
          Overlay string onto another clarion object (array of objects)
 ClarionString[] setOverAndDim(ClarionMemoryModel over, int size)
           
 void setStringAt(ClarionObject index, ClarionObject string)
          Modify contents of char at given position
 void setStringAt(ClarionObject from, ClarionObject to, ClarionObject string)
          Modify contents of string at given position
 void setStringAt(java.lang.Object from, java.lang.Object string)
           
 void setStringAt(java.lang.Object from, java.lang.Object to, java.lang.Object string)
           
 ClarionString setThread()
           
 void setValue(ClarionObject object)
          Set object to given value
static java.lang.String staticConcat(java.lang.Object... obj)
           
static java.lang.String staticConcat(java.lang.StringBuilder target, java.lang.Object... obj)
           
 ClarionString stringAt(ClarionObject o)
           
 ClarionString stringAt(ClarionObject from, ClarionObject to)
          Get sub string at given position
 int strpos(java.lang.String regex)
           
 int strpos(java.lang.String regex, boolean mode)
           
 ClarionString sub(int offset)
          return sub string from given offset.
 ClarionString sub(int offset, int len)
          Return sub string of offset and length
 ClarionObject subtract(ClarionObject object)
          Do a numeric subtract.
 java.lang.String toString()
           
 java.lang.String unquote()
           
 ClarionString upper()
          Return uppercased string
 int val()
          Return ascii character value of string (assume 1 char string)
 
Methods inherited from class org.jclarion.clarion.ClarionObject
add, clear, clearNull, compareTo, decrement, decrement, divide, doSetName, doSetOver, doSetOver, equals, gcd, getName, getOwner, getValue, increment, increment, modulus, multiply, power, setNull, setOver, setOwner, setValue, stringAt, stringAt, subtract
 
Methods inherited from class org.jclarion.clarion.ClarionMemoryModel
addChangeListener, addChangeListener, castTo, getListenerCount, isAnyoneInterestedInChange, isThreaded, lock, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STRING

public static final int STRING
See Also:
Constant Field Values

CSTRING

public static final int CSTRING
See Also:
Constant Field Values

PSTRING

public static final int PSTRING
See Also:
Constant Field Values

ASTRING

public static final int ASTRING
See Also:
Constant Field Values
Constructor Detail

ClarionString

public ClarionString(ClarionString base,
                     java.lang.Thread lock)

ClarionString

public ClarionString()
Create undefined string


ClarionString

public ClarionString(int size)
Create empty string of specified size. space padded.


ClarionString

public ClarionString(java.lang.String content)
Create string of given size defaulted to specified content.


ClarionString

public ClarionString(char[] content)
Create string of given size defaulted to specified content.

Method Detail

initThread

public void initThread()
Specified by:
initThread in interface Threaded
Overrides:
initThread in class ClarionMemoryModel

setThread

public ClarionString setThread()

getLockedObject

public java.lang.Object getLockedObject(java.lang.Thread t)

toString

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

like

public ClarionString like()
clone string

Returns:

setValue

public void setValue(ClarionObject object)
Description copied from class: ClarionObject
Set object to given value

Specified by:
setValue in class ClarionObject

add

public ClarionObject add(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric add. Result is returned as a new object

Specified by:
add in class ClarionObject
Returns:

compareTo

public int compareTo(ClarionObject object)
Description copied from class: ClarionObject
Do a Comparison. Comparison type is preferentially numeric but if either object is a non numeric string then comparsion is a lexical comparison

Specified by:
compareTo in class ClarionObject
Returns:

intValue

public int intValue()
Description copied from class: ClarionObject
Return integer representation of the object

Specified by:
intValue in class ClarionObject
Returns:

multiply

public ClarionObject multiply(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric multiply. Result is returned as a new object

Specified by:
multiply in class ClarionObject
Returns:

setName

public ClarionString setName(java.lang.String name)
Set external name for the object - used by external systems like SQL driver

Parameters:
name -
Returns:

dim

public ClarionString[] dim(int size)
return 1d array clone of the object based on size. Note java object array returned is one larger than specified as clarion starts arrays at offset '1' whilst java as offset '0'


setOverAndDim

public ClarionString[] setOverAndDim(ClarionMemoryModel over,
                                     int size)

dim

public ClarionString[][] dim(int s1,
                             int s2)
return 2d array clone of the object based on size. Note java object array returned is one larger than specified as clarion starts arrays at offset '1' whilst java as offset '0'


dim

public ClarionString[][][] dim(int s1,
                               int s2,
                               int s3)
return 3d array clone of the object based on size. Note java object array returned is one larger than specified as clarion starts arrays at offset '1' whilst java as offset '0'


setEncoding

public ClarionString setEncoding(int encoding)
Set string encoding. A few options exists String - fixed width pstring - fixed width memory footprint but first char specifies string length cstring - fixed width memory footprint - 0x00 terminated string astring - no idea

Parameters:
encoding -
Returns:

setOver

public ClarionString setOver(ClarionMemoryModel o)
Overlay string onto another clarion object

Parameters:
o -
Returns:

setOver

public ClarionString setOver(ClarionMemoryModel[] o)
Overlay string onto another clarion object (array of objects)

Parameters:
o -
Returns:

divide

public ClarionObject divide(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric divide. Result is returned as a new object

Specified by:
divide in class ClarionObject
Returns:

getBool

public ClarionBool getBool()
Description copied from class: ClarionObject
Convert to bool object

Specified by:
getBool in class ClarionObject
Returns:

getNumber

public ClarionNumber getNumber()
Description copied from class: ClarionObject
Convert to number object

Specified by:
getNumber in class ClarionObject
Returns:

getReal

public ClarionReal getReal()
Description copied from class: ClarionObject
Convert to real object

Specified by:
getReal in class ClarionObject
Returns:

getString

public ClarionString getString()
Description copied from class: ClarionObject
Convert to string object

Specified by:
getString in class ClarionObject
Returns:

modulus

public ClarionObject modulus(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric modulus. Result is returned as a new object

Specified by:
modulus in class ClarionObject
Returns:

power

public ClarionObject power(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric power. Result is returned as a new object

Specified by:
power in class ClarionObject
Returns:

subtract

public ClarionObject subtract(ClarionObject object)
Description copied from class: ClarionObject
Do a numeric subtract. Result is returned as a new object

Specified by:
subtract in class ClarionObject
Returns:

boolValue

public boolean boolValue()
Description copied from class: ClarionObject
Return boolen representation of the object

Specified by:
boolValue in class ClarionObject
Returns:

clear

public void clear(int method)
Description copied from class: ClarionObject
Clear object value.

Specified by:
clear in class ClarionObject

setStringAt

public void setStringAt(ClarionObject index,
                        ClarionObject string)
Modify contents of char at given position

Parameters:
index -
string -

setStringAt

public void setStringAt(java.lang.Object from,
                        java.lang.Object string)

setStringAt

public void setStringAt(ClarionObject from,
                        ClarionObject to,
                        ClarionObject string)
Modify contents of string at given position

Parameters:
index -
string -

setStringAt

public void setStringAt(java.lang.Object from,
                        java.lang.Object to,
                        java.lang.Object string)

all

public ClarionString all()
Return source string repeated upto 255 characters

Parameters:
source -
Returns:

all

public ClarionString all(int src)
Return this string repeated upto src characters long

Parameters:
source -
Returns:

negate

public ClarionObject negate()
Description copied from class: ClarionObject
Do a numeric negation. Result is returned as a new object

Specified by:
negate in class ClarionObject
Returns:

val

public int val()
Return ascii character value of string (assume 1 char string)

Returns:

isNumeric

public boolean isNumeric()
Return true is string encodes a legitimate numeric

Returns:

isUpper

public boolean isUpper()
return true if string is upper case. If string length>1 then only test first char

Returns:

isAlpha

public boolean isAlpha()
return true if string is only alpha characters.If string length>1 then only test first char

Returns:

getDecimal

public ClarionDecimal getDecimal()
Description copied from class: ClarionObject
Convert to decimal object

Specified by:
getDecimal in class ClarionObject
Returns:

format

public ClarionString format(java.lang.String aFormat)
Format string as per specified picture formatter

Parameters:
aFormat -
Returns:

deformat

public ClarionString deformat(java.lang.String aFormat)
Remove formatting characters from format For numeric - remove everything but numeric formatters For date, convert back to date format For time, convert back to time format For picture/key tokens return placeholder tokens

Parameters:
aFormat -
Returns:

len

public int len()
Get string length - result dependent upon encoding system used

Returns:

chr

public static ClarionString chr(int ascii)
Convert ascii code into a string

Parameters:
ascii -
Returns:

left

public ClarionString left(int offset)
Return string left shifted.

Parameters:
offset - - length of resultant string.
Returns:

left

public ClarionString left()
return left(len())

Returns:

right

public ClarionString right(int offset)
Return string right justified

Parameters:
offset - length of resultant string
Returns:

right

public ClarionString right()
return right justified string


center

public ClarionString center(int offset)
Return center justified string

Parameters:
offset - resultant length of new string
Returns:

center

public ClarionString center()
Return center justified string

Returns:

sub

public ClarionString sub(int offset)
return sub string from given offset.

Parameters:
offset -
Returns:

sub

public ClarionString sub(int offset,
                         int len)
Return sub string of offset and length

Parameters:
offset -
len -
Returns:

upper

public ClarionString upper()
Return uppercased string

Returns:

lower

public ClarionString lower()
Return lower cased string

Returns:

clip

public ClarionString clip()
return clipped string - trailing whitespace removed.

Returns:

inString

public int inString(java.lang.String search)
Find position of string in another string

Parameters:
search -
Returns:

inString

public int inString(java.lang.String search,
                    int step,
                    int ofs)
find position of a string in another string

Parameters:
search -
step -
ofs -
Returns:

deserialize

public void deserialize(java.io.InputStream is)
                 throws java.io.IOException
Description copied from class: ClarionMemoryModel
Read object from memory as clarion would represent object in memory

Specified by:
deserialize in class ClarionMemoryModel
Throws:
java.io.IOException

serialize

public void serialize(java.io.OutputStream is)
               throws java.io.IOException
Description copied from class: ClarionMemoryModel
Write java object to memory as clarion would represent object in memory

Specified by:
serialize in class ClarionMemoryModel
Throws:
java.io.IOException

stringAt

public ClarionString stringAt(ClarionObject o)
Overrides:
stringAt in class ClarionObject

stringAt

public ClarionString stringAt(ClarionObject from,
                              ClarionObject to)
Description copied from class: ClarionObject
Get sub string at given position

Overrides:
stringAt in class ClarionObject
Returns:

allowedSize

public int allowedSize()

isDecimal

public boolean isDecimal()
Overrides:
isDecimal in class ClarionObject

genericLike

public ClarionObject genericLike()
Specified by:
genericLike in class ClarionObject

isConstrained

public boolean isConstrained()
Specified by:
isConstrained in class ClarionObject

concat

public java.lang.String concat(java.lang.Object... obj)
Do string concatination

Overrides:
concat in class ClarionObject
Parameters:
obj -
Returns:

staticConcat

public static java.lang.String staticConcat(java.lang.Object... obj)

staticConcat

public static java.lang.String staticConcat(java.lang.StringBuilder target,
                                            java.lang.Object... obj)

concatSegment

public void concatSegment(java.lang.StringBuilder target)
Overrides:
concatSegment in class ClarionObject

rtrim

public static java.lang.String rtrim(java.lang.String in)

notifyChange

public void notifyChange()
Overrides:
notifyChange in class ClarionMemoryModel

capitalize

public static java.lang.String capitalize(java.lang.String input)

getSize

public int getSize()
Description copied from class: ClarionObject
Return max size of the object when represented as a string Used mainly by ASCII file driver

Specified by:
getSize in class ClarionObject
Returns:

getClarionWildCardEx

public static java.util.regex.Pattern getClarionWildCardEx(java.lang.String pattern,
                                                           boolean ignoreCase)

getClarionRegEx

public static java.util.regex.Pattern getClarionRegEx(java.lang.String pattern,
                                                      boolean ignoreCase)

strpos

public int strpos(java.lang.String regex)

strpos

public int strpos(java.lang.String regex,
                  boolean mode)

match

public boolean match(java.lang.String regex)

match

public boolean match(java.lang.String regex,
                     int mode)

quote

public java.lang.String quote()

quote

public java.lang.String quote(boolean mode)
Quote. See clarion 6 doco. What exactly this does will remain a mystery when mode is false - generate clarion encoded string. Clarion 6 is actually buggy, this implementation mirrors that bugginess perfectly When mode is true - do something strange and unexplicable. See clarion 6 doco

Parameters:
mode -
Returns:

unquote

public java.lang.String unquote()


Copyright © 2010. All Rights Reserved.