Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package org.apache.cxf.binding.corba.runtime;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 
 
 public class CorbaStreamWriter implements XMLStreamWriter {
 
     protected String defaultNS = "";
     protected CorbaTypeListener[] listeners;
     protected ServiceInfo serviceInfo;
     protected CorbaTypeMap typeMap;
     protected ORB orb;
     protected CorbaNamespaceContext ctx = new CorbaNamespaceContext();
 
     private List<ArgTypeparams;
     private int paramCounter;
 
     private Stack<QNameelements = new Stack<QName>();
     private QName paramElement;
     private QName wrapElementName;    
 
     private boolean skipWrap;
     
 
     public CorbaStreamWriter(ORB orbRef,
                              CorbaTypeMap map,
                              ServiceInfo sinfo) {
          = orbRef;
          = map;
          = sinfo;
     }
 
     public CorbaStreamWriter(ORB orbRef,
                              List<ArgTypeparamTypes,
                              CorbaTypeMap map,
                              ServiceInfo sinfo,
                              boolean wrap) {
         this(orbRefmapsinfo);
          = paramTypes;
          = wrap;
          = new CorbaTypeListener[paramTypes.size()];
     }
 
     public CorbaObjectHandler[] getCorbaObjects() {
         //REVISIT, we can make the CorbaTypeListener & CorbaObjectHandler the same object.
         CorbaObjectHandler[] handlers = new CorbaObjectHandler[.];
         for (int i = 0; i < .i++) {
             if ([i] == null) {
                 throw new CorbaBindingException("Uninitalized object for parameter "
                                                 + .get(i).getName());
             }
             handlers[i] = [i].getCorbaObject();
         }
         return handlers;
     }
 
     public void writeStartElement(String namespaceURIString localName)
         throws XMLStreamException {
         writeStartElement(""localNamenamespaceURI);
    }
    public void writeEndElement() throws XMLStreamException {
        if (.empty()) {
             = null;
        } else {
            QName name = .pop();
            if ((name.equals()) || (name.equals())) {
                // let the struct check if all members wer processed
                // it is necessary for empty sequences with minOccurs=0 as last elements of struct
                if ( instanceof CorbaStructListener) {
                    .processEndElement(name);
                }
                 = null;
            } else {
                .processEndElement(name);
            }
        }
        .pop();
    }
    public void writeStartElement(java.lang.String localName)
        throws XMLStreamException {
        writeStartElement(""localName);
    }
    public void writeStartElement(java.lang.String prefix,
                                  java.lang.String localName,
                                  java.lang.String namespaceURI)
        throws XMLStreamException {
        .push();
        if (prefix != null) {
            setPrefix(prefixnamespaceURI);
        }
        QName name = new QName(namespaceURIlocalNameprefix);
        .push(name);
        if (!) {
            if ( == null) {
                 = name;
                setCurrentTypeListener(name);
            } else {
                .processStartElement(name);
            }
        } else {
             = name;
             = false;
        }
    }
    protected void setCurrentTypeListener(QName namethrows XMLStreamException {
        ArgType param = .get();
        QName idlType = param.getIdltype();
        if (! || (name.getLocalPart().equals(param.getName()))) {
             = CorbaHandlerUtils.getTypeListener(nameidlType);
            [] = ;
            ++;
        } else {
            throw new XMLStreamException("Expected element not found: " + param.getName()
                                         + " (Found " + name.getLocalPart() + ")");
        }
    }
    public void writeEmptyElement(java.lang.String namespaceURI,
                                  java.lang.String localName)
        throws XMLStreamException {
        writeStartElement(namespaceURIlocalName);
        writeEndElement();
    }
    public void writeEmptyElement(java.lang.String prefix,
                                  java.lang.String localName,
                                  java.lang.String namespaceURI)
        throws XMLStreamException {
        writeStartElement(namespaceURIlocalNameprefix);
        writeEndElement();
    }
    public void writeEmptyElement(java.lang.String localName)
        throws XMLStreamException {
        writeStartElement(localName);
        writeEndElement();
    }
    
    public void writeEndDocument()
        throws XMLStreamException {
    }
    public void close()
        throws XMLStreamException {
    }
    public void flush()
        throws XMLStreamException {
    }
    public void writeAttribute(java.lang.String localName,
                               java.lang.String value)
        throws XMLStreamException {
        writeAttribute(""localNamevalue);
    }
    public void writeAttribute(java.lang.String prefix,
                               java.lang.String namespaceURI,
                               java.lang.String localName,
                               java.lang.String value)
        throws XMLStreamException {
        .processWriteAttribute(prefixnamespaceURIlocalNamevalue);
    }
    public void writeAttribute(java.lang.String namespaceURI,
                               java.lang.String localName,
                               java.lang.String value)
        throws XMLStreamException {
        writeAttribute(""namespaceURIlocalNamevalue);
    }
    public void writeNamespace(java.lang.String prefix,
                               java.lang.String namespaceURI)
        throws XMLStreamException {
        if ( != null) {
            .processWriteNamespace(prefixnamespaceURI);
        }
        setPrefix(prefixnamespaceURI);
    }
    public void writeDefaultNamespace(java.lang.String namespaceURI)
        throws XMLStreamException {
         = namespaceURI;
    }
    public void writeComment(java.lang.String data)
        throws XMLStreamException {
    }
    public void writeProcessingInstruction(java.lang.String target)
        throws XMLStreamException {
    }
    public void writeProcessingInstruction(java.lang.String target,
                                           java.lang.String data)
        throws XMLStreamException {
    }
    public void writeCData(java.lang.String data)
        throws XMLStreamException {
        throw new XMLStreamException("Not yet implemented");
    }
    public void writeDTD(java.lang.String dtd)
        throws XMLStreamException {
    }
    public void writeEntityRef(java.lang.String name)
        throws XMLStreamException {
        throw new XMLStreamException("Not yet implemented");
    }
    public void writeStartDocument()
        throws XMLStreamException {
    }
    public void writeStartDocument(java.lang.String encoding,
                                   java.lang.String version)
        throws XMLStreamException {
    }
    public void writeStartDocument(java.lang.String version)
        throws XMLStreamException {
    }
    public void writeCharacters(java.lang.String text)
        throws XMLStreamException {
    }
    public void writeCharacters(char[] text,
                                int start,
                                int len)
        throws XMLStreamException {
        .processCharacters(new String(textstartlen));
    }
    public java.lang.String getPrefix(java.lang.String uri)
        throws XMLStreamException {
        return .getPrefix(uri);
    }
    public void setPrefix(java.lang.String prefix,
                          java.lang.String uri)
        throws XMLStreamException {
        .setPrefix(prefixuri);
    }
    public void setDefaultNamespace(java.lang.String uri)
        throws XMLStreamException {
         = uri;
    }
    public void setNamespaceContext(NamespaceContext context)
        throws XMLStreamException {
        //ignore
    }
        return ;
    }
    public java.lang.Object getProperty(java.lang.String name)
        throws java.lang.IllegalArgumentException {
        return null;
    }
    
    
    
    public class CorbaNamespaceContext implements NamespaceContext {
        private Map<StringStringmap;
        private CorbaNamespaceContext parent;
        public CorbaNamespaceContext() {
            this. = new HashMap<StringString>();
        }
        private CorbaNamespaceContext(Map<StringStringmapCorbaNamespaceContext p) {
            this. = map;
            this. = p;
        }
        
        public void push() {
             = new CorbaNamespaceContext();
             = new HashMap<StringString>();
        }
        public void pop() {
            if ( != null) {
                 = .;
                 = .;
            }
        }
        
        public void setPrefix(String pfxString ns) {
            .put(pfxns);
        }
        public String getNamespaceURI(String prefix) {
            String answer = .get(prefix);
            if (answer == null &&  != null) {
                return .getNamespaceURI(prefix);
            }
            return answer;
        }
        public String getPrefix(String namespaceURI) {
            for (Map.Entry<StringStringentry : .entrySet()) {
                if (namespaceURI.equals(entry.getValue())) {
                    return entry.getKey();
                }
            }
            if ( != null) {
                return .getPrefix(namespaceURI);
            }
            return null;
        }
        public Iterator<StringgetPrefixes(String namespaceURI) {
            Set<Stringset = new HashSet<String>();
            for (Map.Entry<StringStringentry : .entrySet()) {
                if (namespaceURI.equals(entry.getValue())) {
                    set.add(entry.getKey());
                }
            }
            if ( != null) {
                Iterator<?> iter = .getPrefixes(namespaceURI);
                while (iter.hasNext()) {
                    set.add((String)iter.next());
                }
            }
            return set.iterator();
        }
    }
    
New to GrepCode? Check out our FAQ X