本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}