Example usage for org.apache.wicket.util.string Strings isEmpty

List of usage examples for org.apache.wicket.util.string Strings isEmpty

Introduction

In this page you can find the example usage for org.apache.wicket.util.string Strings isEmpty.

Prototype

public static boolean isEmpty(final CharSequence string) 

Source Link

Document

Checks whether the string is considered empty.

Usage

From source file:com.asptt.plongee.resa.wicket.page.inscription.InscriptionFilleulPlongeePage.java

public List<Adherent> getMatchingAdherents(String search) {
    if (Strings.isEmpty(search)) {
        List<Adherent> emptyList = Collections.emptyList();
        return emptyList;
    }/*  w  w w .  j  av  a 2s .co m*/

    if (list == null) {
        list = ResaSession.get().getAdherentService().rechercherExternes();
    }

    ArrayList<Adherent> newList = new ArrayList<Adherent>();
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getNom().startsWith(search.toUpperCase())) {
            newList.add(list.get(i));
        }
    }
    return newList;
}

From source file:com.asptt.plongee.resa.wicket.page.secretariat.DesInscriptionPlongeePage.java

public List<Adherent> getMatchingAdherents(String search) {
    if (Strings.isEmpty(search)) {
        List<Adherent> emptyList = Collections.emptyList();
        return emptyList;
    }/*w  w  w  . j a va 2  s .c o m*/

    // Dans le cas de la desinscription, la list de recherche
    // est compose des adhrents actifs et des externes ( priori ils
    // existent dans ce cas)
    List<Adherent> list = ResaSession.get().getAdherentService().rechercherAdherentsActifs();
    list.addAll(ResaSession.get().getAdherentService().rechercherExternes());

    ArrayList<Adherent> newList = new ArrayList<Adherent>();
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getNom().startsWith(search.toUpperCase())) {
            newList.add(list.get(i));
        }
    }
    return newList;
}

From source file:com.asptt.plongee.resa.wicket.page.secretariat.InscriptionAdherentPlongeePage.java

public List<Adherent> getMatchingAdherents(String search) {
    if (Strings.isEmpty(search)) {
        List<Adherent> emptyList = Collections.emptyList();
        return emptyList;
    }//from w  w w  .ja v a2 s . c  o  m

    if (list == null) {
        list = ResaSession.get().getAdherentService().rechercherAdherentsActifs();
    }

    ArrayList<Adherent> newList = new ArrayList<Adherent>();
    for (int i = 0; i < list.size(); i++) {
        if (list.get(i).getNom().startsWith(search.toUpperCase())) {
            newList.add(list.get(i));
        }
    }
    return newList;
}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.behaviors.AbstractMultiAjaxBehavior.java

License:Apache License

private void appendIfNotEmpty(final JSONObject attributesJson, final String key, final String str)
        throws JSONException {
    if (Strings.isEmpty(str) == false) {
        attributesJson.put(key, str);//from  www  .  j  av  a 2s .  c o m
    }
}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.behaviors.AbstractMultiAjaxBehavior.java

License:Apache License

private static void appendListenerHandler(final CharSequence handler, final JSONObject attributesJson,
        final String propertyName, final String functionTemplate) throws JSONException {
    if (Strings.isEmpty(handler) == false) {
        final JsonFunction function;
        if (handler instanceof JsonFunction) {
            function = (JsonFunction) handler;
        } else {/*from  w w  w  .  java2 s  . com*/
            final String func = String.format(functionTemplate, handler);
            function = new JsonFunction(func);
        }
        attributesJson.append(propertyName, function);
    }
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueAutoCompleteTextPanel.java

License:Apache License

private Iterator<String> createAutoCompleteObjectList(String input) {
    List<T> list = createObjectList();
    List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE);

    if (Strings.isEmpty(input)) {
        for (T object : list) {
            choices.add(createAutoCompleteObjectLabel(object));

            if (choices.size() == AUTO_COMPLETE_LIST_SIZE) {
                break;
            }//from w w  w.  j  a v  a2s  .co  m
        }

        return choices.iterator();
    }

    for (T object : list) {
        if (createAutoCompleteObjectLabel(object).toLowerCase().startsWith(input.toLowerCase())) {
            choices.add(createAutoCompleteObjectLabel(object));

            if (choices.size() == AUTO_COMPLETE_LIST_SIZE) {
                break;
            }
        }
    }

    return choices.iterator();
}

From source file:com.evolveum.midpoint.web.page.admin.server.handlers.ResourceRelatedHandlerPanel.java

License:Apache License

private Iterator<String> prepareObjectClassChoiceList(String input) {
    List<String> choices = new ArrayList<>();

    if (getModelObject().getResourceRef() == null) {
        return choices.iterator();
    }//from   ww  w. j  a  v  a  2 s .  c o  m

    if (Strings.isEmpty(input)) {
        for (QName q : getModelObject().getObjectClassList()) {
            choices.add(q.getLocalPart());
            Collections.sort(choices);
        }
    } else {
        for (QName q : getModelObject().getObjectClassList()) {
            if (q.getLocalPart().startsWith(input)) {
                choices.add(q.getLocalPart());
            }
            Collections.sort(choices);
        }
    }

    return choices.iterator();
}

From source file:com.example.justaddwater.facebook.FacebookOAuthPage.java

License:Apache License

public FacebookOAuthPage() {
    log.info("reached FacebookOAuthPage from facebook login");

    HttpServletRequest req = (HttpServletRequest) getRequest().getContainerRequest();
    String code = req.getParameter("code");

    if (!Strings.isEmpty(code)) {
        String authURL = getAuthURL(code);

        try {//from w w w . j  a va 2  s.  com
            String result = readFromURL(authURL);
            String accessToken = null;
            Integer expires = null;
            String[] pairs = result.split("&");

            for (String pair : pairs) {
                String[] kv = pair.split("=");

                if (kv.length != 2) {
                    throw new RuntimeException("Unexpected auth response");
                } else {
                    if (kv[0].equals("access_token")) {
                        accessToken = kv[1];
                    }

                    if (kv[0].equals("expires")) {
                        expires = Integer.valueOf(kv[1]);
                    }
                }
            }

            if (accessToken != null && expires != null) {
                logUserIn(accessToken, expires);
                setResponsePage(AccountPage.class);
            } else {
                throw new RuntimeException("Access token and expires not found");
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    } else {
        setResponsePage(LoginPage.class);
    }
}

From source file:com.example.justaddwater.model.DAO.java

License:Apache License

public User findUserByEmail(String email) {
    log.info("findUserByEmail " + email);
    if (Strings.isEmpty(email))
        return null;

    EntityManager em = getEntityManager();

    Query query = em.createQuery("select u from User u where u.email= :email");
    query.setParameter("email", email);
    List<User> results = query.getResultList();

    log.info("findUserByEmail: results size = " + results.size());

    User u = DAO.getOneFromCollection(results);

    em.close();//from   ww  w.j a va 2 s.co  m
    em = null;

    return u;
}

From source file:com.example.justaddwater.model.DAO.java

License:Apache License

public OneTimeLogin findOneTimeLoginByToken(String token) {
    if (Strings.isEmpty(token))
        return null;

    EntityManager em = getEntityManager();
    Query query = em.createQuery("select otl from OneTimeLogin otl where otl.token = :token");
    query.setParameter("token", KeyFactory.stringToKey(token));
    List<OneTimeLogin> results = query.getResultList();
    OneTimeLogin otl = DAO.getOneFromCollection(results);
    log.info("findOneTimeLoginByToken: user = " + otl.getUser().getEmail());
    em.close();//from  ww  w .  ja  va 2s .c  o  m
    em = null;
    return otl;
}