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


Java JsonNode.isInt方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.JsonNode.isInt方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.isInt方法的具体用法?Java JsonNode.isInt怎么用?Java JsonNode.isInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.JsonNode的用法示例。


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

示例1: fromJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Number fromJson(JsonNode json) {
	if (json.isBigDecimal()) {
		return json.decimalValue();
	} else if (json.isBigInteger()) {
		return json.bigIntegerValue();
	}
	// no methods for Byte, even though numberNode(Byte) is provided.
	// experimentations shows that bytes show up as ints. Oh well..
	else if (json.isDouble()) {
		return json.doubleValue();
	} else if (json.isFloat()) {
		return json.floatValue();
	} else if (json.isInt()) {
		return json.intValue();
	} else if (json.isLong()) {
		return json.longValue();
	} else if (json.isShort()) {
		return json.shortValue();
	} else {
		return null;
	}
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:24,代码来源:NumberOverlay.java

示例2: createSclarProperty

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private Property createSclarProperty(String arrayType, JsonNode node) {
	Property property = null;
	Iterator<JsonNode> nodes = node.elements();
	while (nodes.hasNext()) {
		JsonNode leafNode = nodes.next();
		JsonNodeType type = leafNode.getNodeType();
		switch (type) {
		case STRING:
			property = new StringPropertyBuilder().withExample(leafNode.asText()).build();
			break;
		case BOOLEAN:
			property = new BooleanPropertyBuilder().withExample(leafNode.asBoolean()).build();
			break;
		case NUMBER:
			if (leafNode.isInt() || leafNode.isLong()) {
				property = new IntegerPropertyBuilder().withExample(leafNode.asLong()).build();
			} else if (leafNode.isFloat() || leafNode.isDouble()) {
				property = new NumberPropertyBuilder().withExample(leafNode.asDouble()).build();
			}
			break;
		default:
			break;
		}
	}
	return property;
}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:27,代码来源:SwaggerModelGenerator.java

示例3: identifyPrimitiveMatch

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static UnionResolution identifyPrimitiveMatch(JsonNode datum, Set<Schema.Type> primitives) {
  // Try to identify specific primitive types
  Schema primitiveSchema = null;
  if (datum == null || datum.isNull()) {
    primitiveSchema = closestPrimitive(primitives, Schema.Type.NULL);
  } else if (datum.isShort() || datum.isInt()) {
    primitiveSchema = closestPrimitive(primitives, Schema.Type.INT, Schema.Type.LONG, Schema.Type.FLOAT,
        Schema.Type.DOUBLE);
  } else if (datum.isLong()) {
    primitiveSchema = closestPrimitive(primitives, Schema.Type.LONG, Schema.Type.DOUBLE);
  } else if (datum.isFloat()) {
    primitiveSchema = closestPrimitive(primitives, Schema.Type.FLOAT, Schema.Type.DOUBLE);
  } else if (datum.isDouble()) {
    primitiveSchema = closestPrimitive(primitives, Schema.Type.DOUBLE);
  } else if (datum.isBoolean()) {
    primitiveSchema = closestPrimitive(primitives, Schema.Type.BOOLEAN);
  }
  if (primitiveSchema == null
      && ((datum.isDouble() && datum.doubleValue() >= -Float.MAX_VALUE && datum.doubleValue() <= Float.MAX_VALUE)
          || (datum.isLong()
              && datum.longValue() >= (long) -Float.MAX_VALUE
              && datum.longValue() <= (long) Float.MAX_VALUE))) {
    primitiveSchema = closestPrimitive(primitives, Schema.Type.FLOAT, Schema.Type.DOUBLE);
  }

  if (primitiveSchema != null) {
    return new UnionResolution(primitiveSchema, MatchType.FULL);
  }
  return null;
}
 
开发者ID:HotelsDotCom,项目名称:jasvorno,代码行数:31,代码来源:JasvornoConverter.java

示例4: matches

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private MatchType matches(JsonNode datum, Schema schema) {
  switch (schema.getType()) {
  case RECORD:
    if (datum.isObject()) {
      return matchRecord(datum, schema);
    }
    break;
  case UNION:
    return resolveUnion(datum, schema.getTypes()).matchType;
  case MAP:
    if (datum.isObject()) {
      return matchMapValue(datum, schema);
    }
    break;
  case ARRAY:
    if (datum.isArray()) {
      return matchArrayElement(datum, schema);
    }
    break;
  case BOOLEAN:
    if (datum.isBoolean()) {
      return MatchType.FULL;
    }
    break;
  case FLOAT:
    if (datum.isDouble() && datum.doubleValue() >= -Float.MAX_VALUE && datum.doubleValue() <= Float.MAX_VALUE
        || datum.isLong()
            && datum.longValue() >= (long) -Float.MAX_VALUE
            && datum.longValue() <= (long) Float.MAX_VALUE
        || datum.isFloat()
        || datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case DOUBLE:
    if (datum.isDouble() || datum.isFloat() || datum.isLong() || datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case INT:
    if (datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case LONG:
    if (datum.isLong() || datum.isInt()) {
      return MatchType.FULL;
    }
    break;
  case STRING:
    if (datum.isTextual()) {
      return MatchType.FULL;
    }
    break;
  case ENUM:
    if (datum.isTextual() && schema.hasEnumSymbol(datum.textValue())) {
      return MatchType.FULL;
    }
    break;
  case BYTES:
  case FIXED:
    if (datum.isTextual()) {
      return MatchType.FULL;
    }
    break;
  case NULL:
    if (datum.isNull()) {
      return MatchType.FULL;
    }
    break;
  default: // unknown
    throw new IllegalArgumentException("Unsupported schema: " + schema);
  }
  return MatchType.NONE;
}
 
开发者ID:HotelsDotCom,项目名称:jasvorno,代码行数:76,代码来源:JasvornoConverter.java

示例5: requireIntField

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private int requireIntField(final JsonNode node, final String fieldName) {
    JsonNode value = requireField(node, fieldName);
    if (value.isInt()) {
        return value.asInt();
    }
    throw new RuntimeException("Value of JSON key/field \"" + fieldName + "\" is required to be an int.");
}
 
开发者ID:mgrand,项目名称:bigchaindb-java-driver,代码行数:8,代码来源:SignedBigchaindbTransactionImpl.java

示例6: parse

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public EnumNode parse(String nodeName, JsonNode jsonNode) {
    if (jsonNode == null) return null;
    JsonNode enumNode = jsonNode.get(JsonDataType.ENUM.getValue());
    if (enumNode == null) return null;

    Iterator<JsonNode> nodeIterator = enumNode.elements();
    while (nodeIterator.hasNext()) {
        JsonNode childNode = nodeIterator.next();
        if (isNullNode(childNode)) {
            // null is a valid value
            generator.addItem(null);
        } else {
            // Data type is unconstrained by the schema, but we only support primitive data types
            if (childNode.isInt()) {
                generator.addItem(childNode.intValue());
            } else if(childNode.isFloatingPointNumber()) {
                generator.addItem(childNode.doubleValue());
            } else if (childNode.isTextual()) {
                generator.addItem(childNode.textValue());
            } else if (childNode.isBoolean()) {
                generator.addItem(childNode.booleanValue());
            }
        }
    }
    return new EnumNode(nodeName, generator);
}
 
开发者ID:zezutom,项目名称:schematic,代码行数:28,代码来源:EnumParser.java

示例7: evalObject

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private void evalObject(ObjectNode source, ObjectNode target, RenderContext context,
	ScriptContext scriptContext)
{
	final Iterator<Entry<String, JsonNode>> it = source.fields();
	while( it.hasNext() )
	{
		final Entry<String, JsonNode> e = it.next();
		final String name = e.getKey();
		final JsonNode n = e.getValue();
		if( n.isObject() )
		{
			// recursively handle it
			final ObjectNode nt = jsonMapper.createObjectNode();
			target.put(name, nt);
			evalObject((ObjectNode) n, nt, context, scriptContext);
		}
		else if( n.isInt() || n.isLong() )
		{
			target.put(name, n.asInt());
		}
		else if( n.isFloatingPointNumber() || n.isDouble() )
		{
			target.put(name, n.asDouble());
		}
		else if( n.isBoolean() )
		{
			target.put(name, n.asBoolean());
		}
		else if( n.isArray() )
		{
			target.putArray(name).addAll((ArrayNode) n);
		}
		else
		{
			// freemarker eval
			target.put(name, evaluateMarkUp(context, n.asText(), scriptContext));
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:40,代码来源:TinyMceAddonServiceImpl.java

示例8: JsonObjectExpression

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
protected JsonObjectExpression(ObjectNode o)
{
	super();
	final Iterator<Entry<String, JsonNode>> it = o.fields();
	while( it.hasNext() )
	{
		final Entry<String, JsonNode> e = it.next();
		final String name = e.getKey();
		final JsonNode n = e.getValue();
		if( n.isObject() )
		{
			put(name, new JsonObjectExpression((ObjectNode) n));
		}
		else if( n.isInt() )
		{
			put(name, n.asInt());
		}
		else if( n.isFloatingPointNumber() )
		{
			put(name, n.asDouble());
		}
		else if( n.isBoolean() )
		{
			put(name, n.asBoolean());
		}
		else
		{
			put(name, n.asText());
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:32,代码来源:TinyMceAddonServiceImpl.java

示例9: decodeCriterion

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Criterion decodeCriterion(ObjectNode json) {
    JsonNode ethTypeNode = nullIsIllegal(json.get(CriterionCodec.ETH_TYPE),
                                      CriterionCodec.ETH_TYPE + MISSING_MEMBER_MESSAGE);
    int ethType;
    if (ethTypeNode.isInt()) {
        ethType = ethTypeNode.asInt();
    } else {
        ethType = Integer.decode(ethTypeNode.textValue());
    }
    return Criteria.matchEthType(ethType);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:DecodeCriterionCodecHelper.java

示例10: createObjectModel

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private void createObjectModel(JsonNode node, ModelBuilder modelBuilder, String apiName) {
	Iterator<String> fieldNames = node.fieldNames();

	while (fieldNames.hasNext()) {
		String field = fieldNames.next();
		JsonNode leafNode = node.get(field);

		if (leafNode.getNodeType() == JsonNodeType.NUMBER) {
			if (leafNode.isInt() || leafNode.isLong()) {
				modelBuilder.withIntegerPropertyNamed(field).withExample(leafNode.asLong());
			} else if (leafNode.isFloat() || leafNode.isDouble()) {
				modelBuilder.withNumberPropertyNamed(field).withExample(leafNode.asDouble());
			}
		} else if (leafNode.getNodeType() == JsonNodeType.BOOLEAN) {
			modelBuilder.withBooleanPropertyNamed(field).withExample(leafNode.asBoolean());
		} else if (leafNode.getNodeType() == JsonNodeType.STRING) {
			modelBuilder.withStringPropertyNamed(field).withExample(leafNode.asText());
		} else if (leafNode.getNodeType() == JsonNodeType.OBJECT) {
			String refName = apiName+"-"+field;
			modelBuilder.withReferencePropertyNamed(field).withReferenceTo(refName);
			ModelBuilder objModelBuilder = new ModelBuilder();
			createObjectModel(leafNode, objModelBuilder, refName);
			models.put(refName, objModelBuilder);
		}else if(leafNode.getNodeType() == JsonNodeType.ARRAY){
			createArrayModel(leafNode, modelBuilder.withArrayProperty(field), apiName+"-"+field);				
		}
	}		
}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:29,代码来源:SwaggerModelGenerator.java

示例11: fromJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public Integer fromJson(JsonNode json) {
	return json.isInt() ? json.intValue() : null;
}
 
开发者ID:networknt,项目名称:openapi-parser,代码行数:5,代码来源:IntegerOverlay.java


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