Skip to content

Commit 8649bd9

Browse files
author
pborissow
committed
Removed dependencies on javaxt-core
git-svn-id: svn://192.168.0.80/JavaXT/javaxt-rss@218 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent bb99a77 commit 8649bd9

File tree

4 files changed

+411
-173
lines changed

4 files changed

+411
-173
lines changed

src/javaxt/rss/Feed.java

Lines changed: 68 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package javaxt.rss;
2-
32
import org.w3c.dom.*;
4-
import javaxt.xml.DOM;
5-
//import javaxt.geospatial.geometry.Geometry;
6-
//import javaxt.geospatial.coordinate.Parser;
73

84
//******************************************************************************
95
//** RSS Feed
@@ -21,7 +17,7 @@ public class Feed {
2117
private java.net.URL link = null;
2218
private Object geometry = null;
2319

24-
private javaxt.utils.Date lastUpdate = null;
20+
private java.util.Date lastUpdate = null;
2521
private Integer interval = null;
2622

2723
private Item[] Items = null;
@@ -33,82 +29,75 @@ public class Feed {
3329
/** Creates a new instance of Feed */
3430

3531
protected Feed(org.w3c.dom.Node node) {
36-
java.util.Vector vec = new java.util.Vector();
32+
java.util.ArrayList<Item> items = new java.util.ArrayList<Item>();
3733
NodeList nodeList = node.getChildNodes();
3834
for (int i=0; i<nodeList.getLength(); i++){
39-
node = nodeList.item(i);
40-
String nodeName = node.getNodeName().toLowerCase();
41-
String nodeValue = DOM.getNodeValue(node);
42-
//System.out.println(nodeName + ": " + nodeValue);
43-
if (nodeName.equals("title")) title = nodeValue;
44-
if (nodeName.equals("description") || nodeName.equals("subtitle")){
45-
description = nodeValue;
46-
}
47-
48-
49-
//Parse Location Information (GeoRSS)
50-
if (nodeName.equals("where") || nodeName.equals("georss:where")){
51-
NodeList nodes = node.getChildNodes();
52-
for (int j=0; j<nodes.getLength(); j++){
53-
if (nodes.item(j).getNodeType()==1){
54-
if (Item.isGeometryNode(nodes.item(j).getNodeName().toLowerCase())){
55-
geometry = Item.getGeometry(DOM.getNodeValue(nodes.item(j)).trim());
56-
if (geometry!=null) break;
57-
}
58-
}
59-
}
60-
}
61-
if (Item.isGeometryNode(nodeName)){
62-
geometry = Item.getGeometry(nodeValue);
63-
}
64-
65-
66-
if (nodeName.equals("link")){
67-
String url = nodeValue.trim();
68-
if (url.length()==0){
69-
//get href attribute
70-
}
71-
try{
72-
link = new java.net.URL(url);
73-
}
74-
catch(Exception e){}
75-
}
76-
77-
78-
79-
if (nodeName.equals("item") || nodeName.equals("entry")){
80-
vec.add(new Item(node));
81-
}
82-
83-
if (nodeName.equalsIgnoreCase("lastBuildDate")){
84-
if (nodeValue!=null){
85-
try{
86-
lastUpdate = new javaxt.utils.Date(nodeValue);
87-
}
88-
catch(java.text.ParseException e){
89-
lastUpdate = null;
90-
}
91-
}
92-
}
93-
94-
if (nodeName.equals("ttl")){
95-
try{
96-
interval = javaxt.utils.string.toInt(nodeValue);
97-
}
98-
catch(Exception e){
99-
}
100-
}
101-
102-
}
103-
104-
105-
//Convert Vector to Array
106-
Object[] arr = vec.toArray();
107-
Items = new Item[arr.length];
108-
for (int i=0; i<Items.length; i++){
109-
Items[i] = (Item) arr[i];
35+
node = nodeList.item(i);
36+
if (node.getNodeType()==1){
37+
String nodeName = node.getNodeName().toLowerCase();
38+
String nodeValue = Parser.getNodeValue(node).trim();
39+
if (nodeName.equals("title")) title = nodeValue;
40+
if (nodeName.equals("description") || nodeName.equals("subtitle")){
41+
description = nodeValue;
42+
}
43+
44+
45+
//Parse Location Information (GeoRSS)
46+
if (nodeName.equals("where") || nodeName.equals("georss:where")){
47+
NodeList nodes = node.getChildNodes();
48+
for (int j=0; j<nodes.getLength(); j++){
49+
if (nodes.item(j).getNodeType()==1){
50+
if (Item.isGeometryNode(nodes.item(j).getNodeName().toLowerCase())){
51+
geometry = Item.getGeometry(Parser.getNodeValue(nodes.item(j)).trim());
52+
if (geometry!=null) break;
53+
}
54+
}
55+
}
56+
}
57+
if (Item.isGeometryNode(nodeName)){
58+
geometry = Item.getGeometry(nodeValue);
59+
}
60+
61+
62+
if (nodeName.equals("link")){
63+
String url = nodeValue.trim();
64+
if (url.length()==0){
65+
//get href attribute
66+
}
67+
try{
68+
link = new java.net.URL(url);
69+
}
70+
catch(Exception e){}
71+
}
72+
73+
74+
75+
if (nodeName.equals("item") || nodeName.equals("entry")){
76+
items.add(new Item(node));
77+
}
78+
79+
if (nodeName.equalsIgnoreCase("lastBuildDate")){
80+
if (nodeValue!=null){
81+
try{
82+
lastUpdate = Parser.getDate(nodeValue);
83+
}
84+
catch(java.text.ParseException e){
85+
lastUpdate = null;
86+
}
87+
}
88+
}
89+
90+
if (nodeName.equals("ttl")){
91+
try{
92+
interval = Integer.parseInt(nodeValue);
93+
}
94+
catch(Exception e){
95+
}
96+
}
97+
}
11098
}
111-
99+
100+
this.Items = items.toArray(new Item[items.size()]);
112101
}
113102

114103
public String getTitle(){ return title; }
@@ -117,7 +106,7 @@ protected Feed(org.w3c.dom.Node node) {
117106
public Item[] getItems(){ return Items; }
118107
public Object getLocation(){ return geometry; }
119108

120-
public javaxt.utils.Date getLastUpdate(){
109+
public java.util.Date getLastUpdate(){
121110
return lastUpdate;
122111
}
123112

src/javaxt/rss/Item.java

Lines changed: 65 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package javaxt.rss;
22
import org.w3c.dom.*;
3-
import javaxt.xml.DOM;
4-
//import javaxt.geospatial.geometry.Geometry;
5-
//import javaxt.geospatial.coordinate.Parser;
63

74
//******************************************************************************
85
//** RSS Item
@@ -34,66 +31,68 @@ public class Item {
3431
protected Item(org.w3c.dom.Node node) {
3532
nodeList = node.getChildNodes();
3633
for (int i=0; i<nodeList.getLength(); i++){
37-
node = nodeList.item(i);
38-
String nodeName = node.getNodeName().toLowerCase();
39-
String nodeValue = DOM.getNodeValue(node).trim();
40-
if (nodeName.equals("title")) title = nodeValue;
41-
42-
//Parse Description
43-
if (nodeName.equals("description") || nodeName.equals("subtitle")){
44-
if (description==null || description.length()==0){
45-
description = nodeValue;
46-
}
47-
}
48-
49-
//Parse Link
50-
if (nodeName.equals("link")){
51-
String url = nodeValue;
52-
if (url.length()==0){
53-
//get href attribute
54-
url = DOM.getAttributeValue(node,"href").trim();
55-
}
56-
if (url.length()>0){
57-
try{ link = new java.net.URL(url); }
58-
catch(Exception e){}
59-
}
60-
}
61-
62-
//Parse FeedBurner Link
63-
if (nodeName.equals("feedburner:origLink")){
64-
String url = nodeValue.trim();
65-
if (url.length()>0){
66-
try{ origLink = new java.net.URL(url); }
67-
catch(Exception e){}
68-
}
69-
}
70-
71-
if (nodeName.equals("author")) author = nodeValue;
72-
if (nodeName.endsWith("creator")) creator = nodeValue;
73-
if (nodeName.equalsIgnoreCase("pubDate")) pubDate = nodeValue;
74-
if (nodeName.equalsIgnoreCase("dc:date")) dcDate = nodeValue;
75-
76-
77-
//Parse Location Information (GeoRSS)
78-
if (nodeName.equals("where") || nodeName.equals("georss:where")){
79-
NodeList nodes = node.getChildNodes();
80-
for (int j=0; j<nodes.getLength(); j++){
81-
if (nodes.item(j).getNodeType()==1){
82-
if (isGeometryNode(nodes.item(j).getNodeName().toLowerCase())){
83-
geometry = getGeometry(DOM.getNodeValue(nodes.item(j)).trim());
84-
if (geometry!=null) break;
85-
}
86-
}
87-
}
88-
}
89-
if (isGeometryNode(nodeName)){
90-
geometry = getGeometry(nodeValue);
91-
}
92-
93-
94-
if (nodeName.startsWith("media:")){
95-
media.add(new Media(node));
96-
}
34+
node = nodeList.item(i);
35+
if (node.getNodeType()==1){
36+
String nodeName = node.getNodeName().toLowerCase();
37+
String nodeValue = Parser.getNodeValue(node).trim();
38+
if (nodeName.equals("title")) title = nodeValue;
39+
40+
//Parse Description
41+
if (nodeName.equals("description") || nodeName.equals("subtitle")){
42+
if (description==null || description.length()==0){
43+
description = nodeValue;
44+
}
45+
}
46+
47+
//Parse Link
48+
if (nodeName.equals("link")){
49+
String url = nodeValue;
50+
if (url.length()==0){
51+
//get href attribute
52+
url = Parser.getAttributeValue(node,"href").trim();
53+
}
54+
if (url.length()>0){
55+
try{ link = new java.net.URL(url); }
56+
catch(Exception e){}
57+
}
58+
}
59+
60+
//Parse FeedBurner Link
61+
if (nodeName.equals("feedburner:origLink")){
62+
String url = nodeValue.trim();
63+
if (url.length()>0){
64+
try{ origLink = new java.net.URL(url); }
65+
catch(Exception e){}
66+
}
67+
}
68+
69+
if (nodeName.equals("author")) author = nodeValue;
70+
if (nodeName.endsWith("creator")) creator = nodeValue;
71+
if (nodeName.equalsIgnoreCase("pubDate")) pubDate = nodeValue;
72+
if (nodeName.equalsIgnoreCase("dc:date")) dcDate = nodeValue;
73+
74+
75+
//Parse Location Information (GeoRSS)
76+
if (nodeName.equals("where") || nodeName.equals("georss:where")){
77+
NodeList nodes = node.getChildNodes();
78+
for (int j=0; j<nodes.getLength(); j++){
79+
if (nodes.item(j).getNodeType()==1){
80+
if (isGeometryNode(nodes.item(j).getNodeName().toLowerCase())){
81+
geometry = getGeometry(Parser.getNodeValue(nodes.item(j)).trim());
82+
if (geometry!=null) break;
83+
}
84+
}
85+
}
86+
}
87+
if (isGeometryNode(nodeName)){
88+
geometry = getGeometry(nodeValue);
89+
}
90+
91+
92+
if (nodeName.startsWith("media:")){
93+
media.add(new Media(node));
94+
}
95+
}
9796
}
9897
}
9998

@@ -161,12 +160,12 @@ public java.net.URL getLink(){
161160
/** Return the date/time stamp associated with the current entry. Uses the
162161
* pubDate if it exists. Otherwise, returns dc:date
163162
*/
164-
public javaxt.utils.Date getDate(){
163+
public java.util.Date getDate(){
165164
String date = pubDate;
166165
if (date.length()==0) date = dcDate;
167166
if (date.length()>0){
168167
try{
169-
return new javaxt.utils.Date(date);
168+
return Parser.getDate(date);
170169
}
171170
catch(java.text.ParseException e){
172171
return null;
@@ -223,4 +222,4 @@ public String toString(){
223222
return out.toString();
224223
}
225224

226-
}
225+
}

src/javaxt/rss/Media.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package javaxt.rss;
2-
import javaxt.xml.DOM;
32

43
//******************************************************************************
54
//** Media Class
@@ -24,10 +23,10 @@ public class Media {
2423
/** Creates a new instance of Media. */
2524

2625
protected Media(org.w3c.dom.Node node) {
27-
type = DOM.getAttributeValue(node,"type").trim();
26+
type = Parser.getAttributeValue(node,"type").trim();
2827

2928
//Parse url
30-
String link = DOM.getAttributeValue(node,"url").trim();
29+
String link = Parser.getAttributeValue(node,"url").trim();
3130
if (link.length()>0){
3231
try{ url = new java.net.URL(link); }
3332
catch(Exception e){}
@@ -39,10 +38,10 @@ protected Media(org.w3c.dom.Node node) {
3938
if (node.getNodeType()==1){
4039
String nodeName = node.getNodeName();
4140
if (nodeName.endsWith("credit")){
42-
credit = DOM.getNodeValue(node).trim();
41+
credit = Parser.getNodeValue(node).trim();
4342
}
4443
else if (nodeName.endsWith("description")){
45-
description = DOM.getNodeValue(node).trim();
44+
description = Parser.getNodeValue(node).trim();
4645
}
4746
}
4847
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy