com.smardec.j2native
Class ZeroTerminatedString

java.lang.Object
  |
  +--com.smardec.j2native.Argument
        |
        +--com.smardec.j2native.ZeroTerminatedString
All Implemented Interfaces:
java.lang.Cloneable, StringType
Direct Known Subclasses:
AnsiString, WideString

public abstract class ZeroTerminatedString
extends Argument
implements StringType

ZeroTerminatedString class is a base class for all types of zero-terminated strings.

NOTE: All string lengths include a terminating zero character unless otherwise noted.


Field Summary
 
Fields inherited from class com.smardec.j2native.Argument
JAVA_SIDE, NATIVE_SIDE
 
Constructor Summary
protected ZeroTerminatedString(java.lang.String string)
          Constructs a string with specified value
protected ZeroTerminatedString(java.lang.String string, int maxSize)
          Constructs a string with specified value and sets maximum chars quantity
 
Method Summary
protected abstract  byte getCharLength()
          Returns the character length
 int getLength()
          Additional info: due to every zero-terminated ends with zero value we add additional character to encode zero.
 int getMaxSize()
          Getter for string argument maximum size
 java.lang.String getValue()
          Getter for the string value of the argument
 boolean isAutoResize()
          Shows if string argument is autoresizeable.
protected  boolean isFixedLength()
          Identify if Argument is a fixed length variable.
protected  void read(long handle, int offset)
          Reads itself from the memory.
 void readFromStack(byte[] stack, int offset)
          Read itself from stack.
 void setAutoResize(boolean autoResize)
          Sets an auto resizeable property.
 void setMaxSize(int maxSize)
          Additional note: as autoResize property prevails to maxSize property, you have to set autoResize to false value before setting maxSize property.
 void setValue(java.lang.String value)
          Sets the value for the argument.
protected  long storeToRAM()
          Stores itself to the native memory.
protected  void write(long handle, int offset)
          Writes itself to the memory.
 void writeToStack(byte[] stack, int offset)
          Writes itself to stack.
 
Methods inherited from class com.smardec.j2native.Argument
clone, finalize, free, fromBytesValue, getAlignedLength, getResultFlags, readFromRAM, restoreFromRAM, toBytesValue, toBytesValue, update, writeToRAM
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZeroTerminatedString

protected ZeroTerminatedString(java.lang.String string)
Constructs a string with specified value

Parameters:
string - the value to set.

ZeroTerminatedString

protected ZeroTerminatedString(java.lang.String string,
                               int maxSize)
Constructs a string with specified value and sets maximum chars quantity

Parameters:
string - the value to set.
maxSize - maximum size of the string argument in characters
Method Detail

isAutoResize

public boolean isAutoResize()
Description copied from interface: StringType
Shows if string argument is autoresizeable. Autoresizeabe means that no string value length specified, and it could be any length

Specified by:
isAutoResize in interface StringType
Returns:
is auto resizeable

setAutoResize

public void setAutoResize(boolean autoResize)
Description copied from interface: StringType
Sets an auto resizeable property.

Specified by:
setAutoResize in interface StringType
Parameters:
autoResize - autoresizeability

getMaxSize

public int getMaxSize()
Description copied from interface: StringType
Getter for string argument maximum size

Specified by:
getMaxSize in interface StringType
Returns:
maximum size of the string argument

setMaxSize

public void setMaxSize(int maxSize)
Additional note: as autoResize property prevails to maxSize property, you have to set autoResize to false value before setting maxSize property.

Specified by:
setMaxSize in interface StringType
Parameters:
maxSize - maximum size of the string argument

setValue

public final void setValue(java.lang.String value)
Description copied from interface: StringType
Sets the value for the argument.

Specified by:
setValue in interface StringType
Parameters:
value - the value to set.

getValue

public final java.lang.String getValue()
Description copied from interface: StringType
Getter for the string value of the argument

Specified by:
getValue in interface StringType
Returns:
the string value of the argument

getCharLength

protected abstract byte getCharLength()
Returns the character length

Returns:
character length

getLength

public int getLength()
Additional info: due to every zero-terminated ends with zero value we add additional character to encode zero.

Specified by:
getLength in class Argument
Returns:
an int

writeToStack

public void writeToStack(byte[] stack,
                         int offset)
Description copied from class: Argument
Writes itself to stack.

Specified by:
writeToStack in class Argument
Parameters:
stack - it's byte array, where Argument will be written
offset - offset in stack

readFromStack

public void readFromStack(byte[] stack,
                          int offset)
Description copied from class: Argument
Read itself from stack.

Specified by:
readFromStack in class Argument
Parameters:
stack - it's byte array, from which Argument will be restored
offset - offset in stack

isFixedLength

protected boolean isFixedLength()
Description copied from class: Argument
Identify if Argument is a fixed length variable.

Specified by:
isFixedLength in class Argument
Returns:
true if it is so, and false otherwise

storeToRAM

protected long storeToRAM()
Description copied from class: Argument
Stores itself to the native memory. Argument takes care of memory allocation and writes itself to this allocated memory. After all operations complete method returns this memory address.

Overrides:
storeToRAM in class Argument
Returns:
memory address

write

protected final void write(long handle,
                           int offset)
Description copied from class: Argument
Writes itself to the memory. Exact memory address specified by params.

Specified by:
write in class Argument
Parameters:
handle - identifies location in memory where Argument will be written
offset - memory address offset

read

protected final void read(long handle,
                          int offset)
Description copied from class: Argument
Reads itself from the memory. Exact memory address specified by params.

Specified by:
read in class Argument
Parameters:
handle - identifies location in memory from which Argument will be read
offset - memory address offset


Copyright © 2004-2006 Smardec. All Rights Reserved.