Class FieldConfig
- java.lang.Object
-
- de.julielab.costosys.configuration.ConfigBase
-
- de.julielab.costosys.configuration.FieldConfig
-
public class FieldConfig extends ConfigBase
This class holds the definition of fields for the database table to work with. The definition was read from the configuration XML file.- Author:
- faessler
-
-
Constructor Summary
Constructors Constructor Description FieldConfig(byte[] configData, String schemaName)FieldConfig(List<Map<String,String>> fields, String forEachXPath, String schemaName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Map<String,String>createField(String... configuration)String[]expandPKNames(String fmtStr)Applies each primary key element to the format string and returns the results as array.String[]expandPKNames(String[] fmtStrs)Takes an array of format strings according toString.format(String, Object...)with a single %s symbol.String[]getColumns()String[]getColumnsToRetrieve()StringgetConfigText()Map<String,String>getField(String fieldName)List<Map<String,String>>getFields()List<Map<String,String>>getFieldsToRetrieve()StringgetForEachXPath()StringgetName()String[]getPrimaryKey()List<Integer>getPrimaryKeyFieldNumbers()Stream<Map<String,String>>getPrimaryKeyFields()StringgetPrimaryKeyString()Returns the names of the columns forming the primary key in a CSV format.StringgetTimestampFieldName()booleanisBinary()static booleanisBinaryDataType(String type)static booleanisBooleanType(String type)static booleanisIntegerType(String type)static booleanisKnownType(String type)booleanisNsAware()booleanisOfBinaryDataType(Map<String,String> field)booleanisOfIntegerType(Map<String,String> field)booleanisOfStringType(String fieldName)booleanisOfStringType(Map<String,String> field)booleanisOfTimestampWithoutTZType(String fieldName)static booleanisStringType(String type)static booleanisStringTypeArray(String type)static booleanisTimestampWithoutTZType(String type)Returns true if the stringtypeequals the SQL "timestamp without time zone" type.static booleanisXmlType(String type)voidsetForEachXPath(String forEachXPath)StringtoString()-
Methods inherited from class de.julielab.costosys.configuration.ConfigBase
getActiveConfig, stringFromXpath
-
-
-
-
Method Detail
-
isKnownType
public static boolean isKnownType(String type)
-
isBinaryDataType
public static boolean isBinaryDataType(String type)
-
isStringTypeArray
public static boolean isStringTypeArray(String type)
- Parameters:
type-- Returns:
-
isXmlType
public static boolean isXmlType(String type)
-
isBooleanType
public static boolean isBooleanType(String type)
- Parameters:
type-- Returns:
-
isTimestampWithoutTZType
public static boolean isTimestampWithoutTZType(String type)
Returns true if the stringtypeequals the SQL "timestamp without time zone" type.- Parameters:
type- String to test.- Returns:
- True if
typedenotes a timestamp type without timezone information.
-
isStringType
public static boolean isStringType(String type)
-
isIntegerType
public static boolean isIntegerType(String type)
- Parameters:
type-- Returns:
-
getName
public String getName()
- Returns:
- the name
-
isBinary
public boolean isBinary()
-
isNsAware
public boolean isNsAware()
-
getForEachXPath
public String getForEachXPath()
-
setForEachXPath
public void setForEachXPath(String forEachXPath)
-
isOfTimestampWithoutTZType
public boolean isOfTimestampWithoutTZType(String fieldName)
-
isOfStringType
public boolean isOfStringType(String fieldName)
-
getPrimaryKey
public String[] getPrimaryKey()
- Returns:
- - An Array with the names off all primary keys
-
getPrimaryKeyFieldNumbers
public List<Integer> getPrimaryKeyFieldNumbers()
- Returns:
- - The indices of those fields which are primary keys, beginning with 0
-
getColumnsToRetrieve
public String[] getColumnsToRetrieve()
-
getPrimaryKeyString
public String getPrimaryKeyString()
Returns the names of the columns forming the primary key in a CSV format.This method calls
getPrimaryKey()to obtain the list of primary key column names. It then builds a string consisting of these names separated by commas and returns this string.Example: If the primary key columns are "pmid" and "systemID", the string returned would be "pmid,systemID".
- Returns:
- A comma separated list of the column names which form the primary key in this table scheme.
-
expandPKNames
public String[] expandPKNames(String[] fmtStrs)
Takes an array of format strings according toString.format(String, Object...)with a single %s symbol. The number of format string must be equal to the number of primary key elements of this table schema definition. Then, for theith format string, theith primary key element is applied.- Parameters:
fmtStrs- The format string to fill with primary key elements, one format string per primary key element.- Returns:
- An array of strings corresponding to the format strings filled with the primary key elements.
-
expandPKNames
public String[] expandPKNames(String fmtStr)
Applies each primary key element to the format string and returns the results as array. Each result element corresponds to one primary key element applied to the format string.- Parameters:
fmtStr- The format string to be filled with the primary key elements.- Returns:
- All results corresponding to applying each primary key element once to the given format string.
-
getTimestampFieldName
public String getTimestampFieldName()
-
getConfigText
public String getConfigText()
-
getColumns
public String[] getColumns()
-
-