src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/framework/AbstractDocument.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   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.tools.internal.ws.wsdl.framework;
  27 
  28 import com.sun.tools.internal.ws.wsdl.parser.MetadataFinder;
  29 import com.sun.tools.internal.ws.wsdl.parser.DOMForest;
  30 import com.sun.tools.internal.ws.wscompile.ErrorReceiver;
  31 import com.sun.tools.internal.ws.wscompile.AbortException;
  32 import com.sun.tools.internal.ws.resources.WsdlMessages;
  33 
  34 import javax.xml.namespace.QName;
  35 import java.util.*;
  36 
  37 import org.xml.sax.helpers.LocatorImpl;
  38 
  39 /**
  40  * An abstract class for documents containing entities.
  41  *
  42  * @author WS Development Team
  43  */
  44 public abstract class AbstractDocument {
  45 
  46     protected final DOMForest forest;
  47     protected final ErrorReceiver errReceiver;
  48 
  49     protected AbstractDocument(MetadataFinder forest, ErrorReceiver errReceiver) {
  50         this.forest = forest;
  51         this.errReceiver = errReceiver;
  52         kinds = new HashMap();
  53         importedEntities = new ArrayList();
  54         importedDocuments = new HashSet();
  55         includedEntities = new ArrayList();
  56         includedDocuments = new HashSet();
  57     }
  58 


 146 
 147     public void validateLocally() {
 148         LocallyValidatingAction action = new LocallyValidatingAction();
 149         withAllSubEntitiesDo(action);
 150         if (action.getException() != null) {
 151             throw action.getException();
 152         }
 153     }
 154 
 155     public abstract void validate(EntityReferenceValidator validator);
 156 
 157     protected abstract Entity getRoot();
 158 
 159     private final Map kinds;
 160     private String _systemId;
 161     private final Set importedDocuments;
 162     private final List importedEntities;
 163     private final Set includedDocuments;
 164     private final List includedEntities;
 165 
 166     private class LocallyValidatingAction implements EntityAction {
 167         public LocallyValidatingAction() {
 168         }
 169 

 170         public void perform(Entity entity) {
 171             try {
 172                 entity.validateThis();
 173                 entity.withAllSubEntitiesDo(this);
 174             } catch (ValidationException e) {
 175                 if (_exception == null) {
 176                     _exception = e;
 177                 }
 178             }
 179         }
 180 
 181         public ValidationException getException() {
 182             return _exception;
 183         }
 184 
 185         private ValidationException _exception;
 186     }
 187 }
   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   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.tools.internal.ws.wsdl.framework;
  27 
  28 import com.sun.tools.internal.ws.wsdl.parser.MetadataFinder;
  29 import com.sun.tools.internal.ws.wsdl.parser.DOMForest;
  30 import com.sun.tools.internal.ws.wscompile.ErrorReceiver;
  31 import com.sun.tools.internal.ws.wscompile.AbortException;
  32 import com.sun.tools.internal.ws.resources.WsdlMessages;
  33 
  34 import javax.xml.namespace.QName;
  35 import java.util.*;
  36 


  37 /**
  38  * An abstract class for documents containing entities.
  39  *
  40  * @author WS Development Team
  41  */
  42 public abstract class AbstractDocument {
  43 
  44     protected final DOMForest forest;
  45     protected final ErrorReceiver errReceiver;
  46 
  47     protected AbstractDocument(MetadataFinder forest, ErrorReceiver errReceiver) {
  48         this.forest = forest;
  49         this.errReceiver = errReceiver;
  50         kinds = new HashMap();
  51         importedEntities = new ArrayList();
  52         importedDocuments = new HashSet();
  53         includedEntities = new ArrayList();
  54         includedDocuments = new HashSet();
  55     }
  56 


 144 
 145     public void validateLocally() {
 146         LocallyValidatingAction action = new LocallyValidatingAction();
 147         withAllSubEntitiesDo(action);
 148         if (action.getException() != null) {
 149             throw action.getException();
 150         }
 151     }
 152 
 153     public abstract void validate(EntityReferenceValidator validator);
 154 
 155     protected abstract Entity getRoot();
 156 
 157     private final Map kinds;
 158     private String _systemId;
 159     private final Set importedDocuments;
 160     private final List importedEntities;
 161     private final Set includedDocuments;
 162     private final List includedEntities;
 163 
 164     private static class LocallyValidatingAction implements EntityAction {
 165         public LocallyValidatingAction() {
 166         }
 167 
 168         @Override
 169         public void perform(Entity entity) {
 170             try {
 171                 entity.validateThis();
 172                 entity.withAllSubEntitiesDo(this);
 173             } catch (ValidationException e) {
 174                 if (_exception == null) {
 175                     _exception = e;
 176                 }
 177             }
 178         }
 179 
 180         public ValidationException getException() {
 181             return _exception;
 182         }
 183 
 184         private ValidationException _exception;
 185     }
 186 }