org.eclipse.persistence.oxm.XMLField.convertValueBasedOnSchemaType()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(13.0k)|赞(0)|评价(0)|浏览(75)

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

XMLField.convertValueBasedOnSchemaType介绍

[英]INTERNAL: Called from DOMRecord and XMLReader. MappingNodeValues call XMLReader which calls this method so that other XMLReader subclasses can override.
[中]内部:从DOMRecord和XMLReader调用。MappingNodeValue调用XMLReader,XMLReader调用此方法,以便其他XMLReader子类可以重写。

代码示例

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

private Object getValueFromAttribute(Attr node, XMLField key) {
  currentNode = node.getOwnerElement();
  Object convertedValue = key.convertValueBasedOnSchemaType(node.getNodeValue(), (XMLConversionManager) session.getDatasourcePlatform().getConversionManager(), this);
  currentNode = getDOM();
  return convertedValue;
}

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

private Object getValueFromAttribute(Attr node, XMLField key) {
  currentNode = node.getOwnerElement();
  Object convertedValue = key.convertValueBasedOnSchemaType(node.getNodeValue(), (XMLConversionManager) session.getDatasourcePlatform().getConversionManager(), this);
  currentNode = getDOM();
  return convertedValue;
}

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

private Object getValueFromAttribute(Attr node, XMLField key) {
  currentNode = node.getOwnerElement();
  Object convertedValue = key.convertValueBasedOnSchemaType(node.getNodeValue(), (XMLConversionManager) session.getDatasourcePlatform().getConversionManager(), this);
  currentNode = getDOM();
  return convertedValue;
}

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

private Object convertValue(Element node, XMLField key, Object value) {
  XMLConversionManager xmlCnvMgr = (XMLConversionManager) session.getDatasourcePlatform().getConversionManager();
  if (key.isTypedTextField() && (node != null)) {
    String schemaType = node.getAttributeNS(XMLConstants.SCHEMA_INSTANCE_URL, XMLConstants.SCHEMA_TYPE_ATTRIBUTE);
    if ((null != schemaType) && (schemaType.length() > 0)) {
      QName qname = null;
      int index = schemaType.indexOf(XMLConstants.COLON);
      if (index == -1) {
        qname = new QName(schemaType);
        Class convertClass = key.getJavaClass(qname);
        return xmlCnvMgr.convertObject(value, convertClass);
      } else {
        String prefix = schemaType.substring(0, index);
        String localPart = schemaType.substring(index + 1);
        XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
        String url = xmlPlatform.resolveNamespacePrefix(node, prefix);
        qname = new QName(url, localPart);
        Class convertClass = key.getJavaClass(qname);
        return xmlCnvMgr.convertObject(value, convertClass, qname);
      }
    }
  }
  currentNode = node;
  Object convertedValue = key.convertValueBasedOnSchemaType(value, xmlCnvMgr, this);
  currentNode = getDOM();
  return convertedValue;
}

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

/**
 * Handle attribute operation.  Here we will create and populate an 
 * org.eclipse.persistence.internal.oxm.Reference instance to be used during 
 * the mapping resolution stage.  In particular, the primary key value
 * for this element will be added to the Reference object's list of
 * target primary key values.  Note that if a reference already exists 
 * for the xmlObjectReferenceMapping's source object instance, we will
 * simply add to the target pk value list.  The Reference object will 
 * is stored on the ReferenceResolver associated with the UnmarshalRecord's
 * session.
 */
public void attribute(UnmarshalRecord unmarshalRecord, String namespaceURI, String localName, String value) {
  if (value != null) {
    Object realValue = xmlField.convertValueBasedOnSchemaType(value, (XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager(),unmarshalRecord);
    // build a reference which will be resolved after unmarshalling is complete
    xmlObjectReferenceMapping.buildReference(unmarshalRecord, xmlField, realValue, unmarshalRecord.getSession());
  }
}

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

/**
 * Handle attribute operation.  Here we will create and populate an 
 * org.eclipse.persistence.internal.oxm.Reference instance to be used during 
 * the mapping resolution stage.  In particular, the primary key value
 * for this element will be added to the Reference object's map of
 * target primary key values - based on the target key field name.  Note 
 * that if a reference already exists for the xmlCollectionReferenceMapping's 
 * source object instance, we will simply add to the target pk value list.  
 * The Reference object is stored on the ReferenceResolver associated with 
 * the UnmarshalRecord's session.
 */
public void attribute(UnmarshalRecord unmarshalRecord, String namespaceURI, String localName, String value) {
  if (value != null) {
    Object realValue = xmlField.convertValueBasedOnSchemaType(value, (XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager(),unmarshalRecord);
    // build a reference which will be resolved after unmarshalling is complete
    xmlCollectionReferenceMapping.buildReference(unmarshalRecord, xmlField, realValue, unmarshalRecord.getSession());
  }
}

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

public void attribute(UnmarshalRecord unmarshalRecord, String namespaceURI, String localName, String value) {
  XMLConversionManager xmlConversionManager = (XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager();
  Object objectValue = xmlField.convertValueBasedOnSchemaType(value, xmlConversionManager, unmarshalRecord);
  // PUT VALUE INTO A RECORD KEYED ON XMLFIELD
  if (null == unmarshalRecord.getTransformationRecord()) {
    unmarshalRecord.setTransformationRecord(new XMLTransformationRecord("ROOT", unmarshalRecord));
  }
  unmarshalRecord.getTransformationRecord().put(xmlField, objectValue);
}

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

public void attribute(UnmarshalRecord unmarshalRecord, String namespaceURI, String localName, String value) {
  unmarshalRecord.removeNullCapableValue(this);
  XMLField xmlField = (XMLField) xmlDirectMapping.getField();
  Object realValue = xmlField.convertValueBasedOnSchemaType(value, (XMLConversionManager) unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager(), unmarshalRecord);
  // Perform operations on the object based on the null policy
  Object convertedValue = xmlDirectMapping.getAttributeValue(realValue, unmarshalRecord.getSession(), unmarshalRecord);
  xmlDirectMapping.setAttributeValueInObject(unmarshalRecord.getCurrentObject(), convertedValue);
}

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

/**
 * Handle endElement operation.  Here we will create and populate an 
 * org.eclipse.persistence.internal.oxm.Reference instance to be used during 
 * the mapping resolution stage.  In particular, the primary key value
 * for this element will be added to the Reference object's list of
 * target primary key values.  Note that if a reference already exists 
 * for the xmlObjectReferenceMapping's source object instance, we will
 * simply add to the target pk value list.  The Reference object will 
 * is stored on the ReferenceResolver associated with the UnmarshalRecord's
 * session.
 */
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) {
  if (!xmlField.getLastXPathFragment().nameIsText()) {
    return;
  }
  Object value = unmarshalRecord.getStringBuffer().toString();
  unmarshalRecord.resetStringBuffer();
  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);
  }
  // build a reference which will be resolved after unmarshalling is complete
  xmlObjectReferenceMapping.buildReference(unmarshalRecord, xmlField, value, unmarshalRecord.getSession());
}

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

/**
 * Handle endElement operation.  Here we will create and populate an 
 * org.eclipse.persistence.internal.oxm.Reference instance to be used during 
 * the mapping resolution stage.  In particular, the primary key value
 * for this element will be added to the Reference object's map of
 * target primary key values - based on the target key field name.  Note 
 * that if a reference already exists for the xmlCollectionReferenceMapping's 
 * source object instance, we will simply add to the target pk value list.  
 * The Reference object is stored on the ReferenceResolver associated with 
 * the UnmarshalRecord's session.
 */
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) {
  if (!xmlField.getLastXPathFragment().nameIsText()) {
    return;
  }
  Object value = unmarshalRecord.getStringBuffer().toString();
  unmarshalRecord.resetStringBuffer();
  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);
  }
  // build a reference which will be resolved after unmarshalling is complete
  xmlCollectionReferenceMapping.buildReference(unmarshalRecord, xmlField, value, unmarshalRecord.getSession());
}

代码示例来源: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);
}

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

public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) {
  unmarshalRecord.removeNullCapableValue(this);
  XMLField xmlField = (XMLField) xmlDirectMapping.getField();
  if (!xmlField.getLastXPathFragment().nameIsText()) {
    return;
  }
  Object value;
  if(unmarshalRecord.getStringBuffer().length() == 0) {
    value = this.getMapping().getNullValue();
  } else {
    value = unmarshalRecord.getStringBuffer().toString();
  }
  unmarshalRecord.resetStringBuffer();
  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);
  }
  Object convertedValue = xmlDirectMapping.getAttributeValue(value, unmarshalRecord.getSession(), unmarshalRecord);
  unmarshalRecord.setAttributeValue(convertedValue, xmlDirectMapping);
}

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

public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord) {
    Object value = unmarshalRecord.getStringBuffer().toString();
    boolean isCDATA = unmarshalRecord.isBufferCDATA();
    unmarshalRecord.resetStringBuffer();
    XMLField toWrite = xmlField;
    if(xmlField.isCDATA() != isCDATA) {
      toWrite = new XMLField(xmlField.getName());
      toWrite.setNamespaceResolver(xmlField.getNamespaceResolver());
      toWrite.setIsCDATA(isCDATA);
    }
    //xmlField.setIsCDATA(isCDATA);
    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);
    }

    // PUT VALUE INTO A RECORD KEYED ON XMLFIELD
    if (null == unmarshalRecord.getTransformationRecord()) {
      unmarshalRecord.setTransformationRecord(new XMLTransformationRecord("ROOT", unmarshalRecord));
    }
    unmarshalRecord.getTransformationRecord().put(toWrite, value);
  }
}

相关文章