protected int extractParameterFromLink(Element link, String parameter) { Pattern pattern = Pattern.compile(".*(?:" + parameter + ")=(\\d*)"); String text = link.attr("href"); if (!TextUtils.isEmpty(text)) { Matcher matcher = pattern.matcher(text); if (matcher.find()) return Integer.parseInt(matcher.group(1)); else Utils.appendLog("Href doesn't contain such parameter"); } else Utils.appendLog("Element does not contain href"); return 0; }
protected Element getElement(int column, String select) { Element element = tempColumns.get(column).select(select).first(); if (element != null) return element; else Utils.appendLog("No such element `" + select + "`"); return null; }
protected Date parseDate(String text) { try { if (!text.equals("--")) return PARSING_FORMAT.parse(text); } catch (ParseException e) { Utils.appendLog("Error while parsing time string: `" + text + "`"); } return new Date(0L); }
protected T getFromFile(Context context, int id) { String filename = ParentEntity.getFileName(getGenericTypeClass(), id); T object = null; FileInputStream fis = null; ObjectInputStream is = null; try { fis = context.openFileInput(filename); is = new ObjectInputStream(fis); object = (T) is.readObject(); object.isKeptLocally = true; return object; } catch (FileNotFoundException e) { return null; } catch (Exception e) { e.printStackTrace(); return null; } finally { Utils.close(fis); Utils.close(is); } }