diff options
author | mmayworm | 2009-04-28 19:28:52 +0000 |
---|---|---|
committer | mmayworm | 2009-04-28 19:28:52 +0000 |
commit | 8cb02de19d08c8dac9c3aa05c48c4b78e411f8d4 (patch) | |
tree | 59948842466fe5976897e6b741e39ed556cef106 | |
parent | 860ac5e46e5ef204ad2c394177b50a5067e59a3e (diff) | |
download | org.eclipse.ecf-8cb02de19d08c8dac9c3aa05c48c4b78e411f8d4.tar.gz org.eclipse.ecf-8cb02de19d08c8dac9c3aa05c48c4b78e411f8d4.tar.xz org.eclipse.ecf-8cb02de19d08c8dac9c3aa05c48c4b78e411f8d4.zip |
bug 273151: adding message search api
7 files changed, 286 insertions, 0 deletions
diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageResult.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageResult.java new file mode 100644 index 000000000..a5b5bbad6 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageResult.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: Marcelo Mayworm - initial API and implementation + * + ******************************************************************************/ +package org.eclipse.ecf.presence.search.message; + +import org.eclipse.ecf.presence.im.IChatMessage; +import org.eclipse.ecf.presence.search.IResult; + +/** + * Each result returned for the message search will be reach through this interface. + * The result contain the message that match the search. + * @since 2.0 + */ +public interface IMessageResult extends IResult { + + /** + * Get message for the search. This is the message that comes from the search. + * + * @return {@link IChatMessage} message associated with the search. Will not be <code>null</code> + */ + public IChatMessage getMessage(); +} diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchCompleteEvent.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchCompleteEvent.java new file mode 100644 index 000000000..b1957a12f --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchCompleteEvent.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: Marcelo Mayworm - initial API and implementation + * + ******************************************************************************/ + +package org.eclipse.ecf.presence.search.message; + +import org.eclipse.ecf.presence.search.ISearch; + +/** + * + * @since 2.0 + * + */ +public interface IMessageSearchCompleteEvent extends IMessageSearchEvent { + + /** + * Provide the result for a non-blocking search + * @return ISearch + */ + public ISearch getSearch(); + +} diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchEvent.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchEvent.java new file mode 100644 index 000000000..4732984b0 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchEvent.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: Marcelo Mayworm - initial API and implementation + * + ******************************************************************************/ + +package org.eclipse.ecf.presence.search.message; + +import org.eclipse.ecf.core.util.Event; + +/** + * An event received by a message search. This interface address the events + * that happens on user search API. There be different sub-interfaces of IMessageSearchEvent to + * represent different types of events. + * @since 2.0 + */ +public interface IMessageSearchEvent extends Event { + // +} diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchListener.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchListener.java new file mode 100644 index 000000000..8ff4912e6 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchListener.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: Marcelo Mayworm - initial API and implementation + * + ******************************************************************************/ + +package org.eclipse.ecf.presence.search.message; + +/** + * This Interface allows for implementing classes to execute the search + * for messages in a non block way. Note these methods will be called asynchronously not blocking a search action. + * The provider is free to call the methods below with an arbitrary thread, so the + * implementation of these methods must be appropriately prepared. + * @since 2.0 + */ +public interface IMessageSearchListener { + + /** + * Catch the event fired and proceed to complete the search. + * Handle the search asynchronously. Notify that the search was completed + * for the specific criteria. + * @param event the object that contains the criteria {@link String} + * and deal with the results in a non-blocking way + */ + public void handleMessageSearchEvent(IMessageSearchEvent event); +} diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchManager.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchManager.java new file mode 100644 index 000000000..5c714af36 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/IMessageSearchManager.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: Marcelo Mayworm - initial API and implementation + * + ******************************************************************************/ + +package org.eclipse.ecf.presence.search.message; + +import org.eclipse.ecf.presence.search.*; + +/** + * Get a message search mechanism for an account. + * @since 2.0 + */ +public interface IMessageSearchManager { + + /** + * Execute the search for a specific criteria, blocking until the search returns. + * This method can apply search to match the specific criteria in case if the + * provider is not able to do it completely + * @param criteria Will not be <code>null</code>. + * @return {@link ICriteria} Contain the search results. + * @throws MessageSearchException + */ + public ISearch search(ICriteria criteria) throws MessageSearchException; + + /** + * Execute the search for a specific criteria, not blocking until the search returns. + * This method can apply search to match the specific criteria in case if the + * provider is not able to do it completely. + * The provider is free to call the methods below with an arbitrary thread, so the + * implementation of these methods must be appropriately prepared. + * @param criteria {@link ICriteria}. Must not be <code>null</code>. + * @param listener the listener {@link IMessageSearchListener} to search. Must not be <code>null</code>. + */ + public void search(ICriteria criteria, IMessageSearchListener listener); + + /** + * Create a specific criteria for the provider. Each provider must + * implement a specific Criteria in a convenient approach for keep, + * organize and deal with the {@link ICriterion}. + * @return {@link ICriteria} Will not be <code>null</code> + */ + public ICriteria createCriteria(); + + /** + * Create a specific {@link IRestriction} implementation for the provider. + * This implementation will provide the methods to created and organize + * the {@link ICriterion} that composes the search. The {@link Restriction} + * is a simple implementation of this, but subclasses or new implementation + * may be created as appropriate. + * + * @return {@link IRestriction} Will not be <code>null</code> + */ + public IRestriction createRestriction(); + +} diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/MessageSearchCompleteEvent.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/MessageSearchCompleteEvent.java new file mode 100644 index 000000000..e22497c8e --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/MessageSearchCompleteEvent.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: Marcelo Mayworm - initial API and implementation + * + ******************************************************************************/ + +package org.eclipse.ecf.presence.search.message; + +import org.eclipse.ecf.presence.search.ISearch; + +/** + * + * @since 2.0 + * + */ +public class MessageSearchCompleteEvent implements IMessageSearchCompleteEvent { + + private ISearch search; + + public MessageSearchCompleteEvent(ISearch search) { + this.search = search; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ecf.presence.search.message.IMessageSearchCompleteEvent#getSearch() + */ + public ISearch getSearch() { + return search; + } + + public String toString() { + StringBuffer sb = new StringBuffer("MessageSearchCompleteEvent[search="); //$NON-NLS-1$ + sb.append(getSearch()).append("]"); //$NON-NLS-1$ + return sb.toString(); + } + +} diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/MessageSearchException.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/MessageSearchException.java new file mode 100644 index 000000000..53714bdb4 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/search/message/MessageSearchException.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2008 Marcelo Mayworm. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: Marcelo Mayworm - initial API and implementation + * + ******************************************************************************/ +package org.eclipse.ecf.presence.search.message; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.ecf.core.util.ECFException; + +/** + * + * @since 2.0 + * + */ +public class MessageSearchException extends ECFException { + + /** + * + */ + private static final long serialVersionUID = -2168236531447383111L; + + private String criteria = null; + + /** + * + */ + public MessageSearchException(String criteria) { + super(); + this.criteria = criteria; + } + + /** + * @param status + */ + public MessageSearchException(IStatus status, String criteria) { + super(status); + this.criteria = criteria; + } + + /** + * @param message + * @param cause + */ + public MessageSearchException(String message, Throwable cause, String criteria) { + super(message, cause); + this.criteria = criteria; + } + + /** + * @param message + */ + public MessageSearchException(String message, String criteria) { + super(message); + this.criteria = criteria; + } + + /** + * @param cause + */ + public MessageSearchException(Throwable cause, String criteria) { + super(cause); + this.criteria = criteria; + } + + public String getSearchCriteria() { + return this.criteria; + } + +} |