Example usage for java.lang NumberFormatException printStackTrace

List of usage examples for java.lang NumberFormatException printStackTrace

Introduction

In this page you can find the example usage for java.lang NumberFormatException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.znsx.cms.web.controller.DeviceController.java

@InterfaceDescription(logon = true, method = "Update_Camera", cmd = "2061")
@RequestMapping("/update_camera.json")
public void updateCamera(HttpServletRequest request, HttpServletResponse response) throws Exception {
    SimpleRequestReader reader = new SimpleRequestReader(request);
    String id = request.getParameter("id");
    if (StringUtils.isBlank(id)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [id]");
    }//from www. j a v a  2  s .c  o  m
    String standardNumber = request.getParameter("standardNumber");

    String subType = request.getParameter("subType");

    String name = request.getParameter("name");
    if (null != name && StringUtils.isBlank(name)) {
        throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Can not modify name to empty !");
    }
    name = StringUtils.replace(name, " ", "+");
    String mssId = request.getParameter("mssId");

    String crsId = request.getParameter("crsId");

    Short storeType = null;
    String storeTypeString = request.getParameter("storeType");
    if (StringUtils.isNotBlank(storeTypeString)) {
        try {
            storeType = Short.parseShort(storeTypeString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter storeType[" + storeTypeString + "] invalid !");
        }
    }

    String localStorePlan = request.getParameter("localStorePlan");

    String centerStorePlan = request.getParameter("centerStorePlan");

    String organId = request.getParameter("organId");

    String manufacturerId = request.getParameter("manufacturerId");

    String location = request.getParameter("location");

    String parentId = request.getParameter("parentId");

    Short channelNumber = null;
    String channelId = request.getParameter("channelId");
    if (StringUtils.isNotBlank(channelId)) {
        try {
            channelNumber = Short.parseShort(channelId);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter channelId[" + channelId + "] invalid !");
        }
    }

    String streamType = request.getParameter("streamType");

    String note = request.getParameter("note");

    String expand = request.getParameter("expand");

    String navigation = request.getParameter("navigation");

    String stakeNumber = request.getParameter("stakeNumber");
    stakeNumber = StringUtils.replace(stakeNumber, " ", "+");

    String deviceModelId = request.getParameter("deviceModelId");

    String owner = reader.getString("owner", true);

    String civilCode = reader.getString("civilCode", true);

    Double block = reader.getDouble("block", true);

    String certNum = reader.getString("certNum", true);

    Integer certifiable = reader.getInteger("certifiable", true);

    Integer errCode = reader.getInteger("errCode", true);

    Long endTime = reader.getLong("endTime", true);

    String rmsId = reader.getString("rmsId", true);

    String storeStream = reader.getString("storeStream", true);

    deviceManager.updateCamera(id, standardNumber, subType, name, organId, manufacturerId, location, note,
            storeType, localStorePlan, centerStorePlan, streamType, parentId, mssId, crsId, channelNumber,
            deviceModelId, expand, navigation, stakeNumber, owner, civilCode, block, certNum, certifiable,
            errCode, endTime, rmsId, storeStream);

    BaseDTO dto = new BaseDTO();
    dto.setCmd("2061");
    dto.setMethod("Update_Camera");
    writePage(response, dto);
}

From source file:com.maxl.java.aips2xml.Aips2Xml.java

static void extractPackageInfo() {
    try {/*from  w  ww . j a va2s.  c  om*/
        long startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Processing packages xls ... ");
        // Load Swissmedic xls file
        FileInputStream packages_file = new FileInputStream(FILE_PACKAGES_XLS);
        // Get workbook instance for XLS file (HSSF = Horrible SpreadSheet Format)
        HSSFWorkbook packages_workbook = new HSSFWorkbook(packages_file);
        // Get first sheet from workbook
        HSSFSheet packages_sheet = packages_workbook.getSheetAt(0);
        // Iterate through all rows of first sheet
        Iterator<Row> rowIterator = packages_sheet.iterator();

        int num_rows = 0;
        while (rowIterator.hasNext()) {
            Row row = rowIterator.next();
            if (num_rows > 3) {
                String swissmedic_no5 = ""; // SwissmedicNo5 registration number (5 digits)
                String sequence_name = "";
                String package_id = "";
                String swissmedic_no8 = ""; // SwissmedicNo8 = SwissmedicNo5 + Package id (8 digits)
                String heilmittel_code = "";
                String package_size = "";
                String package_unit = "";
                String swissmedic_cat = "";
                String application_area = "";
                String public_price = "";
                String exfactory_price = "";
                String therapeutic_index = "";
                String withdrawn_str = "";
                String speciality_str = "";
                String plimitation_str = "";
                String add_info_str = ""; // Contains additional information separated by ;

                // 0: Zulassungsnnr, 1: Sequenz, 2: Sequenzname, 3: Zulassunginhaberin, 4: T-Nummer, 5: ATC-Code, 6: Heilmittelcode
                // 7: Erstzulassung Prparat, 8: Zulassungsdatum Sequenz, 9: Gltigkeitsdatum, 10: Verpackung, 11: Packungsgrsse
                // 12: Einheit, 13: Abgabekategorie, 14: Wirkstoff, 15: Zusammensetzung, 16: Anwendungsgebiet Prparat, 17: Anwendungsgebiet Sequenz

                swissmedic_no5 = getAnyValue(row.getCell(0)); // Swissmedic registration number (5 digits)
                sequence_name = getAnyValue(row.getCell(2)); // Sequence name
                heilmittel_code = getAnyValue(row.getCell(6));
                package_size = getAnyValue(row.getCell(11));
                package_unit = getAnyValue(row.getCell(12));
                swissmedic_cat = getAnyValue(row.getCell(13));
                application_area = getAnyValue(row.getCell(16));

                if (row.getCell(10) != null) {
                    package_id = getAnyValue(row.getCell(10));
                    swissmedic_no8 = swissmedic_no5 + package_id;
                    // Fill in row
                    ArrayList<String> pack = new ArrayList<String>();
                    pack.add(swissmedic_no5); // 0
                    pack.add(sequence_name); // 1
                    pack.add(heilmittel_code); // 2
                    pack.add(package_size); // 3
                    pack.add(package_unit); // 4
                    pack.add(swissmedic_cat); // 5
                    if (!application_area.isEmpty())
                        pack.add(application_area + " (Swissmedic)\n"); // 6 = swissmedic + bag
                    else
                        pack.add("");
                    pack.add(public_price); // 7
                    pack.add(exfactory_price); // 8
                    pack.add(therapeutic_index); // 9
                    pack.add(withdrawn_str); // 10
                    pack.add(speciality_str); // 11   
                    pack.add(plimitation_str); // 12
                    pack.add(add_info_str); // 13

                    package_info.put(swissmedic_no8, pack);
                }
            }
            num_rows++;
        }
        long stopTime = System.currentTimeMillis();
        if (SHOW_LOGS) {
            System.out.println(
                    (package_info.size() + 1) + " packages in " + (stopTime - startTime) / 1000.0f + " sec");
        }
        startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Processing atc classes xls ... ");
        if (DB_LANGUAGE.equals("de")) {
            // Load ATC classes xls file
            FileInputStream atc_classes_file = new FileInputStream(FILE_ATC_CLASSES_XLS);
            // Get workbook instance for XLS file (HSSF = Horrible SpreadSheet Format)
            HSSFWorkbook atc_classes_workbook = new HSSFWorkbook(atc_classes_file);
            // Get first sheet from workbook
            HSSFSheet atc_classes_sheet = atc_classes_workbook.getSheetAt(1);
            // Iterate through all rows of first sheet
            rowIterator = atc_classes_sheet.iterator();

            num_rows = 0;
            while (rowIterator.hasNext()) {
                Row row = rowIterator.next();
                if (num_rows > 2) {
                    String atc_code = "";
                    String atc_class = "";
                    if (row.getCell(0) != null) {
                        atc_code = row.getCell(0).getStringCellValue().replaceAll("\\s", "");
                    }
                    if (row.getCell(2) != null) {
                        atc_class = row.getCell(2).getStringCellValue();
                    }
                    // Build a full map atc code to atc class
                    if (atc_code.length() > 0) {
                        atc_map.put(atc_code, atc_class);
                    }
                }
                num_rows++;
            }
        } else if (DB_LANGUAGE.equals("fr")) {
            // Load multilinguagl ATC classes txt file
            String atc_classes_multi = readFromFile(FILE_ATC_MULTI_LINGUAL_TXT);
            // Loop through all lines
            Scanner scanner = new Scanner(atc_classes_multi);
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                List<String> atc_class = Arrays.asList(line.split(": "));
                String atc_code = atc_class.get(0);
                String[] atc_classes_str = atc_class.get(1).split(";");
                String atc_class_french = atc_classes_str[1].trim();
                atc_map.put(atc_code, atc_class_french);
            }
            scanner.close();
        }
        stopTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out
                    .println((atc_map.size() + 1) + " classes in " + (stopTime - startTime) / 1000.0f + " sec");
        // Load Refdata xml file
        File refdata_xml_file = null;
        if (DB_LANGUAGE.equals("de"))
            refdata_xml_file = new File(FILE_REFDATA_PHARMA_DE_XML);
        else if (DB_LANGUAGE.equals("fr"))
            refdata_xml_file = new File(FILE_REFDATA_PHARMA_FR_XML);
        else {
            System.err.println("ERROR: DB_LANGUAGE undefined");
            System.exit(1);
        }
        FileInputStream refdata_fis = new FileInputStream(refdata_xml_file);

        startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Unmarshalling Refdata Pharma " + DB_LANGUAGE + " ... ");

        JAXBContext context = JAXBContext.newInstance(Pharma.class);
        Unmarshaller um = context.createUnmarshaller();
        Pharma refdataPharma = (Pharma) um.unmarshal(refdata_fis);
        List<Pharma.ITEM> pharma_list = refdataPharma.getItem();

        String smno8;
        for (Pharma.ITEM pharma : pharma_list) {
            String ean_code = pharma.getGtin();
            if (ean_code.length() == 13) {
                smno8 = ean_code.substring(4, 12);
                // Extract pharma corresponding to swissmedicno8
                ArrayList<String> pi_row = package_info.get(smno8);
                // Replace sequence_name
                if (pi_row != null) {
                    if (pharma.getAddscr().length() > 0)
                        pi_row.set(1, pharma.getDscr() + ", " + pharma.getAddscr());
                    else
                        pi_row.set(1, pharma.getDscr());
                    if (pharma.getStatus().equals("I")) {
                        if (DB_LANGUAGE.equals("de"))
                            pi_row.set(10, "a.H.");
                        else if (DB_LANGUAGE.equals("fr"))
                            pi_row.set(10, "p.c.");
                    }
                } else {
                    if (SHOW_ERRORS)
                        System.err.println(">> Does not exist in BAG xls: " + smno8 + " (" + pharma.getDscr()
                                + ", " + pharma.getAddscr() + ")");
                }

            } else if (ean_code.length() < 13) {
                if (SHOW_ERRORS)
                    System.err.println(">> EAN code too short: " + ean_code + ": " + pharma.getDscr());
            } else if (ean_code.length() > 13) {
                if (SHOW_ERRORS)
                    System.err.println(">> EAN code too long: " + ean_code + ": " + pharma.getDscr());
            }
        }

        stopTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.println(pharma_list.size() + " medis in " + (stopTime - startTime) / 1000.0f + " sec");

        // Load BAG xml file               
        File bag_xml_file = new File(FILE_PREPARATIONS_XML);
        FileInputStream fis_bag = new FileInputStream(bag_xml_file);

        startTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.print("- Processing preparations xml ... ");

        context = JAXBContext.newInstance(Preparations.class);
        um = context.createUnmarshaller();
        Preparations prepInfos = (Preparations) um.unmarshal(fis_bag);
        List<Preparations.Preparation> prep_list = prepInfos.getPreparations();

        int num_preparations = 0;
        for (Preparations.Preparation prep : prep_list) {
            String swissmedicno5_str = prep.getSwissmedicNo5();
            if (swissmedicno5_str != null) {
                String orggencode_str = ""; // "O", "G" or empty -> ""
                String flagSB20_str = ""; // "Y" -> 20% or "N" -> 10%                     
                if (prep.getOrgGenCode() != null)
                    orggencode_str = prep.getOrgGenCode();
                if (prep.getFlagSB20() != null) {
                    flagSB20_str = prep.getFlagSB20();
                    if (flagSB20_str.equals("Y")) {
                        if (DB_LANGUAGE.equals("de"))
                            flagSB20_str = "SB 20%";
                        else if (DB_LANGUAGE.equals("fr"))
                            flagSB20_str = "QP 20%";
                    } else if (flagSB20_str.equals("N")) {
                        if (DB_LANGUAGE.equals("de"))
                            flagSB20_str = "SB 10%";
                        else if (DB_LANGUAGE.equals("fr"))
                            flagSB20_str = "QP 10%";
                    } else
                        flagSB20_str = "";
                }
                add_info_map.put(swissmedicno5_str, orggencode_str + ";" + flagSB20_str);
            }

            List<Preparation.Packs> packs_list = prep.getPacks();
            for (Preparation.Packs packs : packs_list) {
                // Extract codes for therapeutic index / classification
                String bag_application = "";
                String therapeutic_code = "";
                List<Preparations.Preparation.ItCodes> itcode_list = prep.getItCodes();
                for (Preparations.Preparation.ItCodes itc : itcode_list) {
                    List<Preparations.Preparation.ItCodes.ItCode> code_list = itc.getItCode();
                    int index = 0;
                    for (Preparations.Preparation.ItCodes.ItCode code : code_list) {
                        if (index == 0) {
                            if (DB_LANGUAGE.equals("de"))
                                therapeutic_code = code.getDescriptionDe();
                            else if (DB_LANGUAGE.equals("fr"))
                                therapeutic_code = code.getDescriptionFr();
                        } else {
                            if (DB_LANGUAGE.equals("de"))
                                bag_application = code.getDescriptionDe();
                            else if (DB_LANGUAGE.equals("fr"))
                                bag_application = code.getDescriptionFr();
                        }
                        index++;
                    }
                }
                // Generate new package info
                List<Preparation.Packs.Pack> pack_list = packs.getPack();
                for (Preparation.Packs.Pack pack : pack_list) {
                    // Get SwissmedicNo8 and used it as a key to extract all the relevant package info
                    String swissMedicNo8 = pack.getSwissmedicNo8();
                    ArrayList<String> pi_row = package_info.get(swissMedicNo8);
                    // Preparation also in BAG xml file (we have a price)
                    if (pi_row != null) {
                        // Update Swissmedic catory if necessary ("N->A", Y->"A+")
                        if (pack.getFlagNarcosis().equals("Y"))
                            pi_row.set(5, pi_row.get(5) + "+");
                        // Extract point limitations
                        List<Preparations.Preparation.Packs.Pack.PointLimitations> point_limits = pack
                                .getPointLimitations();
                        for (Preparations.Preparation.Packs.Pack.PointLimitations limits : point_limits) {
                            List<Preparations.Preparation.Packs.Pack.PointLimitations.PointLimitation> plimits_list = limits
                                    .getPointLimitation();
                            if (plimits_list.size() > 0)
                                if (plimits_list.get(0) != null)
                                    pi_row.set(12, ", LIM" + plimits_list.get(0).getPoints() + "");
                        }
                        // Extract exfactory and public prices
                        List<Preparations.Preparation.Packs.Pack.Prices> price_list = pack.getPrices();
                        for (Preparations.Preparation.Packs.Pack.Prices price : price_list) {
                            List<Preparations.Preparation.Packs.Pack.Prices.PublicPrice> public_price = price
                                    .getPublicPrice();
                            List<Preparations.Preparation.Packs.Pack.Prices.ExFactoryPrice> exfactory_price = price
                                    .getExFactoryPrice();
                            if (exfactory_price.size() > 0) {
                                try {
                                    float f = Float.valueOf(exfactory_price.get(0).getPrice());
                                    String ep = String.format("%.2f", f);
                                    pi_row.set(8, "CHF " + ep);
                                } catch (NumberFormatException e) {
                                    if (SHOW_ERRORS)
                                        System.err.println("Number format exception (exfactory price): "
                                                + swissMedicNo8 + " (" + public_price.size() + ")");
                                }

                            }
                            if (public_price.size() > 0) {
                                try {
                                    float f = Float.valueOf(public_price.get(0).getPrice());
                                    String pp = String.format("%.2f", f);
                                    pi_row.set(7, "CHF " + pp);
                                    if (DB_LANGUAGE.equals("de"))
                                        pi_row.set(11, ", SL");
                                    else if (DB_LANGUAGE.equals("fr"))
                                        pi_row.set(11, ", LS");
                                } catch (NumberFormatException e) {
                                    if (SHOW_ERRORS)
                                        System.err.println("Number format exception (public price): "
                                                + swissMedicNo8 + " (" + public_price.size() + ")");
                                }
                            }
                            // Add application area and therapeutic code
                            if (!bag_application.isEmpty())
                                pi_row.set(6, pi_row.get(6) + bag_application + " (BAG)");
                            pi_row.set(9, therapeutic_code);
                        }
                    }
                }
            }
            num_preparations++;
        }

        stopTime = System.currentTimeMillis();
        if (SHOW_LOGS)
            System.out.println(
                    num_preparations + " preparations in " + (stopTime - startTime) / 1000.0f + " sec");

        // Loop through all SwissmedicNo8 numbers
        for (Map.Entry<String, ArrayList<String>> entry : package_info.entrySet()) {
            String swissmedicno8 = entry.getKey();
            ArrayList<String> pi_row = entry.getValue();
        }

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}

From source file:com.znsx.cms.web.controller.DeviceController.java

@InterfaceDescription(logon = true, method = "Create_Camera", cmd = "2060")
@RequestMapping("/create_camera.json")
public void createCamera(HttpServletRequest request, HttpServletResponse response) throws Exception {
    SimpleRequestReader reader = new SimpleRequestReader(request);

    String standardNumber = request.getParameter("standardNumber");

    String subType = request.getParameter("subType");
    if (StringUtils.isBlank(subType)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [subType]");
    }//  ww  w. jav a 2 s  .c  om

    String name = request.getParameter("name");
    if (StringUtils.isBlank(name)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [name]");
    }
    name = StringUtils.replace(name, " ", "+");
    String mssId = request.getParameter("mssId");

    String crsId = request.getParameter("crsId");

    Short storeType = null;
    String storeTypeString = request.getParameter("storeType");
    if (StringUtils.isBlank(storeTypeString)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [storeType]");
    } else {
        try {
            storeType = Short.parseShort(storeTypeString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter storeType[" + storeTypeString + "] invalid !");
        }
    }

    String localStorePlan = request.getParameter("localStorePlan");

    String centerStorePlan = request.getParameter("centerStorePlan");

    String organId = request.getParameter("organId");
    if (StringUtils.isBlank(organId)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [organId]");
    }

    String manufacturerId = request.getParameter("manufacturerId");

    String location = request.getParameter("location");

    String parentId = request.getParameter("parentId");
    if (StringUtils.isBlank(parentId)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [parentId]");
    }

    Short channelNumber = null;
    String channelId = request.getParameter("channelId");
    if (StringUtils.isBlank(channelId)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [channelId]");
    } else {
        try {
            channelNumber = Short.parseShort(channelId);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter channelId[" + channelId + "] invalid !");
        }
    }

    String streamType = request.getParameter("streamType");

    String note = request.getParameter("note");

    String deviceModelId = request.getParameter("deviceModelId");

    String expand = request.getParameter("expand");
    String navigation = request.getParameter("navigation");
    String stakeNumber = request.getParameter("stakeNumber");
    stakeNumber = StringUtils.replace(stakeNumber, " ", "+");

    String owner = reader.getString("owner", true);

    String civilCode = reader.getString("civilCode", true);

    Double block = reader.getDouble("block", true);

    String certNum = reader.getString("certNum", true);

    Integer certifiable = reader.getInteger("certifiable", true);

    Integer errCode = reader.getInteger("errCode", true);

    Long endTime = reader.getLong("endTime", true);

    String rmsId = reader.getString("rmsId", true);

    String storeStream = reader.getString("storeStream", true);

    // License
    License license = licenseManager.getLicense();
    int cameraAmount = Integer.parseInt(license.getCameraAmount());
    int cameraCount = deviceManager.countCamera();
    if (cameraCount >= cameraAmount) {
        throw new BusinessException(ErrorCode.CAMERA_AMOUNT_LIMIT, "Camera amount over license limit !");
    }

    // ??
    if (StringUtils.isBlank(standardNumber)) {
        standardNumber = userManager.generateStandardNum("Camera", organId);
    }

    String id = deviceManager.createCamera(standardNumber, subType, name, organId, manufacturerId, location,
            note, storeType, localStorePlan, centerStorePlan, streamType, parentId, mssId, crsId, channelNumber,
            deviceModelId, expand, navigation, stakeNumber, owner, civilCode, block, certNum, certifiable,
            errCode, endTime, rmsId, storeStream);

    BaseDTO dto = new BaseDTO();
    dto.setCmd("2060");
    dto.setMethod("Create_Camera");
    dto.setMessage(id);

    writePage(response, dto);
}

From source file:com.znsx.cms.web.controller.DeviceController.java

@InterfaceDescription(logon = true, method = "Update_Dvr", cmd = "2051")
@RequestMapping("/update_dvr.json")
public void updateDvr(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String id = request.getParameter("id");
    if (StringUtils.isBlank(id)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [id]");
    }/*from   w w w.  j  a  v a2 s  .  c  om*/
    String standardNumber = request.getParameter("standardNumber");

    String subType = request.getParameter("subType");

    String name = request.getParameter("name");
    if (null != name && StringUtils.isBlank(name)) {
        throw new BusinessException(ErrorCode.PARAMETER_INVALID, "Can not modify name to empty !");
    }
    name = StringUtils.replace(name, " ", "+");
    String ptsId = request.getParameter("ptsId");

    String transport = request.getParameter("transport");

    String mode = request.getParameter("mode");

    Integer maxConnect = null;
    String maxConnectString = request.getParameter("maxConnect");
    if (StringUtils.isNotBlank(maxConnectString)) {
        try {
            maxConnect = Integer.parseInt(maxConnectString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter maxConnect[" + maxConnectString + "] invalid !");
        }
    }

    String organId = request.getParameter("organId");

    String linkType = request.getParameter("linkType");

    String lanIp = request.getParameter("lanIp");

    Integer port = null;
    String portString = request.getParameter("port");
    if (StringUtils.isNotBlank(portString)) {
        try {
            port = Integer.parseInt(portString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter port[" + portString + "] invalid !");
        }
    }

    String manufacturerId = request.getParameter("manufacturerId");

    String deviceModelId = request.getParameter("deviceModelId");

    String location = request.getParameter("location");

    String note = request.getParameter("note");

    String userName = request.getParameter("userName");

    String password = request.getParameter("password");

    Integer heartCycle = null;
    String heartCycleString = request.getParameter("heartCycle");
    if (StringUtils.isNotBlank(heartCycleString)) {
        try {
            heartCycle = Integer.parseInt(heartCycleString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter heartCycle[" + heartCycleString + "] invalid !");
        }
    }

    String expand = request.getParameter("expand");

    Integer aicAmount = null;
    String aicAmountString = request.getParameter("aicAmount");
    if (StringUtils.isNotBlank(aicAmountString)) {
        try {
            aicAmount = Integer.parseInt(aicAmountString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter aicAmount[" + aicAmountString + "] invalid !");
        }
    }

    Integer aocAmount = null;
    String aocAmountString = request.getParameter("aocAmount");
    if (StringUtils.isNotBlank(aocAmountString)) {
        try {
            aocAmount = Integer.parseInt(aocAmountString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter aocAmount[" + aocAmountString + "] invalid !");
        }
    }

    Integer channelAmount = null;
    String channelAmountString = request.getParameter("channelAmount");
    if (StringUtils.isNotBlank(channelAmountString)) {
        try {
            channelAmount = Integer.parseInt(channelAmountString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter channelAmount[" + channelAmountString + "] invalid !");
        }
    }

    String decode = request.getParameter("decode");

    deviceManager.updateDvr(id, standardNumber, subType, name, ptsId, transport, mode, maxConnect, organId,
            linkType, lanIp, port, manufacturerId, deviceModelId, location, note, userName, password,
            heartCycle, expand, aicAmount, aocAmount, channelAmount, decode);
    BaseDTO dto = new BaseDTO();
    dto.setCmd("2051");
    dto.setMethod("Update_Dvr");
    writePage(response, dto);
}

From source file:com.hhwt.travelplanner.adapter.MyCategorylistadapter.java

@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {

    /*      for (int i =0; i <items.size(); i++){*/

    newsno = items.get(position).getSno();
    // Sessiondata.getInstance().setSnonotes(newsno);
    Log.d("newsno", "" + newsno);

    //  }//  w  w w  .  j  ava  2 s .c  o  m

    final Categorylistmodelmytrip item = items.get(position);
    if (position == 0) {
        daycount = 1;
    }
    snno = item.getSno();

    AlertUtils.RatingColorGreen(mContext, holder.item_ratingBar);

    Log.d("create notes", "" + snno);
    try {
        Float rate = Float.parseFloat(item.getRating());
        holder.item_ratingBar.setRating(rate);
        holder.item_ratingBar.setEnabled(false);
    } catch (NumberFormatException e) {
        holder.item_ratingBar.setRating(0);
        holder.item_ratingBar.setEnabled(false);
    }
    holder.title.setText(item.getName());
    holder.subtitle.setText(item.getActivity());
    holder.address.setText(item.getDescription());

    String yourdate = Date_utill.Dateformatchangeforall(item.getDate());
    if (emptydate.equalsIgnoreCase(yourdate)) {
        //     holder.Dateis.setText("(Day " + daycount + ") " + yourdate);
        holder.Dateis.setText(yourdate);
    } else {
        emptydate = yourdate;
        //      holder.Dateis.setText("(Day " + daycount + ") " + yourdate);
        holder.Dateis.setText(yourdate);
        ++daycount;
    }
    final ViewHolder vh = holder;
    if (item.photos.size() > 0) {
        try {
            final String s = item.getPhotos().get(0).getPhotourl();
            //         PicassoCache.getPicassoInstance(mContext).load(s).into(holder.image);
            Picasso.with(mContext).load(s).networkPolicy(NetworkPolicy.OFFLINE).into(holder.image,
                    new Callback() {
                        @Override
                        public void onSuccess() {

                        }

                        @Override
                        public void onError() {
                            //Try again online if cache failed
                            Picasso.with(mContext).load(s).error(R.drawable.background_default)
                                    .placeholder(R.drawable.loading).into(vh.image, new Callback() {
                                        @Override
                                        public void onSuccess() {

                                        }

                                        @Override
                                        public void onError() {
                                            //  vs.Icon.setImageResource(R.drawable.groupchat_icon_48dp);
                                        }
                                    });
                        }
                    });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    Animation animation = AnimationUtils.loadAnimation(mContext,
            (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top);
    holder.cd.startAnimation(animation);
    lastPosition = position;
    holder.itemView.setTag(item);
    holder.todeleteitem.findViewById(R.id.todeleteitem).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            if (onItemClickListener != null) {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        onItemClickListener.onDeleteitemClick(v,
                                (Categorylistmodelmytrip) holder.itemView.getTag());
                    }
                }, 200);
            }
        }
    });

    /* holder.editmenu.findViewById(R.id.editmenu);
            
     holder.editmenu.findViewById(R.id.editmenu).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
            
            
            
        Fragment fr = new newnotes();
        FragmentChangeListener fc = (FragmentChangeListener) context;
        fc.replaceFragment(fr, context.getString(R.string.title_explore));
            
            
            
            
            
      *//*  Intent intents = new Intent(context, ShowGroupimage.class);
         ((Activity) context).startActivity(intents);*//*
                                                                
                                                                
                                                        }
                                                        });*/

    holder.notes.findViewById(R.id.addnotes);

    //   -------------------------------------------------

    notescontent = Sessiondata.getInstance().getNotesno().get(position).getNotes();

    Log.d("Notes", "" + notescontent);

    if (notescontent.equals("0")) {
        holder.notes.setText("Add Notes");

        holder.notes.setBackgroundColor(context.getResources().getColor(R.color.bgyellow));
    } else {
        holder.notes.setText("View Notes");
        holder.notes.setBackgroundColor(context.getResources().getColor(R.color.orangedrak));
        //  ---------------------------------------
    }

    holder.notes.findViewById(R.id.addnotes).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Log.d("Arraylistvaluessno", "" + Sessiondata.getInstance().getNotesno().get(position).getSno());
            parmetersno = Sessiondata.getInstance().getNotesno().get(position).getIdnumber();
            Log.d("Name", "" + Sessiondata.getInstance().getNotesno().get(position).getName());
            Log.d("Arjun", "" + parmetersno);
            Sessiondata.getInstance().setSnonotes(parmetersno);

            Notesalredyhave();

            // showInputDialog();

        }
    });

}

From source file:at.alladin.rmbt.statisticServer.UsageJSONResource.java

@Get("json")
public String request(final String entity) {
    JSONObject result = new JSONObject();
    int month = -1;
    int year = -1;
    try {/*from  www  .j a  v a  2  s  .  co  m*/
        //parameters
        final Form getParameters = getRequest().getResourceRef().getQueryAsForm();
        try {

            if (getParameters.getNames().contains("month")) {
                month = Integer.parseInt(getParameters.getFirstValue("month"));
                if (month > 11 || month < 0) {
                    throw new NumberFormatException();
                }
            }
            if (getParameters.getNames().contains("year")) {
                year = Integer.parseInt(getParameters.getFirstValue("year"));
                if (year < 0) {
                    throw new NumberFormatException();
                }
            }
        } catch (NumberFormatException e) {
            return "invalid parameters";
        }

        Calendar now = new GregorianCalendar();
        Calendar monthBegin = new GregorianCalendar((year > 0) ? year : now.get(Calendar.YEAR),
                (month >= 0) ? month : now.get(Calendar.MONTH), 1);
        Calendar monthEnd = new GregorianCalendar((year > 0) ? year : now.get(Calendar.YEAR),
                (month >= 0) ? month : now.get(Calendar.MONTH),
                monthBegin.getActualMaximum(Calendar.DAY_OF_MONTH));
        //if now -> do not use the last day
        if (month == now.get(Calendar.MONTH) && year == now.get(Calendar.YEAR)) {
            monthEnd = now;
            monthEnd.add(Calendar.DATE, -1);
        }

        JSONObject platforms = getPlatforms(new Timestamp(monthBegin.getTimeInMillis()),
                new Timestamp(monthEnd.getTimeInMillis()));
        JSONObject usage = getClassicUsage(new Timestamp(monthBegin.getTimeInMillis()),
                new Timestamp(monthEnd.getTimeInMillis()));
        JSONObject versionsIOS = getVersions("iOS", new Timestamp(monthBegin.getTimeInMillis()),
                new Timestamp(monthEnd.getTimeInMillis()));
        JSONObject versionsAndroid = getVersions("Android", new Timestamp(monthBegin.getTimeInMillis()),
                new Timestamp(monthEnd.getTimeInMillis()));
        JSONObject versionsApplet = getVersions("Applet", new Timestamp(monthBegin.getTimeInMillis()),
                new Timestamp(monthEnd.getTimeInMillis()));
        JSONObject networkGroupNames = getNetworkGroupName(new Timestamp(monthBegin.getTimeInMillis()),
                new Timestamp(monthEnd.getTimeInMillis()));
        JSONObject networkGroupTypes = getNetworkGroupType(new Timestamp(monthBegin.getTimeInMillis()),
                new Timestamp(monthEnd.getTimeInMillis()));
        result.put("platforms", platforms);
        result.put("usage", usage);
        result.put("versions_ios", versionsIOS);
        result.put("versions_android", versionsAndroid);
        result.put("versions_applet", versionsApplet);
        result.put("network_group_names", networkGroupNames);
        result.put("network_group_types", networkGroupTypes);
    } catch (SQLException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return result.toString();
}

From source file:org.fhaes.jsea.JSEAFrame.java

/**
 * Parse the specified time series file/*w ww.  j a  v  a 2s .  co m*/
 */
public Boolean parseTimeSeriesFile() {

    chronologyYears = new ArrayList<Integer>();
    chronologyActual = new ArrayList<Double>();
    ;

    File f = new File(this.txtTimeSeriesFile.getText());
    if (!f.exists()) {
        log.error("Event list file does not exist");
        return false;
    }

    CSVReader reader;
    try {
        String filename = txtTimeSeriesFile.getText();
        char delimiter = getDelimiter(filename, 2);
        reader = new CSVReader(new FileReader(filename), delimiter);
        ArrayList fileContents = (ArrayList) reader.readAll();
        reader.close();

        int lineNumber = 0;

        for (Object line : fileContents) {
            lineNumber++;
            String[] items = (String[]) line;
            if (items == null)
                continue;
            if (items[0].startsWith("*"))
                continue;
            if (items.length == 1) {
                JOptionPane.showMessageDialog(this, "Invalid number of items on line " + lineNumber
                        + ". There should be only 2 items per line, whereas " + items.length + " was found.",
                        "Invalid file", JOptionPane.ERROR_MESSAGE);
                return false;
            }
            if (items.length != 2) {
                JOptionPane.showMessageDialog(this, "Invalid number of items on line " + lineNumber
                        + ". There should be only 2 items per line, whereas " + items.length + " were found.",
                        "Invalid file", JOptionPane.ERROR_MESSAGE);
                return false;
            }

            try {
                Integer year = Integer.parseInt(items[0].trim());

                if (chronologyYears.size() > 0) {
                    if (!chronologyYears.get(chronologyYears.size() - 1).equals(year - 1)) {
                        JOptionPane.showMessageDialog(this,
                                "Invalid year value on line number " + lineNumber
                                        + ". Years must be sequential.",
                                "Invalid file", JOptionPane.ERROR_MESSAGE);
                        return false;
                    }
                }
                chronologyYears.add(year);
            } catch (NumberFormatException e) {
                JOptionPane
                        .showMessageDialog(this,
                                "Invalid year value :" + StringUtils.rightPadWithTrim(items[0], 5)
                                        + "' on line number " + lineNumber,
                                "Invalid file", JOptionPane.ERROR_MESSAGE);
                return false;
            }

            try {
                Double value = Double.parseDouble(items[1].trim());
                chronologyActual.add(value);
            } catch (NumberFormatException e) {
                JOptionPane.showMessageDialog(this,
                        "Invalid data value '" + StringUtils.rightPadWithTrim(items[0], 5) + "' on line number "
                                + lineNumber + ". Value must be real number",
                        "Invalid file", JOptionPane.ERROR_MESSAGE);
                return false;
            }
        }

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return true;
}

From source file:com.znsx.cms.web.controller.DeviceController.java

@InterfaceDescription(logon = true, method = "Create_Dvr", cmd = "2050")
@RequestMapping("/create_dvr.json")
public void createDvr(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String standardNumber = request.getParameter("standardNumber");

    String subType = request.getParameter("subType");
    if (StringUtils.isBlank(subType)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [subType]");
    }/*  w  ww  . j  a  v  a 2 s .  com*/

    String name = request.getParameter("name");
    if (StringUtils.isBlank(name)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [name]");
    }
    name = StringUtils.replace(name, " ", "+");
    String ptsId = request.getParameter("ptsId");

    String transport = request.getParameter("transport");
    if (StringUtils.isBlank(transport)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [transport]");
    }

    String mode = request.getParameter("mode");
    if (StringUtils.isBlank(mode)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [mode]");
    }

    Integer maxConnect = null;
    String maxConnectString = request.getParameter("maxConnect");
    if (StringUtils.isBlank(maxConnectString)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [maxConnect]");
    } else {
        try {
            maxConnect = Integer.parseInt(maxConnectString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter maxConnect[" + maxConnectString + "] invalid !");
        }
    }

    Integer channelAmount = null;
    String channelAmountString = request.getParameter("channelAmount");
    if (StringUtils.isBlank(channelAmountString)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [channelAmount]");
    } else {
        try {
            channelAmount = Integer.parseInt(channelAmountString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter channelAmount[" + channelAmountString + "] invalid !");
        }
    }

    String organId = request.getParameter("organId");
    if (StringUtils.isBlank(organId)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [organId]");
    }

    String linkType = request.getParameter("linkType");

    String lanIp = request.getParameter("lanIp");
    if (StringUtils.isBlank(lanIp)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [lanIp]");
    }

    Integer port = null;
    String portString = request.getParameter("port");
    if (StringUtils.isBlank(portString)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [port]");
    } else {
        try {
            port = Integer.parseInt(portString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter port[" + portString + "] invalid !");
        }
    }

    String manufacturerId = request.getParameter("manufacturerId");

    String deviceModelId = request.getParameter("deviceModelId");

    String location = request.getParameter("location");

    String note = request.getParameter("note");

    String userName = request.getParameter("userName");
    if (StringUtils.isBlank(userName)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [userName]");
    }

    String password = request.getParameter("password");
    // if (StringUtils.isBlank(password)) {
    // throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND,
    // "missing [password]");
    // }

    Integer heartCycle = null;
    String heartCycleString = request.getParameter("heartCycle");
    if (StringUtils.isBlank(heartCycleString)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [heartCycle]");
    } else {
        try {
            heartCycle = Integer.parseInt(heartCycleString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter heartCycle[" + heartCycleString + "] invalid !");
        }
    }

    String expand = request.getParameter("expand");

    Integer aicAmount = 0;
    String aicAmountString = request.getParameter("aicAmount");
    if (StringUtils.isNotBlank(aicAmountString)) {
        try {
            aicAmount = Integer.parseInt(aicAmountString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter aicAmount[" + aicAmountString + "] invalid !");
        }
    }

    Integer aocAmount = 0;
    String aocAmountString = request.getParameter("aocAmount");
    if (StringUtils.isNotBlank(aocAmountString)) {
        try {
            aocAmount = Integer.parseInt(aocAmountString);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            throw new BusinessException(ErrorCode.PARAMETER_INVALID,
                    "Parameter aocAmount[" + aocAmountString + "] invalid !");
        }
    }

    String decode = request.getParameter("decode");
    if (StringUtils.isBlank(decode)) {
        throw new BusinessException(ErrorCode.PARAMETER_NOT_FOUND, "missing [decode]");
    }

    // ?License?channelAmount???
    License license = licenseManager.getLicense();
    int cameraAmount = Integer.parseInt(license.getCameraAmount());
    int cameraCount = deviceManager.countCamera();
    int generateNum = 0;
    if ((cameraCount + channelAmount.intValue()) > cameraAmount) {
        generateNum = cameraAmount - cameraCount;
    } else {
        generateNum = channelAmount.intValue();
    }
    // ??license????
    if (channelAmount.intValue() > generateNum) {
        throw new BusinessException(ErrorCode.CAMERA_AMOUNT_LIMIT, "camera more than limit");
    }

    // ??
    if (StringUtils.isBlank(standardNumber)) {
        standardNumber = userManager.generateStandardNum("Dvr", organId);
    }

    String id = deviceManager.createDvr(standardNumber, subType, name, ptsId, transport, mode, maxConnect,
            channelAmount, organId, linkType, lanIp, port, manufacturerId, deviceModelId, location, note,
            userName, password, heartCycle, expand, aicAmount, aocAmount, decode);

    Organ organ = new Organ();
    organ.setId(organId);
    Dvr parent = new Dvr();
    parent.setId(id);
    VideoDeviceProperty property = new VideoDeviceProperty();
    property.setStoreType(TypeDefinition.STORE_TYPE_LOCAL);
    property.setLocalStorePlan(TypeDefinition.STORE_PLAN_DEFAULT);
    property.setStoreStream(TypeDefinition.STORE_MAIN_STREAM);

    // ???
    String[] sns = userManager.batchGenerateSN("Camera", organId, generateNum);
    // ?ID?
    // String[] ids = deviceManager.batchGenerateId("Camera", generateNum);
    // ??
    Camera[] cameras = new Camera[generateNum];
    for (int i = 0; i < generateNum; i++) {
        cameras[i] = new Camera();
        // cameras[i].setId(ids[i]);
        cameras[i].setStandardNumber(sns[i]);
        cameras[i].setType(TypeDefinition.DEVICE_TYPE_CAMERA);
        cameras[i].setSubType(TypeDefinition.SUBTYPE_CAMERA_DEFAULT);
        cameras[i].setName(name + "_" + (i + 1));
        cameras[i].setOrgan(organ);
        cameras[i].setLocation(location);
        cameras[i].setNote(note);
        cameras[i].setProperty(property);
        cameras[i].setChannelNumber((short) (i + 1));
        cameras[i].setParent(parent);
        cameras[i].setCreateTime(System.currentTimeMillis());
    }
    deviceManager.batchCreateDvrCameras(cameras);

    BaseDTO dto = new BaseDTO();
    dto.setCmd("2050");
    dto.setMethod("Create_Dvr");
    dto.setMessage(id);

    writePage(response, dto);
}

From source file:cw.kop.autobackground.sources.SourceInfoFragment.java

private void saveSource() {

    final Intent sourceIntent = new Intent();

    String title = sourceTitle.getText().toString();
    String data = sourceData.getText().toString();

    if (type.equals(AppSettings.FOLDER)) {
        data = folderData;//from  w  ww .  jav a 2 s . c  o m
    }

    if (title.equals("")) {
        Toast.makeText(appContext, "Title cannot be empty", Toast.LENGTH_SHORT).show();
        return;
    }
    if (data.equals("")) {
        Toast.makeText(appContext, "Data cannot be empty", Toast.LENGTH_SHORT).show();
        return;
    }

    int num = 0;
    try {
        num = Integer.parseInt(sourceNum.getText().toString());
    } catch (NumberFormatException e) {
        num = 1;
    }

    switch (type) {

    case AppSettings.WEBSITE:
        if (!data.contains("http")) {
            data = "http://" + data;
        }
        break;

    }

    if (sourcePosition == -1) {

        if (FileHandler.isDownloading) {
            Toast.makeText(appContext, "Cannot add source while downloading", Toast.LENGTH_SHORT).show();
            return;
        }

        sourceIntent.setAction(SourceListFragment.ADD_ENTRY);

    } else {

        if (!getArguments().getString("title").equals(title)) {
            FileHandler.renameFolder(getArguments().getString("title"), title);
        }

        if (FileHandler.isDownloading) {
            Toast.makeText(appContext, "Cannot edit while downloading", Toast.LENGTH_SHORT).show();
            return;
        }

        sourceIntent.setAction(SourceListFragment.SET_ENTRY);
    }

    sourceIntent.putExtra("type", type);
    sourceIntent.putExtra("title", sourceTitle.getText().toString());
    sourceIntent.putExtra("data", data);
    sourceIntent.putExtra("num", num);
    sourceIntent.putExtra("position", sourcePosition);
    sourceIntent.putExtra("use", sourceUse.isChecked());
    sourceIntent.putExtra("preview",
            ((CustomSwitchPreference) findPreference("source_show_preview")).isChecked());
    sourceIntent.putExtra("use_time", timePref.isChecked());
    sourceIntent.putExtra("time",
            String.format("%02d:%02d - %02d:%02d", startHour, startMinute, endHour, endMinute));

    try {
        InputMethodManager im = (InputMethodManager) appContext.getSystemService(Context.INPUT_METHOD_SERVICE);
        im.hideSoftInputFromWindow(getView().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (Exception e) {
        e.printStackTrace();
    }

    final int screenHeight = getResources().getDisplayMetrics().heightPixels;
    final View fragmentView = getView();

    if (fragmentView != null) {
        final float viewStartY = getView().getY();

        Animation animation = new Animation() {
            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {
                fragmentView.setY((screenHeight - viewStartY) * interpolatedTime + viewStartY);
            }

            @Override
            public boolean willChangeBounds() {
                return true;
            }
        };

        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                LocalBroadcastManager.getInstance(appContext).sendBroadcast(sourceIntent);
                getFragmentManager().popBackStack();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        animation.setDuration(SLIDE_EXIT_TIME);
        getView().startAnimation(animation);
    } else {
        LocalBroadcastManager.getInstance(appContext).sendBroadcast(sourceIntent);
    }

}

From source file:org.ojbc.bundles.adapters.staticmock.StaticMockQuery.java

List<IdentifiableDocumentWrapper> vehicleSearchDocumentsAsList(Document vehicleSearchRequestMessage,
        DateTime baseDate) throws Exception {

    Element rootElement = vehicleSearchRequestMessage.getDocumentElement();
    String rootNamespaceURI = rootElement.getNamespaceURI();
    String rootLocalName = rootElement.getLocalName();
    if (!(OjbcNamespaceContext.NS_VEHICLE_SEARCH_REQUEST_DOC.equals(rootNamespaceURI)
            && "VehicleSearchRequest".equals(rootLocalName))) {
        throw new IllegalArgumentException("Invalid message, must have {"
                + OjbcNamespaceContext.NS_VEHICLE_SEARCH_REQUEST_DOC + "}VehicleSearchRequest as the root "
                + "instead of {" + rootNamespaceURI + "}" + rootLocalName);
    }/*from  w w  w  .  j ava 2s .co m*/

    NodeList systemElements = XmlUtils.xPathNodeListSearch(rootElement, "vsr:SourceSystemNameText");
    if (systemElements == null || systemElements.getLength() != 1) {
        throw new IllegalArgumentException(
                "Invalid query request message:  must specify exactly one system to query.");
    }
    Node systemElementNode = systemElements.item(0);
    String systemId = systemElementNode.getTextContent();
    if (!INCIDENT_MOCK_ADAPTER_VEHICLE_SEARCH_SYSTEM_ID.equals(systemId)) {
        throw new IllegalArgumentException(
                "Vehicle searches only allowed against static mock incident store.  Illegal system: "
                        + systemId);
    }

    List<IdentifiableDocumentWrapper> ret = new ArrayList<IdentifiableDocumentWrapper>();

    String searchXPath = buildIncidentSearchXPathFromVehicleSearchMessage(vehicleSearchRequestMessage);

    String modelYearLowerString = XmlUtils.xPathStringSearch(vehicleSearchRequestMessage,
            "/vsr-doc:VehicleSearchRequest/vsr:Vehicle/vsr:VehicleYearRange/nc:StartDate/nc:Year");
    String modelYearUpperString = XmlUtils.xPathStringSearch(vehicleSearchRequestMessage,
            "/vsr-doc:VehicleSearchRequest/vsr:Vehicle/vsr:VehicleYearRange/nc:EndDate/nc:Year");

    if (searchXPath == null && isMissing(modelYearLowerString) && isMissing(modelYearUpperString)) {
        return ret;
    }

    for (IdentifiableDocumentWrapper dw : incidentDataSource.getDocuments()) {

        Document d = dw.getDocument();
        LOG.debug("Searching document " + dw.getId());

        boolean match = (searchXPath == null || XmlUtils.xPathNodeSearch(d, searchXPath) != null);
        LOG.debug("Match=" + match + " based on xpath eval");

        if (match && (!(isMissing(modelYearLowerString) && isMissing(modelYearUpperString)))) {

            Integer modelYearLower = Integer.parseInt(modelYearLowerString);
            Integer modelYearUpper = Integer.parseInt(modelYearUpperString);

            String incidentVehicleModelYearString = XmlUtils.xPathStringSearch(d,
                    "/ir:IncidentReport/lexspd:doPublish/lexs:PublishMessageContainer/lexs:PublishMessage/lexs:DataItemPackage/lexs:Digest/lexsdigest:EntityVehicle/nc:Vehicle/nc:ItemModelYearDate");
            Integer incidentVehicleModelYear = null;

            try {
                incidentVehicleModelYear = Integer.parseInt(incidentVehicleModelYearString);
            } catch (NumberFormatException nfe) {
                nfe.printStackTrace();
                LOG.warn("Unparsable vehicle model year: " + incidentVehicleModelYearString);
            }

            if (incidentVehicleModelYear == null) {
                match = false;
            } else {
                if (modelYearLower != null) {
                    match = match && incidentVehicleModelYear >= modelYearLower;
                }
                if (modelYearUpper != null) {
                    match = match && incidentVehicleModelYear <= modelYearUpper;
                }
            }

        }

        if (match) {
            ret.add(dw);
        }

    }

    return ret;

}