Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/util/io
In directory sc8-pr-cvs1:/tmp/cvs-serv11152/src/java/core/org/krysalis/ruper2/util/io
Modified Files:
HtmlUtils.java
Log Message:
Leverage selectors for performList, to make it much more powerful.
Index: HtmlUtils.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper2/util/io/HtmlUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HtmlUtils.java 9 Oct 2003 20:30:26 -0000 1.1
--- HtmlUtils.java 30 Oct 2003 05:15:53 -0000 1.2
***************
*** 14,17 ****
--- 14,20 ----
import org.krysalis.ruper2.util.net.VirtualResourceLocator;
+ import org.krysalis.ruper2.util.net.select.ChildVrlSelector;
+ import org.krysalis.ruper2.util.net.select.MatchingVrlSelector;
+ import org.krysalis.ruper2.util.select.ISelector;
/**
***************
*** 46,51 ****
String content)
throws IOException {
! List children = new ArrayList();
String lowerCaseContent = content.toLowerCase();
int index = 0;
--- 49,70 ----
String content)
throws IOException {
! return getLinks(parent, content, new ChildVrlSelector(parent));
! }
+ public static List getMatching(
+ VirtualResourceLocator parent,
+ String content,
+ String pattern)
+ throws IOException {
+ return getLinks(parent, content, new MatchingVrlSelector(pattern));
+ }
+
+ public static List getLinks(
+ VirtualResourceLocator parent,
+ String content,
+ ISelector selector)
+ throws IOException {
+ List children = new ArrayList();
+ // System.out.println("Selector : " + selector);
String lowerCaseContent = content.toLowerCase();
int index = 0;
***************
*** 67,90 ****
boolean added = false;
! //System.out.println("Link : " + strLink);
VirtualResourceLocator v =
new VirtualResourceLocator(parent, strLink);
! //System.out.println("Possible Child: " + v);
! //
! // Check that the parent of the child is this
! //
! if (v.getParent().equals(parent)) {
! //
! // Store another child, no dups...
! //
! if (!children.contains(v)) {
! children.add(v);
! added = true;
! //System.out.println("Accepted Child: " + v);
}
}
}
--- 86,112 ----
boolean added = false;
! // System.out.println("Link : " + strLink);
VirtualResourceLocator v =
new VirtualResourceLocator(parent, strLink);
! try {
! if (selector.select(v)) {
! //
! // Store another child, no dups...
! //
! if (!children.contains(v)) {
! children.add(v);
! added = true;
! }
! // if (added)
! // System.out.println(
! // "Selected : " + strLink);
}
+ }
+ catch (Exception e) {
+ // :TODO: ...
}
}
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.