src-main.org.awakefw.sql.util.FileNameFromBlobBuilder Maven / Gradle / Ivy
/*
* This file is part of Awake SQL.
* Awake SQL: Remote JDBC access over HTTP.
* Copyright (C) 2013, KawanSoft SAS
* (http://www.kawansoft.com). All rights reserved.
*
* Awake SQL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Awake SQL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see .
*
* If you develop commercial activities using Awake SQL, you must:
* a) disclose and distribute all source code of your own product,
* b) license your own product under the GNU General Public License.
*
* You can be released from the requirements of the license by
* purchasing a commercial license. Buying such a license will allow you
* to ship Awake SQL with your closed source products without disclosing
* the source code.
*
* For more information, please contact KawanSoft SAS at this
* address: [email protected]
*
* Any modifications to this file must keep this entire header
* intact.
*/
package org.awakefw.sql.util;
import org.apache.commons.lang3.StringUtils;
import org.awakefw.file.util.AwakeFileUtil;
import org.awakefw.file.util.Tag;
/**
* @author Nicolas de Pomereu Build the raw filename that will contain the Blob
* or Clob contant
*/
public class FileNameFromBlobBuilder {
// DML
private final static String DELETE = "DELETE";
private final static String INSERT = "INSERT";
private final static String SELECT = "SELECT";
private final static String UPDATE = "UPDATE";
private static final String BLANK = " ";
/** The statement sql string */
private String sqlOrder = null;
/** The column to dump */
private String columnName = null;
/** The parameter index */
private int parameterIndex = 0;
/** true if the Blob is a Clob */
private boolean isClob = false;
/**
* Default constructor
*
* @param sqlOrder
* The statement sql string
* @param columnName
* The column to dump
* @param isClob
* true if the Blob as a Clob
*/
public FileNameFromBlobBuilder(String sqlOrder, String columnName,
boolean isClob) {
if (sqlOrder == null) {
throw new IllegalArgumentException(Tag.AWAKE_PRODUCT_FAIL
+ "sqlOrder can not be null!");
}
if (columnName == null) {
throw new IllegalArgumentException(Tag.AWAKE_PRODUCT_FAIL
+ "columnName can not be null!");
}
this.sqlOrder = sqlOrder;
this.columnName = columnName;
this.isClob = isClob;
}
/**
* Default constructor
*
* @param sqlOrder
* The statement sql string
* @param parameterIndex
* the index of the prepared statement
* @param isClob
* true if the Blob as a Clob
*/
public FileNameFromBlobBuilder(String sqlOrder, int parameterIndex,
boolean isClob) {
if (sqlOrder == null) {
throw new IllegalArgumentException(Tag.AWAKE_PRODUCT_FAIL
+ "sqlOrder can not be null!");
}
if (parameterIndex < 1) {
throw new IllegalArgumentException(Tag.AWAKE_PRODUCT_FAIL
+ "Prepared statement parameterIndex must be >= 1");
}
this.sqlOrder = sqlOrder;
this.parameterIndex = parameterIndex;
this.isClob = isClob;
}
/**
* @return the raw file name of the file to create from the blob/clob column
* with the content
*/
public String getFileName() {
String fileName = null;
String unique = AwakeFileUtil.getUniqueId();
// StatementAnalyser analyser = new StatementAnalyser(sqlOrder,
// new Vector
© 2015 - 2025 Weber Informatics LLC | Privacy Policy