<s> package org . eclipse . jdt . internal . compiler . env ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . core . compiler . IProblem ; public class AccessRuleSet { private AccessRule [ ] accessRules ; public byte classpathEntryType ; public String classpathEntryName ; public AccessRuleSet ( AccessRule [ ] accessRules , byte classpathEntryType , String classpathEntryName ) { this . accessRules = accessRules ; this . classpathEntryType = classpathEntryType ; this . classpathEntryName = classpathEntryName ; } public boolean equals ( Object object ) { if ( this == object ) return true ; if ( ! ( object instanceof AccessRuleSet ) ) return false ; AccessRuleSet otherRuleSet = ( AccessRuleSet ) object ; if ( this . classpathEntryType != otherRuleSet . classpathEntryType || this . classpathEntryName == null && otherRuleSet . classpathEntryName != null || ! this . classpathEntryName . equals ( otherRuleSet . classpathEntryName ) ) { return false ; } int rulesLength = this . accessRules . length ; if ( rulesLength != otherRuleSet . accessRules . length ) return false ; for ( int i = 0 ; i < rulesLength ; i ++ ) if ( ! this . accessRules [ i ] . equals ( otherRuleSet . accessRules [ i ] ) ) return false ; return true ; } public AccessRule [ ] getAccessRules ( ) { return this . accessRules ; } public AccessRestriction getViolatedRestriction ( char [ ] targetTypeFilePath ) { for ( int i = 0 , length = this . accessRules . length ; i < length ; i ++ ) { AccessRule accessRule = this . accessRules [ i ] ; if ( CharOperation . pathMatch ( accessRule . pattern , targetTypeFilePath , true , '/' ) ) { switch ( accessRule . getProblemId ( ) ) { case IProblem . ForbiddenReference : case IProblem . DiscouragedReference : return new AccessRestriction ( accessRule , this . classpathEntryType , this . classpathEntryName ) ; default : return null ; } } } return null ; } public int hashCode ( ) { final int prime = 31 ; int result = 1 ; result = prime * result + hashCode ( this . accessRules ) ; result = prime * result + ( ( this . classpathEntryName == null ) ? 0 : this . classpathEntryName . hashCode ( ) ) ; result = prime * result + this . classpathEntryType ; return result ; } private int hashCode ( AccessRule [ ] rules ) { final int prime = 31 ; if ( rules == null ) return 0 ; int result = 1 ; for ( int i = 0 , length = rules . length ; i < length ; i ++ ) { result = prime * result + ( rules [ i ] == null ? 0 : rules [ i ] . hashCode ( ) ) ; } return result ; } public String toString ( ) { return toString ( true ) ; } public String toString ( boolean wrap ) { StringBuffer buffer = new StringBuffer ( 200 ) ; buffer . append ( "" ) ; if ( wrap ) buffer . append ( '\n' ) ; for ( int i = 0 , length = this . accessRules . length ; i < length ; i ++ ) { if ( wrap ) buffer . append ( '\t' ) ; AccessRule accessRule = this . accessRules [ i ] ; buffer . append ( accessRule ) ; if ( wrap ) buffer . append ( '\n' ) ; else if ( i < length - 1 ) buffer . append ( ", " ) ; } buffer . append ( "" ) ; buffer . append ( this . classpathEntryName ) ; buffer . append ( "]" ) ; return buffer . toString ( ) ; } } </s>