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:
20: package org.apache.axis2.policy.model;
21:
22: import org.apache.neethi.Assertion;
23: import org.apache.neethi.Constants;
24: import org.apache.neethi.PolicyComponent;
25:
26: import javax.xml.namespace.QName;
27: import javax.xml.stream.XMLStreamException;
28: import javax.xml.stream.XMLStreamWriter;
29:
30: /** Assertion to pick up the QName <wsoma:OptimizedMimeSerialization xmlns:wsoma="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"/> */
31: public class MTOMAssertion implements Assertion {
32:
33: private boolean isOptional = false;
34:
35: public final static String NS = "http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization";
36:
37: public final static String MTOM_SERIALIZATION_CONFIG_LN = "OptimizedMimeSerialization";
38: public final static String PREFIX = "wsoma";
39:
40: public QName getName() {
41: return new QName(NS, MTOM_SERIALIZATION_CONFIG_LN);
42: }
43:
44: public short getType() {
45: return Constants.TYPE_ASSERTION;
46: }
47:
48: public boolean equal(PolicyComponent policyComponent) {
49: throw new UnsupportedOperationException("TODO");
50: }
51:
52: public boolean isOptional() {
53:
54: return isOptional;
55: }
56:
57: public void setOptional(boolean isOptional) {
58: this .isOptional = isOptional;
59: }
60:
61: public void serialize(XMLStreamWriter writer)
62: throws XMLStreamException {
63: String prefix = writer.getPrefix(NS);
64:
65: if (prefix == null) {
66: prefix = PREFIX;
67: writer.setPrefix(PREFIX, NS);
68: }
69:
70: writer.writeStartElement(PREFIX, MTOM_SERIALIZATION_CONFIG_LN,
71: NS);
72:
73: if (isOptional)
74: writer.writeAttribute("Optional", "true");
75:
76: writer.writeNamespace(PREFIX, NS);
77: writer.writeEndElement();
78:
79: }
80:
81: public PolicyComponent normalize() {
82: throw new UnsupportedOperationException("TODO");
83: }
84:
85: }
|