1 21 package oracle.toplink.essentials.internal.expressions; 23 24 import java.io.*; 25 import java.util.*; 26 import oracle.toplink.essentials.queryframework.*; 27 import oracle.toplink.essentials.expressions.*; 28 import oracle.toplink.essentials.internal.sessions.AbstractRecord; 29 import oracle.toplink.essentials.internal.sessions.AbstractSession; 30 31 34 public class LiteralExpression extends Expression { 35 protected String value; 36 protected Expression localBase; 37 38 public LiteralExpression() { 39 super(); 40 } 41 42 public LiteralExpression(String newValue, Expression baseExpression) { 43 super(); 44 value = newValue; 45 localBase = baseExpression; 46 } 47 48 52 public String descriptionOfNodeType() { 53 return "Literal"; 54 } 55 56 60 public ExpressionBuilder getBuilder() { 61 return getLocalBase().getBuilder(); 62 } 63 64 protected Expression getLocalBase() { 65 return localBase; 66 } 67 68 public String getValue() { 69 return value; 70 } 71 72 public boolean isLiteralExpression() { 73 return true; 74 } 75 76 80 protected void postCopyIn(Dictionary alreadyDone) { 81 super.postCopyIn(alreadyDone); 82 localBase = localBase.copiedVersionFrom(alreadyDone); 83 } 84 85 89 public void printSQL(ExpressionSQLPrinter printer) { 90 printer.printString(value); 91 } 92 93 97 public void printSQLWithoutConversion(ExpressionSQLPrinter printer) { 98 printSQL(printer); 99 } 100 101 106 public Expression rebuildOn(Expression newBase) { 107 Expression result = (LiteralExpression)clone(); 108 result.setLocalBase(getLocalBase().rebuildOn(newBase)); 109 return result; 110 } 111 112 public void setLocalBase(Expression e) { 113 localBase = e; 114 } 115 116 123 public Expression twistedForBaseAndContext(Expression newBase, Expression context) { 124 return (Expression)this.clone(); 125 } 126 127 132 public Object valueFromObject(Object object, AbstractSession session, AbstractRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean isObjectUnregistered) { 133 return getLocalBase().getFieldValue(getValue()); 134 } 135 136 140 public void writeDescriptionOn(BufferedWriter writer) throws IOException { 141 writer.write(getValue().toString()); 142 } 143 } 144 | Popular Tags |