private Metric toMetric( Node node ) {
        if( node == null ) {
            return null;
        }

        Metric metric = new Metric();

        NodeList attributes = node.getChildNodes();
        for( int i = 0; i < attributes.getLength(); i++ ) {
            Node attribute = attributes.item(i);
            String name = attribute.getNodeName();

            if( name.equals("MetricName") ) {
                metric.setName(provider.getTextValue(attribute));
            }
            else if( name.equals("Namespace") ) {
                metric.setNamespace(provider.getTextValue(attribute));
            }
            else if( name.equals("Dimensions") ) {
                Map<String, String> dimensions = toMetadata(attribute.getChildNodes());
                if( dimensions != null ) {
                    metric.addMetadata(dimensions);
                }
            }
        }
        return metric;
    }
private Metric toMetric ( Node node ) { if ( node == null ) { return null ; } Metric metric = new Metric ( ) ; NodeList attributes = node . getChildNodes ( ) ; for ( int i = 0 ; i < attributes . getLength ( ) ; i ++ ) { Node attribute = attributes . item ( i ) ; String name = attribute . getNodeName ( ) ; if ( name . equals ( "MetricName" ) ) { metric . setName ( provider . getTextValue ( attribute ) ) ; } else if ( name . equals ( "Namespace" ) ) { metric . setNamespace ( provider . getTextValue ( attribute ) ) ; } else if ( name . equals ( "Dimensions" ) ) { Map < String , String > dimensions = toMetadata ( attribute . getChildNodes ( ) ) ; if ( dimensions != null ) { metric . addMetadata ( dimensions ) ; } } } return metric ; }
Converts the given node to a Metric object.

@param node the node to convert
@return a Metric object