Package javax.xml.stream.events

Examples of javax.xml.stream.events.Namespace


            return Collections.emptyMap();
        }

        LinkedHashMap<String,Namespace> m = new LinkedHashMap<String,Namespace>(1 + len + (len>>1));
        for (int i = 0; i < len; ++i) {
            Namespace ns = mNamespaces.get(i);
            String uri = ns.getNamespaceURI();
            if (uri == null) { // shouldn't happen but...
                uri = "";
            }
            m.put(uri, ns);
        }
View Full Code Here


                            n.getNamespaceURI());

        // Any namespaces?
        if (mNsDecls != null) {
            for (int i = 0, len = mNsDecls.size(); i < len; ++i) {
                Namespace ns = mNsDecls.get(i);
                String prefix = ns.getPrefix();
                String uri = ns.getNamespaceURI();
                if (prefix == null || prefix.length() == 0) {
                    sw.writeDefaultNamespace(uri);
                } else {
                    sw.writeNamespace(prefix, uri);
                }
View Full Code Here

        if (mNsDecls != null) {
            if (prefix == null) {
                prefix = "";
            }
            for (int i = 0, len = mNsDecls.size(); i < len; ++i) {
                Namespace ns = mNsDecls.get(i);
                String thisPrefix = ns.getPrefix();
                if (thisPrefix == null) {
                    thisPrefix = "";
                }
                if (prefix.equals(thisPrefix)) {
                    return ns.getNamespaceURI();
                }
            }
        }

        return null;
View Full Code Here

    {
        if (prefix == null) {
            throw new IllegalArgumentException("Illegal to pass null prefix");
        }
        for (int i = 0, len = mNamespaces.size(); i < len; ++i) {
            Namespace ns = mNamespaces.get(i);
            if (prefix.equals(ns.getPrefix())) {
                return ns.getNamespaceURI();
            }
        }
        // Not found; how about from parent?
        if (mParentCtxt != null) {
            String uri = mParentCtxt.getNamespaceURI(prefix);
View Full Code Here

        }
        /* Ok, first: if we can find it from within current namespaces,
         * we are golden:
         */
        for (int i = 0, len = mNamespaces.size(); i < len; ++i) {
            Namespace ns = mNamespaces.get(i);
            if (nsURI.equals(ns.getNamespaceURI())) {
                return ns.getPrefix();
            }
        }
        // If not, let's first try the easy way:
        if (mParentCtxt != null) {
            String prefix = mParentCtxt.getPrefix(nsURI);
View Full Code Here

        }

        // Any local bindings?
        ArrayList<String> l = null;
        for (int i = 0, len = mNamespaces.size(); i < len; ++i) {
            Namespace ns = mNamespaces.get(i);
            if (nsURI.equals(ns.getNamespaceURI())) {
                l = addToList(l, ns.getPrefix());
            }
        }

        // How about parent?
        if (mParentCtxt != null) {
View Full Code Here

                assertTrue("Not a end element", event.isEndElement());
                assertEquals("Invalid end event local name", REQUEST_ELEMENT,
                        event.asEndElement().getName().getLocalPart());
                assertEquals("Invalid end event namespace", NAMESPACE_URI,
                        event.asEndElement().getName().getNamespaceURI());
                Namespace namespace = eventFactory.createNamespace(NAMESPACE_URI);
                QName name = new QName(NAMESPACE_URI, RESPONSE_ELEMENT);
                eventWriter
                        .add(eventFactory.createStartElement(name, null, Collections.singleton(namespace).iterator()));
                eventWriter.add(eventFactory.createEndElement(name, Collections.singleton(namespace).iterator()));
                eventWriter.add(eventFactory.createEndDocument());
View Full Code Here

            case XMLEvent.END_ELEMENT:
                writer.writeEndElement();
                break;
           
            case XMLEvent.NAMESPACE: {
                Namespace ns = (Namespace) event;
                writer.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
                break;
            }
           
            case XMLEvent.START_ELEMENT: {
                StartElement se = event.asStartElement();
                QName n = se.getName();
                writer.writeStartElement(n.getPrefix(), n.getLocalPart(),
                                          n.getNamespaceURI());
                Iterator<?> it = se.getNamespaces();
                while (it.hasNext()) {
                    Namespace ns = (Namespace) it.next();
                    writer.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
                }
                it = se.getAttributes();
                while (it.hasNext()) {
                    Attribute attr = (Attribute) it.next();
                    QName name = attr.getName();
View Full Code Here

    }

    public final void addNamespaceDeclaration(String prefix, String namespaceUri) {
        List<Namespace> newNamespaces = new LinkedList<Namespace>();
        for (Iterator iterator = getStartElement().getNamespaces(); iterator.hasNext();) {
            Namespace namespace = (Namespace) iterator.next();
            newNamespaces.add(namespace);
        }
        Namespace newNamespace;
        if (StringUtils.hasLength(prefix)) {
            newNamespace = getEventFactory().createNamespace(prefix, namespaceUri);
        }
        else {
            newNamespace = getEventFactory().createNamespace(namespaceUri);
View Full Code Here

    {
        // Note: base class checks for 'known' problems and prefixes:
        if (mNsByPrefix == null) {
            mNsByPrefix = buildByPrefixMap();
        }
        Namespace ns = (Namespace) mNsByPrefix.get(prefix);
        if (ns == null && mParentCtxt != null) {
            return mParentCtxt.getNamespaceURI(prefix);
        }
        return (ns == null) ? null : ns.getNamespaceURI();
    }
View Full Code Here

TOP

Related Classes of javax.xml.stream.events.Namespace

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.