Examples of InternalStringBuilder


Examples of org.apache.beehive.netui.util.internal.InternalStringBuilder

    private String getErrorsFromBody()
    {
        final String END_TOKEN = "</span>";
        assert(_saveBody != null);
        InternalStringBuilder body = new InternalStringBuilder(_saveBody.length());
        InternalStringBuilder error = new InternalStringBuilder(_saveBody.length());

        // pull out all of the spans  These should be legally constructed, otherwise we will ignore them.
        int len = _saveBody.length();
        int pos = 0;
        while (pos < len) {

            // find the start of a span, if we dont' find one then it's over....
            int start = _saveBody.indexOf("<span", pos);
            if (start == -1)
                break;

            // if we don't find the end of the <span> then we don't have a legal span so ignore it
            int end = _saveBody.indexOf(END_TOKEN);
            if (end == -1)
                break;

            // copy the pos to start into the body
            int realEnd = end + END_TOKEN.length() + 1;
            body.append(_saveBody.substring(pos, start));
            error.append(_saveBody.substring(start, realEnd));
            pos = realEnd;
        }

        // recreate the remainder of the body, everything not left
        body.append(_saveBody.substring(pos, len));
        _saveBody = body.toString();

        // return the error
        return error.toString();
    }
View Full Code Here

Examples of org.apache.beehive.netui.util.internal.InternalStringBuilder

                return;
            }
        }

        // Render the error messages appropriately
        InternalStringBuilder results = new InternalStringBuilder(128);
        boolean headerDone = false;
        String message = null;
        Iterator reports = null;
        reports = errors.get();

        while (reports.hasNext()) {
            ActionMessage report = (ActionMessage) reports.next();
            if (!headerDone) {
                if (headerPresent) {
                    message = RequestUtils.message(pageContext, qualifiedBundle, locale, "errors.header");
                    results.append(message);
                    results.append("\r\n");
                }
                headerDone = true;
            }
            if (prefixPresent) {
                message = RequestUtils.message(pageContext, qualifiedBundle, locale, "errors.prefix");
                results.append(message);
            }
            message = getErrorMessage(report, qualifiedBundle);
            if (message != null) {
                results.append(message);
                results.append("\r\n");
            }
            if (suffixPresent) {
                message = RequestUtils.message(pageContext, qualifiedBundle, locale, "errors.suffix");
                results.append(message);
            }
        }
        if (headerDone && footerPresent) {
            message = RequestUtils.message(pageContext, qualifiedBundle, locale, "errors.footer");
            results.append(message);
            results.append("\r\n");
        }

        if (hasErrors())
            reportErrors();

        // Print the results to our output writer
        write(results.toString());
    }
View Full Code Here

Examples of org.apache.beehive.netui.util.internal.InternalStringBuilder

        public String format(Object dataToFormat) throws JspException
        {
            if (dataToFormat == null) {
                return null;
            }
            InternalStringBuilder formattedString = new InternalStringBuilder(32);

            SimpleDateFormat dateFormat = null;
            if (getPattern() != null) {
                try {
                    if (locale != null) {
                        dateFormat = new SimpleDateFormat(getPattern(), locale);
                    }
                    else {
                        dateFormat = new SimpleDateFormat(getPattern());
                    }
                }
                catch (IllegalArgumentException e) {
                    String s = Bundle.getString("Tags_DateFormatPatternException", new Object[]{e.getMessage()});
                    logger.warn(s);
                    throw new JspException(s);
                }
            }
            else {
                dateFormat = new SimpleDateFormat();
            }

            if (dataToFormat instanceof java.sql.Date) {

                java.sql.Date date = (java.sql.Date) dataToFormat;
                formattedString.append(dateFormat.format(date));
            }
            else if (dataToFormat instanceof java.util.Date) {

                java.util.Date date = (java.util.Date) dataToFormat;
                formattedString.append(dateFormat.format(date));
            }
            else if (dataToFormat instanceof java.util.Calendar) {
                java.util.Calendar c = (java.util.Calendar) dataToFormat;
                java.util.Date date = new java.util.Date(c.getTimeInMillis());
                formattedString.append(dateFormat.format(date));
            }
            else if (dataToFormat instanceof String) {
                if (dataToFormat.equals("")) {
                    return "";
                }

                DateFormat df = null;
                if (inputPattern != null) {
                    try {
                        df = new SimpleDateFormat(inputPattern);
                    }
                    catch (IllegalArgumentException e) {
                        String s = Bundle.getString("Tags_formatDate_StringPatternError",
                                new Object[]{inputPattern, e.getMessage()});
                        logger.warn(s);
                        throw new JspException(s);
                    }

                    // let try and convert this to some type of date
                    java.util.Date date = df.parse((String) dataToFormat,
                            new ParsePosition(0));
                    if (date != null) {
                        formattedString.append(dateFormat.format(date));
                        return formattedString.toString();
                    }
                }


                // this will loop through all of the formats and
                // try to convert the date to one of them.
                int i;
                for (i = 0; i < commonFormats.length; i++) {

                    if (commonFormats[i] != null) {
                        df = new SimpleDateFormat(commonFormats[i]);
                    }
                    else {
                        df = new SimpleDateFormat();

                    }

                    // let try and convert this to some type of date
                    java.util.Date date = df.parse((String) dataToFormat,
                            new ParsePosition(0));
                    if (date != null) {
                        formattedString.append(dateFormat.format(date));
                        break;
                    }
                }
                if (i == commonFormats.length) {
                    String s = Bundle.getString("Tags_formatDate_String_Error",
                            new Object[]{dataToFormat});
                    logger.error(s);
                    throw new JspException(s);
                }
            }
            else {
                String s = Bundle.getString("Tags_formatDate_Type_Error",
                        new Object[]{dataToFormat.getClass().getName()});
                logger.error(s);
                throw new JspException(s);
            }

            return formattedString.toString();
        }
View Full Code Here

Examples of org.apache.beehive.netui.util.internal.InternalStringBuilder

            String modulePath = PageFlowUtils.getModulePath( request );
            if ( ! moduleConfig.getPrefix().equals( modulePath ) )
            {
                if ( _log.isErrorEnabled() )
                {
                    InternalStringBuilder msg = new InternalStringBuilder( "No module configuration registered for " );
                    msg.append( uri ).append( " (module path " ).append( modulePath ).append( ")." );
                    _log.error( msg.toString() );
                }

                if ( modulePath.length() == 0 ) modulePath = "/";
                InternalUtils.sendDevTimeError( "PageFlow_NoModuleConf", null,
                                                HttpServletResponse.SC_INTERNAL_SERVER_ERROR, request, response,
                                                getServletContext(), new Object[]{ uri, modulePath } );
                return true;
            }

            //
            // Make sure that the requested pageflow matches the pageflow for the directory.
            //
            ActionMapping beginMapping = getBeginMapping();
            if ( beginMapping != null )
            {
                String desiredType = beginMapping.getParameter();
                desiredType = desiredType.substring( desiredType.lastIndexOf( '.' ) + 1 ) + JPF_EXTENSION;
                String requestedType = InternalUtils.getDecodedServletPath( request );
                requestedType = requestedType.substring( requestedType.lastIndexOf( '/' ) + 1 );

                if ( ! requestedType.equals( desiredType ) )
                {
                    if ( _log.isDebugEnabled() )
                    {
                        _log.debug( "Wrong .jpf requested for this directory: got " + requestedType
                                   + ", expected " + desiredType );
                    }

                    if ( _log.isErrorEnabled() )
                    {
                        InternalStringBuilder msg = new InternalStringBuilder( "Wrong .jpf requested for this directory: got " );
                        msg.append( requestedType ).append( ", expected " ).append( desiredType ).append( '.' );
                        _log.error( msg.toString() );
                    }

                    InternalUtils.sendDevTimeError( "PageFlow_WrongPath", null,
                                                    HttpServletResponse.SC_INTERNAL_SERVER_ERROR, request, response,
                                                    getServletContext(), new Object[]{ requestedType, desiredType } );
View Full Code Here

Examples of org.apache.beehive.netui.util.internal.InternalStringBuilder

                    //
                    // Construct a URI that is [shared flow module path] + [base action path] + [action-extension (.do)]
                    //
                    int lastSlash = actionPath.lastIndexOf( '/' );
                    assert lastSlash != -1 : actionPath;
                    InternalStringBuilder uri = new InternalStringBuilder( sf.getModulePath() );
                    uri.append( '/' );
                    uri.append( actionPath.substring( dot + 1 ) );
                    uri.append( ACTION_EXTENSION );
                   
                    try
                    {
                        doForward( uri.toString(), request, response );
                        return false;
                    }
                    catch ( ServletException e )
                    {
                        _log.error( "Could not forward to shared flow URI " + uri, e );
View Full Code Here

Examples of org.apache.beehive.netui.util.internal.InternalStringBuilder

                                                     HttpServletResponse response, Object returningForm )
        throws IOException
    {
                if ( _log.isInfoEnabled() )
        {
            InternalStringBuilder msg = new InternalStringBuilder( "Action \"" ).append( actionPath );
            _log.info( msg.append( "\" was also unhandled by Global.app." ).toString() );
        }
       
        //
        // If there's a PageFlowController for this request, try and let it handle an
        // action-not-found exception.  Otherwise, let Struts print out its "invalid path"
View Full Code Here

Examples of org.apache.beehive.netui.util.internal.InternalStringBuilder

                return;
            }
        }

        // Render the error message appropriately
        InternalStringBuilder results = new InternalStringBuilder(128);

        String message = null;
        Iterator reports = null;
        reports = errors.get(_key);

        while (reports.hasNext()) {
            ActionMessage report = (ActionMessage) reports.next();
            if (prefixPresent) {
                message = RequestUtils.message(pageContext, qualifiedBundle, locale, "error.prefix");
                results.append(message);
            }

            message = getErrorMessage(report, qualifiedBundle);

            if (message != null) {
                results.append(message);
                results.append("\r\n");
            }
            if (suffixPresent) {

                message = RequestUtils.message(pageContext, qualifiedBundle, locale, "error.suffix");
                results.append(message);
            }
        }

        write(results.toString());

        // report any expression errors
        if (hasErrors())
            reportErrors();
    }
View Full Code Here

Examples of org.apache.beehive.netui.util.internal.InternalStringBuilder

    /**
     * Replaces unprintable characters by their espaced (or unicode escaped)
     * equivalents in the given string
     */
    protected static final String addEscapes(String str) {
        InternalStringBuilder retval = new InternalStringBuilder();
        char ch;
        for(int i = 0; i < str.length(); i++) {
            switch(str.charAt(i)) {
                case 0:
                    continue;
                case '\b':
                    retval.append("\\b");
                    continue;
                case '\t':
                    retval.append("\\t");
                    continue;
                case '\n':
                    retval.append("\\n");
                    continue;
                case '\f':
                    retval.append("\\f");
                    continue;
                case '\r':
                    retval.append("\\r");
                    continue;
                case '\"':
                    retval.append("\\\"");
                    continue;
                case '\'':
                    retval.append("\\\'");
                    continue;
                case '\\':
                    retval.append("\\\\");
                    continue;
                default:
                    if((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
                        String s = "0000" + Integer.toString(ch, 16);
                        retval.append("\\u" + s.substring(s.length() - 4, s.length()));
                    } else {
                        retval.append(ch);
                    }
                    continue;
            }
        }
        return retval.toString();
    }
View Full Code Here

Examples of org.apache.beehive.netui.util.internal.InternalStringBuilder

     * Used to convert raw characters to their escaped version
     * when these raw version cannot be used as part of an ASCII
     * string literal.
     */
    protected String add_escapes(String str) {
        InternalStringBuilder retval = new InternalStringBuilder();
        char ch;
        for(int i = 0; i < str.length(); i++) {
            switch(str.charAt(i)) {
                case 0:
                    continue;
                case '\b':
                    retval.append("\\b");
                    continue;
                case '\t':
                    retval.append("\\t");
                    continue;
                case '\n':
                    retval.append("\\n");
                    continue;
                case '\f':
                    retval.append("\\f");
                    continue;
                case '\r':
                    retval.append("\\r");
                    continue;
                case '\"':
                    retval.append("\\\"");
                    continue;
                case '\'':
                    retval.append("\\\'");
                    continue;
                case '\\':
                    retval.append("\\\\");
                    continue;
                default:
                    if((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
                        String s = "0000" + Integer.toString(ch, 16);
                        retval.append("\\u" + s.substring(s.length() - 4, s.length()));
                    } else {
                        retval.append(ch);
                    }
                    continue;
            }
        }
        return retval.toString();
    }
View Full Code Here

Examples of org.apache.beehive.netui.util.internal.InternalStringBuilder

                localRelease();
                return EVAL_PAGE;
             }
        }
        if (parentTag instanceof DivPanel) {
            InternalStringBuilder results = new InternalStringBuilder(128);
            results.append("<div ");
            renderTagId(results);
            if (hasErrors()) {
                reportErrors();
                localRelease();
                return EVAL_PAGE;
            }
            results.append(">");
            ResponseUtils.write(pageContext,results.toString());
            return EVAL_BODY_BUFFERED;
        }

        return EVAL_BODY_BUFFERED;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.