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 Pattern
private static final long
Fields 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 String
decode
(byte[] buffer) private static Collection<String>
void
void
void
load
(File file, Reporter reporter, Collection<String> syntaxHeaders) void
load
(InputStream in) void
load
(InputStream in, File file, Reporter reporter) void
load
(InputStream in, File file, Reporter reporter, String[] syntaxHeaders) void
load
(InputStream in, File file, Reporter reporter, Collection<String> syntaxHeaders) void
void
void
void
replaceAll
(String pattern, String replacement) Replace a string in all the values.private UTF8Properties
replaceAll
(Pattern regex, String replacement) replaceHere
(File file) Replace the string "${.}" in all the values with the path of the specified file.void
void
store
(OutputStream out) void
store
(OutputStream out, String msg) void
Methods 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:
load
in classProperties
- Throws:
IOException
-
load
- Overrides:
load
in classProperties
- Throws:
IOException
-
decode
-
store
- Overrides:
store
in classProperties
- Throws:
IOException
-
store
- Overrides:
store
in 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.
-