org.eclipse.persistence.sdo.helper.SDOFragmentMappingAttributeAccessor Maven / Gradle / Ivy
Show all versions of eclipselink Show documentation
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.sdo.helper;
import org.eclipse.persistence.exceptions.DescriptorException;
import org.eclipse.persistence.mappings.AttributeAccessor;
import commonj.sdo.Property;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import org.w3c.dom.Node;
import org.eclipse.persistence.oxm.XMLUnmarshaller;
import org.eclipse.persistence.oxm.XMLRoot;
import org.eclipse.persistence.sdo.helper.SDOXMLHelper;
import commonj.sdo.helper.HelperContext;
import org.w3c.dom.Document;
import org.eclipse.persistence.platform.xml.XMLPlatformFactory;
import org.eclipse.persistence.oxm.XMLMarshaller;
import org.eclipse.persistence.sdo.SDOProperty;
import org.eclipse.persistence.sdo.SDODataObject;
import org.eclipse.persistence.platform.xml.XMLPlatform;
/**
* Purpose: A wrapper class for handling cases when the domain object attributes are
* to be accessed thru the accessor methods that are called "get" and "set". This is to be used
* when marsalling/unmarshalling SDODataObjects. The propertyName is the name of the property on
* the DataObject and that must be set on this accessor.
*/
public class SDOFragmentMappingAttributeAccessor extends AttributeAccessor {
protected SDOProperty property;
protected HelperContext helperContext;
public SDOFragmentMappingAttributeAccessor(SDOProperty property, HelperContext helper) {
this.property = property;
this.helperContext = helper;
}
/**
* Gets the value of an instance variable in the object.
*/
@Override
public Object getAttributeValueFromObject(Object anObject) throws DescriptorException {
Object attributeValue = ((SDODataObject)anObject).get(property);
if (attributeValue != null) {
if (property.isMany()) {
// handle collection case
ArrayList