Package ariba.util.core

Examples of ariba.util.core.FastStringBuffer


        return newLink;
    }

    static String decamelize (String string)
    {
        FastStringBuffer buf = new FastStringBuffer();
            int lastUCIndex = -1;
        for (int i=0, len = string.length(); i < len; i++) {
            char c = string.charAt(i);
            if (Character.isUpperCase(c)) {
                if (i-1 != lastUCIndex) {
                    buf.append(" ");
                }
                lastUCIndex = i;
            }
            else if (Character.isLowerCase(c)) {
                if (i==0) {
                    c = Character.toUpperCase(c);
                }
            }
            else if (c == '_') {
                c = ' ';
            }
            buf.append(c);
        }
        return buf.toString();
    }
View Full Code Here


    {
        // default is to nop
    }

    public String bareStringContent () {
        final FastStringBuffer buf = new FastStringBuffer();

        AWUtil.iterate(this, new AWUtil.ElementIterator() {
            public Object process(AWElement e) {
               if (e instanceof AWBareString ) {
                    buf.append(((AWBareString)e).string());
                }
                return null; // keep looking
            }
        });
        return buf.toString();
    }
View Full Code Here

        url.append(AWUtil.encodeString(value));
    }

    public static String addQueryParam (String url, String name, String value)
    {
        FastStringBuffer fullUrl = new FastStringBuffer(url);
        addQueryParam(fullUrl, name, value);
        return fullUrl.toString();
    }
View Full Code Here

    private static String addRequestHandlerKey (String url, String key)
    {
        if (!StringUtil.nullOrEmptyOrBlankString(url)) {
            int qIndex = url.indexOf(BeginQueryChar);
            String urlMinusQueryString = (qIndex != -1)? url.substring(0, qIndex): url;
            FastStringBuffer buffer = new FastStringBuffer(urlMinusQueryString);
            if (!urlMinusQueryString.endsWith(HTTP_DELIMITERSTRING)) {
                buffer.append(HTTP_DELIMITERSTRING);
            }
            buffer.append(key);
            if (qIndex != -1) {
                String queryString = url.substring(qIndex, url.length());
                buffer.append(queryString);
            }
            return buffer.toString();
        }
        return url;
    }
View Full Code Here

    {
        long currTime = System.currentTimeMillis();

        Iterator iterator = existingSessions.iterator();
       
        FastStringBuffer debugBuffer = null;
        boolean isDisconnectDebugEnabled =
            Log.aribaweb_userstatus_disconnectTime.isDebugEnabled();
        if (isDisconnectDebugEnabled) {
            debugBuffer = new FastStringBuffer();
        }

        while (iterator.hasNext()) {
            // check if the session is
            // a) invalidated -- remove from list and send out disconnect
            // b) is connected and has not been accessed in time --
            //       set disconnected and send out disconnect
            // c) is disconnected, but has reconnected --
            //       set connected and send out reconnect
            // d) needs to be added to the DB list
            AWSession session = (AWSession)iterator.next();
            long disconnectTime = session.disconnectTime();
            if (session.isInvalidated()) {
                trackSessionTerminate(session);
                iterator.remove();
            }
            else if (disconnectTime != -1) {
                // If disconnectTime is -1, then we don't know when the session
                // is going to disconnect so don't attempt to update connected state.
                // For these sessions, the only valid states are Connected and
                // Disconnected, there is no pending disconnect or reconnect.
                if (session.isConnected() &&
                    currTime > disconnectTime) {
                    session.setConnected(false);
                    // add to disconnect notification list
                    trackSessionPendingDisconnect(session);
                }
                else if (!session.isConnected() &&
                    currTime < session.disconnectTime()) {
                    session.setConnected(true);
                    trackSessionReconnect(session);
                }
            }

            if (isDisconnectDebugEnabled) {
                debugBuffer.append(session.debugDisconnectString());
                debugBuffer.append("\n");
            }
        }

        if (connectList != null) {
            AWConcreteApplication.SessionWrapper sessOp = null;
            while ((sessOp = connectList.poll()) != null) {
                if (sessOp.op == AWConcreteApplication.SessionOp.Add) {
                    try {
                        trackSessionConnect(sessOp.session);
                        existingSessions.add(sessOp.session);
                    }
                    catch (UserSessionExistsException fae) {
                        //In development mode, always log this error.
                        //In production, log it only if debug is enabled.
                        if (AWConcreteApplication.IsDebuggingEnabled
                            || Log.aribaweb_userstatus.isDebugEnabled())
                        {
                            Log.aribaweb_userstatus.error(fae.getMessage(), sessOp.callTrace);
                        }
                    }
                }
                else {
                    trackSessionTerminate(sessOp.session);
                    existingSessions.remove(sessOp.session);
                }
                if (isDisconnectDebugEnabled) {
                    debugBuffer.append(sessOp.session.debugDisconnectString());
                    debugBuffer.append("\n");
                }
            }
        }

        if (isDisconnectDebugEnabled) {
            String debugString = debugBuffer.toString();
            if (!StringUtil.nullOrEmptyOrBlankString(debugString)) {
                Log.aribaweb_userstatus_disconnectTime.debug(debugString);
                Log.aribaweb_userstatus_disconnectTime.setLevel(Log.WarnLevel);
            }
        }
View Full Code Here

        Composing
        -------------- */

    protected String composeUrl ()
    {
        FastStringBuffer fastStringBuffer = new FastStringBuffer(256);
        if (_httpProtocol != null) {
            fastStringBuffer.append(_httpProtocol);
            fastStringBuffer.append("://");
            if (_hostName == null) {
                throw new AWGenericException("Invalid AWDirectActionUrl: missing hostName.");
            }
            fastStringBuffer.append(_hostName);
            if (_portNumber != null) {
                fastStringBuffer.append(":");
                fastStringBuffer.append(_portNumber);
            }
        }
        fastStringBuffer.append(_adaptorUrl);
        if (!_adaptorUrl.endsWith("/")) {
            fastStringBuffer.append("/");
        }
        if (!StringUtil.nullOrEmptyString(_applicationName) ||
            !StringUtil.nullOrEmptyString(_applicationSuffix)) {
            fastStringBuffer.append(_applicationName);
            fastStringBuffer.append(_applicationSuffix);
            fastStringBuffer.append("/");
        }
        if (_applicationNumber != null) {
            fastStringBuffer.append(_applicationNumber);
            fastStringBuffer.append("/");
        }
        if (_directActionName != null) {
            fastStringBuffer.append(AWConcreteApplication.DirectActionRequestHandlerKey);
            fastStringBuffer.append("/");
            fastStringBuffer.append(_directActionName);
            if (_directActionClassName != null) {
                fastStringBuffer.append("/");
                fastStringBuffer.append(_directActionClassName);
            }
        }
        if ((_queryStringValues != null) && !_queryStringValues.isEmpty()) {
            fastStringBuffer.append("?");
            Iterator keyEnumerator = _queryStringValues.keySet().iterator();
            while (true) {
                String currentQueryStringKey = (String)keyEnumerator.next();
                String currentQueryStringValue = _queryStringValues.get(currentQueryStringKey).toString();
                fastStringBuffer.append(currentQueryStringKey);
                fastStringBuffer.append("=");
                currentQueryStringValue = AWUtil.encodeString(currentQueryStringValue);
                fastStringBuffer.append(currentQueryStringValue);
                if (keyEnumerator.hasNext()) {
                    fastStringBuffer.append("&");
                }
                else {
                    break;
                }
            }

        }

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

    }

    public static String concatenateDirectActionUrl (String baseUrl, String directActionName,
                                                     String directActionClassName)
    {
        FastStringBuffer fastStringBuffer = new FastStringBuffer();
        fastStringBuffer.append(baseUrl);
        if (!baseUrl.endsWith("/")) {
            fastStringBuffer.append("/");
        }
        fastStringBuffer.append(directActionName);
        if (directActionClassName != null) {
            fastStringBuffer.append("/");
            fastStringBuffer.append(directActionClassName);
        }
        return fastStringBuffer.toString();
    }
View Full Code Here

        _expiresInSeconds = expiresInSeconds;
    }

    private FastStringBuffer checkoutStringBuffer ()
    {
        FastStringBuffer stringBuffer = null;
        synchronized (SharedStringBufferLock) {
            stringBuffer = SharedStringBuffer;
            SharedStringBuffer = null;
        }
        if (stringBuffer == null) {
            stringBuffer = new FastStringBuffer();
        }
        return stringBuffer;
    }
View Full Code Here

    }

    private String computeHeaderPrefix (String name, String value, String domain,
                                        String path, boolean isSecure, boolean isHTTPOnly)
    {
        FastStringBuffer stringBuffer = checkoutStringBuffer();
        stringBuffer.append(name);
        stringBuffer.append("=");
        stringBuffer.append(value);
        if (path != null) {
            stringBuffer.append("; path=");
            stringBuffer.append(path);
        }
        if (domain != null) {
            stringBuffer.append("; domain=");
            stringBuffer.append(domain);
        }
        if (isSecure) {
            stringBuffer.append("; secure");
        }
        if (isHTTPOnly) {
            stringBuffer.append("; HttpOnly");
        }
        return finalizeStringBuffer(stringBuffer);
    }
View Full Code Here

    public static String logExceptions ()
    {
        Map <Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
        Set<Thread> keys = map.keySet();
        FastStringBuffer sb = new FastStringBuffer();
        for (Thread t : keys) {
            StackTraceElement[] stacktaces = map.get(t);
            if (stacktaces != null) {
                sb.append("Current stack for long running thread: *************************" + t.toString());
                for (StackTraceElement line: stacktaces) {
                    sb.append("\n\t");
                    sb.append(line);
                }
            }
        }
        System.out.println(sb.toString());
        return sb.toString();
    }
View Full Code Here

TOP

Related Classes of ariba.util.core.FastStringBuffer

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.