Package org.eclipse.persistence.oxm.sequenced

Examples of org.eclipse.persistence.oxm.sequenced.Setting


            if (value instanceof List) {
                // iterate list
                for (Iterator i = ((List) value).iterator(); i.hasNext();) {
                    // add a setting to the end of the sequence
                    Object aValue = i.next();
                    Setting setting = convertToSetting(property, aValue);
                    valuesToSettings.put(new Key(property, aValue), setting);
                    settings.add(index++, setting);
                    // no need to check updateContainment flag -
                    // ListWrapper.add() will not pass an entire List here
                    listWrapper.add(aValue, false);
                }
            } else {
                // set individual list item
                // add a setting to the end of the sequence
                Setting setting = convertToSetting(property, value);
                valuesToSettings.put(new Key(property, value), setting);
                settings.add(index, setting);
                int listIdx = getIndexInList(property, value);
                if (listIdx != -1) {
                    listWrapper.add(listIdx, value, false);
                } else {
                    listWrapper.add(value, false);
                }
            }
        } else {
            dataObject.setPropertyInternal((SDOProperty) property, value, false);
            // Update the settings
            Setting setting = convertToSetting(property, value);
            valuesToSettings.put(new Key(property, value), setting);
            settings.add(index, setting);
        }
    }
View Full Code Here


    }

    public void addText(int index, String text) {
        // Trigger store of original sequence
        dataObject._setModified(true);
        Setting textSetting = new Setting(null, TEXT_XPATH);
        textSetting.setObject(dataObject);
        textSetting.setValue(text, false);
        settings.add(index, textSetting);
    }
View Full Code Here

    }

    public void addText(String text) {
        // Trigger store of original sequence
        dataObject._setModified(true);
        Setting textSetting = new Setting(null, TEXT_XPATH);
        textSetting.setObject(dataObject);
        textSetting.setValue(text, false);
        settings.add(textSetting);
    }
View Full Code Here

            throw SDOException.invalidIndex(null, toIndex);
        }
        // trigger deep copy of sequence (if applicable)
        dataObject._setModified(true);

        Setting setting = settings.remove(fromIndex);
        settings.add(toIndex, setting);

        Property prop = getProperty(setting);
        if (prop != null && prop.isMany()) {
            ListWrapper lw = (ListWrapper) dataObject.getList(prop);
View Full Code Here

            lw.add(newIndexInLw, value, false);
        }
    }

    public void remove(int index) {
        Setting setting = settings.get(index);
        remove(setting);
        settings.remove(setting);
    }
View Full Code Here

    }

    private Setting convertToSetting(Property property, Object value) {
        SDOProperty sdoProperty = (SDOProperty) property;
        DatabaseMapping mapping = sdoProperty.getXmlMapping();
        Setting setting = new Setting();
        SDOType sdoType = (SDOType) dataObject.getType();
        XMLDescriptor xmlDescriptor = sdoType.getXmlDescriptor();
        if (null == mapping) {
            setting.setObject(dataObject);

            mapping = xmlDescriptor.getMappingForAttributeName("openContentProperties");
            setting.setMapping(mapping);
            XMLRoot xmlRoot = new XMLRoot();
            if (value instanceof XMLRoot) {
                xmlRoot.setLocalName(((XMLRoot) value).getLocalName());
                xmlRoot.setNamespaceURI(((XMLRoot) value).getNamespaceURI());
                xmlRoot.setObject(((XMLRoot) value).getObject());
            } else {
                xmlRoot.setLocalName(sdoProperty.getName());
                xmlRoot.setNamespaceURI(sdoProperty.getUri());
                xmlRoot.setObject(value);
                // do not set schema type for global properties
                SDOTypeHelper hlpr = (SDOTypeHelper) ((SDOType) dataObject.getType()).getHelperContext().getTypeHelper();
                if (hlpr.getOpenContentProperty(sdoProperty.getUri(), sdoProperty.getName()) == null) {
                    QName schemaTypeQName = hlpr.getXSDTypeFromSDOType(property.getType());
                    if (schemaTypeQName != null && schemaTypeQName != XMLConstants.STRING_QNAME) {
                        xmlRoot.setSchemaType(schemaTypeQName);
                    }
                }
            }
            setting.setValue(xmlRoot, false);
        } else {
            setting = convertToSetting(mapping, value);
        }
        return setting;
    }
View Full Code Here

    }

    private Setting convertToSetting(DatabaseMapping mapping, Object value) {
        XMLDescriptor xmlDescriptor = (XMLDescriptor) mapping.getDescriptor();
        NamespaceResolver nsResolver = xmlDescriptor.getNamespaceResolver();
        Setting rootSetting = new Setting();
        XMLField xmlField = (XMLField) mapping.getField();
        if (xmlField == null) {
            if (mapping instanceof XMLObjectReferenceMapping) {
                xmlField = (XMLField) ((XMLObjectReferenceMapping) mapping).getFields().get(0);
            } else if (mapping instanceof XMLCollectionReferenceMapping) {
                xmlField = (XMLField) ((XMLCollectionReferenceMapping) mapping).getFields().get(0);
            }
        }
        Setting setting = rootSetting;
        if (xmlField != null) {
            XPathFragment xPathFragment = xmlField.getXPathFragment();
            rootSetting = convertToSetting(xPathFragment, nsResolver);
            setting = rootSetting;

            while (xPathFragment.getNextFragment() != null) {
                xPathFragment = xPathFragment.getNextFragment();
                Setting childSetting = convertToSetting(xPathFragment, nsResolver);
                setting.addChild(childSetting);
                setting = childSetting;
            }
        }
        setting.setObject(dataObject);
View Full Code Here

        setting.setValue(value, false);
        return rootSetting;
    }

    private Setting convertToSetting(XPathFragment xPathFragment, NamespaceResolver nsResolver) {
        Setting setting = new Setting();
        String name = xPathFragment.getLocalName();
        if (null == name) {
            name = xPathFragment.getShortName();
        }
        setting.setName(name);
        if (xPathFragment.hasNamespace()) {
            setting.setNamespaceURI(nsResolver.resolveNamespacePrefix(xPathFragment.getPrefix()));
        }
        return setting;
    }
View Full Code Here

    }

    public SDOSequence copy() {
        SDOSequence copy = new SDOSequence(dataObject);
        for (int index = 0, size = settings.size(); index < size; index++) {
            Setting settingCopy = settings.get(index).copy();
            copy.getSettings().add(settingCopy);
            copy.getValuesToSettings().put(new Key(getProperty(settingCopy), getValue(settingCopy)), settingCopy);
        }
        return copy;
    }
View Full Code Here

     * @param value
     * @return true if the a Setting was successfully added to the list,
     *         otherwise false
     */
    public boolean addSettingWithoutModifyingDataObject(int index, Property property, Object value) {
        Setting setting = convertToSetting(property, value);
        valuesToSettings.put(new Key(property, value), setting);
        if (index >= 0) {
            settings.add(index, setting);
        } else {
            settings.add(setting);
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.oxm.sequenced.Setting

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.