本文整理汇总了Java中java.util.Collections.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java Collections.addAll方法的具体用法?Java Collections.addAll怎么用?Java Collections.addAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Collections
的用法示例。
在下文中一共展示了Collections.addAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractNamesFromResults
import java.util.Collections; //导入方法依赖的package包/类
public static List<Map<String, String>> extractNamesFromResults(NodeList results, String[] names) {
Set<String> exNames = new HashSet<>();
List<Map<String, String>> values = new ArrayList<>();
Collections.addAll(exNames, names);
for (int i = 0; i < results.getLength(); i++) {
NodeList bindings = ((Element) results.item(i)).getElementsByTagName("binding");
Map<String, String> value = new HashMap<>();
for (int j = 0; j < bindings.getLength(); j++) {
Element binding = (Element) bindings.item(j);
String var = binding.getAttribute("name");
if (exNames.contains(var)) {
String uri = SparqlExecutor.getTagValue("uri", binding);
if (!(uri == null))
value.put(var, FreebaseInfo.uri2id(uri));
}
}
if (value.size() == exNames.size())
values.add(value);
}
return values;
}
示例2: getSQLKeywords
import java.util.Collections; //导入方法依赖的package包/类
/**
* Get a comma separated list of all a database's SQL keywords that are NOT also SQL92/SQL2003 keywords.
*
* @return the list
* @throws SQLException
*/
public String getSQLKeywords() throws SQLException {
if (mysqlKeywords != null) {
return mysqlKeywords;
}
synchronized (DatabaseMetaData.class) {
// double check, maybe it's already set
if (mysqlKeywords != null) {
return mysqlKeywords;
}
Set<String> mysqlKeywordSet = new TreeSet<String>();
StringBuilder mysqlKeywordsBuffer = new StringBuilder();
Collections.addAll(mysqlKeywordSet, MYSQL_KEYWORDS);
mysqlKeywordSet.removeAll(Arrays.asList(Util.isJdbc4() ? SQL2003_KEYWORDS : SQL92_KEYWORDS));
for (String keyword : mysqlKeywordSet) {
mysqlKeywordsBuffer.append(",").append(keyword);
}
mysqlKeywords = mysqlKeywordsBuffer.substring(1);
return mysqlKeywords;
}
}
示例3: writePrefs
import java.util.Collections; //导入方法依赖的package包/类
public void writePrefs(String filename) {
data.add(Game.VERSION);
data.add(String.valueOf(Settings.get("sound")));
data.add(String.valueOf(Settings.get("autosave")));
data.add(String.valueOf(Settings.get("fps")));
data.add(MultiplayerMenu.savedIP);
data.add(MultiplayerMenu.savedUUID);
data.add(MultiplayerMenu.savedUsername);
List<String> keyPairs = new ArrayList<>();
Collections.addAll(keyPairs, Game.input.getKeyPrefs());
data.add(String.join(":", keyPairs.toArray(new String[keyPairs.size()])));
writeToFile(location + filename + extension, data);
}
示例4: runTest
import java.util.Collections; //导入方法依赖的package包/类
private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {
ArrayList<String> vmOpts = new ArrayList();
Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*"));
Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
"-XX:+VerifyDuringStartup",
"-XX:+VerifyBeforeGC",
"-XX:+VerifyAfterGC",
(verifySilently ? "-Xlog:gc":"-Xlog:gc+verify=debug"),
RunSystemGC.class.getName()});
ProcessBuilder pb =
ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println("Output:\n" + output.getOutput());
return output;
}
示例5: addInformation
import java.util.Collections; //导入方法依赖的package包/类
/**
* allows items to add custom lines of information to the mouseover description
*/
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack remote, World world, List<String> curInfo, ITooltipFlag moreInfo) {
super.addInformation(remote, world, curInfo, moreInfo);
curInfo.add(I18n.format("gui.remote.tooltip.sneakRightClickToEdit"));
NBTTagCompound tag = remote.getTagCompound();
if (tag != null && tag.hasKey("securityX")) {
int x = tag.getInteger("securityX");
int y = tag.getInteger("securityY");
int z = tag.getInteger("securityZ");
int dimensionId = tag.getInteger("securityDimension");
Collections.addAll(curInfo, WordUtils.wrap(I18n.format("gui.remote.tooltip.boundToSecurityStation", dimensionId, x, y, z), 40).split(System.getProperty("line.separator")));
} else {
Collections.addAll(curInfo, WordUtils.wrap(I18n.format("gui.remote.tooltip.rightClickToBind"), 40).split(System.getProperty("line.separator")));
}
}
示例6: createFilterSet
import java.util.Collections; //导入方法依赖的package包/类
private Set<Filter> createFilterSet(String subscriptionId,
String activationTime, String customerId, String customerName,
String ServiceId) {
final Filter subscriptionFilter = new Filter(
TableColumns.SUBSCRIPTION_ID, subscriptionId);
final Filter actTimeFilter = new Filter(TableColumns.ACTIVATION_TIME,
activationTime);
final Filter orgIdFilter = new Filter(TableColumns.CUSTOMER_ID,
customerId);
final Filter orgNameFilter = new Filter(TableColumns.CUSTOMER_NAME,
customerName);
final Filter productIdFilter = new Filter(TableColumns.SERVICE_ID,
ServiceId);
Set<Filter> filterSet = new HashSet<>();
Collections.addAll(filterSet, subscriptionFilter, actTimeFilter,
orgIdFilter, orgNameFilter, productIdFilter);
return filterSet;
}
示例7: listFiles
import java.util.Collections; //导入方法依赖的package包/类
private static Set<File> listFiles(final File folder) {
Set<File> files = new HashSet<File>();
if(folder.isDirectory()) {
final File[] children = folder.listFiles();
if(null == children) {
return files;
}
Collections.addAll(files, children);
}
return files;
}
示例8: addToolSpecificArgs
import java.util.Collections; //导入方法依赖的package包/类
protected void addToolSpecificArgs(T spec, List<String> args) {
Collections.addAll(args, "-x", getLanguage());
args.add("-c");
if (spec.isPositionIndependentCode()) {
if (!spec.getTargetPlatform().getOperatingSystem().isWindows()) {
args.add("-fPIC");
}
}
}
示例9: addUserHashBlackList
import java.util.Collections; //导入方法依赖的package包/类
public DanmakuContext addUserHashBlackList(String... hashes) {
if (!(hashes == null || hashes.length == 0)) {
Collections.addAll(this.mUserHashBlackList, hashes);
setFilterData(DanmakuFilters.TAG_USER_HASH_FILTER, this.mUserHashBlackList);
this.mGlobalFlagValues.updateFilterFlag();
notifyConfigureChanged(DanmakuConfigTag.USER_HASH_BLACK_LIST, this.mUserHashBlackList);
}
return this;
}
示例10: concurrentSkipListMultisetGenerator
import java.util.Collections; //导入方法依赖的package包/类
private static TestStringMultisetGenerator concurrentSkipListMultisetGenerator() {
return new TestStringMultisetGenerator() {
@Override protected Multiset<String> create(String[] elements) {
Multiset<String> multiset = new ConcurrentHashMultiset<String>(
new ConcurrentSkipListMap<String, AtomicInteger>());
Collections.addAll(multiset, elements);
return multiset;
}
@Override
public List<String> order(List<String> insertionOrder) {
return Ordering.natural().sortedCopy(insertionOrder);
}
};
}
示例11: newHashSet
import java.util.Collections; //导入方法依赖的package包/类
/**
* Creates a new HashSet and adds the passed arguments to it.
*
* @param items The items to add to the set.
* @param <T> The type of the set to be created.
* @return A typed set that contains the passed arguments.
*/
@SafeVarargs
static <T> HashSet<T> newHashSet(T... items) {
HashSet<T> result = new HashSet<>((items != null) ? items.length : 0);
if (items != null) {
Collections.addAll(result, items);
}
return result;
}
示例12: getOptionsAsSet
import java.util.Collections; //导入方法依赖的package包/类
/**
* @return All of the option names, as a set.
*/
@Transient
public Set<String> getOptionsAsSet() {
final Set<String> set = new HashSet<>();
Collections.addAll(set, getOptions().split(","));
return set;
}
示例13: addIds
import java.util.Collections; //导入方法依赖的package包/类
/**
* Adds ids to the query.
*/
public IdsQueryBuilder addIds(String... ids) {
if (ids == null) {
throw new IllegalArgumentException("[" + NAME + "] ids cannot be null");
}
Collections.addAll(this.ids, ids);
return this;
}
示例14: findMethodByReturnType
import java.util.Collections; //导入方法依赖的package包/类
/**
* find method by return value
*
* @param type type of returned value
* @return RefMethod
* @throws RuntimeException if method not found
*/
public RefMethod findMethodByReturnType(Class type) {
if (type == null) type = void.class;
List<Method> methods = new ArrayList<>();
Collections.addAll(methods, clazz.getMethods());
Collections.addAll(methods, clazz.getDeclaredMethods());
for (Method m : methods) {
if (type.equals(m.getReturnType())) {
return new RefMethod(m);
}
}
throw new RuntimeException("no such method");
}
示例15: validatedDependents
import java.util.Collections; //导入方法依赖的package包/类
private List<String> validatedDependents( String dependent, String... otherDependents ) {
List<String> dependents = new ArrayList<String>();
dependents.add( dependent );
Collections.addAll( dependents, otherDependents );
for ( String each : dependents ) {
if ( !parser.isRecognized( each ) )
throw new UnconfiguredOptionException( each );
}
return dependents;
}