You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/03/02 09:27:52 UTC

cvs commit: jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/tools ISO8601DateParser.java RFC822DateParser.java

burton      2004/03/02 00:27:52

  Modified:    feedparser TODO
               feedparser/src/java/org/apache/commons/feedparser
                        ContentFeedParserListener.java
                        DefaultFeedParserListener.java
  Added:       feedparser LICENSE
               feedparser/src/java/org/apache/commons/feedparser/tools
                        ISO8601DateParser.java RFC822DateParser.java
  Removed:     feedparser LICENSE.txt
  Log:
  renamed license per rename instructions
  
  Revision  Changes    Path
  1.6       +6 -1      jakarta-commons-sandbox/feedparser/TODO
  
  Index: TODO
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/TODO,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TODO	27 Feb 2004 00:00:54 -0000	1.5
  +++ TODO	2 Mar 2004 08:27:52 -0000	1.6
  @@ -37,4 +37,9 @@
   
       - http://intertwingly.net/wiki/pie/content
   
  -- Support for RSS 1.0 mod_link and Atom links
  \ No newline at end of file
  +- Support for RSS 1.0 mod_link and Atom links
  +
  +- What are my options for XPATH libraries... I should benchmark these..  Also
  +  see if using SAX will just be faster.
  +
  +- Full documentation on how we have to handle dates.
  \ No newline at end of file
  
  
  
  1.3       +202 -55   jakarta-commons-sandbox/feedparser/LICENSE
  
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/ContentFeedParserListener.java
  
  Index: ContentFeedParserListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/ContentFeedParserListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ContentFeedParserListener.java	28 Feb 2004 03:35:21 -0000	1.3
  +++ ContentFeedParserListener.java	2 Mar 2004 08:27:52 -0000	1.4
  @@ -81,7 +81,7 @@
                              String mode,
                              String value ) throws FeedParserException;
   
  -    public void onContent() throws FeedParserException;
  +    public void onContentEnd() throws FeedParserException;
   
   }
   
  
  
  
  1.6       +2 -2      jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/DefaultFeedParserListener.java
  
  Index: DefaultFeedParserListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/DefaultFeedParserListener.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultFeedParserListener.java	28 Feb 2004 03:35:21 -0000	1.5
  +++ DefaultFeedParserListener.java	2 Mar 2004 08:27:52 -0000	1.6
  @@ -124,6 +124,6 @@
                              String mode,
                              String value ) throws FeedParserException {}
   
  -    public void onContent() throws FeedParserException {}
  +    public void onContentEnd() throws FeedParserException {}
   
   }
  
  
  
  1.1                  jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/tools/ISO8601DateParser.java
  
  Index: ISO8601DateParser.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "FeedParser", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.commons.feedparser.tools;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import java.text.*;
  
  /**
   *
   * @author <a href="mailto:burton@apache.org">Kevin A. Burton (burtonator)</a>
   * @version $Id: ISO8601DateParser.java,v 1.1 2004/03/02 08:27:52 burton Exp $
   */
  public class ISO8601DateParser {
  
      private static SimpleDateFormat df
          = new SimpleDateFormat( "yyyy-MM-dd'T'hh:mm:ssz" );
  
      // Different standards may need different levels of granularity in the date and
      // time, so this profile defines six levels. Standards that reference this
      // profile should specify one or more of these granularities. If a given
      // standard allows more than one granularity, it should specify the meaning of
      // the dates and times with reduced precision, for example, the result of
      // comparing two dates with different precisions.
  
      // The formats are as follows. Exactly the components shown here must be
      // present, with exactly this punctuation. Note that the "T" appears literally
      // in the string, to indicate the beginning of the time element, as specified in
      // ISO 8601.
  
      //    Year:
      //       YYYY (eg 1997)
      //    Year and month:
      //       YYYY-MM (eg 1997-07)
      //    Complete date:
      //       YYYY-MM-DD (eg 1997-07-16)
      //    Complete date plus hours and minutes:
      //       YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
      //    Complete date plus hours, minutes and seconds:
      //       YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
      //    Complete date plus hours, minutes, seconds and a decimal fraction of a
      // second
      //       YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
  
      // where:
  
      //      YYYY = four-digit year
      //      MM   = two-digit month (01=January, etc.)
      //      DD   = two-digit day of month (01 through 31)
      //      hh   = two digits of hour (00 through 23) (am/pm NOT allowed)
      //      mm   = two digits of minute (00 through 59)
      //      ss   = two digits of second (00 through 59)
      //      s    = one or more digits representing a decimal fraction of a second
      //      TZD  = time zone designator (Z or +hh:mm or -hh:mm)
  
      public static Date parse( String input ) throws java.text.ParseException {
  
          //NOTE: SimpleDateFormat uses GMT[-+]hh:mm for the TZ which breaks
          //things a bit.  Before we go on we have to repair this.
  
          int inset = 6;
          
          String s0 = input.substring( 0, input.length() - inset );
          String s1 = input.substring( input.length() - inset, input.length() );
  
          input = s0 + "GMT" + s1;
  
          return df.parse( input );
          
      }
  
      public static String toString( Date date, TimeZone tz ) {
  
          df.setTimeZone( tz );
  
          String output = df.format( date );
  
          int inset0 = 9;
          int inset1 = 6;
          
          String s0 = output.substring( 0, output.length() - inset0 );
          String s1 = output.substring( output.length() - inset1, output.length() );
  
          return s0 + s1;
          
      }
      
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/tools/RFC822DateParser.java
  
  Index: RFC822DateParser.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "FeedParser", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.commons.feedparser.tools;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import java.text.*;
  
  /**
   *
   * @author <a href="mailto:burton@apache.org">Kevin A. Burton (burtonator)</a>
   * @version $Id: RFC822DateParser.java,v 1.1 2004/03/02 08:27:52 burton Exp $
   */
  public class RFC822DateParser {
  
      private static SimpleDateFormat df
          = new SimpleDateFormat( "EEE, dd MMM yyyy hh:mm:ss z" );
  
      public static Date parse( String input ) throws java.text.ParseException {
  
          //NOTE: SimpleDateFormat uses GMT[-+]hh:mm for the TZ which breaks
          //things a bit.  Before we go on we have to repair this.
  
          return df.parse( input );
          
      }
  
      public static String toString( Date date, TimeZone tz ) {
  
          df.setTimeZone( tz );
  
          return df.format( date );
          
      }
      
  }
  
  
  
  

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