public class Code extends Object implements IWithProperties, Cloneable
<b> tag in an HTML paragraph.| Modifier and Type | Field and Description |
|---|---|
static int |
ADDED
Indicates that this code was added to the text post-extraction.
|
static int |
CLONEABLE
Indicates that this code can be duplicated in the text.
|
protected StringBuilder |
data
Native data for this code.
|
static int |
DELETEABLE
Indicates that this code can be removed from the text.
|
protected String |
displayText
Display text that is displayed as hint to the end user.
|
static String |
EXTENDED_CODE_TYPE_DELIMITER
An extended code type delimiter.
|
static String |
EXTENDED_CODE_TYPE_PREFIX
An extended code type prefix.
|
static String |
EXTENDED_CODE_TYPE_VALUE_DELIMITER
An extended code type value delimiter.
|
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 LinkedHashMap<String,InlineAnnotation> |
inlineAnnotations
InlineAnnotations for this code.
|
static int |
MARKER_MASKING
Indicates that this code was merged with another code.
|
static int |
MERGED
Indicates that this code was merged with another code.
|
protected String |
mergedData
serialized data for this merged code.
|
protected String |
originalId
Original id for this code.
|
protected StringBuilder |
outerData
Outer data.
|
static String |
PROPERTIES |
static String |
SEP_CODE |
static String |
SEP_CODEANNOTATIONKEY |
static String |
SEP_CODEANNOTATIONVALUE |
static String |
SEP_CODEFIELD |
protected TextFragment.TagType |
tagType
Tag type for this code.
|
protected String |
type
Type of the code.
|
static String |
TYPE_ANNOTATION_ONLY
Special type value indicating the code/marker is only there to hold an annotation.
|
static String |
TYPE_BOLD
Code type value for bold.
|
static String |
TYPE_CDATA
Code type value for CDATA.
|
static String |
TYPE_COMMENT
Code type value for comment.
|
static String |
TYPE_IMAGE
Code type value for image.
|
static String |
TYPE_ITALIC
Code type value for italic.
|
static String |
TYPE_LB
Code type value for line-break.
|
static String |
TYPE_LINK
Code type value for link.
|
static String |
TYPE_NULL
Code type value for null type, to prevent it from ever being truly null.
|
static String |
TYPE_OKAPI_MARKER
Special type value indicating the code/marker is masking an Okapi marker
|
static String |
TYPE_REFERENCE
Code type value for reference.
|
static String |
TYPE_UNDERLINED
Code type value for underline.
|
static String |
TYPE_XML_PROCESSING_INSTRUCTION
Code type value for processing instruction.
|
| Constructor and Description |
|---|
Code() |
Code(String type)
Creates a new code with a null tag type and empty data.
|
Code(TextFragment.TagType tagType,
String type)
Creates a new code with empty data.
|
Code(TextFragment.TagType tagType,
String type,
String data)
Creates a new code.
|
| Modifier and Type | Method and Description |
|---|---|
void |
append(String data)
Appends data to the current code data
|
void |
appendOuterData(String outerData)
Appends data to the current code outerData
|
void |
appendReference(String id)
Appends a reference marker to the current code data.
|
void |
appendReference(String id,
String propertyName)
Appends a reference marker for a given property to the current code data.
|
Code |
clone()
Clone the code.
|
static String |
codesToString(List<Code> list)
Helper method to convert a list of codes into a string.
|
static String |
codesToString(List<Code> list,
boolean stripOuterData)
Helper method to convert a list of codes into a string.
|
InlineAnnotation |
getAnnotation(String type)
Gets the annotation of a given type.
|
Set<String> |
getAnnotationsTypes()
Gets all the types of annotations for this code.
|
String |
getData()
Gets the raw data for the code.
|
String |
getDisplayText()
Get the display equivalent text for this code.
|
int |
getFlag() |
GenericAnnotations |
getGenericAnnotations()
Gets the generic annotation set assigned to the code if any.
|
String |
getGenericAnnotationString(String type,
String fieldName)
Gets the value of a string field for the first generic annotation of a given type
in the annotation set associated with this code.
|
int |
getId()
Id for this code.*
|
static int |
getIndex(List<Code> codes,
boolean forClosing,
int id)
Gets the index in a list of codes for the id of a given code.
|
String |
getMergedData() |
String |
getOriginalId()
The original id is from the filtered format
|
String |
getOuterData()
Gets the outer data for this in-line code.
|
Map<String,Property> |
getProperties() |
Property |
getProperty(String name)
Gets the resource-level property for a given name.
|
Set<String> |
getPropertyNames()
Gets the names of all the resource-level properties for this resource.
|
TextFragment.TagType |
getTagType()
Gets the tag type of the code.
|
String |
getType()
Gets the abstract type for the code.
|
boolean |
hasAnnotation()
Indicates if this code has any type of annotation.
|
boolean |
hasAnnotation(String type)
Indicates if this code has a given type of annotation.
|
boolean |
hasData()
Indicates if this code has data (i.e.
|
boolean |
hasOnlyAnnotation()
Indicates if the code is only a marker for an annotation.
|
boolean |
hasOriginalId()
Indicates if this code has an original id (non-numeric string)
|
boolean |
hasOuterData()
Indicates if this code has outer data (i.e.
|
boolean |
hasProperty(String name)
Indicates if a resource-level property exists for a given name.
|
boolean |
hasReference()
Indicates whether the code has at least one sub-flow part.
|
boolean |
isAdded()
Indicates if this in-line code was added to the text (not found in the source).
|
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.
|
boolean |
isMarkerMasking()
Indicates if this in-line code is masking an Okapi marker.
|
boolean |
isMerged()
Indicates if this in-line code was merged with another code.
|
void |
removeAnnotation(String type)
Removes the annotation of a given type in this code.
|
void |
removeAnnotations()
Removes all annotations from this code.
|
void |
removeProperty(String name)
Removes a resource-level property of a given name.
|
static boolean |
sameCodes(List<Code> codes1,
List<Code> codes2)
Indicates if two codes-storing strings have the same codes or not.
|
void |
setAdded(boolean value)
Sets the flag of this in-line code to indicate if the code was added (not found in the source).
|
void |
setAnnotation(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(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 |
setDisplayText(String text)
Set the display equivalent text for this code.
|
void |
setFlag(int flag) |
void |
setId(int index)
Sets the identifier of the code.
|
void |
setMarkerMasking(boolean value)
Sets the flag of this in-line code to indicate if the code is masking an Okapi marker.
|
void |
setMerged(boolean value)
Sets the flag of this in-line code to indicate if the code was merged.
|
void |
setMergedData(String mergedData) |
void |
setOriginalId(String originalId)
The original id is from the filtered format
|
void |
setOuterData(String value)
Sets the complete data for this in-line code (inner data and outer).
|
Property |
setProperty(Property property)
Sets a resource-level property.
|
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(String value)
Sets the abstract type of the code.
|
static List<Code> |
stringToCodes(String data)
Helper method to convert a storage string into a list of codes.
|
String |
toString()
Gets the string representation of this code: its data.
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcopy, propertyIteratorpublic static final String TYPE_NULL
public static final String TYPE_BOLD
public static final String TYPE_ITALIC
public static final String TYPE_UNDERLINED
public static final String TYPE_LB
public static final String TYPE_LINK
public static final String TYPE_IMAGE
public static final String TYPE_COMMENT
public static final String TYPE_CDATA
public static final String TYPE_XML_PROCESSING_INSTRUCTION
public static final String TYPE_REFERENCE
public static final String TYPE_ANNOTATION_ONLY
public static final String TYPE_OKAPI_MARKER
public static final String EXTENDED_CODE_TYPE_PREFIX
public static final String EXTENDED_CODE_TYPE_DELIMITER
public static final String EXTENDED_CODE_TYPE_VALUE_DELIMITER
protected static final int HASREF
public static final int CLONEABLE
public static final int DELETEABLE
public static final int ADDED
public static final int MERGED
public static final int MARKER_MASKING
public static final String SEP_CODEFIELD
public static final String SEP_CODE
public static final String SEP_CODEANNOTATIONKEY
public static final String SEP_CODEANNOTATIONVALUE
public static final String PROPERTIES
protected TextFragment.TagType tagType
protected String originalId
protected int id
protected String type
TYPE_NULLprotected StringBuilder data
protected String mergedData
protected StringBuilder outerData
protected String displayText
protected int flag
protected LinkedHashMap<String,InlineAnnotation> inlineAnnotations
public Code()
public Code(TextFragment.TagType tagType, String type, 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, String type)
tagType - the tag type.type - the type of code (e.g. the name of the tag).public Code(String type)
type - the type of code (e.g. the name of the tag).public static String codesToString(List<Code> list)
list - the list of the codes to flatten into a string.codesToString(List, boolean),
stringToCodes(String)public static String codesToString(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(List<Code> codes1, List<Code> codes2)
codes1 - the first codes-storing string.codes2 - the second codes-storing string.public static int getIndex(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 List<Code> stringToCodes(String data)
data - the storage string to convert (can be null).codesToString(List),
codesToString(List, boolean)public void append(String data)
data - the data to append.public void appendOuterData(String outerData)
outerData - the outer data to append.public void appendReference(String id)
id - the identifier of the referent resource.public void appendReference(String id, String propertyName)
id - the identifier of the referent resource where the property is located.propertyName - the name of the property.public String toString()
public boolean hasAnnotation()
public boolean hasAnnotation(String type)
type - the type of annotation.public boolean hasOnlyAnnotation()
public boolean hasData()
public boolean hasOriginalId()
public boolean hasOuterData()
public Code clone()
isCloneable() to check.public 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 String getType()
TYPE_NULL if not otherwise set).public void setType(String value)
value - the new abstract type of the code. Null is mapped to TYPE_NULL.public String getData()
public void setData(String value)
value - the new raw data of the code.public String getMergedData()
public void setMergedData(String mergedData)
public int getId()
public void setId(int index)
TextFragment and overriding
the values may result in codes with duplicate IDs.index - the new index to be applied.public String getOriginalId()
public void setOriginalId(String originalId)
public boolean hasReference()
public void setReferenceFlag(boolean value)
value - the new value to apply.public void setOuterData(String value)
value - the data to set (can be null).public 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 boolean isAdded()
public void setAdded(boolean value)
value - true to allow adding, false to forbid it.public boolean isMerged()
public void setMerged(boolean value)
value - true if merged, false otherwise.public boolean isMarkerMasking()
public void setMarkerMasking(boolean value)
value - true if masking an Okapi marker, false otherwise.public void setAnnotation(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(String type)
type - the type of annotation to retrieve.public Set<String> getAnnotationsTypes()
public void removeAnnotations()
public void removeAnnotation(String type)
type - the type of annotation to remove.public GenericAnnotations getGenericAnnotations()
public String getGenericAnnotationString(String type, String fieldName)
type - the type of generic annotation to lookupfieldName - the name of the field to retrieve.public void setDisplayText(String text)
text - The display text for this codepublic String getDisplayText()
public int getFlag()
public void setFlag(int flag)
public Property getProperty(String name)
IWithPropertiesgetProperty in interface IWithPropertiesname - Name of the property to retrieve.public boolean hasProperty(String name)
IWithPropertieshasProperty in interface IWithPropertiesname - The name of the resource-level property to query.public void removeProperty(String name)
IWithPropertiesremoveProperty in interface IWithPropertiesname - The name of the property to remove.public Property setProperty(Property property)
IWithPropertiessetProperty in interface IWithPropertiesproperty - The new property to set.public Map<String,Property> getProperties()
getProperties in interface IWithPropertiesMap of properties for the implementer of interfacepublic Set<String> getPropertyNames()
IWithPropertiesgetPropertyNames in interface IWithPropertiesCopyright © 2021. All rights reserved.