Package org.apache.beehive.netui.util.internal

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


    }

    public static String escapeEscapes(String val)
    {
        assert(val != null);
        InternalStringBuilder sb = new InternalStringBuilder(val.length());
        for (int i = 0; i < val.length(); i++) {
            char c = val.charAt(i);
            if (c == '"') {
                sb.append("&quot;");
                continue;
            }
            if (c == '\\') {
                sb.append("\\\\");
                continue;
            }
            sb.append(c);
        }
        return sb.toString();
    }
View Full Code Here


    }

    public static String legacyEscapeEscapes(String val)
    {
        assert(val != null);
        InternalStringBuilder sb = new InternalStringBuilder(val.length());
        for (int i = 0; i < val.length(); i++) {
            char c = val.charAt(i);
            if (c == '"') {
                sb.append("\\\"");
                continue;
            }
            if (c == '\\') {
                sb.append("\\\\");
                continue;
            }
            sb.append(c);
        }
        return sb.toString();
    }
View Full Code Here

     * @throws JspException
     */
    public static String addParams(String url, Map params, String encoding)
            throws JspException
    {
        InternalStringBuilder urlBuffer = new InternalStringBuilder(url);

        try {
            // Add dynamic parameters if requested
            if ((params != null) && (params.size() > 0)) {

                // Add the required request parameters
                boolean question = url.indexOf('?') >= 0;
                Iterator keys = params.keySet().iterator();
                while (keys.hasNext()) {
                    String key = (String) keys.next();
                    Object value = params.get(key);
                    if (value == null) {
                        if (!question) {
                            urlBuffer.append('?');
                            question = true;
                        }
                        else {
                            urlBuffer.append("&");
                        }
                        urlBuffer.append(URLCodec.encode(key, encoding));
                        urlBuffer.append('='); // Interpret null as "no value"
                    }
                    else if (value instanceof String) {
                        if (!question) {
                            urlBuffer.append('?');
                            question = true;
                        }
                        else {
                            urlBuffer.append("&");
                        }
                        urlBuffer.append(URLCodec.encode(key, encoding));
                        urlBuffer.append('=');
                        urlBuffer.append(URLCodec.encode((String) value, encoding));
                    }
                    else if (value instanceof String[]) {
                        String values[] = (String[]) value;
                        for (int i = 0; i < values.length; i++) {
                            if (!question) {
                                urlBuffer.append('?');
                                question = true;
                            }
                            else {
                                urlBuffer.append("&");
                            }
                            urlBuffer.append(URLCodec.encode(key, encoding));
                            urlBuffer.append('=');
                            urlBuffer.append(URLCodec.encode(values[i], encoding));
                        }
                    }
                    else /* Convert other objects to a string */ {
                        if (!question) {
                            urlBuffer.append('?');
                            question = true;
                        }
                        else {
                            urlBuffer.append("&");
                        }
                        urlBuffer.append(URLCodec.encode(key, encoding));
                        urlBuffer.append('=');
                        urlBuffer.append(URLCodec.encode(value.toString(),
                                encoding));
                    }
                }
            }
        }
        catch (UnsupportedEncodingException uee) {
            uee.printStackTrace();
            throw new JspException("Unsupported Encoding" + encoding, uee);
        }

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

        String boldStart = "<b>";
        String boldEnd = "</b>";
        int pos = in.indexOf(boldStart);
        if (pos == -1)
            return in;
        InternalStringBuilder sb = new InternalStringBuilder(in.substring(0,pos));
        int fill = pos+boldStart.length();
        pos = in.indexOf(boldEnd,fill);
        if (pos == -1)
            return in;
        sb.append(in.substring(fill,pos));
        pos += boldEnd.length();
        sb.append(in.substring(pos));
        return sb.toString();
    }
View Full Code Here

        if ( !uriContext.useAmpEntity() )
        {
            paramSeparator = AMP_CHAR;
        }

        InternalStringBuilder query = new InternalStringBuilder( 64 );
        boolean firstParam = true;
        for ( Iterator i = _params.keySet().iterator(); i.hasNext();
        {
            String name = ( String ) i.next();
           
            for ( Iterator j = ( ( List ) _params.get( name ) ).iterator(); j.hasNext();
            {
                String value = ( String ) j.next();
               
                if ( firstParam )
                {
                    firstParam = false;
                }
                else
                {
                    query.append( paramSeparator );
                }

                query.append( name );

                if ( value != null ) { query.append( '=' ).append( value ); }
            }
        }

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

        assert _errors != null;
        assert _errors.size() > 0;

        int cnt = _errors.size();

        InternalStringBuilder sb = new InternalStringBuilder(128);

        // check the first error to see if we are reporting errors at the end
        AbstractPageError info = (AbstractPageError) _errors.get(0);
        if (isInlineErrors()) {
            String s = getInlineError(info, tagName);
            return s;
        }

        // create the errors
        String s;
        s = Bundle.getString("Tag_Header",
                new Object[]{tagName, Integer.toString(cnt)});
        sb.append(s);

        Object[] args = new Object[4];
        for (int i = 0; i < cnt; i++) {
            Object o = _errors.get(i);
            if (o instanceof EvalErrorInfo) {
                EvalErrorInfo e = (EvalErrorInfo) o;
                assert info != null;

                args[0] = Bundle.getString("Expression_Error");
                args[1] = e.attr;
                args[2] = e.expression;
                args[3] = e.evalExcp.getMessage();
                s = Bundle.getString("Expression_Error_Line", args);
            }
            else if (o instanceof TagErrorInfo) {
                TagErrorInfo e = (TagErrorInfo) o;
                assert info != null;

                args[0] = Bundle.getString("Tag_Error");
                args[1] = e.message;
                s = Bundle.getString("Tag_Error_Line", args);
            }
            sb.append(s);
        }

        s = Bundle.getString("Tag_Footer");
        sb.append(s);
        return sb.toString();
    }
View Full Code Here

        br.doEndTag(writer);

        //Emit javascript if this button needs to sumbit the form or open a popup window
        if (idScript != null || _popupSupport != null || buttonDisable || buttonDisableAndSubmit) {
            ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);
            InternalStringBuilder script = new InternalStringBuilder(32);
            StringBuilderRenderAppender scriptWriter = new StringBuilderRenderAppender(script);
            IScriptReporter sr = getScriptReporter();

            if (buttonDisableAndSubmit)
                srs.writeFeature(sr, scriptWriter, CoreScriptFeature.BUTTON_DISABLE_AND_SUBMIT, true, false, null);
            if (buttonDisable)
                srs.writeFeature(sr, scriptWriter, CoreScriptFeature.BUTTON_DISABLE, true, false, null);
            if (_popupSupport != null)
                _popupSupport.writeScript(request, srs, getScriptReporter(), scriptWriter);
            if (idScript != null)
                scriptWriter.append(idScript);
            write(script.toString());
        }
       
        // Evaluate the remainder of this page
        localRelease();
        return EVAL_PAGE;
View Full Code Here

     * @param uriContext data required to write out the string form.
     * @return the URI as a <code>String</code>
     */
    public String getURIString( URIContext uriContext )
    {
        InternalStringBuilder buf = new InternalStringBuilder( 128 );

        // Append the scheme
        if ( getScheme() != null )
        {
            buf.append( getScheme() ).append( ':' );
        }

        // Append the user info, host and, port
        if ( getHost() != null)
        {
            buf.append( "//" );

            if ( getUserInfo() != null )
            {
                buf.append( getUserInfo() );
                buf.append( '@' );
            }

            buf.append( getHost() );

            if ( getPort() != UNDEFINED_PORT )
            {
                buf.append( ':' ).append( getPort() );
            }
        }

        // Append the path.
        if ( getPath() != null )
        {
            if ( isAbsolute() )
            {
                // absolute URI so
                appendEnsureSeparator( buf, getPath() );
            }
            else
            {
                buf.append( getPath() );
            }
        }

        // Append the parameters (the query)
        if ( _params != null && _params.size() > 0 )
        {
            buf.append( '?' );
            buf.append( getQuery( uriContext ) );
        }

        // Append the fragment
        if ( getFragment() != null && getFragment().length() > 0 )
        {
            buf.append( '#' ).append( getFragment() );
        }

        String url = buf.toString();

        return url;
    }
View Full Code Here

        ArrayList/*<String>*/ list = (ArrayList/*<String>*/)
                org.apache.beehive.netui.tags.RequestUtils.getOuterAttribute(req,
                        ScriptContainer.SCOPE_ID);
        if (list == null)
            return tagId;
        InternalStringBuilder sb = new InternalStringBuilder();
        for (int i=0;i<list.size();i++) {
            sb.append((String)list.get(i));
            sb.append('.');
        }
        sb.append(tagId);
        return sb.toString();


        /*
        Tag tag = this;
        while (tag != null) {
View Full Code Here

    protected void writeBeforeBlocks(AbstractRenderAppender sb)
    {
        if (_codeBefore == null || _codeBefore.size() == 0)
            return;

        InternalStringBuilder s = new InternalStringBuilder(256);
        for (Iterator i = _codeBefore.iterator(); i.hasNext();)
        {
            String code = ( String ) i.next();
            s.append(code);
            s.append("\n");
        }
        ScriptRequestState.writeScriptBlock(pageContext.getRequest(), sb, s.toString());

    }
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.util.internal.InternalStringBuilder

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.