blob: 66a4a41a22c377ee0ae0ef794f6da2c1c49e6118 [file] [log] [blame]
Pierre De Rop3a00a212015-03-01 09:27:46 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for additional information
4 * regarding copyright ownership. The ASF licenses this file to you under the Apache License,
5 * Version 2.0 (the "License"); you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless
7 * required by applicable law or agreed to in writing, software distributed under the License is
8 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
9 * or implied. See the License for the specific language governing permissions and limitations
10 * under the License.
11 */
12package org.apache.felix.dm;
13
14/**
15 * This interface defines meta data regarding a given configuration property.
16 *
17 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
18 */
19public interface PropertyMetaData {
20 /**
21 * The label used to display the property. Example: "Log Level".
22 *
23 * @return The label used to display the property (may be localized)
24 */
25 public PropertyMetaData setHeading(String heading);
26
27 /**
28 * The key of a ConfigurationAdmin property. Example: "printer.logLevel"
29 *
30 * @return The Configuration Admin property name
31 */
32 public PropertyMetaData setId(String id);
33
34 /**
35 * Returns the property primitive type. If must be either one of the following types:<p>
36 * <ul>
37 * <li>String.class</li>
38 * <li>Long.class</li>
39 * <li>Integer.class</li>
40 * <li>Character.class</li>
41 * <li>Byte.class</li>
42 * <li>Double.class</li>
43 * <li>Float.class</li>
44 * <li>Boolean.class</li>
45 * </ul>
46 */
47 public PropertyMetaData setType(Class<?> type);
48
49 /**
50 * Returns a default for this property. The object must be of the appropriate type as defined by the cardinality and getType().
51 * The return type is a list of String objects that can be converted to the appropriate type. The cardinality of the return
52 * array must follow the absolute cardinality of this type. E.g. if the cardinality = 0, the array must contain 1 element.
53 * If the cardinality is 1, it must contain 0 or 1 elements. If it is -5, it must contain from 0 to max 5 elements. Note that
54 * the special case of a 0 cardinality, meaning a single value, does not allow arrays or vectors of 0 elements.
55 */
56 public PropertyMetaData setDefaults(String[] defaults);
57
58 /**
59 * Returns the property description. The description may be localized and must describe the semantics of this type and any
60 * constraints. Example: "Select the log level for the Printer Service".
61 *
62 * @return a localizable description of the property.
63 */
64 public PropertyMetaData setDescription(String description);
65
66 /**
67 * Return the cardinality of this property. The OSGi environment handles multi valued properties in arrays ([]) or in Vector objects.
68 * The return value is defined as follows:<p>
69 *
70 * <ul>
71 * <li> x = Integer.MIN_VALUE no limit, but use Vector</li>
72 * <li> x < 0 -x = max occurrences, store in Vector</li>
73 * <li> x > 0 x = max occurrences, store in array []</li>
74 * <li> x = Integer.MAX_VALUE no limit, but use array []</li>
75 * <li> x = 0 1 occurrence required</li>
76 * </ul>
77 */
78 public PropertyMetaData setCardinality(int cardinality);
79
80 /**
81 * Tells if this property is required or not.
82 */
83 public PropertyMetaData setRequired(boolean required);
84
85 /**
86 * Return a list of valid options for this property (the labels may be localized).
87 *
88 * @return the list of valid options for this property.
89 */
90 public PropertyMetaData addOption(String optionLabel, String optionValue);
91}