<s> """<STR_LIT>""" <EOL> from muntjac . data . container import IFilter <EOL> class SimpleStringFilter ( IFilter ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , propertyId , filterString , ignoreCase , onlyMatchPrefix ) : <EOL> self . propertyId = propertyId <EOL> if ignoreCase : <EOL> self . filterString = filterString . lower ( ) <EOL> else : <EOL> self . filterString = filterString <EOL> self . ignoreCase = ignoreCase <EOL> self . onlyMatchPrefix = onlyMatchPrefix <EOL> def passesFilter ( self , itemId , item ) : <EOL> p = item . getItemProperty ( self . propertyId ) <EOL> if p is None or str ( p ) is None : <EOL> return False <EOL> value = str ( p ) . lower ( ) if self . ignoreCase else str ( p ) <EOL> if self . onlyMatchPrefix : <EOL> if not value . startswith ( self . filterString ) : <EOL> return False <EOL> else : <EOL> if self . filterString not in value : <EOL> return False <EOL> return True <EOL> def appliesToProperty ( self , propertyId ) : <EOL> return self . propertyId == propertyId <EOL> def __eq__ ( self , obj ) : <EOL> if not isinstance ( obj , SimpleStringFilter ) : <EOL> return False <EOL> if ( self . propertyId != obj . propertyId <EOL> and obj . propertyId is not None <EOL> and obj . propertyId != self . propertyId ) : <EOL> return False <EOL> if ( self . filterString != obj . filterString <EOL> and obj . filterString is not None <EOL> and obj . filterString != self . filterString ) : <EOL> return False <EOL> if self . ignoreCase != obj . ignoreCase : <EOL> return False <EOL> if self . onlyMatchPrefix != obj . onlyMatchPrefix : <EOL> return False <EOL> return True <EOL> def __hash__ ( self ) : <EOL> h1 = hash ( self . propertyId ) if self . propertyId is not None else <NUM_LIT:0> <EOL> h2 = hash ( self . filterString ) if self . filterString is not None else <NUM_LIT:0> <EOL> return h1 ^ h2 <EOL> def getPropertyId ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . propertyId <EOL> def getFilterString ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . filterString <EOL> def isIgnoreCase ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . ignoreCase <EOL> def isOnlyMatchPrefix ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . onlyMatchPrefix </s>
