Lizzy v1.1.1

christophedelory.content
Class Content

java.lang.Object
  extended by christophedelory.content.Content

public class Content
extends Object

The definition of a content and its metadata.

Version:
$Revision: 92 $
Author:
Christophe Delory

Constructor Summary
Content(String url)
          Builds a new content from the specified URL.
Content(URI uri)
          Builds a new content from the specified URI.
Content(URL url)
          Builds a new content from the specified URL.
 
Method Summary
 void connect()
          Connects to the specified URL, if not already done.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 long getDuration()
          Returns the content duration in milliseconds.
 String getEncoding()
          Returns the content encoding of the resource that the URL references.
 int getHeight()
          Returns the content height in pixels.
 long getLastModified()
          Returns the date the resource that the URL references was last modified.
 long getLength()
          Returns the content length in bytes of the resource that the URL references.
 String getType()
          Returns the content type of the resource that the URL references.
 URI getURI()
          Returns the URI of the content.
 URL getURL()
          Returns the URL of the content.
 int getWidth()
          Returns the content width in pixels.
 int hashCode()
          Returns a hash code value for this object.
 boolean isValid()
          Specifies if the last connection to the content through its URL has been successful or not.
 void setDuration(long duration)
          Initializes the content duration in milliseconds.
 void setEncoding(String encoding)
          Initializes or overrides the content encoding.
 void setHeight(int height)
          Initializes or overrides the content height, in pixels.
 void setLastModified(long lastModified)
          Initializes or overrides the last modified date.
 void setLength(long length)
          Initializes or overrides the content length, in bytes.
 void setType(String type)
          Initializes or overrides the content type.
 void setWidth(int width)
          Initializes or overrides the content width, in pixels.
 String toString()
          Returns the content URL as a string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Content

public Content(String url)
Builds a new content from the specified URL.

Parameters:
url - an URL as a string. Shall not be null.
Throws:
NullPointerException - if url is null.

Content

public Content(URI uri)
Builds a new content from the specified URI.

Parameters:
uri - an URI. Shall not be null.
Throws:
NullPointerException - if uri is null.

Content

public Content(URL url)
Builds a new content from the specified URL.

Parameters:
url - an URL. Shall not be null.
Throws:
NullPointerException - if url is null.
Method Detail

getURI

public URI getURI()
           throws URISyntaxException
Returns the URI of the content.

Returns:
an URI. Shall not be null.
Throws:
SecurityException - if a required system property value cannot be accessed.
URISyntaxException - if this URL is not formatted strictly according to to RFC2396 and cannot be converted to a URI.
See Also:
getURL(), toString()

getURL

public URL getURL()
           throws MalformedURLException
Returns the URL of the content.

Returns:
an URL. Shall not be null.
Throws:
SecurityException - if a required system property value cannot be accessed.
IllegalArgumentException - if the URL is not absolute.
MalformedURLException - if a protocol handler for the URL could not be found, or if some other error occurred while constructing the URL.
See Also:
getURI(), toString()

getEncoding

public String getEncoding()
Returns the content encoding of the resource that the URL references.

Returns:
a content encoding, or null if unknown.
See Also:
setEncoding(java.lang.String)

setEncoding

public void setEncoding(String encoding)
Initializes or overrides the content encoding.

Parameters:
encoding - a content encoding. May be null.
See Also:
getEncoding()

getLength

public long getLength()
Returns the content length in bytes of the resource that the URL references.

Returns:
a content length, or -1L if unknown.
See Also:
setLength(long)

setLength

public void setLength(long length)
Initializes or overrides the content length, in bytes.

Parameters:
length - a content length. May be negative.
See Also:
getLength()

getType

public String getType()
Returns the content type of the resource that the URL references.

Returns:
a content type, or null if unknown.
See Also:
setType(java.lang.String)

setType

public void setType(String type)
Initializes or overrides the content type.

Parameters:
type - a content type. May be null.
See Also:
getType()

getLastModified

public long getLastModified()
Returns the date the resource that the URL references was last modified. The value is the number of milliseconds since January 1, 1970 GMT.

Returns:
a date, or 0L if unknown.
See Also:
setLastModified(long)

setLastModified

public void setLastModified(long lastModified)
Initializes or overrides the last modified date.

Parameters:
lastModified - a date. May be negative or null.
See Also:
getLastModified()

getDuration

public long getDuration()
Returns the content duration in milliseconds.

Returns:
a duration value. May be negative if unknown.
See Also:
setDuration(long)

setDuration

public void setDuration(long duration)
Initializes the content duration in milliseconds.

Parameters:
duration - a duration value. May be negative if unknown.
See Also:
getDuration()

getWidth

public int getWidth()
Returns the content width in pixels.

Returns:
a width, or -1 if unknown.
Since:
1.0.0
See Also:
setWidth(int)

setWidth

public void setWidth(int width)
Initializes or overrides the content width, in pixels.

Parameters:
width - a width. May be negative if unknown.
Since:
1.0.0
See Also:
getWidth()

getHeight

public int getHeight()
Returns the content height in pixels.

Returns:
an height, or -1 if unknown.
Since:
1.0.0
See Also:
setHeight(int)

setHeight

public void setHeight(int height)
Initializes or overrides the content height, in pixels.

Parameters:
height - an height. May be negative if unknown.
Since:
1.0.0
See Also:
getHeight()

isValid

public boolean isValid()
Specifies if the last connection to the content through its URL has been successful or not. If true, the content metadata may be pertinent.

Returns:
true if the content has been successfully accessed through its URL, false otherwise.
See Also:
connect()

connect

public void connect()
             throws IOException
Connects to the specified URL, if not already done.

Throws:
SecurityException - if a required system property value cannot be accessed.
IllegalArgumentException - if the URL is not absolute.
MalformedURLException - if a protocol handler for the URL could not be found, or if some other error occurred while constructing the URL.
IOException - if any I/O error occurs.
SocketTimeoutException - if the timeout expires before the connection can be established.
See Also:
getURL()

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one. Two objects are the same if their string representations are the same. Examples of valid instances for obj: Content, URL, URI, String, etc.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare. May be null.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
toString()

hashCode

public int hashCode()
Returns a hash code value for this object. This method is supported for the benefit of hashtables such as those provided by Hashtable.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
Since:
1.0.0

toString

public String toString()
Returns the content URL as a string.

Overrides:
toString in class Object
Returns:
an URL as a string.
See Also:
getURL(), getURI()

© 2008-2009 Christophe Delory

Copyright © 2008-2009 Christophe Delory. All Rights Reserved.