java.lang.Object
org.cybergarage.upnp.Icon

public class Iconextends Object
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 Type
    Field
    Description
    private byte[]
    /////////////////////////////////////////////
    private static final String
    /////////////////////////////////////////////
    static final String
    XML 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

    Constructors
    Constructor
    Description
    Creates a new Icon with a default XML node structure.
    Icon(Node node)
    Creates an Icon from an existing XML node.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Gets the raw image data for this icon.
    int
    Gets the color depth of the icon.
    int
    Gets the height of the icon.
    Gets the underlying XML node for this icon.
    Gets the MIME type of the icon.
    Gets the URL where the icon image can be retrieved.
    Gets the user-defined data associated with this icon.
    int
    Gets the width of the icon.
    boolean
    Checks if this icon has raw image data set.
    boolean
    Checks if the icon has a valid MIME type set.
    boolean
    Checks if the icon has a valid URL set.
    static boolean
    Checks if the given XML node represents an icon.
    boolean
    Checks if the given URL matches this icon's URL.
    void
    setBytes(byte[] data)
    Sets the raw image data for this icon.
    void
    setDepth(int value)
    Sets the color depth of the icon as an integer.
    void
    Sets the color depth of the icon as a string.
    void
    setHeight(int value)
    Sets the height of the icon as an integer.
    void
    Sets the height of the icon as a string.
    void
    Sets the MIME type of the icon.
    void
    setURL(String value)
    Sets the URL where the icon image can be retrieved.
    void
    Sets user-defined data associated with this icon.
    void
    setWidth(int value)
    Sets the width of the icon as an integer.
    void
    Sets the width of the icon as a string.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ELEM_NAME

      public static final String ELEM_NAME
      XML element name for icon nodes.
      See Also:
    • iconNode

      private Node iconNode
      /////////////////////////////////////////////
    • MIME_TYPE

      private static final String MIME_TYPE
      /////////////////////////////////////////////
      See Also:
    • WIDTH

      private static final String WIDTH
      /////////////////////////////////////////////
      See Also:
    • HEIGHT

      private static final String HEIGHT
      /////////////////////////////////////////////
      See Also:
    • DEPTH

      private static final String DEPTH
      /////////////////////////////////////////////
      See Also:
    • URL

      private static final String URL
      /////////////////////////////////////////////
      See Also:
    • userData

      private Object userData
      /////////////////////////////////////////////
    • bytes

      private byte[] bytes
      /////////////////////////////////////////////
  • Constructor Details

    • Icon

      public Icon(Node node)
      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

      public Node getIconNode()
      Gets the underlying XML node for this icon.
      Returns:
      the XML node containing icon data
    • isIconNode

      public static boolean isIconNode(Node node)
      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

      public void setMimeType(String value)
      Sets the MIME type of the icon.
      Parameters:
      value - the MIME type (e.g., "image/png", "image/jpeg")
    • getMimeType

      public String getMimeType()
      Gets the MIME type of the icon.
      Returns:
      the MIME type of the icon
    • 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

      public void setWidth(String value)
      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

      public void setHeight(String value)
      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

      public void setDepth(String value)
      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

      public void setURL(String value)
      Sets the URL where the icon image can be retrieved.
      Parameters:
      value - the URL of the icon image
    • getURL

      public String 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

      public boolean isURL(String url)
      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

      public void setUserData(Object data)
      Sets user-defined data associated with this icon.
      Parameters:
      data - the user data object to associate
    • getUserData

      public Object 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