Вы находитесь на странице: 1из 7

Case3:10-cv-03561-WHA Document36-10 Filed10/27/10 Page1 of 7

Exhibit J
Case3:10-cv-03561-WHA Document36-10 Filed10/27/10 Page2 of 7
Comparison of Java (J2SE 1.5) and Android versions of PolicyNodeImpl.java

PolicyNodeImpl.java (Java version) PolicyNodeImpl.java (Android version)


[comments removed and spacing adjusted for comparison] [spacing adjusted for comparison]
final class PolicyNodeImpl implements PolicyNode { public class PolicyNodeImpl implements PolicyNode {

private static final String ANY_POLICY = "2.5.29.32.0"; private static final String ANY_POLICY = "2.5.29.32.0";
private PolicyNodeImpl mParent; private PolicyNodeImpl mParent;
private HashSet mChildren; private HashSet mChildren;
private String mValidPolicy; private String mValidPolicy;
private HashSet mQualifierSet; private HashSet mQualifierSet;
private boolean mCriticalityIndicator; private boolean mCriticalityIndicator;
private HashSet mExpectedPolicySet; private HashSet mExpectedPolicySet;
private boolean mOriginalExpectedPolicySet; private boolean mOriginalExpectedPolicySet;
private int mDepth; private int mDepth;
private boolean isImmutable = false; private boolean isImmutable;

PolicyNodeImpl(PolicyNodeImpl parent, String validPolicy, public PolicyNodeImpl(PolicyNodeImpl policynodeimpl, String s,


Set qualifierSet,boolean criticalityIndicator, Set set, boolean flag,
Set expectedPolicySet,boolean generatedByPolicyMapping) { Set set1, boolean flag1) {
isImmutable = false;
mParent = parent; mParent = policynodeimpl;
mChildren = new HashSet(); mChildren = new HashSet();
if (validPolicy != null) if(s != null) {
mValidPolicy = validPolicy; mValidPolicy = s;
else } else {
mValidPolicy = ""; mValidPolicy = "";
}
if (qualifierSet != null) if(set != null) {
mQualifierSet = new HashSet(qualifierSet); mQualifierSet = new HashSet(set);
else } else {
mQualifierSet = new HashSet(); mQualifierSet = new HashSet();
}
mCriticalityIndicator = criticalityIndicator; mCriticalityIndicator = flag;
if (expectedPolicySet != null) if(set1 != null) {
mExpectedPolicySet = new HashSet(expectedPolicySet); mExpectedPolicySet = new HashSet(set1);
else } else {
mExpectedPolicySet = new HashSet(); mExpectedPolicySet = new HashSet();
}
mOriginalExpectedPolicySet = !generatedByPolicyMapping; mOriginalExpectedPolicySet = !flag1;
if (mParent != null) { if(mParent != null) {
mDepth = mParent.getDepth() + 1; mDepth = mParent.getDepth() + 1;
mParent.addChild(this); mParent.addChild(this);
} else { } else {
mDepth = 0; mDepth = 0;
} }
} }

pa-1425347
Case3:10-cv-03561-WHA Document36-10 Filed10/27/10 Page3 of 7
Comparison of Java (J2SE 1.5) and Android versions of PolicyNodeImpl.java

PolicyNodeImpl.java (Java version) PolicyNodeImpl.java (Android version)


[comments removed and spacing adjusted for comparison] [spacing adjusted for comparison]
PolicyNodeImpl(PolicyNodeImpl parent, PolicyNodeImpl(PolicyNodeImpl policynodeimpl,
PolicyNodeImpl node) { PolicyNodeImpl policynodeimpl1) {
this(parent, node.mValidPolicy, node.mQualifierSet, this(policynodeimpl, policynodeimpl1.mValidPolicy, ((Set)
node.mCriticalityIndicator, node.mExpectedPolicySet, false); (policynodeimpl1.mQualifierSet)), policynodeimpl1.mCriticalityIndicator,
} ((Set) (policynodeimpl1.mExpectedPolicySet)), false);
}

public PolicyNode getParent() { public PolicyNode getParent() {


return mParent; return mParent;
} }
public Iterator<PolicyNodeImpl> getChildren() { public Iterator getChildren() {
return Collections.unmodifiableSet(mChildren).iterator(); return Collections.unmodifiableSet(mChildren).iterator();
} }

public int getDepth() { public int getDepth() {


return mDepth; return mDepth;
} }

public String getValidPolicy() { public String getValidPolicy() {


return mValidPolicy; return mValidPolicy;
} }
public Set<PolicyQualifierInfo> getPolicyQualifiers() { public Set getPolicyQualifiers() {
return Collections.unmodifiableSet(mQualifierSet); return Collections.unmodifiableSet(mQualifierSet);
} }

public Set<String> getExpectedPolicies() { public Set getExpectedPolicies() {


return Collections.unmodifiableSet(mExpectedPolicySet); return Collections.unmodifiableSet(mExpectedPolicySet);
} }

public boolean isCritical() { public boolean isCritical() {


return mCriticalityIndicator; return mCriticalityIndicator;
} }

public String toString() { public String toString() {


StringBuffer buffer = new StringBuffer(this.asString()); StringBuffer stringbuffer = new StringBuffer(asString());
Iterator it = getChildren(); for(Iterator iterator = getChildren(); iterator.hasNext();
while (it.hasNext()) { stringbuffer.append((PolicyNodeImpl)iterator.next()));
buffer.append((PolicyNodeImpl)it.next());
} return stringbuffer.toString();
return buffer.toString(); }
}

pa-1425347
Case3:10-cv-03561-WHA Document36-10 Filed10/27/10 Page4 of 7
Comparison of Java (J2SE 1.5) and Android versions of PolicyNodeImpl.java

PolicyNodeImpl.java (Java version) PolicyNodeImpl.java (Android version)


[comments removed and spacing adjusted for comparison] [spacing adjusted for comparison]
boolean isImmutable() { boolean isImmutable() {
return isImmutable; return isImmutable;
} }

void setImmutable() { void setImmutable() {


if (isImmutable) if(isImmutable) return;
return; PolicyNodeImpl policynodeimpl;
Iterator it = mChildren.iterator(); for(Iterator iterator = mChildren.iterator(); iterator.hasNext();
while (it.hasNext()) { policynodeimpl.setImmutable())
PolicyNodeImpl node = (PolicyNodeImpl) it.next(); policynodeimpl = (PolicyNodeImpl)iterator.next();
node.setImmutable();
} isImmutable = true;
isImmutable = true; }
}

private void addChild(PolicyNodeImpl child) { private void addChild(PolicyNodeImpl policynodeimpl) {


if (isImmutable) { if(isImmutable) {
throw new IllegalStateException("PolicyNode is immutable"); throw new IllegalStateException("PolicyNode is immutable");
} } else {
mChildren.add(child); mChildren.add(policynodeimpl);
} return;
}
}

void addExpectedPolicy(String expectedPolicy) { void addExpectedPolicy(String s) {


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

void prune(int depth) { void prune(int i) {


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

pa-1425347
Case3:10-cv-03561-WHA Document36-10 Filed10/27/10 Page5 of 7
Comparison of Java (J2SE 1.5) and Android versions of PolicyNodeImpl.java

PolicyNodeImpl.java (Java version) PolicyNodeImpl.java (Android version)


[comments removed and spacing adjusted for comparison] [spacing adjusted for comparison]
void deleteChild(PolicyNode childNode) { void deleteChild(PolicyNode policynode) {
if (isImmutable) { if(isImmutable) {
throw new IllegalStateException("PolicyNode is immutable"); throw new IllegalStateException("PolicyNode is immutable");
} } else {
mChildren.remove(childNode); mChildren.remove(policynode);
} return;
}
}

PolicyNodeImpl copyTree() { PolicyNodeImpl copyTree() {


return copyTree(null); return copyTree(null);
} }

private PolicyNodeImpl copyTree(PolicyNodeImpl parent) { private PolicyNodeImpl copyTree(PolicyNodeImpl policynodeimpl) {


PolicyNodeImpl newNode = new PolicyNodeImpl(parent, this); PolicyNodeImpl policynodeimpl1 = new PolicyNodeImpl(policynodeimpl,
this);
Iterator it = mChildren.iterator(); PolicyNodeImpl policynodeimpl2;
while (it.hasNext()) { for(Iterator iterator = mChildren.iterator(); iterator.hasNext();
PolicyNodeImpl node = (PolicyNodeImpl) it.next(); policynodeimpl2.copyTree(policynodeimpl1))
node.copyTree(newNode); policynodeimpl2 = (PolicyNodeImpl)iterator.next();
}
return policynodeimpl1;
return newNode; }
}

Set getPolicyNodes(int depth) { Set getPolicyNodes(int i) {


Set set = new HashSet(); HashSet hashset = new HashSet();
getPolicyNodes(depth, set); getPolicyNodes(i, ((Set) (hashset)));
return set; return hashset;
} }

private void getPolicyNodes(int depth, Set set) { private void getPolicyNodes(int i, Set set) {
if (mDepth == depth) { if(mDepth == i) {
set.add(this); set.add(this);
} else { } else {
Iterator it = mChildren.iterator(); PolicyNodeImpl policynodeimpl;
while (it.hasNext()) { for(Iterator iterator = mChildren.iterator();
PolicyNodeImpl node = (PolicyNodeImpl) it.next(); iterator.hasNext(); policynodeimpl.getPolicyNodes(i, set))
node.getPolicyNodes(depth, set); policynodeimpl = (PolicyNodeImpl)iterator.next();
} }
} }
}

pa-1425347
Case3:10-cv-03561-WHA Document36-10 Filed10/27/10 Page6 of 7
Comparison of Java (J2SE 1.5) and Android versions of PolicyNodeImpl.java

PolicyNodeImpl.java (Java version) PolicyNodeImpl.java (Android version)


[comments removed and spacing adjusted for comparison] [spacing adjusted for comparison]
Set getPolicyNodesExpected(int depth, String expectedOID, boolean Set getPolicyNodesExpected(int i, String s, boolean flag) {
matchAny)
{
if (expectedOID.equals(ANY_POLICY)) { if(s.equals("2.5.29.32.0"))
return getPolicyNodes(depth); return getPolicyNodes(i);
} else { else
return getPolicyNodesExpectedHelper(depth, expectedOID, return getPolicyNodesExpectedHelper(i, s, flag);
matchAny); }
}
}
private Set getPolicyNodesExpectedHelper(int depth, String expectedOID, private Set getPolicyNodesExpectedHelper(int i, String s, boolean flag)
boolean matchAny)
{ {
HashSet set = new HashSet(); HashSet hashset = new HashSet();

if (mDepth < depth) { if(mDepth < i) {


Iterator it = mChildren.iterator(); PolicyNodeImpl policynodeimpl;
while (it.hasNext()) { for(Iterator iterator = mChildren.iterator();
PolicyNodeImpl node = (PolicyNodeImpl) it.next(); iterator.hasNext();
set.addAll(node.getPolicyNodesExpectedHelper(depth, hashset.addAll(policynodeimpl.getPolicyNodesExpectedHelper(i, s, flag)))
expectedOID, policynodeimpl = (PolicyNodeImpl)iterator.next();
matchAny));
}
} else { } else if(flag) {
if (matchAny) {
if (mExpectedPolicySet.contains(ANY_POLICY)) if(mExpectedPolicySet.contains("2.5.29.32.0"))
set.add(this); hashset.add(this);
} else { } else if(mExpectedPolicySet.contains(s)) {
if (mExpectedPolicySet.contains(expectedOID))
set.add(this); hashset.add(this);
} }
}

return set; return hashset;


} }

Set getPolicyNodesValid(int depth, String validOID) { Set getPolicyNodesValid(int i, String s) {


HashSet set = new HashSet(); HashSet hashset = new HashSet();
if (mDepth < depth) { if(mDepth < i) {
Iterator it = mChildren.iterator(); PolicyNodeImpl policynodeimpl;
while (it.hasNext()) { for(Iterator iterator = mChildren.iterator();
PolicyNodeImpl node = (PolicyNodeImpl) it.next(); iterator.hasNext(); hashset.addAll(policynodeimpl.getPolicyNodesValid(i,
set.addAll(node.getPolicyNodesValid(depth, validOID)); s)))
} policynodeimpl = (PolicyNodeImpl)iterator.next();
} else {
if (mValidPolicy.equals(validOID)) } else if(mValidPolicy.equals(s)) {
set.add(this); hashset.add(this);
} }
return set; return hashset;
} }

pa-1425347
Case3:10-cv-03561-WHA Document36-10 Filed10/27/10 Page7 of 7
Comparison of Java (J2SE 1.5) and Android versions of PolicyNodeImpl.java

PolicyNodeImpl.java (Java version) PolicyNodeImpl.java (Android version)


[comments removed and spacing adjusted for comparison] [spacing adjusted for comparison]
private static String policyToString(String oid) { private static String policyToString(String s) {
if (oid.equals(ANY_POLICY)) { if(s.equals("2.5.29.32.0")) {
return "anyPolicy"; return "anyPolicy";
} else { } else {
return oid; return s;
} }
} }

String asString() { String asString() {


if (mParent == null) { if(mParent == null)
return "anyPolicy ROOT\n"; return "anyPolicy ROOT\n";
} else {
StringBuffer sb = new StringBuffer(); StringBuffer stringbuffer = new StringBuffer();
for (int i = 0, n = getDepth(); i < n; i++) { int i = 0;
sb.append(" "); for(int j = getDepth(); i < j; i++)
} stringbuffer.append(" ");
sb.append(policyToString(getValidPolicy())); stringbuffer.append(policyToString(getValidPolicy()));
sb.append(" CRIT: "); stringbuffer.append(" CRIT: ");
sb.append(isCritical()); stringbuffer.append(isCritical());
sb.append(" EP: "); stringbuffer.append(" EP: ");
for (Iterator t = getExpectedPolicies().iterator(); t.hasNext(); for(Iterator iterator = getExpectedPolicies().iterator();
) { iterator.hasNext(); stringbuffer.append(" ")) {
String policy = (String)t.next();
sb.append(policyToString(policy)); String s = (String)iterator.next();
sb.append(" "); stringbuffer.append(policyToString(s));
} }
sb.append(" ("); stringbuffer.append(" (");
sb.append(getDepth()); stringbuffer.append(getDepth());
sb.append(")\n"); stringbuffer.append(")\n");
return sb.toString(); return stringbuffer.toString();
} }
} }
}

pa-1425347

Вам также может понравиться