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


Java ValueType.NUMBER属性代码示例

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


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

示例1: setMetadataBlocks

@POST
@Path("{identifier}/metadatablocks")
@Produces(MediaType.APPLICATION_JSON)
public Response setMetadataBlocks( @PathParam("identifier")String dvIdtf, @QueryParam("key") String apiKey, String blockIds ) {
    
    List<MetadataBlock> blocks = new LinkedList<>();
    try {
        for ( JsonValue blockId : Util.asJsonArray(blockIds).getValuesAs(JsonValue.class) ) {
            MetadataBlock blk = (blockId.getValueType()==ValueType.NUMBER)
                                    ? findMetadataBlock( ((JsonNumber)blockId).longValue() )
                                    : findMetadataBlock( ((JsonString)blockId).getString() );
            if ( blk == null ) {
                return errorResponse(Response.Status.BAD_REQUEST, "Can't find metadata block '"+ blockId + "'");
            }
            blocks.add( blk );
        }
    } catch( Exception e ) {
        return errorResponse(Response.Status.BAD_REQUEST, e.getMessage());
    }
    
    try {
        User u = findUserOrDie(apiKey);
        Dataverse dataverse = findDataverseOrDie(dvIdtf);
        execCommand( new UpdateDataverseMetadataBlocksCommand.SetBlocks(u, dataverse, blocks),
                "updating metadata blocks for dataverse " + dvIdtf );
        return okResponse("Metadata blocks of dataverse " + dvIdtf + " updated.");
        
    } catch (WrappedResponse ex) {
        return ex.getResponse();
    }
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:31,代码来源:Dataverses.java

示例2: convertContentValue

@Override
public Object convertContentValue(Object value) {
	if (value instanceof JsonValue) {
		JsonValue val = (JsonValue) value;
		Object ret = null;
		ValueType typ = val.getValueType();
		if (typ == ValueType.NUMBER)
			ret = ((JsonNumber)val).bigDecimalValue();
		else if (typ == ValueType.STRING)
			ret = ((JsonString)val).getString();
		else if (typ == ValueType.FALSE)
			ret = Boolean.FALSE;
		else if (typ == ValueType.TRUE)
			ret = Boolean.TRUE;
		else if (typ == ValueType.ARRAY) {
			JsonArray arr = (JsonArray)val;
			List<Object> vals = new ArrayList<Object>();
			int sz = arr.size();
			for (int i = 0; i < sz; i++) {
				JsonValue v = arr.get(i);
				vals.add(convertContentValue(v));
			}
			ret = vals;
		} else if (typ == ValueType.OBJECT) {
			//JsonObject obj = (JsonObject)val;
		}
		return ret;
	}
	return value;
}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:30,代码来源:JSONContentHandler.java

示例3: getJsonValueAsNumberString

private static String getJsonValueAsNumberString(JsonValue value) {
    return (value != null && value.getValueType() == ValueType.NUMBER) ? ((JsonNumber) value).toString() : null;
}
 
开发者ID:hyperledger,项目名称:fabric-sdk-java,代码行数:3,代码来源:NetworkConfig.java

示例4: getInt

public int getInt(String key) {
	if (json.get(key).getValueType() == ValueType.NUMBER)
		return ((JsonNumber)json.get(key)).intValueExact();
	else
		return Integer.parseInt(getString(key));
}
 
开发者ID:Anniepoo,项目名称:JavaPengine,代码行数:6,代码来源:Proof.java

示例5: getNearestInt

public int getNearestInt(String key) {
	if (json.get(key).getValueType() == ValueType.NUMBER)
		return ((JsonNumber)json.get(key)).intValue();
	else
		return Integer.parseInt(getString(key));
}
 
开发者ID:Anniepoo,项目名称:JavaPengine,代码行数:6,代码来源:Proof.java

示例6: getDouble

public double getDouble(String key) {
	if (json.get(key).getValueType() == ValueType.NUMBER)
		return ((JsonNumber)json.get(key)).doubleValue();
	else
		return Double.parseDouble(getString(key));
}
 
开发者ID:Anniepoo,项目名称:JavaPengine,代码行数:6,代码来源:Proof.java

示例7: processValueFromMapOrObject

/**
 * <p>
 * So that the request is a valid OAuth 2.0 Authorization Request, values
 * for the response_type and client_id parameters MUST be included using the
 * OAuth 2.0 request syntax, since they are REQUIRED by OAuth 2.0. The
 * values for these parameters MUST match those in the Request Object, if
 * present.
 * </p>
 *
 * @param reqMap
 * @param key
 * @param servletRequest
 * @param requestObject
 */
private static void processValueFromMapOrObject(final Map<String, String> reqMap,
    final String key,
    final HttpServletRequest servletRequest,
    final JsonObject requestObject) {

    final String paramValue;
    if (servletRequest != null && servletRequest.getParameter(key) != null) {
        paramValue = servletRequest.getParameter(key);
    } else {
        paramValue = null;
    }

    final String requestObjectValue;
    if (requestObject == null || !requestObject.containsKey(key)) {
        requestObjectValue = null;
    } else if (requestObject.get(key)
        .getValueType() == ValueType.STRING) {
        requestObjectValue = requestObject.getString(key);
    } else if (requestObject.get(key)
        .getValueType() == ValueType.NUMBER) {
        requestObjectValue = requestObject.getJsonNumber(key)
            .bigIntegerValueExact()
            .toString();
    } else if (requestObject.get(key)
        .getValueType() == ValueType.OBJECT) {
        requestObjectValue = requestObject.getJsonObject(key)
            .toString();
    } else {
        requestObjectValue = null;
    }

    if (OpenIdConnectKey.CLIENT_ID.equals(key) && paramValue != null && requestObjectValue != null && !paramValue.equals(requestObjectValue)) {
        throw new BadRequestException("client_id does not match.");
    }

    if (OpenIdConnectKey.REDIRECT_URI.equals(key) && paramValue != null && requestObjectValue != null && !paramValue.equals(requestObjectValue)) {
        throw new BadRequestException("redirect_uri does not match.");
    }

    if (Util.isNotNullOrEmpty(requestObjectValue)) {
        reqMap.put(key, requestObjectValue);
    } else if (Util.isNotNullOrEmpty(paramValue)) {
        reqMap.put(key, paramValue);
    }
}
 
开发者ID:trajano,项目名称:openid-connect,代码行数:59,代码来源:AuthenticationRequest.java

示例8: getLong

/**
 * Get long value out of the message json payload
 *
 * @param key
 *            Key to find value for
 * @param defaultValue
 *            Default value if key can't be found
 * @return value in object, or the provided default
 */
public long getLong(String key, long defaultValue) {
    JsonObject obj = getParsedBody();
    JsonValue value = obj.get(key);
    if ( value != null && value.getValueType() == ValueType.NUMBER ) {
        return ((JsonNumber) value).longValue();
    }
    return defaultValue;
}
 
开发者ID:gameontext,项目名称:gameon-mediator,代码行数:17,代码来源:RoutedMessage.java


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