public class FileDataNode extends Object implements TreeFileDataNode
Constructor and Description |
---|
FileDataNode(FileData fileData) |
Modifier and Type | Method and Description |
---|---|
void |
afterUpload()
This function is called after upload, whether it is successful or not.
|
void |
appendFileProperties(ByteArrayEncoder bae,
int index)
Called during the upload, by the
FileUploadThread . |
void |
beforeUpload(String uploadFileRoot)
Prepare the fileData to upload.
|
boolean |
canRead()
Indicate if this file can be read.
|
String |
getAbsolutePath()
Returns the absolute path, as it will be sent during the upload.
|
MyTreeNode |
getChild(int index)
Get the child with the given index number, from the direct children of this node
|
MyTreeNode |
getChild(String name)
Get the child with the name, from the direct children of this node.
|
int |
getChildCount()
Returns the number of direct children for this node
|
List<MyTreeNode> |
getChildren()
Returns the list of direct children for this node
|
String |
getDirectory()
Get the directory of the file.
|
File |
getFile() |
String |
getFileExtension() |
long |
getFileLength() |
String |
getFileName()
Get the original filename.
|
InputStream |
getInputStream()
This function creates an InputStream from this file.
|
Date |
getLastModified() |
String |
getMD5()
Retrieves the MD5 sum of the file.
|
String |
getMimeType()
This function return the FileData content type.
|
MyTreeNode |
getParent()
Returns the parent for this node.
|
String |
getRelativeDir()
Retrieves the path of this file relative to the root directory
|
int |
getTotalChildCount()
Returns the number of children (direct children children of children...) for this node
|
TreeFileDataNode |
getTreeFileDataNode()
Links this FileData to the associated
TreeFileDataNode , from the hierarchical view. |
TreePath |
getTreePath()
Get the
TreePath for this node, in the hierarchy. |
boolean |
getUploadFlag()
Indicates whether the check box is checked or not.
|
long |
getUploadLength()
Get size of upload, which may be different from the actual file length.
|
boolean |
isLeaf()
Indicates whether this node has children or not ('terminal' node)
|
boolean |
isPreparedForUpload()
Indicates whether the file can be uploaded or not.
|
void |
removeChild(MyTreeNode child)
Removes a child from the children of this node.
|
void |
setFlatModel(FilePanelFlatDataModel2 flatModel)
Sets the flat model for the current node.
|
void |
setParent(MyTreeNode parent)
Sets the parent for this node.
|
void |
setTreeFileDataNode(TreeFileDataNode node)
Setters for the to the associated
TreeFileDataNode , from the hierarchical view. |
void |
setTreeModel(TreeModel model)
Sets the tree model for the current node.
|
void |
setUploadFlag(boolean uploadFlag)
Allows to set or unset the upload flag.
|
String |
toString()
Important: this method is called by the JTree class, as the 'main' name for the node.
|
public int getTotalChildCount()
MyTreeNode
getTotalChildCount
in interface MyTreeNode
MyTreeNode.getTotalChildCount()
public List<MyTreeNode> getChildren()
MyTreeNode
getChildren
in interface MyTreeNode
public void appendFileProperties(ByteArrayEncoder bae, int index) throws JUploadIOException
FileData
FileUploadThread
. The FileData instance should then call the
ByteArrayEncoder.appendTextProperty(String, String, int)
method to add each file property to the current
upload.appendFileProperties
in interface FileData
bae
- The byte encoder, where the properties must be addedindex
- Index of the file concerned by this value. -1 if this is a global parameter.JUploadIOException
- Encapsulation of the IOException, if any would occurs.ByteArrayEncoder.appendTextProperty(String, String, int)
public void beforeUpload(String uploadFileRoot) throws JUploadException
FileData
PictureFileData
. This method is called before the upload of this file. If no exception is thrown, then
the file is correctly prepared.beforeUpload
in interface FileData
uploadFileRoot
- The biggest path which is common to all uploaded files. Used to calculate the relativeDir
to this root path, for each file. This relative path is sent as metadata during the uploadJUploadException
- Encapsulation of the Exception, if any error would occurs.FileUploadThread
,
FileData.getRelativeDir()
public long getUploadLength()
FileData
#beforeUpload()
and before the call to FileData.afterUpload()
.getUploadLength
in interface FileData
PictureFileData
public void afterUpload()
FileData
PictureFileData.afterUpload()
removes the temporary file, if any
was created.afterUpload
in interface FileData
public InputStream getInputStream() throws JUploadException
FileData
FileUploadThread
class then reads bytes from it
and transfers them to the webserver. The caller is responsible for closing this stream.FileData.isPreparedForUpload()
returns true.getInputStream
in interface FileData
JUploadException
- Encapsulation of the Exception, if any would occurs.public String getFileName()
FileData
getFileName
in interface FileData
public String getFileExtension()
getFileExtension
in interface FileData
public long getFileLength()
getFileLength
in interface FileData
public Date getLastModified()
getLastModified
in interface FileData
public boolean getUploadFlag()
FileData
getUploadFlag
in interface FileData
public void setUploadFlag(boolean uploadFlag)
FileData
setUploadFlag
in interface FileData
public String getDirectory()
FileData
getDirectory
in interface FileData
public String getMD5() throws JUploadException
FileData
getMD5
in interface FileData
JUploadException
#beforeUpload()
public String getMimeType()
FileData
getMimeType
in interface FileData
public boolean canRead()
FileData
public File getFile()
public String getRelativeDir()
FileData
getRelativeDir
in interface FileData
public String getAbsolutePath()
FileData
getAbsolutePath
in interface FileData
public boolean isPreparedForUpload()
FileData
#beforeUpload()
, and the to false in the call to FileData.afterUpload()
.isPreparedForUpload
in interface FileData
public int getChildCount()
MyTreeNode
getChildCount
in interface MyTreeNode
public MyTreeNode getChild(int index)
MyTreeNode
getChild
in interface MyTreeNode
public MyTreeNode getChild(String name)
MyTreeNode
getChild
in interface MyTreeNode
name
- The name of the item we're looking for. For a file, it's the filename, not the absolute path.public MyTreeNode getParent()
MyTreeNode
getParent
in interface MyTreeNode
public void setParent(MyTreeNode parent)
MyTreeNode
setParent
in interface MyTreeNode
MyTreeNode.setParent(MyTreeNode)
public void setTreeModel(TreeModel model)
MyTreeNode
TreeModelEvent
.setTreeModel
in interface MyTreeNode
model
- The model in which this node is, and to which TreeModelEvent
must be sent.MyTreeNode.setTreeModel(TreeModel)
public void setFlatModel(FilePanelFlatDataModel2 flatModel)
setFlatModel
in interface MyTreeNode
flatModel
- The model, which must be kept synchronized.public void removeChild(MyTreeNode child)
MyTreeNode
removeChild
in interface MyTreeNode
child
- The child to removepublic boolean isLeaf()
MyTreeNode
isLeaf
in interface MyTreeNode
public String toString()
toString
in class Object
Object.toString()
public TreeFileDataNode getTreeFileDataNode()
FileData
TreeFileDataNode
, from the hierarchical view.getTreeFileDataNode
in interface FileData
public void setTreeFileDataNode(TreeFileDataNode node)
FileData
TreeFileDataNode
, from the hierarchical view. Allows link between the
flat and hierarchical view.setTreeFileDataNode
in interface FileData
public TreePath getTreePath()
MyTreeNode
TreePath
for this node, in the hierarchy.getTreePath
in interface MyTreeNode
Copyright © 2015. All rights reserved.