|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object PIRL.Database.Fields_Map
public class Fields_Map
A Fields_Map maps a list of field names in user specified order to the actual order of field names as returned from a database table query.
The Fields_Map relates two possible orderings of a list of field names: The actual order is the order of entries as they occur before being mapped. This is expected to be the order in which table record field entries are returned from a database query. The user order is the the order in which the user of table records expects the entries to be in after being mapped. The user order might be thought of as the logical order known to the user of the map as typically set by by pre-determined constant index values associated with known record field names.
The map is constructed by providing a list of field names in user
order and a list of field names in actual order. Every user field
name that is found in the actual field names list results in a
mapping of that name from its index in the user order to its index in
the actual order. User names that are not found in the list of actual
field names are mapped to the no-index value. Field names are
matched
using
either case sensitive or case insensitive comparison.
The map may be used to access a field entry from a record in actual order by specifying a field name or a user index.
Field Summary | |
---|---|
boolean |
Case_Sensitive
Whether to use case sensitive field name matches. |
static boolean |
Case_Sensitive_Default
The default for case sensitive field name matches. |
static String |
ID
|
Constructor Summary | |
---|---|
Fields_Map(List<String> user_fields,
List<String> actual_fields)
Constructs a Fields_Map that maps a List of field names in user index order to their index in a List of field names in actual (table record) order. |
|
Fields_Map(List<String> user_fields,
List<String> actual_fields,
boolean case_sensitive)
Constructs a Fields_Map that maps a List of field names in user index order to their index in a List of field names in actual (table record) order. |
|
Fields_Map(List<String> user_fields,
String[] actual_fields)
Constructs a Fields_Map that maps a List of field names in user index order to their index in an array of field names in actual (table record) order. |
|
Fields_Map(String[] user_fields,
List<String> actual_fields)
Constructs a Fields_Map that maps an array of field names in user index order to their index in a List of field names in actual (table record) order. |
|
Fields_Map(String[] user_fields,
String[] actual_fields)
Constructs a Fields_Map that maps an array of field names in user index order to their index in an array of field names in actual (table record) order. |
|
Fields_Map(String[] user_fields,
String[] actual_fields,
boolean case_sensitive)
Constructs a Fields_Map that maps an array of field names in user index order to their index in an array of field names in actual (table record) order. |
Method Summary | |
---|---|
Vector<String> |
Actual_Fields()
Gets a Vector of field names in actual index order. |
Vector<String> |
Actual_to_User(Vector<String> record)
Remaps a record from actual table record order to user fields order. |
Vector<String> |
All_Actual_Fields()
Gets a Vector of actual field names in unmapped order. |
Vector<String> |
All_User_Fields()
Gets a Vector of all the user field names. |
void |
Confirm_Fields(List<String> field_names)
Confirms that a list of user field names are all mapped to valid actual fields. |
void |
Confirm_Fields(String[] field_names)
Confirms that a list of field names are all mapped to valid record locations. |
String |
entry(List<String> record,
int field_number)
Gets a field entry from a record corresponding to a user field number. |
String |
entry(List<String> record,
String field_name)
Gets a field entry from a record corresponding to a user field name. |
int |
index(int user_field_number)
Maps a user field number to an actual record field number. |
int |
index(String user_field_name)
Maps a user field name to an actual field number. |
Vector<String> |
Table_Fields()
Deprecated. |
String |
toString()
Gets the description of this Fields_Map. |
Vector<String> |
Unmapped_Actual_Fields()
Gets a Vector of unmapped actual field names. |
Vector<String> |
User_Fields()
Gets a Vector of field names in user index order. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String ID
public static boolean Case_Sensitive_Default
The initial value is false;
public boolean Case_Sensitive
user field name to
actual field index
and user field name
to table record entry
mapping. Changing the condition after the
Field_Map has been constructed may produce inconsistent mapping
results.
Constructor Detail |
---|
public Fields_Map(List<String> user_fields, List<String> actual_fields, boolean case_sensitive)
User field names that are not found in the List of actual names map to a -1 index to indicate missing fields.
User field names are compared to actual field names using the default case sensitivity
.
N.B.: The first actual field name that matches each user field name provides the mapping. If the actual field names list contains duplicate entries, only the first entry will be mapped. Likewise, if case insensitive matching is being done only the first actual name that matches a user name regardless of case is mapped.
N.B.: A field names list may contain null entries. A null name always matches a null name. A non-null name never matches a null name.
user_fields
- A List of user field name Strings to be mapped.actual_fields
- A List of field name Strings in actual
(record) order; as returned in the first record of a Database.Select
operation.case_sensitive
- If true, user field names are compared to
actual field names with a case sensitive match; otherwise a
case insensitive match is used.
IllegalArgumentException
- If either argument is null.public Fields_Map(List<String> user_fields, List<String> actual_fields)
User field names that are not found in the List of actual names map to a -1 index to indicate missing fields.
User field names are compared to actual field names using the default case sensitivity
.
N.B.: The first actual field name that matches each user field name provides the mapping. If the actual field names list contains duplicate entries, only the first entry will be mapped. Likewise, if case insensitive matching is being done only the first actual name that matches a user name regardless of case is mapped.
N.B.: A field names list may contain null entries. A null name always matches a null name. A non-null name never matches a null name.
user_fields
- A List of user field name Strings to be mapped.actual_fields
- A List of field name Strings in actual
(record) order; as returned in the first record of a Database.Select
operation.
IllegalArgumentException
- If either argument is null.public Fields_Map(String[] user_fields, String[] actual_fields, boolean case_sensitive)
User field names that are not found in the array of actual names map to a -1 index to indicate missing fields.
N.B.: The first actual field name that matches each user field name provides the mapping. If the actual field names list contains duplicate entries, only the first entry will be mapped. Likewise, if case insensitive matching is being done only the first actual name that matches a user name regardless of case is mapped.
N.B.: A field names list may contain null entries. A null name always matches a null name. A non-null name never matches a null name.
user_fields
- An array of user field name Strings to be mapped.actual_fields
- An array of field name Strings in actual
(tablae record) order; as returned in the first record of a Database.Select
operation.case_sensitive
- If true, user field names are compared to
actual field names with a case sensitive match; otherwise a
case insensitive match is used.
IllegalArgumentException
- If either argument is null.public Fields_Map(String[] user_fields, String[] actual_fields)
User field names that are not found in the array of actual names map to a -1 index to indicate missing fields.
User field names are compared to actual field names using the default case sensitivity
.
N.B.: The first actual field name that matches each user field name provides the mapping. If the actual field names list contains duplicate entries, only the first entry will be mapped. Likewise, if case insensitive matching is being done only the first actual name that matches a user name regardless of case is mapped.
N.B.: A field names list may contain null entries. A null name always matches a null name. A non-null name never matches a null name.
user_fields
- An array of user field name Strings to be mapped.actual_fields
- An array of field name Strings in actual
(table record) order; as returned in the first record of a Database.Select
operation.
IllegalArgumentException
- If either argument is null.public Fields_Map(String[] user_fields, List<String> actual_fields)
User field names that are not found in the List of actual names map to a -1 index to indicate missing fields.
User field names are compared to actual field names using the default case sensitivity
.
N.B.: The first actual field name that matches each user field name provides the mapping. If the actual field names list contains duplicate entries, only the first entry will be mapped. Likewise, if case insensitive matching is being done only the first actual name that matches a user name regardless of case is mapped.
N.B.: A field names list may contain null entries. A null name always matches a null name. A non-null name never matches a null name.
user_fields
- An array of user field name Strings to be mapped.actual_fields
- A List of field name Strings in actual
(record) order; as returned in the first record of a Database.Select
operation.
IllegalArgumentException
- If either argument is null.public Fields_Map(List<String> user_fields, String[] actual_fields)
User field names that are not found in the array of actual names map to a -1 index to indicate missing fields.
User field names are compared to actual field names using the default case sensitivity
.
N.B.: The first actual field name that matches each user field name provides the mapping. If the actual field names list contains duplicate entries, only the first entry will be mapped. Likewise, if case insensitive matching is being done only the first actual name that matches a user name regardless of case is mapped.
N.B.: A field names list may contain null entries. A null name always matches a null name. A non-null name never matches a null name.
user_fields
- A List of user field name Strings to be mapped.actual_fields
- An array of field name Strings in actual
(record) order; as returned in the first record of a Database.Select
operation.
IllegalArgumentException
- If either argument is null.Method Detail |
---|
public int index(int user_field_number)
user_field_number
- The user field number to map.
public int index(String user_field_name)
The specified field name is compared to the list of user field
names with the case sensitivity
of the
Field_Map object.
user_field_name
- The user field name to map.
public String entry(List<String> record, int field_number)
The field number is mapped to is actual index
. If
this results in a valid record index (non-negative less than the size
of the record) the corresponding entry from the record is returned as
a String.
record
- The record List containing field value Strings.
If null, null is returned.field_number
- The user field number before mapping
to its actual field index.
public String entry(List<String> record, String field_name)
The field name is mapped to its actual index
.
If this results in a valid record index (non-negative less than the
size of the record) the corresponding entry from the record is
returned as a String.
record
- The record List containing field value Strings.
If null, null is returned.field_name
- The user field name of the field for which to get
a record entry.
public Vector<String> User_Fields()
Only field names that were mapped when the Fields_Map was constructed will be included in the Vector that is returned.
public Vector<String> All_User_Fields()
All the original user field names, as specified in the constructor, are included in the Vector that is returned.
public Vector<String> Actual_Fields()
Only actual field names that were mapped from user field names when the Fields_Map was constructed will be included in the Vector that is returned. Thus the returned Vector may be smaller than the number of entries in the actual fields name list provided to the constructor.
public Vector<String> All_Actual_Fields()
All the original actual field names, as specified in the constructor, are included in the Vector that is returned.
public Vector<String> Table_Fields()
This is a deprecated name for the All_Actual_Fields()
method.
public Vector<String> Unmapped_Actual_Fields()
public Vector<String> Actual_to_User(Vector<String> record)
A new record is constructed from mapped
entries
of the specified record for all user fields. Any user field
that is not mapped to an actual field results in a null record entry.
Entries of the source record that are not mapped will not be included
in the returned record; the returned record will be the same size as
the user field names list that was used to construct the Fields_Map.
record
- A Vector of field values in actual order. If null,
null is returned.
IllegalArgumentException
- If the source record has fewer
entries than the number of user fields.public String toString()
toString
in class Object
public void Confirm_Fields(String[] field_names) throws Database_Exception
Each name in the list is treated as a user field name that is required to be mapped to an actual field name. Thus the failure of any name in the list to be mapped will throw an exception. Nevertheless, all unmapped field names in the list are identified.
field_names
- An array of user name Strings to be checked. null
entries are ignored.
Database_Exception
- if any names fail to map to valid
record locations. The exception message will list all missing
field names.public void Confirm_Fields(List<String> field_names) throws Database_Exception
Each name in the list is treated as a user field name that is required to be mapped to an actual field name. Thus the failure of any name in the list to be mapped will throw an exception. Nevertheless, all unmapped field names in the list are identified.
field_names
- The list of names to be checked. If null, nothing
is done. Any null entries in the list are ignored.
Database_Exception
- if any of the field names fail to map to
valid actual locations. The exception message will list all
unmapped field names.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |