KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > etymon > pjx > PdfLong


1 /*
2   Copyright (C) Etymon Systems, Inc. <http://www.etymon.com/>
3 */

4
5 package com.etymon.pjx;
6
7 import java.io.*;
8
9 /**
10    Represents a long integer value to be used with byte offsets such
11    as the <code>Prev</code> entry of a document trailer dictionary.
12    @author Nassib Nassar
13 */

14 public class PdfLong
15     extends PdfNumber {
16
17     /**
18        The long value of this object.
19     */

20     protected long _n;
21
22     /**
23        Constructs an long integer object representing a long
24        value.
25        @param n the long value.
26      */

27     public PdfLong(long n) {
28         _n = n;
29     }
30
31     public boolean equals(Object JavaDoc obj) {
32
33         if ( (obj == null) || ( !(obj instanceof PdfLong) ) ) {
34             return false;
35         }
36
37         return (_n == ((PdfLong)obj)._n);
38     }
39
40     public int getInt() {
41         return (int)_n;
42     }
43
44     public long getLong() {
45         return _n;
46     }
47
48     public float getFloat() {
49         return (float)_n;
50     }
51
52     public int hashCode() {
53         return (int)( _n ^ ( _n >>> 32 ) );
54     }
55
56     protected int writePdf(PdfWriter w, boolean spacing) throws IOException {
57
58         DataOutputStream dos = w.getDataOutputStream();
59             
60         int count;
61         
62         if (spacing) {
63             dos.write(' ');
64             count = 1;
65         } else {
66             count = 0;
67         }
68         
69         String JavaDoc s = Long.toString(_n);
70         dos.writeBytes(s);
71         return count + s.length();
72
73     }
74
75 }
76
Popular Tags