public class AnsiString extends ZeroTerminatedString
char[n], where n is the length of the buffer.
NOTE: Please keep in mind that this class is the memory buffer of specified lenght, but not the pointer.
Thereofore when you need to pass this object to a native function call, for example: void foo(char* aString), you
can wrap this object to a Pointer or pass this object as is. In second case JNIWrapper will atomatically wrap this string into Pointer for you.
For example:
AnsiString aString = new AnsiString("String value");
function.invoke(null, aString);
//or
function.invoke(null, new Pointer(aString));
In case when you need to wrap a structure that contains char[n] member, for example:
struct a {
char name[10];
}
You can use the following wrapper:
public class A extendsIn case if a structure contains a char* member, for example:Structure{ AnsiString name = new AnsiString(10); // corresponds tochar name[10]public A() { init(new Parameter[] {name}); } }
struct a {
char name*;
}
Then you can use the following wrapper for it:
public class A extendsStructure{ Pointer name = newPointer(AnsiString.class); // corresponds tochar name*public A() { init(new Parameter[] {name}); } }
NOTE: All string lengths include a terminating zero character unless otherwise noted.
This class should be used directly only if 8-bit characters are required.
Use Str class for working with string values to make your code compatible with
both Unicode and non-Unicode platforms.
Str,
WideStringLICENSE_TYPE, V| Constructor and Description |
|---|
AnsiString()
Constructs a string with the maximum length of 256 characters.
|
AnsiString(AnsiString t)
Constructs a copy of a specified
AnsiString object. |
AnsiString(byte[] bytes)
Creates the string from the specifies byte array.
|
AnsiString(byte[] bytes,
int length)
Creates the string from the specifies byte array.
|
AnsiString(int maxLen)
Constructs a string with a specified maximum length.
|
AnsiString(java.lang.String s)
Constructs a string with a specified value.
|
AnsiString(java.lang.String s,
int maxLen)
Constructs a string with a specified value and maximum length.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
bytesToString(byte[] bytes) |
java.lang.Object |
clone() |
int |
getAlignmentRequirement() |
int |
getFirstMemberSize()
Should return first member size.
|
protected int |
getStrLen(DataBuffer dataBuffer,
int startOffset) |
protected byte[] |
stringToBytes(java.lang.String value) |
asReturnValue, equals, getAlignedLength, getDebugInfo, getLength, getMaxLength, getValue, hashCode, read, setValue, toString, writeacceptIOPerformer, dataBufferAssigned, getDataBuffer, getDataBufferOffset, indent, pop, push, read, read, setDataBuffer, toByteArray, writepublic AnsiString()
public AnsiString(int maxLen)
public AnsiString(java.lang.String s)
public AnsiString(java.lang.String s,
int maxLen)
public AnsiString(byte[] bytes)
bytes - a byte array to create the structure frompublic AnsiString(byte[] bytes,
int length)
bytes - a byte array to create the structure fromlength - specifies the length of the stringpublic AnsiString(AnsiString t)
AnsiString object.protected java.lang.String bytesToString(byte[] bytes)
bytesToString in class ZeroTerminatedStringprotected byte[] stringToBytes(java.lang.String value)
stringToBytes in class ZeroTerminatedStringprotected int getStrLen(DataBuffer dataBuffer, int startOffset)
getStrLen in class ZeroTerminatedStringpublic int getAlignmentRequirement()
getAlignmentRequirement in class Parameterpublic int getFirstMemberSize()
AlignmentAwareParametergetFirstMemberSize in interface AlignmentAwareParametergetFirstMemberSize in class ZeroTerminatedString