author | aefimov |
Thu, 16 Feb 2017 13:14:39 +0300 | |
changeset 43852 | 93a527059d8a |
parent 25871 | b80b84e87032 |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
2 |
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
12009 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.xml.internal.xsom.impl; |
|
27 |
||
28 |
import com.sun.xml.internal.xsom.XSElementDecl; |
|
29 |
import com.sun.xml.internal.xsom.XSIdentityConstraint; |
|
30 |
import com.sun.xml.internal.xsom.XSXPath; |
|
31 |
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl; |
|
32 |
import com.sun.xml.internal.xsom.visitor.XSFunction; |
|
33 |
import com.sun.xml.internal.xsom.visitor.XSVisitor; |
|
34 |
import org.xml.sax.Locator; |
|
35 |
||
36 |
import java.util.Collections; |
|
37 |
import java.util.List; |
|
38 |
||
39 |
/** |
|
40 |
* {@link XSIdentityConstraint} implementation. |
|
41 |
* |
|
42 |
* @author Kohsuke Kawaguchi |
|
43 |
*/ |
|
44 |
public class IdentityConstraintImpl extends ComponentImpl implements XSIdentityConstraint, Ref.IdentityConstraint { |
|
45 |
||
46 |
private XSElementDecl parent; |
|
47 |
private final short category; |
|
48 |
private final String name; |
|
49 |
private final XSXPath selector; |
|
50 |
private final List<XSXPath> fields; |
|
51 |
private final Ref.IdentityConstraint refer; |
|
52 |
||
53 |
public IdentityConstraintImpl(SchemaDocumentImpl _owner, AnnotationImpl _annon, Locator _loc, |
|
54 |
ForeignAttributesImpl fa, short category, String name, XPathImpl selector, |
|
55 |
List<XPathImpl> fields, Ref.IdentityConstraint refer) { |
|
56 |
||
57 |
super(_owner, _annon, _loc, fa); |
|
58 |
this.category = category; |
|
59 |
this.name = name; |
|
60 |
this.selector = selector; |
|
61 |
selector.setParent(this); |
|
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
62 |
this.fields = (List<XSXPath>) Collections.unmodifiableList((List<? extends XSXPath>)fields); |
12009 | 63 |
for( XPathImpl xp : fields ) |
64 |
xp.setParent(this); |
|
65 |
this.refer = refer; |
|
66 |
} |
|
67 |
||
68 |
||
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
69 |
@Override |
12009 | 70 |
public void visit(XSVisitor visitor) { |
71 |
visitor.identityConstraint(this); |
|
72 |
} |
|
73 |
||
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
74 |
@Override |
12009 | 75 |
public <T> T apply(XSFunction<T> function) { |
76 |
return function.identityConstraint(this); |
|
77 |
} |
|
78 |
||
79 |
public void setParent(ElementDecl parent) { |
|
80 |
this.parent = parent; |
|
81 |
parent.getOwnerSchema().addIdentityConstraint(this); |
|
82 |
} |
|
83 |
||
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
84 |
@Override |
12009 | 85 |
public XSElementDecl getParent() { |
86 |
return parent; |
|
87 |
} |
|
88 |
||
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
89 |
@Override |
12009 | 90 |
public String getName() { |
91 |
return name; |
|
92 |
} |
|
93 |
||
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
94 |
@Override |
12009 | 95 |
public String getTargetNamespace() { |
96 |
return getParent().getTargetNamespace(); |
|
97 |
} |
|
98 |
||
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
99 |
@Override |
12009 | 100 |
public short getCategory() { |
101 |
return category; |
|
102 |
} |
|
103 |
||
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
104 |
@Override |
12009 | 105 |
public XSXPath getSelector() { |
106 |
return selector; |
|
107 |
} |
|
108 |
||
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
109 |
@Override |
12009 | 110 |
public List<XSXPath> getFields() { |
111 |
return fields; |
|
112 |
} |
|
113 |
||
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
114 |
@Override |
12009 | 115 |
public XSIdentityConstraint getReferencedKey() { |
116 |
if(category==KEYREF) |
|
117 |
return refer.get(); |
|
118 |
else |
|
119 |
throw new IllegalStateException("not a keyref"); |
|
120 |
} |
|
121 |
||
43852
93a527059d8a
8174735: Update JAX-WS RI integration to latest version
aefimov
parents:
25871
diff
changeset
|
122 |
@Override |
12009 | 123 |
public XSIdentityConstraint get() { |
124 |
return this; |
|
125 |
} |
|
126 |
} |