|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.okapi.common.resource.Code
public class Code
Represents an abstracted in-line code used in a TextFragment object.
For example, a <b> tag in an HTML paragraph.
| Field Summary | |
|---|---|
protected java.util.LinkedHashMap<java.lang.String,InlineAnnotation> |
annotations
Annotations for this code. |
protected static int |
CLONEABLE
Indicates that this code can be duplicated in the text. |
protected java.lang.StringBuilder |
data
Native data for this code. |
protected static int |
DELETEABLE
Indicates that this code can be removed from the text. |
protected int |
flag
Flag for this code. |
protected static int |
HASREF
Indicates that this code has one reference or more in its data part. |
protected int |
id
Id for this code. |
protected java.lang.StringBuilder |
outerData
Outer data. |
protected TextFragment.TagType |
tagType
Tag type for this code. |
protected java.lang.String |
type
Type of the code. |
static java.lang.String |
TYPE_BOLD
Code type value for bold. |
static java.lang.String |
TYPE_COMMENT
Code type value for comment. |
static java.lang.String |
TYPE_IMAGE
Code type value for image. |
static java.lang.String |
TYPE_ITALIC
Code type value for italic. |
static java.lang.String |
TYPE_LB
Code type value for line-break. |
static java.lang.String |
TYPE_LINK
Code type value for link. |
static java.lang.String |
TYPE_REFERENCE
Code type value for reference. |
static java.lang.String |
TYPE_UNDERLINED
Code type value for underline. |
static java.lang.String |
TYPE_XML_PROCESSING_INSTRUCTION
Code type value for processing instruction. |
| Constructor Summary | |
|---|---|
Code(java.lang.String type)
Creates a new code with a null type, and empty data. |
|
Code(TextFragment.TagType tagType,
java.lang.String type)
Creates a new code with empty data. |
|
Code(TextFragment.TagType tagType,
java.lang.String type,
java.lang.String data)
Creates a new code. |
|
| Method Summary | |
|---|---|
void |
append(java.lang.String data)
Appends data to the current code data |
void |
appendOuterData(java.lang.String outerData)
Appends data to the current code outerData |
void |
appendReference(java.lang.String id)
Appends a reference marker to the current code data. |
void |
appendReference(java.lang.String id,
java.lang.String propertyName)
Appends a reference marker for a given property to the current code data. |
Code |
clone()
Clone the code. |
static java.lang.String |
codesToString(java.util.List<Code> list)
Helper method to convert a list of codes into a string. |
static java.lang.String |
codesToString(java.util.List<Code> list,
boolean stripOuterData)
Helper method to convert a list of codes into a string. |
InlineAnnotation |
getAnnotation(java.lang.String type)
Gets the annotation of a given type. |
java.lang.String |
getData()
Gets the raw data for the code. |
int |
getId()
Gets the identifier of the code. |
static int |
getIndex(java.util.List<Code> codes,
boolean forClosing,
int id)
Gets the index in a list of codes for the id of a given code. |
java.lang.String |
getOuterData()
Gets the outer data for this in-line code. |
TextFragment.TagType |
getTagType()
Gets the tag type of the code. |
java.lang.String |
getType()
Gets the abstract type for the code. |
boolean |
hasAnnotation()
Indicates if this code has any type of annotation. |
boolean |
hasAnnotation(java.lang.String type)
Indicates if this code has a given type of annotation. |
boolean |
hasData()
Indicates if this code has data (i.e. |
boolean |
hasOuterData()
Indicates if this code has outer data (i.e. |
boolean |
hasReference()
Indicates whether the code has at least one sub-flow part. |
boolean |
isCloneable()
Indicates if this in-line code can be duplicated in the text. |
boolean |
isDeleteable()
Indicates if this in-line code can be removed from the text. |
void |
removeAnnotation(java.lang.String type)
Removes the annotation of a given type in this code. |
void |
removeAnnotations()
Removes all annotations from this code. |
static boolean |
sameCodes(java.util.List<Code> codes1,
java.util.List<Code> codes2)
Indicates if two codes-storing strings have the same codes or not. |
void |
setAnnotation(java.lang.String type,
InlineAnnotation annotation)
Sets the annotation for this code. |
void |
setCloneable(boolean value)
Sets the flag of this in-line code to indicate if it can be duplicated or not. |
void |
setData(java.lang.String value)
Sets the raw data for the code. |
void |
setDeleteable(boolean value)
Sets the flag of this in-line code to indicate if it can be removed or not. |
void |
setId(int value)
Sets the identifier of the code. |
void |
setOuterData(java.lang.String value)
Sets the complete data for this in-line code (inner data and outer). |
void |
setReferenceFlag(boolean value)
Sets the flag that indicates if this code has a reference (sub-flow) or not. |
void |
setTagType(TextFragment.TagType value)
Sets the tag type for the code. |
void |
setType(java.lang.String value)
Sets the abstract type of the code. |
static java.util.List<Code> |
stringToCodes(java.lang.String data)
Helper method to convert a storage string into a list of codes. |
java.lang.String |
toString()
Gets the string representation of this code: its data. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String TYPE_BOLD
public static final java.lang.String TYPE_ITALIC
public static final java.lang.String TYPE_UNDERLINED
public static final java.lang.String TYPE_LB
public static final java.lang.String TYPE_LINK
public static final java.lang.String TYPE_IMAGE
public static final java.lang.String TYPE_COMMENT
public static final java.lang.String TYPE_XML_PROCESSING_INSTRUCTION
public static final java.lang.String TYPE_REFERENCE
protected static final int HASREF
protected static final int CLONEABLE
protected static final int DELETEABLE
protected TextFragment.TagType tagType
protected int id
protected java.lang.String type
protected java.lang.StringBuilder data
protected java.lang.StringBuilder outerData
protected int flag
protected java.util.LinkedHashMap<java.lang.String,InlineAnnotation> annotations
| Constructor Detail |
|---|
public Code(TextFragment.TagType tagType,
java.lang.String type,
java.lang.String data)
tagType - the tag type.type - the type of code (e.g. the name of the tag). The type must be
exactly the same between the opening and closing codes.data - the content of the code.
public Code(TextFragment.TagType tagType,
java.lang.String type)
tagType - the tag type.type - the type of code (e.g. the name of the tag).public Code(java.lang.String type)
type - the type of code (e.g. the name of the tag).| Method Detail |
|---|
public static java.lang.String codesToString(java.util.List<Code> list)
list - the list of the codes to flatten into a string.
codesToString(List, boolean),
stringToCodes(String)
public static java.lang.String codesToString(java.util.List<Code> list,
boolean stripOuterData)
list - the list of the codes to flatten into a string.stripOuterData - true to remove the outerData in the storage string, false to keep it.
codesToString(List),
stringToCodes(String)
public static boolean sameCodes(java.util.List<Code> codes1,
java.util.List<Code> codes2)
codes1 - the first codes-storing string.codes2 - the second codes-storing string.
public static int getIndex(java.util.List<Code> codes,
boolean forClosing,
int id)
codes - the list of codes to lookup.forClosing - true to get the index of the closing code.id - the id to search for.
public static java.util.List<Code> stringToCodes(java.lang.String data)
data - the storage string to convert (can be null).
codesToString(List),
codesToString(List, boolean)public void append(java.lang.String data)
data - the data to append.public void appendOuterData(java.lang.String outerData)
outerData - the outer data to append.public void appendReference(java.lang.String id)
id - the identifier of the referent resource.
public void appendReference(java.lang.String id,
java.lang.String propertyName)
id - the identifier of the referent resource where the property is located.propertyName - the name of the property.public java.lang.String toString()
toString in class java.lang.Objectpublic boolean hasAnnotation()
public boolean hasAnnotation(java.lang.String type)
public boolean hasData()
public boolean hasOuterData()
public Code clone()
isCloneable() to check.
clone in class java.lang.Objectpublic TextFragment.TagType getTagType()
public void setTagType(TextFragment.TagType value)
value - the new tag type to apply. The value must be one of the
values of TextFragment.TagType.public java.lang.String getType()
public void setType(java.lang.String value)
value - the new abstract type of the code. Null is mapped to "null".public java.lang.String getData()
public void setData(java.lang.String value)
value - the new raw data of the code.public int getId()
public void setId(int value)
TextFragment and overriding the
values may result in codes with duplicate IDs.
value - the new identifier value to be applied.public boolean hasReference()
public void setReferenceFlag(boolean value)
value - the new value to apply.public void setOuterData(java.lang.String value)
value - the data to set (can be null).public java.lang.String getOuterData()
getData()).
Use hasOuterData() to know if there is true outer data.
public boolean isCloneable()
%s should not.
public void setCloneable(boolean value)
value - true to allow duplication, false to forbid it.public boolean isDeleteable()
%s should not.
public void setDeleteable(boolean value)
value - true to allow deletion, false to forbid it.
public void setAnnotation(java.lang.String type,
InlineAnnotation annotation)
type - type of the annotation to set.annotation - the annotation to set. This parameter can be null for example
when the annotation is used like a boolean flag.public InlineAnnotation getAnnotation(java.lang.String type)
type - the type of annotation to retrieve.
public void removeAnnotations()
public void removeAnnotation(java.lang.String type)
type - the type of annotation to remove.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||