Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel.interactive.pagenavigation » [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.interactive.pagenavigation;
   18   
   19   import org.apache.pdfbox.cos.COSBase;
   20   import org.apache.pdfbox.cos.COSDictionary;
   21   
   22   import org.apache.pdfbox.pdmodel.PDDocumentInformation;
   23   import org.apache.pdfbox.pdmodel.common.COSObjectable;
   24   
   25   /**
   26    * This a single thread in a PDF document.
   27    *
   28    * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
   29    * @version $Revision: 1.2 $
   30    */
   31   public class PDThread implements COSObjectable
   32   {
   33   
   34   
   35       private COSDictionary thread;
   36   
   37       /**
   38        * Constructor that is used for a preexisting dictionary.
   39        *
   40        * @param t The underlying dictionary.
   41        */
   42       public PDThread( COSDictionary t )
   43       {
   44           thread = t;
   45       }
   46   
   47       /**
   48        * Default constructor.
   49        *
   50        */
   51       public PDThread()
   52       {
   53           thread = new COSDictionary();
   54           thread.setName( "Type", "Thread" );
   55       }
   56   
   57       /**
   58        * This will get the underlying dictionary that this object wraps.
   59        *
   60        * @return The underlying info dictionary.
   61        */
   62       public COSDictionary getDictionary()
   63       {
   64           return thread;
   65       }
   66   
   67       /**
   68        * Convert this standard java object to a COS object.
   69        *
   70        * @return The cos object that matches this Java object.
   71        */
   72       public COSBase getCOSObject()
   73       {
   74           return thread;
   75       }
   76   
   77       /**
   78        * Get info about the thread, or null if there is nothing.
   79        *
   80        * @return The thread information.
   81        */
   82       public PDDocumentInformation getThreadInfo()
   83       {
   84           PDDocumentInformation retval = null;
   85           COSDictionary info = (COSDictionary)thread.getDictionaryObject( "I" );
   86           if( info != null )
   87           {
   88               retval = new PDDocumentInformation( info );
   89           }
   90   
   91           return retval;
   92       }
   93   
   94       /**
   95        * Set the thread info, can be null.
   96        *
   97        * @param info The info dictionary about this thread.
   98        */
   99       public void setThreadInfo( PDDocumentInformation info )
  100       {
  101           thread.setItem( "I", info );
  102       }
  103   
  104       /**
  105        * Get the first bead in the thread, or null if it has not been set yet.  This
  106        * is a required field for this object.
  107        *
  108        * @return The first bead in the thread.
  109        */
  110       public PDThreadBead getFirstBead()
  111       {
  112           PDThreadBead retval = null;
  113           COSDictionary bead = (COSDictionary)thread.getDictionaryObject( "F" );
  114           if( bead != null )
  115           {
  116               retval = new PDThreadBead( bead );
  117           }
  118   
  119           return retval;
  120       }
  121   
  122       /**
  123        * This will set the first bead in the thread.  When this is set it will
  124        * also set the thread property of the bead object.
  125        *
  126        * @param bead The first bead in the thread.
  127        */
  128       public void setFirstBead( PDThreadBead bead )
  129       {
  130           if( bead != null )
  131           {
  132               bead.setThread( this );
  133           }
  134           thread.setItem( "F", bead );
  135       }
  136   
  137   
  138   }

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