01: /*
02: Copyright (C) Etymon Systems, Inc. <http://www.etymon.com/>
03: */
04:
05: package com.etymon.pjx;
06:
07: import java.io.*;
08:
09: /**
10: Represents the PDF integer object.
11: @author Nassib Nassar
12: */
13: public class PdfInteger extends PdfNumber {
14:
15: /**
16: The int value of this object.
17: */
18: protected int _n;
19:
20: /**
21: A <code>PdfInteger</code> object representing the int value
22: <code>0</code>.
23: */
24: public static final PdfInteger ZERO = new PdfInteger(0);
25:
26: /**
27: Constructs an integer object representing an int value.
28: @param n the int value.
29: */
30: public PdfInteger(int n) {
31: _n = n;
32: }
33:
34: public boolean equals(Object obj) {
35:
36: if ((obj == null) || (!(obj instanceof PdfInteger))) {
37: return false;
38: }
39:
40: return (_n == ((PdfInteger) obj)._n);
41: }
42:
43: public int getInt() {
44: return _n;
45: }
46:
47: public long getLong() {
48: return (long) _n;
49: }
50:
51: public float getFloat() {
52: return (float) _n;
53: }
54:
55: public int hashCode() {
56: return _n;
57: }
58:
59: protected int writePdf(PdfWriter w, boolean spacing)
60: throws IOException {
61:
62: DataOutputStream dos = w.getDataOutputStream();
63:
64: int count;
65:
66: if (spacing) {
67: dos.write(' ');
68: count = 1;
69: } else {
70: count = 0;
71: }
72:
73: String s = Integer.toString(_n);
74: dos.writeBytes(s);
75: return count + s.length();
76: }
77:
78: }
|