1 /* |
1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
57 super(_owner, _annon, _loc, fa); |
57 super(_owner, _annon, _loc, fa); |
58 this.category = category; |
58 this.category = category; |
59 this.name = name; |
59 this.name = name; |
60 this.selector = selector; |
60 this.selector = selector; |
61 selector.setParent(this); |
61 selector.setParent(this); |
62 this.fields = Collections.unmodifiableList((List<? extends XSXPath>)fields); |
62 this.fields = (List<XSXPath>) Collections.unmodifiableList((List<? extends XSXPath>)fields); |
63 for( XPathImpl xp : fields ) |
63 for( XPathImpl xp : fields ) |
64 xp.setParent(this); |
64 xp.setParent(this); |
65 this.refer = refer; |
65 this.refer = refer; |
66 } |
66 } |
67 |
67 |
68 |
68 |
|
69 @Override |
69 public void visit(XSVisitor visitor) { |
70 public void visit(XSVisitor visitor) { |
70 visitor.identityConstraint(this); |
71 visitor.identityConstraint(this); |
71 } |
72 } |
72 |
73 |
|
74 @Override |
73 public <T> T apply(XSFunction<T> function) { |
75 public <T> T apply(XSFunction<T> function) { |
74 return function.identityConstraint(this); |
76 return function.identityConstraint(this); |
75 } |
77 } |
76 |
78 |
77 public void setParent(ElementDecl parent) { |
79 public void setParent(ElementDecl parent) { |
78 this.parent = parent; |
80 this.parent = parent; |
79 parent.getOwnerSchema().addIdentityConstraint(this); |
81 parent.getOwnerSchema().addIdentityConstraint(this); |
80 } |
82 } |
81 |
83 |
|
84 @Override |
82 public XSElementDecl getParent() { |
85 public XSElementDecl getParent() { |
83 return parent; |
86 return parent; |
84 } |
87 } |
85 |
88 |
|
89 @Override |
86 public String getName() { |
90 public String getName() { |
87 return name; |
91 return name; |
88 } |
92 } |
89 |
93 |
|
94 @Override |
90 public String getTargetNamespace() { |
95 public String getTargetNamespace() { |
91 return getParent().getTargetNamespace(); |
96 return getParent().getTargetNamespace(); |
92 } |
97 } |
93 |
98 |
|
99 @Override |
94 public short getCategory() { |
100 public short getCategory() { |
95 return category; |
101 return category; |
96 } |
102 } |
97 |
103 |
|
104 @Override |
98 public XSXPath getSelector() { |
105 public XSXPath getSelector() { |
99 return selector; |
106 return selector; |
100 } |
107 } |
101 |
108 |
|
109 @Override |
102 public List<XSXPath> getFields() { |
110 public List<XSXPath> getFields() { |
103 return fields; |
111 return fields; |
104 } |
112 } |
105 |
113 |
|
114 @Override |
106 public XSIdentityConstraint getReferencedKey() { |
115 public XSIdentityConstraint getReferencedKey() { |
107 if(category==KEYREF) |
116 if(category==KEYREF) |
108 return refer.get(); |
117 return refer.get(); |
109 else |
118 else |
110 throw new IllegalStateException("not a keyref"); |
119 throw new IllegalStateException("not a keyref"); |
111 } |
120 } |
112 |
121 |
|
122 @Override |
113 public XSIdentityConstraint get() { |
123 public XSIdentityConstraint get() { |
114 return this; |
124 return this; |
115 } |
125 } |
116 } |
126 } |