Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DefinitionConfigParser |
|
|
1.0;1 |
1 | /* |
|
2 | * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | */ |
|
16 | package de.smartics.properties.spi.config.definition; |
|
17 | ||
18 | import java.io.InputStream; |
|
19 | ||
20 | import de.smartics.properties.api.core.domain.ConfigException; |
|
21 | import de.smartics.util.lang.classpath.ClassPathContext; |
|
22 | ||
23 | /** |
|
24 | * Parses the <code>definition.xml</code> file for properties. |
|
25 | * |
|
26 | * @param <T> the type of context the parser creates. |
|
27 | */ |
|
28 | public interface DefinitionConfigParser<T extends PropertiesDefinitionContext> |
|
29 | { |
|
30 | /** |
|
31 | * Convenience method using a class' class loader to locate the configuration |
|
32 | * file to parse the configuration file at |
|
33 | * {@link de.smartics.properties.api.core.domain.PropertiesContext#DEFINITION_FILE}. |
|
34 | * |
|
35 | * @param type the type whose class loader to use to locate the configuration |
|
36 | * file. |
|
37 | * @return the read configuration, never <code>null</code>. |
|
38 | * @throws ConfigException on any problem loading the file. |
|
39 | */ |
|
40 | T parse(Class<?> type) throws ConfigException; |
|
41 | ||
42 | /** |
|
43 | * Parses the configuration file at |
|
44 | * {@link de.smartics.properties.api.core.domain.PropertiesContext#DEFINITION_FILE}. |
|
45 | * |
|
46 | * @param context the class loader with its context to use to locate the |
|
47 | * configuration file. |
|
48 | * @return the read configuration, never <code>null</code>. |
|
49 | * @throws ConfigException on any problem loading the file. |
|
50 | */ |
|
51 | T parse(ClassPathContext context) |
|
52 | throws ConfigException; |
|
53 | ||
54 | /** |
|
55 | * Parses the <code>definition.xml</code> from the given stream. |
|
56 | * |
|
57 | * @param systemId the identifier of the resource on the stream. |
|
58 | * @param input the <code>definition.xml</code> on the stream. |
|
59 | * @return the parsed context. |
|
60 | * @throws ConfigException on any problem reading from the stream. |
|
61 | */ |
|
62 | T parse(String systemId, InputStream input) |
|
63 | throws ConfigException; |
|
64 | } |