List of usage examples for org.apache.commons.lang StringUtils endsWithAny
public static boolean endsWithAny(String string, String[] searchStrings)
Check if a String ends with any of an array of specified strings.
From source file:com.haulmont.cuba.security.listener.EntityLogItemDetachListener.java
protected void fillAttributesFromChangesField(EntityLogItem item) { log.trace("fillAttributesFromChangesField for " + item); List<EntityLogAttr> attributes = new ArrayList<>(); StringReader reader = new StringReader(item.getChanges()); Properties properties = new Properties(); try {//w w w . ja v a 2 s. c om properties.load(reader); Enumeration<?> names = properties.propertyNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); if (StringUtils.endsWithAny(name, skipNames)) continue; EntityLogAttr attr = new EntityLogAttr(); attr.setLogItem(item); attr.setName(name); attr.setValue(properties.getProperty(name)); attr.setValueId(properties.getProperty(name + VALUE_ID_SUFFIX)); attr.setOldValue(properties.getProperty(name + OLD_VALUE_SUFFIX)); attr.setOldValueId(properties.getProperty(name + OLD_VALUE_ID_SUFFIX)); attr.setMessagesPack(properties.getProperty(name + MP_SUFFIX)); attributes.add(attr); } } catch (Exception e) { log.error("Unable to fill EntityLog attributes for " + item, e); } Collections.sort(attributes, (o1, o2) -> Ordering.natural().compare(o1.getName(), o2.getName())); item.setAttributes(new LinkedHashSet<>(attributes)); }
From source file:com.htmlhifive.tools.jslint.library.LibraryManager.java
/** * ???????????.//from ww w . java 2s.c o m * * @return ? * @throws JavaScriptModelException ??. */ private Set<IncludePathEntryWrapper> getRemoveList() throws JavaScriptModelException { Set<IncludePathEntryWrapper> removeSet = new HashSet<IncludePathEntryWrapper>(); IncludePathEntryWrapper[] entrys = IncludePathEntryWrapperFactory .getEntryWrappers(project.getResolvedIncludepath(true)); for (int i = 0; i < entrys.length; i++) { IncludePathEntryWrapper entry = entrys[i]; if (StringUtils.endsWithAny(entry.getPath().toString(), (String[]) ignoreRawIdSet.toArray(new String[ignoreRawIdSet.size()]))) { removeSet.add(entry); } } return removeSet; }
From source file:com.htmlhifive.tools.jslint.view.JslintPropertyComposite.java
@Override protected void doUpdate() { getConfigBean().setJsLintPath(textJslintPath.getText()); getConfigBean().setOptionFilePath(textOptionPath.getText()); IStructuredSelection selection = (IStructuredSelection) listviewer.getSelection(); if (selection != null && selection.getFirstElement() != null) { getConfigBean().setOtherProjectPath(((IProject) selection.getFirstElement()).getName()); }//from w w w . j av a 2 s. c om getConfigBean().setUseOtherProject(checkUseOtherProject.getSelection()); getConfigBean().replaceFilterBeans(filterComp.getFilterBeans()); if (existsFile(getConfigBean().getJsLintPath()) && existsFile(getConfigBean().getOptionFilePath()) && StringUtils.endsWithAny(getConfigBean().getJsLintPath(), new String[] { JSLintPluginConstant.JS_HINT_NAME, JSLintPluginConstant.JS_LINT_NAME })) { buttonOptionForm.setEnabled(true); } else { buttonOptionForm.setEnabled(false); } }
From source file:adalid.commons.velocity.Writer.java
private void checkPropertyName(String name, File file) { String pattern = "invalid property name \"{0}\" at file \"{1}\""; String message = MessageFormat.format(pattern, StringUtils.trimToEmpty(name), file); if (StringUtils.isBlank(name)) { throw new RuntimeException(message); }/*w ww . j a v a2s.com*/ String low = name.toLowerCase(); if (StringUtils.endsWithAny(low, DOT_SUFFIXES)) { int endIndex = StringUtils.lastIndexOfAny(low, DOT_SUFFIXES); if (endIndex == 0) { throw new RuntimeException(message); } } }
From source file:ninja.text.TextImpl.java
@Override public boolean endsWithAny(Text... candidate) { String[] d = new String[candidate.length]; for (int i = 0; i < candidate.length; i++) { d[i] = String.valueOf(candidate[i]); }/*from w w w.j a v a 2 s . c o m*/ return StringUtils.endsWithAny(data.toString(), d); }
From source file:ninja.text.TextImpl.java
@Override public boolean endsWithAny(CharSequence... candidate) { String[] d = new String[candidate.length]; for (int i = 0; i < candidate.length; i++) { d[i] = String.valueOf(candidate[i]); }/*from w w w. j a va2 s.co m*/ return StringUtils.endsWithAny(data.toString(), d); }
From source file:org.codice.solr.query.SchemaFieldResolver.java
public SchemaField getSchemaField(String propertyName, boolean isSearchedAsExactValue) { SchemaField schemaField = null;/*from w w w . ja v a 2 s . c o m*/ LukeRequest luke = new LukeRequest(); LukeResponse rsp; try { rsp = luke.process(solr); Map<String, FieldInfo> fieldsInfo = rsp.getFieldInfo(); if (fieldsInfo != null && !fieldsInfo.isEmpty()) { LOGGER.info("got fieldsInfo for {} fields", fieldsInfo.size()); for (Map.Entry<String, FieldInfo> entry : fieldsInfo.entrySet()) { // See if any fieldName startsWith(propertyName) // if it does, then see if remainder of fieldName matches any expected suffix // if suffix matches, then get type of field and cache it if (entry.getKey().startsWith(propertyName) && StringUtils.endsWithAny(entry.getKey(), FORMAT_SUFFIXES)) { String fieldType = entry.getValue().getType(); int index = StringUtils.lastIndexOfAny(entry.getKey(), FORMAT_SUFFIXES); String suffix = entry.getKey().substring(index); if (!isSearchedAsExactValue) { suffix = getSpecialIndexSuffix(suffix); fieldType += suffix; } LOGGER.info("field {} has type {}", entry.getKey(), fieldType); schemaField = new SchemaField(entry.getKey(), fieldType); schemaField.setSuffix(suffix); return schemaField; } } } else { LOGGER.info("fieldsInfo from LukeRequest are either null or empty"); } } catch (SolrServerException e) { LOGGER.info("SolrServerException while processing LukeRequest", e); } catch (IOException e) { LOGGER.info("IOException while processing LukeRequest", e); } LOGGER.info("Did not find SchemaField for property {}", propertyName); return schemaField; }
From source file:org.eclipse.gyrex.admin.ui.http.jetty.internal.ImportCertificateDialog.java
void validate() { final String id = idField.getText(); if (StringUtils.isNotBlank(id) && !IdHelper.isValidId(id)) { setError("The entered id is invalid. It may only contain ASCII chars a-z, 0-9, '.', '-' and/or '_'."); return;/*from w w w . j a v a2s . c om*/ } if (StringUtils.isBlank(id)) { setInfo("Please enter a certificate id."); return; } if (!keystoreTypeField.isSelected(0) && !keystoreTypeField.isSelected(1)) { setInfo("Please select a keystore type."); return; } if (StringUtils.isBlank(keystoreUploadField.getFileName())) { setInfo("Please select a keystore to upload."); return; } if (StringUtils.endsWithAny(keystoreUploadField.getFileName().toLowerCase(), POSSIBLE_PKCS12_EXTENSIONS) && !keystoreTypeField.isSelected(1)) { setWarning( "The selected file might be a PKCS12 keystore. Please verify the correct keystore type is selected!"); return; } updateStatus(Status.OK_STATUS); }
From source file:org.executequery.gui.text.TextUndoManager.java
public void undoableEditHappened(UndoableEditEvent undoableEditEvent) { UndoableEdit edit = undoableEditEvent.getEdit(); AbstractDocument.DefaultDocumentEvent event = (AbstractDocument.DefaultDocumentEvent) edit; EventType eventType = event.getType(); if (eventType == EventType.INSERT) { try {// w w w . j a v a 2 s.c om if (addNextInsert) { add(); } compoundEdit.addEdit(edit); int start = event.getOffset(); int length = event.getLength(); String text = event.getDocument().getText(start, length); if (StringUtils.endsWithAny(text, WHITESPACE)) { addNextInsert = true; } } catch (BadLocationException e) { Log.debug(e); } } else if (eventType == EventType.REMOVE) { add(); compoundEdit.addEdit(edit); add(); } else if (eventType == EventType.CHANGE) { compoundEdit.addEdit(edit); } redoCommand.setEnabled(false); undoCommand.setEnabled(true); }
From source file:org.kuali.rice.krad.uif.util.MessageStructureUtils.java
/** * Process a piece of the message that is assumed to have a valid html tag * * @param messagePiece String piece with html tag content * @param currentMessageComponent the state of the current text based message being built * @param view current View/* www . j a va 2 s .com*/ * @return currentMessageComponent with the new textual content generated by this method appended to its * messageText */ private static Message processHtmlContent(String messagePiece, Message currentMessageComponent, View view) { //raw html messagePiece = messagePiece.trim(); if (StringUtils.startsWithAny(messagePiece, KRADConstants.MessageParsing.UNALLOWED_HTML) || StringUtils.endsWithAny(messagePiece, KRADConstants.MessageParsing.UNALLOWED_HTML)) { throw new RuntimeException("The following html is not allowed in Messages: " + Arrays.toString(KRADConstants.MessageParsing.UNALLOWED_HTML)); } messagePiece = "<" + messagePiece + ">"; return concatenateStringMessageContent(currentMessageComponent, messagePiece, view); }