001 /**
002 * hammurapi-rules @mesopotamia.version@
003 * Hammurapi rules engine.
004 * Copyright (C) 2005 Hammurapi Group
005 *
006 * This program is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 2 of the License, or (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with this library; if not, write to the Free Software
018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019 *
020 * URL: http://http://www.hammurapi.biz
021 * e-Mail: support@hammurapi.biz
022 */
023 package biz.hammurapi.rules;
024
025 import java.util.Collection;
026
027 import javax.rules.Handle;
028
029 /**
030 * Handle manager - creates and maintains handle -> object
031 * mappings.
032 * @author Pavel Vlasov
033 * @version ${Revision}
034 */
035 public interface HandleManager extends Negatable {
036
037 /**
038 * Establishes Handle -> Object mapping.
039 * @param object
040 * @return
041 */
042 Handle addObject(Object object);
043
044 /**
045 * Retrieves object by handle
046 * @param handle
047 * @return
048 */
049 Object getObject(Handle handle);
050
051 /**
052 * @return All objects with handles.
053 */
054 Collection getObjects();
055
056 /**
057 * @return All handles.
058 */
059 Collection getHandles();
060
061 /**
062 * Removes object entry by key.
063 * @param handle
064 */
065 void remove(Handle handle);
066
067 /**
068 * Removes object entry by value;
069 * @param obj
070 */
071 void remove(Object obj);
072
073 /**
074 * @param handle
075 * @return True there is a mapping with given handle in the manager.
076 */
077 boolean contains(Handle handle);
078
079 /**
080 * Rebinds handle to another object
081 * @param handle
082 * @param object
083 */
084 void rebind(Handle handle, Object object);
085
086 /**
087 * Removes all mappings.
088 */
089 void clear();
090 }