1 25 26 package org.objectweb.jonas_lib.deployment.rules; 27 28 import java.util.StringTokenizer ; 29 30 import javax.xml.namespace.QName ; 31 32 import org.apache.commons.digester.Rule; 33 34 import org.objectweb.jonas_lib.deployment.xml.Qname; 35 36 40 public class QNameRule extends Rule { 41 42 43 56 public void body(String namespace, String name, String text) { 57 58 if (text == null) { 60 throw new IllegalArgumentException ("No QName found in the body of the tag " + name); 61 } 62 63 StringTokenizer st = new StringTokenizer (text, ":"); 65 if (st.countTokens() != 2) { 66 throw new IllegalArgumentException ("QName must be on the form prefix:localpart for element " + name); 67 } 68 String prefix = st.nextToken(); 69 String localPart = st.nextToken(); 70 71 String namespaceURI = digester.findNamespaceURI(prefix); 73 if (namespaceURI == null) { 74 throw new IllegalArgumentException ("No namespace found for the prefix '" + prefix + "' in element " + name); 75 } 76 77 QName qName = new QName (namespaceURI, localPart, prefix); 79 80 Qname qNameObject = (Qname) digester.peek(); 82 qNameObject.setName(name); 83 qNameObject.setQName(qName); 84 85 } 86 } 87 | Popular Tags |