Package org.opensextant.annotations
Class Annotation
- java.lang.Object
-
- org.opensextant.annotations.DeepEyeData
-
- org.opensextant.annotations.Annotation
-
public class Annotation extends DeepEyeData
An annotation is at least a typed name/value pair created by something.Creator is called "contributor" because lots of parties can contribute annotations to this pool.
Every annotation belongs to some record (ident by rec_id)
Every annotation instance has an ID itself.Offset and attributes are optional, as some annotations apply to entire records, rather than data at a certain offset.
- Author:
- ubaldino
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.String
contrib
java.lang.String
name
long
offset
optional offsetstatic java.lang.String
OFFSETS_FLD
java.lang.String
rec_id
java.lang.String
source_id
Source ID here is very much optional Currently it is useful for SQLite usage.-
Fields inherited from class org.opensextant.annotations.DeepEyeData
attrs, id, value
-
-
Constructor Summary
Constructors Constructor Description Annotation()
Annotation(java.lang.String aid)
Annotation(java.lang.String aid, java.lang.String rid)
Annotation(java.lang.String aid, java.lang.String rid, java.lang.String ctr, java.lang.String n, java.lang.String v)
-
Method Summary
Modifier and Type Method Description void
addOffset(int x)
void
addOffsetAttribute()
add annot.offset = x or annot.attrs.offsets = "x1;x2;x3"...protected void
addOffsetTo(java.util.Map<java.lang.String,java.lang.Object> repr)
Add offset information (offset, len, offsets, etc ) into the representation of this annotation.java.lang.String
getAttribute(java.lang.String k)
long
getEndOffset()
Compute span end offset.int
getLength()
Compute length, as logic is related to defaults, if value is set or not.java.util.Map<java.lang.String,java.lang.Object>
getMap()
Generate a key-value representation of the object with its current values.java.util.Collection<java.lang.Integer>
getOffsets()
boolean
hasLength()
void
resetOffsets()
This is provided mainly for testing.void
setLength(int l)
java.lang.String
toString()
-
Methods inherited from class org.opensextant.annotations.DeepEyeData
addAttribute, asMap, getAttributeNames, getAttributes, isValue, isValue, list, list, map, newAttributes
-
-
-
-
Field Detail
-
rec_id
public java.lang.String rec_id
-
name
public java.lang.String name
-
source_id
public java.lang.String source_id
Source ID here is very much optional Currently it is useful for SQLite usage.
-
offset
public long offset
optional offset
-
contrib
public java.lang.String contrib
-
OFFSETS_FLD
public static java.lang.String OFFSETS_FLD
-
-
Constructor Detail
-
Annotation
public Annotation()
-
Annotation
public Annotation(java.lang.String aid)
-
Annotation
public Annotation(java.lang.String aid, java.lang.String rid)
-
Annotation
public Annotation(java.lang.String aid, java.lang.String rid, java.lang.String ctr, java.lang.String n, java.lang.String v)
-
-
Method Detail
-
getAttribute
public java.lang.String getAttribute(java.lang.String k)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setLength
public void setLength(int l)
-
hasLength
public boolean hasLength()
-
getLength
public int getLength()
Compute length, as logic is related to defaults, if value is set or not. etc.- Returns:
-
getEndOffset
public long getEndOffset()
Compute span end offset.- Returns:
- end offset (long)
-
addOffsetTo
protected void addOffsetTo(java.util.Map<java.lang.String,java.lang.Object> repr)
Add offset information (offset, len, offsets, etc ) into the representation of this annotation. Some annotations may have a more complex view of offset, e.g., EntityAnnotation overrides this.
-
addOffset
public void addOffset(int x)
-
getOffsets
public java.util.Collection<java.lang.Integer> getOffsets()
-
addOffsetAttribute
public void addOffsetAttribute()
add annot.offset = x or annot.attrs.offsets = "x1;x2;x3"... a string list, not a JSON obj.
-
resetOffsets
public void resetOffsets()
This is provided mainly for testing. The EntityAnnotation class is not intended for reuse e.g., populate an instance and then reset offsets alone. Use sparingly.
-
getMap
public java.util.Map<java.lang.String,java.lang.Object> getMap()
Generate a key-value representation of the object with its current values.- Specified by:
getMap
in classDeepEyeData
- Returns:
- Map
-
-