blob: 902f29392f616f0656650266d137d22a5f9e7689 [file] [log] [blame]
Pierre De Rop379ba3e2010-03-07 00:03:26 +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 */
Marcel Offermans8b93efa2010-07-02 18:27:21 +000012package org.apache.felix.dm;
Pierre De Ropa0204f52010-03-06 22:23:57 +000013
Pierre De Rop379ba3e2010-03-07 00:03:26 +000014/**
15 * This interface defines meta data regarding a given configuration property.
Marcel Offermans5be5f142011-04-26 10:47:12 +000016 *
17 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
Pierre De Rop379ba3e2010-03-07 00:03:26 +000018 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000019public interface PropertyMetaData {
Pierre De Ropa0204f52010-03-06 22:23:57 +000020 /**
21 * The label used to display the property. Example: "Log Level".
Marcel Offermanscba269a2013-01-18 11:00:56 +000022 *
Pierre De Ropa0204f52010-03-06 22:23:57 +000023 * @return The label used to display the property (may be localized)
24 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000025 public PropertyMetaData setHeading(String heading);
Pierre De Ropa0204f52010-03-06 22:23:57 +000026
27 /**
28 * The key of a ConfigurationAdmin property. Example: "printer.logLevel"
Marcel Offermanscba269a2013-01-18 11:00:56 +000029 *
Pierre De Ropa0204f52010-03-06 22:23:57 +000030 * @return The Configuration Admin property name
31 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000032 public PropertyMetaData setId(String id);
Pierre De Ropa0204f52010-03-06 22:23:57 +000033
34 /**
Pierre De Rop379ba3e2010-03-07 00:03:26 +000035 * Returns the property primitive type. If must be either one of the following types:<p>
Pierre De Ropa0204f52010-03-06 22:23:57 +000036 * <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 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000047 public PropertyMetaData setType(Class type);
Pierre De Ropa0204f52010-03-06 22:23:57 +000048
49 /**
Pierre De Rop379ba3e2010-03-07 00:03:26 +000050 * Returns a default for this property. The object must be of the appropriate type as defined by the cardinality and getType().
Pierre De Ropa0204f52010-03-06 22:23:57 +000051 * 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 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000056 public PropertyMetaData setDefaults(String[] defaults);
Pierre De Ropa0204f52010-03-06 22:23:57 +000057
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".
Marcel Offermanscba269a2013-01-18 11:00:56 +000061 *
Pierre De Rop379ba3e2010-03-07 00:03:26 +000062 * @return a localizable description of the property.
Pierre De Ropa0204f52010-03-06 22:23:57 +000063 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000064 public PropertyMetaData setDescription(String description);
Pierre De Ropa0204f52010-03-06 22:23:57 +000065
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 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000078 public PropertyMetaData setCardinality(int cardinality);
Pierre De Ropa0204f52010-03-06 22:23:57 +000079
80 /**
81 * Tells if this property is required or not.
82 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000083 public PropertyMetaData setRequired(boolean required);
Pierre De Ropa0204f52010-03-06 22:23:57 +000084
85 /**
86 * Return a list of valid options for this property (the labels may be localized).
Marcel Offermanscba269a2013-01-18 11:00:56 +000087 *
Pierre De Ropa0204f52010-03-06 22:23:57 +000088 * @return the list of valid options for this property.
89 */
Marcel Offermansfaaed472010-09-08 10:07:32 +000090 public PropertyMetaData addOption(String optionLabel, String optionValue);
Pierre De Ropa0204f52010-03-06 22:23:57 +000091}