diff --git a/README.md b/README.md
index bc59ef5..19ecdcf 100644
--- a/README.md
+++ b/README.md
@@ -31,4 +31,4 @@ To fetch the stats of the given user:
to get data provided by the iConomy plugin:
http://server:port/money.xml
- http://server:port/money.xml?id=username self-explanatory
\ No newline at end of file
+ http://server:port/money.xml?id=username
\ No newline at end of file
diff --git a/doc/allclasses-frame.html b/doc/allclasses-frame.html
new file mode 100644
index 0000000..5524592
--- /dev/null
+++ b/doc/allclasses-frame.html
@@ -0,0 +1,51 @@
+
+
+
+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+Overview
+
+
+
+The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.
+
+Package
+
+
+
+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:
+
Interfaces (italic)
Classes
Enums
Exceptions
Errors
Annotation Types
+
+
+Class/Interface
+
+
+
+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
+
Class inheritance diagram
Direct Subclasses
All Known Subinterfaces
All Known Implementing Classes
Class/interface declaration
Class/interface description
+
+
Nested Class Summary
Field Summary
Constructor Summary
Method Summary
+
+
Field Detail
Constructor Detail
Method Detail
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+
+
+Annotation Type
+
+
+
+Each annotation type has its own separate page with the following sections:
+
Annotation Type declaration
Annotation Type description
Required Element Summary
Optional Element Summary
Element Detail
+
+
+
+Enum
+
+
+
+Each enum has its own separate page with the following sections:
+
Enum declaration
Enum description
Enum Constant Summary
Enum Constant Detail
+
+
+Use
+
+Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
+
+Tree (Class Hierarchy)
+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
+
When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
+
+
+Deprecated API
+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+
+Index
+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+
+Prev/Next
+These links take you to the next or previous class, interface, package, or related page.
+Frames/No Frames
+These links show and hide the HTML frames. All pages are available with or without frames.
+
+
+Serialized Form
+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
+
+
+
+
+
+
+
+
diff --git a/doc/package-list b/doc/package-list
new file mode 100644
index 0000000..9055f0d
--- /dev/null
+++ b/doc/package-list
@@ -0,0 +1,3 @@
+de.sockenklaus.XmlStats
+de.sockenklaus.XmlStats.Datasource
+de.sockenklaus.XmlStats.XmlWorkers
diff --git a/doc/resources/inherit.gif b/doc/resources/inherit.gif
new file mode 100644
index 0000000..c814867
Binary files /dev/null and b/doc/resources/inherit.gif differ
diff --git a/doc/stylesheet.css b/doc/stylesheet.css
new file mode 100644
index 0000000..cbd3428
--- /dev/null
+++ b/doc/stylesheet.css
@@ -0,0 +1,29 @@
+/* Javadoc style sheet */
+
+/* Define colors, fonts and other style attributes here to override the defaults */
+
+/* Page background color */
+body { background-color: #FFFFFF; color:#000000 }
+
+/* Headings */
+h1 { font-size: 145% }
+
+/* Table colors */
+.TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */
+.TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */
+.TableRowColor { background: #FFFFFF; color:#000000 } /* White */
+
+/* Font used in left-hand frame lists */
+.FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
+.FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
+.FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }
+
+/* Navigation bar fonts and colors */
+.NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */
+.NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */
+.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;}
+.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;}
+
+.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
+.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}
+
diff --git a/src/de/sockenklaus/XmlStats/Datasource/Datasource.java b/src/de/sockenklaus/XmlStats/Datasource/Datasource.java
index 4b084bf..3b4596d 100644
--- a/src/de/sockenklaus/XmlStats/Datasource/Datasource.java
+++ b/src/de/sockenklaus/XmlStats/Datasource/Datasource.java
@@ -1,12 +1,35 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats.Datasource;
import java.io.File;
import java.util.ArrayList;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Datasource.
+ */
public abstract class Datasource {
+ /**
+ * Fetch all players.
+ *
+ * @return the array list
+ */
protected ArrayList fetchAllPlayers(){
File[] files = new File("world/players").listFiles();
ArrayList result = new ArrayList();
diff --git a/src/de/sockenklaus/XmlStats/Datasource/MoneyDS.java b/src/de/sockenklaus/XmlStats/Datasource/MoneyDS.java
index a3a7319..17d6d64 100644
--- a/src/de/sockenklaus/XmlStats/Datasource/MoneyDS.java
+++ b/src/de/sockenklaus/XmlStats/Datasource/MoneyDS.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats.Datasource;
+/**
+ * The Class MoneyDS.
+ */
public class MoneyDS extends Datasource {
}
diff --git a/src/de/sockenklaus/XmlStats/Datasource/StatsDS.java b/src/de/sockenklaus/XmlStats/Datasource/StatsDS.java
index 3952932..2aec2fa 100644
--- a/src/de/sockenklaus/XmlStats/Datasource/StatsDS.java
+++ b/src/de/sockenklaus/XmlStats/Datasource/StatsDS.java
@@ -1,3 +1,17 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats.Datasource;
import java.io.File;
@@ -10,12 +24,24 @@ import com.nidefawl.Stats.datasource.PlayerStatSQL;
import de.sockenklaus.XmlStats.XmlStats;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class StatsDS.
+ */
public class StatsDS extends Datasource {
+
+ /** The stats plugin. */
private Stats statsPlugin;
//private Server serverRef;
+ /** The all player names. */
private ArrayList allPlayerNames;
+
+ /** The stats. */
private HashMap stats = new HashMap();
+ /**
+ * Instantiates a new stats ds.
+ */
public StatsDS() {
this.statsPlugin = XmlStats.getStatsPlugin();
//this.serverRef = XmlStats.getServerRef();
@@ -23,14 +49,30 @@ public class StatsDS extends Datasource {
this.stats = fetchAllPlayerStats(allPlayerNames);
}
+ /**
+ * Gets the plugin.
+ *
+ * @return the plugin
+ */
public Stats getPlugin() {
return this.statsPlugin;
}
+ /**
+ * Gets the data folder.
+ *
+ * @return the data folder
+ */
public File getDataFolder(){
return this.statsPlugin.getDataFolder();
}
+ /**
+ * Fetch all player stats.
+ *
+ * @param pPlayerNames the player names
+ * @return the hash map
+ */
private HashMap fetchAllPlayerStats(ArrayList pPlayerNames){
HashMap result = new HashMap();
@@ -44,6 +86,11 @@ public class StatsDS extends Datasource {
return result;
}
+ /**
+ * Gets the stats.
+ *
+ * @return the stats
+ */
public HashMap getStats(){
return this.stats;
}
diff --git a/src/de/sockenklaus/XmlStats/Datasource/UsersDS.java b/src/de/sockenklaus/XmlStats/Datasource/UsersDS.java
index 2a4cbe2..22868e8 100644
--- a/src/de/sockenklaus/XmlStats/Datasource/UsersDS.java
+++ b/src/de/sockenklaus/XmlStats/Datasource/UsersDS.java
@@ -1,8 +1,32 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats.Datasource;
import java.util.ArrayList;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class UsersDS.
+ */
public class UsersDS extends Datasource {
+
+ /**
+ * Gets the all players.
+ *
+ * @return the all players
+ */
public ArrayList getAllPlayers(){
return fetchAllPlayers();
}
diff --git a/src/de/sockenklaus/XmlStats/Settings.java b/src/de/sockenklaus/XmlStats/Settings.java
index 219a632..6bf34d8 100644
--- a/src/de/sockenklaus/XmlStats/Settings.java
+++ b/src/de/sockenklaus/XmlStats/Settings.java
@@ -1,13 +1,37 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats;
import java.io.File;
import org.bukkit.util.config.Configuration;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Settings.
+ */
public class Settings {
+
private static final String configFilename = "config.yml";
private Configuration conf;
+ /**
+ * Instantiates a new settings.
+ *
+ * @param xmlStats the xml stats
+ */
public Settings(XmlStats xmlStats){
File f = new File(xmlStats.getDataFolder(), configFilename);
@@ -26,18 +50,51 @@ public class Settings {
}
}
+ /**
+ * Gets the int.
+ *
+ * @param path the path
+ * @return the int
+ */
public int getInt(String path){
return conf.getInt(path, -1);
}
+
+ /**
+ * Gets the boolean.
+ *
+ * @param path the path
+ * @return the boolean
+ */
public boolean getBoolean(String path){
return conf.getBoolean(path, false);
}
+
+ /**
+ * Gets the string.
+ *
+ * @param path the path
+ * @return the string
+ */
public String getString(String path){
return conf.getString(path, "");
}
+
+ /**
+ * Sets the property.
+ *
+ * @param path the path
+ * @param value the value
+ */
public void setProperty(String path, Object value){
conf.setProperty(path, value);
}
+
+ /**
+ * Gets the settings filename.
+ *
+ * @return the settings filename
+ */
public String getSettingsFilename(){
return configFilename;
}
diff --git a/src/de/sockenklaus/XmlStats/WebServer.java b/src/de/sockenklaus/XmlStats/WebServer.java
index 52a9a4c..162a3e4 100644
--- a/src/de/sockenklaus/XmlStats/WebServer.java
+++ b/src/de/sockenklaus/XmlStats/WebServer.java
@@ -1,3 +1,17 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats;
import java.io.IOException;
@@ -7,15 +21,21 @@ import com.sun.net.httpserver.HttpServer;
import de.sockenklaus.XmlStats.XmlWorkers.*;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class WebServer.
+ */
@SuppressWarnings("restriction")
public class WebServer {
-
+
private InetSocketAddress address;
private HttpServer server = null;
-
- /*
- * Konstruktoren, um die Address zu initialisieren
+ /**
+ * Instantiates a new web server.
+ *
+ * @param port the port
+ * @throws IOException Signals that an I/O exception has occurred.
*/
public WebServer(int port) throws IOException {
this.address = new InetSocketAddress(port);
@@ -29,14 +49,19 @@ public class WebServer {
this.server.start();
}
- /*
- * Beende den Server
+ /**
+ * Stop server.
*/
public void stopServer() {
server.stop(0);
}
- public boolean serverRunning(){
+ /**
+ * Server running.
+ *
+ * @return true, if successful
+ */
+ public boolean isRunning(){
return (this.server == null) ? false : true;
}
}
diff --git a/src/de/sockenklaus/XmlStats/XmlStats.java b/src/de/sockenklaus/XmlStats/XmlStats.java
index cd183ec..5914fc6 100644
--- a/src/de/sockenklaus/XmlStats/XmlStats.java
+++ b/src/de/sockenklaus/XmlStats/XmlStats.java
@@ -1,3 +1,17 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats;
import java.util.logging.Level;
@@ -8,20 +22,27 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.nidefawl.Stats.Stats;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class XmlStats.
+ */
public class XmlStats extends JavaPlugin {
- public final static Logger log = Logger.getLogger("Minecraft");
- public final static double version = 0.01;
- public final static String logprefix = "[XmlStats]";
- public boolean enabled = false;
+ private final static Logger log = Logger.getLogger("Minecraft");
+ private final static double version = 0.01;
+ private final static String logprefix = "[XmlStats]";
+ private boolean enabled = false;
private static Stats statsPlugin;
private static Server serverRef;
private WebServer xmlQueryServer;
private Settings settings;
+ /* (non-Javadoc)
+ * @see org.bukkit.plugin.Plugin#onDisable()
+ */
@Override
public void onDisable() {
- if(enabled && xmlQueryServer.serverRunning()){
+ if(enabled && xmlQueryServer.isRunning()){
enabled = false;
xmlQueryServer.stopServer();
@@ -32,6 +53,9 @@ public class XmlStats extends JavaPlugin {
LogInfo("Plugin Disabled");
}
+ /* (non-Javadoc)
+ * @see org.bukkit.plugin.Plugin#onEnable()
+ */
@Override
public void onEnable() {
@@ -66,22 +90,47 @@ public class XmlStats extends JavaPlugin {
}
+ /**
+ * Log error.
+ *
+ * @param Message the message
+ */
public static void LogError(String Message) {
log.log(Level.SEVERE, logprefix + " " + Message);
}
+ /**
+ * Log info.
+ *
+ * @param Message the message
+ */
public static void LogInfo(String Message) {
log.info(logprefix + " " + Message);
}
+ /**
+ * Log warn.
+ *
+ * @param Message the message
+ */
public static void LogWarn(String Message){
log.log(Level.WARNING, logprefix + " "+ Message);
}
+ /**
+ * Gets the stats plugin.
+ *
+ * @return the stats plugin
+ */
public static Stats getStatsPlugin(){
return statsPlugin;
}
+ /**
+ * Gets the server ref.
+ *
+ * @return the server ref
+ */
public static Server getServerRef(){
return serverRef;
}
diff --git a/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorker.java b/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorker.java
index 27e9de9..134f308 100644
--- a/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorker.java
+++ b/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorker.java
@@ -1,3 +1,17 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats.XmlWorkers;
import java.io.IOException;
@@ -14,9 +28,16 @@ import com.sun.net.httpserver.HttpExchange;
import de.sockenklaus.XmlStats.XmlStats;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class XmlWorker.
+ */
@SuppressWarnings("restriction")
public abstract class XmlWorker implements HttpHandler {
+ /* (non-Javadoc)
+ * @see com.sun.net.httpserver.HttpHandler#handle(com.sun.net.httpserver.HttpExchange)
+ */
public void handle(HttpExchange exchange) {
Map> parameters = new HashMap>();
@@ -51,6 +72,13 @@ public abstract class XmlWorker implements HttpHandler {
}
}
+ /**
+ * Parses the parameters.
+ *
+ * @param queryString the query string
+ * @return the map
+ * @throws UnsupportedEncodingException the unsupported encoding exception
+ */
public Map> parseParameters(String queryString) throws UnsupportedEncodingException {
Map> result = new HashMap>();
@@ -87,5 +115,11 @@ public abstract class XmlWorker implements HttpHandler {
return result;
}
+ /**
+ * Gets the xML.
+ *
+ * @param parameters the parameters
+ * @return the xML
+ */
abstract String getXML(Map> parameters);
}
diff --git a/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerMoney.java b/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerMoney.java
index 8a2f085..883774c 100644
--- a/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerMoney.java
+++ b/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerMoney.java
@@ -1,10 +1,31 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats.XmlWorkers;
import java.util.List;
import java.util.Map;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class XmlWorkerMoney.
+ */
public class XmlWorkerMoney extends XmlWorker {
+ /* (non-Javadoc)
+ * @see de.sockenklaus.XmlStats.XmlWorkers.XmlWorker#getXML(java.util.Map)
+ */
@Override
public String getXML(Map> parameters) {
// TODO Auto-generated method stub
diff --git a/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerUsers.java b/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerUsers.java
index ede6357..92f7397 100644
--- a/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerUsers.java
+++ b/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerUsers.java
@@ -1,3 +1,17 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats.XmlWorkers;
import java.io.StringWriter;
@@ -19,8 +33,15 @@ import com.nidefawl.Stats.Stats;
import de.sockenklaus.XmlStats.Datasource.UsersDS;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class XmlWorkerUsers.
+ */
public class XmlWorkerUsers extends XmlWorker {
+ /* (non-Javadoc)
+ * @see de.sockenklaus.XmlStats.XmlWorkers.XmlWorker#getXML(java.util.Map)
+ */
@Override
public String getXML(Map> parameters) {
UsersDS users = new UsersDS();
diff --git a/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerUserstats.java b/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerUserstats.java
index 15e97a3..e16182f 100644
--- a/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerUserstats.java
+++ b/src/de/sockenklaus/XmlStats/XmlWorkers/XmlWorkerUserstats.java
@@ -1,3 +1,17 @@
+/*
+ * Copyright (C) [2011] [Pascal König]
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of
+* the GNU General Public License as published by the Free Software Foundation; either version
+* 3 of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+* See the GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along with this program;
+* if not, see .
+*/
package de.sockenklaus.XmlStats.XmlWorkers;
import java.io.File;
@@ -24,9 +38,27 @@ import com.nidefawl.Stats.datasource.PlayerStat;
import de.sockenklaus.XmlStats.Datasource.StatsDS;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class XmlWorkerUserstats.
+ */
public class XmlWorkerUserstats extends XmlWorker {
- @Override
+ /** The stats ds. */
+ StatsDS statsDS = new StatsDS();
+
+ /**
+ * Instantiates a new xml worker userstats.
+ */
+ public XmlWorkerUserstats(){
+ this.statsDS = new StatsDS();
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see de.sockenklaus.XmlStats.XmlWorkers.XmlWorker#getXML(java.util.Map)
+ */
public String getXML(Map> parameters) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -37,11 +69,6 @@ public class XmlWorkerUserstats extends XmlWorker {
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
- StatsDS statsDS = new StatsDS();
-
- hModItemResolver itemResolver = new hModItemResolver(new File(statsDS.getDataFolder(),"items.txt"));
-
- String[] resolveCats = {"blockdestroy", "blockcreate", "itemdrop", "itempickup"};
Element root = doc.createElement("stats");
doc.appendChild(root);
@@ -51,37 +78,9 @@ public class XmlWorkerUserstats extends XmlWorker {
*/
for(String playerName : statsDS.getStats().keySet()){
- PlayerStat player_stats = statsDS.getStats().get(playerName);
-
- Element elem_player = doc.createElement("player");
- elem_player.setAttribute("name", playerName);
-
- for(String catName : player_stats.getCats()){
- Category cat = player_stats.get(catName);
- Element elem_cat = doc.createElement("category");
- elem_cat.setAttribute("name", catName);
-
- for(String valName : cat.stats.keySet()){
- int value = cat.get(valName);
- Element elem_value = doc.createElement("stat");
-
- elem_value.setAttribute("name", valName);
-
- if (Arrays.asList(resolveCats).contains(catName)){
- elem_value.setAttribute("id", String.valueOf(itemResolver.getItem(valName)));
- }
- elem_value.setAttribute("value", String.valueOf(value));
-
- elem_cat.appendChild(elem_value);
- }
-
-
- elem_player.appendChild(elem_cat);
- }
-
- root.appendChild(elem_player);
+ root.appendChild(getPlayerElement(playerName, doc));
}
- /*
+ /*
* Hier endet der XML-Aufbau
*/
@@ -96,5 +95,45 @@ public class XmlWorkerUserstats extends XmlWorker {
return "";
}
-
+
+ /**
+ * Build a XML subtree for the given player.
+ *
+ * @param playerName the player name
+ * @param doc the doc
+ * @return Returns a XML subtree for the given playerName.
+ */
+ private Element getPlayerElement(String playerName, Document doc){
+ hModItemResolver itemResolver = new hModItemResolver(new File(statsDS.getDataFolder(),"items.txt"));
+ String[] resolveCats = {"blockdestroy", "blockcreate", "itemdrop", "itempickup"};
+
+ PlayerStat player_stats = statsDS.getStats().get(playerName);
+
+ Element elem_player = doc.createElement("player");
+ elem_player.setAttribute("name", playerName);
+
+ for(String catName : player_stats.getCats()){
+ Category cat = player_stats.get(catName);
+ Element elem_cat = doc.createElement("category");
+ elem_cat.setAttribute("name", catName);
+
+ for(String valName : cat.stats.keySet()){
+ int value = cat.get(valName);
+ Element elem_value = doc.createElement("stat");
+
+ elem_value.setAttribute("name", valName);
+
+ if (Arrays.asList(resolveCats).contains(catName)){
+ elem_value.setAttribute("id", String.valueOf(itemResolver.getItem(valName)));
+ }
+ elem_value.setAttribute("value", String.valueOf(value));
+
+ elem_cat.appendChild(elem_value);
+ }
+
+
+ elem_player.appendChild(elem_cat);
+ }
+ return elem_player;
+ }
}