com.landawn.abacus.parser.AbstractParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of abacus-util-se Show documentation
Show all versions of abacus-util-se Show documentation
A general programming library in Java/Android. It's easy to learn and simple to use with concise and powerful APIs.
/*
* Copyright (C) 2015 HaiYang Li
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.landawn.abacus.parser;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import com.landawn.abacus.exception.ParseException;
import com.landawn.abacus.logging.Logger;
import com.landawn.abacus.logging.LoggerFactory;
import com.landawn.abacus.type.Type;
import com.landawn.abacus.util.BiMap;
import com.landawn.abacus.util.ImmutableBiMap;
import com.landawn.abacus.util.ImmutableCollection;
import com.landawn.abacus.util.ImmutableList;
import com.landawn.abacus.util.ImmutableMap;
import com.landawn.abacus.util.ImmutableNavigableSet;
import com.landawn.abacus.util.ImmutableSet;
import com.landawn.abacus.util.ImmutableSortedMap;
import com.landawn.abacus.util.ImmutableSortedSet;
import com.landawn.abacus.util.N;
import com.landawn.abacus.util.Tuple;
import com.landawn.abacus.util.Tuple.Tuple2;
import com.landawn.abacus.util.function.Function;
/**
*
* @author Haiyang Li
* @param
* @param
* @since 0.8
*/
abstract class AbstractParser, DC extends DeserializationConfig>> implements Parser {
private static final Logger logger = LoggerFactory.getLogger(AbstractParser.class);
static final String ELEMENT_SEPARATOR = ", ".intern();
static final char[] ELEMENT_SEPARATOR_CHAR_ARRAY = ELEMENT_SEPARATOR.toCharArray();
static final String NULL_STRING = "null".intern();
static final char[] NULL_CHAR_ARRAY = NULL_STRING.toCharArray();
static final String TRUE = Boolean.TRUE.toString().intern();
static final char[] TRUE_CHAR_ARRAY = TRUE.toCharArray();
static final String FALSE = Boolean.FALSE.toString().intern();
static final char[] FALSE_CHAR_ARRAY = FALSE.toCharArray();
// ... it has to be big enough to make it's safety to add element to
// ArrayBlockingQueue.
static final int POOL_SIZE = 1000;
static final int CLS_POOL_SIZE = 3000;
/**
*
* @param obj
* @return
*/
@Override
public String serialize(Object obj) {
return serialize(obj, null);
}
/**
*
* @param file
* @param obj
*/
@Override
public void serialize(File file, Object obj) {
serialize(file, obj, null);
}
/**
*
* @param os
* @param obj
*/
@Override
public void serialize(OutputStream os, Object obj) {
serialize(os, obj, null);
}
/**
*
* @param writer
* @param obj
*/
@Override
public void serialize(Writer writer, Object obj) {
serialize(writer, obj, null);
}
/**
*
* @param
* @param targetClass
* @param st
* @return
*/
@Override
public T deserialize(Class targetClass, String st) {
return deserialize(targetClass, st, null);
}
/**
*
* @param
* @param targetClass
* @param file
* @return
*/
@Override
public T deserialize(Class targetClass, File file) {
return deserialize(targetClass, file, null);
}
/**
*
* @param
* @param targetClass
* @param is
* @return
*/
@Override
public T deserialize(Class targetClass, InputStream is) {
return deserialize(targetClass, is, null);
}
/**
*
* @param
* @param targetClass
* @param reader
* @return
*/
@Override
public T deserialize(Class targetClass, Reader reader) {
return deserialize(targetClass, reader, null);
}
static final Map, Tuple2, Object>, Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy