net.rim.device.api.io
Class ScanLine

java.lang.Object
  |
  +--net.rim.device.api.io.LineReader
        |
        +--net.rim.device.api.io.ScanLine

public final class ScanLine
extends LineReader

Utility class for reading out CRLF delimited lines from a SharedInputStream.

Sample code

ScanLine scanLine = new ScanLine( sharedInputStream );
int startPosition = sharedInputStream.getCurrentPosition() - scanLine.lengthUnreadData();
sharedInputStream.setCurrentPosition( startPosition );

Since:
JDE 4.0.0

Field Summary
 
Fields inherited from class net.rim.device.api.io.LineReader
_buffer, _bufferLength, _bufferOffset, _stream, BUFFER_LENGTH
 
Constructor Summary
ScanLine(SharedInputStream stream)
          Creates a new ScanLine instance.
 
Method Summary
 int searchForBoundary(byte[] boundary)
          Searches for middle and end boundaries.
 
Methods inherited from class net.rim.device.api.io.LineReader
getBuffer, getBufferLength, getBufferOffset, getStream, lengthUnreadData, readLine, setBufferLength, setBufferOffset
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScanLine

public ScanLine(SharedInputStream stream)
Creates a new ScanLine instance.
Parameters:
stream - Shared input stream from which to read the lines.
Since:
JDE 4.0.0
Method Detail

searchForBoundary

public int searchForBoundary(byte[] boundary)
                      throws IOException
Searches for middle and end boundaries.

MIME uses this method to find the middle and end boundaries.

Parameters:
boundary - Boundary to search for.
Returns:
An integer value in which the lower bit tells if this is the final boundary or not and the remaining bits provide the number of positions to move back in the stream to the front of the boundary.
Throws:
IllegalArugmentException - If you provide a null boundary, or one with a length larger than 70.
IOException - If end of line reached and no boundary located.
Since:
JDE 4.0.0



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.