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
- AbstractDocument this$0;
- private Element parent;
- private transient AttributeSet attributes;
-
- // $FF: synthetic method
- public AbstractDocument$AbstractElement(AbstractDocument this$0, Element parent, AttributeSet a) {
- this.this$0 = this$0;
- this.attributes = a != null ? a.copyAttributes() : this$0.getAttributeContext().getEmptySet();
- this.parent = parent;
- }
-
- private final void indent(PrintStream out, int n) {
- for(int i = 0; i < n; ++i) {
- out.print(" ");
- }
-
- }
-
- public void dump(PrintStream out, int indentAmount) {
- this.indent(out, indentAmount);
- if (this.getName() == null) {
- out.print("<??");
- } else {
- out.print("<" + this.getName());
- }
-
- if (this.getAttributeCount() > 0) {
- out.println("");
- Enumeration names = this.attributes.getAttributeNames();
-
- while(names.hasMoreElements()) {
- Object name = names.nextElement();
- this.indent(out, indentAmount + 1);
- out.println(name + "=" + this.getAttribute(name));
- }
-
- this.indent(out, indentAmount);
- }
-
- out.println(">");
- if (this.isLeaf()) {
- this.indent(out, indentAmount + 1);
- out.print("[" + this.getStartOffset() + "," + this.getEndOffset() + "]");
- AbstractDocument.Content c = this.this$0.getContent();
-
- try {
- String contentStr = c.getString(this.getStartOffset(), this.getEndOffset() - this.getStartOffset()).trim();
- if (contentStr.length() > 40) {
- contentStr = contentStr.substring(0, 40) + "...";
- }
-
- out.println(contentStr);
- } catch (BadLocationException var6) {
- }
- } else {
- int n = this.getElementCount();
-
- for(int i = 0; i < n; ++i) {
- AbstractDocument$AbstractElement e = (AbstractDocument$AbstractElement)this.getElement(i);
- e.dump(out, indentAmount + 1);
- }
- }
-
- }
-
- protected void finalize() throws Throwable {
- AbstractDocument.AttributeContext context = this.this$0.getAttributeContext();
- context.reclaim(this.attributes);
- }
-
- public int getAttributeCount() {
- return this.attributes.getAttributeCount();
- }
-
- public boolean isDefined(Object attrName) {
- return this.attributes.isDefined(attrName);
- }
-
- public boolean isEqual(AttributeSet attr) {
- return this.attributes.isEqual(attr);
- }
-
- public AttributeSet copyAttributes() {
- return this.attributes;
- }
-
- public Object getAttribute(Object attrName) {
- Object value = this.attributes.getAttribute(attrName);
- if (value == null) {
- AttributeSet a = this.parent != null ? this.parent.getAttributes() : null;
- if (a != null) {
- value = a.getAttribute(attrName);
- }
- }
-
- return value;
- }
-
- public Enumeration getAttributeNames() {
- return this.attributes.getAttributeNames();
- }
-
- public boolean containsAttribute(Object name, Object value) {
- return this.attributes.containsAttribute(name, value);
- }
-
- public boolean containsAttributes(AttributeSet attrs) {
- return this.attributes.containsAttributes(attrs);
- }
-
- public AttributeSet getResolveParent() {
- AttributeSet a = this.attributes.getResolveParent();
- if (a == null && this.parent != null) {
- a = this.parent.getAttributes();
- }
-
- return a;
- }
-
- public void addAttribute(Object name, Object value) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext context = this.this$0.getAttributeContext();
- this.attributes = context.addAttribute(this.attributes, name, value);
- }
-
- public void addAttributes(AttributeSet attr) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext context = this.this$0.getAttributeContext();
- this.attributes = context.addAttributes(this.attributes, attr);
- }
-
- public void removeAttribute(Object name) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext context = this.this$0.getAttributeContext();
- this.attributes = context.removeAttribute(this.attributes, name);
- }
-
- public void removeAttributes(Enumeration names) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext context = this.this$0.getAttributeContext();
- this.attributes = context.removeAttributes(this.attributes, names);
- }
-
- public void removeAttributes(AttributeSet attrs) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext context = this.this$0.getAttributeContext();
- if (attrs == this) {
- this.attributes = context.getEmptySet();
- } else {
- this.attributes = context.removeAttributes(this.attributes, attrs);
- }
-
- }
-
- public void setResolveParent(AttributeSet parent) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext context = this.this$0.getAttributeContext();
- if (parent != null) {
- this.attributes = context.addAttribute(this.attributes, StyleConstants.ResolveAttribute, parent);
- } else {
- this.attributes = context.removeAttribute(this.attributes, StyleConstants.ResolveAttribute);
- }
-
- }
-
- private final void checkForIllegalCast() {
- Thread t = this.this$0.getCurrentWriter();
- if (t == null || t != 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 s) throws IOException {
- s.defaultWriteObject();
- StyleContext.writeAttributeSet(s, this.attributes);
- }
-
- private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
- s.defaultReadObject();
- MutableAttributeSet attr = new SimpleAttributeSet();
- StyleContext.readAttributeSet(s, attr);
- AbstractDocument.AttributeContext context = this.this$0.getAttributeContext();
- this.attributes = context.addAttributes(SimpleAttributeSet.EMPTY, attr);
- }
- }
-