01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: 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.usermodel;
19:
20: import org.apache.poi.util.BitField;
21: import org.apache.poi.util.BitFieldFactory;
22: import org.apache.poi.util.LittleEndian;
23:
24: public class BorderCode implements Cloneable {
25: public static final int SIZE = 4;
26: private short _info;
27: private final static BitField _dptLineWidth = BitFieldFactory
28: .getInstance(0xff);
29: private final static BitField _brcType = BitFieldFactory
30: .getInstance(0xff00);
31: private short _info2;
32: private final static BitField _ico = BitFieldFactory
33: .getInstance(0xff);
34: private final static BitField _dptDpace = BitFieldFactory
35: .getInstance(0x1f00);
36: private final static BitField _fShadow = BitFieldFactory
37: .getInstance(0x2000);
38: private final static BitField _fFrame = BitFieldFactory
39: .getInstance(0x4000);
40:
41: public BorderCode() {
42: }
43:
44: public BorderCode(byte[] buf, int offset) {
45: _info = LittleEndian.getShort(buf, offset);
46: _info2 = LittleEndian.getShort(buf, offset
47: + LittleEndian.SHORT_SIZE);
48: }
49:
50: public void serialize(byte[] buf, int offset) {
51: LittleEndian.putShort(buf, offset, _info);
52: LittleEndian.putShort(buf, offset + LittleEndian.SHORT_SIZE,
53: _info2);
54: }
55:
56: public int toInt() {
57: byte[] buf = new byte[4];
58: serialize(buf, 0);
59: return LittleEndian.getInt(buf);
60: }
61:
62: public boolean isEmpty() {
63: return _info == 0 && _info2 == 0;
64: }
65:
66: public boolean equals(Object o) {
67: BorderCode brc = (BorderCode) o;
68: return _info == brc._info && _info2 == brc._info2;
69: }
70:
71: public Object clone() throws CloneNotSupportedException {
72: return super.clone();
73: }
74: }
|