< prev index next >

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

Print this page


   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                                     }


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 a comment.
2235      *
2236      * @param text The comment text starting from first charcater.
2237      * @param length The number of characters in comment.
2238      */
2239     protected abstract void comm(char[] text, int length);
2240 
2241     /**
2242      * Reports a processing instruction.
2243      *
2244      * @param target The processing instruction target name.
2245      * @param body The processing instruction body text.
2246      */
2247     protected abstract void pi(String target, String body)
2248             throws Exception;
2249 
2250     /**
2251      * 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                                     }


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


< prev index next >