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/25 23:06:26 UTC

svn commit: r164649 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLVPoolEnum.java

Author: elecharny
Date: Mon Apr 25 14:06:25 2005
New Revision: 164649

URL: http://svn.apache.org/viewcvs?rev=164649&view=rev
Log:
Add this class to ease the pool managment

Added:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLVPoolEnum.java

Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLVPoolEnum.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLVPoolEnum.java?rev=164649&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLVPoolEnum.java (added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ber/tlv/TLVPoolEnum.java Mon Apr 25 14:06:25 2005
@@ -0,0 +1,73 @@
+/*
+ *   Copyright 2005 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.asn1.ber.tlv;
+
+import org.apache.asn1.ber.tlv.TLV;
+import org.apache.asn1.util.pools.PoolObject;
+
+/**
+ * This is where all the different TLV pools are named. To add a new pool, we have to
+ * add an entry to the list, and to modify the getType method.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public final class TLVPoolEnum {
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** Pool of tags. The pool number start at 20 */
+    public static final int TAG_POOL = 20;
+
+    /** Pool of lengths */
+    public static final int LENGTH_POOL = 21;
+
+    /** Pool of TLVs */
+    public static final int TLV_POOL = 22;
+
+    /**
+     * Get the name of the object stored in this pool 
+     *
+     * @return The object name
+     */
+    public static String getType(int poolId)
+    {
+
+        switch (poolId)
+        {
+        	case TAG_POOL : return "Tag";
+        	case LENGTH_POOL : return "Length";
+        	case TLV_POOL : return "TLV";
+        	default : return "UKNOWN POOL";
+        }
+    }
+    
+    /**
+     * Allocate a new object the classic way.
+     * @param poolId The object pool Id
+     * @return An object
+     */
+    public static PoolObject allocate(int poolId)
+    {
+    	switch (poolId)
+		{
+			case TAG_POOL : return new Tag();
+			case LENGTH_POOL : return new Length();
+    		case TLV_POOL : return new TLV();
+    		
+    		default : return null;
+		}
+    }
+}