Package ariba.util.core

Examples of ariba.util.core.FastStringBuffer


            Assert.assertNonFatal(false,
                "SecureTextFieldViewer:  must specify a format property");
            return strValue;
        }

        FastStringBuffer buf = new FastStringBuffer(strValue);
        int i,j;
        for (i = format.length()-1, j = buf.length()-1;
             i >= 0;
             i--, j--) {

            char curChar = format.charAt(i);

                // If we found the 'D' format character, then let the
                // character pass through unchanged.
            if (curChar == 'D') {
                continue;
            }

            if (curChar == 'X') {

                    // If we found any other character, then
                    // replace the digit with the cross out character.
                if (j >= 0) {
                    buf.setCharAt(j, blockoutChar);
                }
                else {
                    buf.insert(blockoutChar, 0);
                }
                continue;
            }

                // Otherwise, insert the character into
                // the return string.
            j++;
            int k = Math.max(0, j);
            buf.insert(curChar, k);
        }

            // If we got to the beginning of the format before getting to the
            // beginning of the number, then strip away the remaining digits.
        if (i < j) {
            j++;
            strValue = buf.substring(j, buf.length());
        }
        else {
            strValue = buf.toString();
        }

        return strValue;
    }
View Full Code Here


        return allLocalizedStringsTable;
    }

    public static String unescapeCsvString (String originalString)
    {
        FastStringBuffer fastStringBuffer = new FastStringBuffer();
        int stringLength = originalString.length();
        for (int index = 0; index < stringLength; index++) {
            char currentChar = originalString.charAt(index);
            if (currentChar == '\\') {
                index++;
                if (index >= stringLength) {
                    break;
                }
                currentChar = originalString.charAt(index);
                switch (currentChar) {
                    case 'n':
                        currentChar = '\n';
                        break;
                    case 'r':
                        currentChar = '\r';
                        break;
                    case 't':
                        currentChar = '\t';
                        break;
                    default:
                        break;
                }
            }
            fastStringBuffer.append(currentChar);
        }
        return fastStringBuffer.toString();
    }
View Full Code Here

         ctab.add(new WarekiMap('\u660e', '\u6cbb', 1867, 45));
    }

    private static String convertWareki (String str)
    {
        FastStringBuffer sb = new FastStringBuffer();
        int slen = str.length();
        for (int cidx = 0 ; cidx < slen ; ) {
            for (Iterator e = ctab.iterator() ; e.hasNext() ; ) {
                WarekiMap cm = (WarekiMap)e.next();
                if (str.charAt(cidx) == cm.c1()) {
                    if (cidx == (slen - 1)) {
                        sb.append(str.charAt(cidx));
                        cidx++;
                        break;
                    }
                    else if (str.charAt(cidx + 1) == cm.c2()) {
                        if (cidx == slen - 2) {
                            sb.append(str.charAt(cidx));
                            sb.append(str.charAt(cidx+2));
                            cidx += 2;
                            break;
                        }
                        else {
                            int year = 0;
                            int yidx = cidx + 2;
                            while (yidx < slen) {
                                if (Character.isDigit(str.charAt(yidx))) {
                                    year = year * 10 +
                                           Character.digit(str.charAt(yidx), 10);
                                    yidx++;
                                }
                                else if (str.charAt(yidx) == '\u5143') {
                                    //gann-Nen
                                    if (yidx == cidx + 2) {
                                        year = 1;
                                        yidx++;
                                        break;
                                    }
                                    else {
                                        break;
                                    }
                                }
                                else {
                                    break;
                                }
                            }
                            if (yidx == cidx + 2) {
                                sb.append(str.charAt(cidx));
                                sb.append(str.charAt(cidx+1));
                                cidx += 2;
                                break;
                            }
                            else if (year == 0) {
                                while (cidx < yidx) {
                                    sb.append(str.charAt(cidx));
                                    cidx++;
                                }
                                break;
                            }
                            else {
                                if (str.charAt(yidx) == '\u5e74') {
                                    if (year > cm.years()) {
                                        while (cidx < yidx) {
                                            sb.append(str.charAt(cidx));
                                            cidx++;
                                        }
                                        break;
                                    }
                                    else {
                                        int ryear = cm.startyear() + year;
                                        sb.append(Constants.getInteger(ryear).toString());
                                        cidx = yidx;
                                        break;
                                    }
                                }
                                else {
                                    while (cidx < yidx) {
                                        sb.append(str.charAt(cidx));
                                        cidx++;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    else {
                        sb.append(str.charAt(cidx));
                        cidx++;
                        break;
                    }
                }
                else {
                    if (!e.hasNext()) {
                        sb.append(str.charAt(cidx));
                        cidx++;
                    }
                    continue;
                }
            }
        }
        return sb.toString();
    }
View Full Code Here

    {
        if (locale == null) {
            locale = getDefaultLocale();
        }
       
        FastStringBuffer list = new FastStringBuffer();

        for (int i = 0; i < v.size(); i++) {
            Object obj = v.get(i);
            String line = null;
            Formatter formatter =
                Formatter.getFormatterForType(obj.getClass().getName());
            if (formatter != null) {
                line = formatter.getFormat(formatter.getValue(obj, locale), locale);
            }
            else {
                line = obj.toString();
            }
            if (useHTML) {
                list.append("<li>");
                line = HTML.fullyEscape(line);
            }
            list.append(line);
            if (useHTML) {
                list.append("</li>");
            }
            else {
                list.append(MIME.CRLF);
            }
        }

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

            // return empty string if array is null or empty
        if (ArrayUtil.nullOrEmptyArray(array)) {
            return("");
        }

        FastStringBuffer buf = new FastStringBuffer();

            // copy the array
        int count = array.length;
        Integer[] integers = new Integer[count];
        System.arraycopy(array, 0, integers, 0, count);

            // sort the ints
        Compare compare = Formatter.getFormatterForType(Constants.IntegerType);
        Sort.objects(integers, compare);

            // turn the array into a string
        boolean inRange = false;
        Integer previous = null;
        for (int i = 0; i < count; i++) {
            Integer current = integers[i];
            if (i > 0) {
                    // start a range if the current value is one more than the
                    // previous value
                if (current.intValue() == previous.intValue() + 1) {
                    inRange = true;
                    previous = current;
                        // allow code below to handle range at end of array
                    if (i < count - 1) {
                        continue;
                    }
                }
                    // either the current value is not one more than the
                    // previous, or we're at the end of the array
                if (inRange) {
                    buf.append("-");
                    buf.append(previous.toString());
                    inRange = false;
                        // bail out if we're closing a range at the end of the
                        // array, otherwise fall through to the code below
                    if (previous == current) {
                        break;
                    }
                }
            }

                // add the current value to the buffer, with a comma if
                // it's not the first value in the array
            if (i != 0) {
                buf.append(", ");
            }
            buf.append(current.toString());

                // keep track of the current value for next time...
            previous = current;
        }

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

        return cookieHeader;
    }

    protected String requestString (HttpServletRequest servletRequest)
    {
        FastStringBuffer requestString = new FastStringBuffer();
        requestString.append(servletRequest.getScheme());
        requestString.append("://");
        requestString.append(servletRequest.getServerName());
        requestString.append(":");
        requestString.append(String.valueOf(servletRequest.getServerPort()));
        requestString.append(servletRequest.getContextPath());
        requestString.append(servletRequest.getServletPath());
        requestString.append(((servletRequest.getPathInfo() != null) ? servletRequest.getPathInfo() : ""));
        requestString.append(((servletRequest.getQueryString() != null) ? "?"+servletRequest.getQueryString() : ""));
        return requestString.toString();
    }
View Full Code Here

    static String debugElementIdPathWithDelimiter (AWElementIdPath elementIdPath,
                                                   String delimiter)
    {
        char[] path = elementIdPath.privatePath();
        FastStringBuffer sb = new FastStringBuffer();
        for (int i=0; i < path.length; i++) {
            int element = (int)path[i];
            sb.append(String.valueOf(element));
            sb.append(delimiter);
        }
        return sb.toString();
    }
View Full Code Here

        }

            // Outer loop once per header
    outer:
        while (true) {
            FastStringBuffer header = new FastStringBuffer(lookahead);
                // Inner loop once per line
            while (true) {
                lookahead = readLine(in, charBuf, characterEncoding);

                    // A blank line indicates the end of the headers
                if (StringUtil.nullOrEmptyOrBlankString(lookahead)) {
                    add(headers, header.toString());
                    break outer;
                }
                if ((lookahead.charAt(0) == ' ') ||
                    (lookahead.charAt(0) == '\t')) {
                        // the header continues to the next line
                    for (int i = 1; i < lookahead.length(); i++) {
                        if (!((lookahead.charAt(i) == ' ') ||
                              (lookahead.charAt(i) == '\t'))) {
                            header.append(" ");
                            header.append(lookahead.substring(i));
                            break;
                        }
                    }
                }
                else {
                        // We found the end of the header
                        // lookahead has the start of the next
                    add(headers, header.toString());
                    continue outer;
                }
            }
        }
        return headers;
View Full Code Here

        String brandName = requestHandlerPathComponents[1];
        String brandVersion = requestHandlerPathComponents[2];
        // requestHandlerPathComponents[3] (resource version) is only used for cache busting
        String filename = requestHandlerPathComponents[AWResActionResourceIndex];
        if (requestHandlerPathComponents.length > AWResActionResourceIndex + 1) {
            FastStringBuffer sb = new FastStringBuffer();
            for (int i=AWResActionResourceIndex; i < requestHandlerPathComponents.length -1; i++) {
                sb.append(requestHandlerPathComponents[i]);
                sb.append("/");
            }
            sb.append(requestHandlerPathComponents[requestHandlerPathComponents.length -1]);
            filename = sb.toString();
        }

        if (!isValidResourceFilename(filename)) {
            response.appendContent("Invalid request: " + HTML.escape(filename));
            return response;
View Full Code Here

        return invoke(requestContext, null);
    }

    public String getEncodedString (String validatedObjectType)
    {
        FastStringBuffer encoded = new FastStringBuffer();
        if (_appSpecificValidatorName != null) {
            encoded.append(APP_ENCODING_FLAG);
            encoded.append(",");
            encoded.append(getObjectClassName());
            encoded.append(",");
               encoded.append(_appSpecificValidatorName);
        }
        else {
            encoded.append(getInspectorClassName());
            encoded.append(",");
            encoded.append(getInspectorName());
            if (!getObjectClassName().equals(getInspectorClassName())) {
                encoded.append(",");
                encoded.append(getObjectClassName());
            }
            else {
                encoded.append(",");
                encoded.append("null");
            }
            if (validatedObjectType != null) {
                encoded.append(",");
                encoded.append(validatedObjectType);
            }
            else {
                encoded.append(",");
                encoded.append("null");
            }

        }
        return encoded.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.