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


Java NumberType.INT属性代码示例

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


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

示例1: doLe

protected boolean doLe(JsonNode propertyNode, JsonNode passedNode){
	if(propertyNode.isNumber() && passedNode.isNumber() && propertyNode.numberType() == passedNode.numberType()) {
		Number propertyValue = propertyNode.numberValue();
		Number passedValue = passedNode.numberValue();
		if(propertyNode.numberType() == NumberType.INT) {
			return ((Integer) propertyValue <= (Integer) passedValue);
		} else if(propertyNode.numberType() == NumberType.LONG) {
			return ((Long) propertyValue <= (Long) passedValue);
		} else if(propertyNode.numberType() == NumberType.FLOAT) {
			return ((Float) propertyValue <= (Float) passedValue);
		} else if(propertyNode.numberType() == NumberType.DOUBLE) {
			return ((Double) propertyValue <= (Double) passedValue);
		} else {
			throw new UnsupportedExprException("Le supports only INT, LONG, DOUBLE, FLOAT values");
		}
	} else {
		throw new UnsupportedExprException("Le supports only numeric values of same type for comparison");
	}
}
 
开发者ID:kcthota,项目名称:JSONQuery,代码行数:19,代码来源:LeExpression.java

示例2: doGt

protected boolean doGt(JsonNode propertyNode, JsonNode passedNode){
	if(propertyNode.isNumber() && passedNode.isNumber() && propertyNode.numberType() == passedNode.numberType()) {
		Number propertyValue = propertyNode.numberValue();
		Number passedValue = passedNode.numberValue();
		if(propertyNode.numberType() == NumberType.INT) {
			return ((Integer) propertyValue > (Integer) passedValue);
		} else if(propertyNode.numberType() == NumberType.LONG) {
			return ((Long) propertyValue > (Long) passedValue);
		} else if(propertyNode.numberType() == NumberType.FLOAT) {
			return ((Float) propertyValue > (Float) passedValue);
		} else if(propertyNode.numberType() == NumberType.DOUBLE) {
			return ((Double) propertyValue > (Double) passedValue);
		} else {
			throw new UnsupportedExprException("Gt supports only INT, LONG, DOUBLE, FLOAT values");
		}
	} else {
		throw new UnsupportedExprException("Gt supports only numeric values of same type for comparison");
	}
}
 
开发者ID:kcthota,项目名称:JSONQuery,代码行数:19,代码来源:GtExpression.java

示例3: doLt

protected boolean doLt(JsonNode propertyNode, JsonNode passedNode){
	if(propertyNode.isNumber() && passedNode.isNumber() && propertyNode.numberType() == passedNode.numberType()) {
		Number propertyValue = propertyNode.numberValue();
		Number passedValue = passedNode.numberValue();
		if(propertyNode.numberType() == NumberType.INT) {
			return ((Integer) propertyValue < (Integer) passedValue);
		} else if(propertyNode.numberType() == NumberType.LONG) {
			return ((Long) propertyValue < (Long) passedValue);
		} else if(propertyNode.numberType() == NumberType.FLOAT) {
			return ((Float) propertyValue < (Float) passedValue);
		} else if(propertyNode.numberType() == NumberType.DOUBLE) {
			return ((Double) propertyValue < (Double) passedValue);
		} else {
			throw new UnsupportedExprException("Lt supports only INT, LONG, DOUBLE, FLOAT values");
		}
	} else {
		throw new UnsupportedExprException("Lt supports only numeric values of same type for comparison");
	}
}
 
开发者ID:kcthota,项目名称:JSONQuery,代码行数:19,代码来源:LtExpression.java

示例4: doGe

private boolean doGe(JsonNode propertyNode, JsonNode passedNode){
	if(propertyNode.isNumber() && passedNode.isNumber() && propertyNode.numberType() == passedNode.numberType()) {
		Number propertyValue = propertyNode.numberValue();
		Number passedValue = passedNode.numberValue();
		if(propertyNode.numberType() == NumberType.INT) {
			return ((Integer) propertyValue >= (Integer) passedValue);
		} else if(propertyNode.numberType() == NumberType.LONG) {
			return ((Long) propertyValue >= (Long) passedValue);
		} else if(propertyNode.numberType() == NumberType.FLOAT) {
			return ((Float) propertyValue >= (Float) passedValue);
		} else if(propertyNode.numberType() == NumberType.DOUBLE) {
			return ((Double) propertyValue >=(Double) passedValue);
		} else {
			throw new UnsupportedExprException("Ge supports only INT, LONG, DOUBLE, FLOAT values");
		}
	} else {
		throw new UnsupportedExprException("Ge supports only numeric values of same type for comparison");
	}
}
 
开发者ID:kcthota,项目名称:JSONQuery,代码行数:19,代码来源:GeExpression.java

示例5: parseArray

private cfData	parseArray(JsonParser jp, cfArrayData array, boolean bStrictMapping ) throws JsonParseException, IOException, cfmRunTimeException{
	
	JsonToken	token	= jp.nextToken();
	while ( token != JsonToken.END_ARRAY ){
		
		if ( token == JsonToken.START_ARRAY ){
			array.addElement( parseArray(jp,cfArrayData.createArray(1),bStrictMapping ) );
		}else if ( token == JsonToken.START_OBJECT ){
			array.addElement( parseObject(jp,new cfStructData(),bStrictMapping) );
		}else if ( token == JsonToken.VALUE_NUMBER_INT ){
			
			if ( jp.getNumberType() == NumberType.INT )
				array.addElement( new cfNumberData(jp.getIntValue()) );
			else if ( jp.getNumberType() == NumberType.LONG || jp.getNumberType() == NumberType.BIG_INTEGER )
				array.addElement( new cfNumberData(jp.getLongValue()) );

		}else if ( token == JsonToken.VALUE_NUMBER_FLOAT ){
	
			if ( jp.getNumberType() == NumberType.FLOAT )
				array.addElement( new cfNumberData(jp.getFloatValue()) );
			else if ( jp.getNumberType() == NumberType.DOUBLE )
				array.addElement( new cfNumberData(jp.getDoubleValue()) );

		} else if ( token == JsonToken.VALUE_FALSE ){
			array.addElement( cfBooleanData.FALSE );
		} else if ( token == JsonToken.VALUE_TRUE ){
			array.addElement( cfBooleanData.TRUE );
		} else if ( token == JsonToken.VALUE_NULL ){
			array.addElement( cfNullData.NULL );
		}else
			array.addElement(  getString(jp.getText()) );
	
		token	= jp.nextToken();
	}
	
	return array;
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:37,代码来源:DeserializeJSONJackson.java

示例6: getValue

private Serializable getValue (JsonParser parser, JsonToken token) throws IOException {
  if (token != null) {
    switch (token) {
    case VALUE_STRING:
      return parser.getText ();
    case VALUE_NUMBER_INT:
      if (parser.getNumberType () == NumberType.INT || parser.getNumberType () == NumberType.LONG) {
        return Long.valueOf (parser.getLongValue ());
      } else {
        return parser.getNumberValue ();
      }
    case VALUE_NUMBER_FLOAT:
      if (parser.getNumberType () == NumberType.FLOAT) {
        return Float.valueOf (parser.getFloatValue ());
      } else if (parser.getNumberType () == NumberType.DOUBLE) {
        return Double.valueOf (parser.getDoubleValue ());
      } else {
        return parser.getNumberValue ();
      }
    case VALUE_TRUE:
      return Boolean.TRUE;
    case VALUE_FALSE:
      return Boolean.FALSE;
    case VALUE_NULL:
      return null;
    case END_ARRAY:
    default:
      break;
    }
  }
  return null;
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:32,代码来源:JsonImporter.java

示例7: _parseBooleanPrimitive

protected final boolean _parseBooleanPrimitive(JsonParser jp, DeserializationContext ctxt)
    throws IOException, JsonProcessingException
{
    JsonToken t = jp.getCurrentToken();
    if (t == JsonToken.VALUE_TRUE) {
        return true;
    }
    if (t == JsonToken.VALUE_FALSE) {
        return false;
    }
    if (t == JsonToken.VALUE_NULL) {
        return false;
    }
    // [JACKSON-78]: should accept ints too, (0 == false, otherwise true)
    if (t == JsonToken.VALUE_NUMBER_INT) {
        // 11-Jan-2012, tatus: May be outside of int...
        if (jp.getNumberType() == NumberType.INT) {
            return (jp.getIntValue() != 0);
        }
        return _parseBooleanFromNumber(jp, ctxt);
    }
    // And finally, let's allow Strings to be converted too
    if (t == JsonToken.VALUE_STRING) {
        String text = jp.getText().trim();
        if ("true".equals(text)) {
            return true;
        }
        if ("false".equals(text) || text.length() == 0) {
            return Boolean.FALSE;
        }
        throw ctxt.weirdStringException(text, _valueClass, "only \"true\" or \"false\" recognized");
    }
    // Otherwise, no can do:
    throw ctxt.mappingException(_valueClass, t);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:35,代码来源:StdDeserializer.java

示例8: _parseBoolean

protected final Boolean _parseBoolean(JsonParser jp, DeserializationContext ctxt)
    throws IOException, JsonProcessingException
{
    JsonToken t = jp.getCurrentToken();
    if (t == JsonToken.VALUE_TRUE) {
        return Boolean.TRUE;
    }
    if (t == JsonToken.VALUE_FALSE) {
        return Boolean.FALSE;
    }
    // [JACKSON-78]: should accept ints too, (0 == false, otherwise true)
    if (t == JsonToken.VALUE_NUMBER_INT) {
        // 11-Jan-2012, tatus: May be outside of int...
        if (jp.getNumberType() == NumberType.INT) {
            return (jp.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE;
        }
        return Boolean.valueOf(_parseBooleanFromNumber(jp, ctxt));
    }
    if (t == JsonToken.VALUE_NULL) {
        return (Boolean) getNullValue();
    }
    // And finally, let's allow Strings to be converted too
    if (t == JsonToken.VALUE_STRING) {
        String text = jp.getText().trim();
        if ("true".equals(text)) {
            return Boolean.TRUE;
        }
        if ("false".equals(text)) {
            return Boolean.FALSE;
        }
        if (text.length() == 0) {
            return (Boolean) getEmptyValue();
        }
        throw ctxt.weirdStringException(text, _valueClass, "only \"true\" or \"false\" recognized");
    }
    // Otherwise, no can do:
    throw ctxt.mappingException(_valueClass, t);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:38,代码来源:StdDeserializer.java


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