Example #1
0
        /**
         * Suggestions must be added with the best suggestion first.  ORDER is important.
         * @param token The {@link org.apache.lucene.analysis.Token}
         * @param suggestion The suggestion for the Token
         * @param docFreq The document frequency
         */
        public void add(Token token, string suggestion, int docFreq)
        {
            LinkedHashMap /*<String, Integer>*/ map = (LinkedHashMap)this.suggestions.get(token);

            //Don't bother adding if we already have this token
            if (map == null)
            {
                map = new LinkedHashMap/*<String, Integer>*/ ();
                this.suggestions.put(token, map);
            }
            map.put(suggestion, docFreq);
        }
Example #2
0
        /**
         * Adds a whole bunch of suggestions, and does not worry about frequency.
         *
         * @param token The token to associate the suggestions with
         * @param suggestions The suggestions
         */
        public void add(Token token, List /*<String>*/ suggestions)
        {
            LinkedHashMap /*<String, Integer>*/ map = (LinkedHashMap)this.suggestions.get(token);

            if (map == null)
            {
                map = new LinkedHashMap/*<String, Integer>*/ ();
                this.suggestions.put(token, map);
            }
            for (var iter = suggestions.iterator(); iter.hasNext();)
            {
                string suggestion = (string)iter.next();
                map.put(suggestion, NO_FREQUENCY_INFO);
            }
        }
Example #3
0
                                                 > sort(System.Collections.Generic.ICollection <KeyValuePair <string, FieldInfo> > entrySet)
 {
     System.Collections.Generic.IDictionary <string, FieldInfo
                                             > sorted = new java.util.LinkedHashMap <string, VPackCache.FieldInfo
                                                                                     >();
     System.Collections.Generic.IList <KeyValuePair <string, FieldInfo> > tmp = new System.Collections.Generic.List
                                                                                <KeyValuePair <string, FieldInfo> >(entrySet);
     tmp.Sort(this.fieldComparator);
     foreach (System.Collections.Generic.KeyValuePair <string, FieldInfo
                                                       > entry in tmp)
     {
         sorted[entry.Key] = entry.Value;
     }
     return(sorted);
 }
Example #4
0
 /**
  * Adds an extra field - replacing an already present extra field
  * of the same type.
  *
  * <p />If no extra field of the same type exists, the field will be
  * added as last field.
  * @param ze an extra field
  */
 public void addExtraField(ZipExtraField ze)
 {
     if (ze is UnparseableExtraFieldData)
     {
         unparseableExtra = (UnparseableExtraFieldData)ze;
     }
     else
     {
         if (extraFields == null)
         {
             extraFields = new java.util.LinkedHashMap <ZipShort, ZipExtraField>();
         }
         extraFields.put(ze.getHeaderId(), ze);
     }
     setExtra();
 }
Example #5
0
 /**
  * Replaces all currently attached extra fields with the new array.
  * @param fields an array of extra fields
  */
 public void setExtraFields(ZipExtraField[] fields)
 {
     extraFields = new java.util.LinkedHashMap <ZipShort, ZipExtraField>();
     for (int i = 0; i < fields.Length; i++)
     {
         if (fields[i] is UnparseableExtraFieldData)
         {
             unparseableExtra = (UnparseableExtraFieldData)fields[i];
         }
         else
         {
             extraFields.put(fields[i].getHeaderId(), fields[i]);
         }
     }
     setExtra();
 }
Example #6
0
 /**
  * Adds an extra field - replacing an already present extra field
  * of the same type.
  *
  * <p />The new extra field will be the first one.
  * @param ze an extra field
  */
 public void addAsFirstExtraField(ZipExtraField ze)
 {
     if (ze is UnparseableExtraFieldData)
     {
         unparseableExtra = (UnparseableExtraFieldData)ze;
     }
     else
     {
         java.util.LinkedHashMap <ZipShort, ZipExtraField> copy = extraFields;
         extraFields = new java.util.LinkedHashMap <ZipShort, ZipExtraField>();
         extraFields.put(ze.getHeaderId(), ze);
         if (copy != null)
         {
             copy.remove(ze.getHeaderId());
             extraFields.putAll(copy);
         }
     }
     setExtra();
 }