本文整理了Java中org.eclipse.persistence.oxm.XMLField.getNamespaceResolver()
方法的一些代码示例,展示了XMLField.getNamespaceResolver()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLField.getNamespaceResolver()
方法的具体详情如下:
包路径:org.eclipse.persistence.oxm.XMLField
类名称:XMLField
方法名:getNamespaceResolver
[英]Get the NamespaceResolver associated with this XMLField
[中]获取与此XMLField关联的NamespaceResolver
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
private NamespaceResolver getNamespaceResolverForField(XMLField field){
NamespaceResolver nr = field.getNamespaceResolver();
if(nr == null){
field.setNamespaceResolver(new NamespaceResolver());
}
return field.getNamespaceResolver();
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
/**
* INTERNAL:
* Check if the field is contained in the row.
*/
public boolean containsKey(DatabaseField key) {
XMLField xmlField = convertToXMLField(key);
NodeList nodeList = UnmarshalXPathEngine.getInstance().selectNodes(dom, xmlField, xmlField.getNamespaceResolver());
return nodeList.getLength() > 0;
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
/**
* INTERNAL:
* Check if the field is contained in the row.
*/
public boolean containsKey(DatabaseField key) {
XMLField xmlField = convertToXMLField(key);
NodeList nodeList = UnmarshalXPathEngine.getInstance().selectNodes(dom, xmlField, xmlField.getNamespaceResolver());
return nodeList.getLength() > 0;
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Check if the field is contained in the row.
*/
public boolean containsKey(DatabaseField key) {
XMLField xmlField = convertToXMLField(key);
NodeList nodeList = UnmarshalXPathEngine.getInstance().selectNodes(dom, xmlField, xmlField.getNamespaceResolver());
return nodeList.getLength() > 0;
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public Object buildFieldValue(Object instance, String fieldName, Session session) {
if (null == instance) {
return null;
}
String value = (String) transformationMapping.getAttributeValueFromObject(instance);
if(value == null){
return null;
}
int index = value.lastIndexOf(HASH);
if (index > -1) {
String namespaceURI = value.substring(0, index);
String localName = value.substring(index + 1);
String prefix = null;
NamespaceResolver namespaceResolver = xPath.getNamespaceResolver();
if(null != namespaceResolver) {
prefix = namespaceResolver.resolveNamespaceURI(namespaceURI);
if (prefix == null) {
if (namespaceURI.equals(namespaceResolver.getDefaultNamespaceURI())) {
return localName;
}
}
return prefix + COLON + localName;
}
return localName;
} else {
return value;
}
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo
public Object buildFieldValue(Object instance, String fieldName, Session session) {
if (null == instance) {
return null;
}
String value = (String) transformationMapping.getAttributeValueFromObject(instance);
if(value == null){
return null;
}
int index = value.lastIndexOf(HASH);
if (index > -1) {
String namespaceURI = value.substring(0, index);
String localName = value.substring(index + 1);
String prefix = null;
NamespaceResolver namespaceResolver = xPath.getNamespaceResolver();
if(null != namespaceResolver) {
prefix = namespaceResolver.resolveNamespaceURI(namespaceURI);
if (prefix == null) {
if (namespaceURI.equals(namespaceResolver.getDefaultNamespaceURI())) {
return localName;
}
}
return prefix + COLON + localName;
}
return localName;
} else {
return value;
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
public Object get(DatabaseField key) {
XMLField xmlField = this.convertToXMLField(key);
XPathFragment lastFragment = xmlField.getLastXPathFragment();
NamespaceResolver namespaceResolver = xmlField.getNamespaceResolver();
String namespaceURI = XMLConstants.EMPTY_STRING;
if (null != namespaceResolver) {
namespaceURI = namespaceResolver.resolveNamespacePrefix(lastFragment.getPrefix());
if (null == namespaceURI) {
namespaceURI = XMLConstants.EMPTY_STRING;
}
}
return attributes.getValue(namespaceURI, lastFragment.getLocalName());
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public void initialize(DatabaseMapping mapping, Session session) {
XPathFragment fragment = associatedField.getXPathFragment();
while(fragment.getNextFragment() != null && !(fragment.getNextFragment().nameIsText())) {
fragment = fragment.getNextFragment();
}
if(fragment.hasNamespace() && associatedField.getNamespaceResolver() != null){
String uri = associatedField.getNamespaceResolver().resolveNamespacePrefix(fragment.getPrefix());
fragment.setNamespaceURI(uri);
}
this.rootFragment = fragment;
this.mapping = mapping;
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public void initialize(DatabaseMapping mapping, Session session) {
XPathFragment fragment = associatedField.getXPathFragment();
while(fragment.getNextFragment() != null && !(fragment.getNextFragment().nameIsText())) {
fragment = fragment.getNextFragment();
}
if(fragment.hasNamespace() && associatedField.getNamespaceResolver() != null){
String uri = associatedField.getNamespaceResolver().resolveNamespacePrefix(fragment.getPrefix());
fragment.setNamespaceURI(uri);
}
this.rootFragment = fragment;
this.mapping = mapping;
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
public void initialize(DatabaseMapping mapping, Session session) {
XPathFragment fragment = associatedField.getXPathFragment();
while(fragment.getNextFragment() != null && !(fragment.getNextFragment().nameIsText())) {
fragment = fragment.getNextFragment();
}
if(fragment.hasNamespace() && associatedField.getNamespaceResolver() != null){
String uri = associatedField.getNamespaceResolver().resolveNamespacePrefix(fragment.getPrefix());
fragment.setNamespaceURI(uri);
}
this.rootFragment = fragment;
this.mapping = mapping;
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
public List<XMLEntry> getValuesIndicatingNoEntry(List<DatabaseField> keys, boolean shouldReturnNodes) {
List<XMLField> xmlFields = convertToXMLField(keys);
List<XMLEntry> values = UnmarshalXPathEngine.getInstance().selectNodes(dom, xmlFields, xmlFields.get(0).getNamespaceResolver());
if(shouldReturnNodes) {
return values;
}
for(XMLEntry next:values) {
Node nextNode = (Node)next.getValue();
if(!(nextNode.getNodeType() == Node.ELEMENT_NODE)) {
Object value = getValueFromElement((Element)nextNode.getParentNode(), nextNode, next.getXMLField());
next.setValue(value);
} else {
next.setValue(buildNestedRow((Element)nextNode));
}
}
return values;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
public List<XMLEntry> getValuesIndicatingNoEntry(List<DatabaseField> keys, boolean shouldReturnNodes) {
List<XMLField> xmlFields = convertToXMLField(keys);
List<XMLEntry> values = UnmarshalXPathEngine.getInstance().selectNodes(dom, xmlFields, xmlFields.get(0).getNamespaceResolver());
if(shouldReturnNodes) {
return values;
}
for(XMLEntry next:values) {
Node nextNode = (Node)next.getValue();
if(!(nextNode.getNodeType() == Node.ELEMENT_NODE)) {
Object value = getValueFromElement((Element)nextNode.getParentNode(), nextNode, next.getXMLField());
next.setValue(value);
} else {
next.setValue(buildNestedRow((Element)nextNode));
}
}
return values;
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
public List<XMLEntry> getValuesIndicatingNoEntry(List<DatabaseField> keys, boolean shouldReturnNodes) {
List<XMLField> xmlFields = convertToXMLField(keys);
List<XMLEntry> values = UnmarshalXPathEngine.getInstance().selectNodes(dom, xmlFields, xmlFields.get(0).getNamespaceResolver());
if(shouldReturnNodes) {
return values;
}
for(XMLEntry next:values) {
Node nextNode = (Node)next.getValue();
if(!(nextNode.getNodeType() == Node.ELEMENT_NODE)) {
Object value = getValueFromElement((Element)nextNode.getParentNode(), nextNode, next.getXMLField());
next.setValue(value);
} else {
next.setValue(buildNestedRow((Element)nextNode));
}
}
return values;
}
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
Object result = UnmarshalXPathEngine.getInstance().selectSingleNode(dom, field, field.getNamespaceResolver(), checkForXsiNil);
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
Object result = UnmarshalXPathEngine.getInstance().selectSingleNode(dom, field, field.getNamespaceResolver(), checkForXsiNil);
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
Object result = UnmarshalXPathEngine.getInstance().selectSingleNode(dom, field, field.getNamespaceResolver(), checkForXsiNil);
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
/**
* INTERNAL:
* Add the field-value pair to the document.
*/
public void add(DatabaseField key, Object value) {
if (null == value) {
return;
}
XMLField xmlField = convertToXMLField(key);
XPathFragment lastFragment = xmlField.getLastXPathFragment();
XMLConversionManager xcm = (XMLConversionManager) session.getDatasourcePlatform().getConversionManager();
if (lastFragment.nameIsText()) {
String stringValue = (String)xcm.convertObject(value, String.class);
characters(stringValue);
} else if (lastFragment.isAttribute()) {
String stringValue = (String)xcm.convertObject(value, String.class);
attribute(lastFragment, xmlField.getNamespaceResolver(), stringValue);
} else {
element(lastFragment);
}
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
@Override
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object value, AbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) {
Object fieldValue = xmlCollectionReferenceMapping.buildFieldValue(value, xmlField, session);
if (fieldValue == null) {
if(null != value) {
XMLField f2 = (XMLField) xmlCollectionReferenceMapping.getSourceToTargetKeyFieldAssociations().get(xmlField);
fieldValue = marshalRecord.getMarshaller().getXMLContext().getValueByXPath(value, f2.getXPath(), f2.getNamespaceResolver(), Object.class);
}
if(null == fieldValue) {
return false;
}
}
QName schemaType = getSchemaType(xmlField, fieldValue, session);
String stringValue = getValueToWrite(schemaType, fieldValue, (XMLConversionManager) session.getDatasourcePlatform().getConversionManager(), namespaceResolver);
if (stringValue != null) {
if (xPathFragment.isAttribute()) {
marshalRecord.attribute(xPathFragment, namespaceResolver, stringValue);
marshalRecord.closeStartElement();
} else {
marshalRecord.closeStartElement();
marshalRecord.characters(stringValue);
}
return true;
}
return false;
}
代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object targetObject, AbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) {
Object fieldValue = xmlObjectReferenceMapping.buildFieldValue(targetObject, xmlField, session);
if (fieldValue == null) {
if(null != targetObject) {
XMLField fkField = (XMLField) xmlObjectReferenceMapping.getSourceToTargetKeyFieldAssociations().get(xmlField);
fieldValue = marshalRecord.getMarshaller().getXMLContext().getValueByXPath(targetObject, fkField.getXPath(), fkField.getNamespaceResolver(), Object.class);
}
if(null == fieldValue) {
return false;
}
}
QName schemaType = getSchemaType(xmlField, 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);
marshalRecord.characters(stringValue);
}
return true;
}
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!