play.utils.OrderSafeProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
RePlay is a fork of the Play1 framework, created by Codeborne.
package play.utils;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.joining;
import static org.apache.commons.io.IOUtils.readLines;
import static org.apache.commons.text.StringEscapeUtils.escapeJava;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
/**
* Custom impl of java.util.properties that preserves the key-order from the file and that reads the
* properties-file in utf-8
*/
public class OrderSafeProperties extends java.util.Properties {
private static final Pattern ESCAPED_DOUBLE_QUOTE = Pattern.compile("\\\\\"");
private static final Pattern ESCAPED_SINGLE_QUOTE = Pattern.compile("(^|[^\\\\])(\\\\')");
private static final Pattern BACKSLASH = Pattern.compile("\\\\\\\\");
// set used to preserve key order
private final LinkedHashSet