From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/databinding/castor/Castor2Node.java | 63 +++++++++++++++++++++ .../tuscany/databinding/castor/Castor2SAX.java | 63 +++++++++++++++++++++ .../tuscany/databinding/castor/Castor2Writer.java | 62 +++++++++++++++++++++ .../databinding/castor/InputSource2Castor.java | 63 +++++++++++++++++++++ .../tuscany/databinding/castor/Node2Castor.java | 63 +++++++++++++++++++++ .../tuscany/databinding/castor/Reader2Castor.java | 64 ++++++++++++++++++++++ 6 files changed, 378 insertions(+) create mode 100755 sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Node.java create mode 100644 sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2SAX.java create mode 100644 sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Writer.java create mode 100644 sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/InputSource2Castor.java create mode 100644 sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Node2Castor.java create mode 100644 sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Reader2Castor.java (limited to 'sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding') diff --git a/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Node.java b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Node.java new file mode 100755 index 0000000000..9ae0335ada --- /dev/null +++ b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Node.java @@ -0,0 +1,63 @@ +/* + * 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.castor; + +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.extension.DOMHelper; +import org.apache.tuscany.spi.databinding.extension.TransformerExtension; +import org.exolab.castor.xml.Marshaller; +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +public class Castor2Node extends TransformerExtension implements PullTransformer { + private Class type; + + public Castor2Node(Class type) { + super(); + this.type = type; + } + + public Class getTargetType() { + return Node.class; + } + + public Class getSourceType() { + return type; + } + + public int getWeight() { + return 40; + } + + /** + * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext) + */ + public Node transform(Object source, TransformationContext context) { + try { + Document document = DOMHelper.newDocument(); + Marshaller.marshal(source, document); + return document; + } catch (Exception e) { + throw new TransformationException(e); + } + } + +} diff --git a/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2SAX.java b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2SAX.java new file mode 100644 index 0000000000..643d6fb4ad --- /dev/null +++ b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2SAX.java @@ -0,0 +1,63 @@ +/* + * 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.castor; + +import java.io.Writer; + +import org.apache.tuscany.spi.databinding.PushTransformer; +import org.apache.tuscany.spi.databinding.TransformationContext; +import org.apache.tuscany.spi.databinding.TransformationException; +import org.apache.tuscany.spi.databinding.extension.TransformerExtension; +import org.exolab.castor.xml.Marshaller; + +public class Castor2SAX extends TransformerExtension implements PushTransformer { + private Class type; + + /** + * @param type + */ + public Castor2SAX(Class type) { + super(); + this.type = type; + } + + public Class getSourceType() { + return type; + } + + public Class getTargetType() { + return Writer.class; + } + + public int getWeight() { + return 40; + } + + /** + * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext) + */ + public void transform(T source, Writer writer, TransformationContext context) { + try { + Marshaller.marshal(source, writer); + } catch (Exception e) { + throw new TransformationException(e); + } + } + +} diff --git a/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Writer.java b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Writer.java new file mode 100644 index 0000000000..f477273387 --- /dev/null +++ b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Castor2Writer.java @@ -0,0 +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.databinding.castor; + +import org.apache.tuscany.spi.databinding.PushTransformer; +import org.apache.tuscany.spi.databinding.TransformationContext; +import org.apache.tuscany.spi.databinding.TransformationException; +import org.apache.tuscany.spi.databinding.extension.TransformerExtension; +import org.exolab.castor.xml.Marshaller; +import org.xml.sax.ContentHandler; + +public class Castor2Writer extends TransformerExtension implements PushTransformer { + private Class type; + + /** + * @param type + */ + public Castor2Writer(Class type) { + super(); + this.type = type; + } + + public Class getSourceType() { + return type; + } + + public Class getTargetType() { + return ContentHandler.class; + } + + public int getWeight() { + return 40; + } + + /** + * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext) + */ + public void transform(T source, ContentHandler contentHandler, TransformationContext context) { + try { + Marshaller.marshal(source, contentHandler); + } catch (Exception e) { + throw new TransformationException(e); + } + } + +} diff --git a/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/InputSource2Castor.java b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/InputSource2Castor.java new file mode 100644 index 0000000000..61bac7d20f --- /dev/null +++ b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/InputSource2Castor.java @@ -0,0 +1,63 @@ +/* + * 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.castor; + +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.extension.TransformerExtension; +import org.exolab.castor.xml.Unmarshaller; +import org.xml.sax.InputSource; + +public class InputSource2Castor extends TransformerExtension implements PullTransformer { + private Class type; + + /** + * @param type + */ + public InputSource2Castor(Class type) { + super(); + this.type = type; + } + + public Class getTargetType() { + return type; + } + + public Class getSourceType() { + return InputSource.class; + } + + public int getWeight() { + return 40; + } + + /** + * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext) + */ + public T transform(InputSource source, TransformationContext context) { + try { + Object object = Unmarshaller.unmarshal(type, source); + return type.cast(object); + } catch (Exception e) { + throw new TransformationException(e); + } + } + +} diff --git a/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Node2Castor.java b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Node2Castor.java new file mode 100644 index 0000000000..fa5a15b3ba --- /dev/null +++ b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Node2Castor.java @@ -0,0 +1,63 @@ +/* + * 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.castor; + +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.extension.TransformerExtension; +import org.exolab.castor.xml.Unmarshaller; +import org.w3c.dom.Node; + +public class Node2Castor extends TransformerExtension implements PullTransformer { + private Class type; + + /** + * @param type + */ + public Node2Castor(Class type) { + super(); + this.type = type; + } + + public Class getTargetType() { + return type; + } + + public Class getSourceType() { + return Node.class; + } + + public int getWeight() { + return 40; + } + + /** + * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext) + */ + public T transform(Node source, TransformationContext context) { + try { + Object object = Unmarshaller.unmarshal(type, source); + return type.cast(object); + } catch (Exception e) { + throw new TransformationException(e); + } + } + +} diff --git a/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Reader2Castor.java b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Reader2Castor.java new file mode 100644 index 0000000000..a8ade1bda5 --- /dev/null +++ b/sandbox/old/contrib/databinding-castor/src/main/java/org/apache/tuscany/databinding/castor/Reader2Castor.java @@ -0,0 +1,64 @@ +/* + * 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.castor; + +import java.io.Reader; + +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.extension.TransformerExtension; +import org.exolab.castor.xml.Unmarshaller; + +public class Reader2Castor extends TransformerExtension implements PullTransformer { + private Class type; + + /** + * @param type + */ + public Reader2Castor(Class type) { + super(); + this.type = type; + } + + public Class getTargetType() { + return type; + } + + public Class getSourceType() { + return Reader.class; + } + + public int getWeight() { + return 40; + } + + /** + * @see org.apache.tuscany.spi.databinding.PullTransformer#transform(java.lang.Object, org.apache.tuscany.spi.databinding.TransformationContext) + */ + public T transform(Reader source, TransformationContext context) { + try { + Object object = Unmarshaller.unmarshal(type, source); + return type.cast(object); + } catch (Exception e) { + throw new TransformationException(e); + } + } + +} -- cgit v1.2.3