[
https://issues.apache.org/jira/browse/PDFBOX-1383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14308844#comment-14308844
]
Dominic Tubach commented on PDFBOX-1383:
----------------------------------------
COSArrayList<COSInteger> would be a subclass of COSArrayList<? extends
COSBase>. The extends notation would be required in setter methods and what is
COSBase here would be the most concrete type possible (that would be the one
used in the corresponding getter). I'm not sure if there's something that
should be possible, but isn't when done in that way.
> Proposal for a new COSArrayList
> -------------------------------
>
> Key: PDFBOX-1383
> URL: https://issues.apache.org/jira/browse/PDFBOX-1383
> Project: PDFBox
> Issue Type: Improvement
> Components: PDModel
> Affects Versions: 1.8.7, 2.0.0
> Reporter: Dominic Tubach
> Attachments: DTCOSArrayList.java, DTCOSArrayListTest.java,
> DTCOSBaseConverter.java, DefaultDTCOSBaseConverter.java,
> DefaultDTCOSBaseConverterTest.java
>
>
> Attached is a proposal for a new COSArrayList.
> Main differences to the existing COSArrayList:
> - type safety through generics.
> - it's always clear which types of objects the array holds.
> - flexible loading of objects from a dictionary through COSBaseConverter (see
> below).
> - correct updating of dictionary entry, no matter whether it is optional, a
> single value is allowed, or it is required.
> - listener interface.
> However there are some drawbacks:
> - it allows only classes/interfaces that implement/extend COSObjectable.
> -> DualCOSObjectables are not possible. (Would require an extra class.)
> -> no Java types such as String or Float (I see this as advantage as I was a
> bit confused when I expected an Array with COSNames, but got Strings. By the
> way adding a String in that case would not add a COSName as one might expect,
> but a COSString.)
> - replacing the existing COSArrayList would require changes in existing code.
> - requires (as of now) Java 1.6 (It might be enough to remove the @Override
> annotations for Java 1.5 compatibility.)
> Now to the COSBaseConverter. The COSBaseConverter is just an interface that
> defines a conversion method to convert a COSBase object to a class that
> implements COSObjectable.
> The default implementation tries to find a fitting constructor to instantiate
> the object.
> If the destination class is an Enum it tries to find a fitting static valueOf
> method to create the object.
> (To avoid a conflict with the existing COSArrayList i prefixed everything
> with my initials.)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]