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.ddf;
19:
20: /**
21: * This is the abstract base class for all escher properties.
22: *
23: * @see EscherOptRecord
24: *
25: * @author Glen Stampoultzis (glens at apache.org)
26: */
27: abstract public class EscherProperty {
28: protected short id;
29:
30: /**
31: * The id is distinct from the actual property number. The id includes the property number the blip id
32: * flag and an indicator whether the property is complex or not.
33: */
34: public EscherProperty(short id) {
35: this .id = id;
36: }
37:
38: /**
39: * Constructs a new escher property. The three parameters are combined to form a property
40: * id.
41: */
42: public EscherProperty(short propertyNumber, boolean isComplex,
43: boolean isBlipId) {
44: this .id = (short) (propertyNumber + (isComplex ? 0x8000 : 0x0) + (isBlipId ? 0x4000
45: : 0x0));
46: }
47:
48: public short getId() {
49: return id;
50: }
51:
52: public short getPropertyNumber() {
53: return (short) (id & (short) 0x3FFF);
54: }
55:
56: public boolean isComplex() {
57: return (id & (short) 0x8000) != 0;
58: }
59:
60: public boolean isBlipId() {
61: return (id & (short) 0x4000) != 0;
62: }
63:
64: public String getName() {
65: return EscherProperties.getPropertyName(id);
66: }
67:
68: /**
69: * Most properties are just 6 bytes in length. Override this if we're
70: * dealing with complex properties.
71: */
72: public int getPropertySize() {
73: return 6;
74: }
75:
76: /**
77: * Escher properties consist of a simple fixed length part and a complex variable length part.
78: * The fixed length part is serialized first.
79: */
80: abstract public int serializeSimplePart(byte[] data, int pos);
81:
82: /**
83: * Escher properties consist of a simple fixed length part and a complex variable length part.
84: * The fixed length part is serialized first.
85: */
86: abstract public int serializeComplexPart(byte[] data, int pos);
87: }
|