Skip to content

Commit

Permalink
dont capitalize method names, remove redundant method
Browse files Browse the repository at this point in the history
  • Loading branch information
zhedar committed Apr 22, 2016
1 parent 98da58c commit 2f0fb31
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void encodeHTML(FacesContext context, Button button)
rw.writeAttribute("id", clientId, "id");
rw.writeAttribute("name", clientId, "name");
rw.writeAttribute("type", "button", null);
if(BsfUtils.StringIsValued(button.getDir())) {
if(BsfUtils.isStringValued(button.getDir())) {
rw.writeAttribute("dir", button.getDir(), "dir");
}
if (style != null) {
Expand All @@ -98,7 +98,7 @@ public void encodeHTML(FacesContext context, Button button)
if (null != clickHandler && clickHandler.length() > 0) {
rw.writeAttribute("onclick", clickHandler, null);
}
if (BsfUtils.StringIsValued(button.getDismiss())) {
if (BsfUtils.isStringValued(button.getDismiss())) {
rw.writeAttribute("data-dismiss", button.getDismiss(), null);
}
if (button.isDisabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
// build color picker init script
rw.startElement("script", colorPicker);
rw.writeText("$(function() {" +
"$('#input_" + BsfUtils.EscapeJQuerySpecialCharsInSelector(clientId) + "').minicolors({" +
"$('#input_" + BsfUtils.escapeJQuerySpecialCharsInSelector(clientId) + "').minicolors({" +
(colorPicker.getAttributes().get("control") != null ? " control: '" + colorPicker.getAttributes().get("control") + "'," : "") +
(colorPicker.getAttributes().get("format") != null ? " format: '" + colorPicker.getAttributes().get("format") + "'," : "") +
(colorPicker.getAttributes().get("opacity") != null ? " opacity: " + colorPicker.getAttributes().get("opacity") + "," : "") +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
" pageLength: " + pageLength + ", " +
" lengthMenu: " + dataTable.getPageLengthMenu() + ", " +
" order: " + orderString + ", " +
(BsfUtils.StringIsValued(lang) ? " language: { url: '" + lang + "' } " : "") +
(BsfUtils.isStringValued(lang) ? " language: { url: '" + lang + "' } " : "") +
"});" +
// "var table = " + widgetVar +".DataTable({fixedHeader: true, responsive: true});" +
"var workInProgressErrorMessage = 'Multiple DataTables on the same page are not yet supported when using " +
Expand Down Expand Up @@ -382,9 +382,9 @@ private String determineLanguage(FacesContext fc, DataTable dataTable) {
final Set<String> availableLanguages = new HashSet<String>(Arrays.asList(
new String[] {"de", "en", "es", "fr", "hu", "it", "pl", "ru"}
));
if(BsfUtils.StringIsValued(dataTable.getCustomLangUrl())) {
if(BsfUtils.isStringValued(dataTable.getCustomLangUrl())) {
return dataTable.getCustomLangUrl();
} else if(BsfUtils.StringIsValued(dataTable.getLang())) {
} else if(BsfUtils.isStringValued(dataTable.getLang())) {
String lang = dataTable.getLang();
if(availableLanguages.contains(lang)) return determineLanguageUrl(fc, lang);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void encodeEnd(FacesContext context) throws IOException {
throw new FacesException("The default command component must be inside a form", null);
} else {
String target = (String)attrs.get("target");
if(BsfUtils.StringIsValued(target)) {
if(BsfUtils.isStringValued(target)) {
ResponseWriter rw = context.getResponseWriter();
String formId = form.getClientId();
String actionCommandId = BsfUtils.getComponentClientId(target);
Expand All @@ -61,7 +61,7 @@ public void encodeEnd(FacesContext context) throws IOException {

rw.writeText("" +
"$(function() { " +
" $('form#" + BsfUtils.EscapeJQuerySpecialCharsInSelector(formId) + " :input').keypress(function (e) { " +
" $('form#" + BsfUtils.escapeJQuerySpecialCharsInSelector(formId) + " :input').keypress(function (e) { " +
" if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) { " +
" document.getElementById('" + actionCommandId + "').click();return false; " +
" } else { " +
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/bootsfaces/component/focus/Focus.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public void encodeEnd(FacesContext context) throws IOException {
Map<String, Object> attrs = getAttributes();

String target = (String)attrs.get("target");
if(!BsfUtils.StringIsValued(target)) {
if(!BsfUtils.isStringValued(target)) {
if(this.getParent() != null)
target = this.getParent().getId();
}

//
if(BsfUtils.StringIsValued(target)) {
if(BsfUtils.isStringValued(target)) {
ResponseWriter rw = context.getResponseWriter();
String itemToFocusID = BsfUtils.getComponentClientId(target);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public void encodeBegin(FacesContext context, UIComponent component) throws IOEx
rw.startElement("div", jumbotron);
rw.writeAttribute("id",clientId,"id");

if(BsfUtils.StringIsValued(jumbotron.getStyle()))
if(BsfUtils.isStringValued(jumbotron.getStyle()))
rw.writeAttribute("style", jumbotron.getStyle(), "style");

Tooltip.generateTooltip(context, jumbotron, rw);

String styleClass = "jumbotron";
if(BsfUtils.StringIsValued(jumbotron.getStyleClass()))
if(BsfUtils.isStringValued(jumbotron.getStyleClass()))
styleClass = styleClass + " " + jumbotron.getStyleClass();
rw.writeAttribute("class", styleClass, "class");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce

// Get attributes
String container = scrollSpy.getContainer();
if(!BsfUtils.StringIsValued(container)) {
if(!BsfUtils.isStringValued(container)) {
container = "body";
} else container = "#" + decodeAndEscapeSelectors(context, component, container);

String target = scrollSpy.getTarget();
if(!BsfUtils.StringIsValued(target)) {
if(!BsfUtils.isStringValued(target)) {
target = ".navbar";
} else target = "#" + decodeAndEscapeSelectors(context, component, target);

int offset = scrollSpy.getOffset();
if(!BsfUtils.StringIsValued(target)) {
if(!BsfUtils.isStringValued(target)) {
offset = 20;
}
boolean smooth = scrollSpy.isSmooth();
Expand Down Expand Up @@ -160,7 +160,7 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
*/
private String decodeAndEscapeSelectors(FacesContext context, UIComponent component, String selector) {
selector = ExpressionResolver.getComponentIDs(context, component, selector);
selector = BsfUtils.EscapeJQuerySpecialCharsInSelector(selector);
selector = BsfUtils.escapeJQuerySpecialCharsInSelector(selector);

return selector;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/bootsfaces/component/tree/TreeRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
}
Tree tree = (Tree) component;
String clientId = tree.getClientId();
String jqClientId = BsfUtils.EscapeJQuerySpecialCharsInSelector(clientId);
String jqClientId = BsfUtils.escapeJQuerySpecialCharsInSelector(clientId);
ResponseWriter rw = context.getResponseWriter();

final UIForm form = BsfUtils.getClosestForm(tree);
Expand All @@ -156,9 +156,9 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
(tree.isShowIcon() ? "showIcon: true," : "") +
(tree.isShowCheckbox() ? "showCheckbox: true," : "") +
(tree.isEnableLinks() ? "enableLinks: true," : "") +
(BsfUtils.StringIsValued(tree.getCollapseIcon()) ? "collapseIcon: '" + tree.getCollapseIcon() + "'," : "") +
(BsfUtils.StringIsValued(tree.getExpandIcon()) ? "expandIcon: '" + tree.getExpandIcon() + "'," : "") +
(BsfUtils.StringIsValued(tree.getColor()) ? "color: '" + tree.getColor() + "'," : "") +
(BsfUtils.isStringValued(tree.getCollapseIcon()) ? "collapseIcon: '" + tree.getCollapseIcon() + "'," : "") +
(BsfUtils.isStringValued(tree.getExpandIcon()) ? "expandIcon: '" + tree.getExpandIcon() + "'," : "") +
(BsfUtils.isStringValued(tree.getColor()) ? "color: '" + tree.getColor() + "'," : "") +
" data: getTreeData(), " +
// enable nodeSelected event callback
" onNodeSelected: function(event, data) { " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,27 @@ private static String renderNode(Node node) {
sb.append("\"nodeInternalId\": " + node.getNodeId() + ", ");
}
// TEXT
if(BsfUtils.StringIsValued(node.getText())) {
if(BsfUtils.isStringValued(node.getText())) {
sb.append("\"text\": \"" + node.getText() + "\", ");
}
// ICON
if(BsfUtils.StringIsValued(node.getIcon())) {
if(BsfUtils.isStringValued(node.getIcon())) {
sb.append("\"icon\": \"" + node.getIcon() + "\", ");
}
// SELECTED ICON
if(BsfUtils.StringIsValued(node.getSelectedIcon())) {
if(BsfUtils.isStringValued(node.getSelectedIcon())) {
sb.append("\"selectedIcon\": \"" + node.getSelectedIcon() + "\", ");
}
// COLOR
if(BsfUtils.StringIsValued(node.getColor())) {
if(BsfUtils.isStringValued(node.getColor())) {
sb.append("\"color\": \"" + node.getColor() + "\", ");
}
// BACK COLOR
if(BsfUtils.StringIsValued(node.getBackColor())) {
if(BsfUtils.isStringValued(node.getBackColor())) {
sb.append("\"backColor\": \"" + node.getBackColor() + "\", ");
}
// HREF
if(BsfUtils.StringIsValued(node.getHRef())) {
if(BsfUtils.isStringValued(node.getHRef())) {
sb.append("\"href\": \"" + node.getHRef() + "\", ");
}
// TAGS
Expand Down
27 changes: 7 additions & 20 deletions src/main/java/net/bootsfaces/utils/BsfUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ public static String navigateInAjax(String outcome)
* @param str
* @return
*/
public static boolean StringIsValued(String str) {
if(str != null && !"".equals(str.trim())) return true;
return false;
public static boolean isStringValued(String str) {
return str != null && !"".equals(str.trim());
}

/**
* Get the string if is valued, otherwise return default Value
* Get the string if is not null or empty,
* otherwise return the default value
* @param str
* @param defaultValue
* @return
*/
public static String StringOrDefault(String str, String defaultValue) {
if(StringIsValued(str)) return str;
public static String stringOrDefault(String str, String defaultValue) {
if(isStringValued(str)) return str;
return defaultValue;
}

Expand Down Expand Up @@ -195,25 +195,12 @@ else if (c == '\n')
return sb.toString();
}

/**
* Get the string if is not null or empty,
* otherwise return the default value
*
* @param inputValue
* @param defaultReturnValue
* @return
*/
public static String GetOrDefault (String inputValue, String defaultReturnValue) {
if(StringIsValued(inputValue)) return inputValue;
else return defaultReturnValue;
}

/**
* Escape special jQuery chars in selector query
* @param selector
* @return
*/
public static String EscapeJQuerySpecialCharsInSelector(String selector) {
public static String escapeJQuerySpecialCharsInSelector(String selector) {
String jQuerySpecialChars = "!\"#$%&'()*+,./:;<=>?@[]^`{|}~;";
String[] jsc = jQuerySpecialChars.split("(?!^)");
for(String c: jsc) {
Expand Down

0 comments on commit 2f0fb31

Please sign in to comment.