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 2005/04/03 19:54:51 UTC
svn commit: r159943 -
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/util/pools/PoolEnum.java
Author: elecharny
Date: Sun Apr 3 10:54:50 2005
New Revision: 159943
URL: http://svn.apache.org/viewcvs?view=rev&rev=159943
Log:
Extended the Pools by adding MutableString pools.
Modified:
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/util/pools/PoolEnum.java
Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/util/pools/PoolEnum.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/util/pools/PoolEnum.java?view=diff&r1=159942&r2=159943
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/util/pools/PoolEnum.java (original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/util/pools/PoolEnum.java Sun Apr 3 10:54:50 2005
@@ -23,6 +23,7 @@
import org.apache.asn1.ldap.pojo.LdapMessagePOJO;
import org.apache.asn1.ldap.pojo.SaslAuthenticationPOJO;
import org.apache.asn1.ldap.pojo.SimpleAuthenticationPOJO;
+import org.apache.asn1.util.MutableString;
/**
* This is where all the different pools are named. To add a new pool, we have to
@@ -37,30 +38,54 @@
{
//~ Instance fields ----------------------------------------------------------------------------
- /** IPool of tags */
+ /** Pool of tags */
public static int TAG_POOL = 0;
- /** IPool of TLVs */
+ /** Pool of TLVs */
public static final int TLV_POOL = TAG_POOL++;
- /** IPool of SimpleAuthPOJO objects */
+ /** Pool of SimpleAuthPOJO objects */
public static final int SIMPLE_AUTH_POJO_POOL = TAG_POOL++;
- /** IPool of SaslAuthPOJO objects */
+ /** Pool of SaslAuthPOJO objects */
public static final int SASL_AUTH_POJO_POOL = TAG_POOL++;
- /** IPool of BindResponsePOJO objects */
+ /** Pool of BindResponsePOJO objects */
public static final int BIND_RESPONSE_POJO_POOL = TAG_POOL++;
- /** IPool of BindRequestPOJO objects */
+ /** Pool of BindRequestPOJO objects */
public static final int BIND_REQUEST_POJO_POOL = TAG_POOL++;
- /** IPool of LdapMessageContainer objects */
+ /** Pool of LdapMessageContainer objects */
public static final int LDAP_MESSAGE_CONTAINER_POOL = TAG_POOL++;
- /** IPool of LdapMessagePOJO objects */
+ /** Pool of LdapMessagePOJO objects */
public static final int LDAP_MESSAGE_POJO_POOL = TAG_POOL++;
+ /** Pool of 16 chars length Strings */
+ public static final int STRING_POOL_16 = TAG_POOL++;
+
+ /** Pool of 32 chars length Strings */
+ public static final int STRING_POOL_32 = TAG_POOL++;
+
+ /** Pool of 64 chars length Strings */
+ public static final int STRING_POOL_64 = TAG_POOL++;
+
+ /** Pool of 128 chars length Strings */
+ public static final int STRING_POOL_128 = TAG_POOL++;
+
+ /** Pool of 256 chars length Strings */
+ public static final int STRING_POOL_256 = TAG_POOL++;
+
+ /** Pool of 512 chars length Strings */
+ public static final int STRING_POOL_512 = TAG_POOL++;
+
+ /** Pool of 1024 chars length Strings */
+ public static final int STRING_POOL_1024 = TAG_POOL++;
+
+ /** Pool of streamed Strings */
+ public static final int STREAMED_STRING_POOL = TAG_POOL++;
+
/** To add a new pool type, change the static name.
* Don't forget to add a String in poolStrings ! */
// public static final int <ADDED_POOL> = TAG_POOL++;
@@ -68,6 +93,7 @@
/** The maximum number of pool we could have */
public static final int POOL_NUMBER = TAG_POOL;
+ /** The string representation for debuging purpose */
private static final String[] poolStrings = new String[]{
"TLV",
"SimpleAuthPOJO",
@@ -75,7 +101,15 @@
"BindResponsePOJO",
"BindRequestPOJO",
"LdapMessageContainer",
- "LdapMessagePOJO"
+ "LdapMessagePOJO",
+ "String16",
+ "String32",
+ "String64",
+ "String128",
+ "String256",
+ "String512",
+ "String1024",
+ "StreamedString"
// Add a new pool right here
};
@@ -116,5 +150,22 @@
default : return null;
}
+ }
+
+ /**
+ * Allocate a new object from a sized pool (used for strings).
+ * @param poolId The object pool Id
+ * @return An object
+ */
+ public static PoolObject allocateString( int size )
+ {
+ if (size > 1024)
+ {
+ return new MutableString( size, MutableString.STREAMED);
+ }
+ else
+ {
+ return new MutableString( ( ( size >> 4 ) + ( ( size & 0x0F ) != 0 ? 1 : 0) ) << 4 );
+ }
}
}