public static void writeMultiValueMapFile(MultiValueMap mapping, String path) { try { FileOutputStream fos = new FileOutputStream(path); DataOutputStream dos = new DataOutputStream(fos); Set<Integer> keys = new TreeSet(mapping.keySet()); for(Integer key : keys) { Set<Integer> values = new TreeSet(mapping.getCollection(key)); dos.writeInt(key.intValue()); dos.writeInt(values.size()); for(Integer value : values) dos.writeInt(value.intValue()); } dos.close(); } catch (Exception e) { e.printStackTrace(); } }
public Gui(File xmlConfiguration, OsaActionBeanContext context) { mapDataStreams = new MultiValueMap(); searchConfiguration = new SearchConfiguration(); try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(xmlConfiguration); doc.getDocumentElement().normalize(); getIngestForms(doc); getSearchForm(doc); getResultLayout(doc); getLayout(doc, context); getUploadConfig(doc); getIdGenerationConfig(doc); getFacetFieldsFromConf(doc); getFacetFieldsforAdvBrowse(doc); } catch (Exception e) { logger.error("Failed to load configuration file: " + xmlConfiguration+", "+ e); } }
public Map<String,Integer> engagementStudentsValued(ArrayList<String> actors, MultiMap interac){ MultiValueMap interactions = (MultiValueMap)interac; Map<String,Integer> engagement = new HashMap<String,Integer>(); int cont = 0; for (String i:actors){ cont = interactions.size(i); engagement.put(i, cont); cont = 0; //System.out.println("Engajamento: " + engagement); } return engagement; }
public MultiMap noDuplicatedInteractions(ArrayList<String> actors, MultiMap interactions){ MultiMap clone = new MultiValueMap(); ArrayList<String> edges = new ArrayList<String>(); for (String j:actors){ edges = (ArrayList<String>)interactions.get(j); if (edges != null){ for (String i:edges){ if (!(tuplaExist(i,(ArrayList<String>)clone.get(j)))){ clone.put(j, i); } } } } System.out.println(clone); return clone; }
private MultiMap getSourcePlateTypesForEachAssayPlate(CherryPickRequest cherryPickRequest) { MultiMap assayPlateName2PlateTypes = MultiValueMap.decorate(new HashMap(), new Factory() { public Object create() { return new HashSet(); } }); for (LabCherryPick cherryPick : cherryPickRequest.getLabCherryPicks()) { if (cherryPick.isAllocated() && cherryPick.isMapped()) { assayPlateName2PlateTypes.put(cherryPick.getAssayPlate().getName(), cherryPick.getSourceCopy().findPlate(cherryPick.getSourceWell().getPlateNumber()).getPlateType()); } } return assayPlateName2PlateTypes; }
public FileLogActionManager(AgentStatus agentStatus, ExecutorService threadService, FileTrackerMemory fileMemory, FileLogManagerMemory memory, Collection<? extends FileLogManageAction> actions) { this.agentStatus = agentStatus; this.threadService = threadService; this.fileMemory = fileMemory; this.memory = memory; fileMemory.addListener(this); // build an index of actions by log type if (actions != null) { actionsByLogTypeMap = new MultiValueMap(); for (FileLogManageAction action : actions) { actionsByLogTypeMap.put(action.getLogType(), action); actionsByNameMap.put(action.getLogType() + action.getStatus() + action.getName(), action); } } // create a schedule service // expired events are checked every X seconds. X == eventParkThreshold scheduledService = Executors.newScheduledThreadPool(1); scheduledService.scheduleAtFixedRate(new Runnable() { public void run() { try { checkExpiredEvents(); } catch (Throwable t) { LOG.error(t.toString(), t); } } }, 1000L, getEventParkThreshold() * 1000, TimeUnit.MILLISECONDS); }
public static MultiValueMap readMultiValueMapFile(String path) { MultiValueMap mapping = new MultiValueMap(); try { FileInputStream fis = new FileInputStream(path); DataInputStream dis = new DataInputStream(fis); int len, key, tmp; while(dis.available() != 0) { key = dis.readInt(); if(dis.available() != 0) { len = dis.readInt(); while(dis.available() != 0 && len > 0) { tmp = dis.readInt(); mapping.put(key, tmp); len--; } } } dis.close(); } catch (Exception e) { e.printStackTrace(); } return mapping; }
public PerturbData(MyBaseGraph src, MyBaseGraph tar, MultiValueMap mvm, MultiValueMap all_mvm) { super(); g_src = src; g_tar = tar; mapping = mvm; all_mapping = all_mvm; common_vertices = new ArrayList<Integer>(); model_choices = new HashMap<Integer, Integer>(); lta_dict = new HashMap<Integer, Double>(); }
public PerturbData(MyBaseGraph src, MyBaseGraph tar, List<Integer> cvs, MultiValueMap mvm, MultiValueMap all_mvm) { super(); g_src = src; g_tar = tar; common_vertices = cvs; mapping = mvm; all_mapping = all_mvm; model_choices = new HashMap<Integer, Integer>(); lta_dict = new HashMap<Integer, Double>(); }
/** * Creates a {@link MultiValueMap} of {@link SPVariableResolver} user * friendly names to their respective namespace. * * @param treeMember * The {@link SPObject} whose root to get the namespaces from. * @return The created {@link MultiValueMap}. */ public static MultiValueMap getNamespaces(SPObject treeMember) { if (treeMember == null) { return new MultiValueMap(); } synchronized (resolvers) { MultiValueMap results = new MultiValueMap(); SPObject root = init(treeMember); for (SPVariableResolver resolver: resolvers.get(root.getUUID())) { results.put(resolver.getUserFriendlyName(), resolver.getNamespace()); } return results; } }
/** * 여러개의 메일을 백업 안남기고 삭제한다. * @param userId 로그인 이메일 * @param multiMap 메일함 경로와 uid 목록 * @throws javax.mail.MessagingException * @throws java.io.IOException * @throws org.apache.james.mailbox.exception.MailboxException */ public void expungeWithoutBackup(String userId, MultiValueMap multiMap) throws IOException, MessagingException, MailboxException { MailboxSession session = null; try { session = loginMailboxByUserId(userId); mailboxmanager.startProcessingRequest(session); String userKey = session.getUser().getUserName(); for (Object mailInfo : multiMap.keySet()) { String mailboxPath = mailInfo.toString(); //기존 메일함 MailboxPath existMailboxPath = new MailboxPath(session.getPersonalSpace(), userKey, mailboxPath); MessageManager messageManager = mailboxmanager.getMailbox(existMailboxPath, session); List<MessageRange> ranges = MessageRange.toRanges((List<Long>) multiMap.get(mailboxPath)); expungeWithoutBackup(messageManager, session, ranges); //백업안남기고 완전 삭제 } } finally { if (session != null) { mailboxmanager.endProcessingRequest(session); try { mailboxmanager.logout(session, true); } catch (MailboxException e) { e.printStackTrace(); } } } }
@Override public MultiMap initEmbeddedPageActions() { if(embeddedPageActions == null) { MultiMap mm = new MultiValueMap(); Layout layout = pageInstance.getLayout(); for(ChildPage childPage : layout.getChildPages()) { String layoutContainerInParent = childPage.getContainer(); if(layoutContainerInParent != null) { String newPath = context.getActionPath() + "/" + childPage.getName(); newPath = ServletUtils.removePathParameters(newPath); //#PRT-1650 Path parameters mess with include File pageDir = new File(pageInstance.getChildrenDirectory(), childPage.getName()); try { Page page = DispatcherLogic.getPage(pageDir); EmbeddedPageAction embeddedPageAction = new EmbeddedPageAction( childPage.getName(), childPage.getActualOrder(), newPath, page); mm.put(layoutContainerInParent, embeddedPageAction); } catch (PageNotActiveException e) { logger.warn("Embedded page action is not active, skipping! " + pageDir, e); } } } for(Object entryObj : mm.entrySet()) { Map.Entry entry = (Map.Entry) entryObj; List pageActionContainer = (List) entry.getValue(); Collections.sort(pageActionContainer); } embeddedPageActions = mm; } return embeddedPageActions; }
private MultiMap getParameterMap(HttpServletRequest request) { MultiMap parameters = new MultiValueMap(); Page page = Page.fromRequest(request); String pageSessionNameFromRequest = page.getSessionAttributeName(); if (null != pageSessionNameFromRequest) { parameters.put(Page.IN_REQUEST, pageSessionNameFromRequest); } return parameters; }
@RequestMapping(value = "/programs.htm", method = RequestMethod.GET) public String programs(final Model model) { final List<Meta> knownClasses = executionService.getKnownClasses(); final Map map = TransformedMap.decorate(new MultiValueMap(), TransformerUtils.invokerTransformer("getProgram"), TransformerUtils.nopTransformer()); for (final Meta meta : knownClasses) { map.put(meta, meta); } model.addAttribute("programmap", map); return "programs"; }
/** * M�todo que retorna as intera��es sociais referentes a ferramenta de mensagens ass�ncronas. * @return Um multimap<Person,Person> que representa as intera��es sociais. * Dessa forma Person "key" interage com os Persons "values" * @throws Exception Lancada caso a data de fim venha antes da data de in�cio */ @SuppressWarnings("unchecked") public static MultiValueMap getSocialInteractionsFromMessenger(Course course, Date inicio, Date fim) throws Exception { if(fim.before(inicio)) throw new Exception("Data fim menor que a Data in�cio."); MultiMap interactions = new MultiValueMap(); Facade facade = Facade.getInstance(); List<Person> teachers = facade.getTeachersByCourse(course); List<Person> persons = facade.listStudentsByCourse(course); for (Person p : persons) { for (MessengerMessage m : p.getSent()) { if( (isBetweenDates(m, inicio, fim)) && ( persons.contains(m.getReceiver()) || teachers.contains(m.getReceiver()) ) ) interactions.put(p.getName(), m.getReceiver().getName()); } } Set keys = interactions.keySet(); System.out.println("Cheguei"); for(Object k : keys){ System.out.println(k + " : " + interactions.get(k)); } return (MultiValueMap) interactions; }
/** * M�todo que retorna as intera��es sociais referentes a ferramenta de monitoramento * do twitter. * @param inicio * @param fim * @return */ public static MultiMap getSocialInteractionsFromTwitterTool(Date inicio, Date fim){ Facade facade = Facade.getInstance(); List<Tweet> tweets = facade.getTweetBetweenDates(inicio, fim); MultiMap map = new MultiValueMap(); for(Tweet t : tweets){ if(t.getDateOfTweet().after(inicio) && t.getDateOfTweet().before(fim)) map.put(t.getUserSender().getName(), t.getUserTarget().getName()); } Set keys = map.keySet(); for(Object k : keys){ System.out.println(k + " : " + map.get(k)); } return map; }
/** * M�todo que retorna as intera��es sociais referentes a ferramenta de forum. * @return Um multimap<Person,Person> que representa as intera��es sociais. * Dessa forma Person "key" interage com os Persons "values" paramterizado pelas datas iniciais e finais. */ @SuppressWarnings("unchecked") public static MultiValueMap getSocialInteractionsFromForumsByCourseAndData(Course course, Date dataini, Date datafim) { MultiMap mhm = new MultiValueMap(); Facade facade = Facade.getInstance(); Course crs = facade.getCoursesById(course.getId()); List<Module> mdls = crs.getModules(); for (Module m : mdls) { for(Forum f: m.getForums()){ for(Message msg: f.getMessages()){ if(msg.getMessageReply()!=null &&msg.getDate().after(dataini)&&msg.getDate().before(datafim)&&!msg.getAuthor().equals(msg.getMessageReply().getAuthor())){ mhm.put(msg.getAuthor().getName(), msg.getMessageReply().getAuthor().getName()); }else if(msg.getMessageReply() == null && msg.getDate().after(dataini) && msg.getDate().before(datafim)){ mhm.put(msg.getAuthor().getName(), "EmptyUserReply"); } } } } Iterator it2 = mhm.keySet().iterator(); while(it2.hasNext()){ System.out.println("Retornando chaves:"+it2.next().toString()); } Iterator it = mhm.values().iterator(); while(it.hasNext()){ System.out.println("Retornando valores:"+it.next().toString()); } return (MultiValueMap) mhm; }
@SuppressWarnings({ "unchecked" }) public List<String> getAllExportableClasses() { List<String> exportable = new ArrayList<>(); Set<Short> keys = migrationOrderMap.keySet(); for (Short key : keys) { Collection<?> migrationClassesList = ((MultiValueMap) migrationOrderMap).getCollection(key); for (Object migrationClasses : migrationClassesList) { for (Class<? extends AbstractEntity<Long>> aClass : (List<Class<? extends AbstractEntity<Long>>>) migrationClasses) { exportable.add(aClass.getSimpleName()); } } } return exportable; }
private void addMigrationMixIn() { MultiValueMap entityMap = applicationMetaSource.getEntityMap(); for (Object object : entityMap.values()) { Class aClass = (Class) object; objectMapper.addMixIn(aClass, MigrationMixIn.class); String migrationMixInKey = String.format("%sMigrationMixIn", aClass.getSimpleName()); if(customMixInMap.containsKey(migrationMixInKey)) { objectMapper.addMixIn(aClass, customMixInMap.get(migrationMixInKey)); } } }
public <T> BaseController() { listeners = MultiValueMap.decorate(new HashMap<String,ViewEventCallback<T>>()); }
/** * Gets the process maps. * * @param pid * the pid * * @return the process maps */ public static Map[] getProcessMaps(int pid) { Map processMap = new HashMap(); Map childrenMap = new MultiValueMap(); Map[] result = new Map[] { processMap, childrenMap }; Pointer processes = MyKernel32.INSTANCE.CreateToolhelp32Snapshot( MyKernel32.TH32CS_SNAPPROCESS, 0); if (processes == null) { System.out.println("note: task list is empty "); return result; } PROCESSENTRY32 me = new PROCESSENTRY32(); me.szExeFile = new char[MyKernel32.MAX_PATH]; int size = me.size(); // System.out.println("size: " + size); me.dwSize = size; if (MyKernel32.INSTANCE.Process32First(processes, me)) { // System.out.println("ProcessList:"); do { // System.out.println(/* new String(next.szExeFile) + */" " + // me.th32ModuleID + " " + me.th32DefaultHeapID + " " + // me.th32ProcessID // + " -> " + me.th32ParentProcessID); if (me.th32ProcessID > 0) processMap.put(new Integer(me.th32ProcessID), me); if (me.th32ParentProcessID > 0 && processMap.get(new Integer(me.th32ParentProcessID)) != null) { childrenMap.put(new Integer(me.th32ParentProcessID), new Integer(me.th32ProcessID)); } // System.out.println("\tProcessID=" + me.th32ProcessID + // "\t\t -> ParentProcessID=" + me.th32ParentProcessID); // else // System.out.println("not added"); } while (MyKernel32.INSTANCE.Process32Next(processes, me)); } else System.out .println("get process list: cannot access first process in list "); MyKernel32.INSTANCE.CloseHandle(processes); return result; }
public MultiValueMap getRoomIdUserIdMap() { return roomIdUserIdMap; }
public static MultiValueMap getPathsFromV(MyBaseGraph g, Integer v) { Set<Integer> visitedBefore = new TreeSet<Integer>(), visitedNow = new TreeSet<Integer>(); Queue<Integer> queue = new LinkedList<Integer>(), toBeQueued = new LinkedList<Integer>(); MultiValueMap paths = new MultiValueMap(); HashMap<Integer, Integer> min_lengths = new HashMap<Integer, Integer>(); queue.add(v); ArrayList<Integer> firstPath = new ArrayList<Integer>(); firstPath.add(v); paths.put(v, firstPath); min_lengths.put(v, firstPath.size()); while(queue.size() > 0 || toBeQueued.size() > 0) { Integer node = null; // Init a new round if queue is empty // (length +1 for all new paths) if(queue.size() == 0) { visitedBefore.addAll(visitedNow); visitedNow.clear(); queue.addAll(toBeQueued); toBeQueued.clear(); continue; } // Get a node from the Queue node = queue.poll(); // Crawl node neighborhood if(!visitedBefore.contains(node) && !visitedNow.contains(node)) visitedNow.add(node); List<Integer> nbrs = new ArrayList<Integer>(g.neighborsOf(node)); nbrs.removeAll(visitedBefore); for(Integer nbr : nbrs) { if(!visitedNow.contains(nbr)) { if(!queue.contains(nbr) && !toBeQueued.contains(nbr)) toBeQueued.add(nbr); } // Register short paths to nbr (vita all short paths to node) ArrayList paths_to_node = new ArrayList(paths.getCollection(node)); int min_length = Integer.MAX_VALUE; if(min_lengths.containsKey(nbr)) min_length = min_lengths.get(nbr); for(int i = 0; i < paths_to_node.size(); i++) { ArrayList<Integer> path = (ArrayList<Integer>) paths_to_node.get(i); if(path.size() + 1 > min_length) continue; ArrayList<Integer> new_path = new ArrayList<Integer>(); new_path.addAll(path); new_path.add(nbr); paths.put(nbr, new_path); if(!min_lengths.containsKey(nbr)) min_lengths.put(nbr, new_path.size()); } } } paths.remove(v); return paths; }
public AnnotationProcessor(Object target) { this.target = target; events = new MultiValueMap(); readAnnotations(); }
public FormEventProcessor() { events = new MultiValueMap(); }
@Transactional("rest_tm") public String bookMail(EmlMailFormVo emlMailFormVo) throws Exception { // 예약 시각 검사 if (emlMailFormVo.getReservDt() == null) { // "받는 사람이 정상적으로 지정되지 않았습니다." throw new AppException(messageSource.getMessage("mail.desc.notAssignReceiverPlz", null, "", LocaleContextHolder.getLocale())); } // 발신자 검사 if (emlMailFormVo.getMailFrom() == null) { /*"발송자 이메일은 필수값입니다."*/ throw new AppException(messageSource.getMessage("mail.desc.essentialSenderMailPlz", null, "", LocaleContextHolder.getLocale())); } // 발신자 이름 검사 String mailFromName = StringUtils.defaultString(emlMailFormVo.getMailFrom().get(0).getPersonal()); //보내는 사람 이름 if (StringUtils.contains(mailFromName, "\"")) { //throw new AppException("보내는 이름에 입력할 수 없는 특수문자가 포함되어 있습니다."); } // 수신자 검사 if (emlMailFormVo.getMailTo() == null || emlMailFormVo.getMailTo().size() == 0) { // "받는 사람이 정상적으로 지정되지 않았습니다." throw new AppException(messageSource.getMessage("mail.desc.notAssignReceiverPlz", null, "", LocaleContextHolder.getLocale())); } // 제목 보정 if (StringUtils.isEmpty(emlMailFormVo.getSubject())) { // "제목 없음" emlMailFormVo.setSubject(messageSource.getMessage("mail.label.noTitle", null, "", LocaleContextHolder.getLocale())); } String result = "SUCCESS"; String mode = StringUtils.defaultIfEmpty(emlMailFormVo.getMode(), "write"); //작성 모드 String massMailId = IdGenerator.generateUniqueId(); //대용량 메일 고유 번호 // 최근 수신자로 저장할 주소 추출 // 사용자가 입력한 주소 그대로 최근 수신자로 추출 List<String> mailToList = gatherRecentlyUsedRecipients(emlMailFormVo.getMailTo(), emlMailFormVo.getMailCc(), emlMailFormVo.getMailBcc()); //최근 수신자 저장 updateRecentlyUsedRecipient(emlMailFormVo.getUserId(), mailToList); //예약 메일 등록/수정 모드일 경우 //기존 메일 정보 완전 삭제 List<EmlMailKeyVo> emlMailKeyVoList = emlMailFormVo.getMailIdList(); if (emlMailKeyVoList != null) { MultiValueMap multiMap = new MultiValueMap(); for (EmlMailKeyVo emlMailKeyVo : emlMailKeyVoList) { multiMap.put(emlMailKeyVo.getMailboxName(), emlMailKeyVo.getUid()); } // 로그인용 주소, 메일박스, uid 목록 emlMailboxUtilService.expungeWithoutBackup(emlMailFormVo.getUserId(), multiMap); } //예약 메일함에 저장 emlMailFormDao.insert(new EmlMailForm(emlMailFormVo)); return null; //result; }
public MultiValueMap getFilterFiles() { return filterFiles; }
public void setFilterFiles(MultiValueMap filterFiles) { this.filterFiles = filterFiles; }
public MultiValueMap getEntityMap() { return entityMap; }
protected void transferExperimentConfigurations(Map<String, Object> charBeanMap, List<SimpleCharacterizationUnitBean> charBeanUnits, CharacterizationBean charBean) { if (charBean.getExperimentConfigs().size() == 0) { //SimpleCharacterizationUnitBean aUnit = new SimpleCharacterizationUnitBean("Experiment Configurations", "N/A"); //charBeanUnits.add(aUnit); return; } logger.debug("Experiment Configurations size: " + charBean.getExperimentConfigs().size()); List<ExperimentConfigBean> expConfigBeans = charBean.getExperimentConfigs(); MultiMap technique = new MultiValueMap(); MultiMap instruments = new MultiValueMap(); MultiMap description = new MultiValueMap(); List<MultiMap> expConfigTable = new ArrayList<MultiMap>(); for (ExperimentConfigBean aBean : expConfigBeans) { String techDisplayName = (aBean.getTechniqueDisplayName() == null) ? "" : aBean.getTechniqueDisplayName(); //String instrDisplayNames = (aBean.getInstrumentDisplayNames() == null) ? "" : aBean.getInstrumentDisplayNames(); String desc = (aBean.getDomain().getDescription() == null) ? "" : aBean.getDomain().getDescription(); String[] instNames = aBean.getInstrumentDisplayNames(); StringBuilder sb = new StringBuilder(); if (instNames != null) { for (String instName : instNames) { if (sb.length() > 0) sb.append(","); sb.append(instName); } } technique.put("Technique", techDisplayName); instruments.put("Instruments", sb.toString()); description.put("Description", desc); logger.debug("Tech display name: " + aBean.getTechniqueDisplayName()); } expConfigTable.add(technique); expConfigTable.add(instruments); expConfigTable.add(description); charBeanMap.put("Experiment Configurations", expConfigTable); SimpleCharacterizationUnitBean aUnit = new SimpleCharacterizationUnitBean("Experiment Configurations", expConfigTable); charBeanUnits.add(aUnit); }
@SuppressWarnings("unchecked") /** * Normally, we create 1 file per assay plate. However, in the case where an * assay plate is comprised of wells from library copy plates that have * different plate types, we need to generate a separate file for each source * plate type (i.e., the assay plate will be defined over multiple files). * @return a MultiMap that partitions the cherry picks by file, * ordering both the file names and cherry picks for each file. */ private MultiMap/*<String,SortedSet<CherryPick>>*/ buildCherryPickFiles(CherryPickRequest cherryPickRequest, Set<CherryPickAssayPlate> forPlates) { MultiMap assayPlate2SourcePlateTypes = getSourcePlateTypesForEachAssayPlate(cherryPickRequest); MultiMap result = MultiValueMap.decorate(new TreeMap<String,SortedSet<LabCherryPick>>(), new Factory() { public Object create() { return new TreeSet<LabCherryPick>(PlateMappingCherryPickComparator.getInstance()); } }); // HACK: transform set of CPAP into a set of IDs, for purpose of checking // set membership; we can't rely upon CPAP.equals(), since we're comparing // non-managed entities with managed entities, and therefore we do not have // the guarantee of instance equality for entities with the same ID Set<Serializable> forPlateIds = new HashSet<Serializable>( forPlates .size()); for (CherryPickAssayPlate cpap : forPlates) { if (cpap.getEntityId() == null) { throw new IllegalArgumentException("all members of 'forPlates' must already be persisted and have a database identifier"); } forPlateIds.add(cpap.getEntityId()); } for (LabCherryPick cherryPick : cherryPickRequest.getLabCherryPicks()) { if (cherryPick.isAllocated()) { CherryPickAssayPlate assayPlate = cherryPick.getAssayPlate(); if (forPlates == null || (assayPlate != null && forPlateIds.contains(assayPlate.getEntityId()))) { Set<PlateType> sourcePlateTypes = (Set<PlateType>) assayPlate2SourcePlateTypes.get(assayPlate.getName()); String fileName = makeFilename(cherryPick, sourcePlateTypes.size()); result.put(fileName, cherryPick); } } } return result; }
/** * Returns the name of the block/item that corresponds to its ID. * @author SS111 * @param map a <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> populated by ConfigHelper * @param key the block/item ID * @return String * @see <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> * @see com.github.ss111.ConfigHelper */ public static String getName(MultiValueMap map, Integer key) { @SuppressWarnings("unchecked") Collection<ArrayList<String>> names = map.getCollection(key); String name = new String(); for (ArrayList<String> combo : names) { name = combo.toArray()[0].toString(); break; } return name; }
/** * Determines if a block/item is has a conflicting ID. * <p> * Optionally, by passing the type argument (either BLOCK or ITEM), ConflictHelper will store conflicting block/item IDs in their respective ArrayLists which can then be retrieved by calling ConfigHelper.getConflictingBlocks() or ConfigHelper.getConflictingItems(). * @author SS111 * @param map a <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> populated by ConfigHelper * @param key the block/item ID * @param type the map type (BLOCK or ITEM) * @return Boolean * @see <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> * @see com.github.ss111.ConfigHelper * @see ConflictHelper#getConflictingBlocks() * @see ConflictHelper#getConflictingItems() */ public static Boolean isConflicting(MultiValueMap map, Integer key, String type) { @SuppressWarnings("unchecked") Collection<ArrayList<String>> names = map.getCollection(key); if (names.size() == 1) { return false; } else { ArrayList<String> namesArray = new ArrayList<String>(); for (ArrayList<String> combo : names) { namesArray.add(combo.toArray()[0].toString()); } if (namesArray.toArray()[0].toString().equals(namesArray.toArray()[1].toString())) { return false; } else { if (type == "BLOCK") { conflictingBlocks.add(key); } else if (type == "ITEM") { conflictingItems.add(key); } return true; } } }
/** * Determines if a block/item is has a conflicting ID. * @author SS111 * @param map a <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> populated by ConfigHelper * @param key the block/item ID * @return Boolean * @see <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> * @see com.github.ss111.ConfigHelper */ public static Boolean isConflicting(MultiValueMap map, Integer key) { @SuppressWarnings("unchecked") Collection<ArrayList<String>> names = map.getCollection(key); if (names.size() == 1) { return false; } else { ArrayList<String> namesArray = new ArrayList<String>(); for (ArrayList<String> combo : names) { namesArray.add(combo.toArray()[0].toString()); } if (namesArray.toArray()[0].toString().equals(namesArray.toArray()[1].toString())) { return false; } else { return true; } } }
/** * Returns a sentence that tells what each block/item conflicts with. * @author SS111 * @param map a <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> populated by ConfigHelper * @param key key the block/item ID * @return String * @see <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> * @see com.github.ss111.ConfigHelper */ public static String getConflictString(MultiValueMap map, Integer key) { @SuppressWarnings("unchecked") Collection<ArrayList<String>> names = map.getCollection(key); String conflictString = ""; ArrayList<String> namesArray = new ArrayList<String>(); for (ArrayList<String> combo : names) { namesArray.add(combo.toArray()[0].toString()); } for (int i = 0; i <= names.size() - 1; i++) { if (i == 0) { conflictString += namesArray.toArray()[i] + " conflicts with "; } else if (i == names.size() - 1) { conflictString += namesArray.toArray()[i] + "."; } else if (i == names.size() - 2) { conflictString += namesArray.toArray()[i] + ", and "; } else { conflictString += namesArray.toArray()[i] + ", "; } } return conflictString; }
/** * Returns a sentence that states the configuration files that have conflicts * <p> * This is to be used in conjunction with ConfigHelper.getConflictString(MultiValueMap map, Integer key) * @author SS111 * @param map a <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> populated by ConfigHelper * @param key the block/item ID * @param type the map type (BLOCK or ITEM) * @return String * @see <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> * @see com.github.ss111.ConfigHelper * @see ConifgHelper#getConflictString(MultiValueMap map, Integer key) getConflictString */ public static String getConfigConflictString(MultiValueMap map, Integer key) { @SuppressWarnings("unchecked") Collection<ArrayList<String>> names = map.getCollection(key); String conflictString = "These conflicts are located in "; ArrayList<String> namesArray = new ArrayList<String>(); for (ArrayList<String> combo : names) { namesArray.add(combo.toArray()[1].toString()); } for (int i = 0; i <= names.size() - 1; i++) { if (i == names.size() - 1) { conflictString += namesArray.toArray()[i] + "."; } else if (i == names.size() - 2) { conflictString += namesArray.toArray()[i] + ", and "; } else { conflictString += namesArray.toArray()[i] + ", "; } } return conflictString; }
/** * Creates a list of user friendly names->namespaces. * If you want only the namespaces, do {@link MultiValueMap#values()} * @return */ public MultiValueMap getNamespaces() { return SPResolverRegistry.getNamespaces(this.contextSource); }
/** * Returns a <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> of all the block IDs and their corresponding name(s) and configuration file(s). * @return <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> * @see <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> */ public static MultiValueMap getBlockIDs() { return blockIDs; }
/** * Returns a <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> of all the item IDs and their corresponding name(s) and configuration file(s). * @return <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> * @see <a href="http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/map/MultiValueMap.html">MultiValueMap</a> */ public static MultiValueMap getItemIDs() { return itemIDs; }