jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/http HTTPParserImpl.java,1.8,1.9
Leo Simons <[email protected]>
| Newsgroups | gmane.comp.java.jicarilla.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/http
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30049/platform/components/http/impl/src/java/org/jicarilla/http
Modified Files:
HTTPParserImpl.java
Log Message:
move some code around; add a little more docs.
Index: HTTPParserImpl.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/http/HTTPParserImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- HTTPParserImpl.java 31 Mar 2004 19:42:53 -0000 1.8
+++ HTTPParserImpl.java 31 Mar 2004 20:36:58 -0000 1.9
@@ -833,7 +833,7 @@
// state = done
// 4) else -- state = look for chunk contents
getContext().skipLF();
- markFieldLimit();
+ getContext().markFieldLimit();
getContext().foundChunkSize( getContext().getAndResetView() );
if( getContext().chunkSizeLeft == 0 )
@@ -1007,7 +1007,7 @@
*/
protected void foundStartLineFirstField()
{
- markFieldLimit();
+ getContext().markFieldLimit();
getHandler().foundStartLineFirstField(
getContext().getAndResetView() );
@@ -1020,7 +1020,7 @@
*/
protected void foundStartLineSecondField()
{
- markFieldLimit();
+ getContext().markFieldLimit();
getHandler().foundStartLineSecondField(
getContext().getAndResetView() );
@@ -1036,7 +1036,7 @@
getContext().skipLF();
//getContext().skipCRLF();
- markFieldLimit();
+ getContext().markFieldLimit();
getHandler().foundStartLineThirdField(
getContext().getAndResetView() );
@@ -1169,22 +1169,6 @@
}
}
- // ----------------------------------------------------------------------
- // Miscelleneous Helpers
- // ----------------------------------------------------------------------
-
- /**
- * Update the current buffer {@link Context#view view}, setting its
- * {@link ByteBuffer#limit(int) limit} to the current location. Used
- * during state transitions.
- */
- protected void markFieldLimit()
- {
- getContext().view.limit(
- getContext().source.position() -
- getContext().slice - 1 );
- }
-
/**
* Interact with the {@link m_handler handler} to determine what body type
* to expect and handle the state transition associated with that body
@@ -1217,6 +1201,9 @@
*/
protected final class Context
{
+ // ------------------------------------------------------------------
+ // Properties
+ // ------------------------------------------------------------------
/** The state machine state (used in the big switch/case) */
public int state;
@@ -1275,16 +1262,32 @@
*/
public int chunkSizeLeft;
+ // ------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------
+ /**
+ * Create a new context.
+ *
+ * @see #recycle() if you don't really need a new instance, but simply
+ * clearing out the current one will do as well, use
+ * <code>recycle()</code> instead.
+ */
protected Context()
{
recycle();
}
+ /**
+ * Get the next character from the source.
+ *
+ * @return the next character.
+ */
public char next()
{
ch = (char)source.get();
return ch;
}
+ /** Move the source back one character. */
public void prev()
{
Assert.assertTrue( source.position() > 0 );
@@ -1309,9 +1312,7 @@
return tmp;
}
- /**
- * Create a new view of the current source buffer.
- */
+ /** Create a new view of the current source buffer. */
public ByteBuffer newView()
{
view = source.slice();
@@ -1446,7 +1447,7 @@
* <code>MAX_BUFFER_SIZE</code> and we're not currently reading
* the body of a message.
*/
- private void checkAgainstReallyBigBuffers( final int bufferSize )
+ protected void checkAgainstReallyBigBuffers( final int bufferSize )
throws HTTPException
{
if( state < LOOKING_FOR_BODY || state >= LOOKING_FOR_TRAILER )
@@ -1461,6 +1462,11 @@
}
}
+ /**
+ * Sets {@link chunkSizeLeft}.
+ *
+ * @param size how much chunk is left to parse.
+ */
public void foundChunkSize( ByteBuffer size )
{
// todo: support chunked transfer coding
@@ -1470,5 +1476,17 @@
// 3) set chunkSizeLeft
}
+ /**
+ * Update the current buffer {@link Context#view view}, setting its
+ * {@link ByteBuffer#limit(int) limit} to the current location. Used
+ * during state transitions.
+ */
+ public void markFieldLimit()
+ {
+ getContext().view.limit(
+ getContext().source.position() -
+ getContext().slice - 1 );
+ }
+
}
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click