List of usage examples for java.lang Float valueOf
@HotSpotIntrinsicCandidate public static Float valueOf(float f)
From source file:joachimeichborn.geotag.io.parser.kml.AbstractKmlParser.java
private float parseAccuracy(final Placemark aPlacemark) { if (aPlacemark.getExtendedData() != null) { final List<Data> data = aPlacemark.getExtendedData().getData(); for (final Data entry : data) { if ("accuracy".equals(entry.getName()) && entry.getValue().matches(FLOAT_PATTERN)) { return Float.valueOf(entry.getValue()); }// w w w .j a v a 2 s . co m } } final String description = aPlacemark.getDescription(); if (!StringUtils.isEmpty(description) && description.matches(FLOAT_PATTERN)) { return Float.valueOf(description); } return 0f; }
From source file:com.denimgroup.threadfix.service.defects.utils.jira.DefectPayload.java
public Float getFloatOr0(Object input) { try {//www .j a va 2s . c om return Float.valueOf(String.valueOf(input)); } catch (NumberFormatException e) { LOG.error("Got input " + input + " which could not be parsed as a float."); return 0.0F; } }
From source file:Main.java
/** * <p>Converts an array of primitive floats to objects.</p> * <p>/*from w ww .j a v a 2 s . co m*/ * <p>This method returns <code>null</code> for a <code>null</code> input array.</p> * * @param array a <code>float</code> array * @return a <code>Float</code> array, <code>null</code> if null array input */ public static Float[] toObject(float[] array) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_FLOAT_OBJECT_ARRAY; } final Float[] result = new Float[array.length]; for (int i = 0; i < array.length; i++) { result[i] = Float.valueOf(array[i]); } return result; }
From source file:edu.hku.sdb.upload.UploadHandler.java
public String processLine(String line) { StringBuffer newLine = new StringBuffer(); String[] columnValues = line.split(rowFormat); //80 bit long rowId is sufficient BigInteger rowId = SDBEncrypt.generatePositiveRandShort(prime1, prime2); // Each table has three extra column: row_id, r, s for (int columnIndex = 0; columnIndex < trueValueColMetas.size(); columnIndex++) { ColumnMeta colMeta = trueValueColMetas.get(columnIndex); if (colMeta.getType() instanceof ScalarType) { String plaintext = columnValues[columnIndex]; ScalarType type = (ScalarType) colMeta.getType(); switch (type.getType()) { case INT: case TINYINT: case SMALLINT: case BIGINT: if (colMeta.isSensitive()) { SdbColumnKey colKey = new SdbColumnKey(colMeta.getM(), colMeta.getX()); String encryptedValue = getSDBEncryptedValue(new BigInteger(plaintext), rowId, colKey); newLine = appendColumnString(newLine, columnIndex, encryptedValue); } else { newLine = appendColumnString(newLine, columnIndex, plaintext); }//from w w w . j a v a 2 s .c om break; case DECIMAL: if (colMeta.isSensitive()) { SdbColumnKey colKey = new SdbColumnKey(colMeta.getM(), colMeta.getX()); int scale = type.getScale(); // TODO: overflow is not checked. float valueF = Float.valueOf(plaintext); long valueL = (long) (valueF * Math.pow(10, scale)); String encryptedValue = getSDBEncryptedValue(new BigInteger(String.valueOf(valueL)), rowId, colKey); newLine = appendColumnString(newLine, columnIndex, encryptedValue); } else newLine = appendColumnString(newLine, columnIndex, plaintext); break; case CHAR: case VARCHAR: case STRING: if (colMeta.isSensitive()) { SearchColumnKey searchColKey = new SearchColumnKey(colMeta.getM(), colMeta.getX()); searchEncrypt.prkey = searchColKey.getPubKey(); // We only count letters and numbers as keyword. String[] parts = plaintext.split("[^a-zA-Z0-9]+"); StringBuilder encryptedValues = new StringBuilder(); int count = 0; for (int i = 0; i < parts.length; i++) { if (parts[i].length() > 2) { // keyword with at least 3 chars if (count > 0) { encryptedValues.append(ParserConstant.DEFAULT_COLLETION_DELIMETER); } encryptedValues.append(Base64 .encodeBase64String( searchEncrypt.encrypt(searchColKey.getPriKey(), count, parts[i])) .trim()); count++; } else { LOG.warn("There is sensitive string with length less than 3."); } } newLine = appendColumnString(newLine, columnIndex, encryptedValues); } else { newLine = appendColumnString(newLine, columnIndex, plaintext); } break; default: // They should not be sensitive, since we have do the checking before. newLine = appendColumnString(newLine, columnIndex, plaintext); break; } } else { // Nothing to do now. } } for (int columnIndex = 0; columnIndex < auxiliaryColMetas.size(); columnIndex++) { ColumnMeta colMeta = auxiliaryColMetas.get(columnIndex); if (colMeta.getColName().equals(ColumnDefinition.ROW_ID_COLUMN_NAME)) { SdbColumnKey colKey = new SdbColumnKey(colMeta.getM(), colMeta.getX()); BigInteger encryptedR = SDBEncrypt.SIESEncrypt(rowId, colKey.getM(), colKey.getX(), n); newLine = appendColumnString(newLine, columnValues.length, SDBEncrypt.getSecureString(encryptedR)); } else if (colMeta.getColName().equals(ColumnDefinition.R_COLUMN_NAME)) { BigInteger randomInt = SDBEncrypt.generatePositiveRandShort(prime1, prime2); SdbColumnKey colKey = new SdbColumnKey(colMeta.getM(), colMeta.getX()); String encryptedR = getSDBEncryptedValue(randomInt, rowId, colKey); newLine = appendColumnString(newLine, columnIndex, encryptedR); } else if (colMeta.getColName().equals(ColumnDefinition.S_COLUMN_NAME)) { SdbColumnKey colKey = new SdbColumnKey(colMeta.getM(), colMeta.getX()); String encryptedS = getSDBEncryptedValue(new BigInteger("1"), rowId, colKey); newLine = appendColumnString(newLine, columnIndex, encryptedS); } } return newLine.toString(); }
From source file:com.linuxbox.enkive.filter.EnkiveFilter.java
private boolean filterFloat(String value) { boolean matched = false; float floatValue = Float.valueOf(value); float floatFilterValue = Float.valueOf(filterValue); switch (filterComparator) { case FilterComparator.MATCHES: if (value.equals(filterValue)) matched = true;/*from w ww. j av a 2 s .c om*/ break; case FilterComparator.DOES_NOT_MATCH: if (!value.equals(filterValue)) matched = true; break; case FilterComparator.IS_GREATER_THAN: if (floatValue > floatFilterValue) matched = true; break; case FilterComparator.IS_LESS_THAN: if (floatValue < floatFilterValue) matched = true; break; } return matched; }
From source file:Main.java
/** * <p>Converts an array of primitive floats to objects.</p> * * <p>This method returns {@code null} for a {@code null} input array.</p> * * @param array a {@code float} array// w w w . j a v a2 s . c o m * @return a {@code Float} array, {@code null} if null array input */ public static Float[] toObject(final float[] array) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_FLOAT_OBJECT_ARRAY; } final Float[] result = new Float[array.length]; for (int i = 0; i < array.length; i++) { result[i] = Float.valueOf(array[i]); } return result; }
From source file:it.unimi.dsi.util.Properties.java
public void setProperty(final String key, final float f) { super.setProperty(key, Float.valueOf(f)); }
From source file:com.spstudio.modules.sales.service.impl.SaleServiceImpl.java
@Override // ?/* ww w. j a va2s. co m*/ public Float getDepositRate(MemberType memberType) { List<SystemConfig> configs = configService.findModuleConfig(Configuration.SALE_MODULE_NAME, Configuration.CONFIG_MEMBER_TYPE_DEPOSIT_BONUSRATE); if (configs == null || configs.size() == 0) { return getGlobalDepositRate(); } for (SystemConfig config : configs) { String condition = config.getConfigCondition(); if (condition.startsWith(ConfigConditions.EQUAL)) { String memberTypeId = condition.replace(ConfigConditions.EQUAL, ""); if (memberType.getMemberTypeId().equalsIgnoreCase(memberTypeId)) { try { float bonusRate = Float.valueOf(config.getConfigValue()); return bonusRate; } catch (NumberFormatException ex) { ex.printStackTrace(); } } } } return getGlobalDepositRate(); }
From source file:com.stratio.ingestion.sink.cassandra.EventParser.java
static Object parseValue(String rawValue, final DataType.Name type) { // Type-dependent input sanitization switch (type) { case COUNTER: case VARINT:/* w ww. j a v a2 s . c o m*/ case INT: case BIGINT: case DOUBLE: case FLOAT: case DECIMAL: rawValue = rawValue.replaceAll("\\s+", ""); break; } switch (type) { case ASCII: //FIXME: What about non-ASCII? case TEXT: //FIXME: This is expected to be UTF-8 case VARCHAR: //FIXME: This is expected to be UTF-8 return rawValue; case TIMESTAMP: return parseDate(rawValue); case UUID: case TIMEUUID: return UUID.fromString(rawValue); case COUNTER: return Long.valueOf(rawValue); case VARINT: return new BigInteger(rawValue); case INT: return Integer.valueOf(rawValue); case BIGINT: return Long.valueOf(rawValue); case FLOAT: return Float.valueOf(rawValue); case DOUBLE: return Double.valueOf(rawValue); case DECIMAL: return new BigDecimal(rawValue); case BOOLEAN: return Boolean.valueOf(rawValue); case INET: return parseInetSocketAddress(rawValue); default: throw new IllegalArgumentException("Cassandra type not supported: " + type); } }