blob: 9f273ac240c3ddeb0ccc0be34fbdfc63ca467d9f [file] [log] [blame]
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
* Licensed 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.ws.commons.soap.impl.llom;
import org.apache.ws.commons.om.OMElement;
import org.apache.ws.commons.om.OMXMLParserWrapper;
import org.apache.ws.commons.om.impl.OMNodeEx;
import org.apache.ws.commons.om.impl.llom.OMSerializerUtil;
import org.apache.ws.commons.om.impl.llom.serialize.StreamWriterToContentHandlerConverter;
import org.apache.ws.commons.soap.SOAP12Constants;
import org.apache.ws.commons.soap.SOAPFault;
import org.apache.ws.commons.soap.SOAPFaultDetail;
import org.apache.ws.commons.soap.SOAPProcessingException;
import javax.xml.stream.XMLStreamException;
import java.util.Iterator;
public abstract class SOAPFaultDetailImpl extends SOAPElement implements SOAPFaultDetail {
protected SOAPFaultDetailImpl(SOAPFault parent,
boolean extractNamespaceFromParent) throws SOAPProcessingException {
super(parent,
SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME,
extractNamespaceFromParent);
}
protected SOAPFaultDetailImpl(SOAPFault parent,
OMXMLParserWrapper builder) {
super(parent, SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME, builder);
}
public void addDetailEntry(OMElement detailElement) {
this.addChild(detailElement);
}
public Iterator getAllDetailEntries() {
return this.getChildren();
}
protected void serialize(org.apache.ws.commons.om.impl.OMOutputImpl omOutput, boolean cache) throws XMLStreamException {
// select the builder
short builderType = PULL_TYPE_BUILDER; // default is pull type
if (builder != null) {
builderType = this.builder.getBuilderType();
}
if ((builderType == PUSH_TYPE_BUILDER)
&& (builder.getRegisteredContentHandler() == null)) {
builder.registerExternalContentHandler(new StreamWriterToContentHandlerConverter(omOutput));
}
if (!cache) {
//No caching
if (this.firstChild != null) {
OMSerializerUtil.serializeStartpart(this, omOutput);
((OMNodeEx)firstChild).serializeAndConsume(omOutput);
OMSerializerUtil.serializeEndpart(omOutput);
} else if (!this.done) {
if (builderType == PULL_TYPE_BUILDER) {
OMSerializerUtil.serializeByPullStream(this, omOutput);
} else {
OMSerializerUtil.serializeStartpart(this, omOutput);
builder.setCache(cache);
builder.next();
OMSerializerUtil.serializeEndpart(omOutput);
}
} else {
OMSerializerUtil.serializeNormal(this, omOutput, cache);
}
// do not serialise the siblings
} else {
//Cached
OMSerializerUtil.serializeNormal(this, omOutput, cache);
// do not serialise the siblings
}
}
}