本文整理汇总了Java中javax.swing.text.AttributeSet.getAttributeCount方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet.getAttributeCount方法的具体用法?Java AttributeSet.getAttributeCount怎么用?Java AttributeSet.getAttributeCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.AttributeSet
的用法示例。
在下文中一共展示了AttributeSet.getAttributeCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toAttrSetBuilder
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
static AttrSetBuilder toAttrSetBuilder(AttributeSet attrs) {
AttrSetBuilder builder = new AttrSetBuilder(attrs.getAttributeCount() << 1);
Enumeration<?> en = attrs.getAttributeNames();
while (en.hasMoreElements()) {
Object key = en.nextElement();
Object value = attrs.getAttribute(key);
builder.add(key, value);
}
return builder;
}
示例2: translate
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
public static Map<Attribute,Object> translate(AttributeSet attrs) {
int attrCount = attrs.getAttributeCount();
Map<Attribute,Object> ret = new HashMap<Attribute, Object>(attrCount);
for (Enumeration<?> attrNames = attrs.getAttributeNames(); attrNames.hasMoreElements();) {
Object attrName = attrNames.nextElement();
AttributeTranslateHandler handler = attr2Handler.get(attrName);
if (handler != null) {
Object textAttrValue = handler.getTextAttrValue(attrs.getAttribute(attrName));
if (textAttrValue != null) {
ret.put(handler.getTextAttr(), textAttrValue);
}
} // Unknown attributes are ignored
}
return ret;
}
示例3: isEqual
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
public boolean isEqual(AttributeSet attr) {
if(getAttributeCount() != attr.getAttributeCount()) return false;
return containsAttributes(attr);
}
示例4: isEqual
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
public boolean isEqual(AttributeSet attr) {
return (attr.getAttributeCount() == 1)
&& NAME.equals(attr.getAttribute(NameAttribute));
}
示例5: containsAttributes
import javax.swing.text.AttributeSet; //导入方法依赖的package包/类
public boolean containsAttributes(AttributeSet attributes) {
int attrCount = attributes.getAttributeCount();
return (attrCount == 0)
|| (attrCount == 1)
&& (NAME.equals(attributes.getAttribute(NameAttribute)));
}