本文整理汇总了Java中org.jivesoftware.smackx.ReportedData类的典型用法代码示例。如果您正苦于以下问题:Java ReportedData类的具体用法?Java ReportedData怎么用?Java ReportedData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReportedData类属于org.jivesoftware.smackx包,在下文中一共展示了ReportedData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: searchUsers
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* 查询用户
* @param xmppConnection
* @param userName
* @return
* @throws XMPPException
*/
public static List<HashMap<String, String>> searchUsers(XMPPConnection xmppConnection,String userName) {
List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
try {
UserSearchManager usm = new UserSearchManager(xmppConnection);
Form searchForm = usm.getSearchForm(xmppConnection.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("userAccount", true);
answerForm.setAnswer("userPhote", userName);
ReportedData data = usm.getSearchResults(answerForm, "search" + xmppConnection.getServiceName());
Iterator<ReportedData.Row> it = data.getRows();
while (it.hasNext()) {
HashMap<String, String> user = new HashMap<String, String>();
ReportedData.Row row = it.next();
user.put("userAccount", row.getValues("userAccount").next().toString());
user.put("userPhote", row.getValues("userPhote").next().toString());
results.add(user);
}
} catch (XMPPException e) {
e.printStackTrace();
}
return results;
}
示例2: searchUsers
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* 查询用户
* @param xmppConnection
* @param userName
* @return
* @throws XMPPException
*/
public static List<HashMap<String, String>> searchUsers(XMPPConnection xmppConnection, String userName) {
List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
try {
UserSearchManager usm = new UserSearchManager(xmppConnection);
Form searchForm = usm.getSearchForm(xmppConnection.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("userAccount", true);
answerForm.setAnswer("userPhote", userName);
ReportedData data = usm.getSearchResults(answerForm, "search" + xmppConnection.getServiceName());
Iterator<ReportedData.Row> it = data.getRows();
while (it.hasNext()) {
HashMap<String, String> user = new HashMap<String, String>();
ReportedData.Row row = it.next();
user.put("userAccount", row.getValues("userAccount").next().toString());
user.put("userPhote", row.getValues("userPhote").next().toString());
results.add(user);
}
} catch (XMPPException e) {
Log.e("searchUsers", e.getMessage());
e.printStackTrace();
}
return results;
}
示例3: searchUsers
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* 查找用户
*
* @param
* @param userName
* @return
*/
public List<XmppUser> searchUsers(String userName) {
List<XmppUser> list = new ArrayList<XmppUser>();
UserSearchManager userSearchManager = new UserSearchManager(con);
try {
Form searchForm = userSearchManager.getSearchForm("search."
+ con.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
answerForm.setAnswer("Name", true);
answerForm.setAnswer("search", userName);
ReportedData data = userSearchManager.getSearchResults(answerForm,
"search." + con.getServiceName());
Iterator<ReportedData.Row> rows = data.getRows();
while (rows.hasNext()) {
XmppUser user = new XmppUser(null, null);
ReportedData.Row row = rows.next();
user.setUserName(row.getValues("Username").next().toString());
user.setName(row.getValues("Name").next().toString());
list.add(user);
}
} catch (XMPPException e) {
SLog.e(tag, Log.getStackTraceString(e));
}
return list;
}
示例4: searchUsers
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* 查询用户
*
* @param userName
* @return
* @throws XMPPException
*/
public static List<Session> searchUsers(XMPPConnection mXMPPConnection,String userName) {
List<Session> listUser=new ArrayList<Session>();
try{
UserSearchManager search = new UserSearchManager(mXMPPConnection);
//此处一定要加上 search.
Form searchForm = search.getSearchForm("search."+mXMPPConnection.getServiceName());
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
answerForm.setAnswer("search", userName);
ReportedData data = search.getSearchResults(answerForm,"search."+mXMPPConnection.getServiceName());
Iterator<Row> it = data.getRows();
Row row=null;
while(it.hasNext()){
row=it.next();
Session session=new Session();
session.setFrom(row.getValues("Username").next().toString());
listUser.add(session);
}
}catch(Exception e){
}
return listUser;
}
示例5: submitSearch
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* Submits the completed form and returns the result of the transcript search. The result
* will include all the data returned from the server so be careful with the amount of
* data that the search may return.
*
* @param serviceJID the address of the workgroup service.
* @param completedForm the filled out search form.
* @return the result of the transcript search.
* @throws XMPPException if an error occurs while submiting the search to the server.
*/
public ReportedData submitSearch(String serviceJID, Form completedForm) throws XMPPException {
TranscriptSearch search = new TranscriptSearch();
search.setType(IQ.Type.GET);
search.setTo(serviceJID);
search.addExtension(completedForm.getDataFormToSend());
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(search.getPacketID()));
connection.sendPacket(search);
TranscriptSearch response = (TranscriptSearch) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Cancel the collector.
collector.cancel();
if (response == null) {
throw new XMPPException("No response from server on status set.");
}
if (response.getError() != null) {
throw new XMPPException(response.getError());
}
return ReportedData.getReportedDataFrom(response);
}
示例6: sendSearchForm
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* Sends the filled out answer form to be sent and queried by the search service.
*
* @param con the current Connection.
* @param searchForm the <code>Form</code> to send for querying.
* @param searchService the search service to use. (ex. search.jivesoftware.com)
* @return ReportedData the data found from the query.
* @throws org.jivesoftware.smack.XMPPException
* thrown if a server error has occurred.
*/
public ReportedData sendSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
UserSearch search = new UserSearch();
search.setType(IQ.Type.SET);
search.setTo(searchService);
search.addExtension(searchForm.getDataFormToSend());
PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));
con.sendPacket(search);
IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Cancel the collector.
collector.cancel();
if (response == null) {
throw new XMPPException("No response from server on status set.");
}
if (response.getError() != null) {
return sendSimpleSearchForm(con, searchForm, searchService);
}
return ReportedData.getReportedDataFrom(response);
}
示例7: submitSearch
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* Submits the completed form and returns the result of the transcript
* search. The result will include all the data returned from the server so
* be careful with the amount of data that the search may return.
*
* @param serviceJID
* the address of the workgroup service.
* @param completedForm
* the filled out search form.
* @return the result of the transcript search.
* @throws XMPPException
* if an error occurs while submiting the search to the server.
*/
public ReportedData submitSearch(String serviceJID, Form completedForm)
throws XMPPException {
TranscriptSearch search = new TranscriptSearch();
search.setType(IQ.Type.GET);
search.setTo(serviceJID);
search.addExtension(completedForm.getDataFormToSend());
PacketCollector collector = connection
.createPacketCollector(new PacketIDFilter(search.getPacketID()));
connection.sendPacket(search);
TranscriptSearch response = (TranscriptSearch) collector
.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Cancel the collector.
collector.cancel();
if (response == null) {
throw new XMPPException("No response from server on status set.");
}
if (response.getError() != null) {
throw new XMPPException(response.getError());
}
return ReportedData.getReportedDataFrom(response);
}
示例8: userExist
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
boolean userExist(String user, String jid) {
if (ThreadHelper.xmppConnection.isAuthenticated()) {
String service = "search."+ThreadHelper.xmppConnection.getServiceName();
UserSearchManager search = new UserSearchManager(ThreadHelper.xmppConnection);
try {
Form queryForm = search.getSearchForm(service);
Form searchForm = queryForm.createAnswerForm();
searchForm.setAnswer("Username", true);
searchForm.setAnswer("search", user);
ReportedData data = search.getSearchResults(searchForm, service);
Iterator<Row> rows = data.getRows();
while (rows.hasNext()) {
Row row = rows.next();
Iterator<String> jids = row.getValues("jid");
while (jids.hasNext())
if (jids.next().equalsIgnoreCase(jid))
return true;
}
} catch (XMPPException e) {
if (th.D) Log.e(TAG, e.getMessage(), e);
}
}
return false;
}
示例9: sendSimpleSearchForm
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* Sends the filled out answer form to be sent and queried by the search service.
*
* @param con the current Connection.
* @param searchForm the <code>Form</code> to send for querying.
* @param searchService the search service to use. (ex. search.jivesoftware.com)
* @return ReportedData the data found from the query.
* @throws org.jivesoftware.smack.XMPPException
* thrown if a server error has occurred.
*/
public ReportedData sendSimpleSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
SimpleUserSearch search = new SimpleUserSearch();
search.setForm(searchForm);
search.setType(IQ.Type.SET);
search.setTo(searchService);
PacketCollector collector = con.createPacketCollector(new PacketIDFilter(search.getPacketID()));
con.sendPacket(search);
IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Cancel the collector.
collector.cancel();
if (response == null) {
throw new XMPPException("No response from server on status set.");
}
if (response.getError() != null) {
throw new XMPPException(response.getError());
}
if (response instanceof SimpleUserSearch) {
return ((SimpleUserSearch) response).getReportedData();
}
return null;
}
示例10: searchUsers
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* �����û�
*
* @param serverDomain
* @param userName
* @return
*/
public List<User> searchUsers(String serverDomain, String userName) {
List<User> list = new ArrayList<User>();
UserSearchManager userSearchManager = new UserSearchManager(connection);
try {
Form searchForm = userSearchManager.getSearchForm("search."
+ serverDomain);
Form answerForm = searchForm.createAnswerForm();
answerForm.setAnswer("Username", true);
answerForm.setAnswer("Name", true);
answerForm.setAnswer("search", userName);
ReportedData data = userSearchManager.getSearchResults(answerForm,
"search." + serverDomain);
Iterator<Row> rows = data.getRows();
while (rows.hasNext()) {
User user = new User();
Row row = rows.next();
user.setUserName(row.getValues("Username").next().toString());
user.setName(row.getValues("Name").next().toString());
SLog.i(tag, user.toString());
list.add(user);
}
} catch (XMPPException e) {
SLog.e(tag, Log.getStackTraceString(e));
}
return list;
}
示例11: sendSearchForm
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* Sends the filled out answer form to be sent and queried by the search
* service.
*
* @param con
* the current Connection.
* @param searchForm
* the <code>Form</code> to send for querying.
* @param searchService
* the search service to use. (ex. search.jivesoftware.com)
* @return ReportedData the data found from the query.
* @throws org.jivesoftware.smack.XMPPException
* thrown if a server error has occurred.
*/
public ReportedData sendSearchForm(Connection con, Form searchForm,
String searchService) throws XMPPException {
UserSearch search = new UserSearch();
search.setType(IQ.Type.SET);
search.setTo(searchService);
search.addExtension(searchForm.getDataFormToSend());
PacketCollector collector = con
.createPacketCollector(new PacketIDFilter(search.getPacketID()));
con.sendPacket(search);
IQ response = (IQ) collector.nextResult(SmackConfiguration
.getPacketReplyTimeout());
// Cancel the collector.
collector.cancel();
if (response == null) {
throw new XMPPException("No response from server on status set.");
}
if (response.getError() != null) {
return sendSimpleSearchForm(con, searchForm, searchService);
}
return ReportedData.getReportedDataFrom(response);
}
示例12: sendSimpleSearchForm
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* Sends the filled out answer form to be sent and queried by the search
* service.
*
* @param con
* the current Connection.
* @param searchForm
* the <code>Form</code> to send for querying.
* @param searchService
* the search service to use. (ex. search.jivesoftware.com)
* @return ReportedData the data found from the query.
* @throws org.jivesoftware.smack.XMPPException
* thrown if a server error has occurred.
*/
public ReportedData sendSimpleSearchForm(Connection con, Form searchForm,
String searchService) throws XMPPException {
SimpleUserSearch search = new SimpleUserSearch();
search.setForm(searchForm);
search.setType(IQ.Type.SET);
search.setTo(searchService);
PacketCollector collector = con
.createPacketCollector(new PacketIDFilter(search.getPacketID()));
con.sendPacket(search);
IQ response = (IQ) collector.nextResult(SmackConfiguration
.getPacketReplyTimeout());
// Cancel the collector.
collector.cancel();
if (response == null) {
throw new XMPPException("No response from server on status set.");
}
if (response.getError() != null) {
throw new XMPPException(response.getError());
}
if (response instanceof SimpleUserSearch) {
return ((SimpleUserSearch) response).getReportedData();
}
return null;
}
示例13: performSearch
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* Starts a search based on the Answered form.
*/
public void performSearch() {
searchResults.clearTable();
SwingWorker worker = new SwingWorker() {
ReportedData data;
public Object construct() {
try {
Form answerForm = questionForm.getFilledForm();
data = searchManager.getSearchResults(answerForm, serviceName);
}
catch (XMPPException e) {
Log.error("Unable to load search service.", e);
}
return data;
}
public void finished() {
if (data != null) {
searchResults.showUsersFound(data);
searchResults.invalidate();
searchResults.validate();
searchResults.repaint();
}
else {
JOptionPane.showMessageDialog(searchResults, Res.getString("message.no.results.found"), Res.getString("title.notification"), JOptionPane.ERROR_MESSAGE);
}
}
};
worker.start();
}
示例14: getFirstValue
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
/**
* Returns the first value found in the ReportedData.Row.
*
* @param row the ReportedData.Row.
* @param key the specified key in the ReportedData.Row.
* @return the first value found in the ReportedData.Row
*/
public String getFirstValue(ReportedData.Row row, String key) {
try {
final Iterator<String> rows = row.getValues(key);
while (rows.hasNext()) {
return rows.next();
}
}
catch (Exception e) {
Log.error("Error retrieving the first value.", e);
}
return null;
}
示例15: ChatSearchResult
import org.jivesoftware.smackx.ReportedData; //导入依赖的package包/类
public ChatSearchResult(ReportedData.Row row, String query) {
UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));
String startDate = getFirstValue(row, "startDate");
try {
creationDate = UTC_FORMAT.parse(startDate);
}
catch (ParseException e) {
Log.error(e);
}
sessionID = getFirstValue(row, "sessionID");
StringBuffer authors = new StringBuffer();
Iterator athrs = row.getValues("agentJIDs");
while (athrs.hasNext()) {
authors.append((String)athrs.next());
authors.append(" ");
}
String rell = getFirstValue(row, "relevance");
Double o = Double.valueOf(rell);
relevance = ((int)o.doubleValue() * 100);
question = getFirstValue(row, "question");
customerName = getFirstValue(row, "username");
email = getFirstValue(row, "email");
fields.add(customerName);
fields.add(question);
fields.add(email);
fields.add(authors.toString());
fields.add(creationDate);
}