Package it.unimi.dsi.mg4j.util

Examples of it.unimi.dsi.mg4j.util.MutableString


    
       if ((urlStr==null || urlStr.length()<=0) && (docId==null || indexId==null)) {
           throw new BadQueryException("Url is empty.");
       }
       // Construct the search url.
       MutableString ms = new MutableString(this.searchUrlBase)
           .append("?query=");
       // Add 'date:...+' to query string.   
       if (existStartDate || existEndDate) { // BUG wayback 0000051;  if exist startDate OR endDate
         ms.append("date%3A").append(startDateStr).append('-').append(endDateStr);  
       }    
       else if (exactDateStr!=null) { // BUG wayback 0000153
         ms.append("closestdate%3A").append(exactDateStr);
       }
      
       ms.append('+');
       // Add 'url:URL'.
       if(wbRequest.get(WaybackConstants.REQUEST_TYPE).equals(
                  WaybackConstants.REQUEST_URL_PREFIX_QUERY)) {
           ms.append("url%3A").append(urlStr);
       } else {
           try {       
           if (docId!=null && indexId!=null) {
             // do nothing
           }
           else if (wbRequest.get(WaybackConstants.REQUEST_ALIASES)!=null && wbRequest.get(WaybackConstants.REQUEST_ALIASES).equals("true")) {
                ms.append("exacturlexpand%3A").append(java.net.URLEncoder.encode(urlStr, "UTF-8"));
           }
           else {                        
            URL url=null;
            boolean error=false;
            try {
              url=new URL(urlStr);
            }
            catch (MalformedURLException e) {
              error=true;
            }
            
            if (!error && !urlStr.endsWith("/") && url.getQuery()==null && url.getPath().indexOf('.')==-1) { // BUG nutchwax 0000357 - add also a "/" if the url's query is null and is not a file
              ms.append("exacturlexpandmin%3A").append(java.net.URLEncoder.encode(urlStr, "UTF-8"));
            }
            else {            
              ms.append("exacturl%3A").append(java.net.URLEncoder.encode(urlStr, "UTF-8"));
            }
           }
           }
           catch (UnsupportedEncodingException e) {
             throw new BadQueryException(e.toString());
           }
           catch (NullPointerException e) {
               throw new BadQueryException(e.toString());
           }
       }
       ms.append("&hitsPerPage=").append(hitsPerPage);
       ms.append("&start=").append(start);
       ms.append("&dedupField=site");       
       // As we are always searching agains an url, a
       // higher perDup/Site will return just more versions
       ms.append("&hitsPerDup=").append(hitsPerPage);
       ms.append("&hitsPerSite=").append(hitsPerPage);      
       ms.append("&waybackQuery=true"); // indicates that this OpenSearch request came from wayback      
                     
       /* BUG 0000155 */       
        if (multDet!=null) {
          ms.append("&multDet=").append(multDet);
        }              
     if (docId!=null) {
       ms.append("&id=").append(docId);
     }        
     if (indexId!=null) {
       ms.append("&index=").append(indexId);
     }
     /* BUG 0000155 */       
      
       return ms.toString();
   }
View Full Code Here


            String tab ="\t";
            out.write("# Heritrix Cookie File\n".getBytes());
            out.write("# This file is the Netscape cookies.txt format\n\n".getBytes());
            for (Cookie cookie: new ArrayList<Cookie>(getCookies())) {
                // Guess an initial size
                MutableString line = new MutableString(1024 * 2);
                line.append(cookie.getDomain());
                line.append(tab);
                // XXX line.append(cookie.isDomainAttributeSpecified() ? "TRUE" : "FALSE");
                line.append("TRUE");
                line.append(tab);
                line.append(cookie.getPath() != null ? cookie.getPath() : "/");
                line.append(tab);
                line.append(cookie.isSecure() ? "TRUE" : "FALSE");
                line.append(tab);
                line.append(cookie.getExpiryDate() != null ? cookie.getExpiryDate().getTime() / 1000 : -1);
                line.append(tab);
                line.append(cookie.getName());
                line.append(tab);
                line.append(cookie.getValue() != null ? cookie.getValue() : "");
                line.append("\n");
                out.write(line.toString().getBytes());
            }
        } catch (IOException e) {
            logger.log(Level.SEVERE, "Unable to write " + saveCookiesFile, e);
        } finally {
            IOUtils.closeQuietly(out);
View Full Code Here

TOP

Related Classes of it.unimi.dsi.mg4j.util.MutableString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.