diff options
Diffstat (limited to 'branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java')
-rw-r--r-- | branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java b/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java deleted file mode 100644 index d34b389458..0000000000 --- a/branches/sca-java-M2/sca/services/databinding/databinding-sdo/src/main/java/org/apache/tuscany/databinding/sdo/SDOWrapperHandler.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.databinding.sdo; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sdo.util.SDOUtil; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.WrapperHandler; -import org.apache.tuscany.spi.idl.ElementInfo; -import org.apache.tuscany.spi.model.DataType; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.DataFactory; -import commonj.sdo.helper.TypeHelper; -import commonj.sdo.helper.XMLDocument; -import commonj.sdo.helper.XMLHelper; - -/** - * SDO Wrapper Handler - */ -public class SDOWrapperHandler implements WrapperHandler<Object> { - - /** - * @see org.apache.tuscany.spi.databinding.WrapperHandler#create(ElementInfo, - * TransformationContext) - */ - public Object create(ElementInfo element, TransformationContext context) { - TypeHelper typeHelper = TypeHelper.INSTANCE; - if (context != null) { - DataType targetType = context.getTargetDataType(); - if (targetType != null) { - typeHelper = (TypeHelper) targetType.getMetadata(TypeHelper.class.getName()); - if (typeHelper == null) { - typeHelper = TypeHelper.INSTANCE; - } - } - } - QName typeName = element.getType().getQName(); - DataFactory dataFactory = SDOUtil.createDataFactory(typeHelper); - DataObject root = dataFactory.create(typeName.getNamespaceURI(), typeName.getLocalPart()); - XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper); - return xmlHelper.createDocument(root, element.getQName().getNamespaceURI(), element.getQName().getLocalPart()); - } - - /** - * @see org.apache.tuscany.spi.databinding.WrapperHandler#getChild(java.lang.Object, int, - * ElementInfo) - */ - public Object getChild(Object wrapper, int i, ElementInfo element) { - DataObject wrapperDO = - (wrapper instanceof XMLDocument) ? ((XMLDocument) wrapper).getRootObject() : (DataObject) wrapper; - return wrapperDO.get(element.getQName().getLocalPart()); - } - - /** - * @see org.apache.tuscany.spi.databinding.WrapperHandler#setChild(java.lang.Object, int, - * ElementInfo, java.lang.Object) - */ - public void setChild(Object wrapper, int i, ElementInfo childElement, Object value) { - DataObject wrapperDO = - (wrapper instanceof XMLDocument) ? ((XMLDocument) wrapper).getRootObject() : (DataObject) wrapper; - wrapperDO.set(childElement.getQName().getLocalPart(), value); - } - -} |