gpt4 book ai didi

org.metawidget.util.XmlUtils.documentFromString()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 22:39:05 28 4
gpt4 key购买 nike

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

XmlUtils.documentFromString介绍

[英]Converts the given XML into a org.w3c.dom.Document.

Named documentFromString, rather than just parse, because DocumentBuilder.parse( String ) already exists and, confusingly, uses the String as a URI to the XML rather than as the XML itself.

Note: in performance tests, this method was consistently found to be expensive, of the order of around 10%. Consider implementing DomInspector on your Inspectors or DomInspectionResultProcessor on your InspectionResultProcessors to avoid this hit.
[中]将给定的XML转换为org.w3c.dom.Document
命名为documentFromString,而不仅仅是parse,因为DocumentBuilder.parse( String )已经存在,而且令人困惑的是,它将字符串用作XML的URI,而不是XML本身。
注:在性能测试中,这种方法一直被认为是昂贵的,大约为10%。考虑在你的[[ 5美元] ]或[ [ 6美元] ]上[ [ $$$] ]对你的[ [ $$$] ]实施以避免这一打击。

代码示例

代码示例来源:origin: org.metawidget.modules/metawidget-core

@Override
protected Element stringToElement( String xml ) {
  Document document = XmlUtils.documentFromString( xml );
  return document.getDocumentElement();
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

@Override
protected Element stringToElement( String xml ) {
  Document document = XmlUtils.documentFromString( xml );
  return document.getDocumentElement();
}

代码示例来源:origin: org.metawidget.modules/metawidget-core

/**
 * Process the given inspection result in context of the given Metawidget.
 * <p>
 * This method is marked <code>final</code> because most Metawidget implementations will call
 * <code>processInspectionResultAsDom</code> directly instead. So subclasses need to override
 * <code>processInspectionResultAsDom</code>, not <code>processInspectionResult</code>.
 */
public final String processInspectionResult( String inspectionResult, M metawidget, Object toInspect, String type, String... names ) {
  Document document = XmlUtils.documentFromString( inspectionResult );
  Element inspectionResultRoot = document.getDocumentElement();
  Element newInspectionResultRoot = processInspectionResultAsDom( inspectionResultRoot, metawidget, toInspect, type, names );
  return XmlUtils.documentToString( newInspectionResultRoot.getOwnerDocument(), false );
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

/**
 * Process the given inspection result in context of the given Metawidget.
 * <p>
 * This method is marked <code>final</code> because most Metawidget implementations will call
 * <code>processInspectionResultAsDom</code> directly instead. So subclasses need to override
 * <code>processInspectionResultAsDom</code>, not <code>processInspectionResult</code>.
 */
public final String processInspectionResult( String inspectionResult, M metawidget, Object toInspect, String type, String... names ) {
  Document document = XmlUtils.documentFromString( inspectionResult );
  Element inspectionResultRoot = document.getDocumentElement();
  Element newInspectionResultRoot = processInspectionResultAsDom( inspectionResultRoot, metawidget, toInspect, type, names );
  return XmlUtils.documentToString( newInspectionResultRoot.getOwnerDocument(), false );
}

代码示例来源:origin: org.jboss.forge/forge-scaffold-faces

/**
* Parses the given XML and determines what namespaces it already declares. These are later removed from the list of
* namespaces that Metawidget introduces.
*/
protected Map<String, String> parseNamespaces(final String template)
{
 Map<String, String> namespaces = CollectionUtils.newHashMap();
 Document document = XmlUtils.documentFromString(template);
 Element element = document.getDocumentElement();
 NamedNodeMap attributes = element.getAttributes();
 for (int loop = 0, length = attributes.getLength(); loop < length; loop++)
 {
   org.w3c.dom.Node node = attributes.item(loop);
   String nodeName = node.getNodeName();
   int indexOf = nodeName.indexOf(XMLNS_PREFIX);
   if (indexOf == -1)
   {
    continue;
   }
   namespaces.put(nodeName.substring(indexOf + XMLNS_PREFIX.length()), node.getNodeValue());
 }
 return namespaces;
}

代码示例来源:origin: org.jboss.forge.addon/scaffold-faces

/**
* Parses the given XML and determines what namespaces it already declares. These are later removed from the list of
* namespaces that Metawidget introduces.
*/
protected Map<String, String> parseNamespaces(final String template)
{
 Map<String, String> namespaces = CollectionUtils.newHashMap();
 Document document = XmlUtils.documentFromString(template);
 Element element = document.getDocumentElement();
 NamedNodeMap attributes = element.getAttributes();
 for (int loop = 0, length = attributes.getLength(); loop < length; loop++)
 {
   org.w3c.dom.Node node = attributes.item(loop);
   String nodeName = node.getNodeName();
   int indexOf = nodeName.indexOf(XMLNS_PREFIX);
   if (indexOf == -1)
   {
    continue;
   }
   namespaces.put(nodeName.substring(indexOf + XMLNS_PREFIX.length()), node.getNodeValue());
 }
 return namespaces;
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

/**
 * If your architecture is strongly separated, some metadata may only be available in one tier
 * (eg. JPA annotations in the backend) and some only available in another tier (eg.
 * struts-config.xml in the front-end).
 * <p>
 * For this, <code>CompositeInspector</code> supplies this overloaded method outside the normal
 * <code>Inspector</code> interface. It takes an additional XML string of inspection results,
 * and merges forthcoming inspection results with it.
 * <p>
 * This method is marked <code>final</code> because most Metawidget implementations will call
 * <code>inspectAsDom</code> directly instead. So subclasses need to override
 * <code>inspectAsDom</code>, not <code>inspect</code>.
 */
public final String inspect( String master, Object toInspect, String type, String... names ) {
  Element element = inspectAsDom( XmlUtils.documentFromString( master ), toInspect, type, names );
  if ( element == null ) {
    return null;
  }
  return XmlUtils.nodeToString( element, false );
}

代码示例来源:origin: org.metawidget.modules/metawidget-core

/**
 * If your architecture is strongly separated, some metadata may only be available in one tier
 * (eg. JPA annotations in the backend) and some only available in another tier (eg.
 * struts-config.xml in the front-end).
 * <p>
 * For this, <code>CompositeInspector</code> supplies this overloaded method outside the normal
 * <code>Inspector</code> interface. It takes an additional XML string of inspection results,
 * and merges forthcoming inspection results with it.
 * <p>
 * This method is marked <code>final</code> because most Metawidget implementations will call
 * <code>inspectAsDom</code> directly instead. So subclasses need to override
 * <code>inspectAsDom</code>, not <code>inspect</code>.
 */
public final String inspect( String master, Object toInspect, String type, String... names ) {
  Element element = inspectAsDom( XmlUtils.documentFromString( master ), toInspect, type, names );
  if ( element == null ) {
    return null;
  }
  return XmlUtils.nodeToString( element, false );
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

Element root = XmlUtils.documentFromString( inspectedType ).getDocumentElement();
NodeList elements = root.getFirstChild().getChildNodes();

代码示例来源:origin: org.metawidget.modules/metawidget-all

elements = null;
} else {
  Element root = XmlUtils.documentFromString( inspectedType ).getDocumentElement();
  elements = root.getFirstChild().getChildNodes();

代码示例来源:origin: org.metawidget.modules.swing/metawidget-swing

Element root = XmlUtils.documentFromString( inspectedType ).getDocumentElement();
NodeList elements = root.getFirstChild().getChildNodes();

代码示例来源:origin: org.metawidget.modules/metawidget-all

Element root = XmlUtils.documentFromString( inspectedType ).getDocumentElement();
NodeList elements = root.getFirstChild().getChildNodes();
addColumnTags( tableTag, attributes, elements, metawidgetTag );

代码示例来源:origin: org.metawidget.modules/metawidget-core

protected Document runInspector( Inspector inspector, Object toInspect, String type, String... names )
  throws Exception {
  // DomInspector...
  if ( inspector instanceof DomInspector<?> ) {
    @SuppressWarnings( "unchecked" )
    DomInspector<Element> domInspector = (DomInspector<Element>) inspector;
    Element element = domInspector.inspectAsDom( toInspect, type, names );
    if ( element == null ) {
      return null;
    }
    if ( LOG.isTraceEnabled() ) {
      String xml = XmlUtils.nodeToString( element, true );
      LOG.trace( "{0} inspected {1}{2}\r\n{3}", inspector.getClass(), type, ArrayUtils.toString( names, StringUtils.SEPARATOR_FORWARD_SLASH, true, false ), xml );
    }
    return element.getOwnerDocument();
  }
  // ...or just regular Inspector
  String xml = inspector.inspect( toInspect, type, names );
  if ( xml == null ) {
    return null;
  }
  LOG.trace( "{0} inspected {1}{2}\r\n{3}", inspector.getClass(), type, ArrayUtils.toString( names, StringUtils.SEPARATOR_FORWARD_SLASH, true, false ), xml );
  return XmlUtils.documentFromString( xml );
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

protected Document runInspector( Inspector inspector, Object toInspect, String type, String... names )
  throws Exception {
  // DomInspector...
  if ( inspector instanceof DomInspector<?> ) {
    @SuppressWarnings( "unchecked" )
    DomInspector<Element> domInspector = (DomInspector<Element>) inspector;
    Element element = domInspector.inspectAsDom( toInspect, type, names );
    if ( element == null ) {
      return null;
    }
    if ( LOG.isTraceEnabled() ) {
      String xml = XmlUtils.nodeToString( element, true );
      LOG.trace( "{0} inspected {1}{2}\r\n{3}", inspector.getClass(), type, ArrayUtils.toString( names, StringUtils.SEPARATOR_FORWARD_SLASH, true, false ), xml );
    }
    return element.getOwnerDocument();
  }
  // ...or just regular Inspector
  String xml = inspector.inspect( toInspect, type, names );
  if ( xml == null ) {
    return null;
  }
  LOG.trace( "{0} inspected {1}{2}\r\n{3}", inspector.getClass(), type, ArrayUtils.toString( names, StringUtils.SEPARATOR_FORWARD_SLASH, true, false ), xml );
  return XmlUtils.documentFromString( xml );
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

Element root = XmlUtils.documentFromString( inspectedType ).getDocumentElement();
NodeList elements = root.getFirstChild().getChildNodes();
addColumnComponents( table, elements, metawidget );

代码示例来源:origin: org.metawidget.modules/metawidget-all

Element root = XmlUtils.documentFromString( inspectedType ).getDocumentElement();
NodeList elements = root.getFirstChild().getChildNodes();
addColumnComponents( table, forEach, attributes, elements, metawidget );

代码示例来源:origin: org.jboss.forge.addon/scaffold-faces

Element root = XmlUtils.documentFromString(inspectedType).getDocumentElement();
NodeList elements = root.getFirstChild().getChildNodes();
Map<String, String> embeddedAttributes = CollectionUtils.newHashMap();
Element root = XmlUtils.documentFromString(inspectedType).getDocumentElement();
NodeList elements = root.getFirstChild().getChildNodes();

代码示例来源:origin: org.jboss.forge/forge-scaffold-faces

Element root = XmlUtils.documentFromString(inspectedType).getDocumentElement();
NodeList elements = root.getFirstChild().getChildNodes();
Map<String, String> embeddedAttributes = CollectionUtils.newHashMap();
Element root = XmlUtils.documentFromString(inspectedType).getDocumentElement();
NodeList elements = root.getFirstChild().getChildNodes();

代码示例来源:origin: org.metawidget.modules/metawidget-all

elements = null;
} else {
  Element root = XmlUtils.documentFromString( inspectedType ).getDocumentElement();
  elements = root.getFirstChild().getChildNodes();

代码示例来源:origin: org.metawidget.modules.faces/metawidget-faces

elements = null;
} else {
  Element root = XmlUtils.documentFromString( inspectedType ).getDocumentElement();
  elements = root.getFirstChild().getChildNodes();

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com