1 /*
   2  * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package com.sun.javafx.ext.device.ios.ipod;
  26 
  27 /**
  28  * The MediaFilter class represents a filter that can be used to filter out media items
  29  * from the iPod library. For instance, one can filter out media items of a specific type,
  30  * genre, album title, composer, etc.
  31  * <br/>
  32  * A MediaFilter is defined by its type a and value.
  33  * <br/>
  34  * Valid MediaFilter types are as follows:
  35  * <ul>
  36  * <li><strong>MediaType</strong> - specifies the type of media items, e.g. podcasts, videos, etc. For a list
  37  * of valid media types, see <code>MediaItem.MediaItemType</code> enum values</li>
  38  * <li><strong>Title</strong> - the title (or name) of the media item</li>
  39  * <li><strong>AlbumTitle</strong> - the title of an album, as opposed to the title of an individual song on the
  40  * album</li>
  41  * <li><strong>Artist</strong> - the performing artist(s) for a media item, which may vary from the primary artist
  42  * for the album that a media item belongs to</li>
  43  * <li><strong>AlbumArtist</strong> - the primary performing artist for an album as a whole</li>
  44  * <li><strong>Genre</strong> - the musical or film genre of the media item</li>
  45  * <li><strong>Composer</strong> - the musical composer for the media item</li>
  46  * <li><strong>IsCompilation</strong> - indicates whether the media item is part of a compilation or not. Corresponds to
  47  * the &ldquo;Part of a compilation&rdquo; checkbox in the Info tab in the Get Info dialog in iTunes</li>
  48  * </ul>
  49  *
  50  * Filter values are of the type <code>String</code>, except for the <code>IsCompilation</code> filter type, the value of which
  51  * is a <code>Boolean</code> and except for the <code>MediaType</code> type, the value of which is of the type <code>enum MediaItemType</code>.
  52  * <br/>
  53  * To add a filter to a <code>MediaQuery</code> instance, use <code>MediaQuery.addFilter()</code>.
  54  * <br/>
  55  * To remove a filter from a <code>MediaQuery</code> instance, use <code>MediaQuery.removeFilter()</code>.
  56  */
  57 public class MediaFilter {
  58 
  59     /**
  60      * This enum defines valid values for the MediaFilter's type.
  61      */
  62     public static enum MediaFilterType {
  63         /**
  64          * Specifies the type of media items, for example podcasts, videos, etc. For a list of valid media types,
  65          * see <code>enum MediaItem.MediaItemType</code> values.
  66          */
  67         MediaType(0),
  68         /**
  69          * The title (or name) of the media item.
  70          */
  71         Title(1),
  72         /**
  73          * The title of an album, as opposed to the title of an individual song on the album.
  74          */
  75         AlbumTitle(2),
  76         /**
  77          * The performing artist(s) for a media item, which may vary from the primary artist for the album that a media item belongs to.
  78          */
  79         Artist(3),
  80         /**
  81          * The primary performing artist for an album as a whole.
  82          */
  83         AlbumArtist(4),
  84         /**
  85          * The musical or film genre of the media item.
  86          */
  87         Genre(5),
  88         /**
  89          * The musical composer for the media item.
  90          */
  91         Composer(6),
  92         /**
  93          * Indicates whether the media item is part of a compilation or not. Corresponds to the "Part of a compilation"
  94          * checkbox in the Info tab in the Get Info dialog in iTunes.
  95          */
  96         IsCompilation(7);
  97 
  98         private final int value;
  99 
 100         private MediaFilterType(int value) {
 101             this.value = value;
 102         }
 103 
 104         /**
 105          * Returns the integer value associated with this enum value.
 106          * @return the integer value associated with this enum value.
 107          */
 108         public int getValue() {
 109             return value;
 110         }
 111     }
 112 
 113     private MediaFilterType filterType;
 114     private Object filterValue;
 115 
 116     /**
 117      * Constructs an empty media filter that excludes no media items. Using this filter is equivalent to
 118      * using no filters at all. It is possible to change the filter's type and value later on by calling the
 119      * appropriate setter methods.
 120      */
 121     public MediaFilter() {
 122         this(MediaFilterType.MediaType, MediaItem.MediaItemType.Any);
 123     }
 124 
 125     /**
 126      * Constructs a new media filter of the specified type and value.
 127      *
 128      * @param filterType the filter's type
 129      * @param filterValue the filter's value
 130      */
 131     public MediaFilter(final MediaFilterType filterType, final Object filterValue) {
 132         this.filterType = filterType;
 133         this.filterValue = filterValue;
 134     }
 135 
 136     /**
 137      * Returns this filter's type.
 138      *
 139      * @return this filter's type
 140      */
 141     public MediaFilterType getFilterType() {
 142         return filterType;
 143     }
 144 
 145     /**
 146      * Returns this filter's value
 147      *
 148      * @return this filter's value
 149      */
 150     public Object getFilterValue() {
 151         return filterValue;
 152     }
 153 
 154     /**
 155      * Sets this filter's type
 156      *
 157      * @param filterType the new type of this filter
 158      */
 159     public void setFilterType(final MediaFilterType filterType) {
 160         this.filterType = filterType;
 161     }
 162 
 163     /**
 164      * Sets this filter's value
 165      *
 166      * @param filterValue the new value of this filter
 167      */
 168     public void setFilterValue(final Object filterValue) {
 169         this.filterValue = filterValue;
 170     }
 171 }