|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knime.core.internal.ReferencedFile
public final class ReferencedFile
A File
wrapper with modifiable parent location. This class is used
in cases in which nested elements keep a file reference and the file location
(particular of the parent or the parent of the parent) may change.
Constructor Summary | |
---|---|
ReferencedFile(File rootDir)
Creates new root element. |
|
ReferencedFile(ReferencedFile parent,
String base)
Creates new sub-element. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
|
File |
getFile()
Get the File representing the full path of this referenced
file element. |
ReferencedFile |
getParent()
Get the parent of this element or null if the file's parent is not represented as a ReferencedFile object. |
int |
hashCode()
|
void |
lock()
Locks this file location. |
boolean |
rename(String newBaseName)
Renames this (base) element as an atomic operation. |
String |
toString()
Get absolute path of the represented file. |
void |
unlock()
Unlocks this file hierarchy. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ReferencedFile(File rootDir)
rootDir
- The parent directory of the referenced file location.
NullPointerException
- If the argument is nullpublic ReferencedFile(ReferencedFile parent, String base)
parent
- The parent locationbase
- The name of this file
NullPointerException
- If either argument is nullMethod Detail |
---|
public void lock()
rename(String)
will block until unlock()
is called.
It will also disable the renaming of any element further up the
hierarchy. Parallel reading of the resource is still possibly.
public void unlock()
lock()
).
IllegalMonitorStateException
- If monitor is not held by current thread.public boolean rename(String newBaseName)
getFile()
exists
, it will also be renamed.
newBaseName
- The new name
NullPointerException
- If argument is nullpublic File getFile()
File
representing the full path of this referenced
file element. Please note that the returned file may be renamed after
this method returns. In order to circumvent this, you typically write
code as follows:
ReferencedFile m_refFile = ... // this element m_refFile.lock(); try { File file = m_refFile.getFile(); // do something with this file } finally { m_refFile.unlock(); }
public ReferencedFile getParent()
ReferencedFile
object.
null
.public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |