com.jalios.jcms
Class ChannelFile

java.lang.Object
  extended by java.io.File
      extended by com.jalios.jcms.ChannelFile
All Implemented Interfaces:
Serializable, Comparable<File>

public class ChannelFile
extends File

ChannelFile is the class of the files belonging to a channel upload tree.

Version:
$Revision: 24265 $
Author:
Cécile Le Pape
See Also:
Serialized Form

Field Summary
static String BYTE_EXT
           
protected  Channel channel
           
static String DEFAULT
           
static String FOLDER
           
static String ICON
           
static String MIME
           
static String PROP
           
static String REVISION
           
static String UNKNOWN_TYPE
           
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
ChannelFile(File parent, String filename)
           
ChannelFile(String pathname)
           
ChannelFile(String pathname, String filename)
           
 
Method Summary
static String compactFile(int maxlength, String s)
          Compact a string, replacing extra characters with dots.
 Channel getChannel()
           
 String getChannelRelativePath()
           
static File getCopyOfFile(File file, String copyPrefix)
          copy a File, adding a prefix to the new file name; Prefixes are indexed in case of multiples copies.
 String getExt()
           
 String getIconPath()
           
 Date getLastModified()
           
 String getLengthToString()
           
static Comparator getModifiedComparator()
           
static Comparator getNameComparator()
           
static Comparator getSizeComparator()
           
 String getType()
           
static Comparator getTypeComparator()
           
 boolean isImage()
           
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

FOLDER

public static final String FOLDER
See Also:
Constant Field Values

DEFAULT

public static final String DEFAULT
See Also:
Constant Field Values

UNKNOWN_TYPE

public static final String UNKNOWN_TYPE
See Also:
Constant Field Values

MIME

public static final String MIME
See Also:
Constant Field Values

ICON

public static final String ICON
See Also:
Constant Field Values

PROP

public static final String PROP
See Also:
Constant Field Values

BYTE_EXT

public static final String BYTE_EXT
See Also:
Constant Field Values

channel

protected Channel channel
Constructor Detail

ChannelFile

public ChannelFile(String pathname)

ChannelFile

public ChannelFile(String pathname,
                   String filename)

ChannelFile

public ChannelFile(File parent,
                   String filename)
Method Detail

getLengthToString

public String getLengthToString()

getIconPath

public String getIconPath()
Returns:
the file icon path relative to the channel path and based on its extension; a default icon path otherwise.

getExt

public String getExt()
Returns:
the file extension if there is one; an empty string otherwise.

isImage

public boolean isImage()
Returns:
true if the file is an image, based on its MIME type; false otherwise.

getType

public String getType()
Returns:
the MIME type of the file; ChannelFile.FOLDER if directory; ChannelFile.UNKNOWN_TYPE if the MIME type is unknown.

getLastModified

public Date getLastModified()
Returns:
the date of the file last modification.

getChannelRelativePath

public String getChannelRelativePath()
Returns:
the file path relative to the channel work directory; null if the channel work directory is invalid.

getChannel

public Channel getChannel()

getNameComparator

public static Comparator getNameComparator()
Returns:
a name comparator based on the String.compareTo(String) method.
Use only with ChannelFile objects.

getSizeComparator

public static Comparator getSizeComparator()
Returns:
a size comparator.
Use only with ChannelFile objects.

getModifiedComparator

public static Comparator getModifiedComparator()
Returns:
a last modified date comparator.
Use only with ChannelFile objects.

getTypeComparator

public static Comparator getTypeComparator()
Returns:
a MIME type comparator.
Use only with ChannelFile objects.
See Also:
getType()

compactFile

public static String compactFile(int maxlength,
                                 String s)
Compact a string, replacing extra characters with dots.

Parameters:
maxlength - the maximum length of the string
s - the string to compact
Returns:
the compacted string

getCopyOfFile

public static File getCopyOfFile(File file,
                                 String copyPrefix)
copy a File, adding a prefix to the new file name; Prefixes are indexed in case of multiples copies.

Parameters:
file - the file to copy
copyPrefix - the new file name prefix; must end with _ (example: copy_).


Copyright © 2001-2010 Jalios SA. All Rights Reserved.