Package com.pd4ml.pdf.xfdf
Class XfdfAnnotation
- java.lang.Object
-
- com.pd4ml.pdf.xfdf.XfdfAnnotation
-
public final class XfdfAnnotation extends java.lang.ObjectOne<annots>entry (or a nested<popup>) -- a plain, generic bag of the XFDF attributes and child elements defined across every markup annotation type in ISO 19444-1 §6.4, rather than a separate Java class per PDF annotation subtype. The handful of type-specific pieces of data that don't fit a flat string attribute (vertices, ink gestures, quad points, and the nested popup) get their own typed fields; everything else -- including attributes only some types use -- lives ingetAttributes().getType()is the lower-case XFDF element name (e.g."square","freetext","popup") that bothXfdfReader/XfdfWriterandinternal.AnnotationMapperkey their dispatch on.
-
-
Constructor Summary
Constructors Constructor Description XfdfAnnotation(java.lang.String type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGesture(float[] points)Appends one<gesture>stroke (a flat[x1, y1, x2, y2, ...]point list) to the ink list, creating it if this is the first.static java.lang.StringformatFloat(float value)Trims a clean integer-valued float down to"100"rather than"100.0", matching real producers' output.static java.lang.StringformatFloatList(float[] values, java.lang.String separator)The inverse ofparseFloatList(String, int): joinsvalueswithseparator, or returnsnullifvaluesisnull.java.lang.StringgetAttribute(java.lang.String name)The raw string value of attributename, ornullif this annotation doesn't carry it.java.util.Map<java.lang.String,java.lang.String>getAttributes()Every XFDF attribute this annotation carries (raw attribute name, e.g.java.lang.StringgetContents()Plain-text<contents>body, ornull.java.lang.StringgetContentsRichText()Raw inner XML of<contents-richtext>(the/RCrich text string), ornull.java.lang.StringgetDefaultAppearance()Raw<defaultappearance>text (the/DAstring), ornull.java.util.List<float[]>getInkList()Ink<inklist>: one flat[x1, y1, x2, y2, ...]array per<gesture>stroke, ornull.java.lang.StringgetName()Thenameattribute -- the annotation's PDF/NMunique identifier.intgetPage()Zero-based page index (thepageattribute), or -1 if absent/unparseable.XfdfAnnotationgetPopup()The nested<popup>child, if this annotation has its own popup window, ornull.float[]getQuadPoints()Highlight/Underline/Squiggly/StrikeOut/Redact/Link quad points, flat 8-per-quad, ornull.float[]getRect()Therectattribute as[llx, lly, urx, ury], ornullif absent/unparseable.java.lang.StringgetType()The lower-case XFDF element name, e.g.float[]getVertices()Polygon/Polyline<vertices>as a flat[x1, y1, x2, y2, ...]array, ornull.static float[]parseFloatList(java.lang.String csv, int expectedLength)Parses a comma-separated list of floats (the shape ofrect,coords,start/end,fringe,callout, ...) into an array, or returnsnullif it's blank, malformed, or (whenexpectedLength > 0) not exactly that many values.voidsetAttribute(java.lang.String name, java.lang.String value)Sets (or, with anullvalue, removes) one raw XFDF attribute directly -- what the typed setters below all funnel through.voidsetContents(java.lang.String contents)Sets the plain-text<contents>body -- seegetContents().voidsetContentsRichText(java.lang.String contentsRichText)Sets the raw<contents-richtext>inner XML -- seegetContentsRichText().voidsetDefaultAppearance(java.lang.String defaultAppearance)Sets the raw<defaultappearance>text -- seegetDefaultAppearance().voidsetInkList(java.util.List<float[]> inkList)Replaces the whole ink gesture list -- seegetInkList(); preferaddGesture(float[])to append one stroke at a time.voidsetName(java.lang.String name)Sets thenameattribute -- seegetName().voidsetPage(int page)Sets the zero-basedpageattribute -- seegetPage().voidsetPopup(XfdfAnnotation popup)Sets the nested<popup>child -- seegetPopup().voidsetQuadPoints(float[] quadPoints)Sets the quad points list -- seegetQuadPoints().voidsetRect(float[] rect)voidsetVertices(float[] vertices)Sets the Polygon/Polyline vertex list -- seegetVertices().java.lang.StringtoString()
-
-
-
Method Detail
-
getType
public java.lang.String getType()
The lower-case XFDF element name, e.g."square","freetext","popup".
-
getAttributes
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
Every XFDF attribute this annotation carries (raw attribute name, e.g."interior-color", to its raw string value).
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
The raw string value of attributename, ornullif this annotation doesn't carry it.
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.String value)Sets (or, with anullvalue, removes) one raw XFDF attribute directly -- what the typed setters below all funnel through.
-
getName
public java.lang.String getName()
Thenameattribute -- the annotation's PDF/NMunique identifier.
-
setName
public void setName(java.lang.String name)
Sets thenameattribute -- seegetName().
-
getPage
public int getPage()
Zero-based page index (thepageattribute), or -1 if absent/unparseable.
-
setPage
public void setPage(int page)
Sets the zero-basedpageattribute -- seegetPage().
-
getRect
public float[] getRect()
Therectattribute as[llx, lly, urx, ury], ornullif absent/unparseable.
-
setRect
public void setRect(float[] rect)
-
getContents
public java.lang.String getContents()
Plain-text<contents>body, ornull.
-
setContents
public void setContents(java.lang.String contents)
Sets the plain-text<contents>body -- seegetContents().
-
getContentsRichText
public java.lang.String getContentsRichText()
Raw inner XML of<contents-richtext>(the/RCrich text string), ornull.
-
setContentsRichText
public void setContentsRichText(java.lang.String contentsRichText)
Sets the raw<contents-richtext>inner XML -- seegetContentsRichText().
-
getDefaultAppearance
public java.lang.String getDefaultAppearance()
Raw<defaultappearance>text (the/DAstring), ornull.
-
setDefaultAppearance
public void setDefaultAppearance(java.lang.String defaultAppearance)
Sets the raw<defaultappearance>text -- seegetDefaultAppearance().
-
getVertices
public float[] getVertices()
Polygon/Polyline<vertices>as a flat[x1, y1, x2, y2, ...]array, ornull.
-
setVertices
public void setVertices(float[] vertices)
Sets the Polygon/Polyline vertex list -- seegetVertices().
-
getQuadPoints
public float[] getQuadPoints()
Highlight/Underline/Squiggly/StrikeOut/Redact/Link quad points, flat 8-per-quad, ornull.
-
setQuadPoints
public void setQuadPoints(float[] quadPoints)
Sets the quad points list -- seegetQuadPoints().
-
getInkList
public java.util.List<float[]> getInkList()
Ink<inklist>: one flat[x1, y1, x2, y2, ...]array per<gesture>stroke, ornull.
-
setInkList
public void setInkList(java.util.List<float[]> inkList)
Replaces the whole ink gesture list -- seegetInkList(); preferaddGesture(float[])to append one stroke at a time.
-
addGesture
public void addGesture(float[] points)
Appends one<gesture>stroke (a flat[x1, y1, x2, y2, ...]point list) to the ink list, creating it if this is the first.
-
getPopup
public XfdfAnnotation getPopup()
The nested<popup>child, if this annotation has its own popup window, ornull.
-
setPopup
public void setPopup(XfdfAnnotation popup)
Sets the nested<popup>child -- seegetPopup().
-
parseFloatList
public static float[] parseFloatList(java.lang.String csv, int expectedLength)Parses a comma-separated list of floats (the shape ofrect,coords,start/end,fringe,callout, ...) into an array, or returnsnullif it's blank, malformed, or (whenexpectedLength > 0) not exactly that many values.- Parameters:
expectedLength- the required element count, or<= 0to accept any length
-
formatFloatList
public static java.lang.String formatFloatList(float[] values, java.lang.String separator)The inverse ofparseFloatList(String, int): joinsvalueswithseparator, or returnsnullifvaluesisnull.
-
formatFloat
public static java.lang.String formatFloat(float value)
Trims a clean integer-valued float down to"100"rather than"100.0", matching real producers' output.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-