[
https://issues.apache.org/jira/browse/PDFBOX-2459?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14544780#comment-14544780
]
John Hewson edited comment on PDFBOX-2459 at 5/15/15 2:06 AM:
--------------------------------------------------------------
Alright, the next task is to make the Kids of PDField type safe. The kids of a
non-terminal field are always fields, while the kids of a terminal field are
always widgets. Currently getKids() is implemented on PDField and returns
COSObjectable, then relies on the callee to cast it to PDField or
PDAnnotationWidget as appropriate. This is very brittle, and I've found
numerous bugs in the PDFBox source code due to incorrect assumptions about what
getKids() returns in different contexts (that's understandable as there's zero
type safety).
To introduce type safety we can split List<COSObjectable> getKids() into two
methods, List<PDField> getChildren() and List<PDAnnotationWidget> getWidgets()
in PDNonTerminalField and PDTerminalField, respectively. By distinguishing the
different children of terminal and non-terminal fields in the type system, we
ensure that the kinds of mistakes currently seen in the source code will no
longer be possible. Of course, this means I get to fix the mistakes too. Lucky
me.
was (Author: jahewson):
Alright, the next task is to make the Kids of PDField type safe. The kids of a
non-terminal field are always fields, while the kids of a terminal field are
always widgets. Currently getKids() is implemented on PDField and returns
COSObjectable, then relies on the callee to cast it to PDField or
PDAnnotationWidget as appropriate. This is very brittle, and I've found
numerous bugs in the PDFBox source code due to incorrect assumptions about what
getKids() returns in different contexts (that's understandable as there's zero
type safety).
To introduce type safety we can split List<COSObjectable> getKids() into two
methods, List<PDField> getChildren() and List<PDAnnotationWidget> getWidgets()
in PDNonTerminalField and PDTerminalField, respectively. By distinguishing the
different children of terminal and non-terminal fields in the type system, we
ensure that the kinds of mistakes currently seen in the source code will no
longer be possible. Of course, this means I'll have to fix the mistakes too.
Lucky me.
> Share functionality between Page Tree and Field Tree
> ----------------------------------------------------
>
> Key: PDFBOX-2459
> URL: https://issues.apache.org/jira/browse/PDFBOX-2459
> Project: PDFBox
> Issue Type: Improvement
> Components: PDModel
> Affects Versions: 2.0.0
> Reporter: Maruan Sahyoun
> Assignee: John Hewson
> Priority: Minor
> Fix For: 2.0.0
>
>
> The PDFs page tree and AcroForms field tree share some common functionality
> e.g. resolving inheritable attributes, iterating through leafs and such which
> could be combined into a PDTree class.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]