directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 36441 - in incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src: java/org/apache/snickers/ldap/encoder test/org/apache/snickers/ldap
Date Mon, 16 Aug 2004 02:38:32 GMT
Author: akarasulu
Date: Sun Aug 15 19:38:31 2004
New Revision: 36441

Added:
   incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/ReferralEncoder.java
Removed:
   incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/test/org/apache/snickers/ldap/SnickersEncoderTest.java
Log:
Commit Changes

 o removed test for old encoder as it is no longer necessary 
 o added new referral encoder to enable further reuse
 


Added: incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/ReferralEncoder.java
==============================================================================
--- (empty file)
+++ incubator/directory/snickers/branches/encoder-redesign/ldap-ber-provider/src/java/org/apache/snickers/ldap/encoder/ReferralEncoder.java
Sun Aug 15 19:38:31 2004
@@ -0,0 +1,68 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.snickers.ldap.encoder;
+
+
+import org.apache.snickers.ber.TupleNode;
+import org.apache.snickers.ber.Tuple;
+import org.apache.snickers.ber.Length;
+import org.apache.snickers.ber.DefaultMutableTupleNode;
+import org.apache.snickers.ldap.LdapTag;
+
+import org.apache.ldap.common.message.Referral;
+
+import java.util.Iterator;
+
+
+/**
+ * TupleNode tree encoder for Referrals.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org"> Apache Directory
+ *         Project</a> $Rev$
+ */
+public class ReferralEncoder
+{
+    /**
+     * An instance of this encoder.
+     */
+    public static final ReferralEncoder INSTANCE = new ReferralEncoder();
+
+
+    /**
+     * Encodes a Referral stub object into a TupleNode tree.  This method is
+     * thread safe.
+     *
+     * @param ref an instance of the Referral stub class
+     * @return the encoded TupleTree structure for the Referral object
+     */
+    public TupleNode encode( Referral ref )
+    {
+        Tuple tlv = new Tuple();
+        tlv.setTag( LdapTag.REFERRAL_TAG, false );
+        tlv.setLength( Length.INDEFINATE );
+        DefaultMutableTupleNode refs = new DefaultMutableTupleNode( tlv );
+
+        Iterator list = ref.getLdapUrls().iterator();
+        while( list.hasNext() )
+        {
+            refs.addLast( ( DefaultMutableTupleNode ) EncoderUtils.encode(
+                ( String ) list.next() ) );
+        }
+
+        return refs;
+    }
+}

Mime
View raw message