ArrayPropertyWalker.java
4.74 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.kohsuke.rngom.rngparser.digested.DAttributePattern
* org.kohsuke.rngom.rngparser.digested.DDefine
* org.kohsuke.rngom.rngparser.digested.DElementPattern
* org.kohsuke.rngom.rngparser.digested.DGroupPattern
* org.kohsuke.rngom.rngparser.digested.DOneOrMorePattern
* org.kohsuke.rngom.rngparser.digested.DPattern
* org.kohsuke.rngom.rngparser.digested.DPatternVisitor
* org.kohsuke.rngom.rngparser.digested.DRefPattern
* org.kohsuke.rngom.rngparser.digested.DUnaryPattern
* org.kohsuke.rngom.rngparser.digested.DZeroOrMorePattern
*/
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.exceptions.RNGUnexpectedElementFoundException;
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.DAttributePattern;
import org.kohsuke.rngom.rngparser.digested.DDefine;
import org.kohsuke.rngom.rngparser.digested.DElementPattern;
import org.kohsuke.rngom.rngparser.digested.DGroupPattern;
import org.kohsuke.rngom.rngparser.digested.DOneOrMorePattern;
import org.kohsuke.rngom.rngparser.digested.DPattern;
import org.kohsuke.rngom.rngparser.digested.DPatternVisitor;
import org.kohsuke.rngom.rngparser.digested.DRefPattern;
import org.kohsuke.rngom.rngparser.digested.DUnaryPattern;
import org.kohsuke.rngom.rngparser.digested.DZeroOrMorePattern;
class ArrayPropertyWalker
extends BasePatternWalker {
ArrayPropertyWalker(PropertyInfo propertyInfo, Context context) {
this.relativeDepth = -1;
this.propertyInfo = propertyInfo;
this.context = context;
}
public Void onZeroOrMore(DZeroOrMorePattern p) {
super.handleAnnotation((DPattern)p, this.context, this.propertyInfo);
return this.onUnary((DUnaryPattern)p);
}
public Void onOneOrMore(DOneOrMorePattern p) {
super.handleAnnotation((DPattern)p, this.context, this.propertyInfo);
return this.onUnary((DUnaryPattern)p);
}
public Void onElement(DElementPattern p) {
Integer n = this.relativeDepth;
Integer n2 = this.relativeDepth = Integer.valueOf(this.relativeDepth + 1);
super.handleAnnotation((DPattern)p, this.context, this.propertyInfo);
QName qName = RNGUtils.getSimpleName(p);
if (this.relativeDepth == 0) {
if (!RNGUtils.isElementArrayStart(qName)) {
throw new RNGUnexpectedElementFoundException("Expected rdf:li");
}
DPattern child = this.getChild((DUnaryPattern)p);
if (child instanceof DGroupPattern) {
DGroupPattern group = (DGroupPattern)child;
for (DPattern gChild : group) {
DPattern patt = null;
if (gChild instanceof DRefPattern) {
super.handleAnnotation(gChild, this.context, this.propertyInfo);
super.handleAnnotation(((DRefPattern)gChild).getTarget(), this.context, this.propertyInfo);
patt = ((DRefPattern)gChild).getTarget().getPattern();
super.handleAnnotation(patt, this.context, this.propertyInfo);
}
if (patt instanceof DAttributePattern) {
this.handleAttribute((DAttributePattern)patt);
continue;
}
if (patt == null) continue;
BasePropertyWalker bw = new BasePropertyWalker(this.propertyInfo, this.context);
patt.accept((DPatternVisitor)bw);
}
} else {
BasePropertyWalker bw = new BasePropertyWalker(this.propertyInfo, this.context);
child.accept((DPatternVisitor)bw);
}
}
return null;
}
private void handleAttribute(DAttributePattern p) {
super.handleAnnotation((DPattern)p, this.context, this.propertyInfo);
QName qName = RNGUtils.getSimpleName(p);
if (RNGUtils.isAttributeXMLLang(qName)) {
PropertyInfo langAlternative = new PropertyInfo("http://www.w3.org/XML/1998/namespace", "lang", this.context.getCurrentSchemaInfo());
langAlternative.setIsArrayItemQualifier(true);
BasePropertyWalker bw = new BasePropertyWalker(langAlternative, this.context);
this.getChild((DUnaryPattern)p).accept((DPatternVisitor)bw);
this.propertyInfo.addChild(langAlternative);
}
}
}