View Javadoc

1   package org.naftulin.configmgr;
2   
3   import java.io.Serializable;
4   import java.util.Date;
5   
6   import org.naftulin.configmgr.parsers.ConfigEntryParser;
7   
8   /***
9    * Configuration management entry associates a key to a configuration, stored as a content.
10   * In addition to key and content, it registers the file name from which a configuration was read,
11   * whether the configuration is in an error state, and whether or not it was overwritten.
12   * The entry is considered to be in error, if it cannot be parsed from the configuration file.
13   * In such case, instead of the configuration, an exception would be stored in the configuration entry 
14   * content. If the configuration in error is requested, the exception is returned.
15   * The owervritten stands flag is to show whether a configuration was programmatically 
16   * ovewrittend (by using {@link ConfigurationManagement#addConfigurationManagmentEntry(ConfigurationManagementEntry) 
17   * add configuration method}. Otherwise it is false; it is also reset when reload is called
18   * on {@link ConfigurationManagement ConfigurationManagement}. It could also be set by user.
19   * 
20   * @author Henry Naftulin
21   * @since 1.0
22   */
23  public interface ConfigurationManagementEntry extends Serializable {
24  	/***
25  	 * Returns configuration the key associated with this record.
26  	 * @return configuration the key associated with this record.
27  	 */
28  	String getKey();
29  	
30  	/***
31  	 * Returns the file name from where the configuration was read. 
32  	 * @return the file name from where the configuration was read.
33  	 */
34  	String getFileName();
35  	
36  	/***
37  	 * Returns true if the record was overwritten.
38  	 * @return true if the record was overwritten.
39  	 */
40  	boolean isOverwritten();
41  	
42  	/***
43  	 * Returns true if the record is in error state.
44  	 * @return true if the record is in error state.
45  	 */
46  	boolean isError();	
47  	/***
48  	 * Returns the parsed configuration. 
49  	 * @return the parsed configuration.
50  	 */
51  	Object getContent();
52  	
53  	/***
54  	 * Returns the string representation of this entry.
55  	 * @return the string representation of this entry.
56  	 */
57  	String toString();
58  	
59  	/***
60  	 * Returns the date and time when this entry was created.
61  	 * @return the date and time when this entry was created.
62  	 */
63  	Date getCreateDate();
64  	
65  	/***
66  	 * Returns the date and time when this entry was modified.
67  	 * @return the date and time when this entry was modified.
68  	 */
69  	Date getModifiedDate();
70  	
71  	/***
72  	 * Sets the date the entry was modified.
73  	 * @param modifiedDate modified date
74  	 */
75  	void setModifiedDate(Date modifiedDate);
76  	
77  	/***
78  	 * Returns the processor that parsed the cofiguration from the configuration file.
79  	 * @return the processor that parsed the cofiguration from the configuration file.
80  	 */
81  	ConfigEntryParser getProcessor();
82  	
83  	/***
84  	 * Sets the owerwritten flag.
85  	 * @param overwritten true if the record was overwritten.
86  	 */
87  	void setOverwritten(boolean overwritten);
88  	
89  	/***
90  	 * Returns the configuration type of this entry.
91  	 * @return the configuration type of this entry.
92  	 */
93  	ConfigurationType getConfigurationType();
94  	
95  }