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


Java XmlCursor.toFirstContentToken方法代码示例

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


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

示例1: createFromXmlObject

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
static XML createFromXmlObject(XMLLibImpl lib, XmlObject xo)
{
    XScriptAnnotation anno;
    XmlCursor curs = xo.newCursor();
    if (curs.currentTokenType().isStartdoc())
    {
        curs.toFirstContentToken();
    }
    try {
        anno = new XScriptAnnotation(curs);
        curs.setBookmark(anno);
    } finally {
        curs.dispose();
    }
    return new XML(lib, anno);
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:17,代码来源:XML.java

示例2: 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

示例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: 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

示例5: remove

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 */
void remove ()
{
    XmlCursor childCurs = newCursor();

    if (childCurs.currentTokenType().isStartdoc())
    {
        // Remove on the document removes all children.
        TokenType tt = childCurs.toFirstContentToken();
        while (!tt.isEnd() && !tt.isEnddoc())
        {
            removeToken(childCurs);
            tt = childCurs.currentTokenType();      // Now see where we're pointing after the delete -- next token.
        }
    }
    else
    {
            removeToken(childCurs);
    }

    childCurs.dispose();
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:25,代码来源:XML.java

示例6: appendChild

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param xml
 * @return
 */
XML appendChild(Object xml)
{
    XmlCursor curs = newCursor();

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

    // Move the cursor to the end of this element
    if (curs.isStart())
    {
        curs.toEndToken();
    }

    insertChild(curs, xml);

    curs.dispose();

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

示例7: copy

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @return
 */
Object copy()
{
    XmlCursor srcCurs = newCursor();

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

    XML xml = createEmptyXML(lib);

    XmlCursor destCurs = xml.newCursor();
    destCurs.toFirstContentToken();

    srcCurs.copyXml(destCurs);

    destCurs.dispose();
    srcCurs.dispose();

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

示例8: 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

示例9: localName

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @return
 */
String localName()
{
    XmlCursor cursor = newCursor();
    if (cursor.isStartdoc())
        cursor.toFirstContentToken();

    String name = null;

    if(cursor.isStart() ||
       cursor.isAttr() ||
       cursor.isProcinst())
    {
        javax.xml.namespace.QName qname = cursor.getName();
        name = qname.getLocalPart();
    }
    cursor.dispose();

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

示例10: prependChild

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param xml
 * @return
 */
XML prependChild (Object xml)
{
    XmlCursor curs = newCursor();

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

    // Move the cursor to the first content token
    curs.toFirstContentToken();

    insertChild(curs, xml);

    curs.dispose();

    return this;
}
 
开发者ID:CyboticCatfish,项目名称:code404,代码行数:24,代码来源:XML.java

示例11: 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:CyboticCatfish,项目名称:code404,代码行数:26,代码来源:XML.java

示例12: removeToken

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param curs
 */
protected void removeToken (XmlCursor curs)
{
    XmlObject xo = XmlObject.Factory.newInstance();

    // Don't delete anything move to another document so it gets orphaned nicely.
    XmlCursor tmpCurs = xo.newCursor();
    tmpCurs.toFirstContentToken();


    curs.moveXml(tmpCurs);

    tmpCurs.dispose();
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:18,代码来源:XML.java

示例13: changeNS

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
protected void changeNS (String oldURI, String newURI)
{
    XmlCursor curs = newCursor();
    while (curs.toParent()) {
      /* Goto the top of the document */
    }

    TokenType tt = curs.currentTokenType();
    if (tt.isStartdoc())
    {
        tt = curs.toFirstContentToken();
    }

    if (tt.isStart())
    {
        do
        {
            if (tt.isStart() || tt.isAttr() || tt.isNamespace())
            {
                javax.xml.namespace.QName currQName = curs.getName();
                if (oldURI.equals(currQName.getNamespaceURI()))
                {
                    curs.setName(new javax.xml.namespace.QName(newURI, currQName.getLocalPart()));
                }
            }

            tt = curs.toNextToken();
        } while (!tt.isEnddoc() && !tt.isNone());
    }

    curs.dispose();
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:33,代码来源:XML.java

示例14: setAttribute

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param attrName
 * @param value
 */
void setAttribute(XMLName xmlName, Object value)
{
    if (xmlName.uri() == null &&
        xmlName.localName().equals("*"))
    {
        throw ScriptRuntime.typeError("@* assignment not supported.");
    }

    XmlCursor curs = newCursor();

    String strValue = ScriptRuntime.toString(value);
    if (curs.currentTokenType().isStartdoc())
    {
        curs.toFirstContentToken();
    }

    javax.xml.namespace.QName qName;

    try
    {
        qName = new javax.xml.namespace.QName(xmlName.uri(), xmlName.localName());
    }
    catch(Exception e)
    {
        throw ScriptRuntime.typeError(e.getMessage());
    }

    if (!curs.setAttributeText(qName, strValue))
    {
        if (curs.currentTokenType().isStart())
        {
            // Can only add attributes inside of a start.
            curs.toNextToken();
        }
        curs.insertAttributeWithValue(qName, strValue);
    }

    curs.dispose();
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:45,代码来源:XML.java

示例15: namespace

import org.apache.xmlbeans.XmlCursor; //导入方法依赖的package包/类
/**
 *
 * @param prefix
 * @return
 */
Object namespace(String prefix)
{
    XmlCursor cursor = newCursor();
    if (cursor.isStartdoc())
    {
        cursor.toFirstContentToken();
    }

    Object result = null;

    if (prefix == null)
    {
        if(cursor.isStart() ||
           cursor.isAttr())
        {
            Object[] inScopeNS = NamespaceHelper.inScopeNamespaces(lib, cursor);
            // XXX Is it reaaly necessary to create the second cursor?
            XmlCursor cursor2 = newCursor();
            if (cursor2.isStartdoc())
                cursor2.toFirstContentToken();

            result = NamespaceHelper.getNamespace(lib, cursor2, inScopeNS);

            cursor2.dispose();
        }
    }
    else
    {
        Map prefixToURI = NamespaceHelper.getAllNamespaces(lib, cursor);
        String uri = (String)prefixToURI.get(prefix);
        result = (uri == null) ? Undefined.instance : new Namespace(lib, prefix, uri);
    }

    cursor.dispose();

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


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