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.
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.camel.component.flatpack;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.sf.flatpack.DataSet;
import net.sf.flatpack.DefaultParserFactory;
import net.sf.flatpack.Parser;
import net.sf.flatpack.ParserFactory;
import net.sf.flatpack.writer.DelimiterWriterFactory;
import net.sf.flatpack.writer.FixedWriterFactory;
import net.sf.flatpack.writer.Writer;
import org.apache.camel.Exchange;
import org.apache.camel.spi.DataFormat;
import org.apache.camel.util.IOHelper;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.ResourceHelper;
import org.jdom.JDOMException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Flatpack DataFormat.
*
* This data format supports two operations:
*
*
marshal = from List<Map<String, Object>> to OutputStream (can be converted to String)
*
unmarshal = from InputStream (such as a File) to {@link DataSetList}.
*
* Notice: The Flatpack library does currently not support header and trailers for the marshal operation.
*
* @version
*/
public class FlatpackDataFormat implements DataFormat {
private static final transient Logger LOG = LoggerFactory.getLogger(FlatpackDataFormat.class);
private ParserFactory parserFactory = DefaultParserFactory.getInstance();
private char delimiter = ',';
private char textQualifier = '"';
private boolean ignoreFirstRecord = true;
private boolean fixed;
private boolean allowShortLines;
private boolean ignoreExtraColumns;
private String definition;
@SuppressWarnings("unchecked")
public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
ObjectHelper.notNull(graph, "The object to marshal must be provided");
List