gpt4 book ai didi

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

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

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

XmlUtils.getFirstChildElement介绍

[英]Get the indexed Element.

Similar to Element.getChildNodes.item, but ignores any Nodes (such as indentation TextNodes).
[中]获取索引元素。
Element.getChildNodes.item类似,但忽略任何节点(例如缩进文本节点)。

代码示例

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

@Override
protected Element getFirstChildElement( Element parent ) {
  return XmlUtils.getFirstChildElement( parent );
}

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

@Override
protected Element getFirstChildElement( Element parent ) {
  return XmlUtils.getFirstChildElement( parent );
}

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

/**
 * Convert the given Element to a JSON Schema (v3) String.
 * <p>
 * If converting <code>inspection-result</code> DOMs into JSON Schemas, consider using this
 * method in conjunction with <code>JsonSchemaMappingProcessor</code> and
 * <code>JsonTypeMappingProcessor</code>. The result is directly compatible with the JavaScript
 * versions of Metawidget. It can therefore be returned by REST services (see
 * http://blog.kennardconsulting.com/2013/02/metawidget-and-rest.html).
 */
public static String inspectionResultToJsonSchema( Element inspectionResult ) {
  return inspectionResultToJsonSchema( XmlUtils.getFirstChildElement( inspectionResult ), false );
}

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

/**
 * Convert the given Element to a JSON Schema (v3) String.
 * <p>
 * If converting <code>inspection-result</code> DOMs into JSON Schemas, consider using this
 * method in conjunction with <code>JsonSchemaMappingProcessor</code> and
 * <code>JsonTypeMappingProcessor</code>. The result is directly compatible with the JavaScript
 * versions of Metawidget. It can therefore be returned by REST services (see
 * http://blog.kennardconsulting.com/2013/02/metawidget-and-rest.html).
 */
public static String inspectionResultToJsonSchema( Element inspectionResult ) {
  return inspectionResultToJsonSchema( XmlUtils.getFirstChildElement( inspectionResult ), false );
}

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

/**
 * Prepend 'package' attribute to class 'name' and 'extends' attributes, and to 'class'
 * attributes of children.
 */
@Override
protected void preprocessDocument( Document document ) {
  Element root = document.getDocumentElement();
  String packagePrefix = root.getAttribute( "package" );
  if ( packagePrefix != null && !"".equals( packagePrefix ) ) {
    packagePrefix += StringUtils.SEPARATOR_DOT_CHAR;
    String topLevelAttribute = getTopLevelTypeAttribute();
    String extendsAttribute = getExtendsAttribute();
    Element child = XmlUtils.getFirstChildElement( root );
    while ( child != null ) {
      // 'name' attribute of 'class'/'subclass' element
      String name = child.getAttribute( topLevelAttribute );
      if ( name != null && !"".equals( name ) && name.indexOf( StringUtils.SEPARATOR_DOT_CHAR ) == -1 ) {
        child.setAttribute( topLevelAttribute, packagePrefix + name );
      }
      // 'extends' attribute of 'subclass' element
      String extendsClass = child.getAttribute( extendsAttribute );
      if ( extendsClass != null && !"".equals( extendsClass ) && extendsClass.indexOf( StringUtils.SEPARATOR_DOT_CHAR ) == -1 ) {
        child.setAttribute( extendsAttribute, packagePrefix + extendsClass );
      }
      // 'class' attributes of children
      prependPackageToClassAttribute( child, packagePrefix );
      child = XmlUtils.getNextSiblingElement( child );
    }
  }
}

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

Element trait = XmlUtils.getFirstChildElement( element );

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

Element trait = XmlUtils.getFirstChildElement( element );

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

public Element processInspectionResultAsDom( Element inspectionResult, M metawidget, Object toInspect, String type, String... names ) {
  Element entity = XmlUtils.getFirstChildElement( inspectionResult );
  // Sanity check
  String elementName = entity.getNodeName();
  if ( !ENTITY.equals( elementName ) ) {
    throw InspectionResultProcessorException.newException( "Top-level element name should be " + ENTITY + ", not " + elementName );
  }
  Map<String, String> attributes = XmlUtils.getAttributesAsMap( entity );
  processEntity( attributes, metawidget, toInspect, type, names );
  XmlUtils.setMapAsAttributes( entity, attributes );
  processTraits( entity, metawidget, toInspect, type, names );
  return inspectionResult;
}

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

/**
* Inspects a {@link JavaClass} instance and provides inspection results in return.
*
* @param klass The {@link JavaClass} to inspect.
* @return A list representing inspection results for the {@link JavaClass}. Each list item corresponds to the
*         inspection result for every property of the provided {@link JavaClass}.
*/
public List<Map<String, String>> inspect(JavaClassSource klass)
{
 setupCompositeInspector();
 Element inspectionResult = compositeInspector.inspectAsDom(null, klass.getQualifiedName(), (String[]) null);
 Element inspectedEntity = XmlUtils.getFirstChildElement(inspectionResult);
 Element inspectedProperty = XmlUtils.getFirstChildElement(inspectedEntity);
 List<Map<String, String>> viewPropertyAttributes = new ArrayList<Map<String, String>>();
 while (inspectedProperty != null)
 {
   Map<String, String> propertyAttributes = XmlUtils.getAttributesAsMap(inspectedProperty);
   viewPropertyAttributes.add(propertyAttributes);
   inspectedProperty = XmlUtils.getNextSiblingElement(inspectedProperty);
 }
 return viewPropertyAttributes;
}

代码示例来源:origin: org.jboss.forge/forge-scaffoldx-api

/**
* Inspects a {@link JavaClass} instance and provides inspection results in return.
* 
* @param klass The {@link JavaClass} to inspect.
* @return A list representing inspection results for the {@link JavaClass}. Each list item corresponds to the
*         inspection result for every property of the provided {@link JavaClass}.
*/
public List<Map<String, String>> inspect(JavaClass klass)
{
 setupCompositeInspector();
 Element inspectionResult = compositeInspector.inspectAsDom(null, klass.getQualifiedName(), (String[]) null);
 Element inspectedEntity = XmlUtils.getFirstChildElement(inspectionResult);
 Element inspectedProperty = XmlUtils.getFirstChildElement(inspectedEntity);
 List<Map<String, String>> viewPropertyAttributes = new ArrayList<Map<String, String>>();
 while (inspectedProperty != null)
 {
   Map<String, String> propertyAttributes = XmlUtils.getAttributesAsMap(inspectedProperty);
   viewPropertyAttributes.add(propertyAttributes);
   inspectedProperty = XmlUtils.getNextSiblingElement(inspectedProperty);
 }
 return viewPropertyAttributes;
}

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

public Element processInspectionResultAsDom( Element inspectionResult, M metawidget, Object toInspect, String type, String... names ) {
  Element entity = XmlUtils.getFirstChildElement( inspectionResult );
  // Sanity check
  String elementName = entity.getNodeName();
  if ( !ENTITY.equals( elementName ) ) {
    throw InspectionResultProcessorException.newException( "Top-level element name should be " + ENTITY + ", not " + elementName );
  }
  Map<String, String> attributes = XmlUtils.getAttributesAsMap( entity );
  processEntity( attributes, metawidget, toInspect, type, names );
  XmlUtils.setMapAsAttributes( entity, attributes );
  processTraits( entity, metawidget, toInspect, type, names );
  return inspectionResult;
}

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

/**
 * Inspect the <code>toInspect</code> for properties and actions.
 * <p>
 * This method can be overridden by clients wishing to modify the inspection process. Most
 * clients will find it easier to override one of the sub-methods, such as
 * <code>inspectTrait</code> or <code>inspectProperty</code>.
 */
protected void inspectTraits( Element toInspect, Element toAddTo ) {
  if ( toInspect == null ) {
    return;
  }
  Document document = toAddTo.getOwnerDocument();
  // Do 'extends' attribute first
  String extendsAttribute = getExtendsAttribute();
  if ( extendsAttribute != null ) {
    if ( toInspect.hasAttribute( extendsAttribute ) ) {
      inspectTraits( (Element) traverse( null, toInspect.getAttribute( extendsAttribute ), false ).getValue(), toAddTo );
    }
  }
  // Next, inspect each child...
  Element element = document.createElementNS( NAMESPACE, ENTITY );
  inspectTraitSiblings( element, XmlUtils.getFirstChildElement( toInspect ) );
  // ...and combine them all. Note the element may already exist from the superclass,
  // and its attributes will get overridden by the subclass
  XmlUtils.combineElements( toAddTo, element, NAME, NAME );
}

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

/**
 * Inspect the <code>toInspect</code> for properties and actions.
 * <p>
 * This method can be overridden by clients wishing to modify the inspection process. Most
 * clients will find it easier to override one of the sub-methods, such as
 * <code>inspectTrait</code> or <code>inspectProperty</code>.
 */
protected void inspectTraits( Element toInspect, Element toAddTo ) {
  if ( toInspect == null ) {
    return;
  }
  Document document = toAddTo.getOwnerDocument();
  // Do 'extends' attribute first
  String extendsAttribute = getExtendsAttribute();
  if ( extendsAttribute != null ) {
    if ( toInspect.hasAttribute( extendsAttribute ) ) {
      inspectTraits( (Element) traverse( null, toInspect.getAttribute( extendsAttribute ), false ).getValue(), toAddTo );
    }
  }
  // Next, inspect each child...
  Element element = document.createElementNS( NAMESPACE, ENTITY );
  inspectTraitSiblings( element, XmlUtils.getFirstChildElement( toInspect ) );
  // ...and combine them all. Note the element may already exist from the superclass,
  // and its attributes will get overridden by the subclass
  XmlUtils.combineElements( toAddTo, element, NAME, NAME );
}

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

Element trait = XmlUtils.getFirstChildElement( entity );

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

protected Element inspect() {
  TypeAndNames typeAndNames = PathUtils.parsePath( mPath, StringUtils.SEPARATOR_DOT_CHAR );
  String type = typeAndNames.getType();
  // Inspect using the 'raw' type (eg. contactForm)
  Element inspectionResult = mPipeline.inspectAsDom( null, type, typeAndNames.getNamesAsArray() );
  // (pageContext may be null in unit tests)
  if ( pageContext != null ) {
    // Try to locate the runtime bean. This allows some Inspectors
    // to act on it polymorphically.
    Object obj = pageContext.findAttribute( type );
    if ( obj != null ) {
      Element additionalInspectionResult = mPipeline.inspectAsDom( obj, obj.getClass().getName(), typeAndNames.getNamesAsArray() );
      // Combine the subtrees
      //
      // Note the top-level types attribute will be different, because one is the 'raw'
      // type (eg. contactForm) and one the runtime bean (eg.
      // org.metawidget.example.struts.addressbook.form.BusinessContactForm)
      if ( inspectionResult == null ) {
        inspectionResult = additionalInspectionResult;
      } else if ( additionalInspectionResult != null ) {
        Element inspectionResultEntity = XmlUtils.getFirstChildElement( inspectionResult );
        Element additionalInspectionResultEntity = XmlUtils.getFirstChildElement( additionalInspectionResult );
        XmlUtils.combineElements( inspectionResultEntity, additionalInspectionResultEntity, NAME, null );
      }
    }
  }
  return inspectionResult;
}

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

Element trait = XmlUtils.getFirstChildElement( entity );

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

Element trait = XmlUtils.getFirstChildElement( entity );

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

Element entity = XmlUtils.getFirstChildElement( inspectionResult );
Element trait = XmlUtils.getFirstChildElement( entity );

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

Element entity = XmlUtils.getFirstChildElement( inspectionResult );
Element trait = XmlUtils.getFirstChildElement( entity );

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

Element baseSequence = XmlUtils.getFirstChildElement( baseElement );
toInspectToUse = XmlUtils.getFirstChildElement( toInspectToUse );

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