com.judoscript.util
Class MsgBytes

java.lang.Object
  extended by com.judoscript.util.Ascii
      extended by com.judoscript.util.MsgBytes

public class MsgBytes
extends Ascii

This class is used to represent a subarray of bytes in an HTTP message.


Field Summary
protected  byte[] bytes
           
protected  int length
           
protected  int offset
           
 
Constructor Summary
MsgBytes()
           
MsgBytes(byte[] b, int off, int len)
           
 
Method Summary
 boolean equals(byte[] b, int off, int len)
          Compares the message bytes to the specified subarray of bytes.
 boolean equals(java.lang.String s)
          Compares the message bytes to the specified String object.
 boolean equalsIgnoreCase(byte[] b, int off, int len)
          Compares the message bytes to the specified subarray of bytes.
 boolean equalsIgnoreCase(java.lang.String s)
          Compares the message bytes to the specified String object.
 byte[] getBytes()
           
 int getBytes(byte[] buf, int buf_offset)
          Puts the message bytes in buf starting at buf_offset.
 byte[] getEffectiveBytes()
           
 MsgBytes getEffectiveMsgBytes()
           
 int getLength()
           
 int getOffset()
           
 int indexOf(int c)
           
 int indexOf(int index, int c)
           
 int indexOf(int index, java.lang.String s)
           
 int indexOf(java.lang.String s)
           
 int indexOfIgnoreCase(int index, java.lang.String s)
           
 int indexOfIgnoreCase(java.lang.String s)
           
 boolean isSet()
           
 int length()
           
 void reset()
           
 void setBytes(byte[] b, int off, int len)
           
 void setOffset(int ofst)
          Sets the new offset.
 void skip(int distance)
           
 boolean startsWith(int index, java.lang.String s)
           
 boolean startsWith(java.lang.String s)
          Returns true if the message bytes starts with the specified string.
 boolean startsWithIgnoreCase(int index, java.lang.String s)
           
 boolean startsWithIgnoreCase(java.lang.String s)
           
 java.lang.String substring(int idx, int len)
           
 long toDate(HttpDate d)
          Returns the message bytes parsed as a date.
 int toInteger()
          Returns the message bytes parsed as an unsigned integer.
 java.lang.String toString()
           
 void write(java.io.OutputStream out)
          Writes the message bytes to the specified output stream.
 
Methods inherited from class com.judoscript.util.Ascii
isAlpha, isDigit, isLower, isUpper, isWhite, parseInt, toLower, toUpper
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bytes

protected byte[] bytes

offset

protected int offset

length

protected int length
Constructor Detail

MsgBytes

public MsgBytes()

MsgBytes

public MsgBytes(byte[] b,
                int off,
                int len)
Method Detail

reset

public void reset()

setBytes

public void setBytes(byte[] b,
                     int off,
                     int len)

getBytes

public int getBytes(byte[] buf,
                    int buf_offset)
Puts the message bytes in buf starting at buf_offset.

Returns:
the number of bytes added to buf.

getBytes

public byte[] getBytes()

getOffset

public int getOffset()

getLength

public int getLength()

isSet

public boolean isSet()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

length

public int length()

toInteger

public int toInteger()
              throws java.lang.NumberFormatException
Returns the message bytes parsed as an unsigned integer.

Throws:
java.lang.NumberFormatException - if the integer format was invalid

toDate

public long toDate(HttpDate d)
            throws java.lang.IllegalArgumentException
Returns the message bytes parsed as a date.

Parameters:
d - the HttpDate object to use for parsing
Throws:
java.lang.IllegalArgumentException - if the date format was invalid

equals

public boolean equals(java.lang.String s)
Compares the message bytes to the specified String object.

Parameters:
s - the String to compare
Returns:
true if the comparison succeeded, false otherwise

equalsIgnoreCase

public boolean equalsIgnoreCase(java.lang.String s)
Compares the message bytes to the specified String object. Case is ignored in the comparison.

Parameters:
s - the String to compare
Returns:
true if the comparison succeeded, false otherwise

equals

public boolean equals(byte[] b,
                      int off,
                      int len)
Compares the message bytes to the specified subarray of bytes.

Parameters:
b - the bytes to compare
off - the start offset of the bytes
len - the length of the bytes
Returns:
true if the comparison succeeded, false otherwise

equalsIgnoreCase

public boolean equalsIgnoreCase(byte[] b,
                                int off,
                                int len)
Compares the message bytes to the specified subarray of bytes. Case is ignored in the comparison.

Parameters:
b - the bytes to compare
off - the start offset of the bytes
len - the length of the bytes
Returns:
true if the comparison succeeded, false otherwise

startsWith

public boolean startsWith(java.lang.String s)
Returns true if the message bytes starts with the specified string.

Parameters:
s - the string

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Writes the message bytes to the specified output stream.

Parameters:
out - the output stream
Throws:
java.io.IOException - if an I/O error has occurred

setOffset

public void setOffset(int ofst)
Sets the new offset.


skip

public void skip(int distance)

startsWithIgnoreCase

public boolean startsWithIgnoreCase(java.lang.String s)

startsWith

public boolean startsWith(int index,
                          java.lang.String s)

startsWithIgnoreCase

public boolean startsWithIgnoreCase(int index,
                                    java.lang.String s)

indexOf

public int indexOf(int index,
                   java.lang.String s)

indexOf

public int indexOf(java.lang.String s)

indexOfIgnoreCase

public int indexOfIgnoreCase(int index,
                             java.lang.String s)

indexOfIgnoreCase

public int indexOfIgnoreCase(java.lang.String s)

indexOf

public int indexOf(int index,
                   int c)

indexOf

public int indexOf(int c)

substring

public java.lang.String substring(int idx,
                                  int len)

getEffectiveBytes

public byte[] getEffectiveBytes()

getEffectiveMsgBytes

public MsgBytes getEffectiveMsgBytes()