1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.archive.crawler.settings;
25
26 import javax.management.InvalidAttributeValueException;
27 import javax.management.MBeanAttributeInfo;
28
29 /***
30 *
31 * @author John Erik Halse
32 */
33 public class ModuleAttributeInfo extends MBeanAttributeInfo {
34
35 private static final long serialVersionUID = -4447321338690051514L;
36
37 private String type;
38 private boolean isOverrideable;
39 private boolean isTransient;
40 private final Object defaultValue;
41 private final Object legalValueLists[];
42 private boolean complexType = false;
43 private boolean isExpertSetting;
44
45 /*** Construct a new instance of ModuleAttributeInfo.
46 *
47 * @param type the element to create info for.
48 *
49 * @throws InvalidAttributeValueException
50 * @throws java.lang.IllegalArgumentException
51 */
52 public ModuleAttributeInfo(Type type)
53 throws InvalidAttributeValueException {
54
55 super(type.getName(), type.getClass().getName(), type.getDescription(),
56 true, true, false);
57 setType(type.getDefaultValue());
58 this.isOverrideable = type.isOverrideable();
59 this.isTransient = type.isTransient();
60 this.legalValueLists = type.getLegalValues();
61 this.isExpertSetting = type.isExpertSetting();
62
63 this.defaultValue = type.getValue();
64 if (type.getDefaultValue() instanceof ComplexType) {
65 complexType = true;
66 }
67 }
68
69 public ModuleAttributeInfo(ModuleAttributeInfo attr) {
70 super(attr.getName(), attr.getType(), attr.getDescription(),
71 true, true, false);
72 setType(attr.getDefaultValue());
73 this.isOverrideable = attr.isOverrideable();
74 this.isTransient = attr.isTransient();
75 this.legalValueLists = attr.getLegalValues();
76 this.isExpertSetting = attr.isExpertSetting();
77 this.defaultValue = attr.getDefaultValue();
78 this.complexType = attr.complexType;
79 }
80
81 public Object[] getLegalValues() {
82 return legalValueLists;
83 }
84
85 /*** Returns true if this attribute refers to a ComplexType.
86 *
87 * @return true if this attribute refers to a ComplexType.
88 */
89 public boolean isComplexType() {
90 return complexType;
91 }
92
93 /*** Returns true if this attribute could be overridden in per settings.
94 *
95 * @return True if overrideable.
96 */
97 public boolean isOverrideable() {
98 return isOverrideable;
99 }
100
101 /*** Returns true if this attribute should be hidden from UI and not be
102 * serialized to persistent storage.
103 *
104 * @return True if transient.
105 */
106 public boolean isTransient() {
107 return isTransient;
108 }
109
110 /*** Returns true if this Type should only show up in expert mode in UI.
111 *
112 * @return true if this Type should only show up in expert mode in UI.
113 */
114 public boolean isExpertSetting() {
115 return isExpertSetting;
116 }
117
118 /***
119 * @return Default value.
120 */
121 public Object getDefaultValue() {
122 return defaultValue;
123 }
124
125
126
127
128 public String getType() {
129 return type;
130 }
131
132 protected void setType(Object type) {
133 this.type = type.getClass().getName();
134 }
135 }