KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hdf > model > hdftypes > PlexOfCps


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.hdf.model.hdftypes;
19
20
21 /**
22  * common data structure in a Word file. Contains an array of 4 byte ints in
23  * the front that relate to an array of abitrary data structures in the back.
24  *
25  * This class acts more like a pointer. In the sense that it doesn't store any
26  * data. It only provides convenience methods for accessing a particular
27  * PlexOfCps
28  *
29  * @author Ryan Ackley
30  */

31 public class PlexOfCps
32 {
33     private int _count;
34     private int _offset;
35     private int _sizeOfStruct;
36
37
38     /**
39      * Constructor
40      *
41      * @param size The size in bytes of this PlexOfCps
42      * @param sizeOfStruct The size of the data structure type stored in
43      * this PlexOfCps.
44      */

45     public PlexOfCps(int size, int sizeOfStruct)
46     {
47         _count = (size - 4)/(4 + sizeOfStruct);
48         _sizeOfStruct = sizeOfStruct;
49     }
50     public int getIntOffset(int index)
51     {
52       return index * 4;
53     }
54     /**
55      * returns the number of data structures in this PlexOfCps.
56      *
57      * @return The number of data structures in this PlexOfCps
58      */

59     public int length()
60     {
61         return _count;
62     }
63     /**
64      * Returns the offset, in bytes, from the beginning if this PlexOfCps to
65      * the data structure at index.
66      *
67      * @param index The index of the data structure.
68      *
69      * @return The offset, in bytes, from the beginning if this PlexOfCps to
70      * the data structure at index.
71      */

72     public int getStructOffset(int index)
73     {
74         return (4 * (_count + 1)) + (_sizeOfStruct * index);
75     }
76 }
77
Popular Tags