KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdfwriter > COSWriterXRefEntry


1 /**
2  * Copyright (c) 2003-2006, www.pdfbox.org
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. Neither the name of pdfbox; nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * http://www.pdfbox.org
29  *
30  */

31 package org.pdfbox.pdfwriter;
32
33 import org.pdfbox.persistence.util.COSObjectKey;
34
35 import org.pdfbox.cos.COSBase;
36
37 /**
38  * this is en entry in the xref section of the physical pdf document
39  * generated by the COSWriter.
40  *
41  * @author Michael Traut
42  * @version $Revision: 1.7 $
43  */

44 public class COSWriterXRefEntry implements Comparable JavaDoc
45 {
46     private long offset;
47     private COSBase object;
48     private COSObjectKey key;
49     private boolean free = false;
50
51
52
53     /**
54      * {@inheritDoc}
55      */

56     public int compareTo(Object JavaDoc obj)
57     {
58         if (obj instanceof COSWriterXRefEntry)
59         {
60             return (int)(getKey().getNumber() - ((COSWriterXRefEntry)obj).getKey().getNumber());
61         }
62         else
63         {
64             return -1;
65         }
66     }
67     /**
68      * This will get the Object key.
69      *
70      * @return The object key.
71      */

72     public COSObjectKey getKey()
73     {
74         return key;
75     }
76
77     /**
78      * This will get the offset into the document.
79      *
80      * @return The offset into the document.
81      */

82     public long getOffset()
83     {
84         return offset;
85     }
86
87     /**
88      * Gets the xref 'free' attribute.
89      *
90      * @return The free attribute.
91      */

92     public boolean isFree()
93     {
94         return free;
95     }
96
97     /**
98      * This will set the free attribute.
99      *
100      * @param newFree The newly freed attribute.
101      */

102     public void setFree(boolean newFree)
103     {
104         free = newFree;
105     }
106
107     /**
108      * This will set the object key.
109      *
110      * @param newKey The new object key.
111      */

112     private void setKey(COSObjectKey newKey)
113     {
114         key = newKey;
115     }
116
117     /**
118      * The offset attribute.
119      *
120      * @param newOffset The new value for the offset.
121      */

122     public void setOffset(long newOffset)
123     {
124         offset = newOffset;
125     }
126
127     /**
128      * COSWriterXRefEntry constructor comment.
129      *
130      * @param start The start attribute.
131      * @param obj The COS object that this entry represents.
132      * @param keyValue The key to the COS object.
133      */

134     public COSWriterXRefEntry(long start, COSBase obj, COSObjectKey keyValue)
135     {
136         super();
137         setOffset(start);
138         setObject(obj);
139         setKey(keyValue);
140     }
141
142     /**
143      * This will get the object.
144      *
145      * @return The object.
146      */

147     public COSBase getObject()
148     {
149         return object;
150     }
151
152     /**
153      * This will set the object for this xref.
154      *
155      * @param newObject The object that is being set.
156      */

157     private void setObject(COSBase newObject)
158     {
159         object = newObject;
160     }
161 }
Popular Tags