public class ExtendedWorkspaceDocumentManagerImpl extends WorkspaceDocumentManagerImpl
WorkspaceDocumentManagerImpl.DocumentPair
Modifier and Type | Method and Description |
---|---|
void |
closeFile(Path filePath)
Close the given file in document manager.
|
void |
disableExplicitMode(Lock lock)
Disables explicit mode.
|
Optional<Lock> |
enableExplicitMode(Path tempFile)
Enables explicit mode.
|
String |
getFileContent(Path filePath)
Returns the content of the file.
|
static ExtendedWorkspaceDocumentManagerImpl |
getInstance() |
boolean |
isFileOpen(Path filePath)
Checks whether the given file is open in workspace.
|
Optional<Lock> |
openFile(Path filePath,
String content)
Opens the given file in document manager.
|
Optional<Lock> |
updateFile(Path filePath,
String updatedContent)
Updates given file in document manager with new content.
|
clearAllFilePaths, getAllFilePaths, lockFile
public static ExtendedWorkspaceDocumentManagerImpl getInstance()
public boolean isFileOpen(Path filePath)
isFileOpen
in interface WorkspaceDocumentManager
isFileOpen
in class WorkspaceDocumentManagerImpl
filePath
- Path of the filepublic Optional<Lock> openFile(Path filePath, String content) throws WorkspaceDocumentException
openFile
in interface WorkspaceDocumentManager
openFile
in class WorkspaceDocumentManagerImpl
filePath
- Path of the filecontent
- Content of the fileLock
retrieving a lock for the file. You must call Lock.unlock() once you are done with the work.WorkspaceDocumentException
- when file cannot be opened.public Optional<Lock> updateFile(Path filePath, String updatedContent) throws WorkspaceDocumentException
Optional<Lock> lock = Optional.empty(); try { lock = documentManager.updateFile(filePath, ""); } finally { lock.ifPresent(Lock:unlock); }
updateFile
in interface WorkspaceDocumentManager
updateFile
in class WorkspaceDocumentManagerImpl
filePath
- Path of the fileupdatedContent
- New content of the fileLock
retrieving a lock for the file. You must call Lock.unlock() once you are done with the work.WorkspaceDocumentException
- when file cannot be updated.public void closeFile(Path filePath) throws WorkspaceDocumentException
closeFile
in interface WorkspaceDocumentManager
closeFile
in class WorkspaceDocumentManagerImpl
filePath
- Path of the fileWorkspaceDocumentException
- when file cannot be closed.public String getFileContent(Path filePath) throws WorkspaceDocumentException
getFileContent
in interface WorkspaceDocumentManager
getFileContent
in class WorkspaceDocumentManagerImpl
filePath
- Path of the fileWorkspaceDocumentException
- when file cannot be read.public Optional<Lock> enableExplicitMode(Path tempFile)
Optional<Lock> lock = documentManager.enableExplicitMode(tempFile); try { //your code } finally { documentManager.disableExplicitMode(lock.orElse(null)); }
tempFile
- temp file pathdisableExplicitMode(Lock)
public void disableExplicitMode(Lock lock)
Optional<Lock> lock = documentManager.enableExplicitMode(tempFile); try { //your code } finally { documentManager.disableExplicitMode(lock.orElse(null)); }
lock
- that returned from enableExplicitModeenableExplicitMode(java.nio.file.Path)
Copyright © 2019 WSO2. All rights reserved.