Methods Summary |
---|
private boolean | add(PolicyAssertion assertion)
if (assertion == null) {
return false;
}
if (this.assertions.contains(assertion)) {
return false;
} else {
this.assertions.add(assertion);
this.vocabulary.add(assertion.getName());
return true;
}
|
private boolean | addAll(java.util.Collection assertions)
boolean result = true;
if (assertions != null) {
for (PolicyAssertion assertion : assertions) {
result &= add(assertion); // this is here to ensure that vocabulary is built correctly as well
}
}
return result;
|
public int | compareTo(com.sun.xml.ws.policy.AssertionSet that)An {@code Comparable.compareTo(T o)} interface method implementation.
if (this.equals(that)) {
return 0;
}
// comparing vocabularies
final Iterator<QName> vIterator1 = this.getVocabulary().iterator();
final Iterator<QName> vIterator2 = that.getVocabulary().iterator();
while (vIterator1.hasNext()) {
final QName entry1 = vIterator1.next();
if (vIterator2.hasNext()) {
final QName entry2 = vIterator2.next();
final int result = PolicyUtils.Comparison.QNAME_COMPARATOR.compare(entry1, entry2);
if (result != 0) {
return result;
}
} else {
return 1; // we have more entries in this vocabulary
}
}
if (vIterator2.hasNext()) {
return -1; // we have more entries in that vocabulary
}
// vocabularies are equal => comparing assertions
final Iterator<PolicyAssertion> pIterator1 = this.getAssertions().iterator();
final Iterator<PolicyAssertion> pIterator2 = that.getAssertions().iterator();
while (pIterator1.hasNext()) {
final PolicyAssertion pa1 = pIterator1.next();
if (pIterator2.hasNext()) {
final PolicyAssertion pa2 = pIterator2.next();
final int result = ASSERTION_COMPARATOR.compare(pa1, pa2);
if (result != 0) {
return result;
}
} else {
return 1; // we have more entries in this assertion set
}
}
if (pIterator2.hasNext()) {
return -1; // we have more entries in that assertion set
}
// seems like objects are very simmilar although not equal => we must not return 0 otherwise the TreeSet
// holding this element would discard the newly added element. Thus we return that the first argument is
// greater than second (just because it is first...)
return 1;
|
public boolean | contains(javax.xml.namespace.QName assertionName)Returns true if the assertion set contains the assertion name specified in its vocabulary
return vocabulary.contains(assertionName);
|
public static com.sun.xml.ws.policy.AssertionSet | createAssertionSet(java.util.Collection assertions)Creates and returns new assertion set holding a set of provided policy assertions.
if (assertions == null || assertions.isEmpty()) {
return EMPTY_ASSERTION_SET;
}
final AssertionSet result = new AssertionSet(new LinkedList<PolicyAssertion>());
result.addAll(assertions);
Collections.sort(result.assertions, ASSERTION_COMPARATOR);
return result;
|
public static com.sun.xml.ws.policy.AssertionSet | createMergedAssertionSet(java.util.Collection alternatives)Creates and returns new assertion set holding content of all provided policy assertion sets.
This method should not be used to perform a merge of general Policy instances. A client should be aware of the
method's result meaning and the difference between merge of Policy instances and merge of AssertionSet instances.
if (alternatives == null || alternatives.isEmpty()) {
return EMPTY_ASSERTION_SET;
}
final AssertionSet result = new AssertionSet(alternatives);
Collections.sort(result.assertions, ASSERTION_COMPARATOR);
return result;
|
public static com.sun.xml.ws.policy.AssertionSet | emptyAssertionSet()
return EMPTY_ASSERTION_SET;
|
public boolean | equals(java.lang.Object obj)An {@code Object.equals(Object obj)} method override.
if (this == obj) {
return true;
}
if (!(obj instanceof AssertionSet)) {
return false;
}
final AssertionSet that = (AssertionSet) obj;
boolean result = true;
result = result && this.vocabulary.equals(that.vocabulary);
result = result && this.assertions.size() == that.assertions.size() && this.assertions.containsAll(that.assertions);
return result;
|
public java.util.Collection | get(javax.xml.namespace.QName name)Searches for assertions with given name. Only assertions that are contained as immediate children of the assertion set are
searched, i.e. nested policies are not searched.
final List<PolicyAssertion> matched = new LinkedList<PolicyAssertion>();
if (vocabulary.contains(name)) {
// we iterate the assertion set only if we are sure we contain such assertion name in our vocabulary
for (PolicyAssertion assertion : assertions) {
if (assertion.getName().equals(name)) {
matched.add(assertion);
}
}
}
return matched;
|
java.util.Collection | getAssertions()Return all assertions contained in this assertion set.
return assertions;
|
java.util.Collection | getVocabulary()Retrieves the vocabulary of this policy expression. The vocabulary is represented by an immutable collection of
unique QName objects. Each of those objects represents single assertion type contained in the assertion set.
return immutableVocabulary;
|
public int | hashCode()An {@code Object.hashCode()} method override.
int result = 17;
result = 37 * result + vocabulary.hashCode();
result = 37 * result + assertions.hashCode();
return result;
|
boolean | isCompatibleWith(com.sun.xml.ws.policy.AssertionSet alternative)Checks whether this policy alternative is compatible with the provided policy alternative.
return this.vocabulary.equals(alternative.vocabulary);
|
public boolean | isEmpty()Returns {@code true} if this assertion set contains no assertions.
return assertions.isEmpty();
|
public java.util.Iterator | iterator()Returns an iterator over a set of child policy assertion objects.
return this.assertions.iterator();
|
public java.lang.String | toString()An {@code Object.toString()} method override.
return toString(0, new StringBuffer()).toString();
|
java.lang.StringBuffer | toString(int indentLevel, java.lang.StringBuffer buffer)A helper method that appends indented string representation of this instance to the input string buffer.
final String indent = PolicyUtils.Text.createIndent(indentLevel);
final String innerIndent = PolicyUtils.Text.createIndent(indentLevel + 1);
buffer.append(indent).append("assertion set {").append(PolicyUtils.Text.NEW_LINE);
if (assertions.isEmpty()) {
buffer.append(innerIndent).append("no assertions").append(PolicyUtils.Text.NEW_LINE);
} else {
for (PolicyAssertion assertion : assertions) {
assertion.toString(indentLevel + 1, buffer).append(PolicyUtils.Text.NEW_LINE);
}
}
buffer.append(indent).append('}");
return buffer;
|