KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > datatypes > ValidationPercentBaseContext


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 /* $Id: ValidationPercentBaseContext.java 426576 2006-07-28 15:44:37Z jeremias $ */
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 PercentBaseContext {
33     
34     /**
35      * Main constructor.
36      */

37     private ValidationPercentBaseContext() {
38     }
39
40     /**
41      * Returns the value for the given lengthBase.
42      * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj)
43      */

44     public int getBaseLength(int lengthBase, FObj fobj) {
45         //Simply return a dummy value which produces a non-zero value when a non-zero percentage
46
//was specified.
47
return 100000;
48     }
49
50     private static PercentBaseContext pseudoContextForValidation = null;
51     
52     /** @return a base context for validation purposes. See class description. */
53     public static PercentBaseContext getPseudoContextForValidationPurposes() {
54         if (pseudoContextForValidation == null) {
55             pseudoContextForValidation = new ValidationPercentBaseContext();
56         }
57         return pseudoContextForValidation;
58     }
59     
60 }
61
Popular Tags