protected ContentFilterRule(String ruleText){
  super(ruleText);
  parentSearchLevel=DEFAULT_PARENT_SEARCH_LEVEL;
  int contentRuleMarkIndex=StringUtils.indexOf(ruleText,MASK_CONTENT_RULE);
  int ruleStartIndex=StringUtils.indexOf(ruleText,ATTRIBUTE_START_MARK);
  if (ruleStartIndex == -1) {
    tagName=ruleText.substring(contentRuleMarkIndex + MASK_CONTENT_RULE.length());
  }
 else {
    tagName=ruleText.substring(contentRuleMarkIndex + MASK_CONTENT_RULE.length(),ruleStartIndex);
  }
  if (contentRuleMarkIndex > 0) {
    String domains=ruleText.substring(0,contentRuleMarkIndex);
    loadDomains(domains);
  }
  while (ruleStartIndex != -1) {
    int equalityIndex=ruleText.indexOf(EQUAL,ruleStartIndex + 1);
    int quoteStartIndex=ruleText.indexOf(QUOTES,equalityIndex + 1);
    int quoteEndIndex=getQuoteIndex(ruleText,quoteStartIndex + 1);
    if (quoteStartIndex == -1 || quoteEndIndex == -1) {
      break;
    }
    int ruleEndIndex=ruleText.indexOf(ATTRIBUTE_END_MARK,quoteEndIndex + 1);
    String attributeName=ruleText.substring(ruleStartIndex + 1,equalityIndex);
    String attributeValue=ruleText.substring(quoteStartIndex + 1,quoteEndIndex);
    attributeValue=StringUtils.replace(attributeValue,"\"\"","\"");
switch (attributeName) {
case TAG_CONTENT_MASK:
      tagContentFilter=attributeValue;
    break;
case WILDCARD_MASK:
  wildcard=new Wildcard(attributeValue,Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
break;
case TAG_CONTENT_MAX_LENGTH:
maxLength=NumberUtils.toInt(attributeValue);
break;
case TAG_CONTENT_MIN_LENGTH:
minLength=NumberUtils.toInt(attributeValue);
break;
case PARENT_ELEMENTS:
parentElements=Arrays.asList(StringUtils.split(attributeValue,','));
break;
case PARENT_SEARCH_LEVEL:
parentSearchLevel=NumberUtils.toInt(attributeValue);
break;
default :
attributesFilter.put(attributeName,attributeValue);
break;
}
if (ruleEndIndex == -1) break;
ruleStartIndex=ruleText.indexOf(ATTRIBUTE_START_MARK,ruleEndIndex + 1);
}
}

protected ContentFilterRule ( String ruleText ) { super ( ruleText ) ; parentSearchLevel = DEFAULT_PARENT_SEARCH_LEVEL ; int contentRuleMarkIndex = StringUtils . indexOf ( ruleText , MASK_CONTENT_RULE ) ; int ruleStartIndex = StringUtils . indexOf ( ruleText , ATTRIBUTE_START_MARK ) ; if ( ruleStartIndex == - 1 ) { tagName = ruleText . substring ( contentRuleMarkIndex + MASK_CONTENT_RULE . length ( ) ) ; } else { tagName = ruleText . substring ( contentRuleMarkIndex + MASK_CONTENT_RULE . length ( ) , ruleStartIndex ) ; } if ( contentRuleMarkIndex > 0 ) { String domains = ruleText . substring ( 0 , contentRuleMarkIndex ) ; loadDomains ( domains ) ; } while ( ruleStartIndex != - 1 ) { int equalityIndex = ruleText . indexOf ( EQUAL , ruleStartIndex + 1 ) ; int quoteStartIndex = ruleText . indexOf ( QUOTES , equalityIndex + 1 ) ; int quoteEndIndex = getQuoteIndex ( ruleText , quoteStartIndex + 1 ) ; if ( quoteStartIndex == - 1 || quoteEndIndex == - 1 ) { break ; } int ruleEndIndex = ruleText . indexOf ( ATTRIBUTE_END_MARK , quoteEndIndex + 1 ) ; String attributeName = ruleText . substring ( ruleStartIndex + 1 , equalityIndex ) ; String attributeValue = ruleText . substring ( quoteStartIndex + 1 , quoteEndIndex ) ; attributeValue = StringUtils . replace ( attributeValue , "\"\"" , "\"" ) ; switch ( attributeName ) { case TAG_CONTENT_MASK : tagContentFilter = attributeValue ; break ; case WILDCARD_MASK : wildcard = new Wildcard ( attributeValue , Pattern . DOTALL | Pattern . CASE_INSENSITIVE ) ; break ; case TAG_CONTENT_MAX_LENGTH : maxLength = NumberUtils . toInt ( attributeValue ) ; break ; case TAG_CONTENT_MIN_LENGTH : minLength = NumberUtils . toInt ( attributeValue ) ; break ; case PARENT_ELEMENTS : parentElements = Arrays . asList ( StringUtils . split ( attributeValue , ',' ) ) ; break ; case PARENT_SEARCH_LEVEL : parentSearchLevel = NumberUtils . toInt ( attributeValue ) ; break ; default : attributesFilter . put ( attributeName , attributeValue ) ; break ; } if ( ruleEndIndex == - 1 ) break ; ruleStartIndex = ruleText . indexOf ( ATTRIBUTE_START_MARK , ruleEndIndex + 1 ) ; } }
creates an instance of the contentfilterrule from its text format
