本文整理汇总了Java中java.util.List.get方法的典型用法代码示例。如果您正苦于以下问题:Java List.get方法的具体用法?Java List.get怎么用?Java List.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.List
的用法示例。
在下文中一共展示了List.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clickCountry
import java.util.List; //导入方法依赖的package包/类
private void clickCountry(List<String> countryNames,int i){
String northName = countryNames.get(i);
for (int j = 0; j < mOpenCountries.size(); j++) {
ChooseCountryBean countryBean = mOpenCountries.get(j);
String name = countryBean.getName();
String country_id = countryBean.getCountry_id();
if(northName.equals(name)){
isContains = true;
Intent north = new Intent();
north.putExtra("countryName",northName);
north.putExtra("countryId",country_id);
getActivity().setResult(Activity.RESULT_OK,north);
getActivity().finish();
}
}
if (!isContains){
Toast.makeText(getContext(),"该国家暂时没有开放",Toast.LENGTH_SHORT).show();
}
}
示例2: applyAndUpdate
import java.util.List; //导入方法依赖的package包/类
/**
* Creates a new FilteredBlock from the given Block, using this filter to select transactions. Matches can cause the
* filter to be updated with the matched element, this ensures that when a filter is applied to a block, spends of
* matched transactions are also matched. However it means this filter can be mutated by the operation. The returned
* filtered block already has the matched transactions associated with it.
*/
public synchronized FilteredBlock applyAndUpdate(Block block) {
List<Transaction> txns = block.getTransactions();
List<Sha256Hash> txHashes = new ArrayList<>(txns.size());
List<Transaction> matched = Lists.newArrayList();
byte[] bits = new byte[(int) Math.ceil(txns.size() / 8.0)];
for (int i = 0; i < txns.size(); i++) {
Transaction tx = txns.get(i);
txHashes.add(tx.getHash());
if (applyAndUpdate(tx)) {
Utils.setBitLE(bits, i);
matched.add(tx);
}
}
PartialMerkleTree pmt = PartialMerkleTree.buildFromLeaves(block.getParams(), bits, txHashes);
FilteredBlock filteredBlock = new FilteredBlock(block.getParams(), block.cloneAsHeader(), pmt);
for (Transaction transaction : matched)
filteredBlock.provideTransaction(transaction);
return filteredBlock;
}
示例3: queryLatestEventBefore
import java.util.List; //导入方法依赖的package包/类
/**
* This is used to query a single Event ({@link VaultEntry} before a given point in time.
* This is useful to determine why certain events might have happened (correlation of events).
*
* @param timestamp The point in time to get the preceding event from.
* @param type The Type of {@link VaultEntry} to query for.
* @return The event of the {@link VaultEntryType} preceding the specified point in time.
*/
public VaultEntry queryLatestEventBefore(final Date timestamp, final VaultEntryType type) {
VaultEntry returnValue = null;
try {
PreparedQuery<VaultEntry> query
= vaultDao.queryBuilder().orderBy("timestamp", false)
.limit(1L)
.where()
.eq(VaultEntry.TYPE_FIELD_NAME, type)
.and()
.le(VaultEntry.TIMESTAMP_FIELD_NAME, timestamp)
.prepare();
List<VaultEntry> tmpList = vaultDao.query(query);
if (tmpList.size() > 0) {
returnValue = tmpList.get(0);
}
} catch (SQLException exception) {
LOG.log(Level.SEVERE, "Error while db query", exception);
}
return returnValue;
}
示例4: dispatchBackPress
import java.util.List; //导入方法依赖的package包/类
/**
* 处理fragment回退键
* <p>如果fragment实现了OnBackClickListener接口,返回{@code true}: 表示已消费回退键事件,反之则没消费</p>
* <p>具体示例见FragmentActivity</p>
*
* @param fragmentManager fragment管理器
* @return 是否消费回退事件
*/
public static boolean dispatchBackPress(@NonNull FragmentManager fragmentManager) {
List<Fragment> fragments = fragmentManager.getFragments();
if (fragments == null || fragments.isEmpty()) return false;
for (int i = fragments.size() - 1; i >= 0; --i) {
Fragment fragment = fragments.get(i);
if (fragment != null
&& fragment.isResumed()
&& fragment.isVisible()
&& fragment.getUserVisibleHint()
&& fragment instanceof OnBackClickListener
&& ((OnBackClickListener) fragment).onBackClick()) {
return true;
}
}
return false;
}
示例5: splitProperties
import java.util.List; //导入方法依赖的package包/类
public static String[][] splitProperties(String str) {
Pattern p = Pattern.compile("(,|:)\\s*(([A-Z]|-|_)*)\\s*=");
Matcher matcher = p.matcher(str);
List<String[]> list = new ArrayList<String[]>();
int endIndex = 0;
while (matcher.find()) {
if (list.size() > 0) {
list.get(list.size() - 1)[1] = str.substring(endIndex,
matcher.start()).trim();
}
list.add(new String[2]);
list.get(list.size() - 1)[0] = str.substring(matcher.start() + 1,
matcher.end() - 1).trim();
endIndex = matcher.end();
}
if (list.size() > 0) {
list.get(list.size() - 1)[1] = str.substring(endIndex).trim();
}
return (String[][]) list.toArray(new String[0][2]);
}
示例6: testCreateEnrolmentFutureReservationExists
import java.util.List; //导入方法依赖的package包/类
@Test
@RunAsStudent
public void testCreateEnrolmentFutureReservationExists() throws Exception {
// Setup
reservation.setMachine(room.getExamMachines().get(0));
reservation.setStartAt(DateTime.now().plusDays(1));
reservation.setEndAt(DateTime.now().plusDays(2));
reservation.save();
DateTime enrolledOn = DateTime.now();
enrolment.setEnrolledOn(enrolledOn);
enrolment.setReservation(reservation);
enrolment.save();
// Execute
Result result = request(Helpers.POST,
String.format("/app/enroll/%s/exam/%d", exam.getCourse().getCode(), exam.getId()), null);
assertThat(result.status()).isEqualTo(200);
// Verify
List<ExamEnrolment> enrolments = Ebean.find(ExamEnrolment.class).findList();
assertThat(enrolments).hasSize(1);
ExamEnrolment e = enrolments.get(0);
assertThat(e.getEnrolledOn().isAfter(enrolledOn));
assertThat(e.getReservation()).isNull();
}
示例7: checkSubmittedBean
import java.util.List; //导入方法依赖的package包/类
public void checkSubmittedBean(boolean allowEmpty) throws Exception {
List<StatusBean> statusSet = consumer.getStatusSet();
if (allowEmpty && statusSet.isEmpty()) return;
assertThat(statusSet.get(0), is(instanceOf(DummyOperationBean.class)));
DummyOperationBean operationBean = (DummyOperationBean) statusSet.get(0);
assertThat(operationBean.getDataKey(), is(equalTo(DEFAULT_ENTRY_PATH + GROUP_NAME_SOLSTICE_SCAN)));
assertTrue(operationBean.getFilePath().contains("test_nexus"));
assertTrue(operationBean.getFilePath().endsWith(NEXUS_FILE_EXTENSION));
assertTrue(operationBean.getOutputFilePath().contains("processed"));
assertTrue(operationBean.getOutputFilePath(),
operationBean.getOutputFilePath().endsWith("-"+processingName+NEXUS_FILE_EXTENSION));
assertThat(operationBean.getDatasetPath(), is(equalTo(DEFAULT_ENTRY_PATH + detectorName)));
assertThat(operationBean.getSlicing(), is(nullValue()));
assertThat(operationBean.getProcessingPath(), is(equalTo("/tmp/sum.nxs")));
assertThat(operationBean.isDeleteProcessingFile(), is(false));
assertThat(operationBean.getAxesNames(), is(nullValue()));
assertThat(operationBean.getXmx(), is(equalTo("1024m")));
assertThat(operationBean.getDataDimensions(), is(nullValue()));
assertThat(operationBean.getScanRank(), is(2));
assertThat(operationBean.isReadable(), is(true));
assertThat(System.getProperty("java.io.tmpdir"), startsWith(operationBean.getRunDirectory()));
assertThat(operationBean.getNumberOfCores(), is(1));
}
示例8: next
import java.util.List; //导入方法依赖的package包/类
@Override
public Object[] next() {
Object tuple[] = new Object[columnsNum];
List<String[]> tuples;
if (countryCnt < countrySize) {
tuples = tr_country_file.getTuplesByIndex(countryCnt);
}
else {
tuples = tr_div_file.getTuplesByIndex(divCnt);
}
String[] tr_record = tuples.get(tuplesCnt++);
int col = 0;
tuple[col++] = tr_record[0]; // tr_id
tuple[col++] = tr_record[1]; // tr_name
tuple[col++] = Double.valueOf(tr_record[2]); // tr_rate
if (tuplesCnt == tuples.size()) {
tuplesCnt = 0;
if (countryCnt < countrySize) {
countryCnt++;
}
else {
divCnt++;
}
}
return tuple;
}
示例9: presentParams
import java.util.List; //导入方法依赖的package包/类
/**
* @return a readable String of the parameters and their names
*/
String presentParams() {
StringBuilder sb = new StringBuilder("(");
List<TableParamDef> params = params();
for (int i = 0; i < params.size(); i++) {
TableParamDef paramDef = params.get(i);
if (i != 0) {
sb.append(", ");
}
sb.append(paramDef.getName()).append(": ").append(paramDef.getType().getSimpleName());
}
sb.append(")");
return sb.toString();
}
示例10: getByUID
import java.util.List; //导入方法依赖的package包/类
@Override
public ChatMessage getByUID(Long uid) {
// TODO Auto-generated method stub
List list = doFind(ChatMessageDAO.SQL_QUERY_FIND_MESSAGE_BY_UID, new Object[] { uid });
if ((list != null) && (list.size() > 0)) {
return (ChatMessage) list.get(0);
} else {
return null;
}
}
示例11: createRainflowCounts
import java.util.List; //导入方法依赖的package包/类
private double[][] createRainflowCounts(List<String> values, Map<String, Integer> indexMap) {
double[][] counts = new double[indexMap.size()][indexMap.size()];
int currentIndex = 4;
while (currentIndex < values.size()) {
String value1 = values.get(currentIndex - 4);
String value2 = values.get(currentIndex - 3);
String value3 = values.get(currentIndex - 2);
String value4 = values.get(currentIndex - 1);
boolean betweenIncreasing = value2.compareTo(value1) >= 0 && value2.compareTo(value4) <= 0
&& value3.compareTo(value1) >= 0 && value3.compareTo(value4) <= 0;
boolean betweenDecreasing = value2.compareTo(value1) <= 0 && value2.compareTo(value4) >= 0
&& value3.compareTo(value1) <= 0 && value3.compareTo(value4) >= 0;
if (betweenIncreasing || betweenDecreasing) {
int fromIndex = indexMap.get(value2);
int toIndex = indexMap.get(value3);
counts[fromIndex][toIndex] = counts[fromIndex][toIndex] + 1;
values.remove(currentIndex - 2);
values.remove(currentIndex - 3);
currentIndex = 4;
} else { // nothing found
currentIndex++;
}
}
return counts;
}
示例12: test_getExistingBuildConfigs
import java.util.List; //导入方法依赖的package包/类
/**
* Makes test that configuration configuations are not null
*/
public void test_getExistingBuildConfigs() throws Exception {
final List configurations = configManager.getExistingBuildConfigs();
assertNotNull(configurations);
assertTrue(!configurations.isEmpty()); // this relays on test data populated by DBUnit
final BuildConfig config = (BuildConfig) configurations.get(0);
assertTrue(config.getBuildID() != BuildConfig.UNSAVED_ID);
assertNotNull(config.getBuildName());
}
示例13: getDatasetBuilder
import java.util.List; //导入方法依赖的package包/类
/**
* @return null if datasetPath is not canonical and couldn't find a corresponding table in the source
*/
static DatasetBuilder getDatasetBuilder(
HiveClient client,
String user,
NamespaceKey datasetPath,
boolean isCanonicalDatasetPath,
boolean ignoreAuthzErrors,
HiveConf hiveConf,
DatasetConfig oldConfig) throws TException {
final List<String> noSourceSchemaPath =
datasetPath.getPathComponents().subList(1, datasetPath.getPathComponents().size());
// extract database and table names from dataset path
final String dbName;
final String tableName;
switch (noSourceSchemaPath.size()) {
case 1:
dbName = "default";
tableName = noSourceSchemaPath.get(0);
break;
case 2:
dbName = noSourceSchemaPath.get(0);
tableName = noSourceSchemaPath.get(1);
break;
default:
//invalid.
return null;
}
// if the dataset path is not canonized we need to get it from the source
final Table table;
final String canonicalTableName;
final String canonicalDbName;
if (isCanonicalDatasetPath) {
canonicalDbName = dbName;
canonicalTableName = tableName;
table = null;
} else {
// passed datasetPath is not canonical, we need to get it from the source
table = client.getTable(dbName, tableName, ignoreAuthzErrors);
if(table == null){
return null;
}
canonicalTableName = table.getTableName();
canonicalDbName = table.getDbName();
}
final List<String> canonicalDatasetPath = Lists.newArrayList(datasetPath.getRoot(), canonicalDbName, canonicalTableName);
return new DatasetBuilder(client, user, new NamespaceKey(canonicalDatasetPath), ignoreAuthzErrors, hiveConf, canonicalDbName, canonicalTableName, table, oldConfig);
}
示例14: applyProjection
import java.util.List; //导入方法依赖的package包/类
void applyProjection(List projAttrib, ExecutionContext context, Collection result,
Object iterValue, SelectResults intermediateResults, boolean isIntersection)
throws FunctionDomainException, TypeMismatchException, NameResolutionException,
QueryInvocationTargetException {
if (projAttrib == null) {
iterValue = deserializePdxForLocalDistinctQuery(context, iterValue);
this.addToResultsWithUnionOrIntersection(result, intermediateResults, isIntersection,
iterValue);
} else {
// TODO : Asif : Optimize this . This condition looks ugly.
/*
* if (result instanceof StructBag || result instanceof LinkedStructSet || result instanceof
* LinkedStructBag) {
*/
boolean isStruct = result instanceof SelectResults
&& ((SelectResults) result).getCollectionType().getElementType() != null
&& ((SelectResults) result).getCollectionType().getElementType().isStructType();
if (isStruct) {
int projCount = projAttrib.size();
Object[] values = new Object[projCount];
Iterator projIter = projAttrib.iterator();
int i = 0;
while (projIter.hasNext()) {
Object projDef[] = (Object[]) projIter.next();
values[i] = deserializePdxForLocalDistinctQuery(context,
((CompiledValue) projDef[1]).evaluate(context));
i++;
}
this.addToStructsWithUnionOrIntersection(result, intermediateResults, isIntersection,
values);
} else {
Object[] temp = (Object[]) projAttrib.get(0);
Object val = deserializePdxForLocalDistinctQuery(context,
((CompiledValue) temp[1]).evaluate(context));
this.addToResultsWithUnionOrIntersection(result, intermediateResults, isIntersection, val);
}
}
}
示例15: testDelete
import java.util.List; //导入方法依赖的package包/类
@Test
public void testDelete() {
saveBean("kk");
List<Bean> beanRS = finalDb.findAll(Bean.class);
Bean b = beanRS.get(0);
finalDb.delete(b);
Assert.assertEquals(0, finalDb.findAll(Bean.class).size());
}