com.jinvoke
Enum Charset

java.lang.Object
  extended by java.lang.Enum<Charset>
      extended by com.jinvoke.Charset
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Charset>

public enum Charset
extends java.lang.Enum<Charset>

Indicates how Java Strings are converted when passing to native code.

Strings in native code can be wide character(Unicode i.e. wchar_t*) or single character(Ansi i.e. char*). This enumeration specifies the character set for native methods using the NativeImport annotation, and for String, StringBuffer and StringBuilder members of native structs using the NativeStruct annotation.

This attribute affects how arguments of type are passed to the native function.

Examples:

The following code example shows how to specify a charset enumeration value when declaring a @NativeStruct. In this case, the pszDisplayName and lpszTitle members are converted to/from Ansi strings.

import com.jinvoke.Charset;
import com.jinvoke.NativeStruct;

@NativeStruct(charset=Charset.ANSI)
public class BrowseInfo {
    public int    hwndOwner;
    public int    pidlRoot;

    public StringBuffer pszDisplayName; // display name of item selected - returned
    public String lpszTitle;                    // text to go in the banner over the tree

    public int    ulFlags;                              
    public int    lpfn;
    public int    lParam;                               
    public int    iImage;                               
}

The following code example shows how to specify a charset enumeration value when declaring a native method using the @NativeImport annotation:

        @NativeImport(library="Shell32", charset=Charset.ANSI)
        public static native boolean SHGetPathFromIDListA(int pidl, StringBuffer path);


Enum Constant Summary
ANSI
          Convert Strings to single-character strings.
AUTO
          Automatically convert Strings appropriately for the target operating system.
UNICODE
          Convert Strings to wide-character strings.
 
Method Summary
 int getIntCode()
           
static Charset valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static Charset[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

ANSI

public static final Charset ANSI
Convert Strings to single-character strings. This uses the native data type of char when converting Strings to native strings.


UNICODE

public static final Charset UNICODE
Convert Strings to wide-character strings. This uses the native data type of wchar_t when converting Strings to native strings.


AUTO

public static final Charset AUTO
Automatically convert Strings appropriately for the target operating system. The default is Unicode for Windows, and Ansi for Unix operating systems.

Method Detail

values

public static final Charset[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(Charset c : Charset.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static Charset valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name

getIntCode

public int getIntCode()