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 bothProperty
s andITextUnit
s 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 theAbstractFilter
to automatically generate proper attribute-basedIResource
s
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PropertyTextUnitPlaceholder.PlaceholderAccessType
-
Constructor Summary
Constructors Constructor Description PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value)
Constructor forProperty
only.PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value, int valueStartPos, int valueEndPos)
Constructor forProperty
andITextUnit
without a main offsets.PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value, int mainStartPos, int mainEndPos, int valueStartPos, int valueEndPos)
Constructor forProperty
andITextUnit
that are delimited by formatting (i.e., name="value").
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(PropertyTextUnitPlaceholder aThat)
Compare twoPropertyTextUnitPlaceholder
s.boolean
equals(Object aThat)
Define equality of state.PropertyTextUnitPlaceholder.PlaceholderAccessType
getAccessType()
Get the placeholderPropertyTextUnitPlaceholder.PlaceholderAccessType
.String
getElementType()
int
getMainEndPos()
Get the ending offset of the attributeint
getMainStartPos()
Get the offset to the beginning of the attribute.String
getMimeType()
Get the attribute values mimetypeString
getName()
Get the attribute nameString
getValue()
Get the attribute valueint
getValueEndPos()
Get the ending offset of the attribute valueint
getValueStartPos()
Get the starting offset of the attribute value.int
hashCode()
A class that overrides equals must also override hashCode. Return a hash code based on the MainStartPos onlyvoid
setAccessType(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType)
void
setElementType(String elementType)
void
setMainEndPos(int mainEndPos)
Set the ending offset of the attributevoid
setMainStartPos(int mainStartPos)
Set the offset to the beginning of the attribute.void
setMimeType(String mimeType)
Set the attribute values mimetypevoid
setName(String name)
Set the attribute namevoid
setValue(String value)
Set the attribute valuevoid
setValueEndPos(int valueEndPos)
Set the ending offset of the attribute valuevoid
setValueStartPos(int valueStartPos)
Set the starting offset of the attribute value.
-
-
-
Constructor Detail
-
PropertyTextUnitPlaceholder
public PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value)
Constructor forProperty
only. All offsets are the same, useful for creating placeholders for read-onlyProperty
s- Parameters:
accessType
- aPropertyTextUnitPlaceholder.PlaceholderAccessType
name
- attribute namevalue
- attribute value
-
PropertyTextUnitPlaceholder
public PropertyTextUnitPlaceholder(PropertyTextUnitPlaceholder.PlaceholderAccessType accessType, String name, String value, int valueStartPos, int valueEndPos)
Constructor forProperty
andITextUnit
without a main offsets. This is useful for cases where values are not delimited by any formatting- Parameters:
accessType
- aPropertyTextUnitPlaceholder.PlaceholderAccessType
name
- 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 forProperty
andITextUnit
that 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.PlaceholderAccessType
name
- 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 twoPropertyTextUnitPlaceholder
s. Compare is based in MainStartPos order only. Allows sorting of manyPropertyTextUnitPlaceholder
s in the order they appear in the input- Specified by:
compareTo
in interfaceComparable<PropertyTextUnitPlaceholder>
- Parameters:
aThat
- thePropertyTextUnitPlaceholder
used 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:
equals
in classObject
- Parameters:
aThat
- thePropertyTextUnitPlaceholder
that is compared to this object
-
-