01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.jaxws.message.databinding.impl;
20:
21: import org.apache.axiom.om.OMElement;
22: import org.apache.axis2.jaxws.message.databinding.OMBlock;
23: import org.apache.axis2.jaxws.message.factory.BlockFactory;
24: import org.apache.axis2.jaxws.message.impl.BlockImpl;
25:
26: import javax.xml.stream.XMLStreamException;
27: import javax.xml.stream.XMLStreamReader;
28: import javax.xml.stream.XMLStreamWriter;
29: import javax.xml.ws.WebServiceException;
30:
31: /** OMBlockImpl Block with a business object that is an OMElement */
32: public class OMBlockImpl extends BlockImpl implements OMBlock {
33:
34: /**
35: * Called by OMBlockFactory
36: *
37: * @param busObject
38: * @param factory
39: */
40: OMBlockImpl(OMElement busObject, BlockFactory factory) {
41: super (busObject, null, busObject.getQName(), factory);
42: }
43:
44: @Override
45: protected Object _getBOFromReader(XMLStreamReader reader,
46: Object busContext) throws XMLStreamException,
47: WebServiceException {
48: // Take a shortcut and return the OMElement
49: return this .getOMElement();
50: }
51:
52: @Override
53: protected XMLStreamReader _getReaderFromBO(Object busObj,
54: Object busContext) throws XMLStreamException,
55: WebServiceException {
56: OMElement om = (OMElement) busObj;
57: return om.getXMLStreamReader();
58: }
59:
60: @Override
61: protected void _outputFromBO(Object busObject, Object busContext,
62: XMLStreamWriter writer) throws XMLStreamException,
63: WebServiceException {
64: OMElement om = (OMElement) busObject;
65: om.serialize(writer);
66: }
67:
68: public boolean isElementData() {
69: return true;
70: }
71: }
|