com.jniwrapper
Class WideString

java.lang.Object
  extended by com.jniwrapper.Parameter
      extended by com.jniwrapper.ZeroTerminatedString
          extended by com.jniwrapper.WideString
All Implemented Interfaces:
AlignmentAwareParameter, StringParameter

public class WideString
extends ZeroTerminatedString

Represents Unicode string (wchar_t[n]) value and type, where n is the length of the buffer..

NOTE: Please keep in mind that this class is the memory buffer of specified length, but not the pointer. Theretofore when you need to pass this object to a native function call, for example: void foo(wchar_t* aString), you can wrap this object to a Pointer or pass this object as is. In second case JNIWrapper will automatically wrap this string into Pointer for you. For example:

      WideString aString = new WideString("String value");
      function.invoke(null, aString);
      //or
      function.invoke(null, new Pointer(aString));

 
In case when you need to wrap a structure that contains a string member, for example:
  struct a {
      wchar_t name[10];
  }
 
You can use the following wrapper:
  public class A extends Structure {
      private WideString name = new WideString(10); // corresponds to wchar_t name[10]
      public A() {
          init(new Parameter[] {name});
      }
  }
 
In case if a structure contains a char* member, for example:
  struct a {
      wchar_t name*;
  }
 
Then you can use the following wrapper for it:
  public class A extends Structure {
      Pointer name = new Pointer(WideString.class); // corresponds to char name*
      public A() {
          init(new Parameter[] {name});
      }
  }
 
NOTE: All string lengths include the terminating zero character unless otherwise noted.

This class should be used directly only if Unicode characters are required. Use Str class for working with string values to make your code compatible with both Unicode and non-Unicode platforms.

See Also:
AnsiString, Str

Field Summary
 
Fields inherited from class com.jniwrapper.Parameter
LICENSE_TYPE, V
 
Constructor Summary
WideString()
          Constructs a string with the maximum length of 256 characters.
WideString(int maxLen)
          Constructs a string with a specified maximum length.
WideString(java.lang.String s)
          Constructs a string with a specified value.
WideString(java.lang.String s, int maxLen)
          Constructs a string with a specified value and maximum length.
WideString(WideString t)
          Constructs a copy of a specified AnsiString object.
 
Method Summary
protected  java.lang.String bytesToString(byte[] bytes)
           
 java.lang.Object clone()
           
 int getAlignmentRequirement()
           
protected  int getStrLen(DataBuffer dataBuffer, int startOffset)
           
protected  byte[] stringToBytes(java.lang.String value)
           
 
Methods inherited from class com.jniwrapper.ZeroTerminatedString
asReturnValue, equals, getAlignedLength, getDebugInfo, getFirstMemberSize, getLength, getMaxLength, getValue, hashCode, read, setValue, toString, write
 
Methods inherited from class com.jniwrapper.Parameter
acceptIOPerformer, dataBufferAssigned, getDataBuffer, getDataBufferOffset, indent, pop, push, read, read, setDataBuffer, toByteArray, write
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WideString

public WideString()
Constructs a string with the maximum length of 256 characters.


WideString

public WideString(int maxLen)
Constructs a string with a specified maximum length.


WideString

public WideString(java.lang.String s)
Constructs a string with a specified value. The maximum length of the string equals the length of a specified value (including terminating zero).


WideString

public WideString(java.lang.String s,
                  int maxLen)
Constructs a string with a specified value and maximum length.


WideString

public WideString(WideString t)
Constructs a copy of a specified AnsiString object.

Method Detail

bytesToString

protected java.lang.String bytesToString(byte[] bytes)
Specified by:
bytesToString in class ZeroTerminatedString

stringToBytes

protected byte[] stringToBytes(java.lang.String value)
Specified by:
stringToBytes in class ZeroTerminatedString

clone

public java.lang.Object clone()
Specified by:
clone in class Parameter

getStrLen

protected int getStrLen(DataBuffer dataBuffer,
                        int startOffset)
Specified by:
getStrLen in class ZeroTerminatedString

getAlignmentRequirement

public int getAlignmentRequirement()
Overrides:
getAlignmentRequirement in class Parameter
Returns:
required alignment within a structure or an array