&header;
- <property name="projects" value="support"/>
+ <property name="projects" value="support,crawler"/>
&delegator;
</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"/>
</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"/>
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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;
+ }
+
+}
* 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
--- /dev/null
+/*
+ * 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 );
+ }
+ }
+}