FileDocCategorySizeDatePackage
PolicyNodeImpl.javaAPI DocAndroid 1.5 API8737Wed May 06 22:41:06 BST 2009org.apache.harmony.security.tests.support.cert

PolicyNodeImpl

public class PolicyNodeImpl extends Object implements PolicyNode

Fields Summary
private static final String
ANY_POLICY
private PolicyNodeImpl
mParent
private HashSet
mChildren
private String
mValidPolicy
private HashSet
mQualifierSet
private boolean
mCriticalityIndicator
private HashSet
mExpectedPolicySet
private boolean
mOriginalExpectedPolicySet
private int
mDepth
private boolean
isImmutable
Constructors Summary
public PolicyNodeImpl(PolicyNodeImpl policynodeimpl, String s, Set set, boolean flag, Set set1, boolean flag1)


           
                         
        isImmutable = false;
        mParent = policynodeimpl;
        mChildren = new HashSet();
        if(s != null) {
            mValidPolicy = s;
        } else {
            mValidPolicy = "";
        }
        if(set != null) {
            mQualifierSet = new HashSet(set);
        } else {
            mQualifierSet = new HashSet();
        }
        mCriticalityIndicator = flag;
        if(set1 != null) {
            mExpectedPolicySet = new HashSet(set1);
        } else {
            mExpectedPolicySet = new HashSet();
        }
        mOriginalExpectedPolicySet = !flag1;
        if(mParent != null) {
            mDepth = mParent.getDepth() + 1;
            mParent.addChild(this);
        } else {
            mDepth = 0;
        }
    
PolicyNodeImpl(PolicyNodeImpl policynodeimpl, PolicyNodeImpl policynodeimpl1)

        this(policynodeimpl, policynodeimpl1.mValidPolicy, ((Set) (policynodeimpl1.mQualifierSet)), policynodeimpl1.mCriticalityIndicator, ((Set) (policynodeimpl1.mExpectedPolicySet)), false);
    
Methods Summary
private voidaddChild(org.apache.harmony.security.tests.support.cert.PolicyNodeImpl policynodeimpl)

        if(isImmutable) {
            throw new IllegalStateException("PolicyNode is immutable");
        } else {
            mChildren.add(policynodeimpl);
            return;
        }
    
voidaddExpectedPolicy(java.lang.String s)

        if(isImmutable)
            throw new IllegalStateException("PolicyNode is immutable");
        if(mOriginalExpectedPolicySet) {
            mExpectedPolicySet.clear();
            mOriginalExpectedPolicySet = false;
        }
        mExpectedPolicySet.add(s);
    
java.lang.StringasString()

        if(mParent == null)
            return "anyPolicy  ROOT\n";
        StringBuffer stringbuffer = new StringBuffer();
        int i = 0;
        for(int j = getDepth(); i < j; i++)
            stringbuffer.append("  ");

        stringbuffer.append(policyToString(getValidPolicy()));
        stringbuffer.append("  CRIT: ");
        stringbuffer.append(isCritical());
        stringbuffer.append("  EP: ");
        for(Iterator iterator = getExpectedPolicies().iterator(); iterator.hasNext(); stringbuffer.append(" ")) {
            String s = (String)iterator.next();
            stringbuffer.append(policyToString(s));
        }

        stringbuffer.append(" (");
        stringbuffer.append(getDepth());
        stringbuffer.append(")\n");
        return stringbuffer.toString();
    
org.apache.harmony.security.tests.support.cert.PolicyNodeImplcopyTree()

        return copyTree(null);
    
private org.apache.harmony.security.tests.support.cert.PolicyNodeImplcopyTree(org.apache.harmony.security.tests.support.cert.PolicyNodeImpl policynodeimpl)

        PolicyNodeImpl policynodeimpl1 = new PolicyNodeImpl(policynodeimpl, this);
        PolicyNodeImpl policynodeimpl2;
        for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl2.copyTree(policynodeimpl1))
            policynodeimpl2 = (PolicyNodeImpl)iterator.next();

        return policynodeimpl1;
    
voiddeleteChild(java.security.cert.PolicyNode policynode)

        if(isImmutable) {
            throw new IllegalStateException("PolicyNode is immutable");
        } else {
            mChildren.remove(policynode);
            return;
        }
    
public java.util.IteratorgetChildren()

        return Collections.unmodifiableSet(mChildren).iterator();
    
public intgetDepth()

        return mDepth;
    
public java.util.SetgetExpectedPolicies()

        return Collections.unmodifiableSet(mExpectedPolicySet);
    
public java.security.cert.PolicyNodegetParent()

        return mParent;
    
java.util.SetgetPolicyNodes(int i)

        HashSet hashset = new HashSet();
        getPolicyNodes(i, ((Set) (hashset)));
        return hashset;
    
private voidgetPolicyNodes(int i, java.util.Set set)

        if(mDepth == i) {
            set.add(this);
        } else {
            PolicyNodeImpl policynodeimpl;
            for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl.getPolicyNodes(i, set))
                policynodeimpl = (PolicyNodeImpl)iterator.next();
        }
    
java.util.SetgetPolicyNodesExpected(int i, java.lang.String s, boolean flag)

        if(s.equals("2.5.29.32.0"))
            return getPolicyNodes(i);
        else
            return getPolicyNodesExpectedHelper(i, s, flag);
    
private java.util.SetgetPolicyNodesExpectedHelper(int i, java.lang.String s, boolean flag)

        HashSet hashset = new HashSet();
        if(mDepth < i) {
            PolicyNodeImpl policynodeimpl;
            for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); hashset.addAll(policynodeimpl.getPolicyNodesExpectedHelper(i, s, flag)))
                policynodeimpl = (PolicyNodeImpl)iterator.next();

        } else if(flag) {
            if(mExpectedPolicySet.contains("2.5.29.32.0"))
                hashset.add(this);
        } else if(mExpectedPolicySet.contains(s)) {
            hashset.add(this);
        }
        return hashset;
    
java.util.SetgetPolicyNodesValid(int i, java.lang.String s)

        HashSet hashset = new HashSet();
        if(mDepth < i) {
            PolicyNodeImpl policynodeimpl;
            for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); hashset.addAll(policynodeimpl.getPolicyNodesValid(i, s)))
                policynodeimpl = (PolicyNodeImpl)iterator.next();

        } else if(mValidPolicy.equals(s)) {
            hashset.add(this);
        }
        return hashset;
    
public java.util.SetgetPolicyQualifiers()

        return Collections.unmodifiableSet(mQualifierSet);
    
public java.lang.StringgetValidPolicy()

        return mValidPolicy;
    
public booleanisCritical()

        return mCriticalityIndicator;
    
booleanisImmutable()

        return isImmutable;
    
private static java.lang.StringpolicyToString(java.lang.String s)

        if(s.equals("2.5.29.32.0")) {
            return "anyPolicy";
        } else {
            return s;
        }
    
voidprune(int i)

        if(isImmutable)
            throw new IllegalStateException("PolicyNode is immutable");
        if(mChildren.size() == 0)
            return;
        Iterator iterator = mChildren.iterator();
        do {
            if(!iterator.hasNext())  break;
            PolicyNodeImpl policynodeimpl = (PolicyNodeImpl)iterator.next();
            policynodeimpl.prune(i);
            if(policynodeimpl.mChildren.size() == 0 && i > mDepth + 1)
                iterator.remove();
        } while(true);
    
voidsetImmutable()

        if(isImmutable)  return;
        PolicyNodeImpl policynodeimpl;
        for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl.setImmutable())
            policynodeimpl = (PolicyNodeImpl)iterator.next();

        isImmutable = true;
    
public java.lang.StringtoString()

        StringBuffer stringbuffer = new StringBuffer(asString());
        for(Iterator iterator = getChildren(); iterator.hasNext(); stringbuffer.append((PolicyNodeImpl)iterator.next()));
        return stringbuffer.toString();