01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.internal;
16:
17: import java.util.List;
18: import java.util.Map;
19:
20: import org.apache.tapestry.OptionGroupModel;
21: import org.apache.tapestry.OptionModel;
22:
23: public final class OptionGroupModelImpl implements OptionGroupModel {
24: private final String _label;
25:
26: private final boolean _disabled;
27:
28: private final List<OptionModel> _options;
29:
30: private final Map<String, String> _attributes;
31:
32: public OptionGroupModelImpl(String label, boolean disabled,
33: List<OptionModel> options, String... attributeKeysAndValues) {
34: this (
35: label,
36: disabled,
37: options,
38: attributeKeysAndValues.length == 0 ? null
39: : TapestryInternalUtils
40: .mapFromKeysAndValues(attributeKeysAndValues));
41: }
42:
43: public OptionGroupModelImpl(String label, boolean disabled,
44: List<OptionModel> options, Map<String, String> attributes) {
45: _label = label;
46: _disabled = disabled;
47: _options = options;
48: _attributes = attributes;
49: }
50:
51: public Map<String, String> getAttributes() {
52: return _attributes;
53: }
54:
55: public String getLabel() {
56: return _label;
57: }
58:
59: public List<OptionModel> getOptions() {
60: return _options;
61: }
62:
63: public boolean isDisabled() {
64: return _disabled;
65: }
66:
67: @Override
68: public String toString() {
69: return String.format("OptionGroupModel[%s]", _label);
70: }
71:
72: }
|