Class Utils

  • Direct Known Subclasses:
    Utils

    public class Utils
    extends java.lang.Object
    This class contains static utility methods for the emitter.
    Author:
    Rich Scheuerle (scheu@us.ibm.com), Tom Jordahl (tomj@macromedia.com)
    • Constructor Summary

      Constructors 
      Constructor Description
      Utils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String genQNameAttributeString​(QName qname, java.lang.String prefix)
      Generate an XML prefixed attribute value with a corresponding xmlns declaration for the prefix.
      static java.lang.String genQNameAttributeStringWithLastLocalPart​(QName qname, java.lang.String prefix)  
      static java.lang.String getAttribute​(org.w3c.dom.Node node, java.lang.String attr)
      Given a node, return the value of the given attribute.
      static java.util.Vector getAttributesWithLocalName​(org.w3c.dom.Node node, java.lang.String localName)
      Given a node, return the attributes that have the specified local name.
      static java.util.HashSet getDerivedTypes​(TypeEntry type, SymbolTable symbolTable)
      This method returns a set of all types that are derived from this type via an extension of a complexType
      static java.lang.String getLastLocalPart​(java.lang.String localPart)  
      static QName[] getMemberTypeQNames​(org.w3c.dom.Node node)
      Method getMemberTypeQNames
      protected static java.util.HashSet getNestedTypes​(TypeEntry type, SymbolTable symbolTable, boolean derivedFlag)
      This method returns a set of all the nested types.
      static QName getNodeNameQName​(org.w3c.dom.Node node)
      XML nodes may have a name attribute.
      static QName getNodeQName​(org.w3c.dom.Node node)
      An xml element may have a name.
      static QName getQNameFromPrefixedName​(org.w3c.dom.Node node, java.lang.String prefixedName)
      Convert a prefixed name into a qname
      static java.lang.String getScopedAttribute​(org.w3c.dom.Node node, java.lang.String attr)
      Given a node, return the value of the given attribute.
      static QName getTypeQName​(org.w3c.dom.Node node, BooleanHolder forElement, boolean ignoreMaxOccurs)
      An XML element or attribute node has several ways of identifying the type of the element or attribute: - use the type attribute to reference a complexType/simpleType - use the ref attribute to reference another element, group or attributeGroup - use of an anonymous type (i.e.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • getScopedAttribute

        public static java.lang.String getScopedAttribute​(org.w3c.dom.Node node,
                                                          java.lang.String attr)
        Given a node, return the value of the given attribute. If the attribute does not exist, searching continues through ancestor nodes until found. This method is useful for finding attributes that pertain to a group of contained nodes (i.e. xlmns, xmlns:tns, targetNamespace, name)
        Parameters:
        node -
        attr -
        Returns:
      • getAttribute

        public static java.lang.String getAttribute​(org.w3c.dom.Node node,
                                                    java.lang.String attr)
        Given a node, return the value of the given attribute. Returns null if the attribute is not found
        Parameters:
        node -
        attr -
        Returns:
      • getAttributesWithLocalName

        public static java.util.Vector getAttributesWithLocalName​(org.w3c.dom.Node node,
                                                                  java.lang.String localName)
        Given a node, return the attributes that have the specified local name. Returns null if the attribute is not found
        Parameters:
        node -
        localName -
        Returns:
      • getNodeQName

        public static QName getNodeQName​(org.w3c.dom.Node node)
        An xml element may have a name. For example <.element name="foo" type="b:bar">. has the name "element". This routine gets the full QName of the element.
        Parameters:
        node -
        Returns:
      • getNodeNameQName

        public static QName getNodeNameQName​(org.w3c.dom.Node node)
        XML nodes may have a name attribute. For example <.element name="foo" type="b:bar">. has the name attribute value "foo". This routine gets the QName of the name attribute value.
        Parameters:
        node -
        Returns:
      • getTypeQName

        public static QName getTypeQName​(org.w3c.dom.Node node,
                                         BooleanHolder forElement,
                                         boolean ignoreMaxOccurs)
        An XML element or attribute node has several ways of identifying the type of the element or attribute: - use the type attribute to reference a complexType/simpleType - use the ref attribute to reference another element, group or attributeGroup - use of an anonymous type (i.e. a nested type underneath itself) - a wsdl:part can use the element attribute. - an extension can use the base attribute.

        This routine returns a QName representing this "type". The forElement value is also returned to indicate whether the QName represents an element (i.e. obtained using the ref attribute) or a type.

        Other attributes affect the QName that is returned. If the "minOccurs" and "maxOccurs" are set such that the type is a collection of "types", then an artificial qname is returned to represent the collection.

        Parameters:
        node - of the reference
        forElement - output parameter is set to true if QName is for an element (i.e. ref= or element= attribute was used).
        ignoreMaxOccurs - indicates whether minOccurs/maxOccurs affects the QName
        Returns:
        QName representing the type of this element
      • getMemberTypeQNames

        public static QName[] getMemberTypeQNames​(org.w3c.dom.Node node)
        Method getMemberTypeQNames
        Parameters:
        node -
        Returns:
      • getQNameFromPrefixedName

        public static QName getQNameFromPrefixedName​(org.w3c.dom.Node node,
                                                     java.lang.String prefixedName)
        Convert a prefixed name into a qname
        Parameters:
        node -
        prefixedName -
        Returns:
      • getDerivedTypes

        public static java.util.HashSet getDerivedTypes​(TypeEntry type,
                                                        SymbolTable symbolTable)
        This method returns a set of all types that are derived from this type via an extension of a complexType
        Parameters:
        type -
        symbolTable -
        Returns:
      • getNestedTypes

        protected static java.util.HashSet getNestedTypes​(TypeEntry type,
                                                          SymbolTable symbolTable,
                                                          boolean derivedFlag)
        This method returns a set of all the nested types. Nested types are types declared within this TypeEntry (or descendents) plus any extended types and the extended type nested types The elements of the returned HashSet are Types.
        Parameters:
        type - is the type entry to consider
        symbolTable - is the symbolTable
        derivedFlag - should be set if all dependendent derived types should also be returned.
        Returns:
      • genQNameAttributeString

        public static java.lang.String genQNameAttributeString​(QName qname,
                                                               java.lang.String prefix)
        Generate an XML prefixed attribute value with a corresponding xmlns declaration for the prefix. If there is no namespace, don't prefix the name or emit the xmlns attribute.

        Caller should provide the enclosing quotes.

        Usage: println("name=\"" + genXMLQNameString(qname, "foo") + "\""

        Parameters:
        qname -
        prefix -
        Returns:
      • genQNameAttributeStringWithLastLocalPart

        public static java.lang.String genQNameAttributeStringWithLastLocalPart​(QName qname,
                                                                                java.lang.String prefix)
      • getLastLocalPart

        public static java.lang.String getLastLocalPart​(java.lang.String localPart)