Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.pdfbox.pdmodel;
   18   
   19   import java.io.IOException;
   20   
   21   import org.apache.pdfbox.cos.COSBase;
   22   import org.apache.pdfbox.cos.COSDictionary;
   23   import org.apache.pdfbox.cos.COSName;
   24   import org.apache.pdfbox.pdmodel.common.PDNameTreeNode;
   25   import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDDestination;
   26   import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageDestination;
   27   
   28   /**
   29    * This class holds all of the name trees that are available at the document level.
   30    *
   31    * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
   32    * @version $Revision: 1.2 $
   33    */
   34   public class PDDestinationNameTreeNode extends PDNameTreeNode
   35   {
   36   
   37       /**
   38        * Constructor.
   39        */
   40       public PDDestinationNameTreeNode()
   41       {
   42           super( PDPageDestination.class );
   43       }
   44   
   45       /**
   46        * Constructor.
   47        *
   48        * @param dic The COS dictionary.
   49        */
   50       public PDDestinationNameTreeNode( COSDictionary dic )
   51       {
   52           super( dic, PDPageDestination.class );
   53       }
   54   
   55       /**
   56        * {@inheritDoc}
   57        */
   58       protected Object convertCOSToPD( COSBase base ) throws IOException
   59       {
   60           COSBase destination = base;
   61           if( base instanceof COSDictionary )
   62           {
   63               //the destination is sometimes stored in the D dictionary
   64               //entry instead of being directly an array, so just dereference
   65               //it for now
   66               destination = ((COSDictionary)base).getDictionaryObject( COSName.D );
   67           }
   68           return PDDestination.create( destination );
   69       }
   70   
   71       /**
   72        * {@inheritDoc}
   73        */
   74       protected PDNameTreeNode createChildNode( COSDictionary dic )
   75       {
   76           return new PDDestinationNameTreeNode(dic);
   77       }
   78   }

Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel » [javadoc | source]