private Object castFloat(BFloat jValue, Class<?> targetType) { if ((targetType == Float.class || targetType == float.class)) { return (float) jValue.floatValue(); } return jValue.floatValue(); }
@Override public double getFloatField(String fieldName) { return ((BFloat) value.get(fieldName)).floatValue(); }
private static void setParam(PreparedStatement stmt, BValue value, BType bType, int index, boolean isKey) throws SQLException { int type = bType.getTag(); switch (type) { case TypeTags.INT_TAG: stmt.setLong(index, ((BInteger) value).intValue()); break; case TypeTags.STRING_TAG: stmt.setString(index, value.stringValue()); break; case TypeTags.FLOAT_TAG: stmt.setDouble(index, ((BFloat) value).floatValue()); break; case TypeTags.BOOLEAN_TAG: stmt.setBoolean(index, ((BBoolean) value).booleanValue()); break; case TypeTags.BYTE_TAG: stmt.setByte(index, ((BByte) value).byteValue()); break; default: if (isKey && value instanceof BMap) { stmt.setString(index, sortBMap(((BMap) value).getMap())); } else { stmt.setString(index, value.toString()); } } }
private static BValueArray jsonArrayToBFloatArray(BValueArray arrayNode) { BValueArray floatArray = new BValueArray(BTypes.typeFloat); for (int i = 0; i < arrayNode.size(); i++) { BRefType<?> jsonValue = arrayNode.getRefValue(i); floatArray.add(i, ((BFloat) convertJSON(jsonValue, BTypes.typeFloat)).floatValue()); } return floatArray; }
break; case TypeTags.FLOAT_TAG: stmt.setDouble(index, ((BFloat) constrainedType.get(fieldName)).floatValue()); break; case TypeTags.BOOLEAN_TAG:
public static void copyArgValueForWorkerReceive(StackFrame currentSF, int regIndex, BType paramType, BRefType passedInValue) { switch (paramType.getTag()) { case TypeTags.INT_TAG: currentSF.longRegs[regIndex] = ((BInteger) passedInValue).intValue(); break; case TypeTags.BYTE_TAG: currentSF.intRegs[regIndex] = ((BByte) passedInValue).byteValue(); break; case TypeTags.FLOAT_TAG: currentSF.doubleRegs[regIndex] = ((BFloat) passedInValue).floatValue(); break; case TypeTags.STRING_TAG: currentSF.stringRegs[regIndex] = (passedInValue).stringValue(); break; case TypeTags.BOOLEAN_TAG: currentSF.intRegs[regIndex] = (((BBoolean) passedInValue).booleanValue()) ? 1 : 0; break; default: currentSF.refRegs[regIndex] = passedInValue; } }
private Object[] createEvent(BMap<String, BValue> data) { BStructureType streamType = (BStructureType) data.getType(); Object[] event = new Object[streamType.getFields().size()]; int index = 0; for (Map.Entry<String, BField> fieldEntry : streamType.getFields().entrySet()) { BField field = fieldEntry.getValue(); switch (field.getFieldType().getTag()) { case TypeTags.INT_TAG: event[index++] = ((BInteger) data.get(field.fieldName)).intValue(); break; case TypeTags.FLOAT_TAG: event[index++] = ((BFloat) data.get(field.fieldName)).floatValue(); break; case TypeTags.BOOLEAN_TAG: event[index++] = ((BBoolean) data.get(field.fieldName)).booleanValue(); break; case TypeTags.STRING_TAG: event[index++] = data.get(field.fieldName).stringValue(); break; default: throw new BallerinaException("Fields in streams do not support data types other than int, " + "float, boolean and string"); } } return event; }
break; case TypeTags.FLOAT_TAG: structData[i] = ((BFloat) bValue).floatValue(); break; case TypeTags.STRING_TAG:
private void setDataSourceProperties(BMap<String, BRefType<?>> options, HikariConfig config) { for (String key : options.keys()) { BValue value = options.get(key); if (value instanceof BString) { config.addDataSourceProperty(key, value.stringValue()); } else if (value instanceof BInteger) { config.addDataSourceProperty(key, ((BInteger) value).intValue()); } else if (value instanceof BBoolean) { config.addDataSourceProperty(key, ((BBoolean) value).booleanValue()); } else if (value instanceof BFloat) { config.addDataSourceProperty(key, ((BFloat) value).floatValue()); } } }
break; data.doubleRegs[regIndex] = ((BFloat) val).floatValue(); break; case TypeTags.DECIMAL_TAG:
break; result.doubleRegs[doubleRegCount++] = ((BFloat) vals[i]).floatValue(); break; case TypeTags.DECIMAL_TAG:
@Override public void execute(Context context) { String configKey = context.getStringArgument(0); BValue configValue = context.getRefArgument(0); BType type = configValue.getType(); if (type == BTypes.typeString) { CONFIG_REGISTRY.addConfiguration(configKey, configValue.stringValue()); } else if (type == BTypes.typeInt) { CONFIG_REGISTRY.addConfiguration(configKey, ((BInteger) configValue).intValue()); } else if (type == BTypes.typeFloat) { CONFIG_REGISTRY.addConfiguration(configKey, ((BFloat) configValue).floatValue()); } else if (type == BTypes.typeBoolean) { CONFIG_REGISTRY.addConfiguration(configKey, ((BBoolean) configValue).floatValue()); } context.setReturnValues(); } }
sf.doubleRegs[doubleIndex] = ((BFloat) closure.value()).floatValue(); newArgRegs[argRegIndex++] = doubleIndex++; break;
break; case TypeTags.FLOAT_TAG: this.writeNumber(((BFloat) json).floatValue()); break; case TypeTags.DECIMAL_TAG:
jmsMessage.setLong(key, ((BInteger) value).intValue()); } else if (value instanceof BFloat) { jmsMessage.setDouble(key, ((BFloat) value).floatValue()); } else { LOGGER.error("Couldn't set invalid data type to MapMessage : " + value.getType().getName());
((BFloat) bValue).floatValue()); ((BFloat) bMessage).floatValue()); .getNumber(), (float) ((BFloat) bValue).floatValue()); .getNumber(), (float) ((BFloat) bMessage).floatValue());