diff --git a/build/classes/fr/devinsy/xid/DomPresenter.class b/build/classes/fr/devinsy/xid/DomPresenter.class index 0771c5a..0a5a7e0 100644 Binary files a/build/classes/fr/devinsy/xid/DomPresenter.class and b/build/classes/fr/devinsy/xid/DomPresenter.class differ diff --git a/build/classes/fr/devinsy/xid/FilePresenter.class b/build/classes/fr/devinsy/xid/FilePresenter.class index 3d7ea46..ef17491 100644 Binary files a/build/classes/fr/devinsy/xid/FilePresenter.class and b/build/classes/fr/devinsy/xid/FilePresenter.class differ diff --git a/build/classes/fr/devinsy/xid/Presenter.class b/build/classes/fr/devinsy/xid/Presenter.class index 57a5d04..0a5522a 100644 Binary files a/build/classes/fr/devinsy/xid/Presenter.class and b/build/classes/fr/devinsy/xid/Presenter.class differ diff --git a/build/classes/fr/devinsy/xid/StringPresenter.class b/build/classes/fr/devinsy/xid/StringPresenter.class index 1c1107a..1a672c7 100644 Binary files a/build/classes/fr/devinsy/xid/StringPresenter.class and b/build/classes/fr/devinsy/xid/StringPresenter.class differ diff --git a/demo/XidDemo.java b/demo/XidDemo.java index 8a35774..24ddb6e 100644 --- a/demo/XidDemo.java +++ b/demo/XidDemo.java @@ -25,187 +25,277 @@ class XidDemo */ public static void main (String[] args) { - System.out.println("Hello World!"); + System.out.println("Hello World!"); + + //test (); + + // + Data datas; + IdData tag; + + + + + // Step #01. + { + System.out.println ("----------------------------"); + + // Populate attributes. + datas = new Data (); + datas.setContent ("name", "Superman"); + + StringBuffer html; + try + { + html = StringPresenter.doXid ("
a name
", datas); + } + catch (Exception exception) + { + System.out.println("Error " + exception.getMessage()); + html = null; + } + System.out.println ("datas = new Data ();"); + System.out.println ("datas.setContent (\"name\", \"Superman\");"); + System.out.println ("+"); + System.out.println ("
a name
"); + System.out.println ("=>"); + System.out.println (html); + } + + + // Step #02. + { + System.out.println ("----------------------------"); + // Populate attributes. + datas = new Data (); + datas.setContent ("lastname", "Spiderman"); + datas.appendAttribute ("lastname", "style", "background: blue;"); + datas.appendAttribute ("lastname", "style", "foreground: red;"); + datas.setAttribute ("lastname", "class", "nameClass"); + + StringBuffer html; + try + { + html = StringPresenter.doXid ("
a last name
", datas); + } + catch (Exception exception) + { + System.out.println("Error " + exception.getMessage()); + html = null; + } + + System.out.println ("datas = new Data ();"); + System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");"); + System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"background: blue;\");"); + System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");"); + System.out.println ("datas.setAttribute (\"lastname\", \"class\", \"nameClass\");"); + System.out.println ("+"); + System.out.println ("
a last name
"); + System.out.println ("=>"); + System.out.println (html); + } + + + // Step #03. + { + System.out.println ("----------------------------"); + // Populate attributes. + datas = new Data (); + datas.setContent ("words", 0, "alpha"); + datas.setContent ("words", 1, "bravo"); + datas.setContent ("words", 2, "charlie"); + datas.setContent ("words", 3, "delta"); + datas.setContent ("words", 4, "echo"); + datas.setContent ("words", 5, "fox"); + + StringBuffer html; + try + { + html = StringPresenter.doXid ("", datas); + } + catch (Exception exception) + { + System.out.println("Error " + exception.getMessage()); + html = null; + } + + System.out.println ("datas = new Data ();"); + System.out.println ("datas.setContent (\"words\", 0, \"alpha\");"); + System.out.println ("datas.setContent (\"words\", 1, \"bravo\");"); + System.out.println ("datas.setContent (\"words\", 2, \"charlie\");"); + System.out.println ("datas.setContent (\"words\", 3, \"delta\");"); + System.out.println ("datas.setContent (\"words\", 4, \"echo\");"); + System.out.println ("datas.setContent (\"words\", 5, \"fox\");"); + System.out.println ("+"); + System.out.println (""); + System.out.println ("=>"); + System.out.println (html); + } + + + // Step #04. + { + System.out.println ("----------------------------"); + // Populate attributes. + datas = new Data (); + datas.setContent ("identity", 0, "last_name", "Jemba"); + datas.setContent ("identity", 0, "first_name", "Epo"); + datas.setContent ("identity", 1, "last_name", "Momon"); + datas.setContent ("identity", 1, "first_name", "Christian"); + datas.setContent ("identity", 2, "last_name", "Tronche"); + datas.setContent ("identity", 2, "first_name", "Christophe"); + + + StringBuffer source = new StringBuffer (); + source.append ("\n"); + source.append (" \n"); + source.append ("
noidJeanReve
"); + + String htmlSource = source.toString (); + StringBuffer html; + try + { + html = StringPresenter.doXid (htmlSource, datas); + } + catch (Exception exception) + { + System.out.println("Error " + exception.getMessage()); + html = null; + } + + System.out.println ("datas = new Data ();"); + System.out.println ("datas.setContent (\"identity\", 0, \"last_name\", \"Jemba\");"); + System.out.println ("datas.setContent (\"identity\", 0, \"first_name\", \"Epo\");"); + System.out.println ("datas.setContent (\"identity\", 1, \"last_name\", \"Momon\");"); + System.out.println ("datas.setContent (\"identity\", 1, \"first_name\", \"Christian\");"); + System.out.println ("datas.setContent (\"identity\", 2, \"last_name\", \"Tronche\");"); + System.out.println ("datas.setContent (\"identity\", 2, \"first_name\", \"Christophe\");"); + + System.out.println ("+"); + System.out.println (htmlSource); + System.out.println ("=>"); + System.out.println (html); + } + + + // Step #05. + { + System.out.println ("----------------------------"); + // Populate attributes. + datas = new Data (); + datas.setContent ("identity", 0, "last_name", "Jemba"); + datas.setContent ("identity", 0, "first_name", "Epo"); + datas.setContent ("identity", 1, "last_name", "Momon"); + datas.setContent ("identity", 1, "first_name", "Christian"); + datas.setContent ("identity", 2, "last_name", "Tronche"); + datas.setContent ("identity", 2, "first_name", "Christophe"); + //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); + //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); + //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS); + + // + StringBuffer source = new StringBuffer (); + source.append ("\n"); + source.append (" \n"); + source.append (" \n"); + source.append (" \n"); + source.append (" \n"); + source.append ("
noidFirst NameLast Name
noidJeanReve
noida first namea last name
noida first name morea last name more
\n"); + String htmlSource = source.toString (); + + System.out.println ("datas = new Data ();"); + System.out.println ("datas.setContent (\"identity\", 0, \"first_name\", \"Epo\");"); + System.out.println ("datas.setContent (\"identity\", 0, \"last_name\", \"Jemba\");"); + System.out.println ("datas.setContent (\"identity\", 1, \"first_name\", \"Christian\");"); + System.out.println ("datas.setContent (\"identity\", 1, \"last_name\", \"Momon\");"); + System.out.println ("datas.setContent (\"identity\", 2, \"first_name\", \"Christophe\");"); + System.out.println ("datas.setContent (\"identity\", 2, \"last_name\", \"Tronche\");"); + + System.out.println ("+"); + System.out.println (htmlSource); + System.out.println ("=>"); + + + // #05.1 + datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_FIRST_ROW); + System.out.println ("ONLY_FIRST_ROW:"); + StringBuffer html; + try + { + html = StringPresenter.doXid (htmlSource, datas); + } + catch (Exception exception) + { + System.out.println(exception.getMessage()); + html = null; + } + System.out.println (html); + System.out.println (""); + + + // #05.2 + datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_FIRST_TWO_ROWS); + System.out.println ("ONLY_FIRST_TWO_ROWS:"); + try + { + html = StringPresenter.doXid (htmlSource, datas); + } + catch (Exception exception) + { + System.out.println("Error " + exception.getMessage()); + html = null; + } + System.out.println (html); + System.out.println (""); - //test (); + + // #05.3 + datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_ROWS_WITH_ID); + System.out.println ("ONLY_ROWS_WITH_ID:"); + try + { + html = StringPresenter.doXid (htmlSource, datas); + } + catch (Exception exception) + { + System.out.println("Error " + exception.getMessage()); + html = null; + } + System.out.println (html); + System.out.println (""); - // - Data datas; - IdData tag; - - - - String htmlSource; - StringBuffer html; - StringBuffer errorMessage; - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("name", "Superman"); - - errorMessage = new StringBuffer (); - html = StringPresenter.doXid ("
a name
", datas, errorMessage); - - System.out.println ("datas = new Data ();"); - System.out.println ("datas.setContent (\"name\", \"Superman\");"); - System.out.println ("+"); - System.out.println ("
a name
"); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("lastname", "Spiderman"); - datas.appendAttribute ("lastname", "style", "background: blue;"); - datas.appendAttribute ("lastname", "style", "foreground: red;"); - datas.setAttribute ("lastname", "class", "nameClass"); - - - errorMessage = new StringBuffer (); - html = StringPresenter.doXid ("
a last name
", datas, errorMessage); - - System.out.println ("datas = new Data ();"); - System.out.println ("datas.setContent (\"lastname\", \"Spiderman\");"); - System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"background: blue;\");"); - System.out.println ("datas.appendAttribute (\"lastname\", \"style\", \"foreground: red;\");"); - System.out.println ("datas.setAttribute (\"lastname\", \"class\", \"nameClass\");"); - System.out.println ("+"); - System.out.println ("
a last name
"); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("words", 0, "alpha"); - datas.setContent ("words", 1, "bravo"); - datas.setContent ("words", 2, "charlie"); - datas.setContent ("words", 3, "delta"); - datas.setContent ("words", 4, "echo"); - datas.setContent ("words", 5, "fox"); - - - errorMessage = new StringBuffer (); - html = StringPresenter.doXid ("", datas, errorMessage); - - System.out.println ("datas = new Data ();"); - System.out.println ("datas.setContent (\"words\", 0, \"alpha\");"); - System.out.println ("datas.setContent (\"words\", 1, \"bravo\");"); - System.out.println ("datas.setContent (\"words\", 2, \"charlie\");"); - System.out.println ("datas.setContent (\"words\", 3, \"delta\");"); - System.out.println ("datas.setContent (\"words\", 4, \"echo\");"); - System.out.println ("datas.setContent (\"words\", 5, \"fox\");"); - System.out.println ("+"); - System.out.println (""); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("identity", 0, "last_name", "Jemba"); - datas.setContent ("identity", 0, "first_name", "Epo"); - datas.setContent ("identity", 1, "last_name", "Momon"); - datas.setContent ("identity", 1, "first_name", "Christian"); - datas.setContent ("identity", 2, "last_name", "Tronche"); - datas.setContent ("identity", 2, "first_name", "Christophe"); - - - errorMessage = new StringBuffer (); - StringBuffer source = new StringBuffer (); - source.append ("\n"); - source.append (" \n"); - source.append ("
noidJeanReve
"); - htmlSource = source.toString (); - html = StringPresenter.doXid (htmlSource, datas, errorMessage); - - System.out.println ("datas = new Data ();"); - System.out.println ("datas.setContent (\"identity\", 0, \"last_name\", \"Jemba\");"); - System.out.println ("datas.setContent (\"identity\", 0, \"first_name\", \"Epo\");"); - System.out.println ("datas.setContent (\"identity\", 1, \"last_name\", \"Momon\");"); - System.out.println ("datas.setContent (\"identity\", 1, \"first_name\", \"Christian\");"); - System.out.println ("datas.setContent (\"identity\", 2, \"last_name\", \"Tronche\");"); - System.out.println ("datas.setContent (\"identity\", 2, \"first_name\", \"Christophe\");"); - - System.out.println ("+"); - System.out.println (htmlSource); - System.out.println ("=>"); - System.out.println (html); - - - // Populate attributes of Test 03. - System.out.println ("----------------------------"); - datas = new Data (); - datas.setContent ("identity", 0, "last_name", "Jemba"); - datas.setContent ("identity", 0, "first_name", "Epo"); - datas.setContent ("identity", 1, "last_name", "Momon"); - datas.setContent ("identity", 1, "first_name", "Christian"); - datas.setContent ("identity", 2, "last_name", "Tronche"); - datas.setContent ("identity", 2, "first_name", "Christophe"); - //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITH_ID); - //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ONLY_ROWS_WITHOUT_ID); - //datas.setIterationStrategy ("identity", IdsDataByIndex.IterationStrategy.ALL_ROWS); - - - errorMessage = new StringBuffer (); - source = new StringBuffer (); - source.append ("\n"); - source.append (" \n"); - source.append (" \n"); - source.append (" \n"); - source.append (" \n"); - source.append ("
noidFirst NameLast Name
noidJeanReve
noida first namea last name
noida first name morea last name more
\n"); - htmlSource = source.toString (); - - System.out.println ("datas = new Data ();"); - System.out.println ("datas.setContent (\"identity\", 0, \"first_name\", \"Epo\");"); - System.out.println ("datas.setContent (\"identity\", 0, \"last_name\", \"Jemba\");"); - System.out.println ("datas.setContent (\"identity\", 1, \"first_name\", \"Christian\");"); - System.out.println ("datas.setContent (\"identity\", 1, \"last_name\", \"Momon\");"); - System.out.println ("datas.setContent (\"identity\", 2, \"first_name\", \"Christophe\");"); - System.out.println ("datas.setContent (\"identity\", 2, \"last_name\", \"Tronche\");"); - - System.out.println ("+"); - System.out.println (htmlSource); - System.out.println ("=>"); - - - datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_FIRST_ROW); - System.out.println ("ONLY_FIRST_ROW:"); - html = StringPresenter.doXid (htmlSource, datas, errorMessage); - System.out.println (html); - - System.out.println (""); - datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_FIRST_TWO_ROWS); - System.out.println ("ONLY_FIRST_TWO_ROWS:"); - html = StringPresenter.doXid (htmlSource, datas, errorMessage); - System.out.println (html); - - System.out.println (""); - datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_ROWS_WITH_ID); - System.out.println ("ONLY_ROWS_WITH_ID:"); - html = StringPresenter.doXid (htmlSource, datas, errorMessage); - System.out.println (html); - - System.out.println (""); - datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_ROWS_WITHOUT_ID); - System.out.println ("ONLY_ROWS_WITHOUT_ID:"); - html = StringPresenter.doXid (htmlSource, datas, errorMessage); - System.out.println (html); - - System.out.println (""); - datas.setIterationStrategy ("identities", IdData.IterationStrategy.ALL_ROWS); - System.out.println ("ALL_ROWS:"); - html = StringPresenter.doXid (htmlSource, datas, errorMessage); - System.out.println (html); - - - } + + // #05.4 + datas.setIterationStrategy ("identities", IdData.IterationStrategy.ONLY_ROWS_WITHOUT_ID); + System.out.println ("ONLY_ROWS_WITHOUT_ID:"); + try + { + html = StringPresenter.doXid (htmlSource, datas); + } + catch (Exception exception) + { + System.out.println("Error " + exception.getMessage()); + html = null; + } + System.out.println (html); + System.out.println (""); + + + // #05.5 + datas.setIterationStrategy ("identities", IdData.IterationStrategy.ALL_ROWS); + System.out.println ("ALL_ROWS:"); + try + { + html = StringPresenter.doXid (htmlSource, datas); + } + catch (Exception exception) + { + System.out.println("Error " + exception.getMessage()); + html = null; + } + System.out.println (html); + } + } } diff --git a/src/fr/devinsy/xid/DomPresenter.java b/src/fr/devinsy/xid/DomPresenter.java index 4de127d..cd678a4 100644 --- a/src/fr/devinsy/xid/DomPresenter.java +++ b/src/fr/devinsy/xid/DomPresenter.java @@ -94,29 +94,29 @@ public class DomPresenter extends Presenter /* * */ - public StringBuffer doXid (Data datas, StringBuffer errorOutput) + public StringBuffer doXid (Data datas) throws Exception { - return (doXid (datas.getIdsDataById (), errorOutput)); + return (doXid (datas.getIdsDataById ())); } /* * */ - public StringBuffer doXid (IdsDataById datas, StringBuffer errorOutput) + public StringBuffer doXid (IdsDataById datas) throws Exception { StringBuffer result; if (this.doc == null) { String errorMessage = "source not defined"; - errorOutput.append (errorMessage); logger.error (errorMessage); result = null; + throw new Exception (errorMessage); } else { // Build the web page. - result = Presenter.doXid (this.doc, datas, errorOutput); + result = Presenter.doXid (this.doc, datas); } // @@ -127,11 +127,11 @@ public class DomPresenter extends Presenter /* * Xid a file with data. */ - static public StringBuffer doXid (Document doc, IdsDataById datas, String webappPath, StringBuffer errorOutput) + static public StringBuffer doXid (Document doc, IdsDataById datas, String webappPath) throws Exception { StringBuffer result; - result = Presenter.process (doc, datas, webappPath, errorOutput); + result = Presenter.process (doc, datas, webappPath); // return (result); diff --git a/src/fr/devinsy/xid/FilePresenter.java b/src/fr/devinsy/xid/FilePresenter.java index 8f7b864..ceb9585 100644 --- a/src/fr/devinsy/xid/FilePresenter.java +++ b/src/fr/devinsy/xid/FilePresenter.java @@ -68,16 +68,16 @@ public class FilePresenter extends DomPresenter /* * */ - public StringBuffer doXid (Data datas, StringBuffer errorOutput) + public StringBuffer doXid (Data datas) throws Exception { - return (doXid (datas.getIdsDataById (), errorOutput)); + return (doXid (datas.getIdsDataById ())); } /* * */ - public StringBuffer doXid (IdsDataById datas, StringBuffer errorOutput) + public StringBuffer doXid (IdsDataById datas) throws Exception { StringBuffer result; @@ -89,22 +89,22 @@ public class FilePresenter extends DomPresenter if (source == null) { String errorMessage = "source file not defined"; - errorOutput.append (errorMessage); logger.error (errorMessage); result = null; + throw new Exception (errorMessage); } else if (!source.exists ()) { String errorMessage = "source file defined but not found (" + sourceFilePath + ")"; - errorOutput.append (errorMessage); logger.error (errorMessage); result = null; + throw new Exception (errorMessage); } else if ((this.doc == null) || (this.sourceFileTime != source.lastModified ())) { this.sourceFileTime = source.lastModified (); - this.doc = Presenter.fileToTree (sourceFilePath, errorOutput); + this.doc = Presenter.fileToTree (sourceFilePath); if (this.doc != null) { @@ -113,7 +113,7 @@ public class FilePresenter extends DomPresenter } // Build the web page. - result = Presenter.doXid (doc, datas, errorOutput); + result = Presenter.doXid (doc, datas); // return (result); @@ -123,11 +123,11 @@ public class FilePresenter extends DomPresenter /* * Xid a file without data. */ - static public StringBuffer doXid (String fileName, StringBuffer errorOutput) + static public StringBuffer doXid (String fileName) throws Exception { StringBuffer result; - Document doc = Presenter.fileToTree (fileName, errorOutput); + Document doc = Presenter.fileToTree (fileName); if (doc == null) { @@ -137,7 +137,7 @@ public class FilePresenter extends DomPresenter { Presenter.addMetaTag (doc, "generator", "XID 0.0"); - result = Presenter.doXid (doc, null, errorOutput); + result = Presenter.doXid (doc, null); } // diff --git a/src/fr/devinsy/xid/Presenter.java b/src/fr/devinsy/xid/Presenter.java index be50a68..f71d009 100644 --- a/src/fr/devinsy/xid/Presenter.java +++ b/src/fr/devinsy/xid/Presenter.java @@ -14,6 +14,7 @@ import org.w3c.dom.*; public class Presenter { static final public char INDEX_SEPARATOR = '_'; + static protected int bufferSize = 2048; static protected org.apache.log4j.Logger logger; static @@ -25,17 +26,42 @@ public class Presenter /* * Xid a file with data. */ - static public StringBuffer doXid (Document doc, IdsDataById datas, StringBuffer errorOutput) + static public StringBuffer doXid (Document doc, IdsDataById datas) throws Exception { StringBuffer result; - result = Presenter.process (doc, datas, errorOutput); + result = Presenter.process (doc, datas); // return (result); } + + /* + * + */ + static public int bufferSize() + { + int result; + + result = bufferSize; + + // + return(result); + } + + /* + * + */ + static public void setBufferSize(int value) + { + if (bufferSize > 0) + { + bufferSize = value; + } + } + /* * */ @@ -117,11 +143,11 @@ public class Presenter /* * */ - static protected StringBuffer processChildren (Node node, IdsDataById datas, StringBuffer errorOutput) + static protected StringBuffer processChildren (Node node, IdsDataById datas) throws Exception { StringBuffer result; - result = processChildren (node, datas, "", errorOutput); + result = processChildren (node, datas, ""); // return (result); @@ -133,8 +159,7 @@ public class Presenter */ static protected StringBuffer processChildren (Node node, IdsDataById datas, - String suffix, - StringBuffer errorOutput) + String suffix) throws Exception { StringBuffer result; result = new StringBuffer (); @@ -190,12 +215,12 @@ public class Presenter lineCounter += 1; if (lineCounter == 1) { - result.append (process (children.item (childIndex), datas, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, suffix)); } } else { - result.append (process (children.item (childIndex), datas, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, suffix)); } } break; @@ -210,12 +235,12 @@ public class Presenter if ((lineCounter == 1) || (lineCounter == 2)) { - result.append (process (children.item (childIndex), datas, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, suffix)); } } else { - result.append (process (children.item (childIndex), datas, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, suffix)); } } break; @@ -230,12 +255,12 @@ public class Presenter if ((attrs2 != null) && (attrs2.getNamedItem ("id") != null)) { - result.append (process (children.item (childIndex), datas, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, suffix)); } } else { - result.append (process (children.item (childIndex), datas, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, suffix)); } } break; @@ -249,12 +274,12 @@ public class Presenter if ((attrs2 == null) || (attrs2.getNamedItem ("id") == null)) { - result.append (process (children.item(childIndex), datas, suffix, errorOutput)); + result.append (process (children.item(childIndex), datas, suffix)); } } else { - result.append (process (children.item (childIndex), datas, suffix, errorOutput)); + result.append (process (children.item (childIndex), datas, suffix)); } } break; @@ -262,7 +287,7 @@ public class Presenter case ALL_ROWS: for (int childIndex = 0; childIndex < childrenCount; childIndex++) { - result.append (process (children.item(childIndex), datas, suffix, errorOutput)); + result.append (process (children.item(childIndex), datas, suffix)); } break; } @@ -286,13 +311,12 @@ public class Presenter static protected StringBuffer processElementWithId (Node node, NamedNodeMap attrs, Node idAttr, - IdsDataById datas, - StringBuffer errorOutput) + IdsDataById datas) throws Exception { StringBuffer result; - result = processElementWithId (node, attrs, idAttr, datas, "", errorOutput); + result = processElementWithId (node, attrs, idAttr, datas, ""); // return (result); @@ -311,11 +335,10 @@ public class Presenter * The ID. */ static protected StringBuffer processElementWithId (Node node, - NamedNodeMap attrs, - Node idAttr, - IdsDataById datas, - String suffix, - StringBuffer errorOutput) + NamedNodeMap attrs, + Node idAttr, + IdsDataById datas, + String suffix) throws Exception { StringBuffer result; result = new StringBuffer (); @@ -331,7 +354,7 @@ public class Presenter if (dataCore == null) { - result.append (Presenter.processElementBasically (node, datas, suffix, errorOutput)); + result.append (Presenter.processElementBasically (node, datas, suffix)); } else if (dataCore instanceof IdData) { @@ -373,7 +396,7 @@ public class Presenter if ((data == null) || (data.display () == null)) { - result.append (processChildren (node, datas, suffix, errorOutput)); + result.append (processChildren (node, datas, suffix)); } else { @@ -420,7 +443,7 @@ public class Presenter // Insert data. if ((data == null) || (data.display () == null)) { - result.append (processChildren (node, datas, suffix, errorOutput)); + result.append (processChildren (node, datas, suffix)); } else { @@ -438,7 +461,7 @@ public class Presenter // Manage a Hashmap. IdsDataById data = (IdsDataById) tags.elementAt (nLine); - result.append (Presenter.processElementWithId (node, attrs, idAttr, data, Integer.toString (nLine), errorOutput)); + result.append (Presenter.processElementWithId (node, attrs, idAttr, data, Integer.toString (nLine))); result.append ('\n'); } } @@ -458,11 +481,11 @@ public class Presenter /** * */ - static protected StringBuffer process (Node node, IdsDataById datas, StringBuffer errorOutput) + static protected StringBuffer process (Node node, IdsDataById datas) throws Exception { StringBuffer result; - result = Presenter.process (node, datas, "", errorOutput); + result = Presenter.process (node, datas, ""); // return (result); @@ -473,7 +496,7 @@ public class Presenter * Recursive method that processes a node and any child nodes. * */ - static protected StringBuffer process (Node node, IdsDataById datas, String suffix, StringBuffer errorOutput) + static protected StringBuffer process (Node node, IdsDataById datas, String suffix) throws Exception { logger.debug ("process - started"); String TRANSITIONAL_DTD = "xhtml1-transitional.dtd"; @@ -517,7 +540,7 @@ public class Presenter // Log.write(Log.TRACE,"systemId = " + systemId); } - result.append (Presenter.process (((Document) node).getDocumentElement(), datas, suffix, errorOutput)); + result.append (Presenter.process (((Document) node).getDocumentElement(), datas, suffix)); break; } @@ -535,12 +558,11 @@ public class Presenter attrs, idAttr, datas, - suffix, - errorOutput)); + suffix)); } else { - result.append (Presenter.processElementBasically (node, datas, suffix, errorOutput)); + result.append (Presenter.processElementBasically (node, datas, suffix)); } break; @@ -607,11 +629,11 @@ public class Presenter /* * */ - static StringBuffer processElementBasically (Node node, IdsDataById datas,StringBuffer errorOutput) + static StringBuffer processElementBasically (Node node, IdsDataById datas) throws Exception { StringBuffer result; - result = processElementBasically (node, datas, "", errorOutput); + result = processElementBasically (node, datas, ""); // return (result); @@ -621,7 +643,7 @@ public class Presenter /* * */ - static StringBuffer processElementBasically (Node node, IdsDataById datas, String suffix, StringBuffer errorOutput) + static StringBuffer processElementBasically (Node node, IdsDataById datas, String suffix) throws Exception { StringBuffer result; logger.debug("processElementBasically - started"); @@ -648,7 +670,7 @@ public class Presenter { result.append('>'); - result.append (processChildren (node, datas, suffix, errorOutput)); + result.append (processChildren (node, datas, suffix)); result.append(" needs this possibility. */ - static protected Document fileToTree (String fileName, StringBuffer errorOutput) + static protected Document fileToTree (String fileName) throws Exception { Document result; try { - result = buildTree (new FileInputStream (new File (fileName)), errorOutput); + result = buildTree (new FileInputStream (new File (fileName))); } catch (IOException exception) { String errorMessage = "IOError during parsing." + exception.getMessage (); - errorOutput.append (errorMessage); logger.error (errorMessage); result = null; + throw new Exception (errorMessage, exception); } // diff --git a/src/fr/devinsy/xid/StringPresenter.java b/src/fr/devinsy/xid/StringPresenter.java index a49104f..b2e14f0 100644 --- a/src/fr/devinsy/xid/StringPresenter.java +++ b/src/fr/devinsy/xid/StringPresenter.java @@ -65,15 +65,15 @@ public class StringPresenter extends DomPresenter /* * */ - public StringBuffer doXid (Data datas, StringBuffer errorOutput) + public StringBuffer doXid (Data datas) throws Exception { - return (doXid (datas.getIdsDataById (), errorOutput)); + return (doXid (datas.getIdsDataById ())); } /* * */ - public StringBuffer doXid (IdsDataById datas, StringBuffer errorOutput) + public StringBuffer doXid (IdsDataById datas) throws Exception { StringBuffer result; @@ -82,9 +82,9 @@ public class StringPresenter extends DomPresenter // Build doc from this.html. String htmlSource; if ((this.html.startsWith ("")) || - (this.html.startsWith (""))) + (this.html.startsWith ("")) || + (this.html.startsWith (""))) { htmlSource = html; } @@ -95,11 +95,11 @@ public class StringPresenter extends DomPresenter // StringBufferInputStream is deprecated so we use another solution. // (see http://www.developpez.net/forums/archive/index.php/t-14101.html). - doc = buildTree (new ByteArrayInputStream (htmlSource.getBytes ()), errorOutput); + doc = buildTree (new ByteArrayInputStream (htmlSource.getBytes ())); } StringBuffer htmlTarget; - htmlTarget = Presenter.doXid (doc, datas, errorOutput); + htmlTarget = Presenter.doXid (doc, datas); if (htmlTarget == null) { @@ -134,22 +134,22 @@ public class StringPresenter extends DomPresenter /* * */ - static public StringBuffer doXid (String html, Data datas, StringBuffer errorOutput) + static public StringBuffer doXid (String html, Data datas) throws Exception { - return (doXid (html, datas.getIdsDataById (), errorOutput)); + return (doXid (html, datas.getIdsDataById ())); } /* * Xid a string with html in. */ - static public StringBuffer doXid (String html, IdsDataById datas, StringBuffer errorOutput) + static public StringBuffer doXid (String html, IdsDataById datas) throws Exception { StringBuffer result; StringPresenter presenter = new StringPresenter (html); - result = presenter.doXid (datas, errorOutput); + result = presenter.doXid (datas); // return (result);