(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 14 Mar 2006 20:39:25 +0000 (20:39 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 14 Mar 2006 20:39:25 +0000 (20:39 +0000)
build.xml
build/header.xml
build/trailer.xml
support/src/org/wamblee/conditions/Condition.java [new file with mode: 0644]
support/src/org/wamblee/conditions/OrCondition.java [new file with mode: 0644]
support/src/org/wamblee/general/Pair.java [moved from support/src/org/wamblee/Pair.java with 97% similarity]
support/src/org/wamblee/xml/XSLT.java [new file with mode: 0644]

index d4aef7ef1cc28835cf94cd773eed13ca2d2d24c2..149a1150d20fab44b0f5b641969db0ad2ab71cd1 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -11,7 +11,7 @@
 
     &header;
     
-    <property name="projects" value="support"/>
+    <property name="projects" value="support,crawler"/>
     
     &delegator;
 
index 260d482beaa47ba05876f29a7ea883ac7beabea4..ff7ce1be975213f7f7694f4ce7d722fa23b2034e 100644 (file)
@@ -9,6 +9,9 @@
 </target>
 
 
+<property name="project.home" value=".."/>
+<property name="build.dir" value="${project.home}/build"/>
+<property name="lib.dir" value="${project.home}/lib/wamblee"/>
 
 <target name="download.dep">
   <if>
   </antcall>
 </target>
 
+<target name="httpclient.d">
+  <antcall target="download.dep">
+    <param name="group" value="commons-httpclient"/>
+    <param name="version" value="3.0"/>
+  </antcall>
+</target>
+
+<target name="jtidy.d">
+  <antcall target="download.dep">
+    <param name="group" value="jtidy"/>
+    <param name="version" value="4aug2000r7-dev"/>
+  </antcall>
+</target>
+
+<property name="support.dist.dir" value="${lib.dir}/support"/>
+<target name="wamblee.support.d">
+  <copy todir="${download.dir}">
+    <fileset dir="${support.dist.dir}">
+      <include name="support.jar"/>
+    </fileset>
+  </copy>
+</target>
+<target name="wamblee.support.test.d">
+  <copy todir="${download.dir}">
+    <fileset dir="${support.dist.dir}">
+      <include name="support-test.jar"/>
+    </fileset>
+  </copy>
+</target>
+
+<property name="crawler.dist.dir" value="${lib.dir}/crawler"/>
+<target name="wamblee.crawler.d">
+  <copy todir="${download.dir}">
+    <fileset dir="${crawler.dist.dir}">
+      <include name="crawler.jar"/>
+    </fileset>
+  </copy>
+</target>
+<target name="wamblee.crawler.test.d">
+  <copy todir="${download.dir}">
+    <fileset dir="${crawler.dist.dir}">
+      <include name="crawler-test.jar"/>
+    </fileset>
+  </copy>
+</target>
+
 <target name="junit.d">
   <antcall target="download.dep">
     <param name="group" value="junit"/>
       <!--  The project.home property can also be overriden in a build.xml
             in case the source is in a subdirectory and not necessarily
             in the top-level directory --> 
-    <property name="project.home" value=".."/>
-    <property name="build.dir" value="${project.home}/build"/>
-    <property name="lib.dir" value="${project.home}/lib/wamblee"/>
+   
     <property name="ant.lib.dir" value="${project.home}/lib/ant"/>
     <property name="ant.downloaded.lib.dir" value="${project.home}/lib/ant/downloaded"/>
     <property name="external.lib.dir" value="lib/external"/>
index 106b4d6ec2196279b2d0244a0277f7d8e1d5cb81..95ba839c374248d0380a2959caa865339ad70c2d 100644 (file)
   </delete> 
 </target>
        
-<target name="dist-lite-product" depends="jar">
+<target name="dist-lite-product" depends="deps,jar">
     <mkdir dir="${module.dist.dir}"/>
        <delete>
                <fileset dir="${module.dist.dir}" excludes="**/CVS" />
        </copy>
 </target>
 
-<target name="dist-lite-test" depends="testclasses">
+<target name="dist-lite-test" depends="deps,testclasses">
     <jar destfile="${module.dist.dir}/${module.testjar.name}"
                basedir="${module.testclasses.dir}" 
                includes="**/*.class"/>
diff --git a/support/src/org/wamblee/conditions/Condition.java b/support/src/org/wamblee/conditions/Condition.java
new file mode 100644 (file)
index 0000000..98da09e
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2005 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.wamblee.conditions;
+
+
+/**
+ * Determines if an object matches.
+ */
+public interface Condition<T> {
+
+    /**
+     * Determines if a program matches. 
+     * @param aProgram Program to match. 
+     * @return True iff the program matches. 
+     */
+    boolean matches(T aObject); 
+}
diff --git a/support/src/org/wamblee/conditions/OrCondition.java b/support/src/org/wamblee/conditions/OrCondition.java
new file mode 100644 (file)
index 0000000..14bd24a
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2005 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+
+package org.wamblee.conditions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * 
+ */
+public class OrCondition<T> implements Condition<T> {
+    
+    private List<Condition<T>> _conditions;
+    
+    public OrCondition(Condition<T> aCondition1, Condition<T> aCondition2) {
+        _conditions = new ArrayList<Condition<T>>();
+        _conditions.add(aCondition1); 
+        _conditions.add(aCondition2);
+    }
+    
+    public OrCondition(List<Condition<T>> aConditions) { 
+        _conditions = aConditions; 
+    }
+
+    /* (non-Javadoc)
+     * @see org.wamblee.crawler.kiss.ProgramMatcher#matches(org.wamblee.crawler.kiss.Program)
+     */
+    public boolean matches(T aObject) {
+        for (Condition<T> condition: _conditions) { 
+            if ( condition.matches(aObject)) { 
+                return true; 
+            }
+        }
+        return false; 
+    }
+
+}
similarity index 97%
rename from support/src/org/wamblee/Pair.java
rename to support/src/org/wamblee/general/Pair.java
index e06e8e1eba55c102fe6f7ac75b67918e69003f03..f7a3d9728863d8acee7db0178ae2ec33728bcae0 100644 (file)
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */ 
-package org.wamblee.utils;
+package org.wamblee.general;
 
 /**
  * Represents a pair of objects. This is inspired on the C++ Standard Template Library
diff --git a/support/src/org/wamblee/xml/XSLT.java b/support/src/org/wamblee/xml/XSLT.java
new file mode 100644 (file)
index 0000000..14789e8
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2005 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.wamblee.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+
+import org.w3c.dom.Document;
+
+/**
+ * XSLT utilities.
+ */
+public class XSLT {
+
+    /**
+     * Transforms a DOM document into another DOM document using a given XSLT
+     * transformation.
+     * 
+     * @param aDocument
+     *            Document to transform.
+     * @param aXslt
+     *            XSLT to use.
+     * @return Transformed document.
+     */
+    public static Document transform( Document aDocument, File aXslt ) {
+        Source source = new DOMSource( aDocument );
+        DOMResult result = new DOMResult( );
+        transform( source, result, aXslt );
+        return (Document) result.getNode( );
+    }
+    
+    public static Document transform(byte[] aDocument, File aXslt ) {
+        Source source = new StreamSource( new ByteArrayInputStream(aDocument) );
+        DOMResult result = new DOMResult( );
+        transform( source, result, aXslt );
+        return (Document) result.getNode( );
+    }
+
+    /**
+     * Transforms a DOM document into another DOM document using a given XSLT
+     * transformation.
+     * 
+     * @param aDocument
+     *            Document to transform.
+     * @param aXslt
+     *            XSLT to use.
+     * @return Transformed document.
+     */
+    public static void transform( Source aSource, Result aResult,
+            File aXslt ) {
+        try {
+            Source xslt = new StreamSource( aXslt );
+            Transformer transformer = TransformerFactory.newInstance( )
+                    .newTransformer( xslt );
+            transformer.transform( aSource, aResult );
+        } catch ( TransformerConfigurationException e ) {
+            throw new RuntimeException(
+                    "Configuration problem of XSLT transformation", e );
+        } catch ( TransformerException e ) {
+            throw new RuntimeException( "Error transforming document", e );
+        }
+    }
+}