⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messageelement.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    /**     * Returns a duplicate of this node, i.e., serves as a generic copy     * constructor for nodes. The duplicate node has no parent; (     * <code>parentNode</code> is <code>null</code>.).     * <br>Cloning an <code>Element</code> copies all attributes and their     * values, including those generated by the XML processor to represent     * defaulted attributes, but this method does not copy any text it     * contains unless it is a deep clone, since the text is contained in a     * child <code>Text</code> node. Cloning an <code>Attribute</code>     * directly, as opposed to be cloned as part of an <code>Element</code>     * cloning operation, returns a specified attribute (     * <code>specified</code> is <code>true</code>). Cloning any other type     * of node simply returns a copy of this node.     * <br>Note that cloning an immutable subtree results in a mutable copy,     * but the children of an <code>EntityReference</code> clone are readonly     * . In addition, clones of unspecified <code>Attr</code> nodes are     * specified. And, cloning <code>Document</code>,     * <code>DocumentType</code>, <code>Entity</code>, and     * <code>Notation</code> nodes is implementation dependent.     *     * @param deep If <code>true</code>, recursively clone the subtree under     *             the specified node; if <code>false</code>, clone only the node     *             itself (and its attributes, if it is an <code>Element</code>).     * @return The duplicate node.     */    public Node cloneNode(boolean deep) {        try{            MessageElement clonedSelf = (MessageElement) cloning();            if(deep){                if(children != null){                    for(int i =0; i < children.size(); i++){                        NodeImpl child = (NodeImpl)children.get(i);                        if(child != null) {  // why child can be null?                            NodeImpl clonedChild = (NodeImpl)child.cloneNode(deep); // deep == true                            clonedChild.setParent(clonedSelf);                            clonedChild.setOwnerDocument(getOwnerDocument());                                                        clonedSelf.childDeepCloned( child, clonedChild );                        }                    }                }            }            return clonedSelf;        }        catch(Exception e){            return null;        }    }    // Called when a child is cloned from cloneNode().    //    // This is used by sub-classes to update internal state when specific elements    // are cloned.    protected void childDeepCloned( NodeImpl oldNode, NodeImpl newNode )    {    }    /**     *  protected clone method (not public)     *     *  copied status     *  -------------------     *  protected String    name ;             Y     *  protected String    prefix ;           Y     *  protected String    namespaceURI ;     Y     *  protected transient Attributes attributes  Y     *  protected String    id;               Y?     *  protected String    href;             Y?     *  protected boolean   _isRoot = true;   Y?     *  protected SOAPEnvelope message = null; N?     *  protected transient DeserializationContext context;  Y?     *  protected transient QName typeQName = null;          Y?     *  protected Vector qNameAttrs = null;                  Y?     *  protected transient SAX2EventRecorder recorder = null; N?     *  protected int startEventIndex = 0;                   N?     *  protected int startContentsIndex = 0;                N?     *  protected int endEventIndex = -1;                    N?     *  protected CharacterData textRep = null;             Y?     *  protected MessageElement parent = null;             N     *  public ArrayList namespaces = null;                 Y     *  protected String encodingStyle = null;              N?     *   private Object objectValue = null;                 N?     *     * @return     * @throws CloneNotSupportedException     */    protected Object cloning() throws CloneNotSupportedException    {        try{            MessageElement clonedME = null;            clonedME = (MessageElement)this.clone();            clonedME.setName(name);            clonedME.setNamespaceURI(namespaceURI);            clonedME.setPrefix(prefix);            // new AttributesImpl will copy all data not set referencing only            clonedME.setAllAttributes(new AttributesImpl(attributes));            //       clonedME.addNamespaceDeclaration((namespaces.clone()); // cannot do this. since we cannot access the namepace arraylist            clonedME.namespaces = new ArrayList();            if(namespaces != null){                for(int i = 0; i < namespaces.size(); i++){                    //     jeus.util.Logger.directLog( " Debug :  namspace.size() = " + namespaces.size());                    Mapping namespace = (Mapping)namespaces.get(i);                    clonedME.addNamespaceDeclaration(namespace.getPrefix(), namespace.getNamespaceURI()); // why exception here!!                }            }            clonedME.children = new ArrayList();            // clear parents relationship to old parent            clonedME.parent = null;            // clonedME.setObjectValue(objectValue); // how to copy this???            clonedME.setDirty(this._isDirty);            if(encodingStyle != null){                clonedME.setEncodingStyle(encodingStyle);            }            return clonedME;        }catch(Exception ex){            return null;        }    }    /**     * set all the attributes of this instance     * @param attrs a new attributes list     */    public void setAllAttributes(Attributes attrs){        attributes = attrs;    }    /**     * remove all children.     */    public void detachAllChildren()    {        removeContents();    }    /**     * Obtain an Attributes collection consisting of all attributes     * for this MessageElement, including namespace declarations.     *     * @return Attributes collection     */    public Attributes getCompleteAttributes() {        if (namespaces == null) {            return attributes;        }        AttributesImpl attrs = null;        if (attributes == NullAttributes.singleton) {            attrs = new AttributesImpl();        } else {            attrs = new AttributesImpl(attributes);        }        for (Iterator iterator = namespaces.iterator(); iterator.hasNext();) {            Mapping mapping = (Mapping) iterator.next();            String prefix = mapping.getPrefix();            String nsURI = mapping.getNamespaceURI();            attrs.addAttribute(Constants.NS_URI_XMLNS, prefix,                               "xmlns:" + prefix, nsURI, "CDATA");        }        return attrs;    }    /**     * get the local name of this element     * @return name     */    public String getName() {        return name;    }    /**     * set the local part of this element's name     * @param name     */    public void setName(String name) {        this.name = name;    }    /**     * get the fully qualified name of this element     * @return a QName describing the name of thsi element     */    public QName getQName() {        return new QName(namespaceURI, name);    }    /**     * set the name and namespace of this element     * @param qName qualified name     */    public void setQName(QName qName) {        this.name = qName.getLocalPart();        this.namespaceURI = qName.getNamespaceURI();    }    /**     * set the namespace URI of the element     * @param nsURI new namespace URI     */    public void setNamespaceURI(String nsURI) {        namespaceURI = nsURI;    }    /**     * get the element's type.     * If we are a reference, we look up our target in the context and     * return (and cache) its type.     * @return     */    public QName getType() {        // Try to get the type from our target if we're a reference...        if (typeQName == null && href != null && context != null) {            MessageElement referent = context.getElementByID(href);            if (referent != null) {                typeQName = referent.getType();            }        }        return typeQName;    }    /**     * set the element's type     * @param qname     */    public void setType(QName qname) {        typeQName = qname;    }    /**     * get the event recorder     * @return recorder or null     */    public SAX2EventRecorder getRecorder() {        return recorder;    }    /**     * set the event recorder     * @param rec     */    public void setRecorder(SAX2EventRecorder rec) {        recorder = rec;    }    /**     * Get the encoding style.  If ours is null, walk up the hierarchy     * and use our parent's.  Default if we're the root is "".     *     * @return the currently in-scope encoding style     */    public String getEncodingStyle() {        if (encodingStyle == null) {            if (parent == null) {                return "";            }            return ((MessageElement) parent).getEncodingStyle();        }        return encodingStyle;    }    /**     * remove all chidlren.     * All SOAPExceptions which can get thrown in this process are ignored.     */    public void removeContents() {        // unlink        if (children != null) {            for (int i = 0; i < children.size(); i++) {                try {                    ((NodeImpl) children.get(i)).setParent(null);                } catch (SOAPException e) {                    log.debug("ignoring", e);                }            }            // empty the collection            children.clear();            setDirty();        }    }    /**     * get an iterator over visible prefixes. This includes all declared in     * parent elements     * @return an iterator.     */    public Iterator getVisibleNamespacePrefixes() {        Vector prefixes = new Vector();        // Add all parents namespace definitions        if(parent !=null){            Iterator parentsPrefixes = ((MessageElement)parent).getVisibleNamespacePrefixes();            if(parentsPrefixes != null){                while(parentsPrefixes.hasNext()){                    prefixes.add(parentsPrefixes.next());                }            }        }        Iterator mine = getNamespacePrefixes();        if(mine != null){            while(mine.hasNext()){                prefixes.add(mine.next());            }        }        return prefixes.iterator();    }    /**     * Sets the encoding style for this <CODE>SOAPElement</CODE>     * object to one specified. The semantics of a null value,     * as above in getEncodingStyle() are to just use the parent's value,     * but null here means set to "".     *     * @param   encodingStyle a <CODE>String</CODE>     *     giving the encoding style     * @throws  java.lang.IllegalArgumentException  if     *     there was a problem in the encoding style being set.     * @see #getEncodingStyle() getEncodingStyle()     */    public void setEncodingStyle(String encodingStyle) throws SOAPException {        if (encodingStyle == null) {            encodingStyle = "";        }        this.encodingStyle = encodingStyle;        // Wherever we set the encoding style, map the SOAP-ENC prefix        // just for fun (if it's a known style)        if (encodingStyle.equals(Constants.URI_SOAP11_ENC)) {            addMapping(enc11Mapping);        } else if (encodingStyle.equals(Constants.URI_SOAP12_ENC)) {            addMapping(enc12Mapping);        }    }    /**     * Note that this method will log a error and no-op if there is     * a value (set using setObjectValue) in the MessageElement.     */    public void addChild(MessageElement el) throws SOAPException    {        if (objectValue != null) {            IllegalStateException exc =                new IllegalStateException(Messages.getMessage("valuePresent"));            log.error(Messages.getMessage("valuePresent"), exc);            throw exc;        }        initializeChildren();        children.add(el);        el.parent = this;    }    /**     * get a list of children     * @return a list, or null if there are no children     */    public List getChildren()    {        return children;    }    /**     * set the index point of our content's starting in the     * event recording     * @param index index value of the first event of our recorder.     */    public void setContentsIndex(int index)    {        startContentsIndex = index;    }    /**     * set a new namespace mapping list     * @param namespaces     */    public void setNSMappings(ArrayList namespaces)    {        this.namespaces = namespaces;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -