[ 
https://issues.apache.org/jira/browse/PDFBOX-1383?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

John Hewson updated PDFBOX-1383:
--------------------------------
    Priority: Major  (was: Minor)

> 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
>             Fix For: 2.0.0
>
>         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)

Reply via email to