Package de.xima.fc.mdl.fdv.form
Class ParsedFieldName
- java.lang.Object
-
- de.xima.fc.mdl.fdv.form.ParsedFieldName
-
public class ParsedFieldName extends Object
Represents a parsed field name from a submitted form.For normal form elements, the name as submitted in the HTTP request is the same as the name that was configured in the form designer, e.g. "tfName". For repeated elements, the name contains several pieces of information and looks like "tfName_dyn_fsContact_9". For question elements (select elements displayed as questions), the name looks like "selHobbies_quest_2".
- Author:
- XIMA MEDIA GmbH
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(Object o)
static ParsedFieldName
forBasicElement(String elementName)
Creates a new parsed field name for a basic element, using the given parameters.static ParsedFieldName
forFieldName(String fieldName)
static ParsedFieldName
forRepeatedElement(String elementName, String containerName, int repetitionId)
Creates a new parsed field name for a repeated element, using the given parameters.String
getContainerName()
If the form element is not repeated, this returns just thegetElementName()
.int
getElementIndex()
String
getElementName()
String
getRawName()
Gets the raw name of the field as it would be submitted in an HTTP request.int
hashCode()
boolean
isDynamic()
Deprecated.UseisRepeated()
instead.boolean
isInsideRepeatedContainer()
Gets whether this element is inside a repeated container, i.e.boolean
isQuestion()
boolean
isRepeated()
Gets whether this element is either repeated itself or is inside a repeated container.boolean
isSelfRepeated()
Gets whether this element is itself repeated, i.e.whether it is repeated and its element name is the same as the container name.String
toString()
ParsedFieldName
withSuffix(String suffix, boolean preserveContainerName)
Adds a suffix the element's name, but preserves the container name and the repetition index.
-
-
-
Method Detail
-
getContainerName
public String getContainerName()
If the form element is not repeated, this returns just thegetElementName()
. If the form element is itself repeated, this returns thegetElementName()
as well. If the form element is inside a repeated container, this returns the name of that container.- Returns:
- The name of the repeated parent element.
-
getElementIndex
public int getElementIndex()
- Returns:
- The ID of the repetition instance, which may not necessarily start at 0 and may not be continuous.
-
getElementName
public String getElementName()
- Returns:
- The name of the repeated element, usually as configured in the designer, e.g. tfName. For repeated elements, this is the base name without the repetition index.
-
getRawName
public String getRawName()
Gets the raw name of the field as it would be submitted in an HTTP request.- Returns:
- The raw name of the field.
-
isDynamic
@Deprecated public boolean isDynamic()
Deprecated.UseisRepeated()
instead.Gets whether this element is either repeated itself or is inside a repeated container.- Returns:
true
if this element is repeated,false
otherwise.
-
isInsideRepeatedContainer
public boolean isInsideRepeatedContainer()
Gets whether this element is inside a repeated container, i.e. whether it is repeated, but its element name is different from the container name.- Returns:
true
if this element is inside a repeated container,false
otherwise.
-
isQuestion
public boolean isQuestion()
- Returns:
true
if this element is a multi-question with multiple answer rows,false
otherwise.
-
isRepeated
public boolean isRepeated()
Gets whether this element is either repeated itself or is inside a repeated container.- Returns:
true
if this element is repeated,false
otherwise.
-
isSelfRepeated
public boolean isSelfRepeated()
Gets whether this element is itself repeated, i.e.whether it is repeated and its element name is the same as the container name.- Returns:
true
if this element is itself repeated,false
otherwise.
-
withSuffix
public ParsedFieldName withSuffix(String suffix, boolean preserveContainerName)
Adds a suffix the element's name, but preserves the container name and the repetition index. The option to preserve the container name controls whether the suffix is also added to the container name if the element isisSelfRepeated()
.For example:
"tfName".withSuffix("First", *) = "tfNameFirst" "tfEmail_dyn_tfEmail_3".withSuffix("X", false) = "tf1X_dyn_tf1X_3" "tfEmail_dyn_tfEmail_3".withSuffix("X", true) = "tf1X_dyn_tf1_3" "upl1_dyn_fs1_9".withSuffix(".uuid", *) = upl1.uuid_dyn_fs1_9 "sel1_quest_2".withSuffix("2", *) = sel12_quest_2
- Parameters:
suffix
- The suffix to add to the element's name.preserveContainerName
- Whether to preserve the container name if the element isisSelfRepeated()
.- Returns:
- A new parsed field name with the given suffix added to the element's name.
-
forBasicElement
public static ParsedFieldName forBasicElement(String elementName)
Creates a new parsed field name for a basic element, using the given parameters. This method assumes that the element is neither repeated nor a select element displayed as questions.- Parameters:
elementName
- The name of the basic element, usually as configured in the designer, e.g. "tfName".- Returns:
- The parsed field name, see
ParsedFieldName
for details.
-
forFieldName
public static ParsedFieldName forFieldName(String fieldName)
- Parameters:
fieldName
- A submitted field name to parse.- Returns:
- The parsed field name, see
ParsedFieldName
for details.
-
forRepeatedElement
public static ParsedFieldName forRepeatedElement(String elementName, String containerName, int repetitionId)
Creates a new parsed field name for a repeated element, using the given parameters. This method assumes that the element is not a select element displayed as questions.- Parameters:
elementName
- The base name of the repeated element, usually as configured in the designer, e.g. "tfName".containerName
- The name of the repeated container, usually as configured in the designer, e.g. "fsContact".repetitionId
- The ID of the repetition, which may not necessarily start at 0 and may not be continuous.- Returns:
- The parsed field name, see
ParsedFieldName
for details.
-
-