Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*     */ package org.apache.xml.resolver.tools;
  /*     */ 
  /*     */ import java.io.IOException;
  /*     */ import java.io.InputStream;
  /*     */ import java.io.PrintStream;
  /*     */ import java.net.MalformedURLException;
  /*     */ import java.net.URL;
  /*     */ import java.util.Locale;
  /*     */ import javax.xml.parsers.SAXParser;
 /*     */ import javax.xml.parsers.SAXParserFactory;
 /*     */ import org.apache.xml.resolver.Catalog;
 /*     */ import org.apache.xml.resolver.CatalogManager;
 /*     */ import org.apache.xml.resolver.helpers.Debug;
 /*     */ import org.xml.sax.AttributeList;
 /*     */ import org.xml.sax.DTDHandler;
 /*     */ import org.xml.sax.DocumentHandler;
 /*     */ import org.xml.sax.EntityResolver;
 /*     */ import org.xml.sax.ErrorHandler;
 /*     */ import org.xml.sax.InputSource;
 /*     */ import org.xml.sax.Locator;
 /*     */ import org.xml.sax.Parser;
 /*     */ import org.xml.sax.SAXException;
 /*     */ 
 /*     */ 

Deprecated:
 
 /*     */ public class ResolvingParser
 /*     */   implements ParserDTDHandlerDocumentHandlerEntityResolver
 /*     */ {
 /*  66 */   public static boolean namespaceAware = true;
 /*     */ 
 /*  69 */   public static boolean validating = false;
 /*     */ 
 /*  75 */   public static boolean suppressExplanation = false;
 /*     */ 
 /*  78 */   private SAXParser saxParser = null;
 /*     */ 
 /*  81 */   private Parser parser = null;
 /*     */ 
 /*  84 */   private DocumentHandler documentHandler = null;
 /*     */ 
 /*  87 */   private DTDHandler dtdHandler = null;
 /*     */ 
 /*  90 */   private CatalogManager catalogManager = CatalogManager.getStaticManager();
 /*     */ 
 /*  93 */   private CatalogResolver catalogResolver = null;
 /*     */ 
 /*  96 */   private CatalogResolver piCatalogResolver = null;
 /*     */ 
 /*  99 */   private boolean allowXMLCatalogPI = false;
 /*     */ 
 /* 102 */   private boolean oasisXMLCatalogPI = false;
 /*     */ 
 /* 105 */   private URL baseURL = null;
 /*     */ 
 /*     */   public ResolvingParser()
 /*     */   {
 /* 109 */     initParser();
 /*     */   }
 /*     */ 
 /*     */   public ResolvingParser(CatalogManager manager)
 /*     */   {
 /* 114 */     this. = manager;
 /* 115 */     initParser();
 /*     */   }
 /*     */ 
 /*     */   private void initParser()
 /*     */   {
 /* 120 */     this. = new CatalogResolver(this.);
 /*     */ 
 /* 122 */     SAXParserFactory spf = SAXParserFactory.newInstance();
 /* 123 */     spf.setNamespaceAware();
 /* 124 */     spf.setValidating();
 /*     */     try
 /*     */     {
 /* 127 */       this. = spf.newSAXParser();
 /* 128 */       this. = this..getParser();
 /* 129 */       this. = null;
 /* 130 */       this. = null;
 /*     */     } catch (Exception ex) {
 /* 132 */       ex.printStackTrace();
 /*     */     }
 /*     */   }
 /*     */ 
 /*     */   public Catalog getCatalog()
 /*     */   {
 /* 138 */     return this..getCatalog();
 /*     */   }
 /*     */ 
 /*     */   public void parse(InputSource input)
 /*     */     throws IOExceptionSAXException
 /*     */   {
 /* 165 */     setupParse(input.getSystemId());
 /*     */     try {
 /* 167 */       this..parse(input);
 /*     */     } catch (InternalError ie) {
 /* 169 */       explain(input.getSystemId());
 /* 170 */       throw ie;
 /*     */     }
 /*     */   }
/*     */ 
/*     */   public void parse(String systemId)
/*     */     throws IOExceptionSAXException
/*     */   {
/* 181 */     setupParse(systemId);
/*     */     try {
/* 183 */       this..parse(systemId);
/*     */     } catch (InternalError ie) {
/* 185 */       explain(systemId);
/* 186 */       throw ie;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDocumentHandler(DocumentHandler handler)
/*     */   {
/* 192 */     this. = handler;
/*     */   }
/*     */ 
/*     */   public void setDTDHandler(DTDHandler handler)
/*     */   {
/* 197 */     this. = handler;
/*     */   }
/*     */ 
/*     */   public void setEntityResolver(EntityResolver resolver)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void setErrorHandler(ErrorHandler handler)
/*     */   {
/* 212 */     this..setErrorHandler(handler);
/*     */   }
/*     */ 
/*     */   public void setLocale(Locale localethrows SAXException
/*     */   {
/* 217 */     this..setLocale(locale);
/*     */   }
/*     */ 
/*     */   public void characters(char[] chint startint length)
/*     */     throws SAXException
/*     */   {
/* 223 */     if (this. != null)
/* 224 */       this..characters(chstartlength);
/*     */   }
/*     */ 
/*     */   public void endDocument()
/*     */     throws SAXException
/*     */   {
/* 230 */     if (this. != null)
/* 231 */       this..endDocument();
/*     */   }
/*     */ 
/*     */   public void endElement(String name)
/*     */     throws SAXException
/*     */   {
/* 237 */     if (this. != null)
/* 238 */       this..endElement(name);
/*     */   }
/*     */ 
/*     */   public void ignorableWhitespace(char[] chint startint length)
/*     */     throws SAXException
/*     */   {
/* 245 */     if (this. != null)
/* 246 */       this..ignorableWhitespace(chstartlength);
/*     */   }
/*     */ 
/*     */   public void processingInstruction(String targetString pidata)
/*     */     throws SAXException
/*     */   {
/* 254 */     if (target.equals("oasis-xml-catalog")) {
/* 255 */       URL catalog = null;
/* 256 */       String data = pidata;
/*     */ 
/* 258 */       int pos = data.indexOf("catalog=");
/* 259 */       if (pos >= 0) {
/* 260 */         data = data.substring(pos + 8);
/* 261 */         if (data.length() > 1) {
/* 262 */           String quote = data.substring(0, 1);
/* 263 */           data = data.substring(1);
/* 264 */           pos = data.indexOf(quote);
/* 265 */           if (pos >= 0) {
/* 266 */             data = data.substring(0, pos);
/*     */             try {
/* 268 */               if (this. != null)
/* 269 */                 catalog = new URL(this.data);
/*     */               else {
/* 271 */                 catalog = new URL(data);
/*     */               }
/*     */             }
/*     */             catch (MalformedURLException mue)
/*     */             {
/*     */             }
/*     */           }
/*     */         }
/*     */       }
/* 280 */       if (this.) {
/* 281 */         if (this..getAllowOasisXMLCatalogPI()) {
/* 282 */           this...message(4, "oasis-xml-catalog PI"pidata);
/*     */ 
/* 284 */           if (catalog != null) {
/*     */             try {
/* 286 */               this...message(4, "oasis-xml-catalog"catalog.toString());
/* 287 */               this. = true;
/*     */ 
/* 289 */               if (this. == null) {
/* 290 */                 this. = new CatalogResolver(true);
/*     */               }
/*     */ 
/* 293 */               this..getCatalog().parseCatalog(catalog.toString());
/*     */             } catch (Exception e) {
/* 295 */               this...message(3, "Exception parsing oasis-xml-catalog: " + catalog.toString());
/*     */             }
/*     */           }
/*     */           else
/* 299 */             this...message(3, "PI oasis-xml-catalog unparseable: " + pidata);
/*     */         }
/*     */         else {
/* 302 */           this...message(4, "PI oasis-xml-catalog ignored: " + pidata);
/*     */         }
/*     */       }
/* 305 */       else this...message(3, "PI oasis-xml-catalog occurred in an invalid place: " + pidata);
/*     */ 
/*     */     }
/* 309 */     else if (this. != null) {
/* 310 */       this..processingInstruction(targetpidata);
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDocumentLocator(Locator locator)
/*     */   {
/* 317 */     if (this. != null)
/* 318 */       this..setDocumentLocator(locator);
/*     */   }
/*     */ 
/*     */   public void startDocument()
/*     */     throws SAXException
/*     */   {
/* 324 */     if (this. != null)
/* 325 */       this..startDocument();
/*     */   }
/*     */ 
/*     */   public void startElement(String nameAttributeList atts)
/*     */     throws SAXException
/*     */   {
/* 332 */     this. = false;
/* 333 */     if (this. != null)
/* 334 */       this..startElement(nameatts);
/*     */   }
/*     */ 
/*     */   public void notationDecl(String nameString publicIdString systemId)
/*     */     throws SAXException
/*     */   {
/* 341 */     this. = false;
/* 342 */     if (this. != null)
/* 343 */       this..notationDecl(namepublicIdsystemId);
/*     */   }
/*     */ 
/*     */   public void unparsedEntityDecl(String nameString publicIdString systemIdString notationName)
/*     */     throws SAXException
/*     */   {
/* 353 */     this. = false;
/* 354 */     if (this. != null)
/* 355 */       this..unparsedEntityDecl(namepublicIdsystemIdnotationName);
/*     */   }
/*     */ 
/*     */   public InputSource resolveEntity(String publicIdString systemId)
/*     */   {
/* 365 */     this. = false;
/* 366 */     String resolved = this..getResolvedEntity(publicIdsystemId);
/*     */ 
/* 368 */     if ((resolved == null) && (this. != null)) {
/* 369 */       resolved = this..getResolvedEntity(publicIdsystemId);
/*     */     }
/*     */ 
/* 372 */     if (resolved != null) {
/*     */       try {
/* 374 */         InputSource iSource = new InputSource(resolved);
/* 375 */         iSource.setPublicId(publicId);
/*     */ 
/* 388 */         URL url = new URL(resolved);
/* 389 */         InputStream iStream = url.openStream();
/* 390 */         iSource.setByteStream(iStream);
/*     */ 
/* 392 */         return iSource;
/*     */       } catch (Exception e) {
/* 394 */         this...message(1, "Failed to create InputSource (" + e.toString() + ")"resolved);
/*     */ 
/* 398 */         return null;
/*     */       }
/*     */     }
/* 401 */     return null;
/*     */   }
/*     */ 
/*     */   private void setupParse(String systemId)
/*     */   {
/* 407 */     this. = true;
/* 408 */     this..setEntityResolver(this);
/* 409 */     this..setDocumentHandler(this);
/* 410 */     this..setDTDHandler(this);
/*     */ 
/* 412 */     URL cwd = null;
/*     */     try
/*     */     {
/* 415 */       cwd = FileURL.makeURL("basename");
/*     */     } catch (MalformedURLException mue) {
/* 417 */       cwd = null;
/*     */     }
/*     */     try
/*     */     {
/* 421 */       this. = new URL(systemId);
/*     */     } catch (MalformedURLException mue) {
/* 423 */       if (cwd != null) {
/*     */         try {
/* 425 */           this. = new URL(cwdsystemId);
/*     */         }
/*     */         catch (MalformedURLException mue2) {
/* 428 */           this. = null;
/*     */         }
/*     */       }
/*     */       else
/* 432 */         this. = null;
/*     */     }
/*     */   }
/*     */ 
/*     */   private void explain(String systemId)
/*     */   {
/* 439 */     if (!) {
/* 440 */       ..println("Parser probably encountered bad URI in " + systemId);
/* 441 */       ..println("For example, replace '/some/uri' with 'file:/some/uri'.");
/*     */     }
/*     */   }
/*     */ }
/* Location:           /home/mnovotny/projects/EMBEDDED_JBOSS_BETA3_COMMUNITY/embedded/output/lib/embedded-jboss/lib/thirdparty-all.jar
 * Qualified Name:     org.apache.xml.resolver.tools.ResolvingParser
 * JD-Core Version:    0.6.0
 */
New to GrepCode? Check out our FAQ X