当前位置: 首页>>代码示例>>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;未经允许,请勿转载。