diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-08-31 16:28:21 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-08-31 16:28:21 +0200 |
commit | 1ac5be485502e7d6d4c117335e083c684739e6af (patch) | |
tree | 279c22e269158dde838f31ebcf3daf4272573583 /src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java | |
parent | 8d456085e57334dc34707a49666006619e2c77c6 (diff) |
some code cleanup
Diffstat (limited to 'src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java')
-rw-r--r-- | src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java b/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java index 80ffeaaa..2874b9a5 100644 --- a/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java +++ b/src/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java @@ -6,11 +6,11 @@ import java.util.List; import eu.siacs.conversations.xml.Element; public class JingleCandidate { - + public static int TYPE_UNKNOWN; public static int TYPE_DIRECT = 0; public static int TYPE_PROXY = 1; - + private boolean ours; private boolean usedByCounterpart = false; private String cid; @@ -19,12 +19,12 @@ public class JingleCandidate { private int type; private String jid; private int priority; - - public JingleCandidate(String cid,boolean ours) { + + public JingleCandidate(String cid, boolean ours) { this.ours = ours; this.cid = cid; } - + public String getCid() { return cid; } @@ -32,15 +32,15 @@ public class JingleCandidate { public void setHost(String host) { this.host = host; } - + public String getHost() { return this.host; } - + public void setJid(String jid) { this.jid = jid; } - + public String getJid() { return this.jid; } @@ -48,15 +48,15 @@ public class JingleCandidate { public void setPort(int port) { this.port = port; } - + public int getPort() { return this.port; } - + public void setType(int type) { this.type = type; } - + public void setType(String type) { if ("proxy".equals(type)) { this.type = TYPE_PROXY; @@ -70,42 +70,46 @@ public class JingleCandidate { public void setPriority(int i) { this.priority = i; } - + public int getPriority() { return this.priority; } - + public boolean equals(JingleCandidate other) { return this.getCid().equals(other.getCid()); } - + public boolean equalValues(JingleCandidate other) { - return other.getHost().equals(this.getHost())&&(other.getPort()==this.getPort()); + return other.getHost().equals(this.getHost()) + && (other.getPort() == this.getPort()); } - + public boolean isOurs() { return ours; } - + public int getType() { return this.type; } public static List<JingleCandidate> parse(List<Element> canditates) { List<JingleCandidate> parsedCandidates = new ArrayList<JingleCandidate>(); - for(Element c : canditates) { + for (Element c : canditates) { parsedCandidates.add(JingleCandidate.parse(c)); } return parsedCandidates; } - + public static JingleCandidate parse(Element candidate) { - JingleCandidate parsedCandidate = new JingleCandidate(candidate.getAttribute("cid"), false); + JingleCandidate parsedCandidate = new JingleCandidate( + candidate.getAttribute("cid"), false); parsedCandidate.setHost(candidate.getAttribute("host")); parsedCandidate.setJid(candidate.getAttribute("jid")); parsedCandidate.setType(candidate.getAttribute("type")); - parsedCandidate.setPriority(Integer.parseInt(candidate.getAttribute("priority"))); - parsedCandidate.setPort(Integer.parseInt(candidate.getAttribute("port"))); + parsedCandidate.setPriority(Integer.parseInt(candidate + .getAttribute("priority"))); + parsedCandidate + .setPort(Integer.parseInt(candidate.getAttribute("port"))); return parsedCandidate; } @@ -113,26 +117,27 @@ 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", "" + this.getPort()); element.setAttribute("jid", this.getJid()); - element.setAttribute("priority",""+this.getPriority()); - if (this.getType()==TYPE_DIRECT) { - element.setAttribute("type","direct"); - } else if (this.getType()==TYPE_PROXY) { - element.setAttribute("type","proxy"); + element.setAttribute("priority", "" + this.getPriority()); + if (this.getType() == TYPE_DIRECT) { + element.setAttribute("type", "direct"); + } else if (this.getType() == TYPE_PROXY) { + element.setAttribute("type", "proxy"); } return element; } public void flagAsUsedByCounterpart() { - this.usedByCounterpart = true; + this.usedByCounterpart = true; } public boolean isUsedByCounterpart() { return this.usedByCounterpart; } - + public String toString() { - return this.getHost()+":"+this.getPort()+" (prio="+this.getPriority()+")"; + return this.getHost() + ":" + this.getPort() + " (prio=" + + this.getPriority() + ")"; } } |