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


Java DefaultElement类代码示例

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


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

示例1: getXmlValueText

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
private Object getXmlValueText(List nodes) {
    if (nodes == null || nodes.isEmpty()) {
        return null;
    }
    Object node = nodes.get(0);
    if (node instanceof DefaultText) {
        return StringUtils.trim(((DefaultText) node).getText());
    }
    if (node instanceof DefaultAttribute) {
        return StringUtils.trim(((DefaultAttribute) node).getText());
    }
    if (node instanceof DefaultElement) {
        return StringUtils.trim(((DefaultElement) node).getText());
    }

    throw new IllegalArgumentException("unsupported node type ["+node+"].");
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:18,代码来源:XmlParser.java

示例2: MqResToDto

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
/**
 * 将mq查询结果包装成list--dto的形式,dto内容为item中的内容
 * 
 * @param recv
 * @return
 */
public static Map MqResToDto(String recv) {
    // System.out.println("####recv"+recv);
    List res = new ArrayList();
    Map map = new HashMap();
    try {
        Document doc = DocumentHelper.parseText(recv);
        List list = doc.selectNodes("//item");
        Iterator<DefaultElement> it = list.iterator();
        while (it.hasNext()) {
            Map elementdto = XmlUtil.Dom2Map(it.next());
            res.add(elementdto);
        }
        map.put("resultList", res);// 放入结果集
        /* 如果存在REC_MNT,说明是分页查询类,需要将总记录数返回 */
        Node de = doc.selectSingleNode("//REC_MNT");
        if (DataUtil.isNotEmpty(de)) {
            map.put("countInteger", de.getText());
        }
    } catch (Exception e) {
        logger.error("", e);
    }
    return map;
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:30,代码来源:XmlUtil.java

示例3: MqResToDto

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
/**
 * 将mq查询结果包装成list--dto的形式,dto内容为item中的内容
 * 
 * @param recv
 * @return
 */
public static Map MqResToDto(String recv) {
	// System.out.println("####recv"+recv);
	List res = new ArrayList();
	Map map = new HashMap();
	try {
		Document doc = DocumentHelper.parseText(recv);
		List list = doc.selectNodes("//item");
		Iterator<DefaultElement> it = list.iterator();
		while (it.hasNext()) {
			Map elementdto = XmlUtil.Dom2Map(it.next());
			res.add(elementdto);
		}
		map.put("resultList", res);// 放入结果集
		/*
		 * 如果存在REC_MNT,说明是分页查询类,需要将总记录数返回
		 */
		Node de = doc.selectSingleNode("//REC_MNT");
		if (DataUtil.isNotEmpty(de)) {
			map.put("countInteger", de.getText());
		}
	} catch (Exception e) {
		log.error(XmlUtil.class, e);
	}
	return map;
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:32,代码来源:XmlUtil.java

示例4: addAppMapping

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
@Override
public boolean addAppMapping(AppMappingConfig appMapping)
{
    try
    {
        Element rootElm = document.getRootElement();
        Element mappingEle = new DefaultElement("mapping");
        mappingEle.add(buildElement("deviceId", appMapping.getDeviceId()));
        mappingEle.add(buildElement("esdkApp", appMapping.getEsdkApp()));
        mappingEle.add(buildElement("deviceApp", appMapping.getDeviceApp()));
        mappingEle.add(buildElement("deviceAppPwd", appMapping.getDeviceAppPwd()));
        rootElm.add(mappingEle);
        
        writeXmlFile(document, this.file);
        
    }
    catch (IOException e)
    {
        LOGGER.error("", e);
        return false;
    }
    
    return true;
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:25,代码来源:AppMappingDAO.java

示例5: parseSeedsFromXML

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
private ReportSeedParsedVoCollection parseSeedsFromXML(String reportXML) throws DocumentException
{
	Document document = DocumentHelper.parseText(reportXML);

	ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
	List list = document.selectNodes("//Project/Seeds/Seed");
	for (Iterator iter = list.iterator(); iter.hasNext();)
	{
		DefaultElement attribute = (DefaultElement) iter.next();

		ReportSeedParsedVo seed = new ReportSeedParsedVo();
		seed.setName(attribute.valueOf("Name"));
		seed.setType(attribute.valueOf("Type"));
		seed.setBOName(attribute.valueOf("BOName"));
		seed.setBOField(attribute.valueOf("BOField"));
		seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
		seeds.add(seed);
	}

	return seeds;
}
 
开发者ID:oopcell,项目名称:AvoinApotti,代码行数:22,代码来源:Logic.java

示例6: parseSeedsFromXML

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
private void parseSeedsFromXML(String reportXML) throws DocumentException
{
	Document document = DocumentHelper.parseText(reportXML);

	ReportSeedParsedVoCollection seeds = new ReportSeedParsedVoCollection();
	List list = document.selectNodes("//Project/Seeds/Seed");
	for (Iterator iter = list.iterator(); iter.hasNext();)
	{
		DefaultElement attribute = (DefaultElement) iter.next();

		ReportSeedParsedVo seed = new ReportSeedParsedVo();
		seed.setName(attribute.valueOf("Name"));
		seed.setType(attribute.valueOf("Type"));
		seed.setBOName(attribute.valueOf("BOName"));
		seed.setBOField(attribute.valueOf("BOField"));
		seed.setCanBeNull(new Boolean(attribute.valueOf("CanBeNull").equalsIgnoreCase("true")));
		seeds.add(seed);
	}

	form.getGlobalContext().Admin.setReportSeedParsed(seeds);
}
 
开发者ID:oopcell,项目名称:AvoinApotti,代码行数:22,代码来源:Logic.java

示例7: handleMacrosNode

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
private void handleMacrosNode(Element xmlChannel) throws IOException {

    for (Object attrObj : xmlChannel.elements()) {
      DefaultElement e = (DefaultElement) attrObj;

      StringWriter sw = new StringWriter();
      XMLWriter writer = new XMLWriter(sw);
      writer.write(e.elements());

      if (this.tasker.getMacros().containsKey(e.attributeValue("name"))) {
        throw new RuntimeException("Macro " + e.attributeValue("name") + " already exists in map.");
      }

      this.tasker.getMacros().put(e.attributeValue("name"), sw.toString());
      this.tasker.getMacroAttrs().put(e.attributeValue("name"), e.attributes());
    }

  }
 
开发者ID:brunocvcunha,项目名称:taskerbox,代码行数:19,代码来源:TaskerboxXmlReader.java

示例8: handleDefaultPropertiesNode

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
private void handleDefaultPropertiesNode(Element xmlChannel) {
  for (Object attrObj : xmlChannel.elements()) {
    DefaultElement e = (DefaultElement) attrObj;

    String propertyValue = e.attributeValue("value");

    for (String defaultAttr : this.tasker.getDefaultProperties().keySet()) {
      propertyValue =
          propertyValue.replace("{" + defaultAttr + "}",
              this.tasker.getDefaultProperties().get(defaultAttr));
    }

    this.tasker.getDefaultProperties().put(e.attributeValue("name"), propertyValue);

  }
}
 
开发者ID:brunocvcunha,项目名称:taskerbox,代码行数:17,代码来源:TaskerboxXmlReader.java

示例9: testNamespaceNodesAreInherited

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
public void testNamespaceNodesAreInherited() throws JaxenException
{
        Namespace ns0 = Namespace.get("p0", "www.acme0.org");
        Namespace ns1 = Namespace.get("p1", "www.acme1.org");
        Namespace ns2 = Namespace.get("p2", "www.acme2.org");
        Element element = new DefaultElement("test", ns1);
        Attribute attribute = new DefaultAttribute("pre:foo", "bar", ns2);
        element.add(attribute);
        Element root = new DefaultElement("root", ns0);
        root.add(element);
        Document doc = new DefaultDocument(root);
        
        XPath xpath = new Dom4jXPath( "/*/*/namespace::node()" );

        List results = xpath.selectNodes( doc );

        assertEquals( 4,
                      results.size() );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:20,代码来源:DOM4JXPathTest.java

示例10: getCurrentPageInfoStringHTML

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
/**
 * Builds an html-info string about the current page and its linked resources
 * 
 * @return HTML-String
 */
private String getCurrentPageInfoStringHTML() {
    // test if currentPage links to resource, which is used (linked) somewhere
    // else in the manifest
    final CPManager cpMgm = (CPManager) CoreSpringFactory.getBean(CPManager.class);
    final DefaultElement ele = cpMgm.getElementByIdentifier(cp, currentPage.getIdRef());
    boolean single = false;
    if (ele instanceof CPResource) {
        final CPResource res = (CPResource) ele;
        single = cpMgm.isSingleUsedResource(res, cp);
    }

    final StringBuilder b = new StringBuilder();
    b.append("<br /><ul>");
    b.append("<li><b>" + translate("cptreecontroller.pagetitle") + "</b> " + currentPage.getTitle() + "</li>");
    if (single) {
        b.append("<li><b>" + translate("cptreecontroller.file") + "</b> " + currentPage.getFileName() + "</li>");
    }
    b.append("</ul>");
    return b.toString();

}
 
开发者ID:huihoo,项目名称:olat,代码行数:27,代码来源:CPTreeController.java

示例11: getElementByIdentifier

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
/**
*/
  @Override
  public DefaultElement getElementByIdentifier(final String id) {
      if (identifier.equals(id)) {
          return this;
      }
      DefaultElement e;
      for (final Iterator<CPItem> it = items.iterator(); it.hasNext();) {
          final CPItem item = it.next();
          e = item.getElementByIdentifier(id);
          if (e != null) {
              return e;
          }
      }
      return null;
  }
 
开发者ID:huihoo,项目名称:olat,代码行数:18,代码来源:CPItem.java

示例12: buildChildren

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
/**
*/
  @Override
  public void buildChildren() {
      final Iterator<DefaultElement> children = this.elementIterator();
      // iterate through children
      while (children.hasNext()) {
          final DefaultElement child = children.next();
          if (child.getName().equals(CPCore.METADATA)) {
              // TODO: implement METADATA
              metadata = new CPMetadata(child);
          } else {
              throw new OLATRuntimeException(CPOrganizations.class, "Invalid IMS-Manifest ( only <metadata> element under <file> is allowed )", new Exception());
          }
      }
      this.clearContent();
      validateElement();
  }
 
开发者ID:huihoo,项目名称:olat,代码行数:19,代码来源:CPFile.java

示例13: buildChildren

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
/**
*/
  @Override
  public void buildChildren() {
      final Iterator<DefaultElement> children = this.elementIterator();
      // iterate through children
      while (children.hasNext()) {
          final DefaultElement child = children.next();
          if (child.getName().equals(CPCore.ORGANIZATION)) {
              final CPOrganization org = new CPOrganization(child);
              org.setParentElement(this);
              org.buildChildren();
              orgas.add(org);
          } else {
              errors.add("Invalid imsmanifest (only \"Organization\"-elements allowed under <organizations> )");
          }
      }
      this.clearContent();
      validateElement();
  }
 
开发者ID:huihoo,项目名称:olat,代码行数:21,代码来源:CPOrganizations.java

示例14: buildDocument

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
/**
 * @param doc
 */
public void buildDocument(final DefaultDocument doc) {
    // Manifest is the root-node of the document, therefore we need to pass the
    // "doc"
    final DefaultElement manifestElement = new DefaultElement(CPCore.MANIFEST);

    manifestElement.add(new DefaultAttribute(CPCore.IDENTIFIER, this.identifier));
    manifestElement.add(new DefaultAttribute(CPCore.SCHEMALOCATION, this.schemaLocation));
    // manifestElement.setNamespace(this.getNamespace()); //FIXME: namespace

    doc.add(manifestElement);

    if (metadata != null) {
        metadata.buildDocument(manifestElement);
    }
    organizations.buildDocument(manifestElement);
    resources.buildDocument(manifestElement);

}
 
开发者ID:huihoo,项目名称:olat,代码行数:22,代码来源:CPManifest.java

示例15: canGetListUsingCorrectListAndSiteName

import org.dom4j.tree.DefaultElement; //导入依赖的package包/类
/**
 * ALF-19833: MacOS: Could not save to SharePoint
 */
@Test
public void canGetListUsingCorrectListAndSiteName() throws Exception
{
    VtiSoapRequest soapRequest = Mockito.mock(VtiSoapRequest.class);
    VtiSoapResponse soapResponse = new VtiSoapResponse(new MockHttpServletResponse());//Mockito.mock(VtiSoapResponse.class);
    Element requestElement = Mockito.mock(Element.class);
    SimpleNamespaceContext nc = Mockito.mock(SimpleNamespaceContext.class);

    Element rootElement = new DefaultElement(QName.get("root", "lists", "some://uri"));
    when(soapRequest.getDocument()).thenReturn(new DefaultDocument(rootElement));
    
    // Invoke the method under test.
    listItemsEndpoint.executeListActionDetails(soapRequest, soapResponse,
                "my-site", "documentLibrary", requestElement, nc);
    
    // Check the condition this test is for.
    verify(listHandler).getList("documentLibrary", "my-site");
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:22,代码来源:TestAbstractListItemsEndpointTest.java


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