| /* |
| ************************************************************************* |
| * Copyright (c) 2004, 2009 Actuate Corporation. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Actuate Corporation - initial API and implementation |
| * |
| ************************************************************************* |
| */ |
| |
| package org.eclipse.datatools.connectivity.oda.impl; |
| |
| import java.math.BigDecimal; |
| import java.sql.Date; |
| import java.sql.Time; |
| import java.sql.Timestamp; |
| import org.eclipse.datatools.connectivity.oda.IParameterMetaData; |
| import org.eclipse.datatools.connectivity.oda.IResultSet; |
| import org.eclipse.datatools.connectivity.oda.IResultSetMetaData; |
| import org.eclipse.datatools.connectivity.oda.IQuery; |
| import org.eclipse.datatools.connectivity.oda.OdaException; |
| import org.eclipse.datatools.connectivity.oda.SortSpec; |
| import org.eclipse.datatools.connectivity.oda.filter.Expression; |
| |
| /** |
| * Default implementation of IQuery |
| * for a simple ODA runtime driver. |
| * @deprecated As of 3.1.2, see package documentation. |
| */ |
| public class SimpleQuery implements IQuery |
| { |
| private int m_maxRows; |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#prepare(java.lang.String) |
| */ |
| public void prepare( String queryText ) throws OdaException |
| { |
| // TODO data source dependent |
| throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$ |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setAppContext(java.lang.Object) |
| */ |
| public void setAppContext( Object context ) throws OdaException |
| { |
| // do nothing; assumes no support for pass-through context |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#close() |
| */ |
| public void close() throws OdaException |
| { |
| // TODO data source dependent |
| throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$ |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#getMetaData() |
| */ |
| public IResultSetMetaData getMetaData() throws OdaException |
| { |
| // TODO Override to return a specific IResultSetMetaData instance. |
| return new SimpleResultSetMetaData(); |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#executeQuery() |
| */ |
| public IResultSet executeQuery() throws OdaException |
| { |
| // TODO Override to return a specific IResultSet instance. |
| IResultSet resultSet = new SimpleResultSet(); |
| resultSet.setMaxRows( getMaxRows() ); |
| return resultSet; |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setProperty(java.lang.String, java.lang.String) |
| */ |
| public void setProperty( String name, String value ) throws OdaException |
| { |
| // do nothing; assumes no query property |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setMaxRows(int) |
| */ |
| public void setMaxRows( int max ) throws OdaException |
| { |
| m_maxRows = max; |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#getMaxRows() |
| */ |
| public int getMaxRows() throws OdaException |
| { |
| return m_maxRows; |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#clearInParameters() |
| */ |
| public void clearInParameters() throws OdaException |
| { |
| // only applies to input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(java.lang.String, int) |
| */ |
| public void setInt( String parameterName, int value ) throws OdaException |
| { |
| // only applies to named input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(int, int) |
| */ |
| public void setInt( int parameterId, int value ) throws OdaException |
| { |
| // only applies to input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(java.lang.String, double) |
| */ |
| public void setDouble( String parameterName, double value ) throws OdaException |
| { |
| // only applies to named input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(int, double) |
| */ |
| public void setDouble( int parameterId, double value ) throws OdaException |
| { |
| // only applies to input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(java.lang.String, java.math.BigDecimal) |
| */ |
| public void setBigDecimal( String parameterName, BigDecimal value ) throws OdaException |
| { |
| // only applies to named input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(int, java.math.BigDecimal) |
| */ |
| public void setBigDecimal( int parameterId, BigDecimal value ) throws OdaException |
| { |
| // only applies to input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setString(java.lang.String, java.lang.String) |
| */ |
| public void setString( String parameterName, String value ) throws OdaException |
| { |
| // only applies to named input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setString(int, java.lang.String) |
| */ |
| public void setString( int parameterId, String value ) throws OdaException |
| { |
| // only applies to input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(java.lang.String, java.sql.Date) |
| */ |
| public void setDate( String parameterName, Date value ) throws OdaException |
| { |
| // only applies to named input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(int, java.sql.Date) |
| */ |
| public void setDate( int parameterId, Date value ) throws OdaException |
| { |
| // only applies to input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(java.lang.String, java.sql.Time) |
| */ |
| public void setTime( String parameterName, Time value ) throws OdaException |
| { |
| // only applies to named input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(int, java.sql.Time) |
| */ |
| public void setTime( int parameterId, Time value ) throws OdaException |
| { |
| // only applies to input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(java.lang.String, java.sql.Timestamp) |
| */ |
| public void setTimestamp( String parameterName, Timestamp value ) throws OdaException |
| { |
| // only applies to named input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(int, java.sql.Timestamp) |
| */ |
| public void setTimestamp( int parameterId, Timestamp value ) throws OdaException |
| { |
| // only applies to input parameter |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(java.lang.String, boolean) |
| */ |
| public void setBoolean( String parameterName, boolean value ) |
| throws OdaException |
| { |
| // only applies to named input parameter |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(int, boolean) |
| */ |
| public void setBoolean( int parameterId, boolean value ) |
| throws OdaException |
| { |
| // only applies to input parameter |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setNull(java.lang.String) |
| */ |
| public void setNull( String parameterName ) throws OdaException |
| { |
| // only applies to named input parameter |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setNull(int) |
| */ |
| public void setNull( int parameterId ) throws OdaException |
| { |
| // only applies to input parameter |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#findInParameter(java.lang.String) |
| */ |
| public int findInParameter( String parameterName ) throws OdaException |
| { |
| // only applies to named input parameter |
| return 0; |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#getParameterMetaData() |
| */ |
| public IParameterMetaData getParameterMetaData() throws OdaException |
| { |
| // sub-class may override; |
| // @see default implementation in SimpleParameterMetaData class |
| return null; // has no parameters |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setSortSpec(org.eclipse.datatools.connectivity.oda.SortSpec) |
| */ |
| public void setSortSpec( SortSpec sortBy ) throws OdaException |
| { |
| // TODO data source dependent |
| throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$ |
| } |
| |
| /* |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#getSortSpec() |
| */ |
| public SortSpec getSortSpec() throws OdaException |
| { |
| // only applies to sorting |
| return null; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#setFilterSpec(org.eclipse.datatools.connectivity.oda.filter.Expression) |
| */ |
| public void setFilterSpec( Expression filterExpr ) throws OdaException |
| { |
| // TODO data source dependent |
| throw new UnsupportedOperationException( "Please override and implement me." ); //$NON-NLS-1$ |
| |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.datatools.connectivity.oda.IQuery#getFilterSpec() |
| */ |
| public Expression getFilterSpec() |
| { |
| // TODO data source dependent |
| return null; |
| } |
| |
| } |