Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdfwriter » [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.pdfwriter;
   18   
   19   import org.apache.pdfbox.persistence.util.COSObjectKey;
   20   
   21   import org.apache.pdfbox.cos.COSBase;
   22   
   23   /**
   24    * this is en entry in the xref section of the physical pdf document
   25    * generated by the COSWriter.
   26    *
   27    * @author Michael Traut
   28    * @version $Revision: 1.7 $
   29    */
   30   public class COSWriterXRefEntry implements Comparable
   31   {
   32       private long offset;
   33       private COSBase object;
   34       private COSObjectKey key;
   35       private boolean free = false;
   36   
   37   
   38   
   39       /**
   40        * {@inheritDoc}
   41        */
   42       public int compareTo(Object obj)
   43       {
   44           if (obj instanceof COSWriterXRefEntry)
   45           {
   46               return (int)(getKey().getNumber() - ((COSWriterXRefEntry)obj).getKey().getNumber());
   47           }
   48           else
   49           {
   50               return -1;
   51           }
   52       }
   53       /**
   54        * This will get the Object key.
   55        *
   56        * @return The object key.
   57        */
   58       public COSObjectKey  getKey()
   59       {
   60           return key;
   61       }
   62   
   63       /**
   64        * This will get the offset into the document.
   65        *
   66        * @return The offset into the document.
   67        */
   68       public long getOffset()
   69       {
   70           return offset;
   71       }
   72   
   73       /**
   74        * Gets the xref 'free' attribute.
   75        *
   76        * @return The free attribute.
   77        */
   78       public boolean isFree()
   79       {
   80           return free;
   81       }
   82   
   83       /**
   84        * This will set the free attribute.
   85        *
   86        * @param newFree The newly freed attribute.
   87        */
   88       public void setFree(boolean newFree)
   89       {
   90           free = newFree;
   91       }
   92   
   93       /**
   94        * This will set the object key.
   95        *
   96        * @param newKey The new object key.
   97        */
   98       private void setKey(COSObjectKey  newKey)
   99       {
  100           key = newKey;
  101       }
  102   
  103       /**
  104        * The offset attribute.
  105        *
  106        * @param newOffset The new value for the offset.
  107        */
  108       public void setOffset(long newOffset)
  109       {
  110           offset = newOffset;
  111       }
  112   
  113       /**
  114        * COSWriterXRefEntry constructor comment.
  115        *
  116        * @param start The start attribute.
  117        * @param obj The COS object that this entry represents.
  118        * @param keyValue The key to the COS object.
  119        */
  120       public COSWriterXRefEntry(long start, COSBase obj, COSObjectKey keyValue)
  121       {
  122           super();
  123           setOffset(start);
  124           setObject(obj);
  125           setKey(keyValue);
  126       }
  127   
  128       /**
  129        * This will get the object.
  130        *
  131        * @return The object.
  132        */
  133       public COSBase getObject()
  134       {
  135           return object;
  136       }
  137   
  138       /**
  139        * This will set the object for this xref.
  140        *
  141        * @param newObject The object that is being set.
  142        */
  143       private void setObject(COSBase newObject)
  144       {
  145           object = newObject;
  146       }
  147   }

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