• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TextBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javolution.text.TextBuilder的典型用法代码示例。如果您正苦于以下问题:Java TextBuilder类的具体用法?Java TextBuilder怎么用?Java TextBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TextBuilder类属于javolution.text包,在下文中一共展示了TextBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: toText

import javolution.text.TextBuilder; //导入依赖的package包/类
/**
 * Returns the decimal text representation of this number.
 *
 * @return the text representation of this number.
 */
public Text toText() {
    if (this == NaN)
        return Text.valueOf("NaN");
    if (this._significand.isZero())
        return Text.valueOf("0.0");
    TextBuilder tb = TextBuilder.newInstance();
    LargeInteger m = _significand;
    if (isNegative()) {
        tb.append('-');
        m = m.opposite();
    }
    tb.append("0.");
    LargeInteger.DECIMAL_FORMAT.format(m, tb);
    int exp = _exponent + m.digitLength();
    if (exp != 0) {
        tb.append("E");
        tb.append(_exponent + m.digitLength());
    }
    Text txt = tb.toText();
    TextBuilder.recycle(tb);
    return txt;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:28,代码来源:FloatingPoint.java


示例2: toText

import javolution.text.TextBuilder; //导入依赖的package包/类
/**
 * Returns the text representation of this term.
 */
public Text toText() {
    TextBuilder tb = TextBuilder.newInstance();
    for (int i = 0; i < _size; i++) {
        tb.append(_variables[i].getSymbol());
        int power = _powers[i];
        switch (power) {
        case 1:
            break;
        case 2:
            tb.append('²');
            break;
        case 3:
            tb.append('³');
            break;
        default:
            tb.append(power);
        }
    }
    return tb.toText();
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:24,代码来源:Term.java


示例3: toText

import javolution.text.TextBuilder; //导入依赖的package包/类
/**
 * Returns the text representation of this matrix.
 *
 * @return the text representation of this matrix.
 */
public Text toText() {
    final int m = this.getNumberOfRows();
    final int n = this.getNumberOfColumns();
    TextBuilder tmp = TextBuilder.newInstance();
    tmp.append('{');
    for (int i = 0; i < m; i++) {
        tmp.append('{');
        for (int j = 0; j < n; j++) {
            tmp.append(get(i, j));
            if (j != n - 1) {
                tmp.append(", ");
            }
        }
        tmp.append("}");
        if (i != m - 1) {
            tmp.append(",\n");
        }            
    }
    tmp.append("}");
    Text txt = tmp.toText();
    TextBuilder.recycle(tmp);
    return txt;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:29,代码来源:Matrix.java


示例4: toText

import javolution.text.TextBuilder; //导入依赖的package包/类
/**
 * Returns the text representation of this vector.
 *
 * @return the text representation of this vector.
 */
public Text toText() {
    final int dimension = this.getDimension();
    TextBuilder tmp = TextBuilder.newInstance();
    tmp.append('{');
    for (int i = 0; i < dimension; i++) {
        tmp.append(get(i));
        if (i != dimension - 1) {
            tmp.append(", ");
        }
    }
    tmp.append('}');
    Text txt = tmp.toText();
    TextBuilder.recycle(tmp); 
    return txt;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:21,代码来源:Vector.java


示例5: toText

import javolution.text.TextBuilder; //导入依赖的package包/类
/**
 * Returns the string representation of this coordinates.
 * 
 * @return the coordinates values/units.
 */
public Text toText() {
    double[] coordinates = getCoordinates();
    CoordinateSystem cs = this.getCoordinateReferenceSystem().getCoordinateSystem();
    TextBuilder tb = TextBuilder.newInstance();
    tb.append('[');
    for (int i=0; i < coordinates.length; i++) {
        if (i != 0) {
            tb.append(", ");
        }
        tb.append(getOrdinate(i));
        tb.append(' ');
        tb.append(cs.getAxis(i).getUnit());
    }
    tb.append(']');
    return tb.toText();
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:22,代码来源:Coordinates.java


示例6: putObject

import javolution.text.TextBuilder; //导入依赖的package包/类
public Observable<?> putObject(String bucketName, CharSequence key, ByteBuf data, ObjectMetadata metadata) {
    TextBuilder urlBuilder = TextBuilders.threadLocal();
    urlBuilder.append("/")
            .append(key);

    Request request = httpClient.preparePut(urlBuilder.toString())
            .setBucketName(bucketName)
            .setSignatureCalculatorFactory(signatureCalculatorFactory)
            .setBody(data)
            .setContentLength((int) metadata.getContentLength())
            .setMd5(metadata.getContentMD5())
            .setContentType(metadata.getContentType())
            .build();

    return retrieveResult(request, DiscardBytesParser.getInstance());
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:17,代码来源:AsyncS3Client.java


示例7: appendEncoded

import javolution.text.TextBuilder; //导入依赖的package包/类
public static TextBuilder appendEncoded(TextBuilder sb, CharSequence input, int offset) {
    final int[] safe = SAFE_ASCII;

    for (int c, i = offset, len = input.length(); i < len; i += Character.charCount(c)) {
        c = input.charAt(i);
        if (c <= 127) {
            if (safe[c] != 0) {
                sb.append((char) c);
            } else {
                appendSingleByteEncoded(sb, c);
            }
        } else {
            appendMultiByteEncoded(sb, c);
        }
    }
    return sb;
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:18,代码来源:UTF8UrlEncoder.java


示例8: shouldReturnDifferentBuildersForDifferentThreads

import javolution.text.TextBuilder; //导入依赖的package包/类
@Test
public void shouldReturnDifferentBuildersForDifferentThreads() throws InterruptedException {
    // Given
    TextBuilder mainThreadBuilder = TextBuilders.threadLocal();
    AtomicReference<TextBuilder> otherThreadBuilder = new AtomicReference<>();

    Thread thread = new Thread(() -> otherThreadBuilder.set(TextBuilders.threadLocal()));

    // When
    thread.start();
    thread.join();

    // Then
    assertThat(otherThreadBuilder.get()).isNotNull();
    assertThat(mainThreadBuilder).isNotSameAs(otherThreadBuilder.get());
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:17,代码来源:TextBuildersTest.java


示例9: log

import javolution.text.TextBuilder; //导入依赖的package包/类
@Override
protected void log(Level level, Object... message) {
    if (level.compareTo(currentLevel()) < 0)
        return;
    TextBuilder tmp = new TextBuilder();
    Throwable exception = null;
    for (Object pfx : prefix) {
        tmp.append(pfx); // Uses TextContext for formatting.
    }
    for (Object obj : message) {
        if ((exception == null) && (obj instanceof Throwable)) {
            exception = (Throwable) obj;
        } else {
            tmp.append(obj); // Uses TextContext for formatting.
        }
    }
    for (Object sfx : suffix) {
        tmp.append(sfx); // Uses TextContext for formatting.
    }
    int osgiLevel = TO_OSGI_LEVEL[level.ordinal()];
    String msg = tmp.toString();
    Object[] logServices = OSGiServices.getLogServices();
    for (Object logService : logServices) {
        ((LogService)logService).log(osgiLevel, msg, exception);
    }
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:27,代码来源:LogContextImpl.java


示例10: get

import javolution.text.TextBuilder; //导入依赖的package包/类
public String get() {
    final ByteBuffer buffer = getByteBuffer();
    synchronized (buffer) {
        TextBuilder tmp = new TextBuilder();
        try {
            int index = getByteBufferPosition() + offset();
            buffer.position(index);
            _reader.setInput(buffer);
            for (int i = 0; i < _length; i++) {
                char c = (char) _reader.read();
                if (c == 0) { // Null terminator.
                    return tmp.toString();
                } else {
                    tmp.append(c);
                }
            }
            return tmp.toString();
        } catch (IOException e) { // Should never happen.
            throw new Error(e.getMessage());
        } finally {
            _reader.reset();
        }
    }
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:25,代码来源:Struct.java


示例11: toText

import javolution.text.TextBuilder; //导入依赖的package包/类
/**
 * Returns the text representation of this number in the specified radix.
 *
 * @param radix the radix of the representation.
 * @return the text representation of this number in the specified radix.
 */
public Text toText(int radix) {
    TextBuilder tmp = TextBuilder.newInstance();
    try {
        format(this, radix, tmp);
        return tmp.toText();
    } catch (IOException e) {
        throw new Error(e);
    } finally {
        TextBuilder.recycle(tmp);
    }
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:18,代码来源:LargeInteger.java


示例12: toText

import javolution.text.TextBuilder; //导入依赖的package包/类
@Override
public Text toText() {
    TextBuilder tb = TextBuilder.newInstance();
    tb.append('(');
    tb.append(_dividend);
    tb.append(")/(");
    tb.append(_divisor);
    tb.append(')');
    return tb.toText();
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:11,代码来源:RationalFunction.java


示例13: toText

import javolution.text.TextBuilder; //导入依赖的package包/类
@Override
public Text toText() {
    FastTable<Term> terms = FastTable.newInstance();
    terms.addAll(_termToCoef.keySet());
    terms.sort();
    TextBuilder tb = TextBuilder.newInstance();
    for (int i=0, n = terms.size(); i < n; i++) {
        if (i != 0) {
            tb.append(" + ");
        }
        tb.append('[').append(_termToCoef.get(terms.get(i)));
        tb.append(']').append(terms.get(i));
    }
    return tb.toText();
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:16,代码来源:Polynomial.java


示例14: endTime

import javolution.text.TextBuilder; //导入依赖的package包/类
/**
 * Ends measuring time and display the execution time per iteration.
 * 
 * @param iterations
 *            the number iterations performed since {@link #startTime}.
 */
public static void endTime(int iterations) {
    long nanoSeconds = System.nanoTime() - _time;
    long picoDuration = nanoSeconds * 1000 / iterations;
    long divisor;
    String unit;
    if (picoDuration > 1000 * 1000 * 1000 * 1000L) { // 1 s
        unit = " s";
        divisor = 1000 * 1000 * 1000 * 1000L;
    } else if (picoDuration > 1000 * 1000 * 1000L) {
        unit = " ms";
        divisor = 1000 * 1000 * 1000L;
    } else if (picoDuration > 1000 * 1000L) {
        unit = " us";
        divisor = 1000 * 1000L;
    } else {
        unit = " ns";
        divisor = 1000L;
    }
    TextBuilder tb = TextBuilder.newInstance();
    tb.append(picoDuration / divisor);
    int fracDigits = 4 - tb.length(); // 4 digits precision.
    tb.append(".");
    for (int i = 0, j = 10; i < fracDigits; i++, j *= 10) {
        tb.append((picoDuration * j / divisor) % 10);
    }
    System.out.println(tb.append(unit));
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:34,代码来源:JScience.java


示例15: format

import javolution.text.TextBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Appendable format(Amount arg0, Appendable arg1)
        throws IOException {
    if (arg0.getUnit() instanceof Currency)
        return formatMoney(arg0, arg1);
    if (arg0.isExact()) {
        TypeFormat.format(arg0.getExactValue(), arg1);
        arg1.append(' ');
        return UnitFormat.getInstance().format(arg0.getUnit(), arg1);
    }
    double value = arg0.getEstimatedValue();
    double error = arg0.getAbsoluteError();
    int log10Value = (int) MathLib.floor(MathLib.log10(MathLib
            .abs(value)));
    int log10Error = (int) MathLib.floor(MathLib.log10(error));
    int digits = log10Value - log10Error - 1; // Exact digits.
    digits = MathLib.max(1, digits + _errorDigits);

    boolean scientific = (MathLib.abs(value) >= 1E6)
            || (MathLib.abs(value) < 1E-6);
    boolean showZeros = true;
    TextBuilder tb = TextBuilder.newInstance();
    TypeFormat.format(value, digits, scientific, showZeros, tb);
    int endMantissa = 0;
    for (; endMantissa < tb.length(); endMantissa++) {
        if (tb.charAt(endMantissa) == 'E')
            break;
    }
    int bracketError = (int) (error * MathLib.toDoublePow10(1,
            -log10Error + _errorDigits - 1));
    tb.insert(endMantissa, Text.valueOf('[').plus(
            Text.valueOf(bracketError)).plus(']'));
    arg1.append(tb);
    arg1.append(' ');
    return UnitFormat.getInstance().format(arg0.getUnit(), arg1);
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:38,代码来源:AmountFormat.java


示例16: listObjects

import javolution.text.TextBuilder; //导入依赖的package包/类
public void listObjects(String bucketName, CharSequence prefix, Subscriber<? super ObjectListing> subscriber) {
    TextBuilder urlBuilder = TextBuilders.threadLocal();
    urlBuilder.append("/?");
    appendQueryString(urlBuilder, prefix, null, null, null);

    Request request = httpClient.prepareList(urlBuilder.toString())
            .setBucketName(bucketName)
            .setSignatureCalculatorFactory(signatureCalculatorFactory)
            .build();

    retrieveResult(request, listResponseParser, subscriber);
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:13,代码来源:AsyncS3Client.java


示例17: getObject

import javolution.text.TextBuilder; //导入依赖的package包/类
public Observable<SizedInputStream> getObject(String bucketName, CharSequence location) {
    TextBuilder urlBuilder = TextBuilders.threadLocal();
    urlBuilder.append("/");
    UTF8UrlEncoder.appendEncoded(urlBuilder, location);

    Request request = httpClient.prepareGet(urlBuilder.toString())
            .setBucketName(bucketName)
            .setSignatureCalculatorFactory(signatureCalculatorFactory)
            .build();

    return retrieveResult(request, ConsumeBytesParser.getInstance());
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:13,代码来源:AsyncS3Client.java


示例18: deleteObject

import javolution.text.TextBuilder; //导入依赖的package包/类
public Observable<?> deleteObject(String bucketName, CharSequence location) {
    TextBuilder urlBuilder = TextBuilders.threadLocal();
    urlBuilder.append("/");
    UTF8UrlEncoder.appendEncoded(urlBuilder, location);

    Request request = httpClient.prepareDelete(urlBuilder.toString())
            .setBucketName(bucketName)
            .setSignatureCalculatorFactory(signatureCalculatorFactory)
            .build();

    return retrieveResult(request, DiscardBytesParser.getInstance());
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:13,代码来源:AsyncS3Client.java


示例19: appendSingleByteEncoded

import javolution.text.TextBuilder; //导入依赖的package包/类
private final static void appendSingleByteEncoded(TextBuilder sb, int value) {
    if (encodeSpaceUsingPlus && value == 32) {
        sb.append('+');
        return;
    }

    sb.append('%');
    sb.append(HEX[value >> 4]);
    sb.append(HEX[value & 0xF]);
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:11,代码来源:UTF8UrlEncoder.java


示例20: appendMultiByteEncoded

import javolution.text.TextBuilder; //导入依赖的package包/类
private final static void appendMultiByteEncoded(TextBuilder sb, int value) {
    if (value < 0x800) {
        appendSingleByteEncoded(sb, (0xc0 | (value >> 6)));
        appendSingleByteEncoded(sb, (0x80 | (value & 0x3f)));
    } else if (value < 0x10000) {
        appendSingleByteEncoded(sb, (0xe0 | (value >> 12)));
        appendSingleByteEncoded(sb, (0x80 | ((value >> 6) & 0x3f)));
        appendSingleByteEncoded(sb, (0x80 | (value & 0x3f)));
    } else {
        appendSingleByteEncoded(sb, (0xf0 | (value >> 18)));
        appendSingleByteEncoded(sb, (0x80 | (value >> 12) & 0x3f));
        appendSingleByteEncoded(sb, (0x80 | (value >> 6) & 0x3f));
        appendSingleByteEncoded(sb, (0x80 | (value & 0x3f)));
    }
}
 
开发者ID:codewise,项目名称:RxS3,代码行数:16,代码来源:UTF8UrlEncoder.java



注:本文中的javolution.text.TextBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RiotLib类代码示例发布时间:2022-05-23
下一篇:
Java Mode类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap