com.jalios.jcms
Class ChannelFile

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

public class ChannelFile
extends java.io.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 java.lang.String BYTE_EXT
           
protected  Channel channel
           
static java.lang.String DEFAULT
           
static java.lang.String FOLDER
           
static java.lang.String ICON
           
static java.lang.String MIME
           
static java.lang.String PROP
           
static java.lang.String REVISION
           
static java.lang.String UNKNOWN_TYPE
           
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
ChannelFile(java.io.File parent, java.lang.String filename)
           
ChannelFile(java.lang.String pathname)
           
ChannelFile(java.lang.String pathname, java.lang.String filename)
           
 
Method Summary
static java.lang.String compactFile(int maxlength, java.lang.String s)
          Compact a string, replacing extra characters with dots.
 Channel getChannel()
           
 java.lang.String getChannelRelativePath()
           
static java.io.File getCopyOfFile(java.io.File file, java.lang.String copyPrefix)
          copy a File, adding a prefix to the new file name; Prefixes are indexed in case of multiples copies.
 java.lang.String getExt()
           
 java.lang.String getIconPath()
           
 java.util.Date getLastModified()
           
 java.lang.String getLengthToString()
           
static java.util.Comparator getModifiedComparator()
           
static java.util.Comparator getNameComparator()
           
static java.util.Comparator getSizeComparator()
           
 java.lang.String getType()
           
static java.util.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 java.lang.String REVISION
See Also:
Constant Field Values

FOLDER

public static final java.lang.String FOLDER
See Also:
Constant Field Values

DEFAULT

public static final java.lang.String DEFAULT
See Also:
Constant Field Values

UNKNOWN_TYPE

public static final java.lang.String UNKNOWN_TYPE
See Also:
Constant Field Values

MIME

public static final java.lang.String MIME
See Also:
Constant Field Values

ICON

public static final java.lang.String ICON
See Also:
Constant Field Values

PROP

public static final java.lang.String PROP
See Also:
Constant Field Values

BYTE_EXT

public static final java.lang.String BYTE_EXT
See Also:
Constant Field Values

channel

protected Channel channel
Constructor Detail

ChannelFile

public ChannelFile(java.lang.String pathname)

ChannelFile

public ChannelFile(java.lang.String pathname,
                   java.lang.String filename)

ChannelFile

public ChannelFile(java.io.File parent,
                   java.lang.String filename)
Method Detail

getLengthToString

public java.lang.String getLengthToString()

getIconPath

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

getExt

public java.lang.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 java.lang.String getType()
Returns:
the MIME type of the file; ChannelFile.FOLDER if directory; ChannelFile.UNKNOWN_TYPE if the MIME type is unknown.

getLastModified

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

getChannelRelativePath

public java.lang.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 java.util.Comparator getNameComparator()
Returns:
a name comparator based on the String.compareTo(String) method.
Use only with ChannelFile objects.

getSizeComparator

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

getModifiedComparator

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

getTypeComparator

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

compactFile

public static java.lang.String compactFile(int maxlength,
                                           java.lang.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 java.io.File getCopyOfFile(java.io.File file,
                                         java.lang.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.