All Downloads are FREE. Search and download functionalities are using the official Maven repository.

soot.jimple.infoflow.android.axml.parsers.AbstractBinaryXMLFileParser Maven / Gradle / Ivy

There is a newer version: 2.14.1
Show newest version
package soot.jimple.infoflow.android.axml.parsers;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import soot.jimple.infoflow.android.axml.AXmlDocument;
import soot.jimple.infoflow.android.axml.AXmlNode;

/**
 * Abstract base class for all binary XML file parsers
 * 
 * @author Steven Arzt
 */
public abstract class AbstractBinaryXMLFileParser implements IBinaryXMLFileParser {

	/**
	 * Map containing lists of nodes sharing the same tag.
	 * The tag is the key to access the list.
	 */
	protected HashMap> nodesWithTag = new HashMap>();

	/**
	 * The xml document.
	 */
	protected AXmlDocument document = new AXmlDocument();
	
	/**
	 * Adds a pointer to the given node with the key tag.  
	 * 
	 * @param	tag		the node's tag
	 * @param	node	the node being pointed to
	 */
	protected void addPointer(String tag, AXmlNode node) {
		if(!this.nodesWithTag.containsKey(tag)) this.nodesWithTag.put(tag, new ArrayList());
		this.nodesWithTag.get(tag).add(node);
	}
	
	@Override
	public AXmlDocument getDocument() {
		return this.document;
	}
	
	@Override
	public List getNodesWithTag(String tag) {
		if(this.nodesWithTag.containsKey(tag))
			return new ArrayList(this.nodesWithTag.get(tag));
		else
			return Collections.emptyList();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy