View Javadoc
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  package org.apache.any23.configuration;
19  
20  /**
21   * Defines the main <i>Any23</i> configuration.
22   */
23  public interface Configuration {
24  
25      /**
26       * Returns all the defined configuration properties.
27       *
28       * @return list of defined properties.
29       */
30      String[] getProperties();
31  
32      /**
33       * Checks whether a property is defined or not in configuration.
34       *
35       * @param propertyName
36       *            name of property to check.
37       * 
38       * @return <code>true</code> if defined, <code>false</code> otherwise.
39       */
40      boolean defineProperty(String propertyName);
41  
42      /**
43       * Returns the value of a specified property, of the default value if property is not defined.
44       *
45       * @param propertyName
46       *            name of property
47       * @param defaultValue
48       *            default value if not found.
49       * 
50       * @return the value associated to <i>propertyName</i>.
51       */
52      String getProperty(String propertyName, String defaultValue);
53  
54      /**
55       * Returns the value of the specified <code>propertyName</code> or raises an exception if <code>propertyName</code>
56       * is not defined.
57       *
58       * @param propertyName
59       *            name of property to be returned.
60       * 
61       * @return property value.
62       * 
63       * @throws IllegalArgumentException
64       *             if the property name is not defined or the found property value is blank or empty.
65       */
66      String getPropertyOrFail(String propertyName);
67  
68      /**
69       * Returns the {@link Integer} value of the specified <code>propertyName</code> or raises an exception if
70       * <code>propertyName</code> is not defined.
71       *
72       * @param propertyName
73       *            name of property to be returned.
74       * 
75       * @return property value.
76       * 
77       * @throws NullPointerException
78       *             if the property name is not defined.
79       * @throws IllegalArgumentException
80       *             if the found property value is blank or empty.
81       * @throws NumberFormatException
82       *             if the found property value is not a valid {@link Integer}.
83       */
84      int getPropertyIntOrFail(String propertyName);
85  
86      /**
87       * Returns the value of a <i> flag property</i>. Such properties can assume only two values:
88       * <ul>
89       * <li><code>on</code> if flag is active (<code>true</code> is returned).
90       * <li><code>off</code> if flag is inactive (<code>false</code> is returned).
91       * </ul>
92       *
93       * @param propertyName
94       *            name of property flag.
95       * 
96       * @return <code>true</code> for <code>on</code>, <code>false</code> for <code>off</code>.
97       * 
98       * @throws IllegalArgumentException
99       *             if the <code>propertyName</code> is not declared.
100      */
101     boolean getFlagProperty(final String propertyName);
102 
103     /**
104      * Returns a human readable string containing the configuration dump.
105      *
106      * @return a string describing the configuration options.
107      */
108     String getConfigurationDump();
109 
110 }