From 09fa4bb91cf4e7f4e29136232a9daac37ef48529 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 22 Apr 2006 22:09:56 +0000 Subject: [PATCH] version 0.4.4: if default node is created, use it as selected node --- src/de/todesbaum/jsite/main/Configuration.java | 32 +++++++++++++++++++++++++- src/de/todesbaum/jsite/main/Version.java | 2 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index 3931dcb..1a06f37 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -171,18 +171,38 @@ public class Configuration { return Boolean.parseBoolean(nodeValue); } + /** + * Returns the hostname of the node. + * @return The hostname of the node + * @deprecated Use {@link #getSelectedNode()} instead + */ public String getNodeAddress() { return getNodeValue(new String[] { "node-address" }, "localhost"); } + /** + * Sets the hostname of the node. + * @param nodeAddress The hostname of the node + * @deprecated Use {@link #setSelectedNode(Node)} instead + */ public void setNodeAddress(String nodeAddress) { rootNode.replace("node-address", nodeAddress); } + /** + * The port number of the node + * @return The port number of the node + * @deprecated Use {@link #getSelectedNode()} instead. + */ public int getNodePort() { return getNodeIntValue(new String[] { "node-port" }, 9481); } + /** + * Sets the port number of the node. + * @param nodePort The port number of the node + * @deprecated Use {@link #setSelectedNode(Node)} instead + */ public void setNodePort(int nodePort) { rootNode.replace("node-port", String.valueOf(nodePort)); } @@ -305,6 +325,10 @@ public class Configuration { if (nodesNode == null) { String hostname = getNodeAddress(); int port = getNodePort(); + if (hostname == null) { + hostname = "127.0.0.1"; + port = 9481; + } return new Node[] { new Node(hostname, port, "Node") }; } SimpleXML[] nodeNodes = nodesNode.getNodes("node"); @@ -344,7 +368,13 @@ public class Configuration { public Node getSelectedNode() { SimpleXML selectedNodeNode = rootNode.getNode("selected-node"); if (selectedNodeNode == null) { - return null; + String hostname = getNodeAddress(); + int port = getNodePort(); + if (hostname == null) { + hostname = "127.0.0.1"; + port = 9481; + } + return new Node(hostname, port, "Node"); } String name = selectedNodeNode.getNode("name").getValue(); String hostname = selectedNodeNode.getNode("hostname").getValue(); diff --git a/src/de/todesbaum/jsite/main/Version.java b/src/de/todesbaum/jsite/main/Version.java index 1eb492e..2c635c8 100644 --- a/src/de/todesbaum/jsite/main/Version.java +++ b/src/de/todesbaum/jsite/main/Version.java @@ -25,7 +25,7 @@ package de.todesbaum.jsite.main; */ public class Version { - private static final String VERSION = "0.4.3"; + private static final String VERSION = "0.4.4"; public static final String getVersion() { return VERSION; -- 2.7.4