Code example for Matcher

Methods: group, groupCount, matches

0
         * @param locationNode the {@link LocationPoint} to receive the location data. 
         * @param location The string containing the location info. 
         */ 
        private void parseLocation(LocationPoint locationNode, String location) {
            Matcher m = sLocationPattern.matcher(location);
            if (m.matches()) {
                try { 
                    double longitude = Double.parseDouble(m.group(1));
                    double latitude = Double.parseDouble(m.group(2));
                     
                    locationNode.setLocation(longitude, latitude);
                     
                    if (m.groupCount() == 3) {
                        // looks like we have elevation data. 
                        locationNode.setElevation(Double.parseDouble(m.group(3)));
                    } 
                } catch (NumberFormatException e) {
                    // wrong data, do nothing. 
                } 
            } 
        }