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


Java XmlCursor.isText方法代码示例

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


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

示例1: hasSimpleContent

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @return
 */
boolean hasSimpleContent()
{
    boolean simpleContent = false;

    XmlCursor curs = newCursor();

    if (curs.isAttr() || curs.isText()) {
        return true;
    }

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

    simpleContent = !(curs.toFirstChild());

    curs.dispose();

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

示例2: setLocalName

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param name
 */
void setLocalName(String localName)
{
    XmlCursor cursor = newCursor();

    try
    {
        if(cursor.isStartdoc())
            cursor.toFirstContentToken();

        if(cursor.isText() || cursor.isComment()) return;


        javax.xml.namespace.QName qname = cursor.getName();
        cursor.setName(new javax.xml.namespace.QName(
            qname.getNamespaceURI(), localName, qname.getPrefix()));
    }
    finally
    {
        cursor.dispose();
    }
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:26,代码来源:XML.java

示例3: setNamespace

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param ns
 */
void setNamespace(Namespace ns)
{
    XmlCursor cursor = newCursor();

    try
    {
        if(cursor.isStartdoc())
            cursor.toFirstContentToken();

        if(cursor.isText() ||
           cursor.isComment() ||
           cursor.isProcinst()) return;

        String prefix = ns.prefix();
        if (prefix == null) {
            prefix = "";
        }
        cursor.setName(new javax.xml.namespace.QName(
            ns.uri(), localName(), prefix));
    }
    finally
    {
        cursor.dispose();
    }
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:30,代码来源:XML.java

示例4: toString

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @return
 */
public String toString()
{
    String result;
    XmlCursor curs = newCursor();

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

    if (curs.isText())
    {
         result = curs.getChars();
    }
    else if (curs.isStart() && hasSimpleContent())
    {
        result = curs.getTextValue();
    }
    else
    {
        result = toXMLString(0);
    }

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

示例5: nextToken

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 * filter out empty textNodes here
 *
 * @param xml
 */
private static void nextToken(XmlCursor xml)
{
    do
    {
        xml.toNextToken();

        if (!xml.isText())
        {
            // Not a text node
            break;
        }
        else if (xml.getChars().trim().length() > 0)
        {
            // Text node is not empty
            break;
        }
    }
    while (true);
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:25,代码来源:LogicalEquality.java

示例6: dumpNode

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param cursor
 * @param opts
 * @return
 */
private static String dumpNode(XmlCursor cursor, XmlOptions opts)
{
    if (cursor.isText())
        return cursor.getChars();

    if (cursor.isFinish())
        return "";

    cursor.push();
    boolean wanRawText = cursor.isStartdoc() && !cursor.toFirstChild();
    cursor.pop();

    return wanRawText ? cursor.getTextValue() : cursor.xmlText( opts );
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:21,代码来源:XML.java

示例7: setName

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param name
 */
void setName(QName qname)
{
    XmlCursor cursor = newCursor();

    try
    {
        if(cursor.isStartdoc())
            cursor.toFirstContentToken();

        if(cursor.isText() || cursor.isComment()) return;

        if(cursor.isProcinst())
        {
            String localName = qname.localName();
            cursor.setName(new javax.xml.namespace.QName(localName));
        }
        else
        {
            String prefix = qname.prefix();
            if (prefix == null) { prefix = ""; }
            cursor.setName(new javax.xml.namespace.QName(
                qname.uri(), qname.localName(), prefix));
        }
    }
    finally
    {
        cursor.dispose();
    }
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:34,代码来源:XML.java

示例8: textNodesEqual

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param xmlOne
 * @param xmlTwo
 * @return
 */
private static boolean textNodesEqual(XmlCursor xmlOne, XmlCursor xmlTwo)
{
    boolean result = false;

    if (xmlOne.isText() && xmlTwo.isText())
    {
        if (xmlOne.getChars().equals(xmlTwo.getChars()))
        {
            result = true;
        }
    }

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

示例9: toXMLString

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @return
 */
String toXMLString(int indent)
{
    // XXX indent is ignored

    String result;

    XmlCursor curs = newCursor();

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

    try
    {
        if (curs.isText())
        {
            result = curs.getChars();
        }
        else if (curs.isAttr())
        {
            result = curs.getTextValue();
        }
        else if (curs.isComment() || curs.isProcinst())
        {
            result = XML.dumpNode(curs, getOptions());

            // todo: XBeans-dependent hack here
            // If it's a comment or PI, take off the xml-frament stuff
            String start = "<xml-fragment>";
            String end = "</xml-fragment>";

            if (result.startsWith(start))
            {
                result = result.substring(start.length());
            }

            if (result.endsWith(end))
            {
                result = result.substring(0, result.length() - end.length());
            }
        }
        else
        {
            result = XML.dumpNode(curs, getOptions());
        }
    }
    finally
    {
        curs.dispose();
    }

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

示例10: nodesEqual

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
public static boolean nodesEqual(XmlCursor xmlOne, XmlCursor xmlTwo)
{
    boolean result = false;

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

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

    if (xmlOne.currentTokenType() == xmlTwo.currentTokenType())
    {
        if (xmlOne.isEnddoc())
        {
            // Both empty
            result = true;
        }
        else if (xmlOne.isAttr())
        {
            result = attributesEqual(xmlOne, xmlTwo);
        }
        else if (xmlOne.isText())
        {
            result = textNodesEqual(xmlOne, xmlTwo);
        }
        else if (xmlOne.isComment())
        {
            result = commentsEqual(xmlOne, xmlTwo);
        }
        else if (xmlOne.isProcinst())
        {
            result = processingInstructionsEqual(xmlOne, xmlTwo);
        }
        else if (xmlOne.isStart())
        {
            // Compare root elements
            result = elementsEqual(xmlOne, xmlTwo);
        }
    }

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

示例11: elementsEqual

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
private static boolean elementsEqual(XmlCursor xmlOne, XmlCursor xmlTwo)
{
    boolean result = true;

    if (!qnamesEqual(xmlOne.getName(), xmlTwo.getName()))
    {
        result = false;
    }
    else
    {
        // These filter out empty text nodes.
        nextToken(xmlOne);
        nextToken(xmlTwo);

        do
        {
            if (xmlOne.currentTokenType() != xmlTwo.currentTokenType())
            {
                // Not same token
                result = false;
                break;
            }
            else if (xmlOne.isEnd())
            {
                // Done with this element, step over end
                break;
            }
            else if (xmlOne.isEnddoc())
            {
                // Shouldn't get here
                break;
            }
            else if (xmlOne.isAttr())
            {
                // This one will move us to the first non-attr token.
                result = attributeListsEqual(xmlOne, xmlTwo);
            }
            else
            {
                if (xmlOne.isText())
                {
                    result = textNodesEqual(xmlOne, xmlTwo);
                }
                else if (xmlOne.isComment())
                {
                    result = commentsEqual(xmlOne, xmlTwo);
                }
                else if (xmlOne.isProcinst())
                {
                    result = processingInstructionsEqual(xmlOne, xmlTwo);
                }
                else if (xmlOne.isStart())
                {
                    result = elementsEqual(xmlOne, xmlTwo);
                }
                else
                {
                    //XML.log("Unknown token type" + xmlOne.currentTokenType());
                }

                // These filter out empty text nodes.
                nextToken(xmlOne);
                nextToken(xmlTwo);
            }
        }
        while(result);
    }

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


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