Java Code Examples for java.util.ArrayList#addAll()

The following examples show how to use java.util.ArrayList#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReferenceCountingReadOnlyIndexReaderFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private String[] getStringValues(int n, String fieldName) throws IOException
{
    Document document = document(n);
    ArrayList<Field> fields = new ArrayList<Field>();
    ArrayList<String> answer = new ArrayList<String>(2);
    fields.addAll((List<Field>) document.getFields());

    for (Field field : fields)
    {
        if (field.name().equals(fieldName))
        {
            answer.add(field.stringValue());
        }
    }

    return answer.toArray(new String[answer.size()]);
}
 
Example 2
Source File: EnvLoader.java    From baratine with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Starts the current environment.
 */
public static void stop(ClassLoader loader)
{
  for (; loader != null; loader = loader.getParent()) {
    if (loader instanceof EnvironmentClassLoader) {
      ((EnvironmentClassLoader) loader).stop();
      return;
    }
  }

  ArrayList<EnvLoaderListener> listeners;
  listeners = new ArrayList<EnvLoaderListener>();
  listeners.addAll(_globalEnvironmentListeners);
  _globalEnvironmentListeners.clear();

  for (int i = 0; i < listeners.size(); i++) {
    EnvLoaderListener listener = listeners.get(i);

    listener.environmentStop(null);
  }
}
 
Example 3
Source File: InvokableTypeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Shared implementation of {@linkplain ClassType#allMethods()} and
 * {@linkplain InterfaceType#allMethods()}
 * @return A list of all methods (recursively)
 */
public final List<Method> allMethods() {
    ArrayList<Method> list = new ArrayList<>(methods());
    ClassType clazz = superclass();
    while (clazz != null) {
        list.addAll(clazz.methods());
        clazz = clazz.superclass();
    }
    /*
     * Avoid duplicate checking on each method by iterating through
     * duplicate-free allInterfaces() rather than recursing
     */
    for (InterfaceType interfaze : getAllInterfaces()) {
        list.addAll(interfaze.methods());
    }
    return list;
}
 
Example 4
Source File: DataMover.java    From tuffylite with Apache License 2.0 6 votes vote down vote up
public double getMLEProb(Collection<GAtom> atoms, Set<Component> components, BitSet world){

		ArrayList<Partition> parts = new ArrayList<Partition>();
		for(Component c : components){
			parts.addAll(c.parts);
		}

		double rs = 0;

		for(Partition p : parts){

			BitSet conf = new BitSet(atoms.size()+1);
			for(Integer atom : p.mrf.getCoreAtoms()){
				if(p.mrf.atoms.get(atom).truth == true){
					conf.set(atom);
				}
			}

			rs += wordLogPF.get(p).get(conf);
		}

		rs -= wholeLogPF;

		return Math.exp(rs);
	}
 
Example 5
Source File: IgniteBinaryObjectQueryArgumentsTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @return Cache configurations.
 */
private CacheConfiguration[] getCacheConfigurations() {
    final ArrayList<CacheConfiguration> ccfgs = new ArrayList<>();

    ccfgs.add(getCacheConfiguration(OBJECT_CACHE));
    ccfgs.addAll(getCacheConfigurations(STR_CACHE, String.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(PRIM_CACHE, Integer.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(ENUM_CACHE, EnumKey.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(UUID_CACHE, UUID.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(DATE_CACHE, Date.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(TIMESTAMP_CACHE, Timestamp.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(BIG_DECIMAL_CACHE, BigDecimal.class, Person.class));
    ccfgs.add(getCacheConfiguration(FIELD_CACHE, Integer.class, SearchValue.class));

    return ccfgs.toArray(new CacheConfiguration[ccfgs.size()]);
}
 
Example 6
Source File: Client.java    From geoportal-server-harvester with Apache License 2.0 6 votes vote down vote up
private List<String> queryIdsScroll(String term, String value, long size) throws IOException, URISyntaxException {
  ArrayList<String> ids = new ArrayList<>();
  SearchContext searchContext = new SearchContext();

  while (!Thread.currentThread().isInterrupted()) {
    QueryResponse response = query(term, value, size, searchContext);
    if (Thread.currentThread().isInterrupted()) {
      break;
    }
    if (response.hits == null || response.hits.hits == null || response.hits.hits.isEmpty()) {
      break;
    }
    ids.addAll(response.hits.hits.stream()
            .map(h -> h._id)
            .filter(id -> id != null)
            .collect(Collectors.toList()));
  }

  return ids;
}
 
Example 7
Source File: TreeNode.java    From KEEL with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Removes the descendants from a identifier given of a node. The nodes whose descendants are being
 * removed become leaf nodes
 * 
 * @param original_identifier   Identifier of the node that is becoming a leaf node and whose descendants
 * are being removed
 * @return ArrayList with all the identifiers of the nodes that are being removed
 */
public ArrayList <Integer> deleteDescendants (int original_identifier) {
    ArrayList <Integer> nodes_deleted;
    
    nodes_deleted = new ArrayList <Integer> ();
    
    // Obtain descendants of descendants
    if (left != null) {
        nodes_deleted.addAll(left.deleteDescendants(original_identifier));
    }
    
    if (right != null) {
        nodes_deleted.addAll(right.deleteDescendants(original_identifier));
    }
    
    left = null;
    right = null;
    condition = null;
    
    if (identifier != original_identifier) {
        nodes_deleted.add(identifier);
    }
    
    return nodes_deleted;
}
 
Example 8
Source File: Answer.java    From CogniCrypt with Eclipse Public License 2.0 6 votes vote down vote up
public Answer combineWith(final Answer a) {
	final Answer combined = new Answer();
	combined.setValue(this.value + " + " + a.getValue());

	final ArrayList<CodeDependency> cpD = new ArrayList<CodeDependency>();
	if (this.codeDependencies != null) {
		cpD.addAll(this.codeDependencies);
	}
	if (a.getCodeDependencies() != null) {
		cpD.addAll(a.getCodeDependencies());
	}
	combined.setCodeDependencies(cpD);

	final ArrayList<ClaferDependency> clD = new ArrayList<ClaferDependency>();
	if (this.claferDependencies != null) {
		clD.addAll(this.claferDependencies);
	}
	if (a.getClaferDependencies() != null) {
		clD.addAll(a.getClaferDependencies());
	}
	combined.setClaferDependencies(clD);

	return combined;
}
 
Example 9
Source File: AbstractHadoopJob.java    From Kylin with Apache License 2.0 5 votes vote down vote up
protected void attachKylinPropsAndMetadata(IIInstance ii, Configuration conf) throws IOException {
    File tmp = File.createTempFile("kylin_job_meta", "");
    tmp.delete(); // we need a directory, so delete the file first

    File metaDir = new File(tmp, "meta");
    metaDir.mkdirs();
    metaDir.getParentFile().deleteOnExit();

    // write kylin.properties
    KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
    File kylinPropsFile = new File(metaDir, "kylin.properties");
    kylinConfig.writeProperties(kylinPropsFile);

    // write II / model_desc / II_desc / dict / table
    ArrayList<String> dumpList = new ArrayList<String>();
    dumpList.add(ii.getResourcePath());
    dumpList.add(ii.getDescriptor().getModel().getResourcePath());
    dumpList.add(ii.getDescriptor().getResourcePath());

    for (String tableName : ii.getDescriptor().getModel().getAllTables()) {
        TableDesc table = MetadataManager.getInstance(kylinConfig).getTableDesc(tableName);
        dumpList.add(table.getResourcePath());
    }

    for (IISegment segment : ii.getSegments()) {
        dumpList.addAll(segment.getDictionaryPaths());
    }

    dumpResources(kylinConfig, metaDir, dumpList);

    // hadoop distributed cache
    conf.set("tmpfiles", "file:///" + OptionsHelper.convertToFileURL(metaDir.getAbsolutePath()));
}
 
Example 10
Source File: OrderedList.java    From Open-Lowcode with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * gets an ordered list of all the elements
 * 
 * @return a full ordered list
 */
public ArrayList<E> getOrderedList() {
	ArrayList<E> orderedanswer = new ArrayList<E>();
	if (!orderedlist.isEmpty()) {
		Integer lastkey = orderedlist.lastKey();
		while (lastkey != null) {

			ArrayList<E> elements = orderedlist.get(lastkey);
			orderedanswer.addAll(elements);

			lastkey = orderedlist.lowerKey(lastkey);
		}
	}
	return orderedanswer;
}
 
Example 11
Source File: QFiles.java    From pacaya with Apache License 2.0 5 votes vote down vote up
private static List<File> getMatchingFiles(File file, Pattern regex) {
    ArrayList<File> files = new ArrayList<File>();
    if (file.exists()) {
        if (file.isFile()) {
            if (regex.matcher(file.getName()).matches()) {
                files.add(file);
            }
        } else {
            for (File subFile : file.listFiles()) {
                files.addAll(getMatchingFiles(subFile, regex));
            }
        }
    }
    return files;
}
 
Example 12
Source File: CPlatformWindow.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void orderAboveSiblingsImpl(Window[] windows) {
    ArrayList<Window> childWindows = new ArrayList<Window>();

    final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
    final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();

    // Go through the list of windows and perform ordering.
    for (Window w : windows) {
        boolean iconified = false;
        final Object p = componentAccessor.getPeer(w);
        if (p instanceof LWWindowPeer) {
            CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
            iconified = isIconified();
            if (pw != null && pw.isVisible() && !iconified) {
                // If the window is one of ancestors of 'main window' or is going to become main by itself,
                // the window should be ordered above its siblings; otherwise the window is just ordered
                // above its nearest parent.
                if (pw.isOneOfOwnersOrSelf(this)) {
                    CWrapper.NSWindow.orderFront(pw.getNSWindowPtr());
                } else {
                    CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove,
                            pw.owner.getNSWindowPtr());
                }
                pw.applyWindowLevel(w);
            }
        }
        // Retrieve the child windows for each window from the list except iconified ones
        // and store them for future use.
        // Note: we collect data about child windows even for invisible owners, since they may have
        // visible children.
        if (!iconified) {
            childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
        }
    }
    // If some windows, which have just been ordered, have any child windows, let's start new iteration
    // and order these child windows.
    if (!childWindows.isEmpty()) {
        orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
    }
}
 
Example 13
Source File: CassandraMetricBatch.java    From monasca-persister with Apache License 2.0 5 votes vote down vote up
public List<Deque<BatchStatement>> getAllBatches() {
  logTokenBatchMap("metric batches", metricQueries);
  logTokenBatchMap("dimension batches", dimensionQueries);
  logTokenBatchMap("dimension metric batches", dimensionMetricQueries);
  logTokenBatchMap("metric dimension batches", metricDimensionQueries);
  logReplicaBatchMap("measurement batches", measurementQueries);

  ArrayList<Deque<BatchStatement>> list = new ArrayList<>();
  list.addAll(metricQueries.values());
  list.addAll(dimensionQueries.values());
  list.addAll(dimensionMetricQueries.values());
  list.addAll(metricDimensionQueries.values());
  list.addAll(measurementQueries.values());
  return list;
}
 
Example 14
Source File: JythonPlugin.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Executes all the scripts beneath some folders
 * @param beneathFolders the folders we want to get the scripts from
 * @return the errors that occured while executing the scripts
 */
public static List<Throwable> execAll(HashMap<String, Object> locals, final String startingWith,
        IPythonInterpreter interpreter, File[] beneathFolders, File[] additionalPythonpathFolders) {
    List<Throwable> errors = new ArrayList<Throwable>();

    ArrayList<File> pythonpath = new ArrayList<File>();
    pythonpath.addAll(Arrays.asList(beneathFolders));
    if (additionalPythonpathFolders != null) {
        pythonpath.addAll(Arrays.asList(additionalPythonpathFolders));
    }
    File[] pythonpathFolders = pythonpath.toArray(new File[pythonpath.size()]);

    for (File file : beneathFolders) {
        if (file != null) {
            if (!file.exists()) {
                String msg = "The folder:" + file +
                        " does not exist and therefore cannot be used to " +
                        "find scripts to run starting with:" + startingWith;
                Log.log(IStatus.ERROR, msg, null);
                errors.add(new RuntimeException(msg));
            }
            File[] files = getFilesBeneathFolder(startingWith, file);
            for (File f : files) {
                Throwable throwable = exec(locals, interpreter, f, pythonpathFolders);
                if (throwable != null) {
                    errors.add(throwable);
                }
            }
        }
    }
    return errors;
}
 
Example 15
Source File: ProgramConverter.java    From systemds with Apache License 2.0 5 votes vote down vote up
/**
 * This creates a deep copy of a function program block. The central reference to singletons of function program blocks
 * poses the need for explicit copies in order to prevent conflicting writes of temporary variables (see ExternalFunctionProgramBlock.
 * 
 * @param namespace function namespace
 * @param oldName ?
 * @param pid ?
 * @param IDPrefix ?
 * @param prog runtime program
 * @param fnStack ?
 * @param fnCreated ?
 * @param plain ?
 */
public static void createDeepCopyFunctionProgramBlock(String namespace, String oldName, long pid, int IDPrefix, Program prog, HashSet<String> fnStack, HashSet<String> fnCreated, boolean plain) 
{
	//fpb guaranteed to be non-null (checked inside getFunctionProgramBlock)
	FunctionProgramBlock fpb = prog.getFunctionProgramBlock(namespace, oldName);
	String fnameNew = (plain)? oldName :(oldName+Lop.CP_CHILD_THREAD+pid); 
	String fnameNewKey = DMLProgram.constructFunctionKey(namespace,fnameNew);

	if( prog.getFunctionProgramBlocks().containsKey(fnameNewKey) )
		return; //prevent redundant deep copy if already existent
	
	//create deep copy
	FunctionProgramBlock copy = null;
	ArrayList<DataIdentifier> tmp1 = new ArrayList<>();
	ArrayList<DataIdentifier> tmp2 = new ArrayList<>();
	if( fpb.getInputParams()!= null )
		tmp1.addAll(fpb.getInputParams());
	if( fpb.getOutputParams()!= null )
		tmp2.addAll(fpb.getOutputParams());
	
	
	if( !fnStack.contains(fnameNewKey) ) {
		fnStack.add(fnameNewKey);
		copy = new FunctionProgramBlock(prog, tmp1, tmp2);
		copy.setChildBlocks( rcreateDeepCopyProgramBlocks(fpb.getChildBlocks(), pid, IDPrefix, fnStack, fnCreated, plain, fpb.isRecompileOnce()) );
		copy.setRecompileOnce( fpb.isRecompileOnce() );
		copy.setThreadID(pid);
		fnStack.remove(fnameNewKey);
	}
	else //stop deep copy for recursive function calls
		copy = fpb;
	
	//copy.setVariables( (LocalVariableMap) fpb.getVariables() ); //implicit cloning
	//note: instructions not used by function program block
	
	//put 
	prog.addFunctionProgramBlock(namespace, fnameNew, copy);
	fnCreated.add(DMLProgram.constructFunctionKey(namespace, fnameNew));
}
 
Example 16
Source File: ViewUtil.java    From Liz with GNU General Public License v3.0 5 votes vote down vote up
public static List<View> getAllChildren(View target) {
    if (!(target instanceof ViewGroup)) return Collections.singletonList(target);

    ArrayList<View> allChildren = new ArrayList<>();
    ViewGroup viewGroup = (ViewGroup) target;
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View child = viewGroup.getChildAt(i);
        ArrayList<View> targetsChildren = new ArrayList<>();
        targetsChildren.add(target);
        targetsChildren.addAll(getAllChildren(child));
        allChildren.addAll(targetsChildren);
    }
    return allChildren;
}
 
Example 17
Source File: Compiler.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
private static <T> List<T> concat(final List<T> l1, final List<T> l2) {
    final ArrayList<T> l = new ArrayList<>(l1);
    l.addAll(l2);
    l.trimToSize();
    return l;
}
 
Example 18
Source File: HTMLLayoutPageHintManager.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public ArrayList getPageHint( )
{
	ArrayList hints = new ArrayList( );
	hints.addAll( pageHints );
	return hints;
}
 
Example 19
Source File: EnterpriseHDMTxSignaturePool.java    From bitherj with Apache License 2.0 4 votes vote down vote up
public List<Integer> signaturePubIndexes() {
    ArrayList<Integer> indexes = new ArrayList<Integer>();
    indexes.addAll(signatures.keySet());
    Collections.sort(indexes);
    return indexes;
}
 
Example 20
Source File: KAStarNode.java    From OSPREY3 with GNU General Public License v2.0 4 votes vote down vote up
private ArrayList<KAStarNode> getChildren( HashSet<ArrayList<String>> nextPLSeqs,
		HashSet<ArrayList<String>> pSeqs, HashSet<ArrayList<String>> lSeqs ) {

	ArrayList<ArrayList<String>> strandSeqs = new ArrayList<>(Arrays.asList(null, null, null));
	// lower bound pf values
	ArrayList<Boolean> lbContSCFlexVals = new ArrayList<>(Arrays.asList(false, false, true));
	ArrayList<String> lbPFImplVals = new ArrayList<>(Arrays.asList(new PFTraditional().getImpl(), new PFTraditional().getImpl(), new PFUB().getImpl()));

	// upper bound pf values
	ArrayList<Boolean> ubContSCFlexVals = new ArrayList<>(Arrays.asList(true, true, false));
	ArrayList<String> ubPFImplVals = new ArrayList<>(Arrays.asList(new PFUB().getImpl(), new PFUB().getImpl(), new PFTraditional().getImpl()));

	// minimized pf values
	ArrayList<Boolean> tightContSCFlexVals = new ArrayList<>(Arrays.asList(true, true, true));
	ArrayList<String> tightPFImplVals = new ArrayList<>(Arrays.asList(PFAbstract.getCFGImpl(), PFAbstract.getCFGImpl(), PFAbstract.getCFGImpl()));

	ArrayList<KAStarNode> ans = new ArrayList<>();

	for( ArrayList<String> pSeq : pSeqs ) {

		for( ArrayList<String> lSeq : lSeqs ) {

			ArrayList<String> putativeNextPLSeq = new ArrayList<String>();

			putativeNextPLSeq.addAll(pSeq);
			putativeNextPLSeq.addAll(lSeq);
			putativeNextPLSeq.trimToSize();

			if( !nextPLSeqs.contains(putativeNextPLSeq) ) continue;

			numCreated++;

			// create partition functions for next sequences
			strandSeqs.set(2, putativeNextPLSeq);
			strandSeqs.set(0, pSeq);
			strandSeqs.set(1, lSeq);

			if( !isFullyDefined() ) {
				// create partition functions
				ConcurrentHashMap<Integer, PFAbstract> lbPFs = ksObj.createPFs4Seqs(strandSeqs, lbContSCFlexVals, lbPFImplVals);
				ConcurrentHashMap<Integer, PFAbstract> ubPFs = ksObj.createPFs4Seqs(strandSeqs, ubContSCFlexVals, ubPFImplVals);

				// create KUStar node with lower and upper bounds
				ans.add( new KAStarNode( new KSCalc(numCreated, lbPFs), new KSCalc(numCreated, ubPFs), childScoreNeedsRefinement(lbPFs) ) );
				ans.get(ans.size()-1).parentlbScore = this.lbScore;
			}

			else if( KSImplKAStar.useTightBounds ) {
				// create a leaf node; we don't need upper or lower bounds ;we only need the minimized partition 
				// function our search problems exist, so we need only delete the lb, ub pfs from the table

				ConcurrentHashMap<Integer, PFAbstract> tightPFs = ksObj.createPFs4Seqs(strandSeqs, tightContSCFlexVals, tightPFImplVals);

				// assign sequence number from allowedSequences obj
				KSAllowedSeqs complexSeqs = ksObj.strand2AllowedSeqs.get(2);
				int seqID = complexSeqs.getPosOfSeq(tightPFs.get(2).getSequence());

				// create new KUStar node with tight score
				ans.add( new KAStarNode( new KSCalc(seqID, tightPFs), null, false ) );
				ans.get(ans.size()-1).parentlbScore = this.lbScore;

				// processed nodes are those whose confs will be minimized
				numLeavesCreated = ksObj.getNumSeqsCreated(1);
			}

			else
				throw new RuntimeException("ERROR: cannot expand a fully assigned node");
		}
	}

	return ans;
}