labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ber...@apache.org
Subject svn commit: r652651 - /labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java
Date Thu, 01 May 2008 20:27:29 GMT
Author: berndf
Date: Thu May  1 13:27:28 2008
New Revision: 652651

URL: http://svn.apache.org/viewvc?rev=652651&view=rev
Log:
[vysper] return bare jid

Modified:
    labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java

Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java?rev=652651&r1=652650&r2=652651&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java (original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java Thu May  1
13:27:28 2008
@@ -26,16 +26,18 @@
 	private String node;
 	private String domain;
 	private String resource;
+    public static final String CHAR_AT = "@";
+    public static final String CHAR_SLASH = "/";
 
-	public static EntityImpl parse(String entity) throws EntityFormatException {
+    public static EntityImpl parse(String entity) throws EntityFormatException {
 		String node = null;
 		String domain;
 		String resource = null;
 		if (entity == null)
 			throw new EntityFormatException("entity must not be NULL");
 
-		if (entity.contains("@")) {
-			String[] parts = entity.split("@");
+		if (entity.contains(CHAR_AT)) {
+			String[] parts = entity.split(CHAR_AT);
 			if (parts.length != 2)
 				throw new EntityFormatException(
 						"entity must be of format node@domain/resource");
@@ -44,8 +46,8 @@
 			entity = parts[1];
 		}
 		domain = entity;
-		if (entity.contains("/")) {
-			int indexOfSlash = entity.indexOf("/");
+		if (entity.contains(CHAR_SLASH)) {
+			int indexOfSlash = entity.indexOf(CHAR_SLASH);
 			domain = entity.substring(0, indexOfSlash);
 			resource = entity.substring(indexOfSlash);
 			resource = ResourcePrep.prepare(resource);
@@ -78,17 +80,19 @@
 	}
 
 	public String getFullQualifiedName() {
-		StringBuffer buffer = new StringBuffer();
-		if (isNodeSet())
-			buffer.append(node).append("@");
-		buffer.append(domain);
-		if (isResourceSet())
-			buffer.append("/").append(resource);
-		return buffer.toString();
+        return buildEntityString(node, domain, resource);
 	}
 
+    private String buildEntityString(String node, String domain, String resource) {
+        StringBuffer buffer = new StringBuffer();
+        if (isNodeSet()) buffer.append(node).append(CHAR_AT);
+        buffer.append(domain);
+        if (isResourceSet()) buffer.append(CHAR_SLASH).append(resource);
+        return buffer.toString();
+    }
+
     public String getBareJID() {
-		return null;
+		return buildEntityString(node, domain, null);
 	}
 
     public String getCanonicalizedName() {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message