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

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

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

Element.getTextNormalize介绍

[英]Returns the textual content of this element with all surrounding whitespace removed and internal whitespace normalized to a single space. If no textual value exists for the element, or if only whitespace exists, the empty string is returned.
[中]

代码示例

代码示例来源:origin: gocd/gocd

@Test
public void shouldReturnAMessageWhenAllArtifactsHaveBeenDeletedButArtifactsDeletedFlagHasNotBeenSet() throws Exception {
  HtmlRenderer renderer = new HtmlRenderer("context");
  DirectoryEntries directoryEntries = new DirectoryEntries();
  directoryEntries.render(renderer);
  Element document = getRenderedDocument(renderer);
  assertThat(document.getChildren().size(), is(1));
  assertThat(document.getChild("p").getTextNormalize(),
      Matchers.containsString("Artifacts for this job instance are unavailable as they may have been or deleted externally. Re-run the stage or job to generate them again."));
}

代码示例来源:origin: gocd/gocd

@Test
public void shouldReturnAMessageWhenAllArtifactsArePurgedIncludingCruiseOutput() throws Exception {
  HtmlRenderer renderer = new HtmlRenderer("context");
  DirectoryEntries directoryEntries = new DirectoryEntries();
  directoryEntries.setIsArtifactsDeleted(true);
  directoryEntries.render(renderer);
  Element document = getRenderedDocument(renderer);
  assertThat(document.getChildren().size(), is(1));
  assertThat(document.getChild("p").getTextNormalize(),
      Matchers.containsString("Artifacts for this job instance are unavailable as they may have been or deleted externally. Re-run the stage or job to generate them again."));
}

代码示例来源:origin: gocd/gocd

@Test
public void shouldReturnAMessageWhenThereAreNoArtifacts() throws Exception {
  HtmlRenderer renderer = new HtmlRenderer("context");
  DirectoryEntries directoryEntries = new DirectoryEntries();
  directoryEntries.add(new FolderDirectoryEntry("cruise-output", "", new DirectoryEntries()));
  directoryEntries.setIsArtifactsDeleted(true);
  directoryEntries.render(renderer);
  Element document = getRenderedDocument(renderer);
  assertThat(document.getChildren().size(), is(2));
  assertThat(document.getChild("p").getTextNormalize(),
      Matchers.containsString("Artifacts for this job instance are unavailable as they may have been or deleted externally. Re-run the stage or job to generate them again."));
  assertThat(document.getChild("ul").getChild("div").getChild("span").getChild("a").getTextNormalize(), is("cruise-output"));
}

代码示例来源:origin: gocd/gocd

@Test
public void shouldListAllArtifactsWhenArtifactsNotPurged() throws Exception {
  HtmlRenderer renderer = new HtmlRenderer("context");
  DirectoryEntries directoryEntries = new DirectoryEntries();
  directoryEntries.add(new FolderDirectoryEntry("cruise-output", "", new DirectoryEntries()));
  directoryEntries.add(new FolderDirectoryEntry("some-artifact", "", new DirectoryEntries()));
  directoryEntries.render(renderer);
  Element document = getRenderedDocument(renderer);
  assertThat(document.getChildren().size(), is(2));
  Element cruiseOutputElement = (Element) document.getChildren().get(0);
  assertThat(cruiseOutputElement.getChild("div").getChild("span").getChild("a").getTextNormalize(), is("cruise-output"));
  Element artifactElement = (Element) document.getChildren().get(1);
  assertThat(artifactElement.getChild("div").getChild("span").getChild("a").getTextNormalize(), is("some-artifact"));
}

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

/**
 * Returns the normalized textual content of the named child element, or
 * null if there's no such child. See <code>{@link
 * #getTextNormalize()}</code> for details of text normalizing.
 *
 * @param  cname                the name of the child
 * @return                     normalized text content for the named child,
 *                             or null if no such child
 */
public String getChildTextNormalize(final String cname) {
  final Element child = getChild(cname);
  if (child == null) {
    return null;
  }
  return child.getTextNormalize();
}

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

/**
 * Returns the normalized textual content of the named child element, or
 * null if there's no such child.
 * 
 * @param cname
 *        the name of the child
 * @param ns
 *        the namespace of the child. A null implies Namespace.NO_NAMESPACE.
 * @return normalized text content for the named child, or null if no such
 *         child
 */
public String getChildTextNormalize(final String cname, final Namespace ns) {
  final Element child = getChild(cname, ns);
  if (child == null) {
    return null;
  }
  return child.getTextNormalize();
}

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

/**
 * @return the normalized text.
 * @see org.jdom2.Element#getTextNormalize()
 */
public String getTextNormalize()
{
  return element.getTextNormalize();
}

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

@Override
public void setConfiguration (Element e) throws ConfigurationException {
  Element enabled = e.getChild("enabled");
  Element disabled = e.getChild("disabled");
  if (enabled != null && !"".equals(enabled.getTextNormalize()))
    enabledRealms = new HashSet(Arrays.asList(enabled.getTextNormalize().split(" ")));
  if (disabled != null && !"".equals(disabled.getTextNormalize()))
    disabledRealms = new HashSet(Arrays.asList(disabled.getTextNormalize().split(" ")));;
}

代码示例来源:origin: edu.ucar/cdm

private void readValue(Element pdsHashElement, String key, Namespace ns, boolean value) {
 if (pdsHashElement != null) {
  Element e = pdsHashElement.getChild(key, ns);
  if (e != null) {
   value = true; // no value means true
   String t = e.getTextNormalize();
   if (t != null && t.equalsIgnoreCase("true")) value = true;
   if (t != null && t.equalsIgnoreCase("false")) value = false;
  }
 }
 pdsHash.put(key, value);
}

代码示例来源:origin: edu.ucar/netcdf

private void readValue(Element pdsHashElement, String key, Namespace ns, boolean value) {
 if (pdsHashElement != null) {
  Element e = pdsHashElement.getChild(key, ns);
  if (e != null) {
   value = true; // no value means true
   String t = e.getTextNormalize();
   if (t != null && t.equalsIgnoreCase("true")) value = true;
   if (t != null && t.equalsIgnoreCase("false")) value = false;
  }
 }
 pdsHash.put(key, value);
}

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

private boolean readValue(Element pdsHashElement, String key, Namespace ns, boolean value) {
 if (pdsHashElement != null) {
  Element e = pdsHashElement.getChild(key, ns);
  if (e != null) {
   value = true; // no value means true
   String t = e.getTextNormalize();
   if (t != null && t.equalsIgnoreCase("true")) value = true;
   if (t != null && t.equalsIgnoreCase("false")) value = false;
  }
 }
 return value;
}

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

public List<String> getRootList(String elementName) {
 List<String> result = new ArrayList<>();
 List<Element> rootList = rootElem.getChildren(elementName);
 for (Element elem : rootList) {
  String location = StringUtils.cleanPath(elem.getTextNormalize());
  if (location.length() > 0)
   result.add(location);
 }
 return result;
}

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

public List<String> getElementList(String elementName, String subElementName) {
 List<String> result = new ArrayList<>();
 Element elem = rootElem.getChild( elementName );
 if (elem == null) return result;
 List<Element> rootList = elem.getChildren(subElementName);
 for (Element elem2 : rootList) {
  String location = StringUtils.cleanPath(elem2.getTextNormalize());
  if (location.length() > 0)
   result.add(location);
 }
 return result;
}

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

protected Documentation readDocumentation(Element s) {
 String href = s.getAttributeValue("href", Catalog.xlinkNS);
 String title = s.getAttributeValue("title", Catalog.xlinkNS);
 String type = s.getAttributeValue("type"); // not XLink type
 String content = s.getTextNormalize();
 URI uri = null;
 if (href != null) {
  try {
   uri = Catalog.resolveUri(baseURI, href);
  }
  catch (Exception e) {
   errlog.format(" ** Invalid documentation href = '%s' err='%s'%n", href, e.getMessage());
   logger.debug(" ** Invalid documentation href = '{}' err='{}'", href, e.getMessage());
  }
 }
 return new Documentation(href, uri, title, type, content);
}

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

public static CalendarDateUnit getTimeUnit(Document doc) {
 Element root = doc.getRootElement();
 Element timeUnitE = root.getChild("TimeUnit");
 if (timeUnitE == null) return null;
 String cal = timeUnitE.getAttributeValue("calendar");
 String timeUnitS = timeUnitE.getTextNormalize();
 try {
  return CalendarDateUnit.of(cal, timeUnitS);
 } catch (Exception e) {
  log.error("Illegal date unit {} in FeatureDatasetCapabilitiesXML", timeUnitS);
  return null;
 }
}

代码示例来源:origin: edu.ucar/cdm

protected InvDocumentation readDocumentation(Element s) {
 String href = s.getAttributeValue("href", xlinkNS);
 String title = s.getAttributeValue("title", xlinkNS);
 String type = s.getAttributeValue("type"); // not XLink type
 String content = s.getTextNormalize();
 // LOOK im not so sure this should be resolved!
 URI uriResolved = null;
 if (href != null) {
  try {
   uriResolved = docURI.resolve(href);
  } catch (Exception e) {
   factory.appendErr(" ** Invalid documentation href = " + href + " " + e.getMessage() + "\n");
  }
 }
 return new InvDocumentation(href, uriResolved, title, type, content);
}

代码示例来源:origin: edu.ucar/netcdf

protected InvDocumentation readDocumentation(Element s) {
 String href = s.getAttributeValue("href", xlinkNS);
 String title = s.getAttributeValue("title", xlinkNS);
 String type = s.getAttributeValue("type"); // not XLink type
 String content = s.getTextNormalize();
 // LOOK im not so sure this should be resolved!
 URI uriResolved = null;
 if (href != null) {
  try {
   uriResolved = docURI.resolve(href);
  } catch (Exception e) {
   factory.appendErr(" ** Invalid documentation href = " + href + " " + e.getMessage() + "\n");
  }
 }
 return new InvDocumentation(href, uriResolved, title, type, content);
}

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

protected InvDocumentation readDocumentation(InvCatalog cat, Element s) {
 String href = s.getAttributeValue("href", xlinkNS);
 String title = s.getAttributeValue("title", xlinkNS);
 String type = s.getAttributeValue("type"); // not XLink type
 String content = s.getTextNormalize();
 URI uri = null;
 if (href != null) {
  try {
   uri = cat.resolveUri(href);
  } catch (Exception e) {
   factory.appendErr(" ** Invalid documentation href = " + href + " " + e.getMessage() + "\n");
  }
 }
 InvDocumentation doc = new InvDocumentation(href, uri, title, type, content);
 // LOOK XHTML ?? !!
 if (InvCatalogFactory.debugXML) System.out.println(" Documentation added: " + doc);
 return doc;
}

代码示例来源:origin: edu.ucar/cdm

protected InvDocumentation readDocumentation(InvCatalog cat, Element s) {
 String href = s.getAttributeValue("href", xlinkNS);
 String title = s.getAttributeValue("title", xlinkNS);
 String type = s.getAttributeValue("type"); // not XLink type
 String content = s.getTextNormalize();
 URI uri = null;
 if (href != null) {
  try {
   uri = cat.resolveUri(href);
  } catch (Exception e) {
   factory.appendErr(" ** Invalid documentation href = " + href + " " + e.getMessage() + "\n");
  }
 }
 InvDocumentation doc = new InvDocumentation(href, uri, title, type, content);
 // LOOK XHTML ?? !!
 if (InvCatalogFactory.debugXML) System.out.println(" Documentation added: " + doc);
 return doc;
}

代码示例来源:origin: edu.ucar/netcdf

protected InvDocumentation readDocumentation( InvCatalog cat, Element s) {
 String href = s.getAttributeValue("href", xlinkNS);
 String title = s.getAttributeValue("title", xlinkNS);
 String type = s.getAttributeValue("type"); // not XLink type
 String content = s.getTextNormalize();
 URI uri = null;
 if (href != null) {
  try {
   uri = cat.resolveUri(href);
  } catch (Exception e) {
   factory.appendErr(" ** Invalid documentation href = "+href+" "+e.getMessage()+"\n");
  }
 }
 InvDocumentation doc = new InvDocumentation( href, uri, title, type, content);
 // LOOK XHTML ?? !!
 if (InvCatalogFactory.debugXML) System.out.println (" Documentation added: "+ doc);
 return doc;
}

相关文章

微信公众号

最新文章

更多