Example usage for java.math BigDecimal toString

List of usage examples for java.math BigDecimal toString

Introduction

In this page you can find the example usage for java.math BigDecimal toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns the string representation of this BigDecimal , using scientific notation if an exponent is needed.

Usage

From source file:net.sourceforge.msscodefactory.v1_11.MSSBamMssCF.MSSBamMssCFBindNumberDefDefaultValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "MSSBamMssCFBindNumberDefDefaultValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }//from w w w.  j ava 2  s. c  om

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof IMSSBamBLNumberDefObj) {
        BigDecimal defaultValue = ((IMSSBamBLNumberDefObj) genDef).getOptionalDefaultValue();
        if (defaultValue == null) {
            ret = null;
        } else {
            ret = defaultValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "IMSSBamBLNumberDefObj");
    }

    return (ret);
}

From source file:net.sourceforge.msscodefactory.v1_11.MSSBamMssCF.MSSBamMssCFBindNumberDefUnknownValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "MSSBamMssCFBindNumberDefUnknownValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }//from   w w  w. ja va  2 s  .c  om

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof IMSSBamBLNumberDefObj) {
        BigDecimal unknownValue = ((IMSSBamBLNumberDefObj) genDef).getOptionalUnknownValue();
        if (unknownValue == null) {
            ret = null;
        } else {
            ret = unknownValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "IMSSBamBLNumberDefObj");
    }

    return (ret);
}

From source file:org.finra.datagenerator.engine.scxml.tags.RangeExtension.java

/**
 * Performs variable assignments from a set of values
 *
 * @param action            a RangeTag Action
 * @param possibleStateList a current list of possible states produced so far from expanding a model state
 * @return the cartesian product of every current possible state and the set of values specified by action
 *///ww w  . j  av a2s .  c  o  m
public List<Map<String, String>> pipelinePossibleStates(RangeTag action,
        List<Map<String, String>> possibleStateList) {
    String variable = action.getName();
    BigDecimal from = new BigDecimal(action.getFrom());
    BigDecimal to = new BigDecimal(action.getTo());
    BigDecimal step;
    if (action.getStep() != null) {
        step = new BigDecimal(action.getStep());
    } else {
        step = BigDecimal.ONE;
    }

    List<BigDecimal> rangeValues = new ArrayList<>();
    if (step.signum() == 1) {
        for (BigDecimal current = from; current.compareTo(to) <= 0; current = current.add(step)) {
            rangeValues.add(current);
        }
    } else if (step.signum() == -1) {
        for (BigDecimal current = from; current.compareTo(to) >= 0; current = current.add(step)) {
            rangeValues.add(current);
        }
    } else {
        rangeValues.add(from);
    }

    //take the product
    List<Map<String, String>> productTemp = new LinkedList<>();
    for (Map<String, String> p : possibleStateList) {
        for (BigDecimal value : rangeValues) {
            HashMap<String, String> n = new HashMap<>(p);
            n.put(variable, value.toString());
            productTemp.add(n);
        }
    }

    return productTemp;
}

From source file:org.opendatakit.aggregate.format.element.OhmageJsonElementFormatter.java

@Override
public void formatDecimal(BigDecimal dub, FormElementModel element, String ordinalValue, Row row) {
    OhmageJsonTypes.text resp = new OhmageJsonTypes.text(element.getElementName(), dub.toString());
    responses.add(resp);/*w ww.  j  ava2  s. c  om*/
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindNumberDefMaxValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindNumberDefMaxValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }//from  w w w  .  jav a  2s .c o m

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamNumberDefObj) {
        BigDecimal maxValue = ((ICFBamNumberDefObj) genDef).getOptionalMaxValue();
        if (maxValue == null) {
            ret = null;
        } else {
            ret = maxValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamNumberDefObj");
    }

    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindNumberDefMinValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindNumberDefMinValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }/*from  w w  w  .j ava 2 s. c  o  m*/

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamNumberDefObj) {
        BigDecimal minValue = ((ICFBamNumberDefObj) genDef).getOptionalMinValue();
        if (minValue == null) {
            ret = null;
        } else {
            ret = minValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamNumberDefObj");
    }

    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindUInt64DefMaxValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindUInt64DefMaxValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }//  ww w .  ja v  a  2  s  .c o  m

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamUInt64DefObj) {
        BigDecimal maxValue = ((ICFBamUInt64DefObj) genDef).getOptionalMaxValue();
        if (maxValue == null) {
            ret = null;
        } else {
            ret = maxValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamUInt64DefObj");
    }

    return (ret);
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindUInt64DefMinValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindUInt64DefMinValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }//from  www .j av a2s.  c o  m

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamUInt64DefObj) {
        BigDecimal minValue = ((ICFBamUInt64DefObj) genDef).getOptionalMinValue();
        if (minValue == null) {
            ret = null;
        } else {
            ret = minValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamUInt64DefObj");
    }

    return (ret);
}

From source file:cherry.foundation.crypto.SecureBigDecimalEncoderTest.java

@Test
public void testSecureBigDecimal() throws Exception {
    SecureBigDecimal.setEncoder(createSecureBigDecimalEncoder());
    for (int i = 0; i < 100; i++) {

        BigDecimal plain = BigDecimal.valueOf(random.nextDouble());
        SecureBigDecimal ss0 = SecureBigDecimal.plainValueOf(plain);
        assertThat(ss0.plain(), is(plain));
        assertThat(ss0.crypto(), is(not(plain.toString())));

        SecureBigDecimal ss1 = SecureBigDecimal.cryptoValueOf(ss0.crypto());
        assertThat(ss1.plain(), is(plain));
        assertThat(ss1.crypto(), is(ss0.crypto()));

        SecureBigDecimal ss2 = SecureBigDecimal.plainValueOf(ss1.plain());
        assertThat(ss2.plain(), is(plain));
        assertThat(ss2.crypto(), is(ss0.crypto()));

        SecureBigDecimal ss3 = SecureBigDecimal.cryptoValueOf(ss2.crypto());
        assertThat(ss3.plain(), is(plain));
        assertThat(ss3.crypto(), is(ss0.crypto()));
    }//from   w w  w  .j  av  a 2s.com
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMssCF.CFAccMssCFBindAccountEntryDebit.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFAccMssCFBindAccountEntryDebit.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }//  w w w .  ja v  a 2  s.  c  o  m

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFAccAccountEntryObj) {
        BigDecimal debit = ((ICFAccAccountEntryObj) genDef).getOptionalDebit();
        if (debit == null) {
            ret = null;
        } else {
            ret = debit.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFAccAccountEntryObj");
    }

    return (ret);
}