summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-10-18 16:12:14 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-10-18 16:12:14 (GMT)
commitb929d80743dca78406f0fb338175c90590a4ed67 (patch)
treecc72c6175ed8dfe1151d94273ea4993af76ac7de /src
parent10d5bd33ce017971a25816606c06f0c73746aed8 (diff)
downloadstroke-b929d80743dca78406f0fb338175c90590a4ed67.zip
stroke-b929d80743dca78406f0fb338175c90590a4ed67.tar.bz2
And more cleanups
Change-Id: I862e11dc293ce84e0311f1ad470293e07735aeaf
Diffstat (limited to 'src')
-rw-r--r--src/com/isode/stroke/client/Client.java6
-rw-r--r--src/com/isode/stroke/client/ClientSession.java16
-rw-r--r--src/com/isode/stroke/compress/ZLibCodecompressor.java2
-rw-r--r--src/com/isode/stroke/elements/DiscoInfo.java47
-rw-r--r--src/com/isode/stroke/elements/MUCPayload.java4
-rw-r--r--src/com/isode/stroke/elements/Storage.java2
6 files changed, 46 insertions, 31 deletions
diff --git a/src/com/isode/stroke/client/Client.java b/src/com/isode/stroke/client/Client.java
index 106ff70..a4ef619 100644
--- a/src/com/isode/stroke/client/Client.java
+++ b/src/com/isode/stroke/client/Client.java
@@ -27,10 +27,8 @@ public class Client extends CoreClient {
private final MUCManager mucManager;
private final MUCRegistry mucRegistry;
- //NOPMD, this is not better as a local variable
- private final DirectedPresenceSender directedPresenceSender;
- //NOPMD, this is not better as a local variable
- private final StanzaChannelPresenceSender stanzaChannelPresenceSender;
+ private final DirectedPresenceSender directedPresenceSender; //NOPMD, this is not better as a local variable
+ private final StanzaChannelPresenceSender stanzaChannelPresenceSender; //NOPMD, this is not better as a local variable
private final SoftwareVersionResponder softwareVersionResponder;
/**
diff --git a/src/com/isode/stroke/client/ClientSession.java b/src/com/isode/stroke/client/ClientSession.java
index 0327e89..f6082b7 100644
--- a/src/com/isode/stroke/client/ClientSession.java
+++ b/src/com/isode/stroke/client/ClientSession.java
@@ -189,17 +189,17 @@ public class ClientSession {
public void start() {
streamStreamStartReceivedConnection = stream.onStreamStartReceived.connect(new Slot1<ProtocolHeader>(){
- public void call(ProtocolHeader p1) {
+ public void call(final ProtocolHeader p1) {
handleStreamStart(p1);
}
});
streamElementReceivedConnection = stream.onElementReceived.connect(new Slot1<Element>(){
- public void call(Element p1) {
+ public void call(final Element p1) {
handleElement(p1);
}
});
streamClosedConnection = stream.onClosed.connect(new Slot1<SessionStream.Error>(){
- public void call(SessionStream.Error p1) {
+ public void call(final SessionStream.Error p1) {
handleStreamClosed(p1);
}
});
@@ -227,7 +227,7 @@ public class ClientSession {
}
}
- private void handleStreamStart(final ProtocolHeader header) {
+ private void handleStreamStart(final ProtocolHeader header) { //NOPMD, I'm not removing header from the API
if (!checkState(State.WaitingForStreamStart)) {
return;
}
@@ -405,14 +405,14 @@ public class ClientSession {
});
stanzaAckOnAckedConnection_ = stanzaAckRequester_.onStanzaAcked.connect(new Slot1<Stanza>() {
- public void call(Stanza p1) {
+ public void call(final Stanza p1) {
handleStanzaAcked(p1);
}
});
stanzaAckResponder_ = new StanzaAckResponder();
stanzaResponderAckConnection_ = stanzaAckResponder_.onAck.connect(new Slot1<Long>() {
- public void call(Long p1) {
+ public void call(final Long p1) {
ack(p1);
}
});
@@ -471,7 +471,7 @@ public class ClientSession {
private void continueSessionInitialization() {
if (needResourceBind) {
state = State.BindingResource;
- ResourceBind resourceBind = new ResourceBind();
+ final ResourceBind resourceBind = new ResourceBind();
if (localJID.getResource().length() != 0) {
resourceBind.setResource(localJID.getResource());
}
@@ -519,7 +519,7 @@ public class ClientSession {
checkTrustOrFinish(certificate, verificationError);
}
else {
- ServerIdentityVerifier identityVerifier = new ServerIdentityVerifier(localJID);
+ final ServerIdentityVerifier identityVerifier = new ServerIdentityVerifier(localJID);
if (identityVerifier.certificateVerifies(certificate)) {
continueAfterTLSEncrypted();
}
diff --git a/src/com/isode/stroke/compress/ZLibCodecompressor.java b/src/com/isode/stroke/compress/ZLibCodecompressor.java
index 750904e..3925949 100644
--- a/src/com/isode/stroke/compress/ZLibCodecompressor.java
+++ b/src/com/isode/stroke/compress/ZLibCodecompressor.java
@@ -14,7 +14,7 @@ import com.jcraft.jzlib.JZlib;
import com.jcraft.jzlib.ZStream;
public abstract class ZLibCodecompressor {
- protected final int CHUNK_SIZE = 1024;
+ protected static final int CHUNK_SIZE = 1024;
protected final ZStream stream_ = new ZStream();
public ByteArray process(ByteArray input) throws ZLibException {
diff --git a/src/com/isode/stroke/elements/DiscoInfo.java b/src/com/isode/stroke/elements/DiscoInfo.java
index f30a682..d7ff8e8 100644
--- a/src/com/isode/stroke/elements/DiscoInfo.java
+++ b/src/com/isode/stroke/elements/DiscoInfo.java
@@ -31,25 +31,29 @@ public class DiscoInfo extends Payload {
public static final String MessageDeliveryReceiptsFeature = "urn:xmpp:receipts";
public static class Identity implements Comparable<Identity> {
+ private final String name_;
+ private final String category_;
+ private final String type_;
+ private final String lang_;
/**
* Identity(name, "client", "pc", "");
*/
- public Identity(String name) {
+ public Identity(final String name) {
this(name, "client");
}
/**
* Identity(name, category, "pc, "");
*/
- public Identity(String name, String category) {
+ public Identity(final String name, final String category) {
this(name, category, "pc");
}
/**
* Identity(name, category, type, "");
*/
- public Identity(String name, String category, String type) {
+ public Identity(final String name, final String category, final String type) {
this(name, category, type, "");
}
@@ -60,7 +64,7 @@ public class DiscoInfo extends Payload {
* @param type Identity type, notnull.
* @param lang Identity language, notnull.
*/
- public Identity(String name, String category, String type, String lang) {
+ public Identity(final String name, final String category, final String type, final String lang) {
NotNull.exceptIfNull(name, "name");
NotNull.exceptIfNull(category, "category");
NotNull.exceptIfNull(type, "type");
@@ -104,7 +108,7 @@ public class DiscoInfo extends Payload {
}
// Sorted according to XEP-115 rules
- public int compareTo(Identity other) {
+ public int compareTo(final Identity other) {
if (other == null) {
return -1;
}
@@ -122,12 +126,25 @@ public class DiscoInfo extends Payload {
return category_.compareTo(other.category_);
}
}
-
- private final String name_;
- private final String category_;
- private final String type_;
- private final String lang_;
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof Identity)) {
+ return false;
+ }
+ final Identity o = (Identity)other;
+ return o.category_.equals(category_) && o.lang_.equals(lang_) && o.name_.equals(name_) && o.type_.equals(type_);
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 37 * hash + (this.name_ != null ? this.name_.hashCode() : 0);
+ hash = 37 * hash + (this.category_ != null ? this.category_.hashCode() : 0);
+ hash = 37 * hash + (this.type_ != null ? this.type_.hashCode() : 0);
+ hash = 37 * hash + (this.lang_ != null ? this.lang_.hashCode() : 0);
+ return hash;
+ }
}
@@ -146,7 +163,7 @@ public class DiscoInfo extends Payload {
*
* @param node Notnull.
*/
- public void setNode(String node) {
+ public void setNode(final String node) {
NotNull.exceptIfNull(node, "node");
node_ = node;
}
@@ -163,7 +180,7 @@ public class DiscoInfo extends Payload {
*
* @param identity Non-null.
*/
- public void addIdentity(Identity identity) {
+ public void addIdentity(final Identity identity) {
NotNull.exceptIfNull(identity, "identity");
identities_.add(identity);
}
@@ -180,12 +197,12 @@ public class DiscoInfo extends Payload {
*
* @param feature Non-null.
*/
- public void addFeature(String feature) {
+ public void addFeature(final String feature) {
NotNull.exceptIfNull(feature, "feature");
features_.add(feature);
}
- public boolean hasFeature(String feature) {
+ public boolean hasFeature(final String feature) {
return features_.contains(feature);
}
@@ -193,7 +210,7 @@ public class DiscoInfo extends Payload {
*
* @param form Non-null.
*/
- public void addExtension(Form form) {
+ public void addExtension(final Form form) {
NotNull.exceptIfNull(form, "form");
extensions_.add(form);
}
diff --git a/src/com/isode/stroke/elements/MUCPayload.java b/src/com/isode/stroke/elements/MUCPayload.java
index 03b776e..0445c56 100644
--- a/src/com/isode/stroke/elements/MUCPayload.java
+++ b/src/com/isode/stroke/elements/MUCPayload.java
@@ -62,7 +62,7 @@ public class MUCPayload extends Payload {
* @param since date-time, should not be null
*/
public void setSince(Date since) {
- since_ = since;
+ since_ = (Date)since.clone();
}
/**
@@ -110,6 +110,6 @@ public class MUCPayload extends Payload {
* @return date, ca be null if not set
*/
public Date getSince() {
- return since_;
+ return (Date)since_.clone();
}
} \ No newline at end of file
diff --git a/src/com/isode/stroke/elements/Storage.java b/src/com/isode/stroke/elements/Storage.java
index 8597c27..4581141 100644
--- a/src/com/isode/stroke/elements/Storage.java
+++ b/src/com/isode/stroke/elements/Storage.java
@@ -40,7 +40,7 @@ public class Storage extends Payload {
* Class for bookmarking web pages, i.e., HTTP or HTTPS URLs.
*
*/
- public class URL {
+ public static class URL {
public URL() {
}