aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-09-01 10:58:26 +0200
committerDaniel Gultsch <daniel@gultsch.de>2014-09-01 10:58:26 +0200
commit0ffdb03aa3fb5840989f149e733c4d6cdf98c9ad (patch)
tree78b21bb19f9473c7a30060a455f7d09f78f906b2
parent271b0f9c5852fcf6aed92421fc3d5802f930e383 (diff)
parent2acf510ea97666919ac066a2bf312f47a386ac56 (diff)
Merge pull request #402 from emdete/remove_poormans_tostring
optimize string operations a bit
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/crypto/PgpEngine.java4
-rw-r--r--src/eu/siacs/conversations/entities/Message.java8
-rw-r--r--src/eu/siacs/conversations/persistance/DatabaseBackend.java4
-rw-r--r--src/eu/siacs/conversations/persistance/FileBackend.java2
-rw-r--r--src/eu/siacs/conversations/xml/Element.java4
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java4
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java8
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java6
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java6
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java2
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/streammgmt/AckPacket.java2
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/streammgmt/ResumePacket.java2
12 files changed, 26 insertions, 26 deletions
diff --git a/src/eu/siacs/conversations/crypto/PgpEngine.java b/src/eu/siacs/conversations/crypto/PgpEngine.java
index 47b1a0cb..430aaf99 100644
--- a/src/eu/siacs/conversations/crypto/PgpEngine.java
+++ b/src/eu/siacs/conversations/crypto/PgpEngine.java
@@ -106,8 +106,8 @@ public class PgpEngine {
outputFile.getAbsolutePath(), options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
- message.setBody("" + outputFile.getSize() + ","
- + imageWidth + "," + imageHeight);
+ message.setBody(Long.toString(outputFile.getSize()) + ','
+ + imageWidth + ',' + imageHeight);
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
PgpEngine.this.mXmppConnectionService
.updateMessage(message);
diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java
index 84aac4f5..f36ffa90 100644
--- a/src/eu/siacs/conversations/entities/Message.java
+++ b/src/eu/siacs/conversations/entities/Message.java
@@ -150,13 +150,13 @@ public class Message extends AbstractEntity {
public String getReadableBody(Context context) {
if ((encryption == ENCRYPTION_PGP) && (type == TYPE_TEXT)) {
- return "" + context.getText(R.string.encrypted_message_received);
+ return context.getText(R.string.encrypted_message_received).toString();
} else if ((encryption == ENCRYPTION_OTR) && (type == TYPE_IMAGE)) {
- return "" + context.getText(R.string.encrypted_image_received);
+ return context.getText(R.string.encrypted_image_received).toString();
} else if (encryption == ENCRYPTION_DECRYPTION_FAILED) {
- return "" + context.getText(R.string.decryption_failed);
+ return context.getText(R.string.decryption_failed).toString();
} else if (type == TYPE_IMAGE) {
- return "" + context.getText(R.string.image_file);
+ return context.getText(R.string.image_file).toString();
} else {
return body.trim();
}
diff --git a/src/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/eu/siacs/conversations/persistance/DatabaseBackend.java
index 22871a9e..2a403fab 100644
--- a/src/eu/siacs/conversations/persistance/DatabaseBackend.java
+++ b/src/eu/siacs/conversations/persistance/DatabaseBackend.java
@@ -137,7 +137,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
public CopyOnWriteArrayList<Conversation> getConversations(int status) {
CopyOnWriteArrayList<Conversation> list = new CopyOnWriteArrayList<Conversation>();
SQLiteDatabase db = this.getReadableDatabase();
- String[] selectionArgs = { "" + status };
+ String[] selectionArgs = { Integer.toString(status) };
Cursor cursor = db.rawQuery("select * from " + Conversation.TABLENAME
+ " where " + Conversation.STATUS + " = ? order by "
+ Conversation.CREATED + " desc", selectionArgs);
@@ -163,7 +163,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
+ "=?", selectionArgs, null, null, Message.TIME_SENT
+ " DESC", String.valueOf(limit));
} else {
- String[] selectionArgs = { conversation.getUuid(), "" + timestamp };
+ String[] selectionArgs = { conversation.getUuid(), Long.toString(timestamp) };
cursor = db.query(Message.TABLENAME, null, Message.CONVERSATION
+ "=? and " + Message.TIME_SENT + "<?", selectionArgs,
null, null, Message.TIME_SENT + " DESC",
diff --git a/src/eu/siacs/conversations/persistance/FileBackend.java b/src/eu/siacs/conversations/persistance/FileBackend.java
index 6e16240d..0af9c6e2 100644
--- a/src/eu/siacs/conversations/persistance/FileBackend.java
+++ b/src/eu/siacs/conversations/persistance/FileBackend.java
@@ -180,7 +180,7 @@ public class FileBackend {
long size = file.getSize();
int width = scalledBitmap.getWidth();
int height = scalledBitmap.getHeight();
- message.setBody("" + size + "," + width + "," + height);
+ message.setBody(Long.toString(size) + ',' + width + ',' + height);
return file;
} catch (FileNotFoundException e) {
throw new ImageCopyException(R.string.error_file_not_found);
diff --git a/src/eu/siacs/conversations/xml/Element.java b/src/eu/siacs/conversations/xml/Element.java
index d23a81ba..a09946c2 100644
--- a/src/eu/siacs/conversations/xml/Element.java
+++ b/src/eu/siacs/conversations/xml/Element.java
@@ -146,10 +146,10 @@ public class Element {
}
public void setAttribute(String name, long value) {
- this.setAttribute(name, "" + value);
+ this.setAttribute(name, Long.toString(value));
}
public void setAttribute(String name, int value) {
- this.setAttribute(name, "" + value);
+ this.setAttribute(name, Integer.toString(value));
}
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java b/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java
index 2874b9a5..3e7c7b68 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java
@@ -117,9 +117,9 @@ public class JingleCandidate {
Element element = new Element("candidate");
element.setAttribute("cid", this.getCid());
element.setAttribute("host", this.getHost());
- element.setAttribute("port", "" + this.getPort());
+ element.setAttribute("port", Integer.toString(this.getPort()));
element.setAttribute("jid", this.getJid());
- element.setAttribute("priority", "" + this.getPriority());
+ element.setAttribute("priority", Integer.toString(this.getPriority()));
if (this.getType() == TYPE_DIRECT) {
element.setAttribute("type", "direct");
} else if (this.getType() == TYPE_PROXY) {
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index 317838fd..a5cc2c49 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -95,7 +95,7 @@ public class JingleConnection {
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
- message.setBody("" + file.getSize() + "," + imageWidth + ","
+ message.setBody(Long.toString(file.getSize()) + ',' + imageWidth + ','
+ imageHeight);
mXmppConnectionService.databaseBackend.createMessage(message);
mXmppConnectionService.markMessage(message,
@@ -302,7 +302,7 @@ public class JingleConnection {
}
if (supportedFile) {
long size = Long.parseLong(fileSize.getContent());
- message.setBody("" + size);
+ message.setBody(Long.toString(size));
conversation.getMessages().add(message);
if (size <= this.mJingleConnectionManager
.getAutoAcceptFileSize()) {
@@ -630,7 +630,7 @@ public class JingleConnection {
this.transportId = this.mJingleConnectionManager.nextRandomId();
content.setTransportId(this.transportId);
content.ibbTransport().setAttribute("block-size",
- "" + this.ibbBlockSize);
+ Integer.toString(this.ibbBlockSize));
packet.setContent(content);
this.sendJinglePacket(packet);
}
@@ -652,7 +652,7 @@ public class JingleConnection {
Content content = new Content("initiator", "a-file-offer");
content.setTransportId(this.transportId);
content.ibbTransport().setAttribute("block-size",
- "" + this.ibbBlockSize);
+ Integer.toString(this.ibbBlockSize));
answer.setContent(content);
this.sendJinglePacket(answer);
return true;
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java b/src/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java
index 331b53de..cd87552b 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java
@@ -59,7 +59,7 @@ public class JingleInbandTransport extends JingleTransport {
Element open = iq.addChild("open", "http://jabber.org/protocol/ibb");
open.setAttribute("sid", this.sessionId);
open.setAttribute("stanza", "iq");
- open.setAttribute("block-size", "" + this.blockSize);
+ open.setAttribute("block-size", Integer.toString(this.blockSize));
this.account.getXmppConnection().sendIqPacket(iq,
new OnIqPacketReceived() {
@@ -134,8 +134,8 @@ public class JingleInbandTransport extends JingleTransport {
iq.setTo(this.counterpart);
Element data = iq.addChild("data",
"http://jabber.org/protocol/ibb");
- data.setAttribute("seq", "" + this.seq);
- data.setAttribute("block-size", "" + this.blockSize);
+ data.setAttribute("seq", Integer.toString(this.seq));
+ data.setAttribute("block-size", Integer.toString(this.blockSize));
data.setAttribute("sid", this.sessionId);
data.setContent(base64);
this.account.getXmppConnection().sendIqPacket(iq,
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java b/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java
index e476decc..1a8ab9dd 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java
@@ -58,10 +58,10 @@ public class JingleSocks5Transport extends JingleTransport {
byte[] reply = new byte[2];
outputStream.write(login);
inputStream.read(reply);
+ final String connect = Character.toString('\u0005') + '\u0001' + '\u0000'
+ + '\u0003' + '\u0028' + destination + '\u0000'
+ + '\u0000';
if (Arrays.equals(reply, expectedReply)) {
- String connect = "" + '\u0005' + '\u0001' + '\u0000'
- + '\u0003' + '\u0028' + destination + '\u0000'
- + '\u0000';
outputStream.write(connect.getBytes());
byte[] result = new byte[2];
inputStream.read(result);
diff --git a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
index 1e8e3fd6..d19e6dfd 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java
@@ -30,7 +30,7 @@ public class Content extends Element {
"urn:xmpp:jingle:apps:file-transfer:3");
Element offer = description.addChild("offer");
Element file = offer.addChild("file");
- file.addChild("size").setContent("" + actualFile.getSize());
+ file.addChild("size").setContent(Long.toString(actualFile.getSize()));
if (otr) {
file.addChild("name").setContent(actualFile.getName() + ".otr");
} else {
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/AckPacket.java b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/AckPacket.java
index c936891c..f93b5d87 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/AckPacket.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/AckPacket.java
@@ -7,7 +7,7 @@ public class AckPacket extends AbstractStanza {
public AckPacket(int sequence, int smVersion) {
super("a");
this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
- this.setAttribute("h", "" + sequence);
+ this.setAttribute("h", Integer.toString(sequence));
}
}
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/ResumePacket.java b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/ResumePacket.java
index df039d5a..9cdcfa5e 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/ResumePacket.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/streammgmt/ResumePacket.java
@@ -8,7 +8,7 @@ public class ResumePacket extends AbstractStanza {
super("resume");
this.setAttribute("xmlns", "urn:xmpp:sm:" + smVersion);
this.setAttribute("previd", id);
- this.setAttribute("h", "" + sequence);
+ this.setAttribute("h", Integer.toString(sequence));
}
}