Package net.sf.okapi.common.filters
Class PropertyTextUnitPlaceholder
- java.lang.Object
-
- net.sf.okapi.common.filters.PropertyTextUnitPlaceholder
-
- All Implemented Interfaces:
Comparable<PropertyTextUnitPlaceholder>
public class PropertyTextUnitPlaceholder extends Object implements Comparable<PropertyTextUnitPlaceholder>
This class acts as a placeholder for bothPropertys andITextUnits that are found within tags. HTML and XML attributes are the canonical case. Along with the attribute name, value and type this class stores offset information for the name and value that can be used by theAbstractFilterto automatically generate proper attribute-basedIResources
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPropertyTextUnitPlaceholder.PlaceholderAccessType
-
Constructor Summary
Constructors Constructor Description PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value)Constructor forPropertyonly.PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value, int valueStartPos, int valueEndPos)Constructor forPropertyandITextUnitwithout a main offsets.PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value, int mainStartPos, int mainEndPos, int valueStartPos, int valueEndPos)Constructor forPropertyandITextUnitthat are delimited by formatting (i.e., name="value").
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(PropertyTextUnitPlaceholder aThat)Compare twoPropertyTextUnitPlaceholders.booleanequals(Object aThat)Define equality of state.PropertyTextUnitPlaceholder.PlaceholderAccessTypegetAccessType()Get the placeholderPropertyTextUnitPlaceholder.PlaceholderAccessType.StringgetElementType()intgetMainEndPos()Get the ending offset of the attributeintgetMainStartPos()Get the offset to the beginning of the attribute.StringgetMimeType()Get the attribute values mimetypeStringgetName()Get the attribute nameStringgetValue()Get the attribute valueintgetValueEndPos()Get the ending offset of the attribute valueintgetValueStartPos()Get the starting offset of the attribute value.inthashCode()A class that overrides equals must also override hashCode. Return a hash code based on the MainStartPos onlyvoidsetAccessType(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType)voidsetElementType(String elementType)voidsetMainEndPos(int mainEndPos)Set the ending offset of the attributevoidsetMainStartPos(int mainStartPos)Set the offset to the beginning of the attribute.voidsetMimeType(String mimeType)Set the attribute values mimetypevoidsetName(String name)Set the attribute namevoidsetValue(String value)Set the attribute valuevoidsetValueEndPos(int valueEndPos)Set the ending offset of the attribute valuevoidsetValueStartPos(int valueStartPos)Set the starting offset of the attribute value.
-
-
-
Constructor Detail
-
PropertyTextUnitPlaceholder
public PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value)
Constructor forPropertyonly. All offsets are the same, useful for creating placeholders for read-onlyPropertys- Parameters:
accessType- aPropertyTextUnitPlaceholder.PlaceholderAccessTypename- attribute namevalue- attribute value
-
PropertyTextUnitPlaceholder
public PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value, int valueStartPos, int valueEndPos)
Constructor forPropertyandITextUnitwithout a main offsets. This is useful for cases where values are not delimited by any formatting- Parameters:
accessType- aPropertyTextUnitPlaceholder.PlaceholderAccessTypename- attribute namevalue- attribute valuevalueStartPos- start offset of the valuevalueEndPos- ending offset of the value
-
PropertyTextUnitPlaceholder
public PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value, int mainStartPos, int mainEndPos, int valueStartPos, int valueEndPos)
Constructor forPropertyandITextUnitthat are delimited by formatting (i.e., name="value"). The offset 'n' in name is the mainStartPos, the offset 'v' in value is the valueStartPos.- Parameters:
accessType- aPropertyTextUnitPlaceholder.PlaceholderAccessTypename- attribute namevalue- attribute valuemainStartPos- start offset of the value delimitermainEndPos- end offset of the entire attributevalueStartPos- start offset of the valuevalueEndPos- ending offset of the value
-
-
Method Detail
-
getAccessType
public PropertyTextUnitPlaceholder.PlaceholderAccessType getAccessType()
Get the placeholderPropertyTextUnitPlaceholder.PlaceholderAccessType.- Returns:
- one of TRANSLATABLE, READ_ONLY_PROPERTY, WRITABLE_PROPERTY
-
setAccessType
public void setAccessType(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType)
- Parameters:
accessType- the type, one of TRANSLATABLE, READ_ONLY_PROPERTY, WRITABLE_PROPERTY
-
getMainStartPos
public int getMainStartPos()
Get the offset to the beginning of the attribute.- Returns:
- offset as int
-
setMainStartPos
public void setMainStartPos(int mainStartPos)
Set the offset to the beginning of the attribute.- Parameters:
mainStartPos- the offset as integer
-
getMainEndPos
public int getMainEndPos()
Get the ending offset of the attribute- Returns:
- offset as integer
-
setMainEndPos
public void setMainEndPos(int mainEndPos)
Set the ending offset of the attribute- Parameters:
mainEndPos- the ending offset as an integer
-
setName
public void setName(String name)
Set the attribute name- Parameters:
name- the attribute name
-
getName
public String getName()
Get the attribute name- Returns:
- the attribute name
-
setValue
public void setValue(String value)
Set the attribute value- Parameters:
value- the attribute value
-
getValue
public String getValue()
Get the attribute value- Returns:
- the attribute value
-
getValueStartPos
public int getValueStartPos()
Get the starting offset of the attribute value.- Returns:
- the starting offset as int
-
setValueStartPos
public void setValueStartPos(int valueStartPos)
Set the starting offset of the attribute value.- Parameters:
valueStartPos- the start offset as int
-
getValueEndPos
public int getValueEndPos()
Get the ending offset of the attribute value- Returns:
- the ending offset as int
-
setValueEndPos
public void setValueEndPos(int valueEndPos)
Set the ending offset of the attribute value- Parameters:
valueEndPos- the ending offset as int
-
setMimeType
public void setMimeType(String mimeType)
Set the attribute values mimetype- Parameters:
mimeType- the mimeType to set
-
getMimeType
public String getMimeType()
Get the attribute values mimetype- Returns:
- the mimeType
-
setElementType
public void setElementType(String elementType)
-
getElementType
public String getElementType()
-
compareTo
public int compareTo(PropertyTextUnitPlaceholder aThat)
Compare twoPropertyTextUnitPlaceholders. Compare is based in MainStartPos order only. Allows sorting of manyPropertyTextUnitPlaceholders in the order they appear in the input- Specified by:
compareToin interfaceComparable<PropertyTextUnitPlaceholder>- Parameters:
aThat- thePropertyTextUnitPlaceholderused to compare to this object
-
equals
public boolean equals(Object aThat)
Define equality of state. Equality is based on the MainStartPos of the attribute.- Overrides:
equalsin classObject- Parameters:
aThat- thePropertyTextUnitPlaceholderthat is compared to this object
-
-