Method from javax.swing.text.html.MuxingAttributeSet Detail: |
public boolean containsAttribute(Object name,
Object value) {
return value.equals(getAttribute(name));
}
Checks whether a given attribute name/value is defined. |
public boolean containsAttributes(AttributeSet attrs) {
boolean result = true;
Enumeration names = attrs.getAttributeNames();
while (result && names.hasMoreElements()) {
Object name = names.nextElement();
result = attrs.getAttribute(name).equals(getAttribute(name));
}
return result;
}
Checks whether the attribute set contains all of
the given attributes. |
public AttributeSet copyAttributes() {
AttributeSet[] as = getAttributes();
MutableAttributeSet a = new SimpleAttributeSet();
int n = 0;
for (int i = as.length - 1; i >= 0; i--) {
a.addAttributes(as[i]);
}
return a;
}
Copies a set of attributes. |
public Object getAttribute(Object key) {
AttributeSet[] as = getAttributes();
int n = as.length;
for (int i = 0; i < n; i++) {
Object o = as[i].getAttribute(key);
if (o != null) {
return o;
}
}
return null;
}
Gets the value of an attribute. If the requested
attribute is a StyleConstants attribute that has
a CSS mapping, the request will be converted. |
public int getAttributeCount() {
AttributeSet[] as = getAttributes();
int n = 0;
for (int i = 0; i < as.length; i++) {
n += as[i].getAttributeCount();
}
return n;
}
Gets the number of attributes that are defined. |
public Enumeration getAttributeNames() {
return new MuxingAttributeNameEnumeration();
}
Gets the names of all attributes. |
protected synchronized AttributeSet[] getAttributes() {
return attrs;
}
Returns the AttributeSet s multiplexing too. When the
AttributeSet s need to be referenced, this should be called. |
public AttributeSet getResolveParent() {
return null;
}
Returns null, subclasses may wish to do something more
intelligent with this. |
protected synchronized void insertAttributeSetAt(AttributeSet as,
int index) {
int numAttrs = attrs.length;
AttributeSet newAttrs[] = new AttributeSet[numAttrs + 1];
if (index < numAttrs) {
if (index > 0) {
System.arraycopy(attrs, 0, newAttrs, 0, index);
System.arraycopy(attrs, index, newAttrs, index + 1,
numAttrs - index);
}
else {
System.arraycopy(attrs, 0, newAttrs, 1, numAttrs);
}
}
else {
System.arraycopy(attrs, 0, newAttrs, 0, numAttrs);
}
newAttrs[index] = as;
attrs = newAttrs;
}
Inserts as at index . This assumes
the value of index is between 0 and attrs.length,
inclusive. |
public boolean isDefined(Object key) {
AttributeSet[] as = getAttributes();
for (int i = 0; i < as.length; i++) {
if (as[i].isDefined(key)) {
return true;
}
}
return false;
}
Checks whether a given attribute is defined.
This will convert the key over to CSS if the
key is a StyleConstants key that has a CSS
mapping. |
public boolean isEqual(AttributeSet attr) {
return ((getAttributeCount() == attr.getAttributeCount()) &&
containsAttributes(attr));
}
Checks whether two attribute sets are equal. |
protected synchronized void removeAttributeSetAt(int index) {
int numAttrs = attrs.length;
AttributeSet[] newAttrs = new AttributeSet[numAttrs - 1];
if (numAttrs > 0) {
if (index == 0) {
// FIRST
System.arraycopy(attrs, 1, newAttrs, 0, numAttrs - 1);
}
else if (index < (numAttrs - 1)) {
// MIDDLE
System.arraycopy(attrs, 0, newAttrs, 0, index);
System.arraycopy(attrs, index + 1, newAttrs, index,
numAttrs - index - 1);
}
else {
// END
System.arraycopy(attrs, 0, newAttrs, 0, numAttrs - 1);
}
}
attrs = newAttrs;
}
Removes the AttributeSet at index . This assumes
the value of index is greater than or equal to 0,
and less than attrs.length. |
protected synchronized void setAttributes(AttributeSet[] attrs) {
this.attrs = attrs;
}
Directly sets the AttributeSet s that comprise this
MuxingAttributeSet . |