Java Code Examples for org.apache.commons.lang3.StringUtils#substringBetween()
The following examples show how to use
org.apache.commons.lang3.StringUtils#substringBetween() .
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: RestoreStateHandler.java From peer-os with Apache License 2.0 | 6 votes |
private String extractSnapshotLabel( String backupFilePath, String oldContainerName ) { String label = null; try { String s = StringUtils.substringBetween( backupFilePath, oldContainerName, ".tar.gz" ); label = StringUtils.substringAfterLast( s, "_" ); } catch ( Exception e ) { log.error( "Couldn't extract snapshot label from file '{}' and container '{}': {}", backupFilePath, oldContainerName, e.getMessage() ); } return label; }
Example 2
Source File: PermissionUtils.java From RuoYi with Apache License 2.0 | 6 votes |
/** * 权限错误消息提醒 * * @param permissionsStr 错误信息 * @return 提示信息 */ public static String getMsg(String permissionsStr) { String permission = StringUtils.substringBetween(permissionsStr, "[", "]"); String msg = MessageUtils.message(PERMISSION, permission); if (StrUtil.endWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION)) { msg = MessageUtils.message(CREATE_PERMISSION, permission); } else if (StrUtil.endWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION)) { msg = MessageUtils.message(UPDATE_PERMISSION, permission); } else if (StrUtil.endWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION)) { msg = MessageUtils.message(DELETE_PERMISSION, permission); } else if (StrUtil.endWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION)) { msg = MessageUtils.message(EXPORT_PERMISSION, permission); } else if (StrUtil.endWithAny(permission, PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION)) { msg = MessageUtils.message(VIEW_PERMISSION, permission); } return msg; }
Example 3
Source File: Downloader.java From MMDownloader with Apache License 2.0 | 5 votes |
public Worker(String imgURL, String path, String subFolder, int pageNum, int numberOfPages) { this.imgURL = imgURL; // http://wasabisyrup.com/storage/gallery/fTF1QkrSaJ4/P0001_9nmjZa2886s.jpg this.path = path; this.subFolder = subFolder; this.pageNum = pageNum; // 페이지 번호는 001.jpg, 052.jpg, 337.jpg같은 형식 this.numberOfPages = numberOfPages; this.host = StringUtils.substringBetween(imgURL, "http://", "/"); this.referer = StringUtils.substringBeforeLast(imgURL, "/"); }
Example 4
Source File: MatchExtCommunitySetHandler.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
private boolean matchCondition(final List<ExtendedCommunities> extendedCommunities, final String matchExtCommunitySetName, final MatchSetOptionsType matchSetOptions) { final String setKey = StringUtils .substringBetween(matchExtCommunitySetName, "=\"", "\""); final List<ExtendedCommunities> extCommunityfilter = this.extCommunitySets.getUnchecked(setKey); if (extCommunityfilter == null || extCommunityfilter.isEmpty()) { return false; } List<ExtendedCommunities> extCommList; if (extendedCommunities == null) { extCommList = Collections.emptyList(); } else { extCommList = extendedCommunities; } if (matchSetOptions.equals(MatchSetOptionsType.ALL)) { return extCommList.containsAll(extCommunityfilter) && extCommunityfilter.containsAll(extCommList); } final boolean noneInCommon = Collections.disjoint(extCommList, extCommunityfilter); if (matchSetOptions.equals(MatchSetOptionsType.ANY)) { return !noneInCommon; } //(matchSetOptions.equals(MatchSetOptionsType.INVERT)) return noneInCommon; }
Example 5
Source File: ComponentTreeLocatorHelper.java From bobcat with Apache License 2.0 | 5 votes |
private static int calculateElementNumber(String element) { int toReturn = 0; String elementNumber = StringUtils.substringBetween(element, "[", "]"); if (null != elementNumber) { try { toReturn = Integer.parseInt(elementNumber); } catch (NumberFormatException e) { LOG.error("Error in component settings", e); } } return toReturn; }
Example 6
Source File: FileTabController.java From axelor-open-suite with GNU Affero General Public License v3.0 | 5 votes |
public void showRecord(ActionRequest request, ActionResponse response) { try { FileTab fileTab = request.getContext().asType(FileTab.class); fileTab = Beans.get(FileTabRepository.class).find(fileTab.getId()); String btnName = request.getContext().get("_signal").toString(); String fieldName = StringUtils.substringBetween(btnName, "show", "Btn"); MetaJsonField jsonField = Beans.get(MetaJsonFieldRepository.class) .all() .filter( "self.name = ?1 AND self.type = 'many-to-many' AND self.model = ?2 AND self.modelField = 'attrs'", fieldName, fileTab.getClass().getName()) .fetchOne(); if (jsonField == null) { return; } String ids = Beans.get(FileTabService.class).getShowRecordIds(fileTab, jsonField.getName()); response.setView( ActionView.define(I18n.get(jsonField.getTitle())) .model(jsonField.getTargetModel()) .add("grid", jsonField.getGridView()) .add("form", jsonField.getFormView()) .domain("self.id IN (" + ids + ")") .map()); } catch (Exception e) { TraceBackService.trace(response, e); } }
Example 7
Source File: WebClientUtils.java From htmlunit with Apache License 2.0 | 5 votes |
/** * Attaches a visual (GUI) debugger to the specified client. * @param client the client to which the visual debugger is to be attached * @see <a href="http://www.mozilla.org/rhino/debugger.html">Mozilla Rhino Debugger Documentation</a> */ public static void attachVisualDebugger(final WebClient client) { final ScopeProvider sp = null; final HtmlUnitContextFactory cf = ((JavaScriptEngine) client.getJavaScriptEngine()).getContextFactory(); final Main main = Main.mainEmbedded(cf, sp, "HtmlUnit JavaScript Debugger"); main.getDebugFrame().setExtendedState(Frame.MAXIMIZED_BOTH); final SourceProvider sourceProvider = new SourceProvider() { @Override public String getSource(final DebuggableScript script) { String sourceName = script.getSourceName(); if (sourceName.endsWith("(eval)") || sourceName.endsWith("(Function)")) { return null; // script is result of eval call. Rhino already knows the source and we don't } if (sourceName.startsWith("script in ")) { sourceName = StringUtils.substringBetween(sourceName, "script in ", " from"); for (final WebWindow ww : client.getWebWindows()) { final WebResponse wr = ww.getEnclosedPage().getWebResponse(); if (sourceName.equals(wr.getWebRequest().getUrl().toString())) { return wr.getContentAsString(); } } } return null; } }; main.setSourceProvider(sourceProvider); }
Example 8
Source File: SqliteConnectionThreadPoolFactory.java From codenjoy with GNU General Public License v3.0 | 5 votes |
public SqliteConnectionThreadPoolFactory(boolean inMemory, String uri, ContextPathGetter context) { if (inMemory) { String name = StringUtils.substringBetween(uri, "/", ".db"); database = String.format("file:%s?mode=memory&cache=shared", name); } else { database = uri.replace(".db", "_" + context.getContext() + ".db"); createDirs(database); } }
Example 9
Source File: MediaUtil.java From wechat-mp-sdk with Apache License 2.0 | 5 votes |
private static String getFileNameFromContentDisposition(HttpResponse response) { Header header = ObjectUtils.firstNonNull(response.getFirstHeader("Content-disposition"), response.getFirstHeader("Content-Disposition")); if (header == null) { return null; } return StringUtils.substringBetween(header.getValue(), "filename=\"", "\""); }
Example 10
Source File: HeaderEnhanceFilter.java From microservice-integration with MIT License | 5 votes |
public ServerHttpRequest doFilter(ServerHttpRequest request) { ServerHttpRequest req = request; String authorization = request.getHeaders().getFirst("Authorization"); String requestURI = request.getURI().getPath(); // test if request url is permit all , then remove authorization from header LOGGER.info(String.format("Enhance request URI : %s.", requestURI)); if (StringUtils.isNotEmpty(authorization)) { if (isJwtBearerToken(authorization)) { try { authorization = StringUtils.substringBetween(authorization, "."); String decoded = new String(Base64.decodeBase64(authorization)); Map properties = new ObjectMapper().readValue(decoded, Map.class); String userId = (String) properties.get(USER_ID_IN_HEADER); req = request.mutate() .header(USER_ID_IN_HEADER, userId) .build(); } catch (Exception e) { LOGGER.error("Failed to customize header for the request, but still release it as the it would be regarded without any user details.", e); } } } else { LOGGER.info("Regard this request as anonymous request, so set anonymous user_id in the header."); req = request.mutate() .header(USER_ID_IN_HEADER, ANONYMOUS_USER_ID) .build(); } return req; }
Example 11
Source File: Configurator.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * Retrieve Gateway port based on the configured port offset * * @param carbonFilePath String * @return port int */ protected static int getGatewayPort(String carbonFilePath) { int port = 0; try { File file = new File(carbonFilePath); String carbonXMLContent = FileUtils.readFileToString(file); String offsetStr = StringUtils.substringBetween(carbonXMLContent, ConfigConstants.START_OFFSET_TAG, ConfigConstants.END_OFFSET_TAG); port = ConfigConstants.GATEWAY_DEFAULT_PORT + Integer.parseInt(offsetStr); } catch (IOException e) { log.error("Error occurred while reading the carbon XML.", e); Runtime.getRuntime().exit(1); } return port; }
Example 12
Source File: ComponentTreeLocatorHelper.java From bobcat with Apache License 2.0 | 5 votes |
private static int calculateElementNumber(String element) { int toReturn = 0; String elementNumber = StringUtils.substringBetween(element, "[", "]"); if (null != elementNumber) { try { toReturn = Integer.parseInt(elementNumber); } catch (NumberFormatException e) { LOG.error("Error in component settings", e); } } return toReturn; }
Example 13
Source File: BaseExceptionHandler.java From FEBS-Cloud with Apache License 2.0 | 5 votes |
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public FebsResponse handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { String message = "该方法不支持" + StringUtils.substringBetween(e.getMessage(), "'", "'") + "请求方法"; log.error(message); return new FebsResponse().message(message); }
Example 14
Source File: BaseExceptionHandler.java From FEBS-Cloud with Apache License 2.0 | 5 votes |
@ExceptionHandler(value = HttpMediaTypeNotSupportedException.class) @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public FebsResponse handleHttpMediaTypeNotSupportedException(HttpMediaTypeNotSupportedException e) { String message = "该方法不支持" + StringUtils.substringBetween(e.getMessage(), "'", "'") + "媒体类型"; log.error(message); return new FebsResponse().message(message); }
Example 15
Source File: AdvancedImportServiceImpl.java From axelor-open-suite with GNU Affero General Public License v3.0 | 4 votes |
@Transactional public void readFields( String value, int index, List<FileField> fileFieldList, List<Integer> ignoreFields, Mapper mapper, FileTab fileTab) throws AxelorException, ClassNotFoundException { FileField fileField = new FileField(); fileField.setSequence(index); if (Strings.isNullOrEmpty(value)) { return; } String importType = StringUtils.substringBetween(value, "(", ")"); if (!Strings.isNullOrEmpty(importType) && (importType.equalsIgnoreCase(forSelectUseValues) || importType.equalsIgnoreCase(forSelectUseTitles) || importType.equalsIgnoreCase(forSelectUseTranslatedTitles))) { fileField.setForSelectUse(this.getForStatusSelect(importType)); } else { fileField.setImportType(this.getImportType(value, importType)); } value = value.split("\\(")[0]; String importField = null; String subImportField = null; if (value.contains(".")) { importField = value.substring(0, value.indexOf(".")); subImportField = value.substring(value.indexOf(".") + 1, value.length()); } else { importField = value; } boolean isValid = this.checkFields(mapper, importField, subImportField); if (isValid) { this.setImportFields(mapper, fileField, importField, subImportField); } else { ignoreFields.add(index); } fileFieldList.add(fileField); fileField = fileFieldRepository.save(fileField); fileTab.addFileFieldListItem(fileField); }
Example 16
Source File: AccessServlet.java From wechat-mp-sdk with Apache License 2.0 | 4 votes |
private String getMsgType(String message) { return StringUtils.substringBetween(message, "<MsgType><![CDATA[", "]]></MsgType>"); }
Example 17
Source File: PaymentExecutionHelper.java From XS2A-Sandbox with Apache License 2.0 | 4 votes |
public RedirectedParams(String scaRedirect) { encryptedPaymentId = StringUtils.substringBetween(scaRedirect, "paymentId=", "&redirectId="); redirectId = StringUtils.substringAfter(scaRedirect, "&redirectId="); }
Example 18
Source File: OptIn.java From Natty with GNU General Public License v3.0 | 4 votes |
@Override public void execute(Room room) { User user = message.getUser(); long userId = user.getId(); String userName = user.getName(); int reputation = user.getReputation(); String data = CommandUtils.extractData(message.getPlainContent()).trim(); String pieces[] = data.split(" "); if(pieces.length>=2){ String tag = pieces[0]; String postType = pieces[1]; boolean whenInRoom = true; if(pieces.length==3 && pieces[2].equals("always")){ whenInRoom = false; } if(!tag.equals("all")){ tag = StringUtils.substringBetween(message.getPlainContent(),"[","]"); } if(postType.equals("all") || postType.equals("naa")){ OptedInUser optedInUser = new OptedInUser(); optedInUser.setPostType(postType); optedInUser.setRoomId(room.getRoomId()); optedInUser.setUser(new SOUser(userName,userId,reputation,null)); optedInUser.setTagname(tag); optedInUser.setWhenInRoom(whenInRoom); StorageService service = new FileStorageService(); service.addOptedInUser(optedInUser); } else { room.replyTo(message.getId(), "Type of post can be naa or all"); } } else if(pieces.length==1){ room.replyTo(message.getId(), "Please specify the type of post."); } }
Example 19
Source File: _JFCodeGenerator.java From sdb-mall with Apache License 2.0 | 4 votes |
public void vueAddUpdate(String className, TableMeta tablemeta) { boolean includeFlag = false; for (String includeClass:includedVueClass ) { if (includeClass.equalsIgnoreCase(className)) { includeFlag = true; break; } } if (!includeFlag) { return; } String packages = toPackages(); String classNameSmall = toClassNameSmall(className); String basePathUrl = basePath.replace('.', '/'); Map<String, String> columnMap = new HashMap<>(); for (ColumnMeta columnMeta :tablemeta.columnMetas ) { String desc = StringUtils.substringBetween(columnMeta.remarks, "[", "]"); columnMap.put(columnMeta.attrName, desc); } String primaryKey = StrKit.toCamelCase(tablemeta.primaryKey); jfEngine.render("/html/add-or-update.html", Kv.by("tablemeta", tablemeta) .set("package", packages) .set("className", className) .set("columnMap", columnMap) .set("primaryKey", primaryKey) .set("classNameSmall", classNameSmall) .set("basePath", basePathUrl) , new StringBuilder() .append(viewFolder) .append("/") .append(classNameSmall) .append("-add-or-update") .append(".vue") ); }
Example 20
Source File: IAndroidUtils.java From carina with Apache License 2.0 | 3 votes |
/** * This method provides app's version name for the app that is already installed to * devices, based on its package name. * In order to do that we search for "versionName" parameter in system dump. * Ex. "versionCode" returns 11200050, "versionName" returns 11.2.0 * * @param packageName String * @return appVersion String */ default public String getAppVersionName(String packageName){ String command = "dumpsys package ".concat(packageName); String output = this.executeShell(command); String versionName = StringUtils.substringBetween(output, "versionName=", "\n"); UTILS_LOGGER.info(String.format("Version name for '%s' package name is %s", packageName, versionName)); return versionName; }