All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jpedal.io.types.Offsets Maven / Gradle / Ivy

There is a newer version: 20151002
Show newest version
/*
 * ===========================================
 * Java Pdf Extraction Decoding Access Library
 * ===========================================
 *
 * Project Info:  http://www.idrsolutions.com
 * Help section for developers at http://www.idrsolutions.com/support/
 *
 * (C) Copyright 1997-2015 IDRsolutions and Contributors.
 *
 * This file is part of JPedal/JPDF2HTML5
 *
     This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


 *
 * ---------------
 * Offsets.java
 * ---------------
 */
package org.jpedal.io.types;

import java.io.IOException;

import org.jpedal.io.RandomAccessBuffer;
import org.jpedal.utils.*;
import org.jpedal.utils.repositories.*;

/**
 * byte positions of objects in PDF file
 */
public class Offsets extends Vector_Int{

    private boolean refTableInvalid;
    
    /**flag to show if compressed*/
    private Vector_boolean isCompressed=new Vector_boolean(2000);

    /**generation of each object*/
    private Vector_Int generation = new Vector_Int( 2000 );

    /**location of end ref*/
    private Vector_Int xref=new Vector_Int(100);

    public Offsets(final int i) {
        super(i);
    }

    public void addXref(final int pointer) {
        xref.addElement(pointer);
    }
    
    
    /**
     * precalculate sizes for each object
     */
    public int[] calculateObjectLength(final int eof) {

        if(refTableInvalid) {
            return null;
        }
        
        //add eol to refs as catchall
        xref.addElement(eof);

        final int[] xrefs=xref.get();

        //get order list of refs
        final int xrefCount=xrefs.length;
        int[] xrefID=new int[xrefCount];
        for(int i=0;i0){

                //decide if line is a section header or value

                //first count tokens
                int lastChar=1,currentChar;
                for(int j=1;j eof) {
                            bufSize = (int) (eof - id);
                        }

                        if(bufSize>0){

                            /** get bytes into buffer */
                            final byte[] buffer = getBytes(id, bufSize,pdf_datafile);

                            //look for space o b j
                            for(int ii=4;iithis.elementAt(current_number)))
        {
            this.setElementAt( current_offset, current_number );
            generation.setElementAt( current_generation, current_number );
            isCompressed.setElementAt(isEntryCompressed,current_number);
        }else{
            //LogWriter.writeLog("Object "+current_number + ", generation "+
            //current_generation + " already exists as"+
            //existing_generation);
        }
    }
    
    /**
     * general routine to turn reference into id with object name
     */
    public final boolean isCompressed( final int ref)
    {

        return isCompressed.elementAt(ref);
    }
    
    public boolean isRefTableInvalid(){
        return refTableInvalid;
    }

    public void setRefTableInvalid(final boolean value) {
        refTableInvalid=value;
    }
}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy