From e1ab207943693a5d7c31d103f538f6c859c436ff Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Thu, 18 Oct 2012 17:27:38 +0100 Subject: And more cleanup Change-Id: I49cf4cba01452b291655dfccdc134180270c1ff3 diff --git a/pmd-ruleset.xml b/pmd-ruleset.xml index b7bcf01..2442561 100644 --- a/pmd-ruleset.xml +++ b/pmd-ruleset.xml @@ -45,6 +45,7 @@ + diff --git a/src/com/isode/stroke/elements/DiscoInfo.java b/src/com/isode/stroke/elements/DiscoInfo.java index d7ff8e8..4ef1537 100644 --- a/src/com/isode/stroke/elements/DiscoInfo.java +++ b/src/com/isode/stroke/elements/DiscoInfo.java @@ -16,7 +16,11 @@ import java.util.List; * disco#info from XEP-0030. */ public class DiscoInfo extends Payload { - + private String node_ = ""; + private final List identities_ = new ArrayList(); + private final List features_ = new ArrayList(); + private final List
extensions_ = new ArrayList(); + public static final String ChatStatesFeature = "http://jabber.org/protocol/chatstates"; public static final String SecurityLabelsFeature = "urn:xmpp:sec-label:0"; public static final String SecurityLabelsCatalogFeature = "urn:xmpp:sec-label:catalog:2"; @@ -148,9 +152,6 @@ public class DiscoInfo extends Payload { } - public DiscoInfo() { - } - /** * * @return Node, notnull. @@ -222,8 +223,5 @@ public class DiscoInfo extends Payload { public List getExtensions() { return new ArrayList(extensions_); } - private String node_ = ""; - private final List identities_ = new ArrayList(); - private final List features_ = new ArrayList(); - private final List extensions_ = new ArrayList(); + } diff --git a/src/com/isode/stroke/parser/tree/NullParserElement.java b/src/com/isode/stroke/parser/tree/NullParserElement.java index 83f8b6f..b5270c0 100644 --- a/src/com/isode/stroke/parser/tree/NullParserElement.java +++ b/src/com/isode/stroke/parser/tree/NullParserElement.java @@ -25,5 +25,5 @@ public class NullParserElement extends ParserElement{ /** * Empty/Null Parser element */ - public static NullParserElement element = new NullParserElement(); + public static final NullParserElement element = new NullParserElement(); } diff --git a/src/com/isode/stroke/queries/IQRouter.java b/src/com/isode/stroke/queries/IQRouter.java index 61c2221..bb4dafa 100644 --- a/src/com/isode/stroke/queries/IQRouter.java +++ b/src/com/isode/stroke/queries/IQRouter.java @@ -29,7 +29,6 @@ public class IQRouter { public IQRouter(IQChannel channel) { channel_ = channel; - final IQRouter thisObject = this; channel_.onIQReceived.connect(new Slot1() { public void call(IQ p1) { diff --git a/src/com/isode/stroke/serializer/xml/XMLElement.java b/src/com/isode/stroke/serializer/xml/XMLElement.java index 9512c85..6a51d3f 100644 --- a/src/com/isode/stroke/serializer/xml/XMLElement.java +++ b/src/com/isode/stroke/serializer/xml/XMLElement.java @@ -37,22 +37,22 @@ public class XMLElement implements XMLNode { } public String serialize() { - String result = ""; - result += "<" + tag_; + StringBuilder result = new StringBuilder(); + result.append("<").append(tag_); for (String key : attributes_.keySet()) { - result += " " + key + "=\"" + attributes_.get(key) + "\""; + result.append(" ").append(key).append("=\"").append(attributes_.get(key)).append("\""); } if (childNodes_.size() > 0) { - result += ">"; + result.append(">"); for (XMLNode node : childNodes_) { - result += node.serialize(); + result.append(node.serialize()); } - result += ""; + result.append(""); } else { - result += "/>"; + result.append("/>"); } - return result; + return result.toString(); } public void setAttribute(String attribute, String value) { diff --git a/src/com/isode/stroke/streamstack/XMPPLayer.java b/src/com/isode/stroke/streamstack/XMPPLayer.java index 8163998..34c25b5 100644 --- a/src/com/isode/stroke/streamstack/XMPPLayer.java +++ b/src/com/isode/stroke/streamstack/XMPPLayer.java @@ -29,7 +29,20 @@ import com.isode.stroke.signals.Signal1; * XML parsing being multi-threaded here. */ public class XMPPLayer implements HighLayer, XMPPParserClient { + public final Signal1 onStreamStart = new Signal1(); + public final Signal1 onElement = new Signal1(); + public final Signal1 onWriteData = new Signal1(); + public final Signal1 onDataRead = new Signal1(); + public final Signal onError = new Signal(); + private PayloadParserFactoryCollection payloadParserFactories_; + private XMPPParser xmppParser_; + private PayloadSerializerCollection payloadSerializers_; + private XMPPSerializer xmppSerializer_; + private boolean resetParserAfterParse_; + private boolean inParser_; + + public XMPPLayer( PayloadParserFactoryCollection payloadParserFactories, PayloadSerializerCollection payloadSerializers, @@ -80,12 +93,6 @@ public class XMPPLayer implements HighLayer, XMPPParserClient { writeDataToChildLayer(data); } - public final Signal1 onStreamStart = new Signal1(); - public final Signal1 onElement = new Signal1(); - public final Signal1 onWriteData = new Signal1(); - public final Signal1 onDataRead = new Signal1(); - public final Signal onError = new Signal(); - public void handleStreamStart(ProtocolHeader header) { onStreamStart.emit(header); } @@ -102,14 +109,6 @@ public class XMPPLayer implements HighLayer, XMPPParserClient { resetParserAfterParse_ = false; } - private PayloadParserFactoryCollection payloadParserFactories_; - private XMPPParser xmppParser_; - private PayloadSerializerCollection payloadSerializers_; - private XMPPSerializer xmppSerializer_; - private boolean resetParserAfterParse_; - private boolean inParser_; - private EventLoop eventLoop_; - /* Multiple-inheritance workarounds */ private StreamLayer fakeStreamLayer_ = new StreamLayer() { diff --git a/src/com/isode/stroke/stringcodecs/Hexify.java b/src/com/isode/stroke/stringcodecs/Hexify.java index 52facb4..d3d3882 100644 --- a/src/com/isode/stroke/stringcodecs/Hexify.java +++ b/src/com/isode/stroke/stringcodecs/Hexify.java @@ -13,7 +13,7 @@ import com.isode.stroke.base.ByteArray; public class Hexify { public static String hexify(byte datum) { - return String.format("%02x", new Byte(datum)); + return String.format("%02x", Byte.valueOf(datum)); } public static String hexify(ByteArray data) { -- cgit v0.10.2-6-g49f6