Forge - Shell API 1.2.0.Final

org.jboss.forge.resources
Class DirectoryResource

java.lang.Object
  extended by org.jboss.forge.resources.AbstractResource<File>
      extended by org.jboss.forge.resources.FileResource<DirectoryResource>
          extended by org.jboss.forge.resources.DirectoryResource
All Implemented Interfaces:
Resource<File>

public class DirectoryResource
extends FileResource<DirectoryResource>

A standard, build-in, resource for representing directories on the file-system.

Author:
Mike Brock, Lincoln Baxter, III

Field Summary
 
Fields inherited from class org.jboss.forge.resources.FileResource
file, lastModification, scratch, scratchFile
 
Fields inherited from class org.jboss.forge.resources.AbstractResource
flags, parent, resourceFactory
 
Constructor Summary
DirectoryResource(ResourceFactory factory, File file)
           
 
Method Summary
 DirectoryResource createFrom(File file)
          Create a new Resource instance for the target file.
 DirectoryResource createTempResource()
           
protected  List<Resource<?>> doListResources()
          Strategy method for returning child resources.
 boolean equals(Object obj)
           
 Resource<?> getChild(String name)
          Obtain a reference to the child resource.
 DirectoryResource getChildDirectory(String name)
          Obtain a reference to the child DirectoryResource.
<E,T extends Resource<E>>
T
getChildOfType(Class<T> type, String name)
          Using the given type, obtain a reference to the child resource of the given type.
 String getName()
          Return the common name of the resource.
 DirectoryResource getOrCreateChildDirectory(String name)
           
 Resource<?> getParent()
          Get the parent of the current resource.
 String toString()
           
 
Methods inherited from class org.jboss.forge.resources.FileResource
createNewFile, delete, delete, deleteOnExit, exists, getResourceInputStream, getUnderlyingResourceObject, isDirectory, isStale, markUpToDate, mkdir, mkdirs, reify, renameTo, renameTo, setContents, setContents, setContents
 
Methods inherited from class org.jboss.forge.resources.AbstractResource
getFlags, getFullyQualifiedName, getResourceFactory, hashCode, isFlagSet, listResources, listResources, setFlag, unsetFlag
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectoryResource

public DirectoryResource(ResourceFactory factory,
                         File file)
Method Detail

doListResources

protected List<Resource<?>> doListResources()
Description copied from class: AbstractResource
Strategy method for returning child resources. Subclasses should implement or override this method.

Specified by:
doListResources in class AbstractResource<File>
Returns:

getChild

public Resource<?> getChild(String name)
Obtain a reference to the child resource.

Specified by:
getChild in interface Resource<File>
Overrides:
getChild in class FileResource<DirectoryResource>

getChildDirectory

public DirectoryResource getChildDirectory(String name)
                                    throws ResourceException
Obtain a reference to the child DirectoryResource. If that resource does not exist, return a new instance. If the resource exists and is not a DirectoryResource, throw ResourceException

Throws:
ResourceException

getOrCreateChildDirectory

public DirectoryResource getOrCreateChildDirectory(String name)

getChildOfType

public <E,T extends Resource<E>> T getChildOfType(Class<T> type,
                                                  String name)
                                     throws ResourceException
Using the given type, obtain a reference to the child resource of the given type. If the result is not of the requested type and does not exist, return null. If the result is not of the requested type and exists, throw ResourceException

Throws:
ResourceException

createTempResource

public DirectoryResource createTempResource()
Overrides:
createTempResource in class FileResource<DirectoryResource>

createFrom

public DirectoryResource createFrom(File file)
Description copied from class: FileResource
Create a new Resource instance for the target file. The new Resource should be of the same type as this.

Specified by:
createFrom in interface Resource<File>
Specified by:
createFrom in class FileResource<DirectoryResource>
Parameters:
file - The file to create the resource instance from.
Returns:
A new resource.

getParent

public Resource<?> getParent()
Description copied from class: FileResource
Get the parent of the current resource. Returns null if the current resource is the project root.

Specified by:
getParent in interface Resource<File>
Overrides:
getParent in class FileResource<DirectoryResource>
Returns:
An instance of the resource parent.

getName

public String getName()
Description copied from interface: Resource
Return the common name of the resource. If it's a file, for instance, just the file name.

Specified by:
getName in interface Resource<File>
Overrides:
getName in class FileResource<DirectoryResource>
Returns:
The name of the resource.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class AbstractResource<File>

Forge - Shell API 1.2.0.Final

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.