]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.management/src/org/simantics/db/management/discovery/ServerInfo.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.management / src / org / simantics / db / management / discovery / ServerInfo.java
diff --git a/bundles/org.simantics.db.management/src/org/simantics/db/management/discovery/ServerInfo.java b/bundles/org.simantics.db.management/src/org/simantics/db/management/discovery/ServerInfo.java
new file mode 100644 (file)
index 0000000..f4a18e2
--- /dev/null
@@ -0,0 +1,128 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db.management.discovery;\r
+\r
+import org.simantics.db.service.ServerInformation;\r
+\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class ServerInfo {\r
+\r
+    public static final ServerInfo[] NONE = {};\r
+\r
+    private final String             name;\r
+\r
+//    private final ServerAddress  address;\r
+    \r
+    private final ServerInformation  info;\r
+    \r
+    private final String aux_info;\r
+\r
+    /**\r
+     * @param name\r
+     * @param address\r
+     * @throws IllegalArgumentException if the address is not in host:port\r
+     *         format\r
+     */\r
+//    public ServerInfo(String name, String address) throws IllegalArgumentException {\r
+//        this(name, address, null, null);\r
+//    }\r
+    \r
+//    public ServerInfo(String name, String address, String aux_info) throws IllegalArgumentException {\r
+//        this(name, address, null, aux_info);\r
+//    }\r
+//\r
+//    public ServerInfo(String name) {\r
+//        this(name, null);\r
+//    }\r
+//    \r
+//    public ServerInfo(String name, String aux_info) {\r
+//        this(name, aux_info, null);\r
+//    }\r
+//\r
+//    public ServerInfo(String name, String address, ServerInformation info) throws IllegalArgumentException {\r
+//        this(name, address, info, null);\r
+//    }\r
+//\r
+    public ServerInfo(String name, ServerInformation info, String aux_info) throws IllegalArgumentException {\r
+        this.name = name;\r
+//        this.address = address == null ? null : new ServerAddress(address);\r
+        this.info = info;\r
+        this.aux_info = aux_info;\r
+    }\r
+//\r
+//    public ServerInfo(String name, ServerInformation info) {\r
+//        this(name, address, info, null);\r
+//    }\r
+//    \r
+//    public ServerInfo(String name, ServerInformation info, String aux_info) {\r
+//        this.name = name;\r
+////        this.address = address;\r
+//        this.info = info;\r
+//        this.aux_info = aux_info;\r
+//    }\r
+\r
+    public String getName() {\r
+        return name;\r
+    }\r
+\r
+//    public ServerAddress getAddress() {\r
+//        return address;\r
+//    }\r
+\r
+    public ServerInformation getInfo() {\r
+        return info;\r
+    }\r
+    \r
+    public String getAuxInfo() {\r
+       return aux_info;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+       String str = name + " "; //+ address;\r
+       if(aux_info != null)\r
+               str += " "+aux_info;\r
+       return str;\r
+    }\r
+\r
+    @Override\r
+    public int hashCode() {\r
+        return ((name == null) ? 0 : name.hashCode());\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (this == obj)\r
+            return true;\r
+        if (obj == null || getClass() != obj.getClass())\r
+            return false;\r
+        final ServerInfo other = (ServerInfo) obj;\r
+//        if (address == null) {\r
+//            if (other.address != null)\r
+//                return false;\r
+//            // The name field is used for equals\r
+//            // only when the address is null.\r
+//            if (!name.equals(other.name))\r
+//                return false;\r
+//        } else if (!address.equals(other.address))\r
+//            return false;\r
+        return true;\r
+    }\r
+\r
+//    public ServerInfo withAddress(ServerAddress address) {\r
+//        return new ServerInfo(name, address);\r
+//    }\r
+\r
+}\r