merged 1.1 branch into head
[mir.git] / source / mir / rss / RSSReader.java
index 6d89d49..f038335 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001, 2002 The Mir-coders group
+ * Copyright (C) 2001-2006 The Mir-coders group
  *
  * This file is part of Mir.
  *
@@ -19,8 +19,6 @@
  *
  * In addition, as a special exception, The Mir-coders gives permission to link
  * the code of this program with  any library licensed under the Apache Software License,
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
- * (or with modified versions of the above that use the same license as the above),
  * and distribute linked combinations including the two.  You must obey the
  * GNU General Public License in all respects for all of the code used other than
  * the above mentioned libraries.  If you modify this file, you may extend this
  */
 package mir.rss;
 
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import mir.util.DateTimeFunctions;
+import mir.util.DateTimeRoutines;
 import mir.util.HTTPClientHelper;
 import mir.util.xml.XMLParserEngine;
 import mir.util.xml.XMLParserExc;
 import mir.util.xml.XMLParserFailure;
 
-/**
- *
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: </p>
- * @author not attributable
- * @version 1.0
- */
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 public class RSSReader {
   public static final String RDF_NAMESPACE_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
@@ -141,7 +129,7 @@ public class RSSReader {
 
   public RSSData parseUrl(String anUrl) throws RSSExc, RSSFailure {
     try {
-      HTTPClientHelper httpClientHelper = new HTTPClientHelper();      
+      HTTPClientHelper httpClientHelper = new HTTPClientHelper();
       InputStream inputStream = httpClientHelper.getUrl(anUrl);
       if (inputStream==null)
         throw new RSSExc("RSSChannel.parseUrl: Can't get url content");
@@ -182,20 +170,19 @@ public class RSSReader {
       if (aTag.getLocalName().equals("RDF")) {
         return new RDFSectionHandler(data);
       }
-      else
-        throw new XMLParserFailure(new RSSExc("'RDF' tag expected"));
-    };
+                       throw new XMLParserFailure(new RSSExc("'RDF' tag expected"));
+    }
 
     public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
-    };
+    }
 
     public void characters(String aCharacters) throws XMLParserExc {
       if (aCharacters.trim().length()>0)
         throw new XMLParserExc("No character data allowed here");
-    };
+    }
 
     public void finishSection() throws XMLParserExc {
-    };
+    }
   }
 
   private class RDFSectionHandler extends mir.util.xml.AbstractSectionHandler {
@@ -211,21 +198,21 @@ public class RSSReader {
       String rdfClass = makeQualifiedName(aTag);
 
       return new RDFResourceSectionHandler(rdfClass, identifier);
-    };
+    }
 
     public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
       if (aHandler instanceof RDFResourceSectionHandler) {
         data.addResource(((RDFResourceSectionHandler) aHandler).getResource());
       }
-    };
+    }
 
     public void characters(String aCharacters) throws XMLParserExc {
       if (aCharacters.trim().length()>0)
         throw new XMLParserExc("No character data allowed here");
-    };
+    }
 
     public void finishSection() throws XMLParserExc {
-    };
+    }
   }
 
   private mir.util.xml.SectionHandler makePropertyValueSectionHandler(mir.util.xml.XMLName aTag, Map anAttributes) {
@@ -304,22 +291,22 @@ public class RSSReader {
       currentTag = aTag;
 
       return makePropertyValueSectionHandler(aTag, anAttributes);
-    };
+    }
 
     public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
       if (aHandler instanceof PropertyValueSectionHandler) {
         usePropertyValueSectionHandler(resource, (PropertyValueSectionHandler) aHandler, currentTag);
 //        resource.set(makeQualifiedName(currentTag), ( (PropertyValueSectionHandler) aHandler).getFieldValue());
       }
-    };
+    }
 
     public void characters(String aCharacters) throws XMLParserExc {
       if (aCharacters.trim().length()>0)
         throw new XMLParserExc("No character data allowed here");
-    };
+    }
 
     public void finishSection() throws XMLParserExc {
-    };
+    }
 
     public RDFResource getResource() {
       if ((resource.getIdentifier()==null || resource.getIdentifier().length()==0) && resource.get("rss:link")!=null) {
@@ -348,20 +335,20 @@ public class RSSReader {
         return new RDFSequenceSectionHandler();
       else
         return new DiscardingSectionHandler();
-    };
+    }
 
     public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
       if (aHandler instanceof RDFSequenceSectionHandler) {
         structuredData= ((RDFSequenceSectionHandler) aHandler).getItems();
       }
-    };
+    }
 
     public void characters(String aCharacters) throws XMLParserExc {
       stringData.append(aCharacters);
-    };
+    }
 
     public void finishSection() throws XMLParserExc {
-    };
+    }
 
     public String getData() {
       return stringData.toString();
@@ -370,8 +357,7 @@ public class RSSReader {
     public Object getValue() {
       if (structuredData==null)
         return stringData.toString();
-      else
-        return structuredData;
+                       return structuredData;
     }
   }
 
@@ -387,21 +373,21 @@ public class RSSReader {
         return new RDFSequenceSectionHandler();
       else
         return new DiscardingSectionHandler();
-    };
+    }
 
     public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
       if (aHandler instanceof RDFSequenceSectionHandler) {
         items.addAll(((RDFSequenceSectionHandler) aHandler).getItems());
       }
-    };
+    }
 
     public void characters(String aCharacters) throws XMLParserExc {
       if (aCharacters.trim().length()>0)
         throw new XMLParserExc("No character data allowed here");
-    };
+    }
 
     public void finishSection() throws XMLParserExc {
-    };
+    }
 
     public List getItems() {
       return items;
@@ -421,17 +407,17 @@ public class RSSReader {
 
     public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc {
       throw new XMLParserFailure(new RSSExc("No subtags allowed here"));
-    };
+    }
 
     public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
-    };
+    }
 
     public void characters(String aCharacters) throws XMLParserExc {
       data.append(aCharacters);
-    };
+    }
 
     public void finishSection() throws XMLParserExc {
-    };
+    }
 
     public String getData() {
       return data.toString();
@@ -451,23 +437,23 @@ public class RSSReader {
 
     public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc {
       throw new XMLParserFailure(new RSSExc("No subtags allowed here"));
-    };
+    }
 
     public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
-    };
+    }
 
     public void characters(String aCharacters) throws XMLParserExc {
       data.append(aCharacters);
-    };
+    }
 
     public void finishSection() throws XMLParserExc {
-    };
+    }
 
     public Object getValue() {
       try {
         String expression = data.toString().trim();
 
-        return DateTimeFunctions.parseW3CDTFString(expression);
+        return DateTimeRoutines.parseW3CDTFString(expression);
       }
       catch (Throwable t) {
 
@@ -493,16 +479,16 @@ public class RSSReader {
       }
 
       return new DiscardingSectionHandler();
-    };
+    }
 
     public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
-    };
+    }
 
     public void characters(String aCharacters) throws XMLParserExc {
-    };
+    }
 
     public void finishSection() throws XMLParserExc {
-    };
+    }
 
     public List getItems() {
       return items;
@@ -526,19 +512,19 @@ public class RSSReader {
       data.append("<"+tag+">");
 
       return new RDFLiteralSectionHandler();
-    };
+    }
 
     public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
       data.append(((RDFLiteralSectionHandler) aHandler).getData());
       data.append("</"+tag+">");
-    };
+    }
 
     public void characters(String aCharacters) throws XMLParserExc {
       data.append(aCharacters);
-    };
+    }
 
     public void finishSection() throws XMLParserExc {
-    };
+    }
 
     public Object getValue() {
       return data.toString();
@@ -548,15 +534,15 @@ public class RSSReader {
   private class DiscardingSectionHandler extends mir.util.xml.AbstractSectionHandler {
     public mir.util.xml.SectionHandler startElement(String aTag, Map anAttributes) throws XMLParserExc {
       return this;
-    };
+    }
 
     public void endElement(mir.util.xml.SectionHandler aHandler) throws XMLParserExc {
-    };
+    }
 
     public void characters(String aCharacters) throws XMLParserExc {
-    };
+    }
 
     public void finishSection() throws XMLParserExc {
-    };
+    }
   }
 }