jreceiver.common.rec.source
Class SourceRec

java.lang.Object
  |
  +--jreceiver.common.rec.BaseRec
        |
        +--jreceiver.common.rec.source.SourceRec
All Implemented Interfaces:
Hashable, Rec, Source
Direct Known Subclasses:
MexternalRec, MfileRec, PlaylistRec, TuneRec

public class SourceRec
extends BaseRec
implements Source

Bean to describe a record for the Source table

Version:
$Revision: 1.6 $ $Date: 2003/04/27 23:14:31 $
Author:
Reed Esau

Field Summary
protected  java.net.URL m_content_url
          The link to the resource on the JReceiver Content Server Note that the stored should be escaped to UTF-8 with %XX codes.
protected  org.esau.ptarmigan.util.PtarURI m_direct_uri
          A direct link to the resource, either a file:/ to a local file or an http:/ direct link to a remote resouce.
protected  java.lang.String m_dst_mime
           
protected  int m_duration
           
protected  java.lang.String m_mime
           
protected  int m_site_id
           
protected  int m_src_id
           
protected  int m_src_type
           
protected  java.lang.String m_title
           
 
Fields inherited from interface jreceiver.common.rec.source.Source
DEFAULT_URL, FORCE_PLAYLIST_URL, HKEY_CONTENT_URL, HKEY_DIRECT_URI, HKEY_DST_MIME, HKEY_DURATION, HKEY_MIME, HKEY_SITE_ID, HKEY_SRC_ID, HKEY_SRC_TYPE, HKEY_TITLE, MAX_SRC_ID, MIN_SRC_ID, POPULATE_CONTENT_URL, POPULATE_DIRECT_URI, POPULATE_MEXTERNAL, POPULATE_MFILE, SRCTYPE_PLAYLIST, SRCTYPE_TUNE, SRCTYPE_UNDEFINED
 
Fields inherited from interface jreceiver.common.rec.Rec
HKEY_KEY, NO_LIMIT
 
Constructor Summary
SourceRec()
          ctor - default (for use with beanutils)
SourceRec(java.util.Hashtable hash)
          ctor - construct from a hashtable, usually retrieved via XML-RPC
SourceRec(int src_id)
          ctor - minimal (for use by DeviceStatusRec creators who want to return minimal info)
SourceRec(int src_id, java.lang.String title, int site_id, int src_type, java.lang.String mime, int duration)
          ctor - used to do basic initialization
SourceRec(int src_id, java.lang.String title, int site_id, int src_type, java.lang.String mime, int duration, java.lang.String dst_mime, org.esau.ptarmigan.util.PtarURI direct_uri, java.net.URL content_url)
          ctor - used in initializing source for a specific driver
 
Method Summary
static SourceRec createInstance(java.util.Hashtable hash)
          Create a SourceRec object preserved as a hash that has arrived over an XML-RPC connection or similar.
 java.lang.String getContentSystemId()
          obtain the content server URL as a string
 java.net.URL getContentURL()
          obtain the content server URL of the source
 java.lang.String getDirectSystemId()
          Obtain the URL (as a String) of a local file source (in file:/ form) or if a remote source, a direct link to it.
 org.esau.ptarmigan.util.PtarURI getDirectURI()
          Obtain the URL of a local file source (in file:/ form) or if a remote source, a direct link to it.
 java.lang.String getDstMime()
          Obtain an ARBITRARY mime-types for the source that is consumable by a particular driver used in the construction of this source object, either through transcoding or (preferably) natively.
 int getDuration()
          Obtain the duration of the source, in seconds
 java.io.File getFile()
           
 java.lang.String getFileExtension()
          Obtain the short file name, without root drive or directory prefix
 java.lang.String getFileName()
          Obtain the short file name, without root drive or directory prefix
 java.lang.String getFilePath()
          Obtain the file path
 boolean getIsLocal()
          Return true if the source refers to a local file, as indexed in the mfile table.
 boolean getIsOffsite()
          return true if the source is offsite, i.e., stored on a peer server
 boolean getIsPlaylist()
          return true if the source refers to list of tunes
 boolean getIsTune()
          return true if the source refers to a single tune
 java.lang.Object getKey()
          return the Integer object that serves as this Rec's key.
 java.lang.String getMime()
          obtain the source content-type id
 int getSiteId()
          obtain the source's location (0 if local; >0 if off-site)
 int getSrcId()
          obtain the source id
 java.lang.String getTitle()
          obtain the source name
 int getType()
          obtain the source type
 void setContentURL(java.net.URL url)
          assign the URL of the source on the content server
 void setDirectURI(org.esau.ptarmigan.util.PtarURI uri)
          assign the URI of the source
 void setDirectURI(java.lang.String s_encoded_uri)
          assign the URI (note the 'I' not the 'L') of the source
 void setDuration(int duration)
          Assign the duration of the source, in seconds
 void setKey(java.lang.Object new_key)
          assign the Number-derived object that serves as this Rec's key.
 void setMime(java.lang.String mime)
          assign the source content-type id
 void setSrcId(int src_id)
          assign the source id
 void setTitle(java.lang.String title)
          assign the source name
 java.util.Hashtable toHash()
          Store the object as a hash suitable for transport over an XML-RPC connection or similar.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class jreceiver.common.rec.BaseRec
dissolve, dissolveMap, find, find, find, find
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_src_id

protected int m_src_id

m_title

protected java.lang.String m_title

m_site_id

protected int m_site_id

m_src_type

protected int m_src_type

m_mime

protected java.lang.String m_mime

m_duration

protected int m_duration

m_dst_mime

protected java.lang.String m_dst_mime

m_content_url

protected java.net.URL m_content_url
The link to the resource on the JReceiver Content Server Note that the stored should be escaped to UTF-8 with %XX codes.

m_direct_uri

protected org.esau.ptarmigan.util.PtarURI m_direct_uri
A direct link to the resource, either a file:/ to a local file or an http:/ direct link to a remote resouce. Note that the stored should be escaped to UTF-8 with %XX codes.
Constructor Detail

SourceRec

public SourceRec()
ctor - default (for use with beanutils)

SourceRec

public SourceRec(int src_id)
ctor - minimal (for use by DeviceStatusRec creators who want to return minimal info)

SourceRec

public SourceRec(int src_id,
                 java.lang.String title,
                 int site_id,
                 int src_type,
                 java.lang.String mime,
                 int duration)
ctor - used to do basic initialization

SourceRec

public SourceRec(int src_id,
                 java.lang.String title,
                 int site_id,
                 int src_type,
                 java.lang.String mime,
                 int duration,
                 java.lang.String dst_mime,
                 org.esau.ptarmigan.util.PtarURI direct_uri,
                 java.net.URL content_url)
ctor - used in initializing source for a specific driver

SourceRec

public SourceRec(java.util.Hashtable hash)
          throws RecException
ctor - construct from a hashtable, usually retrieved via XML-RPC
Method Detail

toString

public java.lang.String toString()
Description copied from interface: Hashable
Returns a string representation of the object.
Specified by:
toString in interface Hashable
Overrides:
toString in class java.lang.Object

getKey

public java.lang.Object getKey()
return the Integer object that serves as this Rec's key.
Specified by:
getKey in interface Rec

setKey

public void setKey(java.lang.Object new_key)
assign the Number-derived object that serves as this Rec's key.
Specified by:
setKey in interface Rec

getSrcId

public int getSrcId()
Description copied from interface: Source
obtain the source id
Specified by:
getSrcId in interface Source
Following copied from interface: jreceiver.common.rec.source.Source
Returns:
 

setSrcId

public void setSrcId(int src_id)
Description copied from interface: Source
assign the source id
Specified by:
setSrcId in interface Source

getTitle

public java.lang.String getTitle()
Description copied from interface: Source
obtain the source name
Specified by:
getTitle in interface Source

setTitle

public void setTitle(java.lang.String title)
Description copied from interface: Source
assign the source name
Specified by:
setTitle in interface Source

getSiteId

public int getSiteId()
Description copied from interface: Source
obtain the source's location (0 if local; >0 if off-site)
Specified by:
getSiteId in interface Source

getType

public int getType()
Description copied from interface: Source
obtain the source type
Specified by:
getType in interface Source

getMime

public java.lang.String getMime()
obtain the source content-type id
Specified by:
getMime in interface Source

setMime

public void setMime(java.lang.String mime)
assign the source content-type id
Specified by:
setMime in interface Source

getDuration

public int getDuration()
Description copied from interface: Source
Obtain the duration of the source, in seconds
Specified by:
getDuration in interface Source

setDuration

public void setDuration(int duration)
Description copied from interface: Source
Assign the duration of the source, in seconds
Specified by:
setDuration in interface Source

getDstMime

public java.lang.String getDstMime()
Description copied from interface: Source
Obtain an ARBITRARY mime-types for the source that is consumable by a particular driver used in the construction of this source object, either through transcoding or (preferably) natively.

Only valid if source is initialized for a particular driver.

Specified by:
getDstMime in interface Source

getContentURL

public java.net.URL getContentURL()
obtain the content server URL of the source

If requested by a client, this URL refers to the source on the Content Server.

Specified by:
getContentURL in interface Source

setContentURL

public void setContentURL(java.net.URL url)
assign the URL of the source on the content server
Specified by:
setContentURL in interface Source

getContentSystemId

public java.lang.String getContentSystemId()
obtain the content server URL as a string
Specified by:
getContentSystemId in interface Source

setDirectURI

public void setDirectURI(org.esau.ptarmigan.util.PtarURI uri)
assign the URI of the source
Specified by:
setDirectURI in interface Source

setDirectURI

public void setDirectURI(java.lang.String s_encoded_uri)
                  throws java.io.IOException,
                         java.net.MalformedURLException
assign the URI (note the 'I' not the 'L') of the source

Typically invoked via Digester from SourceBuilder with the 'system-id' element of ptarmigan.xsd.

NOTE: as provided the system-id will be url-encoded. The SourceRec must accommodate this.

Specified by:
setDirectURI in interface Source
Parameters:
s_encoded_uri - A url-encoded system-id that references the source.
Throws:
java.io.IOException -  
java.net.MalformedURLException -  

getDirectURI

public org.esau.ptarmigan.util.PtarURI getDirectURI()
Obtain the URL of a local file source (in file:/ form) or if a remote source, a direct link to it.
Specified by:
getDirectURI in interface Source

getDirectSystemId

public java.lang.String getDirectSystemId()
Obtain the URL (as a String) of a local file source (in file:/ form) or if a remote source, a direct link to it.
Specified by:
getDirectSystemId in interface Source

getFile

public java.io.File getFile()
                     throws java.io.IOException
Specified by:
getFile in interface Source

getFilePath

public java.lang.String getFilePath()
                             throws java.io.IOException
Obtain the file path
Specified by:
getFilePath in interface Source
Returns:
null if source is not a file

getFileName

public java.lang.String getFileName()
                             throws java.io.IOException
Obtain the short file name, without root drive or directory prefix
Specified by:
getFileName in interface Source
Returns:
null if source is not a file

getFileExtension

public java.lang.String getFileExtension()
                                  throws java.io.IOException
Obtain the short file name, without root drive or directory prefix
Specified by:
getFileExtension in interface Source
Returns:
null if source is not a file

getIsLocal

public boolean getIsLocal()
Description copied from interface: Source
Return true if the source refers to a local file, as indexed in the mfile table.
Specified by:
getIsLocal in interface Source

getIsOffsite

public boolean getIsOffsite()
Description copied from interface: Source
return true if the source is offsite, i.e., stored on a peer server

Note that this is NOT the same thing as an 'external' source, which is outside the peergroup. An example would be the BBC streaming source.

Specified by:
getIsOffsite in interface Source

getIsTune

public boolean getIsTune()
Description copied from interface: Source
return true if the source refers to a single tune
Specified by:
getIsTune in interface Source

getIsPlaylist

public boolean getIsPlaylist()
Description copied from interface: Source
return true if the source refers to list of tunes
Specified by:
getIsPlaylist in interface Source

toHash

public java.util.Hashtable toHash()
Store the object as a hash suitable for transport over an XML-RPC connection or similar.

Use SourceRec(Hashtable) to transform the data back into an object of this type.

Specified by:
toHash in interface Hashable
Returns:
 

createInstance

public static SourceRec createInstance(java.util.Hashtable hash)
                                throws RecException,
                                       java.net.MalformedURLException
Create a SourceRec object preserved as a hash that has arrived over an XML-RPC connection or similar.

The hash should have been created with toHash().



Copyright © 2001-2002 Reed Esau, All Rights Reserved.