public abstract class Import<DBOBJ extends JDBCObject<?>>
extends java.lang.Object
implements java.io.Serializable
NOTE: A single instance of the implementing class is cached by
ImportProcessor
and used throughout the import processing.
Modifier and Type | Field and Description |
---|---|
static int |
ACTION_ADD
The action code for add.
|
static int |
ACTION_CLEAR
The action code for clear.
|
static int |
ACTION_DELETE
The action code for delete.
|
static int |
ACTION_UPDATE
The action code for update.
|
static int |
ACTION_UPDATE_ADD
The action code for update-add.
|
private java.lang.String |
ivClassPrefix
The import object's class name prefix (the class name sans the
"Import" suffix).
|
protected FlashServletContext |
ivContext
The current context for the servlet or thread using the object.
|
protected int |
ivLineNo
The current line number being processed.
|
protected int |
ivNumFields
The number of fields in an import record.
|
protected DBOBJ |
ivObject
The database object being added, updated or deleted.
|
protected boolean |
ivStarAll
A flag indicating if doing *ALL wildcard processing.
|
protected java.lang.String |
ivTextLine
The current line of import text data being processed.
|
protected boolean |
ivUseMixedCase
A flag indicating if doing mixed-case processing.
|
protected java.util.HashMap<java.lang.String,java.lang.String> |
ivValues
The values from the supplied set of data.
|
private static java.util.regex.Pattern |
REGEX_DECIMAL
The regular expression for determining a valid decimal number.
|
private static java.util.regex.Pattern |
REGEX_INTEGER
The regular expression for determining a valid integer number.
|
private static long |
serialVersionUID
The class' serialization version id.
|
Modifier | Constructor and Description |
---|---|
protected |
Import()
The constructor for the abstract import object.
|
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
addRecord()
Adds a new record to the Flash database.
|
protected abstract boolean |
deleteRecord()
Deletes an existing record from the Flash database.
|
FlashServletContext |
getContext()
Returns the import object's servlet context (i.e.
|
protected java.lang.String |
getMixedCase(java.lang.String s)
Returns a mixed case string for the given string.
|
int |
getNumFields()
Returns the number of fields in an import record (does not include import
record type and action code).
|
java.lang.String |
getProperty(java.lang.String key)
Returns a requested value from properties.
|
protected int |
getTrueAction(int action)
Returns the actual action to perform (add, update, delete).
|
abstract void |
housekeeping()
Garbage collection: Kills (nullifies) objects used by the import class.
|
abstract boolean |
importData(int action,
java.util.ArrayList<java.lang.String> data,
int lineNo)
Imports a record of data values into the Flash database.
|
protected boolean |
isDecimal(java.lang.String value)
Answers if a string value represents a valid decimal number.
|
protected boolean |
isInteger(java.lang.String value)
Answers if a string value represents a valid integer number.
|
protected boolean |
isStarAll(java.lang.String value)
Answers if a given value equals the configured *ALL wildcard value in
properties.
|
protected boolean |
isTrue(java.lang.String key)
Answers if a configured value in properties is true.
|
protected void |
log(java.lang.String msgid)
Writes a IMPORT log file entry for the given message id.
|
protected void |
log(java.lang.String msgid,
java.lang.String... values)
Writes a IMPORT log file entry for the given message id.
|
protected java.lang.String |
qualifyKey(java.lang.String key)
Returns the given property key prefixed with "Import." and the import
object's class name sans the "Import" suffix ("Import.ivClassPrefix.key").
|
protected java.lang.String |
qualifyMsgId(java.lang.String msgid)
Returns the given message id prefixed with the import object's class name
sans the "Import" suffix ("ivClassPrefix.msgid").
|
void |
setContext(FlashServletContext ctx)
Sets the import object's servlet context (i.e.
|
void |
setTextLine(java.lang.String text)
Sets the current line of import text data being processed.
|
protected abstract boolean |
updateRecord()
Updates an existing record in the Flash database.
|
protected abstract boolean |
validForAdd()
Answers if appropriate data has been supplied in order to add a record
to the Flash database.
|
protected abstract boolean |
validForDelete()
Answers if appropriate data has been supplied in order to delete a record
in the Flash database.
|
protected abstract boolean |
validForUpdate()
Answers if appropriate data has been supplied in order to update a record
in the Flash database.
|
private static final long serialVersionUID
private static final java.util.regex.Pattern REGEX_INTEGER
private static final java.util.regex.Pattern REGEX_DECIMAL
public static final int ACTION_ADD
public static final int ACTION_UPDATE
public static final int ACTION_DELETE
public static final int ACTION_UPDATE_ADD
public static final int ACTION_CLEAR
private java.lang.String ivClassPrefix
protected FlashServletContext ivContext
protected java.util.HashMap<java.lang.String,java.lang.String> ivValues
protected DBOBJ extends JDBCObject<?> ivObject
protected java.lang.String ivTextLine
protected int ivLineNo
protected boolean ivStarAll
protected boolean ivUseMixedCase
protected int ivNumFields
public FlashServletContext getContext()
public void setContext(FlashServletContext ctx)
ctx
- (FlashServletContext) The current servlet or thread context.protected java.lang.String getMixedCase(java.lang.String s)
WordFix
corrections to the result.
This is a shortcut convenience method for
getContext().getController(WordFixController.class).getMixedCase()
.s
- (String) The string to process.public int getNumFields()
public java.lang.String getProperty(java.lang.String key)
key
- (String) The key for the desired value. The key is
automatically prefixed with the results of qualifyKey
("Import.ivClassPrefix.key").null
if the
key does not exist in properties.protected int getTrueAction(int action)
action
- (int) The current action.protected boolean isDecimal(java.lang.String value)
value
- (String) The value to check.true
if the value is a valid decimal,
otherwise false
.protected boolean isInteger(java.lang.String value)
value
- (String) The value to check.true
if the value is a valid integer,
otherwise false
.protected boolean isStarAll(java.lang.String value)
value
- (String) The value to check.true
if the given value is the same,
otherwise false
.protected boolean isTrue(java.lang.String key)
key
- (String) The key for the configured value to check. The key
is automatically prefixed with the results of qualifyKey
("Import.ivClassPrefix.key").true
if true, otherwise false
.protected void log(java.lang.String msgid)
msgid
- (String) The id for the message to log. The msgid is
automatically prefixed with "MSG.Import." plus the results of
qualifyMsgId
("MSG.Import.ivClassPrefix.msgid").protected void log(java.lang.String msgid, java.lang.String... values)
msgid
- (String) The id for the message to log. The msgid is
automatically prefixed with "MSG.Import." plus the results of
qualifyMsgId
("MSG.Import.ivClassPrefix.msgid").values
- (String) The value(s) to replace in the message text.
This parameter uses the varargs feature and can therefore be
passed as multiple parms (msgid, value1, value2, value3, valueN)
or as an array (msgid, values[]).protected java.lang.String qualifyKey(java.lang.String key)
key
- (String) The property key to qualify.protected java.lang.String qualifyMsgId(java.lang.String msgid)
msgid
- (String) The id for the message to qualify.public void setTextLine(java.lang.String text)
text
- (String) The current line of text.public abstract void housekeeping()
public abstract boolean importData(int action, java.util.ArrayList<java.lang.String> data, int lineNo)
action
- (int) The action code (i.e. add, update, delete).data
- (ArrayList) The set of data values to be imported. Each
element corresponds to a field in the original text line.lineNo
- (int) The current line number being processedtrue
if the import of data was successful,
otherwise false
.protected abstract boolean addRecord()
true
if the add was successful,
otherwise false
.protected abstract boolean deleteRecord()
true
if the delete was successful,
otherwise false
.protected abstract boolean updateRecord()
true
if the update was successful,
otherwise false
.protected abstract boolean validForAdd()
true
if appropriate data has been supplied,
otherwise false
.protected abstract boolean validForDelete()
true
if appropriate data has been supplied,
otherwise false
.protected abstract boolean validForUpdate()
true
if appropriate data has been supplied,
otherwise false
.