當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.getNodeType方法代碼示例

本文整理匯總了Java中org.dom4j.Node.getNodeType方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getNodeType方法的具體用法?Java Node.getNodeType怎麽用?Java Node.getNodeType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.dom4j.Node的用法示例。


在下文中一共展示了Node.getNodeType方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRepeatingComplexSingletonChildName

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Gets the qualified element name of the repeatingComplexSingleton child of
 *  the node specified by the provided path, or an empty string if such a child
 *  does not exist.
 *
 * @param  xpath  NOT YET DOCUMENTED
 * @return        The repeatingComplexSingletonChildName value
 */
public String getRepeatingComplexSingletonChildName(String xpath) {
	String normalizedXPath = XPathUtils.normalizeXPath(xpath);
	Node instanceDocNode = getInstanceDocNode(normalizedXPath);
	if (instanceDocNode != null && instanceDocNode.getNodeType() == org.dom4j.Node.ELEMENT_NODE) {
		List children = ((Element) instanceDocNode).elements();
		if (children.size() == 1) {
			Element childElement = (Element) children.get(0);
			String childPath = childElement.getPath();
			SchemaNode schemaNode = getSchemaNode(childPath);
			if (schemaNode != null && schemaNode.getTypeDef().isComplexType() && isRepeatingElement(childPath))
				return childElement.getQualifiedName();
		}
	}
	return "";
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:24,代碼來源:SchemaHelper.java

示例2: process

import org.dom4j.Node; //導入方法依賴的package包/類
@Override
public <T> T process(T xml, Iterable<Effect> effects) throws XmlBuilderException {
    if (!canHandle(xml)) {
        throw new IllegalArgumentException("XML model is not supported");
    }
    final Node xmlNode = (Node) xml;
    final Dom4jNode<?> node;
    switch (xmlNode.getNodeType()) {
        case Node.DOCUMENT_NODE:
            node = new Dom4jDocument((Document) xmlNode);
            break;
        case Node.ELEMENT_NODE:
            node = new Dom4jElement((Element) xmlNode);
            break;
        case Node.ATTRIBUTE_NODE:
            node = new Dom4jAttribute((Attribute) xmlNode);
            break;
        default:
            throw new IllegalArgumentException("XML node type is not supported");
    }
    final Navigator<Dom4jNode> navigator = new Dom4jNavigator(xmlNode);
    for (Effect effect : effects) {
        effect.perform(navigator, node);
    }
    return xml;
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:27,代碼來源:Dom4jNavigatorSpi.java

示例3: hasChildren

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Return true if the specified node is an Element and has either a
 *  sub-element, or an attribute (even if they are empty), OR content.
 *
 * @param  xpath  xpath to the node to be evaluated for children
 * @return        true if sub-elements, or attributes, false otherwise or if
 *      node is not an Element
 */
public boolean hasChildren(String xpath) {
	// prtln ("\nhasChildren: " + xpath);
	if (xpath == null || xpath.trim().length() == 0)
		return false;
	Node node = doc.selectSingleNode(xpath);
	if (node == null) {
		prtlnErr("\thasChildren() could not find node: (" + xpath + ")");
		return false;
	}

	if (node.getNodeType() != Node.ELEMENT_NODE) {
		prtlnErr("hasChildern() called with an non-Element - returning false");
		return false;
	}

	Element e = (Element) node;

	// we used to check for "hasText" but why would we want to do that here???
	/*
		We DO want to check in the case of an element that can contain text which ALSO
		has attributes. So we can do this check IF the typeDef is the right kind ...
	*/
	boolean hasText = (e.getTextTrim() != null && e.getTextTrim().length() > 0);
	if (hasText)
		return true;

	return (e.elements().size() > 0 ||
		e.attributeCount() > 0);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:38,代碼來源:DocMap.java

示例4: isEmpty

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Returns true if an element (recursively) has no textual content, no
 *  children, and no attributes with values.<p>
 *
 *  Note: returns FALSE if no node exists at the given path.
 *
 * @param  xpath  Description of the Parameter
 * @return        true if empty, false if any errors are encountered
 */
public boolean isEmpty(String xpath) {
	Node node = doc.selectSingleNode(xpath);
	String msg = "";

	// return FALSE if a node is not found (this is kind of a wierd convention?)
	if (node == null) {
		msg = " ... couldn't find node at " + xpath + " returning FALSE";
		// prtlnErr(msg);
		return false;
	}

	if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
		String content = node.getText();
		// return (content == null || content.trim().length() == 0);

		// 2/28/07 - no longer ignore whitespace!
		return (content == null || content.length() == 0);
	}

	if (node.getNodeType() != Node.ELEMENT_NODE) {
		msg = "  ...  called with an unknown type of node - returning false";
		// prtlnErr(msg);
		return false;
	}

	boolean ret = Dom4jUtils.isEmpty((Element) node);
	return ret;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:38,代碼來源:DocMap.java

示例5: getNodeExistsWithRequiredAttribute

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Return true if the node specified by key exists in the instance document
 *  and it has a required attribute in the instance document.
 *
 * @param  key  a jsp-encoded xpath
 * @return      The nodeExistsWithRequiredAttribute value
 */
public String getNodeExistsWithRequiredAttribute(String key) {
	String xpath = XPathUtils.decodeXPath(key);
	Node node = docMap.selectSingleNode(xpath);
	if (node == null) {
		return FALSE;
	}
	if (node.getNodeType() != Node.ELEMENT_NODE) {
		return FALSE;
	}
	Element element = (Element) node;
	if (element.attributes().isEmpty()) {
		return FALSE;
	}

	/* check attributes for a required one */
	for (Iterator i = element.attributeIterator(); i.hasNext(); ) {
		Attribute attribute = (Attribute) i.next();
		String attPath = xpath + "/@" + attribute.getQualifiedName();
		SchemaNode schemaNode = this.schemaHelper.getSchemaNode(attPath);
		if (schemaNode == null) {
			// prtln ("schemaNode not found for attribute (" + attPath + ")");
			continue;
		}
		if (schemaNode.isRequired())
			return TRUE;
	}
	return FALSE;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:36,代碼來源:SchemEditForm.java

示例6: prependCopy

import org.dom4j.Node; //導入方法依賴的package包/類
@Override
public void prependCopy(Dom4jNode node) throws XmlBuilderException {
    final Node wrappedNode = node.getNode();
    if (Node.ELEMENT_NODE != wrappedNode.getNodeType()) {
        throw new XmlBuilderException("Unable to copy non-element node " + node);
    }
    final Element parent = wrappedNode.getParent();
    if (null == parent) {
        throw new XmlBuilderException("Unable to prepend - no parent found of " + node);
    }
    final int prependIndex = parent.indexOf(wrappedNode);
    final Element copiedNode = ((Element) wrappedNode).createCopy();
    parent.elements().add(prependIndex, copiedNode);
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:15,代碼來源:Dom4jNavigator.java

示例7: saveXML

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 * Сохраним измененные параметры в XML
 */
private void saveXML() {
    if (params != null) {
        if (Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FRACTAL).size()
            > 0) {
            Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FRACTAL).get(0)
                .addAttribute(Uses.TAG_BOARD_VALUE, tfFRactal.getText());
        }
        Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_RUNNING_TEXT).get(0)
            .addAttribute(Uses.TAG_BOARD_VALUE, textFieldRunning.getText());
        Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FON_IMG).get(0)
            .addAttribute(Uses.TAG_BOARD_VALUE, textFieldPict.getText());
        // удалить предыдущие узды CDATA
        for (int i = 0; i < params.nodeCount(); i++) {
            final Node node = params.node(i);
            if (node.getNodeType() == Node.CDATA_SECTION_NODE) {
                params.remove(node);
            }
        }
        final String str = textAreaHtml.getText();
        if (!"".equals(str)) {
            params.addCDATA(str);
        }
        Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_VIDEO_FILE).get(0)
            .addAttribute(Uses.TAG_BOARD_VALUE, textFieldVideo.getText());
        Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FONT_SIZE).get(0)
            .addAttribute(Uses.TAG_BOARD_VALUE,
                String.valueOf((Integer) spinnerFontSize.getValue()));
        Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_SPEED_TEXT).get(0)
            .addAttribute(Uses.TAG_BOARD_VALUE,
                String.valueOf((Integer) spinnerSpeed.getValue()));
        Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_FONT_COLOR).get(0)
            .addAttribute(Uses.TAG_BOARD_VALUE, textFieldFontColor.getText());
        Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_SIMPLE_DATE).get(0)
            .addAttribute(Uses.TAG_BOARD_VALUE, checkBoxDate.isSelected() ? "1" : "0");
        Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_GRID_NEXT).get(0)
            .addAttribute(Uses.TAG_BOARD_VALUE, checkBoxGridNext.isSelected() ? "1" : "0");
        Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_GRID_NEXT_COLS).get(0)
            .addAttribute(Uses.TAG_BOARD_VALUE,
                String.valueOf((Integer) spinnerGridNextCols.getValue()));
        Uses.elementsByAttr(params, Uses.TAG_BOARD_NAME, Uses.TAG_BOARD_GRID_NEXT_ROWS).get(0)
            .addAttribute(Uses.TAG_BOARD_VALUE,
                String.valueOf((Integer) spinnerGridNextRows.getValue()));

    }
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:49,代碼來源:FBoardParams.java


注:本文中的org.dom4j.Node.getNodeType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。