List of usage examples for java.util TreeMap keySet
public Set<K> keySet()
From source file:org.mnsoft.pdfocr.Wrapper.java
/** * Read the configuration/*from www. jav a 2 s . c om*/ * properties file. * * @param filename The configuration file name. */ @SuppressWarnings("rawtypes") private void readConfiguration(String filename) { /* * Read the configuration file */ log.debug("> readConfiguration"); log.debug("> Loading configuration from " + filename); final Properties p = FileLoader.loadProperties(filename); if (p == null) { log.info("! No configuration file specified. Using default values."); setAttribute("cmd", this.OCR_COMMAND); setAttribute("creator", this.OCR_CREATOR); setAttribute("tmpext", this.TMP_EXTENSION); log.debug("+ Configuration Parameter CMD=" + this.OCR_COMMAND); log.debug("+ Configuration Parameter CREATOR=" + this.OCR_CREATOR); log.debug("+ Configuration Parameter TMPEXT=" + this.TMP_EXTENSION); log.debug("< readConfiguration"); return; } /* * Convert property names to upper case */ final TreeMap<String, String> uppercaseConfigurationParameters = new TreeMap<String, String>(); for (final Iterator it = p.keySet().iterator(); it.hasNext();) { final String pName = (String) it.next(); final String pValue = (String) p.get(pName); uppercaseConfigurationParameters.put(pName.toUpperCase(), pValue); } /* * We save the parameters that already are in the * HashMap, i.e. which have been passed in as command * line parameters */ final TreeMap<String, String> uppercaseCommandLineParameters = new TreeMap<String, String>(); for (final Iterator it = this.parameters.keySet().iterator(); it.hasNext();) { final String pName = (String) it.next(); final String pValue = (String) this.parameters.get(pName); uppercaseCommandLineParameters.put(pName.toUpperCase(), pValue); } final HashMap<String, String> upperCaseParameters = new HashMap<String, String>(); for (final String key : uppercaseConfigurationParameters.keySet()) { final String value = uppercaseConfigurationParameters.get(key); upperCaseParameters.put(key, value); log.debug("+ Configuration Parameter " + key + "=" + value); if ((key.length() > 4) && key.substring(0, 4).equalsIgnoreCase("SYS.")) { System.setProperty(key.substring(4), value); log.debug("+ Java System Parameter " + key.substring(4) + "=" + value); } } for (final String key : uppercaseCommandLineParameters.keySet()) { final String value = uppercaseCommandLineParameters.get(key); upperCaseParameters.put(key, value); log.debug("+ Command Line Parameter " + key + "=" + value); if ((key.length() > 4) && key.substring(0, 4).equalsIgnoreCase("SYS.")) { System.setProperty(key.substring(4), value); log.debug("+ Java System Parameter " + key.substring(4) + "=" + value); } } this.parameters = upperCaseParameters; if (getAttribute("cmd") != null) { this.OCR_COMMAND = getAttribute("cmd"); log.debug("+ Configuration Parameter CMD=" + this.OCR_COMMAND); } if (getAttribute("creator") != null) { this.OCR_CREATOR = getAttribute("CREATOR"); log.debug("+ Configuration Parameter CREATOR=" + this.OCR_CREATOR); } if (getAttribute("tmpext") != null) { this.TMP_EXTENSION = getAttribute("tmpext"); log.debug("+ Configuration Parameter TMPEXT=" + this.TMP_EXTENSION); } if (getAttribute("tmpdir") != null) { this.TMP_DIR = getAttribute("tmpdir"); log.debug("+ Configuration Parameter TMPDIR=" + this.TMP_DIR); } log.debug("< readConfiguration"); }
From source file:org.kuali.ole.module.purap.document.web.struts.AccountsPayableActionBase.java
/** * Builds and asks questions which require text input by the user for a payment request or a credit memo. * * @param mapping An ActionMapping * @param form An ActionForm * @param request The HttpServletRequest * @param response The HttpServletResponse * @param questionType A String used to distinguish which question is being asked * @param notePrefix A String explaining what action was taken, to be prepended to the note containing the reason, which gets * written to the document * @param operation A one-word String description of the action to be taken, to be substituted into the message. (Can be an * empty String for some messages.) * @param messageKey A (whole) key to the message which will appear on the question screen * @param questionsAndCallbacks A TreeMap associating the type of question to be asked and the type of callback which should * happen in that case * @param messagePrefix The most general part of a key to a message text to be retrieved from ConfigurationService, * Describes a collection of questions. * @param redirect An ActionForward to return to if done with questions * @return An ActionForward/*ww w.j av a 2 s . c o m*/ * @throws Exception */ protected ActionForward askQuestionWithInput(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, String questionType, String notePrefix, String operation, String messageKey, TreeMap<String, PurQuestionCallback> questionsAndCallbacks, String messagePrefix, ActionForward redirect) throws Exception { KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form; AccountsPayableDocumentBase apDocument = (AccountsPayableDocumentBase) kualiDocumentFormBase.getDocument(); String question = request.getParameter(OLEConstants.QUESTION_INST_ATTRIBUTE_NAME); String reason = request.getParameter(OLEConstants.QUESTION_REASON_ATTRIBUTE_NAME); String noteText = ""; ConfigurationService kualiConfiguration = SpringContext.getBean(ConfigurationService.class); String firstQuestion = questionsAndCallbacks.firstKey(); PurQuestionCallback callback = null; Iterator questions = questionsAndCallbacks.keySet().iterator(); String mapQuestion = null; String key = null; // Start in logic for confirming the close. if (question == null) { key = getQuestionProperty(messageKey, messagePrefix, kualiConfiguration, firstQuestion); String message = StringUtils.replace(key, "{0}", operation); // Ask question if not already asked. return this.performQuestionWithInput(mapping, form, request, response, firstQuestion, message, OLEConstants.CONFIRMATION_QUESTION, questionType, ""); } else { // find callback for this question while (questions.hasNext()) { mapQuestion = (String) questions.next(); if (StringUtils.equals(mapQuestion, question)) { callback = questionsAndCallbacks.get(mapQuestion); break; } } key = getQuestionProperty(messageKey, messagePrefix, kualiConfiguration, mapQuestion); Object buttonClicked = request.getParameter(OLEConstants.QUESTION_CLICKED_BUTTON); if (question.equals(mapQuestion) && buttonClicked.equals(ConfirmationQuestion.NO)) { // If 'No' is the button clicked, just reload the doc String nextQuestion = null; // ask another question if more left if (questions.hasNext()) { nextQuestion = (String) questions.next(); key = getQuestionProperty(messageKey, messagePrefix, kualiConfiguration, nextQuestion); return this.performQuestionWithInput(mapping, form, request, response, nextQuestion, key, OLEConstants.CONFIRMATION_QUESTION, questionType, ""); } else { return mapping.findForward(OLEConstants.MAPPING_BASIC); } } // Have to check length on value entered. String introNoteMessage = notePrefix + OLEConstants.BLANK_SPACE; // Build out full message. noteText = introNoteMessage + reason; int noteTextLength = noteText.length(); // Get note text max length from DD. int noteTextMaxLength = SpringContext.getBean(DataDictionaryService.class) .getAttributeMaxLength(Note.class, OLEConstants.NOTE_TEXT_PROPERTY_NAME).intValue(); if (StringUtils.isBlank(reason) || (noteTextLength > noteTextMaxLength)) { // Figure out exact number of characters that the user can enter. int reasonLimit = noteTextMaxLength - noteTextLength; if (reason == null) { // Prevent a NPE by setting the reason to a blank string. reason = ""; } return this.performQuestionWithInputAgainBecauseOfErrors(mapping, form, request, response, mapQuestion, key, OLEConstants.CONFIRMATION_QUESTION, questionType, "", reason, PurapKeyConstants.ERROR_PAYMENT_REQUEST_REASON_REQUIRED, OLEConstants.QUESTION_REASON_ATTRIBUTE_NAME, new Integer(reasonLimit).toString()); } } // make callback if (ObjectUtils.isNotNull(callback)) { AccountsPayableDocument refreshedApDocument = callback.doPostQuestion(apDocument, noteText); kualiDocumentFormBase.setDocument(refreshedApDocument); } String nextQuestion = null; // ask another question if more left if (questions.hasNext()) { nextQuestion = (String) questions.next(); key = getQuestionProperty(messageKey, messagePrefix, kualiConfiguration, nextQuestion); return this.performQuestionWithInput(mapping, form, request, response, nextQuestion, key, OLEConstants.CONFIRMATION_QUESTION, questionType, ""); } return redirect; }
From source file:de.uzk.hki.da.sb.SIPFactory.java
private Feedback checkMetadataForLicense(int jobId, File sourceFolder, File packageFolder) { boolean premisLicenseBool = contractRights.getCclincense() != null; boolean metsLicenseBool = false; boolean lidoLicenseBool = false; boolean publicationBool = contractRights.getPublicRights().getAllowPublication(); TreeMap<File, String> metadataFileWithType; try {/* w w w. j av a 2 s .c o m*/ metadataFileWithType = new FormatDetectionService(sourceFolder).getMetadataFileWithType(); if (metadataFileWithType.containsValue(C.CB_PACKAGETYPE_METS)) { ArrayList<File> metsFiles = new ArrayList<File>(); ArrayList<MetsLicense> licenseMetsFile = new ArrayList<MetsLicense>(); for (File f : metadataFileWithType.keySet()) if (metadataFileWithType.get(f).equals(C.CB_PACKAGETYPE_METS)) metsFiles.add(f); for (File f : metsFiles) {// assuming more as usual mets is allowed (check is done by FormatDetectionService) e.g. publicMets for testcase-creation SAXBuilder builder = XMLUtils.createNonvalidatingSaxBuilder(); Document metsDoc = builder.build(f); MetsParser mp = new MetsParser(metsDoc); licenseMetsFile.add(mp.getLicenseForWholeMets()); } Collections.sort(licenseMetsFile, new NullLastComparator<MetsLicense>()); if (licenseMetsFile.get(0) == null) // all licenses are null metsLicenseBool = false; else if (!licenseMetsFile.get(0).equals(licenseMetsFile.get(licenseMetsFile.size() - 1))) // first and last lic have to be same in sorted array return Feedback.INVALID_LICENSE_DATA_IN_METADATA; else metsLicenseBool = true; } else if (metadataFileWithType.containsValue(C.CB_PACKAGETYPE_LIDO)) { ArrayList<File> lidoFiles = new ArrayList<File>(); ArrayList<LidoLicense> licenseLidoFile = new ArrayList<LidoLicense>(); for (File f : metadataFileWithType.keySet()) if (metadataFileWithType.get(f).equals(C.CB_PACKAGETYPE_LIDO)) lidoFiles.add(f); for (File f : lidoFiles) {// assuming more as one metadata is allowed (check is done by FormatDetectionService) SAXBuilder builder = XMLUtils.createNonvalidatingSaxBuilder(); Document metsDoc = builder.build(f); LidoParser lp = new LidoParser(metsDoc); licenseLidoFile.add(lp.getLicenseForWholeLido()); } Collections.sort(licenseLidoFile, new NullLastComparator<LidoLicense>()); if (licenseLidoFile.get(0) == null) // all licenses are null lidoLicenseBool = false; else if (!licenseLidoFile.get(0).equals(licenseLidoFile.get(licenseLidoFile.size() - 1))) // first and last lic have to be same in sorted array return Feedback.INVALID_LICENSE_DATA_IN_METADATA; else lidoLicenseBool = true; } } catch (Exception e) { e.printStackTrace(); return Feedback.INVALID_LICENSE_DATA_IN_METADATA; } //activate to be able to create non licensed test sips //publicationBool=false; //premisLicenseBool=false; //publicationBool=false; if (premisLicenseBool && (metsLicenseBool || lidoLicenseBool)) { return Feedback.DUPLICATE_LICENSE_DATA; } if (publicationBool && !premisLicenseBool && !metsLicenseBool && !lidoLicenseBool) { return Feedback.PUBLICATION_NO_LICENSE; } logger.info( "License is satisfiable: Premis-License:" + premisLicenseBool + " Mets-License:" + metsLicenseBool + " Lido-License:" + lidoLicenseBool + " Publication-Decision:" + publicationBool); return Feedback.SUCCESS; }
From source file:gemlite.shell.admin.dao.AdminDao.java
/** * region/*from ww w. j av a 2 s .c o m*/ * * @return * @throws IOException */ private String showRegions() throws IOException { do { System.out.println("------------------------"); Map param = new HashMap(); param.put("beanName", "ListRegionsService"); Execution execution = FunctionService.onServer(clientPool).withArgs(param); ResultCollector rc = execution.execute("REMOTE_ADMIN_FUNCTION"); Object obj = rc.getResult(); if (obj == null) { System.out.println("can't get regions list"); return null; } ArrayList list = (ArrayList) obj; if (!(list.get(0) instanceof Set)) { System.out.println(list.get(0)); return null; } TreeSet regionSet = (TreeSet) list.get(0); Iterator regionIters = regionSet.iterator(); StringBuilder sb = new StringBuilder(); TreeMap<String, String> regionMap = new TreeMap<String, String>(); int no = 1; sb.append("NO.").append("\t").append("RegionName").append("\n"); while (regionIters.hasNext()) { String fullPath = (String) regionIters.next(); sb.append(no).append("\t").append(fullPath).append("\n"); regionMap.put(String.valueOf(no), fullPath); no++; } System.out.println(sb.toString()); System.out.println( "------------------------\nRegionNames,Your choice?No.or regionName,ALL(all) means export all regions,X to exit"); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); String line = bufferedReader.readLine(); if (line == null) { System.out.println("no input regionName!"); } else if (!"x".equalsIgnoreCase(line.trim()) && !regionMap.entrySet().contains(line.trim()) && !"ALL".equalsIgnoreCase(line.trim()) && !regionMap.keySet().contains(line.trim())) { System.out.println("error input:" + line); } else { if (regionMap.keySet().contains(line.trim())) return regionMap.get(String.valueOf(line.trim())); return line.trim(); } } while (true); }
From source file:kz.nurlan.kaspandr.KaspandrWindow.java
private String checkLessonCountByGroup(String lessons) throws JsonParseException, JsonMappingException, IOException { String resultString = ""; ObjectNode rootNode1 = mapper.readValue("{\"lessons\":[" + lessons + "]}", ObjectNode.class); JsonNode lessonsNode1 = rootNode1.get("lessons"); HashMap<String, Integer> groupMap = new HashMap<String, Integer>(); HashMap<String, String> groupNameMap = new HashMap<String, String>(); ValueComparator bvc = new ValueComparator(groupNameMap); TreeMap<String, String> sortedGroupNameMap = new TreeMap<String, String>(bvc); groupMap.put("all", 0); if (lessonsNode1 != null && lessonsNode1.isArray()) { Iterator<JsonNode> it = lessonsNode1.elements(); while (it.hasNext()) { JsonNode lesson = it.next(); if (lesson.get("id") != null && !lesson.get("status").textValue().equalsIgnoreCase("deleted") && lesson.get("group") != null && !lesson.get("group").textValue().isEmpty()) { if (groupMap.containsKey(lesson.get("group").textValue())) groupMap.put(lesson.get("group").textValue(), groupMap.get(lesson.get("group").textValue()) + 1); else groupMap.put(lesson.get("group").textValue(), 1); groupNameMap.put(lesson.get("group").textValue(), lesson.get("groupName").textValue()); }/* w w w . ja va 2 s .co m*/ groupMap.put("all", groupMap.get("all") + 1); } } sortedGroupNameMap.putAll(groupNameMap); int count = 0; for (String group : groupMap.keySet()) { if (!group.equals("all")) { count += groupMap.get(group); } } for (String group : sortedGroupNameMap.keySet()) { if (!resultString.isEmpty()) resultString += ", "; resultString += groupNameMap.get(group) + "(" + groupMap.get(group) + ")"; } resultString = "Lessons(" + count + "/" + groupMap.get("all") + "); " + resultString; return resultString; }
From source file:org.openmicroscopy.shoola.agents.measurement.view.IntensityView.java
/** * Outputs the summary information from the shape map. * //from www . j a v a 2s.c om * @param writer The Excel writer. * @param shapeMap see above. * @throws IOException */ private void outputSummary(ExcelWriter writer, TreeMap<Coord3D, ROIShape> shapeMap) { int rowIndex = 0; printSummaryHeader(writer, rowIndex); rowIndex++; Coord3D start = shapeMap.firstKey(); Coord3D end = shapeMap.lastKey(); Coord3D coord; List<Integer> channels = new ArrayList<Integer>(channelName.keySet()); Set<Coord3D> keys; Iterator<Coord3D> i; for (Integer c : channels) { keys = shapeMap.keySet(); i = keys.iterator(); while (i.hasNext()) { coord = (Coord3D) i.next(); populateData(coord, c); outputSummaryRow(writer, rowIndex, c, coord.getZSection(), coord.getTimePoint()); rowIndex++; } } }
From source file:org.opendatakit.database.data.ColumnDefinitionTest.java
@SuppressWarnings("unchecked") @Test//from ww w . j av a 2s .c om public void testBuildExtendedJson() { List<Column> columns = new ArrayList<Column>(); // arbitrary type derived from integer columns.add(new Column("col0", "col0", "myothertype:integer", "[]")); // primitive types columns.add(new Column("col1", "col1", "boolean", "[]")); columns.add(new Column("col2", "col2", "integer", "[]")); columns.add(new Column("col3", "col3", "number", "[]")); columns.add(new Column("col4", "col4", "string", "[]")); // string with 500 varchars allocated to it columns.add(new Column("col5", "col5", "string(500)", "[]")); columns.add(new Column("col6", "col6", "configpath", "[]")); columns.add(new Column("col7", "col7", "rowpath", "[]")); // object type (geopoint) columns.add(new Column("col8", "col8", "geopoint", "[\"col8_accuracy\",\"col8_altitude\",\"col8_latitude\",\"col8_longitude\"]")); columns.add(new Column("col8_accuracy", "accuracy", "number", "[]")); columns.add(new Column("col8_altitude", "altitude", "number", "[]")); columns.add(new Column("col8_latitude", "latitude", "number", "[]")); columns.add(new Column("col8_longitude", "longitude", "number", "[]")); // arbitrary type derived from string columns.add(new Column("col9", "col9", "mytype", "[]")); // arrays columns.add(new Column("col12", "col12", "array", "[\"col12_items\"]")); columns.add(new Column("col12_items", "items", "integer", "[]")); // array with 500 varchars allocated to it columns.add(new Column("col14", "col14", "array(400)", "[\"col14_items\"]")); columns.add(new Column("col14_items", "items", "string", "[]")); columns.add(new Column("col1a", "col1a", "geolist:array(500)", "[\"col1a_items\"]")); columns.add(new Column("col1a_items", "items", "geopoint", "[\"col1a_items_accuracy\",\"col1a_items_altitude\",\"col1a_items_latitude\"," + "\"col1a_items_longitude\"]")); columns.add(new Column("col1a_items_accuracy", "accuracy", "number", "[]")); columns.add(new Column("col1a_items_altitude", "altitude", "number", "[]")); columns.add(new Column("col1a_items_latitude", "latitude", "number", "[]")); columns.add(new Column("col1a_items_longitude", "longitude", "number", "[]")); ArrayList<ColumnDefinition> colDefs = ColumnDefinition.buildColumnDefinitions("appName", "testTable", columns); String equivalentXLSXConverterDataTableModel = "{" + "\"col0\": {" + "\"type\": \"integer\"," + "\"_defn\": [" + "{" + "\"_row_num\": 2," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementType\": \"myothertype:integer\"," + "\"elementKey\": \"col0\"," + "\"elementName\": \"col0\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col0\"" + "}," + "\"col1\": {" + "\"type\": \"boolean\"," + "\"_defn\": [" + "{" + "\"_row_num\": 3," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementKey\": \"col1\"," + "\"elementName\": \"col1\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1\"" + "}," + "\"col2\": {" + "\"type\": \"integer\"," + "\"_defn\": [" + "{" + "\"_row_num\": 4," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementKey\": \"col2\"," + "\"elementName\": \"col2\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col2\"" + "}," + "\"col3\": {" + "\"type\": \"number\"," + "\"_defn\": [" + "{" + "\"_row_num\": 5," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementKey\": \"col3\"," + "\"elementName\": \"col3\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col3\"" + "}," + "\"col4\": {" + "\"type\": \"string\"," + "\"_defn\": [" + "{" + "\"_row_num\": 6," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementKey\": \"col4\"," + "\"elementName\": \"col4\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col4\"" + "}," + "\"col5\": {" + "\"type\": \"string\"," + "\"_defn\": [" + "{" + "\"_row_num\": 7," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementType\": \"string(500)\"," + "\"elementKey\": \"col5\"," + "\"elementName\": \"col5\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col5\"" + "}," + "\"col6\": {" + "\"type\": \"string\"," + "\"_defn\": [" + "{" + "\"_row_num\": 8," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementType\": \"configpath\"," + "\"elementKey\": \"col6\"," + "\"elementName\": \"col6\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col6\"" + "}," + "\"col7\": {" + "\"type\": \"string\"," + "\"_defn\": [" + "{" + "\"_row_num\": 9," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementType\": \"rowpath\"," + "\"elementKey\": \"col7\"," + "\"elementName\": \"col7\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col7\"" + "}," + "\"col8\": {" + "\"type\": \"object\"," + "\"elementType\": \"geopoint\"," + "\"properties\": {" + "\"latitude\": {" + "\"type\": \"number\"," + "\"elementKey\": \"col8_latitude\"," + "\"elementName\": \"latitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col8.latitude\"" + "}," + "\"longitude\": {" + "\"type\": \"number\"," + "\"elementKey\": \"col8_longitude\"," + "\"elementName\": \"longitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col8.longitude\"" + "}," + "\"altitude\": {" + "\"type\": \"number\"," + "\"elementKey\": \"col8_altitude\"," + "\"elementName\": \"altitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col8.altitude\"" + "}," + "\"accuracy\": {" + "\"type\": \"number\"," + "\"elementKey\": \"col8_accuracy\"," + "\"elementName\": \"accuracy\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col8.accuracy\"" + "}" + "}," + "\"_defn\": [" + "{" + "\"_row_num\": 10," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementKey\": \"col8\"," + "\"elementName\": \"col8\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col8\"," + "\"listChildElementKeys\": [" + "\"col8_accuracy\"," + "\"col8_altitude\"," + "\"col8_latitude\"," + "\"col8_longitude\"" + "]," + "\"notUnitOfRetention\": true" + "}," + "\"col9\": {" + "\"type\": \"string\"," + "\"_defn\": [" + "{" + "\"_row_num\": 11," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementType\": \"mytype\"," + "\"elementKey\": \"col9\"," + "\"elementName\": \"col9\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col9\"" + "}," + "\"col12\": {" + "\"type\": \"array\"," + "\"_defn\": [" + "{" + "\"_row_num\": 12," + "\"section_name\": \"model\"" + "}" + "]," + "\"items\": {" + "\"type\": \"integer\"," + "\"elementKey\": \"col12_items\"," + "\"elementName\": \"items\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col12.items\"," + "\"notUnitOfRetention\": true" + "}," + "\"elementKey\": \"col12\"," + "\"elementName\": \"col12\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col12\"," + "\"listChildElementKeys\": [" + "\"col12_items\"" + "]" + "}," + "\"col14\": {" + "\"type\": \"array\"," + "\"_defn\": [" + "{" + "\"_row_num\": 13," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementType\": \"array(400)\"," + "\"items\": {" + "\"type\": \"string\"," + "\"elementKey\": \"col14_items\"," + "\"elementName\": \"items\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col14.items\"," + "\"notUnitOfRetention\": true" + "}," + "\"elementKey\": \"col14\"," + "\"elementName\": \"col14\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col14\"," + "\"listChildElementKeys\": [" + "\"col14_items\"" + "]" + "}," + "\"col1a\": {" + "\"type\": \"array\"," + "\"_defn\": [" + "{" + "\"_row_num\": 14," + "\"section_name\": \"model\"" + "}" + "]," + "\"elementType\": \"geolist:array(500)\"," + "\"items\": {" + "\"type\": \"object\"," + "\"elementType\": \"geopoint\"," + "\"properties\": {" + "\"latitude\": {" + "\"type\": \"number\"," + "\"elementName\": \"latitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.latitude\"," + "\"elementKey\": \"col1a_items_latitude\"," + "\"notUnitOfRetention\": true" + "}," + "\"longitude\": {" + "\"type\": \"number\"," + "\"elementName\": \"longitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.longitude\"," + "\"elementKey\": \"col1a_items_longitude\"," + "\"notUnitOfRetention\": true" + "}," + "\"altitude\": {" + "\"type\": \"number\"," + "\"elementName\": \"altitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.altitude\"," + "\"elementKey\": \"col1a_items_altitude\"," + "\"notUnitOfRetention\": true" + "}," + "\"accuracy\": {" + "\"type\": \"number\"," + "\"elementName\": \"accuracy\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.accuracy\"," + "\"elementKey\": \"col1a_items_accuracy\"," + "\"notUnitOfRetention\": true" + "}" + "}," + "\"elementKey\": \"col1a_items\"," + "\"elementName\": \"items\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items\"," + "\"listChildElementKeys\": [" + "\"col1a_items_accuracy\"," + "\"col1a_items_altitude\"," + "\"col1a_items_latitude\"," + "\"col1a_items_longitude\"" + "]," + "\"notUnitOfRetention\": true" + "}," + "\"elementKey\": \"col1a\"," + "\"elementName\": \"col1a\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a\"," + "\"listChildElementKeys\": [" + "\"col1a_items\"" + "]" + "}," + "\"col8_latitude\": {" + "\"type\": \"number\"," + "\"elementKey\": \"col8_latitude\"," + "\"elementName\": \"latitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col8.latitude\"" + "}," + "\"col8_longitude\": {" + "\"type\": \"number\"," + "\"elementKey\": \"col8_longitude\"," + "\"elementName\": \"longitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col8.longitude\"" + "}," + "\"col8_altitude\": {" + "\"type\": \"number\"," + "\"elementKey\": \"col8_altitude\"," + "\"elementName\": \"altitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col8.altitude\"" + "}," + "\"col8_accuracy\": {" + "\"type\": \"number\"," + "\"elementKey\": \"col8_accuracy\"," + "\"elementName\": \"accuracy\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col8.accuracy\"" + "}," + "\"col12_items\": {" + "\"type\": \"integer\"," + "\"elementKey\": \"col12_items\"," + "\"elementName\": \"items\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col12.items\"," + "\"notUnitOfRetention\": true" + "}," + "\"col14_items\": {" + "\"type\": \"string\"," + "\"elementKey\": \"col14_items\"," + "\"elementName\": \"items\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col14.items\"," + "\"notUnitOfRetention\": true" + "}," + "\"col1a_items\": {" + "\"type\": \"object\"," + "\"elementType\": \"geopoint\"," + "\"properties\": {" + "\"latitude\": {" + "\"type\": \"number\"," + "\"elementName\": \"latitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.latitude\"," + "\"elementKey\": \"col1a_items_latitude\"," + "\"notUnitOfRetention\": true" + "}," + "\"longitude\": {" + "\"type\": \"number\"," + "\"elementName\": \"longitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.longitude\"," + "\"elementKey\": \"col1a_items_longitude\"," + "\"notUnitOfRetention\": true" + "}," + "\"altitude\": {" + "\"type\": \"number\"," + "\"elementName\": \"altitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.altitude\"," + "\"elementKey\": \"col1a_items_altitude\"," + "\"notUnitOfRetention\": true" + "}," + "\"accuracy\": {" + "\"type\": \"number\"," + "\"elementName\": \"accuracy\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.accuracy\"," + "\"elementKey\": \"col1a_items_accuracy\"," + "\"notUnitOfRetention\": true" + "}" + "}," + "\"elementKey\": \"col1a_items\"," + "\"elementName\": \"items\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items\"," + "\"listChildElementKeys\": [" + "\"col1a_items_accuracy\"," + "\"col1a_items_altitude\"," + "\"col1a_items_latitude\"," + "\"col1a_items_longitude\"" + "]," + "\"notUnitOfRetention\": true" + "}," + "\"col1a_items_latitude\": {" + "\"type\": \"number\"," + "\"elementName\": \"latitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.latitude\"," + "\"elementKey\": \"col1a_items_latitude\"," + "\"notUnitOfRetention\": true" + "}," + "\"col1a_items_longitude\": {" + "\"type\": \"number\"," + "\"elementName\": \"longitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.longitude\"," + "\"elementKey\": \"col1a_items_longitude\"," + "\"notUnitOfRetention\": true" + "}," + "\"col1a_items_altitude\": {" + "\"type\": \"number\"," + "\"elementName\": \"altitude\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.altitude\"," + "\"elementKey\": \"col1a_items_altitude\"," + "\"notUnitOfRetention\": true" + "}," + "\"col1a_items_accuracy\": {" + "\"type\": \"number\"," + "\"elementName\": \"accuracy\"," + "\"elementSet\": \"data\"," + "\"elementPath\": \"col1a.items.accuracy\"," + "\"elementKey\": \"col1a_items_accuracy\"," + "\"notUnitOfRetention\": true" + "}," + "\"_id\": {" + "\"type\": \"string\"," + "\"isNotNullable\": true," + "\"elementKey\": \"_id\"," + "\"elementName\": \"_id\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_id\"" + "}," + "\"_row_etag\": {" + "\"type\": \"string\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_row_etag\"," + "\"elementName\": \"_row_etag\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_row_etag\"" + "}," + "\"_sync_state\": {" + "\"type\": \"string\"," + "\"isNotNullable\": true," + "\"elementKey\": \"_sync_state\"," + "\"elementName\": \"_sync_state\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_sync_state\"" + "}," + "\"_conflict_type\": {" + "\"type\": \"integer\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_conflict_type\"," + "\"elementName\": \"_conflict_type\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_conflict_type\"" + "}," + "\"_default_access\": {" + "\"type\": \"string\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_default_access\"," + "\"elementName\": \"_default_access\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_default_access\"" + "}," + "\"_row_owner\": {" + "\"type\": \"string\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_row_owner\"," + "\"elementName\": \"_row_owner\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_row_owner\"" + "}," + "\"_group_read_only\": {" + "\"type\": \"string\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_group_read_only\"," + "\"elementName\": \"_group_read_only\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_group_read_only\"" + "}," + "\"_group_modify\": {" + "\"type\": \"string\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_group_modify\"," + "\"elementName\": \"_group_modify\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_group_modify\"" + "}," + "\"_group_privileged\": {" + "\"type\": \"string\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_group_privileged\"," + "\"elementName\": \"_group_privileged\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_group_privileged\"" + "}," + "\"_form_id\": {" + "\"type\": \"string\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_form_id\"," + "\"elementName\": \"_form_id\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_form_id\"" + "}," + "\"_locale\": {" + "\"type\": \"string\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_locale\"," + "\"elementName\": \"_locale\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_locale\"" + "}," + "\"_savepoint_type\": {" + "\"type\": \"string\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_savepoint_type\"," + "\"elementName\": \"_savepoint_type\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_savepoint_type\"" + "}," + "\"_savepoint_timestamp\": {" + "\"type\": \"string\"," + "\"isNotNullable\": true," + "\"elementKey\": \"_savepoint_timestamp\"," + "\"elementName\": \"_savepoint_timestamp\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_savepoint_timestamp\"" + "}," + "\"_savepoint_creator\": {" + "\"type\": \"string\"," + "\"isNotNullable\": false," + "\"elementKey\": \"_savepoint_creator\"," + "\"elementName\": \"_savepoint_creator\"," + "\"elementSet\": \"instanceMetadata\"," + "\"elementPath\": \"_savepoint_creator\"" + "}" + "}"; int metaCount = 0; TreeMap<String, Object> model = ColumnDefinition.getExtendedDataModel(colDefs); TypeReference<TreeMap<String, Object>> refType = new TypeReference<TreeMap<String, Object>>() { }; TreeMap<String, Object> xlsxModel; try { xlsxModel = ODKFileUtils.mapper.readValue(equivalentXLSXConverterDataTableModel, refType); } catch (IOException e) { assertFalse("failed to parse XLSXConverter version", true); return; } for (String elementKey : model.keySet()) { TreeMap<String, Object> value = (TreeMap<String, Object>) model.get(elementKey); assert (xlsxModel.containsKey(elementKey)); Map<String, Object> xlsxValue = (Map<String, Object>) xlsxModel.get(elementKey); List<String> ignoredKeys = new ArrayList<String>(); for (String key : xlsxValue.keySet()) { if (key.startsWith("_")) { ignoredKeys.add(key); } if (key.equals("prompt_type_name")) { ignoredKeys.add(key); } } for (String key : ignoredKeys) { xlsxValue.remove(key); } assertEquals("Investigating: " + elementKey, value.size(), xlsxValue.size()); recursiveMatch(elementKey, value, xlsxValue); ColumnDefinition def = null; try { def = ColumnDefinition.find(colDefs, elementKey); } catch (IllegalArgumentException e) { // ignore } if (def == null) { assertEquals(value.get("elementSet"), "instanceMetadata"); assertEquals(value.get("elementKey"), elementKey); assertEquals(value.get("elementName"), elementKey); assertEquals(value.get("elementPath"), elementKey); assertEquals(value.containsKey("notUnitOfRetention"), false); if (elementKey.equals(TableConstants.ID)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), true); } else if (elementKey.equals(TableConstants.ROW_ETAG)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), false); } else if (elementKey.equals(TableConstants.SYNC_STATE)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), true); } else if (elementKey.equals(TableConstants.CONFLICT_TYPE)) { metaCount++; assertEquals(value.get("type"), "integer"); assertEquals(value.get("isNotNullable"), false); } else if (elementKey.equals(TableConstants.DEFAULT_ACCESS)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), false); } else if (elementKey.equals(TableConstants.ROW_OWNER)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), false); } else if (elementKey.equals(TableConstants.GROUP_READ_ONLY)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), false); } else if (elementKey.equals(TableConstants.GROUP_MODIFY)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), false); } else if (elementKey.equals(TableConstants.GROUP_PRIVILEGED)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), false); } else if (elementKey.equals(TableConstants.SAVEPOINT_TIMESTAMP)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), true); } else if (elementKey.equals(TableConstants.SAVEPOINT_TYPE)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), false); } else if (elementKey.equals(TableConstants.SAVEPOINT_CREATOR)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), false); } else if (elementKey.equals(TableConstants.FORM_ID)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), false); } else if (elementKey.equals(TableConstants.LOCALE)) { metaCount++; assertEquals(value.get("type"), "string"); assertEquals(value.get("isNotNullable"), false); } else { throw new IllegalStateException("Unexpected non-user column"); } } else { assertEquals(value.get("elementPath"), def.getElementName()); assertEquals(value.get("elementSet"), "data"); assertEquals(value.get("elementName"), def.getElementName()); assertEquals(value.get("elementKey"), def.getElementKey()); if (!def.isUnitOfRetention()) { assertEquals(value.get("notUnitOfRetention"), true); } // TODO: there are a lot more paths to verify here... assertEquals(value.containsKey("isNotNullable"), false); } } assertEquals(metaCount, 14); }
From source file:be.cytomine.client.HttpClient.java
public void authorize(String action, String url, String contentType, String accept) throws IOException { url = url.replace(host, ""); url = url.replace("http://" + host, ""); url = url.replace("https://" + host, ""); TreeMap<String, String> headers = new TreeMap<String, String>(); headers.put("accept", accept); headers.put("date", getActualDateStr()); log.debug("AUTHORIZE: " + action + "\\n\\n" + contentType + "\\n" + headers.get("date") + "\n"); String canonicalHeaders = action + "\n\n" + contentType + "\n" + headers.get("date") + "\n"; String messageToSign = canonicalHeaders + url; log.debug("publicKey=" + publicKey); log.debug("privateKey=" + privateKey); log.debug("messageToSign=" + messageToSign); SecretKeySpec privateKeySign = new SecretKeySpec(privateKey.getBytes(), "HmacSHA1"); try {// w ww. j a v a2s.c om Mac mac = Mac.getInstance("HmacSHA1"); mac.init(privateKeySign); byte[] rawHmac = mac.doFinal(new String(messageToSign.getBytes(), "UTF-8").getBytes()); byte[] signatureBytes = Base64.encodeBase64(rawHmac); String signature = new String(signatureBytes); String authorization = "CYTOMINE " + publicKey + ":" + signature; log.debug("signature=" + signature); log.debug("authorization=" + authorization); headers.put("authorization", authorization); for (String key : headers.keySet()) { addHeader(key, headers.get(key)); } } catch (GeneralSecurityException e) { throw new IOException(e); } }
From source file:playground.meisterk.org.matsim.run.facilities.ShopsOf2005ToFacilities.java
private static void processPickPayOpenTimes(final ActivityFacilitiesImpl facilities) { System.out.println("Setting up Pickpay open times..."); List<String> openTimeLines = null; List<String> addressLines = null; String[] openTokens = null, closeTokens = null; String[] addressTokens = null; Vector<Integer> openNumbers = new Vector<Integer>(); Vector<Integer> closeNumbers = new Vector<Integer>(); TreeMap<String, String> aPickpayOpentime = new TreeMap<String, String>(); String facilityId = null;/*ww w. j a va2 s.c o m*/ int addressLinePointer = 1; // ignore header line final String OPEN = "Auf"; final String CLOSE = "Zu"; String openLinePattern = ".*\\s" + OPEN + "\\s.*"; String closeLinePattern = ".*\\s" + CLOSE + "\\s.*"; try { openTimeLines = FileUtils.readLines(new File(pickPayOpenTimesFilename), "UTF-8"); addressLines = FileUtils.readLines(new File(pickPayAdressesFilename), "UTF-8"); } catch (IOException e) { e.printStackTrace(); } // remember relevant lines only String key = null; for (String line : openTimeLines) { if (line.matches(openLinePattern)) { key = line; } else if (line.matches(closeLinePattern)) { if (!aPickpayOpentime.containsKey(key)) { aPickpayOpentime.put(key, line); } } } for (String openLine : aPickpayOpentime.keySet()) { openTokens = openLine.split(ANYTHING_BUT_DIGITS); addressTokens = addressLines.get(addressLinePointer).split(FIELD_DELIM); shopId = new ShopId(PICKPAY, "", addressTokens[1], "", addressTokens[4], addressTokens[5], addressTokens[2]); addressLinePointer++; facilityId = shopId.getShopId(); //System.out.println(facilityId); ActivityFacilityImpl theCurrentPickpay = (ActivityFacilityImpl) facilities.getFacilities() .get(Id.create(facilityId, ActivityFacility.class)); if (theCurrentPickpay != null) { // yeah, we can use the open times ActivityOptionImpl shopping = theCurrentPickpay.createActivityOption(ACTIVITY_TYPE_SHOP); openNumbers.clear(); closeNumbers.clear(); // print out and extract numbers //System.out.print(OPEN + ":\t"); for (String token : openTokens) { if (!token.equals("") && !token.equals(openTokens[0])) { openNumbers.add(Integer.valueOf(token)); //System.out.print(token + "\t"); } } //System.out.println(); closeTokens = aPickpayOpentime.get(openLine).split(ANYTHING_BUT_DIGITS); //System.out.print(CLOSE + ":\t"); for (String token : closeTokens) { if (!token.equals("")) { closeNumbers.add(Integer.valueOf(token)); //System.out.print(token + "\t"); } } //System.out.println(); // now process numbers //String day = "wkday"; Day[] days = Day.values(); int dayPointer = 0; OpeningTimeImpl opentime = null; int openSeconds = 0; int closeSeconds = 0; int previousOpenSeconds = 0; if (openNumbers.size() == closeNumbers.size()) { for (int ii = 0; ii < openNumbers.size(); ii += 2) { openSeconds = openNumbers.get(ii) * 3600 + openNumbers.get(ii + 1) * 60; closeSeconds = closeNumbers.get(ii) * 3600 + closeNumbers.get(ii + 1) * 60; // check if a new day starts if (openSeconds <= previousOpenSeconds) { dayPointer++; } previousOpenSeconds = openSeconds; opentime = new OpeningTimeImpl(days[dayPointer].getAbbrevEnglish(), openSeconds, closeSeconds); shopping.addOpeningTime(opentime); } } else { throw new RuntimeException("openNumbers[] and closeNumbers[] have different size. Aborting..."); } System.out.flush(); } else { System.out.println("A pickpay with id " + facilityId + " does not exist."); } } System.out.println("Setting up Pickpay open times...done."); }
From source file:com.searchtechnologies.aspire.components.heritrixconnector.HeritrixScanner.java
@Override public AspireObject getStatus() throws AspireException { HeritrixSourceInfo info = (HeritrixSourceInfo) this.info; AspireObject status = addDerivedStatus(STAGE_ID, super.getStatus()); if (info != null) { CrawlJob job = info.getCrawlJob(); if (job != null) { status.push("uriTotalsReportData"); status.setAttribute("defaultConfig", Boolean.toString(info.useDefaultConfigFile())); if (info.useDefaultConfigFile()) { status.setAttribute("url", info.getStartUrl()); } else { status.setAttribute("configFile", info.getConfigFileLocation()); }/*from w w w.ja v a 2 s . c om*/ if (job != null & job.uriTotalsReportData() != null) for (Entry<String, Long> entry2 : job.uriTotalsReportData().entrySet()) { if (!entry2.getKey().equalsIgnoreCase("futureuricount")) { status.add(entry2.getKey(), entry2.getValue()); } } status.pop(); // uriTotalsReportData status.add("uriTotalReport", job.uriTotalsReport()); status.add("frontierReport", job.frontierReport()); status.add("elapsedReport", job.elapsedReport()); } status.push("contentSourcesDB"); if (info.getIncrementalDB() != null) { status.push("database"); //status.setAttribute("id", ""+info.getDatabaseId()); status.add("friendlyName", info.getFriendlyName()); status.add("urlAdded", info.getDocsAdded()); status.add("urlUpdated", info.getDocsUpdated()); status.add("revisitRate", (info.getDocsUpdated() + 0.0) / ((info.getIncrementalDB().size() - 1) + info.getDocsDeleted() + 0.0)); status.add("urlDeleted", info.getDocsDeleted()); status.add("size", info.getIncrementalDB().size() - 1); status.add("directory", info.getUrlDir()); HashMap<String, MutableInt> hostCount = new HashMap<String, MutableInt>(); HashMap<String, MutableInt> lastHostCount = new HashMap<String, MutableInt>(); long now = new Date().getTime(); for (String url : info.getIncrementalDB().keySet()) { String hostname = null; if (url.equals("||status||")) continue; try { hostname = new URL(StringUtilities.safeUrl(url)).getHost(); } catch (MalformedURLException e) { throw new AspireException( "com.searchtechnologies.aspire.components.heritrixconnector.HeritrixScanner", e, "Error getting hostname for url: %s", url); } DataBaseURLEntry data = DataBaseURLEntry .createDataBaseURLEntryFromString(info.getIncrementalDB().get(url)); if (hostCount.containsKey(hostname)) { hostCount.get(hostname).increment(); } else { hostCount.put(hostname, new MutableInt(1)); } if ((now - data.getTimestamp().getTime()) <= 300000) { //last 5 minutes if (lastHostCount.containsKey(hostname)) { lastHostCount.get(hostname).increment(); } else { lastHostCount.put(hostname, new MutableInt(1)); } } } ValueComparator comparator = new ValueComparator(hostCount); TreeMap<String, MutableInt> sorted_map = new TreeMap<String, MutableInt>(comparator); sorted_map.putAll(hostCount); status.push("hostnames"); for (String hostname : sorted_map.keySet()) { status.push("hostname"); status.setAttribute("name", hostname); status.add("total", hostCount.get(hostname).toString()); status.pop(); // hostname } status.pop(); // hostnames comparator = new ValueComparator(lastHostCount); sorted_map = new TreeMap<String, MutableInt>(comparator); sorted_map.putAll(lastHostCount); status.push("lastHostnames"); for (String hostname : sorted_map.keySet()) { status.push("hostname"); status.setAttribute("name", hostname); status.add("total", lastHostCount.get(hostname).toString()); status.pop(); // hostname } status.pop(); // lastHostnames status.pop(); } } status.popAll(); return status; }