Package de.innovationgate.utils

Examples of de.innovationgate.utils.FormattingChain


        }
        else {
            results = Collections.singletonList(status.result);
        }

        FormattingChain formatters = new FormattingChain();
        if (includeFormatting == true) {
            // Get formatter objects regarding the Attributes format and
            // encoding

            // format Attribute
            formatters.addFormatter(new TagOutputFormatter(status.format, getTMLContext(), stringToBoolean(getTrim())));

            // Encode the result regarding the encode attribute
            String encodersList = getStatus().encode;
            if (encodersList != null && !encodersList.equals("none")) {
                Iterator encoders = WGUtils.deserializeCollection(encodersList, ",", true).iterator();
                while (encoders.hasNext()) {
                    String encoder = (String) encoders.next();
                    try {
                        ObjectFormatter formatter = getCore().getEncodingFormatter(encoder, getTMLContext());
                        formatters.addFormatter(formatter);
                    }
                    catch (FormattingException e) {
                        addWarning("No encoding formatter registered under encoding key '" + encoder + "'");
                    }
                }

            }
        }

        // Get a string from it. Serialize if it is a collection. Format output
        String result = de.innovationgate.utils.WGUtils.serializeCollection(results, (includeFormatting ? status.divider : ""), formatters);
       
        // Set formatting errors as warnings
        Iterator errors = formatters.getErrors().iterator();
        while (errors.hasNext()) {
            FormattingException e = (FormattingException) errors.next();
            addWarning("Formatting/Encoding error: " + WGUtils.getRootCause(e).getMessage());
        }
View Full Code Here


      }     
    }
   
    public String multiencode(String encode, Object input) throws FormattingException {
       
        FormattingChain formatters = new FormattingChain();
        Iterator encoders = WGUtils.deserializeCollection(encode, ",", true).iterator();
        while (encoders.hasNext()) {
            String encoder = (String) encoders.next();
            ObjectFormatter formatter = getwgacore().getEncodingFormatter(encoder, this);
            formatters.addFormatter(formatter);
        }
       
        return formatters.format(input);
       
    }
View Full Code Here

TOP

Related Classes of de.innovationgate.utils.FormattingChain

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.