cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding JXPathBindingBase.java JXPathBindingManager.java ValueJXPathBinding.java ValueJXPathBindingBuilder.java
Date Wed, 29 Oct 2003 14:18:16 GMT
vgritsenko    2003/10/29 06:18:16

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/binding
                        JXPathBindingBase.java JXPathBindingManager.java
                        ValueJXPathBinding.java
                        ValueJXPathBindingBuilder.java
  Log:
  minor tweaks: logging, braces, null objects in dispose()
  
  Revision  Changes    Path
  1.4       +6 -3      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXPathBindingBase.java
  
  Index: JXPathBindingBase.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXPathBindingBase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JXPathBindingBase.java	25 Jul 2003 16:18:22 -0000	1.3
  +++ JXPathBindingBase.java	29 Oct 2003 14:18:16 -0000	1.4
  @@ -80,8 +80,10 @@
        * the new overloaded version of this method.
        */
       public final void loadFormFromModel(Widget frmModel, Object objModel) {
  -        if (objModel == null)
  +        if (objModel == null) {
               throw new NullPointerException("null object passed to loadFormFromModel() method");
  +        }
  +
           JXPathContext jxpc;
           if (!(objModel instanceof JXPathContext)) {
               jxpc = JXPathContext.newContext(objModel);
  @@ -104,8 +106,10 @@
        * the new overloaded version of this method.
        */
       public void saveFormToModel(Widget frmModel, Object objModel) throws BindingException
{
  -        if (objModel == null)
  +        if (objModel == null) {
               throw new NullPointerException("null object passed to saveFormToModel() method");
  +        }
  +
           JXPathContext jxpc;
           if (!(objModel instanceof JXPathContext)) {
               jxpc = JXPathContext.newContext(objModel);
  @@ -127,5 +131,4 @@
       protected Logger getLogger() {
           return logger;
       }
  -
   }
  
  
  
  1.9       +4 -4      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXPathBindingManager.java
  
  Index: JXPathBindingManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXPathBindingManager.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JXPathBindingManager.java	3 Sep 2003 11:51:08 -0000	1.8
  +++ JXPathBindingManager.java	29 Oct 2003 14:18:16 -0000	1.9
  @@ -78,8 +78,8 @@
   
       //TODO caching of the Bindings. 
   
  -    private DatatypeManager datatypeManager;
       private ServiceManager serviceManager;
  +    private DatatypeManager datatypeManager;
       private Configuration configuration;
       private SimpleServiceSelector bindingBuilderSelector;
   
  @@ -104,8 +104,7 @@
               InputSource is = new InputSource(bindSrc.getInputStream());
               is.setSystemId(bindSrc.getURI());
               
  -            Document doc =
  -                DomHelper.parse(is);
  +            Document doc = DomHelper.parse(is);
               Element rootElm = doc.getDocumentElement();
               JXPathBindingBase newBinding = null;
               if (BindingManager.NAMESPACE.equals(rootElm.getNamespaceURI())) {
  @@ -129,7 +128,9 @@
   
       public void dispose() {
           bindingBuilderSelector.dispose();
  +        bindingBuilderSelector = null;
           serviceManager.release(datatypeManager);
  +        datatypeManager = null;
       }
   
       /**
  @@ -191,6 +192,5 @@
           public ServiceManager getServiceManager() {
               return serviceManager;
           }
  -
       }
   }
  
  
  
  1.4       +22 -6     cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/ValueJXPathBinding.java
  
  Index: ValueJXPathBinding.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/ValueJXPathBinding.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ValueJXPathBinding.java	18 Sep 2003 20:14:04 -0000	1.3
  +++ ValueJXPathBinding.java	29 Oct 2003 14:18:16 -0000	1.4
  @@ -148,11 +148,19 @@
               try {
                   Widget widget = frmModel.getWidget(this.fieldId);
                   Object value = widget.getValue();
  -                if (value != null && convertor != null)
  +                if (value != null && convertor != null) {
                       value = convertor.convertToString(value, convertorLocale, null);
  +                }
  +
  +                // FIXME: Remove
  +                // System.out.println("Set lenient to true (was: " + jxpc.isLenient() +
") for " + jxpc);
  +                jxpc.setLenient(true);
  +
                   Object oldValue = jxpc.getValue(this.xpath);
  -                if (getLogger().isDebugEnabled())
  +                if (getLogger().isDebugEnabled()) {
                       getLogger().debug("value= " + value + "-- oldvalue=" + oldValue);
  +                }
  +
                   boolean update = false;
   
                   if ((value == null && oldValue != null) || value != null &&
!value.equals(oldValue)) {
  @@ -166,17 +174,25 @@
                       } catch (JXPathException e) {
                           // if the value has been set to null and the underlying model is
a bean, then
                           // JXPath will not be able to create a relative context
  -                        if (getLogger().isDebugEnabled())
  +                        if (getLogger().isDebugEnabled()) {
                               getLogger().debug("(Ignorable) problem binding field " + widget.getFullyQualifiedId(),
e);
  +                        }
                       }
  -                    if (subContext != null)
  +                    if (subContext != null) {
                           this.updateBinding.saveFormToModel(frmModel, subContext);
  +                    }
  +
                       update = true;
                   }
  -                if (getLogger().isDebugEnabled())
  +
  +                if (getLogger().isDebugEnabled()) {
                       getLogger().debug("done saving " + toString() + " -- value= " + value
+ " -- on-update == " + update);
  +                }
               } catch (Exception e) {
  -                throw new BindingException("Problem binding field " + this.fieldId + "
(parent = \"" + frmModel.getFullyQualifiedId() + "\") to xpath " + this.xpath + " (context
xpath = \"" + jxpc.getContextPointer().asPath() + "\")", e);
  +                throw new BindingException("Problem binding field " + this.fieldId +
  +                                           " (parent = \"" + frmModel.getFullyQualifiedId()
+ "\") to xpath " +
  +                                           this.xpath + " (context xpath = \"" + jxpc.getContextPointer().asPath()
+ "\")",
  +                                           e);
               }
           }
       }
  
  
  
  1.2       +3 -1      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/ValueJXPathBindingBuilder.java
  
  Index: ValueJXPathBindingBuilder.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/ValueJXPathBindingBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ValueJXPathBindingBuilder.java	12 Aug 2003 12:54:45 -0000	1.1
  +++ ValueJXPathBindingBuilder.java	29 Oct 2003 14:18:16 -0000	1.2
  @@ -96,8 +96,10 @@
               if (convertorEl != null) {
                   String datatype = DomHelper.getAttribute(convertorEl, "datatype");
                   String localeStr = convertorEl.getAttribute("datatype");
  -                if (!localeStr.equals(""))
  +                if (!localeStr.equals("")) {
                       convertorLocale = I18nUtils.parseLocale(localeStr);
  +                }
  +
                   convertor = assistant.getDatatypeManager().createConvertor(datatype, convertorEl);
               }
   
  
  
  

Mime
View raw message