Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 1 | /* |
| 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 Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 19 | package org.apache.felix.scrplugin.helper; |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 20 | |
| 21 | import java.util.Map; |
| 22 | |
Carsten Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 23 | public class MetatypeAttributeDefinition { |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 24 | |
Carsten Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 25 | private static final String DEFAULT_TYPE = "String"; |
Carsten Ziegeler | 266800a | 2007-12-06 12:48:09 +0000 | [diff] [blame] | 26 | |
Carsten Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 27 | private String id; |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 28 | |
Carsten Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 29 | private String type = DEFAULT_TYPE; |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 30 | |
Carsten Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 31 | private String defaultValue; |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 32 | |
Carsten Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 33 | private String name; |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 34 | |
Carsten Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 35 | private String[] defaultMultiValue; |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 36 | |
Carsten Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 37 | private String description; |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 38 | |
Carsten Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 39 | private Integer cardinality; |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 40 | |
Carsten Ziegeler | 646b818 | 2012-08-31 07:47:57 +0000 | [diff] [blame] | 41 | private Map<String, String> options; |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 42 | |
| 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 Meschberger | 3b06bcb | 2007-08-29 14:06:57 +0000 | [diff] [blame] | 56 | // do not overwrite default or currently set type |
| 57 | if (type != null) { |
| 58 | this.type = type; |
| 59 | } |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Carsten Ziegeler | 3fc4643 | 2013-04-23 13:37:33 +0000 | [diff] [blame] | 62 | public String getDefaultValue() { |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 63 | return this.defaultValue; |
| 64 | } |
| 65 | |
| 66 | public void setDefaultValue(String defaultValue) { |
Felix Meschberger | 3b06bcb | 2007-08-29 14:06:57 +0000 | [diff] [blame] | 67 | if (defaultValue != null) { |
| 68 | this.defaultValue = defaultValue; |
| 69 | this.defaultMultiValue = null; |
| 70 | } |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | public void setDefaultMultiValue(String[] values) { |
Felix Meschberger | 3b06bcb | 2007-08-29 14:06:57 +0000 | [diff] [blame] | 74 | if (values != null) { |
| 75 | this.defaultValue = null; |
| 76 | this.defaultMultiValue = values; |
Carsten Ziegeler | 266800a | 2007-12-06 12:48:09 +0000 | [diff] [blame] | 77 | if (values.length > 0 && this.cardinality == null ) { |
Felix Meschberger | 3b06bcb | 2007-08-29 14:06:57 +0000 | [diff] [blame] | 78 | this.cardinality = new Integer(Integer.MAX_VALUE); |
| 79 | } |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 80 | } |
| 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 Ziegeler | 5de92da | 2009-03-31 17:12:40 +0000 | [diff] [blame] | 111 | public Map<String, String> getOptions() { |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 112 | return this.options; |
| 113 | } |
| 114 | |
Carsten Ziegeler | 5de92da | 2009-03-31 17:12:40 +0000 | [diff] [blame] | 115 | public void setOptions(Map<String, String> options) { |
Carsten Ziegeler | 4ccaaeb | 2007-08-20 07:20:03 +0000 | [diff] [blame] | 116 | this.options = options; |
| 117 | } |
| 118 | } |