Search in sources :

Example 6 with Property

use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.

the class SDODataObject method convertValueAndSet.

/**
 * INTERNAL:
 */
private void convertValueAndSet(int propertyIndex, Object originalValue) {
    Property property = getInstanceProperty(propertyIndex);
    Object convertedValue = aHelperContext.getDataHelper().convert(property, originalValue);
    set(property, convertedValue);
}
Also used : DataObject(commonj.sdo.DataObject) SequencedObject(org.eclipse.persistence.oxm.sequenced.SequencedObject) Property(commonj.sdo.Property)

Example 7 with Property

use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.

the class SDOSequence method add.

@Override
public void add(int index, String propertyName, Object value) {
    Property property = dataObject.getInstanceProperty(propertyName);
    if (property == null) {
        // Property with given name does not exist - create an open content
        // property
        property = dataObject.defineOpenContentProperty(propertyName, value);
        ((SDOProperty) property).setMany(true);
    }
    add(index, property, value);
}
Also used : Property(commonj.sdo.Property)

Example 8 with Property

use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.

the class SDOSequence method remove.

private void remove(Setting setting) {
    CoreMapping mapping = setting.getMapping();
    if (null != mapping) {
        Property property = null;
        if (null == setting.getName()) {
            XMLRoot xmlRoot = (XMLRoot) setting.getValue();
            if (null != xmlRoot) {
                property = dataObject.getInstanceProperty(xmlRoot.getLocalName());
                valuesToSettings.remove(new Key(property, setting.getValue()));
            }
        } else {
            property = dataObject.getInstanceProperty(mapping.getAttributeName());
            valuesToSettings.remove(new Key(property, setting.getValue()));
        }
        if (property.isMany()) {
            ListWrapper listWrapper = (ListWrapper) dataObject.getList(property);
            listWrapper.remove(setting.getValue(), false, false);
        } else {
            dataObject.unset(property, false, false);
        }
    } else if (setting.getName() != null && setting.getName().equals(TEXT_XPATH)) {
        // Handle "text()"
        dataObject._setModified(true);
    }
    List<Setting> children = setting.getChildren();
    if (null != children) {
        int childrenSize = children.size();
        for (int x = 0; x < childrenSize; x++) {
            remove(children.get(x));
        }
    }
}
Also used : XMLRoot(org.eclipse.persistence.oxm.XMLRoot) Setting(org.eclipse.persistence.oxm.sequenced.Setting) CoreMapping(org.eclipse.persistence.core.mappings.CoreMapping) ListWrapper(org.eclipse.persistence.sdo.helper.ListWrapper) Property(commonj.sdo.Property)

Example 9 with Property

use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.

the class DefaultValueStore method unsetDeclaredProperty.

@Override
public void unsetDeclaredProperty(int propertyIndex) {
    Property prop = ((SDODataObject) dataObject).getInstanceProperty(propertyIndex);
    if (!prop.isMany()) {
        getTypePropertyValues()[propertyIndex] = null;
    }
    getTypePropertiesIsSetStatus()[propertyIndex] = false;
}
Also used : Property(commonj.sdo.Property)

Example 10 with Property

use of commonj.sdo.Property in project eclipselink by eclipse-ee4j.

the class DefaultValueStore method equals.

/**
 *  Indicates if a given ValueStore is equal to this.  The following
 *  attributes are tested for equality:
 *      - data object
 *      - type property values
 *      - open content property values
 *      - property isSet values
 */
@Override
public boolean equals(Object obj) {
    DefaultValueStore dvs;
    try {
        dvs = (DefaultValueStore) obj;
    } catch (ClassCastException cce) {
        return false;
    }
    // Compare data object
    if (dvs.dataObject != this.dataObject) {
        return false;
    }
    // All lists must be the same length
    if (dvs.getTypePropertyValues().length != this.getTypePropertyValues().length || dvs.getTypePropertiesIsSetStatus().length != this.getTypePropertiesIsSetStatus().length) {
        return false;
    }
    for (int i = 0; i < dvs.getTypePropertyValues().length; i++) {
        // isSet values must be equal
        if (dvs.isSetDeclaredProperty(i) != this.isSetDeclaredProperty(i)) {
            return false;
        }
        Object dvsPropVal = dvs.getDeclaredProperty(i);
        Object thisPropVal = this.getDeclaredProperty(i);
        // Both values need to be null or non-null
        if (dvsPropVal == null) {
            if (thisPropVal != null) {
                return false;
            }
        // Here both are null so no need to check anything
        } else {
            if (!(dvsPropVal.equals(thisPropVal))) {
                return false;
            }
        }
    }
    // Compare open content properties
    if (dvs.getOpenContentValues().size() != this.getOpenContentValues().size()) {
        return false;
    }
    Iterator<Property> keyIt = dvs.getOpenContentValues().keySet().iterator();
    while (keyIt.hasNext()) {
        Property key = keyIt.next();
        Object dvsOCVal = dvs.getOpenContentProperty(key);
        Object thisOCVal = this.getOpenContentProperty(key);
        // Both values need to be null or non-null
        if (dvsOCVal == null) {
            if (thisOCVal != null) {
                return false;
            }
        // Here both are null so no need to check anything
        } else {
            if (!(dvsOCVal.equals(thisOCVal))) {
                return false;
            }
        }
    }
    return true;
}
Also used : DataObject(commonj.sdo.DataObject) Property(commonj.sdo.Property)

Aggregations

Property (commonj.sdo.Property)354 DataObject (commonj.sdo.DataObject)204 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)194 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)124 List (java.util.List)99 Type (commonj.sdo.Type)87 SDOSequence (org.eclipse.persistence.sdo.SDOSequence)76 ArrayList (java.util.ArrayList)73 ChangeSummary (commonj.sdo.ChangeSummary)56 SDOType (org.eclipse.persistence.sdo.SDOType)54 ListWrapper (org.eclipse.persistence.sdo.helper.ListWrapper)47 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)37 SDOException (org.eclipse.persistence.exceptions.SDOException)35 Iterator (java.util.Iterator)24 QName (javax.xml.namespace.QName)12 InputStream (java.io.InputStream)11 SDOSetting (org.eclipse.persistence.sdo.SDOSetting)11 Map (java.util.Map)5 XMLDocument (commonj.sdo.helper.XMLDocument)4 SequencedObject (org.eclipse.persistence.oxm.sequenced.SequencedObject)4