| 1 | /* |
| 2 | * Copyright 2008 Eric Caspole |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this |
| 5 | * file except in compliance with the License. You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software distributed under |
| 10 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 11 | * KIND, either express or implied. See the License for the specific language governing |
| 12 | * permissions and limitations under the License. |
| 13 | */ |
| 14 | |
| 15 | package net.sf.madmap; |
| 16 | |
| 17 | /* |
| 18 | 2 object |
| 19 | 4 boolean |
| 20 | 5 char |
| 21 | 6 float |
| 22 | 7 double |
| 23 | 8 byte |
| 24 | 9 short |
| 25 | 10 int |
| 26 | 11 long |
| 27 | */ |
| 28 | |
| 29 | public enum BasicTypeInfo { |
| 30 | DUMMY ((byte)0, 0, "dummy"), |
| 31 | BOOLEAN ((byte)4, 1, "boolean"), |
| 32 | CHAR ((byte)5, 2, "char"), |
| 33 | FLOAT ((byte)6, 4, "float"), |
| 34 | DOUBLE ((byte)7, 8, "double"), |
| 35 | BYTE ((byte)8, 1, "byte"), |
| 36 | SHORT ((byte)9, 2, "short"), |
| 37 | INT ((byte)10,4, "int"), |
| 38 | LONG ((byte)11,8, "long"); |
| 39 | |
| 40 | private final byte code; |
| 41 | private final int size; |
| 42 | private final String name; |
| 43 | |
| 44 | BasicTypeInfo( byte c, int s, String nm ) { |
| 45 | code = c; |
| 46 | size = s; |
| 47 | name = nm; |
| 48 | } |
| 49 | |
| 50 | //int getCode() { return code; } |
| 51 | byte getCode() { return code; } |
| 52 | int getSize() { return size; } |
| 53 | String getName() { return name; } |
| 54 | |
| 55 | BasicTypeInfo get( int tc ) { |
| 56 | for (BasicTypeInfo p : BasicTypeInfo.values()) { |
| 57 | if ( p.getCode() == tc ) { |
| 58 | return p; |
| 59 | } |
| 60 | } |
| 61 | return null; |
| 62 | } |
| 63 | } |