org.apache.ws.commons.tcpmon.core.filter
Class StreamUtil

java.lang.Object
  extended by org.apache.ws.commons.tcpmon.core.filter.StreamUtil

public class StreamUtil
extends Object

Class containing utility methods to work with streams.


Method Summary
static String getAsciiString(Stream stream, int begin, int end)
          Convert a part of a stream to a string, using the ASCII charset encoding.
static void insertAsciiString(Stream stream, String s)
           
static void insertInt(Stream stream, int i)
          Insert an integer in little endian byte order.
static void insertShort(Stream stream, int s)
          Insert a short integer in little endian byte order.
static int readUShort(Stream stream)
          Reads unsigned short in little endian byte order.
static int search(Stream stream, byte[][] patterns)
          Search the stream for occurrences of given patterns.
static int searchEndOfLine(Stream stream)
          Search the available data in the stream for the first occurrence of the end of line sequence (\r\n).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

searchEndOfLine

public static int searchEndOfLine(Stream stream)
Search the available data in the stream for the first occurrence of the end of line sequence (\r\n).

Parameters:
stream - the stream to search in
Returns:
the offset relative to the current position in the stream where the first occurrence of the EOL sequence has been found, or -1 if there is no EOL sequence in the available part of the stream

getAsciiString

public static String getAsciiString(Stream stream,
                                    int begin,
                                    int end)
Convert a part of a stream to a string, using the ASCII charset encoding.


insertAsciiString

public static void insertAsciiString(Stream stream,
                                     String s)

search

public static int search(Stream stream,
                         byte[][] patterns)
Search the stream for occurrences of given patterns. If an occurrence is found, the method will skip all content in the stream before the position where the pattern was found. Otherwise it will skip as much content as possible.

Parameters:
stream - the stream to search
patterns - the patterns to search for
Returns:
the index of the pattern that matches, or -1 if no occurrence has been found

readUShort

public static int readUShort(Stream stream)
Reads unsigned short in little endian byte order.

Parameters:
stream -
Returns:

insertInt

public static void insertInt(Stream stream,
                             int i)
Insert an integer in little endian byte order.

Parameters:
stream -
i -

insertShort

public static void insertShort(Stream stream,
                               int s)
Insert a short integer in little endian byte order.

Parameters:
stream -
s -


Copyright © The Apache Software Foundation. All Rights Reserved.