org.naftulin.configmgr
Class ConfigurationManagementEntryImpl

java.lang.Object
  extended by org.naftulin.configmgr.ConfigurationManagementEntryImpl
All Implemented Interfaces:
java.io.Serializable, ConfigurationManagementEntry

public class ConfigurationManagementEntryImpl
extends java.lang.Object
implements ConfigurationManagementEntry

Configuration management entry associates a key to a configuration, stored as a content. In addition to key and content, it registers the file name from which a configuration was read, whether the configuration is in an error state, and whether or not it was overwritten. The entry is considered to be in error, if it cannot be parsed from the configuration file. In such case, instead of the configuration, an exception would be stored in the configuration entry content. If the configuration in error is requested, the exception is returned. The owervritten stands flag is to show whether a configuration was programmatically ovewrittend (by using add configuration method. Otherwise it is false; it is also reset when reload is called on ConfigurationManagement. It could also be set by user.

Since:
1.0
Author:
Henry Naftulin
See Also:
Serialized Form

Constructor Summary
ConfigurationManagementEntryImpl(java.lang.String key, java.lang.String fileName, java.lang.Object content, ConfigEntryParser processor, ConfigurationType configurationType)
          Creates a configuration management entry.
 
Method Summary
 boolean equals(java.lang.Object object)
          Returns true if the object equals to this record.
 ConfigurationType getConfigurationType()
          Returns the configuration type of this entry.
 java.lang.Object getContent()
          Returns the content of the entry
 java.util.Date getCreateDate()
          Returns the create date for this entry
 java.lang.String getFileName()
          Returns file name associated with the entry
 java.lang.String getKey()
          Returns key for the entry
 java.util.Date getModifiedDate()
          Returns the date and time when this entry was modified.
 ConfigEntryParser getProcessor()
          Returns the processor for this entry
 int hashCode()
          Returns hashcode of this record.
 boolean isError()
          Returns true if the configuration does not have a key, or file name is not associated with the entry or there is no processor associated with the entry.
 boolean isOverwritten()
          Returns true if this entry overwrote another entry with the same key.
 void setModifiedDate(java.util.Date modifiedDate)
          Sets the date the entry was modified.
 void setOverwritten(boolean overwritten)
          Sets overwritten flag.
 java.lang.String toString()
          Returns the string representation of this entry.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigurationManagementEntryImpl

public ConfigurationManagementEntryImpl(java.lang.String key,
                                        java.lang.String fileName,
                                        java.lang.Object content,
                                        ConfigEntryParser processor,
                                        ConfigurationType configurationType)
Creates a configuration management entry. Sets error only if the key or if processor is not set or no file name is associated with the configuration entry.

Parameters:
key - the key entry is stored under
fileName - file that is associated with the entry. Usually file that the entry is read from.
content - the content of the entry. For example properties object.
processor - the processor that can process entry
Method Detail

getKey

public java.lang.String getKey()
Returns key for the entry

Specified by:
getKey in interface ConfigurationManagementEntry
Returns:
the key for the entry

getFileName

public java.lang.String getFileName()
Returns file name associated with the entry

Specified by:
getFileName in interface ConfigurationManagementEntry
Returns:
the file name associated with the entry

setOverwritten

public void setOverwritten(boolean overwritten)
Sets overwritten flag. Method should be called by configuration manager only to say that an entry overwrote another entry in the configuration.

Specified by:
setOverwritten in interface ConfigurationManagementEntry
Parameters:
overwritten -

isOverwritten

public boolean isOverwritten()
Returns true if this entry overwrote another entry with the same key.

Specified by:
isOverwritten in interface ConfigurationManagementEntry
Returns:
true if this entry overwrote another entry with the same key.

isError

public boolean isError()
Returns true if the configuration does not have a key, or file name is not associated with the entry or there is no processor associated with the entry.

Specified by:
isError in interface ConfigurationManagementEntry
Returns:
true if the entry is in error condition

getContent

public java.lang.Object getContent()
Returns the content of the entry

Specified by:
getContent in interface ConfigurationManagementEntry
Returns:
the content

getCreateDate

public java.util.Date getCreateDate()
Returns the create date for this entry

Specified by:
getCreateDate in interface ConfigurationManagementEntry
Returns:
create date for the entry

getProcessor

public ConfigEntryParser getProcessor()
Returns the processor for this entry

Specified by:
getProcessor in interface ConfigurationManagementEntry
Returns:
the processor for this entry

toString

public java.lang.String toString()
Returns the string representation of this entry.

Specified by:
toString in interface ConfigurationManagementEntry
Overrides:
toString in class java.lang.Object
Returns:
the string representation of this entry.

equals

public boolean equals(java.lang.Object object)
Returns true if the object equals to this record.

Overrides:
equals in class java.lang.Object
Returns:
true if the object equals to this record.

hashCode

public int hashCode()
Returns hashcode of this record.

Overrides:
hashCode in class java.lang.Object
Returns:
hashcode of this record.

getModifiedDate

public java.util.Date getModifiedDate()
Returns the date and time when this entry was modified.

Specified by:
getModifiedDate in interface ConfigurationManagementEntry
Returns:
the date and time when this entry was modified.

getConfigurationType

public ConfigurationType getConfigurationType()
Returns the configuration type of this entry.

Specified by:
getConfigurationType in interface ConfigurationManagementEntry
Returns:
the configuration type of this entry.

setModifiedDate

public void setModifiedDate(java.util.Date modifiedDate)
Description copied from interface: ConfigurationManagementEntry
Sets the date the entry was modified.

Specified by:
setModifiedDate in interface ConfigurationManagementEntry
Parameters:
modifiedDate - modified date


Copyright © 2009. All Rights Reserved.