KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hwpf > model > FIBLongHandler


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18 package org.apache.poi.hwpf.model;
19
20 import java.io.IOException JavaDoc;
21
22 import org.apache.poi.util.LittleEndian;
23
24 public class FIBLongHandler
25 {
26   public static final int CBMAC = 0;
27   public static final int PRODUCTCREATED = 1;
28   public static final int PRODUCTREVISED = 2;
29   public static final int CCPTEXT = 3;
30   public static final int CCPFTN = 4;
31   public static final int CCPHDD = 5;
32   public static final int CCPMCR = 6;
33   public static final int CCPATN = 7;
34   public static final int CCPEDN = 8;
35   public static final int CCPTXBX = 9;
36   public static final int CCPHDRTXBX = 10;
37   public static final int PNFBPCHPFIRST = 11;
38   public static final int PNCHPFIRST = 12;
39   public static final int CPNBTECHP = 13;
40   public static final int PNFBPPAPFIRST = 14;
41   public static final int PNPAPFIRST = 15;
42   public static final int CPNBTEPAP = 16;
43   public static final int PNFBPLVCFIRST = 17;
44   public static final int PNLVCFIRST = 18;
45   public static final int CPNBTELVC = 19;
46   public static final int FCISLANDFIRST = 20;
47   public static final int FCISLANDLIM = 21;
48
49   int[] _longs;
50
51   public FIBLongHandler(byte[] mainStream, int offset)
52   {
53     int longCount = LittleEndian.getShort(mainStream, offset);
54     offset += LittleEndian.SHORT_SIZE;
55     _longs = new int[longCount];
56
57     for (int x = 0; x < longCount; x++)
58     {
59       _longs[x] = LittleEndian.getInt(mainStream, offset + (x * LittleEndian.INT_SIZE));
60     }
61   }
62
63   /**
64    * Refers to a 32 bit windows "long" same as a Java int
65    * @param longCode FIXME: Document this!
66    * @return FIXME: Document this!
67    */

68   public int getLong(int longCode)
69   {
70     return _longs[longCode];
71   }
72
73   public void setLong(int longCode, int value)
74   {
75     _longs[longCode] = value;
76   }
77
78   void serialize(byte[] mainStream, int offset)
79     throws IOException JavaDoc
80   {
81     LittleEndian.putShort(mainStream, offset, (short)_longs.length);
82     offset += LittleEndian.SHORT_SIZE;
83
84     for (int x = 0; x < _longs.length; x++)
85     {
86       LittleEndian.putInt(mainStream, offset, _longs[x]);
87       offset += LittleEndian.INT_SIZE;
88     }
89   }
90
91   int sizeInBytes()
92   {
93     return (_longs.length * LittleEndian.INT_SIZE) + LittleEndian.SHORT_SIZE;
94   }
95
96
97 }
98
Popular Tags