Code example for Element

Methods: getTagName

0
    public void map(NullWritable key, Text value, Context context) throws IOException, InterruptedException {
        try { 
            InputSource src = new InputSource(new StringReader(value.toString()));
            Document record = docBuilder.parse(src);
            Element tag = record.getDocumentElement();
            String tagName = tag.getTagName();
             
            if (tagName == "node") {
            	context.getCounter("osm-counters", "nodes").increment(1);
            	mapNode(context, tag);
            } else if (tagName == "way") {
            	context.getCounter("osm-counters", "ways").increment(1);
            	mapWay(context, tag);
            } else if (tagName == "relation") {
            	context.getCounter("osm-counters", "relations").increment(1);
            	mapRelation(context, tag);
            } else { 
            	// unknown tag 
            } 
        } catch (Exception e) {
            // maybe encoding error