src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/SAXConnector.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


 127     public void endPrefixMapping(String prefix) throws SAXException {
 128         if (logger.isLoggable(Level.FINER)) {
 129             logger.log(Level.FINER, "SAXConnector.endPrefixMapping: {0}", new Object[]{prefix});
 130         }
 131         next.endPrefixMapping(prefix);
 132     }
 133 
 134     @Override
 135     public void startElement(String uri, String local, String qname, Attributes atts) throws SAXException {
 136         if (logger.isLoggable(Level.FINER)) {
 137             logger.log(Level.FINER, "SAXConnector.startElement: {0}:{1}:{2}, attrs: {3}", new Object[]{uri, local, qname, atts});
 138         }
 139         // work gracefully with misconfigured parsers that don't support namespaces
 140         if( uri==null || uri.length()==0 )
 141             uri="";
 142         if( local==null || local.length()==0 )
 143             local=qname;
 144         if( qname==null || qname.length()==0 )
 145             qname=local;
 146 
 147 
 148         boolean ignorable = true;
 149         StructureLoader sl;
 150 
 151         // not null only if element content is processed (StructureLoader is used)
 152         // ugly
 153         if((sl = this.context.getStructureLoader()) != null) {
 154             ignorable = ((ClassBeanInfoImpl)sl.getBeanInfo()).hasElementOnlyContentModel();
 155         }
 156 
 157         processText(ignorable);
 158 
 159         tagName.uri = uri;
 160         tagName.local = local;
 161         tagName.qname = qname;
 162         tagName.atts = atts;
 163         next.startElement(tagName);
 164     }
 165 
 166     @Override
 167     public void endElement(String uri, String localName, String qName) throws SAXException {
 168         if (logger.isLoggable(Level.FINER)) {
 169             logger.log(Level.FINER, "SAXConnector.startElement: {0}:{1}:{2}", new Object[]{uri, localName, qName});
 170         }
 171         processText(false);
 172         tagName.uri = uri;
 173         tagName.local = localName;
 174         tagName.qname = qName;
 175         next.endElement(tagName);
 176     }
 177 


 187 
 188     @Override
 189     public final void ignorableWhitespace( char[] buf, int start, int len ) {
 190         if (logger.isLoggable(Level.FINEST)) {
 191             logger.log(Level.FINEST, "SAXConnector.characters{0}", buf);
 192         }
 193         characters(buf,start,len);
 194     }
 195 
 196     @Override
 197     public void processingInstruction(String target, String data) {
 198         // nop
 199     }
 200 
 201     @Override
 202     public void skippedEntity(String name) {
 203         // nop
 204     }
 205 
 206     private void processText( boolean ignorable ) throws SAXException {
 207         if( predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer)))
 208             next.text(buffer);
 209         buffer.setLength(0);
 210     }
 211 
 212 }
   1 /*
   2  * Copyright (c) 1997, 2014, 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


 127     public void endPrefixMapping(String prefix) throws SAXException {
 128         if (logger.isLoggable(Level.FINER)) {
 129             logger.log(Level.FINER, "SAXConnector.endPrefixMapping: {0}", new Object[]{prefix});
 130         }
 131         next.endPrefixMapping(prefix);
 132     }
 133 
 134     @Override
 135     public void startElement(String uri, String local, String qname, Attributes atts) throws SAXException {
 136         if (logger.isLoggable(Level.FINER)) {
 137             logger.log(Level.FINER, "SAXConnector.startElement: {0}:{1}:{2}, attrs: {3}", new Object[]{uri, local, qname, atts});
 138         }
 139         // work gracefully with misconfigured parsers that don't support namespaces
 140         if( uri==null || uri.length()==0 )
 141             uri="";
 142         if( local==null || local.length()==0 )
 143             local=qname;
 144         if( qname==null || qname.length()==0 )
 145             qname=local;
 146 
 147         processText(!context.getCurrentState().isMixed());










 148 
 149         tagName.uri = uri;
 150         tagName.local = local;
 151         tagName.qname = qname;
 152         tagName.atts = atts;
 153         next.startElement(tagName);
 154     }
 155 
 156     @Override
 157     public void endElement(String uri, String localName, String qName) throws SAXException {
 158         if (logger.isLoggable(Level.FINER)) {
 159             logger.log(Level.FINER, "SAXConnector.startElement: {0}:{1}:{2}", new Object[]{uri, localName, qName});
 160         }
 161         processText(false);
 162         tagName.uri = uri;
 163         tagName.local = localName;
 164         tagName.qname = qName;
 165         next.endElement(tagName);
 166     }
 167 


 177 
 178     @Override
 179     public final void ignorableWhitespace( char[] buf, int start, int len ) {
 180         if (logger.isLoggable(Level.FINEST)) {
 181             logger.log(Level.FINEST, "SAXConnector.characters{0}", buf);
 182         }
 183         characters(buf,start,len);
 184     }
 185 
 186     @Override
 187     public void processingInstruction(String target, String data) {
 188         // nop
 189     }
 190 
 191     @Override
 192     public void skippedEntity(String name) {
 193         // nop
 194     }
 195 
 196     private void processText( boolean ignorable ) throws SAXException {
 197         if (predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer)))
 198             next.text(buffer);
 199         buffer.setLength(0);
 200     }
 201 
 202 }