You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2006/12/18 18:53:22 UTC
svn commit: r488368 [23/23] - in /directory/sandbox/pamarcelot/ldapstudio:
ldapstudio-browser-ui/ ldapstudio-browser-ui/META-INF/
ldapstudio-browser-ui/about_files/ ldapstudio-browser-ui/icons/
ldapstudio-browser-ui/icons/ovr16/ ldapstudio-browser-ui/s...
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/AbstractGrammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/AbstractGrammar.java?view=diff&rev=488368&r1=488367&r2=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/AbstractGrammar.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/AbstractGrammar.java Mon Dec 18 09:52:58 2006
@@ -20,62 +20,73 @@
package org.apache.directory.ldapstudio.browser.model;
+
import java.util.HashMap;
+
/**
* 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>
*/
-public abstract class AbstractGrammar implements IGrammar {
+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.
- */
+ * 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;
- public AbstractGrammar() {
+
+ public AbstractGrammar()
+ {
}
+
// ~ Methods
// ------------------------------------------------------------------------------------
/**
- * Return the grammar's name
- *
- * @return The grammar name
- */
- public String getName() {
- return name;
+ * Return the grammar's name
+ *
+ * @return The grammar name
+ */
+ public String getName()
+ {
+ return name;
}
+
/**
- * Set the grammar's name
- *
- * @param name
- * DOCUMENT ME!
- */
- public void setName(String name) {
- this.name = name;
+ * Set the grammar's name
+ *
+ * @param name
+ * DOCUMENT ME!
+ */
+ 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 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 );
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java?view=diff&rev=488368&r1=488367&r2=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/Connection.java Mon Dec 18 09:52:58 2006
@@ -20,17 +20,20 @@
package org.apache.directory.ldapstudio.browser.model;
+
import java.util.ArrayList;
import java.util.List;
import org.apache.directory.shared.ldap.name.LdapDN;
+
/**
* This class represents a LDAP Connection used in the preferences
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class Connection implements Comparable<Connection> {
+public class Connection implements Comparable<Connection>
+{
private String name;
private String host = "localhost";
@@ -50,319 +53,369 @@
/** The Listeners List */
private List<ConnectionListener> listeners;
+
/**
- * Default Constructor
- */
- public Connection() {
- listeners = new ArrayList<ConnectionListener>();
+ * Default Constructor
+ */
+ public Connection()
+ {
+ listeners = new ArrayList<ConnectionListener>();
}
+
/**
- * Constructor for a Connection
- *
- * @param name
- * the Name of the connection
- * @param host
- * the Host
- * @param port
- * the Port
- * @param baseDN
- * the Base DN
- * @param anonymousBind
- * the value of the Anonymous Bind flag
- * @param userDN
- * the User DN
- * @param appendBaseDNtoUserDNWithBaseDN
- * the value of the appendBaseDNtoUserDNWithBaseDN flag
- * @param password
- * the Password
- */
- public Connection(String name, String host, int port, LdapDN baseDN,
- boolean anonymousBind, LdapDN userDN,
- boolean appendBaseDNtoUserDNWithBaseDN, String password) {
- this.name = name;
- this.host = host;
- this.port = port;
- this.baseDN = baseDN;
- this.anonymousBind = anonymousBind;
- this.userDN = userDN;
- this.appendBaseDNtoUserDNWithBaseDN = appendBaseDNtoUserDNWithBaseDN;
- this.password = password;
+ * Constructor for a Connection
+ *
+ * @param name
+ * the Name of the connection
+ * @param host
+ * the Host
+ * @param port
+ * the Port
+ * @param baseDN
+ * the Base DN
+ * @param anonymousBind
+ * the value of the Anonymous Bind flag
+ * @param userDN
+ * the User DN
+ * @param appendBaseDNtoUserDNWithBaseDN
+ * the value of the appendBaseDNtoUserDNWithBaseDN flag
+ * @param password
+ * the Password
+ */
+ public Connection( String name, String host, int port, LdapDN baseDN, boolean anonymousBind, LdapDN userDN,
+ boolean appendBaseDNtoUserDNWithBaseDN, String password )
+ {
+ this.name = name;
+ this.host = host;
+ this.port = port;
+ this.baseDN = baseDN;
+ this.anonymousBind = anonymousBind;
+ this.userDN = userDN;
+ this.appendBaseDNtoUserDNWithBaseDN = appendBaseDNtoUserDNWithBaseDN;
+ this.password = password;
}
+
/**
- * Get the Anonymous Bind Flag
- *
- * @return the anonymousBind
- */
- public boolean isAnonymousBind() {
- return anonymousBind;
+ * Get the Anonymous Bind Flag
+ *
+ * @return the anonymousBind
+ */
+ public boolean isAnonymousBind()
+ {
+ return anonymousBind;
}
+
/**
- * Set the Anonymous Bind flag
- *
- * @param anonymousBind
- * the anonymousBind to set
- */
- public void setAnonymousBind(boolean anonymousBind) {
- this.anonymousBind = anonymousBind;
+ * Set the Anonymous Bind flag
+ *
+ * @param anonymousBind
+ * the anonymousBind to set
+ */
+ public void setAnonymousBind( boolean anonymousBind )
+ {
+ this.anonymousBind = anonymousBind;
}
+
/**
- * Get the Base DN
- *
- * @return the BaseDN
- */
- public LdapDN getBaseDN() {
- return baseDN;
+ * Get the Base DN
+ *
+ * @return the BaseDN
+ */
+ public LdapDN getBaseDN()
+ {
+ return baseDN;
}
+
/**
- * Set the BaseDN
- *
- * @param baseDN
- * the BaseDN to set
- */
- public void setBaseDN(LdapDN baseDN) {
- this.baseDN = baseDN;
+ * Set the BaseDN
+ *
+ * @param baseDN
+ * the BaseDN to set
+ */
+ public void setBaseDN( LdapDN baseDN )
+ {
+ this.baseDN = baseDN;
}
+
/**
- * Get the Host
- *
- * @return the Host
- */
- public String getHost() {
- return host;
+ * Get the Host
+ *
+ * @return the Host
+ */
+ public String getHost()
+ {
+ return host;
}
+
/**
- * Set the Host
- *
- * @param host
- * the Host to set
- */
- public void setHost(String host) {
- this.host = host;
+ * Set the Host
+ *
+ * @param host
+ * the Host to set
+ */
+ public void setHost( String host )
+ {
+ this.host = host;
}
+
/**
- * Get the Name of the connection
- *
- * @return the Name
- */
- public String getName() {
- return name;
+ * Get the Name of the connection
+ *
+ * @return the Name
+ */
+ public String getName()
+ {
+ return name;
}
+
/**
- * Set the Name of the connection
- *
- * @param name
- * the Name to set
- */
- public void setName(String name) {
- this.name = name;
+ * Set the Name of the connection
+ *
+ * @param name
+ * the Name to set
+ */
+ public void setName( String name )
+ {
+ this.name = name;
}
+
/**
- * Get the Password
- *
- * @return the Password
- */
- public String getPassword() {
- return password;
+ * Get the Password
+ *
+ * @return the Password
+ */
+ public String getPassword()
+ {
+ return password;
}
+
/**
- * Set the Password
- *
- * @param password
- * the Password to set
- */
- public void setPassword(String password) {
- this.password = password;
+ * Set the Password
+ *
+ * @param password
+ * the Password to set
+ */
+ public void setPassword( String password )
+ {
+ this.password = password;
}
+
/**
- * Get the Port
- *
- * @return the Port
- */
- public int getPort() {
- return port;
+ * Get the Port
+ *
+ * @return the Port
+ */
+ public int getPort()
+ {
+ return port;
}
+
/**
- * Set the Port
- *
- * @param port
- * the Port to set
- */
- public void setPort(int port) {
- this.port = port;
+ * Set the Port
+ *
+ * @param port
+ * the Port to set
+ */
+ public void setPort( int port )
+ {
+ this.port = port;
}
+
/**
- * Get the User DN
- *
- * @return the User DN
- */
- public LdapDN getUserDN() {
- return userDN;
+ * Get the User DN
+ *
+ * @return the User DN
+ */
+ public LdapDN getUserDN()
+ {
+ return userDN;
}
+
/**
- * Set the User DN
- *
- * @param userDN
- * the User DN to set
- */
- public void setUserDN(LdapDN userDN) {
- this.userDN = userDN;
+ * Set the User DN
+ *
+ * @param userDN
+ * the User DN to set
+ */
+ public void setUserDN( LdapDN userDN )
+ {
+ this.userDN = userDN;
}
+
/**
- * Get the appendBaseDNtoUserDNWithBaseDN Flag
- *
- * @return the appendBaseDNtoUserDNWithBaseDN Flag
- */
- public boolean isAppendBaseDNtoUserDNWithBaseDN() {
- return appendBaseDNtoUserDNWithBaseDN;
+ * Get the appendBaseDNtoUserDNWithBaseDN Flag
+ *
+ * @return the appendBaseDNtoUserDNWithBaseDN Flag
+ */
+ public boolean isAppendBaseDNtoUserDNWithBaseDN()
+ {
+ return appendBaseDNtoUserDNWithBaseDN;
}
+
/**
- * Sets appendBaseDNtoUserDNWithBaseDN Flag
- *
- * @param appendBaseDNtoUserDNWithBaseDN
- * the appendBaseDNtoUserDNWithBaseDN Flag
- */
- public void setAppendBaseDNtoUserDNWithBaseDN(
- boolean appendBaseDNtoUserDNWithBaseDN) {
- this.appendBaseDNtoUserDNWithBaseDN = appendBaseDNtoUserDNWithBaseDN;
+ * Sets appendBaseDNtoUserDNWithBaseDN Flag
+ *
+ * @param appendBaseDNtoUserDNWithBaseDN
+ * the appendBaseDNtoUserDNWithBaseDN Flag
+ */
+ public void setAppendBaseDNtoUserDNWithBaseDN( boolean appendBaseDNtoUserDNWithBaseDN )
+ {
+ this.appendBaseDNtoUserDNWithBaseDN = appendBaseDNtoUserDNWithBaseDN;
}
+
/**
- * Converts a Connection into XML Format
- *
- * @return the corresponding XML String
- */
- public String toXml() {
- StringBuffer sb = new StringBuffer();
+ * Converts a Connection into XML Format
+ *
+ * @return the corresponding XML String
+ */
+ public String toXml()
+ {
+ StringBuffer sb = new StringBuffer();
- sb.append("<connection>");
- sb.append("<name>" + (("".equals(name)) ? "null" : name) + "</name>");
- sb.append("<host>" + (("".equals(host)) ? "null" : host) + "</host>");
- sb.append("<port>" + (("".equals(port)) ? "null" : port) + "</port>");
- sb.append("<baseDN>"
- + (("".equals(baseDN.getNormName())) ? "null" : baseDN
- .getNormName()) + "</baseDN>");
- sb.append("<anonymousBind>" + anonymousBind + "</anonymousBind>");
- sb.append("<userDN>"
- + (("".equals(userDN.getNormName())) ? "null" : userDN
- .getNormName()) + "</userDN>");
- sb.append("<appendBaseDNtoUserDNWithBaseDN>"
- + appendBaseDNtoUserDNWithBaseDN
- + "</appendBaseDNtoUserDNWithBaseDN>");
- sb.append("<password>" + (("".equals(password)) ? "null" : password)
- + "</password>");
- sb.append("</connection>");
+ sb.append( "<connection>" );
+ sb.append( "<name>" + ( ( "".equals( name ) ) ? "null" : name ) + "</name>" );
+ sb.append( "<host>" + ( ( "".equals( host ) ) ? "null" : host ) + "</host>" );
+ sb.append( "<port>" + ( ( "".equals( port ) ) ? "null" : port ) + "</port>" );
+ sb
+ .append( "<baseDN>" + ( ( "".equals( baseDN.getNormName() ) ) ? "null" : baseDN.getNormName() )
+ + "</baseDN>" );
+ sb.append( "<anonymousBind>" + anonymousBind + "</anonymousBind>" );
+ sb
+ .append( "<userDN>" + ( ( "".equals( userDN.getNormName() ) ) ? "null" : userDN.getNormName() )
+ + "</userDN>" );
+ sb.append( "<appendBaseDNtoUserDNWithBaseDN>" + appendBaseDNtoUserDNWithBaseDN
+ + "</appendBaseDNtoUserDNWithBaseDN>" );
+ sb.append( "<password>" + ( ( "".equals( password ) ) ? "null" : password ) + "</password>" );
+ sb.append( "</connection>" );
- return sb.toString();
+ return sb.toString();
}
+
/**
- * Checks if the connection is valid to connect
- *
- * @return true if the connection is valid to connect
- */
- public boolean validToConnect() {
- // Host
- if ((host == null) || ("".equals(host))) {
- return false;
- }
- // Port
- if ((port <= 0) || (port > 65535)) {
- return false;
- }
- return true;
+ * Checks if the connection is valid to connect
+ *
+ * @return true if the connection is valid to connect
+ */
+ public boolean validToConnect()
+ {
+ // Host
+ if ( ( host == null ) || ( "".equals( host ) ) )
+ {
+ return false;
+ }
+ // Port
+ if ( ( port <= 0 ) || ( port > 65535 ) )
+ {
+ return false;
+ }
+ return true;
}
+
/**
- * @see java.lang.Object#toString()
- */
+ * @see java.lang.Object#toString()
+ */
@Override
- public String toString() {
- StringBuffer sb = new StringBuffer();
-
- sb.append("[");
- sb.append("name=\"" + name);
- sb.append("\" | ");
- sb.append("host=\"" + host);
- sb.append("\" | ");
- sb.append("port=\"" + port);
- sb.append("\" | ");
- sb.append("baseDN=\"" + baseDN.getNormName());
- sb.append("\" | ");
- sb.append("anonymousBind=\"" + anonymousBind);
- sb.append("\" | ");
- sb.append("userDN=\"" + userDN.getNormName());
- sb.append("\" | ");
- sb.append("appendBaseDNtoUserDNWithBaseDN=\""
- + appendBaseDNtoUserDNWithBaseDN);
- sb.append("\" | ");
- sb.append("password=\"" + password);
- sb.append("\"]");
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( "[" );
+ sb.append( "name=\"" + name );
+ sb.append( "\" | " );
+ sb.append( "host=\"" + host );
+ sb.append( "\" | " );
+ sb.append( "port=\"" + port );
+ sb.append( "\" | " );
+ sb.append( "baseDN=\"" + baseDN.getNormName() );
+ sb.append( "\" | " );
+ sb.append( "anonymousBind=\"" + anonymousBind );
+ sb.append( "\" | " );
+ sb.append( "userDN=\"" + userDN.getNormName() );
+ sb.append( "\" | " );
+ sb.append( "appendBaseDNtoUserDNWithBaseDN=\"" + appendBaseDNtoUserDNWithBaseDN );
+ sb.append( "\" | " );
+ sb.append( "password=\"" + password );
+ sb.append( "\"]" );
- return sb.toString();
+ return sb.toString();
}
+
/*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(Connection o) {
- Connection otherWrapper = (Connection) o;
- return getName().compareToIgnoreCase(otherWrapper.getName());
+ * (non-Javadoc)
+ *
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo( Connection o )
+ {
+ Connection otherWrapper = ( Connection ) o;
+ return getName().compareToIgnoreCase( otherWrapper.getName() );
}
+
/**
- * Adds a listener for the Connections modifications
- *
- * @param listener
- * the listener to add
- * @return true (as per the general contract of Collection.add).
- */
- public boolean addListener(ConnectionListener listener) {
- return listeners.add(listener);
+ * Adds a listener for the Connections modifications
+ *
+ * @param listener
+ * the listener to add
+ * @return true (as per the general contract of Collection.add).
+ */
+ public boolean addListener( ConnectionListener listener )
+ {
+ return listeners.add( listener );
}
+
/**
- * Removes a listener for the Connections modifications
- *
- * @param listener
- * the listener to remove
- * @return true if the list contained the specified element.
- */
- public boolean removeListener(ConnectionListener listener) {
- return listeners.remove(listener);
+ * Removes a listener for the Connections modifications
+ *
+ * @param listener
+ * the listener to remove
+ * @return true if the list contained the specified element.
+ */
+ public boolean removeListener( ConnectionListener listener )
+ {
+ return listeners.remove( listener );
}
+
/**
- * Notifies all the listeners that the Connection has changed
- */
- private void notifyChanged() {
- for (ConnectionListener listener : listeners) {
- listener.connectionChanged(this);
- }
+ * Notifies all the listeners that the Connection has changed
+ */
+ private void notifyChanged()
+ {
+ for ( ConnectionListener listener : listeners )
+ {
+ listener.connectionChanged( this );
+ }
}
+
/**
- * Notifies all the listeners that the Connection has changed
- */
- public void notifyListeners() {
- notifyChanged();
+ * Notifies all the listeners that the Connection has changed
+ */
+ public void notifyListeners()
+ {
+ notifyChanged();
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java?view=diff&rev=488368&r1=488367&r2=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionGrammar.java Mon Dec 18 09:52:58 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.browser.model;
+
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.HashMap;
@@ -30,13 +31,15 @@
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
+
/**
* This class represent the Connection Grammar used to parsed the XML
* representation of a connection.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ConnectionGrammar extends AbstractGrammar {
+public class ConnectionGrammar extends AbstractGrammar
+{
/** The initial state */
public static int GRAMMAR_START = 0;
@@ -91,398 +94,464 @@
public static int PASSWORD_END = 17;
+
/**
- * Default constructor
- */
+ * Default constructor
+ */
@SuppressWarnings("unchecked")
- public ConnectionGrammar() {
- // Create the transitions table
- super.transitions = (HashMap<Tag, GrammarTransition>[]) Array
- .newInstance(HashMap.class, 20);
-
- // Initilization of the HashMaps
- super.transitions[GRAMMAR_START] = new HashMap<Tag, GrammarTransition>();
- super.transitions[CONNECTIONS_LOOP] = new HashMap<Tag, GrammarTransition>();
- super.transitions[CONNECTION_START] = new HashMap<Tag, GrammarTransition>();
- super.transitions[CONNECTION_END] = new HashMap<Tag, GrammarTransition>();
- super.transitions[NAME_START] = new HashMap<Tag, GrammarTransition>();
- super.transitions[NAME_END] = new HashMap<Tag, GrammarTransition>();
- super.transitions[HOST_START] = new HashMap<Tag, GrammarTransition>();
- super.transitions[HOST_END] = new HashMap<Tag, GrammarTransition>();
- super.transitions[PORT_START] = new HashMap<Tag, GrammarTransition>();
- super.transitions[PORT_END] = new HashMap<Tag, GrammarTransition>();
- super.transitions[BASEDN_START] = new HashMap<Tag, GrammarTransition>();
- super.transitions[BASEDN_END] = new HashMap<Tag, GrammarTransition>();
- super.transitions[ANONYMOUSBIND_START] = new HashMap<Tag, GrammarTransition>();
- super.transitions[ANONYMOUSBIND_END] = new HashMap<Tag, GrammarTransition>();
- super.transitions[USERDN_START] = new HashMap<Tag, GrammarTransition>();
- super.transitions[USERDN_END] = new HashMap<Tag, GrammarTransition>();
- super.transitions[APPENDBASEDNTOUSERDN_START] = new HashMap<Tag, GrammarTransition>();
- super.transitions[APPENDBASEDNTOUSERDN_END] = new HashMap<Tag, GrammarTransition>();
- super.transitions[PASSWORD_START] = new HashMap<Tag, GrammarTransition>();
- super.transitions[PASSWORD_END] = new HashMap<Tag, GrammarTransition>();
-
- // State: [GRAMMAR_START] - Tag: <connections>
- super.transitions[GRAMMAR_START].put(new Tag("connections", Tag.START),
- new GrammarTransition(GRAMMAR_START, CONNECTIONS_LOOP, null));
-
- // State: [CONNECTIONS_LOOP] - Tag: <connection>
- super.transitions[CONNECTIONS_LOOP].put(
- new Tag("connection", Tag.START), new GrammarTransition(
- CONNECTIONS_LOOP, CONNECTION_START, createConnection));
-
- // State: [CONNECTION_START] - Tag: <name>
- super.transitions[CONNECTION_START].put(new Tag("name", Tag.START),
- new GrammarTransition(CONNECTION_START, NAME_START, addName));
-
- // State: [NAME_START] - Tag: </name>
- super.transitions[NAME_START].put(new Tag("name", Tag.END),
- new GrammarTransition(NAME_START, NAME_END, null));
-
- // State: [NAME_END] - Tag: <host>
- super.transitions[NAME_END].put(new Tag("host", Tag.START),
- new GrammarTransition(NAME_END, HOST_START, addHost));
-
- // State: [HOST_START] - Tag: </host>
- super.transitions[HOST_START].put(new Tag("host", Tag.END),
- new GrammarTransition(HOST_START, HOST_END, null));
-
- // State: [HOST_END] - Tag: <port>
- super.transitions[HOST_END].put(new Tag("port", Tag.START),
- new GrammarTransition(HOST_END, PORT_START, addPort));
-
- // State: [PORT_START] - Tag: </port>
- super.transitions[PORT_START].put(new Tag("port", Tag.END),
- new GrammarTransition(PORT_START, PORT_END, null));
-
- // State: [PORT_END] - Tag: <baseDN>
- super.transitions[PORT_END].put(new Tag("baseDN", Tag.START),
- new GrammarTransition(PORT_END, BASEDN_START, addBaseDN));
-
- // State: [BASEDN_START] - Tag: </baseDN>
- super.transitions[BASEDN_START].put(new Tag("baseDN", Tag.END),
- new GrammarTransition(BASEDN_START, BASEDN_END, null));
-
- // State: [BASEDN_END] - Tag: <anonymousBind>
- super.transitions[BASEDN_END].put(new Tag("anonymousBind", Tag.START),
- new GrammarTransition(BASEDN_END, ANONYMOUSBIND_START,
- addAnonymousBind));
-
- // State: [ANONYMOUSBIND_START] - Tag: </anonymousBind>
- super.transitions[ANONYMOUSBIND_START].put(new Tag("anonymousBind",
- Tag.END), new GrammarTransition(ANONYMOUSBIND_START,
- ANONYMOUSBIND_END, null));
-
- // State: [ANONYMOUSBIND_END] - Tag: <userDN>
- super.transitions[ANONYMOUSBIND_END].put(new Tag("userDN", Tag.START),
- new GrammarTransition(ANONYMOUSBIND_END, USERDN_START,
- addUserDN));
-
- // State: [USERDN_START] - Tag: </userDN>
- super.transitions[USERDN_START].put(new Tag("userDN", Tag.END),
- new GrammarTransition(USERDN_START, USERDN_END, null));
-
- // State: [USERDN_END] - Tag: <appendBaseDNtoUserDNWithBaseDN>
- super.transitions[USERDN_END].put(new Tag(
- "appendBaseDNtoUserDNWithBaseDN", Tag.START),
- new GrammarTransition(USERDN_END, APPENDBASEDNTOUSERDN_START,
- appendBaseDNtoUserDNWithBaseDN));
+ public ConnectionGrammar()
+ {
+ // Create the transitions table
+ super.transitions = ( HashMap<Tag, GrammarTransition>[] ) Array.newInstance( HashMap.class, 20 );
+
+ // Initilization of the HashMaps
+ super.transitions[GRAMMAR_START] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[CONNECTIONS_LOOP] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[CONNECTION_START] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[CONNECTION_END] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[NAME_START] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[NAME_END] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[HOST_START] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[HOST_END] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[PORT_START] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[PORT_END] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[BASEDN_START] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[BASEDN_END] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[ANONYMOUSBIND_START] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[ANONYMOUSBIND_END] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[USERDN_START] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[USERDN_END] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[APPENDBASEDNTOUSERDN_START] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[APPENDBASEDNTOUSERDN_END] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[PASSWORD_START] = new HashMap<Tag, GrammarTransition>();
+ super.transitions[PASSWORD_END] = new HashMap<Tag, GrammarTransition>();
+
+ // State: [GRAMMAR_START] - Tag: <connections>
+ super.transitions[GRAMMAR_START].put( new Tag( "connections", Tag.START ), new GrammarTransition(
+ GRAMMAR_START, CONNECTIONS_LOOP, null ) );
+
+ // State: [CONNECTIONS_LOOP] - Tag: <connection>
+ super.transitions[CONNECTIONS_LOOP].put( new Tag( "connection", Tag.START ), new GrammarTransition(
+ CONNECTIONS_LOOP, CONNECTION_START, createConnection ) );
+
+ // State: [CONNECTION_START] - Tag: <name>
+ super.transitions[CONNECTION_START].put( new Tag( "name", Tag.START ), new GrammarTransition( CONNECTION_START,
+ NAME_START, addName ) );
+
+ // State: [NAME_START] - Tag: </name>
+ super.transitions[NAME_START].put( new Tag( "name", Tag.END ), new GrammarTransition( NAME_START, NAME_END,
+ null ) );
+
+ // State: [NAME_END] - Tag: <host>
+ super.transitions[NAME_END].put( new Tag( "host", Tag.START ), new GrammarTransition( NAME_END, HOST_START,
+ addHost ) );
+
+ // State: [HOST_START] - Tag: </host>
+ super.transitions[HOST_START].put( new Tag( "host", Tag.END ), new GrammarTransition( HOST_START, HOST_END,
+ null ) );
+
+ // State: [HOST_END] - Tag: <port>
+ super.transitions[HOST_END].put( new Tag( "port", Tag.START ), new GrammarTransition( HOST_END, PORT_START,
+ addPort ) );
+
+ // State: [PORT_START] - Tag: </port>
+ super.transitions[PORT_START].put( new Tag( "port", Tag.END ), new GrammarTransition( PORT_START, PORT_END,
+ null ) );
+
+ // State: [PORT_END] - Tag: <baseDN>
+ super.transitions[PORT_END].put( new Tag( "baseDN", Tag.START ), new GrammarTransition( PORT_END, BASEDN_START,
+ addBaseDN ) );
+
+ // State: [BASEDN_START] - Tag: </baseDN>
+ super.transitions[BASEDN_START].put( new Tag( "baseDN", Tag.END ), new GrammarTransition( BASEDN_START,
+ BASEDN_END, null ) );
+
+ // State: [BASEDN_END] - Tag: <anonymousBind>
+ super.transitions[BASEDN_END].put( new Tag( "anonymousBind", Tag.START ), new GrammarTransition( BASEDN_END,
+ ANONYMOUSBIND_START, addAnonymousBind ) );
+
+ // State: [ANONYMOUSBIND_START] - Tag: </anonymousBind>
+ super.transitions[ANONYMOUSBIND_START].put( new Tag( "anonymousBind", Tag.END ), new GrammarTransition(
+ ANONYMOUSBIND_START, ANONYMOUSBIND_END, null ) );
+
+ // State: [ANONYMOUSBIND_END] - Tag: <userDN>
+ super.transitions[ANONYMOUSBIND_END].put( new Tag( "userDN", Tag.START ), new GrammarTransition(
+ ANONYMOUSBIND_END, USERDN_START, addUserDN ) );
+
+ // State: [USERDN_START] - Tag: </userDN>
+ super.transitions[USERDN_START].put( new Tag( "userDN", Tag.END ), new GrammarTransition( USERDN_START,
+ USERDN_END, null ) );
+
+ // State: [USERDN_END] - Tag: <appendBaseDNtoUserDNWithBaseDN>
+ super.transitions[USERDN_END].put( new Tag( "appendBaseDNtoUserDNWithBaseDN", Tag.START ),
+ new GrammarTransition( USERDN_END, APPENDBASEDNTOUSERDN_START, appendBaseDNtoUserDNWithBaseDN ) );
- // State: [PREFIXUSERDNWITHBASEDN_START] - Tag:
+ // State: [PREFIXUSERDNWITHBASEDN_START] - Tag:
// </appendBaseDNtoUserDNWithBaseDN>
- super.transitions[APPENDBASEDNTOUSERDN_START].put(new Tag(
- "appendBaseDNtoUserDNWithBaseDN", Tag.END),
- new GrammarTransition(APPENDBASEDNTOUSERDN_START,
- APPENDBASEDNTOUSERDN_END, null));
-
- // State: [PREFIXUSERDNWITHBASEDN_END] - Tag: <password>
- super.transitions[APPENDBASEDNTOUSERDN_END].put(new Tag("password",
- Tag.START), new GrammarTransition(APPENDBASEDNTOUSERDN_END,
- PASSWORD_START, addPassword));
-
- // State: [PASSWORD_START] - Tag: </password>
- super.transitions[PASSWORD_START].put(new Tag("password", Tag.END),
- new GrammarTransition(PASSWORD_START, PASSWORD_END, null));
-
- // State: [PASSWORD_END] - Tag: </connection>
- super.transitions[PASSWORD_END].put(new Tag("connection", Tag.END),
- new GrammarTransition(PASSWORD_END, CONNECTIONS_LOOP, null));
-
- // State: [CONNECTIONS_LOOP] - Tag: </connections>
- super.transitions[CONNECTIONS_LOOP].put(
- new Tag("connections", Tag.END), new GrammarTransition(
- CONNECTIONS_LOOP, GRAMMAR_END, null));
+ super.transitions[APPENDBASEDNTOUSERDN_START].put( new Tag( "appendBaseDNtoUserDNWithBaseDN", Tag.END ),
+ new GrammarTransition( APPENDBASEDNTOUSERDN_START, APPENDBASEDNTOUSERDN_END, null ) );
+
+ // State: [PREFIXUSERDNWITHBASEDN_END] - Tag: <password>
+ super.transitions[APPENDBASEDNTOUSERDN_END].put( new Tag( "password", Tag.START ), new GrammarTransition(
+ APPENDBASEDNTOUSERDN_END, PASSWORD_START, addPassword ) );
+
+ // State: [PASSWORD_START] - Tag: </password>
+ super.transitions[PASSWORD_START].put( new Tag( "password", Tag.END ), new GrammarTransition( PASSWORD_START,
+ PASSWORD_END, null ) );
+
+ // State: [PASSWORD_END] - Tag: </connection>
+ super.transitions[PASSWORD_END].put( new Tag( "connection", Tag.END ), new GrammarTransition( PASSWORD_END,
+ CONNECTIONS_LOOP, null ) );
+
+ // State: [CONNECTIONS_LOOP] - Tag: </connections>
+ super.transitions[CONNECTIONS_LOOP].put( new Tag( "connections", Tag.END ), new GrammarTransition(
+ CONNECTIONS_LOOP, GRAMMAR_END, null ) );
}
/**
- * GrammarAction that create a Connection
- */
- private final GrammarAction createConnection = new GrammarAction(
- "Create Connection") {
- public void action(ConnectionParserContainer container)
- throws XmlPullParserException {
- container.addConnection(new Connection());
- }
+ * GrammarAction that create a Connection
+ */
+ private final GrammarAction createConnection = new GrammarAction( "Create Connection" )
+ {
+ public void action( ConnectionParserContainer container ) throws XmlPullParserException
+ {
+ container.addConnection( new Connection() );
+ }
};
/**
- * GrammarAction that adds a Name to a Connection
- */
- private final GrammarAction addName = new GrammarAction("Add Name") {
- public void action(ConnectionParserContainer container)
- throws XmlPullParserException {
- Connection connection = container.getCurrentConnection();
-
- XmlPullParser xpp = container.getParser();
-
- int eventType = 0;
- try {
- eventType = xpp.next();
- } catch (IOException e) {
- throw new XmlPullParserException(e.getMessage(), xpp, null);
- }
-
- if (eventType != XmlPullParser.TEXT) {
- throw new XmlPullParserException("An error has ocurred.", xpp,
- null);
- } else {
- if (xpp.getText().equals("null")) {
- connection.setName(null);
- } else {
- connection.setName(xpp.getText());
- }
- }
- }
+ * GrammarAction that adds a Name to a Connection
+ */
+ private final GrammarAction addName = new GrammarAction( "Add Name" )
+ {
+ public void action( ConnectionParserContainer container ) throws XmlPullParserException
+ {
+ Connection connection = container.getCurrentConnection();
+
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = 0;
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( e.getMessage(), xpp, null );
+ }
+
+ if ( eventType != XmlPullParser.TEXT )
+ {
+ throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+ }
+ else
+ {
+ if ( xpp.getText().equals( "null" ) )
+ {
+ connection.setName( null );
+ }
+ else
+ {
+ connection.setName( xpp.getText() );
+ }
+ }
+ }
};
/**
- * GrammarAction that adds a Host to a Connection
- */
- private final GrammarAction addHost = new GrammarAction("Add Host") {
- public void action(ConnectionParserContainer container)
- throws XmlPullParserException {
- Connection connection = container.getCurrentConnection();
-
- XmlPullParser xpp = container.getParser();
-
- int eventType = 0;
- try {
- eventType = xpp.next();
- } catch (IOException e) {
- throw new XmlPullParserException(e.getMessage(), xpp, null);
- }
-
- if (eventType != XmlPullParser.TEXT) {
- throw new XmlPullParserException("An error has ocurred.", xpp,
- null);
- } else {
- if (xpp.getText().equals("null")) {
- connection.setHost(null);
- } else {
- connection.setHost(xpp.getText());
- }
- }
- }
+ * GrammarAction that adds a Host to a Connection
+ */
+ private final GrammarAction addHost = new GrammarAction( "Add Host" )
+ {
+ public void action( ConnectionParserContainer container ) throws XmlPullParserException
+ {
+ Connection connection = container.getCurrentConnection();
+
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = 0;
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( e.getMessage(), xpp, null );
+ }
+
+ if ( eventType != XmlPullParser.TEXT )
+ {
+ throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+ }
+ else
+ {
+ if ( xpp.getText().equals( "null" ) )
+ {
+ connection.setHost( null );
+ }
+ else
+ {
+ connection.setHost( xpp.getText() );
+ }
+ }
+ }
};
/**
- * GrammarAction that adds a Port to a Connection
- */
- private final GrammarAction addPort = new GrammarAction("Add Port") {
- public void action(ConnectionParserContainer container)
- throws XmlPullParserException {
- Connection connection = container.getCurrentConnection();
-
- XmlPullParser xpp = container.getParser();
-
- int eventType = 0;
- try {
- eventType = xpp.next();
- } catch (IOException e) {
- throw new XmlPullParserException(e.getMessage(), xpp, null);
- }
-
- if (eventType != XmlPullParser.TEXT) {
- throw new XmlPullParserException("An error has ocurred.", xpp,
- null);
- } else {
- if (xpp.getText().equals("0")) {
- connection.setPort(0);
- } else {
- connection.setPort(Integer.parseInt(xpp.getText()));
- }
- }
- }
+ * GrammarAction that adds a Port to a Connection
+ */
+ private final GrammarAction addPort = new GrammarAction( "Add Port" )
+ {
+ public void action( ConnectionParserContainer container ) throws XmlPullParserException
+ {
+ Connection connection = container.getCurrentConnection();
+
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = 0;
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( e.getMessage(), xpp, null );
+ }
+
+ if ( eventType != XmlPullParser.TEXT )
+ {
+ throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+ }
+ else
+ {
+ if ( xpp.getText().equals( "0" ) )
+ {
+ connection.setPort( 0 );
+ }
+ else
+ {
+ connection.setPort( Integer.parseInt( xpp.getText() ) );
+ }
+ }
+ }
};
/**
- * GrammarAction that adds a BaseDN to a Connection
- */
- private final GrammarAction addBaseDN = new GrammarAction("Add BaseDN") {
- public void action(ConnectionParserContainer container)
- throws XmlPullParserException {
- Connection connection = container.getCurrentConnection();
-
- XmlPullParser xpp = container.getParser();
-
- int eventType = 0;
- try {
- eventType = xpp.next();
- } catch (IOException e) {
- throw new XmlPullParserException(e.getMessage(), xpp, null);
- }
-
- if (eventType != XmlPullParser.TEXT) {
- throw new XmlPullParserException("An error has ocurred.", xpp,
- null);
- } else {
- if (xpp.getText().equals("null")) {
- connection.setBaseDN(LdapDN.EMPTY_LDAPDN);
- } else {
- try {
- connection.setBaseDN(new LdapDN(xpp.getText()));
- } catch (InvalidNameException e) {
- throw new XmlPullParserException(
- "An error has ocurred. " + e.getMessage(), xpp,
- null);
- }
- }
- }
- }
+ * GrammarAction that adds a BaseDN to a Connection
+ */
+ private final GrammarAction addBaseDN = new GrammarAction( "Add BaseDN" )
+ {
+ public void action( ConnectionParserContainer container ) throws XmlPullParserException
+ {
+ Connection connection = container.getCurrentConnection();
+
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = 0;
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( e.getMessage(), xpp, null );
+ }
+
+ if ( eventType != XmlPullParser.TEXT )
+ {
+ throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+ }
+ else
+ {
+ if ( xpp.getText().equals( "null" ) )
+ {
+ connection.setBaseDN( LdapDN.EMPTY_LDAPDN );
+ }
+ else
+ {
+ try
+ {
+ connection.setBaseDN( new LdapDN( xpp.getText() ) );
+ }
+ catch ( InvalidNameException e )
+ {
+ throw new XmlPullParserException( "An error has ocurred. " + e.getMessage(), xpp, null );
+ }
+ }
+ }
+ }
};
/**
- * GrammarAction that adds a AnonymousBind to a Connection
- */
- private final GrammarAction addAnonymousBind = new GrammarAction(
- "Add AnonymousBind") {
- public void action(ConnectionParserContainer container)
- throws XmlPullParserException {
- Connection connection = container.getCurrentConnection();
-
- XmlPullParser xpp = container.getParser();
-
- int eventType = 0;
- try {
- eventType = xpp.next();
- } catch (IOException e) {
- throw new XmlPullParserException(e.getMessage(), xpp, null);
- }
-
- if (eventType != XmlPullParser.TEXT) {
- throw new XmlPullParserException("An error has ocurred.", xpp,
- null);
- } else {
- if (xpp.getText().equals("false")) {
- connection.setAnonymousBind(false);
- } else if (xpp.getText().equals("true")) {
- connection.setAnonymousBind(true);
- } else {
- throw new XmlPullParserException("An error has ocurred.",
- xpp, null);
- }
- }
- }
+ * GrammarAction that adds a AnonymousBind to a Connection
+ */
+ private final GrammarAction addAnonymousBind = new GrammarAction( "Add AnonymousBind" )
+ {
+ public void action( ConnectionParserContainer container ) throws XmlPullParserException
+ {
+ Connection connection = container.getCurrentConnection();
+
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = 0;
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( e.getMessage(), xpp, null );
+ }
+
+ if ( eventType != XmlPullParser.TEXT )
+ {
+ throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+ }
+ else
+ {
+ if ( xpp.getText().equals( "false" ) )
+ {
+ connection.setAnonymousBind( false );
+ }
+ else if ( xpp.getText().equals( "true" ) )
+ {
+ connection.setAnonymousBind( true );
+ }
+ else
+ {
+ throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+ }
+ }
+ }
};
/**
- * GrammarAction that adds a UserDN to a Connection
- */
- private final GrammarAction addUserDN = new GrammarAction("Add UserDN") {
- public void action(ConnectionParserContainer container)
- throws XmlPullParserException {
- Connection connection = container.getCurrentConnection();
-
- XmlPullParser xpp = container.getParser();
-
- int eventType = 0;
- try {
- eventType = xpp.next();
- } catch (IOException e) {
- throw new XmlPullParserException(e.getMessage(), xpp, null);
- }
-
- if (eventType != XmlPullParser.TEXT) {
- throw new XmlPullParserException("An error has ocurred.", xpp,
- null);
- } else {
- if (xpp.getText().equals("null")) {
- connection.setUserDN(LdapDN.EMPTY_LDAPDN);
- } else {
- try {
- connection.setUserDN(new LdapDN(xpp.getText()));
- } catch (InvalidNameException e) {
- throw new XmlPullParserException(
- "An error has ocurred. " + e.getMessage(), xpp,
- null);
- }
- }
- }
- }
+ * GrammarAction that adds a UserDN to a Connection
+ */
+ private final GrammarAction addUserDN = new GrammarAction( "Add UserDN" )
+ {
+ public void action( ConnectionParserContainer container ) throws XmlPullParserException
+ {
+ Connection connection = container.getCurrentConnection();
+
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = 0;
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( e.getMessage(), xpp, null );
+ }
+
+ if ( eventType != XmlPullParser.TEXT )
+ {
+ throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+ }
+ else
+ {
+ if ( xpp.getText().equals( "null" ) )
+ {
+ connection.setUserDN( LdapDN.EMPTY_LDAPDN );
+ }
+ else
+ {
+ try
+ {
+ connection.setUserDN( new LdapDN( xpp.getText() ) );
+ }
+ catch ( InvalidNameException e )
+ {
+ throw new XmlPullParserException( "An error has ocurred. " + e.getMessage(), xpp, null );
+ }
+ }
+ }
+ }
};
/**
- * GrammarAction that adds a appendBaseDNtoUserDNWithBaseDN to a
- * Connection
- */
+ * GrammarAction that adds a appendBaseDNtoUserDNWithBaseDN to a
+ * Connection
+ */
private final GrammarAction appendBaseDNtoUserDNWithBaseDN = new GrammarAction(
- "Add appendBaseDNtoUserDNWithBaseDN") {
- public void action(ConnectionParserContainer container)
- throws XmlPullParserException {
- Connection connection = container.getCurrentConnection();
-
- XmlPullParser xpp = container.getParser();
-
- int eventType = 0;
- try {
- eventType = xpp.next();
- } catch (IOException e) {
- throw new XmlPullParserException(e.getMessage(), xpp, null);
- }
-
- if (eventType != XmlPullParser.TEXT) {
- throw new XmlPullParserException("An error has ocurred.", xpp,
- null);
- } else {
- if (xpp.getText().equals("false")) {
- connection.setAppendBaseDNtoUserDNWithBaseDN(false);
- } else if (xpp.getText().equals("true")) {
- connection.setAppendBaseDNtoUserDNWithBaseDN(true);
- } else {
- throw new XmlPullParserException("An error has ocurred.",
- xpp, null);
- }
- }
- }
+ "Add appendBaseDNtoUserDNWithBaseDN" )
+ {
+ public void action( ConnectionParserContainer container ) throws XmlPullParserException
+ {
+ Connection connection = container.getCurrentConnection();
+
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = 0;
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( e.getMessage(), xpp, null );
+ }
+
+ if ( eventType != XmlPullParser.TEXT )
+ {
+ throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+ }
+ else
+ {
+ if ( xpp.getText().equals( "false" ) )
+ {
+ connection.setAppendBaseDNtoUserDNWithBaseDN( false );
+ }
+ else if ( xpp.getText().equals( "true" ) )
+ {
+ connection.setAppendBaseDNtoUserDNWithBaseDN( true );
+ }
+ else
+ {
+ throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+ }
+ }
+ }
};
/**
- * GrammarAction that adds a Password to a Connection
- */
- private final GrammarAction addPassword = new GrammarAction("Add Password") {
- public void action(ConnectionParserContainer container)
- throws XmlPullParserException {
- Connection connection = container.getCurrentConnection();
-
- XmlPullParser xpp = container.getParser();
-
- int eventType = 0;
- try {
- eventType = xpp.next();
- } catch (IOException e) {
- throw new XmlPullParserException(e.getMessage(), xpp, null);
- }
-
- if (eventType != XmlPullParser.TEXT) {
- throw new XmlPullParserException("An error has ocurred.", xpp,
- null);
- } else {
- if (xpp.getText().equals("null")) {
- connection.setPassword(null);
- } else {
- connection.setPassword(xpp.getText());
- }
- }
- }
+ * GrammarAction that adds a Password to a Connection
+ */
+ private final GrammarAction addPassword = new GrammarAction( "Add Password" )
+ {
+ public void action( ConnectionParserContainer container ) throws XmlPullParserException
+ {
+ Connection connection = container.getCurrentConnection();
+
+ XmlPullParser xpp = container.getParser();
+
+ int eventType = 0;
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( e.getMessage(), xpp, null );
+ }
+
+ if ( eventType != XmlPullParser.TEXT )
+ {
+ throw new XmlPullParserException( "An error has ocurred.", xpp, null );
+ }
+ else
+ {
+ if ( xpp.getText().equals( "null" ) )
+ {
+ connection.setPassword( null );
+ }
+ else
+ {
+ connection.setPassword( xpp.getText() );
+ }
+ }
+ }
};
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionListener.java?view=diff&rev=488368&r1=488367&r2=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionListener.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionListener.java Mon Dec 18 09:52:58 2006
@@ -20,19 +20,21 @@
package org.apache.directory.ldapstudio.browser.model;
+
/**
* Interface that has to be implemented by each Class that wants to listen on
* changes on a Connection
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public interface ConnectionListener {
+public interface ConnectionListener
+{
/**
- * This method is called if the Connection have been modified
- *
- * @param connection
- * the Connection
- */
- public void connectionChanged(Connection connection);
+ * This method is called if the Connection have been modified
+ *
+ * @param connection
+ * the Connection
+ */
+ public void connectionChanged( Connection connection );
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParser.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParser.java?view=diff&rev=488368&r1=488367&r2=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParser.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParser.java Mon Dec 18 09:52:58 2006
@@ -20,6 +20,7 @@
package org.apache.directory.ldapstudio.browser.model;
+
import java.io.IOException;
import java.io.StringReader;
import java.util.List;
@@ -28,85 +29,108 @@
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
+
/**
* This class is a Connection Parser
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ConnectionParser {
+public class ConnectionParser
+{
private ConnectionParserContainer container;
+
/**
- * Default constructor
- *
- * @throws XmlPullParserException
- */
- public ConnectionParser() throws XmlPullParserException {
- this.container = new ConnectionParserContainer();
+ * Default constructor
+ *
+ * @throws XmlPullParserException
+ */
+ public ConnectionParser() throws XmlPullParserException
+ {
+ this.container = new ConnectionParserContainer();
- XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+ XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
- XmlPullParser xpp = factory.newPullParser();
+ XmlPullParser xpp = factory.newPullParser();
- container.setParser(xpp);
+ container.setParser( xpp );
}
- public void parse(String str) throws XmlPullParserException {
- XmlPullParser xpp = container.getParser();
-
- xpp.setInput(new StringReader(str));
- container.setState(ConnectionGrammar.GRAMMAR_START);
-
- int eventType = xpp.getEventType();
- do {
- if (eventType == XmlPullParser.START_DOCUMENT) {
- container.setState(ConnectionGrammar.GRAMMAR_START);
- } else if (eventType == XmlPullParser.END_DOCUMENT) {
- container.setState(ConnectionGrammar.GRAMMAR_END);
- } else if (eventType == XmlPullParser.START_TAG) {
- processTag(Tag.START);
- } else if (eventType == XmlPullParser.END_TAG) {
- processTag(Tag.END);
- }
- try {
- eventType = xpp.next();
- } catch (IOException e) {
- throw new XmlPullParserException(
- "An IOException ocurred during parsing : "
- + e.getMessage(), xpp, null);
- }
- } while (container.getState() != ConnectionGrammar.GRAMMAR_END);
+ public void parse( String str ) throws XmlPullParserException
+ {
+ XmlPullParser xpp = container.getParser();
+
+ xpp.setInput( new StringReader( str ) );
+
+ container.setState( ConnectionGrammar.GRAMMAR_START );
+
+ int eventType = xpp.getEventType();
+ do
+ {
+ if ( eventType == XmlPullParser.START_DOCUMENT )
+ {
+ container.setState( ConnectionGrammar.GRAMMAR_START );
+ }
+ else if ( eventType == XmlPullParser.END_DOCUMENT )
+ {
+ container.setState( ConnectionGrammar.GRAMMAR_END );
+ }
+ else if ( eventType == XmlPullParser.START_TAG )
+ {
+ processTag( Tag.START );
+ }
+ else if ( eventType == XmlPullParser.END_TAG )
+ {
+ processTag( Tag.END );
+ }
+ try
+ {
+ eventType = xpp.next();
+ }
+ catch ( IOException e )
+ {
+ throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
+ null );
+ }
+ }
+ while ( container.getState() != ConnectionGrammar.GRAMMAR_END );
}
- private void processTag(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);
- }
+ private void processTag( 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 a List of the parsed Connections
- *
- * @return a List of the parsed Connections
- */
- public List<Connection> getConnections() {
- return container.getConnections();
+ * Gets a List of the parsed Connections
+ *
+ * @return a List of the parsed Connections
+ */
+ public List<Connection> getConnections()
+ {
+ return container.getConnections();
}
}
Modified: directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParserContainer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParserContainer.java?view=diff&rev=488368&r1=488367&r2=488368
==============================================================================
--- directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParserContainer.java (original)
+++ directory/sandbox/pamarcelot/ldapstudio/ldapstudio-ldapbrowser/src/main/java/org/apache/directory/ldapstudio/browser/model/ConnectionParserContainer.java Mon Dec 18 09:52:58 2006
@@ -20,17 +20,20 @@
package org.apache.directory.ldapstudio.browser.model;
+
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
+
/**
* This container is used for parsing connections
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ConnectionParserContainer {
+public class ConnectionParserContainer
+{
/** The current state of the decoding */
private int state;
@@ -46,109 +49,131 @@
private ConnectionGrammar grammar;
- public ConnectionParserContainer() {
- grammar = new ConnectionGrammar();
- connections = new ArrayList<Connection>();
+
+ public ConnectionParserContainer()
+ {
+ grammar = new ConnectionGrammar();
+ connections = new ArrayList<Connection>();
}
+
/**
- * Get the parser
- *
- * @return Returns the parser
- */
- public XmlPullParser getParser() {
- return parser;
+ * Get the parser
+ *
+ * @return Returns the parser
+ */
+ public XmlPullParser getParser()
+ {
+ return parser;
}
+
/**
- * Set the parser
- *
- * @param state
- * The parser
- */
- public void setParser(XmlPullParser parser) {
- this.parser = parser;
+ * Set the parser
+ *
+ * @param state
+ * The parser
+ */
+ public void setParser( XmlPullParser parser )
+ {
+ this.parser = parser;
}
+
/**
- * Get the current grammar state
- *
- * @return Returns the current grammar state
- */
- public int getState() {
- return state;
+ * Get the current grammar state
+ *
+ * @return Returns 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;
+ * Set the new current state
+ *
+ * @param state
+ * The new state
+ */
+ public void setState( int state )
+ {
+ this.state = state;
}
+
/**
- * Get the transition
- *
- * @return Returns the transition from the previous state to the new
- * state
- */
- public int getTransition() {
- return transition;
+ * Get the transition
+ *
+ * @return Returns 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;
+ * Update the transition from a state to another
+ *
+ * @param transition
+ * The transition to set
+ */
+ public void setTransition( int transition )
+ {
+ this.transition = transition;
}
+
/**
- * Get the connections
- *
- * @return Returns the parsed connections
- */
- public List<Connection> getConnections() {
- return this.connections;
+ * Get the connections
+ *
+ * @return Returns the parsed connections
+ */
+ public List<Connection> getConnections()
+ {
+ return this.connections;
}
+
/**
- * 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);
+ * 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 );
}
+
/**
- * Returns the current Connection
- *
- * @return A Connection
- */
- public Connection getCurrentConnection() {
- return connections.get(connections.size() - 1);
+ * Returns the current Connection
+ *
+ * @return A Connection
+ */
+ public Connection getCurrentConnection()
+ {
+ return connections.get( connections.size() - 1 );
}
+
/**
- * Adds a connection to the Connection List
- *
- * @param connection
- * The Connection to add
- * @return true (as per the general contract of the Collection.add
- * method).
- */
- public boolean addConnection(Connection connection) {
- return connections.add(connection);
+ * Adds a connection to the Connection List
+ *
+ * @param connection
+ * The Connection to add
+ * @return true (as per the general contract of the Collection.add
+ * method).
+ */
+ public boolean addConnection( Connection connection )
+ {
+ return connections.add( connection );
}
}