Package com.sun.jna
Class NativeString
- java.lang.Object
-
- com.sun.jna.NativeString
-
- All Implemented Interfaces:
CharSequence,Comparable
class NativeString extends Object implements CharSequence, Comparable
Provides a temporary allocation of an immutable C string (const char*orconst wchar_t*) for use when converting a Java String into a native memory function argument.- Author:
- Todd Fast, todd.fast@sun.com, twall@users.sf.net
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static StringWIDE_STRING
-
Constructor Summary
Constructors Constructor Description NativeString(WString string)Create a native string as a NUL-terminated array ofwchar_t.NativeString(String string)Create a native string (NUL-terminated array ofchar).NativeString(String string, boolean wide)Create a native string as a NUL-terminated array ofwchar_t(ifwideis true) orchar.NativeString(String string, String encoding)Create a native string (NUL-terminated array ofchar), using the requested encoding.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description charcharAt(int index)intcompareTo(Object other)booleanequals(Object other)PointergetPointer()inthashCode()intlength()CharSequencesubSequence(int start, int end)StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
-
-
-
Field Detail
-
WIDE_STRING
static final String WIDE_STRING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NativeString
public NativeString(String string)
Create a native string (NUL-terminated array ofchar).Uses the encoding returned by
Native.getDefaultStringEncoding().
-
NativeString
public NativeString(String string, boolean wide)
Create a native string as a NUL-terminated array ofwchar_t(ifwideis true) orchar.If not
wide, the encoding is obtained fromNative.getDefaultStringEncoding().- Parameters:
string- value to write to native memorywide- whether to store the String aswchar_t
-
NativeString
public NativeString(WString string)
Create a native string as a NUL-terminated array ofwchar_t.
-
-
Method Detail
-
toString
public String toString()
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
getPointer
public Pointer getPointer()
-
charAt
public char charAt(int index)
- Specified by:
charAtin interfaceCharSequence
-
length
public int length()
- Specified by:
lengthin interfaceCharSequence
-
subSequence
public CharSequence subSequence(int start, int end)
- Specified by:
subSequencein interfaceCharSequence
-
compareTo
public int compareTo(Object other)
- Specified by:
compareToin interfaceComparable
-
-