本文整理汇总了Java中org.jdom.Attribute.getIntValue方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.getIntValue方法的具体用法?Java Attribute.getIntValue怎么用?Java Attribute.getIntValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdom.Attribute
的用法示例。
在下文中一共展示了Attribute.getIntValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColorDescriptor
import org.jdom.Attribute; //导入方法依赖的package包/类
public static ColorDescriptor getColorDescriptor(final Element element) throws Exception {
Attribute attr = element.getAttribute(UIFormXmlConstants.ATTRIBUTE_COLOR);
if (attr != null) {
return new ColorDescriptor(new Color(attr.getIntValue()));
}
String swingColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_SWING_COLOR);
if (swingColor != null) {
return ColorDescriptor.fromSwingColor(swingColor);
}
String systemColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_SYSTEM_COLOR);
if (systemColor != null) {
return ColorDescriptor.fromSystemColor(systemColor);
}
String awtColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_AWT_COLOR);
if (awtColor != null) {
return ColorDescriptor.fromAWTColor(awtColor);
}
return new ColorDescriptor(null);
}
示例2: validateSection
import org.jdom.Attribute; //导入方法依赖的package包/类
private boolean validateSection(Element sectionElement, String expectedChildName, int attributes) {
// Check that section exists
if(sectionElement==null) return false;
// Go through children
Iterator iter = sectionElement.getChildren().iterator();
while(iter.hasNext()) {
Element e = (Element)iter.next();
// Check that child is expected
if(!e.getName().equals(expectedChildName)) return false;
// Check id attribute for existence, isnumber and range (1-4095)
if((attributes|ATTR_ID)!=0) {
Attribute a = e.getAttribute("id");
if(a==null) return false;
try {
int value = a.getIntValue();
if(value<=0||value>=(1<<ID_BITSHIFT)) return false;
} catch(DataConversionException ex) {
return false;
}
}
}
return true;
}
示例3: convertAttributeToInt
import org.jdom.Attribute; //导入方法依赖的package包/类
private static int convertAttributeToInt(final Attribute attribute) {
if (attribute == null) {
return 0;
}
try {
return attribute.getIntValue();
} catch (final Exception ignore) {
return 0;
}
}
示例4: isLeaf
import org.jdom.Attribute; //导入方法依赖的package包/类
public static boolean isLeaf(Element element){
if (!isNode(element))
return false;
Attribute leafAttribute = element.getAttribute("LEAF");
try {
return leafAttribute.getIntValue() == 1;
}
catch (Exception e) {
return false;
}
}
示例5: hasChildren
import org.jdom.Attribute; //导入方法依赖的package包/类
public static boolean hasChildren(Element element){
if (!isNode(element))
return false;
Attribute childcountAttribute = element.getAttribute("CHILDCOUNT");
try {
return childcountAttribute.getIntValue() > 0;
}
catch (Exception e) {
return false;
}
}
示例6: conv
import org.jdom.Attribute; //导入方法依赖的package包/类
/**
* Converts String into java primitive type
* @param type <code>Class</code> target type
* @param attr <code>Attribute</code> value field needs to provide convertable String
* @return <code>Object</code> primitive wrapped into wrapper object
*/
public static Object conv( final Class type, final Attribute attr, final Localizer localizer ) throws Exception {
Attribute a = (Attribute) attr.clone();
Object obj = null;
if ( Parser.LOCALIZED_ATTRIBUTES.contains( a.getName().toLowerCase() ))
if (a.getAttributeType() == Attribute.CDATA_TYPE )
a.setValue( localizer.getString( a.getValue() ));
try {
if (boolean.class.equals( type )) {
obj = new Boolean( a.getBooleanValue() );
} else if (int.class.equals( type )) {
obj = new Integer( a.getIntValue() );
} else if (long.class.equals( type )) {
obj = new Long( a.getLongValue() );
} else if (float.class.equals( type )) {
obj = new Float( a.getFloatValue() );
} else if (double.class.equals( type )) {
obj = new Double( a.getDoubleValue() );
}
} catch (DataConversionException e) {
} finally {
if (obj==null) {
try {
String s = a.getValue();
int k = s.indexOf( '.' ) - 1;
Class pp = (Class) dictionaries.get( s.substring( 0, s.indexOf( '.' ) ) );
obj = pp.getField( s.substring( k + 2 ) ).get( pp );
} catch (Exception ex) {
//
// Try to find the given value as a Constant in SwingConstants
//
obj = PrimitiveConverter.class.getField( a.getValue() ).get( PrimitiveConverter.class );
}
}
}
return obj;
}