~ubuntu-branches/ubuntu/raring/ant-contrib/raring

« back to all changes in this revision

Viewing changes to src/main/java/net/sf/antcontrib/inifile/IniProperty.java

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-09-26 08:45:47 UTC
  • Revision ID: james.westby@ubuntu.com-20090926084547-ynj34y27mg9dr60c
Tags: upstream-1.0~b3+svn177
ImportĀ upstreamĀ versionĀ 1.0~b3+svn177

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2001-2004 Ant-Contrib project.  All rights reserved.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 package net.sf.antcontrib.inifile;
 
17
 
 
18
import java.io.IOException;
 
19
import java.io.Writer;
 
20
 
 
21
 
 
22
/****************************************************************************
 
23
 * A single property in an IniSection.
 
24
 *
 
25
 * @author <a href='mailto:mattinger@yahoo.com'>Matthew Inger</a>
 
26
 *
 
27
 ****************************************************************************/
 
28
 
 
29
 
 
30
public class IniProperty
 
31
        implements IniPart
 
32
{
 
33
    private String name;
 
34
    private String value;
 
35
 
 
36
    /***
 
37
     * Default constructor
 
38
     */
 
39
    public IniProperty()
 
40
    {
 
41
        super();
 
42
    }
 
43
 
 
44
    /***
 
45
     * Construct an IniProperty with a certain name and value
 
46
     * @param name The name of the property
 
47
     * @param value The property value
 
48
     */
 
49
    public IniProperty(String name, String value)
 
50
    {
 
51
        this();
 
52
        this.name = name;
 
53
        this.value = value;
 
54
    }
 
55
 
 
56
    /***
 
57
     * Gets the name of the property
 
58
     */
 
59
    public String getName()
 
60
    {
 
61
        return name;
 
62
    }
 
63
 
 
64
    /***
 
65
     * Sets the name of the property
 
66
     * @param name The name of the property
 
67
     */
 
68
    public void setName(String name)
 
69
    {
 
70
        this.name = name;
 
71
    }
 
72
 
 
73
 
 
74
    /***
 
75
     * Gets the value of the property
 
76
     */
 
77
    public String getValue()
 
78
    {
 
79
        return value;
 
80
    }
 
81
 
 
82
 
 
83
    /***
 
84
     * Sets the value of the property
 
85
     * @param value the value of the property
 
86
     */
 
87
    public void setValue(String value)
 
88
    {
 
89
        this.value = value;
 
90
    }
 
91
 
 
92
 
 
93
    /***
 
94
     * Write this property to a writer object.
 
95
     * @param writer
 
96
     * @throws IOException
 
97
     */
 
98
    public void write(Writer writer)
 
99
            throws IOException
 
100
    {
 
101
        writer.write(name);
 
102
        if (! name.trim().startsWith(";"))
 
103
            writer.write("=" + value);
 
104
    }
 
105
 
 
106
}