Author: vmassol
Date: 2007-12-01 20:35:38 +0100 (Sat, 01 Dec 2007)
New Revision: 6221

Modified:
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/api/PdfExport.java
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/PdfExportImpl.java
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/PdfURLFactory.java
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/XWikiURIResolver.java
Log:
Reformat code

Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/api/PdfExport.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/api/PdfExport.java
     2007-11-30 17:37:18 UTC (rev 6220)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/api/PdfExport.java
     2007-12-01 19:35:38 UTC (rev 6221)
@@ -18,7 +18,6 @@
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  *
  */
-
 package com.xpn.xwiki.pdf.api;
 
 import com.xpn.xwiki.XWikiContext;
@@ -27,11 +26,17 @@
 
 import java.io.OutputStream;
 
-public interface PdfExport {
+public interface PdfExport
+{
     public void exportXHtml(byte[] xhtml, OutputStream out, int type, 
XWikiContext context) throws XWikiException;
+
     public void exportHtml(String xhtml, OutputStream out, int type, 
XWikiContext context) throws XWikiException;
+
     public void export(XWikiDocument doc, OutputStream out, int type, 
XWikiContext context) throws XWikiException;
+
     public void exportToPDF(XWikiDocument doc, OutputStream out, XWikiContext 
context) throws XWikiException;
+
     public byte[] convertToStrictXHtml(byte[] input, XWikiContext context);
+
     public byte[] convertXHtmlToXMLFO(byte[] input, XWikiContext context) 
throws XWikiException;
 }

Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/PdfExportImpl.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/PdfExportImpl.java
        2007-11-30 17:37:18 UTC (rev 6220)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/PdfExportImpl.java
        2007-12-01 19:35:38 UTC (rev 6221)
@@ -18,38 +18,20 @@
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  *
  */
-
 package com.xpn.xwiki.pdf.impl;
 
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.objects.BaseObject;
+import com.xpn.xwiki.pdf.api.PdfExport;
+import com.xpn.xwiki.util.Util;
+import com.xpn.xwiki.web.XWikiRequest;
 import info.informatica.doc.dom4j.CSSStylableElement;
 import info.informatica.doc.dom4j.XHTMLDocument;
 import info.informatica.doc.dom4j.XHTMLDocumentFactory;
 import info.informatica.doc.style.css.dom.DOMCSSStyleSheet;
 import info.informatica.doc.xml.dtd.DefaultEntityResolver;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Properties;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXResult;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -67,24 +49,44 @@
 import org.w3c.tidy.Tidy;
 import org.xml.sax.InputSource;
 
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.XWikiException;
-import com.xpn.xwiki.doc.XWikiDocument;
-import com.xpn.xwiki.objects.BaseObject;
-import com.xpn.xwiki.pdf.api.PdfExport;
-import com.xpn.xwiki.util.Util;
-import com.xpn.xwiki.web.XWikiRequest;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Properties;
 
-public class PdfExportImpl implements PdfExport {
+public class PdfExportImpl implements PdfExport
+{
     private static final Log log = LogFactory.getLog(PdfExportImpl.class);
 
     private Tidy tidy;
+
     private String xhtmlxsl = "xhtml2fo.xsl";
+
     private String fopxsl = "fop.xsl";
+
     public static final int PDF = 0;
+
     public static final int RTF = 1;
 
-    public PdfExportImpl() {
+    public PdfExportImpl()
+    {
         tidy = new Tidy();
         Properties props = new Properties();
         props.setProperty("quiet", "true");
@@ -99,34 +101,41 @@
         tidy.setTrimEmptyElements(false);
     }
 
-    public String getXhtmlxsl() {
+    public String getXhtmlxsl()
+    {
         return xhtmlxsl;
     }
 
-    public String getXhtmlxsl(XWikiContext context) throws XWikiException {
+    public String getXhtmlxsl(XWikiContext context) throws XWikiException
+    {
         String xsl = getPDFTemplateField("xhtmlxsl", context);
-        if ((xsl==null)||("".equals(xsl.trim())))
-         return xhtmlxsl;
-        else
-         return xsl;
+        if ((xsl == null) || ("".equals(xsl.trim()))) {
+            return xhtmlxsl;
+        } else {
+            return xsl;
+        }
     }
 
-    public void setXhtmlxsl(String xhtmlxsl) {
+    public void setXhtmlxsl(String xhtmlxsl)
+    {
         this.xhtmlxsl = xhtmlxsl;
     }
 
-    public void exportXHtml(byte[] xhtml, OutputStream out, int type, 
XWikiContext context) throws XWikiException {
+    public void exportXHtml(byte[] xhtml, OutputStream out, int type, 
XWikiContext context) throws XWikiException
+    {
         // XSL Transformation to XML-FO
         byte[] xmlfo = convertXHtmlToXMLFO(xhtml, context);
 
         // DEBUG OUTPUT
-        if (log.isDebugEnabled())
-         log.debug(new String(xmlfo));
+        if (log.isDebugEnabled()) {
+            log.debug(new String(xmlfo));
+        }
 
         exportXMLFO(xmlfo, out, type);
     }
 
-    public void exportXMLFO(byte[] xmlfo, OutputStream out, int type) throws 
XWikiException {
+    public void exportXMLFO(byte[] xmlfo, OutputStream out, int type) throws 
XWikiException
+    {
         // XSL Transformation to XML-FO
 
         try {
@@ -135,7 +144,8 @@
             // configure foUserAgent as desired
 
             // Construct fop with desired output format
-            Fop fop = fopFactory.newFop((type==PdfExportImpl.RTF) ? 
MimeConstants.MIME_RTF : MimeConstants.MIME_PDF, foUserAgent, out);
+            Fop fop = fopFactory.newFop((type == PdfExportImpl.RTF) ? 
MimeConstants.MIME_RTF : MimeConstants.MIME_PDF,
+                foUserAgent, out);
 
             // Setup JAXP using identity transformer
             TransformerFactory factory = TransformerFactory.newInstance();
@@ -152,18 +162,20 @@
 
             // Result processing
             FormattingResults foResults = fop.getResults();
-            if (foResults!=null) {
+            if (foResults != null) {
                 java.util.List pageSequences = foResults.getPageSequences();
                 for (java.util.Iterator it = pageSequences.iterator(); 
it.hasNext();) {
-                    PageSequenceResults pageSequenceResults = 
(PageSequenceResults)it.next();
-                    if (log.isDebugEnabled())
+                    PageSequenceResults pageSequenceResults = 
(PageSequenceResults) it.next();
+                    if (log.isDebugEnabled()) {
                         log.debug("PageSequence "
-                                + 
(String.valueOf(pageSequenceResults.getID()).length() > 0
-                                ? pageSequenceResults.getID() : "<no id>")
-                                + " generated " + 
pageSequenceResults.getPageCount() + " pages.");
+                            + 
(String.valueOf(pageSequenceResults.getID()).length() > 0
+                            ? pageSequenceResults.getID() : "<no id>")
+                            + " generated " + 
pageSequenceResults.getPageCount() + " pages.");
+                    }
                 }
-                if (log.isDebugEnabled())
+                if (log.isDebugEnabled()) {
                     log.debug("Generated " + foResults.getPageCount() + " 
pages in total.");
+                }
             }
             /*
             // Reset the image cache otherwise it could be a security issue
@@ -180,21 +192,23 @@
 
         } catch (Exception e) {
             throw new XWikiException(XWikiException.MODULE_XWIKI_EXPORT,
-                    XWikiException.ERROR_XWIKI_EXPORT_PDF_FOP_FAILED,
-                    "Exception while exporting PDF", e);
+                XWikiException.ERROR_XWIKI_EXPORT_PDF_FOP_FAILED,
+                "Exception while exporting PDF", e);
         }
-
     }
 
-    public void exportHtml(String html, OutputStream out, int type, 
XWikiContext context) throws XWikiException {
+    public void exportHtml(String html, OutputStream out, int type, 
XWikiContext context) throws XWikiException
+    {
         exportXHtml(applyCSS(convertToStrictXHtml(html.getBytes(), context), 
context), out, type, context);
     }
 
-    public void exportToPDF(XWikiDocument doc, OutputStream out, XWikiContext 
context) throws XWikiException {
+    public void exportToPDF(XWikiDocument doc, OutputStream out, XWikiContext 
context) throws XWikiException
+    {
         export(doc, out, PdfExportImpl.PDF, context);
     }
 
-    public void export(XWikiDocument doc, OutputStream out, int type, 
XWikiContext context) throws XWikiException {
+    public void export(XWikiDocument doc, OutputStream out, int type, 
XWikiContext context) throws XWikiException
+    {
         File dir = (File) 
context.getEngineContext().getAttribute("javax.servlet.context.tempdir");
         File tempdir = new File(dir, RandomStringUtils.randomAlphanumeric(8));
         tidy.setOutputEncoding(context.getWiki().getEncoding());
@@ -206,16 +220,19 @@
             exportHtml(content, out, type, context);
         } finally {
             File[] filelist = tempdir.listFiles();
-            for (int i=0;i<filelist.length;i++)
+            for (int i = 0; i < filelist.length; i++) {
                 filelist[i].delete();
+            }
             tempdir.delete();
         }
     }
 
-    public byte[] convertToStrictXHtml(byte[] input, XWikiContext context) {
+    public byte[] convertToStrictXHtml(byte[] input, XWikiContext context)
+    {
 
-        if (log.isDebugEnabled())
+        if (log.isDebugEnabled()) {
             log.debug(new String(input));
+        }
 
         try {
             InputStream in = new ByteArrayInputStream(input);
@@ -228,14 +245,16 @@
         }
     }
 
-    public byte[] convertXHtmlToXMLFO(byte[] xhtml, XWikiContext context) 
throws XWikiException {
+    public byte[] convertXHtmlToXMLFO(byte[] xhtml, XWikiContext context) 
throws XWikiException
+    {
         byte[] xmlfo = applyXsl(xhtml, getXhtmlxsl(context));
         return applyXsl(xmlfo, getFopxsl(context));
     }
 
-    public byte[] applyXsl(byte[] xml, String xslfile) throws XWikiException {
+    public byte[] applyXsl(byte[] xml, String xslfile) throws XWikiException
+    {
         InputStream xsltinputstream = 
getClass().getClassLoader().getResourceAsStream(xslfile);
-        
+
         InputStream xmlinputstream = new ByteArrayInputStream(xml);
         ByteArrayOutputStream transout = new ByteArrayOutputStream();
 
@@ -248,52 +267,58 @@
             Document xslt = docBuilder.parse(new InputSource(xsltinputstream));
             Document xmldoc = docBuilder.parse(new 
InputSource(xmlinputstream));
             Transformer transformer = 
TransformerFactory.newInstance().newTransformer(new DOMSource(xslt));
-            transformer.transform(new DOMSource(xmldoc),
-                    new StreamResult(transout));
+            transformer.transform(new DOMSource(xmldoc), new 
StreamResult(transout));
         } catch (Exception e) {
             throw new XWikiException(XWikiException.MODULE_XWIKI_EXPORT,
-                    XWikiException.ERROR_XWIKI_EXPORT_XSL_FAILED,
-                    "XSL Transformation Failed", e);
+                XWikiException.ERROR_XWIKI_EXPORT_XSL_FAILED,
+                "XSL Transformation Failed", e);
         }
 
         return transout.toByteArray();
     }
 
-    public byte[] applyCSS(byte[] html, XWikiContext context) throws 
XWikiException {
-        String css = ((context==null)||(context.getWiki()==null)) ? "" : 
context.getWiki().parseTemplate("pdf.css", context);
+    public byte[] applyCSS(byte[] html, XWikiContext context) throws 
XWikiException
+    {
+        String css = ((context == null) || (context.getWiki() == null)) ? "" :
+            context.getWiki().parseTemplate("pdf.css", context);
         String style = getPDFTemplateField("style", context);
-        if (style!=null)
-         css += style;
+        if (style != null) {
+            css += style;
+        }
         return applyCSS(html, css, context);
     }
 
-    public String getPDFTemplateField(String fieldname, XWikiContext context) 
throws XWikiException {
+    public String getPDFTemplateField(String fieldname, XWikiContext context) 
throws XWikiException
+    {
         String fieldcontent = null;
         XWikiDocument doc = getPDFTemplateDocument(context);
-        if (doc!=null) {
+        if (doc != null) {
             BaseObject bobj = doc.getObject("XWiki.PDFClass");
-            if (bobj!=null) {
+            if (bobj != null) {
                 fieldcontent = doc.display(fieldname, "view", bobj, context);
             }
         }
         return fieldcontent;
     }
 
-    public XWikiDocument getPDFTemplateDocument(XWikiContext context) throws 
XWikiException {
+    public XWikiDocument getPDFTemplateDocument(XWikiContext context) throws 
XWikiException
+    {
         XWikiDocument doc = null;
         XWikiRequest request = context.getRequest();
-        if (request!=null) {
+        if (request != null) {
             String pdftemplate = request.get("pdftemplate");
-            if (pdftemplate!=null) {
+            if (pdftemplate != null) {
                 doc = context.getWiki().getDocument(pdftemplate, context);
             }
         }
-        if (doc==null)
+        if (doc == null) {
             doc = context.getDoc();
+        }
         return doc;
     }
 
-    public byte[] applyCSS(byte[] html, String css, XWikiContext context) {
+    public byte[] applyCSS(byte[] html, String css, XWikiContext context)
+    {
         try {
             Reader re = new StringReader(new String(html));
             InputSource source = new InputSource(re);
@@ -317,46 +342,54 @@
             writer.write(document);
             String result = out.toString();
             // DEBUG OUTPUT
-            if (log.isDebugEnabled())
+            if (log.isDebugEnabled()) {
                 log.debug(result);
+            }
             return result.getBytes();
-        } catch (Exception e ) {
+        } catch (Exception e) {
             e.printStackTrace();
             return html;
         }
     }
 
-    private void applyInlineStyle(Element element) {
-        for (int i=0;i<element.nodeCount();i++) {
+    private void applyInlineStyle(Element element)
+    {
+        for (int i = 0; i < element.nodeCount(); i++) {
             org.dom4j.Node node = element.node(i);
             if (node instanceof CSSStylableElement) {
                 CSSStylableElement styleElement = (CSSStylableElement) node;
-                if (styleElement.getComputedStyle()!=null)
-                 styleElement.addAttribute("style", 
styleElement.getComputedStyle().getCssText());
+                if (styleElement.getComputedStyle() != null) {
+                    styleElement.addAttribute("style", 
styleElement.getComputedStyle().getCssText());
+                }
             }
             if (node instanceof Element) {
                 applyInlineStyle((Element) node);
-            }      
+            }
         }
     }
 
-    public String getFopxsl() {
+    public String getFopxsl()
+    {
         return fopxsl;
     }
 
-    public String getFopxsl(XWikiContext context) throws XWikiException {
+    public String getFopxsl(XWikiContext context) throws XWikiException
+    {
         String xsl = getPDFTemplateField("fopxsl", context);
-        if ((xsl==null)||("".equals(xsl.trim())))
-         return fopxsl;
-        else
-         return xsl;
+        if ((xsl == null) || ("".equals(xsl.trim()))) {
+            return fopxsl;
+        } else {
+            return xsl;
+        }
     }
 
-    public void setFopxsl(String fopxsl) {
+    public void setFopxsl(String fopxsl)
+    {
         this.fopxsl = fopxsl;
     }
 
-    public static void main(String[] argv) throws IOException, XWikiException {
+    public static void main(String[] argv) throws IOException, XWikiException
+    {
         String param = argv[0];
         String inputfile;
         String outputfile;
@@ -384,7 +417,7 @@
             content = Util.getFileContent(new File(inputfile));
             // XML-FO2 PDF
             FileOutputStream fos = new FileOutputStream(new File(outputfile));
-            pdf.exportXMLFO(content.getBytes(), fos,PdfExportImpl.PDF);
+            pdf.exportXMLFO(content.getBytes(), fos, PdfExportImpl.PDF);
             fos.close();
         } else if (param.equals("-html2pdf")) {
             inputfile = argv[1];
@@ -392,23 +425,23 @@
             content = Util.getFileContent(new File(inputfile));
             // PDF
             FileOutputStream fos = new FileOutputStream(new File(outputfile));
-            pdf.exportHtml(content, fos,PdfExportImpl.PDF, context);
+            pdf.exportHtml(content, fos, PdfExportImpl.PDF, context);
             fos.close();
         } else {
             inputfile = param;
             outputfile = argv[1];
             content = Util.getFileContent(new File(inputfile));
             // PDF
-                FileOutputStream fos = new FileOutputStream(new 
File(outputfile));
-            pdf.exportHtml(content, fos,PdfExportImpl.PDF, context);
+            FileOutputStream fos = new FileOutputStream(new File(outputfile));
+            pdf.exportHtml(content, fos, PdfExportImpl.PDF, context);
             fos.close();
         }
     }
 
-    public static void saveFile(String filename, byte[] content) throws 
IOException {
-     FileOutputStream fos = new FileOutputStream(new File(filename));
-     fos.write(content);
-     fos.close();
+    public static void saveFile(String filename, byte[] content) throws 
IOException
+    {
+        FileOutputStream fos = new FileOutputStream(new File(filename));
+        fos.write(content);
+        fos.close();
     }
-
 }

Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/PdfURLFactory.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/PdfURLFactory.java
        2007-11-30 17:37:18 UTC (rev 6220)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/PdfURLFactory.java
        2007-12-01 19:35:38 UTC (rev 6221)
@@ -18,25 +18,27 @@
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  *
  */
-
 package com.xpn.xwiki.pdf.impl;
 
 import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.util.Util;
 import com.xpn.xwiki.doc.XWikiAttachment;
 import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.util.Util;
 import com.xpn.xwiki.web.XWikiServletURLFactory;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.net.URL;
 
-public class PdfURLFactory extends XWikiServletURLFactory {
-
-    public PdfURLFactory() {
+public class PdfURLFactory extends XWikiServletURLFactory
+{
+    public PdfURLFactory()
+    {
     }
 
-    public URL createAttachmentURL(String filename, String web, String name, 
String action, String querystring, String xwikidb, XWikiContext context) {
+    public URL createAttachmentURL(String filename, String web, String name, 
String action, String querystring,
+        String xwikidb, XWikiContext context)
+    {
         try {
             File tempdir = (File) context.get("pdfexportdir");
             File file = new File(tempdir, web + "." + name + "." + filename);
@@ -57,7 +59,9 @@
         }
     }
 
-    public URL createAttachmentRevisionURL(String filename, String web, String 
name, String revision, String xwikidb, XWikiContext context) {
+    public URL createAttachmentRevisionURL(String filename, String web, String 
name, String revision, String xwikidb,
+        XWikiContext context)
+    {
         try {
             File tempdir = (File) context.get("pdfexportdir");
             File file = new File(tempdir, web + "." + name + "." + filename);
@@ -78,10 +82,11 @@
         }
     }
 
-
-    public String getURL(URL url, XWikiContext context) {
-        if (url==null)
+    public String getURL(URL url, XWikiContext context)
+    {
+        if (url == null) {
             return "";
+        }
         return Util.escapeURL(url.toString());
     }
 }

Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/XWikiURIResolver.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/XWikiURIResolver.java
     2007-11-30 17:37:18 UTC (rev 6220)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/pdf/impl/XWikiURIResolver.java
     2007-12-01 19:35:38 UTC (rev 6221)
@@ -18,14 +18,13 @@
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  *
  */
-
 package com.xpn.xwiki.pdf.impl;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import java.io.File;
 import java.io.IOException;
@@ -38,37 +37,22 @@
     private static final Log LOG = LogFactory.getLog(XWikiURIResolver.class);
 
     /**
-     * Allow the application to resolve external entities.
-     * <p/>
-     * <p>The Parser will call this method before opening any external
-     * entity except the top-level document entity (including the
-     * external DTD subset, external entities referenced within the
-     * DTD, and external entities referenced within the document
-     * element): the application may request that the parser resolve
-     * the entity itself, that it use an alternative URI, or that it
-     * use an entirely different input source.</p>
-     * <p/>
-     * <p>Application writers can use this method to redirect external
-     * system identifiers to secure and/or local URIs, to look up
-     * public identifiers in a catalogue, or to read an entity from a
-     * database or other input source (including, for example, a dialog
-     * box).</p>
-     * <p/>
-     * <p>If the system identifier is a URL, the SAX parser must
-     * resolve it fully before reporting it to the application.</p>
+     * Allow the application to resolve external entities. <p/> <p>The Parser 
will call this method before opening any
+     * external entity except the top-level document entity (including the 
external DTD subset, external entities
+     * referenced within the DTD, and external entities referenced within the 
document element): the application may
+     * request that the parser resolve the entity itself, that it use an 
alternative URI, or that it use an entirely
+     * different input source.</p> <p/> <p>Application writers can use this 
method to redirect external system
+     * identifiers to secure and/or local URIs, to look up public identifiers 
in a catalogue, or to read an entity from
+     * a database or other input source (including, for example, a dialog 
box).</p> <p/> <p>If the system identifier is
+     * a URL, the SAX parser must resolve it fully before reporting it to the 
application.</p>
      *
-     * @param publicId The public identifier of the external entity
-     *                 being referenced, or null if none was supplied.
-     * @param systemId The system identifier of the external entity
-     *                 being referenced.
-     * @return An InputSource object describing the new input source,
-     *         or null to request that the parser open a regular
+     * @param publicId The public identifier of the external entity being 
referenced, or null if none was supplied.
+     * @param systemId The system identifier of the external entity being 
referenced.
+     * @return An InputSource object describing the new input source, or null 
to request that the parser open a regular
      *         URI connection to the system identifier.
-     * @throws org.xml.sax.SAXException Any SAX exception, possibly
-     *                                  wrapping another exception.
-     * @throws java.io.IOException      A Java-specific IO exception,
-     *                                  possibly the result of creating a new 
InputStream
-     *                                  or Reader for the InputSource.
+     * @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping 
another exception.
+     * @throws java.io.IOException A Java-specific IO exception, possibly the 
result of creating a new InputStream or
+     *         Reader for the InputSource.
      * @see org.xml.sax.InputSource
      */
     public InputSource resolveEntity(String publicId, String systemId) throws 
SAXException, IOException
@@ -80,7 +64,7 @@
 
             if ("http".equals(uri.getScheme()) || 
"file".equals(uri.getScheme())) {
                 String filename = (new File(uri.getPath())).getName();
-                InputStream istream =  
getClass().getClassLoader().getResourceAsStream(filename);
+                InputStream istream = 
getClass().getClassLoader().getResourceAsStream(filename);
                 if (istream != null) {
                     source = new InputSource(istream);
                 } else {
@@ -98,7 +82,7 @@
                 LOG.debug("Unknown URI scheme [" + uri.getScheme() + "] for 
entity ["
                     + systemId + "]. Assuming the entity is already resolved 
and looking for it "
                     + "in the file system.");
-                InputStream istream =  
getClass().getClassLoader().getResourceAsStream(systemId);
+                InputStream istream = 
getClass().getClassLoader().getResourceAsStream(systemId);
                 if (istream != null) {
                     source = new InputSource(istream);
                 } else {

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to