SQLWhereBuilder.java
资源名称:OA.rar [点击查看]
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:2k
源码类别:
OA系统
开发平台:
Java
- package com.gforce.currency.database;
- /**
- * <p>Title: 吉力科技办公自动化系统</p>
- * <p>Description: 吉力科技办公自动化系统</p>
- * <p>Copyright: 版权所有 2003 (c) 西安吉力科技发展有限公司 Copyright (c) 2003 GForce Sceince & Technology</p>
- * <p>Company: 西安吉力科技发展有限公司 (GForce Sceince & Technology)</p>
- * @author 马登军
- * @version 1.0
- */
- public class SQLWhereBuilder {
- public SQLWhereBuilder() {
- }
- public static final void appendAndIfNeed(StringBuffer str) {
- if (str.length() > 6) {
- str.append(" and ");
- }
- else
- {
- str.append(" where ");
- }
- }
- public static final void appendStrValue(StringBuffer str, String value) {
- if (value == null) {
- return;
- }
- else {
- str.append("'");
- str.append(value);
- str.append("'");
- return;
- }
- }
- public static final void appendKeyLikeStr(StringBuffer str, String fieldName,
- String value) {
- if (value == null || value.trim().length() == 0) {
- return;
- }
- else {
- appendKeyOpStr(str, fieldName, "like",value);
- return;
- }
- }
- public static final void appendKeyEqualInt(StringBuffer str, String fieldName,
- String value) {
- appendKeyOpInt(str, fieldName, "=", value);
- }
- public static final void appendKeyOpInt(StringBuffer str, String fieldName,
- String op, String value) {
- if (value == null || value.trim().length() == 0) {
- return;
- }
- else {
- appendAndIfNeed(str);
- str.append(fieldName);
- str.append(" ");
- str.append(op);
- str.append(" ");
- str.append(value);
- return;
- }
- }
- public static final void appendKeyOpStr(StringBuffer str, String fieldName,
- String op, String value) {
- if (value == null || value.trim().length() == 0) {
- return;
- }
- else {
- appendAndIfNeed(str);
- str.append(fieldName);
- str.append(" ");
- str.append(op);
- str.append(" ");
- appendStrValue(str, value);
- return;
- }
- }
- }