List of usage examples for org.apache.commons.lang3 StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr)
Checks if CharSequence contains a search CharSequence irrespective of case, handling null .
From source file:com.glaf.oa.assesssort.web.springmvc.AssesssortController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Assesssort assesssort = assesssortService.getAssesssort(RequestUtils.getLong(request, "assesssortid")); if (assesssort != null) { request.setAttribute("assesssort", assesssort); JSONObject rowJSON = assesssort.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); }//from ww w . ja v a2s . c o m boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (assesssort != null) { canUpdate = true; } } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("assesssort.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/assesssort/edit", modelMap); }
From source file:fr.cph.chicago.core.fragment.BikeFragment.java
private void loadList() { if (bikeAdapter == null) { List<BikeStation> bikeStations = activity.getIntent().getExtras() .getParcelableArrayList(bundleBikeStations); if (bikeStations == null) { bikeStations = new ArrayList<>(); }//w ww .j a v a 2s .c o m bikeAdapter = new BikeAdapter(bikeStations); } bikeListView.setAdapter(bikeAdapter); filter.addTextChangedListener(new TextWatcher() { private List<BikeStation> bikeStations; @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { bikeStations = new ArrayList<>(); } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { bikeStations.addAll(Stream.of(BikeFragment.this.bikeStations).filter( bikeStation -> StringUtils.containsIgnoreCase(bikeStation.getName(), s.toString().trim())) .collect(Collectors.toList())); } @Override public void afterTextChanged(final Editable s) { bikeAdapter.setBikeStations(this.bikeStations); bikeAdapter.notifyDataSetChanged(); } }); bikeListView.setVisibility(ListView.VISIBLE); filter.setVisibility(ListView.VISIBLE); loadingLayout.setVisibility(RelativeLayout.INVISIBLE); errorLayout.setVisibility(RelativeLayout.INVISIBLE); }
From source file:com.norconex.collector.http.robot.impl.StandardRobotsTxtProvider.java
private RobotData.Precision matchesUserAgent(String userAgent, String value) { if ("*".equals(value)) { return RobotData.Precision.WILD; }/* ww w . j a v a 2 s .c o m*/ if (StringUtils.equalsIgnoreCase(userAgent, value)) { return RobotData.Precision.EXACT; } if (value.endsWith("*")) { String val = StringUtils.removeEnd(value, "*"); if (StringUtils.startsWithIgnoreCase(userAgent, val)) { return RobotData.Precision.PARTIAL; } } if (StringUtils.containsIgnoreCase(userAgent, value)) { return RobotData.Precision.PARTIAL; } return RobotData.Precision.NOMATCH; }
From source file:ec.edu.chyc.manejopersonal.managebean.GestorTesis.java
public boolean filtrarCoDirector(Object value, Object filter, Locale locale) { String filterText = (filter == null) ? null : filter.toString().trim(); if (filterText == null || filterText.equals("")) { return true; }/* w w w. j a va2s . co m*/ if (value == null) { return false; } Set<Persona> autores = (Set<Persona>) value; for (Persona per : autores) { if (StringUtils.containsIgnoreCase(per.getNombres(), filterText) || StringUtils.containsIgnoreCase(per.getApellidos(), filterText)) { return true; } } return false; }
From source file:fr.brouillard.oss.jgitver.JGitverModelProcessor.java
private Model provisionModel(Model model, Map<String, ?> options) throws IOException { try {/*w ww .ja va 2 s .co m*/ calculateVersionIfNecessary(); } catch (Exception ex) { throw new IOException("cannot build a Model object using jgitver", ex); } Source source = (Source) options.get(ModelProcessor.SOURCE); //logger.debug( "JGitverModelProcessor.provisionModel source="+source ); if (source == null) { return model; } File location = new File(source.getLocation()); //logger.debug( "JGitverModelProcessor.provisionModel location="+location ); if (!location.isFile()) { // their JavaDoc says Source.getLocation "could be a local file path, a URI or just an empty string." // if it doesn't resolve to a file then calling .getParentFile will throw an exception, // but if it doesn't resolve to a file then it isn't under getMultiModuleProjectDirectory, return model; // therefore the model shouldn't be modified. } File relativePath = location.getParentFile().getCanonicalFile(); if (StringUtils.containsIgnoreCase(relativePath.getCanonicalPath(), workingConfiguration.getMultiModuleProjectDirectory().getCanonicalPath())) { workingConfiguration.getNewProjectVersions().put(GAV.from(model.clone()), workingConfiguration.getCalculatedVersion()); if (Objects.nonNull(model.getVersion())) { // TODO evaluate how to set the version only when it was originally set in the pom file model.setVersion(workingConfiguration.getCalculatedVersion()); } if (Objects.nonNull(model.getParent())) { // if the parent is part of the multi module project, let's update the parent version File relativePathParent = new File( relativePath.getCanonicalPath() + File.separator + model.getParent().getRelativePath()) .getParentFile().getCanonicalFile(); if (StringUtils.containsIgnoreCase(relativePathParent.getCanonicalPath(), workingConfiguration.getMultiModuleProjectDirectory().getCanonicalPath())) { model.getParent().setVersion(workingConfiguration.getCalculatedVersion()); } } // we should only register the plugin once, on the main project if (relativePath.getCanonicalPath() .equals(workingConfiguration.getMultiModuleProjectDirectory().getCanonicalPath())) { if (Objects.isNull(model.getBuild())) { model.setBuild(new Build()); } if (Objects.isNull(model.getBuild().getPlugins())) { model.getBuild().setPlugins(new ArrayList<>()); } Optional<Plugin> pluginOptional = model.getBuild().getPlugins().stream() .filter(x -> JGitverUtils.EXTENSION_GROUP_ID.equalsIgnoreCase(x.getGroupId()) && JGitverUtils.EXTENSION_ARTIFACT_ID.equalsIgnoreCase(x.getArtifactId())) .findFirst(); StringBuilder pluginVersion = new StringBuilder(); try (InputStream inputStream = getClass() .getResourceAsStream("/META-INF/maven/" + JGitverUtils.EXTENSION_GROUP_ID + "/" + JGitverUtils.EXTENSION_ARTIFACT_ID + "/pom" + ".properties")) { Properties properties = new Properties(); properties.load(inputStream); pluginVersion.append(properties.getProperty("version")); } catch (IOException ignored) { // TODO we should not ignore in case we have to reuse it logger.warn(ignored.getMessage(), ignored); } Plugin plugin = pluginOptional.orElseGet(() -> { Plugin plugin2 = new Plugin(); plugin2.setGroupId(JGitverUtils.EXTENSION_GROUP_ID); plugin2.setArtifactId(JGitverUtils.EXTENSION_ARTIFACT_ID); plugin2.setVersion(pluginVersion.toString()); model.getBuild().getPlugins().add(plugin2); return plugin2; }); if (Objects.isNull(plugin.getExecutions())) { plugin.setExecutions(new ArrayList<>()); } Optional<PluginExecution> pluginExecutionOptional = plugin.getExecutions().stream() .filter(x -> "verify".equalsIgnoreCase(x.getPhase())).findFirst(); PluginExecution pluginExecution = pluginExecutionOptional.orElseGet(() -> { PluginExecution pluginExecution2 = new PluginExecution(); pluginExecution2.setPhase("verify"); plugin.getExecutions().add(pluginExecution2); return pluginExecution2; }); if (Objects.isNull(pluginExecution.getGoals())) { pluginExecution.setGoals(new ArrayList<>()); } if (!pluginExecution.getGoals().contains(JGitverAttachModifiedPomsMojo.GOAL_ATTACH_MODIFIED_POMS)) { pluginExecution.getGoals().add(JGitverAttachModifiedPomsMojo.GOAL_ATTACH_MODIFIED_POMS); } if (Objects.isNull(plugin.getDependencies())) { plugin.setDependencies(new ArrayList<>()); } Optional<Dependency> dependencyOptional = plugin.getDependencies().stream() .filter(x -> JGitverUtils.EXTENSION_GROUP_ID.equalsIgnoreCase(x.getGroupId()) && JGitverUtils.EXTENSION_ARTIFACT_ID.equalsIgnoreCase(x.getArtifactId())) .findFirst(); dependencyOptional.orElseGet(() -> { Dependency dependency = new Dependency(); dependency.setGroupId(JGitverUtils.EXTENSION_GROUP_ID); dependency.setArtifactId(JGitverUtils.EXTENSION_ARTIFACT_ID); dependency.setVersion(pluginVersion.toString()); plugin.getDependencies().add(dependency); return dependency; }); } try { legacySupport.getSession().getUserProperties().put( JGitverModelProcessorWorkingConfiguration.class.getName(), JGitverModelProcessorWorkingConfiguration.serializeTo(workingConfiguration)); } catch (JAXBException ex) { throw new IOException("unexpected Model serialization issue", ex); } } return model; }
From source file:com.mirth.connect.donkey.server.controllers.ChannelController.java
public Long getLocalChannelId(String channelId) { int attemptsRemaining = 3; while (true) { try {//from w w w . j ava 2s . c o m Long localChannelId = null; DonkeyDao dao = donkey.getDaoFactory().getDao(); try { localChannelId = dao.getLocalChannelIds().get(channelId); } finally { dao.close(); } if (localChannelId == null) { localChannelId = createChannel(channelId); } return localChannelId; } catch (DonkeyDaoException e) { /* * MIRTH-3475 If two server instances connected to a shared database attempt to * create channels at the same time, they may both obtain the same next local * channel ID, which will result in a duplicate key error. In the rare case that * this happens, we retry 2 more times. */ if (e.getCause() instanceof SQLException) { SQLException sqlException = (SQLException) e.getCause(); /* * The second part of this conditional tests if the SQLException was the result * of a duplicate key violation. MySQL, Oracle and SQL Server generate an * exception with SQLState == 23000, while Postgres returns SQLState == 23505. */ if (--attemptsRemaining == 0 || !(StringUtils.equals(sqlException.getSQLState(), "23000") || StringUtils.equals(sqlException.getSQLState(), "23505") || StringUtils.containsIgnoreCase(sqlException.getMessage(), "duplicate") || StringUtils.containsIgnoreCase(sqlException.getMessage(), "unique constraint"))) { throw e; } /* * If another server is in the middle of creating tables for this channel, wait * for a bit to let it finish. */ try { Thread.sleep(500); } catch (InterruptedException e1) { } } else { throw e; } } } }
From source file:fr.cph.chicago.core.activity.BusBoundActivity.java
@Override public final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); App.checkBusData(this); if (!this.isFinishing()) { setContentView(R.layout.activity_bus_bound); ButterKnife.bind(this); if (busRouteId == null || busRouteName == null || bound == null || boundTitle == null) { final Bundle extras = getIntent().getExtras(); busRouteId = extras.getString(bundleBusRouteId); busRouteName = extras.getString(bundleBusRouteName); bound = extras.getString(bundleBusBound); boundTitle = extras.getString(bundleBusBoundTitle); }/*from ww w .ja v a2s. c o m*/ busBoundAdapter = new BusBoundAdapter(); setListAdapter(busBoundAdapter); getListView().setOnItemClickListener((adapterView, view, position, id) -> { final BusStop busStop = (BusStop) busBoundAdapter.getItem(position); final Intent intent = new Intent(getApplicationContext(), BusActivity.class); final Bundle extras = new Bundle(); extras.putInt(bundleBusStopId, busStop.getId()); extras.putString(bundleBusStopName, busStop.getName()); extras.putString(bundleBusRouteId, busRouteId); extras.putString(bundleBusRouteName, busRouteName); extras.putString(bundleBusBound, bound); extras.putString(bundleBusBoundTitle, boundTitle); extras.putDouble(bundleBusLatitude, busStop.getPosition().getLatitude()); extras.putDouble(bundleBusLongitude, busStop.getPosition().getLongitude()); intent.putExtras(extras); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }); filter.addTextChangedListener(new TextWatcher() { private List<BusStop> busStopsFiltered; @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { busStopsFiltered = new ArrayList<>(); } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { if (busStops != null) { Stream.of(busStops).filter(busStop -> StringUtils.containsIgnoreCase(busStop.getName(), s)) .forEach(busStopsFiltered::add); } } @Override public void afterTextChanged(final Editable s) { busBoundAdapter.update(busStopsFiltered); busBoundAdapter.notifyDataSetChanged(); } }); Util.setWindowsColor(this, toolbar, TrainLine.NA); toolbar.setTitle(busRouteId + " - " + boundTitle); toolbar.setNavigationIcon(arrowBackWhite); toolbar.setOnClickListener(v -> finish()); ObservableUtil.createBusStopBoundObservable(getApplicationContext(), busRouteId, bound) .subscribe(onNext -> { busStops = onNext; busBoundAdapter.update(onNext); busBoundAdapter.notifyDataSetChanged(); }, onError -> { Log.e(TAG, onError.getMessage(), onError); Util.showOopsSomethingWentWrong(getListView()); }); Util.trackAction(this, R.string.analytics_category_req, R.string.analytics_action_get_bus, BUSES_STOP_URL, 0); // Preventing keyboard from moving background when showing up getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); } }
From source file:com.sonicle.webtop.core.util.ZPushManager.java
private List<ListRecord> parseListOutput(List<String> lines) { ArrayList<ListRecord> items = new ArrayList<>(); int lineNo = 0, dataLine = -1; for (String line : lines) { lineNo++;/*from w w w . j a v a 2s. co m*/ if (StringUtils.containsIgnoreCase(line, "All synchronized devices")) { dataLine = lineNo + 4; } if ((dataLine != -1) && (lineNo >= dataLine) && !StringUtils.isBlank(StringUtils.trim(line))) { String[] tokens = StringUtils.split(line, " ", 2); String device = StringUtils.trim(tokens[0]); String users = StringUtils.trim(tokens[1]); items.add(new ListRecord(device, StringUtils.split(users, ","))); } } return items; }
From source file:eu.openanalytics.rsb.EmailDepositITCase.java
private void verifyErrorResult(final MimeMessage rsbResponseMessage) throws IOException, MessagingException { final Multipart parts = (Multipart) rsbResponseMessage.getContent(); final String responseBody = StringUtils .normalizeSpace(((MimeMultipart) getMailBodyPart(parts, "multipart/related").getContent()) .getBodyPart(0).getContent().toString()); assertThat(StringUtils.containsIgnoreCase(responseBody, "error"), is(true)); }
From source file:com.moto.miletus.application.ble.neardevice.NearDeviceNotification.java
/** * getDeviceStates//from ww w .j a v a2 s. c om * * @param device DeviceWrapper * @param states Set<StateWrapper> */ private void getDeviceStates(final DeviceWrapper device, final Set<StateWrapper> states) { ParameterValue light = null; ParameterValue temp = null; for (final StateWrapper state : states) { if (StringUtils.containsIgnoreCase(state.getStateName(), Strings.LIGHT)) { light = state.getValue(); } if (StringUtils.containsIgnoreCase(state.getStateName(), Strings.TEMPERATURE)) { temp = state.getValue(); } } notification(device.getDevice().getName(), light, temp); }