Class 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 Detail

      • getContainerName

        public String getContainerName()
        If the form element is not repeated, this returns just the getElementName(). If the form element is itself repeated, this returns the getElementName() 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isDynamic

        @Deprecated
        public boolean isDynamic()
        Deprecated.
        Use isRepeated() 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 is isSelfRepeated().

        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 is isSelfRepeated().
        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.