Methods Summary |
---|
private boolean | checkParam(java.io.File param)
return !(param == null);
|
private void | checkParameters()
if (!checkParam(propertyfile)) {
throw new BuildException("file token must not be null.", getLocation());
}
|
public org.apache.tools.ant.taskdefs.optional.PropertyFile$Entry | createEntry()The entry nested element.
Entry e = new Entry();
entries.addElement(e);
return e;
|
public void | execute()Execute the task.
/* ========================================================================
*
* Constructors
*/
/* ========================================================================
*
* Methods
*/
checkParameters();
readFile();
executeOperation();
writeFile();
|
private void | executeOperation()
for (Enumeration e = entries.elements(); e.hasMoreElements();) {
Entry entry = (Entry) e.nextElement();
entry.executeOn(properties);
}
|
private void | readFile()
// Create the PropertyFile
properties = new Properties();
try {
if (propertyfile.exists()) {
log("Updating property file: "
+ propertyfile.getAbsolutePath());
FileInputStream fis = null;
try {
fis = new FileInputStream(propertyfile);
BufferedInputStream bis = new BufferedInputStream(fis);
properties.load(bis);
} finally {
if (fis != null) {
fis.close();
}
}
} else {
log("Creating new property file: "
+ propertyfile.getAbsolutePath());
FileOutputStream out = null;
try {
out = new FileOutputStream(propertyfile.getAbsolutePath());
out.flush();
} finally {
if (out != null) {
out.close();
}
}
}
} catch (IOException ioe) {
throw new BuildException(ioe.toString());
}
|
public void | setComment(java.lang.String hdr)optional header comment for the file
comment = hdr;
|
public void | setFile(java.io.File file)Location of the property file to be edited; required.
propertyfile = file;
|
private void | writeFile()
BufferedOutputStream bos = null;
try {
bos = new BufferedOutputStream(new FileOutputStream(propertyfile));
properties.store(bos, comment);
} catch (IOException ioe) {
throw new BuildException(ioe, getLocation());
} finally {
FileUtils.close(bos);
}
|