List of usage examples for java.util Collection toArray
default <T> T[] toArray(IntFunction<T[]> generator)
From source file:org.n52.web.ctrl.ParameterController.java
@Override public Map<String, Object> getExtras(String resourceId, MultiValueMap<String, String> query) { IoParameters queryMap = createFromQuery(query); LOGGER.debug("getExtras() with id '{}' and query '{}'", resourceId, queryMap); Map<String, Object> extras = new HashMap<>(); for (MetadataExtension<T> extension : metadataExtensions) { T from = parameterService.getParameter(resourceId, queryMap); final Map<String, Object> furtherExtras = extension.getExtras(from, queryMap); Collection<String> overridableKeys = checkForOverridingData(extras, furtherExtras); if (!overridableKeys.isEmpty()) { String[] keys = overridableKeys.toArray(new String[0]); LOGGER.warn("Metadata extension overrides existing extra data: {}", Arrays.toString(keys)); }//from w ww . j a va 2 s .co m extras.putAll(furtherExtras); } return extras; }
From source file:org.ambraproject.wombat.service.remote.AbstractContentApi.java
@Override public final CloseableHttpResponse request(ContentKey key, Collection<? extends Header> headers) throws IOException { URI requestAddress = buildUri(key, RequestMode.OBJECT); HttpGet get = new HttpGet(requestAddress); get.setHeaders(headers.toArray(new Header[headers.size()])); return cachedRemoteStreamer.getResponse(get); }
From source file:uk.ac.ebi.intact.editor.controller.bulk.BulkAnnotationController.java
public void addBulkAnnotation(ActionEvent evt) { Class aoClass = null;/*w ww .j a v a 2 s . c o m*/ try { aoClass = Thread.currentThread().getContextClassLoader().loadClass(aoClassName); try { getBulkOperations().getIntactDao().getUserContext().setUser(getCurrentUser()); updatedAcs = getBulkOperations().addAnnotation(new DefaultAnnotation(this.topic, this.value), acs, aoClass, replaceIfTopicExists); } catch (SynchronizerException e) { addErrorMessage("Cannot add annotation " + this.topic, e.getCause() + ": " + e.getMessage()); } catch (FinderException e) { addErrorMessage("Cannot add annotation " + this.topic, e.getCause() + ": " + e.getMessage()); } catch (PersisterException e) { addErrorMessage("Cannot add annotation " + this.topic, e.getCause() + ": " + e.getMessage()); } catch (Throwable e) { addErrorMessage("Cannot add annotation " + this.topic, e.getCause() + ": " + e.getMessage()); } if (acs.length > 0 && updatedAcs.length == 0) { addErrorMessage("Operation failed. The acs may not exist in the database", "None of the ACs could be updated (do they exist?)"); couldNotUpdateAcs = acs; } else if (acs.length != updatedAcs.length) { List<String> acsList = Arrays.asList(acs); List<String> updatedAcsList = Arrays.asList(updatedAcs); Collection<String> couldNotUpdateList = CollectionUtils.subtract(acsList, updatedAcsList); couldNotUpdateAcs = couldNotUpdateList.toArray(new String[couldNotUpdateList.size()]); addWarningMessage("Finished with warnings", updatedAcs.length + " objects were updated, " + couldNotUpdateAcs.length + " objects couldn't be updated (do they exist?)"); } else { addInfoMessage("Operation successful", updatedAcs.length + " objects were updated"); } } catch (ClassNotFoundException e) { addErrorMessage("Could not find class: " + aoClassName, e.getMessage()); } }
From source file:morphy.service.SeekService.java
public Seek[] getAllSeeks() { Collection<Seek> seekCollection = this.seekMap.values(); return seekCollection.toArray(new Seek[seekCollection.size()]); }
From source file:com.adito.activedirectory.GroupContainer.java
synchronized void buildHierarchy(String roleDn) { roleDn = roleDn.toLowerCase();/*from w w w.ja v a 2s .c o m*/ ActiveDirectoryGroup role = (ActiveDirectoryGroup) dnToRoleCache.retrieve(roleDn); if (role != null) { Map<String, ActiveDirectoryGroup> parents = new HashMap<String, ActiveDirectoryGroup>(); addParents(roleDn, parents); Collection<ActiveDirectoryGroup> values = new TreeSet<ActiveDirectoryGroup>(parents.values()); values.remove(role); // groups can be recursive so it might contain itself ActiveDirectoryGroup[] toArray = values.toArray(new ActiveDirectoryGroup[parents.size()]); role.setParents(toArray); } }
From source file:com.mycollab.module.project.view.settings.ProjectMemberInvitePresenter.java
@Override protected void postInitView() { view.addViewListener(new ViewListener<ProjectMemberEvent.InviteProjectMembers>() { private static final long serialVersionUID = 1L; @Override//from ww w. j a v a 2 s . c o m public void receiveEvent(ViewEvent<InviteProjectMembers> event) { InviteProjectMembers inviteMembers = (InviteProjectMembers) event.getData(); ProjectMemberService projectMemberService = AppContextUtil .getSpringBean(ProjectMemberService.class); Collection<String> inviteEmails = inviteMembers.getEmails(); if (CollectionUtils.isNotEmpty(inviteEmails)) { projectMemberService.inviteProjectMembers(inviteEmails.toArray(new String[inviteEmails.size()]), CurrentProjectVariables.getProjectId(), inviteMembers.getRoleId(), UserUIContext.getUsername(), inviteMembers.getInviteMessage(), MyCollabUI.getAccountId()); ExtMailService mailService = AppContextUtil.getSpringBean(ExtMailService.class); if (mailService.isMailSetupValid()) { NotificationUtil.showNotification( UserUIContext.getMessage(ProjectMemberI18nEnum.OPT_INVITATION_SENT_SUCCESSFULLY), UserUIContext.getMessage(GenericI18Enum.HELP_SPAM_FILTER_PREVENT_MESSAGE), Notification.Type.HUMANIZED_MESSAGE); EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoList(this, null)); } else { UI.getCurrent().addWindow(new CanSendEmailInstructionWindow(inviteMembers)); } } } }); }
From source file:captureplugin.drivers.defaultdriver.CaptureParamLibrary.java
public String getStringForFunction(Program prg, String function, String[] params) { if (function.equals("variable")) { if (params.length != 1) { setErrors(true);/* w w w .j a va2 s .c o m*/ setErrorString(mLocalizer.msg("variable_Wrong_Usage", "Wrong usage of command variable. Only one Param is allowed")); return null; } try { int i = Integer.parseInt(params[0]); final Collection<Variable> variables = mConfig.getVariables(); Variable[] varArray = variables.toArray(new Variable[variables.size()]); if (varArray.length < i) { return ""; } return varArray[i - 1].getValue(); } catch (Exception e) { setErrors(true); setErrorString(mLocalizer.msg("variable_Not_A_Number", "The variable-Command needs a Number.")); return null; } } return super.getStringForFunction(prg, function, params); }
From source file:com.blocks.framework.utils.date.StringUtil.java
/** * ?????/*from www . j a va 2 s .co m*/ * * @param src * String * @param pattern * String * @return String[] */ public static String[] findAll(String src, String pattern) { if (src == null) { return new String[0]; } if (pattern == null) { return new String[0]; } Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(src); Collection<String> l = new ArrayList<String>(); while (m.find()) { l.add(m.group()); } return (String[]) l.toArray(new String[] {}); }
From source file:com.smartitengineering.version.impl.jgit.service.impl.MetaRCSServiceImpl.java
public Set<com.smartitengineering.version.api.Commit> searchForCommits(Collection<QueryParameter> parameters) { Collection<QueryParameter> params = parameters == null ? Collections.<QueryParameter>emptyList() : parameters;/*from ww w .jav a2s . co m*/ List<Commit> commits = commitReader.getList(params.toArray(new QueryParameter[0])); LinkedHashSet<com.smartitengineering.version.api.Commit> result = new LinkedHashSet<com.smartitengineering.version.api.Commit>(); if (commits != null) { for (Commit commit : commits) { result.add(MetaFactory.transformMetaCommit(commit)); } } return result; }
From source file:com.qpark.eip.core.spring.AbstractAggregator.java
/** * @param messages/*from w w w .jav a 2 s. c om*/ * @return */ public boolean canRelease(final Collection<Message<?>> messages) { boolean canRelease = false; this.logger.trace("-canRelease collection {}", messages != null ? messages.size() : " collection of messages is null"); if (messages != null && !messages.isEmpty()) { Message<?> m = messages.toArray(new Message<?>[messages.size()])[0]; Integer sequenceSize = new IntegrationMessageHeaderAccessor(m).getSequenceSize(); this.logger.trace(" canRelease collection messages.size()={}, sequenceSize={}", messages.size(), sequenceSize); if (sequenceSize != null && messages.size() == sequenceSize) { canRelease = true; } } this.logger.trace("-canRelease collection canRelease={}", canRelease); return canRelease; }