Author: vmassol
Date: 2008-02-09 19:20:20 +0100 (Sat, 09 Feb 2008)
New Revision: 86

Added:
   
components/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/ParseException.java
Modified:
   
components/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/Parser.java
Log:
XWIKI-654: Rewrite the Rendering engine

* Added ParseException

Added: 
components/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/ParseException.java
===================================================================
--- 
components/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/ParseException.java
                                (rev 0)
+++ 
components/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/ParseException.java
        2008-02-09 18:20:20 UTC (rev 86)
@@ -0,0 +1,111 @@
+package org.xwiki.rendering;
+
+/**
+ * Encapsulate a parsing error.
+ */
+public class ParseException
+    extends Exception
+{
+    /**
+     * The file that caused the ParseException..
+     */
+    private String fileName;
+
+    /**
+     * Line number where the parse exception occurred.
+     */
+    private int lineNumber;
+
+    /**
+     * Construct a new ParseException with the specified detail message.
+     *
+     * @param message The detailed message.
+     * This can later be retrieved by the Throwable.getMessage() method.
+     */
+    public ParseException( String message )
+    {
+        this( null, message, null, -1 );
+    }
+
+    /**
+     * Construct a new ParseException with the specified detail message and 
cause.
+     *
+     * @param message The detailed message.
+     * This can later be retrieved by the Throwable.getMessage() method.
+     * @param e the cause. This can be retrieved later by the 
Throwable.getCause() method.
+     * (A null value is permitted, and indicates that the cause is nonexistent 
or unknown.)
+     */
+    public ParseException( String message, Exception e )
+    {
+        this( e, message, null, -1 );
+    }
+
+    /**
+     * Constructs a new exception with the specified cause. The error message 
is
+     *  (cause == null ? null : cause.toString() ).
+     *
+     * @param e the cause. This can be retrieved later by the 
Throwable.getCause() method.
+     * (A null value is permitted, and indicates that the cause is nonexistent 
or unknown.)
+     */
+    public ParseException( Exception e )
+    {
+        this( e, null, null, -1 );
+    }
+
+    /**
+     * Construct a new ParseException with the specified cause,
+     * filename and linenumber.
+     *
+     * @param e the cause. This can be retrieved later by the 
Throwable.getCause() method.
+     * (A null value is permitted, and indicates that the cause is nonexistent 
or unknown.)
+     * @param file Name of a file that couldn't be parsed.
+     * This can later be retrieved by the getFileName() method.
+     * @param line The line number where the parsing failed.
+     * This can later be retrieved by the getLineNumber() method.
+     */
+    public ParseException( Exception e, String file, int line )
+    {
+        this( e, null, file, line );
+    }
+
+    /**
+     * Construct a new ParseException with the specified cause, detail message,
+     * filename and linenumber.
+     *
+     * @param e the cause. This can be retrieved later by the 
Throwable.getCause() method.
+     * (A null value is permitted, and indicates that the cause is nonexistent 
or unknown.)
+     * @param message The detailed message.
+     * This can later be retrieved by the Throwable.getMessage() method.
+     * @param file Name of a file that couldn't be parsed.
+     * This can later be retrieved by the getFileName() method.
+     * @param line The line number where the parsing failed.
+     * This can later be retrieved by the getLineNumber() method.
+     */
+    public ParseException( Exception e, String message, String file, int line )
+    {
+        super( ( message == null ) ? ( ( e == null ) ? null : e.getMessage() ) 
: message, e );
+
+        this.fileName = file;
+        this.lineNumber = line;
+    }
+
+    /**
+     * Returns the file that caused the ParseException.
+     *
+     * @return the file that caused the ParseException.
+     */
+    public String getFileName()
+    {
+        return fileName;
+    }
+
+    /**
+     * Returns the line number where the  ParseException ocurred.
+     *
+     * @return the line number.
+     */
+    public int getLineNumber()
+    {
+        return lineNumber;
+    }
+}

Modified: 
components/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/Parser.java
===================================================================
--- 
components/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/Parser.java
        2008-02-07 18:09:23 UTC (rev 85)
+++ 
components/xwiki-rendering/xwiki-rendering-api/src/main/java/org/xwiki/rendering/Parser.java
        2008-02-09 18:20:20 UTC (rev 86)
@@ -4,6 +4,6 @@
 
 public interface Parser
 {
-    void parse(Reader source, Listener renderer);
-    Document parse(Reader source);
+    void parse(Reader source, Listener listener) throws ParseException;
+    Document parse(Reader source) throws ParseException;
 }

_______________________________________________
notifications mailing list
notifications@xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to