1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package sk.uniba.euromath.document.schema;
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21 import javax.xml.namespace.QName;
22 import sk.uniba.euromath.document.schema.plug.IAttributeListRuleP;
23 import sk.uniba.euromath.document.schema.plug.IAttributeRuleP;
24 import sk.uniba.euromath.document.schema.plug.INameListP;
25 /***
26 * Wraps the <code>AttributeListRuleP</code> interface.
27 * @author Martin Vysny
28 */
29 public class AttributeListRule {
30 private final IAttributeListRuleP listRule;
31 /***
32 * Constructs a wrapper instance.
33 * @param listRule wrap this rule.
34 */
35 public AttributeListRule(IAttributeListRuleP listRule) {
36 super();
37 this.listRule = listRule;
38 }
39 /***
40 * Returns lists of creatable attributes. Each <code>NameListP</code>
41 * instance describes one attribute rule, with possible multiple names. So,
42 * for one NameListP instance, each QName in map
43 * <code>NameListP.getLocalNames()</code> must map to one instance of
44 * <code>AttributeRule</code>.
45 * @return list of creatable attributes.
46 */
47 public List<INameList<AttributeRule>> getList() {
48 List<? extends INameListP<? extends IAttributeRuleP>> list = listRule.getList();
49 List<INameList<AttributeRule>> result = new ArrayList<INameList<AttributeRule>>(
50 list.size());
51 for (INameListP<? extends IAttributeRuleP> nl : list) {
52 result.add(new NameListWrapper<AttributeRule, IAttributeRuleP>(nl,
53 providerInstance));
54 }
55 return result;
56 }
57 /***
58 * The data provider for namelist.
59 * @author Martin Vysny
60 */
61 private class ForeignAttributesProvider implements
62 INameListWrapperDataProvider<IAttributeRuleP> {
63
64
65
66
67 public Map<QName,IAttributeRuleP> getForeignRules(INameListP original) {
68 return SchemaPool.getInstance().getExportedAttributes(
69 original.getNamespaceUri(), original);
70 }
71 }
72 /***
73 * The instance of the data provider.
74 */
75 private final ForeignAttributesProvider providerInstance = new ForeignAttributesProvider();
76 }