You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Jukka Zitting (JIRA)" <ji...@apache.org> on 2010/02/22 14:30:27 UTC

[jira] Commented: (PDFBOX-630) Create PDDictionaryWrapper

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

Jukka Zitting commented on PDFBOX-630:
--------------------------------------

It would be good if the patch included also the changes where a new class like this simplifies things or reduces the amount of duplicate code. The current patch simply adds more code, without actually doing anything.

> Create PDDictionaryWrapper
> --------------------------
>
>                 Key: PDFBOX-630
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-630
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel
>            Reporter: Johannes Koch
>         Attachments: PDFBox-630_patch_00.txt
>
>
> What is the benefit of having so many classes implement the getCOSDIctionary() method on their own?
> Why not have one class providing this functionality?
> public class PDDictionaryWrapper implements COSObjectable
> {
>     private final COSDictionary dictionary;
>     /**
>      * Default constructor
>      */
>     public PDDictionaryWrapper()
>     {
>         this.dictionary = new COSDictionary();
>     }
>     /**
>      *
>      * @param dictionary the dictionary
>      */
>     public PDDictionaryWrapper(COSDictionary dictionary)
>     {
>         this.dictionary = dictionary;
>     }
>     public COSBase getCOSObject()
>     {
>         return this.dictionary;
>     }
>     /**
>      * Returns the dictionary.
>      *
>      * @return the dictionary
>      */
>     protected COSDictionary getCOSDictionary()
>     {
>         return this.dictionary;
>     }
>     @Override
>     public boolean equals(Object obj)
>     {
>         if (this == obj)
>         {
>             return true;
>         }
>         if (obj instanceof PDDictionaryWrapper)
>         {
>             return this.dictionary.equals(((PDDictionaryWrapper) obj).dictionary);
>         }
>         return false;
>     }
>     @Override
>     public int hashCode()
>     {
>         return this.dictionary.hashCode();
>     }
> }
> and for objects with a required Type:
> public class PDTypedDictionaryWrapper extends PDDictionaryWrapper
> {
>     /**
>      *
>      * @param type the type
>      */
>     public PDTypedDictionaryWrapper(String type)
>     {
>         super();
>         this.getCOSDictionary().setName(COSName.TYPE, type);
>     }
>     /**
>      *
>      * @param dictionary the dictionary
>      */
>     public PDTypedDictionaryWrapper(COSDictionary dictionary)
>     {
>         super(dictionary);
>     }
>     /**
>      * Returns the type.
>      *
>      * @return the type
>      */
>     public String getType()
>     {
>         return this.getCOSDictionary().getNameAsString(COSName.TYPE);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.