KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > armedbear > j > FileHistoryEntry


1 /*
2  * FileHistoryEntry.java
3  *
4  * Copyright (C) 1998-2002 Peter Graves
5  * $Id: FileHistoryEntry.java,v 1.1.1.1 2002/09/24 16:08:05 piso Exp $
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */

21
22 package org.armedbear.j;
23
24 import java.util.Iterator JavaDoc;
25 import java.util.StringTokenizer JavaDoc;
26
27 public final class FileHistoryEntry
28 {
29     private static final String JavaDoc lineSeparator =
30         System.getProperty("line.separator");
31
32     private String JavaDoc name;
33     private String JavaDoc encoding;
34     private String JavaDoc mode;
35     private long when;
36     private PropertyList properties = new PropertyList();
37
38     public FileHistoryEntry()
39     {
40     }
41
42     public String JavaDoc toXml()
43     {
44         FastStringBuffer sb = new FastStringBuffer(" <file name=\"");
45         sb.append(name);
46         sb.append("\"");
47         if (encoding != null) {
48             sb.append(" encoding=\"");
49             sb.append(encoding);
50             sb.append("\"");
51         }
52         sb.append(" mode=\"");
53         sb.append(mode);
54         sb.append("\"");
55         sb.append(" when=\"");
56         sb.append(String.valueOf(when));
57         sb.append("\"");
58         sb.append(">");
59         sb.append(lineSeparator);
60         Iterator JavaDoc it = properties.keyIterator();
61         if (it != null) {
62             while (it.hasNext()) {
63                 Property property = (Property) it.next();
64                 Object JavaDoc value = properties.getProperty(property);
65                 sb.append(propertyToXml(property.getDisplayName(),
66                     value.toString()));
67             }
68         }
69         sb.append(" </file>");
70         return sb.toString();
71     }
72
73     private static String JavaDoc propertyToXml(String JavaDoc name, String JavaDoc value)
74     {
75         FastStringBuffer sb = new FastStringBuffer(" <property name=\"");
76         sb.append(name);
77         sb.append("\" value=\"");
78         sb.append(value);
79         sb.append("\"/>");
80         sb.append(lineSeparator);
81         return new String JavaDoc(sb.toString());
82     }
83
84     public final PropertyList getProperties()
85     {
86         return properties;
87     }
88
89     public void setProperties(PropertyList props)
90     {
91         properties = props;
92     }
93
94     public String JavaDoc getName()
95     {
96         return name;
97     }
98
99     public void setName(String JavaDoc name)
100     {
101         this.name = name;
102     }
103
104     public String JavaDoc getEncoding()
105     {
106         return encoding;
107     }
108
109     public void setEncoding(String JavaDoc encoding)
110     {
111         this.encoding = encoding;
112     }
113
114     public String JavaDoc getMode()
115     {
116         return mode;
117     }
118
119     public void setMode(String JavaDoc mode)
120     {
121         this.mode = mode.intern();
122     }
123
124     public void setWhen(long when)
125     {
126         this.when = when;
127     }
128
129     public void setProperty(Property property, Object JavaDoc value)
130     {
131         properties.setProperty(property, value);
132     }
133
134     public void setProperty(Property property, boolean value)
135     {
136         properties.setProperty(property, value);
137     }
138
139     public void setProperty(Property property, int value)
140     {
141         properties.setProperty(property, value);
142     }
143
144     public boolean setPropertyFromString(Property property, String JavaDoc value)
145     {
146         return properties.setPropertyFromString(property, value);
147     }
148
149     public String JavaDoc getStringProperty(Property property)
150     {
151         return properties.getStringProperty(property);
152     }
153
154     public boolean getBooleanProperty(Property property)
155     {
156         return properties.getBooleanProperty(property);
157     }
158
159     public int getIntegerProperty(Property property)
160     {
161         return properties.getIntegerProperty(property);
162     }
163 }
164
Popular Tags