You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2011/01/30 15:17:34 UTC
svn commit: r1065285 -
/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java
Author: akarasulu
Date: Sun Jan 30 14:17:34 2011
New Revision: 1065285
URL: http://svn.apache.org/viewvc?rev=1065285&view=rev
Log:
forgot to add a class before committing
Added:
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java
Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java?rev=1065285&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/controls/persistentSearch/PersistentSearchFactory.java Sun Jan 30 14:17:34 2011
@@ -0,0 +1,94 @@
+/*
+ * 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.codec.search.controls.persistentSearch;
+
+
+import java.nio.ByteBuffer;
+
+import javax.naming.ldap.BasicControl;
+import javax.naming.ldap.Control;
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.ldap.codec.IControlFactory;
+import org.apache.directory.shared.ldap.model.message.controls.PersistentSearch;
+import org.apache.directory.shared.ldap.model.message.controls.PersistentSearchImpl;
+
+
+/**
+ *
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PersistentSearchFactory implements IControlFactory<PersistentSearch, PersistentSearchDecorator>
+{
+ public String getOid()
+ {
+ return PersistentSearch.OID;
+ }
+
+
+ public PersistentSearchDecorator newCodecControl()
+ {
+ return new PersistentSearchDecorator();
+ }
+
+
+ public PersistentSearchDecorator decorate( PersistentSearch control )
+ {
+ if ( control instanceof PersistentSearchDecorator )
+ {
+ return ( PersistentSearchDecorator ) control;
+ }
+ else
+ {
+ return new PersistentSearchDecorator( control );
+ }
+ }
+
+
+ public PersistentSearch newControl()
+ {
+ return new PersistentSearchImpl();
+ }
+
+
+ public Control toJndiControl( PersistentSearch control ) throws EncoderException
+ {
+ PersistentSearchDecorator decorator = decorate( control );
+ ByteBuffer buf = ByteBuffer.allocate( decorator.computeLength() );
+ decorator.encode( buf );
+ buf.flip();
+ BasicControl jndi = new BasicControl( control.getOid(), control.isCritical(), buf.array() );
+ return jndi;
+ }
+
+
+ public PersistentSearch fromJndiControl( Control jndi ) throws DecoderException
+ {
+ PersistentSearchDecorator decorator = newCodecControl();
+ decorator.setCritical( jndi.isCritical() );
+ decorator.setValue( jndi.getEncodedValue() );
+ byte[] controlBytes = new byte[decorator.computeLength()];
+ decorator.decode( controlBytes );
+ return decorator.getDecorated();
+ }
+}