com.glaivestone.javax.io
Class FileType

java.lang.Object
  |
  +--com.glaivestone.javax.lang.ConstantType
        |
        +--com.glaivestone.javax.io.FileType

public class FileType
extends ConstantType

A FileType constant identifies a specific file type and defines standard attributes such as a brief description and the extension used with the file type.

Constant definitions are provided for some standard, widely-used file types that are common in Java programs. File types are an open-ended set of constants. Additional constants can be created for file types used in your application using the static defineConstant service. A file type definition should typically be used to create a static constant in your application.

Implementation Notes

This class can be subclassed to provide extended attributes of a FileType. If so, the constants should be allocated within the ordinal space of the FileType class itself, i.e., subclasses should not define a separate ordinal allocation counter and the constants must be registered under this class. Subclasses must override the static defineConstant method to throw an IllegalOperationException and implement an equivalent definition service with parameters for the additional properties defined in the subclass.

Author:
Deb Lewis

Field Summary
 java.lang.String description
          Brief description of this file type.
 java.lang.String extension
          The file name extension used for this file type.
static FileType GIF
           
static FileType HTML
           
static FileType JAR
           
static FileType JPEG
           
static FileType TEXT
           
static FileType XML
           
static FileType ZIP
           
 
Fields inherited from class com.glaivestone.javax.lang.ConstantType
name, ord
 
Method Summary
 java.lang.String composeFileName(java.lang.String fileBaseName)
          Answer the file name formed by appending the receiver's extension to the specified base file name.
static FileType defineConstant(java.lang.String name, java.lang.String extension, java.lang.String description)
          Creates a constant with the given name and extension and a unique ordinal value.
static FileType getConstant(int ordinalValue)
          Answer the constant of this type with the specified ordinal value.
static FileType getConstant(java.lang.String name)
          Answer the constant of this type with the specified name.
 boolean sameExtension(java.io.File aFile)
          Answer whether the specified file has the same extension of this file type.
 
Methods inherited from class com.glaivestone.javax.lang.ConstantType
getConstant, getConstant, intValue, toConstantName, toDescriptionString, toIdentificationString, toQualifiedConstantName, toSimpleConstantName, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TEXT

public static final FileType TEXT

HTML

public static final FileType HTML

XML

public static final FileType XML

GIF

public static final FileType GIF

JPEG

public static final FileType JPEG

JAR

public static final FileType JAR

ZIP

public static final FileType ZIP

description

public final java.lang.String description
Brief description of this file type.


extension

public final java.lang.String extension
The file name extension used for this file type.

Method Detail

defineConstant

public static FileType defineConstant(java.lang.String name,
                                      java.lang.String extension,
                                      java.lang.String description)
Creates a constant with the given name and extension and a unique ordinal value.

Throws:
java.lang.IllegalArgumentException - invalid or duplicate properties

getConstant

public static FileType getConstant(int ordinalValue)
Answer the constant of this type with the specified ordinal value.


getConstant

public static FileType getConstant(java.lang.String name)
Answer the constant of this type with the specified name.


composeFileName

public java.lang.String composeFileName(java.lang.String fileBaseName)
Answer the file name formed by appending the receiver's extension to the specified base file name.


sameExtension

public boolean sameExtension(java.io.File aFile)
Answer whether the specified file has the same extension of this file type.


GFL 1.1 API