Package org.eclipse.persistence.internal.queries

Examples of org.eclipse.persistence.internal.queries.DirectMapContainerPolicy


public class XMLAnyAttributeMapping extends DatabaseMapping implements XMLMapping {
    private XMLField field;
    private DirectMapContainerPolicy containerPolicy;

    public XMLAnyAttributeMapping() {
        this.containerPolicy = new DirectMapContainerPolicy(HashMap.class);
    }
View Full Code Here


    }

    private Object buildObjectValuesFromDOMRecord(DOMRecord record, AbstractSession session, ObjectBuildingQuery query) {
        //This DOMRecord represents the root node of the AnyType instance
        //Grab ALL children to populate the collection.
        DirectMapContainerPolicy cp = (DirectMapContainerPolicy) getContainerPolicy();
        Object container = cp.containerInstance();
        org.w3c.dom.Element root = (Element) record.getDOM();
        NamedNodeMap attributes = root.getAttributes();
        Attr next;
        String localName;
        int numberOfAtts = attributes.getLength();
        for (int i = 0; i < numberOfAtts; i++) {
            next = (Attr) attributes.item(i);
            localName = next.getLocalName();
            if (null == localName) {
                localName = next.getName();
            }
            QName key = new QName(next.getNamespaceURI(), localName);
            String value = next.getValue();
            cp.addInto(key, value, container, session);
        }
        return container;
    }
View Full Code Here

        }
        this.containerPolicy.setContainerClass(concreteMapClass);
    }

    public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) {
        DirectMapContainerPolicy cp = (DirectMapContainerPolicy) this.getContainerPolicy();
        if ((attributeValue == null) || (cp.sizeFor(attributeValue) == 0)) {
            return;
        }
        DOMRecord record = (DOMRecord) row;
        if (record.getDOM().getNodeType() != Node.ELEMENT_NODE) {
            return;
        }
        Element root = (Element) record.getDOM();

        if (field != null) {
            root = (Element) XPathEngine.getInstance().create((XMLField) getField(), root, session);
        }
        List extraNamespaces = new ArrayList();
        NamespaceResolver nr = row.getNamespaceResolver();
        for (Object iter = cp.iteratorFor(attributeValue); cp.hasNext(iter);) {
            Object key = cp.next(iter, session);
            if ((key != null) && key instanceof QName) {
                Object value = cp.valueFromKey(key, attributeValue);
                QName attributeName = (QName) key;
                String namespaceURI = attributeName.getNamespaceURI();
                String qualifiedName = attributeName.getLocalPart();

                if (nr != null) {
View Full Code Here

     * Indicates the name of the Map class to be used. 
     * 
     * @param concreteMapClassName
     */
    public void useMapClassName(String concreteMapClassName) {
        this.setContainerPolicy(new DirectMapContainerPolicy());
        this.getContainerPolicy().setContainerClassName(concreteMapClassName);
    }
View Full Code Here

        }
        Object collection = xmlAnyAttributeMapping.getAttributeValueFromObject(object);
        if (collection == null) {
            return false;
        }
        DirectMapContainerPolicy cp = getContainerPolicy();
        Object iter = cp.iteratorFor(collection);
        if (!cp.hasNext(iter)) {
            return false;
        }
        XPathFragment groupingElements = marshalRecord.openStartGroupingElements(namespaceResolver);
        List extraNamespaces = new ArrayList();
        NamespaceResolver nr = marshalRecord.getNamespaceResolver();
        while (cp.hasNext(iter)) {
            Object key = cp.next(iter, session);
            if (key instanceof QName) {
                QName name = (QName) key;
                String value = cp.valueFromKey(key, collection).toString();

                String qualifiedName = name.getLocalPart();
                if (nr != null) {
                    String prefix = nr.resolveNamespaceURI(name.getNamespaceURI());
                    if ((prefix != null) && !prefix.equals("")) {
View Full Code Here

        return true;
    }

    public void attribute(UnmarshalRecord unmarshalRecord, String namespaceURI, String localName, String value) {
        try {
            DirectMapContainerPolicy cp = (DirectMapContainerPolicy) xmlAnyAttributeMapping.getContainerPolicy();
            Object containerInstance = unmarshalRecord.getContainerInstance(this);
            QName key = new QName(namespaceURI, localName);
            cp.addInto(key, value, containerInstance, unmarshalRecord.getSession());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
View Full Code Here

public class XMLAnyAttributeMapping extends DatabaseMapping implements XMLMapping {
    private XMLField field;
    private DirectMapContainerPolicy containerPolicy;

    public XMLAnyAttributeMapping() {
        this.containerPolicy = new DirectMapContainerPolicy(HashMap.class);
    }
View Full Code Here

    }

    private Object buildObjectValuesFromDOMRecord(DOMRecord record, AbstractSession session, ObjectBuildingQuery query) {
        //This DOMRecord represents the root node of the AnyType instance
        //Grab ALL children to populate the collection.
        DirectMapContainerPolicy cp = (DirectMapContainerPolicy) getContainerPolicy();
        Object container = cp.containerInstance();
        org.w3c.dom.Element root = (Element) record.getDOM();
        NamedNodeMap attributes = root.getAttributes();
        Attr next;
        String localName;
        int numberOfAtts = attributes.getLength();
        for (int i = 0; i < numberOfAtts; i++) {
            next = (Attr) attributes.item(i);
            localName = next.getLocalName();
            if (null == localName) {
                localName = next.getName();
            }
            QName key = new QName(next.getNamespaceURI(), localName);
            String value = next.getValue();
            cp.addInto(key, value, container, session);
        }
        return container;
    }
View Full Code Here

        }
        this.containerPolicy.setContainerClass(concreteMapClass);
    }

    public void writeSingleValue(Object attributeValue, Object parent, XMLRecord row, AbstractSession session) {
        DirectMapContainerPolicy cp = (DirectMapContainerPolicy) this.getContainerPolicy();
        if ((attributeValue == null) || (cp.sizeFor(attributeValue) == 0)) {
            return;
        }
        DOMRecord record = (DOMRecord) row;
        if (record.getDOM().getNodeType() != Node.ELEMENT_NODE) {
            return;
        }
        Element root = (Element) record.getDOM();

        if (field != null) {
            root = (Element) XPathEngine.getInstance().create((XMLField) getField(), root, session);
        }
        List extraNamespaces = new ArrayList();
        NamespaceResolver nr = row.getNamespaceResolver();
        for (Object iter = cp.iteratorFor(attributeValue); cp.hasNext(iter);) {
            Object key = cp.next(iter, session);
            if ((key != null) && key instanceof QName) {
                Object value = cp.valueFromKey(key, attributeValue);
                QName attributeName = (QName) key;
                String namespaceURI = attributeName.getNamespaceURI();
                String qualifiedName = attributeName.getLocalPart();

                if (nr != null) {
View Full Code Here

     * Indicates the name of the Map class to be used. 
     * 
     * @param concreteMapClassName
     */
    public void useMapClassName(String concreteMapClassName) {
        this.setContainerPolicy(new DirectMapContainerPolicy());
        this.getContainerPolicy().setContainerClassName(concreteMapClassName);
    }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.internal.queries.DirectMapContainerPolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.