1 22 23 package org.xquark.extractor.sql; 24 25 26 public class SqlAttributeExpression extends SqlExpression 27 { 28 29 private static final String RCSRevision = "$Revision: 1.5 $"; 30 private static final String RCSName = "$Name: $"; 31 32 private String _attribute; 33 private String _tableInstance; 34 35 40 public SqlAttributeExpression(String tableInstance, String attribute) 41 { 42 setTableInstance (tableInstance); 43 setAttribute(attribute); 44 } 45 46 49 public SqlAttributeExpression() 50 { 51 52 } 53 54 59 public String getAttribute() 60 { 61 return _attribute; 62 } 63 64 69 public void setAttribute(String aAttribute) 70 { 71 _attribute = aAttribute; 72 } 73 74 79 public String getTableInstance() 80 { 81 return _tableInstance; 82 } 83 84 89 public void setTableInstance(String aTableInstance) 90 { 91 _tableInstance = aTableInstance; 92 } 93 94 public String getName() 95 { 96 return getAttribute(); 97 } 98 99 public String toSql(Context context) { 100 return toSql(context,true); 101 } 102 103 public String toSql(Context context, boolean putQuotes) 104 { 105 107 StringBuffer retVal = new StringBuffer (); 108 109 if (getAttribute().equals("*")) 110 retVal.append(_attribute); 111 else { 112 if (getTableInstance() != null) { 113 if (putQuotes) 114 retVal.append('"'); 115 retVal.append(_tableInstance); 116 if (putQuotes) 117 retVal.append('"'); 118 retVal.append("."); 119 } 120 121 if (putQuotes) 122 retVal.append('"'); 123 retVal.append(_attribute); 124 if (putQuotes) 125 retVal.append('"'); 126 127 if (context.outerJoinPredicate) { 128 if (getTableInstance() 129 .equalsIgnoreCase(context.innerTable.getName())) { 130 retVal.append("(+)"); 131 } 132 } 133 } 134 135 return retVal.toString() ; 137 } 138 } 139 | Popular Tags |