List of usage examples for org.apache.commons.lang StringUtils startsWith
public static boolean startsWith(String str, String prefix)
Check if a String starts with a specified prefix.
From source file:com.adobe.acs.commons.wcm.notifications.impl.SystemNotificationsImpl.java
@Override public String getMessage(String message, String onTime, String offTime) { if (StringUtils.isBlank(message)) { return message; }/*www. ja v a 2s . c o m*/ message = StringUtils.trimToEmpty(message); boolean allowHTML = false; if (StringUtils.startsWith(message, "html:")) { allowHTML = true; message = StringUtils.removeStart(message, "html:"); } if (onTime != null) { message = StringUtils.replace(message, "{{ onTime }}", onTime); } if (offTime != null) { message = StringUtils.replace(message, "{{ offTime }}", offTime); } if (!allowHTML) { message = message.replaceAll("(\r\n|\n)", "<br />"); } return message; }
From source file:com.activecq.api.helpers.DesignHelper.java
/** * Used to create path from Design resource, asset type prefix (css, images, * js, etc) and path (usually file name) * * @param resource/* w w w. j a va2 s . com*/ * @param pathPrefix * @param path * @return */ protected static String makePath(Resource resource, String pathPrefix, String path) { if (StringUtils.startsWith(path, "/")) { // Absolute paths ignore the pathPrefix return resource.getPath() + path; } else { return resource.getPath() + "/" + StringUtils.stripStart(pathPrefix, "/") + "/" + StringUtils.stripStart(path, "/"); } }
From source file:com.groupon.jenkins.dynamic.build.DynamicProject.java
private boolean useNewUi(final String token, final StaplerRequest req) { return isNewUi() && (StringUtils.startsWith(token, "dotCI") || //job pages (NumberUtils.isNumber(token) && (StringUtils.isEmpty(req.getRestOfPath()) || StringUtils.contains(req.getRestOfPath(), "dotCI")))); // buildpages }
From source file:com.hangum.tadpole.rdb.core.editors.intro.IntroEditor.java
/** * set the user browser/*from w w w . ja v a 2s .c o m*/ * * @param url */ private void setBrowserURL(String url) { if (logger.isDebugEnabled()) logger.debug("Default home url is " + url); boolean boolStartHttp = StringUtils.startsWith(url, "http"); //$NON-NLS-1$ if (boolStartHttp) browser.setUrl(url); else browser.setUrl("http://" + url); //$NON-NLS-1$ }
From source file:com.inktomi.wxmetar.MetarParser.java
static boolean parsePresentWeather(String token, final Metar metar) { boolean rval = Boolean.FALSE; String qualifier = null;//from w w w .j av a2 s .c o m String weather = token.replace("+", "").replace("-", ""); // Strip off the qualifier if the length == 4 if (weather.length() == 4) { qualifier = StringUtils.substring(weather, 0, 2); weather = StringUtils.substring(weather, 2, 4); } // Strip off any possible modifier, and try to find a match PresentWeather presentWeather = null; try { presentWeather = PresentWeather.valueOf(weather); } catch (IllegalArgumentException e) { return rval; } if (null != presentWeather) { // Check for a modifier presentWeather.setIntensity(PresentWeather.Intensity.MODERATE); if (StringUtils.startsWith(token, "+")) { presentWeather.setIntensity(PresentWeather.Intensity.HEAVY); } if (StringUtils.startsWith(token, "-")) { presentWeather.setIntensity(PresentWeather.Intensity.LIGHT); } if (null != qualifier) { presentWeather.setQualifier(PresentWeather.Qualifier.valueOf(qualifier)); } metar.presentWeather = presentWeather; rval = Boolean.TRUE; } return rval; }
From source file:com.ewcms.security.acls.service.EwcmsAclService.java
protected boolean isGrant(final String name) { return StringUtils.startsWith(name, rolePrefix) || StringUtils.startsWith(name, groupPerfix); }
From source file:gov.nih.nci.firebird.nes.common.NesTranslatorHelperUtils.java
private static String getTelValue(String prefix, DSETTEL tels) { if (tels != null) { for (TEL tel : tels.getItem()) { if (StringUtils.startsWith(tel.getValue(), prefix)) { return tel.getValue().split(PREFIX_SEPARATOR, 2)[1]; }/* ww w .ja v a2 s .c o m*/ } } return null; }
From source file:hydrograph.ui.perspective.dialog.PreStartActivity.java
private void restartHydrograph() { logger.info("Starting New Hydrograph"); String path = Platform.getInstallLocation().getURL().getPath(); if ((StringUtils.isNotBlank(path)) && (StringUtils.startsWith(path, "/")) && (OSValidator.isWindows())) { path = StringUtils.substring(path, 1); }/*from w w w. j a v a2 s . c om*/ String command = path + HYDROGRAPH_EXE; Runtime runtime = Runtime.getRuntime(); try { if (OSValidator.isWindows()) { String[] commandArray = { "cmd.exe", "/c", command }; runtime.exec(commandArray); } } catch (IOException ioException) { logger.error("Exception occurred while starting hydrograph" + ioException); } System.exit(0); }
From source file:eionet.meta.imp.VocabularyImportBaseHandler.java
/** * This method searches for a related concept in database or in cache. * * @param relatedConceptUri/*from ww w .j a va2 s .co m*/ * uri of related concept * @return found concept or null */ protected VocabularyConcept findRelatedConcept(String relatedConceptUri) { VocabularyConcept foundRelatedConcept = null; String relatedConceptIdentifier; if (StringUtils.startsWith(relatedConceptUri, this.folderContextRoot)) { // it is a self reference to a concept in this vocabulary. // if it is in found concept then we are lucky. but it may be not created yet... and also wont be created at all... relatedConceptIdentifier = relatedConceptUri.replace(this.folderContextRoot, ""); if (StringUtils.contains(relatedConceptIdentifier, "/") || !Util.isValidIdentifier(relatedConceptIdentifier)) { return null; } int index = getPositionIn(this.concepts, relatedConceptIdentifier); if (index < this.concepts.size()) { return this.concepts.get(index); } index = getPositionIn(this.toBeUpdatedConcepts, relatedConceptIdentifier); if (index < this.toBeUpdatedConcepts.size()) { return this.toBeUpdatedConcepts.get(index); } // concept not seen yet. index = getPositionIn(this.notSeenConceptsYet, relatedConceptIdentifier); if (index < this.notSeenConceptsYet.size()) { return this.notSeenConceptsYet.get(index); } // so create it foundRelatedConcept = new VocabularyConcept(); foundRelatedConcept.setId(--this.numberOfCreatedConcepts); foundRelatedConcept.setIdentifier(relatedConceptIdentifier); foundRelatedConcept.setStatus(StandardGenericStatus.VALID); foundRelatedConcept.setStatusModified(new Date(System.currentTimeMillis())); foundRelatedConcept.setAcceptedDate(new Date(System.currentTimeMillis())); List<List<DataElement>> newConceptElementAttributes = new ArrayList<List<DataElement>>(); foundRelatedConcept.setElementAttributes(newConceptElementAttributes); this.notSeenConceptsYet.add(foundRelatedConcept); return foundRelatedConcept; } try { // extract related concept base uri and related concept identifier int lastDelimiterIndex = Math.max(relatedConceptUri.lastIndexOf("/"), Math.max(relatedConceptUri.lastIndexOf("#"), relatedConceptUri.lastIndexOf(":"))) + 1; String relatedConceptBaseUri = relatedConceptUri.substring(0, lastDelimiterIndex); relatedConceptIdentifier = relatedConceptUri.substring(lastDelimiterIndex); if (StringUtils.isNotEmpty(relatedConceptBaseUri) && StringUtils.isNotEmpty(relatedConceptIdentifier)) { // check cache first foundRelatedConcept = this.relatedConceptCache.get(relatedConceptUri); // && !this.notFoundRelatedConceptCache.contains(relatedConceptUri) if (foundRelatedConcept == null) { // not found in cache search in database // search for vocabularies with base uri. VocabularyFolder foundVocabularyFolder = null; VocabularyFilter vocabularyFilter = new VocabularyFilter(); vocabularyFilter.setWorkingCopy(false); vocabularyFilter.setUsePaging(false); vocabularyFilter.setBaseUri(relatedConceptBaseUri); // first search for vocabularies, to find correct concept and to make searching faster for concepts VocabularyResult vocabularyResult = this.vocabularyService.searchVocabularies(vocabularyFilter); if (vocabularyResult != null && vocabularyResult.getTotalItems() > 0) { // get the first found item, since base uri kinda unique foundVocabularyFolder = vocabularyResult.getList().get(0); // folder found, so go on for concept search VocabularyConceptFilter filter = new VocabularyConceptFilter(); filter.setUsePaging(false); filter.setIdentifier(relatedConceptIdentifier); filter.setVocabularyFolderId(foundVocabularyFolder.getId()); // search for concepts now VocabularyConceptResult results = this.vocabularyService.searchVocabularyConcepts(filter); // if found more than one, how can system detect which one is searched for! if (results != null && results.getFullListSize() == 1) { foundRelatedConcept = results.getList().get(0); this.relatedConceptCache.put(relatedConceptUri, foundRelatedConcept); } } } } } catch (ServiceException e) { e.printStackTrace(); } return foundRelatedConcept; }
From source file:com.google.gdt.eclipse.designer.model.widgets.support.UIObjectUtils.java
/** * @return <code>true</code> if given Element is CSS wait DIV. */// w w w. j av a 2 s. com public boolean isWaitDivCSS(Object element) { if (dom.getTagName(element).equals("DIV")) { String className = dom.getClassName(element); return StringUtils.startsWith(className, "wbp__wait_stylesheet"); } return false; }