KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > woody > binding > SetAttributeJXPathBindingBuilder


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.woody.binding;
17
18 import org.apache.cocoon.woody.util.DomHelper;
19 import org.w3c.dom.Element JavaDoc;
20
21 /**
22  * SetAttributeJXPathBindingBuilder provides a helper class for the Factory
23  * implemented in {@link JXPathBindingManager} that helps construct the
24  * actual {@link SetAttributeJXPathBinding} out of the configuration in the
25  * provided configElement which looks like:
26  * <pre><code>
27  * &lt;wb:set-attribute name="<i>attribute-name to set to</i>"
28  * value="<i>attribute-value</i>"/&gt;
29  * </code></pre>
30  *
31  * @version CVS $Id: SetAttributeJXPathBindingBuilder.java 30932 2004-07-29 17:35:38Z vgritsenko $
32  */

33 public class SetAttributeJXPathBindingBuilder
34     extends JXPathBindingBuilderBase {
35
36
37     /**
38      * Creates an instance of {@link SetAttributeJXPathBinding} according to
39      * the attributes of the provided bindingElm.
40      */

41     public JXPathBindingBase buildBinding(Element JavaDoc bindingElm,
42         JXPathBindingManager.Assistant assistant) throws BindingException {
43
44         try {
45             CommonAttributes commonAtts =
46                 JXPathBindingBuilderBase.getCommonAttributes(bindingElm);
47
48             String JavaDoc attName = DomHelper.getAttribute(bindingElm, "name");
49             String JavaDoc attValue = DomHelper.getAttribute(bindingElm, "value");
50
51             SetAttributeJXPathBinding attBinding =
52                 new SetAttributeJXPathBinding(commonAtts, attName, attValue);
53             return attBinding;
54         } catch (BindingException e) {
55             throw e;
56         } catch (Exception JavaDoc e) {
57             throw new BindingException(
58                     "Error building set-attribute binding defined at " +
59                     DomHelper.getLocation(bindingElm), e);
60         }
61     }
62 }
63
Popular Tags