List of usage examples for java.lang Float MAX_VALUE
float MAX_VALUE
To view the source code for java.lang Float MAX_VALUE.
Click Source Link
From source file:qtiscoringengine.AreaMapping.java
@Override boolean validate(QTIRubric rubric, ValidationLog log) { boolean ok = true; if (_entries.size() == 0) { log.addMessage(_node, "Area Mapping did not contain any entries, at least 1 is required"); switch (log.getValidationRigor()) { case None: break; default://from ww w . j av a 2 s . co m ok = false; break; } } if (_defaultValue == null) { log.addMessage(_node, "Required node defaultValue was not specified"); switch (log.getValidationRigor()) { case None: break; default: ok = false; break; } } else if (_defaultValue.getIsError()) { log.addMessage(_node, _defaultValue.getErrorMessage()); switch (log.getValidationRigor()) { case None: break; default: ok = false; break; } } else if (_defaultValue.getValue() == -Float.MAX_VALUE) { log.addMessage(_node, "Could not parse defaultValue"); switch (log.getValidationRigor()) { case None: break; default: ok = false; break; } } return ok; }
From source file:de.j4velin.mapsmeasure.Util.java
/** * Get the altitude data for a specific point * /*from w w w . j a v a 2 s . co m*/ * @param p * the point to get the altitude for * @param httpClient * can be null if no network query should be performed * @param localContext * can be null if no network query should be performed * @return the altitude at point p or -Float.MAX_VALUE if no valid data * could be fetched * @throws IOException */ static float getAltitude(final LatLng p, final HttpClient httpClient, final HttpContext localContext) throws IOException { if (elevationCache == null) { elevationCache = new HashMap<LatLng, Float>(30); } if (elevationCache.containsKey(p)) { return elevationCache.get(p); } else if (httpClient != null && localContext != null) { float altitude = -Float.MAX_VALUE; String url = "http://maps.googleapis.com/maps/api/elevation/xml?locations=" + String.valueOf(p.latitude) + "," + String.valueOf(p.longitude) + "&sensor=true"; HttpGet httpGet = new HttpGet(url); HttpResponse response = httpClient.execute(httpGet, localContext); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); int r = -1; StringBuffer respStr = new StringBuffer(); while ((r = instream.read()) != -1) respStr.append((char) r); String tagOpen = "<elevation>"; String tagClose = "</elevation>"; if (respStr.indexOf(tagOpen) != -1) { int start = respStr.indexOf(tagOpen) + tagOpen.length(); int end = respStr.indexOf(tagClose); altitude = Float.parseFloat(respStr.substring(start, end)); elevationCache.put(p, altitude); } instream.close(); } return altitude; } else { return elevationCache.get(p); } }
From source file:org.apache.orc.tools.json.JsonSchemaFinder.java
static HiveType pickType(JsonElement json) { if (json.isJsonPrimitive()) { JsonPrimitive prim = (JsonPrimitive) json; if (prim.isBoolean()) { return new BooleanType(); } else if (prim.isNumber()) { Matcher matcher = DECIMAL_PATTERN.matcher(prim.getAsString()); if (matcher.matches()) { int intDigits = matcher.group("int").length(); String fraction = matcher.group("fraction"); int scale = fraction == null ? 0 : fraction.length(); if (scale == 0) { if (intDigits < 19) { long value = prim.getAsLong(); if (value >= -128 && value < 128) { return new NumericType(HiveType.Kind.BYTE, intDigits, scale); } else if (value >= -32768 && value < 32768) { return new NumericType(HiveType.Kind.SHORT, intDigits, scale); } else if (value >= -2147483648 && value < 2147483648L) { return new NumericType(HiveType.Kind.INT, intDigits, scale); } else { return new NumericType(HiveType.Kind.LONG, intDigits, scale); }//from w w w . j ava2 s . co m } else if (intDigits == 19) { // at 19 digits, it may fit inside a long, but we need to check BigInteger val = prim.getAsBigInteger(); if (val.compareTo(MIN_LONG) >= 0 && val.compareTo(MAX_LONG) <= 0) { return new NumericType(HiveType.Kind.LONG, intDigits, scale); } } } if (intDigits + scale <= MAX_DECIMAL_DIGITS) { return new NumericType(HiveType.Kind.DECIMAL, intDigits, scale); } } double value = prim.getAsDouble(); if (value >= Float.MIN_VALUE && value <= Float.MAX_VALUE) { return new NumericType(HiveType.Kind.FLOAT, 0, 0); } else { return new NumericType(HiveType.Kind.DOUBLE, 0, 0); } } else { String str = prim.getAsString(); if (TIMESTAMP_PATTERN.matcher(str).matches()) { return new StringType(HiveType.Kind.TIMESTAMP); } else if (HEX_PATTERN.matcher(str).matches()) { return new StringType(HiveType.Kind.BINARY); } else { return new StringType(HiveType.Kind.STRING); } } } else if (json.isJsonNull()) { return new NullType(); } else if (json.isJsonArray()) { ListType result = new ListType(); result.elementType = new NullType(); for (JsonElement child : ((JsonArray) json)) { HiveType sub = pickType(child); if (result.elementType.subsumes(sub)) { result.elementType.merge(sub); } else if (sub.subsumes(result.elementType)) { sub.merge(result.elementType); result.elementType = sub; } else { result.elementType = new UnionType(result.elementType, sub); } } return result; } else { JsonObject obj = (JsonObject) json; StructType result = new StructType(); for (Map.Entry<String, JsonElement> field : obj.entrySet()) { String fieldName = field.getKey(); HiveType type = pickType(field.getValue()); result.fields.put(fieldName, type); } return result; } }
From source file:org.apache.hadoop.hive.accumulo.AccumuloTestSetup.java
protected void createAccumuloTable(Connector conn) throws TableExistsException, TableNotFoundException, AccumuloException, AccumuloSecurityException { TableOperations tops = conn.tableOperations(); if (tops.exists(TABLE_NAME)) { tops.delete(TABLE_NAME);/*from w w w . j av a 2 s . c o m*/ } tops.create(TABLE_NAME); boolean[] booleans = new boolean[] { true, false, true }; byte[] bytes = new byte[] { Byte.MIN_VALUE, -1, Byte.MAX_VALUE }; short[] shorts = new short[] { Short.MIN_VALUE, -1, Short.MAX_VALUE }; int[] ints = new int[] { Integer.MIN_VALUE, -1, Integer.MAX_VALUE }; long[] longs = new long[] { Long.MIN_VALUE, -1, Long.MAX_VALUE }; String[] strings = new String[] { "Hadoop, Accumulo", "Hive", "Test Strings" }; float[] floats = new float[] { Float.MIN_VALUE, -1.0F, Float.MAX_VALUE }; double[] doubles = new double[] { Double.MIN_VALUE, -1.0, Double.MAX_VALUE }; HiveDecimal[] decimals = new HiveDecimal[] { HiveDecimal.create("3.14159"), HiveDecimal.create("2.71828"), HiveDecimal.create("0.57721") }; Date[] dates = new Date[] { Date.valueOf("2014-01-01"), Date.valueOf("2014-03-01"), Date.valueOf("2014-05-01") }; Timestamp[] timestamps = new Timestamp[] { new Timestamp(50), new Timestamp(100), new Timestamp(150) }; BatchWriter bw = conn.createBatchWriter(TABLE_NAME, new BatchWriterConfig()); final String cf = "cf"; try { for (int i = 0; i < 3; i++) { Mutation m = new Mutation("key-" + i); m.put(cf, "cq-boolean", Boolean.toString(booleans[i])); m.put(cf.getBytes(), "cq-byte".getBytes(), new byte[] { bytes[i] }); m.put(cf, "cq-short", Short.toString(shorts[i])); m.put(cf, "cq-int", Integer.toString(ints[i])); m.put(cf, "cq-long", Long.toString(longs[i])); m.put(cf, "cq-string", strings[i]); m.put(cf, "cq-float", Float.toString(floats[i])); m.put(cf, "cq-double", Double.toString(doubles[i])); m.put(cf, "cq-decimal", decimals[i].toString()); m.put(cf, "cq-date", dates[i].toString()); m.put(cf, "cq-timestamp", timestamps[i].toString()); bw.addMutation(m); } } finally { bw.close(); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJDoubleEditor.java
public void setMaxValue(Double value) { final String S_ProcName = "setMaxValue"; if (value == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1, "value"); }//from w w w. j av a 2 s .co m if (value.compareTo(Double.MAX_VALUE) > 0) { throw CFLib.getDefaultExceptionFactory().newArgumentOverflowException(getClass(), S_ProcName, 1, "value", value, Float.MAX_VALUE); } maxValue = value; }
From source file:uk.co.modularaudio.mads.base.soundfile_player.ui.rollpainter.SoundfileDisplaySampleFactory.java
public SoundfileDisplaySampleFactory(final SampleCachingService sampleCachingService, final BufferedImageAllocator bia, final int displayWidth, final int displayHeight, final SoundfilePlayerMadUiInstance uiInstance) { this.sampleCachingService = sampleCachingService; this.bia = bia; this.displayWidth = displayWidth; this.displayWidthMinusOneOverTwo = (int) ((displayWidth - 1.0f) / 2.0f); this.displayHeight = displayHeight; // this.uiInstance = uiInstance; lastBufferPos = 0;//from ww w. j av a2 s .c om numSamplesPerPixel = DEFAULT_SAMPLES_PER_PIXEL; needsFullUpdate = true; maxValue = -Float.MAX_VALUE; minValue = -maxValue; previousMaxValue = 0.0f; previousMinValue = 0.0f; bufferClearer = new SoundfileDisplayBufferClearer(displayWidth, displayHeight); }
From source file:org.lockss.util.PatternFloatMap.java
/** Return the value associated with the first pattern that the string * matches, or the specified default value if none */ public float getMatch(String str, float dfault) { return getMatch(str, dfault, Float.MAX_VALUE); }
From source file:au.org.ala.delta.directives.args.KeyStateParser.java
private void parseNumericChar(DirectiveArgument<Integer> arg) throws ParseException { if (_currentChar == '~') { arg.add(-Float.MAX_VALUE); readNext();//from ww w .j a v a 2s . c o m arg.add(readReal()); } else { arg.add(readReal()); if (_currentChar == '~') { arg.add(Float.MAX_VALUE); readNext(); } else { if (_currentChar == '-') { readNext(); arg.add(readReal()); } else { arg.add(arg.getData().get(0)); } } } }
From source file:uk.ac.horizon.artcodes.fragment.ExperienceRecommendFragment.java
@Nullable private Location getLocation() { if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { final LocationManager locationManager = (LocationManager) getContext().getApplicationContext() .getSystemService(Context.LOCATION_SERVICE); float accuracy = Float.MAX_VALUE; Location location = null; for (String provider : locationManager.getProviders(new Criteria(), true)) { Location newLocation = locationManager.getLastKnownLocation(provider); if (newLocation != null) { if (newLocation.getAccuracy() < accuracy) { accuracy = newLocation.getAccuracy(); location = newLocation; }/* w w w.j av a 2s.c o m*/ } } return location; } else { Log.i("location", "No location permission"); } return null; }
From source file:cerrla.Performance.java
/** * A constructor for a fresh performance object. * /*from w w w . jav a2 s.c o m*/ * @param runIndex * The run index to append to saved files. */ public Performance(int runIndex) { performanceDetails_ = new TreeMap<Integer, Double[]>(); finalEliteScores_ = new ArrayList<Double>(); recentScores_ = new LinkedList<Double>(); internalSDs_ = new LinkedList<Double>(); minMaxReward_ = new double[2]; minMaxReward_[0] = Float.MAX_VALUE; minMaxReward_[1] = -Float.MAX_VALUE; trainingStartTime_ = System.currentTimeMillis(); runIndex_ = runIndex; }