本文整理汇总了Java中nu.xom.Node类的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于nu.xom包,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: advance
import nu.xom.Node; //导入依赖的package包/类
private NodeInfo advance() {
Node nextChild;
do {
if (forwards) {
if (cursor == par.getChildCount()) return null;
nextChild = par.getChild(cursor++);
} else { // backwards
if (cursor == 0) return null;
nextChild = par.getChild(--cursor);
}
} while (nextChild instanceof DocType);
// DocType is not an XPath node; can occur for /child::node()
NodeInfo curr = makeWrapper(nextChild, docWrapper, commonParent, ix);
ix += (forwards ? 1 : -1);
return curr;
}
示例2: prependCopy
import nu.xom.Node; //导入依赖的package包/类
@Override
public void prependCopy(XomNode node) throws XmlBuilderException {
final Node wrappedNode = node.getNode();
if (!(wrappedNode instanceof Element)) {
throw new XmlBuilderException("Unable to copy non-element node " + node);
}
final ParentNode parent = wrappedNode.getParent();
if (null == parent) {
throw new XmlBuilderException("Unable to prepend - no parent found of " + node);
}
try {
final int prependIndex = parent.indexOf(wrappedNode);
final Node copiedNode = wrappedNode.copy();
parent.insertChild(copiedNode, prependIndex);
} catch (IllegalAddException iae) {
throw new XmlBuilderException("Unable to append an copied element to " + parent, iae);
}
}
示例3: moveToParentBefore
import nu.xom.Node; //导入依赖的package包/类
public Node moveToParentBefore(
Node pTargetParentNode
, Node pMovingNode
, Node pPositionBeforeTargetParentsChildNode
) {
// mDocControl in context of pTargetParentNode
mDocControl.setDocumentModifiedCount();
//If this is being moved FROM another document, update the FROM document's modified count
if(pMovingNode.getDocument() != pTargetParentNode.getDocument()){
DocControl.setDocumentModified(pMovingNode);
}
// The SiblingChild should already be attached to Parent element - so this is belt & braces check
if (pPositionBeforeTargetParentsChildNode != null && pPositionBeforeTargetParentsChildNode.getParent() != pTargetParentNode) {
throw new ExInternal("insertBefore error, the sibling is not a child of this node");
}
//Detach from parent
pMovingNode.detach();
int lTargetPosition = ((ParentNode) pTargetParentNode).indexOf(pPositionBeforeTargetParentsChildNode);
((ParentNode) pTargetParentNode).insertChild(pMovingNode, lTargetPosition);
return pMovingNode;
}
示例4: hasParentTask
import nu.xom.Node; //导入依赖的package包/类
public boolean hasParentTask(String id) {
Element t = getTaskElement(id);
Node parentNode = t.getParent();
if (parentNode instanceof Element) {
Element parent = (Element) parentNode;
if (parent.getLocalName().equalsIgnoreCase("task")) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
示例5: updateProject
import nu.xom.Node; //导入依赖的package包/类
protected static void updateProject(Element importProject, Element homeProject, boolean override) throws Exception {
UpdateLogsParameter timeLogParam = UpdateLogsParameter.GetTimeLogParameter(homeProject, importProject, override);
UpdateLogsParameter defectLogParam = UpdateLogsParameter.GetDefectLogParameter(homeProject, importProject, override);
updateLogs(timeLogParam);
updateLogs(defectLogParam);
updateEstimates(homeProject, importProject, override);
Element importLocElement = importProject.getFirstChildElement(LocManager.ELEMENT_NAME);
if (importLocElement != null) {
int locValue = Integer.valueOf(importLocElement.getValue()); // valid test
Element homeLocElement = homeProject.getFirstChildElement(LocManager.ELEMENT_NAME);
Node newNode = importLocElement.copy();
if (homeLocElement != null) {
homeLocElement.getParent().appendChild(newNode);
homeLocElement.getParent().removeChild(homeLocElement);
} else {
homeProject.appendChild(newNode);
}
}
}
示例6: hasParentTask
import nu.xom.Node; //导入依赖的package包/类
/**
* @see net.sf.memoranda.TaskList#hasParentTask(String)
*/
public boolean hasParentTask(String id) {
Element t = getTaskElement(id);
Node parentNode = t.getParent();
if (parentNode instanceof Element) {
Element parent = (Element) parentNode;
if (parent.getLocalName().equalsIgnoreCase("task")) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
示例7: process
import nu.xom.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 XomNode<?> node;
if (xmlNode instanceof Document) {
node = new XomDocument((Document) xmlNode);
} else if (xmlNode instanceof Element) {
node = new XomElement((Element) xmlNode);
} else if (xmlNode instanceof Attribute) {
node = new XomAttribute((Attribute) xmlNode);
} else {
throw new IllegalArgumentException("XML node type is not supported");
}
final Navigator<XomNode> navigator = new XomNavigator(xmlNode);
for (Effect effect : effects) {
effect.perform(navigator, node);
}
return xml;
}
示例8: hasParentTimeLogs
import nu.xom.Node; //导入依赖的package包/类
@Override
public boolean hasParentTimeLogs(String id) {
Element t = getTimeLogElement(id);
Node parentNode = t.getParent();
if (parentNode instanceof Element) {
Element parent = (Element) parentNode;
if (parent.getLocalName().equalsIgnoreCase("timelog")) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
示例9: getNode
import nu.xom.Node; //导入依赖的package包/类
public static Node getNode(Document doc, String entityType, String entityName) {
String query = createQueryStringByName(entityType, entityName);
Nodes nodes = doc.query(query);
if (nodes != null && nodes.size() > 0) {
return nodes.get(0);
}
return null;
}
示例10: hasParentTask
import nu.xom.Node; //导入依赖的package包/类
@Override
public boolean hasParentTask(String id) {
Element t = getTaskElement(id);
Node parentNode = t.getParent();
if (parentNode instanceof Element) {
Element parent = (Element) parentNode;
if (parent.getLocalName().equalsIgnoreCase("task")) {
return true;
} else {
return false;
}
} else {
return false;
}
}
示例11: getBoolean
import nu.xom.Node; //导入依赖的package包/类
public static Boolean getBoolean(String xpath, Node node)
{
String value = getString(xpath, node);
if (StringUtils.isNotBlank(value))
{
if (ArrayUtils.contains(booleanValues, value.toLowerCase()))
{
if (StringUtils.isNumeric(value))
{
return Boolean.valueOf("1".equals(value));
}
}
else
{
throw new XPathValueConvertException(value);
}
return Boolean.valueOf(value);
}
return null;
}
示例12: getDateTime
import nu.xom.Node; //导入依赖的package包/类
public static DateTime getDateTime(String xpath, String format, Node node)
{
String value = getString(xpath, node);
if (StringUtils.isNotBlank(value))
{
try
{
return DateHelper.toDateTime(value, format);
}
catch (Exception e)
{
throw new XPathValueConvertException(e, value);
}
}
return null;
}
示例13: getLong
import nu.xom.Node; //导入依赖的package包/类
public static Long getLong(String xpath, Node node)
{
String value = getString(xpath, node);
if (StringUtils.isNotBlank(value))
{
try
{
return Long.valueOf(value);
}
catch (Exception e)
{
throw new XPathValueConvertException(e, value);
}
}
return null;
}
示例14: getDate
import nu.xom.Node; //导入依赖的package包/类
public static Date getDate(String xpath, String format, Node node)
{
String value = getString(xpath, node);
if (StringUtils.isNotBlank(value))
{
try
{
return DateHelper.toDate(value, format);
}
catch (Exception e)
{
throw new XPathValueConvertException(e, value);
}
}
return null;
}
示例15: getBool
import nu.xom.Node; //导入依赖的package包/类
public static boolean getBool(String xpath, Node node)
{
String value = getString(xpath, node);
if (StringUtils.isNotBlank(value))
{
if (ArrayUtils.contains(booleanValues, value.toLowerCase()))
{
if (StringUtils.isNumeric(value))
{
return "1".equals(value);
}
}
else
{
throw new XPathValueConvertException(value);
}
return Boolean.parseBoolean(value);
}
return false;
}