com.triadsoft.common.properties
Class PropertyFile

java.lang.Object
  extended by com.triadsoft.common.properties.PropertyElement
      extended by com.triadsoft.common.properties.PropertyFile
All Implemented Interfaces:
IPropertyFileListener

public class PropertyFile
extends PropertyElement
implements IPropertyFileListener

Esta clase es la encargada de parsear un archivo de properties, y dividirlo en categorias y entradas. Tambien se puede persistir mediante el metodo save

Author:
Triad (flores.leonardo@triadsoft.com.ar)

Field Summary
static java.lang.String DEFAULT_EXTENSION
           
 
Fields inherited from class com.triadsoft.common.properties.PropertyElement
NO_CHILDREN
 
Constructor Summary
PropertyFile(java.io.File file)
           
PropertyFile(IFile file)
          Permite crear un property file a partir de un IFile
 
Method Summary
 void addCategory(PropertyCategory category)
           
 void addPropertyFileListener(IPropertyFileListener listener)
           
 java.lang.String asText()
          Convierte el PropertyFile en texto
 void categoryAdded(PropertyCategory category)
           
 void categoryRemoved(PropertyCategory category)
           
 void entryAdded(PropertyCategory category, PropertyEntry entry)
           
 void entryRemoved(PropertyCategory category, PropertyEntry entry)
           
 boolean exist(java.lang.String propertyName)
          Devuelve verdadero si existe la propiedad en el archivo
 boolean existCategory(java.lang.String categoryName)
          Devuelve true, si existe una categoria con este nombre
 void fileChanged(PropertyFile propertyFile)
           
 PropertyCategory getCategoryByName(java.lang.String categoryName)
          Devuelve una categoria a partir de su nombre
 PropertyCategory getCategoryFromEntry(java.lang.String entryKey)
          Devuelve la categoria a partir del key buscado
 PropertyElement[] getChildren()
           
 PropertyCategory getDefaultCategory()
          Devuelve la categoria por default.
 PropertyEntry[] getEntries()
           
 IFile getFile()
           
 java.lang.String[] getKeys()
           
 int getLine()
           
 PropertyEntry getPropertyEntry(java.lang.String entryKey)
          Devuelve el objeto PropertyEntry a partir de la clave
 boolean hasChildren()
           
 void keyChanged(PropertyCategory category, PropertyEntry entry)
           
static void main(java.lang.String[] args)
           
 boolean moveToCategory(PropertyEntry entry, PropertyCategory destinityCategory)
          Mueve un entrada a un categoria
 void nameChanged(PropertyCategory category)
           
 void removeCategory(PropertyCategory category)
           
 void removeFromParent()
           
 void removePropertyFileListener(IPropertyFileListener listener)
           
 void resourceChanged(IResourceChangeEvent event)
           
 void save()
           
 void setFile(IFile file)
           
 void valueChanged(PropertyCategory category, PropertyEntry entry)
           
 
Methods inherited from class com.triadsoft.common.properties.PropertyElement
getParent, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EXTENSION

public static final java.lang.String DEFAULT_EXTENSION
See Also:
Constant Field Values
Constructor Detail

PropertyFile

public PropertyFile(java.io.File file)
             throws java.io.IOException
Parameters:
file -
Throws:
java.io.IOException

PropertyFile

public PropertyFile(IFile file)
             throws java.io.IOException
Permite crear un property file a partir de un IFile

Parameters:
file -
Throws:
java.io.IOException
Method Detail

getChildren

public PropertyElement[] getChildren()
Specified by:
getChildren in class PropertyElement

addCategory

public void addCategory(PropertyCategory category)

removeCategory

public void removeCategory(PropertyCategory category)

removeFromParent

public void removeFromParent()
Specified by:
removeFromParent in class PropertyElement

addPropertyFileListener

public void addPropertyFileListener(IPropertyFileListener listener)

removePropertyFileListener

public void removePropertyFileListener(IPropertyFileListener listener)

keyChanged

public void keyChanged(PropertyCategory category,
                       PropertyEntry entry)
Specified by:
keyChanged in interface IPropertyFileListener

valueChanged

public void valueChanged(PropertyCategory category,
                         PropertyEntry entry)
Specified by:
valueChanged in interface IPropertyFileListener

nameChanged

public void nameChanged(PropertyCategory category)
Specified by:
nameChanged in interface IPropertyFileListener

entryAdded

public void entryAdded(PropertyCategory category,
                       PropertyEntry entry)
Specified by:
entryAdded in interface IPropertyFileListener

entryRemoved

public void entryRemoved(PropertyCategory category,
                         PropertyEntry entry)
Specified by:
entryRemoved in interface IPropertyFileListener

categoryAdded

public void categoryAdded(PropertyCategory category)
Specified by:
categoryAdded in interface IPropertyFileListener

categoryRemoved

public void categoryRemoved(PropertyCategory category)
Specified by:
categoryRemoved in interface IPropertyFileListener

hasChildren

public boolean hasChildren()
Specified by:
hasChildren in class PropertyElement
See Also:
PropertyElement.hasChildren()

existCategory

public boolean existCategory(java.lang.String categoryName)
Devuelve true, si existe una categoria con este nombre

Parameters:
categoryName -
Returns:
Booleano TRUE o FALSE

exist

public boolean exist(java.lang.String propertyName)
Devuelve verdadero si existe la propiedad en el archivo

Parameters:
propertyName -
Returns:
Booleano TRUE o FALSE

asText

public java.lang.String asText()
Convierte el PropertyFile en texto

Returns:
un String con todo el contenido del archivo de propiedades

getDefaultCategory

public PropertyCategory getDefaultCategory()
Devuelve la categoria por default. La categoria por default es un categoria que se crea para todas las claves que no pertenecen a un categoria. Todas las claves entontradas antes de un comentario, son agregadas a esta categoria, ya que no se puede identificar a la categoria a la que pertenecen

Returns:
PropertyCategory
See Also:
PropertyCategory

getFile

public IFile getFile()

setFile

public void setFile(IFile file)

resourceChanged

public void resourceChanged(IResourceChangeEvent event)

getCategoryByName

public PropertyCategory getCategoryByName(java.lang.String categoryName)
Devuelve una categoria a partir de su nombre

Parameters:
categoryName - Nombre de la categoria buscada
Returns:
PropertyCategory encontrada, null si no la encuentra

getCategoryFromEntry

public PropertyCategory getCategoryFromEntry(java.lang.String entryKey)
Devuelve la categoria a partir del key buscado

Parameters:
entryKey -
Returns:
null si no existe la entrada

getPropertyEntry

public PropertyEntry getPropertyEntry(java.lang.String entryKey)
Devuelve el objeto PropertyEntry a partir de la clave

Parameters:
entryKey - String que identifica a la entrada
Returns:
ProperyEntry

moveToCategory

public boolean moveToCategory(PropertyEntry entry,
                              PropertyCategory destinityCategory)
Mueve un entrada a un categoria

Parameters:
entry -
destinityCategory -

getLine

public int getLine()
Specified by:
getLine in class PropertyElement
See Also:
PropertyElement.getLine()

getEntries

public PropertyEntry[] getEntries()

getKeys

public java.lang.String[] getKeys()

save

public void save()
          throws java.io.IOException,
                 CoreException
Throws:
java.io.IOException
CoreException

main

public static void main(java.lang.String[] args)

fileChanged

public void fileChanged(PropertyFile propertyFile)
Specified by:
fileChanged in interface IPropertyFileListener