Java Code Examples for org.apache.commons.lang3.StringUtils#contains()
The following examples show how to use
org.apache.commons.lang3.StringUtils#contains() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XGsonBuilder.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public static JsonElement extract(JsonElement jsonElement, String name) { if ((null != jsonElement) && jsonElement.isJsonObject() && StringUtils.isNotEmpty(name)) { JsonObject jsonObject = jsonElement.getAsJsonObject(); if (StringUtils.contains(name, ".")) { String prefix = StringUtils.substringBefore(name, "."); String surfix = StringUtils.substringAfter(name, "."); if (jsonObject.has(prefix)) { return extract(jsonObject.get(prefix), surfix); } } else { if (jsonObject.has(name)) { return jsonObject.get(name); } } } return null; }
Example 2
Source File: AOPUtils.java From para with Apache License 2.0 | 6 votes |
/** * Object types should not start with '_' because it is in conflict with the API. * Some API resources have a path which also starts with '_' like {@code /v1/_me}. * @param obj an object */ protected static void checkAndFixType(ParaObject obj) { if (obj != null) { if (StringUtils.startsWith(obj.getType(), SPECIAL_PREFIX)) { obj.setType(obj.getType().replaceAll("^[" + SPECIAL_PREFIX + "]*", "")); } if (StringUtils.contains(obj.getType(), "#")) { // ElasticSearch doesn't allow # in type mappings obj.setType(obj.getType().replaceAll("#", "")); } if (StringUtils.contains(obj.getType(), "/")) { // type must not contain "/" obj.setType(obj.getType().replaceAll("/", "")); } if (obj.getType().isEmpty()) { obj.setType(Utils.type(Sysprop.class)); } } }
Example 3
Source File: Mp4v2InfoLoader.java From AudioBookConverter with GNU General Public License v2.0 | 6 votes |
static long parseDuration(String info) { String[] lines = StringUtils.split(info, "\n"); for (String line : lines) { if (StringUtils.isNotEmpty(line)) { String[] columns = StringUtils.split(line, ","); if (StringUtils.contains(columns[0], "audio")) { for (int j = 1, columnsLength = columns.length; j < columnsLength; j++) { String column = columns[j]; int k; if ((k = column.indexOf(" sec")) != -1) { String substring = column.substring(1, k); return (long) (Double.parseDouble(substring) * 1000); } } } } } return 0; }
Example 4
Source File: UserPrefsTool.java From sakai with Educational Community License v2.0 | 6 votes |
/** * @return Returns the prefTimeZones. */ public List<SelectItem> getPrefTimeZones() { if (prefTimeZones.size() == 0) { String[] timeZoneArray = TimeZone.getAvailableIDs(); Arrays.sort(timeZoneArray); for (int i = 0; i < timeZoneArray.length; i++) { String tzt = timeZoneArray[i]; if (StringUtils.contains(tzt, '/') && !StringUtils.startsWith(tzt, "SystemV") && !StringUtils.startsWith(tzt, "Etc/GMT")) { String id = tzt; String name = tzt; if (StringUtils.contains(tzt, '_')) { name = StringUtils.replace(tzt, "_", " "); } prefTimeZones.add(new SelectItem(id, name)); } } } return prefTimeZones; }
Example 5
Source File: WeiXinImpl.java From pre with GNU General Public License v3.0 | 6 votes |
/** * 获取用户信息 * * @param openId * @return */ @Override public WeixinUserInfo getUserInfo(String openId) { String url = WEIXIN_URL_GET_USER_INFO + openId; String result = getRestTemplate().getForObject(url, String.class); if(StringUtils.contains(result, "errcode")) { return null; } WeixinUserInfo userInfo = null; try{ userInfo = objectMapper.readValue(result,WeixinUserInfo.class); System.out.println(userInfo); }catch (Exception e){ e.printStackTrace(); } return userInfo; }
Example 6
Source File: DockerUtil.java From julongchain with Apache License 2.0 | 5 votes |
public static String getContainerStatus(String name) { DockerClient dockerClient = getDockerClient(); List<Container> list = dockerClient.listContainersCmd().withShowAll(true).exec(); for (Container container : list) { if (StringUtils.isEmpty(name) || StringUtils.contains(container.getNames()[0], name)) { closeDockerClient(dockerClient); return container.getStatus(); } } closeDockerClient(dockerClient); return null; }
Example 7
Source File: DBusKeeperInitAll.java From DBus with Apache License 2.0 | 5 votes |
private static void checkRegisterServer(Properties pro) { if (StringUtils.equals("false", pro.getProperty("register.server.enabled"))) { String registerServerUrl = pro.getProperty("register.server.url"); if (StringUtils.isBlank(registerServerUrl)) { throw new RuntimeException("register.server.url不能为空"); } if (StringUtils.contains(registerServerUrl, "必须修改") || !StringUtils.startsWith(registerServerUrl, "http")) { throw new RuntimeException("register.server.url格式不正确,正确格式[http://ip:port/xxx]"); } } }
Example 8
Source File: LoginInterceptor.java From fabric-net-server with Apache License 2.0 | 5 votes |
/** 在请求被处理之前调用 */ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { // 检查每个到来的请求对应的session域中是否有登录标识 String token = (String) request.getSession().getAttribute("token"); User user = CacheUtil.getUser(token); if (null == user) { response.sendRedirect("/login"); return false; } String uri = request.getRequestURI(); // System.out.println(uri); switch (user.getRoleId()) { case Role.ADMIN: if (StringUtils.contains(uri, USER.substring(0, USER.length() -2))) { response.sendRedirect("/index"); return false; } break; case Role.MEMBER: if (!StringUtils.equals(uri, INDEX)) { response.sendRedirect("/index"); return false; } break; } return true; }
Example 9
Source File: ContentContainsStringAssertion.java From browserup-proxy with Apache License 2.0 | 5 votes |
@Override public HarEntryPredicate<String> getHarEntryPredicate() { return content -> { Optional<String> result = Optional.empty(); if (!StringUtils.contains(content, text)) { result = Optional.of( String.format( "Expected to find string in content. Search string: '%s', content: '%s'", text, content )); } return result; }; }
Example 10
Source File: RequestUtil.java From seed with Apache License 2.0 | 4 votes |
/** * 判断是否为含附件的请求 */ public static boolean isMultipartRequest(HttpServletRequest request){ return StringUtils.contains(request.getContentType(), "multipart"); }
Example 11
Source File: Db2OffsetReset.java From DBus with Apache License 2.0 | 4 votes |
@Override public void offsetReset(Object... args) { List<TopicPartition> topicPartitions = (List<TopicPartition>) args[0]; List<TopicPartition> topicPartition2Begin = new ArrayList<>(); List<TopicPartition> topicPartition2End = new ArrayList<>(); HashMap<String, String> topicAndOffset = new HashMap<>(); String topicOffsets = dsInfo.getDataTopicOffset(); if (StringUtils.equals(topicOffsets, "none")) return; String[] topicsArr = StringUtils.split(topicOffsets, ","); for (String topic : topicsArr) { topicAndOffset.put(StringUtils.split(topic, "->")[0], StringUtils.split(topic, "->")[1]); } for (TopicPartition tp : topicPartitions) { String topicName = tp.topic(); if (StringUtils.contains(topicOffsets, topicName)) { String topicInfo = topicAndOffset.get(topicName); if (StringUtils.equals(topicInfo, "none")) { break; } else if (StringUtils.equals(topicInfo, "begin")) { topicPartition2Begin.add(tp); consumer.seekToBeginning(topicPartition2Begin); topicPartition2Begin.clear(); logger.info(String.format("TopicName : %s, Offset changed to begin!", tp.topic())); } else if (StringUtils.equals(topicInfo, "end")) { topicPartition2End.add(tp); consumer.seekToEnd(topicPartition2End); topicPartition2End.clear(); logger.info(String.format("TopicName : %s, Offset changed to end!", tp.topic())); } else { long nOffset = Long.parseLong(topicInfo); consumer.seek(tp, nOffset); logger.info(String.format("TopicName : %s, Offset changed as: %d", tp.topic(), consumer.position(tp))); } } } }
Example 12
Source File: AWSIoTService.java From para with Apache License 2.0 | 4 votes |
private String getAccountIdFromARN(String arn) { return StringUtils.contains(arn, ":") ? arn.split(":")[4] : ""; }
Example 13
Source File: MainViewLoginPageModContentFactoryImpl.java From cia with Apache License 2.0 | 4 votes |
@Override public boolean matches(final String page, final String parameters) { return NAME.equals(page) && StringUtils.contains(parameters, ApplicationPageMode.LOGIN.toString()); }
Example 14
Source File: DocumentDataPageModContentFactoryImpl.java From cia with Apache License 2.0 | 4 votes |
@Override public boolean matches(final String page, final String parameters) { return NAME.equals(page) && StringUtils.contains(parameters, DocumentPageMode.DOCUMENTDATA.toString()); }
Example 15
Source File: AbbreviatedCellClickListener.java From cuba with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public void onClick(Entity item, String columnId) { Table.Column column = table.getColumn(columnId); MetaProperty metaProperty; String value; if (DynamicAttributesUtils.isDynamicAttribute(columnId)) { metaProperty = dynamicAttributesTools.getMetaPropertyPath(item.getMetaClass(), columnId).getMetaProperty(); value = dynamicAttributesTools.getDynamicAttributeValueAsString(metaProperty, item.getValueEx(columnId)); } else { value = item.getValueEx(columnId); } if (column.getMaxTextLength() != null) { boolean isMultiLineCell = StringUtils.contains(value, "\n"); if (value == null || (value.length() <= column.getMaxTextLength() + MAX_TEXT_LENGTH_GAP && !isMultiLineCell)) { // todo artamonov if we click with CTRL and Table is multiselect then we lose previous selected items if (!table.getSelected().contains(item)) { table.setSelected(item); } // do not show popup view return; } } VerticalLayout layout = new VerticalLayout(); layout.setMargin(false); layout.setSpacing(false); layout.setWidthUndefined(); layout.setStyleName("c-table-view-textcut"); CubaTextArea textArea = new CubaTextArea(); textArea.setValue(Strings.nullToEmpty(value)); textArea.setReadOnly(true); CubaResizableTextAreaWrapper content = new CubaResizableTextAreaWrapper(textArea); content.setResizableDirection(ResizeDirection.BOTH); // todo implement injection for ThemeConstains in components ThemeConstants theme = App.getInstance().getThemeConstants(); if (theme != null) { content.setWidth(theme.get("cuba.web.Table.abbreviatedPopupWidth")); content.setHeight(theme.get("cuba.web.Table.abbreviatedPopupHeight")); } else { content.setWidth("320px"); content.setHeight("200px"); } layout.addComponent(content); table.withUnwrapped(CubaEnhancedTable.class, enhancedTable -> { enhancedTable.showCustomPopup(layout); enhancedTable.setCustomPopupAutoClose(false); }); }
Example 16
Source File: PoliticianRankingPageVisitHistoryPageModContentFactoryImpl.java From cia with Apache License 2.0 | 4 votes |
@Override public boolean matches(final String page, final String parameters) { return NAME.equals(page) && StringUtils.contains(parameters,PageMode.PAGEVISITHISTORY.toString()); }
Example 17
Source File: ParliamentChartsDecisionActivityByTypePageModContentFactoryImpl.java From cia with Apache License 2.0 | 4 votes |
@Override public boolean matches(final String page, final String parameters) { return NAME.equals(page) && StringUtils.contains(parameters, PageMode.CHARTS.toString()) && parameters.contains(ChartIndicators.DECISIONACTIVITYBYTYPE.toString()); }
Example 18
Source File: CommitteeDecisionTypeDailySummaryPageModContentFactoryImpl2.java From cia with Apache License 2.0 | 4 votes |
@Override public boolean matches(final String page, final String parameters) { return NAME.equals(page) && StringUtils.contains(parameters, CommitteePageMode.DECISIONTYPEDAILYSUMMARY.toString()); }
Example 19
Source File: ConsoleOutMatcherJunit5.java From gocd with Apache License 2.0 | 4 votes |
public ConsoleOutMatcherJunit5 contains(final String str) { if (!StringUtils.contains(actual, str)) { failWithMessage("Expected console to contain [<%s>] but was <%s>.", str, actual); } return this; }
Example 20
Source File: GroovyParser.java From warnings-ng-plugin with MIT License | 4 votes |
private static boolean containsNewline(final String expression) { return StringUtils.contains(expression, "\\n") || StringUtils.contains(expression, "\\r"); }