diff --git a/README.md b/README.md
index 71d289a..712386c 100644
--- a/README.md
+++ b/README.md
@@ -1,28 +1,28 @@
-#LeoTask
+# LeoTask
-LeoTask is a parallel task running and results aggregation framework. It is a free and open-source project designed to facilitate running computational intensive tasks [1]. The framework implements the MapReduce model, allocating tasks to multi-cores of a computer and aggregating results according to a XML based configuration file. The framework includes mechanisms to automatically recover applications from interruptions caused by accidents (e.g. Power Cut). Applications using the framework can continue running after an interruption without losing its calculated results.
+LeoTask is a parallel task running and results aggregation (MapReduce) framework. It is a free and open-source project designed to facilitate running computational intensive tasks [1]. The framework implements the MapReduce model, allocating tasks to multi-cores of a computer and aggregating results according to a XML based configuration file. The framework includes mechanisms to automatically recover applications from interruptions caused by accidents (e.g. Power Cut). Applications using the framework can continue running after an interruption without losing its calculated results.
-[**Download the latest version**](leotask/demo/leotask.zip?raw=true)
+[**Download**](leotask/demo/leotask.zip?raw=true) | [**Introduction**](leotask/doc/introduction.pdf?raw=true) | [**Applications**](https://github.com/mleoking/LeoTaskApp) | [**Discussion**](http://groups.google.com/forum/#!forum/leotask) | [**Wiki**](https://github.com/mleoking/LeoTask/wiki)
## Features:
-* Automatic & parallel parameter space exploration
-* Flexible & configuration-based result aggregation
-* Programming model focusing only on the key logic
-* Reliable & automatic interruption recovery
-* ...
+* Automatic & parallel parameter space exploration.
+* Flexible & configuration-based result aggregation.
+* Programming model focusing only on the key logic.
+* Reliable & automatic interruption recovery.
+* Ultra lightweight ~ 300KB Jar.
-## Utilities
-* Dynamic & cloneable networks structures: a node, a link, a network, and a network set (within which networks can overlap with each other).
-* Integration with Gnuplot
-* Network generation according to common network models
-* DelimitedReader: a sophisticated reader that explores CSV (Comma-separated values) files like a database
-* Fast random number generator based on the Mersenne Twister algorithm
-* ...
+## Utilities:
+* [All dynamic & cloneable networks structures](leotask/src/app/org/leores/demo/NetDemo.java): a node, a link, a network, a network set (within which networks can overlap with each other), multiplex networks.
+* [Integration with Gnuplot](leotask/src/app/org/leores/demo/JGnuplotDemo.java): hybrid programming with Gnuplot, output statistic results as Gnuplot scripts.
+* [Network generation according to common network models](leotask/src/app/org/leores/demo/ModDemo.java): random networks, scale-free networks, etc.
+* [DelimitedReader](leotask/src/app/org/leores/demo/DelimitedReaderDemo.java): a sophisticated reader that explores CSV (Comma-Separated Values) files like a database.
+* [Fast random number generator based on the Mersenne Twister algorithm](leotask/src/app/org/leores/demo/RandomUtilDemo.java).
+* [Versatile curve fitter and function value optimizer (minimizer)](leotask/src/app/org/leores/demo/MathDemo.java).
## Example Application:
-Please refer to [the introduction](https://github.com/mleoking/leotask/blob/master/leotask/introduction.pdf?raw=true) for building an example application using the framework.
+Please refer to [the introduction](leotask/doc/introduction.pdf?raw=true) for building an example application using the framework.
### Code (RollDice.java):
```java
@@ -44,7 +44,7 @@ public class RollDice extends Task {
public boolean step() {
boolean rtn = iStep <= nDice;
if (rtn) {
- sum += (int) (rand.nextDouble() * nSide);
+ sum += (int) (rand.nextDouble() * nSide + 1);
}
return rtn;
}
@@ -54,23 +54,22 @@ public class RollDice extends Task {
### Configuration (rolldice.xml):
```xml
-
+
-
-
-
-
+
+
+
```
-Before running the example application, please install [Java](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html) and include the the directory of the command _java_ in the system's _PATH_ environment variable.
+Before running the example application, please install [Java](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html) and include the the directory of the command _java_ in the system's _PATH_ environment variable. Windows system users can alternatively download and install (_install.bat_) the all-in-one runtime environment package: [LeoTaskRunEnv](https://github.com/mleoking/LeoTaskApp/releases/download/v1.0.0/LeoTaskRunEnv.zip)
Chang the current directory to the "Demo" folder and then execute the following commnad
@@ -78,9 +77,9 @@ Chang the current directory to the "Demo" folder and then execute the following
If you are using a MS windows system, you can also execute "rolldice.bat".
-Additional applications using the framework can be found in [LeoTaskApp](https://github.com/mleoking/LeoTaskApp).
-
## References:
-[1] Changwang Zhang, Shi Zhou, Benjamin M. Chain (January 2015). "[LeoTask: a fast, flexible and reliable framework for computational research](http://arxiv.org/abs/1501.01678)" (arXiv:1501.01678). Cornell University. [(PDF)](http://arxiv-web3.library.cornell.edu/pdf/1501.01678v1)
+[1] Changwang Zhang, Shi Zhou, Benjamin M. Chain (2015). "[LeoTask: a fast, flexible and reliable framework for computational research](http://arxiv.org/abs/1501.01678)", arXiv:1501.01678. [(PDF)](http://arxiv-web3.library.cornell.edu/pdf/1501.01678v1)
+
+
diff --git a/leotask/.gitignore b/leotask/.gitignore
new file mode 100644
index 0000000..7aac4fd
--- /dev/null
+++ b/leotask/.gitignore
@@ -0,0 +1,8 @@
+/bin/
+
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
+
+# Folder config file
+Desktop.ini
\ No newline at end of file
diff --git a/leotask/bin/.gitignore b/leotask/bin/.gitignore
deleted file mode 100644
index cf1db2e..0000000
--- a/leotask/bin/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/org/
diff --git a/leotask/demo/dreader.csv b/leotask/demo/dreader.csv
index 9f14afa..ee3c7be 100644
--- a/leotask/demo/dreader.csv
+++ b/leotask/demo/dreader.csv
@@ -1,26 +1,38 @@
-Test file for csv reader,,,
-----,,,
-1,2,3,4
-5,6,7,8
-data,end,,
----,,,
----,,,
-data,start1,,
-c1,c2,c3,c4
-1,10,100,1000
-2,20,200,1100
-,,,
-data,end,,
-data,start2,,
-c1,c2,c3,c4
-1,30,300,2000
-4,40,400,9000
-1,50,500
-data,start3,,
-c1,c2,c3,c4
-1,30,300,3000
-1,40,400,4000
-2,50,500,
-2,50,500,
-1,30,300,5000
-1,40,400,6000
+Test file for csv reader,,,,
+----,,,,
+1,2,3,4,
+5,6,7,8,
+data,end,,,
+---,,,,
+---,,,,
+data,start1,,,
+c1,c2,c3,c4,
+1,10,100,1000,
+2,20,200,1100,
+,,,,
+data,end,,,
+data,start2,,,
+c1,c2,c3,c4,
+1,30,300,2000,
+4,40,400,9000,
+1,50,500,,
+data,start3,,,
+c1,c2,c3,c4,
+1,30,300,3000,
+1,40,400,4000,
+2,50,500,,
+2,50,500,,
+1,30,300,5000,
+1,40,400,6000,
+data,end,,,
+,,,,
+id,name,age,,
+mm1,Leo,25,,
+mm2,Emily,18,,
+,,,,
+id,date,blood pressure,heart rate,mood
+mm1,01-Apr,100,50,Happy
+mm1,05-Apr,120,60,Sad
+mm2,01-Apr,80,40,
+mm2,03-Apr,90,,Sad
+mm2,05-Apr,,50,Happy
diff --git a/leotask/demo/leotask.jar b/leotask/demo/leotask.jar
index bcc1d3d..015582f 100644
Binary files a/leotask/demo/leotask.jar and b/leotask/demo/leotask.jar differ
diff --git a/leotask/demo/leotask.zip b/leotask/demo/leotask.zip
index 80cbc66..46cccf0 100644
Binary files a/leotask/demo/leotask.zip and b/leotask/demo/leotask.zip differ
diff --git a/leotask/demo/rolldice#.xml b/leotask/demo/rolldice#.xml
index ff8c5e5..b1085fa 100644
--- a/leotask/demo/rolldice#.xml
+++ b/leotask/demo/rolldice#.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/leotask/demo/rolldice.xml b/leotask/demo/rolldice.xml
index 28182f7..d1aee00 100644
--- a/leotask/demo/rolldice.xml
+++ b/leotask/demo/rolldice.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/leotask/introduction.pdf b/leotask/doc/introduction.pdf
similarity index 68%
rename from leotask/introduction.pdf
rename to leotask/doc/introduction.pdf
index 8b918b2..949475c 100644
Binary files a/leotask/introduction.pdf and b/leotask/doc/introduction.pdf differ
diff --git a/leotask/src/app/org/leores/demo/DelimitedReaderDemo.java b/leotask/src/app/org/leores/demo/DelimitedReaderDemo.java
index 6c01d4c..af486ae 100644
--- a/leotask/src/app/org/leores/demo/DelimitedReaderDemo.java
+++ b/leotask/src/app/org/leores/demo/DelimitedReaderDemo.java
@@ -7,11 +7,12 @@
import org.leores.util.Logger;
import org.leores.util.U;
import org.leores.util.able.Processable1;
+import org.leores.util.data.DataTable;
public class DelimitedReaderDemo extends Demo {
+ String sFile = "dreader.csv";
public void delimitedReader() {
- String sFile = "dreader.csv";
String[] rowToStart1 = { "data", "start1" };
String[] columnsToRead = { "c4", "c1" };
String[] rowToEnd = { "data", "end" };
@@ -90,8 +91,6 @@ public void delimitedReader() {
}
protected void _readRowPatterns(String[] rowPattern, String[] rowToStart, String[] columnsToRead, String[] rowToEnd) {
- String sFile = "dreader.csv";
-
DelimitedReader dr;
String[] row;
List lrow;
@@ -174,10 +173,32 @@ public void readRowPatterns() {
_readRowPatterns(rowPatterns, rowToStartEnd, columnsToRead, rowToStartEnd);
}
+ public void readRelatedData() {
+ log("Read from related data:");
+ try {
+ DelimitedReader dr = new DelimitedReader(sFile);
+ dr.prep(null, new String[] { "id", "name" });
+ dr.setValidRowPattern(new String[] { null, "Emily" });
+ String[] row = dr.readValidRow();
+ String id = row[0];
+ dr.prep(null, new String[] { "id", "date", "mood", "blood pressure", "heart rate" });
+ dr.setValidRowPattern(new String[] { id });
+ DataTable dt = dr.readValidDataTable();
+
+ log(dt.getColNames());
+ for (int i = 0, mi = dt.nRows(); i < mi; i++) {
+ log(dt.getRow(i));
+ }
+ } catch (FileNotFoundException e) {
+ log(e);
+ }
+ }
+
public static void demo() {
DelimitedReaderDemo drd = new DelimitedReaderDemo();
- //drd.delimitedReader();
+ drd.delimitedReader();
drd.readRowPatterns();
+ drd.readRelatedData();
}
}
diff --git a/leotask/src/app/org/leores/demo/Demo.java b/leotask/src/app/org/leores/demo/Demo.java
index 54bcd29..ac1b65b 100644
--- a/leotask/src/app/org/leores/demo/Demo.java
+++ b/leotask/src/app/org/leores/demo/Demo.java
@@ -23,14 +23,14 @@ public static void main(String[] args) {
//DelimitedReaderDemo.demo();
//EpidemicDemo.demo();
//FileUtilDemo.demo();
- //JGnuplotDemo.demo();
+ JGnuplotDemo.demo();
//MathDemo.demo();
//ModDemo.demo();
//NetDemo.demo();
//ObjUtilDemo.demo();
//ProcessableDemo.demo();
//RandomUtilDemo.demo();
- TaskDemo.demo();
+ //TaskDemo.demo();
//UtilDemo.demo();
}
}
diff --git a/leotask/src/app/org/leores/demo/JGnuplotDemo.java b/leotask/src/app/org/leores/demo/JGnuplotDemo.java
index 72bc4a9..e476565 100644
--- a/leotask/src/app/org/leores/demo/JGnuplotDemo.java
+++ b/leotask/src/app/org/leores/demo/JGnuplotDemo.java
@@ -18,15 +18,131 @@ public JGnuplotDemo() {
prepPlot();
}
- public void simple() {
- JGnuplot jg = new JGnuplot();
- Plot plot0 = new Plot("simpleplot");
- plot0.load("xlabel=x;ylabel=y;");
+ public void plot2d() {
+ JGnuplot jg = new JGnuplot() {
+ {
+ terminal = "pngcairo enhanced dashed";
+ output = "plot2d.png";
+ }
+ };
+ Plot plot = new Plot("") {
+ {
+ xlabel = "x";
+ ylabel = "y";
+ }
+ };
+ double[] x = { 1, 2, 3, 4, 5 }, y1 = { 2, 4, 6, 8, 10 }, y2 = { 3, 6, 9, 12, 15 };
+ DataTableSet dts = plot.addNewDataTableSet("2D Plot");
+ dts.addNewDataTable("y=2x", x, y1);
+ dts.addNewDataTable("y=3x", x, y2);
+ jg.execute(plot, jg.plot2d);
+ }
+
+ public void plot2dBar() {
+ JGnuplot jg = new JGnuplot() {
+ {
+ terminal = "pngcairo enhanced dashed";
+ output = "plot2dBar.png";
+ }
+ };
+ Plot plot = new Plot("") {
+ {
+ xlabel = "x";
+ ylabel = "y";
+ yrange = "[0:15]";
+ extra2 = "set key top left";
+ }
+ };
double[] x = { 1, 2, 3, 4, 5 }, y1 = { 2, 4, 6, 8, 10 }, y2 = { 3, 6, 9, 12, 15 };
- DataTableSet dts = plot0.addNewDataTableSet("Simple plot");
- dts.addNewDataTable("2x", x, y1);
- dts.addNewDataTable("3x", x, y2);
- jg.execute(plot0, jg.plot2d);
+ DataTableSet dts = plot.addNewDataTableSet("2D Bar");
+ DataTable dt = dts.addNewDataTable("", x, y1, y2);
+ dt.insert(0, new String[] { "", "y1=2x", "y2=3x" });
+ jg.execute(plot, jg.plot2dBar);
+ }
+
+ public void plot3d() {
+ JGnuplot jg = new JGnuplot() {
+ {
+ terminal = "pngcairo enhanced dashed";
+ output = "plot3d.png";
+ }
+ };
+ Plot plot = new Plot("") {
+ {
+ xlabel = "x";
+ ylabel = "y";
+ zlabel = "z";
+ }
+ };
+ double[] x = { 1, 2, 3, 4, 5 }, y = { 2, 4, 6, 8, 10 }, z = { 3, 6, 9, 12, 15 }, z2 = { 2, 8, 18, 32, 50 };
+ DataTableSet dts = plot.addNewDataTableSet("3D Plot");
+ dts.addNewDataTable("z=x+y", x, y, z);
+ dts.addNewDataTable("z=x*y", x, y, z2);
+ jg.execute(plot, jg.plot3d);
+ }
+
+ public void plotDensity() {
+ JGnuplot jg = new JGnuplot() {
+ {
+ terminal = "pngcairo enhanced dashed";
+ output = "plotDensity.png";
+ }
+ };
+ Plot plot = new Plot("") {
+ {
+ xlabel = "x";
+ ylabel = "y";
+ zlabel = "z=x^2+y^2";
+ }
+ };
+ DataTableSet dts = plot.addNewDataTableSet("Density Plot");
+ //prepare data
+ List x = new ArrayList(), y = new ArrayList(), z = new ArrayList();
+ for (double i = -2; i <= 2; i += 0.5) {
+ for (double j = -2; j <= 2; j += 0.5) {
+ x.add(i);
+ y.add(j);
+ z.add(i * i + j * j);
+ }
+ }
+ dts.addNewDataTable("z=x^2+y^2", x, y, z);
+ jg.execute(plot, jg.plotDensity);
+ }
+
+ public void plotImage() {
+ JGnuplot jg = new JGnuplot() {
+ {
+ terminal = "pngcairo enhanced dashed";
+ output = "plotImage.png";
+ }
+ };
+ Plot plot = new Plot("") {
+ {
+ xlabel = "x";
+ ylabel = "y";
+ zlabel = "z=x^2+y^2";
+ }
+ };
+ DataTableSet dts = plot.addNewDataTableSet("Image Plot");
+ //prepare data
+ List x = new ArrayList(), y = new ArrayList(), z = new ArrayList();
+ for (double i = -2; i <= 2; i += 0.5) {
+ for (double j = -2; j <= 2; j += 0.5) {
+ x.add(i);
+ y.add(j);
+ z.add(i * i + j * j);
+ }
+ }
+ dts.addNewDataTable("z=x^2+y^2", x, y, z);
+ jg.execute(plot, jg.plotImage);
+ }
+
+ public void simple() {
+ plot2d();
+ plot2dBar();
+ plot3d();
+ plotDensity();
+ plotImage();
}
public void prepPlot() {
@@ -83,6 +199,9 @@ public void prepPlot() {
plot2.add(dts2);
}
+ /**
+ * Output the generated gnuplot script file without executing it.
+ */
public void compile() {
JGnuplot jg = new JGnuplot();
jg.compile(plot1, jg.plot2d);//if file name is omitted it will use plot.info+".plt" as the file name.
@@ -91,13 +210,18 @@ public void compile() {
jg.compile(plot1, jg.multiplot, "jgnuplot3.plt");
}
+ /**
+ * Shows how to use both synchronized and asynchronized running of Gnuplot.
+ * (Synchronized: your java program will wait until you close the popped
+ * Gnuplot window; Asynchronized: you java program will not wait.)
+ */
public void execute() {
JGnuplot jg = new JGnuplot();
jg.terminal = "wxt enhanced";
jg.execute(plot1, jg.plot2d, jg.JG_InNewThread | jg.JG_Pause);
jg.execute(plot2, jg.plot3d);
jg.beforeStyleVar = "ls1=10;ls10=1;ls2=9;ls9=2;";
- jg.executeA(plot1, jg.plot2d);//asynchronous plot in a new thread
+ jg.executeA(plot1, jg.plot2d);//Asynchronous plot in a new thread
jg.beforeStyleVar = null;
jg.extra = "set label \"Dynamically add extra code using the extra field.\" at graph 0.5,0.5 center";
//jg.extra = "set style line 1 lc rgbcolor 'greenyellow' lt 1 lw 2 pt 1";
@@ -107,13 +231,18 @@ public void execute() {
jg.execute(plot1, jg.multiplot);//show gnuplot warning in the java console. warning can be easily solved by extending the canvas size
}
+ /**
+ * Show different available terminals to plot. Please refer to the Gnuplot
+ * website for the complete list of terminals.
+ */
public void terminals() {
JGnuplot jg = new JGnuplot();
+ jg.execute(plot1, jg.plot2d);//Using the default terminal
//windows terminal is only available to windows. You might get error output from gnuplot if you are not using windows.
jg.terminal = "windows enhanced dashed title 'id=100 hello there' size 600,600";
jg.beforeStyle = "linewidth=4";
jg.execute(plot1, jg.plot2d, ~jg.JG_DeleteTempFile);
- jg.terminal = null;
+ jg.terminal = null;//Set the terminal to the default terminal
jg.execute(plot1, jg.plot2d);//wxt terminal default size 640,384
jg.terminal = "dumb";//ascii art terminal for anything that prints text
jg.execute(plot1, jg.plot2d);
@@ -149,7 +278,7 @@ class JGnuplot2 extends JGnuplot {
public void initialize() {
String sFLoad2 = "jgnuplot2.xml";
- U.copyFileFromClassPath(this, sFLoad2, sFLoad2, false);//this also works in a jar file
+ //U.copyFileFromClassPath(this, sFLoad2, sFLoad2, false);//this also works in a jar file
U.loadFromXML(this, sFLoad2, false);
}
}
@@ -161,10 +290,10 @@ public void initialize() {
public static void demo() {
JGnuplotDemo jgd = new JGnuplotDemo();
jgd.simple();
- jgd.compile();
- jgd.execute();
- jgd.terminals();
- jgd.plotx();
+ //jgd.compile();
+ //jgd.execute();
+ //jgd.terminals();
+ //jgd.plotx();
}
}
diff --git a/leotask/src/app/org/leores/task/app/RollDice.java b/leotask/src/app/org/leores/task/app/RollDice.java
index 50695fb..674f808 100644
--- a/leotask/src/app/org/leores/task/app/RollDice.java
+++ b/leotask/src/app/org/leores/task/app/RollDice.java
@@ -49,7 +49,7 @@ public void beforeRept() {
public boolean step() {
boolean rtn = iStep <= nDice;
if (rtn) {
- sum += (int) (rand.nextDouble() * nSide);
+ sum += (int) (rand.nextDouble() * nSide + 1);
}
return rtn;
}
@@ -87,7 +87,7 @@ public static void mDrawPDF(Tasks tTasks) {
{
xlabel = "No. of sides";
ylabel = "Sum";
- yrange = "[0:9]";
+ yrange = "[0:15]";
extra2 = "unset key;";
}
};
diff --git a/leotask/src/core/org/leores/plot/JGnuplot.java b/leotask/src/core/org/leores/plot/JGnuplot.java
index 76f4267..d4432c9 100644
--- a/leotask/src/core/org/leores/plot/JGnuplot.java
+++ b/leotask/src/core/org/leores/plot/JGnuplot.java
@@ -453,7 +453,6 @@ protected void saveToFile(String sFile, DataTable dt, String type) {
}
String line = U.wrap(sRow, "", "", " ");
fw.append(line + "\n");
-
}
fw.append("e\n");
fw.flush();
diff --git a/leotask/src/core/org/leores/plot/jgnuplot.xml b/leotask/src/core/org/leores/plot/jgnuplot.xml
index b74bba7..1ba78cf 100644
--- a/leotask/src/core/org/leores/plot/jgnuplot.xml
+++ b/leotask/src/core/org/leores/plot/jgnuplot.xml
@@ -136,6 +136,7 @@ set cblabel "$zlabel$";
$header$
unset key;
set view map;
+set title "$info(1)$";
$bp$$bp2$plot '-' using 1:2:3 with image;
$data(1,3d)$
diff --git a/leotask/src/core/org/leores/util/DelimitedReader.java b/leotask/src/core/org/leores/util/DelimitedReader.java
index 3a72a20..4ff0b5f 100644
--- a/leotask/src/core/org/leores/util/DelimitedReader.java
+++ b/leotask/src/core/org/leores/util/DelimitedReader.java
@@ -366,6 +366,10 @@ public DataTable readValidDataTable(boolean bBlock, String info, int... iRtnColu
public DataTable readValidDataTable(boolean bBlock, String info) {
return readValidDataTable(bBlock, info, null);
}
+
+ public DataTable readValidDataTable() {
+ return readValidDataTable(false, null, null);
+ }
public String[] getRowLastRead() {
return rowLastRead;
diff --git a/leotask/src/core/org/leores/util/SerialUtil.java b/leotask/src/core/org/leores/util/SerialUtil.java
index 8399738..620e617 100644
--- a/leotask/src/core/org/leores/util/SerialUtil.java
+++ b/leotask/src/core/org/leores/util/SerialUtil.java
@@ -403,30 +403,34 @@ public static boolean loadFromXML(Object tObj, String sFile, boolean bUnMatchExc
boolean rtn = false;
if (tObj != null && U.valid(sFile)) {
- try {
- File file = new File(sFile);
- DocumentBuilderFactory dBFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder dBuilder;
- dBuilder = dBFactory.newDocumentBuilder();
- Document doc = dBuilder.parse(file);
- doc.getDocumentElement().normalize();
-
- Class objClass = tObj.getClass();
- Element eRoot = doc.getDocumentElement();
- String objClassName = objClass.getName();
- String docRootName = eRoot.getNodeName();
-
- if (objClassName.indexOf(docRootName) < 0 && bUnMatchException) {
- throw new TRuntimeException("loadFromXML: root element does not match the Object class! [sFile,objClassName,docRootName]:", sFile, objClassName, docRootName);
- }
+ if (U.bExistFile(sFile)) {
+ try {
+ File file = new File(sFile);
+ DocumentBuilderFactory dBFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder dBuilder;
+ dBuilder = dBFactory.newDocumentBuilder();
+ Document doc = dBuilder.parse(file);
+ doc.getDocumentElement().normalize();
+
+ Class objClass = tObj.getClass();
+ Element eRoot = doc.getDocumentElement();
+ String objClassName = objClass.getName();
+ String docRootName = eRoot.getNodeName();
+
+ if (objClassName.indexOf(docRootName) < 0 && bUnMatchException) {
+ throw new TRuntimeException("loadFromXML: root element does not match the Object class! [sFile,objClassName,docRootName]:", sFile, objClassName, docRootName);
+ }
- rtn = loadFromXML(tObj, eRoot);
- } catch (ParserConfigurationException e) {
- tLog(e);
- } catch (SAXException e) {
- tLog(e);
- } catch (IOException e) {
- tLog(e);
+ rtn = loadFromXML(tObj, eRoot);
+ } catch (ParserConfigurationException e) {
+ tLog(e);
+ } catch (SAXException e) {
+ tLog(e);
+ } catch (IOException e) {
+ tLog(e);
+ }
+ } else {
+ throw new TRuntimeException("loadFromXML: file does not exist! [sFile]:", sFile);
}
}
diff --git a/leotask/src/core/org/leores/util/data/DataTable.java b/leotask/src/core/org/leores/util/data/DataTable.java
index a7f5c34..aa3f96e 100644
--- a/leotask/src/core/org/leores/util/data/DataTable.java
+++ b/leotask/src/core/org/leores/util/data/DataTable.java
@@ -92,6 +92,15 @@ public boolean addAll(boolean bAddUnEqualSizedList, Processable2