com.jniwrapper.win32.automation.types
Class BStr

java.lang.Object
  extended bycom.jniwrapper.Parameter
      extended bycom.jniwrapper.win32.automation.types.BStr
All Implemented Interfaces:
AutoDeleteParameter, PointerParameter, StringParameter

public class BStr
extends Parameter
implements StringParameter, AutoDeleteParameter, PointerParameter

This type is an analog of WideString, usually used by Automation and corresponds to BSTR native type. If not specially noted, the memory buffer of the BStr instance will be automatically freed by NativeResourceCollector when the instance of this class is garbadge collected.

See Also:
Microsoft Automation SDK documentation, setAutoDelete(boolean)

Field Summary
 
Fields inherited from class com.jniwrapper.Parameter
LICENSE_TYPE, V
 
Constructor Summary
BStr()
          Creates NULL string.
BStr(BStr that)
          Creates the new BStr instance from the specified one.
BStr(java.lang.String s)
          Creates the new BStr by the specified string value.
BStr(java.lang.String s, int length)
          Creates the new BStr with the specified string value.
 
Method Summary
 void acceptIOPerformer(IOPerformer performer, DataBuffer buffer, int initialOffset, boolean isReadOperation, boolean invokedByCallback)
           
 java.lang.Object clone()
           
 boolean equals(java.lang.Object obj)
           
 java.lang.String getDebugInfo()
           
 long getHandle()
           
 int getLength()
          Returns the length of the BStr parameter (which equals to the length of the Pointer), but not the length of the contained string itself.
 java.lang.String getValue()
          Returns string value of this BStr.
 boolean isAutoDelete()
          Returns true if the associated native memory buffer is automatically freed by NativeResourceCollector.
 boolean isNull()
           
 int length()
          Returns the length of this BStr.
 int lengthInBytes()
          Returns the number of bytes of this BStr.
 void read(DataBuffer stackBuffer, int offset, boolean invokedByCallback)
           
 void release()
          Releases native resources of this object.
 void setAutoDelete(boolean autoDelete)
          Makes the NativeResourceCollector automatically free the memory buffer associated with this object or turn the automatic freeing off.
protected  void setHandle(long value)
           
 void setNull()
          Deprecated. Use release() method instead.
 void setValue(java.lang.String value)
          Sets the new value to this BStr object.
 void setValue(java.lang.String value, int length)
          Sets the new value to this BStr.
 java.lang.String toString()
           
 void write(DataBuffer stackBuffer, int offset, boolean invokedByCallback)
           
 
Methods inherited from class com.jniwrapper.Parameter
, a, a, asReturnValue, b, dataBufferAssigned, getAlignedLength, getAlignmentRequirement, getDataBuffer, getDataBufferOffset, hashCode, indent, pop, push, read, read, setDataBuffer, toByteArray, write
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BStr

public BStr()
Creates NULL string.


BStr

public BStr(java.lang.String s)
Creates the new BStr by the specified string value.

Parameters:
s - string value

BStr

public BStr(BStr that)
Creates the new BStr instance from the specified one.

Parameters:
that - value that will be used for creating new instance.

BStr

public BStr(java.lang.String s,
            int length)
Creates the new BStr with the specified string value. The length parameter specifies the number of characters in the string, in case if it may contain null characters within.

Parameters:
s - string value
length - number of the characters in the string
Method Detail

setValue

public void setValue(java.lang.String value)
Sets the new value to this BStr object.

Specified by:
setValue in interface StringParameter
Parameters:
value - new string value

setValue

public void setValue(java.lang.String value,
                     int length)
Sets the new value to this BStr. The length parameter specifies the number of characters in the string, in case if it may contain null characters within.

Parameters:
value - new string value
length - number of the characters in the string

getValue

public java.lang.String getValue()
Returns string value of this BStr.

Specified by:
getValue in interface StringParameter
Returns:
string value of this BStr

length

public int length()
Returns the length of this BStr.

Returns:
the length of this BStr

lengthInBytes

public int lengthInBytes()
Returns the number of bytes of this BStr.

Returns:
the number of bytes of this BStr

isAutoDelete

public boolean isAutoDelete()
Returns true if the associated native memory buffer is automatically freed by NativeResourceCollector.

Specified by:
isAutoDelete in interface AutoDeleteParameter
Returns:
true if the native memory buffer is automatically freed, otherwise false.

setAutoDelete

public void setAutoDelete(boolean autoDelete)
Makes the NativeResourceCollector automatically free the memory buffer associated with this object or turn the automatic freeing off.

Specified by:
setAutoDelete in interface AutoDeleteParameter
Parameters:
autoDelete - if true the memory will be freed automatically, otherwise manual freeing is required.

release

public void release()
Releases native resources of this object.


getLength

public int getLength()
Returns the length of the BStr parameter (which equals to the length of the Pointer), but not the length of the contained string itself.

To obtain the length of this string use length() method.

Returns:
returns the length of the BStr parameter

isNull

public boolean isNull()
Specified by:
isNull in interface PointerParameter
Returns:
true if the reference string is NULL, false otherwise.

setNull

public void setNull()
Deprecated. Use release() method instead.

Makes the object reference NULL value.


getHandle

public long getHandle()

setHandle

protected void setHandle(long value)

write

public void write(DataBuffer stackBuffer,
                  int offset,
                  boolean invokedByCallback)
           throws MemoryAccessViolationException
Throws:
MemoryAccessViolationException

read

public void read(DataBuffer stackBuffer,
                 int offset,
                 boolean invokedByCallback)
          throws MemoryAccessViolationException
Throws:
MemoryAccessViolationException

clone

public java.lang.Object clone()

acceptIOPerformer

public void acceptIOPerformer(IOPerformer performer,
                              DataBuffer buffer,
                              int initialOffset,
                              boolean isReadOperation,
                              boolean invokedByCallback)

getDebugInfo

public java.lang.String getDebugInfo()

toString

public java.lang.String toString()
Returns:
the string value of the object.
See Also:
getValue()

equals

public boolean equals(java.lang.Object obj)