summaryrefslogtreecommitdiffstats
path: root/sandbox/old/contrib/databinding-json/src/main/java/org/apache/tuscany/databinding/json/JSONDataBinding.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/old/contrib/databinding-json/src/main/java/org/apache/tuscany/databinding/json/JSONDataBinding.java')
-rw-r--r--sandbox/old/contrib/databinding-json/src/main/java/org/apache/tuscany/databinding/json/JSONDataBinding.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/sandbox/old/contrib/databinding-json/src/main/java/org/apache/tuscany/databinding/json/JSONDataBinding.java b/sandbox/old/contrib/databinding-json/src/main/java/org/apache/tuscany/databinding/json/JSONDataBinding.java
new file mode 100644
index 0000000000..2cc8c1da37
--- /dev/null
+++ b/sandbox/old/contrib/databinding-json/src/main/java/org/apache/tuscany/databinding/json/JSONDataBinding.java
@@ -0,0 +1,52 @@
+/*
+ * 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.json;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.json.JSONObject;
+
+/**
+ * JAXB DataBinding
+ */
+public class JSONDataBinding extends DataBindingExtension {
+ public static final String NAME = JSONObject.class.getName();
+ public static final String[] ALIASES = new String[] {"json"};
+
+ public static final String ROOT_NAMESPACE = "http://tuscany.apache.org/xmlns/sca/databinding/json/1.0";
+ public static final QName ROOT_ELEMENT = new QName(ROOT_NAMESPACE, "root");
+
+ public JSONDataBinding() {
+ super(NAME, ALIASES, JSONObject.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object copy(Object arg) {
+ try {
+ JSONObject src = (JSONObject)arg;
+ return new JSONObject(src.toString());
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+}