当前位置: 首页>>代码示例>>Java>>正文


Java ValueType类代码示例

本文整理汇总了Java中javax.json.JsonValue.ValueType的典型用法代码示例。如果您正苦于以下问题:Java ValueType类的具体用法?Java ValueType怎么用?Java ValueType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ValueType类属于javax.json.JsonValue包,在下文中一共展示了ValueType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readAdapterNotes

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
private static String readAdapterNotes(JsonObject root) {
    if (root.containsKey("adapterNotes")) {
        JsonValue notes = root.get("adapterNotes");
        if (notes.getValueType() == ValueType.STRING) {
            // Return unquoted string
            return ((JsonString)notes).getString();
        } else {
            return notes.toString();
        }
    }
    return "";
}
 
开发者ID:EXASOL,项目名称:virtual-schemas,代码行数:13,代码来源:RequestJsonParser.java

示例2: jsonToMap

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
private Map<String, String> jsonToMap(JsonObject jsonOutput) {
	Map<String, String> resultMap = new HashMap<>();
	for(String key:jsonOutput.keySet()) {
		JsonValue value = jsonOutput.get(key);
		if(value.getValueType() == ValueType.STRING) {
			resultMap.put(key, jsonOutput.getString(key));
		} else if (!value.getValueType().equals(ValueType.OBJECT)&&!value.getValueType().equals(ValueType.ARRAY)) {
			resultMap.put(key, jsonOutput.getString(key).toString());
		}
	}
	return resultMap;
}
 
开发者ID:denkbar,项目名称:step,代码行数:13,代码来源:CallFunctionHandler.java

示例3: testInt

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
@Test
public void testInt ()
{
	JsonNumber v = new CookJsonInt (1234);

	Assert.assertEquals (ValueType.NUMBER, v.getValueType ());

	Assert.assertEquals (true, v.isIntegral ());
	Assert.assertEquals (1234, v.intValue ());
	Assert.assertEquals (1234, v.intValueExact ());
	Assert.assertEquals (1234, v.longValue ());
	Assert.assertEquals (1234, v.longValueExact ());
	Assert.assertEquals (new BigInteger ("1234"), v.bigIntegerValue ());
	Assert.assertEquals (new BigInteger ("1234"), v.bigIntegerValueExact ());
	Assert.assertEquals (new BigDecimal (1234), v.bigDecimalValue ());
	Assert.assertEquals (1234, v.doubleValue (), 0);
	Assert.assertEquals (new BigDecimal (1234).hashCode (), v.hashCode ());
	Assert.assertEquals ("1234", v.toString ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:20,代码来源:NumberTest.java

示例4: testLong

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
@Test
public void testLong ()
{
	long d = 1234;
	JsonNumber v = new CookJsonLong (d);

	Assert.assertEquals (ValueType.NUMBER, v.getValueType ());

	Assert.assertEquals (true, v.isIntegral ());
	Assert.assertEquals (1234, v.intValue ());
	Assert.assertEquals (1234, v.intValueExact ());
	Assert.assertEquals (d, v.longValue ());
	Assert.assertEquals (d, v.longValueExact ());
	Assert.assertEquals (new BigInteger ("1234"), v.bigIntegerValue ());
	Assert.assertEquals (new BigInteger ("1234"), v.bigIntegerValueExact ());
	Assert.assertEquals (new BigDecimal (d), v.bigDecimalValue ());
	Assert.assertEquals (d, v.doubleValue (), 0);
	Assert.assertEquals (new BigDecimal (d).hashCode (), v.hashCode ());
	Assert.assertEquals ("1234", v.toString ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:21,代码来源:NumberTest.java

示例5: testDouble

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
@Test
public void testDouble ()
{
	double d = 1234;
	JsonNumber v = new CookJsonDouble (d);

	Assert.assertEquals (ValueType.NUMBER, v.getValueType ());

	Assert.assertEquals (false, v.isIntegral ());
	Assert.assertEquals (1234, v.intValue ());
	Assert.assertEquals (1234, v.intValueExact ());
	Assert.assertEquals (1234, v.longValue ());
	Assert.assertEquals (1234, v.longValueExact ());
	Assert.assertEquals (new BigInteger ("1234"), v.bigIntegerValue ());
	Assert.assertEquals (new BigInteger ("1234"), v.bigIntegerValueExact ());
	Assert.assertEquals (BigDecimal.valueOf (d), v.bigDecimalValue ());
	Assert.assertEquals (d, v.doubleValue (), 0);
	Assert.assertEquals (BigDecimal.valueOf (d).hashCode (), v.hashCode ());
	Assert.assertEquals (DoubleUtils.toString (d), v.toString ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:21,代码来源:NumberTest.java

示例6: testBigInteger

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
@Test
public void testBigInteger ()
{
	BigInteger d = new BigInteger ("1234");
	JsonNumber v = new CookJsonBigDecimal (d);

	Assert.assertEquals (ValueType.NUMBER, v.getValueType ());

	Assert.assertEquals (true, v.isIntegral ());
	Assert.assertEquals (d.intValue (), v.intValue ());
	Assert.assertEquals (d.intValue (), v.intValueExact ());
	Assert.assertEquals (d.longValue (), v.longValue ());
	Assert.assertEquals (d.longValue (), v.longValueExact ());
	Assert.assertEquals (d, v.bigIntegerValue ());
	Assert.assertEquals (d, v.bigIntegerValueExact ());
	Assert.assertEquals (new BigDecimal (d), v.bigDecimalValue ());
	Assert.assertEquals (d.doubleValue (), v.doubleValue (), 0);
	Assert.assertEquals (new BigDecimal (d).hashCode (), v.hashCode ());
	Assert.assertEquals (d.toString (), v.toString ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:21,代码来源:NumberTest.java

示例7: testBigDecimal

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
@Test
	public void testBigDecimal ()
	{
		BigDecimal d = new BigDecimal ("1234.1234");
		JsonNumber v = new CookJsonBigDecimal (d);

		Assert.assertEquals (ValueType.NUMBER, v.getValueType ());

		Assert.assertEquals (false, v.isIntegral ());
		Assert.assertEquals (d.intValue (), v.intValue ());
//		Assert.assertEquals (d.intValue (), v.intValueExact ());
		Assert.assertEquals (d.longValue (), v.longValue ());
//		Assert.assertEquals (d.longValue (), v.longValueExact ());
		Assert.assertEquals (d.toBigInteger (), v.bigIntegerValue ());
//		Assert.assertEquals (d.toBigInteger (), v.bigIntegerValueExact ());
		Assert.assertEquals (d, v.bigDecimalValue ());
		Assert.assertEquals (d.doubleValue (), v.doubleValue (), 0);
		Assert.assertEquals (d.hashCode (), v.hashCode ());
		Assert.assertEquals (d.toString (), v.toString ());
	}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:21,代码来源:NumberTest.java

示例8: test

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
@Test
public void test ()
{
	byte[] bytes = "test".getBytes (BOM.utf8);
	CookJsonBinary v = new CookJsonBinary (bytes.clone ());
	Assert.assertEquals (Arrays.hashCode (bytes), v.hashCode ());
	Assert.assertEquals (ValueType.STRING, v.getValueType ());
	Assert.assertArrayEquals (bytes, v.getBytes ());

	String base64 = Base64.encodeBase64String (bytes);
	Assert.assertEquals (base64, v.getString ());
	Assert.assertEquals (base64, v.getChars ());
	Assert.assertEquals ('"' + base64 + '"', v.toString ());
	Assert.assertEquals (BinaryFormat.BINARY_FORMAT_BASE64, v.getBinaryFormat ());

	v.setBinaryFormat (BinaryFormat.BINARY_FORMAT_HEX);
	String hex = Hex.encodeHexString (bytes);
	Assert.assertEquals (hex, v.getString ());
	Assert.assertEquals (hex, v.getChars ());
	Assert.assertEquals ('"' + hex + '"', v.toString ());
	Assert.assertEquals (BinaryFormat.BINARY_FORMAT_HEX, v.getBinaryFormat ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:23,代码来源:CookJsonBinaryTest.java

示例9: getJsonValue

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
public static JsonValue getJsonValue(String json_path, JsonObject response) {
	StringTokenizer tk = new StringTokenizer(json_path, "/");

	JsonValue rValue = response;
	JsonObject value = response;
	while (tk.hasMoreTokens()) {
		String key = tk.nextToken();
		rValue = value.get(key);
		if (rValue == null || (rValue.getValueType() != ValueType.OBJECT)) {
			break;
		} else {
			value = (JsonObject) rValue;
		}
	}
	return rValue;
}
 
开发者ID:Nastel,项目名称:jkool-client-java-api,代码行数:17,代码来源:JKUtils.java

示例10: getAssetMap

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
/**
 * Return a map from id to JsonObject representing an Asset
 * <p>
 * This method will re-read the json file if it has not yet been read, or if it has changed since we last read it.
 */
private synchronized Map<String, JsonObject> getAssetMap() throws IOException {
    if (!file.canRead()) {
        throw new IOException("Cannot read repository file: " + file.getAbsolutePath());
    } else if (assets == null || file.lastModified() != fileLastModified || file.length() != fileLastSize) {
        // Re-read the file if either we've never read it or it's changed length since we last read it
        assets = null;
        fileLastModified = file.lastModified();
        fileLastSize = file.length();

        idCounter = new AtomicInteger(1);
        assets = new HashMap<String, JsonObject>();
        JsonReader reader = Json.createReader(new FileInputStream(file));
        JsonArray assetList = reader.readArray();
        for (JsonValue val : assetList) {
            String id = Integer.toString(idCounter.getAndIncrement());
            if (val.getValueType() == ValueType.OBJECT) {
                assets.put(id, (JsonObject) val);
            }
        }
    }

    return assets;
}
 
开发者ID:WASdev,项目名称:tool.lars,代码行数:29,代码来源:SingleFileClient.java

示例11: getString

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
/**
 * Get optional long value out of the message json payload
 *
 * @param key
 *            Key to find value for
 * @return value in object or null
 */
public String getString(String key) {
    String result = null;
    JsonObject obj = getParsedBody();
    JsonValue value = obj.get(key);
    if ( value != null ) {
        try {
            if ( value.getValueType() == ValueType.STRING) {
                result = obj.getString(key);
            } else {
                result = value.toString();
            }
        } catch (Exception e) { // class cast, etc
            Log.log(Level.FINER, this, "Exception parsing String: " + value, e);
            // fall through to return default value
        }
    }

    return result;
}
 
开发者ID:gameontext,项目名称:gameon-mediator,代码行数:27,代码来源:RoutedMessage.java

示例12: getLongArray

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
/**
 * @param key
 * @return JsonArray value or null
 */
public List<Long> getLongArray(String key, List<Long> defaultValue) {
    JsonObject obj = getParsedBody();
    JsonValue arrayValue = obj.get(key);
    if ( arrayValue != null && arrayValue.getValueType() == ValueType.ARRAY ) {
        try {
            List<Long> result = new ArrayList<>();
            ((JsonArray) arrayValue).forEach(value -> result.add(((JsonNumber) value).longValue()));
            return result;
        } catch (Exception e) { // class cast, etc
            Log.log(Level.FINER, this, "Exception parsing JsonArray: " + arrayValue, e);
            // fall through to return default value
        }
    }
    return defaultValue;
}
 
开发者ID:gameontext,项目名称:gameon-mediator,代码行数:20,代码来源:RoutedMessage.java

示例13: parseTagList

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
@Override
public TagList parseTagList(Reader theReader) {
	JsonReader reader = Json.createReader(theReader);
	JsonObject object = reader.readObject();

	JsonValue resourceTypeObj = object.get("resourceType");
	assertObjectOfType(resourceTypeObj, JsonValue.ValueType.STRING, "resourceType");
	String resourceType = ((JsonString) resourceTypeObj).getString();

	ParserState<TagList> state = ParserState.getPreTagListInstance(myContext, true);
	state.enteringNewElement(null, resourceType);

	parseChildren(object, state);

	state.endingElement();

	return state.getObject();
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:19,代码来源:JsonParser.java

示例14: getEvent

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
private static Event getEvent(final ValueType value) {

        switch (value) {
        case NUMBER:
            return Event.VALUE_NUMBER;
        case STRING:
            return Event.VALUE_STRING;
        case FALSE:
            return Event.VALUE_FALSE;
        case NULL:
            return Event.VALUE_NULL;
        case TRUE:
            return Event.VALUE_TRUE;
        default:
            throw new IllegalArgumentException(value + " not supported");

        }

    }
 
开发者ID:apache,项目名称:johnzon,代码行数:20,代码来源:JsonInMemoryParser.java

示例15: jsonAddedNode

import javax.json.JsonValue.ValueType; //导入依赖的package包/类
public BtcAddedNode jsonAddedNode(JsonValue value) throws BtcException {
	JsonObject object = jsonObject(value);
	if (object == null) {
		return null;
	}
	BtcAddedNode addedNode = new BtcAddedNode();
	addedNode.setAddedNode(object.getString(BTCOBJ_NODE_ADDED_NODE, ""));
	addedNode.setConnected(object.getBoolean(BTCOBJ_NODE_CONNECTED,
			false));
	List<BtcNode> nodes = new ArrayList<BtcNode>();
	JsonValue addresses = object.get(BTCOBJ_NODE_ADDRESSES);
	if ((addresses != null) && (addresses.getValueType() == JsonValue.ValueType.ARRAY) && (addresses instanceof JsonArray)) {
		JsonArray addressesArray = (JsonArray) addresses;
		for (JsonValue address : addressesArray
				.getValuesAs(JsonValue.class)) {
			nodes.add(jsonNode(address));
		}
	}
	addedNode.setAddresses(nodes);
	return addedNode;
}
 
开发者ID:btc4j,项目名称:btc4j-daemon,代码行数:22,代码来源:BtcJsonRpcHttpClient.java


注:本文中的javax.json.JsonValue.ValueType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。