Package org.geotools.xml

Examples of org.geotools.xml.SimpleBinding


                String msg = "Encode failed for " + element.getName() + ". Cause: "
                    + t.getLocalizedMessage();
                throw new RuntimeException(msg, t);
            }
        } else {
            SimpleBinding simple = (SimpleBinding) binding;

            //figure out if the node has any text
            Text text = null;

            for (int i = 0; i < encoding.getChildNodes().getLength(); i++) {
                Node node = (Node) encoding.getChildNodes().item(i);

                if (node instanceof Text) {
                    text = (Text) node;

                    break;
                }
            }

            try {
                if(object != null) {
                    String value = simple.encode(object, (text != null) ? text.getData() : null);
   
                    if (value != null) {
                        //set the text of the node
                        if (text == null) {
                            text = document.createTextNode(value);
View Full Code Here


                return;
            }
        }

        if (binding instanceof SimpleBinding) {
            SimpleBinding simple = (SimpleBinding) binding;

            try {
                encoding.setValue(simple.encode(object, encoding.getValue()));
            } catch (Throwable t) {
                String msg = "Encode failed for " + attribute.getName() + ". Cause: "
                    + t.getLocalizedMessage();
                throw new RuntimeException(msg, t);
            }
View Full Code Here

    }

    public <E extends java.util.Date> void testParseEncode(final QName qname, final String toParse,
            final E toEncode, final String expectedEncoding) throws Exception {

        SimpleBinding strategy = (SimpleBinding) stratagy(qname);
        E parsed = (E) strategy.parse(element(toParse, qname), toParse);
        assertTrue(toEncode.getClass().equals(parsed.getClass()));

        assertEquals(parsed.getClass().getName(), toEncode, parsed);

        String encoded = strategy.encode(toEncode, null);
        assertEquals(expectedEncoding, encoded);
    }
View Full Code Here

TOP

Related Classes of org.geotools.xml.SimpleBinding

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.