Пример #1
0
 private void updateEpisodeCode(String showCode, Integer season, Integer episode) {
   String code =
       showCode
           + StringUtil.padLeft(season.toString(), 2, '0')
           + "."
           + StringUtil.padLeft(episode.toString(), 2, '0');
   metaData.setEpisodeCode(code);
 }
Пример #2
0
  private void handleAttributeLine(String line) {
    if (currentCard == null) {
      currentCard = new OracleCardInfo();
      //            currentCard.setSetName(getSet());
      state = NAME;
    }
    switch (state) {
      case NAME:
        currentCard.setName(line);
        state++;
        break;
      case COST:
        state++;
        line = handleSplit(line);
        //                if (StringUtil.contains(line, "{")) {
        if ("Little Girl".equals(currentCard.getName())) {
          currentCard.setCost("½W");
          break;
        } else if (line.toUpperCase().matches("[{}XYZWUBRG0123456789/, ]+")
            || line.toUpperCase().matches("[0123456789X]*(\\[[WUBRG]{2}\\])+")) {
          currentCard.setCost(line);
          break;
        } // note that if there's no cost (land), it falls through to TYPE, which is what we want.
      case TYPE:
        state++;
        line = handleSplit(line);
        if (line.startsWith("Summon ")) line = "Creature - " + line.substring(7);
        if (line.equals("Interrupt")) line = "Instant";
        boolean good = false;
        for (int i = 0; i < MtgConstants.TYPES.length; i++)
          if (StringUtil.contains(line, MtgConstants.TYPES[i])) good = true;
        good = good || StringUtil.contains(line, "Eaturecray");
        good = good || StringUtil.contains(line, "Scariest");
        good = good || StringUtil.contains(line, "Enchant");
        if (!good)
          throw new IllegalStateException(
              "Card (" + currentCard.getName() + ") can't have a type of '" + line + "'.");

        currentCard.setType(line);
        break;
      case PT:
        state++;
        String[] ss = line.split("/");
        if (ss.length == 2) {
          if ((ss[0].length() <= 3) && (ss[1].length() <= 3)) {
            currentCard.setPt(line);
            break;
          }
        }
      case RULES:
        line = handleSplit(line);
        if (flipLines != null) flipLines.add(line);
        else if ("-----".equals(line)) {
          flipLines = new ArrayList();
        } else currentCard.setRules(line);
    }
  }
Пример #3
0
  @Override
  public String parseLyrics(String pageData, String artistName) {
    int pos = pageData.indexOf(preTag1);
    if (pos < 0) throw new LyricParsingException("Couldn't find first tag on page.");

    String lyrics = StringUtil.grab(pageData, preTag2, postTag, pos + 1);
    if (lyrics == null) throw new LyricParsingException("Couldn't find lyrics between tags.");

    if (denumberfy) lyrics = HtmlUtil.denumberfy(lyrics).trim();
    lyrics = LyricCleanup.clean(lyrics, artistName);

    return lyrics;
  }
Пример #4
0
 private void storeCurrentCard() {
   if ((currentCard != null) && !StringUtil.isEmpty(currentCard.getName()))
     this.storeCard(currentCard);
 }