break;
} else if ("image-mime-type".equals(typeName)) {
String imageAttr = param.substring(0, (param.length() - "-mime-type".length()));
file = (File) request.get(imageAttr);
synchronized (this.files) {
Parameters parameters = (Parameters) this.files.get(file);
String imageMimeType = parameters.getParameter("image-mime-type",
(String) settings.get("image-mime-type",""));
statement.setString(position, imageMimeType);
/** Store the image mime type in the request attributes.
Why do we do this? **/
setRequestAttribute(request, param, imageMimeType);
}
break;
}
case Types.BLOB:
if (value instanceof File) {
file = (File)value;
} else if (value instanceof String) {
file = new File((String)value);
} else {
throw new SQLException("Invalid type for blob: "+value.getClass().getName());
}
//InputStream input = new BufferedInputStream(new FileInputStream(file));
FileInputStream input = new FileInputStream(file);
statement.setBinaryStream(position, input, (int)file.length());
if ("image".equals(typeName)) {
/** If this column type is an image, store the
size, width, and height in a static table **/
Parameters parameters = new Parameters();
parameters.setParameter("image-size", Long.toString(file.length()));
int [] dimensions = ImageDirectoryGenerator.getSize(file);
String type = ImageDirectoryGenerator.getFileType(file);
parameters.setParameter("image-width", Integer.toString(dimensions[0]));
parameters.setParameter("image-height", Integer.toString(dimensions[1]));
parameters.setParameter("image-mime-type",type);
synchronized (this.files) {
this.files.put(file, parameters);
}
}
break;
case Types.INTEGER:
if ("int".equals(typeName)) {
Integer i = null;
if (value instanceof Integer) {
i = (Integer) value;
} else {
i = new Integer((String) value);
}
statement.setInt(position, i.intValue());
break;
} else if ("image-width".equals(typeName)) {
/** Get the image width from the cached image data **/
/** Is this why we store the values in the request
attributes? **/
String imageAttr = param.substring(0, (param.length() - "-width".length()));
file = (File) request.get(imageAttr);
synchronized (this.files) {
Parameters parameters = (Parameters) this.files.get(file);
statement.setInt(position, parameters.getParameterAsInteger("image-width",
Integer.parseInt((String)settings.get("image-width","-1"))));
/** Store the image width in the request attributes.
Why do we do this? **/
setRequestAttribute(request,
param,
parameters.getParameter("image-width",
(String) settings.get("image-width","")));
}
break;
} else if ("image-height".equals(typeName)) {
/** Get the image height from the cached image data **/
String imageAttr = param.substring(0, (param.length() - "-height".length()));
file = (File) request.get(imageAttr);
synchronized (this.files) {
Parameters parameters = (Parameters) this.files.get(file);
statement.setInt(position, parameters.getParameterAsInteger("image-height",
Integer.parseInt((String)settings.get("image-height","-1"))));
setRequestAttribute(request,
param,
parameters.getParameter("image-height",
(String) settings.get("image-height","")));
}
break;
} else if ("image-size".equals(typeName)) {
/** Get the image file size from the cached image data **/
String imageAttr = param.substring(0, (param.length() - "-size".length()));
file = (File) request.get(imageAttr);
synchronized (this.files) {
Parameters parameters = (Parameters) this.files.get(file);
statement.setInt(position, parameters.getParameterAsInteger("image-size",
Integer.parseInt((String)settings.get("image-height","-1"))));
setRequestAttribute(request,
param,
parameters.getParameter("image-size",
(String) settings.get("image-size","")));
}
break;
} else if ("row-index".equals(typeName)) {
statement.setInt(position,rowIndex);