List of usage examples for java.util List addAll
boolean addAll(Collection<? extends E> c);
From source file:net.ostis.scpdev.debug.ui.actions.AbstractBreakpointRulerAction.java
/** * @param resource may be the file open in the editor or the workspace root (if it is an * external file)// w w w.java 2s . c o m * @param document is the document opened in the editor * @param externalFileEditorInput is not-null if this is an external file * @param info is the vertical ruler info (only used if this is not an external file) * @param onlyIncludeLastLineActivity if only the markers that are in the last mouse-click * should be included * * @return the markers that correspond to the markers from the current editor. */ public static List<IMarker> getMarkersFromEditorResource(IResource resource, IDocument document, int lastLineActivity, boolean onlyIncludeLastLineActivity) { List<IMarker> breakpoints = new ArrayList<IMarker>(); try { List<IMarker> markers = new ArrayList<IMarker>(); markers.addAll(Arrays .asList(resource.findMarkers(SCPLineBreakpoint.ID_MARKER, true, IResource.DEPTH_INFINITE))); IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); for (IMarker marker : markers) { if (marker == null) { continue; } IBreakpoint breakpoint = breakpointManager.getBreakpoint(marker); if (breakpoint != null && breakpointManager.isRegistered(breakpoint)) { Position pos = getMarkerPosition(document, marker); if (!onlyIncludeLastLineActivity) { breakpoints.add(marker); } else if (includesRulerLine(pos, document, lastLineActivity)) { breakpoints.add(marker); } } } } catch (CoreException x) { log.error("Unexpected getMarkers error (recovered properly)", x); } return breakpoints; }
From source file:com.aionemu.packetsamurai.utils.collector.data.npcskills.NpcSkillsTool.java
public static void save() { ObjectFactory objFactory = new ObjectFactory(); NpcSkillTemplates collection = objFactory.createNpcSkillTemplates(); List<NpcSkillList> templateList = collection.getNpcskills(); templateList.addAll(skillsByNpcId.values()); Collections.sort(templateList); NpcSkillTemplate total = new NpcSkillTemplate(); total.setSkillid(0);//from w w w .j a va 2 s . co m List<NpcSkillList> toRemove = new ArrayList<NpcSkillList>(); for (NpcSkillList skillList : templateList) { HashMap<IntRange, Integer> useCounts = new HashMap<IntRange, Integer>(); HashMap<NpcSkillTemplate, Integer> skillCounts = new HashMap<NpcSkillTemplate, Integer>(); NpcSkillTemplate totalAttacks = null; int index = 0; if (skillList.getNpcskill().contains(total)) { totalAttacks = skillList.getNpcskill().get(index); index = skillList.getNpcskill().indexOf(total); skillList.getNpcskill().remove(index); } int useTotal = 0; int skillUseTotal = 0; for (NpcSkillTemplate template : skillList.getNpcskill()) skillUseTotal += template.getStats().useCount; if (totalAttacks != null) { useTotal = totalAttacks.getStats().useCount; if (skillUseTotal > useTotal) useTotal = skillUseTotal; } else { useTotal = skillUseTotal; } if (skillList.getNpcskill().size() == 0) { toRemove.add(skillList); continue; } else if (useTotal == 0) { // old data from XML continue; } for (NpcSkillTemplate template : skillList.getNpcskill()) { if (useTotal < MAX_HITS_PER_NPC) { if (template.getStats().maxHp > 90) template.setMaxhp(100); else if (template.getMaxhp() == null || template.getMaxhp() < template.getStats().maxHp) template.setMaxhp(template.getStats().maxHp); if (template.getStats().minHp < 10) template.setMinhp(0); else if (template.getMinhp() == null || template.getMinhp() > template.getStats().minHp) template.setMinhp(template.getStats().minHp); } else { IntRange hpRange = new IntRange(template.getStats().minHp, template.getStats().maxHp); if (useCounts.containsKey(hpRange)) { int oldCounts = useCounts.get(hpRange); useCounts.put(hpRange, oldCounts + template.getStats().useCount); } else useCounts.put(hpRange, template.getStats().useCount); skillCounts.put(template, template.getStats().useCount); } if (useTotal >= MAX_HITS_PER_NPC) template.setProbability(Math.round((float) template.getStats().useCount * 100 / useTotal)); else { template.setProbability(25); } } } templateList.removeAll(toRemove); try { JAXBContext jaxbContext = JAXBContext .newInstance("com.aionemu.packetsamurai.utils.collector.data.npcskills"); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(collection, new FileOutputStream("data/npc_skills/npc_skills.xml")); } catch (PropertyException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (JAXBException e) { e.printStackTrace(); } PacketSamurai.getUserInterface().log("Skills [Npcs] - Saved : " + templateList.size() + " Npc Skills!"); }
From source file:app.commons.ReflectionUtils.java
public static Field[] getAllDeclaredFields(Class clazz) { Class currentClass = clazz;// www . j a v a 2 s . com List<Field> fields = new ArrayList<Field>(); while (currentClass != null) { fields.addAll(Arrays.asList(currentClass.getDeclaredFields())); currentClass = currentClass.getSuperclass(); } return fields.toArray(new Field[fields.size()]); }
From source file:Main.java
private static List<Class> findClasses(File directory, String packageName) { List<Class> classes = new ArrayList<Class>(); if (!directory.exists()) { return classes; }/*from w w w. j a v a 2 s. com*/ File[] files = directory.listFiles(); for (File file : files) { if (file.isDirectory()) { assert !file.getName().contains("."); classes.addAll(findClasses(file, packageName + "." + file.getName())); } else if (file.getName().endsWith(".class")) { try { classes.add(Class .forName(packageName + '.' + file.getName().substring(0, file.getName().length() - 6))); } catch (ClassNotFoundException e) { e.printStackTrace(); } } } return classes; }
From source file:com.erudika.para.persistence.AWSDynamoUtils.java
/** * Lists all table names for this account. * @return a list of DynamoDB tables/*from w w w . j a v a 2s.c o m*/ */ public static List<String> listAllTables() { ListTablesResult ltr = getClient().listTables(100); List<String> tables = new LinkedList<String>(); String lastKey; do { tables.addAll(ltr.getTableNames()); lastKey = ltr.getLastEvaluatedTableName(); } while (!(ltr = getClient().listTables(lastKey, 100)).getTableNames().isEmpty()); return tables; }
From source file:org.jetbrains.webdemo.executors.JunitExecutor.java
private static List<Class> getAllClassesFromTheDir(File directory, String prefix) { List<Class> classes = new ArrayList<Class>(); prefix += directory.getName() + "."; for (File file : directory.listFiles()) { if (file.isDirectory()) { classes.addAll(getAllClassesFromTheDir(file, prefix)); } else {/*from w ww .ja v a2 s. c o m*/ if (file.getName().endsWith(".class")) { try { classes.add(Class.forName( prefix + file.getName().substring(0, file.getName().length() - ".class".length()))); } catch (ClassNotFoundException e) { } } } } return classes; }
From source file:org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT.java
@ParametersFactory public static Iterable<Object[]> parameters() throws Exception { List<NamedXContentRegistry.Entry> entries = new ArrayList<>( ExecutableSection.DEFAULT_EXECUTABLE_CONTEXTS.size() + 1); entries.addAll(ExecutableSection.DEFAULT_EXECUTABLE_CONTEXTS); entries.add(new NamedXContentRegistry.Entry(ExecutableSection.class, new ParseField("compare_analyzers"), CompareAnalyzers::parse));/*from ww w. jav a 2 s. c o m*/ NamedXContentRegistry executeableSectionRegistry = new NamedXContentRegistry(entries); return ESClientYamlSuiteTestCase.createParameters(executeableSectionRegistry); }
From source file:com.mmj.app.common.file.ExcelUtils.java
public static Field[] getAllFields(List<Field> fields, Class<?> type) { for (Field field : type.getDeclaredFields()) { fields.add(field);// w ww. j av a 2 s . c om } if (type.getSuperclass() != null) { fields.addAll(Arrays.asList(getAllFields(fields, type.getSuperclass()))); } return fields.toArray(new Field[fields.size()]); }
From source file:com.opensymphony.xwork2.util.AnnotationUtils.java
/** * * @param clazz The {@link Class} to inspect * @param allInterfaces list of all interfaces *///from ww w. j a v a 2 s. c o m public static void addAllInterfaces(Class clazz, List<Class> allInterfaces) { if (clazz == null) { return; } Class[] interfaces = clazz.getInterfaces(); allInterfaces.addAll(Arrays.asList(interfaces)); addAllInterfaces(clazz.getSuperclass(), allInterfaces); }
From source file:alluxio.client.file.FileSystemTestUtils.java
/** * Returns a list of files at a given {@code path}. * * @param fs a {@link FileSystem} handler * @param path a path in alluxio file system * @return a list of strings representing the file names under the given path *///from ww w. j a va 2s. c om public static List<String> listFiles(FileSystem fs, String path) { try { List<URIStatus> statuses = fs.listStatus(new AlluxioURI(path)); List<String> res = new ArrayList<>(); for (URIStatus status : statuses) { res.add(status.getPath()); if (status.isFolder()) { res.addAll(listFiles(fs, status.getPath())); } } return res; } catch (IOException | AlluxioException e) { throw new RuntimeException(e); } }