burton 2004/08/27 11:07:01
Modified: feedparser TODO
feedparser/src/java/org/apache/commons/feedparser
FOAFFeedParser.java FeedParser.java
feedparser/src/java/org/apache/commons/feedparser/impl
DebugFeedParserListener.java
feedparser/src/java/org/apache/commons/feedparser/locate
FeedReference.java
feedparser/src/java/org/apache/commons/feedparser/test
TestFeedLocator.java
Log:
documentation for FeedReference
Revision Changes Path
1.10 +12 -1 jakarta-commons-sandbox/feedparser/TODO
Index: TODO
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/feedparser/TODO,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TODO 4 Jul 2004 05:52:35 -0000 1.9
+++ TODO 27 Aug 2004 18:07:01 -0000 1.10
@@ -1,5 +1,16 @@
-- Implementation of RSS/Atom autodiscovery...
+
+- Support Base64 Atom values and the ability to enable them.
+
+- Atom's xml:base is NOT supported right now. We NEED to support this.
+
+- Do we support multiple content items in Atom?
+
+
+
+- Implement RSS 2.0 enclosure linkage
+
+- (DONE) Implementation of RSS/Atom autodiscovery...
- Rework the factory mechanism to support multiple FeedParsers... should be an
interface.
1.5 +23 -13
jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/FOAFFeedParser.java
Index: FOAFFeedParser.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/FOAFFeedParser.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FOAFFeedParser.java 22 Aug 2004 11:28:04 -0000 1.4
+++ FOAFFeedParser.java 27 Aug 2004 18:07:01 -0000 1.5
@@ -49,23 +49,33 @@
listener.init();
+ FOAFFeedParserListener flistener = null;
+
+ if ( listener instanceof FOAFFeedParserListener )
+ flistener = (FOAFFeedParserListener)listener;
+
//this should be the root directory.
XPath xpath = new XPath( "/rdf:RDF/foaf:Person" );
xpath.setNamespaceContext( NS.context );
Element person = (Element)xpath.selectSingleNode( doc );
+ String name = RSSFeedParser.getChildElementTextByName( state, "name" );
+
+ String homepage = getAttributeValue( state,
+ "homepage", NS.FOAF,
+ "resource", NS.RDF );
+
+ if ( flistener != null )
+ flistener.onPerson( state, name );
+
xpath = new XPath( "foaf:knows" );
+
xpath.setNamespaceContext( NS.context );
List list = xpath.selectNodes( person );
Iterator i = list.iterator();
- FOAFFeedParserListener flistener = null;
-
- if ( listener instanceof FOAFFeedParserListener )
- flistener = (FOAFFeedParserListener)listener;
-
while ( i.hasNext() ) {
Element knows = (Element)i.next();
@@ -76,15 +86,13 @@
String title = RSSFeedParser.getChildElementTextByName( state,
"name" );
- System.out.println( " FIXME: (debug): " + title );
-
String seeAlso = getAttributeValue( state,
"seeAlso", NS.RDFS,
"resource", NS.RDF );
- String homepage = getAttributeValue( state,
- "homepage", NS.FOAF,
- "resource", NS.RDF );
+ homepage = getAttributeValue( state,
+ "homepage", NS.FOAF,
+ "resource", NS.RDF );
System.out.println( "seeAlso: " + seeAlso );
System.out.println( "homepage: " + homepage );
@@ -108,7 +116,6 @@
flistener.onSeeAlso( state,
seeAlso );
-
flistener.onSeeAlsoEnd();
}
@@ -119,7 +126,10 @@
flistener.onKnowsEnd();
}
-
+
+ if ( flistener != null )
+ flistener.onPersonEnd();
+
listener.finished();
} catch ( Throwable t ) { throw new FeedParserException( t ); }
1.8 +8 -6
jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/FeedParser.java
Index: FeedParser.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/FeedParser.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FeedParser.java 22 Aug 2004 11:28:04 -0000 1.7
+++ FeedParser.java 27 Aug 2004 18:07:01 -0000 1.8
@@ -73,14 +73,16 @@
if ( encoding.equalsIgnoreCase( "UTF-8" ) ) {
String result = XMLCleanser.cleanse( bytes, encoding );
- is = new ByteArrayInputStream( result.getBytes() );
+ bytes = result.getBytes();
- } else {
+ }
- //use the original bytes to build the DOM
- is = new ByteArrayInputStream( bytes );
- }
+ //remove prefix whitespace, intern HTML entities, etc.
+ bytes = FeedFilter.parse( bytes );
+ //build an input stream from the our bytes for parsing...
+ is = new ByteArrayInputStream( bytes );
+
//OK. Now we have the right InputStream so we should build our DOM
//and exec.
DOMBuilder builder = new DOMBuilder();
1.7 +28 -19
jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/impl/DebugFeedParserListener.java
Index: DebugFeedParserListener.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/impl/DebugFeedParserListener.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DebugFeedParserListener.java 18 Aug 2004 18:23:01 -0000 1.6
+++ DebugFeedParserListener.java 27 Aug 2004 18:07:01 -0000 1.7
@@ -18,8 +18,11 @@
import org.apache.commons.feedparser.*;
import org.jdom.*;
+
import java.util.Date;
+import java.io.*;
+
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton (burtonator)</a>
@@ -31,13 +34,19 @@
FeedDirectoryParserListener,
MetaFeedParserListener {
+ PrintStream out = System.out;
+
+ public DebugFeedParserListener( PrintStream out ) {
+ this.out = out;
+ }
+
/**
* Called prior to event parsing to signal the parsing of a new feed.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a>
*/
public void init() {
- System.out.println( "debug: init()" );
+ out.println( "debug: init()" );
}
public void setContext( Object context ) {}
@@ -52,16 +61,16 @@
String link,
String description ) {
- System.out.println( "debug: onChannel" );
- System.out.println( "\ttitle : " + title );
- System.out.println( "\tlink : '" + link + "'" );
- System.out.println( "\tdescription : " + description );
+ out.println( "debug: onChannel" );
+ out.println( "\ttitle : " + title );
+ out.println( "\tlink : '" + link + "'" );
+ out.println( "\tdescription : " + description );
}
public void onChannelEnd() {
- System.out.println( "debug: onChannelEnd" );
+ out.println( "debug: onChannelEnd" );
}
@@ -75,12 +84,12 @@
String link,
String url ) {
- System.out.println( "debug: onImage" );
+ out.println( "debug: onImage" );
}
public void onImageEnd() {
- System.out.println( "debug: onImageEnd" );
+ out.println( "debug: onImageEnd" );
}
/**
@@ -94,16 +103,16 @@
String description,
String permalink ) {
- System.out.println( "debug: onItem" );
+ out.println( "debug: onItem" );
- System.out.println( "\ttitle : " + title );
- System.out.println( "\tlink : '" + link + "'" );
- System.out.println( "\tdescription : " + description );
+ out.println( "\ttitle : " + title );
+ out.println( "\tlink : '" + link + "'" );
+ out.println( "\tdescription : " + description );
}
public void onItemEnd() {
- System.out.println( "debug: onItemEnd" );
+ out.println( "debug: onItemEnd" );
}
/**
@@ -112,7 +121,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a>
*/
public void finished() {
- System.out.println( "debug: finished" );
+ out.println( "debug: finished" );
}
/**
@@ -124,7 +133,7 @@
public void onFolder( FeedParserState state,
String name ) throws FeedParserException {
- System.out.println( "debug: onFolder: " + name );
+ out.println( "debug: onFolder: " + name );
}
@@ -140,14 +149,14 @@
String value,
boolean isSummary ) throws FeedParserException {
- System.out.println( "onContent: " );
- System.out.println( value );
+ out.println( "onContent: " );
+ out.println( value );
}
public void onCreated( FeedParserState state, Date date ) throws
FeedParserException {
- System.out.println( "onCreated: " + date.toString() );
+ out.println( "onCreated: " + date.toString() );
}
1.9 +18 -0
jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/FeedReference.java
Index: FeedReference.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/locate/FeedReference.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FeedReference.java 11 Aug 2004 20:48:09 -0000 1.8
+++ FeedReference.java 27 Aug 2004 18:07:01 -0000 1.9
@@ -20,7 +20,25 @@
import java.util.*;
/**
+ * <p>
+ * A FeedReference is used within the RSS/Atom location facility to pass back
+ * metadata for feed discoveries.
*
+ * <p>
+ * Right now we pass back the URL to the feeds as the `resource' parameter. The
+ * media type (application/rss+xml, application/atom+xml, etc) as the type param
+ * (which is optional). We also pass back the `title' back if its specified
+ * within autodiscovery. This will be null if another discovery method is used.
+ *
+ * <p> Its important to realize that the media type is only given if we're 100%
+ * certain of the value. If we have to use probe discovery or link discovery it
+ * might not be possible to obtain the media type without antoher network
+ * request (via HTTP headers).
+ *
+ * <p> Note that internally (within the ProbeLocator) we don't use absolute
+ * resource URLs but use relative ones and use the media type as the default
+ * media type.
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a>
*/
public class FeedReference {
1.4 +8 -8
jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/test/TestFeedLocator.java
Index: TestFeedLocator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/feedparser/src/java/org/apache/commons/feedparser/test/TestFeedLocator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestFeedLocator.java 16 Aug 2004 23:17:44 -0000 1.3
+++ TestFeedLocator.java 27 Aug 2004 18:07:01 -0000 1.4
@@ -69,13 +69,13 @@
public void test1() throws Exception {
- doTest( "file:tests/locate1.html" );
- doTest( "file:tests/locate2.html" );
- doTest( "file:tests/locate3.html" );
- doTest( "file:tests/locate4.html" );
- doTest( "file:tests/locate5.html" );
- doTest( "file:tests/locate6.html" );
- doTest( "file:tests/locate7.html" );
+ doTest( "file:tests/locate/locate1.html" );
+ doTest( "file:tests/locate/locate2.html" );
+ doTest( "file:tests/locate/locate3.html" );
+ doTest( "file:tests/locate/locate4.html" );
+ doTest( "file:tests/locate/locate5.html" );
+ doTest( "file:tests/locate/locate6.html" );
+ doTest( "file:tests/locate/locate7.html" );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]