incubator-etch-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scco...@apache.org
Subject svn commit: r780705 - in /incubator/etch/branches/name-service: services/ns/src/main/java/org/apache/etch/services/ns/support/ util/src/main/java/org/apache/etch/util/
Date Mon, 01 Jun 2009 16:21:47 GMT
Author: sccomer
Date: Mon Jun  1 16:21:47 2009
New Revision: 780705

URL: http://svn.apache.org/viewvc?rev=780705&view=rev
Log:
added isEmpty method to StringUtil.

removed dependence upon java 1.6 String.isEmpty method which doesn't exist in java 1.5.

Modified:
    incubator/etch/branches/name-service/services/ns/src/main/java/org/apache/etch/services/ns/support/DefaultNSLib.java
    incubator/etch/branches/name-service/services/ns/src/main/java/org/apache/etch/services/ns/support/EtchTransportFactory.java
    incubator/etch/branches/name-service/util/src/main/java/org/apache/etch/util/StringUtil.java

Modified: incubator/etch/branches/name-service/services/ns/src/main/java/org/apache/etch/services/ns/support/DefaultNSLib.java
URL: http://svn.apache.org/viewvc/incubator/etch/branches/name-service/services/ns/src/main/java/org/apache/etch/services/ns/support/DefaultNSLib.java?rev=780705&r1=780704&r2=780705&view=diff
==============================================================================
--- incubator/etch/branches/name-service/services/ns/src/main/java/org/apache/etch/services/ns/support/DefaultNSLib.java
(original)
+++ incubator/etch/branches/name-service/services/ns/src/main/java/org/apache/etch/services/ns/support/DefaultNSLib.java
Mon Jun  1 16:21:47 2009
@@ -31,6 +31,7 @@
 import org.apache.etch.services.ns.NameService.Entry;
 import org.apache.etch.util.AlarmListener;
 import org.apache.etch.util.AlarmManager;
+import org.apache.etch.util.StringUtil;
 import org.apache.etch.util.URL;
 import org.apache.etch.util.core.io.Session;
 
@@ -42,8 +43,10 @@
 {
 	private final static int INITIAL_ALARM_DELAY = 1;
 	
-	// Collection of <session, record> entries to keep track of all listeners connected

-	// to this instance of NSLib
+	/**
+	 * Collection of <session, record> entries to keep track of all listeners
+	 * connected to this instance of NSLib
+	 */
 	public Map<Session, Record> recordsBySession = Collections.synchronizedMap( 
 			new HashMap<Session, Record>() );
 	
@@ -144,7 +147,7 @@
 		
 		public Record( String nsUri, String sourceUri, Map<?,?> qualities, String targetUri,
int ttl )
 		{
-			this.nsUri = ( nsUri == null || nsUri.isEmpty() )? defaultNsUri : nsUri;
+			this.nsUri = StringUtil.isEmpty( nsUri ) ? defaultNsUri : nsUri;
 			this.sourceUri = sourceUri;
 			this.qualities = qualities;
 			this.targetUri = targetUri;
@@ -173,8 +176,8 @@
 		URL u = new URL( uri );
 
 		String sourceUri = u.getUri();
-		if ( sourceUri == null || sourceUri.isEmpty() )
-			throw new IllegalArgumentException( "sourceUri == null" );
+		if ( StringUtil.isEmpty( sourceUri ) )
+			throw new IllegalArgumentException( "sourceUri is empty" );
 		
 		if ( ! u.hasTerm( EtchTransportFactory.LISTENER_REGISTERED_URI ) )
 			throw new IllegalArgumentException( "listener registered uri " +
@@ -187,7 +190,7 @@
 		if ( u.hasTerm( EtchTransportFactory.NS_URI ) )
 			nsUri = u.getTerm( EtchTransportFactory.NS_URI );
 		
-		if ( nsUri == null || nsUri.isEmpty() )
+		if ( StringUtil.isEmpty( nsUri ) )
 			nsUri = defaultNsUri;
 		
 		Record record = new Record( nsUri, sourceUri, qualities, targetUri, ttl );
@@ -246,13 +249,13 @@
 		URL u = new URL( uri );
 		
 		String sourceUri = u.getUri();
-		if ( sourceUri == null || sourceUri.isEmpty() )
-			throw new IllegalArgumentException( "sourceUri == null" );
+		if ( StringUtil.isEmpty( sourceUri ) )
+			throw new IllegalArgumentException( "sourceUri is empty" );
 		
 		String nsUri = null;
 		if ( u.hasTerm( EtchTransportFactory.NS_URI ) )
 			nsUri = u.getTerm( EtchTransportFactory.NS_URI );
-		if ( nsUri == null || nsUri.isEmpty() )
+		if ( StringUtil.isEmpty( nsUri ) )
 			nsUri = getDefaultNsUri();
 		
 		// remove alarm for that session/record
@@ -296,11 +299,11 @@
 		
 		String sourceUri = u.getUri();
 		
-		if ( nsUri == null || nsUri.isEmpty() )
+		if ( StringUtil.isEmpty( nsUri ) )
 			nsUri = getDefaultNsUri();
 		
-		if ( sourceUri == null || sourceUri.isEmpty() )
-			throw new IllegalArgumentException( "sourceUri == null" );
+		if ( StringUtil.isEmpty( sourceUri ) )
+			throw new IllegalArgumentException( "sourceUri is empty" );
 		
 		Entry result = null;
 		

Modified: incubator/etch/branches/name-service/services/ns/src/main/java/org/apache/etch/services/ns/support/EtchTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/etch/branches/name-service/services/ns/src/main/java/org/apache/etch/services/ns/support/EtchTransportFactory.java?rev=780705&r1=780704&r2=780705&view=diff
==============================================================================
--- incubator/etch/branches/name-service/services/ns/src/main/java/org/apache/etch/services/ns/support/EtchTransportFactory.java
(original)
+++ incubator/etch/branches/name-service/services/ns/src/main/java/org/apache/etch/services/ns/support/EtchTransportFactory.java
Mon Jun  1 16:21:47 2009
@@ -32,6 +32,7 @@
 import org.apache.etch.util.AlarmListener;
 import org.apache.etch.util.AlarmManager;
 import org.apache.etch.util.Resources;
+import org.apache.etch.util.StringUtil;
 import org.apache.etch.util.URL;
 import org.apache.etch.util.core.Who;
 import org.apache.etch.util.core.io.Session;
@@ -63,10 +64,10 @@
 		URL u = new URL( uri );
 		
 		// Extract uri for the listener to listen on 
-		if ( !u.hasTerm( LISTENER_URI ) || (listenerUri = u.getTerm( LISTENER_URI )).isEmpty()
)
+		if ( !u.hasTerm( LISTENER_URI ) || StringUtil.isEmpty( listenerUri = u.getTerm( LISTENER_URI
) ) )
 			throw new IllegalArgumentException( "listener uri not configured properly within the etch
uri" );
 		
-		if ( !u.hasTerm( LISTENER_REGISTERED_URI ) || u.getTerm( LISTENER_REGISTERED_URI).isEmpty()
)
+		if ( !u.hasTerm( LISTENER_REGISTERED_URI ) || StringUtil.isEmpty( u.getTerm( LISTENER_REGISTERED_URI)
) )
 			throw new IllegalArgumentException( "listener registered uri " +
 			"not configured properly within the etch uri" );
 		
@@ -106,7 +107,7 @@
 			
 			URL u = new URL( uri );
 
-			if ( u.getUri() == null || u.getUri().isEmpty() )
+			if ( StringUtil.isEmpty( u.getUri() ) )
 				throw new IllegalArgumentException( "source uri == null" );
 
 			if ( u.hasTerm( RECONNECT_TERM ) )

Modified: incubator/etch/branches/name-service/util/src/main/java/org/apache/etch/util/StringUtil.java
URL: http://svn.apache.org/viewvc/incubator/etch/branches/name-service/util/src/main/java/org/apache/etch/util/StringUtil.java?rev=780705&r1=780704&r2=780705&view=diff
==============================================================================
--- incubator/etch/branches/name-service/util/src/main/java/org/apache/etch/util/StringUtil.java
(original)
+++ incubator/etch/branches/name-service/util/src/main/java/org/apache/etch/util/StringUtil.java
Mon Jun  1 16:21:47 2009
@@ -209,4 +209,13 @@
 		}
 		return sb.toString();
 	}
+
+	/**
+	 * @param s
+	 * @return true if s is null or empty.
+	 */
+	public static boolean isEmpty( String s )
+	{
+		return s == null || s.length() == 0;
+	}
 }



Mime
View raw message