⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proxyservlet.java

📁 关于Ultraseek的一些用法,刚初学,所以都是比较简单
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    StandardSearchTopic superTopic = sst.getSuperTopic();    String blurb = sst.getBlurb();    String keywords = sst.getKeywords();    Map urls = sst.getURLs();    dos.writeUTF(name!=null?name:"");    dos.writeUTF(id);    dos.writeUTF(superTopic!=null?superTopic.getID():"");    dos.writeUTF(blurb!=null?blurb:"");    dos.writeUTF(keywords!=null?keywords:"");    Iterator it = urls.entrySet().iterator();    int numURLs = urls.size();    dos.writeInt(numURLs);    for (int i=0; i<numURLs; i++) {      Map.Entry e = (Map.Entry)it.next();      URL url = (URL)e.getKey();      int stars = ((Integer)e.getValue()).intValue();      dos.writeUTF(url.toString());      dos.writeInt(stars);    }  }  private void     writeTopic(DataOutputStream dos, CrossReferenceSearchTopic crst)    throws IOException  {    String id = crst.getID();    String name = crst.getName();    StandardSearchTopic superTopic = crst.getSuperTopic();    StandardSearchTopic xref = crst.getCrossReference();    dos.writeUTF(name!=null?name:"");    dos.writeUTF(id);    dos.writeUTF(superTopic!=null?superTopic.getID():"");    dos.writeUTF(xref!=null?xref.getID():"");  }  private void     writeTopic(DataOutputStream dos, SearchTopic st)    throws IOException  {    if (st instanceof StandardSearchTopic) {      StandardSearchTopic sst = (StandardSearchTopic)st;      dos.writeInt(1);      writeTopic(dos,sst);    } else {      CrossReferenceSearchTopic crst = (CrossReferenceSearchTopic)st;      dos.writeInt(2);      writeTopic(dos,crst);    }  }  private void     writeTopics(DataOutputStream dos, Collection topics)    throws IOException  {    Iterator it = topics.iterator();    while (it.hasNext()) {      SearchTopic st = (SearchTopic)it.next();      writeTopic(dos,st);    }    dos.writeInt(-1);  }  private void     writeTopics(DataOutputStream dos)    throws IOException  {    Map topics = new HashMap();    Stack stack = new Stack();    Iterator it1 = servers.iterator();    while (it1.hasNext()) {      SearchServer server = (SearchServer)it1.next();      SearchTopic st = server.getSearchTopic("0");      if (st==null) continue;      String id = st.getID();      if (!topics.containsKey(id)) topics.put(id,st);      if (st instanceof StandardSearchTopic) {        stack.push(st);        while (!stack.empty()) {          StandardSearchTopic sst = (StandardSearchTopic)stack.pop();          Collection subTopics = sst.getSubTopics();          if (subTopics!=null) {            Iterator it2 = sst.getSubTopics().iterator();            while (it2.hasNext()) {              st = (SearchTopic)it2.next();              id = st.getID();              if (topics.containsKey(id)) continue;              topics.put(id,st);              if (st instanceof StandardSearchTopic) stack.push(st);            }          }        }      }    }    writeTopics(dos,topics.values());  }  private void     writeHeader(DataOutputStream dos, int resultCount, int size,                int docCount, Locale locale)    throws IOException  {    dos.writeInt(1);    dos.writeInt(resultCount);    dos.writeInt(size);    dos.writeInt(docCount);    dos.writeUTF(locale_la(locale));    dos.writeLong(configurationTimestamp);    dos.writeLong(topicsTimestamp);  }  private void     writeTopicIDs(DataOutputStream dos, Collection topics)    throws IOException  {    Iterator it = topics.iterator();    int numTopics = topics.size();    dos.writeInt(numTopics);    for (int i=0; i<numTopics; i++) {      SearchTopic st = (SearchTopic)it.next();      dos.writeUTF(st.getID());    }  }  private void     writeTermFrequencies(DataOutputStream dos, Map termFrequencies)    throws IOException  {    Iterator it = termFrequencies.entrySet().iterator();    int numTermFrequencies = termFrequencies.size();    dos.writeInt(numTermFrequencies);    for (int i=0; i<numTermFrequencies; i++) {      Map.Entry e = (Map.Entry)it.next();      String term = (String)e.getKey();      int frequency = ((Integer)e.getValue()).intValue();      dos.writeUTF(term);      dos.writeInt(frequency);    }  }  private void     writeExtra(DataOutputStream dos, Map extra)    throws IOException  {    Iterator it = extra.entrySet().iterator();    int numExtra = extra.size();    dos.writeInt(numExtra);    for (int i=0; i<numExtra; i++) {      Map.Entry e = (Map.Entry)it.next();      String key = e.getKey().toString();      String value = e.getValue().toString();      dos.writeUTF(key);      dos.writeUTF(value);    }  }  private synchronized String     getIDFromCollection(SearchCollection collection)   {    String id = (String)collection_id.get(collection);    if (id!=null) return id;    Iterator it = collection_id.entrySet().iterator();    while (it.hasNext()) {      Map.Entry e = (Map.Entry)it.next();      SearchCollection key = (SearchCollection)e.getKey();      if (collection.getServer()==key.getServer() &&          collection.getID().equals(key.getID())) {        String value = (String)e.getValue();        collection_id.remove(key);        collection_id.put(collection,value);        return value;      }    }    return "";  }  private void    writeResult(DataOutputStream dos, SearchResult result)     throws IOException   {    float score = result.getScore();    String title = result.getTitle();    String description = result.getDescription();    String url = result.getURLString();    String publisher = result.getPublisher();    String fsKeywords = result.getFsKeywords();    int size = result.getSize();    long date = result.getDateLong();    long indexed = result.getIndexedLong();    short flags = result.getFlags();    short remoteLinkCount = result.getRemoteLinkCount();    String col = getIDFromCollection(result.getSearchCollection());    Map termTFs = result.getTermTFs();    Collection topics = result.getTopics();    Map extra = result.getExtra();    dos.writeFloat(score);    dos.writeUTF(title);    dos.writeUTF(description);    dos.writeUTF(url);    dos.writeUTF(publisher);    dos.writeUTF(fsKeywords);    dos.writeInt(size);    dos.writeLong(date);    dos.writeLong(indexed);    dos.writeShort(flags);    dos.writeShort(remoteLinkCount);    dos.writeUTF(col);    writeTermFrequencies(dos,termTFs);    writeTopicIDs(dos,topics);    writeExtra(dos,extra);  }  private void     writeResults(DataOutputStream dos, List results)    throws IOException  {    Iterator it = results.iterator();    while (it.hasNext()) {      SearchResult result = (SearchResult)it.next();      writeResult(dos,result);    }    dos.writeFloat(-1.0f);  }  private static Collection split(String string) {    Collection collection = new ArrayList();    int length = string.length();    for (int start=0,i; start<length; start=i+1) {      for (i=start; i<length; i++) {        if (string.charAt(i)==' ') break;      }      String substring = string.substring(start,i);      collection.add(substring);    }    return collection;  }  private Searchable    makeSearchable(String string)     throws IOException  {    Collection strings = split(string);    List searchables = new ArrayList(strings.size());    Iterator it = strings.iterator();    while (it.hasNext()) {      Searchable s = (Searchable)id_searchable.get(it.next());      if (s!=null) searchables.add(s);    }    for (int i=0; i<searchables.size(); i++) {      Searchable s = (Searchable)searchables.get(i);      if (s instanceof SearchCollection) {        SearchCollection sc = (SearchCollection)s;        SearchServer ss = sc.getServer();        Collection ids = null;        for (int j=i+1; j<searchables.size(); j++) {          Searchable s1 = (Searchable)searchables.get(j);          if (s1 instanceof SearchCollection) {            SearchCollection sc1 = (SearchCollection)s1;            SearchServer ss1 = sc1.getServer();            if (ss==ss1) {              if (ids==null) {                ids = new ArrayList();                ids.add(sc.getID());              }              ids.add(sc1.getID());              searchables.remove(j);              j--;            }          }        }        if (ids!=null) {          searchables.set(i,ss.searchable(            (String[])ids.toArray(new String[ids.size()])));        }      }    }    if (searchables.size()==0) return null;    if (searchables.size()==1) return (Searchable)searchables.get(0);    return new CompositeSearchable(      (Searchable[])searchables.toArray(        new Searchable[searchables.size()]));  }  private synchronized Searchable    getSearchable(String col)    throws IOException  {    Searchable s = (Searchable)id_searchable.get(col);    if (s!=null) return s;    s = makeSearchable(col);    if (s!=null) id_searchable.put(col,s);    return s;  }  private Query     getQuery(      HttpServletRequest req, Locale locale,      String qt, String ct, long after, long before)     throws IOException  {    Query qry = (qt!=null)? Query.parse(qt,locale) : null;    if (ct!=null) {      Iterator it = servers.iterator();      while (it.hasNext()) {        SearchServer server = (SearchServer)it.next();        SearchTopic topic = server.getSearchTopic(ct);        if (topic==null) continue;        Query q = new TopicQuery(topic);        qry = (qry==null)? q : new FilterQuery(new Query[]{q,qry});        break;      }    }     if (qry!=null && after>Long.MIN_VALUE && before<Long.MAX_VALUE) {       Query q = new DateRangeQuery(new Date(after),new Date(before));      qry = new FilterQuery(new Query[]{qry,q});    }    return qry;  }  private static String locale_la(Locale locale) {    String la = locale.getLanguage();    if (la.equals("zh")) la = locale.toString().toLowerCase(Locale.ENGLISH);    if (la.equals("iw")) la = "he";    return la;  }  private static Map la_locale_map = new HashMap(64);  static {     la_locale_map.put("de",Locale.GERMAN);    la_locale_map.put("en",Locale.ENGLISH);    la_locale_map.put("fr",Locale.FRENCH);    la_locale_map.put("it",Locale.ITALIAN);    la_locale_map.put("ja",Locale.JAPANESE);    la_locale_map.put("ko",Locale.KOREAN);    la_locale_map.put("zh_cn",Locale.SIMPLIFIED_CHINESE);    la_locale_map.put("zh_tw",Locale.TRADITIONAL_CHINESE);    Locale[] locales = Locale.getAvailableLocales();    for (int i=0; i<locales.length; i++) {      Locale locale = locales[i];      String la = locale_la(locale);      if (!la_locale_map.containsKey(la)) la_locale_map.put(la,locale);    }  }  private static Locale la_locale(String la) {    if (la==null) return null;    return (Locale)la_locale_map.get(la);  }  private static int     getIntParameter(HttpServletRequest req, String name, int dflt)   {    String value = req.getParameter(name);    if (value==null) return dflt;    return Integer.parseInt(value);  }  private static long    getLongParameter(HttpServletRequest req, String name, long dflt)   {    String value = req.getParameter(name);    if (value==null) return dflt;    return Long.parseLong(value);  }  /** decode the "String" value, representing a sequence of bytes in   * "charset", returns the decoded string.   * @param value A string, which is actually a sequence of non-decoded bytes.   * @param charset The character set name to decode from.   */  private static String     decode(String value,String charset)     throws UnsupportedEncodingException  {    if (value==null) return value;    byte[] bytes = new byte[value.length()];    /* Convert the "string" to a sequence of bytes */    for (int i = 0; i < value.length(); i++) {      char ch = value.charAt(i);      if ((int) ch <= 0xFF)        bytes[i] = (byte) ch;      else        /* This decode() does not support decoding from           UTF-16, UTF-16LE, or UTF-16BE */        throw new UnsupportedEncodingException();    }    /* Now convert the bytes to the proper charset */    return new String(bytes,charset);  }  private static final Collection emptyCollection    = Collections.unmodifiableCollection(new ArrayList());      private static final List emptyList    = Collections.unmodifiableList(new ArrayList());      private static final Map emptyMap    = Collections.unmodifiableMap(new HashMap());  public static long configurationRefreshInterval = 60*60*1000;  public static long topicsRefreshInterval = 60*60*1000;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -