Example #1
0
 /**
  * Bietet der hoster eine Möglichkeit mehrere links gleichzeitig zu prüfen, kann das über diese
  * Funktion gemacht werden.
  */
 @Override
 public boolean checkLinks(final DownloadLink[] urls) {
   if (urls == null || urls.length == 0) {
     return false;
   }
   try {
     if (Rapidshare.RS_API_WAIT > System.currentTimeMillis()) {
       for (final DownloadLink u : urls) {
         u.setAvailable(true);
         u.getLinkStatus()
             .setStatusText(
                 JDL.L("plugin.host.rapidshare.status.apiflood", "unchecked (API Flood)"));
       }
       return true;
     }
     logger.finest("OnlineCheck: " + urls.length + " links");
     final StringBuilder idlist = new StringBuilder();
     final StringBuilder namelist = new StringBuilder();
     final ArrayList<DownloadLink> links = new ArrayList<DownloadLink>();
     int size = 0;
     for (final DownloadLink u : urls) {
       if (size > 3000) {
         logger.finest("OnlineCheck: SplitCheck " + links.size() + "/" + urls.length + " links");
         /* do not stop here because we are not finished yet */
         this.checkLinksIntern2(links);
         links.clear();
         idlist.delete(0, idlist.capacity());
         namelist.delete(0, namelist.capacity());
       }
       /* workaround reset */
       u.setProperty("htmlworkaround", null);
       idlist.append(",").append(Rapidshare.getID(u.getDownloadURL()));
       namelist.append(",").append(this.getName(u));
       links.add(u);
       size =
           ("https://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles&files="
                   + idlist.toString().substring(1)
                   + "&filenames="
                   + namelist.toString().substring(1)
                   + "&incmd5=1")
               .length();
     }
     if (links.size() != 0) {
       if (links.size() != urls.length) {
         logger.finest("OnlineCheck: SplitCheck " + links.size() + "/" + urls.length + " links");
       } else {
         logger.finest("OnlineCheck: Check " + urls.length + " links");
       }
       if (!this.checkLinksIntern2(links)) {
         return false;
       }
     }
   } catch (final Exception e) {
     e.printStackTrace();
     return false;
   }
   return true;
 }
  /** Prints 36. */
  private static void testStrinBuilderCapacity() {
    String str = "DataDataDataDataData"; // 20 chars

    StringBuilder sb = new StringBuilder();
    System.out.println(sb.capacity()); // 16

    sb = new StringBuilder(str);
    sb.delete(0, sb.length());
    System.out.println(sb.capacity()); // 20 + 16 = 36
  }
  @Override
  public ArrayList<String> getIdentifiers(Context context, T dso) {
    ArrayList<String> identifiers = new ArrayList<>();

    IdentifierService identifierService = new DSpace().getSingletonService(IdentifierService.class);

    if (identifierService != null) {
      identifiers.addAll(identifierService.lookup(context, dso));
    } else {
      log.warn("No IdentifierService found, will return an list containing " + "the Handle only.");
      if (dso.getHandle() != null) {
        identifiers.add(handleService.getCanonicalForm(dso.getHandle()));
      }
    }

    if (log.isDebugEnabled()) {
      StringBuilder dbgMsg = new StringBuilder();
      for (String id : identifiers) {
        if (dbgMsg.capacity() == 0) {
          dbgMsg.append("This DSO's Identifiers are: ");
        } else {
          dbgMsg.append(", ");
        }
        dbgMsg.append(id);
      }
      dbgMsg.append(".");
      log.debug(dbgMsg.toString());
    }

    return identifiers;
  }
 @Test
 public void test18() throws Exception {
   HotSpotInstalledCode installedBenchmarkCode = getInstalledCode("stringBuilder");
   StringBuilder b = (StringBuilder) installedBenchmarkCode.executeVarargs();
   Assert.assertTrue(b.capacity() == 16);
   Assert.assertTrue(b.length() == 0);
 }
Example #5
0
 @Override
 public boolean checkLinks(final DownloadLink[] urls) {
   if (urls == null || urls.length == 0) {
     return false;
   }
   try {
     final Browser br = new Browser();
     prepBrowser(br);
     br.setCookiesExclusive(true);
     final StringBuilder sb = new StringBuilder();
     final ArrayList<DownloadLink> links = new ArrayList<DownloadLink>();
     int index = 0;
     while (true) {
       links.clear();
       while (true) {
         /* we test 50 links at once */
         if (index == urls.length || links.size() > 50) {
           break;
         }
         links.add(urls[index]);
         index++;
       }
       sb.delete(0, sb.capacity());
       sb.append("op=checkfiles&process=Check+URLs&list=");
       for (final DownloadLink dl : links) {
         sb.append(dl.getDownloadURL());
         sb.append("%0A");
       }
       br.postPage("http://qtyfiles.com/?op=checkfiles", sb.toString());
       for (final DownloadLink dllink : links) {
         if (br.containsHTML(
             ">" + dllink.getDownloadURL() + "</td><td style=\"color:red;\">Not found\\!</td>")) {
           dllink.setAvailable(false);
         } else {
           final String[][] linkInformation =
               br.getRegex(
                       ">"
                           + dllink.getDownloadURL()
                           + "</td><td style=\"color:green;\">Found</td><td>([^<>\"]*?)</td>")
                   .getMatches();
           if (linkInformation == null) {
             logger.warning("Linkchecker broken for qtyfiles.com");
             return false;
           }
           String name = extractFileNameFromURL(dllink.getDownloadURL());
           final String size = linkInformation[0][0];
           dllink.setAvailable(true);
           dllink.setName(Encoding.htmlDecode(name).replace(".html", ""));
           dllink.setDownloadSize(SizeFormatter.getSize(size));
         }
       }
       if (index == urls.length) {
         break;
       }
     }
   } catch (final Exception e) {
     return false;
   }
   return true;
 }
  static void printStringBuilder(StringBuilder sb) {
    String str = sb.toString();
    // 버퍼의 문자열을 String 객체로 만들어서 리턴하는 메소오오드

    int len = sb.length();
    // 버퍼의 문자열 길이를 리턴하는 메소드

    int bufsize = sb.capacity();
    System.out.printf("%s(%d): %d %n", str, len, bufsize);
  }
Example #7
0
 public static int extractDigitFromText(String text) throws CommonTestException {
   Pattern pat = Pattern.compile("\\d{1}");
   Matcher m = pat.matcher(text);
   StringBuilder numbers = new StringBuilder();
   while (m.find()) {
     numbers.append(Integer.parseInt(m.group()));
   }
   if (numbers.capacity() != 0) return Integer.parseInt(numbers.toString());
   else throw new CommonTestException("Text does not contain any numbers");
 }
 @Override
 public boolean checkLinks(final DownloadLink[] urls) {
   if (urls == null || urls.length == 0) {
     return false;
   }
   java.util.List<DownloadLink> failedLinkCheck = new ArrayList<DownloadLink>();
   Account acc = AccountController.getInstance().getValidAccount(this);
   setConstants(acc);
   for (DownloadLink url : urls) {
     try {
       requestFileInformation(url);
     } catch (Exception a) {
       failedLinkCheck.add(url);
     }
   }
   while (!failedLinkCheck.isEmpty()) {
     try {
       // not extensively tested.
       final Browser br = new Browser();
       br.setCookie(COOKIE_HOST, "lang", "english");
       br.setCookiesExclusive(true);
       final StringBuilder sb = new StringBuilder();
       final ArrayList<DownloadLink> links = new ArrayList<DownloadLink>();
       while (!failedLinkCheck.isEmpty()) {
         links.clear();
         for (DownloadLink link : failedLinkCheck) {
           links.add(link);
           if (links.size() == 50) break;
         }
         sb.delete(0, sb.capacity());
         sb.append("op=checkfiles&process=Check+URLs&list=");
         for (final DownloadLink dl : links) {
           sb.append(dl.getDownloadURL());
           sb.append("%0A");
         }
         br.postPage(COOKIE_HOST + "/?op=checkfiles", sb.toString());
         for (final DownloadLink dllink : links) {
           final String fid = new Regex(dllink.getDownloadURL(), "([a-z0-9]+)$").getMatch(0);
           if (br.containsHTML("filebox\\.com/" + fid + " found</font>")) {
             dllink.setAvailable(true);
             dllink.setName(fid);
           } else if (br.containsHTML("filebox\\.com/" + fid + " not found\\!</font>")) {
             dllink.setAvailable(false);
           } else {
             dllink.setAvailable(false);
             dllink.getLinkStatus().setStatusText("Linkchecker is probably broken!");
           }
           failedLinkCheck.remove(dllink);
         }
       }
     } catch (Exception b) {
     }
   }
   return true;
 }
Example #9
0
  /**
   * Return the String result of the builder, and reset it/perform cleanup on it.
   *
   * @return the result of builder.toString()
   */
  protected String drainBuilder() {
    String result = builder.toString();

    if (builder.capacity() > CHUNK_SIZE) {
      // The builder was resized; potentially to a large
      // value. Create a smaller one so the old one can be
      // garbage collected
      builder = new StringBuilder(CHUNK_SIZE);
    } else {
      builder.setLength(0);
    }

    return result;
  }
Example #10
0
  public void onCreate(SQLiteDatabase sqLiteDatabase) {
    Log.d("debug", "Creando la Base de Datos");
    StringBuilder sb = new StringBuilder();

    Scanner sc = new Scanner(this.ctx.getResources().openRawResource(R.raw.database));
    while (sc.hasNextLine()) {
      sb.append(sc.nextLine());
      sb.append("\n");
      if (sb.indexOf(";") != -1) {
        sqLiteDatabase.execSQL(sb.toString());
        sb.delete(0, sb.capacity());
      }
    }
  }
Example #11
0
  /**
   * Tries to lookup all Identifiers of this DSpaceObject.
   *
   * @return An array containing all found identifiers or an array with a length of 0.
   */
  public String[] getIdentifiers(Context context) {
    if (identifiers == null) {
      log.debug("This DSO's identifiers cache is empty, looking for identifiers...");
      identifiers = new String[0];

      IdentifierService identifierService =
          new DSpace().getSingletonService(IdentifierService.class);

      if (identifierService != null) {
        identifiers = identifierService.lookup(context, this);
      } else {
        log.warn(
            "No IdentifierService found, will return an array containing " + "the Handle only.");
        if (getHandle() != null) {
          identifiers = new String[] {HandleManager.getCanonicalForm(getHandle())};
        }
      }
    }

    // it the DSO has no identifiers at all including handle, we should return an empty array.
    // G.e. items during submission (workspace items) have no handle and no other identifier.
    if (identifiers == null) {
      identifiers = new String[] {};
    }

    if (log.isDebugEnabled()) {
      StringBuilder dbgMsg = new StringBuilder();
      for (String id : identifiers) {
        if (dbgMsg.capacity() == 0) {
          dbgMsg.append("This DSO's Identifiers are: ");
        } else {
          dbgMsg.append(", ");
        }
        dbgMsg.append(id);
      }
      dbgMsg.append(".");
      log.debug(dbgMsg.toString());
    }

    return identifiers;
  }
Example #12
0
  /**
   * Fetch sources from external systems and do preprocessing
   *
   * @param args 'github' - data will be fetched from Git Hub
   * @throws IOException something went wrong with IO operations (fatal error)
   */
  public static void main(String[] args) throws IOException { // TODO improve error handling!

    Receiver receiver = null;
    switch (args[0]) { // in the future there might be more receivers (GitLab, SVN, ...)
      case "github":
        log.info("GitHub receiver will be used");
        receiver =
            new GitHubReceiver(
                new URL(System.getProperty("github-api-resource")),
                System.getProperty("sourcePath"));
        break;
      default:
        break;
    }

    // fetch java classes
    log.info("Receiving data ...");
    receiver.receive();

    // add additional information from meta data
    log.info("Adding additional information to sources ...");
    File dir = new File(System.getProperty("sourcePath"));
    String[] files = dir.list();
    for (int i = 0; i < files.length; i++) {
      File file = new File(System.getProperty("sourcePath") + "/" + files[i]);
      File output = new File(System.getProperty("sourcePath") + "/" + files[i] + ".temp");
      FileReader fr = new FileReader(file);
      FileWriter fw = new FileWriter(output);
      BufferedReader br = new BufferedReader(fr);
      BufferedWriter bw = new BufferedWriter(fw);
      String line;
      StringBuilder buffer = new StringBuilder();
      boolean buffering = false;
      while ((line = br.readLine()) != null) {

        if (line.contains("/**")) buffering = true; // start buffering JavaDoc comment

        // stop buffering and process buffer
        if ((line.contains("private") || line.contains("public")) && buffering) {

          // add meta data to classes
          if (line.contains("class")) {

            // add URL to source
            StringBuilder temp = new StringBuilder();
            temp.append("\n* <p><a href=\"");
            temp.append(receiver.getMeta(files[i] + "_url"));
            temp.append("\">");
            temp.append(receiver.getMeta(files[i] + "_url"));
            temp.append("</a></p>");

            buffer.insert(buffer.indexOf("/**") + 3, temp.toString());
          }

          bw.append(buffer.toString()); // flush buffer to output
          buffering = false;
          buffer.delete(0, buffer.capacity()); // clear buffer
        }

        if (buffering) {
          buffer.append(line);
          buffer.append("\n");
        } else {
          bw.append(line);
          bw.newLine();
        }
      }
      br.close();
      bw.close();
      fr.close();
      fw.close();

      // update original file with changes
      file.delete();
      output.renameTo(new File(System.getProperty("sourcePath") + "/" + files[i]));
    }
  }
  @RolesAllowed({ALUNO, PROFESSOR})
  public List<RelatorioDTO> converterAtividadesEmRelatorio(
      Monitoria monitoria, List<Atividade> atividades, Integer mes) {

    RelatorioDTO relatorio = new RelatorioDTO();

    relatorio.setAno(monitoria.getAnoMonitoria());
    relatorio.setEdital(monitoria.getEditalMonitoria());
    relatorio.setDisciplina(monitoria.getDisciplina().getComponenteCurricular().getDescricao());
    relatorio.setMatricula(monitoria.getAluno().getMatricula());
    relatorio.setCurso(monitoria.getAluno().getCurso().getDescricao());
    relatorio.setNome(monitoria.getNomeMonitor());
    relatorio.setOrientador(monitoria.getNomeOrientador());
    relatorio.setMes(Util.obterNomeMes(mes));
    StringBuilder descricaoAcumulada = new StringBuilder();
    StringBuilder observacaoAcumulada = new StringBuilder();

    List<SemanaDTO> semanas = new ArrayList<>();

    List<DiaDTO> dias = new ArrayList<>();

    SimpleDateFormat format = new SimpleDateFormat("HH:mm");

    SemanaDTO semana = new SemanaDTO();

    int quantidadeAtividades = 0;
    for (Atividade atividade : atividades) {

      DiaDTO dia = new DiaDTO();

      String horarioInicial = format.format(atividade.getDataInicio());
      String horarioFinal = format.format(atividade.getDataFim());

      dia.setHorario(horarioInicial + " - " + horarioFinal);
      dia.setData(atividade.getDataInicio());
      dias.add(dia);

      if (!StringUtils.isEmpty(atividade.getDescricao())) {
        descricaoAcumulada.append(atividade.getDescricao());
        descricaoAcumulada.append("; ");
      }
      if (!StringUtils.isEmpty(atividade.getObservacoes())) {
        observacaoAcumulada.append(atividade.getObservacoes());
        observacaoAcumulada.append("; ");
      }

      quantidadeAtividades += 1;
      if (((quantidadeAtividades % 5) == 0) || quantidadeAtividades == atividades.size()) {
        semana.setDias(dias);
        semana.setDescricao(descricaoAcumulada.toString());
        semana.setObservacao(observacaoAcumulada.toString());
        dias = new ArrayList<>();
        semanas.add(semana);
        semana = new SemanaDTO();
        descricaoAcumulada.delete(0, descricaoAcumulada.capacity());
        observacaoAcumulada.delete(0, observacaoAcumulada.capacity());
      }
    }

    relatorio.setSemanas(semanas);

    List<RelatorioDTO> relatorios = new ArrayList<>();
    relatorios.add(relatorio);

    return relatorios;
  }
Example #14
0
 @Override
 public boolean checkLinks(final DownloadLink[] urls) {
   if (urls == null || urls.length == 0) {
     return false;
   }
   try {
     final StringBuilder sbIDS = new StringBuilder();
     final StringBuilder sbKEYS = new StringBuilder();
     final HashMap<String, String> params = new HashMap<String, String>();
     final ArrayList<DownloadLink> links = new ArrayList<DownloadLink>();
     int index = 0;
     while (true) {
       links.clear();
       params.clear();
       while (true) {
         if (index == urls.length || links.size() > 25) {
           break;
         }
         links.add(urls[index]);
         index++;
       }
       sbIDS.delete(0, sbIDS.capacity());
       sbKEYS.delete(0, sbKEYS.capacity());
       sbIDS.append("");
       sbKEYS.append("");
       int c = 0;
       for (final DownloadLink dl : links) {
         if (c > 0) {
           sbIDS.append(",");
           sbKEYS.append(",");
         }
         final String id = new Regex(dl.getDownloadURL(), "/dl/(\\d+)/").getMatch(0);
         final String key = new Regex(dl.getDownloadURL(), "/dl/\\d+/([0-9a-zA-Z]+)").getMatch(0);
         sbIDS.append(id);
         sbKEYS.append(key);
         c++;
       }
       /* we want id,status,name, size , md5 and sha1 info */
       params.put("fields", "id,status,name,size,md5,sha1");
       params.put("ids", sbIDS.toString());
       params.put("keys", sbKEYS.toString());
       final HashMap<String, String> info = callAPI(null, "checklinks", null, params);
       final String response = info.get("httpresponse");
       for (final DownloadLink dl : links) {
         final String id = new Regex(dl.getDownloadURL(), "/dl/(\\d+)").getMatch(0);
         final String[] dat =
             new Regex(response, id + ",(\\d+),(.*?),(\\d+),(.*?),(.*?)(\n|$)").getRow(0);
         if (dat != null) {
           dl.setName(dat[1].trim());
           dl.setDownloadSize(Long.parseLong(dat[2].trim()));
           dl.setMD5Hash(dat[3].trim());
           // SHA1 hashes seems to be wrong sometimes
           // dl.setSha1Hash(dat[4].trim());
           if ("1".equalsIgnoreCase(dat[0])) {
             dl.setAvailable(true);
           } else if ("0".equalsIgnoreCase(dat[0])) {
             dl.setAvailable(false);
           } else if ("2".equalsIgnoreCase(dat[0])) {
             dl.setAvailable(true);
             dl.getLinkStatus().setStatusText("HotLink");
           } else {
             dl.setAvailable(false);
             dl.getLinkStatus().setStatusText("Unknown FileStatus " + dat[0]);
           }
         } else {
           dl.setAvailable(false);
         }
       }
       if (index == urls.length) {
         break;
       }
     }
   } catch (final Throwable e) {
     return false;
   }
   return true;
 }
Example #15
0
  @SuppressWarnings({"deprecation", "unchecked"})
  @Override
  public boolean checkLinks(final DownloadLink[] urls) {
    if (urls == null || urls.length == 0) {
      return false;
    }
    try {
      br.setCookiesExclusive(true);
      final StringBuilder sb = new StringBuilder();
      final ArrayList<DownloadLink> links = new ArrayList<DownloadLink>();
      int index = 0;
      int tempcounter = 0;
      while (true) {
        /* Reset tempcounter */
        tempcounter = 0;
        links.clear();
        while (true) {
          /* we test 10 links at once (max = 10) */
          if (index == urls.length || links.size() > 9) {
            break;
          }
          links.add(urls[index]);
          index++;
        }
        sb.delete(0, sb.capacity());
        sb.append("links=");
        for (final DownloadLink dl : links) {
          sb.append(Encoding.urlEncode(dl.getDownloadURL()));
          if (tempcounter < links.size() - 1) {
            sb.append(Encoding.urlEncode("\n"));
          }
          tempcounter++;
        }
        /* Reset tempcounter */
        tempcounter = 0;

        postPage(getAPIProtocol() + this.getHost() + "/download/json_check", sb.toString());
        LinkedHashMap<String, Object> entries = null;
        final ArrayList<Object> ressourcelist =
            (ArrayList<Object>) JavaScriptEngineFactory.jsonToJavaObject(br.toString());
        final String[] json_workaround_array = br.toString().split("\\},\\{");
        for (final DownloadLink dl : links) {
          final String state;
          final String filename;
          final long filesize;
          if (tempcounter <= json_workaround_array.length - 1) {
            entries = (LinkedHashMap<String, Object>) ressourcelist.get(tempcounter);
            state = (String) entries.get("status");
            filename = (String) entries.get("filename");
            filesize = JavaScriptEngineFactory.toLong(entries.get("filesize"), 0);
          } else {
            state = null;
            filename = null;
            filesize = 0;
          }
          if ("offline".equals(state) || state == null) {
            dl.setAvailable(false);
          } else {
            dl.setAvailable(true);
          }
          /* Trust API - offline urls can still have their filename- and size information available */
          if (filename != null) {
            dl.setFinalFileName(filename);
          }
          dl.setDownloadSize(filesize);

          tempcounter++;
        }
        if (index == urls.length) {
          break;
        }
      }
    } catch (final Exception e) {
      return false;
    }
    return true;
  }
  public String toString(boolean unsafeCreate) {
    if (_arrayIndex == 0) {
      return StringPool.BLANK;
    }

    if (_arrayIndex == 1) {
      return _array[0];
    }

    if (_arrayIndex == 2) {
      return _array[0].concat(_array[1]);
    }

    if (_arrayIndex == 3) {
      return _array[0].concat(_array[1]).concat(_array[2]);
    }

    int length = 0;

    for (int i = 0; i < _arrayIndex; i++) {
      length += _array[i].length();
    }

    StringBuilder sb = null;

    if ((length > _unsafeCreateLimit)
        && (_stringConstructor != null)
        && CharBufferPool.isEnabled()
        && unsafeCreate) {

      char[] charBuffer = CharBufferPool.borrow(length);

      int offset = 0;

      for (int i = 0; i < _arrayIndex; i++) {
        String s = _array[i];

        s.getChars(0, s.length(), charBuffer, offset);

        offset += s.length();
      }

      try {
        return _stringConstructor.newInstance(0, length, charBuffer);
      } catch (Exception e) {
        _stringConstructor = null;

        return toString(false);
      }
    } else if (length > _threadLocalBufferLimit) {
      sb = _stringBuilderThreadLocal.get();

      if (sb == null) {
        sb = new StringBuilder(length);

        _stringBuilderThreadLocal.set(sb);
      } else if (sb.capacity() < length) {
        sb.setLength(length);
      }

      sb.setLength(0);
    } else {
      sb = new StringBuilder(length);
    }

    for (int i = 0; i < _arrayIndex; i++) {
      sb.append(_array[i]);
    }

    return sb.toString();
  }
 public String toString() {
   String s = buf.toString();
   buf = new StringBuilder(buf.capacity());
   return s;
 }
 @Override
 public boolean checkLinks(final DownloadLink[] urls) {
   if (urls == null || urls.length == 0) {
     return false;
   }
   try {
     Browser br = new Browser();
     workAroundTimeOut(br);
     br.setCookiesExclusive(true);
     StringBuilder sb = new StringBuilder();
     ArrayList<DownloadLink> links = new ArrayList<DownloadLink>();
     int index = 0;
     while (true) {
       links.clear();
       while (true) {
         /* we test 80 links at once */
         if (index == urls.length || links.size() > 80) break;
         links.add(urls[index]);
         index++;
       }
       sb.delete(0, sb.capacity());
       sb.append(new Sec().run());
       int c = 0;
       for (DownloadLink dl : links) {
         sb.append("&id_" + c + "=" + getID(dl));
         c++;
       }
       int retry = 0;
       while (true) {
         /*
          * workaround for api issues, retry 5 times when content length is only 20 bytes
          */
         if (retry == 5) return false;
         br.postPage("http://cloudzer.net/api/filemultiple", sb.toString());
         if (br.getHttpConnection().getLongContentLength() != 20) {
           break;
         }
         Thread.sleep(500);
         retry++;
       }
       sb = null;
       String infos[][] =
           br.getRegex(Pattern.compile("(.*?),(.*?),(.*?),(.*?),(.*?)(\r|\n|$)")).getMatches();
       for (DownloadLink dl : links) {
         String id = getID(dl);
         int hit = -1;
         for (int i = 0; i < infos.length; i++) {
           if (infos[i][1].equalsIgnoreCase(id)) {
             hit = i;
             break;
           }
         }
         if (hit == -1) {
           /* id not in response, so its offline */
           dl.setAvailable(false);
         } else {
           dl.setFinalFileName(Encoding.htmlDecode(infos[hit][4].trim()));
           long size = SizeFormatter.getSize(infos[hit][2]);
           dl.setDownloadSize(size);
           if (size > 0) {
             dl.setProperty("VERIFIEDFILESIZE", size);
           }
           if ("online".equalsIgnoreCase(infos[hit][0].trim())) {
             dl.setAvailable(true);
             String sha1 = infos[hit][3].trim();
             if (sha1.length() == 0) sha1 = null;
             dl.setSha1Hash(sha1);
             dl.setMD5Hash(null);
           } else {
             dl.setAvailable(false);
           }
         }
       }
       if (index == urls.length) break;
     }
   } catch (Exception e) {
     return false;
   }
   return true;
 }
 @Override
 public boolean checkLinks(DownloadLink[] urls) {
   if (urls == null || urls.length == 0) {
     return false;
   }
   try {
     Browser br = new Browser();
     br.setCookiesExclusive(true);
     br.setFollowRedirects(true);
     /* api does not support keep-alive */
     br.getHeaders().put(new HTTPHeader("Connection", "close"));
     StringBuilder sb = new StringBuilder();
     ArrayList<DownloadLink> links = new ArrayList<DownloadLink>();
     int index = 0;
     while (true) {
       links.clear();
       while (true) {
         /* we test 80 links at once */
         if (index == urls.length || links.size() > 200) {
           break;
         }
         links.add(urls[index]);
         index++;
       }
       sb.delete(0, sb.capacity());
       sb.append("links=");
       int c = 0;
       for (DownloadLink dl : links) {
         if (c > 0) {
           sb.append("\n");
         }
         sb.append(getID(dl));
         c++;
       }
       br.postPage(
           userProtocol() + "://api.share-online.biz/cgi-bin?q=checklinks&md5=1", sb.toString());
       String infos[][] =
           br.getRegex(Pattern.compile("(.*?);([^;]+);(.*?)\\s*?;(\\d+);([0-9a-fA-F]{32})"))
               .getMatches();
       for (DownloadLink dl : links) {
         String id = getID(dl);
         int hit = -1;
         for (int i = 0; i < infos.length; i++) {
           if (infos[i][0].equalsIgnoreCase(id)) {
             hit = i;
             break;
           }
         }
         if (hit == -1) {
           /* id not in response, so its offline */
           dl.setAvailable(false);
         } else {
           dl.setFinalFileName(infos[hit][2].trim());
           long size = -1;
           dl.setDownloadSize(size = SizeFormatter.getSize(infos[hit][3]));
           if (size > 0) {
             dl.setProperty("VERIFIEDFILESIZE", size);
           }
           if (infos[hit][1].trim().equalsIgnoreCase("OK")) {
             dl.setAvailable(true);
             dl.setMD5Hash(infos[hit][4].trim());
           } else {
             dl.setAvailable(false);
           }
         }
       }
       if (index == urls.length) {
         break;
       }
     }
   } catch (Throwable e) {
     return false;
   }
   return true;
 }