directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r439623 - /directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/AbstractMessage.java
Date Sat, 02 Sep 2006 17:41:32 GMT
Author: elecharny
Date: Sat Sep  2 10:41:31 2006
New Revision: 439623

URL: http://svn.apache.org/viewvc?rev=439623&view=rev
Log:
Added the abstract Message class

Added:
    directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/AbstractMessage.java

Added: directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/AbstractMessage.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/AbstractMessage.java?rev=439623&view=auto
==============================================================================
--- directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/AbstractMessage.java
(added)
+++ directory/sandbox/akarasulu/apacheds-2.0/shared/ldap/src/main/java/org/apache/directory/shared/ldap/messages/AbstractMessage.java
Sat Sep  2 10:41:31 2006
@@ -0,0 +1,108 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.messages;
+
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.ldap.Control;
+
+
+/**
+ * Abstract message base class.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AbstractMessage implements Message
+{
+    static final long serialVersionUID = 2L;
+
+    /** Map of message controls using OID Strings for keys and Control values */
+    private final Map<String, Control> controls;
+
+    /** The session unique message sequence identifier */
+    private final int messageId;
+
+
+    /**
+     * Completes the instantiation of a Message.
+     * 
+     * @param messageId the seq id of the message
+     */
+    protected AbstractMessage( final int messageId )
+    {
+        this.messageId = messageId;
+        this.controls = new HashMap<String, Control>();
+    }
+
+
+    /**
+     * Gets the session unique message sequence id for this message. Requests
+     * and their responses if any have the same message id. Clients at the
+     * initialization of a session start with the first message's id set to 1
+     * and increment it with each transaction.
+     * 
+     * @return the session unique message id.
+     */
+    public int getMessageId()
+    {
+        return messageId;
+    }
+
+
+    /**
+     * Gets the controls associated with this message mapped by OID.
+     * 
+     * @return Map of OID strings to Control object instances.
+     * @see Control
+     */
+    public Map<String, Control> getControls()
+    {
+        return Collections.unmodifiableMap( controls );
+    }
+
+
+    /**
+     * Adds a control to this Message.
+     * 
+     * @param control the control to add.
+     * @throws MessageException if controls cannot be added to this Message or the control
is
+     *             not known etc.
+     */
+    public void add( Control control ) throws MessageException
+    {
+        controls.put( control.getID(), control );
+    }
+
+
+    /**
+     * Deletes a control removing it from this Message.
+     * 
+     * @param control the control to remove.
+     * @throws MessageException if controls cannot be added to this Message or the control
is
+     *             not known etc.
+     */
+    public void remove( Control control ) throws MessageException
+    {
+        controls.remove( control.getID() );
+    }
+}



Mime
View raw message