KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > exchange > PacketType


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.exchange;
14
15 /**
16  * Date: May 4, 2004 Time: 11:15:13 AM
17  * @author Sameer Charles
18  */

19 public final class PacketType {
20
21     /**
22      * Supported packet data types
23      */

24     public static final int STRING = 1;
25
26     public static final int BINARY = 2;
27
28     public static final int LONG = 3;
29
30     public static final int DOUBLE = 4;
31
32     public static final int DATE = 5;
33
34     public static final int BOOLEAN = 6;
35
36     public static final int OBJECT = 7;
37
38     /**
39      * String representations for packet data types
40      */

41     public static final String JavaDoc TYPENAME_STRING = "String"; //$NON-NLS-1$
42

43     public static final String JavaDoc TYPENAME_BINARY = "Binary"; //$NON-NLS-1$
44

45     public static final String JavaDoc TYPENAME_LONG = "Long"; //$NON-NLS-1$
46

47     public static final String JavaDoc TYPENAME_DOUBLE = "Double"; //$NON-NLS-1$
48

49     public static final String JavaDoc TYPENAME_DATE = "Date"; //$NON-NLS-1$
50

51     public static final String JavaDoc TYPENAME_BOOLEAN = "Boolean"; //$NON-NLS-1$
52

53     public static final String JavaDoc TYPENAME_OBJECT = "Object"; //$NON-NLS-1$
54

55     /**
56      * Utility class, don't instantiate.
57      */

58     private PacketType() {
59         // unused
60
}
61
62     /**
63      * @param type
64      * @return String representation of the type specified
65      */

66     public static String JavaDoc getNameByType(int type) {
67         switch (type) {
68             case STRING:
69                 return TYPENAME_STRING;
70             case BINARY:
71                 return TYPENAME_BINARY;
72             case BOOLEAN:
73                 return TYPENAME_BOOLEAN;
74             case LONG:
75                 return TYPENAME_LONG;
76             case DOUBLE:
77                 return TYPENAME_DOUBLE;
78             case DATE:
79                 return TYPENAME_DATE;
80             case OBJECT:
81                 return TYPENAME_OBJECT;
82             default:
83                 throw new IllegalArgumentException JavaDoc("unknown type: " + type); //$NON-NLS-1$
84
}
85     }
86 }
87
Popular Tags