001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.platforms.stores.base;
009:
010: //base classes
011: import java.math.BigDecimal;
012: import java.sql.PreparedStatement;
013: import java.sql.ResultSet;
014: import java.sql.SQLException;
015: import java.util.ArrayList;
016:
017: //project specific classes
018: import org.jfolder.common.UnexpectedSystemException;
019: import org.jfolder.platforms.stores.base.SystemStatement;
020:
021: //other classes
022:
023: public class InsertStatement extends SystemStatement {
024:
025: //
026: private CreateStatement wcs = null;
027: //
028: private ArrayList columnNames = null;
029: private ArrayList columnTypes = null;
030: private ArrayList columnValues = null;
031: //
032: private BigDecimal idColumnValue = null;
033: private BigDecimal seriesSequenceColumnValue = null;
034:
035: protected InsertStatement(CreateStatement inWcs) {
036: //super(inWs);
037: this .wcs = inWcs;
038: //
039: this .columnNames = new ArrayList();
040: this .columnTypes = new ArrayList();
041: this .columnValues = new ArrayList();
042: }
043:
044: public CreateStatement getEntity() {
045: return this .wcs;
046: }
047:
048: //
049: public void setDecimalColumn(String inName, BigDecimal inContent) {
050: this .wcs.verifyColumnAndType(inName, DECIMAL, true);
051: addColumn(inName, DECIMAL, inContent);
052: }
053:
054: public void setSStringColumn(String inName, String inContent) {
055: this .wcs.verifyColumnAndType(inName, SHORT_STRING, true);
056: addColumn(inName, SHORT_STRING, inContent);
057: }
058:
059: public void setLStringColumn(String inName, String inContent) {
060: this .wcs.verifyColumnAndType(inName, LONG_STRING, true);
061: addColumn(inName, LONG_STRING, inContent);
062: }
063:
064: public void setBooleanColumn(String inName, Boolean inContent) {
065: this .wcs.verifyColumnAndType(inName, BOOLEAN, true);
066: addColumn(inName, BOOLEAN, inContent);
067: }
068:
069: public void setBObjectColumn(String inName, byte inContent[]) {
070: this .wcs.verifyColumnAndType(inName, BINARY_OBJECT, true);
071: addColumn(inName, BINARY_OBJECT, inContent);
072: }
073:
074: //
075: private void addColumn(String inName, Integer inType, Object inValue) {
076: if (!this .columnNames.contains(inName)) {
077: this .columnNames.add(inName);
078: this .columnTypes.add(inType);
079: this .columnValues.add(inValue);
080: } else {
081: throw new UnexpectedSystemException("Column '" + inName
082: + "' already set");
083: }
084: }
085:
086: //
087: public int getColumnCount() {
088: return this .columnNames.size();
089: }
090:
091: public String getColumnName(int inIndex) {
092: return (String) this .columnNames.get(inIndex);
093: }
094:
095: public Integer getColumnType(int inIndex) {
096: return (Integer) this .columnTypes.get(inIndex);
097: }
098:
099: public Object getColumnValue(int inIndex) {
100: return this .columnValues.get(inIndex);
101: }
102:
103: //
104: public void setIdColumnValue(BigDecimal inValue) {
105: this .idColumnValue = inValue;
106: }
107:
108: public BigDecimal getIdColumnValue() {
109: return this .idColumnValue;
110: }
111:
112: //
113: public void setSeriesSequenceColumnValue(BigDecimal inValue) {
114: this .seriesSequenceColumnValue = inValue;
115: }
116:
117: public BigDecimal getSeriesSequenceColumnValue() {
118: return this.seriesSequenceColumnValue;
119: }
120: }
|