blob: 38701414b15eb27f2e20f14b76ba2885c27f6242 [file] [log] [blame]
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Carsten Ziegeler646b8182012-08-31 07:47:57 +000019package org.apache.felix.scrplugin.helper;
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000020
21import java.util.Map;
22
Carsten Ziegeler646b8182012-08-31 07:47:57 +000023public class MetatypeAttributeDefinition {
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000024
Carsten Ziegeler646b8182012-08-31 07:47:57 +000025 private static final String DEFAULT_TYPE = "String";
Carsten Ziegeler266800a2007-12-06 12:48:09 +000026
Carsten Ziegeler646b8182012-08-31 07:47:57 +000027 private String id;
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000028
Carsten Ziegeler646b8182012-08-31 07:47:57 +000029 private String type = DEFAULT_TYPE;
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000030
Carsten Ziegeler646b8182012-08-31 07:47:57 +000031 private String defaultValue;
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000032
Carsten Ziegeler646b8182012-08-31 07:47:57 +000033 private String name;
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000034
Carsten Ziegeler646b8182012-08-31 07:47:57 +000035 private String[] defaultMultiValue;
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000036
Carsten Ziegeler646b8182012-08-31 07:47:57 +000037 private String description;
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000038
Carsten Ziegeler646b8182012-08-31 07:47:57 +000039 private Integer cardinality;
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000040
Carsten Ziegeler646b8182012-08-31 07:47:57 +000041 private Map<String, String> options;
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000042
43 public String getId() {
44 return this.id;
45 }
46
47 public void setId(String id) {
48 this.id = id;
49 }
50
51 public String getType() {
52 return this.type;
53 }
54
55 public void setType(String type) {
Felix Meschberger3b06bcb2007-08-29 14:06:57 +000056 // do not overwrite default or currently set type
57 if (type != null) {
58 this.type = type;
59 }
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000060 }
61
Carsten Ziegeler3fc46432013-04-23 13:37:33 +000062 public String getDefaultValue() {
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000063 return this.defaultValue;
64 }
65
66 public void setDefaultValue(String defaultValue) {
Felix Meschberger3b06bcb2007-08-29 14:06:57 +000067 if (defaultValue != null) {
68 this.defaultValue = defaultValue;
69 this.defaultMultiValue = null;
70 }
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000071 }
72
73 public void setDefaultMultiValue(String[] values) {
Felix Meschberger3b06bcb2007-08-29 14:06:57 +000074 if (values != null) {
75 this.defaultValue = null;
76 this.defaultMultiValue = values;
Carsten Ziegeler266800a2007-12-06 12:48:09 +000077 if (values.length > 0 && this.cardinality == null ) {
Felix Meschberger3b06bcb2007-08-29 14:06:57 +000078 this.cardinality = new Integer(Integer.MAX_VALUE);
79 }
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +000080 }
81 }
82
83 public String[] getDefaultMultiValue() {
84 return this.defaultMultiValue;
85 }
86
87 public String getName() {
88 return this.name;
89 }
90
91 public void setName(String name) {
92 this.name = name;
93 }
94
95 public String getDescription() {
96 return this.description;
97 }
98
99 public void setDescription(String description) {
100 this.description = description;
101 }
102
103 public Integer getCardinality() {
104 return this.cardinality;
105 }
106
107 public void setCardinality(Integer cardinality) {
108 this.cardinality = cardinality;
109 }
110
Carsten Ziegeler5de92da2009-03-31 17:12:40 +0000111 public Map<String, String> getOptions() {
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +0000112 return this.options;
113 }
114
Carsten Ziegeler5de92da2009-03-31 17:12:40 +0000115 public void setOptions(Map<String, String> options) {
Carsten Ziegeler4ccaaeb2007-08-20 07:20:03 +0000116 this.options = options;
117 }
118}