JNA API 4.0.0

com.sun.jna
Class NativeString

java.lang.Object
  extended by 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* or const 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
(package private) static String WIDE_STRING
           
 
Constructor Summary
NativeString(String string)
          Create a native string (NUL-terminated array of char).
NativeString(String string, boolean wide)
          Create a native string as a NUL-terminated array of wchar_t (if wide is true) or char.
NativeString(String string, String encoding)
          Create a native string (NUL-terminated array of char), using the requested encoding.
NativeString(WString string)
          Create a native string as a NUL-terminated array of wchar_t.
 
Method Summary
 char charAt(int index)
           
 int compareTo(Object other)
           
 boolean equals(Object other)
           
 Pointer getPointer()
           
 int hashCode()
           
 int length()
           
 CharSequence subSequence(int start, int end)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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 of char).

Uses the encoding returned by Native.getDefaultStringEncoding().


NativeString

public NativeString(String string,
                    boolean wide)
Create a native string as a NUL-terminated array of wchar_t (if wide is true) or char.

If not wide, the encoding is obtained from Native.getDefaultStringEncoding().

Parameters:
string - value to write to native memory
wide - whether to store the String as wchar_t

NativeString

public NativeString(WString string)
Create a native string as a NUL-terminated array of wchar_t.


NativeString

public NativeString(String string,
                    String encoding)
Create a native string (NUL-terminated array of char), using the requested encoding.

Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

toString

public String toString()
Specified by:
toString in interface CharSequence
Overrides:
toString in class Object

getPointer

public Pointer getPointer()

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSequence

length

public int length()
Specified by:
length in interface CharSequence

subSequence

public CharSequence subSequence(int start,
                                int end)
Specified by:
subSequence in interface CharSequence

compareTo

public int compareTo(Object other)
Specified by:
compareTo in interface Comparable

JNA API 4.0.0

Copyright © 2007-2013 Timothy Wall. All Rights Reserved.