aQute.lib.utf8properties
Class UTF8Properties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<Object,Object>
          extended by java.util.Properties
              extended by aQute.lib.utf8properties.UTF8Properties
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class UTF8Properties
extends Properties

Properties were by default read as ISO-8859-1 characters. However, in the last 10 years most builds use UTF-8. Since this is in general a global setting, it is very awkward to use ISO-8859-1. In general, it is not often a problem since most of Java is written with the basic ASCII encoding. However, we want to do this right. So in bnd we generally use this UTF-8 Properties class. This class always writes UTF-8. However, it will try to read UTF-8 first. If this fails, it will try ISO-8859-1, and the last attempt is the platform default.

An additional problem is backslash encoding. When reading properties, the Properties class skips backslashes that have no correct next character. This is not a real problem if it was not for bndtools where it turned out to be real tricky to get the UI to understand this since text widgets read from the properties (backslash removed) while the main text is just, well, the main text and has the backslash present. Since we strife to fidelity, we actually fixup the

This class can (and probably should) be used anywhere a Properties class is used.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
UTF8Properties()
           
UTF8Properties(Properties p)
           
 
Method Summary
 void load(InputStream in)
           
 void load(Reader r)
           
 void store(OutputStream out, String msg)
           
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, loadFromXML, propertyNames, save, setProperty, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UTF8Properties

public UTF8Properties(Properties p)

UTF8Properties

public UTF8Properties()
Method Detail

load

public void load(InputStream in)
          throws IOException
Overrides:
load in class Properties
Throws:
IOException

load

public void load(Reader r)
          throws IOException
Overrides:
load in class Properties
Throws:
IOException

store

public void store(OutputStream out,
                  String msg)
           throws IOException
Overrides:
store in class Properties
Throws:
IOException


Copyright © 2014 aQute SARL. All rights reserved.