gpt4 book ai didi

org.eclipse.persistence.oxm.mappings.XMLChoiceObjectMapping类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 00:22:40 28 4
gpt4 key购买 nike

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

XMLChoiceObjectMapping介绍

[英]PUBLIC:

Purpose:Provide a mapping that can map a single attribute to a number of different elements in an XML Document. This will be used to map to Choices or Substitution Groups in an XML Schema

Responsibilities:

  • Allow the user to specify XPath -> Type mappings
  • Handle reading and writing of XML Documents containing a single choice or substitution group element

The XMLChoiceMapping allows the user to specify a number of different xpaths, and types associated with those xpaths. When any of these elements are encountered in the XML Document, they are read in as the correct type and set in the object.

Setting up XPath mappings:Unlike other OXM Mappings, instead of setting a single xpath, the addChoiceElement method is used to specify an xpath and the type associated with this xpath.
xmlChoiceCollectionMapping.addChoiceElement("mystring/text()", String.class);
xmlChoiceCollectionMapping.addChoiceElement("myaddress", Address.class);
[中]公众:
目的:提供一种映射,可以将单个属性映射到XML文档中的多个不同元素。这将用于映射到XML模式中的选项或替换组
责任:
*允许用户指定XPath->Type映射
*处理包含单个选项或替换组元素的XML文档的读写
XMLChoiceMapping允许用户指定许多不同的XPath,以及与这些XPath关联的类型。当在XML文档中遇到这些元素中的任何一个时,它们将作为正确的类型读入,并在对象中设置。
设置XPath映射:与其他OXM映射不同,addChoiceElement方法用于指定XPath以及与此XPath关联的类型,而不是设置单个XPath。
xmlChoiceCollectionMapping。addChoiceElement(“mystring/text()”,字符串。阶级);
xmlChoiceCollectionMapping。addChoiceElement(“myaddress”,Address.class);

代码示例

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

public void addChoiceElement(String xpath, String elementTypeName) {
  addChoiceElement(xpath, elementTypeName, false);
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

public void addChoiceElement(XMLField sourceField, Class elementType, XMLField targetField) {
  getFieldToClassMappings().put(sourceField, elementType);
  this.fieldToClassNameMappings.put(sourceField, elementType.getName());
  if (classToFieldMappings.get(elementType) == null) {
    classToFieldMappings.put(elementType, sourceField);
  }
  addChoiceElementMapping(sourceField, elementType, targetField);
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

public Vector<DatabaseField> getFields() {
  return this.collectFields();
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

public void addChoiceElement(List<XMLField> srcFields, String elementTypeName, List<XMLField> tgtFields) {
  for(XMLField sourceField:srcFields) {
    this.fieldToClassNameMappings.put(sourceField, elementTypeName);
  }
  if (getClassNameToSourceFieldsMappings().get(elementTypeName) == null) {
    getClassNameToSourceFieldsMappings().put(elementTypeName, srcFields);
  }
  addChoiceElementMapping(srcFields, elementTypeName, tgtFields);
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

public void addChoiceElement(List<XMLField> srcFields, Class elementType, List<XMLField> tgtFields) {
  for(XMLField sourceField:srcFields) {
    getFieldToClassMappings().put(sourceField, elementType);
    this.fieldToClassNameMappings.put(sourceField, elementType.getName());
  }
  if (getClassToSourceFieldsMappings().get(elementType) == null) {
    getClassToSourceFieldsMappings().put(elementType, srcFields);
  }
  addChoiceElementMapping(srcFields, elementType, tgtFields);
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

public void preInitialize(AbstractSession session) throws DescriptorException {
  getAttributeAccessor().setIsWriteOnly(this.isWriteOnly());
  getAttributeAccessor().setIsReadOnly(this.isReadOnly());
  super.preInitialize(session);
  Iterator<XMLMapping> mappings = getChoiceElementMappings().values().iterator();
  while(mappings.hasNext()){
    DatabaseMapping nextMapping = (DatabaseMapping)mappings.next();
    nextMapping.setDescriptor(getDescriptor());
    nextMapping.setAttributeName(this.getAttributeName());
    if(nextMapping.getAttributeAccessor() == temporaryAccessor){
      nextMapping.setAttributeAccessor(getAttributeAccessor());
    }                        
    nextMapping.preInitialize(session);
  }
  
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

private DatabaseMapping buildXMLChoiceObjectMapping(String mappingUri) {
  XMLChoiceObjectMapping mapping = new XMLChoiceObjectMapping();
  mapping.setAttributeName(getName());
  //First add XPath for this property
  String xPath = getQualifiedXPath(mappingUri, getType().isDataType());
  mapping.addChoiceElement(xPath, getType().getImplClass());
  //For each substitutable property, create the xpath and add it.
  Iterator<SDOProperty> properties = this.getSubstitutableElements().iterator();
  while(properties.hasNext()) {
    SDOProperty nextProp = properties.next();
    xPath = nextProp.getQualifiedXPath(mappingUri, nextProp.getType().isDataType(), getContainingType());
    mapping.addChoiceElement(xPath, nextProp.getType().getImplClass());
  }
  return mapping;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

try {
  if (jaxbMapping.isAbstractCompositeObjectMapping()) {
    XMLChoiceObjectMapping xmlChoiceMapping = new XMLChoiceObjectMapping();
    xmlChoiceMapping.setAttributeName(attributeName);
    copyAccessorToMapping(jaxbMapping, xmlChoiceMapping);
    xmlChoiceMapping.setProperties(jaxbMapping.getProperties());
    xmlChoiceMapping.addChoiceElement(compositeMapping.getXPath(), Link.class);
    xmlChoiceMapping.addChoiceElement(compositeMapping.getXPath(), refDesc.getJavaClass());
    xmlChoiceMapping.setConverter(new XMLJavaTypeConverter(Class.forName(adapterClassName, true, cl)));
    jaxbDescriptor.removeMappingForAttributeName(jaxbMapping.getAttributeName());
    jaxbDescriptor.addMapping(xmlChoiceMapping);

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

public void setChoiceFieldToClassAssociations(ArrayList associations) {
  if(associations.size() > 0) {
    for(Object next:associations) {
      XMLChoiceFieldToClassAssociation<Converter, XMLField> association = (XMLChoiceFieldToClassAssociation<Converter, XMLField>)next;
      this.addChoiceElement(association.getXmlField(), association.getClassName());
      if(association.getConverter() != null) {
        this.addConverter(association.getXmlField(), association.getConverter());
      }
    }
  }
}
private void addChoiceElementMapping(XMLField xmlField, String className){

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

mappingsList.addAll(getChoiceElementMappings().values());
for(XMLMapping next:getChoiceElementMappingsByClass().values()) {
  if(!(mappingsList.contains(next))) {
    mappingsList.add(next);
    ((XMLDirectMapping)nextMapping).setIsWriteOnly(this.isWriteOnly());
    if(converter != null){
      ((AbstractDirectMapping)nextMapping).setConverter(converter);
    ((XMLCompositeObjectMapping)nextMapping).setIsWriteOnly(this.isWriteOnly());
    if(converter != null){
      ((AbstractCompositeObjectMapping)nextMapping).setConverter(converter);

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

public void addChoiceElement(XMLField sourceField, String elementTypeName, XMLField targetField) {
  this.fieldToClassNameMappings.put(sourceField, elementTypeName);
  addChoiceElementMapping(sourceField, elementTypeName, targetField);
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

public ChoiceObjectMapping generateChoiceMapping(Property property, Descriptor descriptor, NamespaceInfo namespace) {
  ChoiceObjectMapping mapping = new XMLChoiceObjectMapping();
  initializeXMLMapping((XMLChoiceObjectMapping)mapping, property);

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

public void initializeNodeValue() {
  XMLMapping xmlMapping = xmlChoiceMapping.getChoiceElementMappings().get(xmlField);
  if(xmlMapping instanceof XMLDirectMapping) {
    choiceElementNodeValue = new XMLDirectMappingNodeValue((XMLDirectMapping)xmlMapping);
  } else {
    choiceElementNodeValue = new XMLCompositeObjectMappingNodeValue((XMLCompositeObjectMapping)xmlMapping);
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

@Override
public void writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session, WriteType writeType) throws DescriptorException {
  Object value = getAttributeValueFromObject(object);
  Class valueClass = value.getClass();
  if(valueClass == XMLRoot.class) {
    List<XMLField> xflds = getClassToSourceFieldsMappings().get(valueClass);
    if (xflds != null) { 
      valueField = xflds.get(0);

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  if (this.fieldToClassMappings.size() == 0) {
    this.convertClassNamesToClasses(((XMLConversionManager) session.getDatasourcePlatform().getConversionManager()).getLoader());
  Iterator<XMLMapping> mappings = getChoiceElementMappings().values().iterator();
  while(mappings.hasNext()){
    DatabaseMapping nextMapping = (DatabaseMapping)mappings.next();

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

public void writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session) throws DescriptorException {
  Object value = getAttributeValueFromObject(object);
  Class valueClass = value.getClass();
  if(valueClass == XMLRoot.class) {

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

public void preInitialize(AbstractSession session) throws DescriptorException {
  getAttributeAccessor().setIsWriteOnly(this.isWriteOnly());
  getAttributeAccessor().setIsReadOnly(this.isReadOnly());
  super.preInitialize(session);
  ArrayList<XMLMapping> mappingsList = new ArrayList<XMLMapping>();
  mappingsList.addAll(getChoiceElementMappings().values());
  for(XMLMapping next:getChoiceElementMappingsByClass().values()) {
    if(!(mappingsList.contains(next))) {
      mappingsList.add(next);
    }
  }
  for(XMLMapping next:getChoiceElementMappingsByClass().values()) {
    if(!(mappingsList.contains(next))) {
      mappingsList.add(next);
    }
  }
  Iterator<XMLMapping> mappings = mappingsList.iterator();
  while(mappings.hasNext()){
    DatabaseMapping nextMapping = (DatabaseMapping)mappings.next();
    nextMapping.setDescriptor(getDescriptor());
    nextMapping.setAttributeName(this.getAttributeName());
    if(nextMapping.getAttributeAccessor() == temporaryAccessor){
      nextMapping.setAttributeAccessor(getAttributeAccessor());
    }
    nextMapping.preInitialize(session);
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo

private DatabaseMapping buildXMLChoiceObjectMapping(String mappingUri) {
  XMLChoiceObjectMapping mapping = new XMLChoiceObjectMapping();
  mapping.setAttributeName(getName());
  //First add XPath for this property
  String xPath = getQualifiedXPath(mappingUri, getType().isDataType());
  mapping.addChoiceElement(xPath, getType().getImplClass());
  //For each substitutable property, create the xpath and add it.
  Iterator<SDOProperty> properties = this.getSubstitutableElements().iterator();
  while(properties.hasNext()) {
    SDOProperty nextProp = properties.next();
    xPath = nextProp.getQualifiedXPath(mappingUri, nextProp.getType().isDataType(), getContainingType());
    mapping.addChoiceElement(xPath, nextProp.getType().getImplClass());
  }
  return mapping;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.dbws

try {
  if (jaxbMapping.isAbstractCompositeObjectMapping()) {
    XMLChoiceObjectMapping xmlChoiceMapping = new XMLChoiceObjectMapping();
    xmlChoiceMapping.setAttributeName(attributeName);
    copyAccessorToMapping(jaxbMapping, xmlChoiceMapping);
    xmlChoiceMapping.setProperties(jaxbMapping.getProperties());
    xmlChoiceMapping.addChoiceElement(compositeMapping.getXPath(), Link.class);
    xmlChoiceMapping.addChoiceElement(compositeMapping.getXPath(), refDesc.getJavaClass());
    xmlChoiceMapping.setConverter(new XMLJavaTypeConverter(Class.forName(adapterClassName, true, cl)));
    jaxbDescriptor.removeMappingForAttributeName(jaxbMapping.getAttributeName());
    jaxbDescriptor.addMapping(xmlChoiceMapping);

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

public void setChoiceFieldToClassAssociations(ArrayList associations) {
  if(associations.size() > 0) {
    for(Object next:associations) {
      XMLChoiceFieldToClassAssociation<Converter, XMLField> association = (XMLChoiceFieldToClassAssociation<Converter, XMLField>)next;
      this.addChoiceElement(association.getXmlField(), association.getClassName());
      if(association.getConverter() != null) {
        this.addConverter(association.getXmlField(), association.getConverter());
      }
    }
  }
}
private void addChoiceElementMapping(XMLField xmlField, String className){

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