From ab6904bc2f622129bc548391745b08eb0c219e57 Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 21 Jul 2009 07:03:47 +0000 Subject: Fix svn:eol-style and svn:keywords properties for java/xml files git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@796166 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/databinding/axiom/AxiomDataBinding.java | 124 +++++++------- .../sca/databinding/axiom/Exception2OMElement.java | 190 ++++++++++----------- .../axiom/Externalizable2OMElement.java | 154 ++++++++--------- .../sca/databinding/axiom/OMElement2Exception.java | 158 ++++++++--------- .../axiom/OMElement2Externalizable.java | 138 +++++++-------- 5 files changed, 382 insertions(+), 382 deletions(-) (limited to 'java/sca/modules/databinding-axiom/src/main') diff --git a/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java b/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java index 142229f4f6..a2e6abbf19 100644 --- a/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java +++ b/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java @@ -1,62 +1,62 @@ -/* - * 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.sca.databinding.axiom; - -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.databinding.WrapperHandler; -import org.apache.tuscany.sca.databinding.impl.BaseDataBinding; -import org.apache.tuscany.sca.interfacedef.DataType; -import org.apache.tuscany.sca.interfacedef.Operation; - -/** - * DataBinding for AXIOM - * - * @version $Rev$ $Date$ - */ -public class AxiomDataBinding extends BaseDataBinding { - - public static final String NAME = OMElement.class.getName(); - - public AxiomDataBinding() { - super(NAME, OMElement.class); - } - - /** - * @see org.apache.tuscany.sca.databinding.impl.BaseDataBinding#getWrapperHandler() - */ - @Override - public WrapperHandler getWrapperHandler() { - return new OMElementWrapperHandler(); - } - - @Override - public Object copy(Object source, DataType dataType, Operation operation) { - if ( OMElement.class.isAssignableFrom(source.getClass()) ) { - try { - OMElement sourceElement = (OMElement)source; - return sourceElement.cloneOMElement(); - } catch ( Exception e ) { - throw new IllegalArgumentException(e); - } - } - return super.copy(source, dataType, operation); - } - -} +/* + * 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.sca.databinding.axiom; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.databinding.WrapperHandler; +import org.apache.tuscany.sca.databinding.impl.BaseDataBinding; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.Operation; + +/** + * DataBinding for AXIOM + * + * @version $Rev$ $Date$ + */ +public class AxiomDataBinding extends BaseDataBinding { + + public static final String NAME = OMElement.class.getName(); + + public AxiomDataBinding() { + super(NAME, OMElement.class); + } + + /** + * @see org.apache.tuscany.sca.databinding.impl.BaseDataBinding#getWrapperHandler() + */ + @Override + public WrapperHandler getWrapperHandler() { + return new OMElementWrapperHandler(); + } + + @Override + public Object copy(Object source, DataType dataType, Operation operation) { + if ( OMElement.class.isAssignableFrom(source.getClass()) ) { + try { + OMElement sourceElement = (OMElement)source; + return sourceElement.cloneOMElement(); + } catch ( Exception e ) { + throw new IllegalArgumentException(e); + } + } + return super.copy(source, dataType, operation); + } + +} diff --git a/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java b/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java index 429a6dbe5d..f44297edb7 100644 --- a/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java +++ b/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java @@ -1,95 +1,95 @@ -/* - * 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.sca.databinding.axiom; - -import javax.xml.namespace.QName; - -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMAttribute; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMNamespace; -import org.apache.tuscany.sca.databinding.TransformationContext; -import org.apache.tuscany.sca.databinding.javabeans.Java2XMLMapperException; -import org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLTransformer; - -/** - * - * @version $Rev$ $Date$ - */ -public class Exception2OMElement extends JavaBean2XMLTransformer { - - public static final String GETCAUSE = "getCause"; - public static final String GETLOCALIZEDMESSAGE = "getLocalizedMessage"; - public static final String GETSTACKTRACE = "getStackTrace"; - public static final String GETCLASS = "getClass"; - - private OMFactory factory; - - public Exception2OMElement() { - super(); - factory = OMAbstractFactory.getOMFactory(); - } - - @Override - public OMElement transform(Object source, TransformationContext context) { - OMElement element = super.transform(source, context); - AxiomHelper.adjustElementName(context, element); - return element; - } - - @Override - protected boolean isMappedGetter(String methodName) { - if (GETCAUSE.equals(methodName) - || GETLOCALIZEDMESSAGE.equals(methodName) - || GETSTACKTRACE.equals(methodName) - || GETCLASS.equals(methodName)) { - return false; - } else { - return true; - } - } - - @Override - public void appendChild(OMElement parentElement, OMElement childElement) throws Java2XMLMapperException { - parentElement.addChild(childElement); - } - - @Override - public OMElement createElement(QName qName) throws Java2XMLMapperException { - return factory.createOMElement(qName); - } - - @Override - public void appendText(OMElement parentElement, String textData) throws Java2XMLMapperException { - if (textData == null) { - OMNamespace xsi = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi"); - OMAttribute nil = factory.createOMAttribute("nil", xsi, "true"); - parentElement.addAttribute(nil); - } else { - factory.createOMText(parentElement, textData); - } - } - - @Override - public Class getTargetType() { - return OMElement.class; - } - -} +/* + * 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.sca.databinding.axiom; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMAttribute; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.tuscany.sca.databinding.TransformationContext; +import org.apache.tuscany.sca.databinding.javabeans.Java2XMLMapperException; +import org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLTransformer; + +/** + * + * @version $Rev$ $Date$ + */ +public class Exception2OMElement extends JavaBean2XMLTransformer { + + public static final String GETCAUSE = "getCause"; + public static final String GETLOCALIZEDMESSAGE = "getLocalizedMessage"; + public static final String GETSTACKTRACE = "getStackTrace"; + public static final String GETCLASS = "getClass"; + + private OMFactory factory; + + public Exception2OMElement() { + super(); + factory = OMAbstractFactory.getOMFactory(); + } + + @Override + public OMElement transform(Object source, TransformationContext context) { + OMElement element = super.transform(source, context); + AxiomHelper.adjustElementName(context, element); + return element; + } + + @Override + protected boolean isMappedGetter(String methodName) { + if (GETCAUSE.equals(methodName) + || GETLOCALIZEDMESSAGE.equals(methodName) + || GETSTACKTRACE.equals(methodName) + || GETCLASS.equals(methodName)) { + return false; + } else { + return true; + } + } + + @Override + public void appendChild(OMElement parentElement, OMElement childElement) throws Java2XMLMapperException { + parentElement.addChild(childElement); + } + + @Override + public OMElement createElement(QName qName) throws Java2XMLMapperException { + return factory.createOMElement(qName); + } + + @Override + public void appendText(OMElement parentElement, String textData) throws Java2XMLMapperException { + if (textData == null) { + OMNamespace xsi = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi"); + OMAttribute nil = factory.createOMAttribute("nil", xsi, "true"); + parentElement.addAttribute(nil); + } else { + factory.createOMText(parentElement, textData); + } + } + + @Override + public Class getTargetType() { + return OMElement.class; + } + +} diff --git a/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java b/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java index e23d89327c..d2a7f861e8 100644 --- a/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java +++ b/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java @@ -1,77 +1,77 @@ -/* - * 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.sca.databinding.axiom; - -import java.io.ByteArrayOutputStream; -import java.io.Externalizable; -import java.io.ObjectOutputStream; - -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.tuscany.sca.databinding.PullTransformer; -import org.apache.tuscany.sca.databinding.TransformationContext; -import org.apache.tuscany.sca.databinding.TransformationException; -import org.apache.tuscany.sca.databinding.impl.BaseTransformer; -import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.Base64Binary; - -/** - * - * @version $Rev$ $Date$ - */ -public class Externalizable2OMElement extends BaseTransformer implements - PullTransformer { - - @Override - protected Class getSourceType() { - return Externalizable.class; - } - - @Override - protected Class getTargetType() { - return OMElement.class; - } - - public OMElement transform(Externalizable source, TransformationContext context) { - OMElement element = null; - - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(bos); - out.writeObject(source); - out.close(); - OMFactory factory = OMAbstractFactory.getOMFactory(); - OMNamespace ns = AxiomHelper.createOMNamespace(factory, new QName("http://callable")); - element = factory.createOMElement("reference",ns); - element.setText(Base64Binary.encode(bos.toByteArray())); - return element; - } catch (Exception e) { - throw new TransformationException(e); - } - } - - @Override - public int getWeight() { - return 10; - } - -} +/* + * 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.sca.databinding.axiom; + +import java.io.ByteArrayOutputStream; +import java.io.Externalizable; +import java.io.ObjectOutputStream; + +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.tuscany.sca.databinding.PullTransformer; +import org.apache.tuscany.sca.databinding.TransformationContext; +import org.apache.tuscany.sca.databinding.TransformationException; +import org.apache.tuscany.sca.databinding.impl.BaseTransformer; +import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.Base64Binary; + +/** + * + * @version $Rev$ $Date$ + */ +public class Externalizable2OMElement extends BaseTransformer implements + PullTransformer { + + @Override + protected Class getSourceType() { + return Externalizable.class; + } + + @Override + protected Class getTargetType() { + return OMElement.class; + } + + public OMElement transform(Externalizable source, TransformationContext context) { + OMElement element = null; + + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(bos); + out.writeObject(source); + out.close(); + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMNamespace ns = AxiomHelper.createOMNamespace(factory, new QName("http://callable")); + element = factory.createOMElement("reference",ns); + element.setText(Base64Binary.encode(bos.toByteArray())); + return element; + } catch (Exception e) { + throw new TransformationException(e); + } + } + + @Override + public int getWeight() { + return 10; + } + +} diff --git a/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java b/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java index 3dc73c89cb..947cd99a19 100644 --- a/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java +++ b/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java @@ -1,79 +1,79 @@ -/* - * 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.sca.databinding.axiom; - -import java.util.Iterator; - -import javax.xml.namespace.QName; - -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMNode; -import org.apache.axiom.om.OMText; -import org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer; -import org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException; - -/** - * Transformer to convert data from an OMElement to a Java Exception - * - * @version $Rev$ $Date$ - */ -public class OMElement2Exception extends XML2JavaBeanTransformer { - - @Override - public OMElement getRootElement(OMElement element) throws XML2JavaMapperException { - return element; - } - - @Override - public Iterator getChildElements(OMElement parent) throws XML2JavaMapperException { - return parent.getChildElements(); - } - - @Override - public String getElementName(OMElement element) throws XML2JavaMapperException { - return element.getLocalName(); - } - - @Override - public String getText(OMElement element) throws XML2JavaMapperException { - return element.getText(); - } - - @Override - public boolean isTextElement(OMElement element) throws XML2JavaMapperException { - return false; - } - - @Override - public boolean isTextOnly(OMElement element) throws XML2JavaMapperException { - OMNode firstChild = element.getFirstOMChild(); - return firstChild instanceof OMText && firstChild.getNextOMSibling() == null; - } - - @Override - public OMElement getFirstChildWithName(OMElement element, QName name) throws XML2JavaMapperException { - return element.getFirstChildWithName(name); - } - - @Override - public Class getSourceType() { - return OMElement.class; - } - -} +/* + * 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.sca.databinding.axiom; + +import java.util.Iterator; + +import javax.xml.namespace.QName; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMNode; +import org.apache.axiom.om.OMText; +import org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer; +import org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException; + +/** + * Transformer to convert data from an OMElement to a Java Exception + * + * @version $Rev$ $Date$ + */ +public class OMElement2Exception extends XML2JavaBeanTransformer { + + @Override + public OMElement getRootElement(OMElement element) throws XML2JavaMapperException { + return element; + } + + @Override + public Iterator getChildElements(OMElement parent) throws XML2JavaMapperException { + return parent.getChildElements(); + } + + @Override + public String getElementName(OMElement element) throws XML2JavaMapperException { + return element.getLocalName(); + } + + @Override + public String getText(OMElement element) throws XML2JavaMapperException { + return element.getText(); + } + + @Override + public boolean isTextElement(OMElement element) throws XML2JavaMapperException { + return false; + } + + @Override + public boolean isTextOnly(OMElement element) throws XML2JavaMapperException { + OMNode firstChild = element.getFirstOMChild(); + return firstChild instanceof OMText && firstChild.getNextOMSibling() == null; + } + + @Override + public OMElement getFirstChildWithName(OMElement element, QName name) throws XML2JavaMapperException { + return element.getFirstChildWithName(name); + } + + @Override + public Class getSourceType() { + return OMElement.class; + } + +} diff --git a/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java b/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java index ef7359fbcd..6d8d4dce99 100644 --- a/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java +++ b/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java @@ -1,69 +1,69 @@ -/* - * 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.sca.databinding.axiom; - -import java.io.ByteArrayInputStream; -import java.io.Externalizable; -import java.io.ObjectInputStream; - -import org.apache.axiom.om.OMElement; -import org.apache.tuscany.sca.databinding.PullTransformer; -import org.apache.tuscany.sca.databinding.TransformationContext; -import org.apache.tuscany.sca.databinding.TransformationException; -import org.apache.tuscany.sca.databinding.impl.BaseTransformer; -import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.Base64Binary; - -/** - * Transformer to convert data from an OMElement to XML String - * - * @version $Rev$ $Date$ - */ -public class OMElement2Externalizable extends BaseTransformer implements PullTransformer { - // private XmlOptions options; - - public Externalizable transform(OMElement source, TransformationContext context) { - try { - String value = source.getText(); - ByteArrayInputStream bis = new ByteArrayInputStream(Base64Binary.decode(value)); - ObjectInputStream ois = new ObjectInputStream(bis); - Object obj = ois.readObject(); - ois.close(); - Externalizable aReference = (Externalizable) obj; - return aReference; - } catch (Exception e) { - throw new TransformationException(e); - } - } - - @Override - protected Class getSourceType() { - return OMElement.class; - } - - @Override - protected Class getTargetType() { - return Externalizable.class; - } - - @Override - public int getWeight() { - return 10; - } - -} +/* + * 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.sca.databinding.axiom; + +import java.io.ByteArrayInputStream; +import java.io.Externalizable; +import java.io.ObjectInputStream; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.databinding.PullTransformer; +import org.apache.tuscany.sca.databinding.TransformationContext; +import org.apache.tuscany.sca.databinding.TransformationException; +import org.apache.tuscany.sca.databinding.impl.BaseTransformer; +import org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.Base64Binary; + +/** + * Transformer to convert data from an OMElement to XML String + * + * @version $Rev$ $Date$ + */ +public class OMElement2Externalizable extends BaseTransformer implements PullTransformer { + // private XmlOptions options; + + public Externalizable transform(OMElement source, TransformationContext context) { + try { + String value = source.getText(); + ByteArrayInputStream bis = new ByteArrayInputStream(Base64Binary.decode(value)); + ObjectInputStream ois = new ObjectInputStream(bis); + Object obj = ois.readObject(); + ois.close(); + Externalizable aReference = (Externalizable) obj; + return aReference; + } catch (Exception e) { + throw new TransformationException(e); + } + } + + @Override + protected Class getSourceType() { + return OMElement.class; + } + + @Override + protected Class getTargetType() { + return Externalizable.class; + } + + @Override + public int getWeight() { + return 10; + } + +} -- cgit v1.2.3