1 21 22 package org.armedbear.j; 23 24 import java.util.Iterator ; 25 import java.util.StringTokenizer ; 26 27 public final class FileHistoryEntry 28 { 29 private static final String lineSeparator = 30 System.getProperty("line.separator"); 31 32 private String name; 33 private String encoding; 34 private String mode; 35 private long when; 36 private PropertyList properties = new PropertyList(); 37 38 public FileHistoryEntry() 39 { 40 } 41 42 public String 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 it = properties.keyIterator(); 61 if (it != null) { 62 while (it.hasNext()) { 63 Property property = (Property) it.next(); 64 Object 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 propertyToXml(String name, String 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 (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 getName() 95 { 96 return name; 97 } 98 99 public void setName(String name) 100 { 101 this.name = name; 102 } 103 104 public String getEncoding() 105 { 106 return encoding; 107 } 108 109 public void setEncoding(String encoding) 110 { 111 this.encoding = encoding; 112 } 113 114 public String getMode() 115 { 116 return mode; 117 } 118 119 public void setMode(String 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 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 value) 145 { 146 return properties.setPropertyFromString(property, value); 147 } 148 149 public String 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 |