List of usage examples for org.apache.commons.lang ArrayUtils contains
public static boolean contains(boolean[] array, boolean valueToFind)
Checks if the value is in the given array.
From source file:com.cubusmail.server.mail.MessageHandler.java
/** * @return//w ww . jav a 2 s .c o m * @throws MessagingException * @throws IOException */ public GWTMessage getGWTMessage() throws MessagingException, IOException { GWTMessage gwtMsg = new GWTMessage(); gwtMsg.setFrom(getFrom()); gwtMsg.setFromArray(ConvertUtil.convertAddress(this.message.getFrom())); gwtMsg.setTo(getTo()); gwtMsg.setToArray(ConvertUtil.convertAddress(this.message.getRecipients(RecipientType.TO))); gwtMsg.setCc(getCc()); gwtMsg.setCcArray(ConvertUtil.convertAddress(this.message.getRecipients(RecipientType.CC))); gwtMsg.setBcc(getBcc()); gwtMsg.setReplyTo(getReplyTo()); gwtMsg.setReplyToArray(getReplyToArray()); gwtMsg.setSubject(getSubject()); gwtMsg.setDate(this.message.getSentDate()); if (isHtmlMessage()) { gwtMsg.setMessageText(getMessageTextHtml()); } else { gwtMsg.setMessageText(getMessageTextPlain()); } gwtMsg.setHtmlMessage(isHtmlMessage()); gwtMsg.setHasImages(isHasImages()); gwtMsg.setTrustImages(isTrustImages()); gwtMsg.setAcknowledgement(isAcknowledgement()); gwtMsg.setReadBefore(this.readBefore); gwtMsg.setRead(isRead()); gwtMsg.setDraft(isDraftMessage()); long id = getId(); gwtMsg.setId(id); List<MimePart> parts = MessageUtils.attachmentsFromPart(this.message); if (parts.size() > 0) { GWTAttachment[] attachments = new GWTAttachment[parts.size()]; for (int i = 0; i < parts.size(); i++) { attachments[i] = new GWTAttachment(); String fileName = parts.get(i).getFileName(); if (StringUtils.isEmpty(fileName)) { fileName = this.applicationContext.getMessage("message.unknown.attachment", null, SessionManager.get().getLocale()); } attachments[i].setFileName(fileName); int size = parts.get(i).getSize(); if (parts.get(i).getSize() == -1) { try { size = parts.get(i).getInputStream().available(); } catch (IOException e) { size = -1; } } NumberFormat sizeFormat = MessageUtils.createSizeFormat(SessionManager.get().getLocale()); size = MessageUtils.calculateAttachmentSize(size); attachments[i].setSize(size); attachments[i].setSizeText(MessageUtils.formatPartSize(attachments[i].getSize(), sizeFormat)); attachments[i].setMessageId(id); attachments[i].setIndex(i); String extension = StringUtils.substringAfterLast(parts.get(i).getFileName(), "."); if (extension != null) { extension = extension.toLowerCase(); if (ArrayUtils.contains(PREVIEW_EXTENSIONS, extension)) { attachments[i].setPreview(true); } } } gwtMsg.setAttachments(attachments); } Preferences preferences = SessionManager.get().getPreferences(); GWTMessageRecord[] messageArray = ConvertUtil.convertMessagesToStringArray(this.applicationContext, preferences, (IMAPFolder) this.message.getFolder(), 1, new Message[] { this.message }); gwtMsg.setMessageRecord(messageArray[0]); return gwtMsg; }
From source file:adalid.util.velocity.BaseBuilder.java
private void createTextFilePropertiesFile(String source, String target) { boolean java = StringUtils.endsWithIgnoreCase(source, ".java"); boolean bundle = StringUtils.endsWithIgnoreCase(source, ".properties"); File sourceFile = new File(source); String sourceFileName = sourceFile.getName(); String sourceFileSimpleName = StringUtils.substringBeforeLast(sourceFileName, "."); String sourceFolderName = sourceFile.getParentFile().getName(); String sourceFolderSimpleName = StringUtils.substringBeforeLast(sourceFolderName, "."); String sourceEntityName = getOptionalEntityName(sourceFileSimpleName, sourceFolderSimpleName); String properties = source.replace(projectFolderPath, velocityPlatformsTargetFolderPath) + ".properties"; String folder = StringUtils.substringBeforeLast(properties, FS); String template = StringUtils.substringAfter(target, velocityFolderPath + FS).replace(FS, "/"); String path = StringUtils.substringBeforeLast(StringUtils.substringAfter(source, projectFolderPath), FS) .replace(FS, "/").replace(project, PROJECT_ALIAS).replace("eclipse.settings", ".settings"); path = replaceAliasWithRootFolderName(path); String pack = null;// www . ja v a 2 s. c om if (java || bundle) { String s1 = StringUtils.substringAfter(path, SRC); if (StringUtils.contains(s1, PROJECT_ALIAS)) { String s2 = StringUtils.substringBefore(s1, PROJECT_ALIAS); String s3 = SRC + s2; String s4 = StringUtils.substringBefore(path, s3) + s3; String s5 = StringUtils.substringAfter(s1, PROJECT_ALIAS).replace("/", "."); path = StringUtils.removeEnd(s4, "/"); pack = ROOT_PACKAGE_NAME + s5; } } path = finalisePath(path); String file = StringUtils.substringAfterLast(source, FS).replace(project, PROJECT_ALIAS) .replace("eclipse.project", ".project"); List<String> lines = new ArrayList<>(); lines.add("template = " + template); // lines.add("template-type = velocity"); lines.add("path = " + path); if (StringUtils.isNotBlank(pack)) { lines.add("package = " + pack); } lines.add("file = " + file); if (sourceFileSimpleName.equals("eclipse") || sourceFolderSimpleName.equals("eclipse") || sourceFolderSimpleName.equals("nbproject")) { lines.add("disabled = true"); } else if (sourceEntityName != null) { lines.add("disabled-when-missing = " + sourceEntityName); } if (source.endsWith(".css") || source.endsWith(".jrtx")) { lines.add("preserve = true"); } else if (ArrayUtils.contains(preservableFiles, sourceFileName)) { lines.add("preserve = true"); } lines.add("dollar.string = $"); lines.add("pound.string = #"); lines.add("backslash.string = \\\\"); FilUtils.mkdirs(folder); if (write(properties, lines, WINDOWS_CHARSET)) { propertiesFilesCreated++; } }
From source file:com.icantrap.collections.dawg.Dawg.java
private void addCandidatesFromLetters(Stack<StackEntry> stack, int node, char[] letters, String subword, List<Integer> wildcardPositions, int patternIndex) { if (ArrayUtils.contains(letters, '?')) // there's a wildcard, add all the children for (Iterator<Integer> iter = childIterator(node); iter.hasNext();) stack.push(new StackEntry(iter.next(), letters, subword, wildcardPositions, patternIndex)); else // add the children that match a letter for (char letter : getUniqueLetters(letters)) { int candidate = findChild(node, letter); if (-1 != candidate) stack.push(new StackEntry(candidate, letters, subword, wildcardPositions, patternIndex)); }//from ww w . ja v a2 s.co m }
From source file:com.cubusmail.mail.MessageHandler.java
/** * @return/* ww w .j a v a 2 s . c o m*/ * @throws MessagingException * @throws IOException */ public GWTMessage getGWTMessage() throws MessagingException, IOException { GWTMessage gwtMsg = new GWTMessage(); gwtMsg.setFrom(getFrom()); gwtMsg.setFromArray(ConvertUtil.convertAddress(this.message.getFrom())); gwtMsg.setTo(getTo()); gwtMsg.setToArray(ConvertUtil.convertAddress(this.message.getRecipients(RecipientType.TO))); gwtMsg.setCc(getCc()); gwtMsg.setCcArray(ConvertUtil.convertAddress(this.message.getRecipients(RecipientType.CC))); gwtMsg.setBcc(getBcc()); gwtMsg.setReplyTo(getReplyTo()); gwtMsg.setReplyToArray(getReplyToArray()); gwtMsg.setSubject(getSubject()); gwtMsg.setDate(this.message.getSentDate()); if (isHtmlMessage()) { gwtMsg.setMessageText(getMessageTextHtml()); } else { gwtMsg.setMessageText(getMessageTextPlain()); } gwtMsg.setHtmlMessage(isHtmlMessage()); gwtMsg.setHasImages(isHasImages()); gwtMsg.setTrustImages(isTrustImages()); gwtMsg.setAcknowledgement(isAcknowledgement()); gwtMsg.setReadBefore(this.readBefore); gwtMsg.setRead(isRead()); gwtMsg.setDraft(isDraftMessage()); long id = getId(); gwtMsg.setId(id); List<MimePart> parts = MessageUtils.attachmentsFromPart(this.message); if (parts.size() > 0) { GWTAttachment[] attachments = new GWTAttachment[parts.size()]; for (int i = 0; i < parts.size(); i++) { attachments[i] = new GWTAttachment(); String fileName = parts.get(i).getFileName(); if (StringUtils.isEmpty(fileName)) { fileName = this.applicationContext.getMessage("message.unknown.attachment", null, SessionManager.get().getLocale()); } attachments[i].setFileName(fileName); int size = parts.get(i).getSize(); if (parts.get(i).getSize() == -1) { try { size = parts.get(i).getInputStream().available(); } catch (IOException e) { size = -1; } } NumberFormat sizeFormat = MessageUtils.createSizeFormat(SessionManager.get().getLocale()); size = MessageUtils.calculateAttachmentSize(size); attachments[i].setSize(size); attachments[i].setSizeText(MessageUtils.formatPartSize(attachments[i].getSize(), sizeFormat)); attachments[i].setMessageId(id); attachments[i].setIndex(i); String extension = StringUtils.substringAfterLast(parts.get(i).getFileName(), "."); if (extension != null) { extension = extension.toLowerCase(); if (ArrayUtils.contains(PREVIEW_EXTENSIONS, extension)) { attachments[i].setPreview(true); } } } gwtMsg.setAttachments(attachments); } return gwtMsg; }
From source file:gov.nih.nci.cabig.caaers.domain.report.Report.java
public void addToCorrelationId(String correlationId) { String[] existing = getCorrelationIds(); if (ArrayUtils.isEmpty(existing)) { addToMetaData("correlationId", correlationId); addToMetaData(correlationId, DateUtils.formatDate(new Date(), DateUtils.DATE_WITH_HYPHENS)); } else if (!ArrayUtils.contains(existing, correlationId)) { addToMetaData("correlationId", StringUtils.join(existing, ',') + "," + correlationId); addToMetaData(correlationId, DateUtils.formatDate(new Date(), DateUtils.DATE_WITH_HYPHENS)); }// w ww . j a va 2s . c o m }
From source file:com.adobe.acs.commons.errorpagehandler.impl.ErrorPageHandlerImpl.java
/** * Check if this is an image request./* w w w. j a v a 2 s . c o m*/ * * @param request the current {@link SlingHttpServletRequest} * @return true if this request should deliver an image. */ private boolean isImageRequest(final SlingHttpServletRequest request) { if (StringUtils.isBlank(errorImagePath)) { log.warn("ACS AEM Commons error page handler enabled to handle error images, " + "but no error image path was provided."); return false; } final String extension = StringUtils .stripToEmpty(StringUtils.lowerCase(request.getRequestPathInfo().getExtension())); return ArrayUtils.contains(errorImageExtensions, extension); }
From source file:adalid.util.velocity.SecondBaseBuilder.java
private boolean preservable(File sourceFile) { if (preservableFileNames != null) { String sourceFileName = sourceFile.getName(); if (ArrayUtils.contains(preservableFileNames, sourceFileName)) { return true; }//from w ww .j ava 2 s .c o m } if (preservableFileExpressions != null) { String sourceFilePath = sourceFile.getPath(); for (String string : preservableFileExpressions) { if (sourceFilePath.matches(string)) { return true; } } } return false; }
From source file:com.cubusmail.mail.MessageHandler.java
/** * @return Returns the attachments.//from w w w .j a v a 2 s .c o m */ public GWTAttachment[] getGWTComposeAttachments() { if (this.composeAttachments != null) { int index = 0; GWTAttachment[] gwtAttachments = new GWTAttachment[this.composeAttachments.size()]; for (DataSource attachment : this.composeAttachments) { gwtAttachments[index] = new GWTAttachment(); gwtAttachments[index].setFileName(attachment.getName()); int size = -1; try { size = attachment.getInputStream().available(); } catch (IOException e) { // do nothing } gwtAttachments[index].setSize(size); gwtAttachments[index].setSizeText(MessageUtils.formatPartSize(size, MessageUtils.createSizeFormat(SessionManager.get().getLocale()))); gwtAttachments[index].setMessageId(0); gwtAttachments[index].setIndex(index); String extension = StringUtils.substringAfterLast(attachment.getName(), "."); if (extension != null) { extension = extension.toLowerCase(); if (ArrayUtils.contains(PREVIEW_EXTENSIONS, extension)) { gwtAttachments[index].setPreview(true); } } index++; } return gwtAttachments; } return null; }
From source file:com.kylinolap.metadata.model.cube.CubeDesc.java
private void initDerivedMap(TblColRef[] hostCols, DeriveType type, DimensionDesc dimension, TblColRef[] derivedCols, String[] extra) { if (hostCols.length == 0 || derivedCols.length == 0) throw new IllegalStateException("host/derived columns must not be empty"); Array<TblColRef> hostColArray = new Array<TblColRef>(hostCols); List<DeriveInfo> infoList = hostToDerivedMap.get(hostColArray); if (infoList == null) { hostToDerivedMap.put(hostColArray, infoList = new ArrayList<DeriveInfo>()); }/*from w w w .j av a 2 s. c o m*/ infoList.add(new DeriveInfo(type, dimension, derivedCols, false)); for (int i = 0; i < derivedCols.length; i++) { TblColRef derivedCol = derivedCols[i]; boolean isOneToOne = type == DeriveType.PK_FK || ArrayUtils.contains(hostCols, derivedCol) || (extra != null && extra[i].contains("1-1")); derivedToHostMap.put(derivedCol, new DeriveInfo(type, dimension, hostCols, isOneToOne)); } }
From source file:jp.co.acroquest.endosnipe.perfdoctor.rule.RuleManager.java
/** * ?ID??/*from w w w. ja v a 2s . c om*/ * * @return ID */ public String createUniqueId() { String[] ruleSetIds = RulePreferenceUtil.loadRuleSetIds(); String ruleSetId; do { ruleSetId = UUID.randomUUID().toString(); } while (ArrayUtils.contains(ruleSetIds, ruleSetId)); return ruleSetId; }