Package aQute.lib.utf8properties
Class UTF8Properties
- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
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.
This class can (and probably should) be used anywhere a Properties class is used.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final List<ThreadLocal<CharsetDecoder>> private static final Patternprivate static final longFields inherited from class java.util.Properties
defaults -
Constructor Summary
ConstructorsConstructorDescriptionUTF8Properties(File file) UTF8Properties(File file, Reporter reporter) UTF8Properties(File file, Reporter reporter, String[] syntaxHeaders) UTF8Properties(File file, String[] syntaxHeaders) -
Method Summary
Modifier and TypeMethodDescriptionprivate Stringdecode(byte[] buffer) private static Collection<String> voidvoidvoidload(File file, Reporter reporter, Collection<String> syntaxHeaders) voidload(InputStream in) voidload(InputStream in, File file, Reporter reporter) voidload(InputStream in, File file, Reporter reporter, String[] syntaxHeaders) voidload(InputStream in, File file, Reporter reporter, Collection<String> syntaxHeaders) voidvoidvoidvoidreplaceAll(String pattern, String replacement) Replace a string in all the values.private UTF8PropertiesreplaceAll(Pattern regex, String replacement) replaceHere(File file) Replace the string "${.}" in all the values with the path of the specified file.voidvoidstore(OutputStream out) voidstore(OutputStream out, String msg) voidMethods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, keySet, list, list, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
decoders
-
HERE_PATTERN
-
-
Constructor Details
-
Method Details
-
fromArray
-
load
public void load(InputStream in, File file, Reporter reporter, String[] syntaxHeaders) throws IOException - Throws:
IOException
-
load
public void load(InputStream in, File file, Reporter reporter, Collection<String> syntaxHeaders) throws IOException - Throws:
IOException
-
load
- Throws:
IOException
-
load
- Throws:
IOException
-
load
public void load(String source, File file, Reporter reporter, String[] syntaxHeaders) throws IOException - Throws:
IOException
-
load
public void load(String source, File file, Reporter reporter, Collection<String> syntaxHeaders) throws IOException - Throws:
IOException
-
load
- Throws:
Exception
-
load
- Throws:
Exception
-
load
- Throws:
Exception
-
load
- Overrides:
loadin classProperties- Throws:
IOException
-
load
- Overrides:
loadin classProperties- Throws:
IOException
-
decode
-
store
- Overrides:
storein classProperties- Throws:
IOException
-
store
- Overrides:
storein classProperties- Throws:
IOException
-
store
- Throws:
IOException
-
store
- Throws:
IOException
-
replaceAll
Replace a string in all the values. This can be used to preassign variables that change. For example, the base directory ${.} for a loaded properties.- Returns:
- A new UTF8Properties with the replacement.
-
replaceAll
-
replaceHere
Replace the string "${.}" in all the values with the path of the specified file.- Returns:
- A new UTF8Properties with the replacement.
-