Methods Summary |
---|
public java.lang.String | basicDescription()Return description.
Used for toString.
return String.valueOf(getField());
|
public java.lang.String | descriptionOfNodeType()INTERNAL:
Used for debug printing.
return "Parameter";
|
public oracle.toplink.essentials.expressions.Expression | get(java.lang.String attributeOrQueryKey)This allows for nesting of parametrized expression.
This is used for parameterizing object comparisons.
ParameterExpression expression = new ParameterExpression(attributeOrQueryKey);
expression.setBaseExpression(this);
return expression;
|
public oracle.toplink.essentials.expressions.Expression | getBaseExpression()The base expression is what the parameter was derived from.
This is used for nested parameters.
return baseExpression;
|
public oracle.toplink.essentials.expressions.ExpressionBuilder | getBuilder()Return the expression builder which is the ultimate base of this expression, or
null if there isn't one (shouldn't happen if we start from a root)
if (localBase == null) {
//Bug#5097278 Need to return the builder from the base expression if nested.
if (getBaseExpression() != null) {
return ((ParameterExpression)getBaseExpression()).getBuilder();
} else {
return null;
}
}
return localBase.getBuilder();
|
public oracle.toplink.essentials.internal.helper.DatabaseField | getField()
return field;
|
public oracle.toplink.essentials.expressions.Expression | getField(oracle.toplink.essentials.internal.helper.DatabaseField field)This allows for nesting of parametrized expression.
This is used for parameterizing object comparisons.
ParameterExpression expression = new ParameterExpression(field);
expression.setBaseExpression(this);
return expression;
|
public oracle.toplink.essentials.expressions.Expression | getLocalBase()The opposite side of the relation, this is used for conversion of the parameter using the others mapping.
return localBase;
|
public java.lang.Object | getType()The infered type of this parameter.
Please note that the type might not be always initialized to correct value.
It might be null if not initialized correctly return type;
|
public java.lang.Object | getValue(oracle.toplink.essentials.internal.sessions.AbstractRecord translationRow, oracle.toplink.essentials.internal.sessions.AbstractSession session)Extract the value from the row.
This may require recusion if it is a nested parameter.
if (getField() == null) {
return null;
}
Object value = null;
// Check for nested parameters.
if (getBaseExpression() != null) {
value = ((ParameterExpression)getBaseExpression()).getValue(translationRow, session);
if (value == null) {
return null;
}
ClassDescriptor descriptor = session.getDescriptor(value);
//Bug4924639 Aggregate descriptors have to be acquired from their mapping as they are cloned and initialized by each mapping
if (descriptor.isAggregateDescriptor() && ((ParameterExpression)getBaseExpression()).getLocalBase().isObjectExpression()) {
descriptor = ((ObjectExpression)((ParameterExpression)getBaseExpression()).getLocalBase()).getDescriptor();
}
if (descriptor != null) {
// For bug 2990493 must unwrap for EJBQL "Select Person(p) where p = ?1"
//if we had to unwrap it make sure we replace the argument with this value
//incase it is needed again, say in conforming.
//bug 3750793
value = descriptor.getObjectBuilder().unwrapObject(value, session);
translationRow.put(((ParameterExpression)getBaseExpression()).getField(), value);
// The local parameter is either a field or attribute of the object.
DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForField(getField());
if (mapping != null) {
value = mapping.valueFromObject(value, getField(), session);
} else {
mapping = descriptor.getObjectBuilder().getMappingForAttributeName(getField().getName());
if (mapping != null) {
value = mapping.getRealAttributeValueFromObject(value, session);
} else {
DatabaseField queryKeyField = descriptor.getObjectBuilder().getFieldForQueryKeyName(getField().getName());
if (queryKeyField != null) {
mapping = descriptor.getObjectBuilder().getMappingForField(getField());
if (mapping != null) {
value = mapping.valueFromObject(value, getField(), session);
}
}
}
}
}
} else {
value = translationRow.getIndicatingNoEntry(getField());
//Throw an exception if the field is not mapped
if (value == oracle.toplink.essentials.internal.sessions.AbstractRecord.noEntry) {
throw QueryException.parameterNameMismatch(getField().getName());
}
}
// Convert the value to the correct type, i.e. object type mappings.
if (getLocalBase() != null) {
value = getLocalBase().getFieldValue(value);
}
return value;
|
public boolean | isParameterExpression()
return true;
|
public boolean | isValueExpression()INTERNAL:
return true;
|
protected void | postCopyIn(java.util.Dictionary alreadyDone)INTERNAL:
Used for cloning.
super.postCopyIn(alreadyDone);
if (getLocalBase() != null) {
setLocalBase(getLocalBase().copiedVersionFrom(alreadyDone));
}
if (getBaseExpression() != null) {
setBaseExpression(getBaseExpression().copiedVersionFrom(alreadyDone));
}
|
public void | printJava(oracle.toplink.essentials.internal.expressions.ExpressionJavaPrinter printer)INTERNAL:
Print java for project class generation
((DataExpression)getLocalBase()).getBaseExpression().printJava(printer);
printer.printString(".getParameter(\"" + getField().getQualifiedName() + "\")");
|
public void | printSQL(oracle.toplink.essentials.internal.expressions.ExpressionSQLPrinter printer)INTERNAL:
Print SQL onto the stream, using the ExpressionPrinter for context
if (printer.shouldPrintParameterValues()) {
Object value = getValue(printer.getTranslationRow(), printer.getSession());
if(getField() == null) {
printer.printPrimitive(value);
} else {
if (value instanceof Vector) {
printer.printValuelist((Vector)value);
} else {
printer.printParameter(this);
}
}
} else {
if (getField() != null) {
printer.printParameter(this);
}
}
|
public oracle.toplink.essentials.expressions.Expression | rebuildOn(oracle.toplink.essentials.expressions.Expression newBase)INTERNAL:
This expression is built on a different base than the one we want. Rebuild it and
return the root of the new tree
ParameterExpression result = (ParameterExpression)clone();
result.setLocalBase(localBase.rebuildOn(newBase));
return result;
|
protected void | setBaseExpression(oracle.toplink.essentials.expressions.Expression baseExpression)The base expression is what the parameter was derived from.
This is used for nested parameters.
this.baseExpression = baseExpression;
|
public void | setLocalBase(oracle.toplink.essentials.expressions.Expression localBase)The opposite side of the relation, this is used for conversion of the parameter using the others mapping.
this.localBase = localBase;
|
public oracle.toplink.essentials.expressions.Expression | twistedForBaseAndContext(oracle.toplink.essentials.expressions.Expression newBase, oracle.toplink.essentials.expressions.Expression context)INTERNAL:
Rebuild against the base, with the values of parameters supplied by the context
expression. This is used for transforming a standalone expression (e.g. the join criteria of a mapping)
into part of some larger expression. You normally would not call this directly, instead calling twist,
(see the comment there for more details).
return context.getField(getField());
|
public java.lang.Object | valueFromObject(java.lang.Object object, oracle.toplink.essentials.internal.sessions.AbstractSession session, oracle.toplink.essentials.internal.sessions.AbstractRecord translationRow, oracle.toplink.essentials.queryframework.InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean isObjectUnregistered)INTERNAL:
Return the value for in memory comparison.
This is only valid for valueable expressions.
// Run ourselves through the translation row to find the desired value
if (getField() != null) {
return getValue(translationRow, session);
}
throw QueryException.cannotConformExpression();
|
public void | writeDescriptionOn(java.io.BufferedWriter writer)INTERNAL:
Used to print a debug form of the expression tree.
writer.write(basicDescription());
|
public void | writeFields(oracle.toplink.essentials.internal.expressions.ExpressionSQLPrinter printer, java.util.Vector newFields, oracle.toplink.essentials.internal.expressions.SQLSelectStatement statement)INTERNAL:
Append the parameter into the printer.
"Normal" ReadQuery never has ParameterExpression in it's select clause hence for a "normal" ReadQuery this method is never called.
The reason this method was added is that UpdateAllQuery (in case temporary storage is required)
creates a "helper" ReportQuery with ReportItem corresponding to each update expression - and update expression
may be a ParameterExpression. The call created by "helper" ReportQuery is never executed -
it's used during construction of insert call into temporary storage.
//print ", " before each selected field except the first one
if (printer.isFirstElementPrinted()) {
printer.printString(", ");
} else {
printer.setIsFirstElementPrinted(true);
}
// This field is a parameter value, so any name can be used.
newFields.addElement(new DatabaseField("*"));
printSQL(printer);
|
public void | writeSubexpressionsTo(java.io.BufferedWriter writer, int indent)Print the base for debuggin purposes.
if (getBaseExpression() != null) {
getBaseExpression().toString(writer, indent);
}
|