1 package org.apache.ojb.jdo.jdoql; 2 3 17 18 import org.apache.ojb.broker.util.ClassHelper; 19 20 25 public class Type extends QueryTreeNode 26 { 27 28 private String _name; 29 30 private Class _type; 31 32 38 public Type(String typeName, boolean isPrimitive) 39 { 40 _name = typeName; 41 if (isPrimitive) 42 { 43 resolvePrimitiveType(); 44 } 45 } 46 47 51 private void resolvePrimitiveType() 52 { 53 final ClassLoader loader = ClassHelper.getClassLoader(); 54 try 55 { 56 _type = Class.forName(_name, true, loader); 57 } 58 catch (ClassNotFoundException ex) 59 { 60 } 62 } 63 64 69 public Class getType() 70 { 71 return _type; 72 } 73 74 79 public void setType(Class type) 80 { 81 _type = type; 82 if (_type != null) 83 { 84 _name = type.getName(); 85 } 86 } 87 88 93 public String getName() 94 { 95 return _name; 96 } 97 98 101 public void accept(Visitor visitor) 102 { 103 visitor.visit(this); 104 } 105 106 109 public String toString() 110 { 111 return _type == null ? _name : _type.getName(); 112 } 113 } 114 | Popular Tags |