com.blackledge.david.tivo.hmoclient
Class Item

java.lang.Object
  extended by com.blackledge.david.tivo.hmoclient.Item
Direct Known Subclasses:
AudioItem, ContainerItem, ImageItem, VideoItem

public class Item
extends Object

Superclass of all Items in HMO listing.

Version:
$Revision: 1.4 $

Field Summary
protected  Link contentLink
           
protected  ContainerRequest request
           
 
Constructor Summary
protected Item(ContainerRequest request)
           
  Item(ContainerRequest request, Element node)
           
 
Method Summary
 Map getAllDetails()
           
protected  List getChildElementsByTagName(Element parentElement, String name)
          Often we want to work with all the subtags of a given name (or just all subtags) - this gets them for us.
protected  Map getChildTagMap(Node parent)
          Get a mapping of keys to values where the key is the child tag name and the value is the text contained in the tag (which could be null, I think).
 String getContentType()
           
 URL getContentURL()
          Shortcut for getLinks(), look up "Content" link, call Link.getURL().
 String getCopyright()
           
 Date getCreated()
           
 String getCreationDate()
           
 URL getCustomIcon()
          Get the URL to the custom icon link for this item
static Date getDate(String encodedDate)
           
 String getLastAccessDate()
           
 Date getLastAccessed()
           
 Date getLastChanged()
           
 String getLastChangeDate()
           
 List getLinks()
           
protected  long getLong(Node numericNode)
          Interpret the node's child value as an long integer.
protected  String getNodeValue(Node element)
          Typically we want the text value contained within a tag...
protected  Element getSingleChildElementByTagName(Element parentElement, String name)
          Often we know we want one subtag and it won't appear more than once, this gets it for us.
 String getSourceFormat()
           
 String getSourceLocation()
           
 long getSourceSize()
           
 String getTitle()
           
protected  void initDetails(Element description)
          Basic Item details: <Title>{text}</Title> <ContentType>{mime-type}</ContentType> <SourceFormat>{mime-type}</SourceFormat> Optional details: <CreationDate>{date}</CreationDate> <LastChangeDate>{date}</LastChangeDate> <LastAccessDate>{date}</LastAccessDate> <SourceLocation>{text}</SourceLocation> <SourceSize>{bytes}</SourceSize> <Copyright>{text}</Copyright>
 boolean isContainer()
          Is this item a container? Some methods only work for Containers, some only work for non-containers.
 ContainerRequest newContainerRequest()
           
 ContainerRequest newContainerRequest(boolean copyCurrentSettings)
           
protected  Node singleNode(NodeList elementsByTagName)
          Get the only node of the length=1 NodeList.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

protected final ContainerRequest request

contentLink

protected Link contentLink
Constructor Detail

Item

protected Item(ContainerRequest request)

Item

public Item(ContainerRequest request,
            Element node)
Method Detail

getCustomIcon

public URL getCustomIcon()
Get the URL to the custom icon link for this item

Returns:
the URL for the icon image, or null if there isn't a valid one.

getDate

public static Date getDate(String encodedDate)

getLinks

public List getLinks()
Returns:
the item's collection of Link instances.

getContentURL

public URL getContentURL()
Shortcut for getLinks(), look up "Content" link, call Link.getURL(). Often that's the only link, anyhow.

Returns:
the URL of the content Link for this item.

isContainer

public boolean isContainer()
Is this item a container? Some methods only work for Containers, some only work for non-containers. Container Items can make a newContainerRequest(), but can't return information about links ( getContentURL(), getLinks() ).

Returns:
false, by default.

newContainerRequest

public ContainerRequest newContainerRequest()
Throws:
UnsupportedOperationException - if this is not a Container item. See isContainer()

newContainerRequest

public ContainerRequest newContainerRequest(boolean copyCurrentSettings)

getNodeValue

protected String getNodeValue(Node element)
Typically we want the text value contained within a tag... this gets it, or null if anything along the path to getting it is null.

Parameters:
element -
Returns:
a String value (trimmed) or null

getSingleChildElementByTagName

protected Element getSingleChildElementByTagName(Element parentElement,
                                                 String name)
Often we know we want one subtag and it won't appear more than once, this gets it for us.

Parameters:
parentElement -
name - may not be null.
Returns:
the named Tag, or null if that named tag isn't a child of this parentElement.

getChildElementsByTagName

protected List getChildElementsByTagName(Element parentElement,
                                         String name)
Often we want to work with all the subtags of a given name (or just all subtags) - this gets them for us.

Parameters:
parentElement -
name - - null means accept all tag names into the list.
Returns:
List containing only Element instances. never null

getLong

protected long getLong(Node numericNode)
Interpret the node's child value as an long integer.

Parameters:
numericNode -
Returns:
the parsed long value
Throws:
NumberFormatException - if there is a problem including a null node.

singleNode

protected Node singleNode(NodeList elementsByTagName)
Get the only node of the length=1 NodeList. shortcut for .item(0) with enforcement of assumption.

Parameters:
elementsByTagName -
Returns:
the node.
Throws:
IllegalArgumentException - if length is not 1.

initDetails

protected void initDetails(Element description)
Basic Item details: <Title>{text}</Title> <ContentType>{mime-type}</ContentType> <SourceFormat>{mime-type}</SourceFormat> Optional details: <CreationDate>{date}</CreationDate> <LastChangeDate>{date}</LastChangeDate> <LastAccessDate>{date}</LastAccessDate> <SourceLocation>{text}</SourceLocation> <SourceSize>{bytes}</SourceSize> <Copyright>{text}</Copyright>

Parameters:
description -

getAllDetails

public Map getAllDetails()
Returns:
a map of the Items's Details mapping sub-tag Name to the sub-tag's contained text.

getChildTagMap

protected Map getChildTagMap(Node parent)
Get a mapping of keys to values where the key is the child tag name and the value is the text contained in the tag (which could be null, I think).

Parameters:
parent -
Returns:
a map of Tag Name to the tag's first child node value (trimmed)

getTitle

public String getTitle()

getSourceFormat

public String getSourceFormat()

getContentType

public String getContentType()

getCopyright

public String getCopyright()

getCreationDate

public String getCreationDate()

getCreated

public Date getCreated()

getLastAccessDate

public String getLastAccessDate()

getLastAccessed

public Date getLastAccessed()

getLastChangeDate

public String getLastChangeDate()

getLastChanged

public Date getLastChanged()

getSourceLocation

public String getSourceLocation()

getSourceSize

public long getSourceSize()