diff options
author | mattinger <[email protected]> | 2006-08-09 17:30:26 +0000 |
---|---|---|
committer | mattinger <[email protected]> | 2006-08-09 17:30:26 +0000 |
commit | 0058b0ff2af01ec8ae2a0f28993ad691d873e682 (patch) | |
tree | eb325d5871a267e5c9f9c45ee962bbf76c35b46d /src/java | |
parent | 93fbe4fc30d82b8728cb6c778aed2328e9006ca4 (diff) |
Accepting IniFile patch
git-svn-id: file:///home/sven/projects/JOGL/temp/ant-contrib/svn/ant-contrib-code/trunk/ant-contrib@11 32d7a393-a5a9-423c-abd3-5d954feb1f2f
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/net/sf/antcontrib/inifile/IniFile.java | 456 | ||||
-rw-r--r-- | src/java/net/sf/antcontrib/inifile/IniFileTask.java | 769 |
2 files changed, 667 insertions, 558 deletions
diff --git a/src/java/net/sf/antcontrib/inifile/IniFile.java b/src/java/net/sf/antcontrib/inifile/IniFile.java index b65044a..8941be5 100644 --- a/src/java/net/sf/antcontrib/inifile/IniFile.java +++ b/src/java/net/sf/antcontrib/inifile/IniFile.java @@ -1,232 +1,224 @@ -/* - * Copyright (c) 2001-2004 Ant-Contrib project. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package net.sf.antcontrib.inifile; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.util.*; - - -/**************************************************************************** - * Class representing a windows style .ini file. - * - * @author <a href='mailto:[email protected]'>Matthew Inger</a> - * - ****************************************************************************/ - -public class IniFile -{ - private List sections; - private Map sectionMap; - - /*** - * Create a new IniFile object - */ - public IniFile() - { - super(); - this.sections = new ArrayList(); - this.sectionMap = new HashMap(); - } - - /*** - * Gets the List of IniSection objects contained in this IniFile - * @return a List of IniSection objects - */ - public List getSections() - { - return sections; - } - - - /*** - * Gets the IniSection with the given name - * @param name the name of the section - */ - public IniSection getSection(String name) - { - return (IniSection)sectionMap.get(name); - } - - /*** - * Sets an IniSection object. If a section with the given - * name already exists, it is replaced with the passed in section. - * @param section The section to set. - */ - public void setSection(IniSection section) - { - IniSection sec = (IniSection)sectionMap.get(section.getName()); - if (sec != null) - { - int idx = sections.indexOf(sec); - sections.set(idx, section); - } - else - { - sections.add(section); - } - - sectionMap.put(section.getName(), section); - } - - /*** - * Removes an entire section from the IniFile - * @param name The name of the section to remove - */ - public void removeSection(String name) - { - IniSection sec = (IniSection)sectionMap.get(name); - if (sec != null) - { - int idx = sections.indexOf(sec); - sections.remove(idx); - sectionMap.remove(name); - } - } - - /*** - * Gets a named property from a specific section - * @param section The name of the section - * @param property The name of the property - * @return The property value, or null, if either the section or property - * does not exist. - */ - public String getProperty(String section, String property) - { - String value = null; - IniSection sec = getSection(section); - if (sec != null) - { - IniProperty prop = sec.getProperty(property); - if (prop != null) - { - value = prop.getValue(); - } - } - return value; - } - - /*** - * Sets the value of a property in a given section. If the section does - * not exist, it is automatically created. - * @param section The name of the section - * @param property The name of the property - * @param value The value of the property - */ - public void setProperty(String section, String property, String value) - { - IniSection sec = getSection(section); - if (sec == null) - { - sec = new IniSection(section); - setSection(sec); - } - - sec.setProperty(new IniProperty(property, value)); - } - - /*** - * Removes a property from a section. - * @param section The name of the section - * @param property The name of the property - */ - public void removeProperty(String section, String property) - { - IniSection sec = getSection(section); - if (sec != null) - { - sec.removeProperty(property); - } - } - - /*** - * Writes the current iniFile instance to a Writer object for - * serialization. - * @param writer The writer to write to - * @throws IOException - */ - public void write(Writer writer) - throws IOException - { - Iterator it = sections.iterator(); - IniSection section = null; - while (it.hasNext()) - { - section = (IniSection)it.next(); - section.write(writer); - writer.write(System.getProperty("line.separator")); - } - } - - /*** - * Reads from a Reader into the current IniFile instance. Reading - * appends to the current instance, so if the current instance has - * properties, those properties will still exist. - * @param reader The reader to read from. - * @throws IOException - */ - public void read(Reader reader) - throws IOException - { - BufferedReader br = new BufferedReader(reader); - String line = null; - - IniSection currentSection = new IniSection("NONE"); - - while ((line = br.readLine()) != null) - { - int pos = line.indexOf('#'); - if (pos != -1) - line = line.substring(0,pos); - - pos = line.indexOf(';'); - if (pos != -1) - line = line.substring(0,pos); - - line = line.trim(); - if (line.length() > 0) - { - if(line.startsWith("[") && line.endsWith("]")) - { - String secName = line.substring(1, line.length()-1); - currentSection = getSection(secName); - if (currentSection == null) - { - currentSection = new IniSection(secName); - setSection(currentSection); - } - } - else - { - String name = line; - String value = ""; - pos = line.indexOf("="); - if (pos != -1) - { - name = line.substring(0,pos); - value = line.substring(pos+1); - } - - currentSection.setProperty(new IniProperty(name,value)); - } - } - - - } - } -} +/*
+ * Copyright (c) 2001-2004 Ant-Contrib project. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package net.sf.antcontrib.inifile;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.*;
+
+
+/****************************************************************************
+ * Class representing a windows style .ini file.
+ *
+ * @author <a href='mailto:[email protected]'>Matthew Inger</a>
+ *
+ ****************************************************************************/
+
+public class IniFile
+{
+ private List sections;
+ private Map sectionMap;
+
+ /***
+ * Create a new IniFile object
+ */
+ public IniFile()
+ {
+ super();
+ this.sections = new ArrayList();
+ this.sectionMap = new HashMap();
+ }
+
+ /***
+ * Gets the List of IniSection objects contained in this IniFile
+ * @return a List of IniSection objects
+ */
+ public List getSections()
+ {
+ return sections;
+ }
+
+
+ /***
+ * Gets the IniSection with the given name
+ * @param name the name of the section
+ */
+ public IniSection getSection(String name)
+ {
+ return (IniSection)sectionMap.get(name);
+ }
+
+ /***
+ * Sets an IniSection object. If a section with the given
+ * name already exists, it is replaced with the passed in section.
+ * @param section The section to set.
+ */
+ public void setSection(IniSection section)
+ {
+ IniSection sec = (IniSection)sectionMap.get(section.getName());
+ if (sec != null)
+ {
+ int idx = sections.indexOf(sec);
+ sections.set(idx, section);
+ }
+ else
+ {
+ sections.add(section);
+ }
+
+ sectionMap.put(section.getName(), section);
+ }
+
+ /***
+ * Removes an entire section from the IniFile
+ * @param name The name of the section to remove
+ */
+ public void removeSection(String name)
+ {
+ IniSection sec = (IniSection)sectionMap.get(name);
+ if (sec != null)
+ {
+ int idx = sections.indexOf(sec);
+ sections.remove(idx);
+ sectionMap.remove(name);
+ }
+ }
+
+ /***
+ * Gets a named property from a specific section
+ * @param section The name of the section
+ * @param property The name of the property
+ * @return The property value, or null, if either the section or property
+ * does not exist.
+ */
+ public String getProperty(String section, String property)
+ {
+ String value = null;
+ IniSection sec = getSection(section);
+ if (sec != null)
+ {
+ IniProperty prop = sec.getProperty(property);
+ if (prop != null)
+ {
+ value = prop.getValue();
+ }
+ }
+ return value;
+ }
+
+ /***
+ * Sets the value of a property in a given section. If the section does
+ * not exist, it is automatically created.
+ * @param section The name of the section
+ * @param property The name of the property
+ * @param value The value of the property
+ */
+ public void setProperty(String section, String property, String value)
+ {
+ IniSection sec = getSection(section);
+ if (sec == null)
+ {
+ sec = new IniSection(section);
+ setSection(sec);
+ }
+
+ sec.setProperty(new IniProperty(property, value));
+ }
+
+ /***
+ * Removes a property from a section.
+ * @param section The name of the section
+ * @param property The name of the property
+ */
+ public void removeProperty(String section, String property)
+ {
+ IniSection sec = getSection(section);
+ if (sec != null)
+ {
+ sec.removeProperty(property);
+ }
+ }
+
+ /***
+ * Writes the current iniFile instance to a Writer object for
+ * serialization.
+ * @param writer The writer to write to
+ * @throws IOException
+ */
+ public void write(Writer writer)
+ throws IOException
+ {
+ Iterator it = sections.iterator();
+ IniSection section = null;
+ while (it.hasNext())
+ {
+ section = (IniSection)it.next();
+ section.write(writer);
+ writer.write(System.getProperty("line.separator"));
+ }
+ }
+
+ /***
+ * Reads from a Reader into the current IniFile instance. Reading
+ * appends to the current instance, so if the current instance has
+ * properties, those properties will still exist.
+ * @param reader The reader to read from.
+ * @throws IOException
+ */
+ public void read(Reader reader)
+ throws IOException
+ {
+ BufferedReader br = new BufferedReader(reader);
+ String line = null;
+
+ IniSection currentSection = new IniSection("NONE");
+
+ while ((line = br.readLine()) != null)
+ {
+ line = line.trim();
+ if (line.length() > 0 && !line.startsWith("#") && !line.startsWith(";"))
+ {
+ if(line.startsWith("[") && line.endsWith("]"))
+ {
+ String secName = line.substring(1, line.length()-1);
+ currentSection = getSection(secName);
+ if (currentSection == null)
+ {
+ currentSection = new IniSection(secName);
+ setSection(currentSection);
+ }
+ }
+ else
+ {
+ String name = line;
+ String value = "";
+ int pos = line.indexOf("=");
+ if (pos != -1)
+ {
+ name = line.substring(0,pos);
+ value = line.substring(pos+1);
+ }
+
+ currentSection.setProperty(new IniProperty(name,value));
+ }
+ }
+
+
+ }
+ }
+}
diff --git a/src/java/net/sf/antcontrib/inifile/IniFileTask.java b/src/java/net/sf/antcontrib/inifile/IniFileTask.java index d7e44aa..2da6ff5 100644 --- a/src/java/net/sf/antcontrib/inifile/IniFileTask.java +++ b/src/java/net/sf/antcontrib/inifile/IniFileTask.java @@ -1,326 +1,443 @@ -/* - * Copyright (c) 2001-2004 Ant-Contrib project. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package net.sf.antcontrib.inifile; - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Iterator; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; - - -/**************************************************************************** - * Place class description here. - * - * @author <a href='mailto:[email protected]'>Matthew Inger</a> - * @author <additional author> - * - * @since - * - ****************************************************************************/ - - -public class IniFileTask - extends Task -{ - public static abstract class IniOperation - { - private String section; - private String property; - private String ifCond; - private String unlessCond; - - public IniOperation() - { - super(); - } - - public String getSection() - { - return section; - } - - - public void setSection(String section) - { - this.section = section; - } - - - public String getProperty() - { - return property; - } - - - public void setProperty(String property) - { - this.property = property; - } - - - public void setIf(String ifCond) - { - this.ifCond = ifCond; - } - - public void setUnless(String unlessCond) - { - this.unlessCond = unlessCond; - } - - /** - * Returns true if the define's if and unless conditions - * (if any) are satisfied. - */ - public boolean isActive(org.apache.tools.ant.Project p) - { - if (ifCond != null && p.getProperty(ifCond) == null) - { - return false; - } - else if (unlessCond != null && p.getProperty(unlessCond) != null) - { - return false; - } - - return true; - } - - public void execute(Project project, IniFile iniFile) - { - if (isActive(project)) - operate(iniFile); - } - - protected abstract void operate(IniFile file); - } - - public static final class Remove - extends IniOperation - { - public Remove() - { - super(); - } - - protected void operate(IniFile file) - { - String secName = getSection(); - String propName = getProperty(); - - if (propName == null) - { - file.removeSection(secName); - } - else - { - IniSection section = file.getSection(secName); - if (section != null) - section.removeProperty(propName); - } - } - } - - - public final class Set - extends IniOperation - { - private String value; - private String operation; - - public Set() - { - super(); - } - - - public void setValue(String value) - { - this.value = value; - } - - - public void setOperation(String operation) - { - this.operation = operation; - } - - - protected void operate(IniFile file) - { - String secName = getSection(); - String propName = getProperty(); - - IniSection section = file.getSection(secName); - if (section == null) - { - section = new IniSection(secName); - file.setSection(section); - } - - if (propName != null) - { - if (operation != null) - { - if ("+".equals(operation)) - { - IniProperty prop = section.getProperty(propName); - value = prop.getValue(); - int intVal = Integer.parseInt(value) + 1; - value = String.valueOf(intVal); - } - else if ("-".equals(operation)) - { - IniProperty prop = section.getProperty(propName); - value = prop.getValue(); - int intVal = Integer.parseInt(value) - 1; - value = String.valueOf(intVal); - } - } - section.setProperty(new IniProperty(propName, value)); - } - } - - } - - private File source; - private File dest; - private Vector operations; - - public IniFileTask() - { - super(); - this.operations = new Vector(); - } - - public Set createSet() - { - Set set = new Set(); - operations.add(set); - return set; - } - - public Remove createRemove() - { - Remove remove = new Remove(); - operations.add(remove); - return remove; - } - - - public void setSource(File source) - { - this.source = source; - } - - - public void setDest(File dest) - { - this.dest = dest; - } - - - public void execute() - throws BuildException - { - if (dest == null) - throw new BuildException("You must supply a dest file to write to."); - - IniFile iniFile = null; - - try - { - iniFile = readIniFile(source); - } - catch (IOException e) - { - throw new BuildException(e); - } - - Iterator it = operations.iterator(); - IniOperation operation = null; - while (it.hasNext()) - { - operation = (IniOperation)it.next(); - operation.execute(getProject(), iniFile); - } - - FileWriter writer = null; - - try - { - try - { - writer = new FileWriter(dest); - iniFile.write(writer); - } - finally - { - try - { - if (writer != null) - writer.close(); - } - catch (IOException e) - { - ; // gulp - } - } - } - catch (IOException e) - { - throw new BuildException(e); - } - - } - - - private IniFile readIniFile(File source) - throws IOException - { - FileReader reader = null; - IniFile iniFile = new IniFile(); - - if (source == null) - return iniFile; - - try - { - reader = new FileReader(source); - iniFile.read(reader); - } - finally - { - try - { - if (reader != null) - reader.close(); - } - catch (IOException e) - { - ; // gulp - } - } - - return iniFile; - } -} +/*
+ * Copyright (c) 2001-2004 Ant-Contrib project. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package net.sf.antcontrib.inifile;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Property;
+
+
+/****************************************************************************
+ * Place class description here.
+ *
+ * @author <a href='mailto:[email protected]'>Matthew Inger</a>
+ * @author <additional author>
+ *
+ * @since
+ *
+ ****************************************************************************/
+
+
+public class IniFileTask
+ extends Task
+{
+ public static abstract class IniOperation
+ {
+ private String section;
+ private String property;
+
+ public IniOperation()
+ {
+ super();
+ }
+
+ public String getSection()
+ {
+ return section;
+ }
+
+
+ public void setSection(String section)
+ {
+ this.section = section;
+ }
+
+
+ public String getProperty()
+ {
+ return property;
+ }
+
+
+ public void setProperty(String property)
+ {
+ this.property = property;
+ }
+
+ public void execute(Project project, IniFile iniFile)
+ {
+ operate(iniFile);
+ }
+
+ protected abstract void operate(IniFile file);
+ }
+
+ public static abstract class IniOperationConditional extends IniOperation
+ {
+ private String ifCond;
+ private String unlessCond;
+
+ public IniOperationConditional()
+ {
+ super();
+ }
+
+ public void setIf(String ifCond)
+ {
+ this.ifCond = ifCond;
+ }
+
+ public void setUnless(String unlessCond)
+ {
+ this.unlessCond = unlessCond;
+ }
+
+ /**
+ * Returns true if the define's if and unless conditions
+ * (if any) are satisfied.
+ */
+ public boolean isActive(org.apache.tools.ant.Project p)
+ {
+ if (ifCond != null && p.getProperty(ifCond) == null)
+ {
+ return false;
+ }
+ else if (unlessCond != null && p.getProperty(unlessCond) != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public void execute(Project project, IniFile iniFile)
+ {
+ if (isActive(project))
+ operate(iniFile);
+ }
+ }
+
+ public static abstract class IniOperationPropertySetter extends IniOperation
+ {
+ private boolean override;
+ private String resultproperty;
+
+ public IniOperationPropertySetter()
+ {
+ super();
+ }
+
+ public void setOverride(boolean override)
+ {
+ this.override = override;
+ }
+
+ public void setResultProperty(String resultproperty)
+ {
+ this.resultproperty = resultproperty;
+ }
+
+ protected final void setResultPropertyValue(Project project, String value)
+ {
+ if (value != null)
+ {
+ if (override)
+ {
+ if (project.getUserProperty(resultproperty) == null)
+ project.setProperty(resultproperty, value);
+ else
+ project.setUserProperty(resultproperty, value);
+ }
+ else
+ {
+ Property p = (Property)project.createTask("property");
+ p.setName(resultproperty);
+ p.setValue(value);
+ p.execute();
+ }
+ }
+ }
+ }
+
+ public static final class Remove
+ extends IniOperationConditional
+ {
+ public Remove()
+ {
+ super();
+ }
+
+ protected void operate(IniFile file)
+ {
+ String secName = getSection();
+ String propName = getProperty();
+
+ if (propName == null)
+ {
+ file.removeSection(secName);
+ }
+ else
+ {
+ IniSection section = file.getSection(secName);
+ if (section != null)
+ section.removeProperty(propName);
+ }
+ }
+ }
+
+
+ public final class Set
+ extends IniOperationConditional
+ {
+ private String value;
+ private String operation;
+
+ public Set()
+ {
+ super();
+ }
+
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+
+ public void setOperation(String operation)
+ {
+ this.operation = operation;
+ }
+
+
+ protected void operate(IniFile file)
+ {
+ String secName = getSection();
+ String propName = getProperty();
+
+ IniSection section = file.getSection(secName);
+ if (section == null)
+ {
+ section = new IniSection(secName);
+ file.setSection(section);
+ }
+
+ if (propName != null)
+ {
+ if (operation != null)
+ {
+ if ("+".equals(operation))
+ {
+ IniProperty prop = section.getProperty(propName);
+ value = prop.getValue();
+ int intVal = Integer.parseInt(value) + 1;
+ value = String.valueOf(intVal);
+ }
+ else if ("-".equals(operation))
+ {
+ IniProperty prop = section.getProperty(propName);
+ value = prop.getValue();
+ int intVal = Integer.parseInt(value) - 1;
+ value = String.valueOf(intVal);
+ }
+ }
+ section.setProperty(new IniProperty(propName, value));
+ }
+ }
+ }
+
+ public final class Exists
+ extends IniOperationPropertySetter
+ {
+ public Exists()
+ {
+ super();
+ }
+
+ protected void operate(IniFile file)
+ {
+ boolean exists = false;
+ String secName = getSection();
+ String propName = getProperty();
+
+ if (secName == null)
+ throw new BuildException("You must supply a section to search for.");
+
+ if (propName == null)
+ exists = (file.getSection(secName) != null);
+ else
+ exists = (file.getProperty(secName, propName) != null);
+
+ setResultPropertyValue(getProject(), Boolean.valueOf(exists).toString());
+ }
+ }
+
+ public final class Get
+ extends IniOperationPropertySetter
+ {
+ public Get()
+ {
+ super();
+ }
+
+ protected void operate(IniFile file)
+ {
+ String secName = getSection();
+ String propName = getProperty();
+
+ if (secName == null)
+ throw new BuildException("You must supply a section to search for.");
+
+ if (propName == null)
+ throw new BuildException("You must supply a property name to search for.");
+
+ setResultPropertyValue(getProject(), file.getProperty(secName, propName));
+ }
+ }
+
+ private File source;
+ private File dest;
+ private Vector operations;
+
+ public IniFileTask()
+ {
+ super();
+ this.operations = new Vector();
+ }
+
+ public Set createSet()
+ {
+ Set set = new Set();
+ operations.add(set);
+ return set;
+ }
+
+ public Remove createRemove()
+ {
+ Remove remove = new Remove();
+ operations.add(remove);
+ return remove;
+ }
+
+ public Exists createExists()
+ {
+ Exists exists = new Exists();
+ operations.add(exists);
+ return exists;
+ }
+
+ public Get createGet()
+ {
+ Get get = new Get();
+ operations.add(get);
+ return get;
+ }
+
+ public void setSource(File source)
+ {
+ this.source = source;
+ }
+
+
+ public void setDest(File dest)
+ {
+ this.dest = dest;
+ }
+
+
+ public void execute()
+ throws BuildException
+ {
+ if (dest == null)
+ throw new BuildException("You must supply a dest file to write to.");
+
+ IniFile iniFile = null;
+
+ try
+ {
+ iniFile = readIniFile(source);
+ }
+ catch (IOException e)
+ {
+ throw new BuildException(e);
+ }
+
+ Iterator it = operations.iterator();
+ IniOperation operation = null;
+ while (it.hasNext())
+ {
+ operation = (IniOperation)it.next();
+ operation.execute(getProject(), iniFile);
+ }
+
+ FileWriter writer = null;
+
+ try
+ {
+ try
+ {
+ writer = new FileWriter(dest);
+ iniFile.write(writer);
+ }
+ finally
+ {
+ try
+ {
+ if (writer != null)
+ writer.close();
+ }
+ catch (IOException e)
+ {
+ ; // gulp
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ throw new BuildException(e);
+ }
+
+ }
+
+
+ private IniFile readIniFile(File source)
+ throws IOException
+ {
+ FileReader reader = null;
+ IniFile iniFile = new IniFile();
+
+ if (source == null)
+ return iniFile;
+
+ try
+ {
+ reader = new FileReader(source);
+ iniFile.read(reader);
+ }
+ finally
+ {
+ try
+ {
+ if (reader != null)
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ ; // gulp
+ }
+ }
+
+ return iniFile;
+ }
+}
|