Example usage for java.lang String equalsIgnoreCase

List of usage examples for java.lang String equalsIgnoreCase

Introduction

In this page you can find the example usage for java.lang String equalsIgnoreCase.

Prototype

public boolean equalsIgnoreCase(String anotherString) 

Source Link

Document

Compares this String to another String , ignoring case considerations.

Usage

From source file:Main.java

/**
 * Builds a String via the passed String array. If the individual String is null or empty,
 * it skips it. If the delimiter is empty, skips that too
 * @param args String array to use/*from  w  ww.  ja  v  a 2 s.co m*/
 * @param delimiter Delimiter to use (IE , or a space or _ or / or | )
 * @return Fully completed and written String. Example:
 *         String str = buildAStringFromUnknowns(new String[]{"2016", "07", "04"}, "/");
 *         str would print as: "2016/07/04"
 */
public static String buildAStringFromUnknowns(String[] args, String delimiter) {
    StringBuilder sb = new StringBuilder();
    sb.append(""); //So that it will always return something
    try {
        for (int i = 0; i < args.length; i++) {
            String str = args[i];

            //Boot out nulls and blanks
            if (str == null) {
                continue;
            }
            if (str.equalsIgnoreCase("")) {
                continue;
            }

            sb.append(str);
            if (i < args.length - 1) {
                boolean checkNext = true;
                try {
                    String str1 = args[(i + 1)];
                    if (str1 == null) {
                        checkNext = false;
                    } else {
                        if (str1.isEmpty()) {
                            checkNext = false;
                        }
                    }
                } catch (Exception e) {

                }
                if (checkNext) {
                    //Format via delimiter
                    if (delimiter != null) {
                        sb.append(delimiter);
                    }
                }
            }
        }
    } catch (Exception e) {
    }

    return sb.toString();
}

From source file:at.bitfire.ical4android.DateUtils.java

public static String findAndroidTimezoneID(String tzID) {
    String deviceTZ = null;//w  w w  .  j a v  a  2 s.  c  o m
    String availableTZs[] = SimpleTimeZone.getAvailableIDs();

    // first, try to find an exact match (case insensitive)
    for (String availableTZ : availableTZs)
        if (availableTZ.equalsIgnoreCase(tzID)) {
            deviceTZ = availableTZ;
            break;
        }

    // if that doesn't work, try to find something else that matches
    if (deviceTZ == null) {
        for (String availableTZ : availableTZs)
            if (StringUtils.indexOfIgnoreCase(tzID, availableTZ) != -1) {
                deviceTZ = availableTZ;
                Log.w(TAG, "Couldn't find system time zone \"" + tzID + "\", assuming " + deviceTZ);
                break;
            }
    }

    // if that doesn't work, use UTC as fallback
    if (deviceTZ == null) {
        final String defaultTZ = TimeZone.getDefault().getID();
        Log.w(TAG, "Couldn't find system time zone \"" + tzID + "\", using system default (" + defaultTZ
                + ") as fallback");
        deviceTZ = defaultTZ;
    }

    return deviceTZ;
}

From source file:Main.java

/**
 * Return array of children nodes by node name
 *///w w  w  .ja  v a  2 s  . c  o m
public static Node[] childrenByNodeName(Element owner, String searchNode) {
    NodeList list = owner.getElementsByTagName(searchNode);
    Node[] children = new Node[list.getLength()];
    for (int i = 0; i < children.length; i++) {
        if (isElement(list.item(i)) && searchNode.equalsIgnoreCase(list.item(i).getLocalName())) {
            children[i] = list.item(i);
        }
    }
    return children;
}

From source file:com.omertron.themoviedbapi.tools.MethodSub.java

/**
 * Convert a string into an Enum type/*from  ww w . ja  va2s.  c om*/
 *
 * @param value
 * @return
 */
public static MethodSub fromString(String value) {
    if (StringUtils.isNotBlank(value)) {
        for (final MethodSub method : EnumSet.allOf(MethodSub.class)) {
            if (value.equalsIgnoreCase(method.value)) {
                return method;
            }
        }
    }

    // We've not found the type!
    throw new IllegalArgumentException("Method '" + value + "' not recognised");
}

From source file:crawlers.Xinh.java

private static boolean saveImageByUrl(String urlGet, String tags) throws IOException {
    boolean isMore = false;
    List<AppImageEnt> listAppImageEnt = new ArrayList<AppImageEnt>();
    JsonObject jsonObj = readJsonObjectFromUrl(urlGet);
    if (jsonObj != null) {
        JsonElement jsonElementErrorCode = jsonObj.get("ErrorCode");
        if (jsonElementErrorCode != null && jsonElementErrorCode.getAsInt() == 0) {
            String jsonElementLoadMore = jsonObj.get("LoadMore").getAsString();
            if (jsonElementLoadMore.equalsIgnoreCase("YES")) {
                isMore = true;//from   ww w. java2 s.  c o m
            }

            JsonArray jsonElementData = jsonObj.get("DATA").getAsJsonArray();
            if (jsonElementData != null && jsonElementData.size() > 0) {
                for (JsonElement tmpJson : jsonElementData) {
                    JsonObject jsonItem = tmpJson.getAsJsonObject();
                    listAppImageEnt.add(new AppImageEnt(jsonItem, tags, AppImageEnt.STATUS.ENABLE));
                }
            }

            DatabaseServiceUtils.InsertAppImageEnt(listAppImageEnt);
        }
    }
    return isMore;
}

From source file:fr.liglab.adele.cilia.workbench.restmonitoring.utils.http.CiliaRestHelper.java

private static Map<String, String> getComponentInformationFromJSON(JSONObject json) throws CiliaException {
    Map<String, String> retval = new HashMap<String, String>();
    try {/*from  www  .  j ava 2  s.co m*/
        String[] keys = JSONObject.getNames(json);
        for (String key : keys) {
            if (!key.equalsIgnoreCase("Properties")) {
                String value = json.getString(key);
                retval.put(key, value);
            }
        }
    } catch (JSONException e) {
        String message = "Error while parsing JSON message";
        throw new CiliaException(message, e);
    }

    return retval;
}

From source file:com.netflix.genie.common.dto.ApplicationStatus.java

/**
 * Parse config status./*from w  w w.ja v  a2s .co m*/
 *
 * @param value string to parse/convert into config status
 * @return ACTIVE, DEPRECATED, INACTIVE if match
 * @throws GeniePreconditionException on invalid value
 */
public static ApplicationStatus parse(final String value) throws GeniePreconditionException {
    if (StringUtils.isNotBlank(value)) {
        for (final ApplicationStatus status : ApplicationStatus.values()) {
            if (value.equalsIgnoreCase(status.toString())) {
                return status;
            }
        }
    }
    throw new GeniePreconditionException(
            "Unacceptable application status. Must be one of {ACTIVE, DEPRECATED, INACTIVE}");
}

From source file:Main.java

public static String getDate(String integer) {
    SimpleDateFormat sdf = new SimpleDateFormat("EEEE,MMMM d,yyyy h:mm,a", Locale.ENGLISH);
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    String formattedDate = sdf.format(new Date());
    if (!integer.equalsIgnoreCase("null")) {
        long seconds = Integer.valueOf(integer);
        long millis = seconds * 1000;
        Date date = new Date(millis);
        formattedDate = sdf.format(date);
        return formattedDate;
    }/*from  w  ww .  j a  v  a2s  .c o m*/
    return formattedDate;

}

From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.impl.utils.PentahoSystemHelper.java

public static void init() {
    if (PentahoSystem.getInitializedOK()) {
        return;/*from  w  w w  . ja  v a 2 s .c o  m*/
    }
    try {
        PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());

        if (PentahoSystem.getApplicationContext() == null) {
            StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(
                    getSolutionPath(), ""); //$NON-NLS-1$
            // set the base url assuming there is a running server on port 8080
            if (PentahoRequestContextHolder.getRequestContext() != null) {
                applicationContext.setFullyQualifiedServerURL(
                        PentahoRequestContextHolder.getRequestContext().getContextPath());
            }

            String inContainer = System.getProperty("incontainer", "false"); //$NON-NLS-1$ //$NON-NLS-2$
            if (inContainer.equalsIgnoreCase("false")) { //$NON-NLS-1$
                // Setup simple-jndi for datasources
                System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory"); //$NON-NLS-2$ //$NON-NLS-2$
                System.setProperty("org.osjava.sj.root", getSolutionPath() + "/system/simple-jndi"); //$NON-NLS-1$ //$NON-NLS-2$
                System.setProperty("org.osjava.sj.delimiter", "/"); //$NON-NLS-1$ //$NON-NLS-2$
            }
            ApplicationContext springApplicationContext = getSpringApplicationContext();

            IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
            pentahoObjectFactory.init(null, springApplicationContext);
            PentahoSystem.registerObjectFactory(pentahoObjectFactory);

            //force Spring to inject PentahoSystem, there has got to be a better way than this,
            // perhaps an alternate way of initting spring's app context
            springApplicationContext.getBean("pentahoSystemProxy"); //$NON-NLS-1$
            PentahoSystem.init(applicationContext);
        }
    } catch (Exception e) {
        logger.error(e);
    }
}

From source file:com.linuxbox.enkive.web.AuditLogServlet.java

private static String cleanGetParameter(HttpServletRequest request, String parameterName) {
    String parameterValue = request.getParameter(parameterName);

    if (parameterValue == null || parameterValue.equalsIgnoreCase("null")) {
        return null;
    } else {/*  w ww. j  a  va  2 s .c  om*/
        return parameterValue;
    }
}