List of usage examples for java.text FieldPosition setEndIndex
public void setEndIndex(int ei)
From source file:org.osaf.cosmo.eim.schema.text.TriageStatusFormat.java
public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) { if (obj == null) return toAppendTo; if (!(obj instanceof TriageStatus)) throw new IllegalArgumentException("object not a TriageStatus"); TriageStatus ts = (TriageStatus) obj; int begin = -1; int end = -1; Integer code = ts.getCode();/*from w w w . j a va 2 s.c o m*/ if (code != null) // validate that this is a known code; throws // IllegalArgumentException if not TriageStatusUtil.label(code); else code = new Integer(-1); if (pos.getField() == CODE_FIELD) begin = toAppendTo.length(); toAppendTo.append(code); if (pos.getField() == CODE_FIELD) end = toAppendTo.length() - 1; toAppendTo.append(" "); BigDecimal rank = ts.getRank(); if (rank == null) rank = BigDecimal.ZERO; rank.setScale(2); if (pos.getField() == RANK_FIELD) begin = toAppendTo.length(); toAppendTo.append(rank); if (pos.getField() == RANK_FIELD) end = toAppendTo.length() - 1; toAppendTo.append(" "); String autoTriage = BooleanUtils.isTrue(ts.getAutoTriage()) ? AUTOTRIAGE_ON : AUTOTRIAGE_OFF; if (pos.getField() == AUTOTRIAGE_FIELD) begin = toAppendTo.length(); toAppendTo.append(autoTriage); if (pos.getField() == AUTOTRIAGE_FIELD) end = toAppendTo.length() - 1; if (pos != null) { pos.setBeginIndex(begin); pos.setEndIndex(end); } return toAppendTo; }