Class InlineCodeFinder


  • public class InlineCodeFinder
    extends Object
    Implements the methods needed to convert sections of a coded text into in-line codes.
    • Field Detail

      • TAGTYPE

        public static final String TAGTYPE
        Type representing an inline code created with this class.
        See Also:
        Constant Field Values
    • Constructor Detail

      • InlineCodeFinder

        public InlineCodeFinder()
        Creates a new InlineCodeFinder object.
    • Method Detail

      • reset

        public void reset()
        Resets this finder.
      • clone

        public InlineCodeFinder clone()
        Clones this finder.
        Overrides:
        clone in class Object
        Returns:
        A new InlineCodeFinder object that is a copy of this one.
      • addRule

        public void addRule​(String pattern)
        Adds a new rule to the list.
        Parameters:
        pattern - The regular expression pattern for the rule.
      • addRules

        public void addRules​(Collection<String> rules)
        Adds a collection of rules to the list.
        Parameters:
        rules - The collection of rules to add
      • getRules

        public ArrayList<String> getRules()
        Gets a list of all rules.
        Returns:
        The list of all rules.
      • getSample

        public String getSample()
        Gets the sample text to go with the finder.
        Returns:
        The sample text.
      • setSample

        public void setSample​(String value)
        Sets the sample text that can be used to check the rules in a regular expression editor.
        Parameters:
        value - The sample text.
      • useAllRulesWhenTesting

        public boolean useAllRulesWhenTesting()
        Indicates if all rules should be used when testing the patterns in a regular expression editor.
        Returns:
        True if all rules should be used when testing, false when only the current rule should be used.
      • setUseAllRulesWhenTesting

        public void setUseAllRulesWhenTesting​(boolean value)
        Set the flag that indicates if all rules should be used when testing the patterns in a regular expression editor.
        Parameters:
        value - True to use all rules, false to use only the current rule.
      • compile

        public void compile()
        Compiles all the rules into a single compiled pattern.
        Throws:
        PatternSyntaxException - When there is a syntax error in one of the rules.
      • process

        public void process​(TextFragment fragment)
        Applies the rules to a given content and converts all matching sections into in-line codes. The new codes have the type TAGTYPE.

        IMPORTANT: Note that the data of the original data in the new inline code may need to be escaped as they are now part of the fragment 'skeleton' and are not escaped back to the original format when merging.

        Parameters:
        fragment - The fragment where to apply the rules.
      • process

        public void process​(Segment segment,
                            boolean forceUniqueIds)
      • toString

        public String toString()
        Gets a string of all the options for this finder.
        Overrides:
        toString in class Object
        Returns:
        The string storing all the options for this finder.
        See Also:
        fromString(String)
      • fromString

        public void fromString​(String data)
        Sets the options of this finder with the values stored in a given string. The provided string can be created by toString().
        Parameters:
        data - String storing all the options for this finder.
        See Also:
        toString()