home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.text;
-
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.io.PrintStream;
- import java.io.Serializable;
- import java.util.Enumeration;
-
- public abstract class AbstractDocument$AbstractElement implements Element, MutableAttributeSet, Serializable {
- // $FF: synthetic field
- private final AbstractDocument this$0;
- private Element parent;
- private transient AttributeSet attributes;
-
- public AbstractDocument$AbstractElement(AbstractDocument var1, Element var2, AttributeSet var3) {
- this.this$0 = var1;
- this.this$0 = var1;
- this.attributes = var3 != null ? var3.copyAttributes() : var1.getAttributeContext().getEmptySet();
- this.parent = var2;
- }
-
- private final void indent(PrintStream var1, int var2) {
- for(int var3 = 0; var3 < var2; ++var3) {
- var1.print(" ");
- }
-
- }
-
- public void dump(PrintStream var1, int var2) {
- this.indent(var1, var2);
- if (this.getName() == null) {
- var1.print("<??");
- } else {
- var1.print("<" + this.getName());
- }
-
- if (this.getAttributeCount() > 0) {
- var1.println("");
- Enumeration var3 = this.attributes.getAttributeNames();
-
- while(var3.hasMoreElements()) {
- Object var4 = var3.nextElement();
- this.indent(var1, var2 + 1);
- var1.println(var4 + "=" + this.getAttribute(var4));
- }
-
- this.indent(var1, var2);
- }
-
- var1.println(">");
- if (this.isLeaf()) {
- this.indent(var1, var2 + 1);
- var1.print("[" + this.getStartOffset() + "," + this.getEndOffset() + "]");
- AbstractDocument.Content var8 = this.this$0.getContent();
-
- try {
- String var10 = var8.getString(this.getStartOffset(), this.getEndOffset() - this.getStartOffset()).trim();
- if (var10.length() > 40) {
- var10 = var10.substring(0, 40) + "...";
- }
-
- var1.println(var10);
- } catch (BadLocationException var6) {
- }
- } else {
- int var7 = this.getElementCount();
-
- for(int var9 = 0; var9 < var7; ++var9) {
- AbstractDocument$AbstractElement var5 = (AbstractDocument$AbstractElement)this.getElement(var9);
- var5.dump(var1, var2 + 1);
- }
-
- }
- }
-
- protected void finalize() throws Throwable {
- AbstractDocument.AttributeContext var1 = this.this$0.getAttributeContext();
- var1.reclaim(this.attributes);
- }
-
- public int getAttributeCount() {
- return this.attributes.getAttributeCount();
- }
-
- public boolean isDefined(Object var1) {
- return this.attributes.isDefined(var1);
- }
-
- public boolean isEqual(AttributeSet var1) {
- return this.attributes.isEqual(var1);
- }
-
- public AttributeSet copyAttributes() {
- return this.attributes;
- }
-
- public Object getAttribute(Object var1) {
- Object var2 = this.attributes.getAttribute(var1);
- if (var2 == null) {
- AttributeSet var3 = this.getResolveParent();
- if (var3 != null) {
- var2 = var3.getAttribute(var1);
- }
- }
-
- return var2;
- }
-
- public Enumeration getAttributeNames() {
- return this.attributes.getAttributeNames();
- }
-
- public boolean containsAttribute(Object var1, Object var2) {
- return this.attributes.containsAttribute(var1, var2);
- }
-
- public boolean containsAttributes(AttributeSet var1) {
- return this.attributes.containsAttributes(var1);
- }
-
- public AttributeSet getResolveParent() {
- AttributeSet var1 = this.attributes.getResolveParent();
- if (var1 == null && this.parent != null) {
- var1 = this.parent.getAttributes();
- }
-
- return var1;
- }
-
- public void addAttribute(Object var1, Object var2) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var3 = this.this$0.getAttributeContext();
- this.attributes = var3.addAttribute(this.attributes, var1, var2);
- }
-
- public void addAttributes(AttributeSet var1) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var2 = this.this$0.getAttributeContext();
- this.attributes = var2.addAttributes(this.attributes, var1);
- }
-
- public void removeAttribute(Object var1) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var2 = this.this$0.getAttributeContext();
- this.attributes = var2.removeAttribute(this.attributes, var1);
- }
-
- public void removeAttributes(Enumeration var1) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var2 = this.this$0.getAttributeContext();
- this.attributes = var2.removeAttributes(this.attributes, var1);
- }
-
- public void removeAttributes(AttributeSet var1) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var2 = this.this$0.getAttributeContext();
- if (var1 == this) {
- this.attributes = var2.getEmptySet();
- } else {
- this.attributes = var2.removeAttributes(this.attributes, var1);
- }
- }
-
- public void setResolveParent(AttributeSet var1) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var2 = this.this$0.getAttributeContext();
- if (var1 != null) {
- this.attributes = var2.addAttribute(this.attributes, StyleConstants.ResolveAttribute, var1);
- } else {
- this.attributes = var2.removeAttribute(this.attributes, StyleConstants.ResolveAttribute);
- }
- }
-
- private final void checkForIllegalCast() {
- Thread var1 = this.this$0.getCurrentWriter();
- if (var1 == null || var1 != Thread.currentThread()) {
- throw new StateInvariantError("Illegal cast to MutableAttributeSet");
- }
- }
-
- public Document getDocument() {
- return this.this$0;
- }
-
- public Element getParentElement() {
- return this.parent;
- }
-
- public AttributeSet getAttributes() {
- return this;
- }
-
- public String getName() {
- return this.attributes.isDefined("$ename") ? (String)this.attributes.getAttribute("$ename") : null;
- }
-
- public abstract int getStartOffset();
-
- public abstract int getEndOffset();
-
- public abstract Element getElement(int var1);
-
- public abstract int getElementCount();
-
- public abstract int getElementIndex(int var1);
-
- public abstract boolean isLeaf();
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- var1.defaultWriteObject();
- StyleContext.writeAttributeSet(var1, this.attributes);
- }
-
- private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
- var1.defaultReadObject();
- SimpleAttributeSet var2 = new SimpleAttributeSet();
- StyleContext.readAttributeSet(var1, var2);
- AbstractDocument.AttributeContext var3 = this.this$0.getAttributeContext();
- this.attributes = var3.addAttributes(SimpleAttributeSet.EMPTY, var2);
- }
- }
-