Forge - Shell API 1.2.0.Final

org.jboss.forge.resources
Class PropertiesFileResource

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

public class PropertiesFileResource
extends FileResource<PropertiesFileResource>

A property based resource

Author:
George Gastaldi

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
PropertiesFileResource(ResourceFactory factory)
           
PropertiesFileResource(ResourceFactory factory, File file)
           
 
Method Summary
 Resource<File> createFrom(File file)
          Create a new Resource instance for the target file.
protected  List<Resource<?>> doListResources()
          Strategy method for returning child resources.
 Set<String> getKeys()
          Returns the keys in this properties file
 String getProperty(String key)
          Returns the value related to the key in this properties file
 void putAllProperties(Map<String,String> newProperties)
          Adds all the properties and updates the file
 String putProperty(String key, String value)
          Adds a property to this resource
 String removeProperty(String key)
          Removes an entry on this file based on the properties file
 void replaceProperties(Map<String,String> newProperties)
          Replaces all the occurrences
 String toString()
           
 
Methods inherited from class org.jboss.forge.resources.FileResource
createNewFile, createTempResource, delete, delete, deleteOnExit, exists, getChild, getName, getParent, getResourceInputStream, getUnderlyingResourceObject, isDirectory, isStale, markUpToDate, mkdir, mkdirs, reify, renameTo, renameTo, setContents, setContents, setContents
 
Methods inherited from class org.jboss.forge.resources.AbstractResource
equals, 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

PropertiesFileResource

@Inject
public PropertiesFileResource(ResourceFactory factory)

PropertiesFileResource

public PropertiesFileResource(ResourceFactory factory,
                              File file)
Method Detail

createFrom

public Resource<File> 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<PropertiesFileResource>
Parameters:
file - The file to create the resource instance from.
Returns:
A new resource.

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:

putProperty

public String putProperty(String key,
                          String value)
Adds a property to this resource

Parameters:
key -
value -
Returns:
old value or null if none

putAllProperties

public void putAllProperties(Map<String,String> newProperties)
Adds all the properties and updates the file

Parameters:
newProperties -

replaceProperties

public void replaceProperties(Map<String,String> newProperties)
Replaces all the occurrences

Parameters:
newProperties -

removeProperty

public String removeProperty(String key)
Removes an entry on this file based on the properties file

Parameters:
key -
Returns:

getProperty

public String getProperty(String key)
Returns the value related to the key in this properties file

Parameters:
key -
Returns:

getKeys

public Set<String> getKeys()
Returns the keys in this properties file

Returns:

toString

public String toString()
Overrides:
toString in class Object

Forge - Shell API 1.2.0.Final

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