Example usage for java.lang String compareToIgnoreCase

List of usage examples for java.lang String compareToIgnoreCase

Introduction

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

Prototype

public int compareToIgnoreCase(String str) 

Source Link

Document

Compares two strings lexicographically, ignoring case differences.

Usage

From source file:com.sentaroh.android.Utilities.Dialog.SafFileSelectDialogFragment.java

private void updateTreeFileList(String p_dir, final String creat_dir, final String r_dir,
        final TreeFilelistAdapter tfa, final ListView lv) {
    Log.v("", "p_dir=" + p_dir + ", create_dir=" + creat_dir + ", r_dir=" + r_dir);
    SafFile lf = mSafFileMgr.getSafFileBySdcardPath(mDialogSafRoot, r_dir + p_dir + creat_dir, true);
    if (!p_dir.equals("/")) {//not root
        for (int i = tfa.getDataItemCount() - 1; i >= 0; i--) {
            TreeFilelistItem tfi = tfa.getDataItem(i);
            if (tfi.isDir()) {
                String fp = tfi.getPath() + tfi.getName();
                if (fp.equalsIgnoreCase(p_dir)) {
                    if (tfi.isSubDirLoaded())
                        tfa.removeChildItem(tfi, i);
                    int sdc = tfa.getDataItem(i).getSubDirItemCount();
                    sdc++;//from www .ja va 2 s  .co  m
                    tfa.getDataItem(i).setSubDirItemCount(sdc);
                    processLocalDirTree(mDialogFileOnly, r_dir + p_dir, i, tfi, tfa);
                    lv.setSelection(i);
                }
            }
        }
    } else {//root
        Log.v("", "find=" + findDirEntry(tfa, "/", creat_dir));
        if (findDirEntry(tfa, "/", creat_dir) >= 0)
            return;
        for (int i = tfa.getDataItemCount() - 1; i >= 0; i--) {
            TreeFilelistItem tfi = tfa.getDataItem(i);
            if (tfi.isDir()) {
                String fp = tfi.getPath() + tfi.getName();
                if (fp.compareToIgnoreCase(p_dir + creat_dir) < 0) {
                    tfi = buildTreeFileListItem(lf, "/");
                    tfi.setSubDirItemCount(0);
                    if ((i + 1) > tfa.getDataItemCount()) {
                        tfa.addDataItem(tfi);
                    } else {
                        int ip = findNextDirEntry(tfa, i + 1);
                        if (ip >= 0)
                            tfa.insertDataItem(ip, tfi);
                        else {
                            ip = findLastDirEntry(tfa);
                            if (ip >= 0)
                                tfa.insertDataItem(ip + 1, tfi);
                            else
                                tfa.insertDataItem(0, tfi);
                        }
                    }
                    tfa.createShowList();
                    break;
                }
            }
        }
    }
}

From source file:org.eclipse.birt.report.utility.ParameterAccessor.java

public static String[] sortSupportedFormatsByDisplayName(String[] values) {
    Arrays.sort(values, new Comparator<String>() {

        public int compare(String o1, String o2) {
            if (getOutputFormatLabel(o1) != null) {
                return getOutputFormatLabel(o1).compareToIgnoreCase(getOutputFormatLabel(o2));
            }//from w  w  w  . ja va  2 s. c  om
            return o1.compareToIgnoreCase(o2);
        }
    });
    return values;
}

From source file:org.apache.hadoop.hive.ql.udf.generic.GenericUDFRegExpInstr.java

@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
    IntWritable intWritable = new IntWritable(0);

    int position = 1;
    int occurrence = 1;
    int return_option = 0;
    String match_parameter = "c";

    if (arguments[0].get() == null || arguments[1].get() == null) {
        return null;
    }/*from  w  ww  .j  av a  2 s .  c om*/

    str = (String) converters[0].convert(arguments[0].get());
    substr = (String) converters[1].convert(arguments[1].get());

    String strFromPosition = str;

    if (arguments.length > 2) {
        position = ((IntObjectInspector) argumentOIs[2]).get(arguments[2].get());
        if (position > str.length() || position < 1) {
            LOG.warn("illegal start position");
            return intWritable;
        }

        if (arguments.length > 3) {
            occurrence = ((IntObjectInspector) argumentOIs[3]).get(arguments[3].get());
            if (occurrence > str.length() || occurrence < 0) {
                LOG.warn("illegal occurrence");
                return intWritable;
            }
        }

        if (arguments.length > 4) {
            return_option = ((IntObjectInspector) argumentOIs[4]).get(arguments[4].get());
            if ((return_option != 0) && (return_option != 1)) {
                LOG.warn("illegal occurrence");
                return intWritable;
            }
        }

        if (arguments.length > 5) {
            match_parameter = ((StringObjectInspector) argumentOIs[5])
                    .getPrimitiveJavaObject(arguments[5].get());
            match_parameter = match_parameter.toLowerCase();
            char[] tmp_char = match_parameter.toCharArray();

            String tmp_str = "icnmx";
            for (int i = 0; i < match_parameter.length(); i++) {
                if (!tmp_str.contains(String.valueOf(tmp_char[i]))) {
                    LOG.warn("illegal match_parameter");
                    return intWritable;
                }
            }
            match_parameter = String.valueOf(tmp_char[match_parameter.length() - 1]);
        }
    }

    try {
        if (match_parameter.compareToIgnoreCase("i") == 0) {
            p = Pattern.compile(substr.toString(), Pattern.CASE_INSENSITIVE);
        } else if (match_parameter.compareToIgnoreCase("c") == 0) {
            p = Pattern.compile(substr.toString());
        } else if (match_parameter.compareToIgnoreCase("n") == 0) {
            p = Pattern.compile(substr.toString(), Pattern.DOTALL);
        } else if (match_parameter.compareToIgnoreCase("m") == 0) {
            p = Pattern.compile(substr.toString(), Pattern.MULTILINE);
        } else if (match_parameter.compareToIgnoreCase("x") == 0) {
            p = Pattern.compile(substr.toString(), Pattern.COMMENTS);
        } else {
            p = Pattern.compile(substr.toString());
        }

        if (position > 1) {
            strFromPosition = str.substring(position - 1);
        }

        Matcher m = p.matcher(strFromPosition.toString());
        for (int i = 0; i < occurrence; i++) {
            if (m.find()) {
                if (return_option == 0) {
                    intWritable.set(m.start() + position);
                } else {
                    intWritable.set(m.end() + position);
                }
            } else {
                LOG.info("m.find() = " + m.find());
                intWritable.set(0);
                break;
            }
        }
        return intWritable;
    } catch (PatternSyntaxException e) {
        LOG.info("PatternSyntaxException");
        return intWritable;
    }
}

From source file:org.openmrs.module.pmtct.web.controller.PmtctInfantStatController.java

/**
 * @see org.springframework.web.servlet.mvc.ParameterizableViewController#handleRequestInternal(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse)
 *//*from   w  w  w. ja  v a2  s . c  o m*/
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    ModelAndView mav = new ModelAndView();
    mav.setViewName(getViewName());

    PmtctService pmtct;
    List<Object> result = new ArrayList<Object>();
    String pageNumber = request.getParameter("page");

    String startDate = "";

    String endDate = "";

    int infantTestSelect = -1, year = -1, month = -1;

    List<Object> res;

    List<Integer> numberOfPages;

    //      config = PMTCTConfiguration.getInstance(request.getRealPath(PMTCTConstants.CONFIGURATION_FILE_LOC));
    //      constants = config.getListOfConstants().get(0);
    //      request.getSession().setAttribute("enableModification", "" + config.isModificationEnabled());

    request.getSession().setAttribute("pmtctModuleConfigured", "" + PMTCTConfigurationUtils.isConfigured());

    try {
        if (null != request.getParameter("startDate") && "" != request.getParameter("startDate").trim()) {
            startDate = request.getParameter("startDate").trim();
        }
        if (null != request.getParameter("endDate") && "" != request.getParameter("endDate").trim()) {
            endDate = request.getParameter("endDate").trim();
        }
        if (null != request.getParameter("infantTestSelect")
                && "" != request.getParameter("infantTestSelect").trim()) {
            infantTestSelect = Integer.parseInt(request.getParameter("infantTestSelect").trim());
        }
        if (null != request.getParameter("year") && "" != request.getParameter("year").trim()) {
            year = Integer.parseInt(request.getParameter("year").trim());
        }
        if (null != request.getParameter("month") && "" != request.getParameter("month").trim()) {
            month = Integer.parseInt(request.getParameter("month").trim());
        }
        //      }
        //      catch (Exception ex) {
        //         log.error("An error occured when trying to get parameters: \n");
        //         ex.printStackTrace();
        //      }
        //      
        //      try {
        if (pageNumber.compareToIgnoreCase("1") == 0 || pageNumber.compareToIgnoreCase("") == 0) {
            pmtct = Context.getService(PmtctService.class);
            //            pmtct.setPMTCTProgrmaId(config.getConstants());
            res = new ArrayList<Object>();

            mav.addObject("monthsList", monthsList);

            if (request.getParameter("category").equalsIgnoreCase("child")) {
                if (request.getParameter("type").compareTo("1") == 0) {
                    if (startDate.compareTo("") != 0 && endDate.compareTo("") != 0) {
                        res = pmtct.getGeneralStatForInfantTests(startDate, endDate);
                        request.getSession().setAttribute("inf_stat_res", res);
                    }
                    mav.addObject("listHeaderTitle", "pmtct.menu.childTestResumePerPeriod");
                } else if (request.getParameter("type").compareTo("2") == 0) {
                    res = pmtct.getExpectedPatientsInPCR();
                    request.getSession().setAttribute("inf_stat_res", res);
                    mav.addObject("listHeaderTitle", "pmtct.menu.expectedChildInPCR");
                } else if (request.getParameter("type").compareTo("3") == 0) {
                    res = pmtct.getExpectedPatientsForSerologyAt9Months();
                    request.getSession().setAttribute("inf_stat_res", res);
                    mav.addObject("listHeaderTitle", "pmtct.menu.expectedChildInSerologyFor9Month");
                } else if (request.getParameter("type").compareTo("4") == 0) {
                    res = pmtct.getExpectedPatientsForSerologyAt18Months();
                    request.getSession().setAttribute("inf_stat_res", res);
                    mav.addObject("listHeaderTitle", "pmtct.menu.expectedChildInSerologyFor18Month");
                } else if (request.getParameter("type").compareTo("5") == 0) {
                    res = pmtct.getInfantByMoisDeRapportageByInfantTest(month, year, infantTestSelect);
                    request.getSession().setAttribute("inf_stat_res", res);
                    mav.addObject("listHeaderTitle", "pmtct.menu.moisDeRapportageInfantTests");
                }
            }

            for (int i = 0; i < PMTCTConfigurationUtils.getNumberOfRecordPerPage(); i++) {
                if (res.size() == 0)
                    break;
                if (i >= res.size() - 1) {
                    result.add(res.get(i));
                    break;
                } else
                    result.add(res.get(i));
            }

            //paging
            int n = (res.size() == ((int) (res.size() / PMTCTConfigurationUtils.getNumberOfRecordPerPage()))
                    * PMTCTConfigurationUtils.getNumberOfRecordPerPage())
                            ? (res.size() / PMTCTConfigurationUtils.getNumberOfRecordPerPage())
                            : ((int) (res.size() / PMTCTConfigurationUtils.getNumberOfRecordPerPage())) + 1;
            numberOfPages = new ArrayList<Integer>();
            for (int i = 1; i <= n; i++) {
                numberOfPages.add(i);
            }
            request.getSession().setAttribute("inf_stat_numberOfPages", numberOfPages);
        } else {
            res = (List<Object>) request.getSession().getAttribute("inf_stat_res");
            numberOfPages = (List<Integer>) request.getSession().getAttribute("inf_stat_numberOfPages");
            for (int i = (PMTCTConfigurationUtils.getNumberOfRecordPerPage()
                    * (Integer.parseInt(pageNumber) - 1)); i < PMTCTConfigurationUtils
                            .getNumberOfRecordPerPage() * (Integer.parseInt(pageNumber)); i++) {
                if (i >= res.size())
                    break;
                else
                    result.add(res.get(i));
            }
        }

        //page infos
        Object[] pagerInfos = new Object[3];
        pagerInfos[0] = (res.size() == 0) ? 0
                : (PMTCTConfigurationUtils.getNumberOfRecordPerPage() * (Integer.parseInt(pageNumber) - 1)) + 1;
        pagerInfos[1] = (PMTCTConfigurationUtils.getNumberOfRecordPerPage()
                * (Integer.parseInt(pageNumber)) <= res.size())
                        ? PMTCTConfigurationUtils.getNumberOfRecordPerPage() * (Integer.parseInt(pageNumber))
                        : res.size();
        pagerInfos[2] = res.size();

        ApplicationContext appContext = ContextProvider.getApplicationContext();

        mav.addObject("pageInfos", appContext.getMessage("pmtct.pagingInfo.showingResults", pagerInfos,
                Context.getUserContext().getLocale()));
        mav.addObject("numberOfPages", numberOfPages);
        mav.addObject("patientList", result);
        mav.addObject("pageSize", PMTCTConfigurationUtils.getNumberOfRecordPerPage());
        mav.addObject("startDate", startDate);
        mav.addObject("endDate", endDate);
        mav.addObject("positiveId", PMTCTConstants.POSITIVE);
        mav.addObject("infantFeedingMethodId", PMTCTConstants.INFANT_FEEDING_METHOD);

        List<Integer> years = new ArrayList<Integer>();
        for (int yr = 2000; yr < 2016; yr++)
            years.add(yr);
        mav.addObject("years", years);

        FileExporter fexp = new FileExporter();

        if (request.getParameter("export") != null
                && request.getParameter("export").compareToIgnoreCase("csv") == 0) {
            if (request.getParameter("type").compareTo("1") == 0)
                fexp.exportInfantsTestResumeToCSVFile(request, response, res,
                        "general_statistics_for_infant_tests_from_" + startDate + "_to_" + endDate + ".csv",
                        "General Statistics for Infant Tests");
            else if (request.getParameter("type").compareTo("2") == 0)
                fexp.exportInfantsTestToCSVFile(request, response, res,
                        "list_of_expected_infants_for_pcr_test.csv", "List of Expected Infants for PCR Test");
            else if (request.getParameter("type").compareTo("3") == 0)
                fexp.exportInfantsTestToCSVFile(request, response, res,
                        "list_of_expected_infants_for_serology_test_at_9months.csv",
                        "List of Expected Infants for Serology Test at 9 months");
            else if (request.getParameter("type").compareTo("4") == 0)
                fexp.exportInfantsTestToCSVFile(request, response, res,
                        "list_of_expected_infants_for_serology_test_at_18months.csv",
                        "List of Expected Infants for Serology Test at 18 months");
            else if (request.getParameter("type").compareTo("5") == 0) {
                fexp.exportInfantsTestToCSVFile(request, response, res,
                        "list_of_infant_mois_de_rapportage_" + ((infantTestSelect == 1) ? "PCR"
                                : (infantTestSelect == 2) ? "Serology at 9 months" : "Serology at 18 months")
                                + "_" + month + "_" + year + ".csv",
                        "Infant mois de rapportage " + ((infantTestSelect == 1) ? "PCR"
                                : (infantTestSelect == 2) ? "Serology at 9 months" : "Serology at 18 months")
                                + " (" + month + "_" + year + ")");
            }
        }
    } catch (Exception ex) {
        request.getSession().setAttribute(WebConstants.OPENMRS_ERROR_ATTR,
                "An error occured when trying to load data. Find the error in the log file.");
        log.error("INFANTS STATISTICS : An error occured when trying to load data from database: \n"
                + ex.getMessage());
        ex.printStackTrace();
    }

    return mav;
}

From source file:com.circle.utils.XMLSerializer.java

private void setValue(JSONArray jsonArray, Element element, String defaultType) {
    String clazz = getClass(element);
    String type = getType(element);
    type = (type == null) ? defaultType : type;

    if (hasNamespaces(element) && !skipNamespaces) {
        jsonArray.element(simplifyValue(null, processElement(element, type)));
        return;// www  .j  av a  2s .c  o m
    } else if (element.getAttributeCount() > 0) {
        if (isFunction(element)) {
            Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params"));
            String[] params = null;
            String text = element.getValue();
            params = StringUtils.split(paramsAttribute.getValue(), ",");
            jsonArray.element(new JSONFunction(params, text));
            return;
        } else {
            jsonArray.element(simplifyValue(null, processElement(element, type)));
            return;
        }
    }

    boolean classProcessed = false;
    if (clazz != null) {
        if (clazz.compareToIgnoreCase(JSONTypes.ARRAY) == 0) {
            jsonArray.element(processArrayElement(element, type));
            classProcessed = true;
        } else if (clazz.compareToIgnoreCase(JSONTypes.OBJECT) == 0) {
            jsonArray.element(simplifyValue(null, processObjectElement(element, type)));
            classProcessed = true;
        }
    }
    if (!classProcessed) {
        if (type.compareToIgnoreCase(JSONTypes.BOOLEAN) == 0) {
            jsonArray.element(Boolean.valueOf(element.getValue()));
        } else if (type.compareToIgnoreCase(JSONTypes.NUMBER) == 0) {
            // try integer first
            try {
                jsonArray.element(Integer.valueOf(element.getValue()));
            } catch (NumberFormatException e) {
                jsonArray.element(Double.valueOf(element.getValue()));
            }
        } else if (type.compareToIgnoreCase(JSONTypes.INTEGER) == 0) {
            jsonArray.element(Integer.valueOf(element.getValue()));
        } else if (type.compareToIgnoreCase(JSONTypes.FLOAT) == 0) {
            jsonArray.element(Double.valueOf(element.getValue()));
        } else if (type.compareToIgnoreCase(JSONTypes.FUNCTION) == 0) {
            String[] params = null;
            String text = element.getValue();
            Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params"));
            if (paramsAttribute != null) {
                params = StringUtils.split(paramsAttribute.getValue(), ",");
            }
            jsonArray.element(new JSONFunction(params, text));
        } else if (type.compareToIgnoreCase(JSONTypes.STRING) == 0) {
            // see if by any chance has a 'params' attribute
            Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params"));
            if (paramsAttribute != null) {
                String[] params = null;
                String text = element.getValue();
                params = StringUtils.split(paramsAttribute.getValue(), ",");
                jsonArray.element(new JSONFunction(params, text));
            } else {
                if (isArray(element, false)) {
                    jsonArray.element(processArrayElement(element, defaultType));
                } else if (isObject(element, false)) {
                    jsonArray.element(simplifyValue(null, processObjectElement(element, defaultType)));
                } else {
                    jsonArray.element(trimSpaceFromValue(element.getValue()));
                }
            }
        }
    }
}

From source file:com.krawler.spring.crm.dashboard.CrmDashboardController.java

private ArrayList getBubbleSortList(ArrayList lis) throws ServiceException, JSONException {
    for (int x = 1; x < lis.size(); x++) {
        for (int i = 0; i < lis.size() - x; i++) {
            JSONObject jobj = new JSONObject(lis.get(i).toString());
            String reportname = jobj.get("name").toString().toLowerCase();
            JSONObject jobj1 = new JSONObject(lis.get(i + 1).toString());
            String reportname1 = jobj1.get("name").toString().toLowerCase();
            if (reportname.compareToIgnoreCase(reportname1) > 0) {
                Object temp = lis.get(i);
                lis.set(i, lis.get(i + 1));
                lis.set(i + 1, temp);//from  w  ww .ja v  a2s  .  c o m
            }
        }
    }
    return lis;
}

From source file:com.sentaroh.android.Utilities.Dialog.FileSelectDialogFragment.java

private void updateTreeFileList(String p_dir, final String creat_dir, final String r_dir,
        final TreeFilelistAdapter tfa, final ListView lv) {
    //      Log.v("","p_dir="+p_dir+", create_dir="+creat_dir+", r_dir="+r_dir);
    File lf = new File(r_dir + p_dir + creat_dir);
    if (!p_dir.equals("/")) {//not root
        for (int i = tfa.getDataItemCount() - 1; i >= 0; i--) {
            TreeFilelistItem tfi = tfa.getDataItem(i);
            if (tfi.isDir()) {
                String fp = tfi.getPath() + tfi.getName();
                //                  Log.v("","fp="+fp);
                if (fp.equalsIgnoreCase(p_dir)) {
                    if (tfi.isSubDirLoaded())
                        tfa.removeChildItem(tfi, i);
                    int sdc = tfa.getDataItem(i).getSubDirItemCount();
                    sdc++;//from ww  w .  java  2 s.c  o m
                    tfa.getDataItem(i).setSubDirItemCount(sdc);
                    processLocalDirTree(mDialogFileOnly, r_dir, i, tfi, tfa);
                    lv.setSelection(i);
                }
            }
        }
    } else {//root
        if (findDirEntry(tfa, "/", creat_dir) >= 0)
            return;
        boolean found = false;
        for (int i = tfa.getDataItemCount() - 1; i >= 0; i--) {
            TreeFilelistItem tfi = tfa.getDataItem(i);
            String fp = tfi.getPath() + tfi.getName();
            //              Log.v("","tfi name="+tfi.getPath()+", comp="+fp.compareToIgnoreCase(p_dir+creat_dir));
            if (tfi.isDir()) {
                if (fp.compareToIgnoreCase(p_dir + creat_dir) < 0) {
                    found = true;
                    tfi = buildTreeFileListItem(lf, "/");
                    tfi.setSubDirItemCount(0);
                    if ((i + 1) > tfa.getDataItemCount()) {
                        tfa.addDataItem(tfi);
                    } else {
                        int ip = findNextDirEntry(tfa, i + 1);
                        if (ip >= 0)
                            tfa.insertDataItem(ip, tfi);
                        else {
                            ip = findLastDirEntry(tfa);
                            if (ip >= 0)
                                tfa.insertDataItem(ip + 1, tfi);
                            else
                                tfa.insertDataItem(0, tfi);
                        }
                    }
                    tfa.createShowList();
                    break;
                }
            }
        }
        if (!found) {
            TreeFilelistItem tfi = buildTreeFileListItem(lf, "/");
            tfa.insertDataItem(0, tfi);
        }
    }
}

From source file:com.sun.honeycomb.adm.client.AdminClientImpl.java

protected void logSetupCellProps(String cellId, HCSetupCell newProps, String logMethod) {

    String methodName = "setSetupCell";
    Object[] params;//from  w ww . j  a  va2  s  .  c  o m
    String logSessionId = Long.toString(this._sessionId);
    String msgKey = "";
    Level logLevel = ExtLevel.EXT_INFO;

    // Cell config properties
    msgKey = AdminResourcesConstants.MSG_KEY_SETUP_CELL_IP_CONFIG;
    params = new Object[] { logSessionId, cellId, newProps.getAdminVIP(), newProps.getDataVIP(),
            newProps.getSpVIP(), newProps.getSpVIP(), newProps.getSubnet() };
    for (int i = 0; i < params.length; i++) {
        if (params[i] == null) {
            params[i] = "";
        }
    }
    this.extLog(logLevel, msgKey, params, logMethod);

    // Hive configuration
    msgKey = AdminResourcesConstants.MSG_KEY_SETUP_CELL_HIVE_CONFIG;
    params = new Object[] { logSessionId, cellId, newProps.getNtpServer(), newProps.getSmtpServer(),
            newProps.getSmtpPort(), newProps.getExtLogger(), newProps.getAuthorizedClients() };
    for (int i = 0; i < params.length; i++) {
        if (params[i] == null) {
            params[i] = "";
        }
    }

    this.extLog(logLevel, msgKey, params, logMethod);

    //  DNS Configuration
    params = new Object[] { logSessionId, cellId, newProps.getDomainName(), newProps.getPrimaryDnsServer(),
            newProps.getSecondaryDnsServer(), newProps.getDnsSearch() };
    for (int i = 0; i < params.length; i++) {
        if (params[i] == null) {
            params[i] = "";
        }
    }
    String dnsSetting = newProps.getDns();
    if (dnsSetting != null
            && (dnsSetting.compareToIgnoreCase("y") == 0 || dnsSetting.compareToIgnoreCase("Yes") == 0)) {
        msgKey = AdminResourcesConstants.MSG_KEY_SETUP_CELL_DNS_ENABLED;
    } else {
        msgKey = AdminResourcesConstants.MSG_KEY_SETUP_CELL_DNS_DISABLED;
    }

    this.extLog(logLevel, msgKey, params, logMethod);

}

From source file:com.zimbra.cs.mailbox.calendar.Invite.java

public static ICalTok lookupMethod(String methodName) {
    ICalTok toRet;//www.  j  a v a 2  s  .  c  o  m
    String methodNameUpper = methodName.toUpperCase(); // work around livemeeting.com bug
    try {
        toRet = ICalTok.valueOf(methodNameUpper);
    } catch (IllegalArgumentException e) {
        toRet = ICalTok.PUBLISH;
        // Apple iCal generates non-standard "METHOD:EXPORT".
        if (methodNameUpper.compareToIgnoreCase("EXPORT") != 0)
            sLog.warn("Invalid METHOD " + methodName + "; assuming PUBLISH", e);
    }
    switch (toRet) {
    case REQUEST:
    case PUBLISH:
    case REPLY:
    case ADD:
    case CANCEL:
    case REFRESH:
    case COUNTER:
    case DECLINECOUNTER:
        return toRet;
    default:
        return ICalTok.PUBLISH;
    }
}

From source file:com.circle.utils.XMLSerializer.java

private void setValue(JSONObject jsonObject, Element element, String defaultType) {
    String clazz = getClass(element);
    String type = getType(element);
    type = (type == null) ? defaultType : type;

    String key = removeNamespacePrefix(element.getQualifiedName());
    if (hasNamespaces(element) && !skipNamespaces) {
        setOrAccumulate(jsonObject, key, simplifyValue(jsonObject, processElement(element, type)));
        return;/*w  w w  . ja  v a  2 s  .  c o  m*/
    } else if (element.getAttributeCount() > 0) {
        if (isFunction(element)) {
            Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params"));
            String text = element.getValue();
            String[] params = StringUtils.split(paramsAttribute.getValue(), ",");
            setOrAccumulate(jsonObject, key, new JSONFunction(params, text));
            return;
        } /*else{
            setOrAccumulate( jsonObject, key, simplifyValue( jsonObject, processElement( element,
            type ) ) );
            return;
          }*/
    }

    boolean classProcessed = false;
    if (clazz != null) {
        if (clazz.compareToIgnoreCase(JSONTypes.ARRAY) == 0) {
            setOrAccumulate(jsonObject, key, processArrayElement(element, type));
            classProcessed = true;
        } else if (clazz.compareToIgnoreCase(JSONTypes.OBJECT) == 0) {
            setOrAccumulate(jsonObject, key, simplifyValue(jsonObject, processObjectElement(element, type)));
            classProcessed = true;
        }
    }
    if (!classProcessed) {
        if (type.compareToIgnoreCase(JSONTypes.BOOLEAN) == 0) {
            setOrAccumulate(jsonObject, key, Boolean.valueOf(element.getValue()));
        } else if (type.compareToIgnoreCase(JSONTypes.NUMBER) == 0) {
            // try integer first
            try {
                setOrAccumulate(jsonObject, key, Integer.valueOf(element.getValue()));
            } catch (NumberFormatException e) {
                setOrAccumulate(jsonObject, key, Double.valueOf(element.getValue()));
            }
        } else if (type.compareToIgnoreCase(JSONTypes.INTEGER) == 0) {
            setOrAccumulate(jsonObject, key, Integer.valueOf(element.getValue()));
        } else if (type.compareToIgnoreCase(JSONTypes.FLOAT) == 0) {
            setOrAccumulate(jsonObject, key, Double.valueOf(element.getValue()));
        } else if (type.compareToIgnoreCase(JSONTypes.FUNCTION) == 0) {
            String[] params = null;
            String text = element.getValue();
            Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params"));
            if (paramsAttribute != null) {
                params = StringUtils.split(paramsAttribute.getValue(), ",");
            }
            setOrAccumulate(jsonObject, key, new JSONFunction(params, text));
        } else if (type.compareToIgnoreCase(JSONTypes.STRING) == 0) {
            // see if by any chance has a 'params' attribute
            Attribute paramsAttribute = element.getAttribute(addJsonPrefix("params"));
            if (paramsAttribute != null) {
                String[] params = null;
                String text = element.getValue();
                params = StringUtils.split(paramsAttribute.getValue(), ",");
                setOrAccumulate(jsonObject, key, new JSONFunction(params, text));
            } else {
                if (isArray(element, false)) {
                    setOrAccumulate(jsonObject, key, processArrayElement(element, defaultType));
                } else if (isObject(element, false)) {
                    setOrAccumulate(jsonObject, key,
                            simplifyValue(jsonObject, processObjectElement(element, defaultType)));
                } else {
                    setOrAccumulate(jsonObject, key, trimSpaceFromValue(element.getValue()));
                }
            }
        }
    }
}