Package org.apache.vysper.xml.fragment

Examples of org.apache.vysper.xml.fragment.XMLElement


    @Override
    protected Stanza executeCore(XMPPCoreStanza stanza, ServerRuntimeContext serverRuntimeContext, boolean isOutboundStanza, SessionContext sessionContext) {

        // (try to) read thread id
        String threadId = null;
        XMLElement threadElement = null;
        try {
            threadElement = stanza.getSingleInnerElementsNamed("thread");
            if (threadElement != null && threadElement.getSingleInnerText() != null) {
                try {
                    threadId = threadElement.getSingleInnerText().getText();
                } catch (Exception _) {
                    threadId = null;
                }
            }
        } catch (XMLSemanticError _) {
            threadId = null;
        }

        // (try to) read subject id
        String subject = null;
        XMLElement subjectElement = null;
        try {
            subjectElement = stanza.getSingleInnerElementsNamed("subject");
            if (subjectElement != null && subjectElement.getSingleInnerText() != null) {
                try {
                    subject = subjectElement.getSingleInnerText().getText();
                } catch (Exception _) {
                    subject = null;
                }
            }
        } catch (XMLSemanticError _) {
View Full Code Here


    public void testElementSimple() throws DecodingException {
        List<XMLParticle> particles = new ArrayList<XMLParticle>();

        particles.add(new XMLParticle("<balanced/>"));

        XMLElement xmlElement = (XMLElement) xmlRawToFragmentConverter.convert(particles);
        assertNotNull(xmlElement);
        assertEquals("balanced", xmlElement.getName());
    }
View Full Code Here

    public void testElementSimpleAttributes() throws DecodingException {
        List<XMLParticle> particles = new ArrayList<XMLParticle>();

        particles.add(new XMLParticle("<balanced attr1=\"1\" attr2='2' ns:at_tr3=\"\" />"));

        XMLElement xmlElement = (XMLElement) xmlRawToFragmentConverter.convert(particles);
        assertNotNull(xmlElement);
        assertEquals("balanced", xmlElement.getName());
        List<Attribute> attributes = xmlElement.getAttributes();
        assertEquals(3, attributes.size());
        assertEquals("attr1", attributes.get(0).getName());
        assertEquals("1", attributes.get(0).getValue());
        assertEquals("attr2", attributes.get(1).getName());
        assertEquals("2", attributes.get(1).getValue());
View Full Code Here

    public void testElementSimpleAttributesMoreWhitespace() throws DecodingException {
        List<XMLParticle> particles = new ArrayList<XMLParticle>();

        particles.add(new XMLParticle("<balanced attr1 = \"1\"   attr2=' 2 ' ns:at_tr3= \" \" />"));

        XMLElement xmlElement = (XMLElement) xmlRawToFragmentConverter.convert(particles);
        assertNotNull(xmlElement);
        assertEquals("balanced", xmlElement.getName());
        List<Attribute> attributes = xmlElement.getAttributes();
        assertEquals(3, attributes.size());
        assertEquals("attr1", attributes.get(0).getName());
        assertEquals("1", attributes.get(0).getValue());
        assertEquals("attr2", attributes.get(1).getName());
        assertEquals(" 2 ", attributes.get(1).getValue());
View Full Code Here

        List<XMLParticle> particles = new ArrayList<XMLParticle>();

        particles.add(new XMLParticle("<balanced>"));
        particles.add(new XMLParticle("</balanced>"));

        XMLElement xmlElement = (XMLElement) xmlRawToFragmentConverter.convert(particles);
        assertNotNull(xmlElement);
    }
View Full Code Here

        particles.add(new XMLParticle("<balanced>"));
        particles.add(new XMLParticle("<inner>"));
        particles.add(new XMLParticle("</inner>"));
        particles.add(new XMLParticle("</balanced>"));
       
        XMLElement xmlElement = (XMLElement) xmlRawToFragmentConverter.convert(particles);
        assertEquals(1, ((XMLElement)xmlElement).getInnerElements().size());
    }
View Full Code Here

        }
        return (XMLElement) xmlRawToFragmentConverter.convert(particles);
    }

    public void testSimpleNamespacePrefix() throws DecodingException {
        XMLElement element = elementFromString("<p:elm xmlns:p=\"urn:foo\"/>");       
        assertEquals("p", element.getNamespacePrefix());
    }
View Full Code Here

        XMLElement element = elementFromString("<p:elm xmlns:p=\"urn:foo\"/>");       
        assertEquals("p", element.getNamespacePrefix());
    }

    public void testDefaultNamespacePrefix() throws DecodingException {
        XMLElement element = elementFromString("<elm xmlns=\"urn:foo\"/>");       
        assertEquals("", element.getNamespacePrefix());
    }
View Full Code Here

        assertEquals("", element.getNamespacePrefix());
    }

   
    public void testSimpleNamespaceURI() throws DecodingException {
        XMLElement element = elementFromString("<elm xmlns=\"urn:foo\"/>");       
        assertEquals("urn:foo", element.getNamespaceURI());
    }
View Full Code Here

        XMLElement element = elementFromString("<elm xmlns=\"urn:foo\"/>");       
        assertEquals("urn:foo", element.getNamespaceURI());
    }

    public void testSimpleNamespaceURIEmptyElement() throws DecodingException {
        XMLElement element = elementFromString("<elm xmlns=\"urn:foo\">", "</elm>");       
        assertEquals("urn:foo", element.getNamespaceURI());
    }
View Full Code Here

TOP

Related Classes of org.apache.vysper.xml.fragment.XMLElement

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.