diff options
Diffstat (limited to 'branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java')
8 files changed, 0 insertions, 523 deletions
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java deleted file mode 100644 index 771e7221ef..0000000000 --- a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java +++ /dev/null @@ -1,72 +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.axiom;
-
-import java.io.ByteArrayInputStream;
-import java.io.StringWriter;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.tuscany.api.TuscanyRuntimeException;
-import org.apache.tuscany.spi.databinding.DataBinding;
-import org.apache.tuscany.spi.databinding.WrapperHandler;
-import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
-import org.osoa.sca.annotations.Service;
-
-/**
- * DataBinding for AXIOM
- */
-@Service(DataBinding.class)
-public class AxiomDataBinding extends DataBindingExtension {
-
- public static final String NAME = OMElement.class.getName();
-
- public AxiomDataBinding() {
- super(OMElement.class);
- }
-
- /**
- * @see org.apache.tuscany.spi.databinding.extension.DataBindingExtension#getWrapperHandler()
- */
- @Override
- public WrapperHandler getWrapperHandler() {
- return new OMElementWrapperHandler();
- }
-
- public Object copy(Object source) {
- if ( OMElement.class.isAssignableFrom(source.getClass()) ) {
- try {
- OMElement sourceElement = (OMElement)source;
- StringWriter writer = new StringWriter();
- sourceElement.serialize(writer);
-
- StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(writer.toString().getBytes()));
- OMElement copyElement = builder.getDocumentElement();
- return copyElement;
- } catch ( XMLStreamException e ) {
- throw new IllegalArgumentException(e);
- }
- }
- return super.copy(source);
- }
-
-}
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java deleted file mode 100644 index 91b1f4da90..0000000000 --- a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java +++ /dev/null @@ -1,40 +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.axiom; - -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.SimpleType2JavaTransformer; -import org.osoa.sca.annotations.Service; - -/** - * Transformer to convert data from a simple java bject to OMElement - */ -@Service(Transformer.class) -public class OMElement2Object extends SimpleType2JavaTransformer<OMElement> { - - @Override - protected String getText(OMElement source) { - return source.getText(); - } - - public Class getSourceType() { - return OMElement.class; - } -} diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java deleted file mode 100755 index 52be08537d..0000000000 --- a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java +++ /dev/null @@ -1,62 +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.axiom; - -import java.io.StringWriter; - -import javax.xml.stream.XMLStreamException; - -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; - -/** - * Transformer to convert data from an OMElement to XML String - */ -@Service(Transformer.class) -public class OMElement2String extends TransformerExtension<OMElement, String> implements PullTransformer<OMElement, String> { - // private XmlOptions options; - - public String transform(OMElement source, TransformationContext context) { - try { - StringWriter writer = new StringWriter(); - source.serialize(writer); - return writer.toString(); - } catch (XMLStreamException e) { - throw new TransformationException(e); - } - } - - public Class getSourceType() { - return OMElement.class; - } - - public Class getTargetType() { - return String.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java deleted file mode 100755 index 343408a027..0000000000 --- a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java +++ /dev/null @@ -1,50 +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.axiom; - -import javax.xml.stream.XMLStreamReader; - -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.osoa.sca.annotations.Service; - -@Service(Transformer.class) -public class OMElement2XMLStreamReader extends TransformerExtension<OMElement, XMLStreamReader> implements PullTransformer<OMElement, XMLStreamReader> { - // private XmlOptions options; - - public XMLStreamReader transform(OMElement source, TransformationContext context) { - return source.getXMLStreamReader(); - } - - public Class getSourceType() { - return OMElement.class; - } - - public Class getTargetType() { - return XMLStreamReader.class; - } - - public int getWeight() { - return 10; - } - -} diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java deleted file mode 100644 index 0ba2863735..0000000000 --- a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java +++ /dev/null @@ -1,67 +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.axiom; - -import java.util.Iterator; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.WrapperHandler; -import org.apache.tuscany.spi.idl.ElementInfo; - -/** - * OMElement wrapper handler implementation - */ -public class OMElementWrapperHandler implements WrapperHandler<OMElement> { - - private OMFactory factory; - - public OMElementWrapperHandler() { - super(); - this.factory = OMAbstractFactory.getOMFactory(); - } - - public OMElement create(ElementInfo element, TransformationContext context) { - OMElement wrapper = factory.createOMElement(element.getQName(), null); - return wrapper; - } - - public Object getChild(OMElement wrapper, int i, ElementInfo element) { - int index = 0; - for (Iterator e = wrapper.getChildElements(); e.hasNext();) { - OMElement child = (OMElement) e.next(); - if (index != i) { - index++; - continue; - } - if (child.getQName().equals(element.getQName())) { - return child; - } - } - return null; - } - - public void setChild(OMElement wrapper, int i, ElementInfo childElement, Object value) { - wrapper.addChild((OMElement) value); - } - -} diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java deleted file mode 100644 index 5416b5239e..0000000000 --- a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java +++ /dev/null @@ -1,54 +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.axiom; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.Java2SimpleTypeTransformer; -import org.apache.tuscany.spi.idl.ElementInfo; -import org.osoa.sca.annotations.Service; - -/** - * Transformer to convert data from an simple OMElement to Java Object - */ -@Service(Transformer.class) -public class Object2OMElement extends Java2SimpleTypeTransformer<OMElement> { - - private OMFactory factory; - - public Object2OMElement() { - super(); - factory = OMAbstractFactory.getOMFactory(); - } - - protected OMElement createElement(ElementInfo element, String text, TransformationContext context) { - OMElement omElement = factory.createOMElement(element.getQName(), null); - factory.createOMText(omElement, text); - return omElement; - } - - @Override - public Class getTargetType() { - return OMElement.class; - } - -} diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java deleted file mode 100755 index 59ac5423d7..0000000000 --- a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java +++ /dev/null @@ -1,88 +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.axiom; - -import java.io.ByteArrayInputStream; - -import javax.xml.namespace.QName; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMNamespace; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.apache.tuscany.spi.model.DataType; -import org.osoa.sca.annotations.Service; - -@Service(Transformer.class) -public class String2OMElement extends TransformerExtension<String, OMElement> implements - PullTransformer<String, OMElement> { - - @SuppressWarnings("unchecked") - public OMElement transform(String source, TransformationContext context) { - try { - StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(source.getBytes())); - OMElement element = builder.getDocumentElement(); - adjustElementName(context, element); - return element; - } catch (Exception e) { - throw new TransformationException(e); - } - } - - /** - * @param context - * @param element - */ - private void adjustElementName(TransformationContext context, OMElement element) { - if (context != null) { - DataType dataType = context.getTargetDataType(); - Object targetQName = dataType == null ? null : dataType.getLogical(); - if (!(targetQName instanceof QName)) { - return; - } - if (!element.getQName().equals(targetQName)) { - // TODO: Throw expection or switch to the new Element - OMFactory factory = OMAbstractFactory.getOMFactory(); - QName name = (QName)targetQName; - OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix()); - element.setNamespace(namespace); - element.setLocalName(name.getLocalPart()); - } - } - } - - public Class getTargetType() { - return OMElement.class; - } - - public Class getSourceType() { - return String.class; - } - - public int getWeight() { - return 40; - } - -} diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java deleted file mode 100755 index 5b2c89b443..0000000000 --- a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java +++ /dev/null @@ -1,90 +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.axiom; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamReader; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMNamespace; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; -import org.apache.tuscany.spi.databinding.PullTransformer; -import org.apache.tuscany.spi.databinding.TransformationContext; -import org.apache.tuscany.spi.databinding.TransformationException; -import org.apache.tuscany.spi.databinding.Transformer; -import org.apache.tuscany.spi.databinding.extension.TransformerExtension; -import org.apache.tuscany.spi.model.DataType; -import org.osoa.sca.annotations.Service; - -@Service(Transformer.class) -public class XMLStreamReader2OMElement extends TransformerExtension<XMLStreamReader, OMElement> implements - PullTransformer<XMLStreamReader, OMElement> { - - public XMLStreamReader2OMElement() { - super(); - } - - public OMElement transform(XMLStreamReader source, TransformationContext context) { - try { - StAXOMBuilder builder = new StAXOMBuilder(source); - OMElement element = builder.getDocumentElement(); - adjustElementName(context, element); - return element; - } catch (Exception e) { - throw new TransformationException(e); - } - } - - /** - * @param context - * @param element - */ - private void adjustElementName(TransformationContext context, OMElement element) { - if (context != null) { - DataType dataType = context.getTargetDataType(); - Object targetQName = dataType == null ? null : dataType.getLogical(); - if (!(targetQName instanceof QName)) { - return; - } - if (!element.getQName().equals(targetQName)) { - // TODO: Throw expection or switch to the new Element - OMFactory factory = OMAbstractFactory.getOMFactory(); - QName name = (QName)targetQName; - OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix()); - element.setNamespace(namespace); - element.setLocalName(name.getLocalPart()); - } - } - } - - public Class getTargetType() { - return OMElement.class; - } - - public Class getSourceType() { - return XMLStreamReader.class; - } - - public int getWeight() { - return 10; - } - -} |