You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2015/02/03 23:14:37 UTC

[jira] [Commented] (PDFBOX-1383) Proposal for a new COSArrayList

    [ https://issues.apache.org/jira/browse/PDFBOX-1383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14304127#comment-14304127 ] 

Tilman Hausherr commented on PDFBOX-1383:
-----------------------------------------

But IMHO the real problem is elsewhere. COSArrays sometimes have different types in one array, so I don't see that we can use generics. From my experience, patches are accepted if there are "perfect", either solve a specific problem, or if there is a "hey we needed just that" effect on one of us.

> 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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org