diff options
author | Tarun Gupta <tarun1995gupta@gmail.com> | 2015-06-20 12:10:51 (GMT) |
---|---|---|
committer | Tarun Gupta <tarun1995gupta@gmail.com> | 2015-06-30 13:23:04 (GMT) |
commit | ba7342e593920595af36fcd8e8e44ec206f8b561 (patch) | |
tree | fa8921599a20d85845d23d9a97bbc1cf230c7a51 /src/com/isode/stroke/elements | |
parent | a673d269487fd86efe7f9c5f9b4cd1c00cab556d (diff) | |
download | stroke-ba7342e593920595af36fcd8e8e44ec206f8b561.zip stroke-ba7342e593920595af36fcd8e8e44ec206f8b561.tar.bz2 |
Add StreamInitiation Elements.
Adds StreamInitiationFileInfo Element, its Parser and Serializer.
Adds StreamInitiation Element, its Parser and Serializer.
Adds StreamError Parser and Serializer.
Updates StreamManagementEnabled Element.
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Test-Information:
Tests added for StreamInitiation Parser and Serializer, which passes.
Change-Id: I21a7de3f6a5ac0955b6e5aaae3c2607a30eae002
Diffstat (limited to 'src/com/isode/stroke/elements')
3 files changed, 337 insertions, 0 deletions
diff --git a/src/com/isode/stroke/elements/StreamInitiation.java b/src/com/isode/stroke/elements/StreamInitiation.java new file mode 100644 index 0000000..466139c --- /dev/null +++ b/src/com/isode/stroke/elements/StreamInitiation.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2010-2015 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.elements.Payload; +import com.isode.stroke.elements.StreamInitiationFileInfo; +import com.isode.stroke.base.NotNull; +import java.util.Vector; + +public class StreamInitiation extends Payload { + + private boolean isFileTransfer; + private String id = ""; + private StreamInitiationFileInfo fileInfo; + private Vector<String> providedMethods = new Vector<String>(); + private String requestedMethod = ""; + + /** + * Default Constructor. + */ + public StreamInitiation() { + this.isFileTransfer = true; + } + + /** + * @return id, NotNull. + */ + public String getID() { + return id; + } + + /** + * @param id, NotNull. + */ + public void setID(String id) { + NotNull.exceptIfNull(id, "id"); + this.id = id; + } + + /** + * @return fileInfo. + */ + public StreamInitiationFileInfo getFileInfo() { + return fileInfo; + } + + /** + * @param fileInfo. + */ + public void setFileInfo(StreamInitiationFileInfo info) { + fileInfo = info; + } + + /** + * @return providedMethods. + */ + public Vector<String> getProvidedMethods() { + return providedMethods; + } + + /** + * @param method, Not Null. + */ + public void addProvidedMethod(String method) { + NotNull.exceptIfNull(method, "method"); + providedMethods.add(method); + } + + /** + * @param method, Not Null. + */ + public void setRequestedMethod(String method) { + NotNull.exceptIfNull(method, "method"); + requestedMethod = method; + } + + /** + * @return method, Not Null. + */ + public String getRequestedMethod() { + return requestedMethod; + } + + /** + * @return isFileTransfer. + */ + public boolean getIsFileTransfer() { + return isFileTransfer; + } + + /** + * @param isFileTransfer. + */ + public void setIsFileTransfer(boolean b) { + isFileTransfer = b; + } +}
\ No newline at end of file diff --git a/src/com/isode/stroke/elements/StreamInitiationFileInfo.java b/src/com/isode/stroke/elements/StreamInitiationFileInfo.java new file mode 100644 index 0000000..1f9f3a4 --- /dev/null +++ b/src/com/isode/stroke/elements/StreamInitiationFileInfo.java @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2011-2015 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.elements.Payload; +import com.isode.stroke.base.NotNull; +import com.isode.stroke.base.DateTime; +import java.util.Date; + +public class StreamInitiationFileInfo extends Payload { + + private String name = ""; + private String description; + private long size; + private String hash = ""; + private Date date; + private String algo = ""; + private boolean supportsRangeRequests; + private long rangeOffset; + + /** + * Default Constructor. + */ + public StreamInitiationFileInfo() { + this("", "", 0, "", null, "md5"); + } + + /** + * Parameterized Constructor. + * @param name, NotNull. + */ + public StreamInitiationFileInfo(String name) { + this(name, "", 0, "", null, "md5"); + } + + /** + * Parameterized Constructor. + * @param name, NotNull. + * @param description, NotNull. + */ + public StreamInitiationFileInfo(String name, String description) { + this(name, description, 0, "", null, "md5"); + } + + /** + * Parameterized Constructor. + * @param name, NotNull. + * @param description, NotNull. + * @param size. + */ + public StreamInitiationFileInfo(String name, String description, long size) { + this(name, description, size, "", null, "md5"); + } + + /** + * Parameterized Constructor. + * @param name, NotNull. + * @param description, NotNull. + * @param size. + * @param hash, NotNull. + */ + public StreamInitiationFileInfo(String name, String description, long size, String hash) { + this(name, description, size, hash, null, "md5"); + } + + /** + * Parameterized Constructor. + * @param name, NotNull. + * @param description, NotNull. + * @param size. + * @param hash, NotNull. + * @param date. Null means invalid date. + */ + public StreamInitiationFileInfo(String name, String description, long size, String hash, Date date) { + this(name, description, size, hash, date, "md5"); + } + + /** + * Parameterized Constructor. + * @param name, NotNull. + * @param description, NotNull. + * @param size. + * @param hash, NotNull. + * @param date. Null means invalid date. + * @param algo, NotNull. + */ + public StreamInitiationFileInfo(String name, String description, long size, String hash, Date date, String algo) { + NotNull.exceptIfNull(name, "name"); + NotNull.exceptIfNull(description, "description"); + NotNull.exceptIfNull(hash, "hash"); + NotNull.exceptIfNull(algo, "algo"); + this.name = name; + this.description = description; + this.size = size; + this.hash = hash; + this.date = date; + this.algo = algo; + this.supportsRangeRequests = false; + this.rangeOffset = 0L; + } + + /** + * @param name, NotNull. + */ + public void setName(String name) { + NotNull.exceptIfNull(name, "name"); + this.name = name; + } + + /** + * @return name, NotNull. + */ + public String getName() { + return name; + } + + /** + * @param description, NotNull. + */ + public void setDescription(String description) { + NotNull.exceptIfNull(description, "description"); + this.description = description; + } + + /** + * @return description, NotNull. + */ + public String getDescription() { + return description; + } + + /** + * @param size. + */ + public void setSize(long size) { + this.size = size; + } + + /** + * @return size. + */ + public long getSize() { + return size; + } + + /** + * @param hash, NotNull. + */ + public void setHash(String hash) { + NotNull.exceptIfNull(hash, "hash"); + this.hash = hash; + } + + /** + * @return hash, NotNull. + */ + public String getHash() { + return this.hash; + } + + /** + * @param date. Null means invalid date. + */ + public void setDate(Date date) { + this.date = date; + } + + /** + * @return date, which may be null for an invalid date. + */ + public Date getDate() { + return date; + } + + /** + * @param algo, NotNull. + */ + public void setAlgo(String algo) { + NotNull.exceptIfNull(algo, "algo"); + this.algo = algo; + } + + /** + * @return algo, NotNull. + */ + public String getAlgo() { + return this.algo; + } + + /** + * @param supportsRangeRequests. + */ + public void setSupportsRangeRequests(boolean supportsIt) { + this.supportsRangeRequests = supportsIt; + } + + /** + * @return supportsRangeRequests. + */ + public boolean getSupportsRangeRequests() { + return supportsRangeRequests; + } + + /** + * @param offset. + */ + public void setRangeOffset(long offset) { + this.supportsRangeRequests = true; + this.rangeOffset = offset; + } + + /** + * @return offset. + */ + public long getRangeOffset() { + return rangeOffset; + } +} diff --git a/src/com/isode/stroke/elements/StreamManagementEnabled.java b/src/com/isode/stroke/elements/StreamManagementEnabled.java index f0de583..56883ca 100644 --- a/src/com/isode/stroke/elements/StreamManagementEnabled.java +++ b/src/com/isode/stroke/elements/StreamManagementEnabled.java @@ -10,6 +10,10 @@ package com.isode.stroke.elements; public class StreamManagementEnabled implements Element { + public StreamManagementEnabled() { + this.resumeSupported = false; + } + public void setResumeSupported() { resumeSupported = true; } |