当前位置: 首页>>代码示例>>Java>>正文


Java Element.getAttribute方法代码示例

本文整理汇总了Java中org.w3c.dom.Element.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getAttribute方法的具体用法?Java Element.getAttribute怎么用?Java Element.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Element的用法示例。


在下文中一共展示了Element.getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseArrayElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Parse an array element.
 */
public Object parseArrayElement(Element arrayEle, BeanDefinition bd) {
	String elementType = arrayEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
	NodeList nl = arrayEle.getChildNodes();
	ManagedArray target = new ManagedArray(elementType, nl.getLength());
	target.setSource(extractSource(arrayEle));
	target.setElementTypeName(elementType);
	target.setMergeEnabled(parseMergeAttribute(arrayEle));
	parseCollectionElements(nl, target, bd, elementType);
	return target;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:BeanDefinitionParserDelegate.java

示例2: decorate

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
    String propertyName = null;
    String converterClassName = null;
    if (node instanceof Element) {
        Element ele = (Element) node;
        if (ele.hasAttribute(PROPERTY_NAME)) {
            propertyName = ele.getAttribute(PROPERTY_NAME);
        }
        if (ele.hasAttribute(CONVERTER)) {
            converterClassName = ele.getAttribute(CONVERTER);
        }
    }

    // 为配置bean设置factory method
    Class<?> converterType = null;
    if (StringUtils.isNotEmpty(converterClassName)) {
        converterType = ClassUtils.resolveClassName(converterClassName, parserContext.getReaderContext().getBeanClassLoader());
    }
    ConfigBeanConfigUtils.setConfigBeanFactoryMethod(parserContext.getRegistry(),
            definition.getBeanName(), definition.getBeanDefinition(), propertyName, converterType);

    // 注册属性依赖
    DependencyConfigUtils.registerDependency(parserContext.getRegistry(), definition.getBeanName(), new String[]{propertyName});

    return definition;
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:28,代码来源:ConfigBeanBeanDefinitionDecorator.java

示例3: parsePropsElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Parse a props element.
 */
public Properties parsePropsElement(Element propsEle) {
	ManagedProperties props = new OrderedManagedProperties();
	props.setSource(extractSource(propsEle));
	props.setMergeEnabled(parseMergeAttribute(propsEle));

	List propEles = DomUtils.getChildElementsByTagName(propsEle, BeanDefinitionParserDelegate.PROP_ELEMENT);
	for (Iterator it = propEles.iterator(); it.hasNext();) {
		Element propEle = (Element) it.next();
		String key = propEle.getAttribute(BeanDefinitionParserDelegate.KEY_ATTRIBUTE);
		// Trim the text value to avoid unwanted whitespace
		// caused by typical XML formatting.
		String value = DomUtils.getTextValue(propEle).trim();

		TypedStringValue keyHolder = new TypedStringValue(key);
		keyHolder.setSource(extractSource(propEle));
		TypedStringValue valueHolder = new TypedStringValue(value);
		valueHolder.setSource(extractSource(propEle));
		props.put(keyHolder, valueHolder);
	}

	return props;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:26,代码来源:BlueprintParser.java

示例4: configure

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public void configure(Element element) throws Exception {
	super.configure(element);
	
       String version = element.getAttribute("version");
       
       if (version == null) {
           String s = XMLUtils.prettyPrintDOM(element);
           EngineException ee = new EngineException(
               "Unable to find version number for the database object \"" + getName() + "\".\n" +
               "XML data: " + s
           );
           throw ee;
       }
       
       if (VersionUtils.compareMigrationVersion(version, ".m003") < 0) {
       	if (!dataFile.equals("")) dataFile = "'" + dataFile + "'";
		hasChanged = true;
		Engine.logBeans.warn("[ReadFileStep] The object \"" + getName()+ "\" has been updated to .m003 version");
       }
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:22,代码来源:ReadFileStep.java

示例5: parsePropertyElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
private void parsePropertyElement(Element ele, BeanDefinition bd) {
	String propertyName = ele.getAttribute(BeanDefinitionParserDelegate.NAME_ATTRIBUTE);
	if (!StringUtils.hasLength(propertyName)) {
		error("Tag 'property' must have a 'name' attribute", ele);
		return;
	}
	this.parseState.push(new PropertyEntry(propertyName));
	try {
		if (bd.getPropertyValues().contains(propertyName)) {
			error("Multiple 'property' definitions for property '" + propertyName + "'", ele);
			return;
		}
		Object val = parsePropertyValue(ele, bd, propertyName);
		PropertyValue pv = new PropertyValue(propertyName, val);
		pv.setSource(parserContext.extractSource(ele));
		bd.getPropertyValues().addPropertyValue(pv);
	} finally {
		this.parseState.pop();
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:21,代码来源:BlueprintParser.java

示例6: readGroups

import org.w3c.dom.Element; //导入方法依赖的package包/类
private void readGroups(NodeList configFileGroupEls, File basedir, List<ConfigFileGroup> groups) {
    for (int i = 0; i < configFileGroupEls.getLength(); i++) {
        Element configFileGroupEl = (Element)configFileGroupEls.item(i);
        String name = configFileGroupEl.getAttribute(NAME);
        NodeList configFileEls = configFileGroupEl.getElementsByTagNameNS(SPRING_DATA_NS, CONFIG_FILE);
        List<File> configFiles = new ArrayList<File>(configFileEls.getLength());
        readFiles(configFileEls, basedir, configFiles);
        groups.add(ConfigFileGroup.create(name, configFiles));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ProjectConfigFileManagerImpl.java

示例7: parseColumnNames

import org.w3c.dom.Element; //导入方法依赖的package包/类
public String[] parseColumnNames(Element e) {
	String colAttr = e.getAttribute("column");
	String[] columnNames = null;
	if (!StringUtil.isEmpty(colAttr))
		columnNames = new String[] { colAttr };
	else {
		Element colsElement = XMLUtil.getChildElement(e, false, true, "columns");
		Element[] colElements = XMLUtil.getChildElements(colsElement, false, "column");
		for (Element colElement : colElements)
			columnNames = ArrayUtil.append(colElement.getAttribute("name"), columnNames);
	}
	return columnNames;
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:14,代码来源:XMLModelImporter.java

示例8: StepConditionDescriptor

import org.w3c.dom.Element; //导入方法依赖的package包/类
StepConditionDescriptor(Element stepConditionElement) {
    

    try {
        setId(Integer.parseInt(stepConditionElement.getAttribute("id")));
    } catch (NumberFormatException e) {
        // throw new IllegalArgumentException("Invalid Step Condition id value: " + stepConditionElement.getAttribute("id"));
    }

    this.restriction = new RestrictionDescriptor(XMLHelper.getChildElement(stepConditionElement, "restrict-to"));
    this.name = stepConditionElement.getAttribute("name");
}
 
开发者ID:will-gilbert,项目名称:OSWf-OSWorkflow-fork,代码行数:13,代码来源:StepConditionDescriptor.java

示例9: addMetaNode

import org.w3c.dom.Element; //导入方法依赖的package包/类
protected void addMetaNode(Element metaElement) {
	String name = metaElement.getAttribute("name");
	String value = metaElement.getAttribute("value");
	String score = metaElement.getAttribute("score");
	MetaNode metaNode = new MetaNode(name, value, score);

	Collection<MetaNode> metaNodesForName = metaNodes.get(name);
	if (metaNodesForName == null) {
		metaNodesForName = new ArrayList<MetaNode>();
		metaNodes.put(name, metaNodesForName);
	}
	metaNodesForName.add(metaNode);

	
	
	
	NodeList nodeList = metaElement.getChildNodes();
	if (nodeList == null) return;

	for (int n = 0; n < nodeList.getLength(); n++) {
		Node childNode = nodeList.item(n);
		if (childNode.getNodeType() == Node.ELEMENT_NODE) {
			Element childElement = (Element)childNode;
			if ("META".equals(childElement.getNodeName())) {
				metaNode.addMetaNode(childElement);
			}
		}
	}
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:30,代码来源:MetadataHoldingObject.java

示例10: getFloatAttribute

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Get a floating point attribute that may appear in either the default or
 * SODIPODI namespace
 * 
 * @param element The element from which the attribute should be read
 * @param attr The attribute to be read
 * @return The value from the given attribute
 * @throws ParsingException Indicates the value in the attribute was not a float
 */
static float getFloatAttribute(Element element, String attr) throws ParsingException {
	String cx = element.getAttribute(attr);
	if ((cx == null) || (cx.equals(""))) {
		cx = element.getAttributeNS(SODIPODI, attr);
	}
	
	try {
		return Float.parseFloat(cx);
	} catch (NumberFormatException e) {
		throw new ParsingException(element, "Invalid value for: "+attr, e);
	}
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:22,代码来源:Util.java

示例11: VersionInfo

import org.w3c.dom.Element; //导入方法依赖的package包/类
public VersionInfo(Element element) {
	logger.debug("Constructor - entry");

	NodeList nodeList = element.getChildNodes();
	for (int n = 0; n < nodeList.getLength(); n++) {
		Node node = nodeList.item(n);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element childElement = (Element) node;

			if ("VERSION".equals(childElement.getNodeName())) {
				String name = childElement.getAttribute("NAME");
				String revision = childElement.getAttribute("REVISION");
				if ("Compatible index structure version".equals(name)) {
					setIndexStructure(revision);
				} else if ("SES API version".equals(name)) {
					setApi(revision);
				} else if ("SES build".equals(name)) {
					setBuild(revision);
				} else {
					logger.trace("Unexpected version information: " + name + " (" + revision + ")");
				}
			} else {
				logger.trace("Unrecognized child node: '" + childElement.getNodeName() + "'");
			}
		} else if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue() != null) && (node.getNodeValue().trim().length() > 0)) {
			logger.trace("Unexpected text node (" + this.getClass().getName() + "): '" + node.getNodeValue() + "'");
		}
	}
	NamedNodeMap namedNodeMap = element.getAttributes();
	if (namedNodeMap != null) {
		for (int a = 0; a < namedNodeMap.getLength(); a++) {
			Attr attributeNode = (Attr) namedNodeMap.item(a);
			logger.trace("Unrecognized attribute: '" + attributeNode.getName() + "'");
		}
	}

	logger.debug("Constructor - exit");
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:39,代码来源:VersionInfo.java

示例12: Props

import org.w3c.dom.Element; //导入方法依赖的package包/类
Props(Element root) {
	String defaultCache = root.getAttribute("cache");
	key = root.getAttribute("key");
	condition = root.getAttribute("condition");
	method = root.getAttribute(METHOD_ATTRIBUTE);

	if (StringUtils.hasText(defaultCache)) {
		caches = StringUtils.commaDelimitedListToStringArray(defaultCache.trim());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:CacheAdviceParser.java

示例13: parseActionService

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static Metadata parseActionService(final Element element, final ParserContext context) {
    ComponentFactoryMetadata metadata = new ActionServiceMetadata(getId(context, element),
            element.getAttribute(INTERFACE));

    LOG.debug("parseActionService returning {}", metadata);

    return metadata;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:9,代码来源:OpendaylightNamespaceHandler.java

示例14: loadFunctions

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * function标签结构:
 * <function name="partbymonth" class="io.mycat.route.function.PartitionByMonth">
 *     <property name="dateFormat">yyyy-MM-dd</property>
 *     <property name="sBeginDate">2015-01-01</property>
 * </function>
 * @param root
 * @throws ClassNotFoundException
 * @throws InstantiationException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
    */
private void loadFunctions(Element root) throws ClassNotFoundException,
		InstantiationException, IllegalAccessException,
		InvocationTargetException {
	NodeList list = root.getElementsByTagName("function");
	for (int i = 0, n = list.getLength(); i < n; ++i) {
		Node node = list.item(i);
		if (node instanceof Element) {
			Element e = (Element) node;
			//获取name标签
			String name = e.getAttribute("name");
			//如果Map已有,则function重复
			if (functions.containsKey(name)) {
				throw new ConfigException("rule function " + name
						+ " duplicated!");
			}
			//获取class标签
			String clazz = e.getAttribute("class");
			//根据class利用反射新建分片算法
			AbstractPartitionAlgorithm function = createFunction(name, clazz);
			//根据读取参数配置分片算法
			ParameterMapping.mapping(function, ConfigUtil.loadElements(e));
			//每个AbstractPartitionAlgorithm可能会实现init来初始化
			function.init();
			//放入functions map
			functions.put(name, function);
		}
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:41,代码来源:XMLRuleLoader.java

示例15: doParse

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder) {
	String poolSize = element.getAttribute("pool-size");
	if (StringUtils.hasText(poolSize)) {
		builder.addPropertyValue("poolSize", poolSize);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SchedulerBeanDefinitionParser.java


注:本文中的org.w3c.dom.Element.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。