public int[] getPropertyIntArray(String propName) { String strVal = m_env.get(propName, null); if (!StringUtility.hasText(strVal)) { return null; } String[] split = strVal.split(";"); int[] val = new int[split.length]; for (int i = 0; i < split.length; i++) { val[i] = Integer.parseInt(split[i]); } return val; }
/** * This method parses and normalizes the Scout keystroke and sets the class' member variables. * Example: <code> * {@link KeyStrokeNormalizer} ks = new {@link KeyStrokeNormalizer}("ALT-shiFt-F11");<br> * ks.{@link #normalize()};<br> * <br> * ks.{@link #getNormalizedKeystroke()}; //returns 'shift-alternate-f11'<br> * ks.{@link #getKey()}; //returns 'f11' <br> * ks.{@link #hasShift()}; //returns 'true'<br> * ks.{@link #hasAlt()}; //returns 'true' <br> * ks.{@link #hasCtrl()}; //returns 'false'<br> * ks.{@link #isValid()}; //returns 'true' <br> * </code> * <br> * If the keystroke is invalid, {@link #isValid()} will return <code>false</code>, all modifiers ({@link #hasAlt()}, * {@link #hasCtrl()}, {@link #hasShift()}) will be <code>false</code> and the * <code>{@link #getNormalizedKeystroke()} will return <code>null</code> */ public void normalize() { String keyStroke = m_originalKeyStroke; if (StringUtility.hasText(keyStroke)) { keyStroke = keyStroke.toLowerCase(); List<String> components = getComponents(keyStroke); performSanityChecks(keyStroke, components); parseModifiers(components); parseKey(components); if (!m_isValid) { setInvalid(); } } }
@Override public Date unmarshal(String rawValue) throws Exception { if (!StringUtility.hasText(rawValue)) { return null; } // local time of given timezone (or default timezone if not applicable) DatatypeFactory factory = DatatypeFactory.newInstance(); XMLGregorianCalendar xmlCalendar = factory.newXMLGregorianCalendar(rawValue); GregorianCalendar calendar = xmlCalendar.toGregorianCalendar(); long utcMillis = calendar.getTimeInMillis(); // default time Calendar defaultTimezoneCalendar = Calendar.getInstance(); defaultTimezoneCalendar.setTimeInMillis(utcMillis); return defaultTimezoneCalendar.getTime(); }
private void doHtmlResponse(HttpServletRequest req, HttpServletResponse resp) throws IOException { String errorMsg = ""; /* run garbage collection for better estimation of current memory usage */ String doGc = req.getParameter("gc"); if (StringUtility.hasText(doGc)) { System.gc(); errorMsg = "<font color='blue'> System.gc() triggered.</font>"; } List<List<String>> result = getDiagnosticItems(); IDiagnostic[] diagnosticServices = DiagnosticFactory.getDiagnosticProviders(); for (IDiagnostic diagnosticService : diagnosticServices) { if (CollectionUtility.hasElements(diagnosticService.getPossibleActions())) { diagnosticService.addSubmitButtonsHTML(result); } } DiagnosticFactory.addDiagnosticItemToList( result, "System.gc()", "", "<input type='checkbox' name='gc' value='yes'/>"); String diagnosticHTML = getDiagnosticItemsHTML(result); String title = "unknown"; Version version = Version.emptyVersion; IProduct product = Platform.getProduct(); if (product != null) { title = product.getName(); version = Version.parseVersion("" + product.getDefiningBundle().getHeaders().get("Bundle-Version")); } resp.setContentType("text/html"); ServletOutputStream out = resp.getOutputStream(); out.println("<html>"); out.println("<head>"); out.println("<title>" + title + "</title>"); out.println("<style>"); out.println("body {font-family: sans-serif; font-size: 12; background-color : #F6F6F6;}"); out.println("a,a:VISITED {color: #6666ff;text-decoration: none;}"); out.println("table {font-size: 12; empty-cells: show;}"); out.println( "th {text-align: left;vertical-align: top; padding-left: 2; background-color : #cccccc;}"); out.println("td {text-align: left;vertical-align: top; padding-left: 2;}"); out.println("p {margin-top: 4; margin-bottom: 4; padding-top: 4; padding-bottom: 4;}"); out.println("dt {font-weight: bold;}"); out.println("dd {margin-left: 20px; margin-bottom: 3px;}"); out.println(".copyright {font-size: 10;}"); out.println("</style>"); out.println("<script type=\"text/javascript\">"); out.println("function toggle_visibility(id) {"); out.println(" var el = document.getElementById(id);"); out.println(" el.style.display = (el.style.display != 'none' ? 'none' : 'block');"); out.println("}"); out.println("</script>"); out.println("</head>"); out.println("<body>"); out.println("<h3>" + title + " " + version + "</h3>"); out.println( "<form method='POST' action='" + StringUtility.join("?", req.getRequestURL().toString(), req.getQueryString()) + "'>"); out.print(diagnosticHTML); out.println("<p><input type='submit' value='submit'/></p>"); out.println("</form>"); out.print(errorMsg); out.println("<p class=\"copyright\">© " + OfficialVersion.COPYRIGHT + "</p>"); out.println("</body>"); out.println("</html>"); }