我正在使用mule esb将数据存储到salesforce云。所以需要转换以下格式Latitude,Longitude,Proximity
23.2241356,72.629232,0,
23.2241357,72.629233,5,
23.2241358,72.629234,0,
23.2241359,72.629235,5,
采用以下格式,
{proximity__c=23.2241361, longitude__c=72.629237, latitude__c=5.0},
{proximity__c=23.2241362, longitude__c=72.629238, latitude__c=0.0},
{proximity__c=23.2241363, longitude__c=72.629239, latitude__c=5.0},
{proximity__c=23.2241364, longitude__c=72.62924, latitude__c=0.0},
如何通过java实现这一目标?
答案 0 :(得分:1)
以下是可能的解决方案。
int A_left = 4;
int B_left = 4;
int C_left = 4;
int D_left = 4;
int E_left = 4;
答案 1 :(得分:0)
只需在像HashMap或ArrayList这样的集合中保留纬度,经度和接近度,或者在对象集合中保留其他东西
只需在执行迭代时使用for循环迭代它,只需执行足够的基本字符串连接。
- 更新
public class Geo {
private String lat;
private String long;
private String proximity;
void setLat(String Lat){
lat = Lat;
}
void setLong(String Long){
long = Long;
}
void setProximity(String Proximity){
proximity = Proximity;
}
String getLat(){
return lat;
}
String getLong(){
return long;
}
String getProxmity(){
return proximity;
}
}
HashMap<String, Geo> map = new HashMap<String, Geo>();
Geo g1=new Geo();
//set lat,long,proximity
map.put(“Geo”,g1);
Geo g2=new Geo();
//set lat,long,proximity
map.put(“Geo”,g2);
Create as many objects as you want and add to the Hash
Iterator it = map.entrySet().iterator();
String CSV=“”;
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
Geo g= pair.getValue();
if(CSV.length!=0)
CSV=CSV+”,”
CSV=CSV+“{proximity__c=”+g.getProxmity()+”, longitude__c=”+g.getLong()+”, latitude__c=”+g.getLat());
}
// if(CSV.length!=0)
// CSV = CSV.substring(0, CSV.length()-1);