A voir également:
- [JAVA] Aide pour le démarrage d'un projet
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel football - Télécharger - Jeux vidéo
- Pc lent au démarrage - Guide
- Forcer demarrage pc - Guide
- Reinitialiser pc au demarrage - Guide
7 réponses
Voici les différentes interfaces qui sont fournis avec l'énoncé
import java.util.Collection; /** Represents a context strategy i.e. how to obtain a context * of the indexed words. * * * @see FoogleFacade#getAllContextStrategies() * @see FoogleFacade#createIndex(ContextStrategy) */ public interface ContextStrategy { /** Retruns the name of the Strategy. * @return the name of the current strategy. */ public String getName(); /** Returns the context of a result, * this result must be created by a query on an * index that use the current strategy. * * @param result of a qery on an index that * used this strategy. * @return an unmodifiable list of words representing * the context of the result. * * @throws IllegalArgumentException if the result is not created * with an index using this strategy. * *@see Index#getContextStrategy() */ public Collection<? extends CharSequence> getContext(Result result); }
import java.io.File; import java.io.IOException; import java.io.Reader; import java.util.Map; import java.util.regex.Pattern; /** Access point for creating, loading, saving foogle index and * performs some queries on it. * */ public interface FoogleFacade { /** Creates an in-memory index with a specified strategy * and appends all words extracted of a specific file. * @param strategy the context strategy used to create the index. * @param file all words of the file will be appended in the index. * @return a new in-memory index. * @throws IOException if the file doesn't exists or is unreadable. */ public Index createIndex(File file,ContextStrategy strategy) throws IOException; /** Creates an in-memory index with a specified strategy * and appends all words extracted of a specific file. * All words are appended with the line of the reader and the specifed filename. * * Words are separated using the java whitespace rule * (code)\p{javaWhitespace}(/code) (see {@link Pattern}) * and word are indexed is its length is greater or equals to 3. * * @param strategy the context strategy used to create the index. * @param filename filename used for all word from the reader. * @param reader all words contained in the reader will be appended line by line * in the index. * @return a new in-memory index. * @throws IOException if the file doesn't exists or is unreadable. * */ public Index createIndex(String filename,Reader reader,ContextStrategy strategy) throws IOException; /** Creates an in-memory index with a specified strategy * and appends all words extracted of a specific file in the specified index. * All words are appended with the line of the reader and the specifed filename. * @param strategy the context strategy used to create the index. * @param filename filename used for all word from the reader. * @param reader all words contained in the reader will be appended line by line * in the index. * @param accepter specifies how to separate word in the reader and * which words are indexable. * @return a new in-memory index. * @throws IOException if the file doesn't exists or is unreadable. * * @see */ public Index createIndex(String filename,Reader reader,WordAccepter accepter,ContextStrategy strategy) throws IOException; /** Loads an index stored in a file in memory. * @param indexFile file that store the index. * @return an in-memory index corresponding to the file. * @throws IOException raised if there is input/output problems. */ public Index loadIndex(File indexFile) throws IOException; /** Saves an index in a spacific file. * @param index the index to store. * @param indexFile file that will store the index. * @throws IOException raised if there is input/output problems. */ public void saveIndex(Index index,File indexFile) throws IOException; /** Returns a query factory specific to an index. * @param index the queries will be created on this index. * @return a new query factory. * * @see Query#execute(int) */ public QueryFactory createQueryFactory(Index index); /** Returns all context strategies understood by the facade. * This method must returned at least the "none" context strategy. * @return an unmodifiable map of context strategies associated * with their names. */ public Map<String,? extends ContextStrategy> getContextStrategyMap(); }
/** Represents an index of Foogle. * * */ public interface Index { /** Returns the name of the indexed file. * @return the name of the indexed file. */ public String getFilename(); /** Returns the context startegy used by the current index. * @return the context strategy. * * @see FoogleFacade#createIndex(ContextStrategy) * @see FoogleFacade#getAllContextStrategies() */ public ContextStrategy getContextStrategy(); }
/** Represents a query to an index. * The query is specific to an index. * * * @see QueryFactory * @see FoogleFacade#createQueryFactory(Index) */ public interface Query { /** Query the index to find results corresponding to a * specific query. * * @return the result of the query. * * @see Query#execute(int) */ public Iterable<? extends Result> execute(); /** Query the index to find results corresponding to a * specific query. * * @param maxCount a positive integer * * @return the result of the query. * * @see QueryFactory * @see FoogleFacade#createQueryBuilder(String) */ public Iterable<? extends Result> execute(int maxCount); }
import java.util.regex.Pattern; /** Factory used to create index queries, * The factory is specific to an index. * * All results returned by {@link Query#execute()} * on these queries are garanteed to have distinct * line numbers (see {@link Result#getLine()}). * */ public interface QueryFactory { /** Creates a query for a simple word. * * @param word the queried word. * @return a new query. */ public Query query(CharSequence word); /** Creates a query for a regex. * * @param pattern the queried regex. * @return a new query. */ public Query query(Pattern pattern); /** Create a new query by oring query1 and query2. * * @param query1 the first query. * @param query2 the second query. * @return the new query. */ public Query or(Query query1,Query query2); /** Create a new query by anding query1 and query2. * @param query1 the first query. * @param query2 the second query. * @return the new query. */ public Query and(Query query1,Query query2); }
/** Result of a query, represents a location in a line of a file. * * A result can have a specific context value associated with it * depending on the index strategy, use * {@link ContextStrategy#getContext(Result)} to obtain such context. * * * @see Index#executeQuery(Query) */ public interface Result { /** Returns the line number containing * the result * @return a line number. */ public int getLine(); }
import java.util.Scanner; import java.util.regex.Pattern; /** This interface specifies * how words are delimited in a text * using a regex pattern * {@link #getDelimiterRegex()} * and which word are indexed * {@link #isIndexable(CharSequence)}. * */ public interface WordAccepter { /** Returns the regex pattern used to separate words. * @return a regex pattern. * * @see Scanner#useDelimiter(Pattern) */ public Pattern getDelimiterRegex(); /** Indicates if a word should be indexed or not. * @param word the word * @return true if the word is indexable, false otherwise. */ public boolean isIndexable(CharSequence word); }
Salut,
d'une part, l'énoncé ne m'est pas clair et d'une autre, je ne vois pas très bien si les classes qui doivent implémentées les interfaces doivent être abstraites, concrètes...
Si quelqu'un pouvait m'indiquer des pistes, des classes qu'il me faudrait utiliser,etc... pour que je puisse m'avancer.
Merci d'avance
d'une part, l'énoncé ne m'est pas clair et d'une autre, je ne vois pas très bien si les classes qui doivent implémentées les interfaces doivent être abstraites, concrètes...
Si quelqu'un pouvait m'indiquer des pistes, des classes qu'il me faudrait utiliser,etc... pour que je puisse m'avancer.
Merci d'avance
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
arth
Messages postés
9374
Date d'inscription
mardi 27 septembre 2005
Statut
Contributeur
Dernière intervention
16 décembre 2016
1 291
7 juin 2006 à 23:11
7 juin 2006 à 23:11
En gros cest à toi de faire toutes les fonctions données cest bien ca?
Moi je veux bien tenter de t'aider,mais je vais pas avoir trop le temps cette semaine i la semaine prochaine. C'est pour quand ton projet?
Moi je veux bien tenter de t'aider,mais je vais pas avoir trop le temps cette semaine i la semaine prochaine. C'est pour quand ton projet?