[Home] DMelt member access. Java source code: com.jstatcom.util.FArg
/*
This file is part of the software framework JStatCom,
a library for building applications for data based analysis.
Copyright (C) 2000-2005 Markus Kraetzig
This library 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 2.1 of the
License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
*/
package com.jstatcom.util;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
/**
* Since Java 1.5 one should rather use Formatter.format instead of
* this class. However, this one is a bit more tolerant against wrongly
* specified input.
*
* Formatting argument class that originally served as an adapter to
* PrintfFormat. whith a more convenient and shorter syntax.
*
* Usage note:
* One should use the static method sprintf and construct a new
* FArg instance to hold parameters. Further arguments can be
* appended very C-like with a varargs argument, for example:
*
* FArg.sprintf("%-13s %- 8.4f", "statistic:", 2.345)
*
*
* @author Markus Kraetzig
* @see PrintfFormat
*/
public final class FArg {
// incompatible with String.format: %-s, %i
private static final Pattern pattern1 = Pattern
.compile(".*\\s*%[-]?\\s*[0-9]*[is].*\\s*");
// incompatible with String.format: %-2.0d
private static final Pattern pattern2 = Pattern
.compile(".*\\s*%[-]?\\s*[0-9]*\\.[0-9]*d.*\\s*");
private final List