org.w3c.www.http
Class BasicValue

java.lang.Object
  extended by org.w3c.www.http.BasicValue
All Implemented Interfaces:
java.lang.Cloneable, HeaderValue
Direct Known Subclasses:
DAVIfList, DAVStatusURIList, DAVTimeout, HttpAccept, HttpAcceptCharset, HttpAcceptCharsetList, HttpAcceptEncoding, HttpAcceptEncodingList, HttpAcceptLanguage, HttpAcceptLanguageList, HttpAcceptList, HttpBag, HttpCacheControl, HttpChallenge, HttpContentRange, HttpCookieList, HttpCredential, HttpDate, HttpEntityTag, HttpEntityTagList, HttpExtList, HttpInteger, HttpMimeType, HttpParamList, HttpRange, HttpRangeList, HttpSetCookieList, HttpString, HttpTokenList, HttpWarning, HttpWarningList

public abstract class BasicValue
extends java.lang.Object
implements HeaderValue, java.lang.Cloneable


Field Summary
protected  boolean isValid
          Are the parsed values up to date with the lastly set unparsed value ?
protected  byte[] raw
          The header value, as a byte array, if available.
protected  int rlen
          The length of the byte value in case the above buffer is shared.
protected  int roff
          The offset of the value in the above buffer, in case the buffer is shared.
 
Constructor Summary
BasicValue()
           
 
Method Summary
 void addBytes(byte[] buf, int off, int len)
          HeaderValue implementation - Add these bytes to the header raw value.
 void appendValue(org.w3c.www.http.HttpBuffer buf)
          Append this header value to the given output buffer.
protected  void checkByteValue()
          Compute the new RFC822 compatible representation of this header value.
protected  java.lang.Object clone()
           
 void emit(java.io.OutputStream out)
          HeaderValue implementation - Emit this header value to the given output stream.
protected  void error(java.lang.String msg)
          Emit a parsing error.
abstract  java.lang.Object getValue()
          HeaderValue implemenntation - Get this header value.
protected  void invalidateByteValue()
          Invalidate the current byte value for this header, if any.
protected abstract  void parse()
          Parse this header value into its various components.
 void setBytes(byte[] buf, int off, int len)
          HeaderValue implementation - Reset the header byte value.
 void setString(java.lang.String strval)
          Set this Header Value by parsing the given String.
 java.lang.String toExternalForm()
          Return a String encoding this header value in an HTTP compatible way.
 java.lang.String toString()
          Print this header value as it would be emited.
protected abstract  void updateByteValue()
          Update the RFC822 compatible header value for this object.
protected  void validate()
          Validate the parsed value according to the last set raw value.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

raw

protected byte[] raw
The header value, as a byte array, if available.


roff

protected int roff
The offset of the value in the above buffer, in case the buffer is shared.


rlen

protected int rlen
The length of the byte value in case the above buffer is shared.


isValid

protected boolean isValid
Are the parsed values up to date with the lastly set unparsed value ?

Constructor Detail

BasicValue

public BasicValue()
Method Detail

parse

protected abstract void parse()
                       throws HttpParserException
Parse this header value into its various components.

Throws:
HttpParserException - if unable to parse.

updateByteValue

protected abstract void updateByteValue()
Update the RFC822 compatible header value for this object.


checkByteValue

protected final void checkByteValue()
Compute the new RFC822 compatible representation of this header value. If our value is up to date, we just return, otherwise, the abstract updateByteValue is called to perform the job.


validate

protected final void validate()
                       throws HttpInvalidValueException
Validate the parsed value according to the last set raw value. This will trigger the header value parsing, if it is required at this point.

Throws:
HttpInvalidValueException - If the value couldn't be parsed properly.

invalidateByteValue

protected void invalidateByteValue()
Invalidate the current byte value for this header, if any.


error

protected void error(java.lang.String msg)
              throws HttpParserException
Emit a parsing error.

Parameters:
msg - The error message.
Throws:
HttpParserException - If the parsing failed.

appendValue

public void appendValue(org.w3c.www.http.HttpBuffer buf)
Append this header value to the given output buffer.

Specified by:
appendValue in interface HeaderValue
Parameters:
buf - The buffer to append the byte value to.

toExternalForm

public java.lang.String toExternalForm()
Return a String encoding this header value in an HTTP compatible way.

Specified by:
toExternalForm in interface HeaderValue
Returns:
A String.

toString

public java.lang.String toString()
Print this header value as it would be emited.

Overrides:
toString in class java.lang.Object
Returns:
A String representation of this header value.

emit

public void emit(java.io.OutputStream out)
          throws java.io.IOException
HeaderValue implementation - Emit this header value to the given output stream.

Specified by:
emit in interface HeaderValue
Parameters:
out - The output stream to emit the header value to.
Throws:
java.io.IOException - If some IO error occured.

addBytes

public void addBytes(byte[] buf,
                     int off,
                     int len)
HeaderValue implementation - Add these bytes to the header raw value.

Specified by:
addBytes in interface HeaderValue
Parameters:
buf - The byte buffer containing some part of the header value.
off - The offset of the header value in above buffer.
len - The length of the header value in above buffer.

setBytes

public void setBytes(byte[] buf,
                     int off,
                     int len)
HeaderValue implementation - Reset the header byte value.

Specified by:
setBytes in interface HeaderValue
Parameters:
buf - The byte buffer containing some part of the header value.
off - The offset of the header value in above buffer.
len - The length of the header value in above buffer.

setString

public void setString(java.lang.String strval)
Set this Header Value by parsing the given String.

Parameters:
strval - The String value for that object.

getValue

public abstract java.lang.Object getValue()
HeaderValue implemenntation - Get this header value.

Specified by:
getValue in interface HeaderValue
Returns:
An object representing the parsed value for this header.

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException