cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding Binding.java JXPathBindingBase.java JXPathBindingBuilderBase.java AggregateJXPathBinding.java JXPathBindingManager.java
Date Sun, 29 Feb 2004 09:20:56 GMT
antonio     2004/02/29 01:20:56

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/binding
                        Binding.java JXPathBindingBase.java
                        JXPathBindingBuilderBase.java
                        AggregateJXPathBinding.java
                        JXPathBindingManager.java
  Log:
  Formatting code
  
  Revision  Changes    Path
  1.7       +5 -3      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/Binding.java
  
  Index: Binding.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/Binding.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Binding.java	3 Feb 2004 12:22:08 -0000	1.6
  +++ Binding.java	29 Feb 2004 09:20:56 -0000	1.7
  @@ -84,12 +84,14 @@
        * @param frmModel
        * @param objModel
        */
  -    void loadFormFromModel(Widget frmModel, Object objModel) throws BindingException;
  +    void loadFormFromModel(Widget frmModel, Object objModel)
  +            throws BindingException;
   
       /**
        * Saves the infortmation-elements to the objModel from the frmModel.
        * @param frmModel
        * @param objModel
        */
  -    void saveFormToModel(Widget frmModel, Object objModel) throws BindingException;
  +    void saveFormToModel(Widget frmModel, Object objModel)
  +            throws BindingException;
   }
  
  
  
  1.14      +42 -29    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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- JXPathBindingBase.java	6 Feb 2004 16:06:32 -0000	1.13
  +++ JXPathBindingBase.java	29 Feb 2004 09:20:56 -0000	1.14
  @@ -93,7 +93,8 @@
           this(JXPathBindingBuilderBase.CommonAttributes.DEFAULT);
       }
   
  -    protected JXPathBindingBase(JXPathBindingBuilderBase.CommonAttributes commonAtts) {
  +    protected JXPathBindingBase(
  +            JXPathBindingBuilderBase.CommonAttributes commonAtts) {
           this.commonAtts = commonAtts;
       }
   
  @@ -119,34 +120,39 @@
           }
           if (classBinding == null) {
               // Query parent for class
  -            if (parent == null) {
  +            if (parent != null) {
  +                classBinding = parent.getClass(id);
  +                // Cache result
  +                if (classes == null) {
  +                   classes = new HashMap();
  +                }
  +                classes.put(id, classBinding);
  +            } else {
                   // TODO: Improve message to include source location.
                   throw new RuntimeException("Class \"" + id + "\" not found.");
               }
  -            classBinding = parent.getClass(id);
  -            // Cache result
  -            if (classes == null)
  -               classes = new HashMap();
  -            classes.put(id, classBinding);
           }
           return classBinding;
       }
   
       protected Widget getWidget(Widget widget, String id) {
           Widget childWidget = widget.getWidget(id);
  -        if (childWidget == null) {
  -            throw new RuntimeException(getClass().getName() + ": Widget \"" + id +
  -                "\" does not exist in container \"" + widget.getFullyQualifiedId() + "\"
(" +
  -                widget.getLocation() + ").");
  +        if (childWidget != null) {
  +            return childWidget;
  +        } else {
  +            throw new RuntimeException(getClass().getName() + ": Widget \"" +
  +                    id + "\" does not exist in container \"" +
  +                    widget.getFullyQualifiedId() + "\" (" +
  +                    widget.getLocation() + ").");
           }
  -        return childWidget;
       }
   
       /**
        * Performs the actual load binding regardless of the configured value of the "direction"
attribute.
        * Abstract method that subclasses need to implement for specific activity.
        */
  -    public abstract void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException;
  +    public abstract void doLoad(Widget frmModel, JXPathContext jxpc)
  +        throws BindingException;
   
       /**
        * Redefines the Binding action as working on a JXPathContext Type rather
  @@ -154,7 +160,8 @@
        * Executes the actual loading via {@link #doLoad(Widget, JXPathContext)}
        * depending on the configured value of the "direction" attribute.
        */
  -    public final void loadFormFromModel(Widget frmModel, JXPathContext jxpc) throws BindingException
{
  +    public final void loadFormFromModel(Widget frmModel, JXPathContext jxpc)
  +            throws BindingException {
           boolean inheritedLeniency = jxpc.isLenient();
           applyLeniency(jxpc);
           if (this.commonAtts.loadEnabled) {
  @@ -168,20 +175,23 @@
        * it up in a JXPathContext object and then transfering control over to
        * the new overloaded version of this method.
        */
  -    public final void loadFormFromModel(Widget frmModel, Object objModel) throws BindingException
{
  -        if (objModel == null) {
  -            throw new NullPointerException("null object passed to loadFormFromModel() method");
  +    public final void loadFormFromModel(Widget frmModel, Object objModel)
  +            throws BindingException {
  +        if (objModel != null) {
  +            JXPathContext jxpc = makeJXPathContext(objModel);
  +            loadFormFromModel(frmModel, jxpc);
  +        } else {
  +            throw new NullPointerException(
  +                    "null object passed to loadFormFromModel() method");
           }
  -
  -        JXPathContext jxpc = makeJXPathContext(objModel);
  -        loadFormFromModel(frmModel, jxpc);
       }
   
       /**
        * Performs the actual save binding regardless of the configured value of the "direction"
attribute.
        * Abstract method that subclasses need to implement for specific activity.
        */
  -    public abstract void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException;
  +    public abstract void doSave(Widget frmModel, JXPathContext jxpc)
  +            throws BindingException;
   
       /**
        * Redefines the Binding action as working on a JXPathContext Type rather
  @@ -189,7 +199,8 @@
        * Executes the actual saving via {@link #doSave(Widget, JXPathContext)}
        * depending on the configured value of the "direction" attribute.
        */
  -    public final void saveFormToModel(Widget frmModel, JXPathContext jxpc) throws BindingException{
  +    public final void saveFormToModel(Widget frmModel, JXPathContext jxpc)
  +            throws BindingException{
           boolean inheritedLeniency = jxpc.isLenient();
           applyLeniency(jxpc);
           if (this.commonAtts.saveEnabled) {
  @@ -203,13 +214,15 @@
        * it up in a JXPathContext object and then transfering control over to
        * the new overloaded version of this method.
        */
  -    public void saveFormToModel(Widget frmModel, Object objModel) throws BindingException
{
  -        if (objModel == null) {
  -            throw new NullPointerException("null object passed to saveFormToModel() method");
  +    public void saveFormToModel(Widget frmModel, Object objModel)
  +                throws BindingException {
  +        if (objModel != null) {
  +            JXPathContext jxpc = makeJXPathContext(objModel);
  +            saveFormToModel(frmModel, jxpc);    
  +        } else {
  +            throw new NullPointerException(
  +                    "null object passed to saveFormToModel() method");
           }
  -
  -        JXPathContext jxpc = makeJXPathContext(objModel);
  -        saveFormToModel(frmModel, jxpc);
       }
   
       private void applyLeniency(JXPathContext jxpc) {
  
  
  
  1.4       +7 -4      cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXPathBindingBuilderBase.java
  
  Index: JXPathBindingBuilderBase.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/JXPathBindingBuilderBase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JXPathBindingBuilderBase.java	19 Feb 2004 22:13:27 -0000	1.3
  +++ JXPathBindingBuilderBase.java	29 Feb 2004 09:20:56 -0000	1.4
  @@ -76,7 +76,9 @@
        */
       public void enableLogging(Logger logger) {
           this.logger = logger;
  -        logger.debug("JXPathBindingBuilderBase got logger...");
  +        if (logger.isDebugEnabled()) {
  +            logger.debug("JXPathBindingBuilderBase got logger...");
  +        }
       }
   
       /**
  @@ -202,9 +204,10 @@
            * @return null if the leniency parameter is String, otherwise the
            */
           private static Boolean decideLeniency(String leniency) {
  -            if (leniency == null) return null;
  +            if (leniency == null) {
  +                return null;
  +            }
               return new Boolean(leniency);
           }
  -
       }
   }
  
  
  
  1.10      +18 -9     cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/AggregateJXPathBinding.java
  
  Index: AggregateJXPathBinding.java
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/binding/AggregateJXPathBinding.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AggregateJXPathBinding.java	29 Feb 2004 06:07:37 -0000	1.9
  +++ AggregateJXPathBinding.java	29 Feb 2004 09:20:56 -0000	1.10
  @@ -77,7 +77,9 @@
        * @param xpath
        * @param childBindings
        */
  -    public AggregateJXPathBinding(JXPathBindingBuilderBase.CommonAttributes commonAtts,
String widgetId, String xpath, JXPathBindingBase[] childBindings) {
  +    public AggregateJXPathBinding(
  +            JXPathBindingBuilderBase.CommonAttributes commonAtts,
  +            String widgetId, String xpath, JXPathBindingBase[] childBindings) {
           super(commonAtts, childBindings);
           this.widgetId = widgetId;
           this.xpath = xpath;
  @@ -88,9 +90,12 @@
        * narrows the scope on the object-model to the member xpath-context
        * before continuing the binding over the child-bindings.
        */
  -    public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException {
  -        AggregateField aggregate = (AggregateField) frmModel.getWidget(this.widgetId);
  -        JXPathContext subContext = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
  +    public void doLoad(Widget frmModel,
  +            JXPathContext jxpc) throws BindingException {
  +        AggregateField aggregate =
  +            (AggregateField)frmModel.getWidget(this.widgetId);
  +        JXPathContext subContext =
  +            jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
           super.doLoad(aggregate, subContext);
           aggregate.combineFields();
           if (getLogger().isDebugEnabled()) {
  @@ -103,9 +108,12 @@
        * narrows the scope on the object-model to the member xpath-context
        * before continuing the binding over the child-bindings.
        */
  -    public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
  -        AggregateField aggregate = (AggregateField) frmModel.getWidget(this.widgetId);
  -        JXPathContext subContext = jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
  +    public void doSave(Widget frmModel,
  +            JXPathContext jxpc) throws BindingException {
  +        AggregateField aggregate =
  +            (AggregateField) frmModel.getWidget(this.widgetId);
  +        JXPathContext subContext =
  +            jxpc.getRelativeContext(jxpc.getPointer(this.xpath));
           super.doSave(aggregate, subContext);
           if (getLogger().isDebugEnabled()) {
               getLogger().debug("Done saving " + toString());
  @@ -113,6 +121,7 @@
       }
   
       public String toString() {
  -        return "AggregateJXPathBinding [widget=" + this.widgetId + ", xpath=" + this.xpath
+ "]";
  +        return "AggregateJXPathBinding [widget=" + this.widgetId +
  +            ", xpath=" + this.xpath + "]";
       }
   }
  
  
  
  1.20      +81 -56    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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- JXPathBindingManager.java	6 Feb 2004 14:33:05 -0000	1.19
  +++ JXPathBindingManager.java	29 Feb 2004 09:20:56 -0000	1.20
  @@ -1,7 +1,7 @@
   /*
   
    ============================================================================
  -                   The Apache Software License, Version 1.1
  + The Apache Software License, Version 1.1
    ============================================================================
   
    Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  @@ -10,26 +10,26 @@
    tion, are permitted provided that the following conditions are met:
   
    1. Redistributions of  source code must  retain the above copyright  notice,
  -    this list of conditions and the following disclaimer.
  + this list of conditions and the following disclaimer.
   
    2. Redistributions in binary form must reproduce the above copyright notice,
  -    this list of conditions and the following disclaimer in the documentation
  -    and/or other materials provided with the distribution.
  + this list of conditions and the following disclaimer in the documentation
  + and/or other materials provided with the distribution.
   
    3. The end-user documentation included with the redistribution, if any, must
  -    include  the following  acknowledgment:  "This product includes  software
  -    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  -    Alternately, this  acknowledgment may  appear in the software itself,  if
  -    and wherever such third-party acknowledgments normally appear.
  + include  the following  acknowledgment:  "This product includes  software
  + developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  + Alternately, this  acknowledgment may  appear in the software itself,  if
  + and wherever such third-party acknowledgments normally appear.
   
    4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
  -    used to  endorse or promote  products derived from  this software without
  -    prior written permission. For written permission, please contact
  -    apache@apache.org.
  + used to  endorse or promote  products derived from  this software without
  + prior written permission. For written permission, please contact
  + apache@apache.org.
   
    5. Products  derived from this software may not  be called "Apache", nor may
  -    "Apache" appear  in their name,  without prior written permission  of the
  -    Apache Software Foundation.
  + "Apache" appear  in their name,  without prior written permission  of the
  + Apache Software Foundation.
   
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  @@ -47,7 +47,7 @@
    Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
    Software Foundation, please see <http://www.apache.org/>.
   
  -*/
  + */
   package org.apache.cocoon.woody.binding;
   
   import org.apache.avalon.framework.activity.Disposable;
  @@ -70,41 +70,51 @@
   import org.xml.sax.InputSource;
   
   /**
  - * JXPathBindingManager provides an implementation of {@link BindingManager}
  - * by usage of the <a href="http://jakarta.apache.org/commons/jxpath/index.html">
  - * JXPath package</a>.
  - *
  - * @version CVS $Id$
  + * JXPathBindingManager provides an implementation of {@link BindingManager}by
  + * usage of the <a href="http://jakarta.apache.org/commons/jxpath/index.html">
  + * JXPath package </a>.
  + * 
  + * @version CVS $Id: JXPathBindingManager.java,v 1.19 2004/02/06 14:33:05 joerg
  + *               Exp $
    */
  -public class JXPathBindingManager extends AbstractLogEnabled
  -        implements BindingManager, Serviceable, Disposable,
  -                   Initializable, Configurable, ThreadSafe {
  +public class JXPathBindingManager extends AbstractLogEnabled implements
  +        BindingManager, Serviceable, Disposable, Initializable, Configurable,
  +        ThreadSafe {
   
       private static final String PREFIX = "WoodyBinding:";
  +
       private ServiceManager serviceManager;
  +
       private DatatypeManager datatypeManager;
  +
       private Configuration configuration;
  +
       private SimpleServiceSelector bindingBuilderSelector;
  +
       private CacheManager cacheManager;
   
       public void service(ServiceManager serviceManager) throws ServiceException {
           this.serviceManager = serviceManager;
  -        this.datatypeManager = (DatatypeManager)serviceManager.lookup(DatatypeManager.ROLE);
  -        this.cacheManager = (CacheManager)serviceManager.lookup(CacheManager.ROLE);
  +        this.datatypeManager = (DatatypeManager) serviceManager
  +                .lookup(DatatypeManager.ROLE);
  +        this.cacheManager = (CacheManager) serviceManager
  +                .lookup(CacheManager.ROLE);
       }
   
  -    public void configure(Configuration configuration) throws ConfigurationException {
  +    public void configure(Configuration configuration)
  +            throws ConfigurationException {
           this.configuration = configuration;
       }
   
       public void initialize() throws Exception {
  -        bindingBuilderSelector = new SimpleServiceSelector("binding", JXPathBindingBuilderBase.class);
  +        bindingBuilderSelector = new SimpleServiceSelector("binding",
  +                JXPathBindingBuilderBase.class);
           bindingBuilderSelector.enableLogging(getLogger());
           bindingBuilderSelector.configure(configuration.getChild("bindings"));
       }
   
       public Binding createBinding(Source source) throws BindingException {
  -        Binding binding = (Binding)this.cacheManager.get(source, PREFIX);
  +        Binding binding = (Binding) this.cacheManager.get(source, PREFIX);
           if (binding == null) {
               try {
                   InputSource is = new InputSource(source.getInputStream());
  @@ -113,17 +123,26 @@
                   Document doc = DomHelper.parse(is);
                   Element rootElm = doc.getDocumentElement();
                   if (BindingManager.NAMESPACE.equals(rootElm.getNamespaceURI())) {
  -                    binding = getBuilderAssistant().getBindingForConfigurationElement(rootElm);
  -                    ((JXPathBindingBase)binding).enableLogging(getLogger());
  -                    getLogger().debug("Creation of new Binding finished. " + binding);
  +                    binding = getBuilderAssistant()
  +                            .getBindingForConfigurationElement(rootElm);
  +                    ((JXPathBindingBase) binding).enableLogging(getLogger());
  +                    if (getLogger().isDebugEnabled()) {
  +                        getLogger().debug(
  +                                "Creation of new Binding finished. " + binding);
  +                    }
                   } else {
  -                    getLogger().debug("Root Element of said binding file is in wrong namespace.");
  +                    if (getLogger().isDebugEnabled()) {
  +                        getLogger()
  +                                .debug(
  +                                        "Root Element of said binding file is in wrong
namespace.");
  +                    }
                   }
                   this.cacheManager.set(binding, source, PREFIX);
               } catch (BindingException e) {
                   throw e;
               } catch (Exception e) {
  -                throw new BindingException("Error creating binding from " + source.getURI(),
e);
  +                throw new BindingException("Error creating binding from "
  +                        + source.getURI(), e);
               }
           }
           return binding;
  @@ -144,33 +163,40 @@
       /**
        * Assistant Inner class discloses enough features to the created
        * childBindings to recursively
  -     *
  -     * This patterns was chosen to prevent Inversion Of Control between
  -     * this factory and its builder classes (that could be provided by
  -     * third parties.)
  +     * 
  +     * This patterns was chosen to prevent Inversion Of Control between this
  +     * factory and its builder classes (that could be provided by third
  +     * parties.)
        */
  -    /* NOTE: To get access to the logger in this inner class you must not call
  +    /*
  +     * NOTE: To get access to the logger in this inner class you must not call
        * getLogger() as with JDK 1.3 this gives a NoSuchMethod error. You need to
        * implement an explicit access method for the logger in the outer class.
        */
       public class Assistant {
   
  -        private JXPathBindingBuilderBase getBindingBuilder(String bindingType) throws BindingException
{
  +        private JXPathBindingBuilderBase getBindingBuilder(String bindingType)
  +                throws BindingException {
               try {
  -                return (JXPathBindingBuilderBase) bindingBuilderSelector.select(bindingType);
  +                return (JXPathBindingBuilderBase) bindingBuilderSelector
  +                        .select(bindingType);
               } catch (ServiceException e) {
  -                throw new BindingException("Cannot handle binding element with name \""
+ bindingType + "\".", e);
  +                throw new BindingException(
  +                        "Cannot handle binding element with " + "name \""
  +                                + bindingType + "\".", e);
               }
           }
   
           /**
  -         * Creates a {@link Binding} following the specification in the
  +         * Creates a {@link Binding}following the specification in the
            * provided config element.
            */
  -        public JXPathBindingBase getBindingForConfigurationElement(Element configElm) throws
BindingException {
  +        public JXPathBindingBase getBindingForConfigurationElement(
  +                Element configElm) throws BindingException {
               String bindingType = configElm.getLocalName();
               JXPathBindingBuilderBase bindingBuilder = getBindingBuilder(bindingType);
  -            JXPathBindingBase childBinding = bindingBuilder.buildBinding(configElm, this);
  +            JXPathBindingBase childBinding = bindingBuilder.buildBinding(
  +                    configElm, this);
               return childBinding;
           }
   
  @@ -178,21 +204,20 @@
            * Makes an array of childBindings for the child-elements of the
            * provided configuration element.
            */
  -        public JXPathBindingBase[] makeChildBindings(Element parentElement) throws BindingException
{
  -            if (parentElement == null) {
  -                return null;
  -            }
  -
  -            Element[] childElements = DomHelper.getChildElements(parentElement, BindingManager.NAMESPACE);
  -            if (childElements.length > 0) {
  -                JXPathBindingBase[] childBindings = new JXPathBindingBase[childElements.length];
  -                for (int i = 0; i < childElements.length; i++) {
  -                    childBindings[i] = getBindingForConfigurationElement(childElements[i]);
  +        public JXPathBindingBase[] makeChildBindings(Element parentElement)
  +                throws BindingException {
  +            if (parentElement != null) {
  +                Element[] childElements = DomHelper.getChildElements(
  +                        parentElement, BindingManager.NAMESPACE);
  +                if (childElements.length > 0) {
  +                    JXPathBindingBase[] childBindings = new JXPathBindingBase[childElements.length];
  +                    for (int i = 0; i < childElements.length; i++) {
  +                        childBindings[i] = getBindingForConfigurationElement(childElements[i]);
  +                    }
  +                    return childBindings;
                   }
  -                return childBindings;
  -            } else {
  -                return null;
               }
  +            return null;
           }
   
           public DatatypeManager getDatatypeManager() {
  
  
  

Mime
View raw message