pkg://jakarta-commons-digester-1.6-2jpp_4fc.src.rpm:259175/commons-digester-1.6-src.tar.gz
info downloads
commons-digester-1.6-src/ 0040755 0000766 0000766 00000000000 10117664673 016257 5 ustar crazybull crazybull commons-digester-1.6-src/src/ 0040755 0000766 0000766 00000000000 10117664667 017051 5 ustar crazybull crazybull commons-digester-1.6-src/src/conf/ 0040755 0000766 0000766 00000000000 10117664655 017773 5 ustar crazybull crazybull commons-digester-1.6-src/src/conf/MANIFEST.MF 0100644 0000766 0000766 00000000463 10041652064 021410 0 ustar crazybull crazybull Extension-Name: org.apache.commons.digester
Specification-Title: "Jakarta Commons Digester"
Specification-Vendor: "Apache Software Foundation"
Specification-Version: "1.6"
Implementation-Title: "org.apache.commons.digester"
Implementation-Vendor: "Apache Software Foundation"
Implementation-Version: "1.6"
commons-digester-1.6-src/src/examples/ 0040755 0000766 0000766 00000000000 10117664660 020660 5 ustar crazybull crazybull commons-digester-1.6-src/src/examples/api/ 0040755 0000766 0000766 00000000000 10117664656 021436 5 ustar crazybull crazybull commons-digester-1.6-src/src/examples/api/addressbook/ 0040755 0000766 0000766 00000000000 10117664656 023736 5 ustar crazybull crazybull commons-digester-1.6-src/src/examples/api/addressbook/.cvsignore 0100644 0000766 0000766 00000000010 07735526045 025723 0 ustar crazybull crazybull *.class
commons-digester-1.6-src/src/examples/api/addressbook/AddressBook.java 0100644 0000766 0000766 00000002124 10040207031 026744 0 ustar crazybull crazybull /*
* Copyright 2003-2004 The Apache Software Foundation.
*
* 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.
*/
import java.util.LinkedList;
import java.util.Iterator;
/**
* See Main.java.
*/
public class AddressBook {
LinkedList people = new LinkedList();
public void addPerson(Person p) {
people.addLast(p);
}
public void print() {
System.out.println("Address book has " + people.size() + " entries");
for(Iterator i = people.iterator(); i.hasNext(); ) {
Person p = (Person) i.next();
p.print();
}
}
}
commons-digester-1.6-src/src/examples/api/addressbook/Main.java 0100644 0000766 0000766 00000012514 10040206652 025444 0 ustar crazybull crazybull /*
* Copyright 2003-2004 The Apache Software Foundation.
*
* 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.
*/
import org.apache.commons.digester.Digester;
/**
* A simple program to demonstrate the basic functionality of the
* Commons Digester module.
* <p>
* This code will parse the provided "example.xml" file to build a tree
* of java objects, then cause those objects to print out their values
* to demonstrate that the input file has been processed correctly.
* <p>
* As with all code, there are many ways of achieving the same goal;
* the solution here is only one possible solution to the problem.
* <p>
* Very verbose comments are included here, as this class is intended
* as a tutorial; if you look closely at method "addRules", you will
* see that the amount of code required to use the Digester is actually
* quite low.
* <p>
* Usage: java Main example.xml
*/
public class Main {
/**
* Main method : entry point for running this example program.
* <p>
* Usage: java Example example.xml
*/
public static void main(String[] args) {
if (args.length != 1) {
usage();
System.exit(-1);
}
String filename = args[0];
// Create a Digester instance
Digester d = new Digester();
// Prime the digester stack with an object for rules to
// operate on. Note that it is quite common for "this"
// to be the object pushed.
AddressBook book = new AddressBook();
d.push(book);
// Add rules to the digester that will be triggered while
// parsing occurs.
addRules(d);
// Process the input file.
try {
java.io.File srcfile = new java.io.File(filename);
d.parse(srcfile);
}
catch(java.io.IOException ioe) {
System.out.println("Error reading input file:" + ioe.getMessage());
System.exit(-1);
}
catch(org.xml.sax.SAXException se) {
System.out.println("Error parsing input file:" + se.getMessage());
System.exit(-1);
}
// Print out all the contents of the address book, as loaded from
// the input file.
book.print();
}
private static void addRules(Digester d) {
//--------------------------------------------------
// when we encounter a "person" tag, do the following:
// create a new instance of class Person, and push that
// object onto the digester stack of objects
d.addObjectCreate("address-book/person", Person.class);
// map *any* attributes on the tag to appropriate
// setter-methods on the top object on the stack (the Person
// instance created by the preceeding rule).
//
// For example:
// if attribute "id" exists on the xml tag, and method setId
// with one parameter exists on the object that is on top of
// the digester object stack, then a call will be made to that
// method. The value will be type-converted from string to
// whatever type the target method declares (where possible),
// using the commons ConvertUtils functionality.
//
// Attributes on the xml tag for which no setter methods exist
// on the top object on the stack are just ignored.
d.addSetProperties("address-book/person");
// call the addPerson method on the second-to-top object on
// the stack (the AddressBook object), passing the top object
// on the stack (the recently created Person object).
d.addSetNext("address-book/person", "addPerson");
//--------------------------------------------------
// when we encounter a "name" tag, call setName on the top
// object on the stack, passing the text contained within the
// body of that name element [specifying a zero parameter count
// implies one actual parameter, being the body text].
// The top object on the stack will be a person object, because
// the pattern address-book/person always triggers the
// ObjectCreateRule we added previously.
d.addCallMethod("address-book/person/name", "setName", 0);
//--------------------------------------------------
// when we encounter an "email" tag, call addEmail on the top
// object on the stack, passing two parameters: the "type"
// attribute, and the text within the tag body.
d.addCallMethod("address-book/person/email", "addEmail", 2);
d.addCallParam("address-book/person/email", 0, "type");
d.addCallParam("address-book/person/email", 1);
}
private static void usage() {
System.out.println("Usage: java Main example.xml");
}
} commons-digester-1.6-src/src/examples/api/addressbook/Person.java 0100644 0000766 0000766 00000003322 10040207031 026013 0 ustar crazybull crazybull /*
* Copyright 2001-2004 The Apache Software Foundation.
*
* 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.
*/
import java.util.HashMap;
import java.util.Iterator;
/**
* See Main.java.
*/
public class Person {
private int id;
private String category;
private String name;
private HashMap emails = new HashMap();
/**
* A unique id for this person. Note that the Digester automatically
* converts the id to an integer.
*/
public void setId(int id) {
this.id = id;
}
public void setCategory(String category) {
this.category = category;
}
public void setName(String name) {
this.name = name;
}
/** we assume only one email of each type... */
public void addEmail(String type, String address) {
emails.put(type, address);
}
public void print() {
System.out.println("Person #" + id);
System.out.println(" category=" + category);
System.out.println(" name=" + name);
for(Iterator i = emails.keySet().iterator(); i.hasNext(); ) {
String type = (String) i.next();
String address = (String) emails.get(type);
System.out.println(" email (type " + type + ") : " + address);
}
}
}
commons-digester-1.6-src/src/examples/api/addressbook/build.xml 0100644 0000766 0000766 00000011040 10110732434 025527 0 ustar crazybull crazybull <!--
Copyright 2004 The Apache Software Foundation.
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.
-->
<project name="Example-AddressBook" default="compile" basedir=".">
<!-- ========== Initialize Properties ===================================== -->
<property file="build.properties"/> <!-- Component local -->
<property file="../build.properties"/> <!-- examples/api local-->
<property file="../../../../build.properties"/> <!-- Digester local -->
<property file="../../../../../build.properties"/> <!-- Commons local -->
<property file="${user.home}/build.properties"/> <!-- User local -->
<!-- ========== External Dependencies ===================================== -->
<!-- The directories corresponding to your necessary dependencies -->
<property name="jaxp.home" value="/usr/local/jaxp1.1"/>
<property name="commons.home" value="../../../../.."/>
<property name="beanutils.home" value="${commons.home}/beanutils"/>
<property name="collections.home" value="${commons.home}/collections"/>
<property name="logging.home" value="${commons.home}/logging"/>
<property name="digester.home" value="${commons.home}/digester"/>
<!-- ========== Derived Values ============================================ -->
<!-- The locations of necessary jar files -->
<property name="jaxp.jaxp.jar" value="${jaxp.home}/jaxp.jar"/>
<property name="jaxp.parser.jar" value="${jaxp.home}/crimson.jar"/>
<property name="commons-beanutils.jar" value="${beanutils.home}/dist/commons-beanutils.jar"/>
<property name="commons-collections.jar" value="${collections.home}/dist/commons-collections.jar"/>
<property name="commons-logging.jar" value="${logging.home}/dist/commons-logging.jar"/>
<property name="commons-digester.jar" value="${digester.home}/dist/commons-digester.jar"/>
<!-- ========== Component Declarations ==================================== -->
<!-- The name of this component -->
<property name="component.name" value="addressbook"/>
<!-- ========== Compiler Defaults ========================================= -->
<!-- Should Java compilations set the 'debug' compiler option? -->
<property name="compile.debug" value="true"/>
<!-- Should Java compilations set the 'deprecation' compiler option? -->
<property name="compile.deprecation" value="false"/>
<!-- Should Java compilations set the 'optimize' compiler option? -->
<property name="compile.optimize" value="true"/>
<!-- Construct compile classpath -->
<path id="compile.classpath">
<pathelement location="."/>
<pathelement location="${jaxp.jaxp.jar}"/>
<pathelement location="${jaxp.parser.jar}"/>
<pathelement location="${commons-beanutils.jar}"/>
<pathelement location="${commons-collections.jar}"/>
<pathelement location="${commons-logging.jar}"/>
<pathelement location="${commons-digester.jar}"/>
</path>
<!-- ========== Executable Targets ======================================== -->
<target name="compile">
<javac srcdir="."
destdir="."
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="clean">
<delete>
<fileset dir="." includes="*.class"/>
</delete>
<delete dir="docs"/>
</target>
<target name="all" depends="clean,compile"/>
<target name="javadoc" depends="compile">
<mkdir dir="docs"/>
<javadoc destdir="docs"
author="true"
private="true"
version="true">
<classpath refid="compile.classpath"/>
<fileset dir="." includes="*.java"/>
</javadoc>
</target>
<target name="run" depends="compile">
<java classname="Main" fork="yes">
<arg value="example.xml"/>
<classpath refid="compile.classpath"/>
<classpath>
<pathelement location="."/>
</classpath>
</java>
</target>
</project>
commons-digester-1.6-src/src/examples/api/addressbook/example.xml 0100644 0000766 0000766 00000001651 10110732434 026072 0 ustar crazybull crazybull <!--
Copyright 2004 The Apache Software Foundation.
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.
-->
<address-book>
<person id="1" category="acquaintance">
<name>Gonzo</name>
<email type="business">gonzo@muppets.com</email>
</person>
<person id="2" category="rolemodel">
<name>Kermit</name>
<email type="business">kermit@muppets.com</email>
<email type="home">kermie@acme.com</email>
</person>
</address-book>