Here you can find the source of serializeQuery(BigInteger modulus, BigInteger base, BigInteger exponent, boolean brief, String... modexps)
Parameter | Description |
---|---|
modulus | the default modulus to use or null to omit |
base | the default base to use or null to omit |
exponent | the default exponent to use or null to omit |
brief | should the server return a brief or full response? |
modexps | JSON strings of modexps to queryResponse for |
static String serializeQuery(BigInteger modulus, BigInteger base, BigInteger exponent, boolean brief, String... modexps)
//package com.java2s; /*/*from w ww.j av a 2 s . c o m*/ * Copyright 2016 Pascal Mainini * Licensed under MIT license, see included file LICENSE or * http://opensource.org/licenses/MIT */ import java.math.BigInteger; public class Main { /** * Helper method creating the JSON string for a modexp-queryResponse with optional default base, exponent and modulus. * @param modulus the default modulus to use or null to omit * @param base the default base to use or null to omit * @param exponent the default exponent to use or null to omit * @param brief should the server return a brief or full response? * @param modexps JSON strings of modexps to queryResponse for * @return A JSON representation of a modexp-queryResponse */ static String serializeQuery(BigInteger modulus, BigInteger base, BigInteger exponent, boolean brief, String... modexps) { String query = "{"; query = modulus != null ? query + "\"m\":\"" + modulus.toString(16) + "\"," : query; query = base != null ? query + "\"b\":\"" + base.toString(16) + "\"," : query; query = exponent != null ? query + "\"e\":\"" + exponent.toString(16) + "\"," : query; query = brief ? query : query + "\"brief\":false,"; query = modexps.length > 0 ? query + "\"modexps\":[" : query; for (int i = 0; i < modexps.length; i++) { query += modexps[i]; query += i < modexps.length - 1 ? "," : ""; } query = modexps.length > 0 ? query + "]" : query; return query + "}"; } }