/** * Construct. * * @param notAllowed * comma separated list with values which are not allowed in the user agent * @param detectionStrings * a list with strings which has to be in the user agent string */ UserAgent(String notAllowed, List<String>... detectionStrings) { notAllowedList = Strings.split(notAllowed, ','); this.detectionStrings = detectionStrings; }
protected List<String> getTokensFromHeader(HttpServletRequest req, String headerName) { List<String> result = new ArrayList<>(); Enumeration<String> headers = req.getHeaders(headerName); while (headers.hasMoreElements()) { String header = headers.nextElement(); String[] tokens = Strings.split(header, ','); for (String token : tokens) { result.add(token.trim()); } } return result; }
protected List<String> getTokensFromHeader(HttpServletRequest req, String headerName) { List<String> result = new ArrayList<>(); Enumeration<String> headers = req.getHeaders(headerName); while (headers.hasMoreElements()) { String header = headers.nextElement(); String[] tokens = Strings.split(header, ','); for (String token : tokens) { result.add(token.trim()); } } return result; }
private boolean headerContainsToken(HttpServletRequest req, String headerName, String target) { Enumeration<String> headers = req.getHeaders(headerName); while (headers.hasMoreElements()) { String header = headers.nextElement(); String[] tokens = Strings.split(header, ','); for (String token : tokens) { if (target.equalsIgnoreCase(token.trim())) { return true; } } } return false; }
private boolean headerContainsToken(HttpServletRequest req, String headerName, String target) { Enumeration<String> headers = req.getHeaders(headerName); while (headers.hasMoreElements()) { String header = headers.nextElement(); String[] tokens = Strings.split(header, ','); for (String token : tokens) { if (target.equalsIgnoreCase(token.trim())) { return true; } } } return false; }
private String getFileName(Part part) { String contentDisposition = part.getHeader(AbstractResource.CONTENT_DISPOSITION_HEADER_NAME); for (String cd : Strings.split(contentDisposition, ';')) { if (cd.trim().startsWith("filename")) { return cd.substring(cd.indexOf('=') + 1).trim() .replace("\"", ""); } } return null; }
private List<String> collectEvents(AjaxEventBehavior behavior) { List<String> events = new ArrayList<>(); String behaviorEvent = behavior.getEvent(); String[] behaviorEventNames = Strings.split(behaviorEvent, ' '); for (String behaviorEventName : behaviorEventNames) { if (behaviorEventName.startsWith("on")) { behaviorEventName = behaviorEventName.substring(2); } events.add(behaviorEventName); } return events; }
/** * Make paths like aa/bb/cc = cc/bb/aa. * * @param assetPath the path to revert * @return reverted path */ public static String reversePath(String assetPath) { final String[] assetPathComponents = Strings.split(assetPath, '/'); final StringBuilder reversedAssetPath = new StringBuilder(); for (int i = assetPathComponents.length - 1; i >= 0; --i) { if (reversedAssetPath.length() > 0) { reversedAssetPath.append('/'); } reversedAssetPath.append(assetPathComponents[i]); } return reversedAssetPath.toString(); }
public ValidationReport(HtmlValidationConfiguration configuration, IRequestablePage page, String markup, DocType doctype) { this.configuration = configuration; if (page != null) this.page = page.getClass().getName(); else this.page = "<unable to determine page>"; this.markup = markup; this.lines = Strings.split(markup, '\n'); this.doctype = doctype.name(); // getIdentifier(); }
private String getFileName(Part part) { String contentDisposition = part.getHeader(AbstractResource.CONTENT_DISPOSITION_HEADER_NAME); for (String cd : Strings.split(contentDisposition, ';')) { if (cd.trim().startsWith("filename")) { return cd.substring(cd.indexOf('=') + 1).trim() .replace("\"", ""); } } return null; }
/** * * @param value * @return locale */ private Locale getLocale(final String value) { final String[] bits = Strings.split(value, '-'); if (bits.length < 1) { return null; } final String language = bits[0].toLowerCase(Locale.ROOT); if (bits.length > 1) { final String country = bits[1].toUpperCase(Locale.ROOT); return new Locale(language, country); } else { return new Locale(language); } }
/** * Make paths like aa/bb/cc = cc/bb/aa. * * @param assetPath the path to revert * @return reverted path */ public static String reversePath(String assetPath) { final String[] assetPathComponents = Strings.split(assetPath, '/'); final StringBuilder reversedAssetPath = new StringBuilder(); for (int i = assetPathComponents.length - 1; i >= 0; --i) { if (reversedAssetPath.length() > 0) { reversedAssetPath.append('/'); } reversedAssetPath.append(assetPathComponents[i]); } return reversedAssetPath.toString(); }
/** * initializes the ignore paths parameter * * @param filterConfig */ private void initIgnorePaths(final FilterConfig filterConfig) { String paths = filterConfig.getInitParameter(IGNORE_PATHS_PARAM); if (Strings.isEmpty(paths) == false) { String[] parts = Strings.split(paths, ','); for (String path : parts) { path = path.trim(); if (path.startsWith("/")) { path = path.substring(1); } ignorePaths.add(path); } } }
@Override public IMemcachedSettings setServerNames(String serverNames) { Args.notEmpty(serverNames, "serverNames"); String[] ss = Strings.split(serverNames, ','); this.servers = Generics.newArrayList(ss.length); for (String server : ss) { this.servers.add(server.trim()); } return this; }
public SpecialKeys(final Request request) { String rawKeys = request.getParameter("keys"); if (rawKeys != null && rawKeys.length() > 0) { String[] strings = Strings.split(rawKeys, ','); for (String string : strings) specialKeys.add(SpecialKey.getSpecialKey(string)); } }
public SpecialKeys(final Request request) { String rawKeys = request.getRequestParameters().getParameterValue("keys").toString(); if (rawKeys != null && rawKeys.length() > 0) { String[] strings = Strings.split(rawKeys, ','); for (String string : strings) this.specialKeys.add(SpecialKey.getSpecialKey(string)); } }
@Override protected void respond(AjaxRequestTarget target) { IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters(); String coordinateRaw = params.getParameterValue("coordinate").toString(); String featureId = params.getParameterValue("id").toString(); String properties = params.getParameterValue("properties").toString(); JsonObject propertiesJson = null; JsonElement propertiesParsed = new JsonParser().parse(properties); if (!(propertiesParsed instanceof JsonNull)) { propertiesJson = propertiesParsed.getAsJsonObject(); } String[] coordinates = Strings.split(coordinateRaw, ','); Double longitude = Double.parseDouble(coordinates[0]); Double latitude = Double.parseDouble(coordinates[1]); handleChange(target, featureId, new LongLat(longitude, latitude, projection), propertiesJson); }
@Override protected void respond(AjaxRequestTarget target) { IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters(); String coordinateRaw = params.getParameterValue("coordinate").toString(); String featureId = params.getParameterValue("id").toString(); String properties = params.getParameterValue("properties").toString(); JsonObject propertiesJson = null; JsonElement propertiesParsed = new JsonParser().parse(properties); if (!(propertiesParsed instanceof JsonNull)) { propertiesJson = propertiesParsed.getAsJsonObject(); } String[] coordinates = Strings.split(coordinateRaw, ','); Double longitude = Double.parseDouble(coordinates[0]); Double latitude = Double.parseDouble(coordinates[1]); if (!properties.isEmpty()) { handleClick(target, featureId, new LongLat(longitude, latitude, projection), propertiesJson); } else { handleClickMiss(target, new LongLat(longitude, latitude, projection)); } }
/** * * @param params * @param buffer */ protected void writeParamsAsHiddenFields(String[] params, AppendingStringBuffer buffer) { for (String param : params) { String[] pair = Strings.split(param, '='); buffer.append("<input type=\"hidden\" name=\"") .append(recode(pair[0])) .append("\" value=\"") .append(pair.length > 1 ? recode(pair[1]) : "") .append("\" />"); } }
/** * * @param params * @param buffer */ protected void writeParamsAsHiddenFields(String[] params, AppendingStringBuffer buffer) { for (String param : params) { String[] pair = Strings.split(param, '='); buffer.append("<input type=\"hidden\" name=\"") .append(recode(pair[0])) .append("\" value=\"") .append(pair.length > 1 ? recode(pair[1]) : "") .append("\" />"); } }