private List<String> matches(String value,String valueToFound,int start,boolean attr){
  int pos=value.indexOf(valueToFound,start);
  if (pos >= 0) {
    List<String> result=new ArrayList<String>();
    if (valueToFound.length() < 3 && (value.length() != valueToFound.length() - start)) {
      result.add(value);
      return result;
    }
    String firstPart=null;
    if (pos > 0) {
      firstPart=value.substring(0,pos);
    }
    String secondPart=value.substring(pos,pos + valueToFound.length());
    String thirdPart=null;
    if (pos + valueToFound.length() < value.length()) {
      thirdPart=value.substring(pos + valueToFound.length());
    }
    if (firstPart != null && !firstPart.isEmpty()) {
      if (attr) {
        result.addAll(compactAttributeValue(firstPart,start));
      }
 else {
        result.addAll(compactExtension(firstPart,start));
      }
    }
    result.add(secondPart);
    if (thirdPart != null && !thirdPart.isEmpty()) {
      if (attr) {
        result.addAll(compactAttributeValue(thirdPart,0));
      }
 else {
        result.addAll(compactExtension(thirdPart,0));
      }
    }
    return result;
  }
 else {
    return null;
  }
}

private List < String > matches ( String value , String valueToFound , int start , boolean attr ) { int pos = value . indexOf ( valueToFound , start ) ; if ( pos >= 0 ) { List < String > result = new ArrayList < String > ( ) ; if ( valueToFound . length ( ) < 3 && ( value . length ( ) != valueToFound . length ( ) - start ) ) { result . add ( value ) ; return result ; } String firstPart = null ; if ( pos > 0 ) { firstPart = value . substring ( 0 , pos ) ; } String secondPart = value . substring ( pos , pos + valueToFound . length ( ) ) ; String thirdPart = null ; if ( pos + valueToFound . length ( ) < value . length ( ) ) { thirdPart = value . substring ( pos + valueToFound . length ( ) ) ; } if ( firstPart != null && ! firstPart . isEmpty ( ) ) { if ( attr ) { result . addAll ( compactAttributeValue ( firstPart , start ) ) ; } else { result . addAll ( compactExtension ( firstPart , start ) ) ; } } result . add ( secondPart ) ; if ( thirdPart != null && ! thirdPart . isEmpty ( ) ) { if ( attr ) { result . addAll ( compactAttributeValue ( thirdPart , 0 ) ) ; } else { result . addAll ( compactExtension ( thirdPart , 0 ) ) ; } } return result ; } else { return null ; } }
private method that check if a extension or attribute value is found in the value passed . if it is contained the string is splitted in three possible parts ( the part before the match , the matched string , and the rest ) . obviously the returned list is from one to three sized list . if there is no match a null is returned .
