1 3 19 20 package com.sun.org.apache.xml.internal.resolver.readers; 21 22 import java.io.InputStream ; 23 import java.io.IOException ; 24 import java.net.MalformedURLException ; 25 import java.util.Vector ; 26 import com.sun.org.apache.xml.internal.resolver.Catalog; 27 import com.sun.org.apache.xml.internal.resolver.CatalogEntry; 28 import com.sun.org.apache.xml.internal.resolver.CatalogException; 29 30 51 public class TR9401CatalogReader extends TextCatalogReader { 52 53 68 public void readCatalog(Catalog catalog, InputStream is) 69 throws MalformedURLException , IOException { 70 71 catfile = is; 72 73 if (catfile == null) { 74 return; 75 } 76 77 Vector unknownEntry = null; 78 79 try { 80 while (true) { 81 String token = nextToken(); 82 83 if (token == null) { 84 if (unknownEntry != null) { 85 catalog.unknownEntry(unknownEntry); 86 unknownEntry = null; 87 } 88 catfile.close(); 89 catfile = null; 90 return; 91 } 92 93 String entryToken = null; 94 if (caseSensitive) { 95 entryToken = token; 96 } else { 97 entryToken = token.toUpperCase(); 98 } 99 100 if (entryToken.equals("DELEGATE")) { 101 entryToken = "DELEGATE_PUBLIC"; 102 } 103 104 try { 105 int type = CatalogEntry.getEntryType(entryToken); 106 int numArgs = CatalogEntry.getEntryArgCount(type); 107 Vector args = new Vector (); 108 109 if (unknownEntry != null) { 110 catalog.unknownEntry(unknownEntry); 111 unknownEntry = null; 112 } 113 114 for (int count = 0; count < numArgs; count++) { 115 args.addElement(nextToken()); 116 } 117 118 catalog.addEntry(new CatalogEntry(entryToken, args)); 119 } catch (CatalogException cex) { 120 if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { 121 if (unknownEntry == null) { 122 unknownEntry = new Vector (); 123 } 124 unknownEntry.addElement(token); 125 } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { 126 catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", token); 127 unknownEntry = null; 128 } else if (cex.getExceptionType() == CatalogException.UNENDED_COMMENT) { 129 catalog.getCatalogManager().debug.message(1, cex.getMessage()); 130 } 131 } 132 } 133 } catch (CatalogException cex2) { 134 if (cex2.getExceptionType() == CatalogException.UNENDED_COMMENT) { 135 catalog.getCatalogManager().debug.message(1, cex2.getMessage()); 136 } 137 } 138 139 } 140 } 141 | Popular Tags |