gpt4 book ai didi

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

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

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

XmlUtils.setMapAsAttributes介绍

[英]Sets the Map as DOM attributes on the given Element.

This implementation uses element.setAttribute. Therefore if the element already has attributes, the new attributes are added amongst them. If attributes with the same name already exist, they are overwritten. To remove attributes from the given Element, put them in the Map with a null value.
[中]将贴图设置为给定元素上的DOM属性。
此实现使用element.setAttribute。因此,如果元素已经有属性,则会在其中添加新属性。如果具有相同名称的属性已存在,则将覆盖它们。要从给定元素中删除属性,请使用null值将它们放入映射中。

代码示例

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

public static Element importElement( Document document, Element element ) {
  try {
    return (Element) document.importNode( element, true );
  } catch ( DOMException e ) {
    // Note: importNode returns 'DOMException' under Android 1.1_r1
    Element imported = document.createElementNS( element.getNamespaceURI(), element.getNodeName() );
    setMapAsAttributes( imported, getAttributesAsMap( element ) );
    NodeList nodeList = imported.getChildNodes();
    for ( int loop = 0; loop < nodeList.getLength(); loop++ ) {
      Node node = nodeList.item( loop );
      if ( !( node instanceof Element ) ) {
        continue;
      }
      imported.appendChild( importElement( document, (Element) node ) );
    }
    return imported;
  }
}

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

public static Element importElement( Document document, Element element ) {
  try {
    return (Element) document.importNode( element, true );
  } catch ( DOMException e ) {
    // Note: importNode returns 'DOMException' under Android 1.1_r1
    Element imported = document.createElementNS( element.getNamespaceURI(), element.getNodeName() );
    setMapAsAttributes( imported, getAttributesAsMap( element ) );
    NodeList nodeList = imported.getChildNodes();
    for ( int loop = 0; loop < nodeList.getLength(); loop++ ) {
      Node node = nodeList.item( loop );
      if ( !( node instanceof Element ) ) {
        continue;
      }
      imported.appendChild( importElement( document, (Element) node ) );
    }
    return imported;
  }
}

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

/**
 * Inspect the given Element and return a Map of attributes if it is a trait.
 * <p>
 * It is this method's responsibility to decide whether the given Element does, in fact, qualify
 * as a 'trait' - based on its own rules.
 *
 * @param toInspect
 *            DOM element to inspect
 */
protected Element inspectTrait( Document toAddTo, Element toInspect ) {
  // Properties
  Map<String, String> propertyAttributes = inspectProperty( toInspect );
  if ( propertyAttributes != null && !propertyAttributes.isEmpty() ) {
    Element child = toAddTo.createElementNS( NAMESPACE, PROPERTY );
    XmlUtils.setMapAsAttributes( child, propertyAttributes );
    return child;
  }
  // Actions
  Map<String, String> actionAttributes = inspectAction( toInspect );
  if ( actionAttributes != null && !actionAttributes.isEmpty() ) {
    // Sanity check
    if ( propertyAttributes != null ) {
      throw InspectorException.newException( "Ambigious match: " + toInspect.getNodeName() + " matches as both a property and an action" );
    }
    Element child = toAddTo.createElementNS( NAMESPACE, ACTION );
    XmlUtils.setMapAsAttributes( child, actionAttributes );
    return child;
  }
  return null;
}

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

/**
 * Inspect the given Element and return a Map of attributes if it is a trait.
 * <p>
 * It is this method's responsibility to decide whether the given Element does, in fact, qualify
 * as a 'trait' - based on its own rules.
 *
 * @param toInspect
 *            DOM element to inspect
 */
protected Element inspectTrait( Document toAddTo, Element toInspect ) {
  // Properties
  Map<String, String> propertyAttributes = inspectProperty( toInspect );
  if ( propertyAttributes != null && !propertyAttributes.isEmpty() ) {
    Element child = toAddTo.createElementNS( NAMESPACE, PROPERTY );
    XmlUtils.setMapAsAttributes( child, propertyAttributes );
    return child;
  }
  // Actions
  Map<String, String> actionAttributes = inspectAction( toInspect );
  if ( actionAttributes != null && !actionAttributes.isEmpty() ) {
    // Sanity check
    if ( propertyAttributes != null ) {
      throw InspectorException.newException( "Ambigious match: " + toInspect.getNodeName() + " matches as both a property and an action" );
    }
    Element child = toAddTo.createElementNS( NAMESPACE, ACTION );
    XmlUtils.setMapAsAttributes( child, actionAttributes );
    return child;
  }
  return null;
}

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

element.setAttribute( NAME, property.getName() );
XmlUtils.setMapAsAttributes( element, traitAttributes );
XmlUtils.setMapAsAttributes( element, propertyAttributes );
XmlUtils.setMapAsAttributes( element, entityAttributes );
element.setAttribute( NAME, action.getName() );
XmlUtils.setMapAsAttributes( element, traitAttributes );
XmlUtils.setMapAsAttributes( element, actionAttributes );

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

element.setAttribute( NAME, property.getName() );
XmlUtils.setMapAsAttributes( element, traitAttributes );
XmlUtils.setMapAsAttributes( element, propertyAttributes );
XmlUtils.setMapAsAttributes( element, entityAttributes );
element.setAttribute( NAME, action.getName() );
XmlUtils.setMapAsAttributes( element, traitAttributes );
XmlUtils.setMapAsAttributes( element, actionAttributes );

代码示例来源: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-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.metawidget.modules/metawidget-all

XmlUtils.setMapAsAttributes( trait, attributes );

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

XmlUtils.setMapAsAttributes( trait, attributes );

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

XmlUtils.setMapAsAttributes( entity, parentAttributes );

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

XmlUtils.setMapAsAttributes( entity, parentAttributes );

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

XmlUtils.setMapAsAttributes( newInspectionResult, XmlUtils.getAttributesAsMap( inspectionResult ) );
newDocument.appendChild( newInspectionResult );
XmlUtils.setMapAsAttributes( newEntity, XmlUtils.getAttributesAsMap( entity ) );
newInspectionResult.appendChild( newEntity );

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

XmlUtils.setMapAsAttributes( newInspectionResult, XmlUtils.getAttributesAsMap( inspectionResult ) );
newDocument.appendChild( newInspectionResult );
XmlUtils.setMapAsAttributes( newEntity, XmlUtils.getAttributesAsMap( entity ) );
newInspectionResult.appendChild( newEntity );

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

XmlUtils.setMapAsAttributes( entity, inspectEntity( declaredChildType, actualChildType ) );
XmlUtils.setMapAsAttributes( entity, parentAttributes );

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

XmlUtils.setMapAsAttributes( entity, inspectEntity( declaredChildType, actualChildType ) );
XmlUtils.setMapAsAttributes( entity, parentAttributes );

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

XmlUtils.setMapAsAttributes( toAddTo, attributes );
return;
inspectExtension( toInspectToUse, attributes );
inspectRestriction( toInspectToUse, attributes );
XmlUtils.setMapAsAttributes( toAddTo, attributes );
return;

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