public static String buildSelectorFromElementAndAttribute(String elementName,String attributeName,boolean notEmptyAttribute){
  StringBuilder selector=new StringBuilder();
  selector.append(elementName);
  if (attributeName != null && !attributeName.isEmpty()) {
    selector.append(OPEN_BRACKET);
    selector.append(attributeName);
    selector.append(CLOSE_BRACKET);
    if (notEmptyAttribute) {
      selector.append(NOT_PREFIX);
      selector.append(OPEN_BRACKET);
      selector.append(attributeName);
      selector.append(NOT_EMPTY_REGEXP);
      selector.append(CLOSE_BRACKET);
      selector.append(CLOSE_PARENTHESE);
    }
  }
  return selector.toString();
}

public static String buildSelectorFromElementAndAttribute ( String elementName , String attributeName , boolean notEmptyAttribute ) { StringBuilder selector = new StringBuilder ( ) ; selector . append ( elementName ) ; if ( attributeName != null && ! attributeName . isEmpty ( ) ) { selector . append ( OPEN_BRACKET ) ; selector . append ( attributeName ) ; selector . append ( CLOSE_BRACKET ) ; if ( notEmptyAttribute ) { selector . append ( NOT_PREFIX ) ; selector . append ( OPEN_BRACKET ) ; selector . append ( attributeName ) ; selector . append ( NOT_EMPTY_REGEXP ) ; selector . append ( CLOSE_BRACKET ) ; selector . append ( CLOSE_PARENTHESE ) ; } } return selector . toString ( ) ; }
build a jquery selector to retrieve elements that contain a given attribute . the notemptyattribute attribute determines whether this attribute can be empty or not
