List of usage examples for java.lang String toString
public String toString()
From source file:com.draagon.meta.web.view.html.TextAreaView.java
public void doView(PageContext page, Object o, String label, int mode, Map params) throws MetaException { MetaField mf = getMetaField(o);/*from w ww. ja v a2 s. c om*/ try { String val = mf.getString(o); String text = (val == null) ? null : val.toString(); int cols = ViewHelper.getIntAttribute(this, "cols", 40); int rows = ViewHelper.getIntAttribute(this, "rows", 2); // Render the text area doTextAreaView(page, label, mode, cols, rows, text, params); } catch (IOException e) { log.error("Error displaying TextAreaView for field [" + mf + "] with mode [" + modeToString(mode) + "]", e); throw new WebViewException("Cannot render TextAreaView for field [" + mf + "] in mode [" + modeToString(mode) + "]: " + e.getMessage(), e); } }
From source file:com.gargoylesoftware.htmlunit.CodeStyleTest.java
/** * Converts the given alerts definition to an array of expressions. *//*from w w w . j a v a 2 s .c om*/ private static List<String> alertsToList(final String string) { final List<String> list = new ArrayList<>(); if ("\"\"".equals(string)) { list.add(string); } else { final StringBuilder currentToken = new StringBuilder(); boolean insideString = true; boolean startsWithBraces = false; for (final String token : string.split("(?<!\\\\)\"")) { insideString = !insideString; if (currentToken.length() != 0) { currentToken.append('"'); } else { startsWithBraces = token.toString().contains("{"); } if (!insideString && token.startsWith(",") && !startsWithBraces) { list.add(currentToken.toString()); currentToken.setLength(0); startsWithBraces = token.toString().contains("{"); } if (!insideString && token.contains("}")) { final int curlyIndex = token.indexOf('}') + 1; currentToken.append(token.substring(0, curlyIndex)); list.add(currentToken.toString()); currentToken.setLength(0); currentToken.append(token.substring(curlyIndex)); } else { if (!insideString && token.contains(",") && !startsWithBraces) { final String[] expressions = token.split(","); currentToken.append(expressions[0]); if (currentToken.length() != 0) { list.add(currentToken.toString()); } for (int i = 1; i < expressions.length - 1; i++) { list.add(',' + expressions[i]); } currentToken.setLength(0); currentToken.append(',' + expressions[expressions.length - 1]); } else { currentToken.append(token); } } } if (currentToken.length() != 0) { if (!currentToken.toString().contains("\"")) { currentToken.insert(0, '"'); } int totalQuotes = 0; for (int i = 0; i < currentToken.length(); i++) { if (currentToken.charAt(i) == '"' && (i == 0 || currentToken.charAt(i - 1) != '\\')) { totalQuotes++; } } if (totalQuotes % 2 != 0) { currentToken.append('"'); } list.add(currentToken.toString()); } } return list; }
From source file:com.esofthead.mycollab.schedule.email.format.I18nFieldFormat.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override//from ww w .j a v a 2s . c o m public String formatField(MailContext<?> context, String value) { try { Enum valueEnum = Enum.valueOf(enumKey, value.toString()); return LocalizationHelper.getMessage(context.getLocale(), valueEnum); } catch (Exception e) { log.error("Can not generate of object field: " + fieldName + " and " + value, e); return new Span().write(); } }
From source file:org.owasp.webgoat.plugin.HttpBasicsLesson.java
@RequestMapping(method = RequestMethod.POST) public @ResponseBody AttackResult completed(@RequestParam String person, HttpServletRequest request) throws IOException { if (!person.toString().equals("")) { return trackProgress(AttackResult.success( "The server has reversed your name: " + new StringBuffer(person).reverse().toString())); } else {/*ww w . java 2s.c om*/ return trackProgress(AttackResult.failed("You are close, try again")); } }
From source file:org.owasp.webgoat.plugin.InsecureLoginTask.java
@RequestMapping(method = RequestMethod.POST) public @ResponseBody AttackResult completed(@RequestParam String username, @RequestParam String password) throws IOException { if (username.toString().equals("CaptainJack") && password.toString().equals("BlackPearl")) { return trackProgress(success().build()); }/*from www.j av a2s.c om*/ return trackProgress(failed().build()); }
From source file:mustache.specs.SpecResourceLocator.java
@Override public TemplateSource sourceAt(final String uri) throws IOException { notNull(uri, "The uri is required."); notEmpty(uri.toString(), "The uri is required."); String location = resolve(normalize(uri)); String text = templates.get(uri.toString()); if (text == null) { throw new FileNotFoundException(location); }/*from w w w.ja v a 2 s. c o m*/ return new StringTemplateSource(location, text); }
From source file:org.owasp.webgoat.plugin.CrossSiteScriptingLesson1.java
@RequestMapping(method = RequestMethod.POST) public @ResponseBody AttackResult completed(@RequestParam String answer_xss_1, HttpServletRequest request) throws IOException { if (answer_xss_1.toString().toLowerCase().equals("yes")) { return trackProgress(AttackResult.success()); } else {//from w ww. j a va2 s . c o m return trackProgress(AttackResult.failed("Are you sure? Try using a tab from a different site.")); } }
From source file:uk.ac.ox.it.ords.security.model.Audit.java
public void setAuditType(String auditType) { this.auditType = auditType.toString().replace("_", " "); }
From source file:com.seyren.core.util.velocity.AbstractHelper.java
private String getTimeFromUntilString(Date date) { Calendar cal = Calendar.getInstance(); SimpleDateFormat format = new SimpleDateFormat("HH:mm_yyyyMMdd"); cal.setTime(date);/* w w w. j a v a 2 s. co m*/ cal.add(Calendar.HOUR, -1); String from = format.format(cal.getTime()); cal.add(Calendar.HOUR, 1); String until = format.format(cal.getTime()); return "&from=" + until.toString() + "&until=" + from.toString(); }
From source file:com.seyren.core.util.config.GraphiteConfig.java
private String[] splitBaseUrl(String baseUrl) { String[] baseParts = new String[3]; if (baseUrl.toString().contains("://")) { baseParts[0] = baseUrl.toString().split("://")[0]; baseUrl = baseUrl.toString().split("://")[1]; } else {/* w w w . j av a 2 s . c o m*/ baseParts[0] = "http"; } if (baseUrl.contains("/")) { baseParts[1] = baseUrl.split("/")[0]; baseParts[2] = "/" + baseUrl.split("/", 2)[1]; } else { baseParts[1] = baseUrl; baseParts[2] = ""; } return baseParts; }