List of usage examples for javax.swing.text Element getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:ShowHTMLViews.java
public static void displayElement(Document doc, Element e, int indent, PrintStream out) { for (int i = 0; i < indent; i++) { out.print(" "); }// w w w . j ava2 s . co m out.println("===== Element Class: " + getShortClassName(e.getClass())); for (int i = 0; i < indent; i++) { out.print(" "); } int startOffset = e.getStartOffset(); int endOffset = e.getEndOffset(); out.println("Offsets [" + startOffset + ", " + endOffset + "]"); AttributeSet a = e.getAttributes(); Enumeration x = a.getAttributeNames(); for (int i = 0; i < indent; i++) { out.print(" "); } out.println("ATTRIBUTES:"); while (x.hasMoreElements()) { for (int i = 0; i < indent; i++) { out.print(" "); } Object attr = x.nextElement(); out.println(" (" + attr + ", " + a.getAttribute(attr) + ")" + " [" + getShortClassName(attr.getClass()) + "/" + getShortClassName(a.getAttribute(attr).getClass()) + "] "); } // Display the text for a leaf element if (e.isLeaf()) { try { String str = doc.getText(startOffset, endOffset - startOffset); if (str.length() > 40) { str = str.substring(0, 40); } if (str.length() > 0) { for (int i = 0; i < indent; i++) { out.print(" "); } out.println("[" + str + "]"); } } catch (BadLocationException ex) { } } // Display child elements int count = e.getElementCount(); for (int i = 0; i < count; i++) { displayElement(doc, e.getElement(i), indent + 1, out); } }