Package de.xima.fc.common.form
Class FormDataAdapterWrapper
- java.lang.Object
-
- de.xima.fc.common.form.FormDataAdapterWrapper
-
- All Implemented Interfaces:
IFormDataAdapter
,Serializable
public abstract class FormDataAdapterWrapper extends Object implements IFormDataAdapter
Base clas forIFormDataAdapter
that wraps another adapter and forwards all method calls to that wrapped adapter.- Since:
- 8.2.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FormDataAdapterWrapper()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addMultiValue(String fieldName, List<String[]> values)
Adds the given values to the values of the form element.void
addRequestValue(String fieldName, List<String> values)
void
addSingleValue(String fieldName, String... value)
Adds the given values to the values of the form element.Object
aliasValue(String alias)
String
asStringValue(String[] value)
String
asStringValue(List<String[]> value)
Map<String,IFormContainerMetaData>
createCompleteDynContainerMap()
Map<String,String>
getAliasFieldMap()
Map<String,FormContainerMetaData>
getDynContainerMap()
Deprecated.HashSet<String>
getDynFieldSet()
Deprecated.Set<String>
getDynFieldSets()
Set<String>
getFieldAlias()
Map<String,String>
getFieldAliasMap()
FormFieldMetaData
getFieldMetaData(String identifier, boolean asAlias)
Deprecated.Map<String,FormFieldMetaData>
getFieldMetaDataMap()
Deprecated.Map<String,List<String>>
getFieldNotesRead()
Deprecated.Map<String,List<String>>
getFieldNotesUnread()
Deprecated.Set<String>
getFields()
EFormFieldTyp
getFieldTyp(String identifier, boolean asAlias)
List<String[]>
getFieldValues(String fieldName)
Map<String,List<String[]>>
getFieldValuesMap()
Map<String,IFormContainerMetaData>
getIDynContainerMap()
IFieldMetaData
getIFieldMetaData(String identifier, boolean asAlias)
Map<String,IFieldMetaData>
getIFieldMetaDataMap()
Map<String,String>
getMetaDataMap()
String
getNormName(String fieldName)
For each element, a name is defined in the designer.Map<String,List<String>>
getRequestDataMap()
Set<String>
getSendElements()
String
getStringValue(String fieldName)
Each form element may have multiple values.abstract IFormDataAdapter
getWrapped()
Gets the wrapped form data adapter.boolean
hasAlias(String alias)
boolean
hasField(String fieldName)
ERSTMAL: Lieferttrue
, wenn das Formular ein Feld mit dem übergebenen Namen besitzt.void
init(Map<String,List<String>> dataMap)
Deprecated.void
init(Map<String,List<String>> dataMap, List<String> sendElements)
Deprecated.void
init(Map<String,List<String>> dataMap, Map<String,List<org.apache.commons.fileupload.FileItem>> uploadMap)
void
init(Map<String,List<String>> dataMap, Map<String,List<org.apache.commons.fileupload.FileItem>> uploadMap, List<String> sendElements)
boolean
isElementLooped(String elementName)
A repeated form element (also called dynamic or looped) is a form element of which the user can create multiple copies of as they fill out the form.boolean
isQuestionElement(String elementName)
int
loopCount(String elementName)
A repeated form element (also called dynamic or looped) is a form element of which the user can create multiple copies of as they fill out the form.void
mergeRequestData(Map<String,List<String>> oldData)
String[]
normalizeValue(String... value)
String[]
normalizeValue(List<String> value)
List<String[]>
normalizeValues(List<String> stringList)
String
resolveAliasName(String alias)
String
resolveFieldAlias(String alias)
String
resolveFieldName(String fieldName)
EFormFieldTyp
resolveFieldType(String fieldName, boolean asAlias)
boolean
valuesMapHasValue(String fieldName)
-
-
-
Method Detail
-
addMultiValue
public void addMultiValue(String fieldName, List<String[]> values)
Description copied from interface:IFormDataAdapter
Adds the given values to the values of the form element. If one or multiple values exist already for the given form element, they are preserved.- Specified by:
addMultiValue
in interfaceIFormDataAdapter
- Parameters:
fieldName
- The name of a form element.values
- AList
of values to add to the form element.- See Also:
IFormDataAdapter.addSingleValue(String, String...)
-
addRequestValue
public void addRequestValue(String fieldName, List<String> values)
- Specified by:
addRequestValue
in interfaceIFormDataAdapter
-
addSingleValue
public void addSingleValue(String fieldName, String... value)
Description copied from interface:IFormDataAdapter
Adds the given values to the values of the form element. If one or multiple values exist already for the given form element, they are preserved. Please note that the value of a form element is aList
of arrays ofString
s, this adds the given values to the first entry in theList
of values.- Specified by:
addSingleValue
in interfaceIFormDataAdapter
- Parameters:
fieldName
- The name of a form element.value
- One or multiple values to add for the given element.- See Also:
IFormDataAdapter.addMultiValue(String, List)
-
aliasValue
public Object aliasValue(String alias)
- Specified by:
aliasValue
in interfaceIFormDataAdapter
-
asStringValue
public String asStringValue(List<String[]> value)
- Specified by:
asStringValue
in interfaceIFormDataAdapter
- Parameters:
value
- AList
of values to be converted.- Returns:
- The given values, joined with a comma; or the empty string in case
null
or no values were given.
-
asStringValue
public String asStringValue(String[] value)
- Specified by:
asStringValue
in interfaceIFormDataAdapter
- Parameters:
value
- An array of values to be converted.- Returns:
- The given values, joined with a comma; or the empty string in case
null
or no values were given.
-
createCompleteDynContainerMap
public Map<String,IFormContainerMetaData> createCompleteDynContainerMap()
- Specified by:
createCompleteDynContainerMap
in interfaceIFormDataAdapter
- Returns:
- Similar to the
IFormDataAdapter.getDynContainerMap()
, but also contains a value for each valuable element (not container elements etc.) in each repeated container.
-
getAliasFieldMap
public Map<String,String> getAliasFieldMap()
- Specified by:
getAliasFieldMap
in interfaceIFormDataAdapter
- Returns:
- A
Map
that maps from the alias name of a form elements to its name. - See Also:
IFormDataAdapter.getFieldAliasMap()
-
getDynContainerMap
@Deprecated public Map<String,FormContainerMetaData> getDynContainerMap()
Deprecated.- Specified by:
getDynContainerMap
in interfaceIFormDataAdapter
- Returns:
- A map from the
name
of arepeated
container or element to the metadata for that repeated container or element.
-
getDynFieldSet
@Deprecated public HashSet<String> getDynFieldSet()
Deprecated.- Specified by:
getDynFieldSet
in interfaceIFormDataAdapter
- Returns:
- A set that consists of the names of all form elements which are repeated and that have a value.
- See Also:
IFormDataAdapter.isElementLooped(String)
,IFormDataAdapter.getDynContainerMap()
-
getDynFieldSets
public Set<String> getDynFieldSets()
- Specified by:
getDynFieldSets
in interfaceIFormDataAdapter
- Returns:
- A set that consists of the names of all form elements which are repeated and that have a value.
- See Also:
IFormDataAdapter.isElementLooped(String)
,IFormDataAdapter.getDynContainerMap()
-
getFieldAlias
public Set<String> getFieldAlias()
- Specified by:
getFieldAlias
in interfaceIFormDataAdapter
- Returns:
- A
Set
consisting of the alias names of all existing form elements.
-
getFieldAliasMap
public Map<String,String> getFieldAliasMap()
- Specified by:
getFieldAliasMap
in interfaceIFormDataAdapter
- Returns:
- A
Map
that maps from the name of a form elements to its alias name. - See Also:
IFormDataAdapter.getAliasFieldMap()
-
getFieldMetaData
@Deprecated public FormFieldMetaData getFieldMetaData(String identifier, boolean asAlias)
Deprecated.- Specified by:
getFieldMetaData
in interfaceIFormDataAdapter
- Parameters:
identifier
- Identifier, either a name or alias.asAlias
- Whether the identifier is a field name or a field alias.- Returns:
- The metadata for the given field.
-
getFieldMetaDataMap
@Deprecated public Map<String,FormFieldMetaData> getFieldMetaDataMap()
Deprecated.- Specified by:
getFieldMetaDataMap
in interfaceIFormDataAdapter
- Returns:
- A map with the metadata for each element. The key is the field name, e.g.
tf1
-
getFieldNotesRead
@Deprecated public Map<String,List<String>> getFieldNotesRead()
Deprecated.Description copied from interface:IFormDataAdapter
Gets a map with notes for form fields that were already read by a user. The key is the name of the field, e.g.tf1
.- Specified by:
getFieldNotesRead
in interfaceIFormDataAdapter
- Returns:
- Am map with all read field notes.
-
getFieldNotesUnread
@Deprecated public Map<String,List<String>> getFieldNotesUnread()
Deprecated.Description copied from interface:IFormDataAdapter
Gets a map with notes for form fields that were not yet read by a user. The key is the name of the field, e.g.tf1
.- Specified by:
getFieldNotesUnread
in interfaceIFormDataAdapter
- Returns:
- Am map with all unread field notes.
-
getFieldTyp
public EFormFieldTyp getFieldTyp(String identifier, boolean asAlias)
- Specified by:
getFieldTyp
in interfaceIFormDataAdapter
- Parameters:
identifier
- The name of a form element.asAlias
- Iftrue
, interpret the given identifier as the alias name of the form element. Iffalse
, interpret the given identifier as the name of the form element.- Returns:
- The form field type for the given element; or
null
when the given element does not exist.
-
getFieldValues
public List<String[]> getFieldValues(String fieldName)
- Specified by:
getFieldValues
in interfaceIFormDataAdapter
- Parameters:
fieldName
- The name of a form element.- Returns:
- A
List
of all values for the given form element, ornull
if the given form element does not exist.
-
getFieldValuesMap
public Map<String,List<String[]>> getFieldValuesMap()
- Specified by:
getFieldValuesMap
in interfaceIFormDataAdapter
- Returns:
- A
Map
that maps from the name of a form element to its values.
-
getFields
public Set<String> getFields()
- Specified by:
getFields
in interfaceIFormDataAdapter
-
getIDynContainerMap
public Map<String,IFormContainerMetaData> getIDynContainerMap()
- Specified by:
getIDynContainerMap
in interfaceIFormDataAdapter
- Returns:
- A map from the
name
of arepeated
container or element to the metadata for that repeated container or element.
-
getIFieldMetaData
public IFieldMetaData getIFieldMetaData(String identifier, boolean asAlias)
- Specified by:
getIFieldMetaData
in interfaceIFormDataAdapter
-
getIFieldMetaDataMap
public Map<String,IFieldMetaData> getIFieldMetaDataMap()
- Specified by:
getIFieldMetaDataMap
in interfaceIFormDataAdapter
-
getMetaDataMap
public Map<String,String> getMetaDataMap()
- Specified by:
getMetaDataMap
in interfaceIFormDataAdapter
-
getNormName
public String getNormName(String fieldName)
Description copied from interface:IFormDataAdapter
For each element, a name is defined in the designer. When the element is marked as a repeated elements, the created elements get a name that consists of the original name and a suffix. This method takes a name that may contain such a suffix and returns the original form element name.- Specified by:
getNormName
in interfaceIFormDataAdapter
- Parameters:
fieldName
- A form element that may contain suffixes such as the suffix for repeated elements.- Returns:
- The given name, normalized to the form element name as defined in the designer.
-
getRequestDataMap
public Map<String,List<String>> getRequestDataMap()
- Specified by:
getRequestDataMap
in interfaceIFormDataAdapter
-
getSendElements
public Set<String> getSendElements()
- Specified by:
getSendElements
in interfaceIFormDataAdapter
- Returns:
- A
Set
of all elements for which a value was submitted in the (usually POST) request.
-
getStringValue
public String getStringValue(String fieldName)
Description copied from interface:IFormDataAdapter
Each form element may have multiple values. This returns the first value.- Specified by:
getStringValue
in interfaceIFormDataAdapter
- Parameters:
fieldName
- The name of a form element.- Returns:
- The first value for the given form element, or the empty string when no value or the form element does not exist.
-
getWrapped
public abstract IFormDataAdapter getWrapped()
Gets the wrapped form data adapter. This is used as a delegate for all methods.- Returns:
- The wrapped form data adapter.
-
hasAlias
public boolean hasAlias(String alias)
- Specified by:
hasAlias
in interfaceIFormDataAdapter
- Parameters:
alias
- An alias name to check.- Returns:
true
if a form element with the given alias exists, orfalse
otherwise.
-
hasField
public boolean hasField(String fieldName)
Description copied from interface:IFormDataAdapter
ERSTMAL: Lieferttrue
, wenn das Formular ein Feld mit dem übergebenen Namen besitzt.- Specified by:
hasField
in interfaceIFormDataAdapter
- Parameters:
fieldName
- the field to check for- Returns:
- Liefert
true
, wenn das Formular ein Feld mit dem übergebenen Namen besitzt
-
init
public void init(Map<String,List<String>> dataMap, Map<String,List<org.apache.commons.fileupload.FileItem>> uploadMap)
- Specified by:
init
in interfaceIFormDataAdapter
-
init
@Deprecated public void init(Map<String,List<String>> dataMap)
Deprecated.- Specified by:
init
in interfaceIFormDataAdapter
- Parameters:
dataMap
- Map with form values (non uploads).
-
init
@Deprecated public void init(Map<String,List<String>> dataMap, List<String> sendElements)
Deprecated.- Specified by:
init
in interfaceIFormDataAdapter
- Parameters:
dataMap
- Map with form values (non uploads).sendElements
- Elements that were rendered.
-
init
public void init(Map<String,List<String>> dataMap, Map<String,List<org.apache.commons.fileupload.FileItem>> uploadMap, List<String> sendElements)
- Specified by:
init
in interfaceIFormDataAdapter
-
isElementLooped
public boolean isElementLooped(String elementName)
Description copied from interface:IFormDataAdapter
A repeated form element (also called dynamic or looped) is a form element of which the user can create multiple copies of as they fill out the form. This method checks whether the given form element is repeated.- Specified by:
isElementLooped
in interfaceIFormDataAdapter
- Parameters:
elementName
- The name of a form element to check.- Returns:
true
if the form element is a repeated element,false
otherwise (or if the given element does not exist).
-
isQuestionElement
public boolean isQuestionElement(String elementName)
- Specified by:
isQuestionElement
in interfaceIFormDataAdapter
-
loopCount
public int loopCount(String elementName)
Description copied from interface:IFormDataAdapter
A repeated form element (also called dynamic or looped) is a form element of which the user can create multiple copies of as they fill out the form. This method returns how many copies were created.- Specified by:
loopCount
in interfaceIFormDataAdapter
- Parameters:
elementName
- The name of a form element.- Returns:
- The number of repetitions of the given repeated form element, or
0
in case the element is not a repeated element. - See Also:
IFormDataAdapter.isElementLooped(String)
-
mergeRequestData
public void mergeRequestData(Map<String,List<String>> oldData)
- Specified by:
mergeRequestData
in interfaceIFormDataAdapter
-
normalizeValue
public String[] normalizeValue(String... value)
- Specified by:
normalizeValue
in interfaceIFormDataAdapter
- Parameters:
value
- A list of values.- Returns:
- The given list of values, or an empty array in case
null
was given.
-
normalizeValue
public String[] normalizeValue(List<String> value)
- Specified by:
normalizeValue
in interfaceIFormDataAdapter
- Parameters:
value
- AList
of values.- Returns:
- An array with the given values, or an empty array in case
null
was given.
-
normalizeValues
public List<String[]> normalizeValues(List<String> stringList)
- Specified by:
normalizeValues
in interfaceIFormDataAdapter
- Parameters:
stringList
- A list of values.- Returns:
- A
List
with only a single entry, an array containing the given values.
-
resolveAliasName
public String resolveAliasName(String alias)
- Specified by:
resolveAliasName
in interfaceIFormDataAdapter
- Parameters:
alias
- The alias of a form element.- Returns:
- The resolved alias, i.e. the name of the form element with the given alias. Returns the given alias in case no form element with the given alias exists.
- See Also:
IFormDataAdapter.hasAlias(String)
-
resolveFieldAlias
public String resolveFieldAlias(String alias)
- Specified by:
resolveFieldAlias
in interfaceIFormDataAdapter
-
resolveFieldName
public String resolveFieldName(String fieldName)
- Specified by:
resolveFieldName
in interfaceIFormDataAdapter
-
resolveFieldType
public EFormFieldTyp resolveFieldType(String fieldName, boolean asAlias)
- Specified by:
resolveFieldType
in interfaceIFormDataAdapter
-
valuesMapHasValue
public boolean valuesMapHasValue(String fieldName)
- Specified by:
valuesMapHasValue
in interfaceIFormDataAdapter
-
-