View Javadoc

    1   package org.codehaus.xfire.addressing;
    2
    3   import javax.xml.namespace.QName;
    4
    5   import org.codehaus.xfire.util.NamespaceHelper;
    6   import org.codehaus.yom.Element;
    7
    8   public abstract class AbstactAddressingHeadersFactory
    9       implements WSAConstants, AddressingHeadersFactory
    10  {
    11      protected String getChildValue(Element element, String localName, String ns)
    12      {
    13          Element child = element.getFirstChildElement(localName, ns);
    14          if (child == null) return null;
    15
    16          return child.getValue();
    17      }
    18
    19      protected static String qnameToString(Element root, QName qname)
    20      {
    21          String prefix = NamespaceHelper.getUniquePrefix(root, qname.getNamespaceURI());
    22
    23          return prefix + ":" + qname.getLocalPart();
    24      }
    25
    26      protected static QName elementToQName(Element el)
    27      {
    28          String value = el.getValue();
    29
    30          return stringToQName(el, value);
    31      }
    32
    33      protected static QName stringToQName(Element el, String value)
    34      {
    35          int colon = value.indexOf(":");
    36          if (colon > -1)
    37          {
    38              String prefix = value.substring(0, colon);
    39              String local = value.substring(colon+1);
    40              String uri = el.getNamespaceURI(prefix);
    41              return new QName(uri, local, prefix);
    42          }
    43          else
    44          {
    45              String uri = el.getNamespaceURI();
    46              return new QName(value, uri);
    47          }
    48      }
    49  }