
com.cognitect.transit.impl.WriteHandlerMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of transit-java Show documentation
Show all versions of transit-java Show documentation
Transit is a data format and a set of libraries for conveying values between applications written in different languages. This library provides support for marshalling Transit data to/from Java.
The newest version!
// Copyright 2014 Cognitect. All Rights Reserved.
//
// 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.cognitect.transit.impl;
import com.cognitect.transit.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.function.Function;
public class WriteHandlerMap implements TagProvider, Map> {
private static Map> defaultHandlers() {
Map> handlers = new HashMap>();
WriteHandler integerHandler = new WriteHandlers.IntegerWriteHandler();
WriteHandler uriHandler = new WriteHandlers.ToStringWriteHandler("r");
WriteHandler arrayHandler = new WriteHandlers.ArrayWriteHandler();
handlers.put(Boolean.class, new WriteHandlers.BooleanWriteHandler());
handlers.put(null, new WriteHandlers.NullWriteHandler());
handlers.put(String.class, new WriteHandlers.ToStringWriteHandler("s"));
handlers.put(Integer.class, integerHandler);
handlers.put(Long.class, integerHandler);
handlers.put(Short.class, integerHandler);
handlers.put(Byte.class, integerHandler);
handlers.put(BigInteger.class, new WriteHandlers.ToStringWriteHandler("n"));
handlers.put(Float.class, new WriteHandlers.FloatWriteHandler());
handlers.put(Double.class, new WriteHandlers.DoubleWriteHandler());
handlers.put(BigDecimal.class, new WriteHandlers.ToStringWriteHandler("f"));
handlers.put(Character.class, new WriteHandlers.ToStringWriteHandler("c"));
handlers.put(Keyword.class, new WriteHandlers.KeywordWriteHandler());
handlers.put(Symbol.class, new WriteHandlers.ToStringWriteHandler("$"));
handlers.put(byte[].class, new WriteHandlers.BinaryWriteHandler());
handlers.put(UUID.class, new WriteHandlers.UUIDWriteHandler());
handlers.put(java.net.URI.class, uriHandler);
handlers.put(com.cognitect.transit.URI.class, uriHandler);
handlers.put(List.class, new WriteHandlers.ListWriteHandler());
handlers.put(Object[].class, arrayHandler);
handlers.put(int[].class, arrayHandler);
handlers.put(long[].class, arrayHandler);
handlers.put(float[].class, arrayHandler);
handlers.put(double[].class, arrayHandler);
handlers.put(short[].class, arrayHandler);
handlers.put(boolean[].class, arrayHandler);
handlers.put(char[].class, arrayHandler);
handlers.put(Set.class, new WriteHandlers.SetWriteHandler());
handlers.put(Date.class, new WriteHandlers.TimeWriteHandler());
handlers.put(Ratio.class, new WriteHandlers.RatioWriteHandler());
handlers.put(LinkImpl.class, new WriteHandlers.LinkWriteHandler());
handlers.put(Quote.class, new WriteHandlers.QuoteAbstractEmitter());
handlers.put(TaggedValue.class, new WriteHandlers.TaggedValueWriteHandler());
return Collections.unmodifiableMap(handlers);
}
public final static Map> defaults = defaultHandlers();
private final Map> handlers;
private WriteHandlerMap verboseHandlerMap;
Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy