1 22 package org.jboss.ejb.plugins.cmp.ejbql; 23 24 import java.util.List ; 25 26 import org.jboss.ejb.plugins.cmp.bridge.EntityBridge; 27 import org.jboss.ejb.plugins.cmp.bridge.FieldBridge; 28 import org.jboss.ejb.plugins.cmp.bridge.CMPFieldBridge; 29 import org.jboss.ejb.plugins.cmp.bridge.CMRFieldBridge; 30 31 37 public final class ASTPath extends SimpleNode 38 { 39 public List pathList; 40 public List fieldList; 41 public int type; 42 43 public boolean innerJoin; 44 45 public ASTPath(int id) 46 { 47 super(id); 48 } 49 50 public String getPath() 51 { 52 return (String ) pathList.get(pathList.size() - 1); 53 } 54 55 public String getPath(int i) 56 { 57 return (String ) pathList.get(i); 58 } 59 60 public FieldBridge getField() 61 { 62 return (FieldBridge) fieldList.get(fieldList.size() - 1); 63 } 64 65 public boolean isCMPField() 66 { 67 return fieldList.get(fieldList.size() - 1) instanceof CMPFieldBridge; 68 } 69 70 public CMPFieldBridge getCMPField() 71 { 72 return (CMPFieldBridge) fieldList.get(fieldList.size() - 1); 73 } 74 75 public boolean isCMRField() 76 { 77 return fieldList.get(fieldList.size() - 1) instanceof CMRFieldBridge; 78 } 79 80 public boolean isCMRField(int i) 81 { 82 return fieldList.get(i) instanceof CMRFieldBridge; 83 } 84 85 public CMRFieldBridge getCMRField() 86 { 87 return (CMRFieldBridge) fieldList.get(fieldList.size() - 1); 88 } 89 90 public CMRFieldBridge getCMRField(int i) 91 { 92 return (CMRFieldBridge) fieldList.get(i); 93 } 94 95 public EntityBridge getEntity() 96 { 97 Object field = fieldList.get(fieldList.size() - 1); 98 if(field instanceof CMRFieldBridge) 99 { 100 return ((CMRFieldBridge) field).getRelatedEntity(); 101 } 102 else if(field instanceof EntityBridge) 103 { 104 return (EntityBridge) field; 105 } 106 else 107 { 108 return null; 109 } 110 } 111 112 public EntityBridge getEntity(int i) 113 { 114 Object field = fieldList.get(i); 115 if(field instanceof CMRFieldBridge) 116 { 117 return ((CMRFieldBridge) field).getRelatedEntity(); 118 } 119 else if(field instanceof EntityBridge) 120 { 121 return (EntityBridge) field; 122 } 123 else 124 { 125 return null; 126 } 127 } 128 129 public int size() 130 { 131 return fieldList.size(); 132 } 133 134 public String toString() 135 { 136 return pathList.get(pathList.size() - 1) + " <" + type + ">"; 137 } 138 139 public boolean equals(Object o) 140 { 141 if(o instanceof ASTPath) 142 { 143 ASTPath path = (ASTPath) o; 144 return path.getPath().equals(getPath()); 145 } 146 return false; 147 } 148 149 public int hashCode() 150 { 151 return getPath().hashCode(); 152 } 153 154 157 public Object jjtAccept(JBossQLParserVisitor visitor, Object data) 158 { 159 return visitor.visit(this, data); 160 } 161 } 162 | Popular Tags |