Java 类javax.swing.text.AbstractDocument.AbstractElement 实例源码
项目:cn1
文件:DefaultStyledDocument_ElementsAndAttributesTest.java
/**
* Checks what happens when ResolveAttribute of a paragraph is set
* to non-Style object.
*/
public void testGetLogicalStyle03() {
final AbstractElement par = (AbstractElement) doc.getParagraphElement(5);
final MutableAttributeSet set = new SimpleAttributeSet();
StyleConstants.setForeground(set, Color.GREEN);
StyleConstants.setBackground(set, Color.YELLOW);
doc.writeLock();
try {
set.setResolveParent(boldItalic);
par.setResolveParent(set);
assertSame(set, par.getResolveParent());
assertNull(doc.getLogicalStyle(5));
} finally {
doc.writeUnlock();
}
}
项目:cn1
文件:DefaultStyledDocument_ElementBuffer_RemoveTest.java
/**
* This removes only one character from the document: the new line which
* separates two paragraphs.
* The paragraphs merge into one. All their child elements which are
* not entirely contained in the remove region are copied into the
* new paragraph.
*/
public void testRemoveParagraphBreak() throws Exception {
final int offset = paragraph.getEndOffset() - 1;
final int length = 1;
((AbstractElement) paragraph).addAttributes(bold);
buf.remove(offset, length, createEvent(offset, length));
final List<?> edits = getEdits(event);
assertEquals(1, edits.size());
assertChange(edits.get(0), root, 0, new int[] { 0, 16, 16, 21 }, new int[] { 0, 21 });
final AbstractElement branch = (AbstractElement) root.getElement(0);
assertChildren(branch, new int[] { 0, 5, 5, 9, 9, 15, 16, 21 }, new AttributeSet[] {
null, bold, italic, null });
assertEquals(2, branch.getAttributeCount());
assertTrue(branch.isDefined(AttributeSet.ResolveAttribute));
assertTrue(branch.containsAttributes(bold));
}
项目:cn1
文件:DefaultStyledDocument_ElementBuffer_RemoveTest.java
/**
* Removes an entire element before the paragraph break as well the break
* itself.
* Two paragraphs merge. The resulting paragraph doesn't contain the
* child elements which were entirely contained in the remove region.
*/
public void testRemoveFullElementParagraphBreak() throws Exception {
final Element italicElement = paragraph.getElement(2);
final int offset = italicElement.getStartOffset();
final int length = paragraph.getEndOffset() - offset;
((AbstractElement) paragraph).addAttributes(bold);
buf.remove(offset, length, createEvent(offset, length));
final List<?> edits = getEdits(event);
assertEquals(1, edits.size());
assertChange(edits.get(0), root, 0, new int[] { 0, 16, 16, 21 }, new int[] { 0, 21 });
final AbstractElement branch = (AbstractElement) root.getElement(0);
assertChildren(branch, new int[] { 0, 5, 5, 9, 16, 21 }, new AttributeSet[] { null,
bold, null });
assertEquals(2, branch.getAttributeCount());
assertTrue(branch.isDefined(AttributeSet.ResolveAttribute));
assertTrue(branch.containsAttributes(bold));
}
项目:cn1
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSBody() throws Exception {
AbstractElement body =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", body.getName());
assertTrue(body instanceof BlockElement);
body.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
body.addAttribute(HTML.Attribute.BACKGROUND, "bg.jpg");
body.addAttribute(HTML.Attribute.TEXT, "black");
body.addAttribute(HTML.Attribute.LINK, "blue");
body.addAttribute(HTML.Attribute.ALINK, "red");
body.addAttribute(HTML.Attribute.VLINK, "purple");
attr = ss.translateHTMLToCSS(body);
assertSame(NamedStyle.class, attr.getClass());
assertNull(((NamedStyle)attr).getName());
assertEquals(3, attr.getAttributeCount());
assertEquals(isHarmony() ? "url(bg.jpg)" : "bg.jpg",
attr.getAttribute(CSS.Attribute.BACKGROUND_IMAGE)
.toString());
assertEquals("#ffffff",
attr.getAttribute(CSS.Attribute.BACKGROUND_COLOR)
.toString());
assertEquals("black",
attr.getAttribute(CSS.Attribute.COLOR).toString());
}
项目:cn1
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSA() throws Exception {
doc.remove(0, doc.getLength());
HTMLEditorKit kit = new HTMLEditorKit();
kit.read(new StringReader("<a href=\"http://go\">link</a>"), doc, 0);
AbstractElement body =
(AbstractElement)doc.getDefaultRootElement().getElement(1);
assertEquals("body", body.getName());
body.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
body.addAttribute(HTML.Attribute.BACKGROUND, "bg.jpg");
body.addAttribute(HTML.Attribute.TEXT, "black");
body.addAttribute(HTML.Attribute.LINK, "blue");
body.addAttribute(HTML.Attribute.ALINK, "red");
body.addAttribute(HTML.Attribute.VLINK, "purple");
AbstractElement a = (AbstractElement)doc.getCharacterElement(2);
assertNotNull(a.getAttribute(HTML.Tag.A));
attr = ss.translateHTMLToCSS(a);
assertNull(((NamedStyle)attr).getName());
assertEquals(0, attr.getAttributeCount());
}
项目:cn1
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSAlignTop() throws Exception {
AbstractElement branch =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", branch.getName());
branch.addAttribute(HTML.Attribute.ALIGN, "top");
attr = ss.translateHTMLToCSS(branch);
if (isHarmony()) {
assertEquals(0, attr.getAttributeCount());
assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
} else {
assertEquals(1, attr.getAttributeCount());
assertEquals("top",
attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
}
}
项目:cn1
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSAlignBottom() throws Exception {
AbstractElement branch =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", branch.getName());
branch.addAttribute(HTML.Attribute.ALIGN, "bottom");
attr = ss.translateHTMLToCSS(branch);
if (isHarmony()) {
assertEquals(0, attr.getAttributeCount());
assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
} else {
assertEquals(1, attr.getAttributeCount());
assertEquals("bottom",
attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
}
}
项目:cn1
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSAlignChar() throws Exception {
AbstractElement branch =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", branch.getName());
branch.addAttribute(HTML.Attribute.ALIGN, "char");
attr = ss.translateHTMLToCSS(branch);
if (isHarmony()) {
assertEquals(0, attr.getAttributeCount());
assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
} else {
assertEquals(1, attr.getAttributeCount());
assertEquals("char",
attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
}
}
项目:freeVM
文件:DefaultStyledDocument_ElementsAndAttributesTest.java
/**
* Checks what happens when ResolveAttribute of a paragraph is set
* to non-Style object.
*/
public void testGetLogicalStyle03() {
final AbstractElement par = (AbstractElement) doc.getParagraphElement(5);
final MutableAttributeSet set = new SimpleAttributeSet();
StyleConstants.setForeground(set, Color.GREEN);
StyleConstants.setBackground(set, Color.YELLOW);
doc.writeLock();
try {
set.setResolveParent(boldItalic);
par.setResolveParent(set);
assertSame(set, par.getResolveParent());
assertNull(doc.getLogicalStyle(5));
} finally {
doc.writeUnlock();
}
}
项目:freeVM
文件:DefaultStyledDocument_ElementBuffer_RemoveTest.java
/**
* This removes only one character from the document: the new line which
* separates two paragraphs.
* The paragraphs merge into one. All their child elements which are
* not entirely contained in the remove region are copied into the
* new paragraph.
*/
public void testRemoveParagraphBreak() throws Exception {
final int offset = paragraph.getEndOffset() - 1;
final int length = 1;
((AbstractElement) paragraph).addAttributes(bold);
buf.remove(offset, length, createEvent(offset, length));
final List<?> edits = getEdits(event);
assertEquals(1, edits.size());
assertChange(edits.get(0), root, 0, new int[] { 0, 16, 16, 21 }, new int[] { 0, 21 });
final AbstractElement branch = (AbstractElement) root.getElement(0);
assertChildren(branch, new int[] { 0, 5, 5, 9, 9, 15, 16, 21 }, new AttributeSet[] {
null, bold, italic, null });
assertEquals(2, branch.getAttributeCount());
assertTrue(branch.isDefined(AttributeSet.ResolveAttribute));
assertTrue(branch.containsAttributes(bold));
}
项目:freeVM
文件:DefaultStyledDocument_ElementBuffer_RemoveTest.java
/**
* Removes an entire element before the paragraph break as well the break
* itself.
* Two paragraphs merge. The resulting paragraph doesn't contain the
* child elements which were entirely contained in the remove region.
*/
public void testRemoveFullElementParagraphBreak() throws Exception {
final Element italicElement = paragraph.getElement(2);
final int offset = italicElement.getStartOffset();
final int length = paragraph.getEndOffset() - offset;
((AbstractElement) paragraph).addAttributes(bold);
buf.remove(offset, length, createEvent(offset, length));
final List<?> edits = getEdits(event);
assertEquals(1, edits.size());
assertChange(edits.get(0), root, 0, new int[] { 0, 16, 16, 21 }, new int[] { 0, 21 });
final AbstractElement branch = (AbstractElement) root.getElement(0);
assertChildren(branch, new int[] { 0, 5, 5, 9, 16, 21 }, new AttributeSet[] { null,
bold, null });
assertEquals(2, branch.getAttributeCount());
assertTrue(branch.isDefined(AttributeSet.ResolveAttribute));
assertTrue(branch.containsAttributes(bold));
}
项目:freeVM
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSBody() throws Exception {
AbstractElement body =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", body.getName());
assertTrue(body instanceof BlockElement);
body.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
body.addAttribute(HTML.Attribute.BACKGROUND, "bg.jpg");
body.addAttribute(HTML.Attribute.TEXT, "black");
body.addAttribute(HTML.Attribute.LINK, "blue");
body.addAttribute(HTML.Attribute.ALINK, "red");
body.addAttribute(HTML.Attribute.VLINK, "purple");
attr = ss.translateHTMLToCSS(body);
assertSame(NamedStyle.class, attr.getClass());
assertNull(((NamedStyle)attr).getName());
assertEquals(3, attr.getAttributeCount());
assertEquals(isHarmony() ? "url(bg.jpg)" : "bg.jpg",
attr.getAttribute(CSS.Attribute.BACKGROUND_IMAGE)
.toString());
assertEquals("#ffffff",
attr.getAttribute(CSS.Attribute.BACKGROUND_COLOR)
.toString());
assertEquals("black",
attr.getAttribute(CSS.Attribute.COLOR).toString());
}
项目:freeVM
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSA() throws Exception {
doc.remove(0, doc.getLength());
HTMLEditorKit kit = new HTMLEditorKit();
kit.read(new StringReader("<a href=\"http://go\">link</a>"), doc, 0);
AbstractElement body =
(AbstractElement)doc.getDefaultRootElement().getElement(1);
assertEquals("body", body.getName());
body.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
body.addAttribute(HTML.Attribute.BACKGROUND, "bg.jpg");
body.addAttribute(HTML.Attribute.TEXT, "black");
body.addAttribute(HTML.Attribute.LINK, "blue");
body.addAttribute(HTML.Attribute.ALINK, "red");
body.addAttribute(HTML.Attribute.VLINK, "purple");
AbstractElement a = (AbstractElement)doc.getCharacterElement(2);
assertNotNull(a.getAttribute(HTML.Tag.A));
attr = ss.translateHTMLToCSS(a);
assertNull(((NamedStyle)attr).getName());
assertEquals(0, attr.getAttributeCount());
}
项目:freeVM
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSAlignTop() throws Exception {
AbstractElement branch =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", branch.getName());
branch.addAttribute(HTML.Attribute.ALIGN, "top");
attr = ss.translateHTMLToCSS(branch);
if (isHarmony()) {
assertEquals(0, attr.getAttributeCount());
assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
} else {
assertEquals(1, attr.getAttributeCount());
assertEquals("top",
attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
}
}
项目:freeVM
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSAlignBottom() throws Exception {
AbstractElement branch =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", branch.getName());
branch.addAttribute(HTML.Attribute.ALIGN, "bottom");
attr = ss.translateHTMLToCSS(branch);
if (isHarmony()) {
assertEquals(0, attr.getAttributeCount());
assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
} else {
assertEquals(1, attr.getAttributeCount());
assertEquals("bottom",
attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
}
}
项目:freeVM
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSAlignChar() throws Exception {
AbstractElement branch =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", branch.getName());
branch.addAttribute(HTML.Attribute.ALIGN, "char");
attr = ss.translateHTMLToCSS(branch);
if (isHarmony()) {
assertEquals(0, attr.getAttributeCount());
assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
} else {
assertEquals(1, attr.getAttributeCount());
assertEquals("char",
attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
}
}
项目:freeVM
文件:DefaultStyledDocument_ElementsAndAttributesTest.java
/**
* Checks what happens when ResolveAttribute of a paragraph is set
* to non-Style object.
*/
public void testGetLogicalStyle03() {
final AbstractElement par = (AbstractElement) doc.getParagraphElement(5);
final MutableAttributeSet set = new SimpleAttributeSet();
StyleConstants.setForeground(set, Color.GREEN);
StyleConstants.setBackground(set, Color.YELLOW);
doc.writeLock();
try {
set.setResolveParent(boldItalic);
par.setResolveParent(set);
assertSame(set, par.getResolveParent());
assertNull(doc.getLogicalStyle(5));
} finally {
doc.writeUnlock();
}
}
项目:freeVM
文件:DefaultStyledDocument_ElementBuffer_RemoveTest.java
/**
* This removes only one character from the document: the new line which
* separates two paragraphs.
* The paragraphs merge into one. All their child elements which are
* not entirely contained in the remove region are copied into the
* new paragraph.
*/
public void testRemoveParagraphBreak() throws Exception {
final int offset = paragraph.getEndOffset() - 1;
final int length = 1;
((AbstractElement) paragraph).addAttributes(bold);
buf.remove(offset, length, createEvent(offset, length));
final List<?> edits = getEdits(event);
assertEquals(1, edits.size());
assertChange(edits.get(0), root, 0, new int[] { 0, 16, 16, 21 }, new int[] { 0, 21 });
final AbstractElement branch = (AbstractElement) root.getElement(0);
assertChildren(branch, new int[] { 0, 5, 5, 9, 9, 15, 16, 21 }, new AttributeSet[] {
null, bold, italic, null });
assertEquals(2, branch.getAttributeCount());
assertTrue(branch.isDefined(AttributeSet.ResolveAttribute));
assertTrue(branch.containsAttributes(bold));
}
项目:freeVM
文件:DefaultStyledDocument_ElementBuffer_RemoveTest.java
/**
* Removes an entire element before the paragraph break as well the break
* itself.
* Two paragraphs merge. The resulting paragraph doesn't contain the
* child elements which were entirely contained in the remove region.
*/
public void testRemoveFullElementParagraphBreak() throws Exception {
final Element italicElement = paragraph.getElement(2);
final int offset = italicElement.getStartOffset();
final int length = paragraph.getEndOffset() - offset;
((AbstractElement) paragraph).addAttributes(bold);
buf.remove(offset, length, createEvent(offset, length));
final List<?> edits = getEdits(event);
assertEquals(1, edits.size());
assertChange(edits.get(0), root, 0, new int[] { 0, 16, 16, 21 }, new int[] { 0, 21 });
final AbstractElement branch = (AbstractElement) root.getElement(0);
assertChildren(branch, new int[] { 0, 5, 5, 9, 16, 21 }, new AttributeSet[] { null,
bold, null });
assertEquals(2, branch.getAttributeCount());
assertTrue(branch.isDefined(AttributeSet.ResolveAttribute));
assertTrue(branch.containsAttributes(bold));
}
项目:freeVM
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSBody() throws Exception {
AbstractElement body =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", body.getName());
assertTrue(body instanceof BlockElement);
body.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
body.addAttribute(HTML.Attribute.BACKGROUND, "bg.jpg");
body.addAttribute(HTML.Attribute.TEXT, "black");
body.addAttribute(HTML.Attribute.LINK, "blue");
body.addAttribute(HTML.Attribute.ALINK, "red");
body.addAttribute(HTML.Attribute.VLINK, "purple");
attr = ss.translateHTMLToCSS(body);
assertSame(NamedStyle.class, attr.getClass());
assertNull(((NamedStyle)attr).getName());
assertEquals(3, attr.getAttributeCount());
assertEquals(isHarmony() ? "url(bg.jpg)" : "bg.jpg",
attr.getAttribute(CSS.Attribute.BACKGROUND_IMAGE)
.toString());
assertEquals("#ffffff",
attr.getAttribute(CSS.Attribute.BACKGROUND_COLOR)
.toString());
assertEquals("black",
attr.getAttribute(CSS.Attribute.COLOR).toString());
}
项目:freeVM
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSA() throws Exception {
doc.remove(0, doc.getLength());
HTMLEditorKit kit = new HTMLEditorKit();
kit.read(new StringReader("<a href=\"http://go\">link</a>"), doc, 0);
AbstractElement body =
(AbstractElement)doc.getDefaultRootElement().getElement(1);
assertEquals("body", body.getName());
body.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
body.addAttribute(HTML.Attribute.BACKGROUND, "bg.jpg");
body.addAttribute(HTML.Attribute.TEXT, "black");
body.addAttribute(HTML.Attribute.LINK, "blue");
body.addAttribute(HTML.Attribute.ALINK, "red");
body.addAttribute(HTML.Attribute.VLINK, "purple");
AbstractElement a = (AbstractElement)doc.getCharacterElement(2);
assertNotNull(a.getAttribute(HTML.Tag.A));
attr = ss.translateHTMLToCSS(a);
assertNull(((NamedStyle)attr).getName());
assertEquals(0, attr.getAttributeCount());
}
项目:freeVM
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSAlignTop() throws Exception {
AbstractElement branch =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", branch.getName());
branch.addAttribute(HTML.Attribute.ALIGN, "top");
attr = ss.translateHTMLToCSS(branch);
if (isHarmony()) {
assertEquals(0, attr.getAttributeCount());
assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
} else {
assertEquals(1, attr.getAttributeCount());
assertEquals("top",
attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
}
}
项目:freeVM
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSAlignBottom() throws Exception {
AbstractElement branch =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", branch.getName());
branch.addAttribute(HTML.Attribute.ALIGN, "bottom");
attr = ss.translateHTMLToCSS(branch);
if (isHarmony()) {
assertEquals(0, attr.getAttributeCount());
assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
} else {
assertEquals(1, attr.getAttributeCount());
assertEquals("bottom",
attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
}
}
项目:freeVM
文件:StyleSheet_TranslateHTMLToCSS.java
public void testTranslateHTMLToCSSAlignChar() throws Exception {
AbstractElement branch =
(AbstractElement)doc.getDefaultRootElement().getElement(0);
assertEquals("body", branch.getName());
branch.addAttribute(HTML.Attribute.ALIGN, "char");
attr = ss.translateHTMLToCSS(branch);
if (isHarmony()) {
assertEquals(0, attr.getAttributeCount());
assertNull(attr.getAttribute(CSS.Attribute.TEXT_ALIGN));
} else {
assertEquals(1, attr.getAttributeCount());
assertEquals("char",
attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
}
}
项目:jdk8u-jdk
文件:bug7165725.java
public void checkStructureEquivalence(AbstractDocument.AbstractElement elem) {
String name = elem.getName();
if (!goldenName.equals(name)) {
throw new RuntimeException("Bad structure: expected element name is '" + goldenName + "' but the actual name was '" + name + "'.");
}
int goldenChildCount = goldenChildren.size();
int childCount = elem.getChildCount();
if (childCount != goldenChildCount) {
System.out.print("D: children: ");
for (int i = 0; i < childCount; i++) {
System.out.print(" " + elem.getElement(i).getName());
}
System.out.println("");
System.out.print("D: goldenChildren: ");
for (GoldenElement ge : goldenChildren) {
System.out.print(" " + ge.goldenName);
}
System.out.println("");
throw new RuntimeException("Bad structure: expected child count of element '" + goldenName + "' is '" + goldenChildCount + "' but the actual count was '" + childCount + "'.");
}
for (int i = 0; i < childCount; i++) {
AbstractDocument.AbstractElement nextElem = (AbstractDocument.AbstractElement) elem.getElement(i);
GoldenElement goldenElement = goldenChildren.get(i);
goldenElement.checkStructureEquivalence(nextElem);
}
}
项目:openjdk-jdk10
文件:bug7165725.java
public void checkStructureEquivalence(AbstractDocument.AbstractElement elem) {
String name = elem.getName();
if (!goldenName.equals(name)) {
throw new RuntimeException("Bad structure: expected element name is '" + goldenName + "' but the actual name was '" + name + "'.");
}
int goldenChildCount = goldenChildren.size();
int childCount = elem.getChildCount();
if (childCount != goldenChildCount) {
System.out.print("D: children: ");
for (int i = 0; i < childCount; i++) {
System.out.print(" " + elem.getElement(i).getName());
}
System.out.println("");
System.out.print("D: goldenChildren: ");
for (GoldenElement ge : goldenChildren) {
System.out.print(" " + ge.goldenName);
}
System.out.println("");
throw new RuntimeException("Bad structure: expected child count of element '" + goldenName + "' is '" + goldenChildCount + "' but the actual count was '" + childCount + "'.");
}
for (int i = 0; i < childCount; i++) {
AbstractDocument.AbstractElement nextElem = (AbstractDocument.AbstractElement) elem.getElement(i);
GoldenElement goldenElement = goldenChildren.get(i);
goldenElement.checkStructureEquivalence(nextElem);
}
}
项目:openjdk9
文件:bug7165725.java
public void checkStructureEquivalence(AbstractDocument.AbstractElement elem) {
String name = elem.getName();
if (!goldenName.equals(name)) {
throw new RuntimeException("Bad structure: expected element name is '" + goldenName + "' but the actual name was '" + name + "'.");
}
int goldenChildCount = goldenChildren.size();
int childCount = elem.getChildCount();
if (childCount != goldenChildCount) {
System.out.print("D: children: ");
for (int i = 0; i < childCount; i++) {
System.out.print(" " + elem.getElement(i).getName());
}
System.out.println("");
System.out.print("D: goldenChildren: ");
for (GoldenElement ge : goldenChildren) {
System.out.print(" " + ge.goldenName);
}
System.out.println("");
throw new RuntimeException("Bad structure: expected child count of element '" + goldenName + "' is '" + goldenChildCount + "' but the actual count was '" + childCount + "'.");
}
for (int i = 0; i < childCount; i++) {
AbstractDocument.AbstractElement nextElem = (AbstractDocument.AbstractElement) elem.getElement(i);
GoldenElement goldenElement = goldenChildren.get(i);
goldenElement.checkStructureEquivalence(nextElem);
}
}
项目:jdk8u_jdk
文件:bug7165725.java
public void checkStructureEquivalence(AbstractDocument.AbstractElement elem) {
String name = elem.getName();
if (!goldenName.equals(name)) {
throw new RuntimeException("Bad structure: expected element name is '" + goldenName + "' but the actual name was '" + name + "'.");
}
int goldenChildCount = goldenChildren.size();
int childCount = elem.getChildCount();
if (childCount != goldenChildCount) {
System.out.print("D: children: ");
for (int i = 0; i < childCount; i++) {
System.out.print(" " + elem.getElement(i).getName());
}
System.out.println("");
System.out.print("D: goldenChildren: ");
for (GoldenElement ge : goldenChildren) {
System.out.print(" " + ge.goldenName);
}
System.out.println("");
throw new RuntimeException("Bad structure: expected child count of element '" + goldenName + "' is '" + goldenChildCount + "' but the actual count was '" + childCount + "'.");
}
for (int i = 0; i < childCount; i++) {
AbstractDocument.AbstractElement nextElem = (AbstractDocument.AbstractElement) elem.getElement(i);
GoldenElement goldenElement = goldenChildren.get(i);
goldenElement.checkStructureEquivalence(nextElem);
}
}
项目:lookaside_java-1.8.0-openjdk
文件:bug7165725.java
public void checkStructureEquivalence(AbstractDocument.AbstractElement elem) {
String name = elem.getName();
if (!goldenName.equals(name)) {
throw new RuntimeException("Bad structure: expected element name is '" + goldenName + "' but the actual name was '" + name + "'.");
}
int goldenChildCount = goldenChildren.size();
int childCount = elem.getChildCount();
if (childCount != goldenChildCount) {
System.out.print("D: children: ");
for (int i = 0; i < childCount; i++) {
System.out.print(" " + elem.getElement(i).getName());
}
System.out.println("");
System.out.print("D: goldenChildren: ");
for (GoldenElement ge : goldenChildren) {
System.out.print(" " + ge.goldenName);
}
System.out.println("");
throw new RuntimeException("Bad structure: expected child count of element '" + goldenName + "' is '" + goldenChildCount + "' but the actual count was '" + childCount + "'.");
}
for (int i = 0; i < childCount; i++) {
AbstractDocument.AbstractElement nextElem = (AbstractDocument.AbstractElement) elem.getElement(i);
GoldenElement goldenElement = goldenChildren.get(i);
goldenElement.checkStructureEquivalence(nextElem);
}
}
项目:infobip-open-jdk-8
文件:bug7165725.java
public void checkStructureEquivalence(AbstractDocument.AbstractElement elem) {
String name = elem.getName();
if (!goldenName.equals(name)) {
throw new RuntimeException("Bad structure: expected element name is '" + goldenName + "' but the actual name was '" + name + "'.");
}
int goldenChildCount = goldenChildren.size();
int childCount = elem.getChildCount();
if (childCount != goldenChildCount) {
System.out.print("D: children: ");
for (int i = 0; i < childCount; i++) {
System.out.print(" " + elem.getElement(i).getName());
}
System.out.println("");
System.out.print("D: goldenChildren: ");
for (GoldenElement ge : goldenChildren) {
System.out.print(" " + ge.goldenName);
}
System.out.println("");
throw new RuntimeException("Bad structure: expected child count of element '" + goldenName + "' is '" + goldenChildCount + "' but the actual count was '" + childCount + "'.");
}
for (int i = 0; i < childCount; i++) {
AbstractDocument.AbstractElement nextElem = (AbstractDocument.AbstractElement) elem.getElement(i);
GoldenElement goldenElement = goldenChildren.get(i);
goldenElement.checkStructureEquivalence(nextElem);
}
}
项目:jdk8u-dev-jdk
文件:bug7165725.java
public void checkStructureEquivalence(AbstractDocument.AbstractElement elem) {
String name = elem.getName();
if (!goldenName.equals(name)) {
throw new RuntimeException("Bad structure: expected element name is '" + goldenName + "' but the actual name was '" + name + "'.");
}
int goldenChildCount = goldenChildren.size();
int childCount = elem.getChildCount();
if (childCount != goldenChildCount) {
System.out.print("D: children: ");
for (int i = 0; i < childCount; i++) {
System.out.print(" " + elem.getElement(i).getName());
}
System.out.println("");
System.out.print("D: goldenChildren: ");
for (GoldenElement ge : goldenChildren) {
System.out.print(" " + ge.goldenName);
}
System.out.println("");
throw new RuntimeException("Bad structure: expected child count of element '" + goldenName + "' is '" + goldenChildCount + "' but the actual count was '" + childCount + "'.");
}
for (int i = 0; i < childCount; i++) {
AbstractDocument.AbstractElement nextElem = (AbstractDocument.AbstractElement) elem.getElement(i);
GoldenElement goldenElement = goldenChildren.get(i);
goldenElement.checkStructureEquivalence(nextElem);
}
}
项目:OLD-OpenJDK8
文件:bug7165725.java
public void checkStructureEquivalence(AbstractDocument.AbstractElement elem) {
String name = elem.getName();
if (!goldenName.equals(name)) {
throw new RuntimeException("Bad structure: expected element name is '" + goldenName + "' but the actual name was '" + name + "'.");
}
int goldenChildCount = goldenChildren.size();
int childCount = elem.getChildCount();
if (childCount != goldenChildCount) {
System.out.print("D: children: ");
for (int i = 0; i < childCount; i++) {
System.out.print(" " + elem.getElement(i).getName());
}
System.out.println("");
System.out.print("D: goldenChildren: ");
for (GoldenElement ge : goldenChildren) {
System.out.print(" " + ge.goldenName);
}
System.out.println("");
throw new RuntimeException("Bad structure: expected child count of element '" + goldenName + "' is '" + goldenChildCount + "' but the actual count was '" + childCount + "'.");
}
for (int i = 0; i < childCount; i++) {
AbstractDocument.AbstractElement nextElem = (AbstractDocument.AbstractElement) elem.getElement(i);
GoldenElement goldenElement = goldenChildren.get(i);
goldenElement.checkStructureEquivalence(nextElem);
}
}
项目:cn1
文件:DefaultStyledDocument_ElementsAndAttributesTest.java
/**
* Checks that logical style is ResolveAttribute of paragraph.
*/
public void testGetLogicalStyle02() {
final StyleContext context = new StyleContext();
final Style style = context.addStyle("aStyle", null);
final AbstractElement par = (AbstractElement) doc.getParagraphElement(5);
doc.writeLock();
try {
par.addAttribute(AttributeSet.ResolveAttribute, style);
assertSame(style, doc.getLogicalStyle(5));
} finally {
doc.writeUnlock();
}
}
项目:cn1
文件:DefaultStyledDocumentTest.java
public void testCreateDefaultRoot() {
AbstractElement defRoot = doc.createDefaultRoot();
assertTrue(defRoot instanceof SectionElement);
assertEquals(0, defRoot.getAttributeCount());
assertEquals(1, defRoot.getElementCount());
assertTrue(defRoot.getElement(0) instanceof BranchElement);
}
项目:cn1
文件:AbstractDocument_AbstractElementTest.java
public void testDumpAtTextLimit() throws BadLocationException {
String dump = "<bidi root>\n" + " <bidi level\n" + " bidiLevel=0\n" + " >\n"
+ " [0,40][123456789\n" + "123456789\n" + "123456789\n" + "aaabbbccc\n"
+ "]\n";
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(out);
aDocument.insertString(0, dumpTextAtLimit, null);
((AbstractElement) aDocument.getBidiRootElement()).dump(ps, 0);
assertEquals(dump, AbstractDocumentTest.filterNewLines(out.toString()));
}
项目:cn1
文件:AbstractDocument_AbstractElementTest.java
public void testDumpBeyondTextLimit() throws BadLocationException {
String dump = "<bidi root>\n" + " <bidi level\n" + " bidiLevel=0\n" + " >\n"
+ " [0,50][123456789\n" + "123456789\n" + "123456789\n" + "aaabbbccc1...]\n";
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(out);
aDocument.insertString(0, dumpTextBeyondLimit, null);
((AbstractElement) aDocument.getBidiRootElement()).dump(ps, 0);
assertEquals(dump, AbstractDocumentTest.filterNewLines(out.toString()));
}
项目:cn1
文件:AbstractDocument_AbstractElementRTest.java
public void testGetNameParent() throws Exception {
final String parentName = "parentName";
attrs.addAttribute(AbstractDocument.ElementNameAttribute, parentName);
BranchElement parent = doc.new BranchElement(null, attrs);
AbstractElement element = new AbstractElementImpl(doc, parent, null);
assertTrue(parent.isDefined(AbstractDocument.ElementNameAttribute));
assertEquals(parentName, parent.getName());
assertFalse(element.isDefined(AbstractDocument.ElementNameAttribute));
assertNull(element.getName());
}
项目:cn1
文件:DefaultStyledDocument_ElementBuffer_RemoveTest.java
/**
* Remove an entire paragraph.
* Despite it is not necessary to change the document structure,
* it is modified as if only part of the paragraph was removed.
* I.e. a new branch is created, and it contains the children from
* the following paragraph only because all child elements of the first
* paragraph fall into the remove region entirely.
*/
public void testRemoveFullParagraph() throws Exception {
final int offset = paragraph.getStartOffset();
final int length = paragraph.getEndOffset() - offset;
((AbstractElement) paragraph).addAttributes(bold);
buf.remove(offset, length, createEvent(offset, length));
final List<?> edits = getEdits(event);
assertEquals(1, edits.size());
assertChange(edits.get(0), root, 0, new int[] { 0, 16, 16, 21 }, new int[] { 16, 21 });
final AbstractElement branch = (AbstractElement) root.getElement(0);
assertChildren(branch, new int[] { 16, 21 }, new AttributeSet[] { null });
assertEquals(2, branch.getAttributeCount());
assertTrue(branch.isDefined(AttributeSet.ResolveAttribute));
assertTrue(branch.containsAttributes(bold));
}
项目:cn1
文件:AbstractDocument_BranchElement_TreeNodeTest.java
@Override
protected void setUp() throws Exception {
doc = new PlainDocument();
doc.insertString(0, AbstractDocument_BranchElementTest.LTR
+ AbstractDocument_BranchElementTest.RTL
+ AbstractDocument_BranchElementTest.LTR
+ AbstractDocument_BranchElementTest.RTL + "\n01234", null);
doc.writeLock();
aElement = (AbstractElement) doc.getDefaultRootElement();
parented = doc.new BranchElement(parent = aElement, null);
doc.writeUnlock();
}
项目:cn1
文件:HTMLDocument_BlockElementTest.java
public void testGetName() {
AbstractElement block = htmlDoc.new BlockElement(null, null);
assertEquals("paragraph", block.getName());
htmlDoc.lockWrite();
final String name = "asddsa";
block = htmlDoc.new BlockElement(null, null);
block.addAttribute(StyleConstants.NameAttribute, name);
assertEquals(name, block.getName());
}