You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/02/29 01:41:54 UTC
svn commit: r1294918 -
/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/
Author: elecharny
Date: Wed Feb 29 00:41:53 2012
New Revision: 1294918
URL: http://svn.apache.org/viewvc?rev=1294918&view=rev
Log:
Updated the javadoc, plus minor code refactoring
Modified:
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/AbstractDsmlMessageDecorator.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/AbstractGrammar.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Action.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Container.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlControl.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlDecorator.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Container.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Parser.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2ResponseParser.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Grammar.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/GrammarAction.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/GrammarTransition.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/ParserUtils.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Tag.java
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/AbstractDsmlMessageDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/AbstractDsmlMessageDecorator.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/AbstractDsmlMessageDecorator.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/AbstractDsmlMessageDecorator.java Wed Feb 29 00:41:53 2012
@@ -33,16 +33,18 @@ import org.apache.directory.shared.ldap.
/**
* An abstract DSML Message decorator base class.
*
+ * @param <M> The message to decorate
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public abstract class AbstractDsmlMessageDecorator<E extends Message>
- implements DsmlDecorator<E>, Message
+public abstract class AbstractDsmlMessageDecorator<M extends Message>
+ implements DsmlDecorator<M>, Message
{
/** The LDAP message codec */
private final LdapApiService codec;
/** The LDAP message */
- private final E message;
+ private final M message;
/** Map of message controls using OID Strings for keys and Control values */
private final Map<String, Control> controls;
@@ -51,7 +53,13 @@ public abstract class AbstractDsmlMessag
private DsmlControl<? extends Control> currentControl;
- public AbstractDsmlMessageDecorator( LdapApiService codec, E message )
+ /**
+ * Create a new instance of AbstractDsmlMessageDecorator
+ *
+ * @param codec The codec to use
+ * @param message The message to decorate
+ */
+ public AbstractDsmlMessageDecorator( LdapApiService codec, M message )
{
this.codec = codec;
this.message = message;
@@ -70,6 +78,9 @@ public abstract class AbstractDsmlMessag
}
+ /**
+ * @return The codec to use to encode or decode this message
+ */
public LdapApiService getCodecService()
{
return codec;
@@ -206,7 +217,7 @@ public abstract class AbstractDsmlMessag
/**
* {@inheritDoc}
*/
- public E getDecorated()
+ public M getDecorated()
{
return message;
}
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/AbstractGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/AbstractGrammar.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/AbstractGrammar.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/AbstractGrammar.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -30,14 +30,13 @@ import org.xmlpull.v1.XmlPullParserExcep
/**
- * The abstract IGrammar which is the Mother of all the grammars. It contains
+ * The abstract Grammar 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>
*/
public abstract class AbstractGrammar implements Grammar
{
-
/**
* Table of transitions. It's a two dimension array, the first dimension
* indexes the states, the second dimension indexes the Tag value, so it is
@@ -53,7 +52,7 @@ public abstract class AbstractGrammar im
/**
- * Return the grammar's name
+ * Returns the grammar's name
*
* @return The grammar name
*/
@@ -64,10 +63,9 @@ public abstract class AbstractGrammar im
/**
- * Set the grammar's name
+ * Sets the grammar's name
*
- * @param name
- * the name to set
+ * @param name the name to set
*/
public void setName( String name )
{
@@ -76,12 +74,10 @@ public abstract class AbstractGrammar im
/**
- * Get the transition associated with the state and tag
+ * Gets the transition associated with the state and tag
*
- * @param state
- * The current state
- * @param tag
- * The current tag
+ * @param state The current state
+ * @param tag The current tag
* @return A valid transition if any, or null.
*/
public GrammarTransition getTransition( Enum<Dsmlv2StatesEnum> state, Tag tag )
@@ -91,10 +87,9 @@ public abstract class AbstractGrammar im
/**
- * Get the states of the current grammar
+ * Gets the states of the current grammar
*
- * @return
- * Returns the statesEnum.
+ * @return Returns the statesEnum.
*/
public Enum<Dsmlv2StatesEnum>[] getStatesEnum()
{
@@ -105,8 +100,7 @@ public abstract class AbstractGrammar im
/**
* Set the states for this grammar
*
- * @param statesEnum
- * The statesEnum to set.
+ * @param statesEnum The statesEnum to set.
*/
public void setStatesEnum( Enum<Dsmlv2StatesEnum>[] statesEnum )
{
@@ -125,21 +119,23 @@ public abstract class AbstractGrammar im
do
{
- if ( eventType == XmlPullParser.START_DOCUMENT )
- {
- container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
- }
- else if ( eventType == XmlPullParser.END_DOCUMENT )
- {
- container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
- }
- else if ( eventType == XmlPullParser.START_TAG )
- {
- processTag( container, Tag.START );
- }
- else if ( eventType == XmlPullParser.END_TAG )
+ switch ( eventType )
{
- processTag( container, Tag.END );
+ case XmlPullParser.START_DOCUMENT :
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ break;
+
+ case XmlPullParser.END_DOCUMENT :
+ container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
+ break;
+
+ case XmlPullParser.START_TAG :
+ processTag( container, Tag.START );
+ break;
+
+ case XmlPullParser.END_TAG :
+ processTag( container, Tag.END );
+ break;
}
eventType = xpp.next();
@@ -151,12 +147,9 @@ public abstract class AbstractGrammar im
/**
* 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
+ * @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
{
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Action.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Action.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Action.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Action.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -34,10 +34,8 @@ public interface Action
/**
* The action to be executed.
*
- * @param container
- * the container which stores the current data
- * @throws XmlPullParserException
- * thrown if something went wrong.
+ * @param container the container which stores the current data
+ * @throws XmlPullParserException thrown if something went wrong.
*/
void action( Dsmlv2Container container ) throws XmlPullParserException;
}
\ No newline at end of file
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Container.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Container.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Container.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Container.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -28,7 +28,7 @@ package org.apache.directory.shared.dsml
public interface Container
{
/**
- * Get the current grammar state
+ * Gets the current grammar state
*
* @return Returns the current grammar state
*/
@@ -36,16 +36,15 @@ public interface Container
/**
- * Set the new current state
+ * Sets the new current state
*
- * @param state
- * The new state
+ * @param state The new state
*/
void setState( Enum<Dsmlv2StatesEnum> state );
/**
- * Get the transition
+ * Gets the transition
*
* @return Returns the transition from the previous state to the new state
*/
@@ -53,10 +52,9 @@ public interface Container
/**
- * Update the transition from a state to another
+ * Updates the transition from a state to another
*
- * @param transition
- * The transition to set
+ * @param transition The transition to set
*/
void setTransition( Enum<Dsmlv2StatesEnum> transition );
@@ -65,5 +63,4 @@ public interface Container
* @return Returns the states.
*/
Enum<Dsmlv2StatesEnum>[] getStates();
-
}
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlControl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlControl.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlControl.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlControl.java Wed Feb 29 00:41:53 2012
@@ -28,13 +28,14 @@ import org.dom4j.Element;
/**
* A DSML decorator for a {@link Control}.
*
+ * @param <C> The decorated Control
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class DsmlControl<E extends Control>
- implements Control, DsmlDecorator<E>
+public class DsmlControl<C extends Control> implements Control, DsmlDecorator<C>
{
/** The decorated Control */
- private E decorated;
+ private C decorated;
/** The encoded value of the control. */
protected byte[] value;
@@ -43,7 +44,12 @@ public class DsmlControl<E extends Contr
private LdapApiService codec;
- public DsmlControl( LdapApiService codec, E decorated )
+ /**
+ * Creates a new instance of DsmlControl
+ * @param codec The Codec used to encode/decode the Control
+ * @param decorated The decorated control
+ */
+ public DsmlControl( LdapApiService codec, C decorated )
{
this.codec = codec;
this.decorated = decorated;
@@ -51,7 +57,7 @@ public class DsmlControl<E extends Contr
/**
- * Gets the LDAP codec service.
+ * @return The LDAP codec service.
*/
public LdapApiService getCodecService()
{
@@ -71,7 +77,7 @@ public class DsmlControl<E extends Contr
/**
- * Get the control value
+ * Gets the control value
*
* @return The control value
*/
@@ -82,7 +88,7 @@ public class DsmlControl<E extends Contr
/**
- * Set the encoded control value
+ * Sets the encoded control value
*
* @param value The encoded control value to store
*/
@@ -140,7 +146,7 @@ public class DsmlControl<E extends Contr
/**
* {@inheritDoc}
*/
- public E getDecorated()
+ public C getDecorated()
{
return decorated;
}
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlDecorator.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlDecorator.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/DsmlDecorator.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -25,18 +25,18 @@ import org.dom4j.Element;
/**
* This interface defines the methods that must be implemented to define a DSML Decorator
+ *
+ * @param <M> The message to decorate
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public interface DsmlDecorator<E>
+public interface DsmlDecorator<M>
{
/**
* 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.
+ * @param root the root dom4j Element
+ * @return the dom4j Element corresponding to the entry.
*/
Element toDsml( Element root );
@@ -46,5 +46,5 @@ public interface DsmlDecorator<E>
*
* @return The decorated Message instance
*/
- E getDecorated();
+ M getDecorated();
}
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Container.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Container.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Container.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Container.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -61,8 +61,9 @@ public class Dsmlv2Container implements
/**
- * Creates a new LdapMessageContainer object. We will store ten grammars,
- * it's enough ...
+ * Creates a new LdapMessageContainer object.
+ *
+ * @param codec the Codec used to encode/decode the messages
*/
public Dsmlv2Container( LdapApiService codec )
{
@@ -73,7 +74,7 @@ public class Dsmlv2Container implements
/**
* Gets the {@link LdapApiService} associated with this {@link Asn1Container}.
*
- * @return
+ * @return The codec used to encode/decode the messages
*/
public LdapApiService getLdapCodecService()
{
@@ -84,8 +85,7 @@ public class Dsmlv2Container implements
/**
* Gets the DSML Batch Request
*
- * @return
- * Returns the Batch Request
+ * @return Returns the Batch Request
*/
public BatchRequestDsml getBatchRequest()
{
@@ -96,8 +96,7 @@ public class Dsmlv2Container implements
/**
* Sets the DSML Batch Request
*
- * @param batchRequest
- * the Batch Request to set
+ * @param batchRequest the Batch Request to set
*/
public void setBatchRequest( BatchRequestDsml batchRequest )
{
@@ -108,8 +107,7 @@ public class Dsmlv2Container implements
/**
* Gets the DSML Batch Response
*
- * @return
- * Returns the Batch Response
+ * @return Returns the Batch Response
*/
public BatchResponseDsml getBatchResponse()
{
@@ -120,8 +118,7 @@ public class Dsmlv2Container implements
/**
* Sets the DSML Batch Request
*
- * @param batchResponse
- * the Batch Response to set
+ * @param batchResponse the Batch Response to set
*/
public void setBatchResponse( BatchResponseDsml batchResponse )
{
@@ -132,8 +129,7 @@ public class Dsmlv2Container implements
/**
* Gets the parser
*
- * @return
- * the parser
+ * @return the parser
*/
public XmlPullParser getParser()
{
@@ -144,8 +140,7 @@ public class Dsmlv2Container implements
/**
* Sets the parser
*
- * @param parser
- * the parser to set
+ * @param parser the parser to set
*/
public void setParser( XmlPullParser parser )
{
@@ -156,8 +151,7 @@ public class Dsmlv2Container implements
/**
* Get the current grammar state
*
- * @return
- * the current grammar state
+ * @return the current grammar state
*/
public Enum<Dsmlv2StatesEnum> getState()
{
@@ -168,8 +162,7 @@ public class Dsmlv2Container implements
/**
* Set the new current state
*
- * @param state
- * the new state
+ * @param state the new state
*/
public void setState( Enum<Dsmlv2StatesEnum> state )
{
@@ -180,8 +173,7 @@ public class Dsmlv2Container implements
/**
* Get the transition
*
- * @return
- * the transition from the previous state to the new state
+ * @return the transition from the previous state to the new state
*/
public Enum<Dsmlv2StatesEnum> getTransition()
{
@@ -192,8 +184,7 @@ public class Dsmlv2Container implements
/**
* Update the transition from a state to another
*
- * @param transition
- * the transition to set
+ * @param transition the transition to set
*/
public void setTransition( Enum<Dsmlv2StatesEnum> transition )
{
@@ -204,8 +195,7 @@ public class Dsmlv2Container implements
/**
* Get the states for this container's grammars
*
- * @return
- * the states.
+ * @return the states.
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "UWF_UNWRITTEN_FIELD",
justification = "it exists a setter for 'states'")
@@ -218,8 +208,7 @@ public class Dsmlv2Container implements
/**
* Gets the grammar
*
- * @return
- * the grammar
+ * @return the grammar
*/
public AbstractGrammar getGrammar()
{
@@ -230,8 +219,7 @@ public class Dsmlv2Container implements
/**
* Sets the Grammar
*
- * @param grammar
- * the grammar to set
+ * @param grammar the grammar to set
*/
public void setGrammar( AbstractGrammar grammar )
{
@@ -242,12 +230,9 @@ public class Dsmlv2Container implements
/**
* Get the transition associated with the state and tag
*
- * @param currentState
- * the current state
- * @param currentTag
- * the current tag
- * @return
- * a valid transition if any, or null.
+ * @param currentState the current state
+ * @param currentTag the current tag
+ * @return a valid transition if any, or null.
*/
public GrammarTransition getTransition( Enum<Dsmlv2StatesEnum> currentState, Tag currentTag )
{
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Parser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Parser.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Parser.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Parser.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -49,7 +49,7 @@ public class Dsmlv2Parser
private Dsmlv2Container container;
/**
- * flag to indicate if the batch request should maintain a list of all the
+ * flag to indicate if the batch request should maintain a list of all the
* operation request objects present in the DSML document. Default is true
*/
private boolean storeMsgInBatchReq = true;
@@ -61,8 +61,7 @@ public class Dsmlv2Parser
/**
* Creates a new instance of Dsmlv2Parser.
*
- * @throws XmlPullParserException
- * if an error occurs while the initialization of the parser
+ * @throws XmlPullParserException if an error occurs during the initialization of the parser
*/
public Dsmlv2Parser() throws XmlPullParserException
{
@@ -71,11 +70,10 @@ public class Dsmlv2Parser
/**
- *
* Creates a new instance of Dsmlv2Parser.
*
* @param storeMsgInBatchReq flag to set if the parsed requests should b stored
- * @throws XmlPullParserException
+ * @throws XmlPullParserException if an error occurs during the initialization of the parser
*/
public Dsmlv2Parser( boolean storeMsgInBatchReq ) throws XmlPullParserException
{
@@ -97,8 +95,7 @@ public class Dsmlv2Parser
/**
* Creates a new instance of Dsmlv2Parser.
*
- * @throws XmlPullParserException
- * if an error occurs while the initialization of the parser
+ * @throws XmlPullParserException if an error occurs during the initialization of the parser
*/
public Dsmlv2Parser( Dsmlv2Grammar grammar ) throws XmlPullParserException
{
@@ -117,12 +114,9 @@ public class Dsmlv2Parser
/**
* 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
+ * @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
{
@@ -134,12 +128,9 @@ public class Dsmlv2Parser
/**
* 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
+ * @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
{
@@ -150,10 +141,8 @@ public class Dsmlv2Parser
/**
* 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
+ * @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
{
@@ -163,11 +152,9 @@ public class Dsmlv2Parser
/**
* Launches the parsing on the input
- * This method will parse the whole DSML document, without considering the flag {@link #storeMsgInBatchReq}
- * @throws XmlPullParserException
- * when an unrecoverable error occurs
- * @throws IOException
- * when an IO execption occurs
+ * This method will parse the whole DSML document, without considering the flag {@link #storeMsgInBatchReq}
+ * @throws XmlPullParserException when an unrecoverable error occurs
+ * @throws IOException when an IO execption occurs
*/
public void parse() throws XmlPullParserException, IOException
{
@@ -178,32 +165,35 @@ public class Dsmlv2Parser
/**
* Launches the parsing of the Batch Request only
*
- * @throws XmlPullParserException
- * if an error occurs in the parser
+ * @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 )
+ switch ( eventType )
{
- container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
- }
- else if ( eventType == XmlPullParser.END_DOCUMENT )
- {
- container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
- }
- else if ( eventType == XmlPullParser.START_TAG )
- {
- processTag( container, Tag.START );
- }
- else if ( eventType == XmlPullParser.END_TAG )
- {
- processTag( container, Tag.END );
+ case XmlPullParser.START_DOCUMENT :
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ break;
+
+ case XmlPullParser.END_DOCUMENT :
+ container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
+ break;
+
+ case XmlPullParser.START_TAG :
+ processTag( container, Tag.START );
+ break;
+
+ case XmlPullParser.END_TAG :
+ processTag( container, Tag.END );
+ break;
}
+
try
{
eventType = xpp.next();
@@ -227,12 +217,9 @@ public class Dsmlv2Parser
/**
* 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
+ * @param container the DSML container
+ * @param tagType the tag type
+ * @throws XmlPullParserException when an error occurs during the parsing
*/
private static void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
{
@@ -261,8 +248,7 @@ public class Dsmlv2Parser
/**
* 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
+ * @return the Batch Request or null if the it has not been parsed yet
*/
public BatchRequestDsml getBatchRequest()
{
@@ -272,10 +258,8 @@ public class Dsmlv2Parser
/**
* 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
+ * @return the next Request or null if there's no more request
+ * @throws XmlPullParserException when an error occurs during the parsing
*/
public DsmlDecorator<? extends Request> getNextRequest() throws XmlPullParserException
{
@@ -302,23 +286,25 @@ public class Dsmlv2Parser
eventType = xpp.getEventType();
}
- if ( eventType == XmlPullParser.START_DOCUMENT )
+ switch ( eventType )
{
- container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
- }
- else if ( eventType == XmlPullParser.END_DOCUMENT )
- {
- container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
- return null;
- }
- else if ( eventType == XmlPullParser.START_TAG )
- {
- processTag( container, Tag.START );
- }
- else if ( eventType == XmlPullParser.END_TAG )
- {
- processTag( container, Tag.END );
+ case XmlPullParser.START_DOCUMENT :
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ break;
+
+ case XmlPullParser.END_DOCUMENT :
+ container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
+ return null;
+
+ case XmlPullParser.START_TAG :
+ processTag( container, Tag.START );
+ break;
+
+ case XmlPullParser.END_TAG :
+ processTag( container, Tag.END );
+ break;
}
+
try
{
eventType = xpp.next();
@@ -337,8 +323,7 @@ public class Dsmlv2Parser
/**
* Parses all the requests
*
- * @throws XmlPullParserException
- * when an error occurs during the parsing
+ * @throws XmlPullParserException when an error occurs during the parsing
*/
public void parseAllRequests() throws XmlPullParserException
{
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2ResponseParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2ResponseParser.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2ResponseParser.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2ResponseParser.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -53,8 +53,7 @@ public class Dsmlv2ResponseParser
/**
* Creates a new instance of Dsmlv2ResponseParser.
*
- * @throws XmlPullParserException
- * if an error occurs while the initialization of the parser
+ * @throws XmlPullParserException if an error occurs while the initialization of the parser
*/
public Dsmlv2ResponseParser( LdapApiService codec ) throws XmlPullParserException
{
@@ -73,10 +72,8 @@ public class Dsmlv2ResponseParser
/**
* 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
+ * @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
{
@@ -87,12 +84,9 @@ public class Dsmlv2ResponseParser
/**
* 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
+ * @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
{
@@ -104,12 +98,9 @@ public class Dsmlv2ResponseParser
/**
* 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
+ * @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
{
@@ -120,10 +111,8 @@ public class Dsmlv2ResponseParser
/**
* Launches the parsing on the input
*
- * @throws XmlPullParserException
- * when an unrecoverable error occurs
- * @throws IOException
- * when an IO exception occurs
+ * @throws XmlPullParserException when an unrecoverable error occurs
+ * @throws IOException when an IO exception occurs
*/
public void parse() throws XmlPullParserException, IOException
{
@@ -136,32 +125,35 @@ public class Dsmlv2ResponseParser
/**
* Launches the parsing of the Batch Response only
*
- * @throws XmlPullParserException
- * if an error occurs in the parser
+ * @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 )
+ switch ( eventType )
{
- container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
- }
- else if ( eventType == XmlPullParser.END_DOCUMENT )
- {
- container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
- }
- else if ( eventType == XmlPullParser.START_TAG )
- {
- processTag( container, Tag.START );
- }
- else if ( eventType == XmlPullParser.END_TAG )
- {
- processTag( container, Tag.END );
+ case XmlPullParser.START_DOCUMENT :
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ break;
+
+ case XmlPullParser.END_DOCUMENT :
+ container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
+ break;
+
+ case XmlPullParser.START_TAG :
+ processTag( container, Tag.START );
+ break;
+
+ case XmlPullParser.END_TAG :
+ processTag( container, Tag.END );
+ break;
}
+
try
{
eventType = xpp.next();
@@ -178,12 +170,9 @@ public class Dsmlv2ResponseParser
/**
* 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
+ * @param container the DSML container
+ * @param tagType the tag type
+ * @throws XmlPullParserException when an error occurs during the parsing
*/
private static void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
{
@@ -212,8 +201,7 @@ public class Dsmlv2ResponseParser
/**
* 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
+ * @return the Batch Response or null if the it has not been parsed yet
*/
public BatchResponseDsml getBatchResponse()
{
@@ -223,10 +211,8 @@ public class Dsmlv2ResponseParser
/**
* 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
+ * @return the next Request or null if there's no more request
+ * @throws XmlPullParserException when an error occurs during the parsing
*/
public DsmlDecorator<? extends Response> getNextResponse() throws XmlPullParserException
{
@@ -253,23 +239,25 @@ public class Dsmlv2ResponseParser
eventType = xpp.getEventType();
}
- if ( eventType == XmlPullParser.START_DOCUMENT )
+ switch ( eventType )
{
- container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
- }
- else if ( eventType == XmlPullParser.END_DOCUMENT )
- {
- container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
- return null;
- }
- else if ( eventType == XmlPullParser.START_TAG )
- {
- processTag( container, Tag.START );
- }
- else if ( eventType == XmlPullParser.END_TAG )
- {
- processTag( container, Tag.END );
+ case XmlPullParser.START_DOCUMENT :
+ container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
+ break;
+
+ case XmlPullParser.END_DOCUMENT :
+ container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
+ return null;
+
+ case XmlPullParser.START_TAG :
+ processTag( container, Tag.START );
+ break;
+
+ case XmlPullParser.END_TAG :
+ processTag( container, Tag.END );
+ break;
}
+
try
{
eventType = xpp.next();
@@ -288,8 +276,7 @@ public class Dsmlv2ResponseParser
/**
* Parses all the responses
*
- * @throws XmlPullParserException
- * when an error occurs during the parsing
+ * @throws XmlPullParserException when an error occurs during the parsing
*/
public void parseAllResponses() throws XmlPullParserException
{
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Grammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Grammar.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Grammar.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Grammar.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -27,6 +27,8 @@ import org.xmlpull.v1.XmlPullParserExcep
/**
* The interface which expose common behavior of a Grammar implementer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public interface Grammar
{
@@ -34,8 +36,7 @@ public interface Grammar
* This method, when called, executes an action on the current data stored in
* the container.
*
- * @param container
- * the DSML container
+ * @param container the DSML container
* @throws XmlPullParserException when an unrecoverable error occurs
* @throws IOException when an IO error occurs
*/
@@ -61,8 +62,7 @@ public interface Grammar
/**
* Set the grammar's name
*
- * @param name
- * The grammar name
+ * @param name The grammar name
*/
void setName( String name );
}
\ No newline at end of file
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/GrammarAction.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/GrammarAction.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/GrammarAction.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/GrammarAction.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -35,8 +35,7 @@ public abstract class GrammarAction impl
/**
* Creates a new GrammarAction object.
*
- * @param name
- * the name of the create daction
+ * @param name the name of the create daction
*/
public GrammarAction( String name )
{
@@ -47,8 +46,7 @@ public abstract class GrammarAction impl
/**
* Print the action's name
*
- * @return
- * the action's name
+ * @return the action's name
*/
public String toString()
{
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/GrammarTransition.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/GrammarTransition.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/GrammarTransition.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/GrammarTransition.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -41,12 +41,9 @@ public class GrammarTransition
/**
* 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.
+ * @param currentState The current transition
+ * @param nextState The target state
+ * @param action The action to execute. It could be null.
*/
public GrammarTransition( Enum<Dsmlv2StatesEnum> currentState, Enum<Dsmlv2StatesEnum> nextState,
GrammarAction action )
@@ -60,8 +57,7 @@ public class GrammarTransition
/**
* Gets the target state
*
- * @return
- * the target state.
+ * @return the target state.
*/
public Enum<Dsmlv2StatesEnum> getNextState()
{
@@ -72,9 +68,7 @@ public class GrammarTransition
/**
* Tells if the transition has an associated action.
*
- * @return
- * <code>true</code> if an action has been asociated to the
- * transition
+ * @return <code>true</code> if an action has been associated to the transition
*/
public boolean hasAction()
{
@@ -85,8 +79,7 @@ public class GrammarTransition
/**
* Gets the action associated with the transition
*
- * @return
- * the action associated with the transition
+ * @return the action associated with the transition
*/
public GrammarAction getAction()
{
@@ -97,12 +90,9 @@ public class GrammarTransition
/**
* 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.
+ * @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, Enum<Dsmlv2StatesEnum> statesEnum )
{
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/ParserUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/ParserUtils.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/ParserUtils.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/ParserUtils.java Wed Feb 29 00:41:53 2012
@@ -71,33 +71,27 @@ public final class ParserUtils
/** XSD namespace prefix. */
public static final String XSD = "xsd";
+ /** The DSML namespace */
public static final Namespace DSML_NAMESPACE = new Namespace( null, "urn:oasis:names:tc:DSML:2:0:core" );
+ /** The XSD namespace */
public static final Namespace XSD_NAMESPACE = new Namespace( XSD, XML_SCHEMA_URI );
+ /** The XSI namespace */
public static final Namespace XSI_NAMESPACE = new Namespace( XSI, XML_SCHEMA_INSTANCE_URI );
/**
- * Private contstructor.
- */
- private ParserUtils()
- {
- }
-
-
- /**
* Returns the value of the attribute 'type' of the "XMLSchema-instance' namespace if it exists
*
- * @param xpp
- * the XPP parser to use
- * @return
- * the value of the attribute 'type' of the "XMLSchema-instance' namespace if it exists
+ * @param xpp the XPP parser to use
+ * @return the value of the attribute 'type' of the "XMLSchema-instance' namespace if it exists
*/
public static String getXsiTypeAttributeValue( XmlPullParser xpp )
{
String type = null;
int nbAttributes = xpp.getAttributeCount();
+
for ( int i = 0; i < nbAttributes; i++ )
{
// Checking if the attribute 'type' from XML Schema Instance namespace is used.
@@ -108,6 +102,7 @@ public final class ParserUtils
break;
}
}
+
return type;
}
@@ -115,12 +110,9 @@ public final class ParserUtils
/**
* Tells is the given value is a Base64 binary value
*
- * @param parser
- * the XPP parser to use
- * @param attrValue
- * the attribute value
- * @return
- * true if the value of the current tag is Base64BinaryEncoded, false if not
+ * @param parser the XPP parser to use
+ * @param attrValue the attribute value
+ * @return true if the value of the current tag is Base64BinaryEncoded, false if not
*/
public static boolean isBase64BinaryValue( XmlPullParser parser, String attrValue )
{
@@ -128,9 +120,11 @@ public final class ParserUtils
{
return false;
}
+
// We are looking for something that should look like that: "aNameSpace:base64Binary"
// We split the String. The first element should be the namespace prefix and the second "base64Binary"
String[] splitedString = attrValue.split( ":" );
+
return ( splitedString.length == 2 ) && ( XML_SCHEMA_URI.equals( parser.getNamespace( splitedString[0] ) ) )
&& ( BASE64BINARY.equals( splitedString[1] ) );
}
@@ -139,10 +133,8 @@ public final class ParserUtils
/**
* Indicates if the value needs to be encoded as Base64
*
- * @param value
- * the value to check
- * @return
- * true if the value needs to be encoded as Base64
+ * @param value the value to check
+ * @return true if the value needs to be encoded as Base64
*/
public static boolean needsBase64Encoding( Object value )
{
@@ -154,6 +146,7 @@ public final class ParserUtils
{
return !LdifUtils.isLDIFSafe( ( String ) value );
}
+
return true;
}
@@ -161,10 +154,8 @@ public final class ParserUtils
/**
* Encodes the value as a Base64 String
*
- * @param value
- * the value to encode
- * @return
- * the value encoded as a Base64 String
+ * @param value the value to encode
+ * @return the value encoded as a Base64 String
*/
public static String base64Encode( Object value )
{
@@ -184,14 +175,10 @@ public final class ParserUtils
/**
* Parses and verify the parsed value of the requestID
*
- * @param attributeValue
- * the value of the attribute
- * @param xpp
- * the XmlPullParser
- * @return
- * the int value of the resquestID
- * @throws XmlPullParserException
- * if RequestID isn't an Integer and if requestID equals 0
+ * @param attributeValue the value of the attribute
+ * @param xpp the XmlPullParser
+ * @return the int value of the resquestID
+ * @throws XmlPullParserException if RequestID isn't an Integer and if requestID is below 0
*/
public static int parseAndVerifyRequestID( String attributeValue, XmlPullParser xpp ) throws XmlPullParserException
{
@@ -238,6 +225,7 @@ public final class ParserUtils
}
byte[] value;
+
if ( control instanceof CodecControl<?> )
{
value = ( ( org.apache.directory.shared.ldap.codec.api.CodecControl<?> ) control ).getValue();
@@ -272,12 +260,9 @@ public final class ParserUtils
/**
* Indicates if a request ID is needed.
*
- * @param container
- * the associated container
- * @return
- * true if a request ID is needed (ie Processing=Parallel and ResponseOrder=Unordered)
- * @throws XmlPullParserException
- * if the batch request has not been parsed yet
+ * @param container the associated container
+ * @return true if a request ID is needed (ie Processing=Parallel and ResponseOrder=Unordered)
+ * @throws XmlPullParserException if the batch request has not been parsed yet
*/
public static boolean isRequestIdNeeded( Dsmlv2Container container ) throws XmlPullParserException
{
@@ -295,16 +280,15 @@ public final class ParserUtils
/**
* XML Pretty Printer XSLT Transformation
*
- * @param document
- * the Dom4j Document
- * @return
- * the transformed document
+ * @param document the Dom4j Document
+ * @return the transformed document
*/
public static Document styleDocument( Document document )
{
// load the transformer using JAXP
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = null;
+
try
{
transformer = factory.newTransformer( new StreamSource( ParserUtils.class
@@ -320,6 +304,7 @@ public final class ParserUtils
// now lets style the given document
DocumentSource source = new DocumentSource( document );
DocumentResult result = new DocumentResult();
+
try
{
transformer.transform( source, result );
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Tag.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Tag.java?rev=1294918&r1=1294917&r2=1294918&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Tag.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Tag.java Wed Feb 29 00:41:53 2012
@@ -6,16 +6,16 @@
* 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.
- *
+ * under the License.
+ *
*/
package org.apache.directory.shared.dsmlv2;
@@ -52,10 +52,8 @@ public class Tag
/**
* Creates a new instance of Tag.
*
- * @param name
- * the name of the tag
- * @param type
- * the type of the tag
+ * @param name the name of the tag
+ * @param type the type of the tag
*/
public Tag( String name, int type )
{
@@ -67,8 +65,7 @@ public class Tag
/**
* Gets the name of the tag
*
- * @return
- * the name of the tag
+ * @return the name of the tag
*/
public String getName()
{
@@ -79,8 +76,7 @@ public class Tag
/**
* Sets the name of the tag
*
- * @param name
- * the name to set
+ * @param name the name to set
*/
public void setName( String name )
{
@@ -91,8 +87,7 @@ public class Tag
/**
* Gets the type of the tag
*
- * @return
- * the type of the tag
+ * @return the type of the tag
*/
public int getType()
{
@@ -103,8 +98,7 @@ public class Tag
/**
* Sets the type of the tag
*
- * @param type
- * the type to set
+ * @param type the type to set
*/
public void setType( int type )
{
@@ -120,6 +114,7 @@ public class Tag
if ( obj instanceof Tag )
{
Tag tag = ( Tag ) obj;
+
return ( ( this.name.equals( tag.getName() ) ) && ( this.type == tag.getType() ) );
}