Methods Summary |
---|
public void | appendIn(java.io.Writer writer, oracle.toplink.essentials.internal.helper.DatabaseField field)INTERNAL:
All values are printed as ? to allow for parameter binding or translation during the execute of the call.
try {
writer.write(argumentMarker());
} catch (IOException exception) {
throw ValidationException.fileError(exception);
}
getParameters().addElement(field);
getParameterTypes().addElement(IN);
|
public void | appendInOut(java.io.Writer writer, oracle.toplink.essentials.internal.helper.DatabaseField inoutField)INTERNAL:
All values are printed as ? to allow for parameter binding or translation during the execute of the call.
try {
writer.write(argumentMarker());
} catch (IOException exception) {
throw ValidationException.fileError(exception);
}
Object[] inOut = { inoutField, inoutField };
getParameters().addElement(inOut);
getParameterTypes().addElement(INOUT);
|
public void | appendLiteral(java.io.Writer writer, java.lang.Object literal)INTERNAL:
All values are printed as ? to allow for parameter binding or translation during the execute of the call.
try {
writer.write(argumentMarker());
} catch (IOException exception) {
throw ValidationException.fileError(exception);
}
getParameters().addElement(literal);
getParameterTypes().addElement(LITERAL);
|
public void | appendModify(java.io.Writer writer, oracle.toplink.essentials.internal.helper.DatabaseField modifyField)INTERNAL:
All values are printed as ? to allow for parameter binding or translation during the execute of the call.
try {
writer.write(argumentMarker());
} catch (IOException exception) {
throw ValidationException.fileError(exception);
}
getParameters().addElement(modifyField);
getParameterTypes().addElement(MODIFY);
|
public void | appendOut(java.io.Writer writer, oracle.toplink.essentials.internal.helper.DatabaseField outField)INTERNAL:
All values are printed as ? to allow for parameter binding or translation during the execute of the call.
try {
writer.write(argumentMarker());
} catch (IOException exception) {
throw ValidationException.fileError(exception);
}
getParameters().addElement(outField);
getParameterTypes().addElement(OUT);
|
public void | appendParameter(java.io.Writer writer, java.lang.Object parameter, oracle.toplink.essentials.internal.sessions.AbstractSession session)Add the parameter.
If using binding bind the parameter otherwise let the platform print it.
The platform may also decide to bind the value.
session.getDatasourcePlatform().appendParameter(this, writer, parameter);
|
public void | appendTranslation(java.io.Writer writer, oracle.toplink.essentials.internal.helper.DatabaseField modifyField)INTERNAL:
All values are printed as ? to allow for parameter binding or translation during the execute of the call.
try {
writer.write(argumentMarker());
} catch (IOException exception) {
throw ValidationException.fileError(exception);
}
getParameters().addElement(modifyField);
getParameterTypes().addElement(TRANSLATION);
|
public boolean | areManyRowsReturned()The return type is one of, NoReturn, ReturnOneRow or ReturnManyRows.
return getReturnType() == RETURN_MANY_ROWS;
|
protected char | argumentMarker()INTERNAL:
Return the character to use for the argument marker.
? is used in SQL, however other query languages such as XQuery need to use other markers.
return '?";
|
public oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism | buildNewQueryMechanism(oracle.toplink.essentials.queryframework.DatabaseQuery query)Return the appropriate mechanism,
with the call added as necessary.
return new DatasourceCallQueryMechanism(query, this);
|
public oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism | buildQueryMechanism(oracle.toplink.essentials.queryframework.DatabaseQuery query, oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism mechanism)Return the appropriate mechanism,
with the call added as necessary.
if (mechanism.isCallQueryMechanism() && (mechanism instanceof DatasourceCallQueryMechanism)) {
// Must also add the call singleton...
DatasourceCallQueryMechanism callMechanism = ((DatasourceCallQueryMechanism)mechanism);
if (!callMechanism.hasMultipleCalls()) {
callMechanism.addCall(callMechanism.getCall());
callMechanism.setCall(null);
}
callMechanism.addCall(this);
return mechanism;
} else {
return buildNewQueryMechanism(query);
}
|
public java.lang.Object | clone()
try {
return super.clone();
} catch (CloneNotSupportedException exception) {
;//Do nothing
}
return null;
|
protected oracle.toplink.essentials.internal.helper.DatabaseField | createField(java.lang.String fieldName)INTERNAL:
Create a new Database Field
This method can be overridden by subclasses to return other field types
return new DatabaseField(fieldName);
|
protected java.lang.Object | createInOutParameter(java.lang.Object inValue, java.lang.Object outParameter, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Returns INOUT parameter. Called by getValueForInOutParameter method.
Descendents may override this method.
Object[] inOut = { inValue, outParameter };
return inOut;
|
public abstract java.lang.String | getLogString(oracle.toplink.essentials.internal.databaseaccess.Accessor accessor)Return the SQL string for logging purposes.
|
public java.util.Vector | getParameterTypes()The parameter types determine if the parameter is a modify, translation or litteral type.
if (parameterTypes == null) {
parameterTypes = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance();
}
return parameterTypes;
|
public java.util.Vector | getParameters()The parameters are the values in order of occurance in the SQL statement.
This is lazy initialized to conserv space on calls that have no parameters.
if (parameters == null) {
parameters = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance();
}
return parameters;
|
public oracle.toplink.essentials.queryframework.DatabaseQuery | getQuery()Back reference to query, unfortunately required for events.
return query;
|
public java.lang.String | getQueryString()Return the query string of the call.
This must be overwritten by subclasses that support query language translation (SQLCall, XQueryCall).
return "";
|
public int | getReturnType()The return type is one of, NoReturn, ReturnOneRow or ReturnManyRows.
return returnType;
|
protected java.lang.Object | getValueForInOutParameter(java.lang.Object parameter, oracle.toplink.essentials.internal.sessions.AbstractRecord translationRow, oracle.toplink.essentials.internal.sessions.AbstractRecord modifyRow, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Returns value for INOUT parameter. Called by translate and translateSQLString methods.
// parameter ts an array of two Objects: inParameter and outParameter
Object inParameter = ((Object[])parameter)[0];
Object inValue = getValueForInParameter(inParameter, translationRow, modifyRow, session, true);
Object outParameter = ((Object[])parameter)[1];
return createInOutParameter(inValue, outParameter, session);
|
protected java.lang.Object | getValueForInParameter(java.lang.Object parameter, oracle.toplink.essentials.internal.sessions.AbstractRecord translationRow, oracle.toplink.essentials.internal.sessions.AbstractRecord modifyRow, oracle.toplink.essentials.internal.sessions.AbstractSession session, boolean shouldBind)INTERNAL:
Returns value for IN parameter. Called by translate and translateSQLString methods.
In case shouldBind==true tries to return a DatabaseField with type instead of null,
returns null only in case no DatabaseField with type was found.
Object value = parameter;
// Parameter expressions are used for nesting and correct mapping conversion of the value.
if (parameter instanceof ParameterExpression) {
value = ((ParameterExpression)parameter).getValue(translationRow, session);
} else if (parameter instanceof DatabaseField) {
DatabaseField field = (DatabaseField)parameter;
value = translationRow.get(field);
// Must check for the modify row as well for custom SQL compatibility as only one # is required.
if (modifyRow != null) {
if (value == null) {
value = modifyRow.get(field);
}
if (value != null) {
DatabaseField modifyField = modifyRow.getField(field);
if (modifyField != null) {
if (session.getDatasourcePlatform().shouldUseCustomModifyForCall(modifyField)) {
value = session.getDatasourcePlatform().getCustomModifyValueForCall(this, value, modifyField, shouldBind);
}
}
}
}
if ((value == null) && shouldBind) {
if (field.getType() != null) {
value = field;
} else if (modifyRow != null) {
DatabaseField modifyField = modifyRow.getField(field);
if ((modifyField != null) && (modifyField.getType() != null)) {
value = modifyField;
}
}
if (value == null) {
DatabaseField translationField = translationRow.getField(field);
if (translationField == null){
throw QueryException.namedArgumentNotFoundInQueryParameters(field.getName());
}
if (translationField.getType() != null) {
value = translationField;
}
}
}
}
return value;
|
public boolean | hasParameters()The parameters are the values in order of occurance in call.
This is lazy initialized to conserv space on calls that have no parameters.
return (parameters != null) && (!getParameters().isEmpty());
|
public boolean | isCursorReturned()The return type is one of, NoReturn, ReturnOneRow or ReturnManyRows.
return getReturnType() == RETURN_CURSOR;
|
public boolean | isEISInteraction()
return false;
|
public boolean | isEJBQLCall()
return false;
|
public boolean | isFinished()Return whether all the results of the call have been returned.
return !isCursorReturned();
|
public boolean | isNothingReturned()The return type is one of, NoReturn, ReturnOneRow or ReturnManyRows.
return getReturnType() == NO_RETURN;
|
public boolean | isOneRowReturned()The return type is one of, NoReturn, ReturnOneRow or ReturnManyRows.
return getReturnType() == RETURN_ONE_ROW;
|
public boolean | isOutputParameterType(java.lang.Integer parameterType)
return (parameterType == OUT) || (parameterType == INOUT) || (parameterType == OUT_CURSOR);
|
protected boolean | isPrepared()Bound calls can have the SQL pre generated.
return isPrepared;
|
public boolean | isQueryStringCall()
return false;
|
public boolean | isSQLCall()
return false;
|
public boolean | isStoredFunctionCall()
return false;
|
public boolean | isStoredProcedureCall()
return false;
|
public void | prepare(oracle.toplink.essentials.internal.sessions.AbstractSession session)Allow pre-printing of the query/SQL string for fully bound calls, to save from reprinting.
setIsPrepared(true);
|
public void | returnCursor()Cursor return is used for cursored streams.
setReturnType(RETURN_CURSOR);
|
public void | returnManyRows()Many rows are returned for read-all queries.
setReturnType(RETURN_MANY_ROWS);
|
public void | returnNothing()No return is used for modify calls like insert / update / delete.
setReturnType(NO_RETURN);
|
public void | returnOneRow()One row is returned for read-object queries.
setReturnType(RETURN_ONE_ROW);
|
protected void | setIsPrepared(boolean isPrepared)Bound calls can have the SQL pre generated.
this.isPrepared = isPrepared;
|
public void | setParameterTypes(java.util.Vector parameterTypes)The parameter types determine if the parameter is a modify, translation or litteral type.
this.parameterTypes = parameterTypes;
|
public void | setParameters(java.util.Vector parameters)The parameters are the values in order of occurance in the SQL statement.
this.parameters = parameters;
|
public void | setQuery(oracle.toplink.essentials.queryframework.DatabaseQuery query)Back reference to query, unfortunately required for events.
this.query = query;
|
public void | setQueryString(java.lang.String queryString)Set the query string of the call.
This must be overwritten by subclasses that support query language translation (SQLCall, XQueryCall).
// Nothing by default.
|
public void | setReturnType(int returnType)The return type is one of, NoReturn, ReturnOneRow or ReturnManyRows.
this.returnType = returnType;
|
public void | translate(oracle.toplink.essentials.internal.sessions.AbstractRecord translationRow, oracle.toplink.essentials.internal.sessions.AbstractRecord modifyRow, oracle.toplink.essentials.internal.sessions.AbstractSession session)Allow the call to translate from the translation for predefined calls.
//do nothing by default.
|
public void | translateCustomQuery()INTERNAL:
Parse the query string for # markers for custom query based on a query language.
This is used by SQLCall and XQuery call, but can be reused by other query languages.
if (getQueryString().indexOf("#") == -1) {
if (this.getQuery().shouldBindAllParameters() && getQueryString().indexOf("?") == -1){
return;
}
translatePureSQLCustomQuery();
return;
}
int lastIndex = 0;
int litteralIndex = 0;// This index is used to determine the position of litterals
String queryString = getQueryString();
Writer writer = new CharArrayWriter(queryString.length() + 50);
try {
// ** This method is heavily optimized do not touch anyhthing unless you "know" what your doing.
while (lastIndex != -1) {
int poundIndex = queryString.indexOf('#", lastIndex);
String token;
if (poundIndex == -1) {
token = queryString.substring(lastIndex, queryString.length());
lastIndex = -1;
} else {
token = queryString.substring(lastIndex, poundIndex);
}
writer.write(token);
if (poundIndex != -1) {
int wordEndIndex = poundIndex + 1;
while ((wordEndIndex < queryString.length()) && (whitespace().indexOf(queryString.charAt(wordEndIndex)) == -1)) {
wordEndIndex = wordEndIndex + 1;
}
// Check for ## which means field from modify row.
if (queryString.charAt(poundIndex + 1) == '#") {
// Check for ### which means OUT parameter type.
if (queryString.charAt(poundIndex + 2) == '#") {
// Check for #### which means INOUT parameter type.
if (queryString.charAt(poundIndex + 3) == '#") {
String fieldName = queryString.substring(poundIndex + 4, wordEndIndex);
DatabaseField field = createField(fieldName);
appendInOut(writer, field);
} else {
String fieldName = queryString.substring(poundIndex + 3, wordEndIndex);
DatabaseField field = createField(fieldName);
appendOut(writer, field);
}
} else {
String fieldName = queryString.substring(poundIndex + 2, wordEndIndex);
DatabaseField field = createField(fieldName);
appendModify(writer, field);
}
} else {
String fieldName = queryString.substring(poundIndex + 1, wordEndIndex);
DatabaseField field = createField(fieldName);
appendIn(writer, field);
}
lastIndex = wordEndIndex;
}
}
setQueryString(writer.toString());
} catch (IOException exception) {
throw ValidationException.fileError(exception);
}
|
public void | translatePureSQLCustomQuery()INTERNAL:
Parse the query string for # markers for custom query based on a query language.
This is used by SQLCall and XQuery call, but can be reused by other query languages.
int lastIndex = 0;
String queryString = getQueryString();
int parameterIndex = 1; // this is the parameter index
Writer writer = new CharArrayWriter(queryString.length() + 50);
try {
// ** This method is heavily optimized do not touch anyhthing unless you "know" what your doing.
while (lastIndex != -1) {
int markIndex = queryString.indexOf('?", lastIndex);
String token;
if (markIndex == -1) { // did not find question mark then we are done looking
token = queryString.substring(lastIndex, queryString.length()); //write rest of sql
lastIndex = -1;
} else {
token = queryString.substring(lastIndex, markIndex);
lastIndex = markIndex + 1;
}
writer.write(token);
if (markIndex != -1) { // found the question mark now find the named token
int wordEndIndex = markIndex + 1;
while ((wordEndIndex < queryString.length()) && (whitespace().indexOf(queryString.charAt(wordEndIndex)) == -1)) {
wordEndIndex = wordEndIndex + 1;
}
if (wordEndIndex > markIndex + 1){ //found a 'name' for this token (may be positional)
String fieldName = queryString.substring(markIndex + 1, wordEndIndex);
DatabaseField field = createField(fieldName);
appendIn(writer, field);
lastIndex = wordEndIndex;
}else{
DatabaseField field = createField(String.valueOf(parameterIndex));
parameterIndex++;
appendIn(writer, field);
}
}
}
} catch (IOException exception) {
throw ValidationException.fileError(exception);
}
setQueryString(writer.toString());
|
public void | translateQueryString(oracle.toplink.essentials.internal.sessions.AbstractRecord translationRow, oracle.toplink.essentials.internal.sessions.AbstractRecord modifyRow, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Allow the call to translate from the translation for predefined calls.
if (getQueryString().indexOf(argumentMarker()) == -1) {
return;
}
//has a '?'
if (getParameters().isEmpty()) {
//has no parameters
return;
}
int lastIndex = 0;
int parameterIndex = 0;
String queryString = getQueryString();
Writer writer = new CharArrayWriter(queryString.length() + 50);
try {
// ** This method is heavily optimized do not touch anyhthing unless you know "very well" what your doing!!
// Must translate field parameters and may get new bound parameters for large data.
Vector parameterFields = getParameters();
setParameters(null);
while (lastIndex != -1) {
int tokenIndex = queryString.indexOf(argumentMarker(), lastIndex);
String token;
if (tokenIndex == -1) {
token = queryString.substring(lastIndex, queryString.length());
lastIndex = -1;
} else {
token = queryString.substring(lastIndex, tokenIndex);
}
writer.write(token);
if (tokenIndex != -1) {
// Process next parameter.
Integer parameterType = (Integer)getParameterTypes().elementAt(parameterIndex);
if (parameterType == MODIFY) {
DatabaseField field = (DatabaseField)parameterFields.elementAt(parameterIndex);
Object value = modifyRow.get(field);
appendParameter(writer, value, session);
} else if (parameterType == CUSTOM_MODIFY) {
DatabaseField field = (DatabaseField)parameterFields.elementAt(parameterIndex);
Object value = modifyRow.get(field);
if (value != null) {
value = session.getDatasourcePlatform().getCustomModifyValueForCall(this, value, field, false);
}
appendParameter(writer, value, session);
} else if (parameterType == TRANSLATION) {
Object parameter = parameterFields.elementAt(parameterIndex);
Object value = null;
// Parameter expressions are used for nesting and correct mapping conversion of the value.
if (parameter instanceof ParameterExpression) {
value = ((ParameterExpression)parameter).getValue(translationRow, session);
} else {
DatabaseField field = (DatabaseField)parameter;
value = translationRow.get(field);
// Must check for the modify row as well for custom SQL compatibility as only one # is required.
if ((value == null) && (modifyRow != null)) {
value = modifyRow.get(field);
}
}
appendParameter(writer, value, session);
} else if (parameterType == LITERAL) {
Object value = parameterFields.elementAt(parameterIndex);
if(value instanceof DatabaseField) {
value = null;
}
appendParameter(writer, value, session);
} else if (parameterType == IN) {
Object parameter = parameterFields.elementAt(parameterIndex);
Object value = getValueForInParameter(parameter, translationRow, modifyRow, session, false);
appendParameter(writer, value, session);
} else if (parameterType == INOUT) {
Object parameter = parameterFields.elementAt(parameterIndex);
Object value = getValueForInOutParameter(parameter, translationRow, modifyRow, session);
appendParameter(writer, value, session);
}
lastIndex = tokenIndex + 1;
parameterIndex++;
}
}
setQueryString(writer.toString());
} catch (IOException exception) {
throw ValidationException.fileError(exception);
}
|
protected java.lang.String | whitespace()INTERNAL:
Return the characters that represent non-arguments names.
return ",); \n\t:";
|