KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > util > ConfigFileInterface


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  *
22  * $Id: ConfigFileInterface.java,v 1.1 2005/07/13 11:09:06 slobodan Exp $
23  */

24
25 package org.enhydra.util;
26
27 import java.io.File JavaDoc;
28 import java.io.FileNotFoundException JavaDoc;
29 import java.io.IOException JavaDoc;
30 import java.io.OutputStream JavaDoc;
31
32 import com.lutris.util.Config;
33 import com.lutris.util.KeywordValueException;
34
35 /**
36  * ConfigFileInterface is used to manipulate application's configuration files.
37  *
38  * @see Config
39  * @version $Revision: 1.1 $
40  */

41 public interface ConfigFileInterface {
42
43 /**
44  * The key under which the trailing comment is stored.
45  */

46   public static final String JavaDoc TRAILING_COMMENT = "ConfigFileTrailingComment";
47
48 /**
49  * Returns the Config object representing the config data in the file.
50  * @return The Config object for this ConfigFile.
51  */

52   public Config getConfig();
53
54 /**
55  * Returns the comment associated with a given key, or <code>null</code> if
56  * there is no comment. Pass in* <code>ConfigFileInterface.TRAILING_COMMENT</code> to get
57  * the trailing comment.
58  * @param key the key to look up.
59  * @return the associated comment or <code>null</code>
60  */

61   public String JavaDoc getComment (String JavaDoc key);
62
63 /**
64  * Add an entry to the config file.
65  * @param key The config element name.
66  * @param values A string array of values.
67  * @param comment A string containing a properly commented config file comment.
68  * @exception KeywordValueException
69  */

70   public void addEntry(String JavaDoc key, String JavaDoc[] values, String JavaDoc comment)
71     throws KeywordValueException;
72
73 /**
74  * Add an entry to the config file.
75  * @param key The config element name.
76  * @param value A String value.
77  * @param comment A string containing a properly commented config file comment.
78  * @exception KeywordValueException
79  */

80   public void addEntry(String JavaDoc key, String JavaDoc value, String JavaDoc comment)
81     throws KeywordValueException;
82   
83 /**
84  * Remove an entry from the config file.
85  * @param key The config element name.
86  * @exception KeywordValueException
87  */

88   public void removeEntry(String JavaDoc key) throws KeywordValueException;
89   
90 /**
91  * Gets the associated file. If no file is associated with this config, <code>null</code>
92  * is returned.
93  * @return associated file
94  */

95   public File JavaDoc getFile();
96
97 /**
98  * Sets the configuration file. This method can be useful in case when in
99  * construction of ConfigFileInterface implementation object is not defined
100  * associated file.
101  * @param file given reference to configuration file represented as File object.
102  */

103   public void setFile(File JavaDoc file);
104
105 /**
106  * Writes this config to the associated file. If no file is associated with this
107  * config, throws a <code>FileNotFoundException</code>
108  * @exception IOException
109  * @exception FileNotFoundException
110  */

111   public void write() throws IOException JavaDoc, FileNotFoundException JavaDoc;
112
113 /**
114  * Writes out a config file to the OutputStream specified. Note that Objects
115  * other than String or String[] will be converted into a String.
116  * @param outputStream The output stream on which to write the config file.
117  */

118   public void write(OutputStream JavaDoc outputStream);
119  
120 }
121
Popular Tags