< prev index next >

src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/RejectDoctypeSaxFilter.java

Print this page


   1 /*
   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.
   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


  79         }
  80 
  81         // Set ourselves up to be the SAX LexicalHandler
  82         try {
  83             xmlReader.setProperty(LEXICAL_HANDLER_PROP, this);
  84         } catch (Exception e) {
  85             log.severe("SAAJ0603.util.setProperty.exception");
  86             throw new SOAPExceptionImpl(
  87             "Couldn't set the lexical handler property while constructing a RejectDoctypeSaxFilter",
  88             e);
  89         }
  90 
  91         // Set the parent XMLReader of this SAX filter
  92         setParent(xmlReader);
  93     }
  94 
  95     /*
  96      * Override setProperty() to capture any LexicalHandler that is set for
  97      * forwarding of events.
  98      */

  99     public void setProperty(String name, Object value)
 100     throws SAXNotRecognizedException, SAXNotSupportedException {
 101         if (LEXICAL_HANDLER_PROP.equals(name)) {
 102             lexicalHandler = (LexicalHandler) value;
 103         } else {
 104             super.setProperty(name, value);
 105         }
 106     }
 107 
 108     //
 109     // Beginning of SAX LexicalHandler callbacks...
 110     //
 111 

 112     public void startDTD(String name, String publicId, String systemId)
 113     throws SAXException {
 114         throw new SAXException("Document Type Declaration is not allowed");
 115     }
 116 

 117     public void endDTD() throws SAXException {
 118     }
 119 

 120     public void startEntity(String name) throws SAXException {
 121         if (lexicalHandler != null) {
 122             lexicalHandler.startEntity(name);
 123         }
 124     }
 125 

 126     public void endEntity(String name) throws SAXException {
 127         if (lexicalHandler != null) {
 128             lexicalHandler.endEntity(name);
 129         }
 130     }
 131 

 132     public void startCDATA() throws SAXException {
 133         if (lexicalHandler != null) {
 134             lexicalHandler.startCDATA();
 135         }
 136     }
 137 

 138     public void endCDATA() throws SAXException {
 139         if (lexicalHandler != null) {
 140             lexicalHandler.endCDATA();
 141         }
 142     }
 143 

 144     public void comment(char[] ch, int start, int length) throws SAXException {
 145         if (lexicalHandler != null) {
 146             lexicalHandler.comment(ch, start, length);
 147         }
 148     }
 149 
 150     //
 151     // End of SAX LexicalHandler callbacks
 152     //
 153 

 154     public void startElement(String namespaceURI, String localName,
 155     String qName, Attributes atts)   throws SAXException{
 156         if(atts != null ){
 157             boolean eos = false;
 158             if(namespaceURI == DSIG_NS || XENC_NS == namespaceURI){
 159                 eos = true;
 160             }
 161             int length = atts.getLength();
 162             AttributesImpl attrImpl = new AttributesImpl();
 163             for(int i=0; i< length;i++){
 164                 String name = atts.getLocalName(i);
 165                 if(name!=null && (name.equals("Id"))){
 166                     if(eos || atts.getURI(i) == WSU_NS ){
 167                         attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i),
 168                         atts.getQName(i), ID_NAME, atts.getValue(i));
 169                     }else{
 170                          attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i), atts.getQName(i), atts.getType(i), atts.getValue(i));
 171                     }
 172                 }else{
 173                     attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i),
   1 /*
   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.
   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


  79         }
  80 
  81         // Set ourselves up to be the SAX LexicalHandler
  82         try {
  83             xmlReader.setProperty(LEXICAL_HANDLER_PROP, this);
  84         } catch (Exception e) {
  85             log.severe("SAAJ0603.util.setProperty.exception");
  86             throw new SOAPExceptionImpl(
  87             "Couldn't set the lexical handler property while constructing a RejectDoctypeSaxFilter",
  88             e);
  89         }
  90 
  91         // Set the parent XMLReader of this SAX filter
  92         setParent(xmlReader);
  93     }
  94 
  95     /*
  96      * Override setProperty() to capture any LexicalHandler that is set for
  97      * forwarding of events.
  98      */
  99     @Override
 100     public void setProperty(String name, Object value)
 101     throws SAXNotRecognizedException, SAXNotSupportedException {
 102         if (LEXICAL_HANDLER_PROP.equals(name)) {
 103             lexicalHandler = (LexicalHandler) value;
 104         } else {
 105             super.setProperty(name, value);
 106         }
 107     }
 108 
 109     //
 110     // Beginning of SAX LexicalHandler callbacks...
 111     //
 112 
 113     @Override
 114     public void startDTD(String name, String publicId, String systemId)
 115     throws SAXException {
 116         throw new SAXException("Document Type Declaration is not allowed");
 117     }
 118 
 119     @Override
 120     public void endDTD() throws SAXException {
 121     }
 122 
 123     @Override
 124     public void startEntity(String name) throws SAXException {
 125         if (lexicalHandler != null) {
 126             lexicalHandler.startEntity(name);
 127         }
 128     }
 129 
 130     @Override
 131     public void endEntity(String name) throws SAXException {
 132         if (lexicalHandler != null) {
 133             lexicalHandler.endEntity(name);
 134         }
 135     }
 136 
 137     @Override
 138     public void startCDATA() throws SAXException {
 139         if (lexicalHandler != null) {
 140             lexicalHandler.startCDATA();
 141         }
 142     }
 143 
 144     @Override
 145     public void endCDATA() throws SAXException {
 146         if (lexicalHandler != null) {
 147             lexicalHandler.endCDATA();
 148         }
 149     }
 150 
 151     @Override
 152     public void comment(char[] ch, int start, int length) throws SAXException {
 153         if (lexicalHandler != null) {
 154             lexicalHandler.comment(ch, start, length);
 155         }
 156     }
 157 
 158     //
 159     // End of SAX LexicalHandler callbacks
 160     //
 161 
 162     @Override
 163     public void startElement(String namespaceURI, String localName,
 164     String qName, Attributes atts)   throws SAXException{
 165         if(atts != null ){
 166             boolean eos = false;
 167             if(namespaceURI == DSIG_NS || XENC_NS == namespaceURI){
 168                 eos = true;
 169             }
 170             int length = atts.getLength();
 171             AttributesImpl attrImpl = new AttributesImpl();
 172             for(int i=0; i< length;i++){
 173                 String name = atts.getLocalName(i);
 174                 if(name!=null && (name.equals("Id"))){
 175                     if(eos || atts.getURI(i) == WSU_NS ){
 176                         attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i),
 177                         atts.getQName(i), ID_NAME, atts.getValue(i));
 178                     }else{
 179                          attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i), atts.getQName(i), atts.getType(i), atts.getValue(i));
 180                     }
 181                 }else{
 182                     attrImpl.addAttribute(atts.getURI(i), atts.getLocalName(i),
< prev index next >