Lizzy v1.1.1

christophedelory.content.type
Class ContentType

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by christophedelory.content.type.ContentType
All Implemented Interfaces:
Cloneable

public class ContentType
extends FileFilter
implements Cloneable

Defines a mapping between a group of one or more file extensions, and a group of one or more MIME type. MIME stands for Multipurpose Internet Mail Extension, as defined in RFC 2045 and 2046.

Version:
$Revision: 92 $
Author:
Christophe Delory

Constructor Summary
ContentType(String[] extensions, String[] mimeTypes, PlayerSupport[] playerSupports, String description)
          Builds a new content type from the input parameters.
 
Method Summary
 boolean accept(File f)
          Tests whether the name of the given file matches the specified file extension pattern.
 Object clone()
          Creates and returns a "shallow" copy of this object.
 String getDescription()
          Returns the friendly description of the content type.
 String[] getExtensions()
          Returns the list of file extensions.
 String[] getMimeTypes()
          Returns the list of MIME types.
 PlayerSupport[] getPlayerSupports()
          Returns the list of players supporting this type of content.
 boolean matchExtension(String pattern)
          Tests whether this content type matches the specified file extension pattern.
 void setDescription(String description)
          Initializes the friendly description of the content type.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentType

public ContentType(String[] extensions,
                   String[] mimeTypes,
                   PlayerSupport[] playerSupports,
                   String description)
Builds a new content type from the input parameters. The extensions shall include the dot ('.') character, if needed. All input strings are converted to lower case using the default locale.

Parameters:
extensions - an array of file extensions. Shall not be null.
mimeTypes - an array of MIME types. Shall not be null.
playerSupports - an array of player support information. May be null.
description - a (friendly) description of the new content type. May be null.
Throws:
NullPointerException - if extensions or one of its component is null.
NullPointerException - if mimeTypes or one of its component is null.
IllegalArgumentException - if extensions has no items (empty array).
IllegalArgumentException - if mimeTypes has no items (empty array).
See Also:
String.toLowerCase(Locale)
Method Detail

getExtensions

public String[] getExtensions()
Returns the list of file extensions. The extensions may include the dot ('.') character, if it is part of the file extension.

Returns:
an array of extensions. Shall not be null nor empty.

getMimeTypes

public String[] getMimeTypes()
Returns the list of MIME types.

Returns:
an array of MIME types. Shall not be null nor empty.

getPlayerSupports

public PlayerSupport[] getPlayerSupports()
Returns the list of players supporting this type of content.

Returns:
an array of playlist support information. May be empty but not null.
Since:
0.2.0

getDescription

public String getDescription()
Returns the friendly description of the content type.

Specified by:
getDescription in class FileFilter
Returns:
a content type description. May be null.
See Also:
setDescription(java.lang.String), FileFilter.getDescription()

setDescription

public void setDescription(String description)
Initializes the friendly description of the content type.

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

matchExtension

public boolean matchExtension(String pattern)
Tests whether this content type matches the specified file extension pattern. The input pattern is first converted to lower case, using the default locale.

Parameters:
pattern - a file name, or more generally a pattern including a file extension. Shall not be null.
Returns:
true if pattern matches this content type.
Throws:
NullPointerException - if pattern is null.
See Also:
getExtensions(), String.toLowerCase(Locale), String.endsWith(java.lang.String)

accept

public boolean accept(File f)
Tests whether the name of the given file matches the specified file extension pattern.
CAUTION: this method accepts also all directories, in order to be properly used with a JFileChooser.

Specified by:
accept in class FileFilter
Parameters:
f - the file to test. Shall not be null.
Returns:
true if the file extension matches this content type.
Throws:
NullPointerException - if f is null.
See Also:
matchExtension(java.lang.String)

clone

public Object clone()
             throws CloneNotSupportedException
Creates and returns a "shallow" copy of this object.

Overrides:
clone in class Object
Returns:
a clone of this instance.
Throws:
CloneNotSupportedException - shall not be thrown, because this class is cloneable.
Since:
1.0.0
See Also:
Object.clone()

© 2008-2009 Christophe Delory

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