1 3 56 57 package org.jboss.util.xml.catalog.readers; 58 59 import java.io.InputStream ; 60 import java.io.IOException ; 61 import java.net.MalformedURLException ; 62 import java.util.Vector ; 63 64 import org.jboss.util.xml.catalog.Catalog; 65 import org.jboss.util.xml.catalog.CatalogEntry; 66 import org.jboss.util.xml.catalog.CatalogException; 67 68 89 public class TR9401CatalogReader extends TextCatalogReader { 90 91 105 public void readCatalog(Catalog catalog, InputStream is) 106 throws MalformedURLException , IOException { 107 108 catfile = is; 109 110 if (catfile == null) { 111 return; 112 } 113 114 Vector unknownEntry = null; 115 116 while (true) { 117 String token = nextToken(); 118 119 if (token == null) { 120 if (unknownEntry != null) { 121 catalog.unknownEntry(unknownEntry); 122 unknownEntry = null; 123 } 124 catfile.close(); 125 catfile = null; 126 return; 127 } 128 129 String entryToken = null; 130 if (caseSensitive) { 131 entryToken = token; 132 } else { 133 entryToken = token.toUpperCase(); 134 } 135 136 if (entryToken.equals("DELEGATE")) { 137 entryToken = "DELEGATE_PUBLIC"; 138 } 139 140 try { 141 int type = CatalogEntry.getEntryType(entryToken); 142 int numArgs = CatalogEntry.getEntryArgCount(type); 143 Vector args = new Vector (); 144 145 if (unknownEntry != null) { 146 catalog.unknownEntry(unknownEntry); 147 unknownEntry = null; 148 } 149 150 for (int count = 0; count < numArgs; count++) { 151 args.addElement(nextToken()); 152 } 153 154 catalog.addEntry(new CatalogEntry(entryToken, args)); 155 } catch (CatalogException cex) { 156 if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) { 157 if (unknownEntry == null) { 158 unknownEntry = new Vector (); 159 } 160 unknownEntry.addElement(token); 161 } else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) { 162 catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", token); 163 unknownEntry = null; 164 } 165 } 166 } 167 } 168 } 169 | Popular Tags |