List of usage examples for java.util LinkedList get
public E get(int index)
From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java
private static void mapForEZPassPA(LinkedList<String> expectedColumnList) { LinkedHashMap<String, String> actualColumnMap = new LinkedHashMap<String, String>(); int expectedColumnStartIndex = 2; actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), StringUtils.EMPTY); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TAG/LICENSE"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TAG/LICENSE"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Driver Name"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "EXIT DATE"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "EXIT DATE"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "EXIT PLAZA"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "AMOUNT"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Invoice Date"); //actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Unit #"); tollCompanyToTollTagMapping.put(TOLL_COMPANY_EZ_PASS_PA, actualColumnMap); }
From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java
private static void mapForIPass(LinkedList<String> expectedColumnList) { LinkedHashMap<String, String> actualColumnMap = new LinkedHashMap<String, String>(); int expectedColumnStartIndex = 2; actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), StringUtils.EMPTY); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Transponder ID"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Transponder ID"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Driver Name"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Transaction date"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Transaction date"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Toll agency"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Transaction amount"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Invoice Date"); //actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Unit #"); tollCompanyToTollTagMapping.put(TOLL_COMPANY_IPASS, actualColumnMap); }
From source file:com.primovision.lutransport.core.util.TollCompanyTagUploadUtil.java
private static void mapForSunPass(LinkedList<String> expectedColumnList) { LinkedHashMap<String, String> actualColumnMap = new LinkedHashMap<String, String>(); int expectedColumnStartIndex = 2; actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), StringUtils.EMPTY); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TOLL TAG # / PLATE #"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TOLL TAG # / PLATE #"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Driver Name"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TRANSACTION DATE"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "TRANSACTION TIME"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), StringUtils.EMPTY); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "AMOUNT"); actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Invoice Date"); //actualColumnMap.put(expectedColumnList.get(expectedColumnStartIndex++), "Unit #"); tollCompanyToTollTagMapping.put(TOLL_COMPANY_SUN_PASS, actualColumnMap); }
From source file:com.huateng.startup.init.MenuInfoUtil.java
/** * ???/* w w w. j a va 2s. c o m*/ * @param degree */ @SuppressWarnings("unchecked") public static LinkedHashMap<String, Object> setOperatorMenuWithDegree(String degree, String contextPath, Document document) { String sql = "select * FROM TBL_ROLE_FUNC_MAP WHERE KEY_ID in ( " + degree + ")"; ICommQueryDAO commQueryDAO = (ICommQueryDAO) ContextUtil.getBean("CommQueryDAO"); List<Object[]> funcMapList = commQueryDAO.findBySQLQuery(sql); valueIdRole(funcMapList); List<Object> menuLvl1List = allMenuBean.getDataList(); LinkedHashMap<String, Object> menuIndexMap = new LinkedHashMap<String, Object>(); String panelStr = ""; //????? for (int i = 0, n = menuLvl1List.size(); i < n; i++) { Map<String, Object> menuLvl1Map = (Map<String, Object>) menuLvl1List.get(i); LinkedList<Object> menuLvl2List = (LinkedList<Object>) menuLvl1Map.get(Constants.MENU_CHILDREN); List<String> menuList = new ArrayList<String>(); for (int j = 0, m = menuLvl2List.size(); j < m; j++) { Map<String, Object> menuLvl2Map = (Map<String, Object>) menuLvl2List.get(j); LinkedList<Object> menuLvl3List = (LinkedList<Object>) menuLvl2Map.get(Constants.MENU_CHILDREN); for (int k = 0, l = menuLvl3List.size(); k < l; k++) { Map<String, Object> menuLvl3Map = (Map<String, Object>) menuLvl3List.get(k); for (int a = 0, b = funcMapList.size(); a < b; a++) { if (StringUtils.trim(funcMapList.get(a)[1].toString()) .equals(StringUtils.trim(menuLvl3Map.get(Constants.MENU_ID).toString()))) { if (!menuIndexMap.containsKey(menuLvl1Map.get(Constants.MENU_ID).toString())) { Map<String, Object> menuLvl1HashMap = new LinkedHashMap<String, Object>(); String menuId = menuLvl1Map.get(Constants.MENU_ID).toString(); menuLvl1HashMap.put(Constants.MENU_ID, menuLvl1Map.get(Constants.MENU_ID)); menuLvl1HashMap.put(Constants.MENU_TEXT, menuLvl1Map.get(Constants.MENU_TEXT)); menuLvl1HashMap.put(Constants.MENU_CLS, menuLvl1Map.get(Constants.MENU_CLS)); menuLvl1HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL1_FUNC); menuLvl1HashMap.put(Constants.TOOL_BAR_TYPE, Constants.TOOL_BAR_BUTTON); menuLvl1HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENU); menuLvl1HashMap.put(Constants.IS_EXPAND, true); if ("1".equals(menuId) && panelStr.indexOf("baseTree") == -1) { panelStr = panelStr + "baseTree,"; } if ("2".equals(menuId) && panelStr.indexOf("mchtTree") == -1) { panelStr = panelStr + "mchtTree,"; } if ("3".equals(menuId) && panelStr.indexOf("termTree") == -1) { panelStr = panelStr + "termTree,"; } if ("5".equals(menuId) && panelStr.indexOf("queryTree") == -1) { panelStr = panelStr + "queryTree,"; } if ("9".equals(menuId) && panelStr.indexOf("onLinePayTree") == -1) { panelStr = panelStr + "onLinePayTree,"; } if ("10".equals(menuId) && panelStr.indexOf("taskTree") == -1) { panelStr = panelStr + "taskTree,"; } if ("8".equals(menuId) && panelStr.indexOf("clearTree") == -1) { panelStr = panelStr + "clearTree,"; } if ("4".equals(menuId) && panelStr.indexOf("riskTree") == -1) { panelStr = panelStr + "riskTree,"; } if ("11".equals(menuId) && panelStr.indexOf("provisionsTree") == -1) { panelStr = panelStr + "provisionsTree,"; } if ("12".equals(menuId) && panelStr.indexOf("errorTree") == -1) { panelStr = panelStr + "errorTree,"; } Map<String, Object> menuLvl2HashMap = new LinkedHashMap<String, Object>(); menuLvl2HashMap.put(Constants.MENU_ID, menuLvl2Map.get(Constants.MENU_ID)); menuLvl2HashMap.put(Constants.MENU_TEXT, menuLvl2Map.get(Constants.MENU_TEXT)); menuLvl2HashMap.put(Constants.MENU_PARENT_ID, menuLvl2Map.get(Constants.MENU_PARENT_ID)); menuLvl2HashMap.put(Constants.MENU_CLS, menuLvl2Map.get(Constants.MENU_CLS)); menuLvl2HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl2HashMap.put(Constants.IS_EXPAND, true); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); int index = menuList.lastIndexOf((String) menuLvl3Map.get(Constants.MENU_ID)); LinkedList<Object> menuLvl3Child = new LinkedList<Object>(); //System.out.println((String)menuLvl3Map.get(Constants.MENU_ID) + ">>>>>>>>>" + index + ">>>>>" + menuList.size()); if (-1 == index) { String tbar = MenuUtil.initMenu((String) menuLvl3Map.get(Constants.MENU_ID), (String) funcMapList.get(a)[5]); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.ROLE_FLAG, tbar); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3HashMap.put(Constants.IS_EXPAND, true); menuList.add((String) menuLvl3Map.get(Constants.MENU_ID)); menuLvl3Child.add(menuLvl3HashMap); } else { Map<String, Object> menu = (Map<String, Object>) menuLvl3Child.get(index); menu.put(Constants.ROLE_FLAG, (String) menu.get(Constants.ROLE_FLAG) + funcMapList.get(a)[5]); } menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); LinkedList<Object> menuLvl2Child = new LinkedList<Object>(); menuLvl2Child.add(menuLvl2HashMap); menuLvl1HashMap.put(Constants.MENU_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl2Child); menuIndexMap.put(menuLvl1Map.get(Constants.MENU_ID).toString(), menuLvl1HashMap); } else { Map<String, Object> menuLvl1HashMap = (Map<String, Object>) menuIndexMap .get(menuLvl1Map.get(Constants.MENU_ID).toString()); LinkedList<Object> menuLvl2Child = (LinkedList<Object>) menuLvl1HashMap .get(Constants.MENU_CHILDREN); boolean hasMenu = false; for (int c = 0, d = menuLvl2Child.size(); c < d; c++) { Map<String, Object> menuLvl2HashMap = (Map<String, Object>) menuLvl2Child .get(c); if (StringUtils.trim(menuLvl2HashMap.get(Constants.MENU_ID).toString()).equals( StringUtils.trim(menuLvl2Map.get(Constants.MENU_ID).toString()))) { LinkedList<Object> menuLvl3Child = (LinkedList<Object>) menuLvl2HashMap .get(Constants.MENU_CHILDREN); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); int index = menuList .lastIndexOf((String) menuLvl3Map.get(Constants.MENU_ID)); if (-1 == index) { String tbar = MenuUtil.initMenu( (String) menuLvl3Map.get(Constants.MENU_ID), (String) funcMapList.get(a)[5]); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.ROLE_FLAG, tbar); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3HashMap.put(Constants.IS_EXPAND, true); menuList.add((String) menuLvl3Map.get(Constants.MENU_ID)); menuLvl3Child.add(menuLvl3HashMap); } // else{ // Map<String, Object> menu = (Map<String, Object>)menuLvl3Child.get(index); // menu.put(Constants.ROLE_FLAG,(String)menu.get(Constants.ROLE_FLAG) + funcMapList.get(a)[5]); // } menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.IS_EXPAND, true); menuLvl2Child.set(c, menuLvl2HashMap); hasMenu = true; break; } } if (!hasMenu) { String tbar = MenuUtil.initMenu((String) menuLvl3Map.get(Constants.MENU_ID), (String) funcMapList.get(a)[5]); Map<String, Object> menuLvl2HashMap = new HashMap<String, Object>(); menuLvl2HashMap.put(Constants.MENU_ID, menuLvl2Map.get(Constants.MENU_ID)); menuLvl2HashMap.put(Constants.MENU_TEXT, menuLvl2Map.get(Constants.MENU_TEXT)); menuLvl2HashMap.put(Constants.MENU_PARENT_ID, menuLvl2Map.get(Constants.MENU_PARENT_ID)); menuLvl2HashMap.put(Constants.MENU_CLS, menuLvl2Map.get(Constants.MENU_CLS)); menuLvl2HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl2HashMap.put(Constants.IS_EXPAND, true); LinkedList<Object> menuLvl3Child = new LinkedList<Object>(); Map<String, Object> menuLvl3HashMap = new LinkedHashMap<String, Object>(); menuLvl3HashMap.put(Constants.MENU_ID, menuLvl3Map.get(Constants.MENU_ID)); menuLvl3HashMap.put(Constants.MENU_TEXT, menuLvl3Map.get(Constants.MENU_TEXT)); menuLvl3HashMap.put(Constants.MENU_PARENT_ID, menuLvl3Map.get(Constants.MENU_PARENT_ID)); menuLvl3HashMap.put(Constants.MENU_LEAF, true); menuLvl3HashMap.put(Constants.MENU_URL, menuLvl3Map.get(Constants.MENU_URL)); menuLvl3HashMap.put(Constants.MENU_CLS, menuLvl3Map.get(Constants.MENU_CLS)); menuLvl3HashMap.put(Constants.ROLE_FLAG, tbar); menuLvl3HashMap.put(Constants.MENU_HANDLER, Constants.MENU_LVL3_FUNC); //menuLvl3HashMap.put(Constants.TOOLBAR_ICON, Constants.TOOLBAR_ICON_MENUITEM); menuLvl3HashMap.put(Constants.TOOLBAR_ICON, menuLvl3Map.get(Constants.TOOLBAR_ICON)); menuLvl3HashMap.put(Constants.IS_EXPAND, true); menuLvl3Child.add(menuLvl3HashMap); menuLvl2HashMap.put(Constants.MENU_CHILDREN, menuLvl3Child); menuLvl2HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl3Child); menuLvl2Child.add(menuLvl2HashMap); } menuLvl1HashMap.put(Constants.MENU_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.TOOL_BAR_CHILDREN, menuLvl2Child); menuLvl1HashMap.put(Constants.IS_EXPAND, true); menuIndexMap.put(menuLvl1Map.get(Constants.MENU_ID).toString(), menuLvl1HashMap); } } } } } } menuIndexMap.remove(Constants.TREE_MENU_PANEL); if (panelStr.length() != 0) { menuIndexMap.put(Constants.TREE_MENU_PANEL, panelStr.substring(0, panelStr.length() - 1)); } else { menuIndexMap.put(Constants.TREE_MENU_PANEL, ""); } return menuIndexMap; }
From source file:org.apache.hadoop.hdfs.server.namenode.JournalSet.java
public static void chainAndMakeRedundantStreams(Collection<EditLogInputStream> outStreams, PriorityQueue<EditLogInputStream> allStreams, long fromTxId) { // We want to group together all the streams that start on the same start // transaction ID. To do this, we maintain an accumulator (acc) of all // the streams we've seen at a given start transaction ID. When we see a // higher start transaction ID, we select a stream from the accumulator and // clear it. Then we begin accumulating streams with the new, higher start // transaction ID. LinkedList<EditLogInputStream> acc = new LinkedList<EditLogInputStream>(); EditLogInputStream elis;/*w ww. j av a 2 s . c om*/ while ((elis = allStreams.poll()) != null) { if (acc.isEmpty()) { acc.add(elis); } else { EditLogInputStream accFirst = acc.get(0); long accFirstTxId = accFirst.getFirstTxId(); if (accFirstTxId == elis.getFirstTxId()) { // if we have a finalized log segment available at this txid, // we should throw out all in-progress segments at this txid if (elis.isInProgress()) { if (accFirst.isInProgress()) { acc.add(elis); } } else { if (accFirst.isInProgress()) { acc.clear(); } acc.add(elis); } } else if (accFirstTxId < elis.getFirstTxId()) { // try to read from the local logs first since the throughput should // be higher Collections.sort(acc, LOCAL_LOG_PREFERENCE_COMPARATOR); outStreams.add(new RedundantEditLogInputStream(acc, fromTxId)); acc.clear(); acc.add(elis); } else if (accFirstTxId > elis.getFirstTxId()) { throw new RuntimeException("sorted set invariants violated! " + "Got stream with first txid " + elis.getFirstTxId() + ", but the last firstTxId was " + accFirstTxId); } } } if (!acc.isEmpty()) { Collections.sort(acc, LOCAL_LOG_PREFERENCE_COMPARATOR); outStreams.add(new RedundantEditLogInputStream(acc, fromTxId)); acc.clear(); } }
From source file:util.allocation.java
public static LinkedList<HOST> rankingHostlistFromCheapToHigh(LinkedList<String> HOSTIDList, LinkedList<HOST> HOSTList) { LinkedList<HOST> rankedList = new LinkedList<HOST>(); for (String currentHOSTID : HOSTIDList) { for (HOST currentHOST : HOSTList) { if (currentHOST.getID().equals(currentHOSTID)) {/*from ww w . j a v a2s . c om*/ rankedList.add(currentHOST); } } } int size = rankedList.size(); for (int i = 0; i < size - 1; i++) { for (int j = i + 1; j < size; j++) { if (rankedList.get(i).getPrice() > rankedList.get(j).getPrice()) { // ?? Collections.swap(rankedList, i, j); } } } return rankedList; }
From source file:util.allocation.java
public static LinkedList<HOST> recalculateSpaceForHOSTList(LinkedList<HOST> HOSTList, String currentHOSTSolutionID, VM currentVM) { HOST currentHOST = getHOSTByID(currentHOSTSolutionID, HOSTList); float currentHOSTVolume = currentHOST.getVolume(); String currentHOStVolumeUnit = currentHOST.getVolumeUnit(); float currentVMVolume = currentVM.getVolume(); float newVolume = currentHOSTVolume - currentVMVolume; String newItem = Float.toString(newVolume) + "_" + currentHOStVolumeUnit; HOSTList.get(HOSTList.indexOf(currentHOST)).getServiceDescription().replace("volume", newItem); return HOSTList; }
From source file:util.allocation.java
public static LinkedList<String> rankingHostlistFromCheapToHighAndReturnHOSTIDList( LinkedList<String> HOSTIDList, LinkedList<HOST> HOSTList) { LinkedList<HOST> rankedList = new LinkedList<HOST>(); for (String currentHOSTID : HOSTIDList) { for (HOST currentHOST : HOSTList) { if (currentHOST.getID().equals(currentHOSTID)) {//from w ww . j a va2 s.c o m rankedList.add(currentHOST); } } } int size = rankedList.size(); for (int i = 0; i < size - 1; i++) { for (int j = i + 1; j < size; j++) { if (rankedList.get(i).getPrice() > rankedList.get(j).getPrice()) { Collections.swap(rankedList, i, j); } } } LinkedList<String> returnHOSTIDList = new LinkedList<String>(); for (HOST currentHOST : rankedList) { returnHOSTIDList.add(currentHOST.getID()); } return returnHOSTIDList; }
From source file:AndroidUninstallStock.java
public static LinkedHashMap<String, String> getLibFromPackage(String adb, LinkedList<String> liblist, LinkedHashMap<String, String> apklist) throws IOException { LinkedHashMap<String, String> libinclude = new LinkedHashMap<String, String>(); File libget = File.createTempFile("AndroidUninstallStockLibs", null); for (Map.Entry<String, String> info : sortByValues(apklist).entrySet()) { System.out.print("* Libs in " + info.getKey() + " (" + info.getValue() + ")"); LinkedList<String> pull = run(adb, "-s", lastdevice, "pull", "\"" + info.getKey() + "\"", "\"" + libget.getCanonicalPath() + "\""); if (pull.size() > 0 && pull.get(0).indexOf("does not exist") > 0) { System.out.println(" - file not exist"); continue; }/*from w ww . j a va 2 s. c om*/ LinkedList<String> libinapk = getLibsInApk(libget.toPath()); if (libinapk.size() == 0) { System.out.println(" - empty"); } else { System.out.println(":"); for (String libpath : libinapk) { String libname = libpath.substring(libpath.lastIndexOf('/') + 1); boolean libfound = false; for (String lb : liblist) { if (lb.indexOf(libname) > -1) { System.out.println(libpath + " = " + lb); libinclude.put(lb, (libinclude.containsKey(libname) ? libinclude.get(libname) + ", " : "") + info.getKey()); libfound = true; } } if (!libfound) { System.out.println(libpath + " = not found"); } } } } try { libget.delete(); } catch (Exception e) { } return libinclude; }
From source file:org.artifactory.api.maven.MavenArtifactInfo.java
public static MavenArtifactInfo fromRepoPath(RepoPath repoPath) { String groupId, artifactId, version, type = MavenArtifactInfo.NA, classifier = MavenArtifactInfo.NA; String path = repoPath.getPath(); String fileName = repoPath.getName(); //The format of the relative path in maven is a/b/c/artifactId/baseVer/fileName where //groupId="a.b.c". We split the path to elements and analyze the needed fields. LinkedList<String> pathElements = new LinkedList<>(); StringTokenizer tokenizer = new StringTokenizer(path, "/"); while (tokenizer.hasMoreTokens()) { pathElements.add(tokenizer.nextToken()); }//from ww w. j a v a2 s . c o m //Sanity check, we need groupId, artifactId and version if (pathElements.size() < 3) { log.debug( "Cannot build MavenArtifactInfo from '{}'. The groupId, artifactId and version are unreadable.", repoPath); return new MavenArtifactInfo(); } //Extract the version, artifactId and groupId int pos = pathElements.size() - 2; // one before the last path element version = pathElements.get(pos--); artifactId = pathElements.get(pos--); StringBuilder groupIdBuff = new StringBuilder(); for (; pos >= 0; pos--) { if (groupIdBuff.length() != 0) { groupIdBuff.insert(0, '.'); } groupIdBuff.insert(0, pathElements.get(pos)); } groupId = groupIdBuff.toString(); //Extract the type and classifier except for metadata files boolean metaData = NamingUtils.isMetadata(fileName); if (!metaData) { if (MavenNaming.isUniqueSnapshotFileName(fileName)) { version = StringUtils.remove(version, "-" + MavenNaming.SNAPSHOT); version = version + "-" + MavenNaming.getUniqueSnapshotVersionTimestampAndBuildNumber(fileName); } type = StringUtils.substring(fileName, artifactId.length() + version.length() + 2); int versionStartIndex = StringUtils.indexOf(fileName, "-", artifactId.length()) + 1; int classifierStartIndex = StringUtils.indexOf(fileName, "-", versionStartIndex + version.length()); if (classifierStartIndex >= 0) { Set<String> customMavenTypes = getMavenCustomTypes(); for (String customMavenType : customMavenTypes) { if (StringUtils.endsWith(fileName, customMavenType)) { classifier = StringUtils.remove(type, "." + customMavenType); type = customMavenType; break; } } if (MavenArtifactInfo.NA.equals(classifier)) { int typeDotStartIndex = StringUtils.lastIndexOf(type, "."); classifier = StringUtils.substring(type, 0, typeDotStartIndex); type = StringUtils.substring(type, classifier.length() + 1); } } } return new MavenArtifactInfo(groupId, artifactId, version, classifier, type); }