本文整理了Java中org.eclipse.persistence.oxm.mappings.XMLDirectMapping.getField()
方法的一些代码示例,展示了XMLDirectMapping.getField()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLDirectMapping.getField()
方法的具体详情如下:
包路径:org.eclipse.persistence.oxm.mappings.XMLDirectMapping
类名称:XMLDirectMapping
方法名:getField
[英]INTERNAL: Convert the attribute value to a field value. Process any converter if defined, and check for null values.
[中]内部:将属性值转换为字段值。处理任何转换器(如果已定义),并检查空值。
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
public void writeSingleValue(Object value, Object parent, XMLRecord row, AbstractSession session) {
Object fieldValue = getFieldValue(value, session, row);
writeValueIntoRow(row, getField(), fieldValue);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
protected void writeValueIntoRow(AbstractRecord row, DatabaseField aField, Object fieldValue) {
row.put(getField(), fieldValue);
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
Class fieldClassification = getFieldClassification(getField());
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
protected void writeValueIntoRow(AbstractRecord row, DatabaseField aField, Object fieldValue) {
row.put(getField(), fieldValue);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public void writeSingleValue(Object value, Object parent, XMLRecord row, AbstractSession session) {
Object fieldValue = getFieldValue(value, session, row);
if(fieldValue == null && getNullPolicy() != null) {
getNullPolicy().directMarshal((Field) this.getField(), row, parent);
} else {
writeValueIntoRow(row, getField(), fieldValue);
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
protected void writeValueIntoRow(AbstractRecord row, DatabaseField aField, Object fieldValue) {
row.put(getField(), fieldValue);
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public void writeSingleValue(Object value, Object parent, XMLRecord row, AbstractSession session) {
Object fieldValue = getFieldValue(value, session, row);
if(fieldValue == null && getNullPolicy() != null) {
getNullPolicy().directMarshal((Field) this.getField(), row, parent);
} else {
writeValueIntoRow(row, getField(), fieldValue);
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* Return the schema type for a given mapping's xmlfield. If the field does not have a schema type
* set, the attribute classification will be used if non-null. Otherwise, ClassConstants.STRING
* will be returned.
*
* @param mapping
* @param workingSchema
* @return
*/
protected String getSchemaTypeForDirectMapping(XMLDirectMapping mapping, Schema workingSchema) {
return getSchemaTypeForElement((XMLField) mapping.getField(), mapping.getAttributeClassification(), workingSchema);
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object objectValue, AbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) {
Object fieldValue = xmlDirectMapping.getFieldValue(objectValue, session, marshalRecord);
// Check for a null value
if (null == fieldValue) {
// Perform marshal operations based on the null policy
return xmlDirectMapping.getNullPolicy().directMarshal(xPathFragment, marshalRecord, object, session, namespaceResolver);
} else {
QName schemaType = getSchemaType((XMLField) xmlDirectMapping.getField(), fieldValue, session);
String stringValue = getValueToWrite(schemaType, fieldValue, (XMLConversionManager) session.getDatasourcePlatform().getConversionManager(), namespaceResolver);
XPathFragment groupingFragment = marshalRecord.openStartGroupingElements(namespaceResolver);
if (xPathFragment.isAttribute()) {
marshalRecord.attribute(xPathFragment, namespaceResolver, stringValue);
marshalRecord.closeStartGroupingElements(groupingFragment);
} else {
marshalRecord.closeStartGroupingElements(groupingFragment);
if (xmlDirectMapping.isCDATA()) {
marshalRecord.cdata(stringValue);
} else {
marshalRecord.characters(stringValue);
}
}
return true;
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public void initialize(AbstractSession session) throws DescriptorException {
super.initialize(session);
((XMLField)getField()).setIsCDATA(this.isCDATA());
String xpathString = ((XMLField)getField()).getXPath();
if (this.isAbstractDirectMapping() && (xpathString.indexOf(XMLConstants.ATTRIBUTE) == -1) && (!xpathString.endsWith(XMLConstants.TEXT))) {
throw DescriptorException.invalidXpathForXMLDirectMapping(this);
}
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public void initialize(AbstractSession session) throws DescriptorException {
super.initialize(session);
((XMLField)getField()).setIsCDATA(this.isCDATA());
String xpathString = ((XMLField)getField()).getXPath();
if (this.isAbstractDirectMapping() && (xpathString.indexOf(XMLConstants.ATTRIBUTE) == -1) && (!xpathString.endsWith(XMLConstants.TEXT))) {
throw DescriptorException.invalidXpathForXMLDirectMapping(this);
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
public void initialize(AbstractSession session) throws DescriptorException {
super.initialize(session);
((XMLField)getField()).setIsCDATA(this.isCDATA());
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* Build and return an Attribute for a given XMLDirectMapping.
*
* @param mapping
* @param schemaType
* @return
*/
protected Attribute buildAttribute(XMLDirectMapping mapping, String schemaType) {
XPathFragment frag = ((XMLField) mapping.getField()).getXPathFragment();
Attribute attr = new Attribute();
attr.setName(frag.getShortName());
attr.setType(schemaType);
return attr;
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public void initializeMappings() {
Iterator propIterator = this.getDeclaredProperties().iterator();
while(propIterator.hasNext()) {
SDOProperty nextProp = (SDOProperty)propIterator.next();
if(nextProp.getName().equals("type")) {
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName(nextProp.getName());
String xpath = nextProp.getQualifiedXPath(SDOConstants.SDO_URL, true);
mapping.setXPath(xpath);
mapping.setConverter(new TypeStringConverter(this.typeHelper));
if (getXsdType() != null) {
((XMLField)mapping.getField()).setSchemaType(getXsdType());
}
nextProp.setXmlMapping(mapping);
nextProp.addMappingToOwner(true, -1);
} else if(nextProp.getName().equals("opposite")) {
} else {
nextProp.buildMapping(SDOConstants.SDO_URL);
}
}
initialized = true;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo
public void initializeMappings() {
Iterator propIterator = this.getDeclaredProperties().iterator();
while(propIterator.hasNext()) {
SDOProperty nextProp = (SDOProperty)propIterator.next();
if(nextProp.getName().equals("type")) {
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName(nextProp.getName());
String xpath = nextProp.getQualifiedXPath(SDOConstants.SDO_URL, true);
mapping.setXPath(xpath);
mapping.setConverter(new TypeStringConverter(this.typeHelper));
if (getXsdType() != null) {
((XMLField)mapping.getField()).setSchemaType(getXsdType());
}
nextProp.setXmlMapping(mapping);
nextProp.addMappingToOwner(true, -1);
} else if(nextProp.getName().equals("opposite")) {
} else {
nextProp.buildMapping(SDOConstants.SDO_URL);
}
}
initialized = true;
}
代码示例来源: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/org.eclipse.persistence.sdo
private void initializeDescriptor(XMLDescriptor aDescriptor, QName aQName, Type aPropertyType, SDOProperty aValueProperty) {
aDescriptor.setNamespaceResolver(null);
SDOMethodAttributeAccessor accessor = null;
accessor = new SDOMethodAttributeAccessor(aValueProperty);
if (XMLConstants.QNAME_QNAME.equals(aQName)) {
XMLTransformationMapping mapping = new XMLTransformationMapping();
mapping.setAttributeName(ATTRIBUTE_NAME);
QNameTransformer transformer = new QNameTransformer("text()");
mapping.setAttributeTransformer(transformer);
mapping.addFieldTransformer(XPATH, transformer);
NamespaceResolver nsr = new NamespaceResolver();
nsr.setDefaultNamespaceURI(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
XMLField field = new XMLField();
field.setNamespaceResolver(nsr);
field.setXPath("@" + javax.xml.XMLConstants.XMLNS_ATTRIBUTE);
mapping.addFieldTransformer(field, new NamespaceURITransformer());
mapping.setAttributeAccessor(accessor);
aDescriptor.addMapping(mapping);
} else {
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName(ATTRIBUTE_NAME);
mapping.setXPath(XPATH);
mapping.setAttributeClassification(aPropertyType.getInstanceClass());
((XMLField) mapping.getField()).setSchemaType(aQName);
mapping.setAttributeAccessor(accessor);
aDescriptor.addMapping(mapping);
}
aDescriptor.setIsWrapper(true);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
private void initializeDescriptor(XMLDescriptor aDescriptor, QName aQName, Type aPropertyType, SDOProperty aValueProperty) {
aDescriptor.setNamespaceResolver(null);
SDOMethodAttributeAccessor accessor = null;
accessor = new SDOMethodAttributeAccessor(aValueProperty);
if (XMLConstants.QNAME_QNAME.equals(aQName)) {
XMLTransformationMapping mapping = new XMLTransformationMapping();
mapping.setAttributeName(ATTRIBUTE_NAME);
QNameTransformer transformer = new QNameTransformer("text()");
mapping.setAttributeTransformer(transformer);
mapping.addFieldTransformer(XPATH, transformer);
NamespaceResolver nsr = new NamespaceResolver();
nsr.setDefaultNamespaceURI(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
XMLField field = new XMLField();
field.setNamespaceResolver(nsr);
field.setXPath("@" + javax.xml.XMLConstants.XMLNS_ATTRIBUTE);
mapping.addFieldTransformer(field, new NamespaceURITransformer());
mapping.setAttributeAccessor(accessor);
aDescriptor.addMapping(mapping);
} else {
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName(ATTRIBUTE_NAME);
mapping.setXPath(XPATH);
mapping.setAttributeClassification(aPropertyType.getInstanceClass());
((XMLField) mapping.getField()).setSchemaType(aQName);
mapping.setAttributeAccessor(accessor);
aDescriptor.addMapping(mapping);
}
aDescriptor.setIsWrapper(true);
}
代码示例来源: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/org.eclipse.persistence.sdo
((XMLField)mapping.getField()).setSchemaType(getXsdType());
内容来源于网络,如有侵权,请联系作者删除!