[jboss-svn-commits] JBL Code SVN: r5442 - labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Aug 3 12:06:19 EDT 2006


Author: szimano
Date: 2006-08-03 12:06:13 -0400 (Thu, 03 Aug 2006)
New Revision: 5442

Modified:
   labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagSearch.java
Log:
search/null problems in tagme


Modified: labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagSearch.java
===================================================================
--- labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagSearch.java	2006-08-03 16:04:55 UTC (rev 5441)
+++ labs/shotoku/trunk/shotoku-tags/src/java/org/jboss/shotoku/tags/TagSearch.java	2006-08-03 16:06:13 UTC (rev 5442)
@@ -109,45 +109,50 @@
 	private boolean matchTokens(String content, Vector<String> requiredTokens,
 			Vector<String> forbiddenTokens, Vector<String> requestTokens) {
 
-		boolean ret = false;
-		
-		if (requestTokens == null) {
-			return true;
-		}
+		try {
+			boolean ret = false;
 
-		for (int i = 0; i < forbiddenTokens.size(); i++) {
-			if (content.indexOf(forbiddenTokens.get(i)) != -1) {
-				// there is forbidden token - return 0
-				return false;
+			if (requestTokens == null) {
+				return true;
 			}
-		}
 
-		for (int i = 0; i < requiredTokens.size(); i++) {
-			if (content.indexOf(requiredTokens.get(i)) == -1) {
-				// lack of one of the required tokens - return 0
-				return false;
+			for (int i = 0; i < forbiddenTokens.size(); i++) {
+				if (content.indexOf(forbiddenTokens.get(i)) != -1) {
+					// there is forbidden token - return 0
+					return false;
+				}
 			}
-			else {
-				ret = true;
+
+			for (int i = 0; i < requiredTokens.size(); i++) {
+				if (content.indexOf(requiredTokens.get(i)) == -1) {
+					// lack of one of the required tokens - return 0
+					return false;
+				} else {
+					ret = true;
+				}
 			}
-		}
 
-		/*
-		 * if (requiredTokens.size() > 0) { // there is at least one requirted
-		 * token and it has been found return true; }
-		 */
+			/*
+			 * if (requiredTokens.size() > 0) { // there is at least one
+			 * requirted token and it has been found return true; }
+			 */
 
-		for (int i = 0; i < requestTokens.size(); i++) {
-			int fromIndex = -1;
+			for (int i = 0; i < requestTokens.size(); i++) {
+				int fromIndex = -1;
 
-			while ((fromIndex = content.indexOf(requestTokens.get(i),
-					fromIndex + 1)) != -1) {
-				// found at least one required token
-				return true;
+				while ((fromIndex = content.indexOf(requestTokens.get(i),
+						fromIndex + 1)) != -1) {
+					// found at least one required token
+					return true;
+				}
 			}
+
+			// nothing found - maybe there was a only required tokens search
+			return ret;
+		} catch (NullPointerException e) {
+			// some of compared strings was null. This shuldn't happen,
+			// therefore return false
+			return false;
 		}
-
-		// nothing found - maybe there was a only required tokens search
-		return ret;
 	}
 }




More information about the jboss-svn-commits mailing list