public class FolderNode extends Object implements TreeFileDataNode
Modifier | Constructor and Description |
---|---|
|
FolderNode(File file,
UploadPolicy uploadPolicy,
MyTreeTableModel<TreeFileDataNode> model,
FilePanelFlatDataModel2 flatModel)
Creates a node, with no link to any parent.
|
protected |
FolderNode(UploadPolicy uploadPolicy,
MyTreeTableModel<TreeFileDataNode> model,
FilePanelFlatDataModel2 flatModel) |
Modifier and Type | Method and Description |
---|---|
TreeFileDataNode |
addChild(File f)
Adds a given file as a Child of the current node.
|
TreeFileDataNode |
addChild(FileData fileData)
This method adds a new FileData in the children list, for the current object.
|
TreeFileDataNode |
addChild(TreeFileDataNode child)
Add a new child to the children of this folder.
|
int |
addChildAndDescendants(File f)
Adds a given file as a Child of the current node.
|
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 uploadPathRoot)
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.
|
static String |
getAbsolutePath(TreeFileDataNode node)
Retrieves the Absolute Path of a node, within the current visible hierarchy.
|
TreeFileDataNode |
getChild(File file) |
TreeFileDataNode |
getChild(int index)
Get the child with the given index number, from the direct children of this node
|
TreeFileDataNode |
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.
|
protected File |
getFile() |
String |
getFileExtension() |
long |
getFileLength() |
String |
getFileName()
Get the original filename.
|
static String |
getFilename(File file)
Returns the filename of the file.
|
InputStream |
getInputStream()
This function creates an InputStream from this file.
|
static int[] |
getIntArray(int... indexOf) |
static TreeFileDataNode[] |
getItemArray(TreeFileDataNode... child) |
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
|
FolderNode |
getSubfolderOrCreateIt(File file)
This method checks if this the given subfolder has already been created.
|
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 one child from the children list.
|
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.
|
protected FolderNode(UploadPolicy uploadPolicy, MyTreeTableModel<TreeFileDataNode> model, FilePanelFlatDataModel2 flatModel)
public FolderNode(File file, UploadPolicy uploadPolicy, MyTreeTableModel<TreeFileDataNode> model, FilePanelFlatDataModel2 flatModel)
public static String getFilename(File file)
f
- public static String getAbsolutePath(TreeFileDataNode node)
File.separator
. The path starts with a leading File.separator
.node
- public static int[] getIntArray(int... indexOf)
public static TreeFileDataNode[] getItemArray(TreeFileDataNode... child)
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
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 uploadPathRoot) throws JUploadException
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
uploadPathRoot
- 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()
#beforeUpload()
and before the call to FileData.afterUpload()
.getUploadLength
in interface FileData
PictureFileData
public void afterUpload()
PictureFileData.afterUpload()
removes the temporary file, if any
was created.afterUpload
in interface FileData
public InputStream getInputStream() throws JUploadException
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()
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()
getUploadFlag
in interface FileData
public void setUploadFlag(boolean uploadFlag)
setUploadFlag
in interface FileData
public String getDirectory()
getDirectory
in interface FileData
public String getMD5() throws JUploadException
getMD5
in interface FileData
JUploadException
#beforeUpload()
public String getMimeType()
getMimeType
in interface FileData
public boolean canRead()
protected File getFile()
public String getRelativeDir()
getRelativeDir
in interface FileData
public String getAbsolutePath()
getAbsolutePath
in interface FileData
public boolean isPreparedForUpload()
#beforeUpload()
, and the to false in the call to FileData.afterUpload()
.isPreparedForUpload
in interface FileData
public int getChildCount()
getChildCount
in interface MyTreeNode
public TreeFileDataNode getChild(int index)
getChild
in interface MyTreeNode
public TreeFileDataNode getChild(String name)
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 TreeFileDataNode getChild(File file)
public MyTreeNode getParent()
getParent
in interface MyTreeNode
public void setParent(MyTreeNode parent)
setParent
in interface 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)
removeChild
in interface MyTreeNode
child
- The child to removeMyTreeNode.removeChild(wjhk.jupload2.gui.filepanel.treeview.MyTreeNode)
public TreeFileDataNode addChild(FileData fileData)
node
- public TreeFileDataNode addChild(TreeFileDataNode child)
child
- public FolderNode getSubfolderOrCreateIt(File file) throws JUploadExceptionStopAddingFiles
node
- JUploadExceptionStopAddingFiles
public boolean isLeaf()
isLeaf
in interface MyTreeNode
public String toString()
toString
in class Object
Object.toString()
public TreeFileDataNode getTreeFileDataNode()
TreeFileDataNode
, from the hierarchical view.getTreeFileDataNode
in interface FileData
public void setTreeFileDataNode(TreeFileDataNode node)
TreeFileDataNode
, from the hierarchical view. Allows link between the
flat and hierarchical view.setTreeFileDataNode
in interface FileData
public TreePath getTreePath()
TreePath
for this node, in the hierarchy.getTreePath
in interface MyTreeNode
public TreeFileDataNode addChild(File f) throws JUploadExceptionStopAddingFiles
f
- The file to add. If f is a folder, none of its descendants (files, folders) will be added. Only f is
added.JUploadExceptionStopAddingFiles
public int addChildAndDescendants(File f) throws JUploadExceptionStopAddingFiles
f
- The file to add.JUploadExceptionStopAddingFiles
Copyright © 2015. All rights reserved.