⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmllist.java

📁 javascript语言的解释器源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                    if (list.length() > 0)                    {                        xmlNode.replaceAll((XML)list.item(0));                        replace(index, (XML)list.item(0));                        for (int i = 1; i < list.length(); i++)                        {                            insert(index + i, (XML)list.item(i));                        }                    }                }            }            else            {                addToList(xmlValue);            }        }    }    /**     *     * @param name     */    void deleteXMLProperty(XMLName name)    {        for (int i = 0; i < length(); i++)        {            XML xml = getXmlFromAnnotation(i);            if (xml.tokenType() == XmlCursor.TokenType.START)            {                xml.deleteXMLProperty(name);            }        }    }    /**     *     * @param index     */    public void delete(int index)    {        if (index >= 0 && index < length())        {            XML xml = getXmlFromAnnotation(index);            xml.remove();            internalRemoveFromList(index);        }    }    /**     *     * @return     */    public Object[] getIds()    {        Object enumObjs[];        if (prototypeFlag)        {            enumObjs = new Object[0];        }        else        {            enumObjs = new Object[length()];            for (int i = 0; i < enumObjs.length; i++)            {                enumObjs[i] = new Integer(i);            }        }        return enumObjs;    }    /**     *     * @return     */    public Object[] getIdsForDebug()    {        return getIds();    }    // XMLList will remove will delete all items in the list (a set delete) this differs from the XMLList delete operator.    void remove ()    {        int nLen = length();        for (int i = nLen - 1; i >= 0; i--)        {            XML xml = getXmlFromAnnotation(i);            if (xml != null)            {                xml.remove();                internalRemoveFromList(i);            }        }    }    /**     *     * @param index     * @return     */    XML item (int index)    {        return _annos != null            ? getXmlFromAnnotation(index) : XML.createEmptyXML(lib);    }    /**     *     * @param name     * @param value     */    private void setAttribute (XMLName xmlName, Object value)    {        for (int i = 0; i < length(); i++)        {            XML xml = getXmlFromAnnotation(i);            xml.setAttribute(xmlName, value);        }    }    /**     *     * @param toAdd     */    void addToList(Object toAdd)    {        if (toAdd instanceof Undefined)        {            // Missing argument do nothing...            return;        }        if (toAdd instanceof XMLList)        {            XMLList xmlSrc = (XMLList)toAdd;            for (int i = 0; i < xmlSrc.length(); i++)            {                _annos.add(((XML)xmlSrc.item(i)).getAnnotation());            }        }        else if (toAdd instanceof XML)        {            _annos.add(((XML)(toAdd)).getAnnotation());        }        else if (toAdd instanceof XML.XScriptAnnotation)        {            _annos.add((XML.XScriptAnnotation)toAdd);        }    }    //    //    // Methods from section 12.4.4 in the spec    //    //    /**     *     * @param toAdd     */    XML addNamespace(Namespace ns)    {        if(length() == 1)        {            return getXmlFromAnnotation(0).addNamespace(ns);        }        else        {            throw ScriptRuntime.typeError("The addNamespace method works only on lists containing one item");        }    }    /**     *     * @param xml     * @return     */    XML appendChild(Object xml)    {        if (length() == 1)        {            return getXmlFromAnnotation(0).appendChild(xml);        }        else        {            throw ScriptRuntime.typeError("The appendChild method works only on lists containing one item");        }    }    /**     *     * @param attr     * @return     */    XMLList attribute(XMLName xmlName)    {        XMLList result = new XMLList(lib);        for (int i = 0; i < length(); i++)        {            XML xml = getXmlFromAnnotation(i);            result.addToList(xml.attribute(xmlName));        }        return result;    }    /**     *     * @return     */    XMLList attributes()    {        XMLList result = new XMLList(lib);        for (int i = 0; i < length(); i++)        {            XML xml = getXmlFromAnnotation(i);            result.addToList(xml.attributes());        }        return result;    }    XMLList child(long index)    {        XMLList result = new XMLList(lib);        for (int i = 0; i < length(); i++)        {            result.addToList(getXmlFromAnnotation(i).child(index));        }        return result;    }    XMLList child(XMLName xmlName)    {        XMLList result = new XMLList(lib);        for (int i = 0; i < length(); i++)        {            result.addToList(getXmlFromAnnotation(i).child(xmlName));        }        return result;    }    /**     *     * @return     */    int childIndex()    {        if (length() == 1)        {            return getXmlFromAnnotation(0).childIndex();        }        else        {            throw ScriptRuntime.typeError("The childIndex method works only on lists containing one item");        }    }    /**     *     * @return     */    XMLList children()    {        Vector v = new Vector();        for (int i = 0; i < length(); i++)        {            XML xml = getXmlFromAnnotation(i);            if (xml != null)            {                Object o = xml.children();                if (o instanceof XMLList)                {                    XMLList childList = (XMLList)o;                    int cChildren = childList.length();                    for (int j = 0; j < cChildren; j++)                    {                        v.addElement(childList.item(j));                    }                }            }        }        XMLList allChildren = new XMLList(lib);        int sz = v.size();        for (int i = 0; i < sz; i++)        {            allChildren.addToList(v.get(i));        }        return allChildren;    }    /**     *     * @return     */    XMLList comments()    {        XMLList result = new XMLList(lib);        for (int i = 0; i < length(); i++)        {            XML xml = getXmlFromAnnotation(i);            result.addToList(xml.comments());        }        return result;    }    /**     *     * @param xml     * @return     */    boolean contains(Object xml)    {        boolean result = false;        for (int i = 0; i < length(); i++)        {            XML member = getXmlFromAnnotation(i);            if (member.equivalentXml(xml))            {                result = true;                break;            }        }        return result;    }    /**     *     * @return     */    Object copy()    {        XMLList result = new XMLList(lib);        for (int i = 0; i < length(); i++)        {            XML xml = getXmlFromAnnotation(i);            result.addToList(xml.copy());        }        return result;    }    /**     *     * @return     */    XMLList descendants(XMLName xmlName)    {        XMLList result = new XMLList(lib);        for (int i = 0; i < length(); i++)        {            XML xml = getXmlFromAnnotation(i);            result.addToList(xml.descendants(xmlName));        }        return result;    }    /**     *     * @return     */    Object[] inScopeNamespaces()    {        if(length() == 1)        {            return getXmlFromAnnotation(0).inScopeNamespaces();        }        else        {            throw ScriptRuntime.typeError("The inScopeNamespaces method works only on lists containing one item");        }    }    /**     *     * @param child     * @param xml     */    XML insertChildAfter(Object child, Object xml)    {        if (length() == 1)        {            return getXmlFromAnnotation(0).insertChildAfter(child, xml);        }        else        {            throw ScriptRuntime.typeError("The insertChildAfter method works only on lists containing one item");        }    }    /**     *     * @param child     * @param xml     */    XML insertChildBefore(Object child, Object xml)    {        if (length() == 1)        {            return getXmlFromAnnotation(0).insertChildAfter(child, xml);        }        else        {            throw ScriptRuntime.typeError("The insertChildBefore method works only on lists containing one item");        }    }    /**     *     * @return     */    boolean hasOwnProperty(XMLName xmlName)    {        boolean hasProperty = false;        if (prototypeFlag)        {            String property = xmlName.localName();            hasProperty = (0 != findPrototypeId(property));        }        else        {            hasProperty = (getPropertyList(xmlName).length() > 0);        }        return hasProperty;    }    /**     *     * @return     */    boolean hasComplexContent()    {        boolean complexContent;        int length = length();        if (length == 0)        {            complexContent = false;        }        else if (length == 1)        {            complexContent = getXmlFromAnnotation(0).hasComplexContent();        }        else        {            complexContent = false;            for (int i = 0; i < length; i++)            {                XML nextElement = getXmlFromAnnotation(i);                if (nextElement.tokenType() == XmlCursor.TokenType.START)                {                    complexContent = true;                    break;                }            }        }        return complexContent;    }    /**     *     * @return     */    boolean hasSimpleContent()    {        boolean simpleContent;        int length = length();        if (length == 0)        {            simpleContent = true;        }        else if (length == 1)        {            simpleContent = getXmlFromAnnotation(0).hasSimpleContent();        }        else        {            simpleContent = true;            for (int i = 0; i < length; i++)            {                XML nextElement = getXmlFromAnnotation(i);                if (nextElement.tokenType() == XmlCursor.TokenType.START)                {                    simpleContent = false;                    break;                }            }        }        return simpleContent;    }    /**     *     * @return     */    int length()    {        int result = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -