List of usage examples for org.apache.wicket.util.string Strings isEmpty
public static boolean isEmpty(final CharSequence string)
string
is considered empty. From source file:com.example.justaddwater.web.app.ElasticEmail.java
License:Apache License
public static String sendEmail(String from, String fromName, String subject, String body, String to, String bcc) {//ww w. j a va 2 s . co m try { //Construct the data String data = "userName=" + ELASTIC_EMAIL_USERNAME; data += "&api_key=" + ELASTIC_EMAIL_APIKEY; data += "&from=" + from; data += "&from_name=" + fromName; data += "&subject=" + URLEncoder.encode(subject, "UTF-8"); data += "&body_html=" + URLEncoder.encode(body, "UTF-8"); data += "&to=" + to; if (!Strings.isEmpty(bcc)) { // to list is really just a semicolon-separated bcc list data += ";" + bcc; } //Send data URL url = new URL("https://api.elasticemail.com/mailer/send"); URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String result = rd.readLine(); wr.close(); rd.close(); log.info("sent email to: " + to + ", with id: " + result); return result; } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.example.justaddwater.web.app.MySession.java
License:Apache License
public String getUsername() { return !Strings.isEmpty(username) ? username : ""; }
From source file:com.example.justaddwater.web.app.MySession.java
License:Apache License
public boolean isLoggedIn() { return !Strings.isEmpty(getUsername()); }
From source file:com.gfactor.web.wicket.loader.OsgiClassResolver.java
License:Apache License
private List<String> getExportedPackages(Bundle bundle) { String exportedString = (String) bundle.getHeaders().get("Export-Package"); if (Strings.isEmpty(exportedString)) return Collections.emptyList(); String[] splitted = Strings.split(exportedString, ','); if (splitted == null || splitted.length == 0) return Collections.emptyList(); List<String> packages = new ArrayList<String>(); for (String s : splitted) { String pkg = null;//www . j a v a 2 s. co m if (s.contains(";")) pkg = Strings.beforeFirst(s, ';').trim(); else pkg = s.trim(); if (pkg != null && pkg.length() > 0) packages.add(pkg); } return packages; }
From source file:com.gitblit.servlet.ResourceGuardFilter.java
License:Apache License
@Override public void init(FilterConfig filterConfig) throws ServletException { String paths = filterConfig.getInitParameter("deniedPaths"); if (!Strings.isEmpty(paths)) { String[] parts = paths.split(","); for (String path : parts) { if (path.startsWith("/")) { path = path.substring(1); }/* www .ja va 2 s. co m*/ deniedPaths.add(path); } } }
From source file:com.gitblit.wicket.freemarker.FreemarkerPanel.java
License:Apache License
/** * @see org.apache.wicket.markup.html.panel.Panel#onComponentTagBody(org.apache.wicket.markup. * MarkupStream, org.apache.wicket.markup.ComponentTag) */// www .j a v a 2 s . c om @Override public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { if (!Strings.isEmpty(stackTraceAsString)) { // TODO: only display the Freemarker error/stacktrace in development // mode? replaceComponentTagBody(markupStream, openTag, Strings.toMultilineMarkup(stackTraceAsString)); } else if (!parseGeneratedMarkup) { // check that no components have been added in case the generated // markup should not be // parsed if (size() > 0) { throw new WicketRuntimeException( "Components cannot be added if the generated markup should not be parsed."); } if (evaluatedTemplate == null) { // initialize evaluatedTemplate getMarkupResourceStream(null, null); } replaceComponentTagBody(markupStream, openTag, evaluatedTemplate); } else { super.onComponentTagBody(markupStream, openTag); } }
From source file:com.googlecode.wicket.jquery.core.utils.LocaleUtils.java
License:Apache License
/** * Gets the language-code (eg: xx-XX) from a given {@link Locale} * @param locale the {@link Locale}/*from w ww . ja v a 2s.c o m*/ * @return the language-code */ public static String getLangageCode(Locale locale) { if (!Strings.isEmpty(locale.getCountry())) { return String.format("%s-%s", locale.getLanguage(), locale.getCountry()); } return locale.getLanguage(); }
From source file:com.googlecode.wicket.jquery.ui.form.slider.RangeSlider.java
License:Apache License
@Override public void onConfigure(JQueryBehavior behavior) { super.onConfigure(behavior); StringBuilder statements = new StringBuilder(); statements.append("jQuery('#").append(this.lower.getMarkupId()).append("').val(ui.values[0]); "); statements.append("jQuery('#").append(this.upper.getMarkupId()).append("').val(ui.values[1]); "); if (!Strings.isEmpty(super.labelId)) { statements.append("jQuery('#").append(super.labelId).append("').text(").append(this.getLabelPattern()) .append("); "); }//from w ww.j a va2 s. c o m behavior.setOption("slide", String.format("function(event, ui) { %s }", statements)); behavior.setOption("values", this.getModelObject()); }
From source file:com.googlecode.wicket.jquery.ui.JQueryIcon.java
License:Apache License
/** * Indicates whether the icon is {@link JQueryIcon#NONE} * * @param icon the icon//from www . j a va 2 s . com * @return true or false */ public static boolean isNone(String icon) { return Strings.isEmpty(icon); }
From source file:com.googlecode.wicket.kendo.ui.datatable.button.CommandButton.java
License:Apache License
public String toString(JQueryAjaxBehavior behavior) { StringBuilder builder = new StringBuilder(); builder.append("{ "); BuilderUtils.append(builder, "name", this.getName()); builder.append(", "); BuilderUtils.append(builder, "text", this.getText().getObject()); String css = this.getCSSClass(); if (!Strings.isEmpty(css)) /* important */ {// w w w . ja v a2 s. c om builder.append(", "); BuilderUtils.append(builder, "className", css); } if (behavior != null) { builder.append(", "); builder.append("'click': ").append(behavior.getCallbackFunction()); } builder.append(" }"); return builder.toString(); }