org.ogre4j
Class MemoryDataStream

java.lang.Object
  extended by org.xbig.base.NativeObject
      extended by org.ogre4j.MemoryDataStream
All Implemented Interfaces:
IAllocatedObject<IGeneralAllocPolicy>, IDataStream, IGeneralAllocatedObject, IMemoryDataStream, INativeObject

public class MemoryDataStream
extends NativeObject
implements IMemoryDataStream


Field Summary
 
Fields inherited from class org.xbig.base.NativeObject
deleted, object, remote
 
Constructor Summary
  MemoryDataStream(IDataStream sourceStream, boolean freeOnClose)
          Create a stream which pre-buffers the contents of another stream.
  MemoryDataStream(IDataStreamPtr sourceStream, boolean freeOnClose)
          Create a stream which pre-buffers the contents of another stream.
  MemoryDataStream(InstancePointer p)
          This constructor is public for internal useage only!
protected MemoryDataStream(InstancePointer p, boolean remote)
          Creates a Java wrapper object for an existing C++ object.
  MemoryDataStream(int size, boolean freeOnClose)
          Create a stream with a brand new empty memory chunk.
  MemoryDataStream(java.lang.String name, IDataStream sourceStream, boolean freeOnClose)
          Create a named stream which pre-buffers the contents of another stream.
  MemoryDataStream(java.lang.String name, IDataStreamPtr sourceStream, boolean freeOnClose)
          Create a named stream which pre-buffers the contents of another stream.
  MemoryDataStream(java.lang.String name, int size, boolean freeOnClose)
          Create a named stream with a brand new empty memory chunk.
  MemoryDataStream(java.lang.String name, VoidPointer pMem, int size, boolean freeOnClose)
          Wrap an existing memory chunk in a named stream.
  MemoryDataStream(VoidPointer pMem, int size, boolean freeOnClose)
          Wrap an existing memory chunk in a stream.
  MemoryDataStream(WithoutNativeObject val)
          Allows creation of Java objects without C++ objects.
 
Method Summary
 void close()
          Close the stream; this makes further operations invalid.
 void delete()
          Deletes the corresponding C++ object.
 boolean eof()
          Returns true if the stream has reached the end.
 void finalize()
           
 java.lang.String getAsString()
          Returns a String containing the entire stream.
 ShortPointer getCurrentPtr()
          Get a pointer to the current position in the memory block this stream holds.
 java.lang.String getLine(boolean trimAfter)
          Returns a String containing the next line of data, optionally trimmed for whitespace.
 java.lang.String getName()
           
 ShortPointer getPtr()
          Get a pointer to the start of the memory block this stream holds.
 int read(VoidPointer buf, int count)
          Read the requisite number of bytes from the stream, stopping at the end of the file.
 int readLine(BytePointer buf, int maxCount, java.lang.String delim)
          Get a single line from the stream.
 void seek(int pos)
          Repositions the read point to a specified byte.
 void setFreeOnClose(boolean free)
          Sets whether or not to free the encapsulated memory on close.
 int size()
          Returns the total size of the data to be read from the stream, or 0 if this is indeterminate for this stream.
 void skip(long count)
          Skip a defined number of bytes.
 int skipLine(java.lang.String delim)
          Skip a single line from the stream.
 int tell()
          Returns the current byte offset from beginning
 
Methods inherited from class org.xbig.base.NativeObject
disconnectFromNativeObject, equals, getInstancePointer, hashCode, setInstancePointer, setInstancePointer, setInstancePointer, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xbig.base.INativeObject
disconnectFromNativeObject, getInstancePointer, setInstancePointer, setInstancePointer, setInstancePointer
 

Constructor Detail

MemoryDataStream

public MemoryDataStream(InstancePointer p)
This constructor is public for internal useage only! Do not use it!


MemoryDataStream

protected MemoryDataStream(InstancePointer p,
                           boolean remote)
Creates a Java wrapper object for an existing C++ object. If remote is set to 'true' this object cannot be deleted in Java.


MemoryDataStream

public MemoryDataStream(WithoutNativeObject val)
Allows creation of Java objects without C++ objects.

See Also:
WithoutNativeObject, INativeObject.disconnectFromNativeObject()

MemoryDataStream

public MemoryDataStream(VoidPointer pMem,
                        int size,
                        boolean freeOnClose)
Wrap an existing memory chunk in a stream.


MemoryDataStream

public MemoryDataStream(java.lang.String name,
                        VoidPointer pMem,
                        int size,
                        boolean freeOnClose)
Wrap an existing memory chunk in a named stream.


MemoryDataStream

public MemoryDataStream(IDataStream sourceStream,
                        boolean freeOnClose)
Create a stream which pre-buffers the contents of another stream.


MemoryDataStream

public MemoryDataStream(IDataStreamPtr sourceStream,
                        boolean freeOnClose)
Create a stream which pre-buffers the contents of another stream.


MemoryDataStream

public MemoryDataStream(java.lang.String name,
                        IDataStream sourceStream,
                        boolean freeOnClose)
Create a named stream which pre-buffers the contents of another stream.


MemoryDataStream

public MemoryDataStream(java.lang.String name,
                        IDataStreamPtr sourceStream,
                        boolean freeOnClose)
Create a named stream which pre-buffers the contents of another stream.


MemoryDataStream

public MemoryDataStream(int size,
                        boolean freeOnClose)
Create a stream with a brand new empty memory chunk.


MemoryDataStream

public MemoryDataStream(java.lang.String name,
                        int size,
                        boolean freeOnClose)
Create a named stream with a brand new empty memory chunk.

Method Detail

delete

public void delete()
Description copied from interface: INativeObject
Deletes the corresponding C++ object.

Subclasses must implement this but if the native instance was created by the underlying library the native call to dispose must not happen!

Specified by:
delete in interface INativeObject
Specified by:
delete in class NativeObject
See Also:
#remote

finalize

public void finalize()
Overrides:
finalize in class NativeObject

getPtr

public ShortPointer getPtr()
Get a pointer to the start of the memory block this stream holds.

Specified by:
getPtr in interface IMemoryDataStream

getCurrentPtr

public ShortPointer getCurrentPtr()
Get a pointer to the current position in the memory block this stream holds.

Specified by:
getCurrentPtr in interface IMemoryDataStream

read

public int read(VoidPointer buf,
                int count)
Description copied from interface: IDataStream
Read the requisite number of bytes from the stream, stopping at the end of the file.

Specified by:
read in interface IDataStream
Specified by:
read in interface IMemoryDataStream

readLine

public int readLine(BytePointer buf,
                    int maxCount,
                    java.lang.String delim)
Description copied from interface: IDataStream
Get a single line from the stream.

Specified by:
readLine in interface IDataStream
Specified by:
readLine in interface IMemoryDataStream

skipLine

public int skipLine(java.lang.String delim)
Description copied from interface: IDataStream
Skip a single line from the stream.

Specified by:
skipLine in interface IDataStream
Specified by:
skipLine in interface IMemoryDataStream

skip

public void skip(long count)
Description copied from interface: IDataStream
Skip a defined number of bytes. This can also be a negative value, in which case the file pointer rewinds a defined number of bytes.

Specified by:
skip in interface IDataStream
Specified by:
skip in interface IMemoryDataStream

seek

public void seek(int pos)
Description copied from interface: IDataStream
Repositions the read point to a specified byte.

Specified by:
seek in interface IDataStream
Specified by:
seek in interface IMemoryDataStream

tell

public int tell()
Description copied from interface: IDataStream
Returns the current byte offset from beginning

Specified by:
tell in interface IDataStream
Specified by:
tell in interface IMemoryDataStream

eof

public boolean eof()
Description copied from interface: IDataStream
Returns true if the stream has reached the end.

Specified by:
eof in interface IDataStream
Specified by:
eof in interface IMemoryDataStream

close

public void close()
Description copied from interface: IDataStream
Close the stream; this makes further operations invalid.

Specified by:
close in interface IDataStream
Specified by:
close in interface IMemoryDataStream

setFreeOnClose

public void setFreeOnClose(boolean free)
Sets whether or not to free the encapsulated memory on close.

Specified by:
setFreeOnClose in interface IMemoryDataStream

getName

public java.lang.String getName()
Specified by:
getName in interface IDataStream

getLine

public java.lang.String getLine(boolean trimAfter)
Returns a String containing the next line of data, optionally trimmed for whitespace.

Specified by:
getLine in interface IDataStream

getAsString

public java.lang.String getAsString()
Returns a String containing the entire stream.

Specified by:
getAsString in interface IDataStream

size

public int size()
Returns the total size of the data to be read from the stream, or 0 if this is indeterminate for this stream.

Specified by:
size in interface IDataStream


Copyright © 2007 netAllied GmbH. All Rights Reserved.