KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hwpf > usermodel > BorderCode


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
19 package org.apache.poi.hwpf.usermodel;
20
21 import org.apache.poi.util.BitField;
22 import org.apache.poi.util.LittleEndian;
23
24 public class BorderCode
25   implements Cloneable JavaDoc
26 {
27   public static final int SIZE = 4;
28   private short _info;
29     private final static BitField _dptLineWidth = new BitField(0xff);
30     private final static BitField _brcType = new BitField(0xff00);
31   private short _info2;
32     private final static BitField _ico = new BitField(0xff);
33     private final static BitField _dptDpace = new BitField(0x1f00);
34     private final static BitField _fShadow = new BitField(0x2000);
35     private final static BitField _fFrame = new BitField(0x4000);
36
37   public BorderCode()
38   {
39   }
40
41   public BorderCode(byte[] buf, int offset)
42   {
43     _info = LittleEndian.getShort(buf, offset);
44     _info2 = LittleEndian.getShort(buf, offset + LittleEndian.SHORT_SIZE);
45   }
46
47   public void serialize(byte[] buf, int offset)
48   {
49     LittleEndian.putShort(buf, offset, _info);
50     LittleEndian.putShort(buf, offset + LittleEndian.SHORT_SIZE, _info2);
51   }
52
53   public int toInt()
54   {
55     byte[] buf = new byte[4];
56     serialize(buf, 0);
57     return LittleEndian.getInt(buf);
58   }
59
60   public boolean isEmpty()
61   {
62     return _info == 0 && _info2 == 0;
63   }
64
65   public boolean equals(Object JavaDoc o)
66   {
67     BorderCode brc = (BorderCode)o;
68     return _info == brc._info && _info2 == brc._info2;
69   }
70
71   public Object JavaDoc clone()
72     throws CloneNotSupportedException JavaDoc
73   {
74     return super.clone();
75   }
76 }
77
Popular Tags