PropertyDescriptionImpl.java
6.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xmp.schema.model.impl;
import com.adobe.xmp.schema.model.ArrayType;
import com.adobe.xmp.schema.model.PropertyDescription;
import com.adobe.xmp.schema.model.PropertyType;
import com.adobe.xmp.schema.model.SchemaVisitor;
import com.adobe.xmp.schema.model.UnspecifiedType;
import com.adobe.xmp.schema.model.XMPSchemaException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import javax.xml.namespace.QName;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class PropertyDescriptionImpl
implements PropertyDescription {
private String namespaceURI;
private String name;
private PropertyType type;
private ArrayList<PropertyDescription> qualifiers = new ArrayList();
private boolean mandatory;
private boolean deprecated;
private String label;
private String description;
private boolean readOnly;
private Map<QName, Map<String, String>> decoratorStore;
PropertyDescriptionImpl(String name, PropertyType type) {
this.name = name;
this.type = type;
}
@Override
public String getNamespaceURI() {
return this.namespaceURI;
}
@Override
public void setNamespaceURI(String namespaceURI) {
this.namespaceURI = namespaceURI;
}
@Override
public String getName() {
return this.name;
}
@Override
public PropertyType getType() {
return this.type;
}
@Override
public void replaceType(PropertyType finalType) {
if (this.type instanceof UnspecifiedType) {
this.type = finalType;
} else if (this.type instanceof ArrayType && ((ArrayType)this.type).getItemType() instanceof UnspecifiedType) {
((ArrayType)this.type).setItemType(finalType);
}
}
@Override
public void addQualifier(PropertyDescription qualifier) {
this.qualifiers.add(qualifier);
}
@Override
public boolean hasQualifiers() {
return this.qualifiers != null && !this.qualifiers.isEmpty();
}
@Override
public PropertyDescription getQualifier(String namespaceURI, String localName) {
for (PropertyDescription qualifier : this.qualifiers) {
if (!qualifier.getName().equals(localName) || !qualifier.getNamespaceURI().equals(namespaceURI)) continue;
return qualifier;
}
return null;
}
@Override
public List<PropertyDescription> getQualifiers() {
return this.qualifiers;
}
@Override
public void removeQualifier(String namespaceURI, String localName) {
Iterator<PropertyDescription> it = this.qualifiers.iterator();
while (it.hasNext()) {
PropertyDescription qualifier = it.next();
if (!qualifier.getName().equals(localName) || !qualifier.getNamespaceURI().equals(namespaceURI)) continue;
it.remove();
}
}
@Override
public void setMandatory(boolean mandatory) {
this.mandatory = mandatory;
}
@Override
public boolean isMandatory() {
return this.mandatory;
}
@Override
public boolean isDeprecated() {
return this.deprecated;
}
@Override
public void setDeprecated(boolean deprecated) {
this.deprecated = deprecated;
}
@Override
public boolean isReadOnly() {
return this.readOnly;
}
@Override
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
@Override
public String getLabel() {
return this.label;
}
@Override
public void setLabel(String label) {
this.label = label;
}
@Override
public String getDescription() {
return this.description;
}
@Override
public void setDescription(String description) {
this.description = description;
}
@Override
public void accept(SchemaVisitor schemaVisitor) throws XMPSchemaException {
schemaVisitor.visit(this);
}
@Override
public Map<String, String> getDecorator(String namespaceURI, String localName) {
QName qname = new QName(namespaceURI, localName);
Map<QName, Map<String, String>> decorators = this.getDecoratorStore();
Map<String, String> propertyValues = decorators.get(qname);
if (propertyValues == null) {
propertyValues = new TreeMap<String, String>();
decorators.put(qname, propertyValues);
}
return propertyValues;
}
@Override
public boolean hasDecorator(String namespaceURI, String localName) {
if (this.decoratorStore != null) {
QName qname = new QName(namespaceURI, localName);
Map<QName, Map<String, String>> decorators = this.getDecoratorStore();
if (decorators.containsKey(qname)) {
return decorators.get(qname).size() > 0;
}
}
return false;
}
@Override
public boolean hasDecorators() {
return this.decoratorStore != null && this.getDecoratorStore().size() > 0;
}
@Override
public Set<QName> getDecoratorSet() {
if (this.decoratorStore != null) {
Iterator<Map.Entry<QName, Map<String, String>>> it = this.decoratorStore.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<QName, Map<String, String>> entry = it.next();
if (entry.getValue() != null && entry.getValue().size() != 0) continue;
it.remove();
}
return this.decoratorStore.keySet();
}
return this.createSortedMap().keySet();
}
@Override
public void removeDecoratorNS(String namespaceURI) {
Iterator<QName> it = this.getDecoratorSet().iterator();
while (it.hasNext()) {
QName qname = it.next();
if (!qname.getNamespaceURI().equals(namespaceURI)) continue;
it.remove();
}
}
private Map<QName, Map<String, String>> getDecoratorStore() {
if (this.decoratorStore == null) {
this.decoratorStore = this.createSortedMap();
}
return this.decoratorStore;
}
private Map<QName, Map<String, String>> createSortedMap() {
return new TreeMap<QName, Map<String, String>>(new Comparator<QName>(){
@Override
public int compare(QName q1, QName q2) {
int result = q1.getNamespaceURI().compareTo(q2.getNamespaceURI());
if (result == 0) {
result = q1.getLocalPart().compareTo(q2.getLocalPart());
}
return result;
}
});
}
}