1 43 44 package org.jfree.xml.util; 45 46 import org.jfree.xml.attributehandlers.BooleanAttributeHandler; 47 import org.jfree.xml.attributehandlers.ByteAttributeHandler; 48 import org.jfree.xml.attributehandlers.DoubleAttributeHandler; 49 import org.jfree.xml.attributehandlers.FloatAttributeHandler; 50 import org.jfree.xml.attributehandlers.IntegerAttributeHandler; 51 import org.jfree.xml.attributehandlers.LongAttributeHandler; 52 import org.jfree.xml.attributehandlers.ShortAttributeHandler; 53 import org.jfree.xml.attributehandlers.StringAttributeHandler; 54 55 58 public class BasicTypeSupport { 59 60 private BasicTypeSupport () 61 { 62 } 63 64 72 public static String getHandlerClass(final Class c) { 73 if (c.equals(Integer .class) || c.equals(Integer.TYPE)) { 74 return IntegerAttributeHandler.class.getName(); 75 } 76 if (c.equals(Short .class) || c.equals(Short.TYPE)) { 77 return ShortAttributeHandler.class.getName(); 78 } 79 if (c.equals(Long .class) || c.equals(Long.TYPE)) { 80 return LongAttributeHandler.class.getName(); 81 } 82 if (c.equals(Boolean .class) || c.equals(Boolean.TYPE)) { 83 return BooleanAttributeHandler.class.getName(); 84 } 85 if (c.equals(Float .class) || c.equals(Float.TYPE)) { 86 return FloatAttributeHandler.class.getName(); 87 } 88 if (c.equals(Double .class) || c.equals(Double.TYPE)) { 89 return DoubleAttributeHandler.class.getName(); 90 } 91 if (c.equals(Byte .class) || c.equals(Byte.TYPE)) { 92 return ByteAttributeHandler.class.getName(); 93 } 94 if (c.equals(String .class)) { 96 return StringAttributeHandler.class.getName(); 97 } 98 throw new IllegalArgumentException ("BasicTypeSupport.getHandlerClass(Class): " 99 + "this is no attribute type."); 100 } 101 102 110 public static boolean isBasicDataType (final Class c) { 111 if (c.equals(Integer .class) || c.equals(Integer.TYPE)) { 112 return true; 113 } 114 if (c.equals(Short .class) || c.equals(Short.TYPE)) { 115 return true; 116 } 117 if (c.equals(Long .class) || c.equals(Long.TYPE)) { 118 return true; 119 } 120 if (c.equals(Boolean .class) || c.equals(Boolean.TYPE)) { 121 return true; 122 } 123 if (c.equals(Float .class) || c.equals(Float.TYPE)) { 124 return true; 125 } 126 if (c.equals(Double .class) || c.equals(Double.TYPE)) { 127 return true; 128 } 129 if (c.equals(Byte .class) || c.equals(Byte.TYPE)) { 130 return true; 131 } 132 if (c.equals(String .class)) { 134 return true; 135 } 136 return false; 137 } 138 139 146 public static Class getClassRepresentation(final String className) { 147 if (className.equals("::double")) { 148 return Double.TYPE; 149 } 150 if (className.equals("::boolean")) { 151 return Boolean.TYPE; 152 } 153 if (className.equals("::int")) { 154 return Integer.TYPE; 155 } 156 if (className.equals("::short")) { 157 return Short.TYPE; 158 } 159 if (className.equals("::long")) { 160 return Long.TYPE; 161 } 162 if (className.equals("::byte")) { 163 return Byte.TYPE; 164 } 165 throw new IllegalArgumentException ("This is none of my primitives."); 166 } 167 168 } 169 | Popular Tags |