Code example for Node

Methods: getNodeType

0
	/** 
	 * Returns the text region of given node. 
	 */ 
	public static IRegion getHyperlinkRegion(Node node) {
		if (node != null) {
			switch (node.getNodeType()) {
			case Node.DOCUMENT_TYPE_NODE:
			case Node.TEXT_NODE:
				IDOMNode docNode = (IDOMNode) node;
				return new Region(docNode.getStartOffset(), docNode.getEndOffset()
						- docNode.getStartOffset());
 
			case Node.ELEMENT_NODE:
				IDOMElement element = (IDOMElement) node;
				int endOffset;
				if (element.hasEndTag() && element.isClosed()) {
					endOffset = element.getStartEndOffset();
				} 
				else { 
					endOffset = element.getEndOffset();
				}