< prev index next >

jdk/make/src/classes/build/tools/dtdbuilder/DTDParser.java

Print this page


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


 891                 /* fall through */
 892 
 893               case ' ':
 894               case '\t':
 895               case '\n':
 896                 ch = in.read();
 897                 break;
 898             }
 899         }
 900     }
 901 
 902     /**
 903      * Parse a DTD.
 904      * @return the dtd or null if an error occurred.
 905      */
 906     DTD parse(InputStream in, DTDBuilder dtd) {
 907         try {
 908             this.dtd = dtd;
 909             this.in = new DTDInputStream(in, dtd);
 910 
 911             long tm = System.currentTimeMillis();
 912             ch = this.in.read();
 913             parseSection();
 914 
 915             if (ch != -1) {
 916                 error("premature");
 917             }
 918 
 919             tm = System.currentTimeMillis() - tm;
 920             System.err.println("[Parsed DTD " + dtd + " in " + tm + "ms]");
 921         } catch (IOException e) {
 922             error("ioexception");
 923         } catch (Exception e) {
 924             error("exception", e.getClass().getName(), e.getMessage());
 925             e.printStackTrace();
 926         } catch (ThreadDeath e) {
 927             error("terminated");
 928         }
 929         return (nerrors > 0) ? null : dtd;
 930     }
 931 }
   1 /*
   2  * Copyright (c) 1998, 2016, 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


 891                 /* fall through */
 892 
 893               case ' ':
 894               case '\t':
 895               case '\n':
 896                 ch = in.read();
 897                 break;
 898             }
 899         }
 900     }
 901 
 902     /**
 903      * Parse a DTD.
 904      * @return the dtd or null if an error occurred.
 905      */
 906     DTD parse(InputStream in, DTDBuilder dtd) {
 907         try {
 908             this.dtd = dtd;
 909             this.in = new DTDInputStream(in, dtd);
 910 

 911             ch = this.in.read();
 912             parseSection();
 913 
 914             if (ch != -1) {
 915                 error("premature");
 916             }



 917         } catch (IOException e) {
 918             error("ioexception");
 919         } catch (Exception e) {
 920             error("exception", e.getClass().getName(), e.getMessage());
 921             e.printStackTrace();
 922         } catch (ThreadDeath e) {
 923             error("terminated");
 924         }
 925         return (nerrors > 0) ? null : dtd;
 926     }
 927 }
< prev index next >