~ubuntu-branches/debian/squeeze/axis/squeeze

« back to all changes in this revision

Viewing changes to src/org/apache/axis/message/HeaderBuilder.java

  • Committer: Bazaar Package Importer
  • Author(s): Vladimír Lapáček
  • Date: 2006-09-06 22:31:39 UTC
  • Revision ID: james.westby@ubuntu.com-20060906223139-l7m5edxeositeppl
Tags: upstream-1.4
Import upstream version 1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2001-2004 The Apache Software Foundation.
 
3
 * 
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 * 
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 * 
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
package org.apache.axis.message;
 
18
 
 
19
/**
 
20
 *
 
21
 * @author Glen Daniels (gdaniels@allaire.com)
 
22
 */
 
23
 
 
24
import org.apache.axis.AxisFault;
 
25
import org.apache.axis.Constants;
 
26
import org.apache.axis.components.logger.LogFactory;
 
27
import org.apache.axis.encoding.DeserializationContext;
 
28
import org.apache.axis.soap.SOAPConstants;
 
29
import org.apache.axis.utils.Messages;
 
30
import org.apache.commons.logging.Log;
 
31
import org.xml.sax.Attributes;
 
32
import org.xml.sax.SAXException;
 
33
 
 
34
public class HeaderBuilder extends SOAPHandler
 
35
{
 
36
    protected static Log log =
 
37
        LogFactory.getLog(HeaderBuilder.class.getName());
 
38
 
 
39
    private SOAPHeaderElement header;
 
40
    private SOAPEnvelope envelope;
 
41
 
 
42
    HeaderBuilder(SOAPEnvelope envelope)
 
43
    {
 
44
        this.envelope = envelope;
 
45
    }
 
46
 
 
47
    public void startElement(String namespace, String localName,
 
48
                             String prefix, Attributes attributes,
 
49
                             DeserializationContext context)
 
50
        throws SAXException
 
51
    {
 
52
        SOAPConstants soapConstants = context.getSOAPConstants();
 
53
 
 
54
        if (soapConstants == SOAPConstants.SOAP12_CONSTANTS &&
 
55
            attributes.getValue(Constants.URI_SOAP12_ENV, Constants.ATTR_ENCODING_STYLE) != null) {
 
56
 
 
57
            AxisFault fault = new AxisFault(Constants.FAULT_SOAP12_SENDER,
 
58
                null, Messages.getMessage("noEncodingStyleAttrAppear", "Header"), null, null, null);
 
59
 
 
60
            throw new SAXException(fault);
 
61
        }
 
62
 
 
63
        if (!context.isDoneParsing()) {
 
64
            if (myElement == null) {
 
65
                try {
 
66
                    myElement = new SOAPHeader(namespace, localName, prefix,
 
67
                                               attributes, context,
 
68
                                               envelope.getSOAPConstants());
 
69
                } catch (AxisFault axisFault) {
 
70
                    throw new SAXException(axisFault);
 
71
                }
 
72
                envelope.setHeader((SOAPHeader)myElement);
 
73
            }
 
74
            context.pushNewElement(myElement);
 
75
        }
 
76
    }
 
77
 
 
78
    public SOAPHandler onStartChild(String namespace,
 
79
                                    String localName,
 
80
                                    String prefix,
 
81
                                    Attributes attributes,
 
82
                                    DeserializationContext context)
 
83
        throws SAXException
 
84
    {
 
85
        try {
 
86
            header = new SOAPHeaderElement(namespace, localName, prefix,
 
87
                                           attributes, context);
 
88
        } catch (AxisFault axisFault) {
 
89
            throw new SAXException(axisFault);
 
90
        }
 
91
 
 
92
        SOAPHandler handler = new SOAPHandler();
 
93
        handler.myElement = header;
 
94
 
 
95
        return handler;
 
96
    }
 
97
 
 
98
    public void onEndChild(String namespace, String localName,
 
99
                           DeserializationContext context)
 
100
    {
 
101
    }
 
102
}