KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > forms > binding > ExpandJXPathBindingBuilder


1 /*
2  * Copyright 2005 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.forms.binding;
17
18 import org.apache.cocoon.forms.binding.JXPathBindingManager.Assistant;
19 import org.apache.cocoon.forms.binding.library.Library;
20 import org.apache.cocoon.forms.binding.library.LibraryException;
21 import org.apache.cocoon.forms.util.DomHelper;
22 import org.w3c.dom.Element JavaDoc;
23
24 /**
25  * @version $Id: ExpandJXPathBindingBuilder.java 289538 2005-09-16 13:46:22Z sylvain $
26  */

27 public class ExpandJXPathBindingBuilder extends JXPathBindingBuilderBase {
28
29     /* (non-Javadoc)
30      * @see org.apache.cocoon.forms.binding.JXPathBindingBuilderBase#buildBinding(org.w3c.dom.Element, org.apache.cocoon.forms.binding.JXPathBindingManager.Assistant)
31      */

32     public JXPathBindingBase buildBinding(Element JavaDoc bindingElm,
33             Assistant assistant) throws BindingException {
34
35         Library lib = assistant.getContext().getLocalLibrary();
36         
37         String JavaDoc id = DomHelper.getAttribute(bindingElm, "id", null);
38         
39         if(id == null)
40             throw new BindingException("Attribute id is required! (at "+DomHelper.getLocation(bindingElm)+")");
41         
42         try {
43             return (JXPathBindingBase)lib.getBinding(id);
44         } catch(LibraryException e) {
45             throw new BindingException("Could not expand binding from library! (at "+DomHelper.getLocation(bindingElm)+")",e);
46         }
47     }
48 }
49
Popular Tags