Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* The MIT License
* Copyright (c) 2014 Benoit Lacelle
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package blasd.apex.core.io;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.io.Writer;
import java.nio.file.Path;
import java.util.Base64;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.annotations.Beta;
import com.google.common.base.CharMatcher;
import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.base.Splitter.MapSplitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import blasd.apex.core.jmx.SetStaticMBean;
/**
* Various utility method related to Serialization, as conversion from/to String to/from Collections and Map
*
* @author Benoit Lacelle
*
*/
public class ApexSerializationHelper {
protected static final Logger LOGGER = LoggerFactory.getLogger(ApexSerializationHelper.class);
// Excel accepts only 32,767 chars per cell: we accept up to 4 MDX in a row
// https://support.office.com/en-us/article/Excel-specifications-and-limits-16c69c74-3d6a-4aaf-ba35-e6eb276e8eaa
public static final int MAX_CHARS_PER_COLUMN = 8192;
public static final char MAP_KEY_VALUE_SEPARATOR = '=';
// This should be the same as IPostProcessor.SEPARATOR
public static final char MAP_ENTRY_SEPARATOR = ',';
// Human often use ';' as entry separator
public static final char MAP_ENTRY_SEPARATOR_SEMICOLUMN = ';';
// Handle 'a=b,c=d'
public static final MapSplitter MAP_TO_STRING_SPLITTER =
Splitter.on(MAP_ENTRY_SEPARATOR).trimResults().withKeyValueSeparator(MAP_KEY_VALUE_SEPARATOR);
// Handle 'a=b;c=d'
public static final MapSplitter MAP_TO_STRING_SPLITTER_SEMICOLUMN =
Splitter.on(MAP_ENTRY_SEPARATOR_SEMICOLUMN).trimResults().withKeyValueSeparator(MAP_KEY_VALUE_SEPARATOR);
public static final char PIPE = '|';
// TODO
// This should be the same as IPostProcessor.SEPARATOR
public static final char COLLECTION_SEPARATOR = PIPE;
public static final char FORCE_SEPARATOR = '#';
// TODO: Not useful at all?
@Deprecated
protected static final Function