cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dand...@apache.org
Subject svn commit: r515734 [4/11] - in /incubator/cxf/trunk/rt: ./ core/src/main/java/org/apache/cxf/endpoint/ databinding/aegis/ databinding/aegis/src/ databinding/aegis/src/main/ databinding/aegis/src/main/java/ databinding/aegis/src/main/java/org/ databind...
Date Wed, 07 Mar 2007 20:20:15 GMT
Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigIntegerType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigIntegerType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigIntegerType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigIntegerType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,49 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import java.math.BigInteger;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * <code>Type</code> for a <code>BigInteger</code>
+ * 
+ * @author <a href="mailto:peter.royal@pobox.com">peter royal</a>
+ */
+public class BigIntegerType extends Type {
+    public BigIntegerType() {
+        super();
+    }
+
+    @Override
+    public Object readObject(final MessageReader reader, final Context context) {
+        final String value = reader.getValue();
+
+        return null == value ? null : new BigInteger(value);
+    }
+
+    @Override
+    public void writeObject(final Object object, final MessageWriter writer, final Context context) {
+        writer.writeValue(object.toString());
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigIntegerType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BigIntegerType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BooleanType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BooleanType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BooleanType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BooleanType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,39 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class BooleanType extends Type {
+    @Override
+    public Object readObject(MessageReader reader, Context context) {
+        return new Boolean(reader.getValueAsBoolean());
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        writer.writeValueAsBoolean(((Boolean)object).booleanValue());
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BooleanType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BooleanType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CalendarType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CalendarType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CalendarType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CalendarType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,57 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import java.text.ParseException;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.util.date.XsDateTimeFormat;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * Type for the Calendar class.
+ * 
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class CalendarType extends Type {
+    private static XsDateTimeFormat format = new XsDateTimeFormat();
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        String value = reader.getValue();
+
+        if (value == null) {
+            return null;
+        }
+
+        try {
+            return format.parseObject(value);
+        } catch (ParseException e) {
+            throw new DatabindingException("Could not parse xs:dateTime: " + e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        writer.writeValue(format.format(object));
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CalendarType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CalendarType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,40 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * @author <a href="mailto:struman@nuparadigm.com">Sean Truman</a>
+ */
+public class CharacterType extends Type {
+    @Override
+    public Object readObject(MessageReader reader, Context context) {
+        return new Character(reader.getValueAsCharacter());
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        writer.writeValueAsCharacter((Character)object);
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/CharacterType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateTimeType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateTimeType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateTimeType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateTimeType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,49 @@
+package org.apache.cxf.aegis.type.basic;
+
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.util.date.XsDateTimeFormat;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * Type for the Date class which serializes as an xsd:dateTime.
+ * 
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class DateTimeType extends Type {
+    private static XsDateTimeFormat format = new XsDateTimeFormat();
+
+    public DateTimeType() {
+        super();
+        setNillable(false);
+    }
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        String value = reader.getValue();
+
+        if (value == null) {
+            return null;
+        }
+
+        try {
+            Calendar c = (Calendar)format.parseObject(value);
+            return c.getTime();
+        } catch (ParseException e) {
+            throw new DatabindingException("Could not parse xs:dateTime: " + e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        Calendar c = Calendar.getInstance();
+        c.setTime((Date)object);
+        writer.writeValue(format.format(c));
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateTimeType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateTimeType.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateTimeType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,45 @@
+package org.apache.cxf.aegis.type.basic;
+
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.util.date.XsDateFormat;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * Type for the Date class which serializes as an xsd:date (no time
+ * information).
+ * 
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class DateType extends Type {
+    private static XsDateFormat format = new XsDateFormat();
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        String value = reader.getValue();
+
+        if (value == null) {
+            return null;
+        }
+
+        try {
+            Calendar c = (Calendar)format.parseObject(value);
+            return c.getTime();
+        } catch (ParseException e) {
+            throw new DatabindingException("Could not parse xs:dat: " + e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        Calendar c = Calendar.getInstance();
+        c.setTime((Date)object);
+        writer.writeValue(format.format(c));
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateType.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DateType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DoubleType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DoubleType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DoubleType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DoubleType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,43 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class DoubleType extends Type {
+    @Override
+    public Object readObject(MessageReader reader, Context context) {
+        return new Double(reader.getValueAsDouble());
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        if (object instanceof Double) {
+            writer.writeValueAsDouble((Double)object);
+        } else {
+            writer.writeValueAsDouble(new Double(((Number)object).doubleValue()));
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DoubleType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/DoubleType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/FloatType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/FloatType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/FloatType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/FloatType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,44 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class FloatType extends Type {
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) {
+        return new Float(reader.getValueAsFloat());
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        if (object instanceof Float) {
+            writer.writeValueAsFloat((Float)object);
+        } else {
+            writer.writeValueAsFloat(new Float(((Number)object).floatValue()));
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/FloatType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/FloatType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/IntType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/IntType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/IntType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/IntType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,45 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * SimpleSerializer
+ * 
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class IntType extends Type {
+    @Override
+    public Object readObject(MessageReader reader, Context context) {
+        return new Integer(reader.getValueAsInt());
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        if (object instanceof Integer) {
+            writer.writeValueAsInt((Integer)object);
+        } else {
+            writer.writeValueAsInt(new Integer(((Number)object).intValue()));
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/IntType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/IntType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,155 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+class InterfaceInvocationHandler implements InvocationHandler {
+    InterfaceInvocationHandler() {
+    }
+
+    private Map<Object, Object> attributes = new HashMap<Object, Object>();
+
+    public void writeProperty(Object key, Object value) {
+        attributes.put(key, value);
+    }
+
+    public Object readProperty(Object key) {
+        return attributes.get(key);
+    }
+
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+        if (Object.class.getMethod("hashCode", (Class[]) null).equals(method)) {
+            return proxyHashCode(proxy);
+        } else if (Object.class.getMethod("equals", new Class[] {Object.class}).equals(method)) {
+            return proxyEquals(proxy, args[0]);
+        } else if (Object.class.getMethod("toString", (Class[]) null).equals(method)) {
+            return proxyToString(proxy);
+        } else {
+            if (isGetterMethod(method, args)) {
+                return doGetter(method, args);
+            } else if (isSetterMethod(method, args)) {
+                return doSetter(method, args);
+            } else {
+                throw new IllegalAccessError(method.getName() + " is not delegated.");
+            }
+        }
+    }
+
+    protected boolean isGetterMethod(Method method, Object[] args) {
+        if (args != null && args.length > 0) {
+            return false;
+        }
+
+        String methodName = method.getName();
+
+        if (methodName.startsWith("get") && methodName.length() > 3) {
+            return true;
+        } else if (methodName.startsWith("is") && methodName.length() > 2) {
+            return true;
+        /*
+         * // should "hasXXX()" be considered a getter method? else if
+         * (methodName.startsWith("has") && methodName.length() > 3) { return
+         * true; }
+         */
+        } else {
+            return false;
+        }
+    }
+
+    protected boolean isSetterMethod(Method method, Object[] args) {
+        if (args == null || args.length != 1) {
+            return false;
+        }
+
+        if (!"void".equals(method.getReturnType().getName())) {
+            return false;
+        }
+
+        String methodName = method.getName();
+
+        if (methodName.startsWith("set") && methodName.length() > 3) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    protected Object doGetter(Method method, Object[] args) throws Throwable {
+        String methodName = method.getName();
+        String attrName = null;
+
+        if (methodName.startsWith("get")) {
+            attrName = convertMethodName(methodName, 3);
+        } else if (methodName.startsWith("is")) {
+            attrName = convertMethodName(methodName, 2);
+        } else {
+            throw new IllegalAccessError(methodName + " is not a valid getter method.");
+        }
+
+        return readProperty(attrName);
+    }
+
+    protected Object doSetter(Method method, Object[] args) throws Throwable {
+        String methodName = method.getName();
+        String attrName = null;
+
+        if (methodName.startsWith("set")) {
+            attrName = convertMethodName(methodName, 3);
+        } else {
+            throw new IllegalAccessError(methodName + " is not a valid setter method.");
+        }
+
+        writeProperty(attrName, args[0]);
+
+        return null;
+    }
+
+    private String convertMethodName(String methodName, int firstCharacter) {
+        if (methodName.length() >= firstCharacter + 2) {
+            if (!Character.isUpperCase(methodName.charAt(firstCharacter + 1))) {
+                return Character.toLowerCase(methodName.charAt(firstCharacter))
+                       + methodName.substring(firstCharacter + 1);
+            } else {
+                return methodName.substring(3);
+            }
+        } else {
+            return Character.toLowerCase(methodName.charAt(firstCharacter))
+                   + methodName.substring(firstCharacter + 1);
+        }
+    }
+
+    protected Integer proxyHashCode(Object proxy) {
+        return new Integer(System.identityHashCode(proxy));
+    }
+
+    protected Boolean proxyEquals(Object proxy, Object other) {
+        return proxy == other ? Boolean.TRUE : Boolean.FALSE;
+    }
+
+    protected String proxyToString(Object proxy) {
+        return proxy.getClass().getName() + '@' + proxy.hashCode();
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/InterfaceInvocationHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/LongType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/LongType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/LongType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/LongType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,43 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class LongType extends Type {
+    @Override
+    public Object readObject(MessageReader reader, Context context) {
+        return new Long(reader.getValueAsLong());
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        if (object instanceof Long) {
+            writer.writeValueAsLong((Long)object);
+        } else {
+            writer.writeValueAsLong(new Long(((Number)object).longValue()));
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/LongType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/LongType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,326 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+
+import org.apache.cxf.aegis.Aegis;
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.aegis.util.Base64;
+import org.apache.cxf.aegis.util.XmlConstants;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+import org.jdom.Attribute;
+import org.jdom.Element;
+
+/**
+ * Type for runtime inspection of types. Looks as the class to be written, and
+ * looks to see if there is a type for that class. If there is, it writes out
+ * the value and inserts a <em>xsi:type</em> attribute to signal what the type
+ * of the value is. Can specify an optional set of dependent <code>Type</code>'s
+ * in the constructor, in the case that the type is a custom type that may not
+ * have its schema in the WSDL. Can specify whether or not unknown objects
+ * should be serialized as a byte stream.
+ * 
+ * @author <a href="mailto:peter.royal@pobox.com">peter royal</a>
+ */
+public class ObjectType extends Type {
+    private static final QName XSI_TYPE = new QName(XmlConstants.XSI_NS, "type");
+    private static final QName XSI_NIL = new QName(XmlConstants.XSI_NS, "nil");
+
+    private Set<Type> dependencies;
+    private boolean serializedWhenUnknown;
+    private boolean readToDocument = false;
+
+    @SuppressWarnings("unchecked")
+    public ObjectType() {
+        this(Collections.EMPTY_SET);
+        readToDocument = true;
+    }
+
+    public ObjectType(Set<Type> dependencies) {
+        this(dependencies, false);
+    }
+
+    @SuppressWarnings("unchecked")
+    public ObjectType(boolean serializeWhenUnknown) {
+        this(Collections.EMPTY_SET, serializeWhenUnknown);
+    }
+
+    public ObjectType(Set<Type> dependencies, boolean serializeWhenUnknown) {
+        this.dependencies = dependencies;
+        this.serializedWhenUnknown = serializeWhenUnknown;
+    }
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        if (isNil(reader.getAttributeReader(XSI_NIL))) {
+            while (reader.hasMoreElementReaders()) {
+                reader.getNextElementReader();
+            }
+
+            return null;
+        }
+
+        MessageReader typeReader = reader.getAttributeReader(XSI_TYPE);
+
+        if (null == typeReader && !readToDocument) {
+            throw new DatabindingException("Missing 'xsi:type' attribute");
+        }
+
+        String typeName = typeReader.getValue();
+
+        if (null == typeName && !readToDocument) {
+            throw new DatabindingException("Missing 'xsi:type' attribute value");
+        }
+
+        Type type = null;
+        QName typeQName = null;
+        if (typeName != null) {
+            typeQName = extractQName(reader, typeName);
+        } else {
+            typeQName = reader.getName();
+        }
+
+        TypeMapping tm = (TypeMapping)context.get(Aegis.TYPE_MAPPING_KEY);
+        if (tm == null) {
+            tm = getTypeMapping();
+        }
+
+        type = tm.getType(typeQName);
+
+        if (type == null) {
+            type = tm.getType(getSchemaType());
+        }
+
+        if (type == null && readToDocument) {
+            type = getTypeMapping().getType(Document.class);
+        }
+
+        if (null == type) {
+            // TODO should check namespace as well..
+            if (serializedWhenUnknown && "serializedJavaObject".equals(typeName)) {
+                return reconstituteJavaObject(reader);
+            }
+
+            throw new DatabindingException("No mapped type for '" + typeName + "' (" + typeQName + ")");
+        }
+
+        return type.readObject(reader, context);
+    }
+
+    private QName extractQName(MessageReader reader, String typeName) {
+        int colon = typeName.indexOf(':');
+
+        if (-1 == colon) {
+            return new QName(reader.getNamespace(), typeName);
+        } else {
+            return new QName(reader.getNamespaceForPrefix(typeName.substring(0, colon)), typeName
+                .substring(colon + 1));
+        }
+    }
+
+    private Object reconstituteJavaObject(MessageReader reader) throws DatabindingException {
+        ByteArrayInputStream in = new ByteArrayInputStream(Base64.decode(reader.getValue()));
+
+        try {
+            return new ObjectInputStream(in).readObject();
+        } catch (Exception e) {
+            throw new DatabindingException("Unable to reconstitute serialized object", e);
+        }
+    }
+
+    private boolean isNil(MessageReader reader) {
+        return null != reader && "true".equals(reader.getValue());
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) throws DatabindingException {
+        if (null == object) {
+            MessageWriter nilWriter = writer.getAttributeWriter(XSI_NIL);
+
+            nilWriter.writeValue("true");
+
+            nilWriter.close();
+        } else {
+            Type type = determineType(context, object.getClass());
+
+            if (null == type) {
+                handleNullType(object, writer);
+            } else {
+                String prefix = writer.getPrefixForNamespace(type.getSchemaType().getNamespaceURI());
+
+                if (null == prefix || prefix.length() == 0) {
+                    addXsiType(writer, type.getSchemaType().getLocalPart());
+                } else {
+                    addXsiType(writer, prefix + ":" + type.getSchemaType().getLocalPart());
+                }
+
+                type.writeObject(object, writer, context);
+            }
+        }
+    }
+
+    private Type determineType(Context context, Class clazz) {
+        TypeMapping tm = context.getTypeMapping();
+        if (tm == null) {
+            tm = getTypeMapping();
+        }
+        Type type = tm.getType(clazz);
+
+        if (null != type) {
+            return type;
+        }
+
+        Class[] interfaces = clazz.getInterfaces();
+
+        for (int i = 0; i < interfaces.length; i++) {
+            Class anInterface = interfaces[i];
+
+            type = tm.getType(anInterface);
+
+            if (null != type) {
+                return type;
+            }
+        }
+
+        Class superclass = clazz.getSuperclass();
+
+        if (null == superclass || Object.class.equals(superclass)) {
+            return null;
+        }
+
+        return determineType(context, superclass);
+    }
+
+    private void addXsiType(MessageWriter writer, String prefixedType) {
+        MessageWriter typeWriter = writer.getAttributeWriter(XSI_TYPE);
+
+        typeWriter.writeValue(prefixedType);
+
+        typeWriter.close();
+    }
+
+    private void handleNullType(Object object, MessageWriter writer) throws DatabindingException {
+        if (!serializedWhenUnknown) {
+            throw new DatabindingException("Unable to write '" + object + "' [" + object.getClass().getName()
+                                           + "]. Type is unknown.");
+        }
+
+        addXsiType(writer, "serializedJavaObject"); // TODO not sure what
+                                                    // namespace to put
+                                                    // here..should match what
+                                                    // is put in writeSchema
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
+
+        try {
+            ObjectOutputStream objectOutputStream = new ObjectOutputStream(out);
+
+            objectOutputStream.writeObject(object);
+            objectOutputStream.close();
+        } catch (IOException e) {
+            throw new DatabindingException("Unable to serialize '" + object + "' ["
+                                           + object.getClass().getName() + "]", e);
+        }
+
+        writer.writeValue(Base64.encode(out.toByteArray()));
+    }
+
+    public boolean isReadToDocument() {
+        return readToDocument;
+    }
+
+    public void setReadToDocument(boolean readToDocument) {
+        this.readToDocument = readToDocument;
+    }
+
+    public boolean isSerializedWhenUnknown() {
+        return serializedWhenUnknown;
+    }
+
+    public void setSerializedWhenUnknown(boolean serializedWhenUnknown) {
+        this.serializedWhenUnknown = serializedWhenUnknown;
+    }
+
+    public void setDependencies(Set<Type> dependencies) {
+        this.dependencies = dependencies;
+    }
+
+    @Override
+    public Set<Type> getDependencies() {
+        return dependencies;
+    }
+
+    @Override
+    public boolean isComplex() {
+        return true;
+    }
+
+    @Override
+    public boolean isAbstract() {
+        // TODO Auto-generated method stub
+        return super.isAbstract();
+    }
+
+    @Override
+    public boolean isNillable() {
+        // TODO Auto-generated method stub
+        return super.isNillable();
+    }
+
+    @Override
+    public boolean isWriteOuter() {
+        // TODO Auto-generated method stub
+        return super.isWriteOuter();
+    }
+
+    @Override
+    public void setNillable(boolean nillable) {
+        // TODO Auto-generated method stub
+        super.setNillable(nillable);
+    }
+
+    @Override
+    public void writeSchema(Element root) {
+        if (serializedWhenUnknown) {
+            Element simple = new Element("simpleType", XmlConstants.XSD_PREFIX, XmlConstants.XSD);
+            simple.setAttribute(new Attribute("name", "serializedJavaObject"));
+            root.addContent(simple);
+
+            Element restriction = new Element("restriction", XmlConstants.XSD_PREFIX, XmlConstants.XSD);
+            restriction.setAttribute(new Attribute("base", XmlConstants.XSD_PREFIX + ":base64Binary"));
+
+            simple.addContent(restriction);
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ShortType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ShortType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ShortType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ShortType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,43 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class ShortType extends Type {
+    @Override
+    public Object readObject(MessageReader reader, Context context) {
+        return new Short(reader.getValue());
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        if (object instanceof Short) {
+            writer.writeValueAsShort((Short)object);
+        } else {
+            writer.writeValueAsShort(new Short(((Number)object).shortValue()));
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ShortType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ShortType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/SqlDateType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/SqlDateType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/SqlDateType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/SqlDateType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,51 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import java.util.Date;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * Type for the java.sql.Date class which serializes as an xsd:date (no time
+ * information).
+ * 
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class SqlDateType extends DateType {
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        Date date = ((Date)super.readObject(reader, context));
+        if (date == null) {
+            return null;
+        }
+
+        return new java.sql.Date(date.getTime());
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        java.sql.Date date = (java.sql.Date)object;
+
+        super.writeObject(new Date(date.getTime()), writer, context);
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/SqlDateType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/SqlDateType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/StringType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/StringType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/StringType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/StringType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,43 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class StringType extends Type {
+
+    public StringType() {
+    }
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) {
+        return reader.getValue();
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        writer.writeValue(object);
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/StringType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/StringType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimeType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimeType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimeType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimeType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,44 @@
+package org.apache.cxf.aegis.type.basic;
+
+import java.sql.Time;
+import java.text.ParseException;
+import java.util.Calendar;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.util.date.XsTimeFormat;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * Type for the Time class which serializes to an xs:time.
+ * 
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class TimeType extends Type {
+    private static XsTimeFormat format = new XsTimeFormat();
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        String value = reader.getValue();
+
+        if (value == null) {
+            return null;
+        }
+
+        try {
+            Calendar c = (Calendar)format.parseObject(value);
+            return new Time(c.getTimeInMillis());
+        } catch (ParseException e) {
+            throw new DatabindingException("Could not parse xs:dateTime: " + e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        Calendar c = Calendar.getInstance();
+        c.setTime((Time)object);
+        writer.writeValue(format.format(c));
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimeType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimeType.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimeType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimestampType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimestampType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimestampType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimestampType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,44 @@
+package org.apache.cxf.aegis.type.basic;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.Calendar;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.util.date.XsDateTimeFormat;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * Type for the Time class which serializes to an xs:time.
+ * 
+ * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
+ */
+public class TimestampType extends Type {
+    private static XsDateTimeFormat format = new XsDateTimeFormat();
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        String value = reader.getValue();
+
+        if (value == null) {
+            return null;
+        }
+
+        try {
+            Calendar c = (Calendar)format.parseObject(value);
+            return new Timestamp(c.getTimeInMillis());
+        } catch (ParseException e) {
+            throw new DatabindingException("Could not parse xs:dateTime: " + e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) {
+        Calendar c = Calendar.getInstance();
+        c.setTime((Timestamp)object);
+        writer.writeValue(format.format(c));
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimestampType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimestampType.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/TimestampType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/URIType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/URIType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/URIType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/URIType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,45 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import java.net.URI;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+/**
+ * <code>Type</code> for a <code>URI</code>
+ * 
+ * @author <a href="mailto:peter.royal@pobox.com">peter royal</a>
+ */
+public class URIType extends Type {
+    @Override
+    public Object readObject(final MessageReader reader, final Context context) {
+        final String value = reader.getValue();
+
+        return null == value ? null : URI.create(value);
+    }
+
+    @Override
+    public void writeObject(final Object object, final MessageWriter writer, final Context context) {
+        writer.writeValue(((URI)object).toASCIIString());
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/URIType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/URIType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,189 @@
+/**
+ * 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.cxf.aegis.type.basic;
+
+import java.beans.PropertyDescriptor;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.util.NamespaceHelper;
+import org.jdom.Element;
+
+public class XMLBeanTypeInfo extends BeanTypeInfo {
+    private static final Log logger = LogFactory.getLog(XMLBeanTypeInfo.class);
+    private List mappings;
+
+    /**
+     * Map used for storing meta data about each property
+     */
+    private Map<QName, BeanTypePropertyInfo> name2PropertyInfo = new HashMap<QName, BeanTypePropertyInfo>();
+
+    public XMLBeanTypeInfo(Class typeClass, List mappings, String defaultNS) {
+        super(typeClass, defaultNS);
+
+        this.mappings = mappings;
+    }
+
+    @Override
+    protected boolean registerType(PropertyDescriptor desc) {
+        Element e = getPropertyElement(desc.getName());
+        if (e != null && e.getAttributeValue("type") != null) {
+            return false;
+        }
+
+        return super.registerType(desc);
+    }
+
+    @Override
+    protected void mapProperty(PropertyDescriptor pd) {
+        Element e = getPropertyElement(pd.getName());
+        String style = null;
+        QName mappedName = null;
+
+        if (e != null) {
+            String ignore = e.getAttributeValue("ignore");
+            if (ignore != null && ignore.equals("true")) {
+                return;
+            }
+
+            logger.debug("Found mapping for property " + pd.getName());
+
+            style = e.getAttributeValue("style");
+            mappedName = NamespaceHelper.createQName(e, e.getAttributeValue("mappedName"),
+                                                     getDefaultNamespace());
+        }
+
+        if (style == null) {
+            style = "element";
+        }
+        if (mappedName == null) {
+            mappedName = createMappedName(pd);
+        }
+
+        if (e != null) {
+            QName mappedType = NamespaceHelper.createQName(e, e.getAttributeValue("typeName"),
+                                                           getDefaultNamespace());
+            if (mappedType != null) {
+                mapTypeName(mappedName, mappedType);
+            }
+
+            String nillableVal = e.getAttributeValue("nillable");
+            if (nillableVal != null && nillableVal.length() > 0) {
+                ensurePropertyInfo(mappedName).setNillable(Boolean.valueOf(nillableVal).booleanValue());
+            }
+
+            String minOccurs = e.getAttributeValue("minOccurs");
+            if (minOccurs != null && minOccurs.length() > 0) {
+                ensurePropertyInfo(mappedName).setMinOccurs(Integer.parseInt(minOccurs));
+            }
+        }
+
+        try {
+            // logger.debug("Mapped " + pd.getName() + " as " + style + " with
+            // name " + mappedName);
+            if (style.equals("element")) {
+                mapElement(pd.getName(), mappedName);
+            } else if (style.equals("attribute")) {
+                mapAttribute(pd.getName(), mappedName);
+            } else {
+                throw new DatabindingException("Invalid style: " + style);
+            }
+        } catch (DatabindingException ex) {
+            ex.prepend("Couldn't create type for property " + pd.getName() + " on " + getTypeClass());
+
+            throw ex;
+        }
+    }
+
+    private Element getPropertyElement(String name2) {
+        for (Iterator itr = mappings.iterator(); itr.hasNext();) {
+            Element mapping2 = (Element)itr.next();
+            List elements = mapping2.getChildren("property");
+            for (int i = 0; i < elements.size(); i++) {
+                Element e = (Element)elements.get(i);
+                String name = e.getAttributeValue("name");
+
+                if (name != null && name.equals(name2)) {
+                    return e;
+                }
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Grab Nillable by looking in PropertyInfo map if no entry found, revert to
+     * parent class
+     */
+    @Override
+    public boolean isNillable(QName name) {
+        BeanTypePropertyInfo info = getPropertyInfo(name);
+        if (info != null) {
+            return info.isNillable();
+        }
+        return super.isNillable(name);
+    }
+
+    /**
+     * Grab Min Occurs by looking in PropertyInfo map if no entry found, revert
+     * to parent class
+     */
+    @Override
+    public int getMinOccurs(QName name) {
+        BeanTypePropertyInfo info = getPropertyInfo(name);
+        if (info != null) {
+            return info.getMinOccurs();
+        }
+        return super.getMinOccurs(name);
+    }
+
+    /**
+     * Grab the Property Info for the given property
+     * 
+     * @param name
+     * @return the BeanTypePropertyInfo for the property or NULL if none found
+     */
+    private BeanTypePropertyInfo getPropertyInfo(QName name) {
+        return name2PropertyInfo.get(name);
+    }
+
+    /**
+     * Grab the Property Info for the given property but if not found create one
+     * and add it to the map
+     * 
+     * @param name
+     * @return the BeanTypePropertyInfo for the property
+     */
+    private BeanTypePropertyInfo ensurePropertyInfo(QName name) {
+        BeanTypePropertyInfo result = getPropertyInfo(name);
+        if (result == null) {
+            result = new BeanTypePropertyInfo();
+            name2PropertyInfo.put(name, result);
+        }
+        return result;
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,113 @@
+/**
+ * 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.cxf.aegis.type.collection;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.basic.ArrayType;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+
+public class CollectionType extends ArrayType {
+    private Type componentType;
+
+    public CollectionType(Type componentType) {
+        super();
+
+        this.componentType = componentType;
+    }
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        try {
+            return readCollection(reader, context);
+        } catch (IllegalArgumentException e) {
+            throw new DatabindingException("Illegal argument.", e);
+        }
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected Collection<Object> createCollection() {
+        Collection values = null;
+
+        if (getTypeClass().isAssignableFrom(List.class)) {
+            values = new ArrayList();
+        } else if (getTypeClass().isAssignableFrom(Set.class)) {
+            values = new HashSet();
+        } else if (getTypeClass().isAssignableFrom(Vector.class)) {
+            values = new Vector();
+        } else if (getTypeClass().isInterface()) {
+            values = new ArrayList();
+        } else {
+            try {
+                values = (Collection<Object>)getTypeClass().newInstance();
+            } catch (Exception e) {
+                throw new DatabindingException("Could not create map implementation: "
+                                               + getTypeClass().getName(), e);
+            }
+        }
+
+        return values;
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) throws DatabindingException {
+        if (object == null) {
+            return;
+        }
+
+        try {
+            Collection list = (Collection)object;
+
+            Type type = getComponentType();
+
+            if (type == null) {
+                throw new DatabindingException("Couldn't find type for " + type.getTypeClass() + ".");
+            }
+
+            for (Iterator itr = list.iterator(); itr.hasNext();) {
+                String ns = null;
+                if (type.isAbstract()) {
+                    ns = getSchemaType().getNamespaceURI();
+                } else {
+                    ns = type.getSchemaType().getNamespaceURI();
+                }
+
+                writeValue(itr.next(), writer, context, type, type.getSchemaType().getLocalPart(), ns);
+            }
+        } catch (IllegalArgumentException e) {
+            throw new DatabindingException("Illegal argument.", e);
+        }
+    }
+
+    @Override
+    public Type getComponentType() {
+        return componentType;
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/CollectionType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java?view=auto&rev=515734
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java Wed Mar  7 12:20:07 2007
@@ -0,0 +1,265 @@
+/**
+ * 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.cxf.aegis.type.collection;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.aegis.Aegis;
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.util.NamespaceHelper;
+import org.apache.cxf.aegis.util.XmlConstants;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+import org.jdom.Attribute;
+import org.jdom.Element;
+
+public class MapType extends Type {
+    private Type keyType;
+    private Type valueType;
+    private QName keyName;
+    private QName valueName;
+    private QName entryName;
+
+    public MapType(QName schemaType, Type keyType, Type valueType) {
+        super();
+
+        this.keyType = keyType;
+        this.valueType = valueType;
+
+        setSchemaType(schemaType);
+        setKeyName(new QName(schemaType.getNamespaceURI(), "key"));
+        setValueName(new QName(schemaType.getNamespaceURI(), "value"));
+        setEntryName(new QName(schemaType.getNamespaceURI(), "entry"));
+    }
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        Map<Object, Object> map = instantiateMap();
+        try {
+            Type keyType = getKeyType();
+            Type valueType = getValueType();
+
+            Object key = null;
+            Object value = null;
+
+            while (reader.hasMoreElementReaders()) {
+                MessageReader entryReader = reader.getNextElementReader();
+
+                if (entryReader.getName().equals(getEntryName())) {
+                    while (entryReader.hasMoreElementReaders()) {
+                        MessageReader evReader = entryReader.getNextElementReader();
+
+                        if (evReader.getName().equals(getKeyName())) {
+                            key = keyType.readObject(evReader, context);
+                        } else if (evReader.getName().equals(getValueName())) {
+                            value = valueType.readObject(evReader, context);
+                        } else {
+                            readToEnd(evReader);
+                        }
+                    }
+
+                    map.put(key, value);
+                } else {
+                    readToEnd(entryReader);
+                }
+            }
+
+            return map;
+        } catch (IllegalArgumentException e) {
+            throw new DatabindingException("Illegal argument.", e);
+        }
+    }
+
+    private void readToEnd(MessageReader childReader) {
+        while (childReader.hasMoreElementReaders()) {
+            readToEnd(childReader.getNextElementReader());
+        }
+    }
+
+    /**
+     * Creates a map instance. If the type class is a <code>Map</code> or
+     * extends the <code>Map</code> interface a <code>HashMap</code> is
+     * created. Otherwise the map classs (i.e. LinkedHashMap) is instantiated
+     * using the default constructor.
+     * 
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    protected Map<Object, Object> instantiateMap() {
+        Map<Object, Object> map = null;
+
+        if (getTypeClass().equals(Map.class)) {
+            map = new HashMap<Object, Object>();
+        } else if (getTypeClass().equals(Hashtable.class)) {
+            map = new Hashtable<Object, Object>();
+        } else if (getTypeClass().isInterface()) {
+            map = new HashMap<Object, Object>();
+        } else {
+            try {
+                map = (Map<Object, Object>)getTypeClass().newInstance();
+            } catch (Exception e) {
+                throw new DatabindingException("Could not create map implementation: "
+                                               + getTypeClass().getName(), e);
+            }
+        }
+
+        return map;
+    }
+
+    @Override
+    public void writeObject(Object object, MessageWriter writer, Context context) throws DatabindingException {
+        if (object == null) {
+            return;
+        }
+
+        try {
+            Map map = (Map)object;
+
+            Type keyType = getKeyType();
+            Type valueType = getValueType();
+
+            for (Iterator itr = map.entrySet().iterator(); itr.hasNext();) {
+                Map.Entry entry = (Map.Entry)itr.next();
+
+                writeEntry(writer, context, keyType, valueType, entry);
+            }
+        } catch (IllegalArgumentException e) {
+            throw new DatabindingException("Illegal argument.", e);
+        }
+    }
+
+    private void writeEntry(MessageWriter writer, Context context, Type keyType, Type valueType,
+                            Map.Entry entry) throws DatabindingException {
+        keyType = Aegis.getWriteType(context, entry.getKey(), keyType);
+        valueType = Aegis.getWriteType(context, entry.getValue(), valueType);
+
+        MessageWriter entryWriter = writer.getElementWriter(getEntryName());
+
+        MessageWriter keyWriter = entryWriter.getElementWriter(getKeyName());
+        keyType.writeObject(entry.getKey(), keyWriter, context);
+        keyWriter.close();
+
+        MessageWriter valueWriter = entryWriter.getElementWriter(getValueName());
+        valueType.writeObject(entry.getValue(), valueWriter, context);
+        valueWriter.close();
+
+        entryWriter.close();
+    }
+
+    @Override
+    public void writeSchema(Element root) {
+        Element complex = new Element("complexType", XmlConstants.XSD_PREFIX, XmlConstants.XSD);
+        complex.setAttribute(new Attribute("name", getSchemaType().getLocalPart()));
+        root.addContent(complex);
+
+        Element seq = new Element("sequence", XmlConstants.XSD_PREFIX, XmlConstants.XSD);
+        complex.addContent(seq);
+
+        Type keyType = getKeyType();
+        Type valueType = getValueType();
+
+        Element element = new Element("element", XmlConstants.XSD_PREFIX, XmlConstants.XSD);
+        seq.addContent(element);
+
+        element.setAttribute(new Attribute("name", getEntryName().getLocalPart()));
+        element.setAttribute(new Attribute("minOccurs", "0"));
+        element.setAttribute(new Attribute("maxOccurs", "unbounded"));
+
+        Element evComplex = new Element("complexType", XmlConstants.XSD_PREFIX, XmlConstants.XSD);
+        element.addContent(evComplex);
+
+        Element evseq = new Element("sequence", XmlConstants.XSD_PREFIX, XmlConstants.XSD);
+        evComplex.addContent(evseq);
+
+        createElement(root, evseq, getKeyName(), keyType);
+        createElement(root, evseq, getValueName(), valueType);
+    }
+
+    /**
+     * Creates a element in a sequence for the key type and the value type.
+     */
+    private void createElement(Element root, Element seq, QName name, Type type) {
+        Element element = new Element("element", XmlConstants.XSD_PREFIX, XmlConstants.XSD);
+        seq.addContent(element);
+
+        String prefix = NamespaceHelper.getUniquePrefix((Element)root, type.getSchemaType()
+            .getNamespaceURI());
+        String typeName = prefix + ":" + type.getSchemaType().getLocalPart();
+
+        element.setAttribute(new Attribute("name", name.getLocalPart()));
+        element.setAttribute(new Attribute("type", typeName));
+
+        element.setAttribute(new Attribute("minOccurs", "0"));
+        element.setAttribute(new Attribute("maxOccurs", "1"));
+    }
+
+    @Override
+    public Set<Type> getDependencies() {
+        HashSet<Type> deps = new HashSet<Type>();
+        deps.add(getKeyType());
+        deps.add(getValueType());
+        return deps;
+    }
+
+    public Type getKeyType() {
+        return keyType;
+    }
+
+    public Type getValueType() {
+        return valueType;
+    }
+
+    @Override
+    public boolean isComplex() {
+        return true;
+    }
+
+    public QName getKeyName() {
+        return keyName;
+    }
+
+    public void setKeyName(QName keyName) {
+        this.keyName = keyName;
+    }
+
+    public QName getValueName() {
+        return valueName;
+    }
+
+    public void setValueName(QName valueName) {
+        this.valueName = valueName;
+    }
+
+    public QName getEntryName() {
+        return entryName;
+    }
+
+    public void setEntryName(QName entryName) {
+        this.entryName = entryName;
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message