本文整理匯總了Java中java.util.ArrayList類的典型用法代碼示例。如果您正苦於以下問題:Java ArrayList類的具體用法?Java ArrayList怎麽用?Java ArrayList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ArrayList類屬於java.util包,在下文中一共展示了ArrayList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: I18nField
import java.util.ArrayList; //導入依賴的package包/類
/**
* Constructeur, initialisation du champs
* @param listeLangueEnService
* @param langueParDefaut
* @param libelleBtnPlus
*/
public I18nField(Langue langueParDefaut, List<Langue> listeLangueEnService, String libelleBtnPlus) {
super();
setRequired(false);
this.langueParDefaut = langueParDefaut;
this.listeLangueEnService = listeLangueEnService;
listLayoutTraductions = new ArrayList<HorizontalLayout>();
listeTraduction = new ArrayList<I18nTraduction>();
layoutComplet = new VerticalLayout();
layoutComplet.setSpacing(true);
layoutLangue = new VerticalLayout();
layoutLangue.setSpacing(true);
layoutComplet.addComponent(layoutLangue);
btnAddLangue = new OneClickButton(libelleBtnPlus,FontAwesome.PLUS_SQUARE_O);
btnAddLangue.setVisible(false);
btnAddLangue.addStyleName(ValoTheme.BUTTON_TINY);
layoutComplet.addComponent(btnAddLangue);
btnAddLangue.addClickListener(e->{
layoutLangue.addComponent(getLangueLayout(null));
checkVisibleAddLangue();
centerWindow();
});
}
示例2: testGetStoppedWebServersAndJvmsCount
import java.util.ArrayList; //導入依賴的package包/類
@Test
public void testGetStoppedWebServersAndJvmsCount() {
when(mockGroupService.getGroups()).thenReturn(new ArrayList<>(groups));
when(mockJvmService.getJvmStoppedCount(anyString())).thenReturn(0L);
when(mockJvmService.getJvmForciblyStoppedCount(anyString())).thenReturn(0L);
when(mockJvmService.getJvmCount(anyString())).thenReturn(1L);
when(mockWebServerService.getWebServerStoppedCount(anyString())).thenReturn(0L);
when(mockWebServerService.getWebServerCount(anyString())).thenReturn(1L);
Response response = groupServiceRest.getStoppedWebServersAndJvmsCount();
assertNotNull(response);
response = groupServiceRest.getStoppedWebServersAndJvmsCount("testGroup");
assertNotNull(response);
}
示例3: main
import java.util.ArrayList; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
ArrayList<Integer> al = new ArrayList<Integer>();
LinkedList<Integer> ll = new LinkedList<Integer>();
for (int i = 0; i < 1000; i++) {
Integer io = i; // box once
al.add(io);
ll.add(io);
}
al.trimToSize();
PrintWriter pw = new PrintWriter(out);
pw.println(GraphLayout.parseInstance(al).toFootprint());
pw.println(GraphLayout.parseInstance(ll).toFootprint());
pw.println(GraphLayout.parseInstance(al, ll).toFootprint());
pw.close();
}
示例4: decode
import java.util.ArrayList; //導入依賴的package包/類
@Override
protected Mp4WebvttSubtitle decode(byte[] bytes, int length, boolean reset)
throws SubtitleDecoderException {
// Webvtt in Mp4 samples have boxes inside of them, so we have to do a traditional box parsing:
// first 4 bytes size and then 4 bytes type.
sampleData.reset(bytes, length);
List<Cue> resultingCueList = new ArrayList<>();
while (sampleData.bytesLeft() > 0) {
if (sampleData.bytesLeft() < BOX_HEADER_SIZE) {
throw new SubtitleDecoderException("Incomplete Mp4Webvtt Top Level box header found.");
}
int boxSize = sampleData.readInt();
int boxType = sampleData.readInt();
if (boxType == TYPE_vttc) {
resultingCueList.add(parseVttCueBox(sampleData, builder, boxSize - BOX_HEADER_SIZE));
} else {
// Peers of the VTTCueBox are still not supported and are skipped.
sampleData.skipBytes(boxSize - BOX_HEADER_SIZE);
}
}
return new Mp4WebvttSubtitle(resultingCueList);
}
示例5: initMcrmbCore
import java.util.ArrayList; //導入依賴的package包/類
public static void initMcrmbCore() {
commentedConfig = ConfigManager.get().getConfig();
config.sid = commentedConfig.getNode("sid").getString();
if (config.sid.equalsIgnoreCase("null")) {
config.sid = null;
}
config.key = commentedConfig.getNode("key").getString();
if (config.key.equalsIgnoreCase("null")) {
config.key = null;
}
config.logApi = commentedConfig.getNode("logApi").getBoolean();
config.renewOnJoin = commentedConfig.getNode("renewOnJoin").getBoolean();
config.opModifyWhiteList = new ArrayList<>();
try {
config.opModifyWhiteList.addAll(commentedConfig.getNode("opModifyWhiteList").getList(TypeToken.of(String.class)));
} catch (ObjectMappingException e) {
}
config.point = commentedConfig.getNode("point").getString().replace("&", "§");
config.prefix = commentedConfig.getNode("prefix").getString().replace("&", "§");
config.command = commentedConfig.getNode("command").getString();
}
示例6: getAllAncestors
import java.util.ArrayList; //導入依賴的package包/類
protected static List<File> getAllAncestors(File base, File file) {
List<File> files = new ArrayList<>();
if (file != null) {
boolean stop = false;
file = file.getParentFile();
while (!stop) {
if (file == null || !file.toPath().startsWith(base.toPath())) {
stop = true;
} else {
files.add(file);
file = file.getParentFile();
}
}
}
return files;
}
示例7: testisSupertypeOf_wildcardType_upperBoundMatch
import java.util.ArrayList; //導入依賴的package包/類
public <N1 extends Number, N2 extends Number, N11 extends N1>
void testisSupertypeOf_wildcardType_upperBoundMatch() {
// ? extends T
assertAssignable(new TypeToken<List<N11>>() {},
new TypeToken<List<? extends N1>>() {});
assertNotAssignable(new TypeToken<List<N1>>() {},
new TypeToken<List<? extends N11>>() {});
assertNotAssignable(new TypeToken<List<Number>>() {},
new TypeToken<List<? extends N11>>() {});
// ? extends Number
assertAssignable(new TypeToken<List<N1>>() {},
new TypeToken<List<? extends Number>>() {});
assertAssignable(new TypeToken<ArrayList<N1>>() {},
new TypeToken<List<? extends Number>>() {});
assertAssignable(new TypeToken<List<? extends N11>>() {},
new TypeToken<List<? extends Number>>() {});
}
示例8: execute
import java.util.ArrayList; //導入依賴的package包/類
public String execute() throws IOException {
UserEntity user = (UserEntity) httpSession.get("userEntity");
String pwd = httpServletRequest.getParameter("pwd");
if (pwd == null || pwd.isEmpty()) {
pwd = folderRepository.getUserRootFolder(user.getUsername(), user.getId()).getId();
}
for (int i = 0; i < file.length; i++) {
FileEntity fileEntity = new FileEntity();
fileEntity.setOwnerId(user.getId());
fileEntity.setFilename(fileFileName[i]);
fileEntity.setContentType(fileContentType[i]);
fileEntity = boxService.upload(fileEntity, file[i]);
System.out.println("1 " + pwd);
FolderEntity folder = folderRepository.findById(pwd);
System.out.println("2 " + folder);
List<String> files = (folder.getFiles() == null) ? new ArrayList<>() : folder.getFiles();
files.add(fileEntity.getId());
folder.setFiles(files);
folderRepository.save(folder);
}
return SUCCESS;
}
示例9: parseIdentities
import java.util.ArrayList; //導入依賴的package包/類
private static List<ImportedIdentity> parseIdentities(XmlPullParser xpp)
throws XmlPullParserException, IOException {
List<ImportedIdentity> identities = null;
int eventType = xpp.next();
while (!(eventType == XmlPullParser.END_TAG && SettingsExporter.IDENTITIES_ELEMENT.equals(xpp.getName()))) {
if (eventType == XmlPullParser.START_TAG) {
String element = xpp.getName();
if (SettingsExporter.IDENTITY_ELEMENT.equals(element)) {
if (identities == null) {
identities = new ArrayList<>();
}
ImportedIdentity identity = parseIdentity(xpp);
identities.add(identity);
} else {
Timber.w("Unexpected start tag: %s", xpp.getName());
}
}
eventType = xpp.next();
}
return identities;
}
示例10: recommendations
import java.util.ArrayList; //導入依賴的package包/類
@Override
public String recommendations() {
List<Metric> metrics = data.entrySet().stream()
.map(entry -> entry.getValue().entrySet().stream()
.map(data -> new Metric(entry.getKey(), data.getKey(), data.getValue()))
.collect(Collectors.toList()))
.collect(ArrayList::new, List::addAll, List::addAll);
Map<String, List<Metric>> runaways = new HashMap<>();
metrics.stream().collect(Collectors.groupingBy(Metric::name)).entrySet().forEach(entry -> {
LongSummaryStatistics statistics = entry.getValue().stream()
.collect(Collectors.summarizingLong(Metric::value));
runaways.put(entry.getKey(),
entry.getValue().stream().filter(metric -> metric.value() <= statistics.getAverage())
.sorted((m1, m2) -> (int) (m1.value() - m2.value())).collect(Collectors.toList()));
});
return this.buildRunaways(runaways);
}
示例11: addOnTextSizeChangeListener
import java.util.ArrayList; //導入依賴的package包/類
/**
* Adds an {@link OnTextSizeChangeListener} to the list of those whose methods are called
* whenever the {@link TextView}'s {@code textSize} changes.
*/
public AutofitHelper addOnTextSizeChangeListener(OnTextSizeChangeListener listener) {
if (mListeners == null) {
mListeners = new ArrayList<OnTextSizeChangeListener>();
}
mListeners.add(listener);
return this;
}
示例12: testEncoding
import java.util.ArrayList; //導入依賴的package包/類
@Test
public void testEncoding() throws ComponentInitializationException, AttributeEncodingException {
init();
IdPAttribute attribute = new IdPAttribute("test");
List<ScopedStringAttributeValue> stringAttributeValues = new ArrayList<ScopedStringAttributeValue>();
stringAttributeValues.add(new ScopedStringAttributeValue("value1", "scope"));
stringAttributeValues.add(new ScopedStringAttributeValue("value2", "scope"));
attribute.setValues(stringAttributeValues);
JSONObject object = encoder.encode(attribute);
Assert.assertTrue(((String) object.get("attributeName")).split(" ")[0].equals("[email protected]"));
Assert.assertTrue(((String) object.get("attributeName")).split(" ")[1].equals("[email protected]"));
Assert.assertTrue(((String) object.get("attributeName")).split(" ").length == 2);
encoder.setScopeDelimiter(":");
encoder.setStringDelimiter(";");
object = encoder.encode(attribute);
Assert.assertTrue(((String) object.get("attributeName")).split(";")[0].equals("value1:scope"));
Assert.assertTrue(((String) object.get("attributeName")).split(";")[1].equals("value2:scope"));
Assert.assertTrue(((String) object.get("attributeName")).split(";").length == 2);
}
開發者ID:CSCfi,項目名稱:shibboleth-idp-oidc-extension,代碼行數:20,代碼來源:OIDCScopedStringAttributeEncoderTest.java
示例13: testGetMarketplacesForService
import java.util.ArrayList; //導入依賴的package包/類
@Test
public void testGetMarketplacesForService() throws Exception {
returnedCatalogEntries = new ArrayList<VOCatalogEntry>();
returnedCatalogEntries.add(localMarketplaceCE);
returnedCatalogEntries.add(globalMarketplaceCE);
VOService service = new VOService();
List<VOCatalogEntry> catalogEntries = bean
.getMarketplacesForService(service);
Assert.assertEquals(service, passedService);
Assert.assertTrue(serviceCalled);
Assert.assertEquals(2, catalogEntries.size());
Assert.assertEquals(localMarketplaceCE.getMarketplace()
.getMarketplaceId(), catalogEntries.get(0).getMarketplace()
.getMarketplaceId());
Assert.assertEquals(globalMarketplaceCE.getMarketplace()
.getMarketplaceId(), catalogEntries.get(1).getMarketplace()
.getMarketplaceId());
serviceCalled = true;
returnedMarketplaces = new ArrayList<VOMarketplace>();
bean.getMarketplacesForSupplier();
Assert.assertTrue(serviceCalled);
}
示例14: createProjectClassLoader
import java.util.ArrayList; //導入依賴的package包/類
private static ClassLoader[] createProjectClassLoader(MavenProjectContext projectContext) {
try {
List<URL> compileJars = new ArrayList<>();
for (String element : projectContext.getProject().getCompileClasspathElements()) {
compileJars.add(new File(element).toURI().toURL());
}
return new ClassLoader[]{
new URLClassLoader(compileJars.toArray(new URL[compileJars.size()]),
MavenEnricherManager.class.getClassLoader())
};
} catch (Exception e) {
projectContext.getLogger().warn("Instructed to use project classpath, but cannot. Continuing build if we can: ", e);
return new ClassLoader[0];
}
}
示例15: createEvaluator
import java.util.ArrayList; //導入依賴的package包/類
private PropertyEvaluator createEvaluator() {
PropertyProvider predefs = helper.getStockPropertyPreprovider();
File dir = getProjectDirectoryFile();
List<PropertyProvider> providers = new ArrayList<PropertyProvider>();
providers.add(helper.getPropertyProvider("nbproject/private/platform-private.properties")); // NOI18N
providers.add(helper.getPropertyProvider("nbproject/platform.properties")); // NOI18N
PropertyEvaluator baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()]));
providers.add(new ApisupportAntUtils.UserPropertiesFileProvider(baseEval, dir));
baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()]));
providers.add(new DestDirProvider(baseEval));
providers.add(helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH));
providers.add(helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH));
Map<String,String> fixedProps = new HashMap<String,String>();
// synchronize with suite.xml
fixedProps.put(SuiteProperties.ENABLED_CLUSTERS_PROPERTY, "");
fixedProps.put(SuiteProperties.DISABLED_CLUSTERS_PROPERTY, "");
fixedProps.put(SuiteProperties.DISABLED_MODULES_PROPERTY, "");
fixedProps.put(SuiteBrandingModel.BRANDING_DIR_PROPERTY, "branding"); // NOI18N
fixedProps.put("suite.build.dir", "build"); // NOI18N
fixedProps.put("cluster", "${suite.build.dir}/cluster"); // NOI18N
fixedProps.put("dist.dir", "dist"); // NOI18N
fixedProps.put("test.user.dir", "${suite.build.dir}/testuserdir"); // NOI18N
providers.add(PropertyUtils.fixedPropertyProvider(fixedProps));
return PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()]));
}