org.netbeans.modules.jellytools.platform/3 3.13

org.netbeans.jellytools.util
Class FolderContext

java.lang.Object
  extended by org.netbeans.jellytools.util.FolderContext

public class FolderContext
extends Object

The FolderContext class contains methods for finding, creating, removing Data Objects, File Objects and Nodes in a given folder (e.g. 'data'). All objects are addresed relatively to the folder.

Usage:

 public class TestTest extends JellyTestCase {
    ...
    public void test() throws Exception {
        // find data folder
        FolderContext df = FolderContext.getDataFolder(this);
        // create folder
        df.createFolder("resources");
        // create file with given content
        DataObject bundle = df.createDataObject("resources/Bundle.properties", "OpenIDE-Module-Name=My Module\n");
        // new from template
        NewWizardOperator.create("Java Package", df.getTreePath("resources"), "org.netbeans.modules");
        Node node = df.getJellyNode("resources|Bundle");
        ...
        // remove garbage
        df.deleteDataObject("resources");
        ...
        // find work dir, create and mount it if necesarry
        FolderContext wd = FolderContext.getWorkDir(this);
        ...
 


Constructor Summary
FolderContext(URL url)
          Creates a new instance of FolderContext.
 
Method Summary
 DataObject createDataObject(String spec, String content)
          Creates Data Object.
 DataObject createFolder(String spec)
          Creates folder.
 void deleteDataObject(String spec)
          Deletes the File Object.
static FolderContext getDataFolder(JellyTestCase test)
          Returns data folder context for given test.
 DataObject getDataObject(String spec)
          Finds the Data Object.
 FileObject getFileObject(String spec)
          Finds the File Object.
 String getTreePath(String path)
          Returns absolute Tree Path.
static FolderContext getWorkDir(JellyTestCase test)
          Returns working directory context for given test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FolderContext

public FolderContext(URL url)
Creates a new instance of FolderContext.

Parameters:
url - folder's URL
Method Detail

getDataFolder

public static FolderContext getDataFolder(JellyTestCase test)
Returns data folder context for given test.

Parameters:
test - the test
Returns:
FolderContext

getWorkDir

public static FolderContext getWorkDir(JellyTestCase test)
                                throws IOException
Returns working directory context for given test. If working directory is not available method tries to creat it.

Parameters:
test - the test
Returns:
FolderContext
Throws:
IOException - if the directory cannot be created

getFileObject

public FileObject getFileObject(String spec)
Finds the File Object. The spec is a "/" separated relative path that identifies the File Object.

Parameters:
spec - File Object's path
Returns:
FileObject

createFolder

public DataObject createFolder(String spec)
                        throws IOException
Creates folder.

Parameters:
spec - folder's relative path separated by '/'
Returns:
DataObject
Throws:
IOException - if the folder cannot be created

createDataObject

public DataObject createDataObject(String spec,
                                   String content)
                            throws IOException
Creates Data Object.

Parameters:
spec - Data Object's relative path separated by '/'
content - Data Object's content
Returns:
DataObject
Throws:
IOException - if the Data Object cannot be created

getDataObject

public DataObject getDataObject(String spec)
Finds the Data Object. The spec is a "/" separated relative path that identifies the Data Object.

Parameters:
spec - Data Object's path
Returns:
Data Object or 'null' if the Data Object does not exist

deleteDataObject

public void deleteDataObject(String spec)
                      throws IOException
Deletes the File Object. The spec is a "/" separated relative path that identifies the File Object.

Parameters:
spec - File Object's path
Throws:
IOException - if something fails

getTreePath

public String getTreePath(String path)
Returns absolute Tree Path.

Parameters:
path - relative path separated by '|'
Returns:
String

org.netbeans.modules.jellytools.platform/3 3.13

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.