[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Thu Apr 26 15:22:27 UTC 2007
gordonp
Thu Apr 26 11:22:27 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services
In directory dev.open-bio.org:/tmp/cvs-serv718/src/main/ca/ucalgary/seahawk/services
Modified Files:
MobyClient.java
Log Message:
Small method sig and doc updates
moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.11,1.12
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/18 16:01:00 1.11
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/26 15:22:27 1.12
@@ -740,11 +740,11 @@
return new MobyDataObject[0];
}
- // Vector of moby objects we construct based on the xpath mappings found
+ // Vector of moby objects we construct based on the regex mappings found
Vector objectVector = new Vector();
Iterator regex_keys = regexMap.keySet().iterator();
- while(regex_keys.hasNext()){ //map still has untraversed xpath entry to test
+ while(regex_keys.hasNext()){ //map still has untraversed regex entry to test
Pattern pattern = (Pattern) regex_keys.next();
Matcher matcher = pattern.matcher(textData);
@@ -771,29 +771,44 @@
* Using the URL regular expression mappings that have been set up,
* maps a string to moby objects. URL regexs are special because they are
* flexible in the order in which query parameters are given. They
- * may also have requirements based on the hypertext linked.
+ * may also have requirements based on the hypertext linked. This method
+ * does not look at the contents of the URL, but rather the URL itself.
*/
public MobyDataObject[] getMobyObjects(URL url){
- return getMobyObjects(url, null);
+ return getMobyObjects(url, null, null);
}
public MobyDataObject[] getMobyObjects(URL url, String linkText){
+ return getMobyObjects(url, linkText, null);
+ }
+
+ public MobyDataObject[] getMobyObjects(URL url, MobyDataType targetDataType){
+ return getMobyObjects(url, null, targetDataType);
+ }
+
+ public MobyDataObject[] getMobyObjects(URL url, String linkText, MobyDataType targetDataType){
if(urlRegexMap.isEmpty()){
System.out.println("The MOBY Client has not been provided any url regex->moby data mappings!");
return new MobyDataObject[0];
}
- // Vector of moby objects we construct based on the xpath mappings found
+ // Vector of moby objects we construct based on the regex mappings found
Vector objectVector = new Vector();
String urlString = url.toString();
Iterator url_regex_keys = urlRegexMap.keySet().iterator();
- while(url_regex_keys.hasNext()){ // map still has untraversed xpath entry to test
+ while(url_regex_keys.hasNext()){ // map still has untraversed regex entry to test
Pattern pattern = (Pattern) url_regex_keys.next();
+ MobyComplexBuilder rule = (MobyComplexBuilder) urlRegexMap.get(pattern);
+
+ // If we asked for a particular data type, make sure the rule can produce it before we
+ // start to go matching it.
+ if(targetDataType != null && !rule.getDataType().inheritsFrom(targetDataType)){
+ continue;
+ }
Matcher matcher = pattern.matcher(urlString);
while(matcher.find()){
- MobyComplexBuilder rule = (MobyComplexBuilder) urlRegexMap.get(pattern);
try{
MobyDataObject mobyObj = rule.apply(matcher);
More information about the MOBY-guts
mailing list