org.glassfish.main.jul.cfg.LoggingProperties Maven / Gradle / Ivy
/*
* Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.main.jul.cfg;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Collectors;
/**
* Extended {@link Properties} class. Same as {@link Properties}, it uses hashcodes for providing
* values for property names, but the difference is in storing content to a file or stream, which is
* sorted by keys.
*
* Also provides some methods for more comfortable work.
*
* Warning: using other than {@link String} objects can cause unexpected behavior.
*
* @author David Matejcek
*/
// note: this class must not use anything from JUL or GJULE packages, because the dependency is exactly opposite.
public class LoggingProperties extends Properties {
private static final long serialVersionUID = 8351124426913908969L;
/**
* Creates an empty property table.
*/
public LoggingProperties() {
super();
}
/**
* Makes a copy of provided properties.
*
* @param properties
*/
public LoggingProperties(final Properties properties) {
super();
putAll(properties);
}
/**
* @return a sorted {@link Enumeration} of keys.
*/
// affects storage!
@Override
public Enumeration