001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.csv; 014 015import org.apache.juneau.*; 016import org.apache.juneau.serializer.*; 017 018/** 019 * TODO - Work in progress. CSV serializer. 020 */ 021public final class CsvSerializer extends WriterSerializer { 022 023 //------------------------------------------------------------------------------------------------------------------- 024 // Predefined instances 025 //------------------------------------------------------------------------------------------------------------------- 026 027 /** Default serializer, all default settings.*/ 028 public static final CsvSerializer DEFAULT = new CsvSerializer(PropertyStore.DEFAULT); 029 030 031 //------------------------------------------------------------------------------------------------------------------- 032 // Instance 033 //------------------------------------------------------------------------------------------------------------------- 034 035 /** 036 * Constructor. 037 * 038 * @param ps The property store containing all the settings for this object. 039 */ 040 public CsvSerializer(PropertyStore ps) { 041 super(ps, "text/csv"); 042 } 043 044 @Override /* Context */ 045 public CsvSerializerBuilder builder() { 046 return new CsvSerializerBuilder(getPropertyStore()); 047 } 048 049 /** 050 * Instantiates a new clean-slate {@link CsvSerializerBuilder} object. 051 * 052 * <p> 053 * This is equivalent to simply calling <code><jk>new</jk> CsvSerializerBuilder()</code>. 054 * 055 * <p> 056 * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies 057 * the settings of the object called on. 058 * 059 * @return A new {@link CsvSerializerBuilder} object. 060 */ 061 public static CsvSerializerBuilder create() { 062 return new CsvSerializerBuilder(); 063 } 064 065 @Override /* Serializer */ 066 public WriterSerializerSession createSession(SerializerSessionArgs args) { 067 return new CsvSerializerSession(this, args); 068 } 069 070 @Override /* Context */ 071 public ObjectMap asMap() { 072 return super.asMap() 073 .append("CsvSerializer", new ObjectMap()); 074 } 075}