Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/AbstractGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/AbstractGrammar.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/AbstractGrammar.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/AbstractGrammar.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+
+/**
+ * The abstract IGrammar which is the Mother of all the grammars. It contains
+ * the transitions table.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractGrammar implements IGrammar
+{
+
+ /**
+ * Table of transitions. It's a two dimension array, the first dimension
+ * indice the states, the second dimension indices the Tag value, so it is
+ * 256 wide.
+ */
+ protected HashMap<Tag, GrammarTransition>[] transitions;
+
+ /** The grammar name */
+ protected String name;
+
+ /** The grammar's states */
+ protected IStates statesEnum;
+
+
+ /**
+ * Return the grammar's name
+ *
+ * @return The grammar name
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+ /**
+ * Set the grammar's name
+ *
+ * @param name
+ * the name to set
+ */
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+
+ /**
+ * Get the transition associated with the state and tag
+ *
+ * @param state
+ * The current state
+ * @param tag
+ * The current tag
+ * @return A valid transition if any, or null.
+ */
+ public GrammarTransition getTransition( int state, Tag tag )
+ {
+ return transitions[state].get( tag );
+ }
+
+
+ /**
+ * Get the states of the current grammar
+ *
+ * @return
+ * Returns the statesEnum.
+ */
+ public IStates getStatesEnum()
+ {
+ return statesEnum;
+ }
+
+
+ /**
+ * Set the states for this grammar
+ *
+ * @param statesEnum
+ * The statesEnum to set.
+ */
+ public void setStatesEnum( IStates statesEnum )
+ {
+ this.statesEnum = statesEnum;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.studio.dsmlv2.IGrammar#executeAction(org.apache.directory.studio.dsmlv2.Dsmlv2Container)
+ */
+ public void executeAction( Dsmlv2Container container ) throws XmlPullParserException, IOException
+ {
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = xpp.getEventType();
+ do
+ {
+ if ( eventType == XmlPullParser.START_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ }
+ else if ( eventType == XmlPullParser.END_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.END_STATE );
+ }
+ else if ( eventType == XmlPullParser.START_TAG )
+ {
+ processTag( container, Tag.START );
+ }
+ else if ( eventType == XmlPullParser.END_TAG )
+ {
+ processTag( container, Tag.END );
+ }
+ eventType = xpp.next();
+ }
+ while ( eventType != XmlPullParser.END_DOCUMENT );
+ }
+
+
+ /**
+ * Processes the task required in the grammar to the given tag type
+ *
+ * @param container
+ * the DSML container
+ * @param tagType
+ * the tag type
+ * @throws XmlPullParserException
+ * when an error occurs during the parsing
+ */
+ private void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
+ {
+ XmlPullParser xpp = container.getParser();
+
+ String tagName = xpp.getName().toLowerCase();
+
+ GrammarTransition transition = getTransition( container.getState(), new Tag( tagName, tagType ) );
+
+ if ( transition != null )
+ {
+ container.setState( transition.getNextState() );
+
+ if ( transition.hasAction() )
+ {
+ transition.getAction().action( container );
+ }
+ }
+ else
+ {
+ throw new XmlPullParserException( "The tag " + new Tag( tagName, tagType )
+ + " can't be found at this position", xpp, null );
+ }
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Container.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Container.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Container.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Container.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+/**
+ * This interface represents a container that can be used by the parser to store parsed information
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface Container
+{
+ /**
+ * Get the current grammar state
+ *
+ * @return Returns the current grammar state
+ */
+ int getState();
+
+
+ /**
+ * Set the new current state
+ *
+ * @param state
+ * The new state
+ */
+ void setState( int state );
+
+
+ /**
+ * Get the transition
+ *
+ * @return Returns the transition from the previous state to the new state
+ */
+ public int getTransition();
+
+
+ /**
+ * Update the transition from a state to another
+ *
+ * @param transition
+ * The transition to set
+ */
+ public void setTransition( int transition );
+
+
+ /**
+ * @return Returns the states.
+ */
+ public IStates getStates();
+
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/DsmlDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/DsmlDecorator.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/DsmlDecorator.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/DsmlDecorator.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+import org.dom4j.Element;
+
+
+/**
+ * This interface defines the methods that must be implemented to define a DSML Decorator
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface DsmlDecorator
+{
+ /**
+ * Converts the request/reponse to its XML representation in the DSMLv2 format
+ *
+ * @param root
+ * the root dom4j Element
+ * @return
+ * the dom4j Element corresponding to the entry.
+ */
+ public Element toDsml( Element root );
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2Container.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2Container.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2Container.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2Container.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+import org.apache.directory.studio.dsmlv2.reponse.BatchResponse;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest;
+import org.xmlpull.v1.XmlPullParser;
+
+
+/**
+ * This class represents the DSML Container.
+ * It used by the DSML Parser to store information.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Dsmlv2Container implements Container
+{
+ /** The current state of the decoding */
+ private int state;
+
+ /** The current transition */
+ private int transition;
+
+ /** Store the different states for debug purpose */
+ private IStates states;
+
+ /** The pool parser */
+ private XmlPullParser parser;
+
+ /** The BatchRequest of the parsing */
+ private BatchRequest batchRequest;
+
+ /** The BatchResponse of the parsing */
+ private BatchResponse batchResponse;
+
+ /** The associated grammar */
+ private AbstractGrammar grammar;
+
+
+ /**
+ * Gets the DSML Batch Request
+ *
+ * @return
+ * Returns the Batch Request
+ */
+ public BatchRequest getBatchRequest()
+ {
+ return batchRequest;
+ }
+
+
+ /**
+ * Sets the DSML Batch Request
+ *
+ * @param batchRequest
+ * the Batch Request to set
+ */
+ public void setBatchRequest( BatchRequest batchRequest )
+ {
+ this.batchRequest = batchRequest;
+ }
+
+
+ /**
+ * Gets the DSML Batch Response
+ *
+ * @return
+ * Returns the Batch Response
+ */
+ public BatchResponse getBatchResponse()
+ {
+ return batchResponse;
+ }
+
+
+ /**
+ * Sets the DSML Batch Request
+ *
+ * @param batchResponse
+ * the Batch Response to set
+ */
+ public void setBatchResponse( BatchResponse batchResponse )
+ {
+ this.batchResponse = batchResponse;
+ }
+
+
+ /**
+ * Gets the parser
+ *
+ * @return
+ * the parser
+ */
+ public XmlPullParser getParser()
+ {
+ return parser;
+ }
+
+
+ /**
+ * Sets the parser
+ *
+ * @param parser
+ * the parser to set
+ */
+ public void setParser( XmlPullParser parser )
+ {
+ this.parser = parser;
+ }
+
+
+ /**
+ * Get the current grammar state
+ *
+ * @return
+ * the current grammar state
+ */
+ public int getState()
+ {
+ return state;
+ }
+
+
+ /**
+ * Set the new current state
+ *
+ * @param state
+ * the new state
+ */
+ public void setState( int state )
+ {
+ this.state = state;
+ }
+
+
+ /**
+ * Get the transition
+ *
+ * @return
+ * the transition from the previous state to the new state
+ */
+ public int getTransition()
+ {
+ return transition;
+ }
+
+
+ /**
+ * Update the transition from a state to another
+ *
+ * @param transition
+ * the transition to set
+ */
+ public void setTransition( int transition )
+ {
+ this.transition = transition;
+ }
+
+
+ /**
+ * Get the states for this container's grammars
+ *
+ * @return
+ * the states.
+ */
+ public IStates getStates()
+ {
+ return states;
+ }
+
+
+ /**
+ * Gets the grammar
+ *
+ * @return
+ * the grammar
+ */
+ public AbstractGrammar getGrammar()
+ {
+ return grammar;
+ }
+
+
+ /**
+ * Sets the Grammar
+ *
+ * @param grammar
+ * the grammar to set
+ */
+ public void setGrammar( AbstractGrammar grammar )
+ {
+ this.grammar = grammar;
+ }
+
+
+ /**
+ * Get the transition associated with the state and tag
+ *
+ * @param state
+ * the current state
+ * @param tag
+ * the current tag
+ * @return
+ * a valid transition if any, or null.
+ */
+ public GrammarTransition getTransition( int state, Tag tag )
+ {
+ return grammar.getTransition( state, tag );
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2Parser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2Parser.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2Parser.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2Parser.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
+import org.apache.directory.studio.dsmlv2.request.BatchRequest;
+import org.apache.directory.studio.dsmlv2.request.Dsmlv2Grammar;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+
+/**
+ * This class represents the DSMLv2 Parser.
+ * It can be used to parse a DSMLv2 Request input.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Dsmlv2Parser
+{
+ /** The associated DSMLv2 container */
+ private Dsmlv2Container container;
+
+
+ /**
+ * Creates a new instance of Dsmlv2Parser.
+ *
+ * @throws XmlPullParserException
+ * if an error occurs while the initialization of the parser
+ */
+ public Dsmlv2Parser() throws XmlPullParserException
+ {
+ this.container = new Dsmlv2Container();
+
+ this.container.setGrammar( Dsmlv2Grammar.getInstance() );
+
+ XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+ factory.setNamespaceAware( true );
+ XmlPullParser xpp = factory.newPullParser();
+
+ container.setParser( xpp );
+ }
+
+
+ /**
+ * Sets the input file the parser is going to parse
+ *
+ * @param fileName
+ * the name of the file
+ * @throws FileNotFoundException
+ * if the file does not exist
+ * @throws XmlPullParserException
+ * if an error occurs in the parser
+ */
+ 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
+ * if an error occurs in the parser
+ */
+ public void setInput( InputStream inputStream, String inputEncoding ) throws XmlPullParserException
+ {
+ container.getParser().setInput( inputStream, inputEncoding );
+ }
+
+
+ /**
+ * Sets the input string the parser is going to parse
+ *
+ * @param str
+ * the string the parser is going to parse
+ * @throws XmlPullParserException
+ * if an error occurs in the parser
+ */
+ public void setInput( String str ) throws XmlPullParserException
+ {
+ container.getParser().setInput( new StringReader( str ) );
+ }
+
+
+ /**
+ * Launches the parsing on the input
+ *
+ * @throws XmlPullParserException
+ * when an unrecoverable error occurs
+ * @throws IOException
+ */
+ public void parse() throws XmlPullParserException, IOException
+ {
+ Dsmlv2Grammar grammar = Dsmlv2Grammar.getInstance();
+
+ grammar.executeAction( container );
+ }
+
+
+ /**
+ * Launches the parsing of the Batch Request only
+ *
+ * @throws XmlPullParserException
+ * if an error occurs in the parser
+ */
+ public void parseBatchRequest() throws XmlPullParserException
+ {
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = xpp.getEventType();
+ do
+ {
+ if ( eventType == XmlPullParser.START_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ }
+ else if ( eventType == XmlPullParser.END_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.END_STATE );
+ }
+ else if ( eventType == XmlPullParser.START_TAG )
+ {
+ processTag( container, Tag.START );
+ }
+ else if ( eventType == XmlPullParser.END_TAG )
+ {
+ processTag( container, Tag.END );
+ }
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+ null );
+ }
+ }
+ while ( container.getState() != Dsmlv2StatesEnum.BATCHREQUEST_START_TAG );
+ }
+
+
+ /**
+ * Processes the task required in the grammar to the given tag type
+ *
+ * @param container
+ * the DSML container
+ * @param tagType
+ * the tag type
+ * @throws XmlPullParserException
+ * when an error occurs during the parsing
+ */
+ private void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
+ {
+ XmlPullParser xpp = container.getParser();
+
+ String tagName = xpp.getName().toLowerCase();
+
+ GrammarTransition transition = container.getTransition( container.getState(), new Tag( tagName, tagType ) );
+
+ if ( transition != null )
+ {
+ container.setState( transition.getNextState() );
+
+ if ( transition.hasAction() )
+ {
+ transition.getAction().action( container );
+ }
+ }
+ else
+ {
+ throw new XmlPullParserException( "The tag " + new Tag( tagName, tagType )
+ + " can't be found at this position", xpp, null );
+ }
+ }
+
+
+ /**
+ * Gets the Batch Request or null if the it has not been parsed yet
+ *
+ * @return
+ * the Batch Request or null if the it has not been parsed yet
+ */
+ public BatchRequest getBatchRequest()
+ {
+ return container.getBatchRequest();
+ }
+
+
+ /**
+ * Gets the next Request or null if there's no more request
+ * @return
+ * the next Request or null if there's no more request
+ * @throws XmlPullParserException
+ * when an error occurs during the parsing
+ */
+ public LdapMessageCodec getNextRequest() throws XmlPullParserException
+ {
+ if ( container.getBatchRequest() == null )
+ {
+ parseBatchRequest();
+ }
+
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = xpp.getEventType();
+ do
+ {
+ while ( eventType == XmlPullParser.TEXT )
+ {
+ try
+ {
+ xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+ null );
+ }
+ eventType = xpp.getEventType();
+ }
+
+ if ( eventType == XmlPullParser.START_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ }
+ else if ( eventType == XmlPullParser.END_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.END_STATE );
+ return null;
+ }
+ else if ( eventType == XmlPullParser.START_TAG )
+ {
+ processTag( container, Tag.START );
+ }
+ else if ( eventType == XmlPullParser.END_TAG )
+ {
+ processTag( container, Tag.END );
+ }
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+ null );
+ }
+ }
+ while ( container.getState() != Dsmlv2StatesEnum.BATCHREQUEST_LOOP );
+
+ return container.getBatchRequest().getCurrentRequest();
+ }
+
+
+ /**
+ * Parses all the requests
+ *
+ * @throws XmlPullParserException
+ * when an error occurs during the parsing
+ */
+ public void parseAllRequests() throws XmlPullParserException
+ {
+ while ( getNextRequest() != null )
+ {
+ continue;
+ }
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2ResponseParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2ResponseParser.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2ResponseParser.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2ResponseParser.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
+import org.apache.directory.studio.dsmlv2.reponse.BatchResponse;
+import org.apache.directory.studio.dsmlv2.reponse.Dsmlv2ResponseGrammar;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+
+/**
+ * This class represents the DSMLv2 Parser.
+ * It can be used to parse a DSMLv2 Response input.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Dsmlv2ResponseParser
+{
+ /** The associated DSMLv2 container */
+ private Dsmlv2Container container;
+
+
+ /**
+ * Creates a new instance of Dsmlv2ResponseParser.
+ *
+ * @throws XmlPullParserException
+ * if an error occurs while the initialization of the parser
+ */
+ public Dsmlv2ResponseParser() throws XmlPullParserException
+ {
+ this.container = new Dsmlv2Container();
+
+ this.container.setGrammar( Dsmlv2ResponseGrammar.getInstance() );
+
+ XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+ factory.setNamespaceAware( true );
+ XmlPullParser xpp = factory.newPullParser();
+
+ container.setParser( xpp );
+ }
+
+
+ /**
+ * Sets the input string the parser is going to parse
+ *
+ * @param str
+ * the string the parser is going to parse
+ * @throws XmlPullParserException
+ * if an error occurs in the parser
+ */
+ public void setInput( String str ) throws FileNotFoundException, XmlPullParserException
+ {
+ container.getParser().setInput( new StringReader( str ) );
+ }
+
+
+ /**
+ * Sets the input file the parser is going to parse
+ *
+ * @param fileName
+ * the name of the file
+ * @throws FileNotFoundException
+ * if the file does not exist
+ * @throws XmlPullParserException
+ * if an error occurs in the parser
+ */
+ 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
+ * if an error occurs in the parser
+ */
+ public void setInput( InputStream inputStream, String inputEncoding ) throws XmlPullParserException
+ {
+ container.getParser().setInput( inputStream, inputEncoding );
+ }
+
+
+ /**
+ * Launches the parsing on the input
+ *
+ * @throws XmlPullParserException
+ * when an unrecoverable error occurs
+ * @throws IOException
+ */
+ public void parse() throws XmlPullParserException, IOException
+ {
+ Dsmlv2ResponseGrammar grammar = Dsmlv2ResponseGrammar.getInstance();
+
+ grammar.executeAction( container );
+ }
+
+
+ /**
+ * Launches the parsing of the Batch Response only
+ *
+ * @throws XmlPullParserException
+ * if an error occurs in the parser
+ */
+ public void parseBatchResponse() throws XmlPullParserException
+ {
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = xpp.getEventType();
+ do
+ {
+ if ( eventType == XmlPullParser.START_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ }
+ else if ( eventType == XmlPullParser.END_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.END_STATE );
+ }
+ else if ( eventType == XmlPullParser.START_TAG )
+ {
+ processTag( container, Tag.START );
+ }
+ else if ( eventType == XmlPullParser.END_TAG )
+ {
+ processTag( container, Tag.END );
+ }
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+ null );
+ }
+ }
+ while ( container.getState() != Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP );
+ }
+
+
+ /**
+ * Processes the task required in the grammar to the given tag type
+ *
+ * @param container
+ * the DSML container
+ * @param tagType
+ * the tag type
+ * @throws XmlPullParserException
+ * when an error occurs during the parsing
+ */
+ private void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
+ {
+ XmlPullParser xpp = container.getParser();
+
+ String tagName = xpp.getName().toLowerCase();
+
+ GrammarTransition transition = container.getTransition( container.getState(), new Tag( tagName, tagType ) );
+
+ if ( transition != null )
+ {
+ container.setState( transition.getNextState() );
+
+ if ( transition.hasAction() )
+ {
+ transition.getAction().action( container );
+ }
+ }
+ else
+ {
+ throw new XmlPullParserException( "The tag " + new Tag( tagName, tagType )
+ + " can't be found at this position", xpp, null );
+ }
+ }
+
+
+ /**
+ * Gets the Batch Response or null if the it has not been parsed yet
+ *
+ * @return
+ * the Batch Response or null if the it has not been parsed yet
+ */
+ public BatchResponse getBatchResponse()
+ {
+ return container.getBatchResponse();
+ }
+
+
+ /**
+ * Returns the next Request or null if there's no more request
+ * @return
+ * the next Request or null if there's no more request
+ * @throws XmlPullParserException
+ * when an error occurs during the parsing
+ */
+ public LdapResponseCodec getNextResponse() throws XmlPullParserException
+ {
+ if ( container.getBatchResponse() == null )
+ {
+ parseBatchResponse();
+ }
+
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = xpp.getEventType();
+ do
+ {
+ while ( eventType == XmlPullParser.TEXT )
+ {
+ try
+ {
+ xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+ null );
+ }
+ eventType = xpp.getEventType();
+ }
+
+ if ( eventType == XmlPullParser.START_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ }
+ else if ( eventType == XmlPullParser.END_DOCUMENT )
+ {
+ container.setState( Dsmlv2StatesEnum.END_STATE );
+ return null;
+ }
+ else if ( eventType == XmlPullParser.START_TAG )
+ {
+ processTag( container, Tag.START );
+ }
+ else if ( eventType == XmlPullParser.END_TAG )
+ {
+ processTag( container, Tag.END );
+ }
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+ null );
+ }
+ }
+ while ( container.getState() != Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP );
+
+ return container.getBatchResponse().getCurrentResponse();
+ }
+
+
+ /**
+ * Parses all the responses
+ *
+ * @throws XmlPullParserException
+ * when an error occurs during the parsing
+ */
+ public void parseAllResponses() throws XmlPullParserException
+ {
+ while ( getNextResponse() != null )
+ {
+ continue;
+ }
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2StatesEnum.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2StatesEnum.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2StatesEnum.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/Dsmlv2StatesEnum.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,807 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+/**
+ * This class store the Dsml grammar's constants. It is also used for debugging
+ * purpose
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class Dsmlv2StatesEnum implements IStates
+{
+ //====================================================
+ // <batchRequest> ... </batchRequest>
+ //====================================================
+ /** The <batchRequest> tag */
+ public static final int BATCHREQUEST_START_TAG = 104;
+
+ public static final int BATCHREQUEST_LOOP = 105;
+
+ /** The </batchRequest> tag */
+ public static final int BATCHREQUEST_END_TAG = 1;
+
+ //====================================================
+ // <abandonRequest> ... </abandonRequest>
+ //====================================================
+ /** The <abandonRequest> tag */
+ public static final int ABANDON_REQUEST_START_TAG = 2;
+
+ /** The <control> tag */
+ public static final int ABANDON_REQUEST_CONTROL_START_TAG = 4;
+
+ /** The </control> tag */
+ public static final int ABANDON_REQUEST_CONTROL_END_TAG = 5;
+
+ /** The <controlValue> tag */
+ public static final int ABANDON_REQUEST_CONTROLVALUE_START_TAG = 6;
+
+ /** The </controlValue> tag */
+ public static final int ABANDON_REQUEST_CONTROLVALUE_END_TAG = 7;
+
+ //====================================================
+ // <addRequest> ... </addRequest>
+ //====================================================
+ /** The <addRequest> tag */
+ public static final int ADD_REQUEST_START_TAG = 8;
+
+ /** The <control> tag */
+ public static final int ADD_REQUEST_CONTROL_START_TAG = 10;
+
+ /** The </control> tag */
+ public static final int ADD_REQUEST_CONTROL_END_TAG = 11;
+
+ /** The <controlValue> tag */
+ public static final int ADD_REQUEST_CONTROLVALUE_START_TAG = 12;
+
+ /** The </controlValue> tag */
+ public static final int ADD_REQUEST_CONTROLVALUE_END_TAG = 13;
+
+ /** The <attr> tag */
+ public static final int ADD_REQUEST_ATTR_START_TAG = 14;
+
+ /** The </attr> tag */
+ public static final int ADD_REQUEST_ATTR_END_TAG = 15;
+
+ /** The <value> tag */
+ public static final int ADD_REQUEST_VALUE_START_TAG = 16;
+
+ /** The </value> tag */
+ public static final int ADD_REQUEST_VALUE_END_TAG = 17;
+
+ //====================================================
+ // <authRequest> ... </authRequest>
+ //====================================================
+ /** The <authRequest> tag */
+ public static final int AUTH_REQUEST_START_TAG = 18;
+
+ /** The <control> tag */
+ public static final int AUTH_REQUEST_CONTROL_START_TAG = 20;
+
+ /** The </control> tag */
+ public static final int AUTH_REQUEST_CONTROL_END_TAG = 21;
+
+ /** The <controlValue> tag */
+ public static final int AUTH_REQUEST_CONTROLVALUE_START_TAG = 22;
+
+ /** The </controlValue> tag */
+ public static final int AUTH_REQUEST_CONTROLVALUE_END_TAG = 23;
+
+ //====================================================
+ // <compareRequest> ... </compareRequest>
+ //====================================================
+ /** The <compareRequest> tag */
+ public static final int COMPARE_REQUEST_START_TAG = 24;
+
+ /** The <control> tag */
+ public static final int COMPARE_REQUEST_CONTROL_START_TAG = 26;
+
+ /** The </control> tag */
+ public static final int COMPARE_REQUEST_CONTROL_END_TAG = 27;
+
+ /** The <controlValue> tag */
+ public static final int COMPARE_REQUEST_CONTROLVALUE_START_TAG = 28;
+
+ /** The </controlValue> tag */
+ public static final int COMPARE_REQUEST_CONTROLVALUE_END_TAG = 29;
+
+ /** The <assertion> tag */
+ public static final int COMPARE_REQUEST_ASSERTION_START_TAG = 30;
+
+ /** The </assertion> tag */
+ public static final int COMPARE_REQUEST_ASSERTION_END_TAG = 31;
+
+ /** The <value> tag */
+ public static final int COMPARE_REQUEST_VALUE_START_TAG = 32;
+
+ /** The </value> tag */
+ public static final int COMPARE_REQUEST_VALUE_END_TAG = 33;
+
+ //====================================================
+ // <delRequest> ... </delRequest>
+ //====================================================
+ /** The <delRequest> tag */
+ public static final int DEL_REQUEST_START_TAG = 34;
+
+ /** The <control> tag */
+ public static final int DEL_REQUEST_CONTROL_START_TAG = 36;
+
+ /** The </control> tag */
+ public static final int DEL_REQUEST_CONTROL_END_TAG = 37;
+
+ /** The <controlValue> tag */
+ public static final int DEL_REQUEST_CONTROLVALUE_START_TAG = 38;
+
+ /** The </controlValue> tag */
+ public static final int DEL_REQUEST_CONTROLVALUE_END_TAG = 39;
+
+ //====================================================
+ // <extendedRequest> ... </extendedRequest>
+ //====================================================
+ /** The <extendedRequest> tag */
+ public static final int EXTENDED_REQUEST_START_TAG = 40;
+
+ /** The <control> tag */
+ public static final int EXTENDED_REQUEST_CONTROL_START_TAG = 42;
+
+ /** The </control> tag */
+ public static final int EXTENDED_REQUEST_CONTROL_END_TAG = 43;
+
+ /** The <controlValue> tag */
+ public static final int EXTENDED_REQUEST_CONTROLVALUE_START_TAG = 44;
+
+ /** The </controlValue> tag */
+ public static final int EXTENDED_REQUEST_CONTROLVALUE_END_TAG = 45;
+
+ /** The <requestName> tag */
+ public static final int EXTENDED_REQUEST_REQUESTNAME_START_TAG = 46;
+
+ /** The </requestName> tag */
+ public static final int EXTENDED_REQUEST_REQUESTNAME_END_TAG = 47;
+
+ /** The <requestValue> tag */
+ public static final int EXTENDED_REQUEST_REQUESTVALUE_START_TAG = 48;
+
+ /** The </requestValue> tag */
+ public static final int EXTENDED_REQUEST_REQUESTVALUE_END_TAG = 49;
+
+ //====================================================
+ // <modDNRequest> ... </modDNRequest>
+ //====================================================
+ /** The <modDNRequest> tag */
+ public static final int MODIFY_DN_REQUEST_START_TAG = 50;
+
+ /** The <control> tag */
+ public static final int MODIFY_DN_REQUEST_CONTROL_START_TAG = 52;
+
+ /** The </control> tag */
+ public static final int MODIFY_DN_REQUEST_CONTROL_END_TAG = 53;
+
+ /** The <controlValue> tag */
+ public static final int MODIFY_DN_REQUEST_CONTROLVALUE_START_TAG = 54;
+
+ /** The </controlValue> tag */
+ public static final int MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG = 55;
+
+ //====================================================
+ // <modifyRequest> ... </modifyRequest>
+ //====================================================
+ /** The <modifyRequest> tag */
+ public static final int MODIFY_REQUEST_START_TAG = 56;
+
+ /** The <control> tag */
+ public static final int MODIFY_REQUEST_CONTROL_START_TAG = 58;
+
+ /** The </control> tag */
+ public static final int MODIFY_REQUEST_CONTROL_END_TAG = 59;
+
+ /** The <controlValue> tag */
+ public static final int MODIFY_REQUEST_CONTROLVALUE_START_TAG = 60;
+
+ /** The </controlValue> tag */
+ public static final int MODIFY_REQUEST_CONTROLVALUE_END_TAG = 61;
+
+ /** The <modification> tag */
+ public static final int MODIFY_REQUEST_MODIFICATION_START_TAG = 62;
+
+ /** The </modification> tag */
+ public static final int MODIFY_REQUEST_MODIFICATION_END_TAG = 63;
+
+ /** The <value> tag */
+ public static final int MODIFY_REQUEST_VALUE_START_TAG = 64;
+
+ /** The </value> tag */
+ public static final int MODIFY_REQUEST_VALUE_END_TAG = 65;
+
+ //====================================================
+ // <searchRequest> ... </searchRequest>
+ //====================================================
+ /** The <searchRequest> tag */
+ public static final int SEARCH_REQUEST_START_TAG = 66;
+
+ /** The <control> tag */
+ public static final int SEARCH_REQUEST_CONTROL_START_TAG = 68;
+
+ /** The </control> tag */
+ public static final int SEARCH_REQUEST_CONTROL_END_TAG = 69;
+
+ /** The <controlValue> tag */
+ public static final int SEARCH_REQUEST_CONTROLVALUE_START_TAG = 70;
+
+ /** The </controlValue> tag */
+ public static final int SEARCH_REQUEST_CONTROLVALUE_END_TAG = 71;
+
+ /** The <filter> tag */
+ public static final int SEARCH_REQUEST_FILTER_START_TAG = 72;
+
+ /** The </filter> tag */
+ public static final int SEARCH_REQUEST_FILTER_END_TAG = 73;
+
+ /** The <attributes> tag */
+ public static final int SEARCH_REQUEST_ATTRIBUTES_START_TAG = 74;
+
+ /** The </attributes> tag */
+ public static final int SEARCH_REQUEST_ATTRIBUTES_END_TAG = 75;
+
+ /** The <attribute> tag */
+ public static final int SEARCH_REQUEST_ATTRIBUTE_START_TAG = 76;
+
+ /** The </attribute> tag */
+ public static final int SEARCH_REQUEST_ATTRIBUTE_END_TAG = 77;
+
+ /** The <equalityMatch> tag */
+ public static final int SEARCH_REQUEST_EQUALITYMATCH_START_TAG = 84;
+
+ /** The <subStrings> tag */
+ public static final int SEARCH_REQUEST_SUBSTRINGS_START_TAG = 86;
+
+ /** The </subStrings> tag */
+ public static final int SEARCH_REQUEST_SUBSTRINGS_END_TAG = 87;
+
+ /** The <greaterOrEqual> tag */
+ public static final int SEARCH_REQUEST_GREATEROREQUAL_START_TAG = 88;
+
+ /** The <lessOrEqual> tag */
+ public static final int SEARCH_REQUEST_LESSOREQUAL_START_TAG = 90;
+
+ /** The <present> tag */
+ public static final int SEARCH_REQUEST_PRESENT_START_TAG = 92;
+
+ /** The <approxMatch> tag */
+ public static final int SEARCH_REQUEST_APPROXMATCH_START_TAG = 94;
+
+ /** The <extensibleMatch> tag */
+ public static final int SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG = 96;
+
+ /** The <value> tag */
+ public static final int SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_START_TAG = 109;
+
+ /** The </value> tag */
+ public static final int SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG = 110;
+
+ /** The <initial> tag */
+ public static final int SEARCH_REQUEST_INITIAL_START_TAG = 98;
+
+ /** The </initial> tag */
+ public static final int SEARCH_REQUEST_INITIAL_END_TAG = 99;
+
+ /** The <any> tag */
+ public static final int SEARCH_REQUEST_ANY_START_TAG = 100;
+
+ /** The </any> tag */
+ public static final int SEARCH_REQUEST_ANY_END_TAG = 101;
+
+ /** The <final> tag */
+ public static final int SEARCH_REQUEST_FINAL_START_TAG = 102;
+
+ /** The </final> tag */
+ public static final int SEARCH_REQUEST_FINAL_END_TAG = 103;
+
+ /** The <value> tag */
+ public static final int SEARCH_REQUEST_VALUE_START_TAG = 107;
+
+ /** The </value> tag */
+ public static final int SEARCH_REQUEST_VALUE_END_TAG = 108;
+
+ /** The Filter Loop state */
+ public static final int SEARCH_REQUEST_FILTER_LOOP = 106;
+
+ //****************
+ // DSML Response
+ //****************
+
+ /** The Batch Response Loop state */
+ public static final int BATCH_RESPONSE_LOOP = 200;
+
+ /** The Error Response Loop state */
+ public static final int ERROR_RESPONSE = 201;
+
+ /** The Message Start state */
+ public static final int MESSAGE_START = 202;
+
+ /** The Message End state */
+ public static final int MESSAGE_END = 203;
+
+ /** The Detail Start state */
+ public static final int DETAIL_START = 204;
+
+ /** The Detail End state */
+ public static final int DETAIL_END = 205;
+
+ /** The Extended Response state */
+ public static final int EXTENDED_RESPONSE = 206;
+
+ /** The Extended Response Control Start state */
+ public static final int EXTENDED_RESPONSE_CONTROL_START = 207;
+
+ /** The Extended Response Control End state */
+ public static final int EXTENDED_RESPONSE_CONTROL_END = 208;
+
+ /** The Extended Response Control Value Start state */
+ public static final int EXTENDED_RESPONSE_CONTROL_VALUE_START = 245;
+
+ /** The Extended Response Control Value End state */
+ public static final int EXTENDED_RESPONSE_CONTROL_VALUE_END = 246;
+
+ /** The Extended Response Result Code Start state */
+ public static final int EXTENDED_RESPONSE_RESULT_CODE_START = 209;
+
+ /** The Extended Response Result Code End state */
+ public static final int EXTENDED_RESPONSE_RESULT_CODE_END = 210;
+
+ /** The Extended Response Error Message Start state */
+ public static final int EXTENDED_RESPONSE_ERROR_MESSAGE_START = 211;
+
+ /** The Extended Response Error Message End state */
+ public static final int EXTENDED_RESPONSE_ERROR_MESSAGE_END = 212;
+
+ /** The Extended Response Referral Start state */
+ public static final int EXTENDED_RESPONSE_REFERRAL_START = 213;
+
+ /** The Extended Response Referral End state */
+ public static final int EXTENDED_RESPONSE_REFERRAL_END = 214;
+
+ /** The Response Name Start state */
+ public static final int RESPONSE_NAME_START = 215;
+
+ /** The Response Name End state */
+ public static final int RESPONSE_NAME_END = 216;
+
+ /** The Response Start state */
+ public static final int RESPONSE_START = 217;
+
+ /** The Response End state */
+ public static final int RESPONSE_END = 218;
+
+ /** The LDAP Result state */
+ public static final int LDAP_RESULT = 219;
+
+ /** The LDAP Result Control Start state */
+ public static final int LDAP_RESULT_CONTROL_START = 220;
+
+ /** The LDAP Result Control End state */
+ public static final int LDAP_RESULT_CONTROL_END = 221;
+
+ /** The LDAP Result Control Value Start state */
+ public static final int LDAP_RESULT_CONTROL_VALUE_START = 247;
+
+ /** The LDAP Result Control Value End state */
+ public static final int LDAP_RESULT_CONTROL_VALUE_END = 248;
+
+ /** The LDAP Result Result Code Start state */
+ public static final int LDAP_RESULT_RESULT_CODE_START = 222;
+
+ /** The LDAP Result Result Code End state */
+ public static final int LDAP_RESULT_RESULT_CODE_END = 223;
+
+ /** The LDAP Result Error Message Start state */
+ public static final int LDAP_RESULT_ERROR_MESSAGE_START = 224;
+
+ /** The LDAP Result Error Message End state */
+ public static final int LDAP_RESULT_ERROR_MESSAGE_END = 225;
+
+ /** The LDAP Result Referral Start state */
+ public static final int LDAP_RESULT_REFERRAL_START = 226;
+
+ /** The LDAP Result Referral End state */
+ public static final int LDAP_RESULT_REFERRAL_END = 227;
+
+ /** The LDAP Result End state */
+ public static final int LDAP_RESULT_END = 228;
+
+ /** The Search Response state */
+ public static final int SEARCH_RESPONSE = 229;
+
+ /** The Search Result Entry state */
+ public static final int SEARCH_RESULT_ENTRY = 230;
+
+ /** The Search Result Entry Control Start state */
+ public static final int SEARCH_RESULT_ENTRY_CONTROL_START = 231;
+
+ /** The Search Result Entry Control End state */
+ public static final int SEARCH_RESULT_ENTRY_CONTROL_END = 232;
+
+ /** The Search Result Entry Control Value Start state */
+ public static final int SEARCH_RESULT_ENTRY_CONTROL_VALUE_START = 249;
+
+ /** The Search Result Entry Control Value End state */
+ public static final int SEARCH_RESULT_ENTRY_CONTROL_VALUE_END = 250;
+
+ /** The Search Result Entry Attr Start state */
+ public static final int SEARCH_RESULT_ENTRY_ATTR_START = 233;
+
+ /** The Search Result Entry Attr End state */
+ public static final int SEARCH_RESULT_ENTRY_ATTR_END = 234;
+
+ /** The Search Result Entry Value Start state */
+ public static final int SEARCH_RESULT_ENTRY_VALUE_START = 235;
+
+ /** The Search Result Entry Value End state */
+ public static final int SEARCH_RESULT_ENTRY_VALUE_END = 236;
+
+ /** The Search Result Entry Loop state */
+ public static final int SEARCH_RESULT_ENTRY_LOOP = 237;
+
+ /** The Search Result Reference state */
+ public static final int SEARCH_RESULT_REFERENCE = 238;
+
+ /** The Search Result Reference Control Start state */
+ public static final int SEARCH_RESULT_REFERENCE_CONTROL_START = 239;
+
+ /** The Search Result Reference Control End state */
+ public static final int SEARCH_RESULT_REFERENCE_CONTROL_END = 240;
+
+ /** The Search Result Reference Control Value Start state */
+ public static final int SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START = 251;
+
+ /** The Search Result Reference Control Value End state */
+ public static final int SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END = 252;
+
+ /** The Search Result Reference Ref Start state */
+ public static final int SEARCH_RESULT_REFERENCE_REF_START = 241;
+
+ /** The Search Result Reference Ref End state */
+ public static final int SEARCH_RESULT_REFERENCE_REF_END = 242;
+
+ /** The Search Result Reference Loop state */
+ public static final int SEARCH_RESULT_REFERENCE_LOOP = 243;
+
+ /** The Search Result Done End state */
+ public static final int SEARCH_RESULT_DONE_END = 244;
+
+ /** The instance */
+ private static Dsmlv2StatesEnum instance = new Dsmlv2StatesEnum();
+
+
+ private Dsmlv2StatesEnum()
+ {
+ }
+
+
+ /**
+ * Get an instance of this class
+ *
+ * @return An instance on this class
+ */
+ public static Dsmlv2StatesEnum getInstance()
+ {
+ return instance;
+ }
+
+
+ /** Get the current state for a specified grammar */
+ public String getState( int state )
+ {
+ switch ( state )
+ {
+ case BATCHREQUEST_START_TAG:
+ return "BATCHREQUEST_START_TAG";
+ case BATCHREQUEST_LOOP:
+ return "BATCHREQUEST_LOOP";
+ case BATCHREQUEST_END_TAG:
+ return "BATCHREQUEST_END_TAG";
+ case ABANDON_REQUEST_START_TAG:
+ return "ABANDON_REQUEST_START_TAG";
+ case ABANDON_REQUEST_CONTROL_START_TAG:
+ return "ABANDON_REQUEST_CONTROL_START_TAG";
+ case ABANDON_REQUEST_CONTROL_END_TAG:
+ return "ABANDON_REQUEST_CONTROL_END_TAG";
+ case ABANDON_REQUEST_CONTROLVALUE_START_TAG:
+ return "ABANDON_REQUEST_CONTROLVALUE_START_TAG";
+ case ABANDON_REQUEST_CONTROLVALUE_END_TAG:
+ return "ABANDON_REQUEST_CONTROLVALUE_END_TAG";
+ case ADD_REQUEST_START_TAG:
+ return "ADD_REQUEST_START_TAG";
+ case ADD_REQUEST_CONTROL_START_TAG:
+ return "ADD_REQUEST_CONTROL_START_TAG";
+ case ADD_REQUEST_CONTROL_END_TAG:
+ return "ADD_REQUEST_CONTROL_END_TAG";
+ case ADD_REQUEST_CONTROLVALUE_START_TAG:
+ return "ADD_REQUEST_CONTROLVALUE_START_TAG";
+ case ADD_REQUEST_CONTROLVALUE_END_TAG:
+ return "ADD_REQUEST_CONTROLVALUE_END_TAG";
+ case ADD_REQUEST_ATTR_START_TAG:
+ return "ADD_REQUEST_ATTR_START_TAG";
+ case ADD_REQUEST_ATTR_END_TAG:
+ return "ADD_REQUEST_ATTR_END_TAG";
+ case ADD_REQUEST_VALUE_START_TAG:
+ return "ADD_REQUEST_VALUE_START_TAG";
+ case ADD_REQUEST_VALUE_END_TAG:
+ return "ADD_REQUEST_VALUE_END_TAG";
+ case AUTH_REQUEST_START_TAG:
+ return "AUTH_REQUEST_START_TAG";
+ case AUTH_REQUEST_CONTROL_START_TAG:
+ return "AUTH_REQUEST_CONTROL_START_TAG";
+ case AUTH_REQUEST_CONTROL_END_TAG:
+ return "AUTH_REQUEST_CONTROL_END_TAG";
+ case AUTH_REQUEST_CONTROLVALUE_START_TAG:
+ return "AUTH_REQUEST_CONTROLVALUE_START_TAG";
+ case AUTH_REQUEST_CONTROLVALUE_END_TAG:
+ return "AUTH_REQUEST_CONTROLVALUE_END_TAG";
+ case COMPARE_REQUEST_START_TAG:
+ return "COMPARE_REQUEST_START_TAG";
+ case COMPARE_REQUEST_CONTROL_START_TAG:
+ return "COMPARE_REQUEST_CONTROL_START_TAG";
+ case COMPARE_REQUEST_CONTROL_END_TAG:
+ return "COMPARE_REQUEST_CONTROL_END_TAG";
+ case COMPARE_REQUEST_CONTROLVALUE_START_TAG:
+ return "COMPARE_REQUEST_CONTROLVALUE_START_TAG";
+ case COMPARE_REQUEST_CONTROLVALUE_END_TAG:
+ return "COMPARE_REQUEST_CONTROLVALUE_END_TAG";
+ case COMPARE_REQUEST_ASSERTION_START_TAG:
+ return "COMPARE_REQUEST_ASSERTION_START_TAG";
+ case COMPARE_REQUEST_ASSERTION_END_TAG:
+ return "COMPARE_REQUEST_ASSERTION_END_TAG";
+ case COMPARE_REQUEST_VALUE_START_TAG:
+ return "COMPARE_REQUEST_VALUE_START_TAG";
+ case COMPARE_REQUEST_VALUE_END_TAG:
+ return "COMPARE_REQUEST_VALUE_END_TAG";
+ case DEL_REQUEST_START_TAG:
+ return "DEL_REQUEST_START_TAG";
+ case DEL_REQUEST_CONTROL_START_TAG:
+ return "DEL_REQUEST_CONTROL_START_TAG";
+ case DEL_REQUEST_CONTROL_END_TAG:
+ return "DEL_REQUEST_CONTROL_END_TAG";
+ case DEL_REQUEST_CONTROLVALUE_START_TAG:
+ return "DEL_REQUEST_CONTROLVALUE_START_TAG";
+ case DEL_REQUEST_CONTROLVALUE_END_TAG:
+ return "DEL_REQUEST_CONTROLVALUE_END_TAG";
+ case EXTENDED_REQUEST_START_TAG:
+ return "EXTENDED_REQUEST_START_TAG";
+ case EXTENDED_REQUEST_CONTROL_START_TAG:
+ return "EXTENDED_REQUEST_CONTROL_START_TAG";
+ case EXTENDED_REQUEST_CONTROL_END_TAG:
+ return "EXTENDED_REQUEST_CONTROL_END_TAG";
+ case EXTENDED_REQUEST_CONTROLVALUE_START_TAG:
+ return "EXTENDED_REQUEST_CONTROLVALUE_START_TAG";
+ case EXTENDED_REQUEST_CONTROLVALUE_END_TAG:
+ return "EXTENDED_REQUEST_CONTROLVALUE_END_TAG";
+ case EXTENDED_REQUEST_REQUESTNAME_START_TAG:
+ return "EXTENDED_REQUEST_REQUESTNAME_START_TAG";
+ case EXTENDED_REQUEST_REQUESTNAME_END_TAG:
+ return "EXTENDED_REQUEST_REQUESTNAME_END_TAG";
+ case EXTENDED_REQUEST_REQUESTVALUE_START_TAG:
+ return "EXTENDED_REQUEST_REQUESTVALUE_START_TAG";
+ case EXTENDED_REQUEST_REQUESTVALUE_END_TAG:
+ return "EXTENDED_REQUEST_REQUESTVALUE_END_TAG";
+ case MODIFY_DN_REQUEST_START_TAG:
+ return "MODIFY_DN_REQUEST_START_TAG";
+ case MODIFY_DN_REQUEST_CONTROL_START_TAG:
+ return "MODIFY_DN_REQUEST_CONTROL_START_TAG";
+ case MODIFY_DN_REQUEST_CONTROL_END_TAG:
+ return "MODIFY_DN_REQUEST_CONTROL_END_TAG";
+ case MODIFY_DN_REQUEST_CONTROLVALUE_START_TAG:
+ return "MODIFY_DN_REQUEST_CONTROLVALUE_START_TAG";
+ case MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG:
+ return "MODIFY_DN_REQUEST_CONTROLVALUE_END_TAG";
+ case MODIFY_REQUEST_START_TAG:
+ return "MODIFY_REQUEST_START_TAG";
+ case MODIFY_REQUEST_CONTROL_START_TAG:
+ return "MODIFY_REQUEST_CONTROL_START_TAG";
+ case MODIFY_REQUEST_CONTROL_END_TAG:
+ return "MODIFY_REQUEST_CONTROL_END_TAG";
+ case MODIFY_REQUEST_CONTROLVALUE_START_TAG:
+ return "MODIFY_REQUEST_CONTROLVALUE_START_TAG";
+ case MODIFY_REQUEST_CONTROLVALUE_END_TAG:
+ return "MODIFY_REQUEST_CONTROLVALUE_END_TAG";
+ case MODIFY_REQUEST_MODIFICATION_START_TAG:
+ return "MODIFY_REQUEST_MODIFICATION_START_TAG";
+ case MODIFY_REQUEST_MODIFICATION_END_TAG:
+ return "MODIFY_REQUEST_MODIFICATION_END_TAG";
+ case MODIFY_REQUEST_VALUE_START_TAG:
+ return "MODIFY_REQUEST_VALUE_START_TAG";
+ case MODIFY_REQUEST_VALUE_END_TAG:
+ return "MODIFY_REQUEST_VALUE_END_TAG";
+ case SEARCH_REQUEST_START_TAG:
+ return "SEARCH_REQUEST_START_TAG";
+ case SEARCH_REQUEST_CONTROL_START_TAG:
+ return "SEARCH_REQUEST_CONTROL_START_TAG";
+ case SEARCH_REQUEST_CONTROL_END_TAG:
+ return "SEARCH_REQUEST_CONTROL_END_TAG";
+ case SEARCH_REQUEST_CONTROLVALUE_START_TAG:
+ return "SEARCH_REQUEST_CONTROLVALUE_START_TAG";
+ case SEARCH_REQUEST_CONTROLVALUE_END_TAG:
+ return "SEARCH_REQUEST_CONTROLVALUE_END_TAG";
+ case SEARCH_REQUEST_FILTER_START_TAG:
+ return "SEARCH_REQUEST_FILTER_START_TAG";
+ case SEARCH_REQUEST_FILTER_END_TAG:
+ return "SEARCH_REQUEST_FILTER_END_TAG";
+ case SEARCH_REQUEST_ATTRIBUTES_START_TAG:
+ return "SEARCH_REQUEST_ATTRIBUTES_START_TAG";
+ case SEARCH_REQUEST_ATTRIBUTES_END_TAG:
+ return "SEARCH_REQUEST_ATTRIBUTES_END_TAG";
+ case SEARCH_REQUEST_ATTRIBUTE_START_TAG:
+ return "SEARCH_REQUEST_ATTRIBUTE_START_TAG";
+ case SEARCH_REQUEST_ATTRIBUTE_END_TAG:
+ return "SEARCH_REQUEST_ATTRIBUTE_END_TAG";
+ case SEARCH_REQUEST_EQUALITYMATCH_START_TAG:
+ return "SEARCH_REQUEST_EQUALITYMATCH_START_TAG";
+ case SEARCH_REQUEST_SUBSTRINGS_START_TAG:
+ return "SEARCH_REQUEST_SUBSTRINGS_START_TAG";
+ case SEARCH_REQUEST_SUBSTRINGS_END_TAG:
+ return "SEARCH_REQUEST_SUBSTRINGS_END_TAG";
+ case SEARCH_REQUEST_GREATEROREQUAL_START_TAG:
+ return "SEARCH_REQUEST_GREATEROREQUAL_START_TAG";
+ case SEARCH_REQUEST_LESSOREQUAL_START_TAG:
+ return "SEARCH_REQUEST_LESSOREQUAL_START_TAG";
+ case SEARCH_REQUEST_PRESENT_START_TAG:
+ return "SEARCH_REQUEST_PRESENT_START_TAG";
+ case SEARCH_REQUEST_APPROXMATCH_START_TAG:
+ return "SEARCH_REQUEST_APPROXMATCH_START_TAG";
+ case SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG:
+ return "SEARCH_REQUEST_EXTENSIBLEMATCH_START_TAG";
+ case SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_START_TAG:
+ return "SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_START_TAG";
+ case SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG:
+ return "SEARCH_REQUEST_EXTENSIBLEMATCH_VALUE_END_TAG";
+ case SEARCH_REQUEST_INITIAL_START_TAG:
+ return "SEARCH_REQUEST_INITIAL_START_TAG";
+ case SEARCH_REQUEST_INITIAL_END_TAG:
+ return "SEARCH_REQUEST_INITIAL_END_TAG";
+ case SEARCH_REQUEST_ANY_START_TAG:
+ return "SEARCH_REQUEST_ANY_START_TAG";
+ case SEARCH_REQUEST_ANY_END_TAG:
+ return "SEARCH_REQUEST_ANY_END_TAG";
+ case SEARCH_REQUEST_FINAL_START_TAG:
+ return "SEARCH_REQUEST_FINAL_START_TAG";
+ case SEARCH_REQUEST_FINAL_END_TAG:
+ return "SEARCH_REQUEST_FINAL_END_TAG";
+ case SEARCH_REQUEST_VALUE_START_TAG:
+ return "SEARCH_REQUEST_VALUE_START_TAG";
+ case SEARCH_REQUEST_VALUE_END_TAG:
+ return "SEARCH_REQUEST_VALUE_END_TAG";
+ case SEARCH_REQUEST_FILTER_LOOP:
+ return "SEARCH_REQUEST_FILTER_LOOP";
+
+ case BATCH_RESPONSE_LOOP:
+ return "BATCH_RESPONSE_LOOP";
+ case ERROR_RESPONSE:
+ return "ERROR_RESPONSE";
+ case MESSAGE_START:
+ return "MESSAGE_START";
+ case MESSAGE_END:
+ return "MESSAGE_END";
+ case DETAIL_START:
+ return "DETAIL_START";
+ case DETAIL_END:
+ return "DETAIL_END";
+ case EXTENDED_RESPONSE:
+ return "EXTENDED_RESPONSE";
+ case EXTENDED_RESPONSE_CONTROL_START:
+ return "EXTENDED_RESPONSE_CONTROL_START";
+ case EXTENDED_RESPONSE_CONTROL_END:
+ return "EXTENDED_RESPONSE_CONTROL_END";
+ case EXTENDED_RESPONSE_CONTROL_VALUE_START:
+ return "EXTENDED_RESPONSE_CONTROL_VALUE_START";
+ case EXTENDED_RESPONSE_CONTROL_VALUE_END:
+ return "EXTENDED_RESPONSE_CONTROL_VALUE_END";
+ case EXTENDED_RESPONSE_RESULT_CODE_START:
+ return "EXTENDED_RESPONSE_RESULT_CODE_START";
+ case EXTENDED_RESPONSE_RESULT_CODE_END:
+ return "EXTENDED_RESPONSE_RESULT_CODE_END";
+ case EXTENDED_RESPONSE_ERROR_MESSAGE_START:
+ return "EXTENDED_RESPONSE_ERROR_MESSAGE_START";
+ case EXTENDED_RESPONSE_ERROR_MESSAGE_END:
+ return "EXTENDED_RESPONSE_ERROR_MESSAGE_END";
+ case EXTENDED_RESPONSE_REFERRAL_START:
+ return "EXTENDED_RESPONSE_REFERRAL_START";
+ case EXTENDED_RESPONSE_REFERRAL_END:
+ return "EXTENDED_RESPONSE_REFERRAL_END";
+ case RESPONSE_NAME_START:
+ return "RESPONSE_NAME_START";
+ case RESPONSE_NAME_END:
+ return "RESPONSE_NAME_END";
+ case RESPONSE_START:
+ return "RESPONSE_START";
+ case RESPONSE_END:
+ return "RESPONSE_END";
+ case LDAP_RESULT:
+ return "LDAP_RESULT";
+ case LDAP_RESULT_CONTROL_START:
+ return "LDAP_RESULT_CONTROL_START";
+ case LDAP_RESULT_CONTROL_END:
+ return "LDAP_RESULT_CONTROL_END";
+ case LDAP_RESULT_CONTROL_VALUE_START:
+ return "LDAP_RESULT_CONTROL_VALUE_START";
+ case LDAP_RESULT_CONTROL_VALUE_END:
+ return "LDAP_RESULT_CONTROL_VALUE_END";
+ case LDAP_RESULT_RESULT_CODE_START:
+ return "LDAP_RESULT_RESULT_CODE_START";
+ case LDAP_RESULT_RESULT_CODE_END:
+ return "LDAP_RESULT_RESULT_CODE_END";
+ case LDAP_RESULT_ERROR_MESSAGE_START:
+ return "LDAP_RESULT_ERROR_MESSAGE_START";
+ case LDAP_RESULT_ERROR_MESSAGE_END:
+ return "LDAP_RESULT_ERROR_MESSAGE_END";
+ case LDAP_RESULT_REFERRAL_START:
+ return "LDAP_RESULT_REFERRAL_START";
+ case LDAP_RESULT_REFERRAL_END:
+ return "LDAP_RESULT_REFERRAL_END";
+ case LDAP_RESULT_END:
+ return "LDAP_RESULT_END";
+ case SEARCH_RESPONSE:
+ return "SEARCH_RESPONSE";
+ case SEARCH_RESULT_ENTRY:
+ return "SEARCH_RESULT_ENTRY";
+ case SEARCH_RESULT_ENTRY_CONTROL_START:
+ return "SEARCH_RESULT_ENTRY_CONTROL_START";
+ case SEARCH_RESULT_ENTRY_CONTROL_END:
+ return "SEARCH_RESULT_ENTRY_CONTROL_END";
+ case SEARCH_RESULT_ENTRY_CONTROL_VALUE_START:
+ return "SEARCH_RESULT_ENTRY_CONTROL_VALUE_START";
+ case SEARCH_RESULT_ENTRY_CONTROL_VALUE_END:
+ return "SEARCH_RESULT_ENTRY_CONTROL_VALUE_END";
+ case SEARCH_RESULT_ENTRY_ATTR_START:
+ return "SEARCH_RESULT_ENTRY_ATTR_START";
+ case SEARCH_RESULT_ENTRY_ATTR_END:
+ return "SEARCH_RESULT_ENTRY_ATTR_END";
+ case SEARCH_RESULT_ENTRY_VALUE_START:
+ return "SEARCH_RESULT_ENTRY_VALUE_START";
+ case SEARCH_RESULT_ENTRY_VALUE_END:
+ return "SEARCH_RESULT_ENTRY_VALUE_END";
+ case SEARCH_RESULT_ENTRY_LOOP:
+ return "SEARCH_RESULT_ENTRY_LOOP";
+ case SEARCH_RESULT_REFERENCE:
+ return "SEARCH_RESULT_REFERENCE";
+ case SEARCH_RESULT_REFERENCE_CONTROL_START:
+ return "SEARCH_RESULT_REFERENCE_CONTROL_START";
+ case SEARCH_RESULT_REFERENCE_CONTROL_END:
+ return "SEARCH_RESULT_REFERENCE_CONTROL_END";
+ case SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START:
+ return "SEARCH_RESULT_REFERENCE_CONTROL_VALUE_START";
+ case SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END:
+ return "SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END";
+ case SEARCH_RESULT_REFERENCE_REF_START:
+ return "SEARCH_RESULT_REFERENCE_REF_START";
+ case SEARCH_RESULT_REFERENCE_REF_END:
+ return "SEARCH_RESULT_REFERENCE_REF_END";
+ case SEARCH_RESULT_REFERENCE_LOOP:
+ return "SEARCH_RESULT_REFERENCE_LOOP";
+ case SEARCH_RESULT_DONE_END:
+ return "SEARCH_RESULT_DONE_END";
+
+ default:
+ return "UNKNOWN";
+ }
+ }
+}
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/GrammarAction.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/GrammarAction.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/GrammarAction.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/GrammarAction.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+/**
+ * A top level grammar class that store meta informations about the actions.
+ * Those informations are not mandatory, but they can be usefull for debugging.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class GrammarAction implements IAction
+{
+ /** The action's name */
+ protected String name;
+
+
+ /**
+ * Creates a new GrammarAction object.
+ *
+ * @param name
+ * the name of the create daction
+ */
+ public GrammarAction( String name )
+ {
+ this.name = name;
+ }
+
+
+ /**
+ * Print the action's name
+ *
+ * @return
+ * the action's name
+ */
+ public String toString()
+ {
+ return name;
+ }
+}
\ No newline at end of file
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/GrammarTransition.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/GrammarTransition.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/GrammarTransition.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/GrammarTransition.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+/**
+ * Define a transition between two states of a grammar. It stores the next
+ * state, and the action to execute while transiting.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class GrammarTransition
+{
+ /** The next state in the grammar */
+ private int nextState;
+
+ /** The action associated to the transition */
+ private GrammarAction action;
+
+ /** The current state */
+ private int currentState;
+
+
+ /**
+ * Creates a new GrammarTransition object.
+ *
+ * @param currentState
+ * The current transition
+ * @param nextState
+ * The target state
+ * @param action
+ * The action to execute. It could be null.
+ */
+ public GrammarTransition( int currentState, int nextState, GrammarAction action )
+ {
+ this.currentState = currentState;
+ this.nextState = nextState;
+ this.action = action;
+ }
+
+ /**
+ * Gets the target state
+ *
+ * @return
+ * the target state.
+ */
+ public int getNextState()
+ {
+ return nextState;
+ }
+
+
+ /**
+ * Tells if the transition has an associated action.
+ *
+ * @return
+ * <code>true</code> if an action has been asociated to the
+ * transition
+ */
+ public boolean hasAction()
+ {
+ return action != null;
+ }
+
+
+ /**
+ * Gets the action associated with the transition
+ *
+ * @return
+ * the action associated with the transition
+ */
+ public GrammarAction getAction()
+ {
+ return action;
+ }
+
+
+ /**
+ * Returns a representation of the transition as a string
+ *
+ * @param grammar
+ * the grammar which state we want a String from
+ * @param statesEnum
+ * the states enum that contains the states' names
+ * @return
+ * a representation of the transition as a string.
+ */
+ public String toString( int grammar, IStates statesEnum )
+ {
+
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( "Transition from <" ).append( statesEnum.getState( currentState ) ).append( "> to <" ).append(
+ statesEnum.getState( nextState ) ).append( ">, action : " ).append(
+ ( ( action == null ) ? "no action" : action.toString() ) ).append( ">" );
+
+ return sb.toString();
+ }
+}
\ No newline at end of file
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IAction.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IAction.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IAction.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IAction.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+import org.xmlpull.v1.XmlPullParserException;
+
+
+/**
+ * IAction interface just contains the method 'action' which must be implemented
+ * in all the implementong classes.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface IAction
+{
+ // ~ Methods
+ // ------------------------------------------------------------------------------------
+
+ /**
+ * The action to be executed.
+ *
+ * @param container
+ * the container which stores the current data
+ * @throws XmlPullParserException
+ * thrown if something went wrong.
+ */
+ public void action( Dsmlv2Container container ) throws XmlPullParserException;
+}
\ No newline at end of file
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IGrammar.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IGrammar.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IGrammar.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+import java.io.IOException;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+
+/**
+ * The interface which expose common behavior of a Gramar implementer.
+ */
+public interface IGrammar
+{
+ // ~ Methods
+ // ------------------------------------------------------------------------------------
+
+ /**
+ * This method, when called, execute an action on the current data stored in
+ * the container.
+ *
+ * @param container
+ * the DSML container
+ * @throws XmlPullParserException
+ * Thrown when an unrecoverable error occurs.
+ * @throws IOException
+ */
+ void executeAction( Dsmlv2Container container ) throws XmlPullParserException, IOException;
+
+
+ /**
+ * Get the grammar name
+ *
+ * @return Return the grammar's name
+ */
+ String getName();
+
+
+ /**
+ * Get the statesEnum for the current grammar
+ *
+ * @return The specific States Enum for the current grammar
+ */
+ IStates getStatesEnum();
+
+
+ /**
+ * Set the grammar's name
+ *
+ * @param name
+ * The grammar name
+ */
+ void setName( String name );
+}
\ No newline at end of file
Added: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IStates.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IStates.java?rev=796383&view=auto
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IStates.java (added)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/studio/dsmlv2/IStates.java Tue Jul 21 17:04:13 2009
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.studio.dsmlv2;
+
+
+/**
+ * This interface is used to store the different states of a grammar.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface IStates
+{
+ /** The initial state of every grammar */
+ static int INIT_GRAMMAR_STATE = 0;
+
+ /** The ending state for every grammars */
+ static int GRAMMAR_END = -1;
+
+ /** The END_STATE */
+ static int END_STATE = -1;
+
+
+ /**
+ * Gets the specified state
+ *
+ * @param state
+ * the identifier of the state
+ * @return
+ * the specified state
+ */
+ String getState( int state );
+}
\ No newline at end of file
|