com.esri.arcgis.system
Class ByteSwapStreamIO

java.lang.Object
  extended by com.esri.arcgis.system.ByteSwapStreamIO
All Implemented Interfaces:
com.esri.arcgis.interop.RemoteObjRef, IByteSwapStreamIO, Serializable

public class ByteSwapStreamIO
extends Object
implements com.esri.arcgis.interop.RemoteObjRef, IByteSwapStreamIO

Helper object that performs byte swapping of data read and written to stream.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

See Also:
Serialized Form

Constructor Summary
ByteSwapStreamIO()
          Constructs a ByteSwapStreamIO using ArcGIS Engine.
ByteSwapStreamIO(Object obj)
          Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
ByteSwapStreamIO theByteSwapStreamIO = (ByteSwapStreamIO) obj;
 
Method Summary
 boolean equals(Object o)
          Compare this object with another
static String getClsid()
          getClsid.
 IStream getStream()
          The stream to perform byte swap reads and writes to.
 int hashCode()
          the hashcode for this object
 void read(int dataType, int pv, int cb, int[] pcbRead)
          Perform a read byte swapping to the native format.
 void setStreamByRef(IStream ppStream)
          The stream to perform byte swap reads and writes to.
 void write(int dataType, int pv, int cb, int[] pcbWritten)
          Perform a write byte swapping to the windows format.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.esri.arcgis.interop.RemoteObjRef
getJintegraDispatch, release
 

Constructor Detail

ByteSwapStreamIO

public ByteSwapStreamIO()
                 throws IOException,
                        UnknownHostException
Constructs a ByteSwapStreamIO using ArcGIS Engine.

Throws:
IOException - if there are interop problems
UnknownHostException - if there are interop problems

ByteSwapStreamIO

public ByteSwapStreamIO(Object obj)
                 throws IOException
Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
ByteSwapStreamIO theByteSwapStreamIO = (ByteSwapStreamIO) obj;

Construct a ByteSwapStreamIO using a reference to such an object returned from ArcGIS Engine or Server. This is semantically equivalent to casting obj to ByteSwapStreamIO.

Parameters:
obj - an object returned from ArcGIS Engine or Server
Throws:
IOException - if there are interop problems
Method Detail

getClsid

public static String getClsid()
getClsid.


equals

public boolean equals(Object o)
Compare this object with another

Overrides:
equals in class Object

hashCode

public int hashCode()
the hashcode for this object

Overrides:
hashCode in class Object

setStreamByRef

public void setStreamByRef(IStream ppStream)
                    throws IOException,
                           AutomationException
The stream to perform byte swap reads and writes to.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Specified by:
setStreamByRef in interface IByteSwapStreamIO
Parameters:
ppStream - A reference to a com.esri.arcgis.system.IStream (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getStream

public IStream getStream()
                  throws IOException,
                         AutomationException
The stream to perform byte swap reads and writes to.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
getStream in interface IByteSwapStreamIO
Returns:
A reference to a com.esri.arcgis.system.IStream
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

read

public void read(int dataType,
                 int pv,
                 int cb,
                 int[] pcbRead)
          throws IOException,
                 AutomationException
Perform a read byte swapping to the native format.

Remarks

DataType [in]

User specified type of the data to perform swapping on.

pv [out]

A pointer to the buffer which the stream data is read into.

cb [in]

The number of bytes of data to read from the stream object.

pcbRead [out]

A pointer to a ULONG variable that receives the actual number of bytes

read from the stream object. It could be set to NULL. In this case,

the Read method does not provide the number of bytes read.

The Read method reads requested (in cb variable) number of bytes from the stream object into memory, starting at the current seek pointer, and swaps it into the native format. The actual number of bytes read can be less than it was requested if the end of the stream is reached during the read operation or an error can occur if nothing was read from the stream object.

VC++ example:

// Open the file and set it to be the stream object

IBlobStreamPtr ipBlobStream(CLSID_FileStream);
IFilePtr ipFile(ipBlobStream);
ipFile->Open(L"C:\\fileIn", esriReadOnly);
IStreamPtr ipStream(ipFile);
IByteSwapStreamIOPtr ipByteSwapStreamIO (CLSID_ByteSwapStreamIO);
ipByteSwapStreamIO->putref_Stream(ipStream);


// Get the size of the stream

unsigned long size;
ipBlobStream->get_Size(&size);


// Read and swap stream
BYTE pv[14];
ULONG pcbRead;
ipByteSwapStreamIO->Read(esriBSDTBYTE, &pv, size, &pcbRead);

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
read in interface IByteSwapStreamIO
Parameters:
dataType - A com.esri.arcgis.system.esriByteSwapDataType constant (in)
pv - A COM void* (out: use single element array)
cb - The cb (in)
pcbRead - The pcbRead (out: use single element array)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

write

public void write(int dataType,
                  int pv,
                  int cb,
                  int[] pcbWritten)
           throws IOException,
                  AutomationException
Perform a write byte swapping to the windows format.

Remarks

DataType [in]

User specified type of the data to perform swapping on.

pv [in]

A pointer to the buffer which contains the data that is to be written

to the stream object. A valid parameter should be provided.

cb [in]

The number of bytes of data to attempt to write into the stream. The value

can be zero.

pcbRead [out]

A pointer to a ULONG variable that receives the actual number of bytes

written to the stream object. It could be set to NULL. In this case,

the Write method does not provide the number of bytes written.

The Write method writes the specified number of bytes of data to the Stream object and performs a byte swapping on it. The number of bytes actually written to the stream is returned in pcbWritten parameter. If the byte count variable (pv) is zero byte, no data is written to the stream, and the Write operation has no effect.

VC++ example:

// Open the file and set it to be the stream object
IBlobStreamPtr ipBlobStream(CLSID_FileStream);
IFilePtr ipFile(ipBlobStream);
ipFile->Open(L"C:\\fileIn", esriReadOnly);
IStreamPtr ipStream(ipFile);
IByteSwapStreamIOPtr ipByteSwapStreamIO (CLSID_ByteSwapStreamIO);
ipByteSwapStreamIO->putref_Stream(ipStream);


// Get the size of the stream

unsigned long size;
ipBlobStream->get_Size(&size);


// Read and swap stream

BYTE pv[14];
ULONG pcbRead;
ipByteSwapStreamIO->Read(esriBSDTBYTE, &pv, size, &pcbRead);


// Open a file to write the stream to

DeleteFileW(L"C:\\fileOut");
hr = ipFile->Open(L"C:\\fileOut", esriReadWrite);

// Write to the stream

ULONG pcbWritten;
ipByteSwapStreamIO->Write(esriBSDTBYTE, c_pv, size, &pcbWritten);

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
write in interface IByteSwapStreamIO
Parameters:
dataType - A com.esri.arcgis.system.esriByteSwapDataType constant (in)
pv - A COM void* (in)
cb - The cb (in)
pcbWritten - The pcbWritten (out: use single element array)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.