当前位置: 首页>>代码示例>>Java>>正文


Java Text.valueOf方法代码示例

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


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

示例1: characters

import javolution.text.Text; //导入方法依赖的package包/类
public void characters(char[] values, int offset, int count) throws org.xml.sax.SAXException {
    if (isParseForTemplate) {
        // if null, don't worry about it
        if (this.currentNodeForTemplate != null) {
            Node newNode = this.documentForTemplate.createTextNode(new String(values, offset, count));
            this.currentNodeForTemplate.appendChild(newNode);
        }
        return;
    }

    if (currentValue != null && currentFieldName != null) {
        Text value = Text.valueOf(values, offset, count);

        // Debug.logInfo("characters: value=" + value, module);
        if (currentFieldValue == null) {
            currentFieldValue = value;
        } else {
            currentFieldValue = Text.valueOf(currentFieldValue).concat(value);
        }
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:22,代码来源:EntitySaxReader.java

示例2: toText

import javolution.text.Text; //导入方法依赖的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

示例3: toText

import javolution.text.Text; //导入方法依赖的package包/类
/**
 * Returns the text representation of this number.
 *
 * @return The string representation of this number as a <code>Text</code>.
 */

@Override
public Text toText()
{
    return Text.valueOf(value().toString());
}
 
开发者ID:mtommila,项目名称:apfloat,代码行数:12,代码来源:AbstractField.java

示例4: valueOf

import javolution.text.Text; //导入方法依赖的package包/类
/**
 * Returns the rational number for the specified character sequence.
 * 
 * @param  chars the character sequence.
 * @return the corresponding rational number.
 */
public static Rational valueOf(CharSequence chars) {
    Text txt = Text.valueOf(chars); // TODO Use TextFormat...
    int sep = txt.indexOf("/");
    if (sep >= 0) {
        LargeInteger dividend = LargeInteger.valueOf(txt.subtext(0, sep));
        LargeInteger divisor = LargeInteger.valueOf(txt.subtext(
                sep + 1, chars.length()));
        return valueOf(dividend, divisor);
    } else { // No divisor.
        return valueOf(LargeInteger.valueOf(txt),
                LargeInteger.ONE);
    }
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:20,代码来源:Rational.java

示例5: toText

import javolution.text.Text; //导入方法依赖的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 (isExact()) {
        return (_exponent == 0) ? _significand.toText() : 
            _significand.toText().plus("E").plus(Text.valueOf(_exponent));
    }
    int errorDigits = _error.digitLength();
    LargeInteger m = (_significand.isPositive()) ? _significand.plus(FIVE
            .times10pow(errorDigits - 1)) : _significand.plus(MINUS_FIVE
            .times10pow(errorDigits - 1));
    m = m.times10pow(-errorDigits);
    int exp = _exponent + errorDigits;
    Text txt = m.toText();
    int digits = (m.isNegative()) ? txt.length() - 1 : txt.length();
    if (digits > 1) {
        if ((exp < 0) && (-exp < digits)) {
            txt = txt.insert(txt.length() + exp, Text.valueOf('.'));
        } else { // Scientific notation.
            txt = txt.insert(txt.length() - digits + 1, Text.valueOf('.'));
            txt = txt.concat(Text.valueOf('E')).concat(
                    Text.valueOf(exp + digits - 1));
        }
    } else {
        txt = txt.concat(Text.valueOf('E')).concat(Text.valueOf(exp));
    }
    return txt;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:34,代码来源:Real.java

示例6: toText

import javolution.text.Text; //导入方法依赖的package包/类
/**
 * Returns the text representation of this number.
 *
 * @return The string representation of this number as a <code>Text</code>.
 */

public Text toText()
{
    return Text.valueOf(value().toString());
}
 
开发者ID:nick-paul,项目名称:aya-lang,代码行数:11,代码来源:AbstractField.java

示例7: valueOf

import javolution.text.Text; //导入方法依赖的package包/类
/**
 * Returns the real for the specified character sequence.
 * If the precision is not specified (using the <code>±</code> symbol), 
 * the real is supposed exact. Example of valid character sequences:
 * <li>"1.2E3" (1200 exact)</li>
 * <li>"1.2E3±1E-2" (1200 ± 0.01)</li></ul>
 * 
 * @param  chars the character sequence.
 * @return the corresponding real number.
 * @throws NumberFormatException if the character sequence does not contain
 *         a parsable real.
 */
public static Real valueOf(CharSequence chars) throws NumberFormatException {
    if ('-' == chars.charAt(0)) {
        return valueOf(chars.subSequence(1, chars.length())).opposite();
    }
    Text txt = Text.valueOf(chars); // TODO Use TextFormat...
    if ((txt.length() == 3) && (txt.indexOf("NaN", 0) == 0))
        return NaN;
    if (txt.equals("0"))
        return ZERO;
    int exponentIndex = txt.indexOf("E", 0);
    if (exponentIndex >= 0) {
        int exponent = TypeFormat.parseInt(txt.subtext(exponentIndex + 1,
                txt.length()));
        Real r = valueOf(txt.subtext(0, exponentIndex));
        if (r == ZERO)
            return valueOf(LargeInteger.ZERO, 1, exponent);
        r._exponent += exponent;
        return r;
    }
    Real real = FACTORY.object();
    int errorIndex = txt.indexOf("±", 0);
    if (errorIndex >= 0) {
        real._significand = LargeInteger.valueOf(txt.subtext(0, errorIndex));
        real._error = LargeInteger.valueOf(txt.subtext(errorIndex + 1, txt
                .length()));
        if (real._error.isNegative())
            throw new NumberFormatException(chars
                    + " not parsable (error cannot be negative)");
        real._exponent = 0;
        return real;
    }
    int decimalPointIndex = txt.indexOf(".", 0);
    if (decimalPointIndex >= 0) {
        LargeInteger integer = LargeInteger.valueOf(txt.subtext(0,
                decimalPointIndex));
        LargeInteger fraction = LargeInteger.valueOf(txt.subtext(
                decimalPointIndex + 1, txt.length()));
        int fractionDigits = chars.length() - decimalPointIndex - 1;
        real._significand = integer.isNegative() ? integer.times10pow(
                fractionDigits).minus(fraction) : integer.times10pow(
                fractionDigits).plus(fraction);
        real._error = LargeInteger.ZERO;
        real._exponent = -fractionDigits;
        return real;
    } else {
        real._significand = LargeInteger.valueOf(chars);
        real._error = LargeInteger.ZERO;
        real._exponent = 0;
        return real;
    }
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:64,代码来源:Real.java

示例8: csq

import javolution.text.Text; //导入方法依赖的package包/类
private static final CharSequence csq(Object string) {
    return (string instanceof CharSequence) ? (CharSequence) string : Text
            .valueOf(string);

}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:6,代码来源:WebServiceClient.java

示例9: toCharSequence

import javolution.text.Text; //导入方法依赖的package包/类
private static CharSequence toCharSequence(Object obj) {
    return obj instanceof CharSequence ? (CharSequence) obj : Text
            .valueOf(obj);
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:5,代码来源:SAX2ReaderImpl.java

示例10: toText

import javolution.text.Text; //导入方法依赖的package包/类
/**
 * Returns the decimal text representation of this number.
 *
 * @return the text representation of this number.
 */
public Text toText() {
    return Text.valueOf(_value);
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:9,代码来源:Float64.java


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