commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons/jelly/jelly-tags/betwixt/xdocs changes.xml
Date Fri, 17 Sep 2004 00:14:46 GMT
dion        2004/09/16 17:14:46

  Modified:    jelly/jelly-tags/betwixt project.xml
               jelly/jelly-tags/betwixt/xdocs changes.xml
  Added:       jelly/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss
                        Channel.java rss-example.xml TextInput.java
                        RSSDigester.java package.html Item.java Image.java
  Log:
  Move to digester 1.6 and betwixt 0.5
  
  Revision  Changes    Path
  1.1                  jakarta-commons/jelly/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/Channel.java
  
  Index: Channel.java
  ===================================================================
  /*
   * 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.
   */ 
  
  
  package org.apache.commons.digester.rss;
  
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
  import java.io.Serializable;
  import java.io.UnsupportedEncodingException;
  import java.io.Writer;
  import java.util.ArrayList;
  
  
  /**
   * <p>Implementation object representing a <strong>channel</strong> in
the
   * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
   * to further specialize its behavior.</p>
   */
  
  public class Channel implements Serializable {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The set of items associated with this Channel.
       */
      protected ArrayList items = new ArrayList();
  
  
      /**
       * The set of skip days for this channel.
       */
      protected ArrayList skipDays = new ArrayList();
  
  
      /**
       * The set of skip hours for this channel.
       */
      protected ArrayList skipHours = new ArrayList();
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The channel copyright (1-100 characters).
       */
      protected String copyright = null;
  
      public String getCopyright() {
          return (this.copyright);
      }
  
      public void setCopyright(String copyright) {
          this.copyright = copyright;
      }
  
  
      /**
       * The channel description (1-500 characters).
       */
      protected String description = null;
  
      public String getDescription() {
          return (this.description);
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
  
      /**
       * The channel description file URL (1-500 characters).
       */
      protected String docs = null;
  
      public String getDocs() {
          return (this.docs);
      }
  
      public void setDocs(String docs) {
          this.docs = docs;
      }
  
  
      /**
       * The image describing this channel.
       */
      protected Image image = null;
  
      public Image getImage() {
          return (this.image);
      }
  
      public void setImage(Image image) {
          this.image = image;
      }
  
  
      /**
       * The channel language (2-5 characters).
       */
      protected String language = null;
  
      public String getLanguage() {
          return (this.language);
      }
  
      public void setLanguage(String language) {
          this.language = language;
      }
  
  
      /**
       * The channel last build date (1-100 characters).
       */
      protected String lastBuildDate = null;
  
      public String getLastBuildDate() {
          return (this.lastBuildDate);
      }
  
      public void setLastBuildDate(String lastBuildDate) {
          this.lastBuildDate = lastBuildDate;
      }
  
  
      /**
       * The channel link (1-500 characters).
       */
      protected String link = null;
  
      public String getLink() {
          return (this.link);
      }
  
      public void setLink(String link) {
          this.link = link;
      }
  
  
      /**
       * The managing editor (1-100 characters).
       */
      protected String managingEditor = null;
  
      public String getManagingEditor() {
          return (this.managingEditor);
      }
  
      public void setManagingEditor(String managingEditor) {
          this.managingEditor = managingEditor;
      }
  
  
      /**
       * The channel publication date (1-100 characters).
       */
      protected String pubDate = null;
  
      public String getPubDate() {
          return (this.pubDate);
      }
  
      public void setPubDate(String pubDate) {
          this.pubDate = pubDate;
      }
  
  
      /**
       * The channel rating (20-500 characters).
       */
      protected String rating = null;
  
      public String getRating() {
          return (this.rating);
      }
  
      public void setRating(String rating) {
          this.rating = rating;
      }
  
  
      /**
       * The text input description for this channel.
       */
      protected TextInput textInput = null;
  
      public TextInput getTextInput() {
          return (this.textInput);
      }
  
      public void setTextInput(TextInput textInput) {
          this.textInput = textInput;
      }
  
  
      /**
       * The channel title (1-100 characters).
       */
      protected String title = null;
  
      public String getTitle() {
          return (this.title);
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
  
      /**
       * The RSS specification version number used to create this Channel.
       */
      protected double version = 0.91;
  
      public double getVersion() {
          return (this.version);
      }
  
      public void setVersion(double version) {
          this.version = version;
      }
  
  
      /**
       * The webmaster email address (1-100 characters).
       */
      protected String webMaster = null;
  
      public String getWebMaster() {
          return (this.webMaster);
      }
  
      public void setWebMaster(String webMaster) {
          this.webMaster = webMaster;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Add an additional item.
       *
       * @param item The item to be added
       */
      public void addItem(Item item) {
          synchronized (items) {
              items.add(item);
          }
      }
  
  
      /**
       * Add an additional skip day name.
       *
       * @param skipDay The skip day to be added
       */
      public void addSkipDay(String skipDay) {
          synchronized (skipDays) {
              skipDays.add(skipDay);
          }
      }
  
  
      /**
       * Add an additional skip hour name.
       *
       * @param skipHour The skip hour to be added
       */
      public void addSkipHour(String skipHour) {
          synchronized (skipHours) {
              skipHours.add(skipHour);
          }
      }
  
  
      /**
       * Return the items for this channel.
       */
      public Item[] findItems() {
          synchronized (items) {
              Item items[] = new Item[this.items.size()];
              return ((Item[]) this.items.toArray(items));
          }
      }
  
  
      /**
       * Return the items for this channel.
       */
      public Item[] getItems() {
          return findItems();
      }
  
  
      /**
       * Return the skip days for this channel.
       */
      public String[] findSkipDays() {
          synchronized (skipDays) {
              String skipDays[] = new String[this.skipDays.size()];
              return ((String[]) this.skipDays.toArray(skipDays));
          }
      }
  
  
      /**
       * Return the skip hours for this channel.
       */
      public String[] getSkipHours() {
          return findSkipHours();
      }
  
  
      /**
       * Return the skip hours for this channel.
       */
      public String[] findSkipHours() {
          synchronized (skipHours) {
              String skipHours[] = new String[this.skipHours.size()];
              return ((String[]) this.skipHours.toArray(skipHours));
          }
      }
  
  
      /**
       * Return the skip days for this channel.
       */
      public String[] getSkipDays() {
          return findSkipDays();
      }
  
  
      /**
       * Remove an item for this channel.
       *
       * @param item The item to be removed
       */
      public void removeItem(Item item) {
          synchronized (items) {
              items.remove(item);
          }
      }
  
  
      /**
       * Remove a skip day for this channel.
       *
       * @param skipDay The skip day to be removed
       */
      public void removeSkipDay(String skipDay) {
          synchronized (skipDays) {
              skipDays.remove(skipDay);
          }
      }
  
  
      /**
       * Remove a skip hour for this channel.
       *
       * @param skipHour The skip hour to be removed
       */
      public void removeSkipHour(String skipHour) {
          synchronized (skipHours) {
              skipHours.remove(skipHour);
          }
      }
  
  
      /**
       * Render this channel as XML conforming to the RSS 0.91 specification,
       * to the specified output stream, with no indication of character
       * encoding.
       *
       * @param stream The output stream to write to
       */
      public void render(OutputStream stream) {
  
          try {
              render(stream, null);
          } catch (UnsupportedEncodingException e) {
              ; // Can not happen
          }
  
      }
  
  
      /**
       * Render this channel as XML conforming to the RSS 0.91 specification,
       * to the specified output stream, with the specified character encoding.
       *
       * @param stream The output stream to write to
       * @param encoding The character encoding to declare, or <code>null</code>
       *  for no declaration
       *
       * @exception UnsupportedEncodingException if the named encoding
       *  is not supported
       */
      public void render(OutputStream stream, String encoding)
              throws UnsupportedEncodingException {
  
          PrintWriter pw = null;
          if (encoding == null) {
              pw = new PrintWriter(stream);
          } else {
              pw = new PrintWriter(new OutputStreamWriter(stream, encoding));
          }
          render(pw, encoding);
          pw.flush();
  
      }
  
  
      /**
       * Render this channel as XML conforming to the RSS 0.91 specification,
       * to the specified writer, with no indication of character encoding.
       *
       * @param writer The writer to render output to
       */
      public void render(Writer writer) {
  
          render(writer, null);
  
      }
  
  
      /**
       * Render this channel as XML conforming to the RSS 0.91 specification,
       * to the specified writer, indicating the specified character encoding.
       *
       * @param writer The writer to render output to
       * @param encoding The character encoding to declare, or <code>null</code>
       *  for no declaration
       */
      public void render(Writer writer, String encoding) {
  
          PrintWriter pw = new PrintWriter(writer);
          render(pw, encoding);
          pw.flush();
  
      }
  
  
      /**
       * Render this channel as XML conforming to the RSS 0.91 specification,
       * to the specified writer, with no indication of character encoding.
       *
       * @param writer The writer to render output to
       */
      public void render(PrintWriter writer) {
  
          render(writer, null);
  
      }
  
  
      /**
       * Render this channel as XML conforming to the RSS 0.91 specification,
       * to the specified writer, indicating the specified character encoding.
       *
       * @param writer The writer to render output to
       * @param encoding The character encoding to declare, or <code>null</code>
       *  for no declaration
       */
      public void render(PrintWriter writer, String encoding) {
  
          writer.print("<?xml version=\"1.0\"");
          if (encoding != null) {
              writer.print(" encoding=\"");
              writer.print(encoding);
              writer.print("\"");
          }
          writer.println("?>");
          writer.println();
  
          writer.println("<!DOCTYPE rss PUBLIC");
          writer.println("  \"-//Netscape Communications//DTD RSS 0.91//EN\"");
          writer.println("  \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">");
          writer.println();
  
          writer.println("<rss version=\"0.91\">");
          writer.println();
  
          writer.println("  <channel>");
          writer.println();
  
          writer.print("    <title>");
          writer.print(title);
          writer.println("</title>");
  
          writer.print("    <description>");
          writer.print(description);
          writer.println("</description>");
  
          writer.print("    <link>");
          writer.print(link);
          writer.println("</link>");
  
          writer.print("    <language>");
          writer.print(language);
          writer.println("</language>");
  
          if (rating != null) {
              writer.print("    <rating>");
              writer.print(rating);
              writer.println("</rating>");
          }
  
          if (copyright != null) {
              writer.print("    <copyright>");
              writer.print(copyright);
              writer.print("</copyright>");
          }
  
  
          if (pubDate != null) {
              writer.print("    <pubDate>");
              writer.print(pubDate);
              writer.println("</pubDate>");
          }
  
          if (lastBuildDate != null) {
              writer.print("    <lastBuildDate>");
              writer.print(lastBuildDate);
              writer.println("</lastBuildDate>");
          }
  
          if (docs != null) {
              writer.print("    <docs>");
              writer.print(docs);
              writer.println("</docs>");
          }
  
          if (managingEditor != null) {
              writer.print("    <managingEditor>");
              writer.print(managingEditor);
              writer.println("</managingEditor>");
          }
  
          if (webMaster != null) {
              writer.print("    <webMaster>");
              writer.print(webMaster);
              writer.println("</webMaster>");
          }
  
          writer.println();
  
          if (image != null) {
              image.render(writer);
              writer.println();
          }
  
          if (textInput != null) {
              textInput.render(writer);
              writer.println();
          }
  
          String skipDays[] = findSkipDays();
          if (skipDays.length > 0) {
              writer.println("    <skipDays>");
              for (int i = 0; i < skipDays.length; i++) {
                  writer.print("      <skipDay>");
                  writer.print(skipDays[i]);
                  writer.println("</skipDay>");
              }
              writer.println("    </skipDays>");
          }
  
          String skipHours[] = findSkipHours();
          if (skipHours.length > 0) {
              writer.println("    <skipHours>");
              for (int i = 0; i < skipHours.length; i++) {
                  writer.print("      <skipHour>");
                  writer.print(skipHours[i]);
                  writer.println("</skipHour>");
              }
              writer.println("    </skipHours>");
              writer.println();
          }
  
          Item items[] = findItems();
          for (int i = 0; i < items.length; i++) {
              items[i].render(writer);
              writer.println();
          }
  
          writer.println("  </channel>");
          writer.println();
  
          writer.println("</rss>");
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/rss-example.xml
  
  Index: rss-example.xml
  ===================================================================
  <?xml version="1.0"?>
  <!--
   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.
  -->
  
  <!DOCTYPE rss PUBLIC
   "-//Netscape Communications//DTD RSS 0.91//EN"
   "http://my.netscape.com/publish/formats/rss-0.91.dtd">
  
  <rss version="0.91">
  
    <channel>
  
      <title>Apache</title>
      <link>http://www.apache.org</link>
      <description>The Apache Software Foundation</description>
      <language>en-US</language>
      <rating>(PICS-1.1 "http://www.rsac.org/ratingsv01.html"
        2 gen true comment "RSACi North America Server"
        for "http://www.rsac.org" on "1996.04.16T08:15-0500"
        r (n 0 s 0 v 0 l 0))</rating>
  
      <image>
        <title>Apache</title>
        <url>http://jakarta.apache.org/images/jakarta-logo.gif</url>
        <link>http://jakarta.apache.org</link>
        <width>505</width>
        <height>480</height>
        <description>The Jakarta project. Open source, serverside java.</description>
      </image>
  
      <item>
        <title>Commons Attributes 2.1 Released</title>
        <link>http://jakarta.apache.org/site/news/news-2004-2ndHalf.html#20040815.1</link>
        <description>The Jakarta Commons team is happy to announce the release of Commons
Attributes 2.1. 
        This is the first release of the new Commons-Attributes code.</description>
      </item>
  
      <item>
        <title>Cloudscape Becomes Apache Derby</title>
        <link>http://jakarta.apache.org/site/news/elsewhere-2004-2ndHalf.html#20040803.1</link>
        <description>IBM has submitted a proposal to the Apache DB project 
        for a Java-based package to be called 'Derby'.</description>
      </item>
  
      <item>
        <title>Commons BeanUtils 1.7 Released</title>
        <link>http://jakarta.apache.org/site/news/news-2004-2ndHalf.html#20040802.1</link>
      </item>
  
      <item>
        <title>Commons JXPath 1.2 Released</title>
        <link>http://jakarta.apache.org/site/news/news-2004-2ndHalf.html#20040801.2</link>
      </item>
  
    </channel>
  
  </rss>
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/TextInput.java
  
  Index: TextInput.java
  ===================================================================
  /*
   * 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.
   */ 
  
  
  package org.apache.commons.digester.rss;
  
  import java.io.PrintWriter;
  import java.io.Serializable;
  
  
  /**
   * <p>Implementation object representing a <strong>textinput</strong>
in the
   * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
   * to further specialize its behavior.</p>
   */
  
  public class TextInput implements Serializable {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The text input description (1-100 characters).
       */
      protected String description = null;
  
      public String getDescription() {
          return (this.description);
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
  
      /**
       * The text input link (1-500 characters).
       */
      protected String link = null;
  
      public String getLink() {
          return (this.link);
      }
  
      public void setLink(String link) {
          this.link = link;
      }
  
  
      /**
       * The text input field name (1-100 characters).
       */
      protected String name = null;
  
      public String getName() {
          return (this.name);
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
  
      /**
       * The text input submit button label (1-100 characters).
       */
      protected String title = null;
  
      public String getTitle() {
          return (this.title);
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
  
      // -------------------------------------------------------- Package Methods
  
  
      /**
       * Render this channel as XML conforming to the RSS 0.91 specification,
       * to the specified writer.
       *
       * @param writer The writer to render output to
       */
      void render(PrintWriter writer) {
  
          writer.println("    <textinput>");
  
          writer.print("      <title>");
          writer.print(title);
          writer.println("</title>");
  
          writer.print("      <description>");
          writer.print(description);
          writer.println("</description>");
  
          writer.print("      <name>");
          writer.print(name);
          writer.println("</name>");
  
          writer.print("      <link>");
          writer.print(link);
          writer.println("</link>");
  
          writer.println("    </textinput>");
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/RSSDigester.java
  
  Index: RSSDigester.java
  ===================================================================
  /*
   * 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.
   */ 
  
  
  package org.apache.commons.digester.rss;
  
  
  import java.io.File;
  import java.io.IOException;
  import java.io.InputStream;
  import java.net.URL;
  
  import org.apache.commons.digester.Digester;
  import org.apache.commons.logging.LogFactory;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  
  
  /**
   * <p>Implementation of <strong>org.apache.commons.digester.Digester</strong>
   * designed to process input streams that conform to the <em>Rich Site
   * Summary</em> DTD, version 0.91.  For more information about this format,
   * see the <a href="http://my.netscape.com/publish/">My Netscape</a> site.</p>
   *
   * <p>The default implementation object returned by calling
   * <code>parse()</code> (an instance of
   * <code>org.apache.commons.digester.rss.Channel</code>)
   * knows how to render itself in XML format via the <code>render()</code>
   * method.  See the test <code>main()</code> method below for an
   * example of using these classes.</p>
   */
  
  public class RSSDigester extends Digester {
  
  
      // ----------------------------------------------------------- Constructors
  
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * Have we been configured yet?
       */
      protected boolean configured = false;
  
  
      /**
       * The set of public identifiers, and corresponding resource names,
       * for the versions of the DTDs that we know about.
       */
      protected static final String registrations[] = {
          "-//Netscape Communications//DTD RSS 0.9//EN",
          "/org/apache/commons/digester/rss/rss-0.9.dtd",
          "-//Netscape Communications//DTD RSS 0.91//EN",
          "/org/apache/commons/digester/rss/rss-0.91.dtd",
      };
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The fully qualified class name of the <code>Channel</code>
       * implementation class.
       */
      protected String channelClass = "org.apache.commons.digester.rss.Channel";
  
      public String getChannelClass() {
          return (this.channelClass);
      }
  
      public void setChannelClass(String channelClass) {
          this.channelClass = channelClass;
      }
  
  
      /**
       * The fully qualified class name of the <code>Image</code>
       * implementation class.
       */
      protected String imageClass = "org.apache.commons.digester.rss.Image";
  
      public String getImageClass() {
          return (this.imageClass);
      }
  
      public void setImageClass(String imageClass) {
          this.imageClass = imageClass;
      }
  
  
      /**
       * The fully qualified class name of the <code>Item</code>
       * implementation class.
       */
      protected String itemClass = "org.apache.commons.digester.rss.Item";
  
      public String getItemClass() {
          return (this.itemClass);
      }
  
      public void setItemClass(String itemClass) {
          this.itemClass = itemClass;
      }
  
  
      /**
       * The fully qualified class name of the <code>TextInput</code>
       * implementation class.
       */
      protected String textInputClass =
              "org.apache.commons.digester.rss.TextInput";
  
      public String getTextInputClass() {
          return (this.textInputClass);
      }
  
      public void setTextInputClass(String textInputClass) {
          this.textInputClass = textInputClass;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Parse the content of the specified file using this Digester.  Returns
       * the root element from the object stack (which will be the Channel).
       *
       * @param file File containing the XML data to be parsed
       *
       * @exception IOException if an input/output error occurs
       * @exception SAXException if a parsing exception occurs
       */
      public Object parse(File file) throws IOException, SAXException {
  
          configure();
          return (super.parse(file));
  
      }
  
  
      /**
       * Parse the content of the specified input source using this Digester.
       * Returns the root element from the object stack (which will be the
       * Channel).
       *
       * @param input Input source containing the XML data to be parsed
       *
       * @exception IOException if an input/output error occurs
       * @exception SAXException if a parsing exception occurs
       */
      public Object parse(InputSource input) throws IOException, SAXException {
  
          configure();
          return (super.parse(input));
  
      }
  
  
      /**
       * Parse the content of the specified input stream using this Digester.
       * Returns the root element from the object stack (which will be
       * the Channel).
       *
       * @param input Input stream containing the XML data to be parsed
       *
       * @exception IOException if an input/output error occurs
       * @exception SAXException if a parsing exception occurs
       */
      public Object parse(InputStream input) throws IOException, SAXException {
  
          configure();
          return (super.parse(input));
  
      }
  
  
      /**
       * Parse the content of the specified URI using this Digester.
       * Returns the root element from the object stack (which will be
       * the Channel).
       *
       * @param uri URI containing the XML data to be parsed
       *
       * @exception IOException if an input/output error occurs
       * @exception SAXException if a parsing exception occurs
       */
      public Object parse(String uri) throws IOException, SAXException {
  
          configure();
          return (super.parse(uri));
  
      }
  
  
      // -------------------------------------------------------- Package Methods
  
  
  
      // ------------------------------------------------------ Protected Methods
  
  
      /**
       * Configure the parsing rules that will be used to process RSS input.
       */
      protected void configure() {
  
          if (configured) {
              return;
          }
  
          // Register local copies of the DTDs we understand
          for (int i = 0; i < registrations.length; i += 2) {
              URL url = this.getClass().getResource(registrations[i + 1]);
              if (url != null) {
                  register(registrations[i], url.toString());
              }
          }
  
          // FIXME - validate the "version" attribute of the rss element?
  
          // Add the rules for the Channel object
          addObjectCreate("rss/channel", channelClass);
          addCallMethod("rss/channel/copyright", "setCopyright", 0);
          addCallMethod("rss/channel/description", "setDescription", 0);
          addCallMethod("rss/channel/docs", "setDocs", 0);
          addCallMethod("rss/channel/language", "setLanguage", 0);
          addCallMethod("rss/channel/lastBuildDate", "setLastBuildDate", 0);
          addCallMethod("rss/channel/link", "setLink", 0);
          addCallMethod("rss/channel/managingEditor", "setManagingEditor", 0);
          addCallMethod("rss/channel/pubDate", "setPubDate", 0);
          addCallMethod("rss/channel/rating", "setRating", 0);
          addCallMethod("rss/channel/skipDays/day", "addSkipDay", 0);
          addCallMethod("rss/channel/skipHours/hour", "addSkipHour", 0);
          addCallMethod("rss/channel/title", "setTitle", 0);
          addCallMethod("rss/channel/webMaster", "setWebMaster", 0);
  
          // Add the rules for the Image object
          addObjectCreate("rss/channel/image", imageClass);
          addSetNext("rss/channel/image", "setImage",
                  "org.apache.commons.digester.rss.Image");
          addCallMethod("rss/channel/image/description", "setDescription", 0);
          addCallMethod("rss/channel/image/height", "setHeight", 0,
                  new Class[]{ Integer.TYPE });
          addCallMethod("rss/channel/image/link", "setLink", 0);
          addCallMethod("rss/channel/image/title", "setTitle", 0);
          addCallMethod("rss/channel/image/url", "setURL", 0);
          addCallMethod("rss/channel/image/width", "setWidth", 0,
                  new Class[]{ Integer.TYPE });
  
          // Add the rules for the Item object
          addObjectCreate("rss/channel/item", itemClass);
          addSetNext("rss/channel/item", "addItem",
                  "org.apache.commons.digester.rss.Item");
          addCallMethod("rss/channel/item/description", "setDescription", 0);
          addCallMethod("rss/channel/item/link", "setLink", 0);
          addCallMethod("rss/channel/item/title", "setTitle", 0);
  
          // Add the rules for the TextInput object
          addObjectCreate("rss/channel/textinput", textInputClass);
          addSetNext("rss/channel/textinput", "setTextInput",
                  "org.apache.commons.digester.rss.TextInput");
          addCallMethod("rss/channel/textinput/description",
                  "setDescription", 0);
          addCallMethod("rss/channel/textinput/link", "setLink", 0);
          addCallMethod("rss/channel/textinput/name", "setName", 0);
          addCallMethod("rss/channel/textinput/title", "setTitle", 0);
  
          // Mark this digester as having been configured
          configured = true;
  
      }
  
  
      // ------------------------------------------------------ Test Main Program
  
  
      /**
       * Test main program that parses the channel description included in this
       * package as a static resource.
       *
       * @param args The command line arguments (ignored)
       */
      public static void main(String args[]) {
  
          try {
              System.out.println("RSSDigester Test Program");
              System.out.println("Opening input stream ...");
              InputStream is = RSSDigester.class.getResourceAsStream
                      ("/org/apache/commons/digester/rss/rss-example.xml");
              System.out.println("Creating new digester ...");
              RSSDigester digester = new RSSDigester();
              if ((args.length > 0) && (args[0].equals("-debug"))) {
                  digester.setLogger(LogFactory.getLog("RSSDigester"));
              }
              System.out.println("Parsing input stream ...");
              Channel channel = (Channel) digester.parse(is);
              System.out.println("Closing input stream ...");
              is.close();
              System.out.println("Dumping channel info ...");
              channel.render(System.out);
          } catch (Exception e) {
              System.out.println("-->Exception");
              e.printStackTrace(System.out);
          }
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  <title>Package Documentation for org.apache.commons.digester.rss Package</title>
  </head>
  <body bgcolor="white">
  <p>Example usage of Digester to parse XML documents compatible with the
  <em>Rich Site Summary</em> format used by many newsfeeds.</p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/Item.java
  
  Index: Item.java
  ===================================================================
  /*
   * 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.
   */ 
  
  
  package org.apache.commons.digester.rss;
  
  import java.io.PrintWriter;
  import java.io.Serializable;
  
  
  /**
   * <p>Implementation object representing an <strong>item</strong> in the
   * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
   * to further specialize its behavior.</p>
   */
  
  public class Item implements Serializable {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The item description (1-500 characters).
       */
      protected String description = null;
  
      public String getDescription() {
          return (this.description);
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
  
      /**
       * The item link (1-500 characters).
       */
      protected String link = null;
  
      public String getLink() {
          return (this.link);
      }
  
      public void setLink(String link) {
          this.link = link;
      }
  
  
      /**
       * The item title (1-100 characters).
       */
      protected String title = null;
  
      public String getTitle() {
          return (this.title);
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
  
      // -------------------------------------------------------- Package Methods
  
  
      /**
       * Render this channel as XML conforming to the RSS 0.91 specification,
       * to the specified writer.
       *
       * @param writer The writer to render output to
       */
      void render(PrintWriter writer) {
  
          writer.println("    <item>");
  
          writer.print("      <title>");
          writer.print(title);
          writer.println("</title>");
  
          writer.print("      <link>");
          writer.print(link);
          writer.println("</link>");
  
          if (description != null) {
              writer.print("      <description>");
              writer.print(description);
              writer.println("</description>");
          }
  
          writer.println("    </item>");
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons/jelly/jelly-tags/betwixt/src/test/org/apache/commons/digester/rss/Image.java
  
  Index: Image.java
  ===================================================================
  /*
   * 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.
   */ 
  
  
  package org.apache.commons.digester.rss;
  
  import java.io.PrintWriter;
  import java.io.Serializable;
  
  
  /**
   * <p>Implementation object representing an <strong>image</strong> in
the
   * <em>Rich Site Summary</em> DTD, version 0.91.  This class may be subclassed
   * to further specialize its behavior.</p>
   */
  
  public class Image implements Serializable {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The image description (1-100 characters).
       */
      protected String description = null;
  
      public String getDescription() {
          return (this.description);
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
  
      /**
       * The image height in pixels (1-400).
       */
      protected int height = 31;
  
      public int getHeight() {
          return (this.height);
      }
  
      public void setHeight(int height) {
          this.height = height;
      }
  
  
      /**
       * The image link (1-500 characters).
       */
      protected String link = null;
  
      public String getLink() {
          return (this.link);
      }
  
      public void setLink(String link) {
          this.link = link;
      }
  
  
      /**
       * The image alternate text (1-100 characters).
       */
      protected String title = null;
  
      public String getTitle() {
          return (this.title);
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
  
      /**
       * The image location URL (1-500 characters).
       */
      protected String url = null;
  
      public String getURL() {
          return (this.url);
      }
  
      public void setURL(String url) {
          this.url = url;
      }
  
  
      /**
       * The image width in pixels (1-400).
       */
      protected int width = 31;
  
      public int getWidth() {
          return (this.width);
      }
  
      public void setWidth(int width) {
          this.width = width;
      }
  
  
      // -------------------------------------------------------- Package Methods
  
  
      /**
       * Render this channel as XML conforming to the RSS 0.91 specification,
       * to the specified writer.
       *
       * @param writer The writer to render output to
       */
      void render(PrintWriter writer) {
  
          writer.println("    <image>");
  
          writer.print("      <title>");
          writer.print(title);
          writer.println("</title>");
  
          writer.print("      <url>");
          writer.print(url);
          writer.println("</url>");
  
          if (link != null) {
              writer.print("      <link>");
              writer.print(link);
              writer.println("</link>");
          }
  
          writer.print("      <width>");
          writer.print(width);
          writer.println("</width>");
  
          writer.print("      <height>");
          writer.print(height);
          writer.println("</height>");
  
          if (description != null) {
              writer.print("      <description>");
              writer.print(description);
              writer.println("</description>");
          }
  
          writer.println("    </image>");
  
      }
  
  
  }
  
  
  
  1.22      +3 -3      jakarta-commons/jelly/jelly-tags/betwixt/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/betwixt/project.xml,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- project.xml	10 Sep 2004 23:25:48 -0000	1.21
  +++ project.xml	17 Sep 2004 00:14:46 -0000	1.22
  @@ -18,7 +18,7 @@
     <extend>${basedir}/../tag-project.xml</extend>
     <id>commons-jelly-tags-betwixt</id>
     <name>commons-jelly-tags-betwixt</name>
  -  <currentVersion>1.0</currentVersion>
  +  <currentVersion>1.1-SNAPSHOT</currentVersion>
     <package>org.apache.commons.jelly.tags.betwixt</package>
   
     <description>
  @@ -46,13 +46,13 @@
     
       <dependency>
         <id>commons-betwixt</id>
  -      <version>1.0-beta-1</version>
  +      <version>0.5</version>
         <url>http://jakarta.apache.org/commons/betwixt/</url>
       </dependency>
       
       <dependency>
         <id>commons-digester</id>
  -      <version>1.5</version>
  +      <version>1.6</version>
         <url>http://jakarta.apache.org/commons/digester/</url>
       </dependency>
       
  
  
  
  1.3       +3 -0      jakarta-commons/jelly/jelly-tags/betwixt/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/betwixt/xdocs/changes.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- changes.xml	10 Sep 2004 23:25:49 -0000	1.2
  +++ changes.xml	17 Sep 2004 00:14:46 -0000	1.3
  @@ -24,6 +24,9 @@
       <author email="dion@apache.org">dIon Gillard</author>
     </properties>
     <body>
  +    <release version="1.1-SNAPSHOT" date="in CVS">
  +      <action dev="dion" type="update">Move to betwixt 0.5 and digester 1.6</action>
  +    </release>
       <release version="1.0" date="2004-09-11">
         <action dev="dion" type="add">Initial Release</action>
       </release>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message