static String buildStyle(String style,String parentStyle,String defaultStyle){
  String res;
  if (!style.isEmpty()) {
    if (style.startsWith("+")) {
      String addStyles=style.substring(1);
      String inheritedStyles;
      if (parentStyle != null) {
        inheritedStyles=parentStyle;
      }
 else {
        inheritedStyles=defaultStyle;
      }
      if (inheritedStyles != null && !inheritedStyles.isEmpty()) {
        if (!addStyles.isEmpty()) {
          res=inheritedStyles + (addStyles.startsWith(" ") ? "" : " ") + addStyles;
        }
 else {
          res=inheritedStyles;
        }
      }
 else {
        res=style;
      }
    }
 else {
      res=style;
    }
  }
 else   if (parentStyle != null) {
    res=parentStyle;
  }
 else {
    res=defaultStyle;
  }
  if (res != null) {
    res=res.trim();
  }
  return res;
}

static String buildStyle ( String style , String parentStyle , String defaultStyle ) { String res ; if ( ! style . isEmpty ( ) ) { if ( style . startsWith ( "+" ) ) { String addStyles = style . substring ( 1 ) ; String inheritedStyles ; if ( parentStyle != null ) { inheritedStyles = parentStyle ; } else { inheritedStyles = defaultStyle ; } if ( inheritedStyles != null && ! inheritedStyles . isEmpty ( ) ) { if ( ! addStyles . isEmpty ( ) ) { res = inheritedStyles + ( addStyles . startsWith ( " " ) ? "" : " " ) + addStyles ; } else { res = inheritedStyles ; } } else { res = style ; } } else { res = style ; } } else if ( parentStyle != null ) { res = parentStyle ; } else { res = defaultStyle ; } if ( res != null ) { res = res . trim ( ) ; } return res ; }
scipio : builds a style string from current , parent , and default , based on " + " / " = " combination logic . < p > note : subtle difference between null and empty string . < p > fixme ? : there is a loss of information here , because the + / = styles are always removed in the final string . should preserve so macros can use ? < p > fixme : this is inefficient in cases where parent style does not need to be visited , but can ' t change easily in java .
