PropertyWithQualifierWalker.java
3.8 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.kohsuke.rngom.rngparser.digested.DElementPattern
* org.kohsuke.rngom.rngparser.digested.DOptionalPattern
* org.kohsuke.rngom.rngparser.digested.DPattern
* org.kohsuke.rngom.rngparser.digested.DPatternVisitor
* org.kohsuke.rngom.rngparser.digested.DUnaryPattern
*/
package com.adobe.xmp.schema.rng.parser.traverser;
import com.adobe.xmp.schema.rng.model.Context;
import com.adobe.xmp.schema.rng.model.PropertyInfo;
import com.adobe.xmp.schema.rng.model.SchemaInfo;
import com.adobe.xmp.schema.rng.parser.SchemaGenerationHandler;
import com.adobe.xmp.schema.rng.parser.exceptions.RNGParseException;
import com.adobe.xmp.schema.rng.parser.traverser.BasePatternWalker;
import com.adobe.xmp.schema.rng.parser.traverser.BasePropertyWalker;
import com.adobe.xmp.schema.rng.parser.utils.RNGUtils;
import javax.xml.namespace.QName;
import org.kohsuke.rngom.rngparser.digested.DElementPattern;
import org.kohsuke.rngom.rngparser.digested.DOptionalPattern;
import org.kohsuke.rngom.rngparser.digested.DPattern;
import org.kohsuke.rngom.rngparser.digested.DPatternVisitor;
import org.kohsuke.rngom.rngparser.digested.DUnaryPattern;
class PropertyWithQualifierWalker
extends BasePatternWalker {
private boolean ignoreProperty;
PropertyWithQualifierWalker(PropertyInfo propertyInfo, Context context) {
this.relativeDepth = -1;
this.propertyInfo = propertyInfo;
this.context = context;
this.ignoreProperty = false;
}
PropertyWithQualifierWalker(Context context) {
this.relativeDepth = -1;
this.propertyInfo = new PropertyInfo("", "", context.getCurrentSchemaInfo());
this.context = context;
this.ignoreProperty = false;
}
public Void onOptional(DOptionalPattern p) {
super.handleAnnotation((DPattern)p, this.context, this.propertyInfo);
Integer n = this.relativeDepth;
Integer n2 = this.relativeDepth = Integer.valueOf(this.relativeDepth + 1);
if (this.relativeDepth != 0) {
throw new RNGParseException("rng:choice should be topmost element while defining a property");
}
this.propertyInfo.setMandatory(false);
return this.onUnary((DUnaryPattern)p);
}
public Void onElement(DElementPattern p) {
super.handleAnnotation((DPattern)p, this.context, this.propertyInfo);
Integer n = this.relativeDepth;
Integer n2 = this.relativeDepth = Integer.valueOf(this.relativeDepth + 1);
if (this.propertyInfo.isMandatory() && this.relativeDepth != 0) {
throw new RNGParseException("rng:element with property name should be topmost element while defining a property");
}
QName qName = RNGUtils.getSimpleName(p);
String ns = qName.getNamespaceURI();
String localName = qName.getLocalPart();
String prefix = qName.getPrefix();
if (this.context.getCurrentSchemaInfo().getPrefix() == null) {
this.context.getCurrentSchemaInfo().setPrefix(prefix);
}
this.context.getSchemaGenerationHandler().startPropertyConstruction(ns, localName, prefix);
this.propertyInfo.setName(localName);
this.propertyInfo.setNS(ns);
BasePropertyWalker baseProp = new BasePropertyWalker(this.propertyInfo, this.context);
try {
this.getChild((DUnaryPattern)p).accept((DPatternVisitor)baseProp);
}
catch (RNGParseException ex) {
if (this.context.getSchemaGenerationHandler().ignoreErrorInConstructingProperty(ns, localName, ex)) {
this.ignoreProperty = true;
}
throw ex;
}
return null;
}
PropertyInfo getPropInfo() {
return this.propertyInfo;
}
boolean isIgnoreProperty() {
return this.ignoreProperty;
}
}