FileDocCategorySizeDatePackage
PolicyAssertion.javaAPI DocExample11468Tue May 29 16:56:34 BST 2007com.sun.xml.ws.policy

PolicyAssertion

public abstract class PolicyAssertion extends Object
Base class for any policy assertion implementations. It defines the common interface and provides some default implentation of common policy assertion functionality.

Fields Summary
private final com.sun.xml.ws.policy.sourcemodel.AssertionData
data
private AssertionSet
parameters
private NestedPolicy
nestedPolicy
Constructors Summary
protected PolicyAssertion()

        this.data = AssertionData.createAssertionData(null);
    
protected PolicyAssertion(com.sun.xml.ws.policy.sourcemodel.AssertionData assertionData, Collection assertionParameters, AssertionSet nestedAlternative)
Creates generic assertionand stores the data specified in input parameters

param
assertionData assertion creation data specifying the details of newly created assertion
param
assertionParameters collection of assertions parameters of this policy assertion. May be {@code null}.
param
nestedAlternative assertion set specifying nested policy alternative. May be {@code null}.

        this.data = assertionData;
        if (nestedAlternative != null) {
            this.nestedPolicy = NestedPolicy.createNestedPolicy(nestedAlternative);
        }
        
        this.parameters = AssertionSet.createAssertionSet(assertionParameters);
    
Methods Summary
public booleanequals(java.lang.Object obj)
An {@code Object.equals(Object obj)} method override.

        if (this == obj) {
            return true;
        }
        
        if (!(obj instanceof PolicyAssertion)) {
            return false;
        }
        
        final PolicyAssertion that = (PolicyAssertion) obj;
        boolean result = true;
        
        result = result && this.data.equals(that.data);
        result = result && this.parameters.equals(that.parameters);
        result = result && ((this.nestedPolicy == null) ? ((that.nestedPolicy == null) ? true : false) : this.nestedPolicy.equals(that.nestedPolicy));
        
        return result;
    
public final java.lang.StringgetAttributeValue(javax.xml.namespace.QName name)
Returns the value of an attribute. Returns null if an attribute with the given name does not exist.

param
name The fully qualified name of the attribute
return
The value of the attribute. Returns {@code null} if there is no such attribute or if it's value is null.

        return data.getAttributeValue(name);
    
public final java.util.MapgetAttributes()
Returns the disconnected map of attributes attached to the assertion.

'Disconnected' means, that the result of this method will not be synchronized with any consequent assertion's attribute modification. It is also important to notice that a manipulation with returned set of attributes will not have any effect on the actual assertion's attributes.

return
disconnected map of attributes attached to the assertion.

        return data.getAttributes();
    
public final java.util.SetgetAttributesSet()
Returns the disconnected set of attributes attached to the assertion. Each attribute is represented as a single {@code Map.Entry} element.

'Disconnected' means, that the result of this method will not be synchronized with any consequent assertion's attribute modification. It is also important to notice that a manipulation with returned set of attributes will not have any effect on the actual assertion's attributes.

return
disconected set of attributes attached to the assertion.

        return data.getAttributesSet();
    
public final javax.xml.namespace.QNamegetName()
Returns the fully qualified name of the assertion.

return
assertion's fully qualified name.

        return data.getName();
    
public final java.util.IteratorgetNestedAssertionsIterator()
Returns the assertion's parameter collection iterator.

return
the assertion's parameter collection iterator.

        return parameters.iterator();
    
public final NestedPolicygetNestedPolicy()
Returns the nested policy if any.

return
the nested policy if the assertion contains a nested policy. Returns {@code null} otherwise.

        return nestedPolicy;
    
public final java.lang.StringgetValue()
Returns the value of the assertion - the character data content contained in the assertion element representation.

return
assertion's value. May return {@code null} if there is no value set for the assertion.

        return data.getValue();
    
public final booleanhasNestedAssertions()
Returns the boolean information whether this assertion contains any parameters.

return
{@code true} if the assertion contains parameters. Returns {@code false} otherwise.

        return !parameters.isEmpty();
    
public final booleanhasNestedPolicy()
Returns the boolean information whether this assertion contains nested policy.

return
{@code true} if the assertion contains child (nested) policy. Returns {@code false} otherwise.

        return nestedPolicy != null;
    
public inthashCode()
An {@code Object.hashCode()} method override.

        int result = 17;
        
        result = 37 * result + data.hashCode();
        result = 37 * result + ((hasNestedAssertions()) ? 17 : 0);
        result = 37 * result + ((hasNestedPolicy()) ? 17 : 0);
        
        return result;
    
public booleanisOptional()
Method specifies whether the assertion is otpional or not.

This is a default implementation that may be overriden. The method returns {@code true} if the {@code wsp:optional} attribute is present on the assertion and its value is {@code 'true'}. Otherwise the method returns {@code false}.

return
{@code 'true'} if the assertion is optional. Returns {@code false} otherwise.

        boolean result = false;
        final String attributeValue = getAttributeValue(PolicyConstants.OPTIONAL);
        if (attributeValue != null) {
            result = Boolean.parseBoolean(attributeValue);
        }
        
        return result;
    
booleanisParameter()

        return data.getNodeType() == ModelNode.Type.ASSERTION_PARAMETER_NODE;
    
public final booleanisPrivate()
Method specifies whether the assertion is private or not. This is specified by our proprietary visibility element.

return
{@code 'true'} if the assertion is marked as private (i.e. should not be marshalled int generated WSDL documents). Returns {@code false} otherwise.

        return data.isPrivateAttributeSet();
    
public java.lang.StringtoString()
An {@code Object.toString()} method override.

        return toString(0, new StringBuffer()).toString();
    
protected java.lang.StringBuffertoString(int indentLevel, java.lang.StringBuffer buffer)
A helper method that appends indented string representation of this instance to the input string buffer.

param
indentLevel indentation level to be used.
param
buffer buffer to be used for appending string representation of this instance
return
modified buffer containing new string representation of the instance

        final String indent = PolicyUtils.Text.createIndent(indentLevel);
        final String innerIndent = PolicyUtils.Text.createIndent(indentLevel + 1);
        
        buffer.append(indent).append("Assertion {").append(PolicyUtils.Text.NEW_LINE);
        data.toString(indentLevel + 1, buffer);
        buffer.append(PolicyUtils.Text.NEW_LINE);
        
        if (hasNestedAssertions()) {
            buffer.append(innerIndent).append("parameters {").append(PolicyUtils.Text.NEW_LINE);
            for (PolicyAssertion parameter : parameters) {
                parameter.toString(indentLevel + 2, buffer);
            }
            buffer.append(innerIndent).append('}").append(PolicyUtils.Text.NEW_LINE);
        } else {
            buffer.append(innerIndent).append("no parameters").append(PolicyUtils.Text.NEW_LINE);
        }
        
        if (hasNestedPolicy()) {
            nestedPolicy.toString(indentLevel + 1, buffer).append(PolicyUtils.Text.NEW_LINE);
        } else {
            buffer.append(innerIndent).append("no nested policy").append(PolicyUtils.Text.NEW_LINE);
        }
        
        buffer.append(indent).append('}");
        
        return buffer;