|
1 /* |
|
2 * reserved comment block |
|
3 * DO NOT REMOVE OR ALTER! |
|
4 */ |
|
5 /* |
|
6 * Copyright 1999-2004 The Apache Software Foundation. |
|
7 * |
|
8 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
9 * you may not use this file except in compliance with the License. |
|
10 * You may obtain a copy of the License at |
|
11 * |
|
12 * http://www.apache.org/licenses/LICENSE-2.0 |
|
13 * |
|
14 * Unless required by applicable law or agreed to in writing, software |
|
15 * distributed under the License is distributed on an "AS IS" BASIS, |
|
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
17 * See the License for the specific language governing permissions and |
|
18 * limitations under the License. |
|
19 */ |
|
20 /* |
|
21 * $Id: OutputPropertyUtils.java,v 1.2.4.1 2005/09/15 08:15:21 suresh_emailid Exp $ |
|
22 */ |
|
23 package com.sun.org.apache.xml.internal.serializer; |
|
24 |
|
25 import java.util.Properties; |
|
26 |
|
27 /** |
|
28 * This class contains some static methods that act as helpers when parsing a |
|
29 * Java Property object. |
|
30 * |
|
31 * This class is not a public API. |
|
32 * It is only public because it is used outside of this package. |
|
33 * |
|
34 * @see java.util.Properties |
|
35 * @xsl.usage internal |
|
36 */ |
|
37 public final class OutputPropertyUtils |
|
38 { |
|
39 /** |
|
40 * Searches for the boolean property with the specified key in the property list. |
|
41 * If the key is not found in this property list, the default property list, |
|
42 * and its defaults, recursively, are then checked. The method returns |
|
43 * <code>false</code> if the property is not found, or if the value is other |
|
44 * than "yes". |
|
45 * |
|
46 * @param key the property key. |
|
47 * @param props the list of properties that will be searched. |
|
48 * @return the value in this property list as a boolean value, or false |
|
49 * if null or not "yes". |
|
50 */ |
|
51 public static boolean getBooleanProperty(String key, Properties props) |
|
52 { |
|
53 |
|
54 String s = props.getProperty(key); |
|
55 |
|
56 if (null == s || !s.equals("yes")) |
|
57 return false; |
|
58 else |
|
59 return true; |
|
60 } |
|
61 |
|
62 /** |
|
63 * Searches for the int property with the specified key in the property list. |
|
64 * If the key is not found in this property list, the default property list, |
|
65 * and its defaults, recursively, are then checked. The method returns |
|
66 * <code>false</code> if the property is not found, or if the value is other |
|
67 * than "yes". |
|
68 * |
|
69 * @param key the property key. |
|
70 * @param props the list of properties that will be searched. |
|
71 * @return the value in this property list as a int value, or 0 |
|
72 * if null or not a number. |
|
73 */ |
|
74 public static int getIntProperty(String key, Properties props) |
|
75 { |
|
76 |
|
77 String s = props.getProperty(key); |
|
78 |
|
79 if (null == s) |
|
80 return 0; |
|
81 else |
|
82 return Integer.parseInt(s); |
|
83 } |
|
84 |
|
85 } |