本文整理汇总了Java中javolution.text.Text类的典型用法代码示例。如果您正苦于以下问题:Java Text类的具体用法?Java Text怎么用?Java Text使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Text类属于javolution.text包,在下文中一共展示了Text类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例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;
}
示例3: toText
import javolution.text.Text; //导入依赖的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();
}
示例4: toText
import javolution.text.Text; //导入依赖的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;
}
示例5: toText
import javolution.text.Text; //导入依赖的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;
}
示例6: toText
import javolution.text.Text; //导入依赖的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();
}
示例7: initializeRealtimeClasses
import javolution.text.Text; //导入依赖的package包/类
/** Initializes all real-time classes. */
public static synchronized boolean initializeRealtimeClasses() {
Initializer initializer = new Initializer(OSGiServices.class.getClassLoader());
initializer.loadClass(MathLib.class);
initializer.loadClass(Text.class);
initializer.loadClass(TypeFormat.class);
initializer.loadClass(Struct.class);
initializer.loadClass(FastBitSet.class);
initializer.loadClass(FastSortedMap.class);
initializer.loadClass(FastSortedSet.class);
initializer.loadClass(FastSortedTable.class);
initializer.loadClass(Index.class); // Preallocates.
initializer.loadClass(Reducers.class);
initializer.loadClass(Equalities.class);
initializer.loadClass(XMLStreamReaderImpl.class);
initializer.loadClass(XMLStreamWriterImpl.class);
return initializer.initializeLoadedClasses();
}
示例8: 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());
}
示例9: toText
import javolution.text.Text; //导入依赖的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);
}
}
示例10: 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);
}
}
示例11: 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;
}
示例12: toText
import javolution.text.Text; //导入依赖的package包/类
@Override
public Text toText() {
TextBuilder tb = TextBuilder.newInstance();
tb.append('(');
tb.append(_dividend);
tb.append(")/(");
tb.append(_divisor);
tb.append(')');
return tb.toText();
}
示例13: toText
import javolution.text.Text; //导入依赖的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();
}
示例14: format
import javolution.text.Text; //导入依赖的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);
}
示例15: read
import javolution.text.Text; //导入依赖的package包/类
/**
* Reads characters into a portion of an array. This method does not
* block.
*
* @param cbuf the destination buffer.
* @param off the offset at which to start storing characters.
* @param len the maximum number of characters to read
* @return the number of characters read, or -1 if there is no more
* character to be read.
* @throws IOException if an I/O error occurs.
*/
public int read(char cbuf[], int off, int len) throws IOException {
if (input == null)
throw new IOException("Reader closed");
final int inputLength = input.length();
if (index >= inputLength)
return -1;
final int count = MathLib.min(inputLength - index, len);
final Object csq = input;
if (csq instanceof String) {
String str = (String) csq;
str.getChars(index, index + count, cbuf, off);
} else if (csq instanceof Text) {
Text txt = (Text) csq;
txt.getChars(index, index + count, cbuf, off);
} else if (csq instanceof TextBuilder) {
TextBuilder tb = (TextBuilder) csq;
tb.getChars(index, index + count, cbuf, off);
} else if (csq instanceof CharArray) {
CharArray ca = (CharArray) csq;
System.arraycopy(ca.array(), index + ca.offset(), cbuf, off, count);
} else { // Generic CharSequence.
for (int i = off, n = off + count, j = index; i < n;) {
cbuf[i++] = input.charAt(j++);
}
}
index += count;
return count;
}