You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/12/27 17:24:37 UTC
svn commit: r490528 - in
/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2:
Dsmlv2Parser.java Dsmlv2ResponseParser.java
Author: pamarcelot
Date: Wed Dec 27 08:24:37 2006
New Revision: 490528
URL: http://svn.apache.org/viewvc?view=rev&rev=490528
Log:
Updating Javadoc for DSMLv2 Response Parser. Updating the getNextRequest() and getNextResponse() methods so they check if the BatchRequest or BatchResponse has already been parsed (and parses it if not).
Modified:
directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Parser.java
directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Parser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Parser.java?view=diff&rev=490528&r1=490527&r2=490528
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Parser.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2Parser.java Wed Dec 27 08:24:37 2006
@@ -217,8 +217,7 @@
{
if ( container.getBatchRequest() == null )
{
- throw new XmlPullParserException( "The batch request needs to be parsed before parsing a request",
- container.getParser(), null );
+ parseBatchRequest();
}
XmlPullParser xpp = container.getParser();
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java?view=diff&rev=490528&r1=490527&r2=490528
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-dsml-parser/src/main/java/org/apache/directory/ldapstudio/dsmlv2/Dsmlv2ResponseParser.java Wed Dec 27 08:24:37 2006
@@ -33,12 +33,22 @@
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
-
+/**
+ * The DSMLv2 Response Parser can be used to parse a Response in DSMLv2 format.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
public class Dsmlv2ResponseParser
{
private Dsmlv2Container container;
+ /**
+ * Creates a new instance of Dsmlv2ResponseParser.
+ *
+ * @throws XmlPullParserException
+ */
public Dsmlv2ResponseParser() throws XmlPullParserException
{
this.container = new Dsmlv2Container();
@@ -52,26 +62,51 @@
container.setParser( xpp );
}
-
+ /**
+ * Sets the String the parser is going to parse
+ *
+ * @param str
+ * the String to parse
+ * @throws XmlPullParserException
+ */
public void setInput( String str ) throws FileNotFoundException, XmlPullParserException
{
container.getParser().setInput( new StringReader( str ) );
}
-
+ /**
+ * Sets the input file the parser is going to process
+ *
+ * @param fileName
+ * The name of the file to parse
+ * @throws FileNotFoundException
+ * @throws XmlPullParserException
+ */
public void setInputFile( String fileName ) throws FileNotFoundException, XmlPullParserException
{
Reader reader = new FileReader( fileName );
container.getParser().setInput( reader );
}
-
+ /**
+ * Sets the input stream the parser is going to process.
+ *
+ * @param inputStream
+ * contains a raw byte input stream of possibly unknown encoding (when inputEncoding is null)
+ * @param inputEncoding
+ * if not null it MUST be used as encoding for inputStream
+ * @throws XmlPullParserException
+ */
public void setInput( InputStream inputStream, String inputEncoding ) throws XmlPullParserException
{
container.getParser().setInput( inputStream, inputEncoding );
}
-
+ /**
+ * Launches the parsing on the input
+ *
+ * @throws Exception
+ */
public void parse() throws Exception
{
Dsmlv2ResponseGrammar grammar = Dsmlv2ResponseGrammar.getInstance();
@@ -79,7 +114,11 @@
grammar.executeAction( container );
}
-
+ /**
+ * Parses the initial Batch Response
+ *
+ * @throws XmlPullParserException
+ */
public void parseBatchResponse() throws XmlPullParserException
{
XmlPullParser xpp = container.getParser();
@@ -116,7 +155,15 @@
while ( container.getState() != Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP );
}
-
+ /**
+ * Processes the parsing for a given Tag
+ *
+ * @param container
+ * the parser container
+ * @param tagType
+ * the Tag
+ * @throws XmlPullParserException
+ */
private void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
{
XmlPullParser xpp = container.getParser();
@@ -141,7 +188,12 @@
}
}
-
+ /**
+ * Gets the parsed BatchResponqe.
+ *
+ * @return
+ * the parsed BatchResponse
+ */
public BatchResponse getBatchResponse()
{
return container.getBatchResponse();
@@ -158,8 +210,7 @@
{
if ( container.getBatchResponse() == null )
{
- throw new XmlPullParserException( "The batch response needs to be parsed before parsing a response",
- container.getParser(), null );
+ parseBatchResponse();
}
XmlPullParser xpp = container.getParser();
@@ -213,7 +264,11 @@
return container.getBatchResponse().getCurrentResponse();
}
-
+ /**
+ * Parses all the responses until the end of the document
+ *
+ * @throws Exception
+ */
public void parseAllResponses() throws Exception
{
while ( getNextResponse() != null )