Class Rule
- java.lang.Object
-
- net.sf.okapi.lib.xliff2.validation.Rule
-
- All Implemented Interfaces:
IWithExtAttributes
public class Rule extends Object implements IWithExtAttributes
Represents the <rule> element of the Validation module.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRule.NormalizationForm of normalization possible.static classRule.TypeTypes of validation rule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetData()StringgetDisplay()Gets a human readable representation of the rule.StringgetEffectiveData()Gets the effective text to use when applying the rule.booleangetExistsInSource()Gets the flag 'existsInSource'.ExtAttributesgetExtAttributes()Gets theExtAttributesobject for the parent object.StringgetExtAttributeValue(String namespaceURI, String localName)Gets the value for a given extension attribute.Rule.NormalizationgetNormalization()intgetOccurs()Rule.TypegetType()booleanhasExtAttribute()Indicates if at least one extension attribute is present.booleanisCaseSensitive()booleanisEnabled()Indicates if this rule is enabled or not.booleanisInherited()Indicates if this rule is inherited from a parent object.voidprepare()Creates the effective data from the data and flags for this rule.voidsetCaseSensitive(boolean caseSensitive)voidsetData(String data)voidsetEnabled(boolean enabled)Sets the flag indicating if this rule is enabled or not.voidsetExistsInSource(boolean existsInSource)Sets the flag 'existsInSource'voidsetExtAttributes(ExtAttributes attributes)Sets theExtAttributesobject associated with this object.voidsetInherited(boolean inherited)Sets the flag indicating if this rule is inherited from a parent object.voidsetNormalization(Rule.Normalization normalization)voidsetOccurs(int occurs)voidsetType(Rule.Type type)voidverify()Verifies if this rule has valid parameters.
-
-
-
Method Detail
-
getDisplay
public 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 String getData()
-
setData
public void setData(String data)
-
getEffectiveData
public 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.
-
getNormalization
public Rule.Normalization getNormalization()
-
setNormalization
public void setNormalization(Rule.Normalization normalization)
-
setExtAttributes
public void setExtAttributes(ExtAttributes attributes)
Description copied from interface:IWithExtAttributesSets theExtAttributesobject associated with this object.- Specified by:
setExtAttributesin interfaceIWithExtAttributes- Parameters:
attributes- theExtAttributesobject associated with this object. If null, a newExtAttributesobject 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:IWithExtAttributesGets theExtAttributesobject for the parent object. If none exists, one is created.- Specified by:
getExtAttributesin interfaceIWithExtAttributes- Returns:
- the
ExtAttributesobject for the parent object, never null.
-
hasExtAttribute
public boolean hasExtAttribute()
Description copied from interface:IWithExtAttributesIndicates if at least one extension attribute is present.- Specified by:
hasExtAttributein interfaceIWithExtAttributes- Returns:
- true if at least one extension attribute is present; false otherwise.
-
getExtAttributeValue
public String getExtAttributeValue(String namespaceURI, String localName)
Description copied from interface:IWithExtAttributesGets the value for a given extension attribute.- Specified by:
getExtAttributeValuein interfaceIWithExtAttributes- 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.
-
-