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: /* $Id: ValidationPercentBaseContext.java 556248 2007-07-14 08:52:28Z adelmelle $ */
19:
20: package org.apache.fop.datatypes;
21:
22: import org.apache.fop.fo.FObj;
23:
24: /**
25: * This base context is used during validation when the actual base values are still unknown
26: * but should still already be checked. The actual value returned is not so important in this
27: * case. But it's important that zero and non-zero values can be distinguished.
28: * <p>
29: * Example: A table with collapsing border model has no padding. The Table FO should be able
30: * to check if non-zero values (even percentages) have been specified.
31: */
32: public final class ValidationPercentBaseContext implements
33: PercentBaseContext {
34:
35: /**
36: * Main constructor.
37: */
38: private ValidationPercentBaseContext() {
39: }
40:
41: /**
42: * Returns the value for the given lengthBase.
43: * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj)
44: */
45: public int getBaseLength(int lengthBase, FObj fobj) {
46: //Simply return a dummy value which produces a non-zero value when a non-zero percentage
47: //was specified.
48: return 100000;
49: }
50:
51: private static PercentBaseContext pseudoContextForValidation = null;
52:
53: /** @return a base context for validation purposes. See class description. */
54: public static PercentBaseContext getPseudoContext() {
55: if (pseudoContextForValidation == null) {
56: pseudoContextForValidation = new ValidationPercentBaseContext();
57: }
58: return pseudoContextForValidation;
59: }
60:
61: }
|