001: /*
002: * Created on 08-Apr-2005
003: *
004: */
005: package com.jofti.core;
006:
007: import java.util.Map;
008:
009: import com.jofti.api.IndexQuery;
010: import com.jofti.exception.JoftiException;
011: import com.jofti.introspect.ClassIntrospector;
012: import com.jofti.parser.ParserManager;
013:
014: /**
015: *
016: *
017: * The Internal IndexCache is the core interface that IndexCache implmentations must implement.
018: * This allows Adapters and the IndexCache Manager to interact with the IndexCache implementation.<p>
019: *
020: * @author xenephon (xenephon@jofti.com)
021: */
022: public interface InternalIndex {
023:
024: /**
025: * Puts an object into the underlying index instance and indexes the object according to
026: * the class definitions in the index config file. Some indexes may only accept certain types of
027: * object.<p>
028: * @param key value to use as key in the index
029: * @param value value to put into cache and to be indexed
030: * @throws JoftiException thrown as a wrapper exception that contains any index specific exceptions.
031: */
032: public void insert(Object key, Object value)
033: throws IllegalArgumentException, JoftiException;
034:
035: public void insertEntry(Object key, Object value)
036: throws IllegalArgumentException, JoftiException;
037:
038: /**
039: * Deletes an object from the index. Attempting to remove a non-existent, or expired object will
040: * not generate an exception.
041: * <p>
042: * @param key -the key to retrieve the cached object
043: * @param value - the object to be removed
044: * @throws JoftiException - A wrapper for any cache specific exceptions or exceptions generated by the index.
045: */
046: public void remove(Object key, Object value)
047: throws IllegalArgumentException, JoftiException;
048:
049: /**
050: * Deletes all entries for the key from the index. Attempting to remove a non-existent, or expired object will
051: * not generate an exception.
052: * <p>
053: * @param key -the key to retrieve the cached object
054: * @throws JoftiException - A wrapper for any cache specific exceptions or exceptions generated by the index.
055: */
056: public void removeByKey(Object key) throws JoftiException;
057:
058: /**
059: * Returns a Map of attribute values that the index has for the key from the index.
060: * <p>
061: * @param key -the key to retrieve the cached object
062: * @throws JoftiException - A wrapper for any cache specific exceptions or exceptions generated by the index.
063: */
064: public Map getAttributesByKey(Object key) throws JoftiException;
065:
066: /**
067: * Returns whether the index contains the key.
068: * <p>
069: * @param key -the key to check
070: * @throws JoftiException - A wrapper for any cache specific exceptions or exceptions generated by the index.
071: */
072:
073: public boolean contains(Object key) throws JoftiException;
074:
075: /**
076: * Returns the keys that are stored under the entry.
077: * <p>
078: * @param key -the object to check
079: * @throws JoftiException - A wrapper for any cache specific exceptions or exceptions generated by the index.
080: */
081: public Map getEntries(Object key) throws JoftiException;
082:
083: /**
084: * This will remove all the values in the cache and dump the current index.<p>
085: * @throws JoftiException
086: */
087: public void removeAll() throws JoftiException;
088:
089: /**
090: * This queries the index and retrieves a map of matching elements (if any). The map contains
091: * key/value pairs and the result is ordered by the attribute being searched on (if a single attribute is used in the query).
092: * The ordering is preserved in the iteration as it is a @seejava.util.LinkedHashMap.
093: * <p>
094: * If you are using a NameSpacedIndex the keys returned
095: * in this map are of type @see NameSpaceKey.
096: * <p>
097: * @param query - the type of query to perform against the index and cache.
098: * <p>
099: * @return Map a map of the results<br>
100: * @throws JoftiException a wrapper exception for errors in the query. <br>
101: */
102: public Map query(IndexQuery query) throws JoftiException;
103:
104: public long getKeyNumber();
105:
106: public ClassIntrospector getIntrospector();
107:
108: /**
109: * Returns the parser manager configured in this index.
110: * @return ParserManager
111: */
112: public ParserManager getParserManager();
113:
114: }
|