1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/fastinfoset/tools/PrintTable.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,127 @@ 1.4 +/* 1.5 + * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + * 1.28 + * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. 1.29 + */ 1.30 + 1.31 +package com.sun.xml.internal.fastinfoset.tools; 1.32 + 1.33 +import com.sun.xml.internal.fastinfoset.QualifiedName; 1.34 +import java.io.File; 1.35 + 1.36 +import javax.xml.parsers.SAXParser; 1.37 +import javax.xml.parsers.SAXParserFactory; 1.38 + 1.39 +import com.sun.xml.internal.fastinfoset.util.CharArrayArray; 1.40 +import com.sun.xml.internal.fastinfoset.util.ContiguousCharArrayArray; 1.41 +import com.sun.xml.internal.fastinfoset.util.PrefixArray; 1.42 +import com.sun.xml.internal.fastinfoset.util.QualifiedNameArray; 1.43 +import com.sun.xml.internal.fastinfoset.util.StringArray; 1.44 +import com.sun.xml.internal.fastinfoset.vocab.ParserVocabulary; 1.45 + 1.46 + 1.47 +public class PrintTable { 1.48 + 1.49 + /** Creates a new instance of PrintTable */ 1.50 + public PrintTable() { 1.51 + } 1.52 + 1.53 + public static void printVocabulary(ParserVocabulary vocabulary) { 1.54 + printArray("Attribute Name Table", vocabulary.attributeName); 1.55 + printArray("Attribute Value Table", vocabulary.attributeValue); 1.56 + printArray("Character Content Chunk Table", vocabulary.characterContentChunk); 1.57 + printArray("Element Name Table", vocabulary.elementName); 1.58 + printArray("Local Name Table", vocabulary.localName); 1.59 + printArray("Namespace Name Table", vocabulary.namespaceName); 1.60 + printArray("Other NCName Table", vocabulary.otherNCName); 1.61 + printArray("Other String Table", vocabulary.otherString); 1.62 + printArray("Other URI Table", vocabulary.otherURI); 1.63 + printArray("Prefix Table", vocabulary.prefix); 1.64 + } 1.65 + 1.66 + public static void printArray(String title, StringArray a) { 1.67 + System.out.println(title); 1.68 + 1.69 + for (int i = 0; i < a.getSize(); i++) { 1.70 + System.out.println("" + (i + 1) + ": " + a.getArray()[i]); 1.71 + } 1.72 + } 1.73 + 1.74 + public static void printArray(String title, PrefixArray a) { 1.75 + System.out.println(title); 1.76 + 1.77 + for (int i = 0; i < a.getSize(); i++) { 1.78 + System.out.println("" + (i + 1) + ": " + a.getArray()[i]); 1.79 + } 1.80 + } 1.81 + 1.82 + public static void printArray(String title, CharArrayArray a) { 1.83 + System.out.println(title); 1.84 + 1.85 + for (int i = 0; i < a.getSize(); i++) { 1.86 + System.out.println("" + (i + 1) + ": " + a.getArray()[i]); 1.87 + } 1.88 + } 1.89 + 1.90 + public static void printArray(String title, ContiguousCharArrayArray a) { 1.91 + System.out.println(title); 1.92 + 1.93 + for (int i = 0; i < a.getSize(); i++) { 1.94 + System.out.println("" + (i + 1) + ": " + a.getString(i)); 1.95 + } 1.96 + } 1.97 + 1.98 + public static void printArray(String title, QualifiedNameArray a) { 1.99 + System.out.println(title); 1.100 + 1.101 + for (int i = 0; i < a.getSize(); i++) { 1.102 + QualifiedName name = a.getArray()[i]; 1.103 + System.out.println("" + (name.index + 1) + ": " + 1.104 + "{" + name.namespaceName + "}" + 1.105 + name.prefix + ":" + name.localName); 1.106 + } 1.107 + } 1.108 + 1.109 + /** 1.110 + * @param args the command line arguments 1.111 + */ 1.112 + public static void main(String[] args) { 1.113 + try { 1.114 + SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); 1.115 + saxParserFactory.setNamespaceAware(true); 1.116 + 1.117 + SAXParser saxParser = saxParserFactory.newSAXParser(); 1.118 + 1.119 + ParserVocabulary referencedVocabulary = new ParserVocabulary(); 1.120 + 1.121 + VocabularyGenerator vocabularyGenerator = new VocabularyGenerator(referencedVocabulary); 1.122 + File f = new File(args[0]); 1.123 + saxParser.parse(f, vocabularyGenerator); 1.124 + 1.125 + printVocabulary(referencedVocabulary); 1.126 + } catch (Exception e) { 1.127 + e.printStackTrace(); 1.128 + } 1.129 + } 1.130 +}