Example usage for java.lang Float MAX_VALUE

List of usage examples for java.lang Float MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Float MAX_VALUE.

Prototype

float MAX_VALUE

To view the source code for java.lang Float MAX_VALUE.

Click Source Link

Document

A constant holding the largest positive finite value of type float , (2-2-23)·2127.

Usage

From source file:org.vertx.java.http.eventbusbridge.integration.MessageSendWithReplyTest.java

@Test
public void testSendingFloatXmlWithResponseXml() throws IOException {
    final EventBusMessageType messageType = EventBusMessageType.Float;
    final Float sentFloat = Float.MAX_VALUE;
    int port = findFreePort();
    String responseUrl = createHttpServerUrl(port);
    Map<String, String> expectations = createExpectations("someaddress",
            Base64.encodeAsString(sentFloat.toString()), messageType, responseUrl, MediaType.APPLICATION_XML);
    String responseBody = TemplateHelper.generateOutputUsingTemplate(SEND_RESPONSE_TEMPLATE_XML, expectations);
    createHttpServer(port, MediaType.APPLICATION_XML, responseBody);
    Handler<Message> messageConsumerHandler = new MessageSendWithReplyHandler(sentFloat, expectations);
    vertx.eventBus().registerHandler(expectations.get("address"), messageConsumerHandler);
    String requestBody = TemplateHelper.generateOutputUsingTemplate(SEND_REQUEST_TEMPLATE_XML, expectations);
    HttpRequestHelper.sendHttpPostRequest(url, requestBody, (VertxInternal) vertx,
            Status.ACCEPTED.getStatusCode(), MediaType.APPLICATION_XML);
}

From source file:org.opencms.workplace.commons.CmsPropertyCustom.java

/**
 * Performs the editing of the resources properties.<p>
 * //from  w  w  w.j ava 2s .c om
 * @param request the HttpServletRequest
 * @return true, if the properties were successfully changed, otherwise false
 * @throws CmsException if editing is not successful
 */
protected boolean performEditOperation(HttpServletRequest request) throws CmsException {

    boolean useTempfileProject = Boolean.valueOf(getParamUsetempfileproject()).booleanValue();
    try {
        if (useTempfileProject) {
            switchToTempProject();
        }
        // write the common properties defined in the explorer type settings
        Iterator i = getExplorerTypeSettings().getProperties().iterator();
        // iterate over the properties
        while (i.hasNext()) {
            String curProperty = (String) i.next();
            String paramValue = request.getParameter(PREFIX_VALUE + curProperty);
            String oldValue = request.getParameter(PREFIX_HIDDEN + curProperty);
            writeProperty(curProperty, paramValue, oldValue);
        }

        // write the navigation properties if enabled
        if (showNavigation()) {
            // get the navigation enabled parameter
            String paramValue = request.getParameter("enablenav");
            String oldValue = null;
            if (Boolean.valueOf(paramValue).booleanValue()) {
                // navigation enabled, update params
                paramValue = request.getParameter("navpos");
                if (!"-1".equals(paramValue) && !String.valueOf(Float.MAX_VALUE).equals(paramValue)) {
                    // update the property only when it is different from "-1" (meaning no change)
                    oldValue = request.getParameter(PREFIX_HIDDEN + CmsPropertyDefinition.PROPERTY_NAVPOS);
                    writeProperty(CmsPropertyDefinition.PROPERTY_NAVPOS, paramValue, oldValue);
                }
                paramValue = request.getParameter(PREFIX_VALUE + CmsPropertyDefinition.PROPERTY_NAVTEXT);
                oldValue = request.getParameter(PREFIX_HIDDEN + CmsPropertyDefinition.PROPERTY_NAVTEXT);
                writeProperty(CmsPropertyDefinition.PROPERTY_NAVTEXT, paramValue, oldValue);
            } else {
                // navigation disabled, delete property values
                writeProperty(CmsPropertyDefinition.PROPERTY_NAVPOS, null, null);
                writeProperty(CmsPropertyDefinition.PROPERTY_NAVTEXT, null, null);
            }
        }
    } finally {
        if (useTempfileProject) {
            switchToCurrentProject();
        }
    }
    return true;
}

From source file:jp.furplag.util.commons.NumberUtilsTest.java

/**
 * {@link jp.furplag.util.commons.NumberUtils#contains(java.lang.Object, java.lang.Number, java.lang.Number)}.
 */// w w  w  .j av  a2  s .co  m
@SuppressWarnings("unchecked")
@Test
public void testContains() {
    assertEquals("null", false, contains(null, null, null));
    assertEquals("null", false, contains(null, 0, null));
    assertEquals("null", false, contains(null, null, 10));
    assertEquals("null", false, contains(null, 0, 10));
    assertEquals("null: from", true, contains(0, null, 10));
    assertEquals("null: from: overflow", false, contains(11, null, 10));
    assertEquals("null: to", true, contains(0, 0, null));
    assertEquals("null: to", true, contains(11, 10, null));
    assertEquals("null: to: less", false, contains(1, 10, null));
    assertEquals("fraction: Double", true, contains(Math.PI, 0, 10));
    assertEquals("fraction: Float", true, contains(Float.MIN_VALUE, 0, 10));
    assertEquals("NaN", false, contains(Float.NaN, -Float.MAX_VALUE, Float.MAX_VALUE));
    assertEquals("NaN", false, contains(Float.NaN, null, Float.POSITIVE_INFINITY));
    assertEquals("NaN", true, contains(Float.NaN, Float.NaN, Float.POSITIVE_INFINITY));
    assertEquals("NaN", true, contains(Float.NaN, null, Float.NaN));
    assertEquals("NaN", true, contains(Float.NaN, Double.NaN, Float.NaN));
    assertEquals("-Infinity: from", true, contains(1, Float.NEGATIVE_INFINITY, null));
    assertEquals("-Infinity: to", false, contains(1, null, Float.NEGATIVE_INFINITY));
    assertEquals("Infinity: from", false, contains(1, Float.POSITIVE_INFINITY, null));
    assertEquals("Infinity: to", true, contains(1, null, Float.POSITIVE_INFINITY));
    assertEquals("Infinity: only", false, contains(1, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
    assertEquals("Infinity: only", true,
            contains(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
    assertEquals("Infinity: only", true,
            contains(Double.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
    for (Class<?> type : NUMBERS) {
        Class<? extends Number> wrapper = (Class<? extends Number>) ClassUtils.primitiveToWrapper(type);
        Object o = null;
        try {
            if (ClassUtils.isPrimitiveWrapper(wrapper)) {
                o = wrapper.getField("MAX_VALUE").get(null);
            } else {
                o = INFINITY_DOUBLE.pow(2);
                if (BigInteger.class.equals(type))
                    o = ((BigDecimal) o).toBigInteger();
            }
            assertEquals("Infinity: all: " + type.getSimpleName(), true,
                    contains(o, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage() + "\n" + Arrays.toString(e.getStackTrace()));
        }
    }
}

From source file:org.noise_planet.noisecapture.CalibrationLinearityActivity.java

private void updateScatterChart() {
    ScatterChart scatterChart = getScatterChart();
    if (scatterChart == null) {
        return;/* w  w  w .  j  av  a 2 s . c om*/
    }
    if (freqLeqStats.isEmpty()) {
        return;
    }
    float YMin = Float.MAX_VALUE;
    float YMax = Float.MIN_VALUE;
    float XMin = Float.MAX_VALUE;
    float XMax = Float.MIN_VALUE;

    ArrayList<IScatterDataSet> dataSets = new ArrayList<IScatterDataSet>();

    // Frequency count, one dataset by frequency
    int dataSetCount = freqLeqStats.get(freqLeqStats.size() - 1).whiteNoiseLevel.getdBaLevels().length;

    Set<Integer> whiteNoiseValuesSet = new TreeSet<Integer>();

    // Read all white noise values for indexing before usage
    for (LinearCalibrationResult result : freqLeqStats) {
        for (int idFreq = 0; idFreq < result.whiteNoiseLevel.getdBaLevels().length; idFreq++) {
            float dbLevel = result.whiteNoiseLevel.getdBaLevels()[idFreq];
            float referenceDbLevel = freqLeqStats.get(0).whiteNoiseLevel.getdBaLevels()[idFreq];
            whiteNoiseValuesSet.add((int) (dbLevel - referenceDbLevel));
        }
    }
    // Convert into ordered list
    int[] whiteNoiseValues = new int[whiteNoiseValuesSet.size()];

    ArrayList<String> xVals = new ArrayList<String>();
    int i = 0;
    for (int dbValue : whiteNoiseValuesSet) {
        whiteNoiseValues[i++] = dbValue;
        xVals.add(String.valueOf(dbValue));
        XMax = Math.max(XMax, dbValue);
        XMin = Math.min(XMin, dbValue);
    }

    double[] freqs = FFTSignalProcessing
            .computeFFTCenterFrequency(AudioProcess.REALTIME_SAMPLE_RATE_LIMITATION);
    for (int freqId = 0; freqId < dataSetCount; freqId += 1) {
        int freqValue = (int) freqs[freqId];
        if (selectedFrequencies.contains(freqValue)) {
            ArrayList<Entry> yMeasure = new ArrayList<Entry>();
            for (LinearCalibrationResult result : freqLeqStats) {
                float dbLevel = (float) result.measure[freqId].getLeqMean();
                float referenceDbLevel = freqLeqStats.get(0).whiteNoiseLevel.getdBaLevels()[freqId];
                int whiteNoise = (int) (result.whiteNoiseLevel.getdBaLevels()[freqId] - referenceDbLevel);
                YMax = Math.max(YMax, dbLevel);
                YMin = Math.min(YMin, dbLevel);
                yMeasure.add(new Entry(dbLevel, Arrays.binarySearch(whiteNoiseValues, whiteNoise)));
            }
            ScatterDataSet freqSet = new ScatterDataSet(yMeasure, Spectrogram
                    .formatFrequency((int) ThirdOctaveBandsFiltering.STANDARD_FREQUENCIES_REDUCED[freqId]));
            freqSet.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
            freqSet.setColor(ColorTemplate.COLORFUL_COLORS[freqId % ColorTemplate.COLORFUL_COLORS.length]);
            freqSet.setScatterShapeSize(8f);
            freqSet.setValueTextColor(Color.WHITE);
            freqSet.setDrawValues(false);
            dataSets.add(freqSet);
        }
    }

    // create a data object with the datasets
    ScatterData data = new ScatterData(xVals, dataSets);
    scatterChart.setData(data);
    YAxis yl = scatterChart.getAxisLeft();
    yl.setAxisMinValue(YMin - 3);
    yl.setAxisMaxValue(YMax + 3);
    scatterChart.invalidate();
}

From source file:org.alfresco.serializers.types.DefaultTypeConverter.java

@SuppressWarnings("rawtypes")
private DefaultTypeConverter() {
    ///*from w  ww. ja v  a 2s  .co m*/
    // From string
    //
    addConverter(String.class, Class.class, new TypeConverter.Converter<String, Class>() {
        public Class convert(String source) {
            try {
                return Class.forName(source);
            } catch (ClassNotFoundException e) {
                throw new TypeConversionException("Failed to convert string to class: " + source, e);
            }
        }
    });
    addConverter(String.class, Boolean.class, new TypeConverter.Converter<String, Boolean>() {
        public Boolean convert(String source) {
            return Boolean.valueOf(source);
        }
    });
    addConverter(String.class, Character.class, new TypeConverter.Converter<String, Character>() {
        public Character convert(String source) {
            if ((source == null) || (source.length() == 0)) {
                return null;
            }
            return Character.valueOf(source.charAt(0));
        }
    });
    addConverter(String.class, Number.class, new TypeConverter.Converter<String, Number>() {
        public Number convert(String source) {
            try {
                return DecimalFormat.getNumberInstance().parse(source);
            } catch (ParseException e) {
                throw new TypeConversionException("Failed to parse number " + source, e);
            }
        }
    });
    addConverter(String.class, Byte.class, new TypeConverter.Converter<String, Byte>() {
        public Byte convert(String source) {
            return Byte.valueOf(source);
        }
    });
    addConverter(String.class, Short.class, new TypeConverter.Converter<String, Short>() {
        public Short convert(String source) {
            return Short.valueOf(source);
        }
    });
    addConverter(String.class, Integer.class, new TypeConverter.Converter<String, Integer>() {
        public Integer convert(String source) {
            return Integer.valueOf(source);
        }
    });
    addConverter(String.class, Long.class, new TypeConverter.Converter<String, Long>() {
        public Long convert(String source) {
            return Long.valueOf(source);
        }
    });
    addConverter(String.class, Float.class, new TypeConverter.Converter<String, Float>() {
        public Float convert(String source) {
            return Float.valueOf(source);
        }
    });
    addConverter(String.class, Double.class, new TypeConverter.Converter<String, Double>() {
        public Double convert(String source) {
            return Double.valueOf(source);
        }
    });
    addConverter(String.class, BigInteger.class, new TypeConverter.Converter<String, BigInteger>() {
        public BigInteger convert(String source) {
            return new BigInteger(source);
        }
    });
    addConverter(String.class, BigDecimal.class, new TypeConverter.Converter<String, BigDecimal>() {
        public BigDecimal convert(String source) {
            return new BigDecimal(source);
        }
    });
    addConverter(BasicDBObject.class, BigDecimal.class,
            new TypeConverter.Converter<BasicDBObject, BigDecimal>() {
                public BigDecimal convert(BasicDBObject source) {
                    String type = (String) source.get("t");
                    if (type.equals("FIXED_POINT")) {
                        String number = (String) source.get("n");
                        Integer precision = (Integer) source.get("p");
                        MathContext ctx = new MathContext(precision);
                        return new BigDecimal(number, ctx);
                    } else {
                        throw new IllegalArgumentException("Invalid source object for conversion " + source
                                + ", expected a Fixed Decimal object");
                    }
                }
            });
    addConverter(String.class, Date.class, new TypeConverter.Converter<String, Date>() {
        public Date convert(String source) {
            try {
                Date date = ISO8601DateFormat.parse(source);
                return date;
            } catch (PlatformRuntimeException e) {
                throw new TypeConversionException("Failed to convert date " + source + " to string", e);
            } catch (AlfrescoRuntimeException e) {
                throw new TypeConversionException("Failed to convert date " + source + " to string", e);
            }
        }
    });
    addConverter(String.class, Duration.class, new TypeConverter.Converter<String, Duration>() {
        public Duration convert(String source) {
            return new Duration(source);
        }
    });
    addConverter(String.class, QName.class, new TypeConverter.Converter<String, QName>() {
        public QName convert(String source) {
            return QName.createQName(source);
        }
    });
    addConverter(BasicDBObject.class, QName.class, new TypeConverter.Converter<BasicDBObject, QName>() {
        public QName convert(BasicDBObject source) {
            String type = (String) source.get("t");
            if (type.equals("QNAME")) {
                String qname = (String) source.get("v");
                return QName.createQName(qname);
            } else {
                throw new IllegalArgumentException();
            }
        }
    });
    addConverter(String.class, ContentData.class, new TypeConverter.Converter<String, ContentData>() {
        public ContentData convert(String source) {
            return ContentData.createContentProperty(source);
        }
    });
    addConverter(String.class, NodeRef.class, new TypeConverter.Converter<String, NodeRef>() {
        public NodeRef convert(String source) {
            return new NodeRef(source);
        }
    });
    addConverter(BasicDBObject.class, NodeRef.class, new TypeConverter.Converter<BasicDBObject, NodeRef>() {
        public NodeRef convert(BasicDBObject source) {
            String type = (String) source.get("t");
            if (!type.equals("NODEREF")) {
                throw new IllegalArgumentException(
                        "Invalid source object for conversion " + source + ", expected a NodeRef object");
            }
            String protocol = (String) source.get("p");
            String storeId = (String) source.get("s");
            String id = (String) source.get("id");
            NodeRef nodeRef = new NodeRef(new StoreRef(protocol, storeId), id);
            return nodeRef;
        }
    });
    addConverter(String.class, StoreRef.class, new TypeConverter.Converter<String, StoreRef>() {
        public StoreRef convert(String source) {
            return new StoreRef(source);
        }
    });
    addConverter(BasicDBObject.class, StoreRef.class, new TypeConverter.Converter<BasicDBObject, StoreRef>() {
        public StoreRef convert(BasicDBObject source) {
            String type = (String) source.get("t");
            if (!type.equals("STOREREF")) {
                throw new IllegalArgumentException(
                        "Invalid source object for conversion " + source + ", expected a StoreRef object");
            }
            String protocol = (String) source.get("p");
            String storeId = (String) source.get("s");
            return new StoreRef(protocol, storeId);
        }
    });
    addConverter(String.class, ChildAssociationRef.class,
            new TypeConverter.Converter<String, ChildAssociationRef>() {
                public ChildAssociationRef convert(String source) {
                    return new ChildAssociationRef(source);
                }
            });
    addConverter(String.class, AssociationRef.class, new TypeConverter.Converter<String, AssociationRef>() {
        public AssociationRef convert(String source) {
            return new AssociationRef(source);
        }
    });
    addConverter(String.class, InputStream.class, new TypeConverter.Converter<String, InputStream>() {
        public InputStream convert(String source) {
            try {
                return new ByteArrayInputStream(source.getBytes("UTF-8"));
            } catch (UnsupportedEncodingException e) {
                throw new TypeConversionException("Encoding not supported", e);
            }
        }
    });
    addConverter(String.class, MLText.class, new TypeConverter.Converter<String, MLText>() {
        public MLText convert(String source) {
            return new MLText(source);
        }
    });
    addConverter(BasicDBObject.class, MLText.class, new TypeConverter.Converter<BasicDBObject, MLText>() {
        public MLText convert(BasicDBObject source) {
            String type = (String) source.get("t");
            if (!type.equals("MLTEXT")) {
                throw new IllegalArgumentException(
                        "Invalid source object for conversion " + source + ", expected a NodeRef object");
            }

            MLText mlText = new MLText();
            for (String languageTag : source.keySet()) {
                String text = (String) source.get(languageTag);
                Locale locale = Locale.forLanguageTag(languageTag);
                mlText.put(locale, text);
            }

            return mlText;
        }
    });
    //        addConverter(BasicDBObject.class, ContentDataWithId.class, new TypeConverter.Converter<BasicDBObject, ContentDataWithId>()
    //        {
    //            public ContentDataWithId convert(BasicDBObject source)
    //            {
    //                String type = (String)source.get("t");
    //                if(!type.equals("CONTENT_DATA_ID"))
    //                {
    //                    throw new IllegalArgumentException("Invalid source object for conversion "
    //                            + source 
    //                            + ", expected a ContentDataWithId object");
    //                }
    //                String contentUrl = (String)source.get("u");
    //                String mimeType = (String)source.get("m");
    //                Long size = (Long)source.get("s");
    //                String encoding = (String)source.get("e");
    //                String languageTag = (String)source.get("l");
    //                Long id = (Long)source.get("id");
    //                Locale locale = Locale.forLanguageTag(languageTag);
    //
    //                ContentData contentData = new ContentData(contentUrl, mimeType, size, encoding, locale);
    //                ContentDataWithId contentDataWithId = new ContentDataWithId(contentData, id);
    //                return contentDataWithId;
    //            }
    //        });
    addConverter(BasicDBObject.class, ContentData.class,
            new TypeConverter.Converter<BasicDBObject, ContentData>() {
                public ContentData convert(BasicDBObject source) {
                    ContentData contentData = null;

                    String type = (String) source.get("t");
                    if (type.equals("CONTENT")) {
                        String contentUrl = (String) source.get("u");
                        String mimeType = (String) source.get("m");
                        Long size = (Long) source.get("s");
                        String encoding = (String) source.get("e");
                        String languageTag = (String) source.get("l");
                        Locale locale = Locale.forLanguageTag(languageTag);
                        contentData = new ContentData(contentUrl, mimeType, size, encoding, locale);
                    } else if (type.equals("CONTENT_DATA_ID")) {
                        String contentUrl = (String) source.get("u");
                        String mimeType = (String) source.get("m");
                        Long size = (Long) source.get("s");
                        String encoding = (String) source.get("e");
                        String languageTag = (String) source.get("l");
                        Locale locale = Locale.forLanguageTag(languageTag);
                        contentData = new ContentData(contentUrl, mimeType, size, encoding, locale);
                    } else {
                        throw new IllegalArgumentException("Invalid source object for conversion " + source
                                + ", expected a ContentData object");
                    }

                    return contentData;
                }
            });
    addConverter(BasicDBObject.class, String.class, new TypeConverter.Converter<BasicDBObject, String>() {
        public String convert(BasicDBObject source) {
            // TODO distinguish between different BasicDBObject representations e.g. for MLText, ...

            Set<String> languageTags = source.keySet();
            if (languageTags.size() == 0) {
                throw new IllegalArgumentException("Persisted MLText is invalid " + source);
            } else if (languageTags.size() > 1) {
                // TODO
                logger.warn("Persisted MLText has more than 1 locale " + source);
            }

            String languageTag = languageTags.iterator().next();
            String text = source.getString(languageTag);
            return text;
        }
    });
    addConverter(String.class, Locale.class, new TypeConverter.Converter<String, Locale>() {
        public Locale convert(String source) {
            return I18NUtil.parseLocale(source);
        }
    });
    addConverter(String.class, Period.class, new TypeConverter.Converter<String, Period>() {
        public Period convert(String source) {
            return new Period(source);
        }
    });
    addConverter(String.class, VersionNumber.class, new TypeConverter.Converter<String, VersionNumber>() {
        public VersionNumber convert(String source) {
            return new VersionNumber(source);
        }
    });

    //
    // From Locale
    //
    addConverter(Locale.class, String.class, new TypeConverter.Converter<Locale, String>() {
        public String convert(Locale source) {
            String localeStr = source.toString();
            if (localeStr.length() < 6) {
                localeStr += "_";
            }
            return localeStr;
        }
    });

    //
    // From VersionNumber
    //
    addConverter(VersionNumber.class, String.class, new TypeConverter.Converter<VersionNumber, String>() {
        public String convert(VersionNumber source) {
            return source.toString();
        }
    });

    //
    // From MLText
    //
    addConverter(MLText.class, String.class, new TypeConverter.Converter<MLText, String>() {
        public String convert(MLText source) {
            return source.getDefaultValue();
        }
    });

    addConverter(MLText.class, BasicDBObject.class, new TypeConverter.Converter<MLText, BasicDBObject>() {
        public BasicDBObject convert(MLText source) {
            BasicDBObject dbObject = new BasicDBObject("t", "MLTEXT");
            for (Map.Entry<Locale, String> entry : source.entrySet()) {
                dbObject.put(entry.getKey().toLanguageTag(), entry.getValue());
            }
            return dbObject;
        }
    });

    //        addConverter(ContentDataWithId.class, BasicDBObject.class, new TypeConverter.Converter<ContentDataWithId, BasicDBObject>()
    //        {
    //            public BasicDBObject convert(ContentDataWithId source)
    //            {
    //                BasicDBObject dbObject = new BasicDBObject("t", "CONTENT_DATA_ID");
    //
    //                String contentUrl = source.getContentUrl();
    //                Long id = source.getId();
    //                String languageTag = source.getLocale().toLanguageTag();
    //                String encoding = source.getEncoding();
    //                long size = source.getSize();
    //                String mimeType = source.getMimetype();
    //
    //                dbObject.put("u", contentUrl);
    //                dbObject.put("m", mimeType);
    //                dbObject.put("s", size);
    //                dbObject.put("e", encoding);
    //                dbObject.put("l", languageTag);
    //                dbObject.put("id", id);
    //                return dbObject;
    //            }
    //        });

    addConverter(ContentData.class, BasicDBObject.class,
            new TypeConverter.Converter<ContentData, BasicDBObject>() {
                public BasicDBObject convert(ContentData source) {
                    BasicDBObject dbObject = new BasicDBObject("t", "CONTENT");

                    String contentUrl = source.getContentUrl();
                    String languageTag = source.getLocale().toLanguageTag();
                    String encoding = source.getEncoding();
                    long size = source.getSize();
                    String mimeType = source.getMimetype();

                    dbObject.put("u", contentUrl);
                    dbObject.put("m", mimeType);
                    dbObject.put("s", size);
                    dbObject.put("e", encoding);
                    dbObject.put("l", languageTag);
                    return dbObject;
                }
            });

    //
    // From enum
    //
    addConverter(Enum.class, String.class, new TypeConverter.Converter<Enum, String>() {
        public String convert(Enum source) {
            return source.toString();
        }
    });

    // From Period
    addConverter(Period.class, String.class, new TypeConverter.Converter<Period, String>() {
        public String convert(Period source) {
            return source.toString();
        }
    });

    // From Class
    addConverter(Class.class, String.class, new TypeConverter.Converter<Class, String>() {
        public String convert(Class source) {
            return source.getName();
        }
    });

    //
    // Number to Subtypes and Date
    //
    addConverter(Number.class, Boolean.class, new TypeConverter.Converter<Number, Boolean>() {
        public Boolean convert(Number source) {
            return new Boolean(source.longValue() > 0);
        }
    });
    addConverter(Number.class, Byte.class, new TypeConverter.Converter<Number, Byte>() {
        public Byte convert(Number source) {
            return Byte.valueOf(source.byteValue());
        }
    });
    addConverter(Number.class, Short.class, new TypeConverter.Converter<Number, Short>() {
        public Short convert(Number source) {
            return Short.valueOf(source.shortValue());
        }
    });
    addConverter(Number.class, Integer.class, new TypeConverter.Converter<Number, Integer>() {
        public Integer convert(Number source) {
            return Integer.valueOf(source.intValue());
        }
    });
    addConverter(Number.class, Long.class, new TypeConverter.Converter<Number, Long>() {
        public Long convert(Number source) {
            return Long.valueOf(source.longValue());
        }
    });
    addConverter(Number.class, Float.class, new TypeConverter.Converter<Number, Float>() {
        public Float convert(Number source) {
            return Float.valueOf(source.floatValue());
        }
    });
    addConverter(Number.class, Double.class, new TypeConverter.Converter<Number, Double>() {
        public Double convert(Number source) {
            return Double.valueOf(source.doubleValue());
        }
    });
    addConverter(Number.class, Date.class, new TypeConverter.Converter<Number, Date>() {
        public Date convert(Number source) {
            return new Date(source.longValue());
        }
    });
    addConverter(Number.class, String.class, new TypeConverter.Converter<Number, String>() {
        public String convert(Number source) {
            return source.toString();
        }
    });
    addConverter(Number.class, BigInteger.class, new TypeConverter.Converter<Number, BigInteger>() {
        public BigInteger convert(Number source) {
            if (source instanceof BigDecimal) {
                return ((BigDecimal) source).toBigInteger();
            } else {
                return BigInteger.valueOf(source.longValue());
            }
        }
    });
    addConverter(Number.class, BigDecimal.class, new TypeConverter.Converter<Number, BigDecimal>() {
        public BigDecimal convert(Number source) {
            if (source instanceof BigInteger) {
                return new BigDecimal((BigInteger) source);
            } else if (source instanceof Double) {
                return BigDecimal.valueOf((Double) source);
            } else if (source instanceof Float) {
                Float val = (Float) source;
                if (val.isInfinite()) {
                    // What else can we do here?  this is 3.4 E 38 so is fairly big
                    return new BigDecimal(Float.MAX_VALUE);
                }
                return BigDecimal.valueOf((Float) source);
            } else {
                return BigDecimal.valueOf(source.longValue());
            }
        }
    });
    addDynamicTwoStageConverter(Number.class, String.class, InputStream.class);

    //
    // Date, Timestamp ->
    //
    addConverter(Timestamp.class, Date.class, new TypeConverter.Converter<Timestamp, Date>() {
        public Date convert(Timestamp source) {
            return new Date(source.getTime());
        }
    });
    addConverter(Date.class, Number.class, new TypeConverter.Converter<Date, Number>() {
        public Number convert(Date source) {
            return Long.valueOf(source.getTime());
        }
    });
    addConverter(Date.class, String.class, new TypeConverter.Converter<Date, String>() {
        public String convert(Date source) {
            try {
                return ISO8601DateFormat.format(source);
            } catch (PlatformRuntimeException e) {
                throw new TypeConversionException("Failed to convert date " + source + " to string", e);
            }
        }
    });
    addConverter(Date.class, Calendar.class, new TypeConverter.Converter<Date, Calendar>() {
        public Calendar convert(Date source) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(source);
            return calendar;
        }
    });

    addConverter(Date.class, GregorianCalendar.class, new TypeConverter.Converter<Date, GregorianCalendar>() {
        public GregorianCalendar convert(Date source) {
            GregorianCalendar calendar = new GregorianCalendar();
            calendar.setTime(source);
            return calendar;
        }
    });
    addDynamicTwoStageConverter(Date.class, String.class, InputStream.class);

    //
    // Boolean ->
    //
    final Long LONG_FALSE = new Long(0L);
    final Long LONG_TRUE = new Long(1L);
    addConverter(Boolean.class, Long.class, new TypeConverter.Converter<Boolean, Long>() {
        public Long convert(Boolean source) {
            return source.booleanValue() ? LONG_TRUE : LONG_FALSE;
        }
    });
    addConverter(Boolean.class, String.class, new TypeConverter.Converter<Boolean, String>() {
        public String convert(Boolean source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(Boolean.class, String.class, InputStream.class);

    //
    // Character ->
    //
    addConverter(Character.class, String.class, new TypeConverter.Converter<Character, String>() {
        public String convert(Character source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(Character.class, String.class, InputStream.class);

    //
    // Duration ->
    //
    addConverter(Duration.class, String.class, new TypeConverter.Converter<Duration, String>() {
        public String convert(Duration source) {
            return source.toString();
        }

    });
    addDynamicTwoStageConverter(Duration.class, String.class, InputStream.class);

    //
    // Byte
    //
    addConverter(Byte.class, String.class, new TypeConverter.Converter<Byte, String>() {
        public String convert(Byte source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(Byte.class, String.class, InputStream.class);

    //
    // Short
    //
    addConverter(Short.class, String.class, new TypeConverter.Converter<Short, String>() {
        public String convert(Short source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(Short.class, String.class, InputStream.class);

    //
    // Integer
    //
    addConverter(Integer.class, String.class, new TypeConverter.Converter<Integer, String>() {
        public String convert(Integer source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(Integer.class, String.class, InputStream.class);

    //
    // Long
    //
    addConverter(Long.class, String.class, new TypeConverter.Converter<Long, String>() {
        public String convert(Long source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(Long.class, String.class, InputStream.class);

    //
    // Float
    //
    addConverter(Float.class, String.class, new TypeConverter.Converter<Float, String>() {
        public String convert(Float source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(Float.class, String.class, InputStream.class);

    //
    // Double
    //
    addConverter(Double.class, String.class, new TypeConverter.Converter<Double, String>() {
        public String convert(Double source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(Double.class, String.class, InputStream.class);

    //
    // BigInteger
    //
    addConverter(BigInteger.class, String.class, new TypeConverter.Converter<BigInteger, String>() {
        public String convert(BigInteger source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(BigInteger.class, String.class, InputStream.class);

    //
    // Calendar
    //
    addConverter(Calendar.class, Date.class, new TypeConverter.Converter<Calendar, Date>() {
        public Date convert(Calendar source) {
            return source.getTime();
        }
    });
    addConverter(Calendar.class, String.class, new TypeConverter.Converter<Calendar, String>() {
        public String convert(Calendar source) {
            try {
                return ISO8601DateFormat.format(source.getTime());
            } catch (PlatformRuntimeException e) {
                throw new TypeConversionException("Failed to convert date " + source + " to string", e);
            }
        }
    });

    //
    // BigDecimal
    //
    addConverter(BigDecimal.class, BasicDBObject.class,
            new TypeConverter.Converter<BigDecimal, BasicDBObject>() {
                public BasicDBObject convert(BigDecimal source) {
                    String number = source.toPlainString();
                    int precision = source.precision();
                    BasicDBObject dbObject = new BasicDBObject();
                    dbObject.put("t", "FIXED_POINT");
                    dbObject.put("n", number);
                    dbObject.put("p", precision);
                    return dbObject;
                }
            });
    addConverter(BigDecimal.class, String.class, new TypeConverter.Converter<BigDecimal, String>() {
        public String convert(BigDecimal source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(BigDecimal.class, String.class, InputStream.class);

    //
    // QName
    //
    addConverter(QName.class, String.class, new TypeConverter.Converter<QName, String>() {
        public String convert(QName source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(QName.class, String.class, InputStream.class);

    //
    // EntityRef (NodeRef, ChildAssociationRef, NodeAssociationRef)
    //
    addConverter(EntityRef.class, String.class, new TypeConverter.Converter<EntityRef, String>() {
        public String convert(EntityRef source) {
            return source.toString();
        }
    });
    addConverter(EntityRef.class, BasicDBObject.class, new TypeConverter.Converter<EntityRef, BasicDBObject>() {
        public BasicDBObject convert(EntityRef source) {
            BasicDBObject ret = null;

            if (source instanceof NodeRef) {
                NodeRef nodeRef = (NodeRef) source;

                BasicDBObjectBuilder builder = BasicDBObjectBuilder.start("t", "NODEREF");
                builder.add("p", nodeRef.getStoreRef().getProtocol());
                builder.add("s", nodeRef.getStoreRef().getIdentifier());
                builder.add("id", nodeRef.getId());
                ret = (BasicDBObject) builder.get();
            } else if (source instanceof StoreRef) {
                StoreRef storeRef = (StoreRef) source;

                BasicDBObjectBuilder builder = BasicDBObjectBuilder.start("t", "STOREREF");
                builder.add("p", storeRef.getProtocol());
                builder.add("s", storeRef.getIdentifier());
                ret = (BasicDBObject) builder.get();
            } else {
                throw new IllegalArgumentException();
            }

            return ret;
        }
    });
    addDynamicTwoStageConverter(EntityRef.class, String.class, InputStream.class);

    //
    // ContentData
    //
    addConverter(ContentData.class, String.class, new TypeConverter.Converter<ContentData, String>() {
        public String convert(ContentData source) {
            return source.getInfoUrl();
        }
    });
    addDynamicTwoStageConverter(ContentData.class, String.class, InputStream.class);

    //
    // Path
    //
    addConverter(Path.class, String.class, new TypeConverter.Converter<Path, String>() {
        public String convert(Path source) {
            return source.toString();
        }
    });
    addDynamicTwoStageConverter(Path.class, String.class, InputStream.class);

    //
    // Content Reader
    //
    addConverter(ContentReader.class, InputStream.class,
            new TypeConverter.Converter<ContentReader, InputStream>() {
                public InputStream convert(ContentReader source) {
                    return source.getContentInputStream();
                }
            });
    addConverter(ContentReader.class, String.class, new TypeConverter.Converter<ContentReader, String>() {
        public String convert(ContentReader source) {
            // Getting the string from the ContentReader binary is meaningless
            return source.toString();
        }
    });

    //
    // Content Writer
    //
    addConverter(ContentWriter.class, String.class, new TypeConverter.Converter<ContentWriter, String>() {
        public String convert(ContentWriter source) {
            return source.toString();
        }
    });

    addConverter(Collection.class, BasicDBList.class, new TypeConverter.Converter<Collection, BasicDBList>() {
        public BasicDBList convert(Collection source) {
            BasicDBList ret = new BasicDBList();
            for (Object o : source) {
                ret.add(o);
            }
            return ret;
        }
    });

    addConverter(BasicDBList.class, Collection.class, new TypeConverter.Converter<BasicDBList, Collection>() {
        @SuppressWarnings("unchecked")
        public Collection convert(BasicDBList source) {
            Collection ret = new LinkedList();
            for (Object o : source) {
                ret.add(o);
            }
            return ret;
        }
    });

    //
    // Input Stream
    //
    addConverter(InputStream.class, String.class, new TypeConverter.Converter<InputStream, String>() {
        public String convert(InputStream source) {
            try {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                byte[] buffer = new byte[8192];
                int read;
                while ((read = source.read(buffer)) > 0) {
                    out.write(buffer, 0, read);
                }
                byte[] data = out.toByteArray();
                return new String(data, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                throw new TypeConversionException("Cannot convert input stream to String.", e);
            } catch (IOException e) {
                throw new TypeConversionException("Conversion from stream to string failed", e);
            } finally {
                if (source != null) {
                    try {
                        source.close();
                    } catch (IOException e) {
                        //NOOP
                    }
                }
            }
        }
    });
    addDynamicTwoStageConverter(InputStream.class, String.class, Date.class);

    addDynamicTwoStageConverter(InputStream.class, String.class, Double.class);

    addDynamicTwoStageConverter(InputStream.class, String.class, Long.class);

    addDynamicTwoStageConverter(InputStream.class, String.class, Boolean.class);

    addDynamicTwoStageConverter(InputStream.class, String.class, QName.class);

    addDynamicTwoStageConverter(InputStream.class, String.class, Path.class);

    addDynamicTwoStageConverter(InputStream.class, String.class, NodeRef.class);

}

From source file:org.opencms.workplace.tools.sites.CmsSiteDetailDialog.java

/**
 * Build select options for the position.<p>
 *
 * @param currSite the current selected site
 *
 * @return the select options/*from   w w  w. j a  v a2  s .c o m*/
 */
private List<CmsSelectWidgetOption> createNavOpts(CmsSiteBean currSite) {

    List<CmsSite> sites = new ArrayList<CmsSite>();
    for (CmsSite site : OpenCms.getSiteManager().getAvailableSites(getCms(), true)) {
        if (site.getSiteMatcher() != null) {
            sites.add(site);
        }
    }

    float maxValue = 0;
    float nextPos = 0;

    // calculate value for the first navigation position
    float firstValue = 1;
    if (sites.size() > 0) {
        try {
            maxValue = sites.get(0).getPosition();
        } catch (Exception e) {
            // should usually never happen
        }
    }

    if (maxValue != 0) {
        firstValue = maxValue / 2;
    }

    List<String> options = new ArrayList<String>(sites.size() + 1);
    List<String> values = new ArrayList<String>(sites.size() + 1);

    // add the first entry: before first element
    options.add(getMessages().key(org.opencms.workplace.commons.Messages.GUI_CHNAV_POS_FIRST_0));
    values.add(firstValue + "");

    // show all present navigation elements in box
    for (int i = 0; i < sites.size(); i++) {
        String navText = sites.get(i).getTitle();
        float navPos = sites.get(i).getPosition();
        String siteRoot = sites.get(i).getSiteRoot();
        // get position of next nav element
        nextPos = navPos + 2;
        if ((i + 1) < sites.size()) {
            nextPos = sites.get(i + 1).getPosition();
        }
        // calculate new position of current nav element
        float newPos;
        if ((nextPos - navPos) > 1) {
            newPos = navPos + 1;
        } else {
            newPos = (navPos + nextPos) / 2;
        }
        // check new maxValue of positions and increase it
        if (navPos > maxValue) {
            maxValue = navPos;
        }
        // if the element is the current file, mark it in select box
        if ((currSite != null) && (currSite.getSiteRoot() != null) && currSite.getSiteRoot().equals(siteRoot)) {
            options.add(CmsEncoder.escapeHtml(
                    getMessages().key(org.opencms.workplace.commons.Messages.GUI_CHNAV_POS_CURRENT_1,
                            new Object[] { sites.get(i).getSiteRoot() })));
            values.add("-1");
        } else {
            options.add(CmsEncoder.escapeHtml(navText + " [" + sites.get(i).getSiteRoot() + "/]"));
            values.add(newPos + "");
        }
    }

    // add the entry: at the last position
    options.add(getMessages().key(org.opencms.workplace.commons.Messages.GUI_CHNAV_POS_LAST_0));
    values.add((maxValue + 1) + "");

    // add the entry: no change
    options.add(getMessages().key(org.opencms.workplace.commons.Messages.GUI_CHNAV_NO_CHANGE_0));
    if ((currSite != null) && (currSite.getPosition() == Float.MAX_VALUE)) {
        // current resource has no valid position, use "last position"
        values.add((maxValue + 1) + "");
    } else {
        // current resource has valid position, use "-1" for no change
        values.add("-1");
    }
    List<CmsSelectWidgetOption> result = new ArrayList<CmsSelectWidgetOption>();
    for (int i = 0; i < values.size(); i++) {
        String val = values.get(i);
        String opt = options.get(i);
        result.add(new CmsSelectWidgetOption(val, false, opt));
    }
    return result;
}

From source file:tilt.image.page.Line.java

/**
 * Find the smallest distance to the line's segments
 * @param pt the point to measure towards
 * @return the minimum distance//from  w w w  . java 2s. com
 */
public float closestDistTo(Point pt) {
    float minDist = Float.MAX_VALUE;
    for (int i = 1; i < points.size(); i++) {
        Point last = points.get(i - 1);
        Point curr = points.get(i);
        Segment seg = new Segment(last, curr);
        float dist = (float) seg.distFromLine(pt);
        if (dist < minDist)
            minDist = dist;
    }
    return minDist;
}

From source file:gov.nist.itl.versus.similarity.transforms.ColorModels.java

public boolean convertRGBToEuclidDistImageOut(ImageObject image, ImageObject newIm) {

    if (image == null || image.getNumCols() <= 0 || image.getNumRows() <= 0) {
        logger.debug("ERROR: no image \n");

        return false;
    }/*  w w w  . jav  a 2 s.  c o  m*/

    if (newIm == null || newIm.getNumCols() != image.getNumCols() || newIm.getNumRows() != image.getNumRows()) {

        logger.debug("ERROR: no image or mismatch of size \n");
        return false;
    }

    if (newIm.getNumBands() != 1) {
        logger.debug("ERROR: input images should have sampPerPixel = 1");

        return false;
    }

    if (newIm.getType() != ImageObject.TYPE_FLOAT) {
        logger.debug("ERROR: outImage type is not FLOAT type");

        return false;
    }

    int numrows, numcols;
    numrows = image.getNumRows();
    numcols = image.getNumCols();

    long size = image.getSize() / image.getNumBands();
    double sum;
    _MaxVal = 0.0F; //norm = 4072.0234; // this is sqrt(255^3)
    _MinVal = Float.MAX_VALUE; //5000
    int index, indexColor;
    boolean signal = true;
    int num_bands = image.getNumBands();
    for (index = 0, indexColor = 0; index < size; index++, indexColor += num_bands) {

        sum = image.getFloat(indexColor) * image.getFloat(indexColor);
        sum += image.getFloat(indexColor + 1) * image.getFloat(indexColor + 1);
        sum += image.getFloat(indexColor + 2) * image.getFloat(indexColor + 2);
        sum = Math.sqrt(sum);

        newIm.setFloat(index, (float) sum);

        if (sum > _MaxVal)
            _MaxVal = (float) sum;

        if (sum < _MinVal)
            _MinVal = (float) sum;
    }

    signal = false;

    logger.debug("Max dist in 3D = " + _MaxVal);
    logger.debug("Min dist in 3D = " + _MinVal);

    if (signal)
        return false;

    return true;
}

From source file:com.alibaba.wasp.jdbc.TestPreparedStatement.java

public void testObject() throws SQLException {
    Statement stat = conn.createStatement();
    ResultSet rs;//from   w w w  .  j  a  v a2  s  . c om
    stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
    stat.execute("INSERT INTO TEST VALUES(1, 'Hello')");
    PreparedStatement prep = conn
            .prepareStatement("SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? FROM TEST");
    prep.setObject(1, Boolean.TRUE);
    prep.setObject(2, "Abc");
    prep.setObject(3, new BigDecimal("10.2"));
    prep.setObject(4, new Byte((byte) 0xff));
    prep.setObject(5, new Short(Short.MAX_VALUE));
    prep.setObject(6, new Integer(Integer.MIN_VALUE));
    prep.setObject(7, new Long(Long.MAX_VALUE));
    prep.setObject(8, new Float(Float.MAX_VALUE));
    prep.setObject(9, new Double(Double.MAX_VALUE));
    prep.setObject(10, Date.valueOf("2001-02-03"));
    prep.setObject(11, Time.valueOf("04:05:06"));
    prep.setObject(12, Timestamp.valueOf("2001-02-03 04:05:06.123456789"));
    prep.setObject(13, new java.util.Date(Date.valueOf("2001-02-03").getTime()));
    prep.setObject(14, new byte[] { 10, 20, 30 });
    prep.setObject(15, new Character('a'), Types.OTHER);
    prep.setObject(16, "2001-01-02", Types.DATE);
    // converting to null seems strange...
    prep.setObject(17, "2001-01-02", Types.NULL);
    prep.setObject(18, "3.725", Types.DOUBLE);
    prep.setObject(19, "23:22:21", Types.TIME);
    prep.setObject(20, new java.math.BigInteger("12345"), Types.OTHER);
    rs = prep.executeQuery();
    rs.next();
    assertTrue(rs.getObject(1).equals(Boolean.TRUE));
    assertTrue(rs.getObject(2).equals("Abc"));
    assertTrue(rs.getObject(3).equals(new BigDecimal("10.2")));
    assertTrue(rs.getObject(4).equals((byte) 0xff));
    assertTrue(rs.getObject(5).equals(new Short(Short.MAX_VALUE)));
    assertTrue(rs.getObject(6).equals(new Integer(Integer.MIN_VALUE)));
    assertTrue(rs.getObject(7).equals(new Long(Long.MAX_VALUE)));
    assertTrue(rs.getObject(8).equals(new Float(Float.MAX_VALUE)));
    assertTrue(rs.getObject(9).equals(new Double(Double.MAX_VALUE)));
    assertTrue(rs.getObject(10).equals(Date.valueOf("2001-02-03")));
    assertEquals("04:05:06", rs.getObject(11).toString());
    assertTrue(rs.getObject(11).equals(Time.valueOf("04:05:06")));
    assertTrue(rs.getObject(12).equals(Timestamp.valueOf("2001-02-03 04:05:06.123456789")));
    assertTrue(rs.getObject(13).equals(Timestamp.valueOf("2001-02-03 00:00:00")));
    assertEquals(new byte[] { 10, 20, 30 }, (byte[]) rs.getObject(14));
    assertTrue(rs.getObject(15).equals('a'));
    assertTrue(rs.getObject(16).equals(Date.valueOf("2001-01-02")));
    assertTrue(rs.getObject(17) == null && rs.wasNull());
    assertTrue(rs.getObject(18).equals(new Double(3.725)));
    assertTrue(rs.getObject(19).equals(Time.valueOf("23:22:21")));
    assertTrue(rs.getObject(20).equals(new java.math.BigInteger("12345")));

    // } else if(x instanceof java.io.Reader) {
    // return session.createLob(Value.CLOB,
    // TypeConverter.getInputStream((java.io.Reader)x), 0);
    // } else if(x instanceof java.io.InputStream) {
    // return session.createLob(Value.BLOB, (java.io.InputStream)x, 0);
    // } else {
    // return ValueBytes.get(TypeConverter.serialize(x));

    stat.execute("DROP TABLE TEST");

}

From source file:com.spoiledmilk.ibikecph.navigation.routing_engine.SMRoute.java

public boolean isTooFarFromRoute(Location loc, int maxDistance) {
    if (turnInstructions.size() > 0) {
        SMTurnInstruction currentTurn = turnInstructions.get(0);
        lastCorrectedLocation = new Location(loc);

        if (pastTurnInstructions.size() < 0) {
            // lastCorrectedHeading = SMGPSUtil.bearingBetween(loc,
            // currentTurn.loc);
            // We have passed no turns. Check if we have managed to get on
            // the route somehow.
            if (currentTurn != null) {
                double currentDistanceFromStart = loc.distanceTo(currentTurn.loc);
                LOG.d("Current distance from start: " + currentDistanceFromStart);
                if (currentDistanceFromStart > maxDistance) {
                    return checkLocation(loc, maxDistance);
                }/*from  www .  ja  v  a 2  s .c  o  m*/
            }
            return false;
        }

        distanceFromRoute = Float.MAX_VALUE;
        return checkLocation(loc, maxDistance);
    }
    return false;
}