net.sf.okapi.lib.xliff2.validation

## Class Rule

- java.lang.Object
- - net.sf.okapi.lib.xliff2.validation.Rule

- All Implemented Interfaces:
    IWithExtAttributes

      public class Rule
      extends java.lang.Object
      implements IWithExtAttributes

  Represents the <rule> element of the Validation module.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Rule.Normalization` Form of normalization possible.
    `static class` | `Rule.Type` Types of validation rule.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Rule(Rule original)` Copy constructor.
    `Rule(java.lang.String type, java.lang.String data)` Creates a rule of a given type.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getData()`
    `java.lang.String` | `getDisplay()` Gets a human readable representation of the rule.
    `java.lang.String` | `getEffectiveData()` Gets the effective text to use when applying the rule.
    `boolean` | `getExistsInSource()` Gets the flag 'existsInSource'.
    `ExtAttributes` | `getExtAttributes()` Gets the `ExtAttributes` object for the parent object.
    `java.lang.String` | `getExtAttributeValue(java.lang.String namespaceURI, java.lang.String localName)` Gets the value for a given extension attribute.
    `Rule.Normalization` | `getNormalization()`
    `int` | `getOccurs()`
    `Rule.Type` | `getType()`
    `boolean` | `hasExtAttribute()` Indicates if at least one extension attribute is present.
    `boolean` | `isCaseSensitive()`
    `boolean` | `isEnable()` Deprecated.
    `boolean` | `isEnabled()` Indicates if this rule is enabled or not.
    `boolean` | `isInherited()` Indicates if this rule is inherited from a parent object.
    `void` | `prepare()` Creates the effective data from the data and flags for this rule.
    `void` | `setCaseSensitive(boolean caseSensitive)`
    `void` | `setData(java.lang.String data)`
    `void` | `setEnable(boolean enable)` Deprecated.
    `void` | `setEnabled(boolean enabled)` Sets the flag indicating if this rule is enabled or not.
    `void` | `setExistsInSource(boolean existsInSource)` Sets the flag 'existsInSource'
    `void` | `setExtAttributes(ExtAttributes attributes)` Sets the `ExtAttributes` object associated with this object.
    `void` | `setInherited(boolean inherited)` Sets the flag indicating if this rule is inherited from a parent object.
    `void` | `setNormalization(Rule.Normalization normalization)`
    `void` | `setOccurs(int occurs)`
    `void` | `setType(Rule.Type type)`
    `void` | `verify()` Verifies if this rule has valid parameters.

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

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

- - ### Constructor Detail

    - #### Rule

          public Rule(java.lang.String type,
              java.lang.String data)

      Creates a rule of a given type.
      Parameters:
        `type` - the name of the rule type.
        `data` - the text data for the rule (can be null).

    - #### Rule

          public Rule(Rule original)

      Copy constructor.
      Parameters:
        `original` - the original object to duplicate.

  - ### Method Detail

    - #### getDisplay

          public java.lang.String getDisplay()

      Gets a human readable representation of the rule.
      Returns:
        the text display of this rule.

    - #### getType

          public Rule.Type getType()

    - #### setType

          public void setType(Rule.Type type)

    - #### getData

          public java.lang.String getData()

    - #### setData

          public void setData(java.lang.String data)

    - #### getEffectiveData

          public java.lang.String getEffectiveData()

      Gets the effective text to use when applying the rule. For example if the rule is not case sensitive or need to be normalized, the original data string needs to be modified for applying the rule. The effective data is the result of those changes.
      Returns:
        the effective data for this rule.

    - #### getOccurs

          public int getOccurs()

    - #### setOccurs

          public void setOccurs(int occurs)

    - #### getExistsInSource

          public boolean getExistsInSource()

      Gets the flag 'existsInSource'.
      Returns:
        the flag 'existsinSource'

    - #### setExistsInSource

          public void setExistsInSource(boolean existsInSource)

      Sets the flag 'existsInSource'
      Parameters:
        `existsInSource` - the flag 'existsinSource' to set

    - #### isCaseSensitive

          public boolean isCaseSensitive()

    - #### setCaseSensitive

          public void setCaseSensitive(boolean caseSensitive)

    - #### isEnabled

          public boolean isEnabled()

      Indicates if this rule is enabled or not.
      Returns:
        true if this rule is enabled, false if it is not.

    - #### setEnabled

          public void setEnabled(boolean enabled)

      Sets the flag indicating if this rule is enabled or not.
      Parameters:
        `enabled` - true to enable this rule, false to disable it.

    - #### isEnable

          @Deprecated
          public boolean isEnable()

      Deprecated.
      Use `isEnabled()` instead of this method.
      Returns:
        true if this rule is enabled, false if it is not.

    - #### setEnable

          @Deprecated
          public void setEnable(boolean enable)

      Deprecated.
      Use `setEnabled(boolean)` instead of this method.
      Parameters:
        `enable` - true to enable this rule, false to disable it.

    - #### getNormalization

          public Rule.Normalization getNormalization()

    - #### setNormalization

          public void setNormalization(Rule.Normalization normalization)

    - #### setExtAttributes

          public void setExtAttributes(ExtAttributes attributes)

      Description copied from interface: `IWithExtAttributes`
      Sets the `ExtAttributes` object associated with this object.
      Specified by:
        `setExtAttributes` in interface `IWithExtAttributes`
      Parameters:
        `attributes` - the `ExtAttributes` object associated with this object. If null, a new `ExtAttributes` object is created.

    - #### isInherited

          public boolean isInherited()

      Indicates if this rule is inherited from a parent object.
      Returns:
        true if this rule is inherited from a parent object, false otherwise.

    - #### setInherited

          public void setInherited(boolean inherited)

      Sets the flag indicating if this rule is inherited from a parent object.
      Parameters:
        `inherited` - true if this rule is inherited from a parent object, false otherwise.

    - #### getExtAttributes

          public ExtAttributes getExtAttributes()

      Description copied from interface: `IWithExtAttributes`
      Gets the `ExtAttributes` object for the parent object. If none exists, one is created.
      Specified by:
        `getExtAttributes` in interface `IWithExtAttributes`
      Returns:
        the `ExtAttributes` object for the parent object, never null.

    - #### hasExtAttribute

          public boolean hasExtAttribute()

      Description copied from interface: `IWithExtAttributes`
      Indicates if at least one extension attribute is present.
      Specified by:
        `hasExtAttribute` in interface `IWithExtAttributes`
      Returns:
        true if at least one extension attribute is present; false otherwise.

    - #### getExtAttributeValue

          public java.lang.String getExtAttributeValue(java.lang.String namespaceURI,
                                              java.lang.String localName)

      Description copied from interface: `IWithExtAttributes`
      Gets the value for a given extension attribute.
      Specified by:
        `getExtAttributeValue` in interface `IWithExtAttributes`
      Parameters:
        `namespaceURI` - the URI of the namespace for the attribute.
        `localName` - the name of the attribute.
      Returns:
        the value of the extension attribute, or null if it does not exist.

    - #### prepare

          public void prepare()

      Creates the effective data from the data and flags for this rule. For example make the data lower-case or normalize it as needed.

    - #### verify

          public void verify()

      Verifies if this rule has valid parameters.
      Throws:
        `XLIFFException` - if there is a problem with the rule's parameters.