< prev index next >

src/share/classes/jdk/internal/util/xml/impl/Parser.java

Print this page
rev 13658 : 8213325: (props) Properties.loadFromXML does not fully comply with the spec
Reviewed-by: alanb, rriggs, dfuchs, naoto
   1 /*
   2  * Copyright (c) 2012, 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


 633                             break;
 634 
 635                         default:
 636                             panic(FAULT);
 637                     }
 638                     break;
 639 
 640                 default:
 641                     panic(FAULT);
 642             }
 643         }
 644     }
 645 
 646     /**
 647      * Parses the document type declaration subset.
 648      *
 649      * @exception Exception is parser specific exception form panic method.
 650      * @exception IOException
 651      */
 652     private void dtdsub() throws Exception {


 653         char ch;
 654         for (short st = 0; st >= 0;) {
 655             ch = getch();
 656             switch (st) {
 657                 case 0:     // skip white spaces before a declaration
 658                     switch (chtyp(ch)) {
 659                         case '<':
 660                             ch = getch();
 661                             switch (ch) {
 662                                 case '?':
 663                                     pi();
 664                                     break;
 665 
 666                                 case '!':
 667                                     ch = getch();
 668                                     bkch();
 669                                     if (ch == '-') {
 670                                         comm();
 671                                         break;
 672                                     }


2210                 {
2211                     break;
2212                 }
2213             } else {
2214                 break;
2215             }
2216         }
2217         mChIdx--;  // bkch();
2218         return ch;
2219     }
2220 
2221     /**
2222      * Reports document type.
2223      *
2224      * @param name The name of the entity.
2225      * @param pubid The public identifier of the entity or <code>null</code>.
2226      * @param sysid The system identifier of the entity or <code>null</code>.
2227      */
2228     protected abstract void docType(String name, String pubid, String sysid)
2229             throws SAXException;







2230 
2231     /**
2232      * Reports a comment.
2233      *
2234      * @param text The comment text starting from first charcater.
2235      * @param length The number of characters in comment.
2236      */
2237     protected abstract void comm(char[] text, int length);
2238 
2239     /**
2240      * Reports a processing instruction.
2241      *
2242      * @param target The processing instruction target name.
2243      * @param body The processing instruction body text.
2244      */
2245     protected abstract void pi(String target, String body)
2246             throws Exception;
2247 
2248     /**
2249      * Reports new namespace prefix. The Namespace prefix (


   1 /*
   2  * Copyright (c) 2012, 2018, 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


 633                             break;
 634 
 635                         default:
 636                             panic(FAULT);
 637                     }
 638                     break;
 639 
 640                 default:
 641                     panic(FAULT);
 642             }
 643         }
 644     }
 645 
 646     /**
 647      * Parses the document type declaration subset.
 648      *
 649      * @exception Exception is parser specific exception form panic method.
 650      * @exception IOException
 651      */
 652     private void dtdsub() throws Exception {
 653         startInternalSub(); // reports the event before parsing the subset
 654 
 655         char ch;
 656         for (short st = 0; st >= 0;) {
 657             ch = getch();
 658             switch (st) {
 659                 case 0:     // skip white spaces before a declaration
 660                     switch (chtyp(ch)) {
 661                         case '<':
 662                             ch = getch();
 663                             switch (ch) {
 664                                 case '?':
 665                                     pi();
 666                                     break;
 667 
 668                                 case '!':
 669                                     ch = getch();
 670                                     bkch();
 671                                     if (ch == '-') {
 672                                         comm();
 673                                         break;
 674                                     }


2212                 {
2213                     break;
2214                 }
2215             } else {
2216                 break;
2217             }
2218         }
2219         mChIdx--;  // bkch();
2220         return ch;
2221     }
2222 
2223     /**
2224      * Reports document type.
2225      *
2226      * @param name The name of the entity.
2227      * @param pubid The public identifier of the entity or <code>null</code>.
2228      * @param sysid The system identifier of the entity or <code>null</code>.
2229      */
2230     protected abstract void docType(String name, String pubid, String sysid)
2231             throws SAXException;
2232 
2233     /**
2234      * Reports the start of DTD internal subset.
2235      *
2236      * @throws SAXException if the receiver throws SAXException
2237      */
2238     public abstract void startInternalSub () throws SAXException;
2239 
2240     /**
2241      * Reports a comment.
2242      *
2243      * @param text The comment text starting from first charcater.
2244      * @param length The number of characters in comment.
2245      */
2246     protected abstract void comm(char[] text, int length);
2247 
2248     /**
2249      * Reports a processing instruction.
2250      *
2251      * @param target The processing instruction target name.
2252      * @param body The processing instruction body text.
2253      */
2254     protected abstract void pi(String target, String body)
2255             throws Exception;
2256 
2257     /**
2258      * Reports new namespace prefix. The Namespace prefix (


< prev index next >