Package org.apache.axis.components.encoding

Examples of org.apache.axis.components.encoding.XMLEncoder


     * @param orig the String to encode
     * @return a String in which XML special chars are repalced by entities
     */
    public static String xmlEncodeString(String orig)
    {
        XMLEncoder encoder = getXMLEncoder(MessageContext.getCurrentContext());
        return encoder.encode(orig);
    }
View Full Code Here


    /**
     * Get the XMLEncoder for specific encoding
     * @return XMLEncoder
     */
    public static XMLEncoder getXMLEncoder(String encoding) {
        XMLEncoder encoder = null;
        try {
            encoder = XMLEncoderFactory.getEncoder(encoding);
        } catch (Exception e) {
            log.error(Messages.getMessage("exception00"), e);
            encoder = XMLEncoderFactory.getDefaultEncoder();
View Full Code Here

    /**
     * Get the current encoding in effect
     * @return string
     */
    public static String getEncoding(MessageContext msgContext) {
        XMLEncoder encoder = getXMLEncoder(msgContext);
        return encoder.getEncoding();
    }
View Full Code Here

    /**
     * Get the current encoding in effect
     * @return string
     */
    public static String getEncoding() {
        XMLEncoder encoder = getXMLEncoder(MessageContext.getCurrentContext());
        return encoder.getEncoding();
    }
View Full Code Here

     * @param encoderChoice name of the encoder to use
     * @param invalidXmlString string we expect to fail
     */
    private void assertInvalidStringsDetected(String encoderChoice, String invalidXmlString) throws Exception {
        try {
            XMLEncoder encoder = XMLEncoderFactory.getEncoder(encoderChoice);
            encoder.encode(invalidXmlString);
            fail("A UnsupportedEncodingException should have been thrown.");
        } catch (IllegalArgumentException expected) {
            // expected
        }
    }
View Full Code Here

            // expected
        }
    }

    public void testUTF8() throws Exception {
        XMLEncoder encoder = XMLEncoderFactory.getEncoder(XMLEncoderFactory.ENCODING_UTF_8);
        String encodedUmlauts = encoder.encode(GERMAN_UMLAUTS);

        assertEquals(XMLEncoderFactory.ENCODING_UTF_8, encoder.getEncoding());
        assertEquals(GERMAN_UMLAUTS, encodedUmlauts);
        verifyCommonAssertions(encoder);
    }
View Full Code Here

        assertEquals(GERMAN_UMLAUTS, encodedUmlauts);
        verifyCommonAssertions(encoder);
    }

    public void testUTF16() throws Exception {
        XMLEncoder encoder = XMLEncoderFactory.getEncoder(XMLEncoderFactory.ENCODING_UTF_16);
        String encodedUmlauts = encoder.encode(GERMAN_UMLAUTS);

        assertEquals(XMLEncoderFactory.ENCODING_UTF_16, encoder.getEncoding());
        assertEquals(GERMAN_UMLAUTS, encodedUmlauts);
        //verifyCommonAssertions(encoder);
    }
View Full Code Here

        //verifyCommonAssertions(encoder);
    }


    public void test2UTF8() throws Exception {
        XMLEncoder encoder = XMLEncoderFactory.getEncoder(XMLEncoderFactory.ENCODING_UTF_8);
        String encodedAccents = encoder.encode(FRENCH_ACCENTS);

        assertEquals(XMLEncoderFactory.ENCODING_UTF_8, encoder.getEncoding());
        assertEquals(FRENCH_ACCENTS, encodedAccents);
        verifyCommonAssertions(encoder);
    }
View Full Code Here

        assertEquals(FRENCH_ACCENTS, encodedAccents);
        verifyCommonAssertions(encoder);
    }

    public void test2UTF16() throws Exception {
        XMLEncoder encoder = XMLEncoderFactory.getEncoder(XMLEncoderFactory.ENCODING_UTF_16);
        String encodedAccents = encoder.encode(FRENCH_ACCENTS);

        assertEquals(XMLEncoderFactory.ENCODING_UTF_16, encoder.getEncoding());
        assertEquals(FRENCH_ACCENTS, encodedAccents);
        //verifyCommonAssertions(encoder);
    }
View Full Code Here

     * @param orig the String to encode
     * @return a String in which XML special chars are repalced by entities
     */
    public static String xmlEncodeString(String orig)
    {
        XMLEncoder encoder = getXMLEncoder(MessageContext.getCurrentContext());
        return encoder.encode(orig);
    }
View Full Code Here

TOP

Related Classes of org.apache.axis.components.encoding.XMLEncoder

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.