PropertyListWalker.java
3.72 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.kohsuke.rngom.rngparser.digested.DAttributePattern
* org.kohsuke.rngom.rngparser.digested.DContainerPattern
* org.kohsuke.rngom.rngparser.digested.DElementPattern
* org.kohsuke.rngom.rngparser.digested.DInterleavePattern
* org.kohsuke.rngom.rngparser.digested.DPattern
* org.kohsuke.rngom.rngparser.digested.DPatternVisitor
* org.kohsuke.rngom.rngparser.digested.DXmlTokenPattern
*/
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.PropertyWithQualifierWalker;
import com.adobe.xmp.schema.rng.parser.utils.RNGUtils;
import java.util.ArrayList;
import javax.xml.namespace.QName;
import org.kohsuke.rngom.rngparser.digested.DAttributePattern;
import org.kohsuke.rngom.rngparser.digested.DContainerPattern;
import org.kohsuke.rngom.rngparser.digested.DElementPattern;
import org.kohsuke.rngom.rngparser.digested.DInterleavePattern;
import org.kohsuke.rngom.rngparser.digested.DPattern;
import org.kohsuke.rngom.rngparser.digested.DPatternVisitor;
import org.kohsuke.rngom.rngparser.digested.DXmlTokenPattern;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
class PropertyListWalker
extends BasePatternWalker {
private ArrayList<PropertyInfo> propInfoList;
private boolean rdfAboutFound;
PropertyListWalker(ArrayList<PropertyInfo> propInfoList, Context context) {
this.relativeDepth = -1;
this.propInfoList = propInfoList;
this.context = context;
this.rdfAboutFound = false;
}
@Override
public Void onElement(DElementPattern p) {
super.handleAnnotation((DPattern)p, this.context, null);
QName qName = RNGUtils.getSimpleName(p);
Integer n = this.relativeDepth;
Integer n2 = this.relativeDepth = Integer.valueOf(this.relativeDepth + 1);
if (!RNGUtils.isElementRDFDesc(qName)) {
throw new RNGUnexpectedElementFoundException("Expected rdf:desc but could not find it");
}
return this.onXmlToken((DXmlTokenPattern)p);
}
@Override
protected Void onContainer(DContainerPattern p) {
Integer n = this.relativeDepth;
Integer n2 = this.relativeDepth = Integer.valueOf(this.relativeDepth + 1);
SchemaInfo schemaInfo = new SchemaInfo();
this.context.setCurrentSchemaInfo(schemaInfo);
for (DPattern c = p.firstChild(); c != null; c = c.getNext()) {
PropertyInfo pInfo;
PropertyWithQualifierWalker propertyWalker = new PropertyWithQualifierWalker(this.context);
c.accept((DPatternVisitor)propertyWalker);
if (propertyWalker.isIgnoreProperty() || (pInfo = propertyWalker.getPropInfo()) == null) continue;
this.propInfoList.add(pInfo);
}
return null;
}
@Override
public Void onInterleave(DInterleavePattern p) {
Integer n = this.relativeDepth;
Integer n2 = this.relativeDepth = Integer.valueOf(this.relativeDepth + 1);
super.handleAnnotation((DPattern)p, this.context, null);
return this.onContainer((DContainerPattern)p);
}
public Void onAttribute(DAttributePattern p) {
if (this.relativeDepth == 0) {
this.rdfAboutFound = RNGUtils.isElementRDFAbout(RNGUtils.getSimpleName(p));
}
return null;
}
boolean isRdfAboutFound() {
return this.rdfAboutFound;
}
}