net.sf.okapi.common.filters

## Class InlineCodeFinder

- java.lang.Object
- - net.sf.okapi.common.filters.InlineCodeFinder

-     public class InlineCodeFinder
      extends java.lang.Object

  Implements the methods needed to convert sections of a coded text into in-line codes.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `TAGTYPE` Type representing an inline code created with this class.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InlineCodeFinder()` Creates a new InlineCodeFinder object.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRule(java.lang.String pattern)` Adds a new rule to the list.
    `InlineCodeFinder` | `clone()` Clones this finder.
    `void` | `compile()` Compiles all the rules into a single compiled pattern.
    `void` | `fromString(java.lang.String data)` Sets the options of this finder with the values stored in a given string.
    `java.util.ArrayList<java.lang.String>` | `getRules()` Gets a list of all rules.
    `java.lang.String` | `getSample()` Gets the sample text to go with the finder.
    `void` | `process(TextFragment fragment)` Applies the rules to a given content and converts all matching sections into in-line codes.
    `void` | `reset()` Resets this finder.
    `void` | `setSample(java.lang.String value)` Sets the sample text that can be used to check the rules in a regular expression editor.
    `void` | `setUseAllRulesWhenTesting(boolean value)` Set the flag that indicates if all rules should be used when testing the patterns in a regular expression editor.
    `java.lang.String` | `toString()` Gets a string of all the options for this finder.
    `boolean` | `useAllRulesWhenTesting()` Indicates if all rules should be used when testing the patterns in a regular expression editor.

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### TAGTYPE

          public static final java.lang.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 `java.lang.Object`
      Returns:
        A new InlineCodeFinder object that is a copy of this one.

    - #### addRule

          public void addRule(java.lang.String pattern)

      Adds a new rule to the list.
      Parameters:
        `pattern` - The regular expression pattern for the rule.

    - #### getRules

          public java.util.ArrayList<java.lang.String> getRules()

      Gets a list of all rules.
      Returns:
        The list of all rules.

    - #### getSample

          public java.lang.String getSample()

      Gets the sample text to go with the finder.
      Returns:
        The sample text.

    - #### setSample

          public void setSample(java.lang.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.

    - #### toString

          public java.lang.String toString()

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

    - #### fromString

          public void fromString(java.lang.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()`