[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Fri Apr 9 15:49:18 UTC 2010


gordonp
Fri Apr  9 11:49:18 EDT 2010
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources
In directory dev.open-bio.org:/tmp/cvs-serv1294/src/main/ca/ucalgary/seahawk/resources

Modified Files:
	RegexFilterBeanShell 
Log Message:
Added case sensitivity, eliminated auto-attr matching since select-all xpath has been fixed
moby-live/Java/src/main/ca/ucalgary/seahawk/resources RegexFilterBeanShell,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/RegexFilterBeanShell,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/RegexFilterBeanShell	2010/03/17 20:03:06	1.1
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/RegexFilterBeanShell	2010/04/09 15:49:18	1.2
@@ -1,4 +1,5 @@
 import java.util.*;
+import java.util.regex.Pattern;
 import org.dom4j.*;
 import org.dom4j.io.SAXReader;
 
@@ -13,24 +14,18 @@
 int i = 1;
 Map collections = new LinkedHashMap();
 Map collectionsEnd = new HashMap();
-select: for (Iterator iter = nodelist.iterator(); iter.hasNext();) {
+Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE | Pattern.DOTALL | (Boolean.parseBoolean(case_sensitive) ? 0 : Pattern.CASE_INSENSITIVE));
+for (Iterator iter = nodelist.iterator(); iter.hasNext();) {
         Node node = (Node) iter.next();
         boolean match = false;
         switch(node.getNodeType()){
                 case Node.ELEMENT_NODE:
-                        if(node.getText().matches(".*?"+regex+".*")){
+                        if(pattern.matcher(node.getText()).find()){
                                 match = true;
                         }
-                        else{
-                                for(Object attr: ((Element) node).attributeIterator()){
-                                        if(((Attribute) attr).getValue().matches(".*?"+regex+".*")){
-                                                match = true; break;
-                                        }
-                                }
-                        }
                         break;
                 case Node.ATTRIBUTE_NODE:
-                        if(node.getValue().matches(".*?"+regex+".*")){
+                        if(pattern.matcher(node.getValue()).find()){
                                 match = true;
                         }
                         break;




More information about the MOBY-guts mailing list