001: /*
002: Copyright (C) 2005 Know Gate S.L. All rights reserved.
003: C/Oņa, 107 1š2 28050 Madrid (Spain)
004:
005: Redistribution and use in source and binary forms, with or without
006: modification, are permitted provided that the following conditions
007: are met:
008:
009: 1. Redistributions of source code must retain the above copyright
010: notice, this list of conditions and the following disclaimer.
011:
012: 2. The end-user documentation included with the redistribution,
013: if any, must include the following acknowledgment:
014: "This product includes software parts from hipergate
015: (http://www.hipergate.org/)."
016: Alternately, this acknowledgment may appear in the software itself,
017: if and wherever such third-party acknowledgments normally appear.
018:
019: 3. The name hipergate must not be used to endorse or promote products
020: derived from this software without prior written permission.
021: Products derived from this software may not be called hipergate,
022: nor may hipergate appear in their name, without prior written
023: permission.
024:
025: This library is distributed in the hope that it will be useful,
026: but WITHOUT ANY WARRANTY; without even the implied warranty of
027: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029: You should have received a copy of hipergate License with this code;
030: if not, visit http://www.hipergate.org or mail to info@hipergate.org
031: */
032:
033: package com.knowgate.hipergate.datamodel;
034:
035: import java.util.ArrayList;
036: import java.sql.SQLException;
037: import java.sql.Connection;
038:
039: /**
040: * @author Sergio Montoro Ten
041: * @version 1.0
042: */
043: public interface ImportLoader {
044:
045: int MODE_APPEND = 1;
046: int MODE_UPDATE = 2;
047: int MODE_APPENDUPDATE = 3;
048: int WRITE_LOOKUPS = 4;
049:
050: /**
051: * Get columns count
052: * @return int
053: */
054: int columnCount();
055:
056: /**
057: * Get array of column names
058: * @return String[]
059: */
060: String[] columnNames() throws IllegalStateException;
061:
062: /**
063: * Get current value for a column given its index
064: * @param iColumnIndex int [0..columnCount()-1]
065: * @return Object
066: * @throws ArrayIndexOutOfBoundsException
067: */
068: Object get(int iColumnIndex) throws ArrayIndexOutOfBoundsException;
069:
070: /**
071: * Get current value for a column given its name
072: * @param sColumnName Case insensitive String
073: * @return Object
074: * @throws ArrayIndexOutOfBoundsException if no column with such name was found
075: */
076: Object get(String sColumnName)
077: throws ArrayIndexOutOfBoundsException;
078:
079: /**
080: * Get column index from its name
081: * @param sColumnName String
082: * @return int [0..columnCount()-1] or -1 if column was not found
083: */
084: int getColumnIndex(String sColumnName);
085:
086: /**
087: * Put current value for a column
088: * @param iColumnIndex int [0..columnCount()-1]
089: * @param oValue Object
090: * @throws ArrayIndexOutOfBoundsException
091: */
092: void put(int iColumnIndex, Object oValue)
093: throws ArrayIndexOutOfBoundsException;
094:
095: /**
096: * Put current value for a column
097: * @param sColumnName String Column name
098: * @param oValue Object
099: * @throws ArrayIndexOutOfBoundsException
100: */
101: void put(String sColumnName, Object oValue)
102: throws ArrayIndexOutOfBoundsException;
103:
104: /**
105: * Set all current values to null
106: */
107: void setAllColumnsToNull();
108:
109: /**
110: * Prepare ImportLoader for repeated execution
111: * @param oConn Connection
112: * @param oCols ColumnList List of columns that will be inserted or updated at the database
113: * @throws SQLException
114: */
115: void prepare(Connection oConn, ColumnList oCols)
116: throws SQLException;
117:
118: /**
119: * <p>Close ImportLoader</p>
120: * Must be always called before ImportLoader is destroyed
121: * @throws SQLException
122: */
123: void close() throws SQLException;
124:
125: /**
126: * Store a single row or a set of related rows
127: * @param oConn Connection
128: * @param sWorkArea String
129: * @param iFlags int
130: * @throws SQLException
131: * @throws IllegalArgumentException
132: * @throws NullPointerException
133: */
134: void store(Connection oConn, String sWorkArea, int iFlags)
135: throws SQLException, IllegalArgumentException,
136: NullPointerException;
137: }
|