Compare commits

...

1 commit

Author SHA1 Message Date
Patrick Gotthard
c447eda87b #244 Update iTunes module 2016-02-20 18:35:57 +01:00
11 changed files with 1719 additions and 1665 deletions

View file

@ -1,273 +1,268 @@
/* /*
* AbstractITunesObject.java * AbstractITunesObject.java
* *
* Created on August 1, 2005, 7:37 PM * Created on August 1, 2005, 7:37 PM
* *
* This library is provided under dual licenses. * This library is provided under dual licenses.
* You may choose the terms of the Lesser General Public License or the Apache * You may choose the terms of the Lesser General Public License or the Apache
* License at your discretion. * License at your discretion.
* *
* Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
* *
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
*/ */
package com.rometools.modules.itunes; package com.rometools.modules.itunes;
import java.net.URL; import java.net.URL;
import java.util.Arrays;
/**
* This is an abstract object that implements the attributes common across Feeds or Items in an /**
* iTunes compatible RSS feed. * This is an abstract object that implements the attributes common across Feeds or Items in an
* * iTunes compatible RSS feed.
* @version $Revision: 1.4 $ *
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @version $Revision: 1.4 $
*/ * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
public abstract class AbstractITunesObject implements ITunes, java.lang.Cloneable { */
/** public abstract class AbstractITunesObject implements ITunes, java.lang.Cloneable {
* /**
*/ *
private static final long serialVersionUID = 1L; */
private static final long serialVersionUID = 1L;
/**
* The URI that iTunes used for its custom tags. /**
* <p> * The URI that iTunes used for its custom tags.
* What is up with using a versioned DTD anyway? * <p>
* </p> * What is up with using a versioned DTD anyway?
* \ * </p>
*/ * \
public static final String URI = "http://www.itunes.com/dtds/podcast-1.0.dtd"; */
public static final String URI = "http://www.itunes.com/dtds/podcast-1.0.dtd";
/**
* The RDF namespace URI. /**
*/ * The RDF namespace URI.
public static final String RDF_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; */
public static final String RDF_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
/**
* A default prefix to use for itunes tags. /**
*/ * A default prefix to use for itunes tags.
public static final String PREFIX = "itunes"; */
private String author; public static final String PREFIX = "itunes";
private boolean block; private String author;
private boolean explicit; private boolean block;
private URL image; private Explicit explicit;
private String[] keywords; private URL image;
private String subtitle; private String[] keywords;
private String summary; private String subtitle;
private String summary;
/**
* Defined by the ROME API /**
* * Defined by the ROME API
* @return Class of the Interface for this module. *
*/ * @return Class of the Interface for this module.
@Override */
public Class<? extends AbstractITunesObject> getInterface() { @Override
return getClass(); public Class<? extends AbstractITunesObject> getInterface() {
} return getClass();
}
/**
* The URI this module implements /**
* * The URI this module implements
* @return "http://www.itunes.com/dtds/podcast-1.0.dtd" *
*/ * @return "http://www.itunes.com/dtds/podcast-1.0.dtd"
@Override */
public String getUri() { @Override
return AbstractITunesObject.URI; public String getUri() {
} return AbstractITunesObject.URI;
}
/**
* Required by the ROME API /**
* * Required by the ROME API
* @return A clone of this module object *
*/ * @return A clone of this module object
@Override */
public abstract Object clone(); @Override
public abstract Object clone();
/**
* Returns the author string for this feed or entry /**
* * Returns the author string for this feed or entry
* @return Returns the author string for this feed or entry *
*/ * @return Returns the author string for this feed or entry
@Override */
public String getAuthor() { @Override
return author; public String getAuthor() {
} return author;
}
/**
* Sets the author string for this feed or entry /**
* * Sets the author string for this feed or entry
* @param author Sets the author string for this feed or entry *
*/ * @param author Sets the author string for this feed or entry
@Override */
public void setAuthor(final String author) { @Override
this.author = author; public void setAuthor(final String author) {
} this.author = author;
}
/**
* Boolean as to whether to block this feed or entry /**
* * Boolean as to whether to block this feed or entry
* @return Boolean as to whether to block this feed or entry *
*/ * @return Boolean as to whether to block this feed or entry
@Override */
public boolean getBlock() { @Override
return block; public boolean getBlock() {
} return block;
}
/**
* Boolean as to whether to block this feed or entry /**
* * Boolean as to whether to block this feed or entry
* @param block Boolean as to whether to block this feed or entry *
*/ * @param block Boolean as to whether to block this feed or entry
@Override */
public void setBlock(final boolean block) { @Override
this.block = block; public void setBlock(final boolean block) {
} this.block = block;
}
/**
* Boolean as to whether this feed or entry contains adult content /**
* * Boolean as to whether this feed or entry contains adult content
* @return Boolean as to whether this feed or entry contains adult content *
*/ * @return Boolean as to whether this feed or entry contains adult content
@Override */
public boolean getExplicit() { @Override
return explicit; public Explicit getExplicit() {
} return explicit;
}
/**
* Boolean as to whether this feed or entry contains adult content /**
* * Boolean as to whether this feed or entry contains adult content
* @param explicit Boolean as to whether this feed or entry contains adult content *
*/ * @param explicit Boolean as to whether this feed or entry contains adult content
@Override */
public void setExplicit(final boolean explicit) { @Override
this.explicit = explicit; public void setExplicit(final Explicit explicit) {
} this.explicit = explicit;
}
@Override
public URL getImage() { @Override
return image; public URL getImage() {
} return image;
}
@Override
public void setImage(final URL image) { @Override
this.image = image; public void setImage(final URL image) {
} this.image = image;
}
/**
* A list of keywords for this feed or entry /**
* * A list of keywords for this feed or entry
* Must not contain spaces *
* * Must not contain spaces
* @return A list of keywords for this feed or entry *
*/ * @return A list of keywords for this feed or entry
@Override */
public String[] getKeywords() { @Override
return keywords == null ? new String[0] : keywords; public String[] getKeywords() {
} return keywords == null ? new String[0] : keywords;
}
/**
* A list of keywords for this feed or entry /**
* * A list of keywords for this feed or entry
* Must not contain spaces *
* * Must not contain spaces
* @param keywords A list of keywords for this feed or enty *
*/ * @param keywords A list of keywords for this feed or enty
@Override */
public void setKeywords(final String[] keywords) { @Override
this.keywords = keywords; public void setKeywords(final String[] keywords) {
} this.keywords = keywords;
}
/**
* A subtitle for this feed or entry /**
* * A subtitle for this feed or entry
* @return A subtitle for this feed or entry *
*/ * @return A subtitle for this feed or entry
@Override */
public String getSubtitle() { @Override
return subtitle; public String getSubtitle() {
} return subtitle;
}
/**
* A subtitle for this feed or entry /**
* * A subtitle for this feed or entry
* @param subtitle A subtitle for this feed or entry *
*/ * @param subtitle A subtitle for this feed or entry
@Override */
public void setSubtitle(final String subtitle) { @Override
this.subtitle = subtitle; public void setSubtitle(final String subtitle) {
} this.subtitle = subtitle;
}
/**
* A subtitle for this feed or entry /**
* * A subtitle for this feed or entry
* @return A subtitle for this feed or entry *
*/ * @return A subtitle for this feed or entry
@Override */
public String getSummary() { @Override
return summary; public String getSummary() {
} return summary;
}
/**
* A subtitle for this feed or entry /**
* * A subtitle for this feed or entry
* @param summary A subtitle for this feed or entry *
*/ * @param summary A subtitle for this feed or entry
@Override */
public void setSummary(final String summary) { @Override
this.summary = summary; public void setSummary(final String summary) {
} this.summary = summary;
}
@Override
public String toString() { @Override
final StringBuffer sb = new StringBuffer("["); public String toString() {
sb.append(" Author: "); StringBuilder builder = new StringBuilder();
sb.append(getAuthor()); builder.append("AbstractITunesObject [author=");
sb.append(" Block: "); builder.append(author);
sb.append(getBlock()); builder.append(", block=");
sb.append(" Explicit: "); builder.append(block);
sb.append(getExplicit()); builder.append(", explicit=");
sb.append(" Image: "); builder.append(explicit);
sb.append(getImage()); builder.append(", image=");
sb.append(" Keywords: "); builder.append(image);
builder.append(", keywords=");
if (getKeywords() != null) { builder.append(Arrays.toString(keywords));
for (int i = 0; i < keywords.length; i++) { builder.append(", subtitle=");
sb.append("'" + getKeywords()[i] + "'"); builder.append(subtitle);
} builder.append(", summary=");
} builder.append(summary);
builder.append("]");
sb.append(" Subtitle: "); return builder.toString();
sb.append(getSubtitle()); }
sb.append(" Summary: ");
sb.append(getSummary()); }
sb.append("]");
return sb.toString();
}
}

View file

@ -1,76 +1,85 @@
/* /*
* EntryInformation.java * EntryInformation.java
* *
* Created on November 19, 2005, 10:56 PM * Created on November 19, 2005, 10:56 PM
* *
* This library is provided under dual licenses. * This library is provided under dual licenses.
* You may choose the terms of the Lesser General Public License or the Apache * You may choose the terms of the Lesser General Public License or the Apache
* License at your discretion. * License at your discretion.
* *
* Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
* *
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
*/ */
package com.rometools.modules.itunes; package com.rometools.modules.itunes;
import com.rometools.modules.itunes.types.Duration; import com.rometools.modules.itunes.types.Duration;
/** /**
* This class contains information for iTunes podcast feeds that exist at the Item level. * This class contains information for iTunes podcast feeds that exist at the Item level.
* *
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
* @version $Revision: 1.2 $ * @version $Revision: 1.2 $
* *
*/ */
public interface EntryInformation extends ITunes { public interface EntryInformation extends ITunes {
/** /**
* Returns the Duration object for this Item * marker for closed captioning support on video.
* *
* @return Returns the Duration object for this Item * @see http://www.apple.com/itunes/podcasts/specs.html#isClosedCaptioned
*/ */
public Duration getDuration(); enum ClosedCaptioned {
yes, no
/** }
* Sets the Duration object for this Item
* /**
* @param duration Sets the Duration object for this Item * Returns the Duration object for this Item
*/ *
public void setDuration(Duration duration); * @return Returns the Duration object for this Item
*/
public boolean getClosedCaptioned(); public Duration getDuration();
public void setClosedCaptioned(boolean closedCaptioned); /**
* Sets the Duration object for this Item
public Integer getOrder(); *
* @param duration Sets the Duration object for this Item
public void setOrder(Integer order); */
} public void setDuration(Duration duration);
public ClosedCaptioned getClosedCaptioned();
public void setClosedCaptioned(ClosedCaptioned closedCaptioned);
public Integer getOrder();
public void setOrder(Integer order);
}

View file

@ -1,178 +1,177 @@
/* /*
* EntryInformation.java * EntryInformation.java
* *
* Created on August 1, 2005, 7:37 PM * Created on August 1, 2005, 7:37 PM
* *
* This library is provided under dual licenses. * This library is provided under dual licenses.
* You may choose the terms of the Lesser General Public License or the Apache * You may choose the terms of the Lesser General Public License or the Apache
* License at your discretion. * License at your discretion.
* *
* Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
* *
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
*/ */
package com.rometools.modules.itunes; package com.rometools.modules.itunes;
import com.rometools.modules.itunes.types.Duration; import java.net.MalformedURLException;
import com.rometools.rome.feed.CopyFrom; import java.net.URL;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.net.MalformedURLException; import com.rometools.modules.itunes.types.Duration;
import java.net.URL; import com.rometools.rome.feed.CopyFrom;
/** /**
* This class contains information for iTunes podcast feeds that exist at the Item level. * This class contains information for iTunes podcast feeds that exist at the Item level.
* *
* @version $Revision: 1.2 $ * @version $Revision: 1.2 $
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class EntryInformationImpl extends AbstractITunesObject implements EntryInformation { public class EntryInformationImpl extends AbstractITunesObject implements EntryInformation {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(EntryInformationImpl.class); private static final Logger LOG = LoggerFactory.getLogger(EntryInformationImpl.class);
private Duration duration; private Duration duration;
private boolean closedCaptioned; private ClosedCaptioned closedCaptioned;
private Integer order; private Integer order;
/** /**
* Creates a new instance of EntryInformationImpl * Creates a new instance of EntryInformationImpl
*/ */
public EntryInformationImpl() { public EntryInformationImpl() {
} }
/** /**
* Returns the Duration object for this Item * Returns the Duration object for this Item
* *
* @return Returns the Duration object for this Item * @return Returns the Duration object for this Item
*/ */
@Override @Override
public Duration getDuration() { public Duration getDuration() {
return duration; return duration;
} }
/** /**
* Sets the Duration object for this Item * Sets the Duration object for this Item
* *
* @param duration Sets the Duration object for this Item * @param duration Sets the Duration object for this Item
*/ */
@Override @Override
public void setDuration(final Duration duration) { public void setDuration(final Duration duration) {
this.duration = duration; this.duration = duration;
} }
@Override @Override
public boolean getClosedCaptioned() { public ClosedCaptioned getClosedCaptioned() {
return closedCaptioned; return closedCaptioned;
} }
@Override @Override
public void setClosedCaptioned(boolean closedCaptioned) { public void setClosedCaptioned(final ClosedCaptioned closedCaptioned) {
this.closedCaptioned = closedCaptioned; this.closedCaptioned = closedCaptioned;
} }
@Override @Override
public Integer getOrder() { public Integer getOrder() {
return order; return order;
} }
@Override @Override
public void setOrder(Integer order) { public void setOrder(final Integer order) {
this.order = order; this.order = order;
} }
/** /**
* Defined by the ROME module API * Defined by the ROME module API
* *
* @param obj Object to copy from * @param obj Object to copy from
*/ */
@Override @Override
public void copyFrom(final CopyFrom obj) { public void copyFrom(final CopyFrom obj) {
final EntryInformationImpl info = (EntryInformationImpl) obj; final EntryInformationImpl info = (EntryInformationImpl) obj;
setAuthor(info.getAuthor()); setAuthor(info.getAuthor());
setBlock(info.getBlock()); setBlock(info.getBlock());
if (info.getDuration() != null) { if (info.getDuration() != null) {
setDuration(new Duration(info.getDuration().getMilliseconds())); setDuration(new Duration(info.getDuration().getMilliseconds()));
} }
setExplicit(info.getExplicit()); setExplicit(info.getExplicit());
try { try {
if (info.getImage() != null) { if (info.getImage() != null) {
setImage(new URL(info.getImage().toExternalForm())); setImage(new URL(info.getImage().toExternalForm()));
} }
} catch (final MalformedURLException e) { } catch (final MalformedURLException e) {
LOG.debug("Error copying URL:" + info.getImage(), e); LOG.debug("Error copying URL:" + info.getImage(), e);
} }
if (info.getKeywords() != null) { if (info.getKeywords() != null) {
setKeywords(info.getKeywords().clone()); setKeywords(info.getKeywords().clone());
} }
setSubtitle(info.getSubtitle()); setSubtitle(info.getSubtitle());
setSummary(info.getSummary()); setSummary(info.getSummary());
setClosedCaptioned(info.getClosedCaptioned()); setClosedCaptioned(info.getClosedCaptioned());
setOrder(info.getOrder()); setOrder(info.getOrder());
} }
/** /**
* Required by the ROME API * Required by the ROME API
* *
* @return A clone of this module object * @return A clone of this module object
*/ */
@Override @Override
public Object clone() { public Object clone() {
final EntryInformationImpl info = new EntryInformationImpl(); final EntryInformationImpl info = new EntryInformationImpl();
info.copyFrom(this); info.copyFrom(this);
return info; return info;
} }
@Override @Override
public String toString() { public String toString() {
final StringBuffer sb = new StringBuffer("["); StringBuilder builder = new StringBuilder();
sb.append(" duration: "); builder.append("EntryInformationImpl [duration=");
sb.append(getDuration()); builder.append(duration);
sb.append(" closedCaptioned: "); builder.append(", closedCaptioned=");
sb.append(getClosedCaptioned()); builder.append(closedCaptioned);
sb.append(" order: "); builder.append(", order=");
sb.append(getOrder()); builder.append(order);
sb.append("]"); builder.append("]");
sb.append(super.toString()); return builder.toString();
}
return sb.toString();
} }
}

View file

@ -55,50 +55,50 @@ public interface FeedInformation extends ITunes {
/** /**
* The parent categories for this feed * The parent categories for this feed
* *
* @return The parent categories for this feed * @return The parent categories for this feed
*/ */
public List<Category> getCategories(); public List<Category> getCategories();
/** /**
* The parent categories for this feed * The parent categories for this feed
* *
* @param categories The parent categories for this feed * @param categories The parent categories for this feed
*/ */
public void setCategories(List<Category> categories); public void setCategories(List<Category> categories);
public boolean getComplete(); public Boolean getComplete();
public void setComplete(boolean complete); public void setComplete(Boolean complete);
public String getNewFeedUrl(); public URL getNewFeedUrl();
public void setNewFeedUrl(String newFeedUrl); public void setNewFeedUrl(URL newFeedUrl);
/** /**
* Sets the owner email address for the feed. * Sets the owner email address for the feed.
* *
* @param ownerEmailAddress Sets the owner email address for the feed. * @param ownerEmailAddress Sets the owner email address for the feed.
*/ */
public void setOwnerEmailAddress(String ownerEmailAddress); public void setOwnerEmailAddress(String ownerEmailAddress);
/** /**
* Returns the owner email address for the feed. * Returns the owner email address for the feed.
* *
* @return Returns the owner email address for the feed. * @return Returns the owner email address for the feed.
*/ */
public String getOwnerEmailAddress(); public String getOwnerEmailAddress();
/** /**
* Sets the owner name for the feed * Sets the owner name for the feed
* *
* @param ownerName Sets the owner name for the feed * @param ownerName Sets the owner name for the feed
*/ */
public void setOwnerName(String ownerName); public void setOwnerName(String ownerName);
/** /**
* Returns the owner name for the feed * Returns the owner name for the feed
* *
* @return Returns the owner name for the feed * @return Returns the owner name for the feed
*/ */
public String getOwnerName(); public String getOwnerName();

View file

@ -1,228 +1,227 @@
/* /*
* FeedInformation.java * FeedInformation.java
* *
* Created on August 1, 2005, 7:11 PM * Created on August 1, 2005, 7:11 PM
* *
* *
* This library is provided under dual licenses. * This library is provided under dual licenses.
* You may choose the terms of the Lesser General Public License or the Apache * You may choose the terms of the Lesser General Public License or the Apache
* License at your discretion. * License at your discretion.
* *
* Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
* *
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
*/ */
package com.rometools.modules.itunes; package com.rometools.modules.itunes;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.rometools.modules.itunes.types.Category; import com.rometools.modules.itunes.types.Category;
import com.rometools.rome.feed.CopyFrom; import com.rometools.rome.feed.CopyFrom;
/** /**
* This class contains information for iTunes podcast feeds that exist at the Channel level. * This class contains information for iTunes podcast feeds that exist at the Channel level.
* *
* @version $Revision: 1.2 $ * @version $Revision: 1.2 $
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class FeedInformationImpl extends AbstractITunesObject implements FeedInformation { public class FeedInformationImpl extends AbstractITunesObject implements FeedInformation {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(FeedInformationImpl.class); private static final Logger LOG = LoggerFactory.getLogger(FeedInformationImpl.class);
private String ownerName; private String ownerName;
private String ownerEmailAddress; private String ownerEmailAddress;
private List<Category> categories; private List<Category> categories;
private boolean complete; private Boolean complete;
private String newFeedUrl; private URL newFeedUrl;
/** /**
* Creates a new instance of FeedInformationImpl * Creates a new instance of FeedInformationImpl
*/ */
public FeedInformationImpl() { public FeedInformationImpl() {
} }
/** /**
* The parent categories for this feed * The parent categories for this feed
* *
* @return The parent categories for this feed * @return The parent categories for this feed
*/ */
@Override @Override
public List<Category> getCategories() { public List<Category> getCategories() {
return categories == null ? (categories = new ArrayList<Category>()) : categories; return categories == null ? (categories = new ArrayList<Category>()) : categories;
} }
/** /**
* The parent categories for this feed * The parent categories for this feed
* *
* @param categories The parent categories for this feed * @param categories The parent categories for this feed
*/ */
@Override @Override
public void setCategories(final List<Category> categories) { public void setCategories(final List<Category> categories) {
this.categories = categories; this.categories = categories;
} }
@Override @Override
public boolean getComplete() { public Boolean getComplete() {
return complete; return complete;
} }
@Override @Override
public void setComplete(boolean complete) { public void setComplete(final Boolean complete) {
this.complete = complete; this.complete = complete;
} }
@Override @Override
public String getNewFeedUrl() { public URL getNewFeedUrl() {
return newFeedUrl; return newFeedUrl;
} }
@Override @Override
public void setNewFeedUrl(String newFeedUrl) { public void setNewFeedUrl(final URL newFeedUrl) {
this.newFeedUrl = newFeedUrl; this.newFeedUrl = newFeedUrl;
} }
/** /**
* Returns the owner name for the feed * Returns the owner name for the feed
* *
* @return Returns the owner name for the feed * @return Returns the owner name for the feed
*/ */
@Override @Override
public String getOwnerName() { public String getOwnerName() {
return ownerName; return ownerName;
} }
/** /**
* Sets the owner name for the feed * Sets the owner name for the feed
* *
* @param ownerName Sets the owner name for the feed * @param ownerName Sets the owner name for the feed
*/ */
@Override @Override
public void setOwnerName(final String ownerName) { public void setOwnerName(final String ownerName) {
this.ownerName = ownerName; this.ownerName = ownerName;
} }
/** /**
* Returns the owner email address for the feed. * Returns the owner email address for the feed.
* *
* @return Returns the owner email address for the feed. * @return Returns the owner email address for the feed.
*/ */
@Override @Override
public String getOwnerEmailAddress() { public String getOwnerEmailAddress() {
return ownerEmailAddress; return ownerEmailAddress;
} }
/** /**
* Sets the owner email address for the feed. * Sets the owner email address for the feed.
* *
* @param ownerEmailAddress Sets the owner email address for the feed. * @param ownerEmailAddress Sets the owner email address for the feed.
*/ */
@Override @Override
public void setOwnerEmailAddress(final String ownerEmailAddress) { public void setOwnerEmailAddress(final String ownerEmailAddress) {
this.ownerEmailAddress = ownerEmailAddress; this.ownerEmailAddress = ownerEmailAddress;
} }
/** /**
* Required by the ROME API * Required by the ROME API
* *
* @param obj object to copy property values from * @param obj object to copy property values from
*/ */
@Override @Override
public void copyFrom(final CopyFrom obj) { public void copyFrom(final CopyFrom obj) {
final FeedInformationImpl info = (FeedInformationImpl) obj; final FeedInformationImpl info = (FeedInformationImpl) obj;
setAuthor(info.getAuthor()); setAuthor(info.getAuthor());
setBlock(info.getBlock()); setBlock(info.getBlock());
getCategories().clear(); getCategories().clear();
if (info.getCategories() != null) { if (info.getCategories() != null) {
getCategories().addAll(info.getCategories()); getCategories().addAll(info.getCategories());
} }
setComplete(info.getComplete()); setComplete(info.getComplete());
setNewFeedUrl(info.getNewFeedUrl()); setNewFeedUrl(info.getNewFeedUrl());
setExplicit(info.getExplicit()); setExplicit(info.getExplicit());
try { try {
if (info.getImage() != null) { if (info.getImage() != null) {
setImage(new URL(info.getImage().toExternalForm())); setImage(new URL(info.getImage().toExternalForm()));
} }
} catch (final MalformedURLException e) { } catch (final MalformedURLException e) {
LOG.debug("Error copying URL:" + info.getImage(), e); LOG.debug("Error copying URL:" + info.getImage(), e);
} }
if (info.getKeywords() != null) { if (info.getKeywords() != null) {
setKeywords(info.getKeywords().clone()); setKeywords(info.getKeywords().clone());
} }
setOwnerEmailAddress(info.getOwnerEmailAddress()); setOwnerEmailAddress(info.getOwnerEmailAddress());
setOwnerName(info.getOwnerName()); setOwnerName(info.getOwnerName());
setSubtitle(info.getSubtitle()); setSubtitle(info.getSubtitle());
setSummary(info.getSummary()); setSummary(info.getSummary());
} }
/** /**
* Returns a copy of this FeedInformationImpl object * Returns a copy of this FeedInformationImpl object
* *
* @return Returns a copy of this FeedInformationImpl object * @return Returns a copy of this FeedInformationImpl object
*/ */
@Override @Override
public Object clone() { public Object clone() {
final FeedInformationImpl info = new FeedInformationImpl(); final FeedInformationImpl info = new FeedInformationImpl();
info.copyFrom(this); info.copyFrom(this);
return info; return info;
} }
@Override @Override
public String toString() { public String toString() {
final StringBuffer sb = new StringBuffer("["); StringBuilder builder = new StringBuilder();
sb.append(" email: "); builder.append("FeedInformationImpl [ownerName=");
sb.append(getOwnerEmailAddress()); builder.append(ownerName);
sb.append(" name: "); builder.append(", ownerEmailAddress=");
sb.append(getOwnerName()); builder.append(ownerEmailAddress);
sb.append(" categories: "); builder.append(", categories=");
sb.append(getCategories()); builder.append(categories);
sb.append(" complete: "); builder.append(", complete=");
sb.append(getComplete()); builder.append(complete);
sb.append(" newFeedUrl: "); builder.append(", newFeedUrl=");
sb.append(getNewFeedUrl()); builder.append(newFeedUrl);
sb.append("]"); builder.append("]");
sb.append(super.toString()); return builder.toString();
}
return sb.toString();
} }
}

View file

@ -1,149 +1,158 @@
/* /*
* ITunes.java * ITunes.java
* *
* Created on November 19, 2005, 10:58 PM * Created on November 19, 2005, 10:58 PM
* *
* This library is provided under dual licenses. * This library is provided under dual licenses.
* You may choose the terms of the Lesser General Public License or the Apache * You may choose the terms of the Lesser General Public License or the Apache
* License at your discretion. * License at your discretion.
* *
* Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
* *
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.rometools.modules.itunes; package com.rometools.modules.itunes;
import com.rometools.rome.feed.module.Module; import com.rometools.rome.feed.module.Module;
import java.net.URL; import java.net.URL;
/** /**
* This interface contains the methods common to all iTunes module points. * This interface contains the methods common to all iTunes module points.
* *
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
* @version $Revision: 1.3 $ * @version $Revision: 1.3 $
*/ */
public interface ITunes extends Module { public interface ITunes extends Module {
public static final String URI = AbstractITunesObject.URI; /**
* Marker for podcasts containing explicit material.
/** *
* Returns the author string for this feed or entry * @see http://www.apple.com/itunes/podcasts/specs.html#explicit
* */
* @return Returns the author string for this feed or entry enum Explicit {
*/ yes, no, clean
public String getAuthor(); }
/** public static final String URI = AbstractITunesObject.URI;
* Sets the author string for this feed or entry
* /**
* @param author Sets the author string for this feed or entry * Returns the author string for this feed or entry
*/ *
public void setAuthor(String author); * @return Returns the author string for this feed or entry
*/
/** public String getAuthor();
* Boolean as to whether to block this feed or entry
* /**
* @return Boolean as to whether to block this feed or entry * Sets the author string for this feed or entry
*/ *
public boolean getBlock(); * @param author Sets the author string for this feed or entry
*/
/** public void setAuthor(String author);
* Boolean as to whether to block this feed or entry
* /**
* @param block Boolean as to whether to block this feed or entry * Boolean as to whether to block this feed or entry
*/ *
public void setBlock(boolean block); * @return Boolean as to whether to block this feed or entry
*/
/** public boolean getBlock();
* Boolean as to whether this feed or entry contains adult content
* /**
* @return Boolean as to whether this feed or entry contains adult content * Boolean as to whether to block this feed or entry
*/ *
public boolean getExplicit(); * @param block Boolean as to whether to block this feed or entry
*/
/** public void setBlock(boolean block);
* Boolean as to whether this feed or entry contains adult content
* /**
* @param explicit Boolean as to whether this feed or entry contains adult content * whether this feed or entry contains adult content or not
*/ *
public void setExplicit(boolean explicit); * @return explicit state as to whether this feed or entry contains adult content
*/
public URL getImage(); public Explicit getExplicit();
public void setImage(URL image); /**
* whether this feed or entry contains adult content or not
/** *
* A list of keywords for this feed or entry * @param explicit explicit state as to whether this feed or entry contains adult content
* */
* Must not contain spaces public void setExplicit(Explicit explicit);
*
* @return A list of keywords for this feed or entry public URL getImage();
*/
public String[] getKeywords(); public void setImage(URL image);
/** /**
* A list of keywords for this feed or entry * A list of keywords for this feed or entry
* *
* Must not contain spaces * Must not contain spaces
* *
* @param keywords A list of keywords for this feed or enty * @return A list of keywords for this feed or entry
*/ */
public void setKeywords(String[] keywords); public String[] getKeywords();
/** /**
* A subtitle for this feed or entry * A list of keywords for this feed or entry
* *
* @return A subtitle for this feed or entry * Must not contain spaces
*/ *
public String getSubtitle(); * @param keywords A list of keywords for this feed or enty
*/
/** public void setKeywords(String[] keywords);
* A subtitle for this feed or entry
* /**
* @param subtitle A subtitle for this feed or entry * A subtitle for this feed or entry
*/ *
public void setSubtitle(String subtitle); * @return A subtitle for this feed or entry
*/
/** public String getSubtitle();
* A subtitle for this feed or entry
* /**
* @return A subtitle for this feed or entry * A subtitle for this feed or entry
*/ *
public String getSummary(); * @param subtitle A subtitle for this feed or entry
*/
/** public void setSubtitle(String subtitle);
* A subtitle for this feed or entry
* /**
* @param summary A subtitle for this feed or entry * A subtitle for this feed or entry
*/ *
public void setSummary(String summary); * @return A subtitle for this feed or entry
*/
} public String getSummary();
/**
* A subtitle for this feed or entry
*
* @param summary A subtitle for this feed or entry
*/
public void setSummary(String summary);
}

View file

@ -1,207 +1,209 @@
/* /*
* ITunesGenerator.java * ITunesGenerator.java
* *
* Created on August 1, 2005, 10:44 PM * Created on August 1, 2005, 10:44 PM
* *
* This library is provided under dual licenses. * This library is provided under dual licenses.
* You may choose the terms of the Lesser General Public License or the Apache * You may choose the terms of the Lesser General Public License or the Apache
* License at your discretion. * License at your discretion.
* *
* Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
* *
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
*/ */
package com.rometools.modules.itunes.io; package com.rometools.modules.itunes.io;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace; import org.jdom2.Namespace;
import com.rometools.modules.itunes.AbstractITunesObject; import com.rometools.modules.itunes.AbstractITunesObject;
import com.rometools.modules.itunes.EntryInformationImpl; import com.rometools.modules.itunes.EntryInformationImpl;
import com.rometools.modules.itunes.FeedInformationImpl; import com.rometools.modules.itunes.FeedInformationImpl;
import com.rometools.modules.itunes.types.Category; import com.rometools.modules.itunes.types.Category;
import com.rometools.rome.feed.module.Module; import com.rometools.rome.feed.module.Module;
import com.rometools.rome.io.ModuleGenerator; import com.rometools.rome.io.ModuleGenerator;
/** /**
* @version $Revision: 1.3 $ * @version $Revision: 1.3 $
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class ITunesGenerator implements ModuleGenerator { public class ITunesGenerator implements ModuleGenerator {
private static final HashSet<Namespace> NAMESPACES = new HashSet<Namespace>(); private static final HashSet<Namespace> NAMESPACES = new HashSet<Namespace>();
private static final Namespace NAMESPACE = Namespace.getNamespace(AbstractITunesObject.PREFIX, AbstractITunesObject.URI); private static final Namespace NAMESPACE = Namespace.getNamespace(AbstractITunesObject.PREFIX, AbstractITunesObject.URI);
static { static {
NAMESPACES.add(NAMESPACE); NAMESPACES.add(NAMESPACE);
} }
/** Creates a new instance of ITunesGenerator */ /** Creates a new instance of ITunesGenerator */
public ITunesGenerator() { public ITunesGenerator() {
} }
@Override @Override
public void generate(final Module module, final Element element) { public void generate(final Module module, final Element element) {
Element root = element; Element root = element;
while (root.getParent() != null && root.getParent() instanceof Element) { while (root.getParent() != null && root.getParent() instanceof Element) {
root = (Element) root.getParent(); root = (Element) root.getParent();
} }
root.addNamespaceDeclaration(NAMESPACE); root.addNamespaceDeclaration(NAMESPACE);
if (!(module instanceof AbstractITunesObject)) { if (!(module instanceof AbstractITunesObject)) {
return; return;
} }
final AbstractITunesObject itunes = (AbstractITunesObject) module; final AbstractITunesObject itunes = (AbstractITunesObject) module;
if (itunes instanceof FeedInformationImpl) { if (itunes instanceof FeedInformationImpl) {
// Do Channel Specific Stuff. // Do Channel Specific Stuff.
final FeedInformationImpl info = (FeedInformationImpl) itunes; final FeedInformationImpl info = (FeedInformationImpl) itunes;
final Element owner = generateSimpleElement("owner", "");
final Element email = generateSimpleElement("email", info.getOwnerEmailAddress()); final Element owner = generateSimpleElement("owner", "");
owner.addContent(email); final Element email = generateSimpleElement("email", info.getOwnerEmailAddress());
owner.addContent(email);
final Element name = generateSimpleElement("name", info.getOwnerName()); final Element name = generateSimpleElement("name", info.getOwnerName());
owner.addContent(name); owner.addContent(name);
element.addContent(owner); element.addContent(owner);
final List<Category> categories = info.getCategories(); final List<Category> categories = info.getCategories();
for (final Category cat : categories) { for (final Category cat : categories) {
final Element category = generateSimpleElement("category", ""); final Element category = generateSimpleElement("category", "");
category.setAttribute("text", cat.getName()); category.setAttribute("text", cat.getName());
if (cat.getSubcategory() != null) { if (cat.getSubcategory() != null) {
final Element subcat = generateSimpleElement("category", ""); final Element subcat = generateSimpleElement("category", "");
subcat.setAttribute("text", cat.getSubcategory().getName()); subcat.setAttribute("text", cat.getSubcategory().getName());
category.addContent(subcat); category.addContent(subcat);
} }
element.addContent(category); element.addContent(category);
} }
if (info.getComplete()) { if (info.getComplete() != null) {
element.addContent(generateSimpleElement("complete", "yes")); if (info.getComplete()) {
} element.addContent(generateSimpleElement("complete", "yes"));
} else {
if (info.getNewFeedUrl() != null) { element.addContent(generateSimpleElement("complete", "no"));
element.addContent(generateSimpleElement("new-feed-url", info.getNewFeedUrl())); }
} }
} else if (itunes instanceof EntryInformationImpl) { if (info.getNewFeedUrl() != null) {
final EntryInformationImpl info = (EntryInformationImpl) itunes; element.addContent(generateSimpleElement("new-feed-url", info.getNewFeedUrl().toExternalForm()));
}
if (info.getDuration() != null) {
element.addContent(generateSimpleElement("duration", info.getDuration().toString())); } else if (itunes instanceof EntryInformationImpl) {
} final EntryInformationImpl info = (EntryInformationImpl) itunes;
if (info.getClosedCaptioned()) {
element.addContent(generateSimpleElement("isClosedCaptioned", "yes")); if (info.getDuration() != null) {
} element.addContent(generateSimpleElement("duration", info.getDuration().toString()));
if (info.getOrder() != null) { }
element.addContent(generateSimpleElement("order", info.getOrder().toString())); if (info.getClosedCaptioned() != null) {
} element.addContent(generateSimpleElement("isClosedCaptioned", info.getClosedCaptioned().name()));
} }
if (info.getOrder() != null) {
if (itunes.getAuthor() != null) { element.addContent(generateSimpleElement("order", info.getOrder().toString()));
element.addContent(generateSimpleElement("author", itunes.getAuthor())); }
} }
if (itunes.getBlock()) { if (itunes.getAuthor() != null) {
element.addContent(generateSimpleElement("block", "")); element.addContent(generateSimpleElement("author", itunes.getAuthor()));
} }
if (itunes.getExplicit()) { if (itunes.getBlock()) {
element.addContent(generateSimpleElement("explicit", "yes")); element.addContent(generateSimpleElement("block", ""));
} else { }
element.addContent(generateSimpleElement("explicit", "no"));
} if (itunes.getExplicit() != null) {
element.addContent(generateSimpleElement("explicit", itunes.getExplicit().name()));
if (itunes.getImage() != null) { }
final Element image = generateSimpleElement("image", "");
image.setAttribute("href", itunes.getImage().toExternalForm()); if (itunes.getImage() != null) {
element.addContent(image); final Element image = generateSimpleElement("image", "");
} image.setAttribute("href", itunes.getImage().toExternalForm());
element.addContent(image);
if (itunes.getKeywords() != null) { }
final StringBuffer sb = new StringBuffer();
if (itunes.getKeywords() != null) {
for (int i = 0; i < itunes.getKeywords().length; i++) { final StringBuffer sb = new StringBuffer();
if (i != 0) {
sb.append(", "); for (int i = 0; i < itunes.getKeywords().length; i++) {
} if (i != 0) {
sb.append(", ");
sb.append(itunes.getKeywords()[i]); }
}
sb.append(itunes.getKeywords()[i]);
element.addContent(generateSimpleElement("keywords", sb.toString())); }
}
element.addContent(generateSimpleElement("keywords", sb.toString()));
if (itunes.getSubtitle() != null) { }
element.addContent(generateSimpleElement("subtitle", itunes.getSubtitle()));
} if (itunes.getSubtitle() != null) {
element.addContent(generateSimpleElement("subtitle", itunes.getSubtitle()));
if (itunes.getSummary() != null) { }
element.addContent(generateSimpleElement("summary", itunes.getSummary()));
} if (itunes.getSummary() != null) {
} element.addContent(generateSimpleElement("summary", itunes.getSummary()));
}
/** }
* Returns the list of namespaces this module uses.
* /**
* @return set of Namespace objects. * Returns the list of namespaces this module uses.
*/ *
@Override * @return set of Namespace objects.
public Set<Namespace> getNamespaces() { */
return NAMESPACES; @Override
} public Set<Namespace> getNamespaces() {
return NAMESPACES;
/** }
* Returns the namespace URI this module handles.
* /**
* @return Returns the namespace URI this module handles. * Returns the namespace URI this module handles.
*/ *
@Override * @return Returns the namespace URI this module handles.
public String getNamespaceUri() { */
return AbstractITunesObject.URI; @Override
} public String getNamespaceUri() {
return AbstractITunesObject.URI;
protected Element generateSimpleElement(final String name, final String value) { }
final Element element = new Element(name, NAMESPACE);
element.addContent(value); protected Element generateSimpleElement(final String name, final String value) {
final Element element = new Element(name, NAMESPACE);
return element; element.addContent(value);
}
} return element;
}
}

View file

@ -1,234 +1,253 @@
/* /*
* ITunesParser.java * ITunesParser.java
* *
* Created on August 1, 2005, 8:29 PM * Created on August 1, 2005, 8:29 PM
* *
* This library is provided under dual licenses. * This library is provided under dual licenses.
* You may choose the terms of the Lesser General Public License or the Apache * You may choose the terms of the Lesser General Public License or the Apache
* License at your discretion. * License at your discretion.
* *
* Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin * Copyright (C) 2005 Robert Cooper, Temple of the Screaming Penguin
* *
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.rometools.modules.itunes.io; package com.rometools.modules.itunes.io;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.jdom2.Content; import org.jdom2.Content;
import org.jdom2.Element; import org.jdom2.Element;
import org.jdom2.Namespace; import org.jdom2.Namespace;
import org.jdom2.output.XMLOutputter; import org.jdom2.output.XMLOutputter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.rometools.modules.itunes.AbstractITunesObject; import com.rometools.modules.itunes.AbstractITunesObject;
import com.rometools.modules.itunes.EntryInformationImpl; import com.rometools.modules.itunes.EntryInformation;
import com.rometools.modules.itunes.FeedInformationImpl; import com.rometools.modules.itunes.EntryInformationImpl;
import com.rometools.modules.itunes.types.Category; import com.rometools.modules.itunes.FeedInformationImpl;
import com.rometools.modules.itunes.types.Duration; import com.rometools.modules.itunes.ITunes;
import com.rometools.modules.itunes.types.Subcategory; import com.rometools.modules.itunes.types.Category;
import com.rometools.rome.io.ModuleParser; import com.rometools.modules.itunes.types.Duration;
import com.rometools.rome.io.WireFeedParser; import com.rometools.modules.itunes.types.Subcategory;
import com.rometools.rome.feed.module.Module;
/** import com.rometools.rome.io.ModuleParser;
* @version $Revision: 1.10 $ import com.rometools.rome.io.WireFeedParser;
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> import com.rometools.utils.Integers;
*/
public class ITunesParser implements ModuleParser { /**
* @version $Revision: 1.10 $
private static final Logger LOG = LoggerFactory.getLogger(ITunesParser.class); * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/
Namespace ns = Namespace.getNamespace(AbstractITunesObject.URI); public class ITunesParser implements ModuleParser {
/** Creates a new instance of ITunesParser */ private static final Logger LOG = LoggerFactory.getLogger(ITunesParser.class);
public ITunesParser() {
} private final Namespace ns;
public void setParser(final WireFeedParser feedParser) { /** Creates a new instance of ITunesParser */
} public ITunesParser() {
this(Namespace.getNamespace(AbstractITunesObject.URI));
@Override }
public String getNamespaceUri() {
return AbstractITunesObject.URI; /**
} * @param ns target namespace
*/
@Override protected ITunesParser(final Namespace ns) {
public com.rometools.rome.feed.module.Module parse(final Element element, final Locale locale) { this.ns = ns;
AbstractITunesObject module = null; }
if (element.getName().equals("channel")) { /**
final FeedInformationImpl feedInfo = new FeedInformationImpl(); * @param feedParser ignored
module = feedInfo; */
public void setParser(final WireFeedParser feedParser) {
// Now I am going to get the channel specific tags }
final Element owner = element.getChild("owner", ns);
@Override
if (owner != null) { public String getNamespaceUri() {
final Element name = owner.getChild("name", ns); return AbstractITunesObject.URI;
}
if (name != null) {
feedInfo.setOwnerName(name.getValue().trim()); @Override
} public Module parse(final Element element, final Locale locale) {
AbstractITunesObject module = null;
final Element email = owner.getChild("email", ns);
if (element.getName().equals("channel")) {
if (email != null) { final FeedInformationImpl feedInfo = new FeedInformationImpl();
feedInfo.setOwnerEmailAddress(email.getValue().trim()); module = feedInfo;
}
} // Now I am going to get the channel specific tags
final Element owner = element.getChild("owner", ns);
final List<Element> categories = element.getChildren("category", ns);
for (final Element element2 : categories) { if (owner != null) {
final Element category = element2; final Element name = owner.getChild("name", ns);
if (category != null && category.getAttribute("text") != null) {
final Category cat = new Category(); if (name != null) {
cat.setName(category.getAttribute("text").getValue().trim()); feedInfo.setOwnerName(name.getValue().trim());
}
final Element subcategory = category.getChild("category", ns);
final Element email = owner.getChild("email", ns);
if (subcategory != null && subcategory.getAttribute("text") != null) {
final Subcategory subcat = new Subcategory(); if (email != null) {
subcat.setName(subcategory.getAttribute("text").getValue().trim()); feedInfo.setOwnerEmailAddress(email.getValue().trim());
cat.setSubcategory(subcat); }
} }
feedInfo.getCategories().add(cat); final List<Element> categories = element.getChildren("category", ns);
} for (final Element element2 : categories) {
} final Element category = element2;
if (category != null && category.getAttribute("text") != null) {
final Element complete = element.getChild("complete", ns); final Category cat = new Category();
if (complete != null) { cat.setName(category.getAttribute("text").getValue().trim());
feedInfo.setComplete("yes".equals(complete.getTextTrim().toLowerCase()));
} final Element subcategory = category.getChild("category", ns);
final Element newFeedUrl = element.getChild("new-feed-url", ns); if (subcategory != null && subcategory.getAttribute("text") != null) {
if (newFeedUrl != null) { final Subcategory subcat = new Subcategory();
feedInfo.setNewFeedUrl(newFeedUrl.getTextTrim()); subcat.setName(subcategory.getAttribute("text").getValue().trim());
} cat.setSubcategory(subcat);
}
} else if (element.getName().equals("item")) {
final EntryInformationImpl entryInfo = new EntryInformationImpl(); feedInfo.getCategories().add(cat);
module = entryInfo; }
}
// Now I am going to get the item specific tags
final Element complete = element.getChild("complete", ns);
final Element duration = element.getChild("duration", ns); if (complete != null) {
feedInfo.setComplete("yes".equals(complete.getTextTrim().toLowerCase()));
if (duration != null && duration.getValue() != null) { }
final Duration dur = new Duration(duration.getValue().trim());
entryInfo.setDuration(dur); final Element newFeedUrl = element.getChild("new-feed-url", ns);
} if (newFeedUrl != null) {
try {
final Element closedCaptioned = element.getChild("isClosedCaptioned", ns); feedInfo.setNewFeedUrl(new URL(newFeedUrl.getTextTrim()));
} catch (final MalformedURLException e) {
if (closedCaptioned != null && closedCaptioned.getValue() != null && closedCaptioned.getValue().trim().equalsIgnoreCase("yes")) { LOG.debug("Malformed URL Exception reading itunes:new-feed-url tag: {}", newFeedUrl.getTextTrim());
entryInfo.setClosedCaptioned(true); }
} }
final Element order = element.getChild("order", ns); } else if (element.getName().equals("item")) {
final EntryInformationImpl entryInfo = new EntryInformationImpl();
if (order != null && order.getValue() != null) { module = entryInfo;
final Integer o = Integer.valueOf(order.getValue().trim());
entryInfo.setOrder(o); // Now I am going to get the item specific tags
}
} final Element duration = element.getChild("duration", ns);
if (module != null) { if (duration != null && duration.getValue() != null) {
// All these are common to both Channel and Item final Duration dur = new Duration(duration.getValue().trim());
final Element author = element.getChild("author", ns); entryInfo.setDuration(dur);
}
if (author != null && author.getText() != null) {
module.setAuthor(author.getText()); final Element isClosedCaptioned = element.getChild("isClosedCaptioned", ns);
}
if (isClosedCaptioned != null && isClosedCaptioned.getValue() != null ) {
final Element block = element.getChild("block", ns); entryInfo.setClosedCaptioned(EntryInformation.ClosedCaptioned.valueOf(isClosedCaptioned.getTextTrim().toLowerCase()));
}
if (block != null) {
module.setBlock(true); final Element order = element.getChild("order", ns);
}
if (order != null && order.getValue() != null) {
final Element explicit = element.getChild("explicit", ns); final Integer o = Integer.valueOf(order.getValue().trim());
entryInfo.setOrder(o);
if (explicit != null && explicit.getValue() != null && explicit.getValue().trim().equalsIgnoreCase("yes")) { }
module.setExplicit(true); }
} if (module != null) {
// All these are common to both Channel and Item
final Element keywords = element.getChild("keywords", ns); final Element author = element.getChild("author", ns);
if (keywords != null) { if (author != null && author.getText() != null) {
final StringTokenizer tok = new StringTokenizer(getXmlInnerText(keywords).trim(), ","); module.setAuthor(author.getText());
final String[] keywordsArray = new String[tok.countTokens()]; }
for (int i = 0; tok.hasMoreTokens(); i++) { final Element block = element.getChild("block", ns);
keywordsArray[i] = tok.nextToken();
} if (block != null) {
module.setBlock("yes".equals(block.getTextTrim().toLowerCase()));
module.setKeywords(keywordsArray); }
}
final Element explicit = element.getChild("explicit", ns);
final Element subtitle = element.getChild("subtitle", ns);
if (explicit != null && explicit.getValue() != null) {
if (subtitle != null) { module.setExplicit(ITunes.Explicit.valueOf(explicit.getTextTrim().toLowerCase()));
module.setSubtitle(subtitle.getTextTrim()); }
}
final Element keywords = element.getChild("keywords", ns);
final Element summary = element.getChild("summary", ns);
if (keywords != null) {
if (summary != null) { final StringTokenizer tok = new StringTokenizer(getXmlInnerText(keywords).trim(), ",");
module.setSummary(summary.getTextTrim()); final String[] keywordsArray = new String[tok.countTokens()];
}
for (int i = 0; tok.hasMoreTokens(); i++) {
final Element image = element.getChild("image", ns); keywordsArray[i] = tok.nextToken();
}
if (image != null && image.getAttributeValue("href") != null) {
try { module.setKeywords(keywordsArray);
final URL imageURL = new URL(image.getAttributeValue("href").trim()); }
module.setImage(imageURL);
} catch (final MalformedURLException e) { final Element subtitle = element.getChild("subtitle", ns);
LOG.debug("Malformed URL Exception reading itunes:image tag: {}", image.getAttributeValue("href"));
} if (subtitle != null) {
} module.setSubtitle(subtitle.getTextTrim());
} }
return module; final Element summary = element.getChild("summary", ns);
}
if (summary != null) {
protected String getXmlInnerText(final Element e) { module.setSummary(summary.getTextTrim());
final StringBuffer sb = new StringBuffer(); }
final XMLOutputter xo = new XMLOutputter();
final List<Content> children = e.getContent(); final Element image = element.getChild("image", ns);
sb.append(xo.outputString(children));
return sb.toString(); if (image != null && image.getAttributeValue("href") != null) {
} try {
} final URL imageURL = new URL(image.getAttributeValue("href").trim());
module.setImage(imageURL);
} catch (final MalformedURLException e) {
LOG.debug("Malformed URL Exception reading itunes:image tag: {}", image.getAttributeValue("href"));
}
}
}
return module;
}
protected String getXmlInnerText(final Element e) {
final StringBuffer sb = new StringBuffer();
final XMLOutputter xo = new XMLOutputter();
final List<Content> children = e.getContent();
sb.append(xo.outputString(children));
return sb.toString();
}
}

View file

@ -47,12 +47,11 @@ import org.jdom2.Namespace;
* @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a> * @author <a href="mailto:cooper@screaming-penguin.com">Robert "kebernet" Cooper</a>
*/ */
public class ITunesParserOldNamespace extends ITunesParser { public class ITunesParserOldNamespace extends ITunesParser {
String URI = "http://www.itunes.com/DTDs/Podcast-1.0.dtd"; private static final String URI = "http://www.itunes.com/DTDs/Podcast-1.0.dtd";
/** Creates a new instance of ITunesParserOldNamespace */ /** Creates a new instance of ITunesParserOldNamespace */
public ITunesParserOldNamespace() { public ITunesParserOldNamespace() {
super(); super(Namespace.getNamespace(URI));
super.ns = Namespace.getNamespace(URI);
} }
@Override @Override

View file

@ -1,123 +1,242 @@
/* /*
* ITunesParserTest.java * ITunesParserTest.java
* JUnit based test * JUnit based test
* *
* Created on August 2, 2005, 1:30 PM * Created on August 2, 2005, 1:30 PM
*/ */
package com.rometools.modules.itunes; package com.rometools.modules.itunes;
import java.io.File; import java.io.File;
import java.util.Iterator; import java.io.IOException;
import java.util.List; import java.util.Iterator;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import com.rometools.modules.AbstractTestCase;
import com.rometools.modules.itunes.EntryInformation.ClosedCaptioned;
import com.rometools.modules.AbstractTestCase; import com.rometools.modules.itunes.ITunes.Explicit;
import com.rometools.modules.itunes.AbstractITunesObject; import com.rometools.modules.itunes.io.ITunesGenerator;
import com.rometools.modules.itunes.EntryInformationImpl; import com.rometools.rome.feed.module.Module;
import com.rometools.modules.itunes.FeedInformationImpl; import com.rometools.rome.feed.synd.SyndEntry;
import com.rometools.modules.itunes.io.ITunesGenerator; import com.rometools.rome.feed.synd.SyndFeed;
import com.rometools.rome.feed.module.Module; import com.rometools.rome.io.FeedException;
import com.rometools.rome.feed.synd.SyndEntry; import com.rometools.rome.io.SyndFeedInput;
import com.rometools.rome.feed.synd.SyndFeed; import com.rometools.rome.io.XmlReader;
import com.rometools.rome.io.SyndFeedInput;
import com.rometools.rome.io.XmlReader; import junit.framework.Test;
import junit.framework.TestSuite;
/**
* /**
* @author cooper *
*/ * @author cooper
public class ITunesParserTest extends AbstractTestCase { */
public class ITunesParserTest extends AbstractTestCase {
private static final Logger LOG = LoggerFactory.getLogger(ITunesParserTest.class);
private static final Logger LOG = LoggerFactory.getLogger(ITunesParserTest.class);
public ITunesParserTest(final String testName) { private static final int itemCountInLeShowFeed = 4;
super(testName);
} public ITunesParserTest(final String testName) {
super(testName);
@Override }
protected void setUp() throws Exception {
} @Override
protected void setUp() throws Exception {
@Override }
protected void tearDown() throws Exception {
} @Override
protected void tearDown() throws Exception {
public static Test suite() { }
final TestSuite suite = new TestSuite(ITunesParserTest.class);
public static Test suite() {
return suite; final TestSuite suite = new TestSuite(ITunesParserTest.class);
}
return suite;
/** }
* Test of getNamespaceUri method, of class com.totsp.xml.syndication.itunes.ITunesParser.
*/ /**
public void testGetNamespaceUri() { * Test of getNamespaceUri method, of class com.totsp.xml.syndication.itunes.ITunesParser.
LOG.debug("testGetNamespaceUri"); */
public void testGetNamespaceUri() {
assertEquals("Namespace", "http://www.itunes.com/dtds/podcast-1.0.dtd", new ITunesGenerator().getNamespaceUri()); LOG.debug("testGetNamespaceUri");
}
assertEquals("Namespace", "http://www.itunes.com/dtds/podcast-1.0.dtd", new ITunesGenerator().getNamespaceUri());
/** }
* Test of parse method, of class com.totsp.xml.syndication.itunes.ITunesParser.
*/ /**
public void testParse() throws Exception { * Test of parse method, of class com.totsp.xml.syndication.itunes.ITunesParser.
File feed = new File(getTestFile("xml/leshow.xml")); */
final SyndFeedInput input = new SyndFeedInput(); public void testParse() throws Exception {
SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL())); File feed = new File(getTestFile("xml/leshow.xml"));
final SyndFeedInput input = new SyndFeedInput();
final Module module = syndfeed.getModule(AbstractITunesObject.URI); SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));
final FeedInformationImpl feedInfo = (FeedInformationImpl) module;
final Module module = syndfeed.getModule(AbstractITunesObject.URI);
assertEquals("owner", "Harry Shearer", feedInfo.getOwnerName()); final FeedInformationImpl feedInfo = (FeedInformationImpl) module;
assertEquals("email", "", feedInfo.getOwnerEmailAddress());
assertEquals("image", "http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg", feedInfo.getImage().toExternalForm()); assertEquals("owner", "Harry Shearer", feedInfo.getOwnerName());
assertEquals("category", "Comedy", feedInfo.getCategories().get(0).getName()); assertEquals("email", "", feedInfo.getOwnerEmailAddress());
assertEquals( assertEquals("image", "http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg", feedInfo.getImage().toExternalForm());
"summary", assertEquals("category", "Comedy", feedInfo.getCategories().get(0).getName());
"A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.", assertEquals(
feedInfo.getSummary()); "summary",
assertEquals(true, feedInfo.getComplete()); "A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.",
assertEquals("http://example.org", feedInfo.getNewFeedUrl()); feedInfo.getSummary());
assertEquals("complete", Boolean.TRUE, feedInfo.getComplete());
List<SyndEntry> entries = syndfeed.getEntries(); assertEquals("new-feed-url", "http://newlocation.com/example.rss", feedInfo.getNewFeedUrl().toExternalForm());
Iterator<SyndEntry> it = entries.iterator(); assertFalse("block", feedInfo.getBlock());
while (it.hasNext()) { List<SyndEntry> entries = syndfeed.getEntries();
final SyndEntry entry = it.next(); Iterator<SyndEntry> it = entries.iterator();
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
LOG.debug("{}", entryInfo); while (it.hasNext()) {
} final SyndEntry entry = it.next();
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
feed = new File(getTestFile("xml/rsr.xml")); LOG.debug("{}", entryInfo);
syndfeed = input.build(new XmlReader(feed.toURI().toURL())); }
entries = syndfeed.getEntries();
it = entries.iterator(); feed = new File(getTestFile("xml/rsr.xml"));
syndfeed = input.build(new XmlReader(feed.toURI().toURL()));
while (it.hasNext()) { entries = syndfeed.getEntries();
final SyndEntry entry = it.next(); it = entries.iterator();
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
LOG.debug("{}", entryInfo.getDuration()); while (it.hasNext()) {
} final SyndEntry entry = it.next();
} final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
LOG.debug("{}", entryInfo.getDuration());
/** }
* Test of parse method, of class com.rometools.modules.itunes.io.ITunesParser.
*/ }
public void testParseItem() throws Exception {
File feed = new File(getTestFile("xml/leshow.xml")); /**
final SyndFeedInput input = new SyndFeedInput(); * Test of parse method, of class com.rometools.modules.itunes.io.ITunesParser.
SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL())); */
public void testParseItem() throws Exception {
SyndEntry entry = syndfeed.getEntries().get(0); File feed = new File(getTestFile("xml/leshow.xml"));
final SyndFeedInput input = new SyndFeedInput();
EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI); SyndFeed syndfeed = input.build(new XmlReader(feed.toURI().toURL()));
assertEquals(true, entryInfo.getClosedCaptioned());
assertEquals(Integer.valueOf(2), entryInfo.getOrder()); SyndEntry entry = syndfeed.getEntries().get(0);
assertEquals("http://example.org/image.png", entryInfo.getImage().toString());
} EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
} assertEquals(ClosedCaptioned.yes, entryInfo.getClosedCaptioned());
assertEquals(Integer.valueOf(2), entryInfo.getOrder());
assertEquals("http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg", entryInfo.getImage().toString());
}
/**
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testParseRsr() throws IOException, FeedException {
final SyndFeed syndfeed = getSyndFeed("xml/rsr.xml");
final List<SyndEntry> entries = syndfeed.getEntries();
final Iterator<SyndEntry> it = entries.iterator();
while (it.hasNext()) {
final SyndEntry entry = it.next();
final EntryInformationImpl entryInfo = (EntryInformationImpl) entry.getModule(AbstractITunesObject.URI);
LOG.debug("{}", entryInfo.getDuration());
}
}
/**
* test for itunes:explicit tags.
*
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testImageTagOnItem() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("xml/leshow.xml");
assertEquals("http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg",
((EntryInformation) feed.getEntries().get(0).getModule(AbstractITunesObject.URI)).getImage().toExternalForm());
}
/**
* test for itunes:explicit tags.
*
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testExplicitTags() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("xml/leshow.xml");
final FeedInformationImpl feedInfo = (FeedInformationImpl) feed.getModule(AbstractITunesObject.URI);
assertEquals("explicit tag on feed", Explicit.yes, feedInfo.getExplicit());
assertEquals("wrong count of items", itemCountInLeShowFeed, feed.getEntries().size());
assertEquals("explicit tag on 1. item", Explicit.yes,
((EntryInformation) feed.getEntries().get(0).getModule(AbstractITunesObject.URI)).getExplicit());
assertEquals("explicit tag on 2. item", Explicit.no,
((EntryInformation) feed.getEntries().get(1).getModule(AbstractITunesObject.URI)).getExplicit());
assertEquals("explicit tag on 3. item", Explicit.clean,
((EntryInformation) feed.getEntries().get(2).getModule(AbstractITunesObject.URI)).getExplicit());
assertNull("explicit tag on 4. item",
((EntryInformation) feed.getEntries().get(3).getModule(AbstractITunesObject.URI)).getExplicit());
}
/**
* test for itunes:isClosedCaptioned tags.
*
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testClosedCaptionedTags() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("xml/leshow.xml");
assertEquals("wrong count of items", itemCountInLeShowFeed, feed.getEntries().size());
assertEquals("isClosedCaptioned tag on 1. item", ClosedCaptioned.yes,
((EntryInformation) feed.getEntries().get(0).getModule(AbstractITunesObject.URI)).getClosedCaptioned());
assertEquals("isClosedCaptioned tag on 2. item", ClosedCaptioned.no,
((EntryInformation) feed.getEntries().get(1).getModule(AbstractITunesObject.URI)).getClosedCaptioned());
assertEquals("isClosedCaptioned tag on 3. item", ClosedCaptioned.no,
((EntryInformation) feed.getEntries().get(2).getModule(AbstractITunesObject.URI)).getClosedCaptioned());
assertNull("isClosedCaptioned tag on 4. item",
((EntryInformation) feed.getEntries().get(3).getModule(AbstractITunesObject.URI)).getClosedCaptioned());
}
/**
* test for itunes:order tags.
*
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testOrderTags() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("xml/leshow.xml");
assertEquals("wrong count of items", itemCountInLeShowFeed, feed.getEntries().size());
assertEquals("order tag on 1. item", Integer.valueOf(2),
((EntryInformation) feed.getEntries().get(0).getModule(AbstractITunesObject.URI)).getOrder());
assertEquals("order tag on 2. item", Integer.valueOf(1),
((EntryInformation) feed.getEntries().get(1).getModule(AbstractITunesObject.URI)).getOrder());
assertNull("order tag on 3. item",
((EntryInformation) feed.getEntries().get(2).getModule(AbstractITunesObject.URI)).getOrder());
assertNull("order tag on 4. item",
((EntryInformation) feed.getEntries().get(3).getModule(AbstractITunesObject.URI)).getOrder());
}
/**
* test for itunes:block tags.
*
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
public void testBlockTags() throws IOException, FeedException {
final SyndFeed feed = getSyndFeed("xml/leshow.xml");
assertEquals("wrong count of items", itemCountInLeShowFeed, feed.getEntries().size());
assertTrue("block tag on 1. item",
((EntryInformation) feed.getEntries().get(0).getModule(AbstractITunesObject.URI)).getBlock());
assertFalse("block tag on 2. item",
((EntryInformation) feed.getEntries().get(1).getModule(AbstractITunesObject.URI)).getBlock());
assertFalse("block tag on 3. item",
((EntryInformation) feed.getEntries().get(2).getModule(AbstractITunesObject.URI)).getBlock());
assertFalse("block tag on 4. item",
((EntryInformation) feed.getEntries().get(3).getModule(AbstractITunesObject.URI)).getBlock());
}
/**
* @param testfile path to test file
* @return SyndFeed from test file
* @throws FeedException if error on parsing feed
* @throws IOException if file not readable
*/
private SyndFeed getSyndFeed(final String testfile) throws IOException, FeedException {
return new SyndFeedInput().build(new File(getTestFile(testfile)));
}
}

View file

@ -1,189 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"> <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel> <channel>
<title>KCRW&#39;s Le Show</title> <title>KCRW&#39;s Le Show</title>
<itunes:author>Harry Shearer</itunes:author> <itunes:author>Harry Shearer</itunes:author>
<link>http://www.kcrw.com/show/ls</link> <link>http://www.kcrw.com/show/ls</link>
<description>A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.</description> <description>A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.</description>
<itunes:subtitle>An hour&#39;s worth of Harry Shearer</itunes:subtitle> <itunes:subtitle>An hour&#39;s worth of Harry Shearer</itunes:subtitle>
<itunes:summary>A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.</itunes:summary> <itunes:summary>A weekly, hour-long romp through the worlds of media, politics, sports and show business, leavened with an eclectic mix of mysterious music, hosted by Harry Shearer.</itunes:summary>
<itunes:complete>yes</itunes:complete> <itunes:complete>yes</itunes:complete>
<itunes:new-feed-url>http://example.org</itunes:new-feed-url> <itunes:new-feed-url>http://newlocation.com/example.rss</itunes:new-feed-url>
<language>en</language> <language>en</language>
<copyright>KCRW 2005</copyright>
<copyright>KCRW 2005</copyright> <itunes:owner>
<itunes:name>Harry Shearer</itunes:name>
<itunes:owner> <itunes:email></itunes:email>
<itunes:name>Harry Shearer</itunes:name> </itunes:owner>
<itunes:email></itunes:email> <itunes:image rel="image" href="http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg">KCRW&#39;s Le Show</itunes:image>
</itunes:owner> <category>Comedy</category>
<itunes:category text="Comedy" />
<itunes:image rel="image" href="http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg">KCRW&#39;s Le Show</itunes:image> <itunes:category text="Comedy" />
<itunes:block>no</itunes:block>
<itunes:explicit>yes</itunes:explicit>
<category>Comedy</category> <item>
<title>le Show</title>
<itunes:author>Harry Shearer</itunes:author>
<itunes:category text="Comedy"/> <description></description>
<itunes:subtitle></itunes:subtitle>
<itunes:summary></itunes:summary>
<enclosure url="http://a1.phobos.apple.com/Podcasts/y2005/m08/d01/h14/eosmhmit.mp3" length="16770270" type="" />
<guid>http://66.186.18.80/podcast/mp3/ls/ls050731le_Show.mp3</guid>
<itunes:category text="Comedy"/> <pubDate>Sun, 31 Jul 2005 16:00:00 GMT</pubDate>
<category>Comedy</category>
<itunes:category text="Comedy" />
<itunes:category text="Comedy" />
<itunes:explicit>yes</itunes:explicit>
<itunes:duration>46:34</itunes:duration>
<itunes:keywords></itunes:keywords>
<item> <itunes:isClosedCaptioned>yes</itunes:isClosedCaptioned>
<title>le Show</title> <itunes:order>2</itunes:order>
<itunes:author>Harry Shearer</itunes:author> <itunes:image rel="image" href="http://a1.phobos.apple.com/Music/y2005/m06/d26/h21/mcdrrifv.jpg">KCRW&#39;s Le Show</itunes:image>
<description></description> <itunes:block>yes</itunes:block>
<itunes:subtitle></itunes:subtitle> </item>
<itunes:summary></itunes:summary> <item>
<enclosure url="http://a1.phobos.apple.com/Podcasts/y2005/m08/d01/h14/eosmhmit.mp3" length="16770270" type=""/> <title>le Show</title>
<guid>http://66.186.18.80/podcast/mp3/ls/ls050731le_Show.mp3</guid> <itunes:author>Harry Shearer</itunes:author>
<description></description>
<pubDate>Sun, 31 Jul 2005 16:00:00 GMT</pubDate> <itunes:subtitle></itunes:subtitle>
<itunes:summary></itunes:summary>
<enclosure url="http://a1.phobos.apple.com/Podcasts/y2005/m07/d25/h15/kubgxyqj.mp3" length="15841460" type="" />
<guid>http://66.186.18.80/podcast/mp3/ls/ls050724le_Show.mp3</guid>
<category>Comedy</category> <pubDate>Sun, 24 Jul 2005 16:00:00 GMT</pubDate>
<category>Comedy</category>
<itunes:category text="Comedy" />
<itunes:category text="Comedy"/> <itunes:category text="Comedy" />
<itunes:explicit>no</itunes:explicit>
<itunes:duration>44:00</itunes:duration>
<itunes:block>no</itunes:block>
<itunes:isClosedCaptioned>no</itunes:isClosedCaptioned>
<itunes:category text="Comedy"/> <itunes:order>1</itunes:order>
<itunes:keywords></itunes:keywords>
</item>
<item>
<title>le Show</title>
<itunes:author>Harry Shearer</itunes:author>
<itunes:explicit>no</itunes:explicit> <description></description>
<itunes:subtitle></itunes:subtitle>
<itunes:duration>46:34</itunes:duration> <itunes:summary></itunes:summary>
<enclosure url="http://a1.phobos.apple.com/Features/y2005/m07/d18/h18/dj.mwuhgyyh.mp3" length="17483726" type="" />
<itunes:keywords></itunes:keywords> <guid>http://66.186.18.80/podcast/mp3/ls/ls050717le_Show.mp3</guid>
<itunes:isClosedCaptioned>yes</itunes:isClosedCaptioned> <pubDate>Sun, 17 Jul 2005 16:00:00 GMT</pubDate>
<itunes:order>2</itunes:order> <category>Comedy</category>
<itunes:image href="http://example.org/image.png"></itunes:image> <itunes:category text="Comedy" />
</item> <itunes:category text="Comedy" />
<itunes:duration>48:33</itunes:duration>
<itunes:block>no</itunes:block>
<item> <itunes:isClosedCaptioned>no</itunes:isClosedCaptioned>
<title>le Show</title> <itunes:explicit>clean</itunes:explicit>
<itunes:author>Harry Shearer</itunes:author> </item>
<description> <item>
</description> <title>le Show</title>
<itunes:subtitle> <itunes:author>Harry Shearer</itunes:author>
</itunes:subtitle> <enclosure url="http://a1.phobos.apple.com/Music/y2005/m07/d12/h14/axebmlyj.mp3" length="16541124" type="" />
<itunes:summary> <guid>http://66.186.18.80/podcast/mp3/ls/ls050710le_Show.mp3</guid>
</itunes:summary> <pubDate>Sun, 10 Jul 2005 16:00:00 GMT</pubDate>
<enclosure url="http://a1.phobos.apple.com/Podcasts/y2005/m07/d25/h15/kubgxyqj.mp3" length="15841460" type=""/> <category>Comedy</category>
<guid>http://66.186.18.80/podcast/mp3/ls/ls050724le_Show.mp3</guid> <itunes:category text="Comedy" />
<itunes:category text="Comedy" />
<pubDate>Sun, 24 Jul 2005 16:00:00 GMT</pubDate> <itunes:duration>45:56</itunes:duration>
<itunes:keywords></itunes:keywords>
</item>
<category>Comedy</category>
<itunes:category text="Comedy"/>
<itunes:category text="Comedy"/>
<itunes:explicit>no</itunes:explicit>
<itunes:duration>44:00</itunes:duration>
<itunes:keywords></itunes:keywords>
</item>
<item>
<title>le Show</title>
<itunes:author>Harry Shearer</itunes:author>
<description>
</description>
<itunes:subtitle>
</itunes:subtitle>
<itunes:summary>
</itunes:summary>
<enclosure url="http://a1.phobos.apple.com/Features/y2005/m07/d18/h18/dj.mwuhgyyh.mp3" length="17483726" type=""/>
<guid>http://66.186.18.80/podcast/mp3/ls/ls050717le_Show.mp3</guid>
<pubDate>Sun, 17 Jul 2005 16:00:00 GMT</pubDate>
<category>Comedy</category>
<itunes:category text="Comedy"/>
<itunes:category text="Comedy"/>
<itunes:explicit>no</itunes:explicit>
<itunes:duration>48:33</itunes:duration>
<itunes:keywords></itunes:keywords>
</item>
<item>
<title>le Show</title>
<itunes:author>Harry Shearer</itunes:author>
<description></description>
<itunes:subtitle></itunes:subtitle>
<itunes:summary></itunes:summary>
<enclosure url="http://a1.phobos.apple.com/Music/y2005/m07/d12/h14/axebmlyj.mp3" length="16541124" type=""/>
<guid>http://66.186.18.80/podcast/mp3/ls/ls050710le_Show.mp3</guid>
<pubDate>Sun, 10 Jul 2005 16:00:00 GMT</pubDate>
<category>Comedy</category>
<itunes:category text="Comedy"/>
<itunes:category text="Comedy"/>
<itunes:explicit>no</itunes:explicit>
<itunes:duration>45:56</itunes:duration>
<itunes:keywords></itunes:keywords>
</item>
</channel> </channel>
</rss> </rss>