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


Java Element类代码示例

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


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

示例1: KalturaRule

import org.w3c.dom.Element; //导入依赖的package包/类
public KalturaRule(Element node) throws KalturaApiException {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("message")) {
            this.message = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("actions")) {
            this.actions = ParseUtils.parseArray(KalturaAccessControlAction.class, aNode);
            continue;
        } else if (nodeName.equals("conditions")) {
            this.conditions = ParseUtils.parseArray(KalturaCondition.class, aNode);
            continue;
        } else if (nodeName.equals("contexts")) {
            this.contexts = ParseUtils.parseArray(KalturaAccessControlContextTypeHolder.class, aNode);
            continue;
        } else if (nodeName.equals("stopProcessing")) {
            this.stopProcessing = ParseUtils.parseBool(txt);
            continue;
        } 
    }
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:25,代码来源:KalturaRule.java

示例2: loadTableRules

import org.w3c.dom.Element; //导入依赖的package包/类
/**
 * tableRule tag:
 * <tableRule name="sharding-by-month">
 * <rule>
 * <columns>create_date</columns>
 * <algorithm>partbymonth</algorithm>
 * </rule>
 * </tableRule>
 *
 * @param root
 * @throws SQLSyntaxErrorException
 */
private void loadTableRules(Element root) throws SQLSyntaxErrorException {
    NodeList list = root.getElementsByTagName("tableRule");
    for (int i = 0, n = list.getLength(); i < n; ++i) {
        Node node = list.item(i);
        if (node instanceof Element) {
            Element e = (Element) node;
            String name = e.getAttribute("name");
            if (StringUtil.isEmpty(name)) {
                throw new ConfigException("name is null or empty");
            }
            if (tableRules.containsKey(name)) {
                throw new ConfigException("table rule " + name + " duplicated!");
            }
            NodeList ruleNodes = e.getElementsByTagName("rule");
            int length = ruleNodes.getLength();
            if (length > 1) {
                throw new ConfigException("only one rule can defined :" + name);
            }
            //rule has only one element now. Maybe it will not contains one rule in feature
            //RuleConfig:rule->function
            RuleConfig rule = loadRule((Element) ruleNodes.item(0));
            tableRules.put(name, new TableRuleConfig(name, rule));
        }
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:38,代码来源:XMLRuleLoader.java

示例3: nextElement

import org.w3c.dom.Element; //导入依赖的package包/类
public static Element nextElement(Iterator iter) {
    while (iter.hasNext()) {
        Node n = (Node) iter.next();
        if (n instanceof Text) {
            Text t = (Text) n;
            if (t.getData().trim().length() == 0)
                continue;
            fail("parsing.nonWhitespaceTextFound", t.getData().trim());
        }
        if (n instanceof Comment)
            continue;
        if (!(n instanceof Element))
            fail("parsing.elementExpected");
        return (Element) n;
    }

    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Util.java

示例4: start

import org.w3c.dom.Element; //导入依赖的package包/类
/**  Start a session with Kaltura's server.   The result KS is the session key that
you should pass to all services that requires a ticket.     */
 public String start(String secret, String userId, KalturaSessionType type, int partnerId, int expiry, String privileges) throws KalturaApiException {
     KalturaParams kparams = new KalturaParams();
     kparams.add("secret", secret);
     kparams.add("userId", userId);
     kparams.add("type", type);
     kparams.add("partnerId", partnerId);
     kparams.add("expiry", expiry);
     kparams.add("privileges", privileges);
     this.kalturaClient.queueServiceCall("session", "start", kparams);
     if (this.kalturaClient.isMultiRequest())
         return null;
     Element resultXmlElement = this.kalturaClient.doQueue();
     String resultText = resultXmlElement.getTextContent();
     return ParseUtils.parseString(resultText);
 }
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:18,代码来源:KalturaSessionService.java

示例5: writeDefinitionToXML

import org.w3c.dom.Element; //导入依赖的package包/类
@Override
protected void writeDefinitionToXML(Element typeElement) {

	Element childTypesElement = XMLTools.addTag(typeElement, ELEMENT_CHILD_TYPES);
	for (ParameterType type : types) {
		Element childTypeElement = XMLTools.addTag(childTypesElement, ELEMENT_CHILD_TYPE);
		type.writeDefinitionToXML(childTypeElement);
	}

	// now default list
	Element defaultEntriesElement = XMLTools.addTag(typeElement, ELEMENT_DEFAULT_ENTRIES);
	for (Object defaultValue : defaultValues) {
		Element defaultEntryElement = XMLTools.addTag(defaultEntriesElement, ELEMENT_DEFAULT_ENTRY);
		if (defaultValue != null && defaultValue instanceof String) {
			defaultEntryElement.setTextContent(defaultValue.toString());
		} else {
			defaultEntriesElement.setAttribute(ATTRIBUTE_IS_NULL, "true");
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:21,代码来源:ParameterTypeTupel.java

示例6: getMapFromXML

import org.w3c.dom.Element; //导入依赖的package包/类
public static Map<String,Object> getMapFromXML(String xmlString) throws ParserConfigurationException, IOException, SAXException {

        //这里用Dom的方式解析回包的最主要目的是防止API新增回包字段
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputStream is =  IOUtils.toInputStream(xmlString);
        Document document = builder.parse(is);
        //获取到document里面的全部结点
        NodeList allNodes = document.getFirstChild().getChildNodes();
        Node node;
        Map<String, Object> map = new HashMap<String, Object>();
        int i=0;
        while (i < allNodes.getLength()) {
            node = allNodes.item(i);
            if(node instanceof Element){
                map.put(node.getNodeName(),node.getTextContent());
            }
            i++;
        }
        return map;

    }
 
开发者ID:1991wangliang,项目名称:pay,代码行数:23,代码来源:XMLParser.java

示例7: ExportCustomProperties

import org.w3c.dom.Element; //导入依赖的package包/类
/**
 * @param root
 */
public void ExportCustomProperties(Document doc)
{
	Element eForm = doc.getDocumentElement() ;
	if (!m_csCustomOnloadMethod.equals(""))
	{
		eForm.setAttribute("customOnload", m_csCustomOnloadMethod) ;
	}
	if (!m_csCustomSubmitMethod.equals(""))
	{
		eForm.setAttribute("customSubmit", m_csCustomSubmitMethod) ;
	}
	if (!m_csDefaultCursor.equals(""))
	{
		eForm.setAttribute("defaultCursor", m_csDefaultCursor) ;
	}
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:20,代码来源:CEntityResourceForm.java

示例8: KalturaCountryRestriction

import org.w3c.dom.Element; //导入依赖的package包/类
public KalturaCountryRestriction(Element node) throws KalturaApiException {
    super(node);
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("countryRestrictionType")) {
            this.countryRestrictionType = KalturaCountryRestrictionType.get(ParseUtils.parseInt(txt));
            continue;
        } else if (nodeName.equals("countryList")) {
            this.countryList = ParseUtils.parseString(txt);
            continue;
        } 
    }
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:17,代码来源:KalturaCountryRestriction.java

示例9: KalturaConversionAttribute

import org.w3c.dom.Element; //导入依赖的package包/类
public KalturaConversionAttribute(Element node) throws KalturaApiException {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("flavorParamsId")) {
            this.flavorParamsId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("name")) {
            this.name = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("value")) {
            this.value = ParseUtils.parseString(txt);
            continue;
        } 
    }
}
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:19,代码来源:KalturaConversionAttribute.java

示例10: visitRoot

import org.w3c.dom.Element; //导入依赖的package包/类
private Schema visitRoot(Node root, String nameSchema){
	Schema s = new Schema(nameSchema);
	types = new SetAssociativeArray();
	dummyNr = 0;
	//process the complexType nodes under the schema node
	NodeList children = root.getChildNodes();
	int nr=children.getLength();
	for(int j=0; j<nr; j++){
		if (children.item(j).getNodeName().equalsIgnoreCase("xs:complexType")){
			Node nodeCT = children.item(j);
			String name = getAttr("name",nodeCT);
			vtools.dataModel.schema.Element eCT = processComplexTypeNode(nodeCT,name,false);
			types.add(eCT.getLabel(), eCT.getType().clone());
		}	
	}
	//process the element nodes under the schema node
	for(int j=0; j<nr; j++){
		if (children.item(j).getNodeName().equalsIgnoreCase("xs:element")){
			vtools.dataModel.schema.Element elem = processElementNode(children.item(j));
			s.addRootElement(elem);
		}
	}
	
	return s;
}
 
开发者ID:RJMillerLab,项目名称:ibench,代码行数:26,代码来源:XSDReader.java

示例11: buildSingleMetadataResolver

import org.w3c.dom.Element; //导入依赖的package包/类
/**
 * Build single metadata resolver.
 *
 * @param metadataFilterChain the metadata filters chained together
 * @param resource the resource
 * @param document the xml document to parse
 * @return list of resolved metadata from resources.
 * @throws IOException the iO exception
 */
private List<MetadataResolver> buildSingleMetadataResolver(final MetadataFilter metadataFilterChain,
                                         final Resource resource, final Document document) throws IOException {
    final List<MetadataResolver> resolvers = new ArrayList<>();
    final Element metadataRoot = document.getDocumentElement();
    final DOMMetadataResolver metadataProvider = new DOMMetadataResolver(metadataRoot);

    metadataProvider.setParserPool(this.configBean.getParserPool());
    metadataProvider.setFailFastInitialization(true);
    metadataProvider.setRequireValidMetadata(this.requireValidMetadata);
    metadataProvider.setId(metadataProvider.getClass().getCanonicalName());
    if (metadataFilterChain != null) {
        metadataProvider.setMetadataFilter(metadataFilterChain);
    }
    logger.debug("Initializing metadata resolver for [{}]", resource.getURL());

    try {
        metadataProvider.initialize();
    } catch (final ComponentInitializationException ex) {
        logger.warn("Could not initialize metadata resolver. Resource will be ignored", ex);
    }
    resolvers.add(metadataProvider);
    return resolvers;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:33,代码来源:AbstractMetadataResolverAdapter.java

示例12: unmarshalParams

import org.w3c.dom.Element; //导入依赖的package包/类
private void unmarshalParams(Element paramsElem) {
    String prefixListAttr = paramsElem.getAttributeNS(null, "PrefixList");
    this.inclusiveNamespaces = prefixListAttr;
    int begin = 0;
    int end = prefixListAttr.indexOf(' ');
    List<String> prefixList = new ArrayList<String>();
    while (end != -1) {
        prefixList.add(prefixListAttr.substring(begin, end));
        begin = end + 1;
        end = prefixListAttr.indexOf(' ', begin);
    }
    if (begin <= prefixListAttr.length()) {
        prefixList.add(prefixListAttr.substring(begin));
    }
    this.params = new ExcC14NParameterSpec(prefixList);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:DOMExcC14NMethod.java

示例13: parseModel

import org.w3c.dom.Element; //导入依赖的package包/类
@Override
public Element parseModel(Document doc){
	Element process=doc.createElement("process");
	if(StringHelper.isNotEmpty(name)){
		process.setAttribute("name", name);
	}
	process.setAttribute("xmlns", "http://jbpm.org/4.4/jpdl");
	if(StringHelper.isNotEmpty(key)){
		process.setAttribute("key", key);
	}
	if(StringHelper.isNotEmpty(version)){
		process.setAttribute("version", version);
	}
	if(StringHelper.isNotEmpty(description)){
		Element desc=doc.createElement("description");
		desc.setTextContent(description);
		process.appendChild(desc);
	}
	return process;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:21,代码来源:ProcessDefinition.java

示例14: findSubElements

import org.w3c.dom.Element; //导入依赖的package包/类
/**
 * Find all direct child elements of an element.
 * More useful than {@link Element#getElementsByTagNameNS} because it does
 * not recurse into recursive child elements.
 * Children which are all-whitespace text nodes or comments are ignored; others cause
 * an exception to be thrown.
 * @param parent a parent element in a DOM tree
 * @return a list of direct child elements (may be empty)
 * @throws IllegalArgumentException if there are non-element children besides whitespace
 */
static List<Element> findSubElements(Element parent) throws IllegalArgumentException {
    NodeList l = parent.getChildNodes();
    List<Element> elements = new ArrayList<>(l.getLength());
    for (int i = 0; i < l.getLength(); i++) {
        Node n = l.item(i);
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            elements.add((Element)n);
        } else if (n.getNodeType() == Node.TEXT_NODE) {
            String text = ((Text)n).getNodeValue();
            if (text.trim().length() > 0) {
                throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
            }
        } else if (n.getNodeType() == Node.COMMENT_NODE) {
            // OK, ignore
        } else {
            throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
        }
    }
    return elements;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:XMLUtil.java

示例15: createGraphElement

import org.w3c.dom.Element; //导入依赖的package包/类
private Element createGraphElement(Element root) {
	Element graphEl = doc.createElement("graph");
	root.appendChild(graphEl);

	if (network.getEdgeCount(true) > network.getEdgeCount(false)) {
		graphEl.setAttribute("edgedefault", "directed");
	} else {
		graphEl.setAttribute("edgedefault", "undirected");
	}

	// Create nodes
	createNodes(graphEl);

	// Create edges
	createEdges(graphEl);

	return graphEl;
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:19,代码来源:GraphMLExporter.java


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