1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2013, 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 |
30 import com.sun.tools.internal.ws.wscompile.ErrorReceiver; |
30 import com.sun.tools.internal.ws.wscompile.ErrorReceiver; |
31 |
31 |
32 import javax.xml.namespace.QName; |
32 import javax.xml.namespace.QName; |
33 import java.util.ArrayList; |
33 import java.util.ArrayList; |
34 import java.util.Iterator; |
34 import java.util.Iterator; |
35 import java.util.Set; |
|
36 |
35 |
37 /** |
36 /** |
38 * A WSDL document. |
37 * A WSDL document. |
39 * |
38 * |
40 * @author WS Development Team |
39 * @author WS Development Team |
108 |
107 |
109 public void accept(WSDLDocumentVisitor visitor) throws Exception { |
108 public void accept(WSDLDocumentVisitor visitor) throws Exception { |
110 _definitions.accept(visitor); |
109 _definitions.accept(visitor); |
111 } |
110 } |
112 |
111 |
|
112 @Override |
113 public void validate(EntityReferenceValidator validator) { |
113 public void validate(EntityReferenceValidator validator) { |
114 GloballyValidatingAction action = |
114 GloballyValidatingAction action = |
115 new GloballyValidatingAction(this, validator); |
115 new GloballyValidatingAction(this, validator); |
116 withAllSubEntitiesDo(action); |
116 withAllSubEntitiesDo(action); |
117 if (action.getException() != null) { |
117 if (action.getException() != null) { |
118 throw action.getException(); |
118 throw action.getException(); |
119 } |
119 } |
120 } |
120 } |
121 |
121 |
|
122 @Override |
122 protected Entity getRoot() { |
123 protected Entity getRoot() { |
123 return _definitions; |
124 return _definitions; |
124 } |
125 } |
125 |
126 |
126 private Definitions _definitions; |
127 private Definitions _definitions; |
127 |
128 |
128 private class GloballyValidatingAction |
129 private static class GloballyValidatingAction implements EntityAction, EntityReferenceAction { |
129 implements EntityAction, EntityReferenceAction { |
|
130 public GloballyValidatingAction( |
130 public GloballyValidatingAction( |
131 AbstractDocument document, |
131 AbstractDocument document, |
132 EntityReferenceValidator validator) { |
132 EntityReferenceValidator validator) { |
133 _document = document; |
133 _document = document; |
134 _validator = validator; |
134 _validator = validator; |
135 } |
135 } |
136 |
136 |
|
137 @Override |
137 public void perform(Entity entity) { |
138 public void perform(Entity entity) { |
138 try { |
139 try { |
139 entity.validateThis(); |
140 entity.validateThis(); |
140 entity.withAllEntityReferencesDo(this); |
141 entity.withAllEntityReferencesDo(this); |
141 entity.withAllSubEntitiesDo(this); |
142 entity.withAllSubEntitiesDo(this); |
144 _exception = e; |
145 _exception = e; |
145 } |
146 } |
146 } |
147 } |
147 } |
148 } |
148 |
149 |
|
150 @Override |
149 public void perform(Kind kind, QName name) { |
151 public void perform(Kind kind, QName name) { |
150 try { |
152 try { |
151 GloballyKnown entity = _document.find(kind, name); |
153 _document.find(kind, name); |
152 } catch (NoSuchEntityException e) { |
154 } catch (NoSuchEntityException e) { |
153 // failed to resolve, check with the validator |
155 // failed to resolve, check with the validator |
154 if (_exception == null) { |
156 if (_exception == null) { |
155 if (_validator == null |
157 if (_validator == null |
156 || !_validator.isValid(kind, name)) { |
158 || !_validator.isValid(kind, name)) { |