1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!--
Copyright 1999-2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<!-- Created by htmlize-0.67 in css mode. -->
<html>
<head>
<title>AbstractPropertyValue.java</title>
<style type="text/css">
<!--
body {
color: #000000;
background-color: #faf0e6;
} /* default */
.jde-java-font-lock-package {
color: #0000cd;
background-color: #faf0e6;
} /* jde-java-font-lock-package-face */
.jde-java-font-lock-constant {
color: #5f9ea0;
background-color: #faf0e6;
} /* jde-java-font-lock-constant-face */
.keyword {
color: #8b0000;
background-color: #faf0e6;
} /* font-lock-keyword-face */
.jde-java-font-lock-doc-tag {
color: #008b00;
background-color: #faf0e6;
} /* jde-java-font-lock-doc-tag-face */
.jde-java-font-lock-number {
color: #bc8f8f;
background-color: #faf0e6;
} /* jde-java-font-lock-number-face */
.jde-java-font-lock-italic {
background-color: #faf0e6;
font-style: italic;
} /* jde-java-font-lock-italic-face */
.string {
color: #008b00;
background-color: #faf0e6;
} /* font-lock-string-face */
.variable-name {
color: #8b008b;
background-color: #faf0e6;
} /* font-lock-variable-name-face */
.jde-java-font-lock-modifier {
color: #da70d6;
background-color: #faf0e6;
} /* jde-java-font-lock-modifier-face */
.type {
color: #4682b4;
background-color: #faf0e6;
} /* font-lock-type-face */
.comment {
color: #00008b;
background-color: #faf0e6;
} /* font-lock-comment-face */
.function-name {
color: #8b2323;
background-color: #faf0e6;
} /* font-lock-function-name-face */
a {
color: inherit;
background-color: inherit;
font: inherit;
text-decoration: inherit;
}
a:hover {
text-decoration: underline;
}
-->
</style>
</head>
<body>
<pre>
<span class="comment">/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/</span>
<span class="keyword">package</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">datatypes</span>;
<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">fo</span>.<span class="type">PropertyConsts</span>;
<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">fo</span>.<span class="type">PropNames</span>;
<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">fo</span>.<span class="jde-java-font-lock-package">properties</span>.<span class="jde-java-font-lock-number">*</span>;
<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">fo</span>.<span class="type">FONode</span>;
<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">fo</span>.<span class="jde-java-font-lock-package">expr</span>.<span class="type">PropertyException</span>;
<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">datatypes</span>.<span class="type">PropertyValue</span>;
<span class="comment">/**
* Base abstract class for all property value types.
* @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
*/</span>
<span class="jde-java-font-lock-modifier">public</span> <span class="jde-java-font-lock-modifier">abstract</span> <span class="keyword">class</span> <span class="function-name" id="AbstractPropertyValueClass">AbstractPropertyValue</span>
<span class="keyword">implements</span> <span class="type">PropertyValue</span>, <span class="type">Cloneable</span>
{
<span class="comment">/**
* An integer index to the type of property of which this is a value.
*/</span>
<span class="jde-java-font-lock-modifier">protected</span> <span class="type">int</span> <span class="variable-name" id="property">property</span>;
<span class="comment">/**
* An integer property type.
*/</span>
<span class="jde-java-font-lock-modifier">public</span> <span class="jde-java-font-lock-modifier">final</span> <span class="type">int</span> <span class="variable-name" id="type">type</span>;
<span class="comment">/**
* The PropertyConsts singleton.
*/</span>
<span class="jde-java-font-lock-modifier">public</span> <span class="jde-java-font-lock-modifier">final</span> <span class="type">PropertyConsts</span> <span class="variable-name" id="propertyConsts">propertyConsts</span>;
<span class="comment">/**
* </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="index">index</span><span class="comment"> index of the property in the property arrays.
* </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">type</span><span class="comment"> of this value
*/</span>
<span class="jde-java-font-lock-modifier">public</span> <span class="function-name" id="AbstractPropertyValue">AbstractPropertyValue</span>(<span class="type">int</span> <span class="variable-name">index</span>, <span class="type">int</span> <span class="variable-name">type</span>)
<span class="keyword">throws</span> <span class="type">PropertyException</span>
{
<span class="keyword">if</span> (index < <span class="jde-java-font-lock-number">1</span> || index > PropNames.<span class="jde-java-font-lock-constant" id="LAST_PROPERTY_INDEX">LAST_PROPERTY_INDEX</span>)
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">PropertyException</span>("<span class="string">Invalid property index: </span>" + index);
<span class="keyword">if</span> (type < <span class="jde-java-font-lock-number">0</span> || type > PropertyValue.<span class="jde-java-font-lock-constant" id="LAST_PROPERTY_TYPE">LAST_PROPERTY_TYPE</span>)
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">PropertyException</span>("<span class="string">Invalid property type: </span>" + type);
property = index;
<span class="keyword">this</span>.type = type;
propertyConsts = PropertyConsts.getPropertyConsts();
}
<span class="comment">/**
* </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="propertyName">propertyName</span><span class="comment"> a <tt>String</tt> containing the property name.
*/</span>
<span class="jde-java-font-lock-modifier">public</span> <span class="function-name">AbstractPropertyValue</span>(<span class="type">String</span> <span class="variable-name">propertyName</span>, <span class="type">int</span> <span class="variable-name">type</span>)
<span class="keyword">throws</span> <span class="type">PropertyException</span>
{
propertyConsts = PropertyConsts.getPropertyConsts();
property = PropNames.getPropertyIndex(propertyName);
<span class="keyword">if</span> (property < <span class="jde-java-font-lock-number">1</span> || property > PropNames.<span class="jde-java-font-lock-constant">LAST_PROPERTY_INDEX</span>)
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">PropertyException</span>("<span class="string">Invalid property index: </span>" + property);
<span class="keyword">if</span> (type < <span class="jde-java-font-lock-number">0</span> || type > PropertyValue.<span class="jde-java-font-lock-constant">LAST_PROPERTY_TYPE</span>)
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">PropertyException</span>("<span class="string">Invalid property type: </span>" + type);
<span class="keyword">this</span>.type = type;
}
<span class="comment">/**
* </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> <tt>int</tt> property index.
*/</span>
<span class="jde-java-font-lock-modifier">public</span> <span class="type">int</span> <span class="function-name" id="getProperty">getProperty</span>() {
<span class="keyword">return</span> property;
}
<span class="jde-java-font-lock-modifier">public</span> <span class="type">void</span> <span class="function-name" id="setProperty">setProperty</span>(<span class="type">int</span> <span class="variable-name">index</span>) <span class="keyword">throws</span> <span class="type">PropertyException</span> {
<span class="keyword">if</span> (index < <span class="jde-java-font-lock-number">0</span> || index > PropNames.<span class="jde-java-font-lock-constant">LAST_PROPERTY_INDEX</span>)
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">PropertyException</span>("<span class="string">Invalid property index: </span>" + index);
property = index;
}
<span class="comment">/**
* </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> type field of the <tt>PropertyValue</tt>.
*/</span>
<span class="jde-java-font-lock-modifier">public</span> <span class="type">int</span> <span class="function-name" id="getType">getType</span>() {
<span class="keyword">return</span> type;
}
<span class="comment">/**
* In some circumstances, the property against which a type is to be
* validated may not be the same as the property against which this
* <i></span><span class="jde-java-font-lock-italic">AbstractPropertyValue</span><span class="comment"></i> is defined.
* A specific property argument is then required.
* </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="testProperty">testProperty</span><span class="comment"> <tt>int</tt> property index of the property
* for which the type is to be validated.
* </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">type</span><span class="comment"> <tt>int</tt> bitmap of data types to check for
* validity against this property.
*/</span>
<span class="jde-java-font-lock-modifier">public</span> <span class="type">void</span> <span class="function-name" id="validate">validate</span>(<span class="type">int</span> <span class="variable-name">testProperty</span>, <span class="type">int</span> <span class="variable-name">type</span>)
<span class="keyword">throws</span> <span class="type">PropertyException</span>
{
<span class="comment">// N.B. PROPERTY_SPECIFIC inheritance may require more specialized
</span> <span class="comment">// checks. Only line-height comes into this category.
</span>
<span class="comment">// N.B. The first commented-out condition means that I cannot validate
</span> <span class="comment">// unless the property is NOT inherited.
</span> <span class="comment">// I can't remember why I put this
</span> <span class="comment">// condition in here. Removing it. pbw 2002/02/18
</span> <span class="comment">//if (propertyConsts.inherited.get(testProperty) == Property.NO
</span> <span class="comment">//&& (propertyConsts.getDataTypes(testProperty) & type) == 0) {
</span>
<span class="keyword">if</span> ((propertyConsts.getDataTypes(testProperty) & type) == <span class="jde-java-font-lock-number">0</span>) {
<span class="type">String</span> <span class="variable-name" id="pname">pname</span> = PropNames.getPropertyName(testProperty);
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">PropertyException</span>
("<span class="string">Datatype(s) </span>" +
Property.listDataTypes(type) +
"<span class="string"> not defined on </span>" + pname);
}
}
<span class="comment">/**
* </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">type</span><span class="comment"> <tt>int</tt> bitmap of data types to check for
* validity against this property.
*/</span>
<span class="jde-java-font-lock-modifier">public</span> <span class="type">void</span> <span class="function-name">validate</span>(<span class="type">int</span> <span class="variable-name">type</span>) <span class="keyword">throws</span> <span class="type">PropertyException</span> {
<span class="comment">// N.B. PROPERTY_SPECIFIC inheritance may require more specialized
</span> <span class="comment">// checks. Only line-height comes into this category.
</span> validate(property, type);
}
<span class="jde-java-font-lock-modifier">public</span> <span class="jde-java-font-lock-modifier">static</span> <span class="type">String</span> <span class="function-name" id="typeString">typeString</span>(<span class="type">int</span> <span class="variable-name">type</span>) {
<span class="keyword">if</span> (type < <span class="jde-java-font-lock-number">0</span> || type >PropertyValue.<span class="jde-java-font-lock-constant">LAST_PROPERTY_TYPE</span>)
<span class="keyword">return</span> "<span class="string">Property type out of range</span>";
<span class="keyword">return</span> PropertyValue.propertyTypes.get(type);
}
<span class="jde-java-font-lock-modifier">public</span> <span class="type">String</span> <span class="function-name" id="toString">toString</span>() {
<span class="keyword">try</span> {
<span class="keyword">return</span> "<span class="string">Property: </span>" + PropNames.getPropertyName(property)
+ "<span class="string"> Index: </span>" + property + "<span class="string"> Type: </span>" +
typeString(type);
} <span class="keyword">catch</span> (<span class="type">PropertyException</span> <span class="variable-name" id="e">e</span>) {
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">RuntimeException</span>(e.getMessage());
}
}
<span class="jde-java-font-lock-modifier">public</span> <span class="type">Object</span> <span class="function-name" id="clone">clone</span>() <span class="keyword">throws</span> <span class="type">CloneNotSupportedException</span> {
<span class="keyword">return</span> <span class="keyword">super</span>.clone();
}
}
</pre>
</body>
</html>
|