1
|
|
/*
|
2
|
|
* JBind
|
3
|
|
*
|
4
|
|
* Copyright (c) by Stefan Wachter. All rights reserved.
|
5
|
|
*
|
6
|
|
* Usage, modification, and redistribution is subject to license terms that are
|
7
|
|
* available at 'http://www.jbind.org'. The JBind license is like the
|
8
|
|
* 'Apache Software License V 1.1'.
|
9
|
|
*/
|
10
|
|
package org.jbind.xml.schema.element;
|
11
|
|
|
12
|
|
import org.jbind.xml.base.IAttribute;
|
13
|
|
import org.jbind.xml.base.IRef;
|
14
|
|
import org.jbind.xml.base.ISymbolspace;
|
15
|
|
import org.jbind.xml.base.ISymbolspaces;
|
16
|
|
import org.jbind.xml.core.cmp.IComponent;
|
17
|
|
import org.jbind.xml.core.cmp.IComponentStore;
|
18
|
|
import org.jbind.xml.core.content.IElemGroupDecl;
|
19
|
|
import org.jbind.xml.msg.IConstraintViolations;
|
20
|
|
import org.jbind.xml.msg.XmlException;
|
21
|
|
import org.jbind.xml.msg.XmlMessages;
|
22
|
|
import org.jbind.xml.schema.instantiation.IElemValHelper;
|
23
|
|
import org.jbind.xml.schema.instantiation.IElementHelper;
|
24
|
|
import org.jbind.xml.schema.instantiation.IHasTopLevelJobs;
|
25
|
|
import org.jbind.xml.schema.instantiation.IJobRefs;
|
26
|
|
|
27
|
|
public class ModelGroupRef extends Particle implements IModelGroupRef {
|
28
|
|
|
29
|
|
private IRef myRef = null;
|
30
|
|
|
31
|
80
|
public ModelGroupRef(CreationParams aCreationParams) {
|
32
|
80
|
super(aCreationParams);
|
33
|
|
}
|
34
|
|
|
35
|
122
|
protected IAttribute doCreateAttribute(ACParams anACParams) throws XmlException {
|
36
|
122
|
IAttribute res = null;
|
37
|
122
|
String an = NameUtil.getSchemaAttributeName(anACParams);
|
38
|
122
|
if ("ref".equals(an)) {
|
39
|
80
|
res = new RefAttribute(anACParams, ISymbolspaces.ELEMENT_GROUP);
|
40
|
80
|
myRef = res.getRef();
|
41
|
|
} else {
|
42
|
42
|
res = super.doCreateAttribute(anACParams);
|
43
|
|
}
|
44
|
122
|
return res;
|
45
|
|
}
|
46
|
|
|
47
|
291
|
public IRef getRef() {
|
48
|
291
|
return myRef;
|
49
|
|
}
|
50
|
|
|
51
|
3
|
public void setRef(IRef aRef) {
|
52
|
3
|
myRef = aRef;
|
53
|
|
}
|
54
|
|
|
55
|
80
|
public void validateElement(IElemValHelper aHelper, IConstraintViolations aViolations) {
|
56
|
80
|
super.validateElement(aHelper, aViolations);
|
57
|
80
|
if (null == myRef) {
|
58
|
0
|
aViolations.add(XmlMessages.missingAttribute("ref", this));
|
59
|
|
}
|
60
|
|
}
|
61
|
|
|
62
|
155
|
public void collectRefsForCreation(IJobRefs aJobRefs) {
|
63
|
155
|
aJobRefs.add(getRef(), true, this);
|
64
|
|
}
|
65
|
|
|
66
|
308
|
public void collectRefsForCompletion(IElementHelper anElementHelper, IJobRefs aJobRefs) {}
|
67
|
0
|
public void collectRefsForValidation(IElementHelper anElementHelper, IJobRefs aJobRefs) {}
|
68
|
|
|
69
|
79
|
public IComponent createComponent(IElementHelper aHelper, IConstraintViolations aViolations) {
|
70
|
79
|
IElemGroupDecl gc = (IElemGroupDecl)aHelper.getComponent(getRef(), true);
|
71
|
79
|
return gc.createReference(this, getRange());
|
72
|
|
}
|
73
|
79
|
public void completeComponent(IElementHelper aHelper, IComponent aComponent, IConstraintViolations aViolations) {}
|
74
|
|
|
75
|
79
|
public void addSchemaData(IComponentStore aStore, IComponent aComponent, IConstraintViolations aViolations) {}
|
76
|
0
|
public void createAndAddJob(IHasTopLevelJobs aHasTopLevelJobs) {}
|
77
|
0
|
public ISymbolspace getSymbolSpace() {
|
78
|
0
|
return ISymbolspaces.ELEMENT_GROUP;
|
79
|
|
}
|
80
|
0
|
public String getName() {
|
81
|
0
|
return myRef.getLocalPart();
|
82
|
|
}
|
83
|
|
}
|
84
|
|
|