summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarun Gupta <tarun1995gupta@gmail.com>2015-06-08 19:16:57 (GMT)
committerTarun Gupta <tarun1995gupta@gmail.com>2015-06-14 13:30:22 (GMT)
commit9518f8b9d6924e95e4ad839f40866560bd7a7878 (patch)
tree6d7532fd1628c2f3e0e71b4a10fc14bec8c49a29 /src/com/isode/stroke/elements
parentafaf2c8e7a9276bc4a61337357092c49e6817159 (diff)
downloadstroke-9518f8b9d6924e95e4ad839f40866560bd7a7878.zip
stroke-9518f8b9d6924e95e4ad839f40866560bd7a7878.tar.bz2
Add the Bytestreams Element.
Adds Bytestreams Element, Parser and Serializer. License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details. Test-Information: Tests added for both Parser and Serializer, which passes. Change-Id: Ia623f8fcd628d7b34f7f8f935602c6c4c0ffaac1
Diffstat (limited to 'src/com/isode/stroke/elements')
-rw-r--r--src/com/isode/stroke/elements/Bytestreams.java159
1 files changed, 159 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/Bytestreams.java b/src/com/isode/stroke/elements/Bytestreams.java
new file mode 100644
index 0000000..9c351b5
--- /dev/null
+++ b/src/com/isode/stroke/elements/Bytestreams.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2010 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+/*
+ * Copyright (c) 2015 Tarun Gupta.
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+package com.isode.stroke.elements;
+
+import com.isode.stroke.base.NotNull;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.elements.Payload;
+import java.util.Vector;
+
+public class Bytestreams extends Payload {
+
+ public class StreamHost {
+
+ public String host;
+ public JID jid;
+ public int port;
+
+ /**
+ * Default Constructor.
+ */
+ public StreamHost() {
+ this("", new JID(), -1);
+ }
+
+ /**
+ * StreamHost with single parameter, host.
+ */
+ public StreamHost(String host) {
+ this(host, new JID(), -1);
+ }
+
+ /**
+ * StreamHost with two parameter, host and jid.
+ */
+ public StreamHost(String host, JID jid) {
+ this(host, jid, -1);
+ }
+
+ /**
+ * StreamHost with three parameter, host, jid and port.
+ */
+ public StreamHost(String host, JID jid, int port) {
+ NotNull.exceptIfNull(host, "host");
+ NotNull.exceptIfNull(jid, "jid");
+ this.host = host;
+ this.jid = jid;
+ this.port = port;
+ }
+
+ /**
+ * @return host, NotNull.
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * @param host, NotNull.
+ */
+ public void setHost(String host) {
+ NotNull.exceptIfNull(host, "host");
+ this.host = host;
+ }
+
+ /**
+ * @return jid, NotNull.
+ */
+ public JID getJID() {
+ return jid;
+ }
+
+ /**
+ * @param jid, NotNull.
+ */
+ public void setJID(JID jid) {
+ NotNull.exceptIfNull(jid, "jid");
+ this.jid = jid;
+ }
+
+ /**
+ * @return port.
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * @param port.
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ }
+
+ private String id = "";
+ JID usedStreamHost;
+ Vector<StreamHost> streamHosts = new Vector<StreamHost>();
+
+ /**
+ * Default Constructor.
+ */
+ public Bytestreams() {
+
+ }
+
+ /**
+ * @return id, notnull.
+ */
+ public String getStreamID() {
+ return id;
+ }
+
+ /**
+ * @param id, notnull.
+ */
+ public void setStreamID(String id) {
+ NotNull.exceptIfNull(id, "id");
+ this.id = id;
+ }
+
+ /**
+ * @return usedStreamHost
+ */
+ public JID getUsedStreamHost() {
+ return usedStreamHost;
+ }
+
+ /**
+ * @param host
+ */
+ public void setUsedStreamHost(JID host) {
+ usedStreamHost = host;
+ }
+
+ /**
+ * @return streamHosts, notnull.
+ */
+ public Vector<StreamHost> getStreamHosts() {
+ return streamHosts;
+ }
+
+ /**
+ * @param streamHost, notnull.
+ */
+ public void addStreamHost(StreamHost streamHost) {
+ NotNull.exceptIfNull(streamHost, "streamHost");
+ streamHosts.add(streamHost);
+ }
+} \ No newline at end of file