Class MediaList

java.lang.Object
io.sf.carte.doc.style.css.om.MediaList
All Implemented Interfaces:
MediaQueryList, Serializable, MediaList

public class MediaList extends Object implements MediaQueryList, Serializable
Old MediaList and MediaQueryList implementation, supporting lists of plain media types (not media queries).

You can use it as a faster MediaQueryList implementation when you know that the media does not involve media queries.

See Also:
  • Method Details

    • createMediaList

      public static MediaList createMediaList()
      Create a media list for all media.
      Returns:
      the media list.
    • createMediaList

      public static MediaList createMediaList(String media)
      Create a media list for the given media.
      Parameters:
      media - the media specification.
      Returns:
      the media list.
    • createFromMediaList

      public static MediaList createFromMediaList(MediaList list)
    • createUnmodifiable

      public static MediaList createUnmodifiable()
      Create an unmodifiable media list for all media.
      Returns:
      the unmodifiable media list.
    • createUnmodifiable

      public static MediaList createUnmodifiable(String media)
      Create an unmodifiable media list for the given media.
      Parameters:
      media - the comma-separated list of media. If null, the media list will be for all media.
      Returns:
      the unmodifiable media list.
    • createMediaList

      public static MediaList createMediaList(SACMediaList media)
      Create a media list for the given SAC media list.
      Parameters:
      media - the media list. If null, the list will be for all media.
      Returns:
      the media list.
    • getMedia

      public String getMedia()
      Description copied from interface: MediaQueryList
      Get the serialized form of this media query list.
      Specified by:
      getMedia in interface MediaQueryList
      Returns:
      the serialized form of this media query list.
    • getMediaText

      public String getMediaText()
      Specified by:
      getMediaText in interface MediaList
    • getMinifiedMedia

      public String getMinifiedMedia()
      Description copied from interface: MediaQueryList
      Get a minified serialized form of this media query list.
      Specified by:
      getMinifiedMedia in interface MediaQueryList
      Returns:
      the minified serialized form of this media query list.
    • setMediaText

      public void setMediaText(String mediaText) throws DOMException
      Specified by:
      setMediaText in interface MediaList
      Throws:
      DOMException
    • getLength

      public int getLength()
      Specified by:
      getLength in interface MediaList
    • item

      public String item(int index)
      Specified by:
      item in interface MediaList
    • deleteMedium

      public void deleteMedium(String oldMedium) throws DOMException
      Specified by:
      deleteMedium in interface MediaList
      Throws:
      DOMException
    • appendMedium

      public void appendMedium(String newMedium) throws DOMException
      Specified by:
      appendMedium in interface MediaList
      Throws:
      DOMException
    • isAllMedia

      public boolean isAllMedia()
      Is this an all-media list?
      Specified by:
      isAllMedia in interface MediaQueryList
      Returns:
      true if this list matches all media, false otherwise.
    • isNotAllMedia

      public boolean isNotAllMedia()
      Description copied from interface: MediaQueryList
      Determine if this list is composed only of queries that evaluate to not all.
      Specified by:
      isNotAllMedia in interface MediaQueryList
      Returns:
      true if this list matches no media, false otherwise.
    • hasErrors

      public boolean hasErrors()
      Did this media query list produce errors when being parsed ?
      Specified by:
      hasErrors in interface MediaQueryList
      Returns:
      true if this list come from a media string that produced errors when parsed, false otherwise.
    • getExceptions

      public List<CSSParseException> getExceptions()
      Description copied from interface: MediaQueryList
      Get the exceptions found while parsing the query, if any.
      Specified by:
      getExceptions in interface MediaQueryList
      Returns:
      the exceptions found while parsing the query, or null if no errors were found while parsing the media query.
    • matches

      public boolean matches(MediaQueryList otherMedia)
      Does the given media list contain any media present in this list?
      Specified by:
      matches in interface MediaQueryList
      Parameters:
      otherMedia - the other media list to test.
      Returns:
      true if the other list contains any media which belongs to this list, false otherwise.
    • matches

      public boolean matches(String medium, CSSCanvas canvas)
      Does this list match the given medium-canvas combination?

      Unless medium is a media query string, matches are according to HTML4 spec, section 6.13.

      Specified by:
      matches in interface MediaQueryList
      Parameters:
      medium - the lowercase name of the medium to test for.
      canvas - the canvas where the document is to be rendered, or null if no canvas.
      Returns:
      true if this list matches the supplied media name and canvas, false otherwise.
    • unmodifiable

      public MediaList unmodifiable()
      Gives an unmodifiable view of this media list.
      Returns:
      an unmodifiable view of this media list.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • addListener

      public void addListener(MediaQueryListListener listener) throws DOMException
      Description copied from interface: MediaQueryList
      Appends a listener to the list of media query list listeners, unless it is already in that list.
      Specified by:
      addListener in interface MediaQueryList
      Parameters:
      listener - the listener to be appended.
      Throws:
      DOMException
    • removeListener

      public void removeListener(MediaQueryListListener listener) throws DOMException
      Description copied from interface: MediaQueryList
      Removes a listener from the list of media query list listeners.
      Specified by:
      removeListener in interface MediaQueryList
      Parameters:
      listener - the listener to be removed.
      Throws:
      DOMException