List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:de.micromata.genome.util.strings.converter.StandardStringConverter.java
@Override public Pair<Character, String> objectToString(Object value) { if (value == null) { return Pair.make(ConvertedStringTypes.NULL.getShortType(), null); }/*w ww . ja v a 2 s . c o m*/ if (value instanceof String) { return Pair.make(ConvertedStringTypes.STRING.getShortType(), (String) value); } if (value instanceof Boolean) { return Pair.make(ConvertedStringTypes.BOOLEAN.getShortType(), Boolean.toString((Boolean) value)); } if (value instanceof Byte) { return Pair.make(ConvertedStringTypes.BYTE.getShortType(), Byte.toString((Byte) value)); } if (value instanceof Short) { return Pair.make(ConvertedStringTypes.SHORT.getShortType(), Short.toString((Short) value)); } if (value instanceof Integer) { return Pair.make(ConvertedStringTypes.INTEGER.getShortType(), Integer.toString((Integer) value)); } if (value instanceof Long) { return Pair.make(ConvertedStringTypes.LONG.getShortType(), Long.toString((Long) value)); } if (value instanceof Float) { return Pair.make(ConvertedStringTypes.FLOAT.getShortType(), Float.toString((Float) value)); } if (value instanceof Double) { return Pair.make(ConvertedStringTypes.DOUBLE.getShortType(), Double.toString((Double) value)); } if (value instanceof Date) { return Pair.make(ConvertedStringTypes.DATE.getShortType(), formatDate((Date) value)); } if (value instanceof BigDecimal) { return Pair.make(ConvertedStringTypes.BIGDECIMAL.getShortType(), formatBigDecimal((BigDecimal) value)); } if (value instanceof Character) { return Pair.make(ConvertedStringTypes.CHAR.getShortType(), Character.toString((Character) value)); } if (value instanceof byte[]) { return Pair.make(ConvertedStringTypes.BYTEARRAY.getShortType(), formatByteArray((byte[]) value)); } if (value instanceof String[]) { return Pair.make(ConvertedStringTypes.STRINGARRAY.getShortType(), formatStringArray((String[]) value)); } if (value instanceof Long[]) { return Pair.make(ConvertedStringTypes.LONGARRAY.getShortType(), formatLongArray((Long[]) value)); } throw new IllegalArgumentException( "StringConverter; Cannot encode object to string: " + value.getClass().getName()); }
From source file:org.apache.sling.scripting.sightly.impl.engine.compiled.SourceIdentifier.java
public static String getScriptName(String slashSubpackage, String fullyQualifiedClassName) { String className = fullyQualifiedClassName; StringBuilder pathElements = new StringBuilder("/"); if (StringUtils.isNotEmpty(slashSubpackage) && className.contains(slashSubpackage)) { className = className.replaceAll(slashSubpackage + "\\.", ""); }/*w ww. j a va2 s.co m*/ String[] classElements = StringUtils.split(className, '.'); for (int i = 0; i < classElements.length; i++) { String classElem = classElements[i]; Matcher matcher = MANGLED_CHAR_PATTER.matcher(classElem); if (matcher.matches()) { String group = matcher.group(2); char unmangled = unmangle(group); classElem = classElem.replaceAll(group, Character.toString(unmangled)); while (matcher.find()) { group = matcher.group(2); unmangled = unmangle(group); classElem = classElem.replaceAll(group, Character.toString(unmangled)); } } else { int underscoreIndex = classElem.indexOf('_'); if (underscoreIndex > -1) { if (underscoreIndex == classElem.length() - 1) { classElem = classElem.substring(0, classElem.length() - 1); } else { classElem = classElem.replaceAll("_", "."); } } } pathElements.append(classElem); if (i < classElements.length - 1) { pathElements.append("/"); } } return pathElements.toString(); }
From source file:dkpro.similarity.algorithms.lexical.string.CosineSimilarity.java
@Override public double getSimilarity(String string1, String string2) throws SimilarityException { List<String> parts1 = new ArrayList<String>(); List<String> parts2 = new ArrayList<String>(); for (char c : string1.toCharArray()) { parts1.add(Character.toString(c)); }//from w ww . j a va 2s . com for (char c : string2.toCharArray()) { parts2.add(Character.toString(c)); } return getSimilarity(parts1, parts2); }
From source file:org.apache.lucene.benchmark.byTask.tasks.WriteLineDocTaskTest.java
private void doReadTest(Path file, Type fileType, String expTitle, String expDate, String expBody) throws Exception { InputStream in = Files.newInputStream(file); switch (fileType) { case BZIP2:/*w ww . j a v a 2 s. com*/ in = csFactory.createCompressorInputStream(CompressorStreamFactory.BZIP2, in); break; case GZIP: in = csFactory.createCompressorInputStream(CompressorStreamFactory.GZIP, in); break; case PLAIN: break; // nothing to do default: assertFalse("Unknown file type!", true); //fail, should not happen } try (BufferedReader br = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) { String line = br.readLine(); assertHeaderLine(line); line = br.readLine(); assertNotNull(line); String[] parts = line.split(Character.toString(WriteLineDocTask.SEP)); int numExpParts = expBody == null ? 2 : 3; assertEquals(numExpParts, parts.length); assertEquals(expTitle, parts[0]); assertEquals(expDate, parts[1]); if (expBody != null) { assertEquals(expBody, parts[2]); } assertNull(br.readLine()); } }
From source file:de.codesourcery.jasm16.lexer.Lexer.java
private void parseNextToken() { if (scanner.eof()) { return;//from w w w .j a v a2 s. co m } // clear buffer buffer.setLength(0); // skip whitespace int startIndex = relativeParseIndex(); while (!scanner.eof() && isWhitespace(scanner.peek())) { buffer.append(scanner.read()); } if (buffer.length() > 0) { currentTokens.add(new Token(TokenType.WHITESPACE, buffer.toString(), startIndex)); } if (scanner.eof()) { return; } startIndex = relativeParseIndex(); char currentChar = scanner.peek(); buffer.setLength(0); while (!scanner.eof()) { currentChar = scanner.peek(); switch (currentChar) { case ' ': // whitespace case '\t': // whitespace handleString(buffer.toString(), startIndex); return; case ';': // single-line comment handleString(buffer.toString(), startIndex); startIndex = relativeParseIndex(); scanner.read(); currentTokens.add(new Token(TokenType.SINGLE_LINE_COMMENT, ";", relativeParseIndex() - 1)); return; case '\\': handleString(buffer.toString(), startIndex); startIndex = relativeParseIndex(); scanner.read(); currentTokens.add(new Token(TokenType.STRING_ESCAPE, "\\", relativeParseIndex() - 1)); return; case '\'': case '"': // string delimiter handleString(buffer.toString(), startIndex); startIndex = relativeParseIndex(); scanner.read(); currentTokens.add(new Token(TokenType.STRING_DELIMITER, Character.toString(currentChar), relativeParseIndex() - 1)); return; case '\n': // parse unix-style newline handleString(buffer.toString(), startIndex); startIndex = relativeParseIndex(); scanner.read(); currentTokens.add(new Token(TokenType.EOL, "\n", relativeParseIndex() - 1)); return; case '\r': // parse DOS-style newline buffer.append(scanner.read()); if (!scanner.eof() && scanner.peek() == '\n') { handleString(buffer.toString(), buffer.length() - 1, startIndex); scanner.read(); currentTokens.add(new Token(TokenType.EOL, "\r\n", relativeParseIndex() - 2)); return; } continue; case ':': handleString(buffer.toString(), startIndex); scanner.read(); currentTokens.add(new Token(TokenType.COLON, ":", relativeParseIndex() - 1)); return; case '(': handleString(buffer.toString(), startIndex); scanner.read(); currentTokens.add(new Token(TokenType.PARENS_OPEN, "(", relativeParseIndex() - 1)); return; case ')': handleString(buffer.toString(), startIndex); scanner.read(); currentTokens.add(new Token(TokenType.PARENS_CLOSE, ")", relativeParseIndex() - 1)); return; case '[': handleString(buffer.toString(), startIndex); scanner.read(); currentTokens.add(new Token(TokenType.ANGLE_BRACKET_OPEN, "[", relativeParseIndex() - 1)); return; case ']': handleString(buffer.toString(), startIndex); scanner.read(); currentTokens.add(new Token(TokenType.ANGLE_BRACKET_CLOSE, "]", relativeParseIndex() - 1)); return; case ',': handleString(buffer.toString(), startIndex); scanner.read(); currentTokens.add(new Token(TokenType.COMMA, ",", relativeParseIndex() - 1)); return; } if (Operator.isOperatorPrefix(currentChar)) { parseOperator(startIndex); return; } // ...keep the rest...some unrecognized character sequence buffer.append(scanner.read()); } handleString(buffer.toString(), startIndex); }
From source file:net.pandoragames.far.ui.swing.dialog.SettingsDialog.java
private void init() { this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); this.setResizable(false); JPanel basePanel = new JPanel(); basePanel.setLayout(new BoxLayout(basePanel, BoxLayout.Y_AXIS)); basePanel.setBorder(/*w w w .j a va 2 s. c o m*/ BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); registerCloseWindowKeyListener(basePanel); // sink for error messages MessageLabel errorField = new MessageLabel(); errorField.setMinimumSize(new Dimension(100, swingConfig.getStandardComponentHight())); errorField.setBorder(BorderFactory.createEmptyBorder(1, SwingConfig.PADDING, 2, SwingConfig.PADDING)); TwoComponentsPanel lineError = new TwoComponentsPanel(errorField, Box.createRigidArea(new Dimension(1, swingConfig.getStandardComponentHight()))); lineError.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineError); // character set JLabel labelCharset = new JLabel(swingConfig.getLocalizer().localize("label.default-characterset")); labelCharset.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(labelCharset); JComboBox listCharset = new JComboBox(swingConfig.getCharsetList().toArray()); listCharset.setAlignmentX(Component.LEFT_ALIGNMENT); listCharset.setSelectedItem(swingConfig.getDefaultCharset()); listCharset.setEditable(true); listCharset.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); listCharset.addActionListener(new CharacterSetListener(errorField)); listCharset.setEditor(new CharacterSetEditor(errorField)); basePanel.add(listCharset); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // select the group selector JPanel selectorPanel = new JPanel(); selectorPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); selectorPanel.setAlignmentX(Component.LEFT_ALIGNMENT); // linePattern.setAlignmentX( Component.LEFT_ALIGNMENT ); JLabel labelSelector = new JLabel(swingConfig.getLocalizer().localize("label.group-ref-indicator")); selectorPanel.add(labelSelector); JComboBox selectorBox = new JComboBox(FARConfig.GROUPREFINDICATORLIST); selectorBox.setSelectedItem(Character.toString(groupReference)); selectorBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JComboBox cbox = (JComboBox) event.getSource(); String indicator = (String) cbox.getSelectedItem(); groupReference = indicator.charAt(0); } }); selectorPanel.add(selectorBox); basePanel.add(selectorPanel); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // checkbox DO BACKUP JCheckBox doBackupFlag = new JCheckBox(swingConfig.getLocalizer().localize("label.create-backup")); doBackupFlag.setAlignmentX(Component.LEFT_ALIGNMENT); doBackupFlag.setHorizontalTextPosition(SwingConstants.LEADING); doBackupFlag.setSelected(replaceForm.isDoBackup()); doBackupFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { doBackup = ItemEvent.SELECTED == event.getStateChange(); backupFlagEvent = event; } }); basePanel.add(doBackupFlag); JTextField backupDirPathTextField = new JTextField(); backupDirPathTextField.setPreferredSize( new Dimension(SwingConfig.COMPONENT_WIDTH, swingConfig.getStandardComponentHight())); backupDirPathTextField.setMaximumSize( new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, swingConfig.getStandardComponentHight())); backupDirPathTextField.setText(backupDirectory.getPath()); backupDirPathTextField.setToolTipText(backupDirectory.getPath()); backupDirPathTextField.setEditable(false); JButton openBaseDirFileChooserButton = new JButton(swingConfig.getLocalizer().localize("button.browse")); BrowseButtonListener backupDirButtonListener = new BrowseButtonListener(backupDirPathTextField, new BackUpDirectoryRepository(swingConfig, findForm, replaceForm, errorField), swingConfig.getLocalizer().localize("label.choose-backup-directory")); openBaseDirFileChooserButton.addActionListener(backupDirButtonListener); TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(backupDirPathTextField, openBaseDirFileChooserButton); lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT); basePanel.add(lineBaseDir); basePanel.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JPanel fileInfoPanel = new JPanel(); fileInfoPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), swingConfig.getLocalizer().localize("label.default-file-info"))); fileInfoPanel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.setLayout(new BoxLayout(fileInfoPanel, BoxLayout.Y_AXIS)); JLabel fileInfoLabel = new JLabel(swingConfig.getLocalizer().localize("message.displayed-in-info-column")); fileInfoLabel.setAlignmentX(Component.LEFT_ALIGNMENT); fileInfoPanel.add(fileInfoLabel); fileInfoPanel.add(Box.createHorizontalGlue()); JRadioButton nothingRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.nothing")); nothingRadio.setAlignmentX(Component.LEFT_ALIGNMENT); nothingRadio.setActionCommand(SwingConfig.DefaultFileInfo.NOTHING.name()); nothingRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.NOTHING); fileInfoOptions.add(nothingRadio); fileInfoPanel.add(nothingRadio); JRadioButton readOnlyRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.read-only-warning")); readOnlyRadio.setAlignmentX(Component.LEFT_ALIGNMENT); readOnlyRadio.setActionCommand(SwingConfig.DefaultFileInfo.READONLY.name()); readOnlyRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.READONLY); fileInfoOptions.add(readOnlyRadio); fileInfoPanel.add(readOnlyRadio); JRadioButton sizeRadio = new JRadioButton(swingConfig.getLocalizer().localize("label.filesize")); sizeRadio.setAlignmentX(Component.LEFT_ALIGNMENT); sizeRadio.setActionCommand(SwingConfig.DefaultFileInfo.SIZE.name()); sizeRadio.setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.SIZE); fileInfoOptions.add(sizeRadio); fileInfoPanel.add(sizeRadio); JCheckBox showPlainBytesFlag = new JCheckBox( " " + swingConfig.getLocalizer().localize("label.show-plain-bytes")); showPlainBytesFlag.setAlignmentX(Component.LEFT_ALIGNMENT); showPlainBytesFlag.setHorizontalTextPosition(SwingConstants.LEADING); showPlainBytesFlag.setSelected(swingConfig.isShowPlainBytes()); showPlainBytesFlag.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { showBytes = ItemEvent.SELECTED == event.getStateChange(); } }); fileInfoPanel.add(showPlainBytesFlag); JRadioButton lastModifiedRadio = new JRadioButton( swingConfig.getLocalizer().localize("label.last-modified")); lastModifiedRadio.setAlignmentX(Component.LEFT_ALIGNMENT); lastModifiedRadio.setActionCommand(SwingConfig.DefaultFileInfo.LAST_MODIFIED.name()); lastModifiedRadio .setSelected(swingConfig.getDefaultFileInfo() == SwingConfig.DefaultFileInfo.LAST_MODIFIED); fileInfoOptions.add(lastModifiedRadio); fileInfoPanel.add(lastModifiedRadio); basePanel.add(fileInfoPanel); // buttons JPanel buttonPannel = new JPanel(); buttonPannel.setAlignmentX(Component.LEFT_ALIGNMENT); buttonPannel.setLayout(new FlowLayout(FlowLayout.TRAILING)); // cancel JButton cancelButton = new JButton(swingConfig.getLocalizer().localize("button.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { SettingsDialog.this.dispose(); } }); buttonPannel.add(cancelButton); // save JButton saveButton = new JButton(swingConfig.getLocalizer().localize("button.save")); saveButton.addActionListener(new SaveButtonListener()); buttonPannel.add(saveButton); this.getRootPane().setDefaultButton(saveButton); this.add(basePanel); this.add(buttonPannel); placeOnScreen(swingConfig.getScreenCenter()); }
From source file:com.stimulus.archiva.domain.Email.java
protected void addHeaderToField(String specialHeaderName, String headerName) { try {/*from w w w. j a v a2 s .com*/ String[] headerValue = getHeader(headerName); if (headerValue != null && headerValue.length > 0) { StringBuffer buffer = new StringBuffer(); for (int i = 0; i < headerValue.length; i++) { buffer.append(headerValue[i]); buffer.append(","); } String header = buffer.toString(); if (header.endsWith(Character.toString(','))) header = header.substring(0, header.length() - 1); putField(specialHeaderName, header); } } catch (Exception e) { } }
From source file:org.docx4j.fonts.fop.fonts.truetype.TTFFontLoader.java
private void copyWidthsSingleByte(TTFFile ttf) { int[] wx = ttf.getWidths(); for (int i = singleFont.getFirstChar(); i <= singleFont.getLastChar(); i++) { singleFont.setWidth(i, ttf.getCharWidth(i)); }/*www .j a v a 2 s . c o m*/ Iterator iter = ttf.getCMaps().listIterator(); while (iter.hasNext()) { TTFCmapEntry ce = (TTFCmapEntry) iter.next(); if (ce.getUnicodeStart() < 0xFFFE) { for (char u = (char) ce.getUnicodeStart(); u <= ce.getUnicodeEnd(); u++) { int codePoint = singleFont.getEncoding().mapChar(u); if (codePoint <= 0) { String unicode = Character.toString(u); String charName = Glyphs.stringToGlyph(unicode); if (charName.length() > 0) { NamedCharacter nc = new NamedCharacter(charName, unicode); int glyphIndex = ce.getGlyphStartIndex() + u - ce.getUnicodeStart(); singleFont.addUnencodedCharacter(nc, wx[glyphIndex]); } } } } } }
From source file:jp.terasoluna.fw.file.dao.standard.VariableFileLineIterator.java
/** * ????? ???? ????<br>/*from w w w .j a va 2 s . c o m*/ * <code>fileLineString</code>?<code>null</code>???? ?????????<code>String</code>???? * @param fileLineString ??1? * @return ? */ @Override protected String[] separateColumns(String fileLineString) { if (fileLineString == null || "".equals(fileLineString)) { return new String[0]; } // 1??? StringBuilder columnBuilder = new StringBuilder(); // ???? char previousChar = Character.MIN_VALUE; // ?????? List<String> columnList = new ArrayList<String>(); boolean isEnclosed = true; boolean isEscaped = false; int fieldCount = 0; char[] columnEncloseChar = getColumnEncloseChar(); if (!isEnclosed()) { return StringUtils.splitByWholeSeparatorPreserveAllTokens(fileLineString, Character.toString(delimiter)); } else { for (char currentChar : fileLineString.toCharArray()) { if (previousChar == Character.MIN_VALUE) { previousChar = currentChar; } if (previousChar == getEncloseCharcter(columnEncloseChar, fieldCount)) { if (isEnclosed) { if (currentChar == getEncloseCharcter(columnEncloseChar, fieldCount)) { isEnclosed = false; } } else { if (currentChar == getEncloseCharcter(columnEncloseChar, fieldCount)) { if (isEscaped) { columnBuilder.append(currentChar); isEscaped = false; } else { isEscaped = true; } } else if (currentChar == getDelimiter()) { if (isEscaped) { columnList.add(columnBuilder.toString()); previousChar = Character.MIN_VALUE; columnBuilder.delete(0, columnBuilder.length()); isEnclosed = true; isEscaped = false; fieldCount++; } else { columnBuilder.append(currentChar); isEscaped = false; } } else { columnBuilder.append(currentChar); } } } else { if (currentChar != getDelimiter()) { columnBuilder.append(currentChar); } else { columnList.add(columnBuilder.toString()); previousChar = Character.MIN_VALUE; columnBuilder.delete(0, columnBuilder.length()); fieldCount++; } } } columnList.add(columnBuilder.toString()); return columnList.toArray(new String[columnList.size()]); } }
From source file:com.appdynamics.monitors.pingdom.communicator.PingdomCommunicator.java
@SuppressWarnings("rawtypes") private void getChecks(Map<String, Integer> metrics) { try {//from ww w. j a v a2s . c o m HttpClient httpclient = new DefaultHttpClient(); UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password); HttpGet httpget = new HttpGet(baseAddress + "/api/2.0/checks"); httpget.addHeader(BasicScheme.authenticate(creds, "US-ASCII", false)); httpget.addHeader("App-Key", appkey); HttpResponse response; response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); // reading in the JSON response String result = ""; if (entity != null) { InputStream instream = entity.getContent(); int b; try { while ((b = instream.read()) != -1) { result += Character.toString((char) b); } } finally { instream.close(); } } // parsing the JSON response try { JSONParser parser = new JSONParser(); ContainerFactory containerFactory = new ContainerFactory() { public List creatArrayContainer() { return new LinkedList(); } public Map createObjectContainer() { return new LinkedHashMap(); } }; // retrieving the metrics and populating HashMap JSONObject obj = (JSONObject) parser.parse(result); if (obj.get("checks") == null) { logger.error("Error retrieving data. " + obj); return; } JSONArray array = (JSONArray) parser.parse(obj.get("checks").toString()); for (Object checkObj : array) { JSONObject check = (JSONObject) checkObj; Map json = (Map) parser.parse(check.toJSONString(), containerFactory); String metricName = ""; if (json.containsKey("name")) { metricName = "Checks|" + json.get("name") + "|"; } else { logger.error("Encountered error while parsing metrics for a check: no name found!"); continue; } if (json.containsKey("id")) { try { metrics.put(metricName + "id", Integer.parseInt(json.get("id").toString())); } catch (NumberFormatException e) { logger.error("Error parsing metric value for " + metricName + "id"); } } if (json.containsKey("lastresponsetime")) { try { metrics.put(metricName + "lastresponsetime", Integer.parseInt(json.get("lastresponsetime").toString())); } catch (NumberFormatException e) { logger.error("Error parsing metric value for " + metricName + "lastresponsetime"); } } if (json.containsKey("lasttesttime")) { try { int testTime = Integer.parseInt(json.get("lasttesttime").toString()); java.util.Date date = new java.util.Date(testTime); Calendar cal = GregorianCalendar.getInstance(); cal.setTime(date); metrics.put(metricName + "lasttesttime", cal.get(Calendar.HOUR_OF_DAY)); } catch (NumberFormatException e) { logger.error("Error parsing metric value for " + metricName + "lasttesttime"); } catch (Throwable t) { logger.error("Error parsing metric value for " + metricName + "lasttesttime: can't get hour of day"); } } if (json.containsKey("resolution")) { try { metrics.put(metricName + "resolution", Integer.parseInt(json.get("resolution").toString())); } catch (NumberFormatException e) { logger.error("Error parsing metric value for " + metricName + "resolution"); } } if (json.containsKey("status")) { String status = json.get("status").toString(); if (status != null) { if (status.equals("down")) { metrics.put(metricName + "status", 0); } else if (status.equals("up")) { metrics.put(metricName + "status", 1); } else if (status.equals("unconfirmed_down")) { metrics.put(metricName + "status", 5); } else if (status.equals("unknown")) { metrics.put(metricName + "status", 20); } else if (status.equals("paused")) { metrics.put(metricName + "status", 50); } else { logger.error("Error parsing metric value for " + metricName + "status: Unknown status '" + status + "'"); } } else { logger.error("Error parsing metric value for " + metricName + "status"); } } } } catch (ParseException e) { logger.error("JSON Parsing error: " + e.getMessage()); } catch (Throwable e) { logger.error(e.getMessage()); } // parse header in the end to get the Req-Limits Header[] responseHeaders = response.getAllHeaders(); getLimits(metrics, responseHeaders); } catch (IOException e1) { logger.error(e1.getMessage()); } catch (Throwable t) { logger.error(t.getMessage()); } }