当前位置: 首页>>代码示例>>Java>>正文


Java XmlCursor.TokenType方法代码示例

本文整理汇总了Java中org.apache.xmlbeans.XmlCursor.TokenType方法的典型用法代码示例。如果您正苦于以下问题:Java XmlCursor.TokenType方法的具体用法?Java XmlCursor.TokenType怎么用?Java XmlCursor.TokenType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.xmlbeans.XmlCursor的用法示例。


在下文中一共展示了XmlCursor.TokenType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tokenType

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @return
 */
XmlCursor.TokenType tokenType()
{
    XmlCursor.TokenType result;

    XmlCursor curs = newCursor();

    if (curs.isStartdoc())
    {
        curs.toFirstContentToken();
    }

    result = curs.currentTokenType();

    curs.dispose();

    return result;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:22,代码来源:XML.java

示例2: nodeKind

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @return
 */
Object nodeKind()
{
    String result;
    XmlCursor.TokenType tt = tokenType();

    if (tt == XmlCursor.TokenType.ATTR)
    {
        result = "attribute";
    }
    else if (tt == XmlCursor.TokenType.TEXT)
    {
        result = "text";
    }
    else if (tt == XmlCursor.TokenType.COMMENT)
    {
        result = "comment";
    }
    else if (tt == XmlCursor.TokenType.PROCINST)
    {
        result = "processing-instruction";
    }
    else if (tt == XmlCursor.TokenType.START)
    {
        result = "element";
    }
    else
    {
        // A non-existant node has the nodeKind() of text
        result = "text";
    }

    return result;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:38,代码来源:XML.java

示例3: doPut

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param currXMLNode
 * @param xmlValue
 * @return
 */
private boolean doPut(XMLName name, XML currXMLNode, XMLObjectImpl xmlValue)
{
    boolean result = false;
    XmlCursor curs = currXMLNode.newCursor();

    try
    {
        // Replace the node with this new xml value.
        XML xml;

        int toAssignLen = xmlValue.length();

        for (int i = 0; i < toAssignLen; i++)
        {
            if (xmlValue instanceof XMLList)
            {
                xml = ((XMLList) xmlValue).item(i);
            }
            else
            {
                xml = (XML) xmlValue;
            }

            // If it's an attribute or text node, make text node.
            XmlCursor.TokenType tt = xml.tokenType();
            if (tt == XmlCursor.TokenType.ATTR || tt == XmlCursor.TokenType.TEXT)
            {
                xml = makeXmlFromString(lib, name, xml.toString());
            }

            if (i == 0)
            {
                // 1st assignment is replaceChild all others are appendChild
                replace(curs, xml);
            }
            else
            {
                insertChild(curs, xml);
            }
        }

        // We're done we've blown away the node because the rvalue was XML...
        result = true;
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
        throw ScriptRuntime.typeError(ex.getMessage());
    }
    finally
    {
        curs.dispose();
    }

    return result;
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:63,代码来源:XML.java

示例4: equivalentXml

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
     *
     * @param target
     * @return
     */
    boolean equivalentXml(Object target)
    {
        boolean result = false;

        if (target instanceof XML)
        {
            XML otherXml = (XML) target;

            // Compare with toString() if either side is text node or attribute
            // otherwise compare as XML
            XmlCursor.TokenType thisTT = tokenType();
            XmlCursor.TokenType otherTT = otherXml.tokenType();
            if (thisTT == XmlCursor.TokenType.ATTR || otherTT == XmlCursor.TokenType.ATTR ||
                thisTT == XmlCursor.TokenType.TEXT || otherTT == XmlCursor.TokenType.TEXT)
            {
                result = toString().equals(otherXml.toString());
            }
            else
            {
                XmlCursor cursOne = newCursor();
                XmlCursor cursTwo = otherXml.newCursor();

                result = LogicalEquality.nodesEqual(cursOne, cursTwo);

                cursOne.dispose();
                cursTwo.dispose();

// Old way of comparing by string.
//                boolean orgPrettyPrinting = prototype.prettyPrinting;
//                prototype.prettyPrinting = true;
//                result = toXMLString(0).equals(otherXml.toXMLString(0));
//                prototype.prettyPrinting = orgPrettyPrinting;
            }
        }
        else if (target instanceof XMLList)
        {
            XMLList otherList = (XMLList) target;

            if (otherList.length() == 1)
            {
                result = equivalentXml(otherList.getXmlFromAnnotation(0));
            }
        }
        else if (hasSimpleContent())
        {
            String otherStr = ScriptRuntime.toString(target);

            result = toString().equals(otherStr);
        }

        return result;
    }
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:58,代码来源:XML.java

示例5: matchChildren

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param tokenType
 * @return
 */
private XMLList matchChildren(XmlCursor.TokenType tokenType)
{
    return matchChildren(tokenType, XMLName.formStar());
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:10,代码来源:XML.java


注:本文中的org.apache.xmlbeans.XmlCursor.TokenType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。