[jboss-svn-commits] JBoss Common SVN: r2695 - in jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder: runtime and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Jan 5 16:21:54 EST 2008


Author: alesj
Date: 2008-01-05 16:21:54 -0500 (Sat, 05 Jan 2008)
New Revision: 2695

Added:
   jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/runtime/ChildMapInterceptor.java
Modified:
   jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
Log:
Adding map entry interceptor.

Modified: jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
===================================================================
--- jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java	2007-12-29 14:51:42 UTC (rev 2694)
+++ jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java	2008-01-05 21:21:54 UTC (rev 2695)
@@ -115,6 +115,7 @@
 import org.jboss.xb.builder.runtime.PropertyInterceptor;
 import org.jboss.xb.builder.runtime.PropertyWildcardHandler;
 import org.jboss.xb.builder.runtime.ValueHandler;
+import org.jboss.xb.builder.runtime.ChildMapInterceptor;
 import org.jboss.xb.spi.BeanAdapterBuilder;
 import org.jboss.xb.spi.BeanAdapterFactory;
 import org.jboss.xb.spi.DefaultBeanAdapterBuilder;
@@ -1558,9 +1559,11 @@
             ParticleBinding particle = new ParticleBinding(elementBinding, child.minOccurs(), child.maxOccurs(), child.unbounded());
             model.addParticle(particle);
 
-            DefaultElementInterceptor interceptor = null;
+            DefaultElementInterceptor interceptor;
             if (typeInfo.isCollection())
                interceptor = ChildCollectionInterceptor.SINGLETON;
+            else if (typeInfo.isMap())
+               interceptor = ChildMapInterceptor.SINGLETON;
             else
                throw new UnsupportedOperationException("TODO");
             typeBinding.pushInterceptor(qName, interceptor);

Added: jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/runtime/ChildMapInterceptor.java
===================================================================
--- jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/runtime/ChildMapInterceptor.java	                        (rev 0)
+++ jbossxb-builder/trunk/src/main/java/org/jboss/xb/builder/runtime/ChildMapInterceptor.java	2008-01-05 21:21:54 UTC (rev 2695)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.xb.builder.runtime;
+
+import java.util.Map;
+import javax.xml.namespace.QName;
+
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+import org.jboss.xb.spi.BeanAdapter;
+
+/**
+ * ChildMapInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ChildMapInterceptor extends DefaultElementInterceptor
+{
+   /** The instance */
+   public static final ChildMapInterceptor SINGLETON = new ChildMapInterceptor();
+
+   @Override
+   @SuppressWarnings("unchecked")
+   public void add(Object parent, Object child, QName qName)
+   {
+      if (child instanceof Map.Entry == false)
+         throw new IllegalArgumentException("Child is not a map entry: " + child + ", parent: " + parent);
+
+      Map.Entry entry = (Map.Entry) child;
+      BeanAdapter beanAdapter = (BeanAdapter) parent;
+      Map map = (Map) beanAdapter.getValue();
+      map.put(entry.getKey(), entry.getValue());
+   }
+}




More information about the jboss-svn-commits mailing list