Example usage for java.math BigInteger toString

List of usage examples for java.math BigInteger toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns the decimal String representation of this BigInteger.

Usage

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamMssCF.MSSBamMssCFBindUInt64DefUnknownValue.java

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

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

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

    String ret;

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

    return (ret);
}

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

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

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }// w  w w.  j  av 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 IMSSBamBLUInt64DefObj) {
        BigInteger defaultValue = ((IMSSBamBLUInt64DefObj) genDef).getOptionalDefaultValue();
        if (defaultValue == null) {
            ret = null;
        } else {
            ret = defaultValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "IMSSBamBLUInt64DefObj");
    }

    return (ret);
}

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

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

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

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

    String ret;

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

    return (ret);
}

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

@Test
public void testSecureBigInteger() throws Exception {
    SecureBigInteger.setEncoder(createSecureBigIntegerEncoder());
    for (int i = 0; i < 100; i++) {

        BigInteger plain = BigInteger.valueOf(random.nextInt());
        SecureBigInteger ss0 = SecureBigInteger.plainValueOf(plain);
        assertThat(ss0.plain(), is(plain));
        assertThat(ss0.crypto(), is(not(plain.toString())));

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

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

        SecureBigInteger ss3 = SecureBigInteger.cryptoValueOf(ss2.crypto());
        assertThat(ss3.plain(), is(plain));
        assertThat(ss3.crypto(), is(ss0.crypto()));
    }//from  w  w w. j  a  v  a2s.com
}

From source file:org.dbrain.data.jackson.serializers.JsonBigIntegerSerializer.java

@Override
public void serialize(BigInteger value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
    if (value != null) {
        if (value.compareTo(MIN_VALUE) >= 0 && value.compareTo(MAX_VALUE) <= 0) {
            jgen.writeNumber(value);/*ww w . j a  v  a  2 s. c o  m*/
        } else {
            jgen.writeString(value.toString());
        }
    } else {
        jgen.writeNull();
    }
}

From source file:be.fedict.trust.service.bean.TrustServiceTrustLinker.java

private RevokedCertificateEntity findRevokedCertificate(String issuer, BigInteger serialNumber) {

    return this.entityManager.find(RevokedCertificateEntity.class,
            new RevokedCertificatePK(issuer, serialNumber.toString()));
}

From source file:org.apache.xml.security.keys.content.x509.XMLX509IssuerSerial.java

/**
 * Constructor XMLX509IssuerSerial/*from  w w w  .j  a  v  a  2  s. c om*/
 *
 * @param doc
 * @param x509IssuerName
 * @param x509SerialNumber
 */
public XMLX509IssuerSerial(Document doc, String x509IssuerName, BigInteger x509SerialNumber) {
    super(doc);
    XMLUtils.addReturnToElement(this.constructionElement);
    addTextElement(x509IssuerName, Constants._TAG_X509ISSUERNAME);
    addTextElement(x509SerialNumber.toString(), Constants._TAG_X509SERIALNUMBER);
}

From source file:org.drools.planner.examples.cloudbalancing.persistence.CloudBalancingGenerator.java

public CloudBalance createCloudBalance(String inputId, int cloudComputerListSize, int cloudProcessListSize) {
    random = new Random(47);
    CloudBalance cloudBalance = new CloudBalance();
    cloudBalance.setId(0L);// ww w  .  ja  va  2s .c  o m
    createCloudComputerList(cloudBalance, cloudComputerListSize);
    createCloudProcessList(cloudBalance, cloudProcessListSize);
    BigInteger possibleSolutionSize = BigInteger.valueOf(cloudBalance.getComputerList().size())
            .pow(cloudBalance.getProcessList().size());
    String flooredPossibleSolutionSize = "10^" + (possibleSolutionSize.toString().length() - 1);
    logger.info("CloudBalance {} has {} computers and {} processes with a search space of {}.", inputId,
            cloudComputerListSize, cloudProcessListSize,
            possibleSolutionSize.compareTo(BigInteger.valueOf(1000L)) < 0 ? possibleSolutionSize
                    : flooredPossibleSolutionSize);
    return cloudBalance;
}

From source file:be.fedict.trust.service.dao.bean.CertificateAuthorityDAOBean.java

public CertificateAuthorityEntity findCertificateAuthority(X509Certificate certificate) {
    BigInteger serialNumber = certificate.getSerialNumber();
    String key = new String();
    key += certificate.getSubjectX500Principal().toString() + "|" + serialNumber.toString();
    LOG.debug("find (2) CA: " + key);

    return this.entityManager.find(CertificateAuthorityEntity.class,
            //certificate.getSubjectX500Principal().toString());
            key);//from w  ww  .j  a  v  a  2s  . c om
}

From source file:org.i3xx.step.uno.impl.ScriptCacheImpl.java

/**
 * Load scripts to the cache/*from w w  w. j  ava  2 s  .co m*/
 * 
 * @param store
 * @param key
 * @throws IOException 
 */
public void load(Store store, BigInteger key) throws IOException {
    //
    // Gets a sorted map of the keys. The map is in the order
    // of the sort objects (not in key order) which are long
    // values (set by the ScriptLoader).
    //
    Map<Object, BigInteger> map = store.getSortMap(key);
    List<BigInteger> list = new ArrayList<BigInteger>();
    Iterator<Object> iter = map.keySet().iterator();
    while (iter.hasNext())
        list.add(map.get(iter.next()));

    names = new String[list.size()];
    buffer = new byte[list.size()][];

    int c = 0;
    byte[] buf = new byte[1024];

    for (int i = 0; i < list.size(); i++) {
        BigInteger id = list.get(i);
        names[i] = id.toString();
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        OutputStream out = compress ? new GZIPOutputStream(bout) : bout;
        InputStream in = store.read(key, id);
        try {
            while ((c = in.read(buf)) > -1)
                out.write(buf, 0, c);
        } finally {
            out.flush();
            out.close();
            in.close();
        }
        buffer[i] = bout.toByteArray();
    } //for
}