KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > ddf > EscherProperty


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.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 {
29     private short id;
30
31     /**
32      * The id is distinct from the actual property number. The id includes the property number the blip id
33      * flag and an indicator whether the property is complex or not.
34      */

35     public EscherProperty( short id )
36     {
37         this.id = id;
38     }
39
40     /**
41      * Constructs a new escher property. The three parameters are combined to form a property
42      * id.
43      */

44     public EscherProperty( short propertyNumber, boolean isComplex, boolean isBlipId )
45     {
46         this.id = (short)(propertyNumber +
47                 (isComplex ? 0x8000 : 0x0) +
48                 (isBlipId ? 0x4000 : 0x0));
49     }
50
51     public short getId()
52     {
53         return id;
54     }
55
56     public short getPropertyNumber()
57     {
58         return (short) ( id & (short) 0x3FFF );
59     }
60
61     public boolean isComplex()
62     {
63         return ( id & (short) 0x8000 ) != 0;
64     }
65
66     public boolean isBlipId()
67     {
68         return ( id & (short) 0x4000 ) != 0;
69     }
70
71     public String JavaDoc getName()
72     {
73         return EscherProperties.getPropertyName(id);
74     }
75
76     /**
77      * Most properties are just 6 bytes in length. Override this if we're
78      * dealing with complex properties.
79      */

80     public int getPropertySize()
81     {
82         return 6;
83     }
84
85     /**
86      * Escher properties consist of a simple fixed length part and a complex variable length part.
87      * The fixed length part is serialized first.
88      */

89     abstract public int serializeSimplePart( byte[] data, int pos );
90     /**
91      * Escher properties consist of a simple fixed length part and a complex variable length part.
92      * The fixed length part is serialized first.
93      */

94     abstract public int serializeComplexPart( byte[] data, int pos );
95 }
96
Popular Tags