Package client.net.sf.saxon.ce.tree.util

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


     */

    private String toRadical(long number, int[] digits, int pictureLength,
                             NumericGroupFormatter numGroupFormatter) {

        FastStringBuffer temp = new FastStringBuffer(FastStringBuffer.TINY);
        int base = digits.length;
        FastStringBuffer s = new FastStringBuffer(FastStringBuffer.TINY);
        long n = number;
        int count = 0;
        while (n > 0) {
            int digit = digits[(int) (n % base)];
            s.prependWideChar(digit);
            count++;
            n = n / base;
        }

        for (int i = 0; i < (pictureLength - count); i++) {
View Full Code Here


     * @param number the number to be formatted: formatted in Western decimal style unless in the range 1 to 9999
     * @return the Japanese Kanji representation of the number if in the range 1-9999
     */

    public String toJapanese(long number) {
        FastStringBuffer fsb = new FastStringBuffer(FastStringBuffer.TINY);
        if (number == 0) {
            fsb.appendWideChar(0x3007);
        } else if (number <= 9999) {
            toJapanese((int)number, fsb, false);
        } else {
            fsb.append("" + number);
        }
        return fsb.toString();
    }
View Full Code Here

        if (textOnly) {
            CharSequence textValue;
            if (constantText != null) {
                textValue = constantText;
            } else {
                FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.SMALL);
                SequenceIterator iter = content.iterate(context);
                while (true) {
                    Item item = iter.next();
                    if (item==null) break;
                    sb.append(item.getStringValueCS());
                }
                textValue = sb.condense();
            }
            root = new TextFragmentValue(textValue, getBaseURI());
            ((TextFragmentValue)root).setConfiguration(controller.getConfiguration());
        } else {
            try {
View Full Code Here

    */

    public CharSequence format(List numbers, int groupSize, String groupSeparator,
                        String letterValue, String ordinal, Numberer numberer) {

        FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.TINY);
        int num = 0;
        int tok = 0;
        // output first punctuation token
        if (startsWithPunctuation) {
            sb.append((String)punctuationTokens.get(tok));
        }
        // output the list of numbers
        while (num<numbers.size()) {
            if (num>0) {
                if (tok==0 && startsWithPunctuation) {
                    // The first punctuation token isn't a separator if it appears before the first
                    // formatting token. Such a punctuation token is used only once, at the start.
                    sb.append(".");
                } else {
                    sb.append((String)punctuationTokens.get(tok));
                }
            }
            Object o = numbers.get(num++);
            String s;
            if (o instanceof Long) {
                long nr = ((Long)o).longValue();
                RegularGroupFormatter rgf = new RegularGroupFormatter(groupSize, groupSeparator);
                s = numberer.format(nr, (String)formatTokens.get(tok), rgf, letterValue, ordinal);
            } else if (o instanceof BigDecimal) {
                s = new IntegerValue((BigDecimal)o).getStringValue();
            } else {
                s = o.toString();
            }
            sb.append(s);
            tok++;
            if (tok==formatTokens.size()) tok--;
        }
        // output the final punctuation token
        if (punctuationTokens.size()>formatTokens.size()) {
            sb.append((String)punctuationTokens.get(punctuationTokens.size()-1));
        }
        return sb.condense();
    }
View Full Code Here

    @Override
    public String format(FastStringBuffer value) {
        int [] valueEx = StringValue.expand(value);
        int [] groupSeparatorVal = StringValue.expand(groupSeparator);
        FastStringBuffer temp = new FastStringBuffer(FastStringBuffer.TINY);
        if (groupSize>0) {
            for (int i=valueEx.length-1,j=0; i>=0; i--, j++) {
                if (j!=0 && (j % groupSize) == 0) {
                    temp.prependWideChar(groupSeparatorVal[0]);
                }
                temp.prependWideChar(valueEx[i]);
            }
            return temp.toString();
        }
        return value.toString();
    }
View Full Code Here

     * @return a message display of the contents of the sequence
     */

    public static String depictSequenceStart(SequenceIterator seq, int max) {
        try {
            FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.SMALL);
            int count = 0;
            sb.append(" (");
            while (true) {
                Item next = seq.next();
                if (next == null) {
                    sb.append(") ");
                    return sb.toString();
                }
                if (count++ > 0) {
                    sb.append(", ");
                }
                if (count > max) {
                    sb.append("...) ");
                    return sb.toString();
                }

                sb.append(Err.depict(next));
            }
        } catch (XPathException e) {
            return "";
        }
    }
View Full Code Here

     * In the case of XSLT instructions, the toString() method gives an abstracted view of the syntax
     * @return a representation of the expression as a string
     */

    public String toString() {
        FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.SMALL);
        sb.append("if (");
        for (int i=0; i<conditions.length; i++) {
            sb.append(conditions[i].toString());
            sb.append(") then (");
            sb.append(actions[i].toString());
            if (i == conditions.length - 1) {
                sb.append(")");
            } else {
                sb.append(") else if (");
            }
        }
        return sb.toString();
    }
View Full Code Here

TOP

Related Classes of client.net.sf.saxon.ce.tree.util.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.