public class GenericAnnotation extends InlineAnnotation
CLASSNAME_SEPARATOR, data| Constructor and Description |
|---|
GenericAnnotation() |
GenericAnnotation(String type)
Creates a new annotation for a given type.
|
GenericAnnotation(String type,
Object... list)
Creates a new annotation for a given type.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addAnnotation(Code code,
GenericAnnotation ann)
Adds an annotation to an inline code.
|
static void |
addAnnotation(ITextUnit tu,
GenericAnnotation ann)
Adds an annotation to a text unit.
|
static void |
addAnnotation(TextContainer tc,
GenericAnnotation ann)
Adds an annotation to a text container.
|
GenericAnnotation |
clone()
Clones this annotation.
|
static GenericAnnotation |
createFromString(String storage)
Creates a new GenericAnnotation object from a storage string.
|
void |
fromString(String storage)
Initializes this annotation from a storage string originally obtained
from
InlineAnnotation.toString(). |
Boolean |
getBoolean(String name) |
Double |
getDouble(String name) |
int |
getFieldCount() |
Integer |
getInteger(String name) |
Set<String> |
getNames() |
String |
getString(String name)
Gets the string value for a given field.
|
String |
getType()
Gets the type of annotation.
|
void |
remove(String name) |
void |
setBoolean(String name,
Boolean value)
sets a boolean field.
|
void |
setDouble(String name,
Double value) |
void |
setFields(Object... list)
Sets a list of key+values pairs for this annotation.
|
void |
setInteger(String name,
Integer value) |
void |
setString(String name,
String value)
Sets a string field.
|
String |
toString()
Gets a storage string representation of the whole annotation that can
be used for serialization.
|
getData, setDatapublic GenericAnnotation()
public GenericAnnotation(String type)
Note that it is technically to have two annotations with the same type but different fields. This is a side effect of the capability to access the annotation in a generic way. The user is responsible for keeping consistent types of annotations.
type - the identifier of the type (cannot be null or empty).public GenericAnnotation(String type, Object... list)
setFields(Object...) method after
creating the annotation.type - the identifier of the type (cannot be null or empty).list - the list of key+value pairs to set.public static GenericAnnotation createFromString(String storage)
storage - the serialized representation of the object.public static void addAnnotation(ITextUnit tu, GenericAnnotation ann)
tu - the text unit where to attach the annotation.ann - the annotation to attach (if null, nothing is attached).public static void addAnnotation(TextContainer tc, GenericAnnotation ann)
tc - the text container where to attach the annotation.ann - the annotation to attach (if null, nothing is attached).public static void addAnnotation(Code code, GenericAnnotation ann)
code - the code where to add the annotation.ann - the annotation to add (if null, nothing is attached).public void setFields(Object... list)
list - the list of key+value pairs to set.public GenericAnnotation clone()
InlineAnnotationclone in interface IPersistentAnnotationclone in class InlineAnnotationpublic String getType()
public String getString(String name)
name - the name of the field.public void setString(String name, String value)
name - the name of the field to set.value - the value to set, use null to remove the field.public void setBoolean(String name, Boolean value)
name - the name of the field to set.value - the value to set, use null to remove the field.public String toString()
InlineAnnotationtoString in interface IAnnotationtoString in class InlineAnnotationpublic void fromString(String storage)
InlineAnnotationInlineAnnotation.toString().fromString in interface IPersistentAnnotationfromString in class InlineAnnotationstorage - The storage string to use for the initialization.public int getFieldCount()
public void remove(String name)
Copyright © 2022. All rights reserved.