Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么Apex在这个集合上向后迭代?_Java_Salesforce_Visualforce_Apex_Soql - Fatal编程技术网

Java 为什么Apex在这个集合上向后迭代?

Java 为什么Apex在这个集合上向后迭代?,java,salesforce,visualforce,apex,soql,Java,Salesforce,Visualforce,Apex,Soql,我以前从未在Java中工作过,更不用说Apex了,也不太熟悉数据库,所以如果我犯了一些非常愚蠢的错误,请原谅 我正在开发一个VisualForce页面,让我所在组织的员工在多个记录的富文本字段中搜索关键字。SOQL对于长文本字段不是很好,所以我使用SOSL 用户转到VF页面的URI,并根据URI中的三个GET参数执行SOSL查询:和、或、和非。这允许用户“保存”并与其他员工共享他们的搜索。(是的,我将防止SQL注入。) 例如: https://abc123.visual.force.com/ap

我以前从未在Java中工作过,更不用说Apex了,也不太熟悉数据库,所以如果我犯了一些非常愚蠢的错误,请原谅

我正在开发一个VisualForce页面,让我所在组织的员工在多个记录的富文本字段中搜索关键字。SOQL对于长文本字段不是很好,所以我使用SOSL

用户转到VF页面的URI,并根据URI中的三个GET参数执行SOSL查询:
、和
。这允许用户“保存”并与其他员工共享他们的搜索。(是的,我将防止SQL注入。)

例如:

https://abc123.visual.force.com/apex/myCustomController?and=bilbo,baggins&or=frodo,pippin,merry&not=sauron
这将产生:

FIND '(bilbo* AND baggins*) OR (frodo* OR pippin* OR merry*) AND NOT (sauron*)'...
相反,我得到的是:

FIND 'AND NOT (sauron*) OR (frodo* or pippin* or merry*)(bilbo* and baggins*)'...
urlParamTypes
集合将继续按字母顺序倒序遍历最外层的
for
循环

我尝试过分类,我尝试过以相反的顺序写,但没有任何效果。除此之外,事情似乎进展得非常顺利,所以让我感到沮丧的是,我遇到的问题似乎很愚蠢

非常感谢您的想法

Public with sharing class myController{

    Public Map<String, String> urlParams {get; set;}
    Public Set<String> urlParamTypes = new Set<String>{'and','or','not'};
    Public String queryString {get; set;}
    Public List<myCustomObject> candidates {get; set;}

    Public myController(){
        urlParams = ApexPages.currentPage().getParameters();
        Integer totalParamTypes = urlParams.size();
        Integer intOfParamTypes = 0;
        for(String thisParamType : urlParamTypes){
            String thisParamString = urlParams.get(thisParamType);
            Integer intOfThisParamType = 0;
            Integer totalOfThisParamType = 0;

            if(thisParamString != null && thisParamString.length() > 0){
                intOfParamTypes++;

                if(thisParamType == 'or' && intOfParamTypes > 0){
                    queryString += ' OR ';
                }else
                if(thisParamType == 'not' && intOfParamTypes > 0){
                    queryString += ' AND NOT ';
                }

                queryString += '(' + thisParamString.replace(',', '* ' + (thisParamType == 'not' ? 'AND' : thisParamType) + ' ') + '*)';
            }

        }
        queryString = 'FIND \'' + queryString + '\' RETURNING myCustomObject (id,name)';
        List<List <myCustomObject>> searchList = search.query(queryString);
        candidates = ((List<sObject>)searchList[0]);
    }

}
Public与共享类myController{
公共映射urlParams{get;set;}
公共集合urlParamTypes=新集合{'and','or','not'};
公共字符串查询字符串{get;set;}
公共候选列表{get;set;}
公共myController(){
urlParams=ApexPages.currentPage().getParameters();
整数totalParamTypes=urlParams.size();
整数intOfParamTypes=0;
for(字符串thisParamType:urlParamTypes){
String thisParamString=urlParams.get(thisParamType);
整数intOfThisParamType=0;
ThisparamType的整数totalOfThisParamType=0;
if(thisParamString!=null&&thisParamString.length()>0){
intOfParamTypes++;
if(thisParamType=='或'&&intOfParamTypes>0){
queryString+='或';
}否则
if(thisParamType=='not'&&intOfParamTypes>0){
queryString+='和NOT';
}
queryString+='(“+thisParamString.replace”(“,”,“*”+(thisParamType=='not'?”和“:thisParamType)+'+'*)”;
}
}
queryString='FIND\''+queryString+'\'返回myCustomObject(id,name)';
List searchList=search.query(queryString);
候选人=((列表)搜索列表[0]);
}
}

Set
不维护排序。这些值似乎以相反的顺序出现这一事实是巧合。您可以使用
列表
来代替吗?

集合
不维护排序。这些值似乎以相反的顺序出现这一事实是巧合。您可以使用
列表
来代替吗?

集合
不维护排序。这些值似乎以相反的顺序出现这一事实是巧合。您可以使用
列表
来代替吗?

集合
不维护排序。这些值似乎以相反的顺序出现这一事实是巧合。你能用
List
代替吗?

啊,答对了。非常感谢。输入杂耍很难,来自PHP。啊,宾果。非常感谢。输入杂耍很难,来自PHP。啊,宾果。非常感谢。输入杂耍很难,来自PHP。啊,宾果。非常感谢。类型转换很难,来自PHP。