當前位置: 首頁>>代碼示例>>Java>>正文


Java List類代碼示例

本文整理匯總了Java中java.util.List的典型用法代碼示例。如果您正苦於以下問題:Java List類的具體用法?Java List怎麽用?Java List使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


List類屬於java.util包,在下文中一共展示了List類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findAddressesByApplication

import java.util.List; //導入依賴的package包/類
public List<String> findAddressesByApplication(String application) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if(consumerUrls == null) return ret;
    
    for(Map.Entry<String, Map<Long, URL>> e1 : consumerUrls.entrySet()) {
        Map<Long, URL> value = e1.getValue();
        for(Map.Entry<Long, URL> e2 : value.entrySet()) {
            URL u = e2.getValue();
            if(application.equals(u.getParameter(Constants.APPLICATION_KEY))) {
                String addr = u.getAddress();
                if(addr != null) ret.add(addr);
            }
        }
    }
    
    return ret;
}
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:19,代碼來源:ConsumerServiceImpl.java

示例2: getParameters

import java.util.List; //導入依賴的package包/類
private boolean getParameters(String parameter, List<Integer> parsedParams)
{
    String[] params = parameter.split(" ");
    if (params.length != 2)
    {
        System.out.println("Malformed parameter string (" + parameter + ") - expected <x> <y>");
        return false;   // Error - incorrect number of parameters.
    }
    Integer lhs, rhs;
    try
    {
        lhs = Integer.valueOf(params[0]);
        rhs = Integer.valueOf(params[1]);
    }
    catch (NumberFormatException e)
    {
        System.out.println("Malformed parameter string (" + parameter + ") - " + e.getMessage());
        return false;
    }
    if (lhs == null || rhs == null)
    {
        System.out.println("Malformed parameter string (" + parameter + ")");
        return false;   // Error - incorrect parameters.
    }
    InventoryPlayer inv = Minecraft.getMinecraft().thePlayer.inventory;
    if (lhs < 0 || lhs >= inv.getSizeInventory() || rhs < 0 || rhs >= inv.getSizeInventory())
    {
        System.out.println("Inventory swap parameters out of bounds - must be between 0 and " + (inv.getSizeInventory() - 1));
        return false;   // Out of bounds.
    }
    parsedParams.add(lhs);
    parsedParams.add(rhs);
    return true;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:35,代碼來源:InventoryCommandsImplementation.java

示例3: list

import java.util.List; //導入依賴的package包/類
public List<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException {
    if (recurse) {
        throw new UnsupportedEncodingException();
    }
    final List<JavaFileObject> result = new LinkedList<JavaFileObject> ();        
    if (location == StandardLocation.SOURCE_PATH) {
        final List<Integer> pkglst = packages.get(packageName);
        if (pkglst != null) {
            for (Integer foid : pkglst) {
                InferableJavaFileObject jfo = content.get(foid);
                assert jfo != null;
                if (kinds.contains(jfo.getKind())) {
                    result.add(jfo);
                }
            }
        }
    }
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:MemoryFileManager.java

示例4: readGraph

import java.util.List; //導入依賴的package包/類
@Override
public Graph readGraph(List<Path> files) throws IOException, IllegalArgumentException {
    if (files == null || files.isEmpty()) {
        throw new IllegalArgumentException("No files given to read in.");
    }
    Graph graph = new Graph(settings);

    BufferedReader reader = new BufferedReader(new FileReader(files.get(0).toFile()));

    String currentLine = reader.readLine();
    while (currentLine != null) {
        // read in the nodes of the graph
        if (currentLine.startsWith("Nodes:")) {
            extractNodes(graph, reader);
        }

        // read in the edges of the graph
        if (currentLine.startsWith("Edges:")) {
            extractEdges(graph, reader);
        }

        currentLine = reader.readLine();
    }

    return graph;
}
 
開發者ID:emufog,項目名稱:emufog,代碼行數:27,代碼來源:BriteFormatReader.java

示例5: getEmpList

import java.util.List; //導入依賴的package包/類
public List<Emp> getEmpList() throws SQLException
{
	
	List<Emp> empList = new ArrayList<>();
	DBHelper db = DBHelper.getInstance();
	Connection conn = db.getConnection();
	ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM emp");

	Emp emp = null;
	while(rs.next())
	{
		int empno = rs.getInt("empno");
		String name = rs.getString(2);
		String job = rs.getString(3);
		int mgr = rs.getInt(4);
		String hiredate = rs.getString(5);
		double sal = rs.getDouble(6);
		double comm = rs.getDouble(7);
		int deptno = rs.getInt("deptno");
		empList.add(new Emp(empno, name, job, mgr, hiredate, sal, comm, deptno));
	}	
	db.closeConnection(conn);
	return empList;
}
 
開發者ID:JAVA201708,項目名稱:Homework,代碼行數:25,代碼來源:HOMEWORK.java

示例6: shouldConnectOnlyResponsesRelatedToExpression

import java.util.List; //導入依賴的package包/類
@Test
public void shouldConnectOnlyResponsesRelatedToExpression() throws Exception {
    // given
    String template = "template";
    ExpressionBean expressionBean = new ExpressionBean();
    expressionBean.setTemplate(template);

    Response relatedResponse = Mockito.mock(Response.class);
    Response unrelatedResponse = Mockito.mock(Response.class);

    when(itemResponseManager.getVariable("relatedResponse")).thenReturn(relatedResponse);
    when(itemResponseManager.getVariable("unrelatedResponse")).thenReturn(unrelatedResponse);

    when(identifiersFromExpressionExtractor.extractResponseIdentifiersFromTemplate(template)).thenReturn(
            Lists.newArrayList("relatedResponse", "notExistingId"));

    // when
    expressionToResponseConnector.connectResponsesToExpression(expressionBean, itemResponseManager);

    // then
    verify(identifiersFromExpressionExtractor).extractResponseIdentifiersFromTemplate(template);
    verify(relatedResponse).setExpression(expressionBean);
    List<Response> connectedResponses = expressionBean.getResponses();
    assertEquals(1, connectedResponses.size());
    assertEquals(relatedResponse, connectedResponses.get(0));
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:27,代碼來源:ExpressionToResponseConnectorJUnitTest.java

示例7: getBodyRefreshCounts

import java.util.List; //導入依賴的package包/類
public int[] getBodyRefreshCounts() {
    List<TableRowComponent> tableRows = getTableRows();
    int[] counts = new int[tableRows.size()];
    for (int i = 0; i < tableRows.size(); i++) {
        counts[i] = tableRows.get(i).getRefreshCount();
    }
    return counts;
}
 
開發者ID:Nordstrom,項目名稱:Selenium-Foundation,代碼行數:9,代碼來源:TableComponent.java

示例8: idOfClosest

import java.util.List; //導入依賴的package包/類
public static Integer idOfClosest(final List<DateTime> list, final DateTime key, final int low, final int high) {
    // Cas particuliers
    if (list == null || list.isEmpty() || key == null || low > high) {
        return null;
    }
    // Evacuation des cas où la valeur serait hors de l'intervalle -----------
    if (list.size() == 1) {
        return 0;
    }
    if (list.get(low).getMillis() >= key.getMillis()) {
        return low;
    }
    if (list.get(high).getMillis() <= key.getMillis()) {
        return high;
    }

    int idx = binarySearch(list, key, low, high);
    if (idx < 0) {
        idx = -(idx) - 1;
        if (idx != 0 && idx < list.size()) {
            return (key.getMillis()  - list.get(idx - 1).getMillis()  <= list.get(idx).getMillis() - key.getMillis() ) ? idx - 1 : idx;
        }
        return null;
    }
    return idx;
}
 
開發者ID:iapafoto,項目名稱:DicomViewer,代碼行數:27,代碼來源:SortedListTools.java

示例9: demoListIterRemove

import java.util.List; //導入依賴的package包/類
private static void demoListIterRemove(List<String> list) {
    System.out.println("list: " + list);
    try {
        Iterator iter = list.iterator();
        while (iter.hasNext()) {
            String e = (String) iter.next();
            System.out.println(e);
            if ("Two".equals(e)) {
                System.out.println("Calling iter.remove()...");
                iter.remove();
            }
        }
    } catch (Exception ex) {
        System.out.println(ex.getClass().getName());
    }
    System.out.println("list: " + list);
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Cookbook,代碼行數:18,代碼來源:Chapter07Concurrency02.java

示例10: getSetupClauses

import java.util.List; //導入依賴的package包/類
/**
 * Ritorna la lista di YadaClause trovate nella configurazione
 */
public List<YadaClause> getSetupClauses() {
	List<YadaClause> result = new ArrayList<YadaClause>();
	for (ImmutableHierarchicalConfiguration sub : configuration.immutableConfigurationsAt("config/setup/clauses")) {
		for (Iterator<String> names = sub.getKeys(); names.hasNext();) {
			String name = names.next();
			String content = sub.getString(name);
			YadaClause clause = new YadaClause();
			clause.setName(name);
			clause.setContent(content.trim().replaceAll("\\s+", " ")); // Collasso gli spazi multipli in spazio singolo
			clause.setClauseVersion(1);
			result.add(clause);
		}
	}
	return result;
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:19,代碼來源:YadaConfiguration.java

示例11: performFiltering

import java.util.List; //導入依賴的package包/類
@Override
protected FilterResults performFiltering(CharSequence constraint) {
    final List<String> list;

    if (TextUtils.isEmpty(constraint)) {
        list = mItems;
    } else {
        list = new ArrayList<>();
        final String normalizedConstraint = Normalizer.forSearch(constraint);
        for (String item : mItems) {
            final String normalizedItem = Normalizer.forSearch(item);
            if (normalizedItem.startsWith(normalizedConstraint) || //
                    normalizedItem.contains(" " + normalizedConstraint)) {
                list.add(item);
            }
        }
    }

    final FilterResults results = new FilterResults();
    results.values = list;
    results.count = list.size();
    return results;
}
 
開發者ID:cyrilmottier,項目名稱:QueryHighlighter,代碼行數:24,代碼來源:MainActivity.java

示例12: testRestartConnectorLeaderRedirect

import java.util.List; //導入依賴的package包/類
@Test
public void testRestartConnectorLeaderRedirect() throws Throwable {
    final Capture<Callback<Void>> cb = Capture.newInstance();
    herder.restartConnector(EasyMock.eq(CONNECTOR_NAME), EasyMock.capture(cb));
    expectAndCallbackNotLeaderException(cb);

    EasyMock.expect(RestServer.httpRequest(EasyMock.eq("http://leader:8083/connectors/" + CONNECTOR_NAME + "/restart?forward=true"),
            EasyMock.eq("POST"), EasyMock.isNull(), EasyMock.<TypeReference>anyObject()))
            .andReturn(new RestServer.HttpResponse<>(202, new HashMap<String, List<String>>(), null));

    PowerMock.replayAll();

    connectorsResource.restartConnector(CONNECTOR_NAME, null);

    PowerMock.verifyAll();
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:17,代碼來源:ConnectorsResourceTest.java

示例13: getUCCList

import java.util.List; //導入依賴的package包/類
public List<ColumnCombinationBitset> getUCCList() {
    List<ColumnCombinationBitset> uccList = new LinkedList<>();
    uccList.add(new ColumnCombinationBitset(0));
    uccList.add(new ColumnCombinationBitset(1));
    uccList.add(new ColumnCombinationBitset(2, 3, 5));
    uccList.add(new ColumnCombinationBitset(2, 4, 5));
    uccList.add(new ColumnCombinationBitset(5, 7));
    return uccList;
}
 
開發者ID:HPI-Information-Systems,項目名稱:metanome-algorithms,代碼行數:10,代碼來源:FDminimizerShadowedFDFixture.java

示例14: test

import java.util.List; //導入依賴的package包/類
@Override
public boolean test(final List<Expressie> argumenten, final Context context) {
    boolean match = false;
    if (argumenten != null && argumenten.size() == AANTAL_ARGUMENTEN) {
        match = argumenten.get(1).isVariabele();
    }
    return match;
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:9,代碼來源:ExistentieleFunctieSignatuur.java

示例15: getAllCourseLevelSessions

import java.util.List; //導入依賴的package包/類
/**
 * GET  /courseLevelSessions -> get all the courseLevelSessions.
 */
@RequestMapping(value = "/courseLevelSessions",
    method = RequestMethod.GET,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<CourseLevelSession> getAllCourseLevelSessions() {
    log.debug("REST request to get all CourseLevelSessions");
    return courseLevelSessionRepository.findAll();
}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:12,代碼來源:CourseLevelSessionResource.java


注:本文中的java.util.List類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。