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.parser.*; 017 018/** 019 * TODO - Work in progress. CSV parser. 020 */ 021public class CsvParser extends ReaderParser { 022 023 //------------------------------------------------------------------------------------------------------------------- 024 // Predefined instances 025 //------------------------------------------------------------------------------------------------------------------- 026 027 /** Default parser, all default settings.*/ 028 public static final CsvParser DEFAULT = new CsvParser(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 CsvParser(PropertyStore ps) { 041 super(ps, "text/csv"); 042 } 043 044 @Override /* Context */ 045 public CsvParserBuilder builder() { 046 return new CsvParserBuilder(getPropertyStore()); 047 } 048 049 /** 050 * Instantiates a new clean-slate {@link CsvParserBuilder} object. 051 * 052 * <p> 053 * Note that this method creates a builder initialized to all default settings, whereas {@link #builder()} copies 054 * the settings of the object called on. 055 * 056 * @return A new {@link CsvParserBuilder} object. 057 */ 058 public static CsvParserBuilder create() { 059 return new CsvParserBuilder(); 060 } 061 062 @Override /* Parser */ 063 public ReaderParserSession createSession(ParserSessionArgs args) { 064 return new CsvParserSession(this, args); 065 } 066 067 @Override /* Context */ 068 public ObjectMap asMap() { 069 return super.asMap() 070 .append("CsvParser", new ObjectMap()); 071 } 072}