com.jk.data.dynamic.query.Query Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jk-framework-data Show documentation
Show all versions of jk-framework-data Show documentation
This contains a set of API's that ease the database programming with Java, in both: JDBC and JPA Persisitnce).
/*
* Copyright 2002-2022 Dr. Jalal Kiswani.
* Email: [email protected]
* Check out https://smart-api.com for more details
*
* All the opensource projects of Dr. Jalal Kiswani are free for personal and academic use only,
* for commercial usage and support, please contact the author.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jk.data.dynamic.query;
import java.util.ArrayList;
import java.util.List;
// TODO: Auto-generated Javadoc
/**
* The Class Query.
*/
public class Query {
/** The structor. */
ArrayList structor = new ArrayList();
/**
* Adds the component.
*
* @param component the component
* @return the query
*/
// ///////////////////////////////////////////////////////////////////
public Query addComponent(final QueryComponent component) {
this.structor.add(component);
return this;
}
/**
* Adds the component.
*
* @param component the component
* @param count the count
* @param separator the separator
* @param surroundWithParenchthisis the surround with parenchthisis
* @return the query
*/
// ///////////////////////////////////////////////////////////////////
public Query addComponent(final QueryComponent component, final int count, final QueryComponent separator,
final boolean surroundWithParenchthisis) {
final ArrayList components = new ArrayList();
for (int i = 0; i < count; i++) {
components.add(component);
}
addComponents(components, separator, surroundWithParenchthisis);
return this;
}
/**
* Adds the components.
*
* @param components the components
* @param separator the separator
* @param surroundWithParenchthisis the surround with parenchthisis
* @return the query
*/
// ///////////////////////////////////////////////////////////////////
public Query addComponents(final List components, final QueryComponent separator, final boolean surroundWithParenchthisis) {
if (surroundWithParenchthisis) {
addComponent(Keyword.LEFT_PARENTHESES);
}
for (int i = 0; i < components.size(); i++) {
if (i != 0) {
addComponent(separator);
}
addComponent(components.get(i));
}
if (surroundWithParenchthisis) {
addComponent(Keyword.RIGHT_PARENTHESES);
}
return this;
}
/**
* Adds the value.
*
* @param value the value
* @return the query
*/
// ///////////////////////////////////////////////////////////////////
public Query addValue(final Object value) {
addComponent(new ObjectComponent(value));
return this;
}
/**
* Adds the values.
*
* @param values the values
* @param separator the separator
* @param surroundWithParenchthisis the surround with parenchthisis
* @return the query
*/
// ///////////////////////////////////////////////////////////////////
public Query addValues(final List