All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nerd4j.csv.registry.CSVFieldProcessorRegistry Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
/*
 * #%L
 * Nerd4j CSV
 * %%
 * Copyright (C) 2013 Nerd4j
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * .
 * #L%
 */
package org.nerd4j.csv.registry;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

import org.nerd4j.csv.field.CSVFieldProcessor;
import org.nerd4j.csv.field.processor.EmptyCSVFieldProcessor;
import org.nerd4j.csv.field.processor.FormatBoolean;
import org.nerd4j.csv.field.processor.FormatNumber;
import org.nerd4j.csv.field.processor.ParseBoolean;
import org.nerd4j.csv.field.processor.ParseNumber;


/**
 * Represents a registry of {@link CSVFieldProcessor}s.
 * 
 * 

* This registry is internally used to refer {@link CSVFieldProcessor}s by name. * It is possible to register custom processors. *

* *

* The following processors are registered by default: *

    *
  • parseByte
  • *
  • parseShort
  • *
  • parseInteger
  • *
  • parseLong
  • *
  • parseFloat
  • *
  • parseDouble
  • *
  • parseBigInteger
  • *
  • parseBigDecimal
  • *
  • parseAtomicInteger
  • *
  • parseAtomicLong
  • *
    *
  • formatByte
  • *
  • formatShort
  • *
  • formatInteger
  • *
  • formatLong
  • *
  • formatFloat
  • *
  • formatDouble
  • *
  • formatBigInteger
  • *
  • formatBigDecimal
  • *
  • formatAtomicInteger
  • *
  • formatAtomicLong
  • *
    *
  • parseBoolean
  • *
  • formatBoolean
  • *
*

* * @author Nerd4j Team */ final class CSVFieldProcessorRegistry extends CSVAbstractRegistry> { /** * Default constructor. * */ public CSVFieldProcessorRegistry() { super(); this.registerDefaults(); } /* ***************** */ /* PRIVATE METHODS */ /* ***************** */ /** * Creates and registers the default entries and builders. * */ @SuppressWarnings("rawtypes") private void registerDefaults() { setEntry( "default", new EmptyCSVFieldProcessor() ); /* Simple Boolean Processors. */ setEntry( "parseBoolean", new ParseBoolean() ); setEntry( "formatBoolean", new FormatBoolean() ); /* Simple String to Number Processors. */ setEntry( "parseByte", new ParseNumber( Byte.class ) ); setEntry( "parseShort", new ParseNumber( Short.class ) ); setEntry( "parseInteger", new ParseNumber( Integer.class ) ); setEntry( "parseLong", new ParseNumber( Long.class ) ); setEntry( "parseFloat", new ParseNumber( Float.class ) ); setEntry( "parseDouble", new ParseNumber( Double.class ) ); setEntry( "parseBigInteger", new ParseNumber( BigInteger.class ) ); setEntry( "parseBigDecimal", new ParseNumber( BigDecimal.class ) ); setEntry( "parseAtomicInteger", new ParseNumber( AtomicInteger.class ) ); setEntry( "parseAtomicLong", new ParseNumber( AtomicLong.class ) ); /* Simple Number to String Processors. */ setEntry( "formatByte", new FormatNumber() ); setEntry( "formatShort", new FormatNumber() ); setEntry( "formatInteger", new FormatNumber() ); setEntry( "formatLong", new FormatNumber() ); setEntry( "formatFloat", new FormatNumber() ); setEntry( "formatDouble", new FormatNumber() ); setEntry( "formatBigInteger", new FormatNumber() ); setEntry( "formatBigDecimal", new FormatNumber() ); setEntry( "formatAtomicInteger", new FormatNumber() ); setEntry( "formatAtomicLong", new FormatNumber() ); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy