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: */package org.apache.cxf.ws.policy.builder.xml;
19:
20: import org.w3c.dom.Element;
21:
22: import org.apache.cxf.ws.policy.PolicyConstants;
23: import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion;
24: import org.apache.neethi.Assertion;
25: import org.apache.neethi.PolicyComponent;
26:
27: /**
28: * XmlPrimitiveAssertion is a primitive implementation of an AssertionBuilder
29: * that simply wraps the underlying xml element.
30: *
31: */
32: public class XmlPrimitiveAssertion extends PrimitiveAssertion {
33:
34: private Element element;
35: private PolicyConstants constants;
36:
37: /**
38: * Constructs a XmlPrimitiveAssertion from an xml element.
39: *
40: * @param e the xml element
41: */
42: public XmlPrimitiveAssertion(Element e, PolicyConstants c) {
43: super (e, c);
44: element = e;
45: constants = c;
46: }
47:
48: /**
49: * Returns the wrapped element.
50: *
51: * @return the wrapped element
52: */
53: public Element getValue() {
54: return element;
55: }
56:
57: /**
58: * Throws an UnsupportedOperationException since an assertion of an unknown
59: * element can't be fully normalized due to it's unknown composite.
60: */
61: public PolicyComponent normalize(boolean isDeep) {
62: throw new UnsupportedOperationException();
63: }
64:
65: protected Assertion cloneMandatory() {
66: Element e = (Element) element.cloneNode(true);
67: if (isOptional()) {
68: e.removeAttributeNode(e.getAttributeNodeNS(constants
69: .getNamespace(), constants.getOptionalAttrName()));
70: }
71: return new XmlPrimitiveAssertion(e, constants);
72: }
73: }
|