Support_Formatpublic class Support_Format extends TestCase
Fields Summary |
---|
protected String | text |
Constructors Summary |
---|
public Support_Format(String p1)
super(p1);
|
Methods Summary |
---|
protected static boolean | compare(java.util.Vector vector1, java.util.Vector vector2)compares two vectors regardless of the order of their elements
return vector1.size() == vector2.size() && vector1.containsAll(vector2);
| protected static java.util.Vector | findFields(java.text.AttributedCharacterIterator iterator)finds attributes with regards to char index in this
AttributedCharacterIterator, and puts them in a vector
Vector<FieldContainer> result = new Vector<FieldContainer>();
while (iterator.getIndex() != iterator.getEndIndex()) {
int start = iterator.getRunStart();
int end = iterator.getRunLimit();
Iterator<Attribute> it = iterator.getAttributes().keySet().iterator();
while (it.hasNext()) {
AttributedCharacterIterator.Attribute attribute = it.next();
Object value = iterator.getAttribute(attribute);
result.add(new FieldContainer(start, end, attribute, value));
// System.out.println(start + " " + end + ": " + attribute + ",
// " + value );
// System.out.println("v.add(new FieldContainer(" + start +"," +
// end +"," + attribute+ "," + value+ "));");
}
iterator.setIndex(end);
}
return result;
| protected void | t_Format(int count, java.lang.Object object, java.text.Format format, java.util.Vector expectedResults)
// System.out.println(format.format(object));
Vector<FieldContainer> results = findFields(format.formatToCharacterIterator(object));
assertTrue("Test " + count
+ ": Format returned incorrect CharacterIterator for "
+ format.format(object), compare(results, expectedResults));
| protected void | t_FormatWithField(int count, java.text.Format format, java.lang.Object object, java.lang.String text, java.text.Format$Field field, int begin, int end)
StringBuffer buffer = new StringBuffer();
FieldPosition pos = new FieldPosition(field);
format.format(object, buffer, pos);
// System.out.println(buffer);
// System.out.println(pos);
if (text == null) {
assertEquals("Test " + count + ": incorrect formatted text",
this.text, buffer.toString());
} else {
assertEquals("Test " + count + ": incorrect formatted text", text,
buffer.toString());
}
assertEquals("Test " + count + ": incorrect begin index for field "
+ field, begin, pos.getBeginIndex());
assertEquals("Test " + count + ": incorrect end index for field"
+ field, end, pos.getEndIndex());
|
|