You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Dominic Tubach (JIRA)" <ji...@apache.org> on 2012/08/06 12:32:02 UTC

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

Dominic Tubach created PDFBOX-1383:
--------------------------------------

             Summary: Proposal for a new COSArrayList
                 Key: PDFBOX-1383
                 URL: https://issues.apache.org/jira/browse/PDFBOX-1383
             Project: PDFBox
          Issue Type: Improvement
          Components: PDModel
            Reporter: Dominic Tubach
            Priority: Minor


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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Posted by "Dominic Tubach (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1383?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dominic Tubach updated PDFBOX-1383:
-----------------------------------

    Attachment: DefaultDTCOSBaseConverterTest.java
                DTCOSArrayListTest.java
                DefaultDTCOSBaseConverter.java
                DTCOSBaseConverter.java
                DTCOSArrayList.java
    
> Proposal for a new COSArrayList
> -------------------------------
>
>                 Key: PDFBOX-1383
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1383
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel
>            Reporter: Dominic Tubach
>            Priority: Minor
>         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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira