1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.neethi;
17
18 import java.util.Iterator;
19 import java.util.List;
20
21 import javax.xml.stream.XMLStreamException;
22 import javax.xml.stream.XMLStreamWriter;
23
24 /**
25 * All is a PolicyOperator that require all its PolicyComponents to be met.
26 */
27 public class All extends AbstractPolicyOperator {
28
29 /**
30 * Adds an assertion to its PolicyComponent list.
31 *
32 * @param assertion the assertion to be added.
33 */
34 public void addAssertion(Assertion assertion) {
35 addPolicyComponent(assertion);
36 }
37
38 /**
39 * Returns a <tt>List</tt> of it's PolicyComponents.
40 *
41 * @return a List of it's PolicyComponents
42 */
43 public List getAssertions() {
44 return policyComponents;
45 }
46
47
48 public void serialize(XMLStreamWriter writer) throws XMLStreamException {
49 String prefix = writer.getPrefix(Constants.URI_POLICY_NS);
50
51 if (prefix == null) {
52 writer.writeStartElement(Constants.ATTR_WSP, Constants.ELEM_ALL, Constants.URI_POLICY_NS);
53 writer.writeNamespace(Constants.ATTR_WSP, Constants.URI_POLICY_NS);
54 writer.setPrefix(Constants.ATTR_WSP, Constants.URI_POLICY_NS);
55 } else {
56 writer.writeStartElement(Constants.URI_POLICY_NS, Constants.ELEM_ALL);
57 }
58
59 PolicyComponent policyComponent;
60
61 for (Iterator iterator = getPolicyComponents().iterator(); iterator
62 .hasNext();) {
63 policyComponent = (PolicyComponent) iterator.next();
64 policyComponent.serialize(writer);
65 }
66
67 writer.writeEndElement();
68 }
69
70 /**
71 * Returns Constants.TYPE_ALL
72 */
73 public short getType() {
74 return Constants.TYPE_ALL;
75 }
76 }