001/*
002 * $Id: PdfIndirectReference.java 4784 2011-03-15 08:33:00Z blowagie $
003 *
004 * This file is part of the iText (R) project.
005 * Copyright (c) 1998-2011 1T3XT BVBA
006 * Authors: Bruno Lowagie, Paulo Soares, et al.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU Affero General Public License version 3
010 * as published by the Free Software Foundation with the addition of the
011 * following permission added to Section 15 as permitted in Section 7(a):
012 * FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY 1T3XT,
013 * 1T3XT DISCLAIMS THE WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
014 *
015 * This program is distributed in the hope that it will be useful, but
016 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
017 * or FITNESS FOR A PARTICULAR PURPOSE.
018 * See the GNU Affero General Public License for more details.
019 * You should have received a copy of the GNU Affero General Public License
020 * along with this program; if not, see http://www.gnu.org/licenses or write to
021 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
022 * Boston, MA, 02110-1301 USA, or download the license from the following URL:
023 * http://itextpdf.com/terms-of-use/
024 *
025 * The interactive user interfaces in modified source and object code versions
026 * of this program must display Appropriate Legal Notices, as required under
027 * Section 5 of the GNU Affero General Public License.
028 *
029 * In accordance with Section 7(b) of the GNU Affero General Public License,
030 * a covered work must retain the producer line in every PDF that is created
031 * or manipulated using iText.
032 *
033 * You can be released from the requirements of the license by purchasing
034 * a commercial license. Buying such a license is mandatory as soon as you
035 * develop commercial activities involving the iText software without
036 * disclosing the source code of your own applications.
037 * These activities include: offering paid services to customers as an ASP,
038 * serving PDFs on the fly in a web application, shipping iText with a closed
039 * source product.
040 *
041 * For more information, please contact iText Software Corp. at this
042 * address: sales@itextpdf.com
043 */
044package com.itextpdf.text.pdf;
045
046/**
047 * <CODE>PdfIndirectReference</CODE> contains a reference to a <CODE>PdfIndirectObject</CODE>.
048 * <P>
049 * Any object used as an element of an array or as a value in a dictionary may be specified
050 * by either a direct object of an indirect reference. An <I>indirect reference</I> is a reference
051 * to an indirect object, and consists of the indirect object's object number, generation number
052 * and the <B>R</B> keyword.<BR>
053 * This object is described in the 'Portable Document Format Reference Manual version 1.3'
054 * section 4.11 (page 54).
055 *
056 * @see         PdfObject
057 * @see         PdfIndirectObject
058 */
059
060public class PdfIndirectReference extends PdfObject {
061    
062    // membervariables
063    
064/** the object number */
065    protected int number;
066    
067/** the generation number */
068    protected int generation = 0;
069    
070    // constructors
071    
072    protected PdfIndirectReference() {
073        super(0);
074    }
075    
076/**
077 * Constructs a <CODE>PdfIndirectReference</CODE>.
078 *
079 * @param               type                    the type of the <CODE>PdfObject</CODE> that is referenced to
080 * @param               number                  the object number.
081 * @param               generation              the generation number.
082 */
083    
084    PdfIndirectReference(int type, int number, int generation) {
085        super(0, new StringBuffer().append(number).append(" ").append(generation).append(" R").toString());
086        this.number = number;
087        this.generation = generation;
088    }
089    
090/**
091 * Constructs a <CODE>PdfIndirectReference</CODE>.
092 *
093 * @param               type                    the type of the <CODE>PdfObject</CODE> that is referenced to
094 * @param               number                  the object number.
095 */
096    
097    PdfIndirectReference(int type, int number) {
098        this(type, number, 0);
099    }
100    
101    // methods
102    
103/**
104 * Returns the number of the object.
105 *
106 * @return              a number.
107 */
108    
109    public int getNumber() {
110        return number;
111    }
112    
113/**
114 * Returns the generation of the object.
115 *
116 * @return              a number.
117 */
118    
119    public int getGeneration() {
120        return generation;
121    }
122    
123    public String toString() {
124        return new StringBuffer().append(number).append(" ").append(generation).append(" R").toString();
125    }
126}