package org.example.schema; import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.*; import javax.xml.namespace.QName; @XmlRegistry public class ObjectFactory { private final static QName _RootFoo_QNAME = new QName("http://www.example.org/schema", "foo"); private final static QName _RootBar_QNAME = new QName("http://www.example.org/schema", "bar"); public Root createRoot() { return new Root(); } @XmlElementDecl(namespace = "http://www.example.org/schema", name = "foo", scope = Root.class) public JAXBElement<String> createRootFoo(String value) { return new JAXBElement<String>(_RootFoo_QNAME, String.class, Root.class, value); } @XmlElementDecl(namespace = "http://www.example.org/schema", name = "bar", scope = Root.class) public JAXBElement<String> createRootBar(String value) { return new JAXBElement<String>(_RootBar_QNAME, String.class, Root.class, value); } }
public Map<String, EntityType> getEntitiesTypesMap(boolean isAttribute) { Map<String, EntityType> entitiesTypes = isAttribute ? attributeTypeMap : elementTypeMap; if (entitiesTypes.isEmpty()) { final Map<XPathFragment, XPathNode> nodeMap = isAttribute ? xPathNode.getAttributeChildrenMap() : xPathNode.getNonAttributeChildrenMap(); if (nodeMap != null) { for(Map.Entry<XPathFragment, XPathNode> entry : nodeMap.entrySet()) { entitiesTypes.put(entry.getKey().getLocalName(), new EntityType(entry.getKey().getXMLField().getType())); } } } return entitiesTypes; }
@Override public Collection<QName> getExpectedElements() { final List<QName> elements = new LinkedList<QName>(); final XPathNodeWrapper currentNodeWrapper = getCurrentNodeWrapper(); final Map<XPathFragment, XPathNode> nonAttributeChildrenMap = currentNodeWrapper == null ? null : currentNodeWrapper.xPathNode.getNonAttributeChildrenMap(); if (nonAttributeChildrenMap != null) { for(Map.Entry<XPathFragment, XPathNode> entry : nonAttributeChildrenMap.entrySet()) { elements.add(new QName(entry.getKey().getNamespaceURI(), entry.getKey().getLocalName())); } } return elements; }
actualNodeWrapper == null ? null : actualNodeWrapper.xPathNode.getNonAttributeChildrenMap(); if (name.getLocalPart().equalsIgnoreCase(child.getKey().getLocalName())) { childNode = child.getValue(); break; final MappingNodeValue nodeValue = (MappingNodeValue) childNode.getNodeValue(); ClassDescriptor descriptor = nodeValue.getMapping().getReferenceDescriptor(); descriptor = nodeValue.getMapping().getDescriptor(); objectBuilder.getRootXPathNode(), nodeWrapper, nodeValue, descriptor, name);
@Override public Collection<QName> getExpectedAttributes() { final List<QName> attributes = new LinkedList<QName>(); final XPathNodeWrapper currentNodeWrapper = getCurrentNodeWrapper(); final Map<XPathFragment, XPathNode> attributeChildrenMap = currentNodeWrapper == null ? null :currentNodeWrapper.xPathNode.getAttributeChildrenMap(); if (attributeChildrenMap != null) { for(Map.Entry<XPathFragment, XPathNode> entry : attributeChildrenMap.entrySet()) { attributes.add(new QName(entry.getKey().getNamespaceURI(), entry.getKey().getLocalName())); } } return attributes; }
private NodeValue getNodeValueForMapping(Mapping xmlMapping) { if(xmlMapping instanceof BinaryDataMapping){ return new XMLBinaryDataMappingNodeValue((BinaryDataMapping)xmlMapping); } else if(xmlMapping instanceof DirectMapping) { return new XMLDirectMappingNodeValue((DirectMapping)xmlMapping); } else if(xmlMapping instanceof ObjectReferenceMapping) { return new XMLObjectReferenceMappingNodeValue((ObjectReferenceMapping)xmlMapping, xmlField); } else { return new XMLCompositeObjectMappingNodeValue((CompositeObjectMapping)xmlMapping); } } public void setNullCapableNodeValue(XMLChoiceObjectMappingNodeValue nodeValue) {
public boolean marshal(NodeValue nodeValue, XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, CoreAbstractSession session, NamespaceResolver namespaceResolver, XPathFragment rootFragment) { if(nodeValue.isContainerValue()) { ((ContainerValue)nodeValue).marshalSingleValue(xPathFragment, marshalRecord, object, value, session, namespaceResolver, this); return true; } else { return nodeValue.marshal(xPathFragment, marshalRecord, object, session, namespaceResolver, this, rootFragment); } }
public boolean isOwningNode(XPathFragment xPathFragment) { if(isMixedNodeValue) { if(xPathFragment.nameIsText()) { return true; } else { return false; } } return choiceElementNodeValue.isOwningNode(xPathFragment); }
private XPathFragment getOwningFragment(NodeValue nodeValue, XPathFragment frag){ while(frag != null) { if(nodeValue.isOwningNode(frag)) { return frag; } frag = frag.getNextFragment(); } return null; }
protected XMLUnmarshaller(CONTEXT xmlContext, Map<String, Boolean> parserFeatures) { super(xmlContext); stringBuffer = new StrBuffer(); initialize(parserFeatures); setErrorHandler(DEFAULT_ERROR_HANDLER); }
private Type getContainerType(final boolean isIndividual) { final XPathNodeWrapper currentNodeWrapper = getCurrentNodeWrapper(); if (currentNodeWrapper.nodeValue != null && currentNodeWrapper.nodeValue.isContainerValue()) { final DatabaseMapping mapping = currentNodeWrapper.nodeValue.getMapping(); Converter valueConverter = null; if (mapping != null) { if (isIndividual) { if (mapping instanceof AbstractCompositeDirectCollectionMapping) { valueConverter = ((AbstractCompositeDirectCollectionMapping) mapping).getValueConverter(); } else if (mapping instanceof XMLCompositeCollectionMapping) { valueConverter = ((XMLCompositeCollectionMapping) mapping).getConverter(); } } if (valueConverter instanceof TypeConversionConverter) { return ((TypeConversionConverter) valueConverter).getObjectClass(); } else if (mapping.getContainerPolicy() != null) { return mapping.getContainerPolicy().getContainerClass(); } } } return null; }
public void startDocument() throws SAXException { if (unmarshaller.getIDResolver() != null && parentRecord == null) { unmarshaller.getIDResolver().startDocument(unmarshaller.getErrorHandler()); } }
@Override public void setXPathNode(XPathNode xPathNode) { super.setXPathNode(xPathNode); if(this.anyNodeValue != null) { this.anyNodeValue.setXPathNode(xPathNode); } }
/** * INTERNAL: * If the UnmarshalRecord has a ReferenceResolver, tell it to resolve its * references. * @since EclipseLink 2.5.0 */ public void resolveReferences(CoreAbstractSession abstractSession, IDResolver idResolver) { if(null != referenceResolver) { referenceResolver.resolveReferences(abstractSession, idResolver, unmarshaller.getErrorHandler()); } }
final TreeObjectBuilder objectBuilder = (TreeObjectBuilder) descriptor.getObjectBuilder(); return new XPathNodeWrapper(objectBuilder.getRootXPathNode(), null, null, descriptor, new QName(expectedType.getSimpleName()));
@Override public boolean isArrayCollection() { final XPathNodeWrapper currentNodeWrapper = getCurrentNodeWrapper(); if (currentNodeWrapper != null && lastAccessedNode != null && lastAccessedNode.name == currentNodeWrapper.name) { final MappingNodeValue nodeValue = currentNodeWrapper.getNodeValue(); return nodeValue != null && nodeValue.isContainerValue(); } else { return false; } }
private NodeValue getNodeValueForMapping(Mapping xmlMapping) { if(xmlMapping instanceof BinaryDataMapping){ return new XMLBinaryDataMappingNodeValue((BinaryDataMapping)xmlMapping); } else if(xmlMapping instanceof DirectMapping) { return new XMLDirectMappingNodeValue((DirectMapping)xmlMapping); } else if(xmlMapping instanceof ObjectReferenceMapping) { return new XMLObjectReferenceMappingNodeValue((ObjectReferenceMapping)xmlMapping, xmlField); } else { return new XMLCompositeObjectMappingNodeValue((CompositeObjectMapping)xmlMapping); } } public void setNullCapableNodeValue(XMLChoiceObjectMappingNodeValue nodeValue) {
public boolean marshal(NodeValue nodeValue, XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, AbstractSession session, NamespaceResolver namespaceResolver) { if(nodeValue.isContainerValue()) { ((ContainerValue)nodeValue).marshalSingleValue(xPathFragment, marshalRecord, object, value, session, namespaceResolver, this); return true; } else { return nodeValue.marshal(xPathFragment, marshalRecord, object, session, namespaceResolver, this); } }
public boolean isOwningNode(XPathFragment xPathFragment) { if(isMixedNodeValue) { if(xPathFragment.nameIsText()) { return true; } else { return false; } } return choiceElementNodeValue.isOwningNode(xPathFragment); }
public boolean marshal(NodeValue nodeValue, XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, CoreAbstractSession session, NamespaceResolver namespaceResolver) { if(nodeValue.isContainerValue()) { ((ContainerValue)nodeValue).marshalSingleValue(xPathFragment, marshalRecord, object, value, session, namespaceResolver, this); return true; } else { return nodeValue.marshal(xPathFragment, marshalRecord, object, session, namespaceResolver, this); } }