-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.2.0
-
generic
-
solaris_2.5.1
should use text1.equals(text2) instead of text1 == text2 because
strings may not be interned.
Test code:
import java.awt.font.StyledString;
import java.awt.font.StyledStringIterator;
import java.awt.Font;
import java.text.AttributeSet;
public class GetCharsTest {
public static void main (String args[]) {
try {
char cArray6[] = new char[6];
char cArray5[] = new char[5];
String string2 = "123456";
StyledString s, s2;
StyledStringIterator anIterator;
StyledStringIterator anotherIterator;
Font font2 = new Font("Helvetica",Font.BOLD,12);
s = new StyledString(string2,font2);
System.out.println("character " + s.charAt(0) );
System.out.println("character " + s.charAt(5) );
// System.out.println("character " + s.charAt(6) ); //bug no E
// System.out.println("character " + s.charAt(7) );
System.out.println("character " + s.charAt(0) );
System.out.println("character " + s.getFontAt(0) );
System.out.println("character " + s.getFontAt(6) );
System.out.println("character " + s.getFontAt(5) );
// System.out.println("character " + s.getFontAt(7) );
// System.out.println("character " + s.getFontAt(-1) );
System.out.println("string " + s.toString() );
System.out.println("length " + s.length() );
// StyledString aStyledString = s.substring(1,2);
s.getChars(0, 6, cArray6, 0);
System.out.println("6 ok");
// s.getChars(0, 8, cArray5, 0);
// System.out.println("5 bug");
// s.getChars(0, 6, cArray5, 0);
// System.out.println("5 bug");
// s.getChars(0, 6, null, 0); // correctly throws Null
s.getChars(6, 6, cArray6, 0); //bug
// s.getChars(0, 7, cArray6, 0);
// s.getChars(7, 7, cArray6, 0);
anIterator = new StyledStringIterator(s, 0, 6, 0);
System.out.println("test run start" + anIterator.getRunStart() );
System.out.println("test run limit (FONT)" + anIterator.getRunLimit("Font") );
System.out.println("test run start" + anIterator.getRunStart() );
System.out.println("test run start (FONT)" + anIterator.getRunLimit("Font") );
anIterator = new StyledStringIterator(s, 0, 6, 6);
s = new StyledString();
System.out.println("length " + s.length() );
anIterator = new StyledStringIterator(s, 0, 0, 0);
AttributeSet aSet = anIterator.getAttributes();
System.out.println("attributes " + aSet); // bug is null
// anIterator = new StyledStringIterator("what's up", null);
// anIterator = new StyledStringIterator(null, 1, 0, 0); // throws IllegalArgE, not NullE
anIterator = new StyledStringIterator(s, 0, 0, 0);
System.out.println("test run start" + anIterator.getRunStart() );
System.out.println("test run limit (FONT)" + anIterator.getRunLimit("Font") );
System.out.println("test run start" + anIterator.getRunStart() );
System.out.println("test run start (FONT)" + anIterator.getRunLimit("Font") );
System.out.println("equals null" + anIterator.equals(null) );
System.out.println("equals null" + s.equals(null) );
s = new StyledString("hello", font2);
String st = new String("he"); st = st + "llo";
s2 = new StyledString(st, font2);
anotherIterator = new StyledStringIterator(s, 0, 5, 0);
anIterator = new StyledStringIterator(s2, 0, 5, 0);
System.out.println(anIterator + "<>" + anotherIterator);
System.out.println("equal" + anIterator.equals(anotherIterator) );
} catch (Throwable exception) {
System.out.println("Exception" + exception);
}
System.out.println("Done ssf");
System.exit(0);
}
}
strings may not be interned.
Test code:
import java.awt.font.StyledString;
import java.awt.font.StyledStringIterator;
import java.awt.Font;
import java.text.AttributeSet;
public class GetCharsTest {
public static void main (String args[]) {
try {
char cArray6[] = new char[6];
char cArray5[] = new char[5];
String string2 = "123456";
StyledString s, s2;
StyledStringIterator anIterator;
StyledStringIterator anotherIterator;
Font font2 = new Font("Helvetica",Font.BOLD,12);
s = new StyledString(string2,font2);
System.out.println("character " + s.charAt(0) );
System.out.println("character " + s.charAt(5) );
// System.out.println("character " + s.charAt(6) ); //bug no E
// System.out.println("character " + s.charAt(7) );
System.out.println("character " + s.charAt(0) );
System.out.println("character " + s.getFontAt(0) );
System.out.println("character " + s.getFontAt(6) );
System.out.println("character " + s.getFontAt(5) );
// System.out.println("character " + s.getFontAt(7) );
// System.out.println("character " + s.getFontAt(-1) );
System.out.println("string " + s.toString() );
System.out.println("length " + s.length() );
// StyledString aStyledString = s.substring(1,2);
s.getChars(0, 6, cArray6, 0);
System.out.println("6 ok");
// s.getChars(0, 8, cArray5, 0);
// System.out.println("5 bug");
// s.getChars(0, 6, cArray5, 0);
// System.out.println("5 bug");
// s.getChars(0, 6, null, 0); // correctly throws Null
s.getChars(6, 6, cArray6, 0); //bug
// s.getChars(0, 7, cArray6, 0);
// s.getChars(7, 7, cArray6, 0);
anIterator = new StyledStringIterator(s, 0, 6, 0);
System.out.println("test run start" + anIterator.getRunStart() );
System.out.println("test run limit (FONT)" + anIterator.getRunLimit("Font") );
System.out.println("test run start" + anIterator.getRunStart() );
System.out.println("test run start (FONT)" + anIterator.getRunLimit("Font") );
anIterator = new StyledStringIterator(s, 0, 6, 6);
s = new StyledString();
System.out.println("length " + s.length() );
anIterator = new StyledStringIterator(s, 0, 0, 0);
AttributeSet aSet = anIterator.getAttributes();
System.out.println("attributes " + aSet); // bug is null
// anIterator = new StyledStringIterator("what's up", null);
// anIterator = new StyledStringIterator(null, 1, 0, 0); // throws IllegalArgE, not NullE
anIterator = new StyledStringIterator(s, 0, 0, 0);
System.out.println("test run start" + anIterator.getRunStart() );
System.out.println("test run limit (FONT)" + anIterator.getRunLimit("Font") );
System.out.println("test run start" + anIterator.getRunStart() );
System.out.println("test run start (FONT)" + anIterator.getRunLimit("Font") );
System.out.println("equals null" + anIterator.equals(null) );
System.out.println("equals null" + s.equals(null) );
s = new StyledString("hello", font2);
String st = new String("he"); st = st + "llo";
s2 = new StyledString(st, font2);
anotherIterator = new StyledStringIterator(s, 0, 5, 0);
anIterator = new StyledStringIterator(s2, 0, 5, 0);
System.out.println(anIterator + "<>" + anotherIterator);
System.out.println("equal" + anIterator.equals(anotherIterator) );
} catch (Throwable exception) {
System.out.println("Exception" + exception);
}
System.out.println("Done ssf");
System.exit(0);
}
}