Package org.exolab.castor.types

Examples of org.exolab.castor.types.AnyNode


            for (int i = 0; i < dmdSecs.length; i++) {
                if ("dmdSec_fullRecordLink".equals(dmdSecs[i].getID())) {
                    fullLinkDmd = dmdSecs[i];
                } else {
                    if (dmdSecs[i].getMdWrap().getXmlData().getAnyObjectCount() == 1) {
                        AnyNode anyNode = (AnyNode) dmdSecs[i].getMdWrap().getXmlData()
                                .getAnyObject(0);
                        int type = dmdSecs[i].getMdWrap().getMDTYPE().getType();
                        DescriptiveMetadata dmd = new DescriptiveMetadata(anyNode, type);
                        String id = dmdSecs[i].getID();
                        dmdMap.put(id, dmd);
View Full Code Here


            for (int i = 0; i < dmdSecs.length; i++) {
                if ("dmdSec_fullRecordLink".equals(dmdSecs[i].getID())) {
                    fullLinkDmd = dmdSecs[i];
                } else {
                    if (dmdSecs[i].getMdWrap().getXmlData().getAnyObjectCount() == 1) {
                        AnyNode anyNode = (AnyNode) dmdSecs[i].getMdWrap().getXmlData()
                                .getAnyObject(0);
                        int type = dmdSecs[i].getMdWrap().getMDTYPE().getType();
                        DescriptiveMetadata dmd = new DescriptiveMetadata(anyNode, type);
                        String id = dmdSecs[i].getID();
                        dmdMap.put(id, dmd);
View Full Code Here

        if (_elements.search(node) >= 0) return;
        else _elements.push(node);

        if (node.getNodeType() == AnyNode.ELEMENT) {
            //the first sibling node of the current one
            AnyNode siblingNode = node.getNextSibling();

            String name = node.getLocalName();

            //-- retrieve the attributes and handle them
            AttributeListImpl atts = new AttributeListImpl();
            AnyNode tempNode = node.getFirstAttribute();
            String xmlName = null;
            String value = null;
            while (tempNode != null) {
                xmlName = tempNode.getLocalName();
                value = tempNode.getStringValue();
                atts.addAttribute(xmlName, null, value);
                tempNode = tempNode.getNextSibling();
            }//attributes

            //-- namespace management
            _context = _context.createNamespaces();
            String nsPrefix = node.getNamespacePrefix();
            String nsURI = node.getNamespaceURI();

             //-- retrieve the namespaces declaration and handle them
            tempNode = node.getFirstNamespace();
            String prefix = null;
            while (tempNode != null) {
                prefix = tempNode.getNamespacePrefix();
                value = tempNode.getNamespaceURI();
                if (value != null && value.length() >0)
                    _context.addNamespace(prefix, value);
                tempNode = tempNode.getNextSibling();
             }//namespaceNode


            String qName = null;
            //maybe the namespace is already bound to a prefix in the
            //namespace context
            if (nsURI != null && nsURI.length() > 0) {
                String tempPrefix = _context.getNamespacePrefix(nsURI);
                if (tempPrefix != null)
                    nsPrefix = tempPrefix;
                else {
                    _context.addNamespace(nsPrefix, nsURI);
                }
            }


            if (nsPrefix != null) {
                int len = nsPrefix.length();
                if (len > 0) {
                    StringBuffer sb = new StringBuffer(len+name.length()+1);
                    sb.append(nsPrefix);
                    sb.append(':');
                    sb.append(name);
                    qName = sb.toString();
                } else qName = name;
            } else {
                qName = name;
            }

             try {
                 _context.declareAsAttributes(atts,true);
                 handler.startElement(qName, atts);
             } catch (SAXException sx) {
                  throw new SAXException(sx);
             }

             //-- handle child&daughter elements
             tempNode = node.getFirstChild();
             while (tempNode != null) {
                 processAnyNode(tempNode, handler);
                 tempNode = tempNode.getNextSibling();
             }

             //-- finish element
             try {
               handler.endElement(qName);
View Full Code Here

     * @param namespace the namespace of the element.
    **/
    public void endElement(String name, String namespace)
        throws XMLException
    {
        AnyNode node = (AnyNode)_nodes.pop();
        if (_nodes.isEmpty()) {
            //-- add to appInfo
            _appInfo.add(node);
        }
        else {
View Full Code Here

    public void characters(char[] ch, int start, int length)
        throws XMLException
    {
        //-- Do delagation if necessary
        AnyNode text = new AnyNode(AnyNode.TEXT,
                                   null,  //-- no local name for text nodes
                                   null,  //-- no prefix
                                   null,  //-- no namespace
                                   new String(ch, start, length));
                                  
        if (!_nodes.isEmpty()) {
            AnyNode parent = (AnyNode)_nodes.peek();
            parent.addChild(text);
        }
        else {
            _appInfo.add(text);
        }
       
View Full Code Here

     * @param namespace the namespace of the element.
    **/
    public void endElement(String name, String namespace)
        throws XMLException
    {
        AnyNode node = (AnyNode)_nodes.pop();
        if (_nodes.isEmpty()) {
            //-- add to appInfo
            _documentation.add(node);
        }
        else {
View Full Code Here

    public void characters(char[] ch, int start, int length)
        throws XMLException
    {
        //-- Do delagation if necessary
        AnyNode text = new AnyNode(AnyNode.TEXT,
                                   null,  //-- no local name for text nodes
                                   null,  //-- no prefix
                                   null,  //-- no namespace
                                   new String(ch, start, length));
                                  
        if (!_nodes.isEmpty()) {
            AnyNode parent = (AnyNode)_nodes.peek();
            parent.addChild(text);
        }
        else {
            _documentation.add(text);
        }
       
View Full Code Here

    }
    //-------------------------------------------------

    //--Namespace related (SAX2 Events)
    public void startPrefixMapping(String prefix, String uri) throws SAXException {
        AnyNode temp = new AnyNode(AnyNode.NAMESPACE, null, prefix, uri, null);
        _namespaces.push(temp);
    }
View Full Code Here

           throws SAXException
    {
        _character = false;
        String qName;
        String value;
        AnyNode tempNode = null;

        //Namespace handling code to be moved once we integrate
        //the new event API
        /////////////////NAMESPACE HANDLING/////////////////////
        _context = _context.createNamespaces();
        String prefix = "";
        String namespaceURI = null;
        int idx = name.indexOf(':');
        if (idx >= 0) {
             prefix = name.substring(0,idx);
        }
        namespaceURI = _context.getNamespaceURI(prefix);
        //--Overhead here since we process attributes twice
        for (int i=0; i<atts.getLength(); ++i) {
            qName = atts.getName(i);
            value = atts.getValue(i);
            String nsPrefix = null;

            if (qName.startsWith(XMLNS_PREFIX)) {
                //handles namespace declaration
                // Extract the prefix if any
                nsPrefix = (qName.equals(XMLNS_PREFIX))?null:qName.substring(XMLNS_PREFIX_LENGTH);
                tempNode = new AnyNode(AnyNode.NAMESPACE, getLocalPart(qName), nsPrefix, value, null);
                _context.addNamespace(nsPrefix, value);
                _namespaces.push(tempNode);
                if (prefix.equals(nsPrefix))
                    namespaceURI = value;
            }
        }
        ////////////////////////END OF NAMESPACE HANDLING///////////////

        createNodeElement(namespaceURI, getLocalPart(name), name);
        while (!_namespaces.empty()) {
           tempNode = (AnyNode)_namespaces.pop();
           _node.addNamespace(tempNode);
        }

        //process attributes
        for (int i=0; i<atts.getLength(); ++i) {

            qName = atts.getName(i);
            value = atts.getValue(i);

            //Namespace handling already done
            if (!qName.startsWith(XMLNS_PREFIX)) {
                tempNode = new AnyNode(AnyNode.ATTRIBUTE, getLocalPart(qName), null, null, value);
                _node.addAttribute(tempNode);
            }
        }
        tempNode = null;
    }
View Full Code Here

          throws SAXException
    {
        createNodeElement(namespaceURI, localName, qName);
        //empty the namespaces stack
        //that must have been filled by startPrefixMapping()
        AnyNode tempNode = null;
        while (!_namespaces.empty()) {
           tempNode = (AnyNode)_namespaces.pop();
           _node.addNamespace(tempNode);
        }
        //process attributes
        for (int i=0; i<atts.getLength(); ++i) {

            String uri       = atts.getURI(i);
            String qname     = atts.getQName(i);
            String localname = atts.getLocalName(i);
            String value     = atts.getValue(i);
            tempNode = new AnyNode(AnyNode.ATTRIBUTE, localname, null, uri, value);
            _node.addAttribute(tempNode);
        }
        tempNode = null;
    }
View Full Code Here

TOP

Related Classes of org.exolab.castor.types.AnyNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.