gpt4 book ai didi

org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping.getField()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 16:19:05 38 4
gpt4 key购买 nike

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

XMLCompositeDirectCollectionMapping.getField介绍

暂无

代码示例

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

public Object convertObjectValueToDataValue(Object objectValue, Session session) {
  return this.conversionManager.convertListToString(objectValue, ((Field)mapping.getField()).getSchemaType());
}

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

public Object convertObjectValueToDataValue(Object objectValue, Session session) {
  return this.conversionManager.convertListToString(objectValue, ((Field)mapping.getField()).getSchemaType());
}

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

public void writeSingleValue(Object value, Object parent, XMLRecord record, AbstractSession session) {
  Object element = convertObjectValueToDataValue(value, session, record.getMarshaller());
  record.add(this.getField(), element);
}

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

public void writeSingleValue(Object value, Object parent, XMLRecord record, AbstractSession session) {
  Object element = convertObjectValueToDataValue(value, session, record.getMarshaller());
  record.add(this.getField(), element);
}

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

public Object convertDataValueToObjectValue(Object dataValue, Session session) {
  return this.conversionManager.convertStringToList(dataValue, getObjectClass(), mapping.getContainerPolicy(), ((Field)mapping.getField()).getSchemaType());
}

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

public Object convertDataValueToObjectValue(Object dataValue, Session session) {
  return this.conversionManager.convertStringToList(dataValue, getObjectClass(), mapping.getContainerPolicy(), ((Field)mapping.getField()).getSchemaType());
}

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

/**
 * INTERNAL:
 * Initialize the mapping.
 */
public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  if (this.getField() instanceof XMLField) {
    if (valueConverter instanceof TypeConversionConverter) {
      TypeConversionConverter converter = (TypeConversionConverter) valueConverter;
      this.getField().setType(converter.getObjectClass());
    }
    String xpathString = ((XMLField) getField()).getXPath();
    if (this.isAbstractCompositeDirectCollectionMapping() && (xpathString.indexOf(XMLConstants.ATTRIBUTE) == -1) && (!xpathString.endsWith(XMLConstants.TEXT))) {
      throw DescriptorException.invalidXpathForXMLDirectMapping(this);
    }
  }
  ContainerPolicy cp = getContainerPolicy();
  if (cp != null) {
    if (cp.getContainerClass() == null) {
      Class cls = session.getDatasourcePlatform().getConversionManager().convertClassNameToClass(cp.getContainerClassName());
      cp.setContainerClass(cls);
    }
  }
  ((XMLField) this.getField()).setIsCDATA(this.isCDATA());
}

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

/**
 * INTERNAL:
 * Initialize the mapping.
 */
public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  if (this.getField() instanceof XMLField) {
    if (valueConverter instanceof TypeConversionConverter) {
      TypeConversionConverter converter = (TypeConversionConverter) valueConverter;
      this.getField().setType(converter.getObjectClass());
    }
    String xpathString = ((XMLField) getField()).getXPath();
    if (this.isAbstractCompositeDirectCollectionMapping() && (xpathString.indexOf(XMLConstants.ATTRIBUTE) == -1) && (!xpathString.endsWith(XMLConstants.TEXT))) {
      throw DescriptorException.invalidXpathForXMLDirectMapping(this);
    }
  }
  ContainerPolicy cp = getContainerPolicy();
  if (cp != null) {
    if (cp.getContainerClass() == null) {
      Class cls = session.getDatasourcePlatform().getConversionManager().convertClassNameToClass(cp.getContainerClassName());
      cp.setContainerClass(cls);
    }
  }
  ((XMLField) this.getField()).setIsCDATA(this.isCDATA());
}

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

/**
 * INTERNAL:
 * Initialize the mapping.
 */
public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  if (this.getField() instanceof XMLField && getValueConverter() instanceof TypeConversionConverter) {
    TypeConversionConverter converter = (TypeConversionConverter) getValueConverter();
    this.getField().setType(converter.getObjectClass());
  }
  ContainerPolicy cp = getContainerPolicy();
  if (cp != null) {
    if (cp.getContainerClass() == null) {
      Class cls = session.getDatasourcePlatform().getConversionManager().convertClassNameToClass(cp.getContainerClassName());
      cp.setContainerClass(cls);
    }
  }
  ((XMLField) this.getField()).setIsCDATA(this.isCDATA());
}

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

public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) {
  XMLField xmlField = (XMLField) xmlCompositeDirectCollectionMapping.getField();
  if (!xmlField.getLastXPathFragment().nameIsText()) {
    return;
  }
  
  Object value = unmarshalRecord.getStringBuffer().toString();
  Object collection = unmarshalRecord.getContainerInstance(this);
  unmarshalRecord.resetStringBuffer();
  if (xmlCompositeDirectCollectionMapping.usesSingleNode()) {
    StringTokenizer stringTokenizer = new StringTokenizer((String) value);
    while (stringTokenizer.hasMoreTokens()) {
      addUnmarshalValue(unmarshalRecord, stringTokenizer.nextToken(), collection);
    }
  } else {
    if (value.equals(XMLConstants.EMPTY_STRING)) {
      if (xmlCompositeDirectCollectionMapping.getNullPolicy().isNullRepresentedByEmptyNode() ||
          xmlCompositeDirectCollectionMapping.getNullPolicy().isNullRepresentedByXsiNil()) {
        return;
      }
    }
    addUnmarshalValue(unmarshalRecord, value, collection);
  }
}

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

public void writeSingleValue(Object value, Object parent, XMLRecord record, AbstractSession session) {
  Object element = value;
  if (hasValueConverter()) {
    if (getValueConverter() instanceof XMLConverter) {
      element = ((XMLConverter) getValueConverter()).convertObjectValueToDataValue(element, session, record.getMarshaller());
    } else {
      element = getValueConverter().convertObjectValueToDataValue(element, session);
    }
  }
  record.add(this.getField(), element);
}

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

public boolean startElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Attributes atts) {
  XMLField xmlField = (XMLField) xmlCompositeDirectCollectionMapping.getField();
  if (xmlField.getLastXPathFragment().nameIsText()) {
    String type = atts.getValue(XMLConstants.SCHEMA_INSTANCE_URL, XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    if (null != type) {
      String namespaceURI = null;
      int colonIndex = type.indexOf(XMLConstants.COLON);
      if (colonIndex > -1) {
        String prefix = type.substring(0, colonIndex);
        namespaceURI = unmarshalRecord.resolveNamespacePrefix(prefix);
        type = type.substring(colonIndex + 1);
      }
      unmarshalRecord.setTypeQName(new QName(namespaceURI, type));
    }
    if (xmlCompositeDirectCollectionMapping.getNullPolicy().isNullRepresentedByXsiNil() && xmlCompositeDirectCollectionMapping.getNullPolicy().valueIsNull(atts)) {
      getContainerPolicy().addInto(null, unmarshalRecord.getContainerInstance(this), unmarshalRecord.getSession());
    }
  } else if (xmlField.getLastXPathFragment().isAttribute()) {
    if (!this.xmlCompositeDirectCollectionMapping.usesSingleNode()) {
      String namespaceURI = xmlField.getLastXPathFragment().getNamespaceURI();
      if (namespaceURI == null) {
        namespaceURI = XMLConstants.EMPTY_STRING;
      }
      String value = atts.getValue(namespaceURI, xmlField.getLastXPathFragment().getLocalName());
      Object collection = unmarshalRecord.getContainerInstance(this);
      addUnmarshalValue(unmarshalRecord, value, collection);
    }
  }
  return true;
}

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

private XMLDescriptor buildAnnotationDescriptor() {
  XMLDescriptor descriptor = new XMLDescriptor();
  descriptor.setJavaClass(Annotation.class);
  descriptor.setNamespaceResolver(namespaceResolver);
  XMLCompositeDirectCollectionMapping documentationMapping = new XMLCompositeDirectCollectionMapping();
  documentationMapping.setAttributeName("documentation");
  documentationMapping.useCollectionClass(ArrayList.class);
  documentationMapping.setXPath(Constants.SCHEMA_PREFIX + ":" + "documentation");
  ((XMLField)documentationMapping.getField()).setUsesSingleNode(false);
  descriptor.addMapping(documentationMapping);
  XMLFragmentCollectionMapping appInfoMapping = new XMLFragmentCollectionMapping();
  appInfoMapping.setAttributeName("appInfo");
  appInfoMapping.setXPath(Constants.SCHEMA_PREFIX + ":" + "appinfo");
  appInfoMapping.useCollectionClass(java.util.ArrayList.class);
  descriptor.addMapping(appInfoMapping);
  return descriptor;
}

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

private XMLDescriptor buildAnnotationDescriptor() {
  XMLDescriptor descriptor = new XMLDescriptor();
  descriptor.setJavaClass(Annotation.class);
  descriptor.setNamespaceResolver(namespaceResolver);
  XMLCompositeDirectCollectionMapping documentationMapping = new XMLCompositeDirectCollectionMapping();
  documentationMapping.setAttributeName("documentation");
  documentationMapping.useCollectionClass(ArrayList.class);
  documentationMapping.setXPath(Constants.SCHEMA_PREFIX + ":" + "documentation");
  ((XMLField)documentationMapping.getField()).setUsesSingleNode(false);
  descriptor.addMapping(documentationMapping);
  XMLFragmentCollectionMapping appInfoMapping = new XMLFragmentCollectionMapping();
  appInfoMapping.setAttributeName("appInfo");
  appInfoMapping.setXPath(Constants.SCHEMA_PREFIX + ":" + "appinfo");
  appInfoMapping.useCollectionClass(java.util.ArrayList.class);
  descriptor.addMapping(appInfoMapping);
  return descriptor;
}

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

private XMLDescriptor buildAnnotationDescriptor() {
  XMLDescriptor descriptor = new XMLDescriptor();
  descriptor.setJavaClass(Annotation.class);
  descriptor.setNamespaceResolver(namespaceResolver);
  XMLCompositeDirectCollectionMapping documentationMapping = new XMLCompositeDirectCollectionMapping();
  documentationMapping.setAttributeName("documentation");
  documentationMapping.useCollectionClass(ArrayList.class);
  documentationMapping.setXPath(XMLConstants.SCHEMA_PREFIX + ":" + "documentation");
  ((XMLField)documentationMapping.getField()).setUsesSingleNode(false);
  descriptor.addMapping(documentationMapping);
  XMLFragmentCollectionMapping appInfoMapping = new XMLFragmentCollectionMapping();
  appInfoMapping.setAttributeName("appInfo");
  appInfoMapping.setXPath(XMLConstants.SCHEMA_PREFIX + ":" + "appinfo");
  appInfoMapping.useCollectionClass(java.util.ArrayList.class);
  descriptor.addMapping(appInfoMapping);
  return descriptor;
}

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

public SDOChangeSummaryType(SDOTypeHelper sdoTypeHelper) {
  super(SDOConstants.SDO_URL, SDOConstants.CHANGESUMMARY, sdoTypeHelper);
  setInstanceClass(ChangeSummary.class);
  xmlDescriptor.setJavaClass(SDOChangeSummary.class);
  xmlDescriptor.setSequencedObject(false);
  
  XMLDirectMapping loggingMapping = new XMLDirectMapping();
  loggingMapping.setAttributeName("loggingMapping");
  loggingMapping.setXPath("@logging");
  loggingMapping.setNullValue(Boolean.TRUE);
  xmlDescriptor.addMapping(loggingMapping);
  XMLCompositeDirectCollectionMapping createdMapping = new XMLCompositeDirectCollectionMapping();
  createdMapping.setAttributeName("createdXPaths");
  createdMapping.setXPath("@create");
  createdMapping.useCollectionClass(ArrayList.class);
  ((XMLField)createdMapping.getField()).setUsesSingleNode(true);
  xmlDescriptor.addMapping(createdMapping);
  XMLCompositeDirectCollectionMapping deletedMapping = new XMLCompositeDirectCollectionMapping();
  deletedMapping.setAttributeName("deletedXPaths");
  deletedMapping.setXPath("@delete");
  deletedMapping.useCollectionClass(ArrayList.class);
  ((XMLField)deletedMapping.getField()).setUsesSingleNode(true);
  xmlDescriptor.addMapping(deletedMapping);
  XMLAnyCollectionMapping aChangeMapping = new XMLAnyCollectionMapping();
  aChangeMapping.setAttributeName("modifiedDoms");
  aChangeMapping.setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT);
  aChangeMapping.useCollectionClass(ArrayList.class);
  xmlDescriptor.addMapping(aChangeMapping);
}

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

private DatabaseMapping buildXMLCompositeDirectCollectionMapping(String mappingUri) {
  XMLCompositeDirectCollectionMapping mapping = new XMLCompositeDirectCollectionMapping();
  mapping.setAttributeName(getName());
  String xpath = getQualifiedXPath(mappingUri, true);
  mapping.setXPath(xpath);
  mapping.setAttributeElementClass(getType().getInstanceClass());
  if (getXsdType() != null) {
    ((XMLField)mapping.getField()).setSchemaType(getXsdType());
  } 
  if (getType().equals(SDOConstants.SDO_STRINGS)) {
    mapping.setUsesSingleNode(true);
  }
  
  if (getType().getInstanceClass() != null) {
    if (shouldAddInstanceClassConverter()) {
      InstanceClassConverter converter = new InstanceClassConverter();
      converter.setCustomClass(getType().getInstanceClass());
      mapping.setValueConverter(converter);
    }
  }
  return mapping;
}

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

private DatabaseMapping buildXMLCompositeDirectCollectionMapping(String mappingUri) {
  XMLCompositeDirectCollectionMapping mapping = new XMLCompositeDirectCollectionMapping();
  mapping.setAttributeName(getName());
  String xpath = getQualifiedXPath(mappingUri, true);
  mapping.setXPath(xpath);
  mapping.setAttributeElementClass(getType().getInstanceClass());
  if (getXsdType() != null) {
    ((XMLField)mapping.getField()).setSchemaType(getXsdType());
  }
  if (getType().equals(SDOConstants.SDO_STRINGS)) {
    mapping.setUsesSingleNode(true);
  }
  if (getType().getInstanceClass() != null) {
    if (shouldAddInstanceClassConverter()) {
      InstanceClassConverter converter = new InstanceClassConverter();
      converter.setCustomClass(getType().getInstanceClass());
      mapping.setValueConverter(converter);
    }
  }
  return mapping;
}

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

public SDOChangeSummaryType(SDOTypeHelper sdoTypeHelper) {
  super(SDOConstants.SDO_URL, SDOConstants.CHANGESUMMARY, sdoTypeHelper);
  setInstanceClass(ChangeSummary.class);
  xmlDescriptor.setJavaClass(SDOChangeSummary.class);
  xmlDescriptor.setSequencedObject(false);
  XMLDirectMapping loggingMapping = new XMLDirectMapping();
  loggingMapping.setAttributeName("loggingMapping");
  loggingMapping.setXPath("@logging");
  loggingMapping.setNullValue(Boolean.TRUE);
  xmlDescriptor.addMapping(loggingMapping);
  XMLCompositeDirectCollectionMapping createdMapping = new XMLCompositeDirectCollectionMapping();
  createdMapping.setAttributeName("createdXPaths");
  createdMapping.setXPath("@create");
  createdMapping.useCollectionClass(ArrayList.class);
  ((XMLField)createdMapping.getField()).setUsesSingleNode(true);
  xmlDescriptor.addMapping(createdMapping);
  XMLCompositeDirectCollectionMapping deletedMapping = new XMLCompositeDirectCollectionMapping();
  deletedMapping.setAttributeName("deletedXPaths");
  deletedMapping.setXPath("@delete");
  deletedMapping.useCollectionClass(ArrayList.class);
  ((XMLField)deletedMapping.getField()).setUsesSingleNode(true);
  xmlDescriptor.addMapping(deletedMapping);
  XMLAnyCollectionMapping aChangeMapping = new XMLAnyCollectionMapping();
  aChangeMapping.setAttributeName("modifiedDoms");
  aChangeMapping.setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_ALL_AS_ELEMENT);
  aChangeMapping.useCollectionClass(ArrayList.class);
  xmlDescriptor.addMapping(aChangeMapping);
}

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

private void addUnmarshalValue(UnmarshalRecord unmarshalRecord, Object value, Object collection) {
  if (null == value) {
    return;
  }
  if (xmlCompositeDirectCollectionMapping.getNullPolicy().isNullRepresentedByXsiNil() && xmlCompositeDirectCollectionMapping.getNullPolicy().valueIsNull(unmarshalRecord.getAttributes())) {
    return;
  }
  if ((!isWhitespaceAware() && XMLConstants.EMPTY_STRING.equals(value))) {
    return;
  }
  XMLField xmlField = (XMLField) xmlCompositeDirectCollectionMapping.getField();
  XMLConversionManager xmlConversionManager = (XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager();
  if (unmarshalRecord.getTypeQName() != null) {
    Class typeClass = xmlField.getJavaClass(unmarshalRecord.getTypeQName());
    value = xmlConversionManager.convertObject(value, typeClass, unmarshalRecord.getTypeQName());
  } else {
    value = xmlField.convertValueBasedOnSchemaType(value, xmlConversionManager, unmarshalRecord);
  }
  if (xmlCompositeDirectCollectionMapping.hasValueConverter()) {
    if (xmlCompositeDirectCollectionMapping.getValueConverter() instanceof XMLConverter) {
      value = ((XMLConverter) xmlCompositeDirectCollectionMapping.getValueConverter()).convertDataValueToObjectValue(value, unmarshalRecord.getSession(), unmarshalRecord.getUnmarshaller());
    } else {
      value = xmlCompositeDirectCollectionMapping.getValueConverter().convertDataValueToObjectValue(value, unmarshalRecord.getSession());
    }
  }
  
  unmarshalRecord.addAttributeValue(this, value, collection);
}

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