Examples of FastStringBuffer


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

Examples of client.net.sf.saxon.ce.tree.util.FastStringBuffer

     */

    private String makeKey(StructuredQName functionName, int arity) {
        String uri = functionName.getNamespaceURI();
        String local = functionName.getLocalName();
        FastStringBuffer sb = new FastStringBuffer(uri.length() + local.length() + 8);
        sb.append('{');
        sb.append(uri);
        sb.append('}');
        sb.append(local);
        sb.append("#" + arity);
        return sb.toString();
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.tree.util.FastStringBuffer

                        // null should no longer be returned, but the spec has changed, so it's
                        // better to be defensive
                return new AnyURIValue(s);

            case GENERATE_ID:
                FastStringBuffer buffer = new FastStringBuffer(FastStringBuffer.TINY);
                node.generateId(buffer);
                buffer.condense();
                return new StringValue(buffer);

            case DOCUMENT_URI:
                // If the node is in the document pool, get the URI under which it is registered.
                // Otherwise, return its systemId.
View Full Code Here

Examples of client.net.sf.saxon.ce.tree.util.FastStringBuffer

        // for example "\", must be %-encoded.
        if (allAllowedAscii(s)) {
            // it's worth doing a prescan to avoid the cost of copying in the common all-ASCII case
            return s;
        }
        FastStringBuffer sb = new FastStringBuffer(s.length()+20);
        for (int i=0; i<s.length(); i++) {
            final char c = s.charAt(i);
            if (c>=0x7f || !allowedASCII[(int)c]) {
                escapeChar(c, ((i+1)<s.length() ? s.charAt(i+1) : ' '), sb);
            } else {
                sb.append(c);
            }
        }
        return sb;
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.tree.util.FastStringBuffer

     * should NOT be %HH-encoded
     * @return the %HH-encoded string
     */

    public static CharSequence escape(CharSequence s, String allowedPunctuation) {
        FastStringBuffer sb = new FastStringBuffer(s.length());
        for (int i=0; i<s.length(); i++) {
            char c = s.charAt(i);
            if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9')) {
                sb.append(c);
            } else if (c<=0x20 || c>=0x7f) {
                escapeChar(c, ((i+1)<s.length() ? s.charAt(i+1) : ' '), sb);
            } else if (allowedPunctuation.indexOf(c) >= 0) {
                sb.append(c);
            } else {
                escapeChar(c, ' ', sb);
            }

        }
View Full Code Here

Examples of client.net.sf.saxon.ce.tree.util.FastStringBuffer

        }
        return url;
    }

    private static CharSequence reallyEscapeURL(CharSequence url) {
        FastStringBuffer sb = new FastStringBuffer(url.length() + 20);
        final String hex = "0123456789ABCDEF";
        byte[] array = new byte[4];

        for (int i=0; i<url.length(); i++) {
            char ch = url.charAt(i);
            if (ch<32 || ch>126) {
                int used = UTF8CharacterSet.getUTF8Encoding(ch,
                                                 (i+1 < url.length() ? url.charAt(i+1): ' '), array);
                for (int b=0; b<used; b++) {
                    //int v = (array[b]>=0 ? array[b] : 256 + array[b]);
                    int v = ((int)array[b]) & 0xff;
                    sb.append('%');
                    sb.append(hex.charAt(v/16));
                    sb.append(hex.charAt(v%16));
                }

            } else {
                sb.append(ch);
            }
        }
        return sb;
    }
View Full Code Here

Examples of client.net.sf.saxon.ce.tree.util.FastStringBuffer

            length = ((DoubleValue)argument[2].evaluateItem(context)).round().getDoubleValue();
            if (length < 0) {
              length = 0;
            }
        }
        FastStringBuffer sb = new FastStringBuffer((int)length);
        int i=0;
        int pos=0;
        while(i<start-1 && pos<str.length()) {
            int c = (int)str.charAt(pos++);
            if (c<55296 || c>56319) i++;    // don't count high surrogates, i.e. D800 to DBFF
        }
        int j=0;
        while (j<length && pos<str.length()) {
            char c = str.charAt(pos++);
            sb.append(c);
            if ((int)c<55296 || (int)c>56319) j++;    // don't count high surrogates, i.e. D800 to DBFF
        }
        StringValue result = new StringValue(sb);
        if (sv.isKnownToContainNoSurrogates()) {
            result.setContainsNoSurrogates();
View Full Code Here

Examples of client.net.sf.saxon.ce.tree.util.FastStringBuffer

        if (country == null) {
            country = "US";
        }

        Numberer numberer = config.makeNumberer(language, country);
        FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.SMALL);
        if (numberer.getClass() == Numberer_en.class && !"en".equals(language) && !languageDefaulted) {
            sb.append("[Language: en]");
        }



        int i = 0;
        while (true) {
            while (i < format.length() && format.charAt(i) != '[') {
                sb.append(format.charAt(i));
                if (format.charAt(i) == ']') {
                    i++;
                    if (i == format.length() || format.charAt(i) != ']') {
                        XPathException e = new XPathException("Closing ']' in date picture must be written as ']]'");
                        e.setErrorCode("XTDE1340");
                        e.setXPathContext(context);
                        throw e;
                    }
                }
                i++;
            }
            if (i == format.length()) {
                break;
            }
            // look for '[['
            i++;
            if (i < format.length() && format.charAt(i) == '[') {
                sb.append('[');
                i++;
            } else {
                int close = (i < format.length() ? format.indexOf("]", i) : -1);
                if (close == -1) {
                    XPathException e = new XPathException("Date format contains a '[' with no matching ']'");
                    e.setErrorCode("XTDE1340");
                    e.setXPathContext(context);
                    throw e;
                }
                String componentFormat = format.substring(i, close);
                sb.append(formatComponent(value, Whitespace.removeAllWhitespace(componentFormat),
                        numberer, country, context));
                i = close+1;
            }
        }
        return sb;
View Full Code Here

Examples of client.net.sf.saxon.ce.tree.util.FastStringBuffer

                return "";
            }
        case'z':       // timezone
            if (value.hasTimezone()) {
                int tz = value.getTimezoneInMinutes();
                FastStringBuffer fsb = new FastStringBuffer(FastStringBuffer.TINY);
                fsb.append("GMT");
                if (tz != 0) {
                    CalendarValue.appendTimezone(tz, fsb);
                }
                int comma = format.indexOf(',');
                int min = 0;
                if (comma > 0) {
                    String widths = format.substring(comma);
                    int[] range = getWidths(widths);
                    min = range[0];
                }
                if (min < 6) {
                    if (tz % 60 == 0) {
                        // No minutes component in timezone
                        fsb.setLength(fsb.length() - 3);
                    }
                }
                if (min < fsb.length() - 3) {
                    if (fsb.charAt(4) == '0') {
                        fsb.removeCharAt(4);
                    }
                }
                return fsb;
            } else {
                return "";
View Full Code Here

Examples of client.net.sf.saxon.ce.tree.util.FastStringBuffer

            min = range[0];
            max = range[1];
            if (defaultFormat) {
                // if format was defaulted, the explicit widths override the implicit format
                if (primary.endsWith("1") && min != primary.length()) {
                    FastStringBuffer sb = new FastStringBuffer(min+1);
                    for (int i=1; i<min; i++) {
                        sb.append('0');
                    }
                    sb.append('1');
                    primary = sb.toString();
                }
            }
        }

        if ("P".equals(component)) {
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.