java.lang.Object
org.cybergarage.upnp.Icon
Represents a UPnP device icon with its associated metadata and image data.
This class encapsulates the properties of a UPnP device icon as defined in the UPnP Device Architecture specification. Each icon has properties such as MIME type, width, height, color depth, and URL. The class also supports storing the actual icon image data as a byte array.
Icons are used by UPnP devices to provide visual representations that can be displayed in control point applications or user interfaces.
Field Summary
Modifier and TypeFieldDescriptionprivate byte[]/////////////////////////////////////////////private static final String/////////////////////////////////////////////static final StringXML element name for icon nodes.private static final String/////////////////////////////////////////////private Node/////////////////////////////////////////////private static final String/////////////////////////////////////////////private static final String/////////////////////////////////////////////private Object/////////////////////////////////////////////private static final String/////////////////////////////////////////////Constructor Summary
Method Summary
Modifier and TypeMethodDescriptionbyte[]getBytes()Gets the raw image data for this icon.intgetDepth()Gets the color depth of the icon.intGets the height of the icon.Gets the underlying XML node for this icon.Gets the MIME type of the icon.getURL()Gets the URL where the icon image can be retrieved.Gets the user-defined data associated with this icon.intgetWidth()Gets the width of the icon.booleanhasBytes()Checks if this icon has raw image data set.booleanChecks if the icon has a valid MIME type set.booleanhasURL()Checks if the icon has a valid URL set.static booleanisIconNode(Node node) Checks if the given XML node represents an icon.booleanChecks if the given URL matches this icon's URL.voidsetBytes(byte[] data) Sets the raw image data for this icon.voidsetDepth(int value) Sets the color depth of the icon as an integer.voidSets the color depth of the icon as a string.voidsetHeight(int value) Sets the height of the icon as an integer.voidSets the height of the icon as a string.voidsetMimeType(String value) Sets the MIME type of the icon.voidSets the URL where the icon image can be retrieved.voidsetUserData(Object data) Sets user-defined data associated with this icon.voidsetWidth(int value) Sets the width of the icon as an integer.voidSets the width of the icon as a string.
Field Details
ELEM_NAME
iconNode
/////////////////////////////////////////////MIME_TYPE
/////////////////////////////////////////////- See Also:
WIDTH
/////////////////////////////////////////////- See Also:
HEIGHT
/////////////////////////////////////////////- See Also:
DEPTH
/////////////////////////////////////////////- See Also:
URL
/////////////////////////////////////////////- See Also:
userData
/////////////////////////////////////////////bytes
private byte[] bytes/////////////////////////////////////////////
Constructor Details
Icon
Creates an Icon from an existing XML node.- Parameters:
node- the XML node containing icon data
Icon
public Icon()Creates a new Icon with a default XML node structure.
Method Details
getIconNode
Gets the underlying XML node for this icon.- Returns:
- the XML node containing icon data
isIconNode
Checks if the given XML node represents an icon.- Parameters:
node- the XML node to check- Returns:
- true if the node is an icon node, false otherwise
setMimeType
Sets the MIME type of the icon.- Parameters:
value- the MIME type (e.g., "image/png", "image/jpeg")
getMimeType
hasMimeType
public boolean hasMimeType()Checks if the icon has a valid MIME type set.- Returns:
- true if a MIME type is set and not empty, false otherwise
setWidth
Sets the width of the icon as a string.- Parameters:
value- the width as a string
setWidth
public void setWidth(int value) Sets the width of the icon as an integer.- Parameters:
value- the width in pixels
getWidth
public int getWidth()Gets the width of the icon.- Returns:
- the width in pixels, or 0 if not set or invalid
setHeight
Sets the height of the icon as a string.- Parameters:
value- the height as a string
setHeight
public void setHeight(int value) Sets the height of the icon as an integer.- Parameters:
value- the height in pixels
getHeight
public int getHeight()Gets the height of the icon.- Returns:
- the height in pixels, or 0 if not set or invalid
setDepth
Sets the color depth of the icon as a string.- Parameters:
value- the color depth as a string
setDepth
public void setDepth(int value) Sets the color depth of the icon as an integer.- Parameters:
value- the color depth in bits per pixel
getDepth
public int getDepth()Gets the color depth of the icon.- Returns:
- the color depth in bits per pixel, or 0 if not set or invalid
setURL
Sets the URL where the icon image can be retrieved.- Parameters:
value- the URL of the icon image
getURL
Gets the URL where the icon image can be retrieved.- Returns:
- the URL of the icon image
hasURL
public boolean hasURL()Checks if the icon has a valid URL set.- Returns:
- true if a URL is set and not empty, false otherwise
isURL
Checks if the given URL matches this icon's URL.- Parameters:
url- the URL to compare- Returns:
- true if the URLs match, false otherwise
setUserData
Sets user-defined data associated with this icon.- Parameters:
data- the user data object to associate
getUserData
Gets the user-defined data associated with this icon.- Returns:
- the user data object, or null if not set
setBytes
public void setBytes(byte[] data) Sets the raw image data for this icon.- Parameters:
data- the byte array containing the icon image data
hasBytes
public boolean hasBytes()Checks if this icon has raw image data set.- Returns:
- true if image data is available, false otherwise
getBytes
public byte[] getBytes()Gets the raw image data for this icon.- Returns:
- the byte array containing the icon image data, or null if not set