Java Formatter Usage fperfdata(String label, double val, String uom, int warnp, double warn, int critp, double crit, boolean minp, double minv, boolean maxp, double maxv)

Here you can find the source of fperfdata(String label, double val, String uom, int warnp, double warn, int critp, double crit, boolean minp, double minv, boolean maxp, double maxv)

Description

fperfdata

License

Open Source License

Declaration

public static String fperfdata(String label, double val, String uom, int warnp, double warn, int critp,
            double crit, boolean minp, double minv, boolean maxp, double maxv) 

Method Source Code

//package com.java2s;
/*****************************************************************************
 *
 * Blue Star, a Java Port of ./* w w  w .ja va 2 s  .  c o m*/
 * Last Modified : 3/20/2006
 *
 * License:
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * 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 Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 *****************************************************************************/

import java.util.Formatter;

public class Main {
    public static String fperfdata(String label, double val, String uom, int warnp, double warn, int critp,
            double crit, boolean minp, double minv, boolean maxp, double maxv) {
        Formatter f = new Formatter(new StringBuffer());

        if (label.matches("['= ]"))
            f.format("'%s'=", label);
        else
            f.format("%s=", label);

        f.format("%f", val);
        f.format("%s;", uom);

        if (warnp != 0)
            f.format("%f", warn);

        f.format(";");

        if (critp != 0)
            f.format("%f", crit);

        f.format(";");

        if (minp)
            f.format("%f", minv);

        if (maxp) {
            f.format(";");
            f.format("%f", maxv);
        }

        return f.toString();
    }
}

Related

  1. formatNumber(int number)
  2. formatResponse(Formatter formatter, String response)
  3. formatTzname(final String format, final String letter)
  4. formatv(String format, Object[] args)
  5. formatZeroDecimals(Number x)
  6. generateMacOnIncrease(final String baseMac, final long l)
  7. getCommitCounterStr(final long commitCounter)
  8. getFormatedTime(double timeInSeconds)
  9. getPropertiesString(Properties myProps)