当前位置: 首页>>代码示例>>Java>>正文


Java ArrayList.containsAll方法代码示例

本文整理汇总了Java中java.util.ArrayList.containsAll方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayList.containsAll方法的具体用法?Java ArrayList.containsAll怎么用?Java ArrayList.containsAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.ArrayList的用法示例。


在下文中一共展示了ArrayList.containsAll方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkTasksPresent

import java.util.ArrayList; //导入方法依赖的package包/类
private void checkTasksPresent(String url, boolean mustBePresent, String... ids) throws Exception 
{
    List<String> taskIds = Arrays.asList(ids);
    JSONObject json = getDataFromRequest(url);
    JSONArray result = json.getJSONArray("data");
    assertNotNull(result);

    ArrayList<String> resultIds = new ArrayList<String>(result.length());
    for (int i=0; i<result.length(); i++)
    {
        JSONObject taskObject = result.getJSONObject(i);
        String taskId = taskObject.getString("id");
        resultIds.add(taskId);
        if (mustBePresent == false && taskIds.contains(taskId))
        {
            fail("The results should not contain id: "+taskId);
        }
    }
    if (mustBePresent && resultIds.containsAll(taskIds) == false)
    {
        fail("Not all task Ids were present!\nExpected: "+taskIds +"\nActual: "+resultIds); 
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:AbstractWorkflowRestApiTest.java

示例2: getTokenCompleted

import java.util.ArrayList; //导入方法依赖的package包/类
void getTokenCompleted(LoginClient.Request request, Bundle result) {
    if (getTokenClient != null) {
        getTokenClient.setCompletedListener(null);
    }
    getTokenClient = null;

    loginClient.notifyBackgroundProcessingStop();

    if (result != null) {
        ArrayList<String> currentPermissions =
                result.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
        Set<String> permissions = request.getPermissions();
        if ((currentPermissions != null) &&
                ((permissions == null) || currentPermissions.containsAll(permissions))) {
            // We got all the permissions we needed, so we can complete the auth now.
            complete(request, result);
            return;
        }

        // We didn't get all the permissions we wanted, so update the request with just the
        // permissions we still need.
        Set<String> newPermissions = new HashSet<String>();
        for (String permission : permissions) {
            if (!currentPermissions.contains(permission)) {
                newPermissions.add(permission);
            }
        }
        if (!newPermissions.isEmpty()) {
            addLoggingExtra(
                LoginLogger.EVENT_EXTRAS_NEW_PERMISSIONS,
                TextUtils.join(",", newPermissions)
            );
        }

        request.setPermissions(newPermissions);
    }

    loginClient.tryNextHandler();
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:40,代码来源:GetTokenLoginMethodHandler.java

示例3: visitProjection

import java.util.ArrayList; //导入方法依赖的package包/类
@Override
public String visitProjection(RelationalAlgebraParser.ProjectionContext ctx) {
	String translation = "SELECT " + visit(ctx.attrlist()) + " FROM " + visit(ctx.expr());
	
	/**
	 * CASCADE OF PROJECTIONS: PROJECT [...] (PROJECT [...] (...));
	 * => check if the attributes list of a projection contains
	 * in the outer projection's attributes list.
	 */
	// If its parent it's a projection as well...
	
	if (ctx.getParent() instanceof RelationalAlgebraParser.ProjectionContext) {
		RelationalAlgebraParser.ProjectionContext currentProjectAttrList = ctx;
		RelationalAlgebraParser.ProjectionContext outerProjectAttrList = 
				(ProjectionContext) ctx.getParent();
		ArrayList<String> currentProjectAttributes;
		ArrayList<String> outerProjectAttributes;
		
		String[] currentProjectAttrListSplitted = splitAttrList(currentProjectAttrList);
		String[] outerProjectAttrListSplitted = splitAttrList(outerProjectAttrList);
		
		currentProjectAttributes = new ArrayList<String>(
				Arrays.asList(currentProjectAttrListSplitted));
		outerProjectAttributes = new ArrayList<String>(Arrays.asList(outerProjectAttrListSplitted));
	
		if (!currentProjectAttributes.containsAll(outerProjectAttributes)) {
			appendError("The projection attributes list " + currentProjectAttributes
					+ " does not contain its outer projection attributes list "
					+ outerProjectAttributes);
		}
		
		// Return only the RELATION
		return visit(ctx.expr());
	}
	
	return translation;
}
 
开发者ID:tteguayco,项目名称:JITRAX,代码行数:38,代码来源:RelationalAlgebraEvalVisitor.java

示例4: visitDivision

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * https://users.dcc.uchile.cl/~cgutierr/cursos/BD/divisionSQL.pdf
 */
@Override
public String visitDivision(RelationalAlgebraParser.DivisionContext ctx) {
	ArrayList<Attribute> leftRelationColumns = expressionSchema(ctx.expr(0));
	ArrayList<Attribute> rightRelationColumns = expressionSchema(ctx.expr(1));
	
	if (leftRelationColumns == null || rightRelationColumns == null) {
		return "";
	}
	
	// Let R(r) / S(s), r must contain s strictly 
	if (leftRelationColumns.size() > rightRelationColumns.size()) {
		if (leftRelationColumns.containsAll(rightRelationColumns)) {
			String division = "";
			String divisionSchema = listToString(expressionSchema(ctx));
			String rightRelationSchema = listToString(rightRelationColumns);
			String leftRelationName = visit(ctx.expr(0));
			String rightRelationName = visit(ctx.expr(1));
			
			division += "SELECT " + divisionSchema + "\n";
			division += "FROM " + leftRelationName + " NATURAL JOIN "  + rightRelationName + "\n";
			division += "GROUP BY " + divisionSchema + "\n";
			division += "HAVING COUNT(*) = (SELECT COUNT(*) FROM " + rightRelationName + ")";
			
			return preppendSelectStarIfNeeded(ctx, division);
		}
	}
	
	appendError("Division: incompatible schemas.");
	return "";
}
 
开发者ID:tteguayco,项目名称:JITRAX,代码行数:34,代码来源:RelationalAlgebraEvalVisitor.java

示例5: getRegisterClassForRegister

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * Find the register class that contains the
 * specified physical register.  If the register is not in a register
 * class, return null. If the register is in multiple classes, and the
 * classes have a superset-subset relationship and the same set of
 * types, return the superclass.  Otherwise return null.
 * @param r
 * @return
 */
public CodeGenRegisterClass getRegisterClassForRegister(Record r)
{
    ArrayList<CodeGenRegisterClass> rcs = getRegisterClasses();
    CodeGenRegisterClass foundRC = null;
    for (int i = 0, e = rcs.size(); i != e; ++i)
    {
        CodeGenRegisterClass rc = registerClasses.get(i);
        for (int ei = 0, ee = rc.elts.size(); ei != ee; ++ei)
        {
            if (r != rc.elts.get(ei))
                continue;

            // If a register's classes have different types, return null.
            if (foundRC != null && !rc.getValueTypes().equals(foundRC.getValueTypes()))
                return null;

            // If this is the first class that contains the register,
            // make a note of it and go on to the next class.
            if (foundRC == null)
            {
                foundRC = rc;
                break;
            }

            ArrayList<Record> elements = new ArrayList<>();
            elements.addAll(rc.elts);

            ArrayList<Record> foundElements = new ArrayList<>();
            foundElements.addAll(foundRC.elts);

            // Check to see if the previously found class that contains
            // the register is a subclass of the current class. If so,
            // prefer the superclass.
            if(elements.containsAll(foundElements))
            {
                foundRC = rc;
                break;
            }

            // Check to see if the previously found class that contains
            // the register is a superclass of the current class. If so,
            // prefer the superclass.
            if (foundElements.containsAll(elements))
                break;

            // Multiple classes, and neither is a superclass of the other.
            // Return null.
            return null;
        }
    }
    return foundRC;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:62,代码来源:CodeGenTarget.java

示例6: nextJoin

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * 
 * @param start
 * @param joinVars
 * @return
 */
protected int nextJoin(int start, ArrayList<String> joinVars) {
	// Triples are joined on the joinVars
	String joinArg = toArgumentList(joinVars);
	// Projection arguments initially contain everything from the current resultSchema
	String projectArgs = addToProjectArgs("", null, (start == 1 ? "t0" : resultName), resultSchema);

	/*
	 * JOIN
	 */
	List<Triple> triples = opBGP.getPattern().getList();
	Triple triple = triples.get(start);
	ArrayList<String> tripleVars = getVarsOfTriple(triple);
	
	// start with joining current result relation (t0 or previous join) with t(start)
	String joinArguments = (start == 1 ? "t0" : resultName) + " BY " + joinArg + ", t" + start + " BY " + joinArg;
	// add variables of t(start) that do not already exist in the current resultSchema to the projection arguments
	projectArgs = addToProjectArgs(projectArgs, resultSchema, "t" + start, tripleVars);
	// update resultSchema -> add additional variables that do not already exist in the current resultSchema
	addToResultSchema(tripleVars);

	/*
	 * Successive Triples which also result in a JOIN on the same variables can be added to this JOIN
	 */
	ArrayList<String> sharedVars;
	int endIndex = start + 1;
	while (endIndex < triples.size()) {
		triple = triples.get(endIndex);
		tripleVars = getVarsOfTriple(triple);
		sharedVars = getSharedVars(resultSchema, tripleVars);
		if (joinVars.containsAll(sharedVars) && sharedVars.containsAll(joinVars)) {
			// joinVars and sharedVars contain the same elements (perhaps not in the same order) -> add Triple to this JOIN
			joinArguments += ", t" + endIndex + " BY " + joinArg;
			// add variables of the current triple that do not already exist in the current resultSchema to the projection arguments
			projectArgs = addToProjectArgs(projectArgs, resultSchema, "t" + endIndex, tripleVars);
			// update resultSchema -> add additional variables that do not already exist in the current resultSchema
			addToResultSchema(tripleVars);
			endIndex++;
		}
		// Triple can't be added to this JOIN -> END OF JOIN
		else
			break;
	}

	String join = resultName + " = JOIN " + joinArguments + " ;";
	joinBlock += join + "\n";

	/*
	 * PROJECTION -> drop duplicated entries generated by the JOIN statement
	 */
	String foreach = resultName + " = FOREACH " + resultName + " GENERATE " + projectArgs + " ;";
	joinBlock += foreach + "\n";

	return endIndex - 1;
}
 
开发者ID:aschaetzle,项目名称:PigSPARQL,代码行数:61,代码来源:PigBGPBase.java

示例7: generateUnion

import java.util.ArrayList; //导入方法依赖的package包/类
private String generateUnion() {
    String union = "";
    ArrayList<String> leftOpSchema = leftOp.getSchema();
    ArrayList<String> rightOpSchema = rightOp.getSchema();

    // schemas are exactly the same
    if(leftOpSchema.equals(rightOpSchema)) {
        union += resultName + " = UNION ";
        union += leftOp.getResultName() + ", " + rightOp.getResultName();
        resultSchema.addAll(leftOp.getSchema());
    }
    // schemas are the same but in different order
    else if (leftOpSchema.size()==rightOpSchema.size() && leftOpSchema.containsAll(rightOpSchema)) {
        union += "u1 = FOREACH " + rightOp.getResultName() + " GENERATE ";
        union += leftOpSchema.get(0);
        for (int i=1; i<leftOpSchema.size(); i++) {
            union += ", " + leftOpSchema.get(i);
        }
        union += " ;\n";
        union += resultName + " = UNION " + leftOp.getResultName() + ", u1";
        resultSchema.addAll(leftOpSchema);
    }
    // different schemas
    else {
        leftOuterVars = new ArrayList<String>();
        rightOuterVars = new ArrayList<String>();
        sharedVars = getSharedVars();
        leftOuterVars.addAll(leftOp.getSchema());
        leftOuterVars.removeAll(sharedVars);
        rightOuterVars.addAll(rightOp.getSchema());
        rightOuterVars.removeAll(sharedVars);
        String u1 = "u1 = FOREACH " + leftOp.getResultName() + " GENERATE ";
        String u2 = "u2 = FOREACH " + rightOp.getResultName() + " GENERATE ";
        boolean first = true;
        for (int i=0; i<sharedVars.size(); i++) {
            u1 += (first ? "": ", ") + sharedVars.get(i);
            u2 += (first ? "": ", ") + sharedVars.get(i);
            first = false;
        }
        for (int i=0; i<leftOuterVars.size(); i++) {
            u1 += (first ? "": ", ") + leftOuterVars.get(i);
            u2 += (first ? "": ", ") + "null AS " + leftOuterVars.get(i);
            first = false;
        }
        for (int i=0; i<rightOuterVars.size(); i++) {
            u1 += (first ? "": ", ") + "null AS " + rightOuterVars.get(i);
            u2 += (first ? "": ", ") + rightOuterVars.get(i);
            first = false;
        }
        union += u1 + " ;\n" + u2 + " ;\n";
        union += resultName + " = UNION " + "u1, u2";
        resultSchema.addAll(sharedVars);
        resultSchema.addAll(leftOuterVars);
        resultSchema.addAll(rightOuterVars);
        varsWithNulls.addAll(leftOuterVars);
        varsWithNulls.addAll(rightOuterVars);
    }
    union += " ;\n";
    return union;
}
 
开发者ID:aschaetzle,项目名称:PigSPARQL,代码行数:61,代码来源:PigUnion.java

示例8: contentsMatchs

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * returns true if these two sets refer to the same objects.<br>
 * This isn't as simple as a equals, as one or both sets might not yet have been cached into objects.<br>
 * We thus get the object names from both sets, and compare them instead.<br>
 * <br>
 * BEWARE: dont attempt touching stuff on objects that have the same name as this can cause confusion with whats touching what 
 * @param set
 * @return
 */
public boolean contentsMatchs(SceneObjectSet set){
	ArrayList<String> ourNames = this.getNames();
	ArrayList<String> comparisonNames = set.getNames();
	
	return ourNames.containsAll(comparisonNames);
}
 
开发者ID:ThomasWrobel,项目名称:JAMCore,代码行数:16,代码来源:SceneObjectSet.java


注:本文中的java.util.ArrayList.containsAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。