From: Alex L. <al...@jb...> - 2005-07-31 17:43:09
|
User: aloubyansky Date: 05/07/31 13:42:00 Modified: src/main/org/jboss/xb/binding/sunday/unmarshalling/impl/runtime Tag: Branch_4_0 RtElementHandler.java Log: backport from head: make [Element|Attribute]Binding.get<XXX>MetaData() return metadata taking into account metadata inherited from its type binding Revision Changes Path No revision No revision 1.1.2.7 +29 -54 jboss-common/src/main/org/jboss/xb/binding/sunday/unmarshalling/impl/runtime/RtElementHandler.java (In the diff below, changes in quantity of whitespace are not shown.) Index: RtElementHandler.java =================================================================== RCS file: /cvsroot/jboss/jboss-common/src/main/org/jboss/xb/binding/sunday/unmarshalling/impl/runtime/RtElementHandler.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -b -r1.1.2.6 -r1.1.2.7 --- RtElementHandler.java 25 Jul 2005 16:19:40 -0000 1.1.2.6 +++ RtElementHandler.java 31 Jul 2005 17:42:00 -0000 1.1.2.7 @@ -38,7 +38,7 @@ /** * @author <a href="mailto:al...@jb...">Alexey Loubyansky</a> - * @version <tt>$Revision: 1.1.2.6 $</tt> + * @version <tt>$Revision: 1.1.2.7 $</tt> */ public class RtElementHandler implements ElementHandler @@ -49,7 +49,7 @@ public Object startElement(Object parent, QName elementName, ElementBinding element) { - if(element.isSkip() || element.getType().isSkip()) + if(element.isSkip()) { return parent; } @@ -59,19 +59,7 @@ if(!type.isSimple()) { ClassMetaData classMetaData = element.getClassMetaData(); - MapEntryMetaData mapEntryMetaData = null; - if(classMetaData == null) - { - mapEntryMetaData = element.getMapEntryMetaData(); - if(mapEntryMetaData == null) - { - classMetaData = type.getClassMetaData(); - if(classMetaData == null) - { - mapEntryMetaData = type.getMapEntryMetaData(); - } - } - } + MapEntryMetaData mapEntryMetaData = element.getMapEntryMetaData(); // todo: if addMethod is specified, it's probably some collection field // but should not be set as a property. Instead, items are added to it using the addMethod @@ -318,7 +306,7 @@ public Object endElement(Object o, QName elementName, ElementBinding element) { - if(element.isSkip() || element.getType().isSkip()) + if(element.isSkip()) { return o; } @@ -342,7 +330,7 @@ public void setParent(Object parent, Object o, QName qName, ElementBinding element, ElementBinding parentElement) { - if(element.isSkip() || element.getType().isSkip()) + if(element.isSkip()) { return; } @@ -477,20 +465,16 @@ MapEntryMetaData mapEntryMetaData = element.getMapEntryMetaData(); if(mapEntryMetaData == null) { - mapEntryMetaData = element.getType().getMapEntryMetaData(); - if(mapEntryMetaData == null) - { throw new JBossXBRuntimeException((owner instanceof Map ? "Parent object is an instance of java.util.Map" : "putMethod is specified for element " + qName ) + - " but mapEntry is specified for niether element " + + " but mapEntry is specified for neither element " + qName + " nor it's type " + element.getType().getQName() ); } - } Class oClass = o.getClass(); String getKeyMethodName = mapEntryMetaData.getGetKeyMethod(); @@ -678,11 +662,6 @@ propertyMetaData = element.getType().getPropertyMetaData(); } */ - - if(propertyMetaData == null) - { - addMethodMetaData = element.getType().getAddMethodMetaData(); - } } if(addMethodMetaData != null) @@ -779,7 +758,7 @@ // Private - private void setMapEntryValue(MapEntryMetaData mapEntryMetaData, Object parent, Object o) + private static void setMapEntryValue(MapEntryMetaData mapEntryMetaData, Object parent, Object o) { String getValueMethodName = mapEntryMetaData.getGetValueMethod(); if(getValueMethodName == null) @@ -798,7 +777,7 @@ invokeSetter(setValueMethod, parent, o, setValueMethodName); } - private void invokeSetter(Method setValueMethod, Object parent, Object o, String setValueMethodName) + private static void invokeSetter(Method setValueMethod, Object parent, Object o, String setValueMethodName) { try { @@ -818,7 +797,7 @@ } } - private Method getSetMethod(Class cls, String getMethodName, String setMethodName) + private static Method getSetMethod(Class cls, String getMethodName, String setMethodName) { Method getKeyMethod; try @@ -848,14 +827,11 @@ return setKeyMethod; } - private MapEntryMetaData getMapEntryMetaData(ElementBinding element, QName qName) + private static MapEntryMetaData getMapEntryMetaData(ElementBinding element, QName qName) { MapEntryMetaData mapEntryMetaData = element.getMapEntryMetaData(); if(mapEntryMetaData == null) { - mapEntryMetaData = element.getType().getMapEntryMetaData(); - if(mapEntryMetaData == null) - { throw new JBossXBRuntimeException("Element " + qName + " bound as map entry key or value but map entry metadata is not available for its parent element nor its " + @@ -866,11 +842,10 @@ " type." ); } - } return mapEntryMetaData; } - private Object newInstance(Class cls, QName elementName, TypeBinding type) + private static Object newInstance(Class cls, QName elementName, TypeBinding type) { Object o; try @@ -904,7 +879,7 @@ return o; } - private Class getClass(String className, ElementBinding element, QName elementName) + private static Class getClass(String className, ElementBinding element, QName elementName) { TypeBinding type = element.getType(); String localClassName = className; |