Skip navigation links
JNA API 5.3.1
com.sun.jna

Class NativeString

  • All Implemented Interfaces:
    java.lang.CharSequence, java.lang.Comparable


    class NativeString
    extends java.lang.Object
    implements java.lang.CharSequence, java.lang.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

      Fields 
      Modifier and Type Field and Description
      (package private) static java.lang.String WIDE_STRING 
    • Constructor Summary

      Constructors 
      Constructor and Description
      NativeString(java.lang.String string)
      Create a native string (NUL-terminated array of char).
      NativeString(java.lang.String string, boolean wide)
      Create a native string as a NUL-terminated array of wchar_t (if wide is true) or char.
      NativeString(java.lang.String string, java.lang.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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      char charAt(int index) 
      int compareTo(java.lang.Object other) 
      boolean equals(java.lang.Object other) 
      Pointer getPointer() 
      int hashCode() 
      int length() 
      java.lang.CharSequence subSequence(int start, int end) 
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.CharSequence

        chars, codePoints
    • Constructor Detail

      • NativeString

        public NativeString(java.lang.String string)
        Create a native string (NUL-terminated array of char).

        Uses the encoding returned by Native.getDefaultStringEncoding().

      • NativeString

        public NativeString(java.lang.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(java.lang.String string,
                            java.lang.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 java.lang.Object
      • equals

        public boolean equals(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Specified by:
        toString in interface java.lang.CharSequence
        Overrides:
        toString in class java.lang.Object
      • getPointer

        public Pointer getPointer()
      • charAt

        public char charAt(int index)
        Specified by:
        charAt in interface java.lang.CharSequence
      • length

        public int length()
        Specified by:
        length in interface java.lang.CharSequence
      • subSequence

        public java.lang.CharSequence subSequence(int start,
                                                  int end)
        Specified by:
        subSequence in interface java.lang.CharSequence
      • compareTo

        public int compareTo(java.lang.Object other)
        Specified by:
        compareTo in interface java.lang.Comparable
JNA API 5.3.1

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