org.jdom2.Element.setName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中org.jdom2.Element.setName()方法的一些代码示例,展示了Element.setName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.setName()方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:setName

Element.setName介绍

[英]Sets the (local) name of the element.
[中]设置元素的(本地)名称。

代码示例

代码示例来源:origin: org.jdom/jdom

/**
 * Creates a new element with the supplied (local) name and namespace. If
 * the provided namespace is null, the element will have no namespace.
 *
 * @param  name                 local name of the element
 * @param  namespace            namespace for the element
 * @throws IllegalNameException if the given name is illegal as an element
 *                              name
 */
public Element(final String name, final Namespace namespace) {
  super(CType.Element);
  setName(name);
  setNamespace(namespace);
}

代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata

/**
 * @param name The name of the element.
 * @return {@link Element}
 * @see org.jdom2.Element#setName(java.lang.String)
 */
public Element setName( String name )
{
  return element.setName( name );
}

代码示例来源:origin: io.wcm/io.wcm.handler.commons

/**
 * Sets element name - should not be used for HtmlElement-derived classes!
 * @param value Element name
 * @return Self reference
 * @deprecated Deprecated
 */
@Override
@Deprecated
public final org.jdom2.Element setName(String value) {
 return super.setName(value);
}

代码示例来源:origin: senbox-org/s1tbx

private void addMetadataFiles(final String internalPath, final MetadataElement destElem) throws IOException {
  String[] metaFiles = productDir.list(internalPath);
  for (String file : metaFiles) {
    if (file.endsWith(".xml")) {
      try {
        final File metaFile = getFile(internalPath + "/" + file);
        final Document xmlDoc = XMLSupport.LoadXML(metaFile.getAbsolutePath());
        final Element metaFileElement = xmlDoc.getRootElement();
        if (metaFileElement.getName().equals("lut")) {
          metaFileElement.setName(file.substring(0, file.lastIndexOf(".xml")));
        }
        AbstractMetadataIO.AddXMLMetadata(metaFileElement, destElem);
      } catch (IOException e) {
        SystemUtils.LOG.severe("Unable to read metadata " + file);
      }
    }
  }
}

代码示例来源:origin: org.mycore/mycore-mods

private Element cloneRelatedItem(Element relatedItem) {
  Element mods = relatedItem.clone();
  mods.setName("mods");
  mods.removeAttribute("type");
  mods.removeAttribute("href", MCRConstants.XLINK_NAMESPACE);
  mods.removeAttribute("type", MCRConstants.XLINK_NAMESPACE);
  mods.removeChildren("part", MCRConstants.MODS_NAMESPACE);
  return mods;
}

代码示例来源:origin: org.mycore/mycore-mods

/**
 * Merges the publication data returned by the data source with the existing data
 */
void mergeResultWith(Element existingData) {
  if (existingData.getName().equals("relatedItem")) {
    // resolved is always mods:mods, transform to mods:relatedItem to be mergeable
    result.setName("relatedItem");
    result.setAttribute(existingData.getAttribute("type").clone());
  }
  MCRMerger a = MCRMergerFactory.buildFrom(existingData);
  MCRMerger b = MCRMergerFactory.buildFrom(result);
  a.mergeFrom(b);
}

代码示例来源:origin: org.mycore/mycore-wcms2

/**
 * Converts the navigation.xml to the old format.
 */
private static byte[] convertToOldFormat(byte[] xml) throws JDOMException, IOException {
  SAXBuilder builder = new SAXBuilder();
  Document doc = builder.build(new ByteArrayInputStream(xml));
  Element rootElement = doc.getRootElement();
  rootElement.setAttribute("href", rootElement.getName());
  List<Element> children = rootElement.getChildren();
  for (Element menu : children) {
    String id = menu.getAttributeValue("id");
    menu.setName(id);
    menu.setAttribute("href", id);
    menu.removeAttribute("id");
  }
  XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
  ByteArrayOutputStream bout = new ByteArrayOutputStream(xml.length);
  out.output(doc, bout);
  return bout.toByteArray();
}

代码示例来源:origin: Unidata/thredds

private Element writeCoordTransform(CoverageTransform ct) {
 Element ctElem = new Element("coordTransform");
 ctElem.setAttribute("name", ct.getName());
 ctElem.setAttribute("transformType", ct.isHoriz() ? "Projection" : "Vertical");
 for (Attribute param : ct.getAttributes()) {
  Element pElem = ncmlWriter.makeAttributeElement(param);
  pElem.setName("parameter");
  ctElem.addContent(pElem);
 }
 return ctElem;
}

代码示例来源:origin: Unidata/thredds

public Element makeNetcdfElement(NetcdfFile ncFile, String location) {
 Element rootElem = makeGroupElement(ncFile.getRootGroup());
 // rootElem isn't just like any other group element; we must undo some of the changes made to it in writeGroup().
 rootElem.setName("netcdf");         // Was "group".
 rootElem.removeAttribute("name");   // This attribute is not defined on the root "netcdf" element.
 rootElem.addNamespaceDeclaration(namespace);
 if (null == location)
  location = ncFile.getLocation();
 if (null != location) {
  rootElem.setAttribute("location", URLnaming.canonicalizeWrite(location));
 }
 if (null != ncFile.getId())
  rootElem.setAttribute("id", ncFile.getId());
 if (null != ncFile.getTitle())
  rootElem.setAttribute("title", ncFile.getTitle());
 return rootElem;
}

代码示例来源:origin: jpos/jPOS

@Test
public void testInstantiateThrowsNullPointerException3() throws Throwable {
  String[] args = new String[0];
  Q2 q2 = new Q2(args);
  Element element = new Element("testQFactoryName", "testQFactoryUri");
  element.setAttribute(new Attribute("testQFactoryName", "testQFactoryValue", 0));
  Element e = (Element) element.clone();
  QFactory qFactory = new QFactory(new ObjectName("testQFactoryParam1", "testQFactoryParam2", "testQFactoryParam3"), q2);
  e.setName("testQFactoryName");
  String[] args2 = new String[2];
  args2[0] = "stat";
  args2[1] = "undeplying:";
  Q2 server = new Q2(args2);
  try {
    qFactory.instantiate(server, e);
    fail("Expected NullPointerException to be thrown");
  } catch (NullPointerException ex) {
    assertNull("ex.getMessage()", ex.getMessage());
    assertTrue("qFactory.classMapping.getKeys().hasMoreElements()", qFactory.classMapping
        .getKeys().hasMoreElements());
    assertSame("qFactory.q2", q2, qFactory.q2);
    assertEquals("e.getName()", "testQFactoryName", e.getName());
    assertSame("server.getCommandLineArgs()", args2, server.getCommandLineArgs());
  }
}

相关文章

微信公众号

最新文章

更多