Package br.com.caelum.tubaina

Examples of br.com.caelum.tubaina.TubainaException


  @Override
  public Chunk createChunk(String options, String content) {
    int maxLineLenght = Utilities.maxLineLength(content) - Utilities.getMinIndent(content);
    if(maxLineLenght >Tubaina.MAX_LINE_LENGTH)
      throw new TubainaException ("Chapter " + Chapter.getChaptersCount() +
                    "  -  Code has " + maxLineLenght + " columns:\n\n" + content);
    return new CodeChunk(content, options);
  }
View Full Code Here


    File image = ResourceLocator.getInstance().getFile(path);
    try {
      BufferedImage measurable = ImageIO.read(image);
      width = measurable.getWidth();
    } catch (IOException e) {
      throw new TubainaException("Image not existant", e);
    } catch (NullPointerException e) {
      throw new TubainaException(path + " is not a valid image");
    }
    resources.add(new ImageResource(image, matcher.group(2)));
    return new ImageChunk(path, matcher.group(2), width);
  }
View Full Code Here

        }
      } else { // close tag found
        if (!stack.isEmpty() && stack.peek().equalsIgnoreCase(matcher.group(4))) {
          stack.pop();
        } else {
          throw new TubainaException("Tag " + matcher.group(4) + " closed unproperly");
        }
      }
    }

    if (!stack.isEmpty()) {
      throw new TubainaException("There is(are) unclosed tag(s) : " + stack.toString());
    }

    if (chunkStart < 0) { // if item was not found
      throw new TubainaException("There is no item inside a list tag on chapter " + Chapter.getChaptersCount());
      // chunks.add(new ParagraphChunk(text));
      // return "";
    }
    String textBefore = text.substring(0, chunkStart - 1).trim();
    if (textBefore.length() > 0) {
      throw new TubainaException("There is some inside a list tag, but outside an item on chapter "
          + Chapter.getChaptersCount());
      // chunks.add(new ParagraphChunk(textBefore));
    }

    if (chunkEnd < 0) {
View Full Code Here

  @Override
  public Chunk createChunk(String options, String content) {
    int maxLineLenght = Utilities.maxLineLength(content) - Utilities.getMinIndent(content);
    if(maxLineLenght >Tubaina.MAX_LINE_LENGTH)
      throw new TubainaException ("Chapter " + Chapter.getChaptersCount() +
                    "  -  XML code has " + maxLineLenght + " columns:\n\n" + content);   
    return new XmlChunk(options, content);
  }
View Full Code Here

            LOG.warn("Image: '" + srcImage.getPath() + "' is too big for the page");
          }
          FileUtils.copyFileToDirectory(srcImage, this.imagePath);
        } catch (IOException e) {
          LOG.warn("Error while copying " + srcImage.getPath() + ":\n" + "\t\t" + e.getMessage());
          throw new TubainaException("Couldn't copy image", e);
        }
      } else {
        LOG.warn("Error while copying '" + srcImage.getPath() + "':\n" + "\t\tDestination image '"
            + destinationPath.getPath() + "' already exists");
      }
    } else {
      LOG.warn("Image: '" + srcImage.getPath() + "' doesn't exists");
      throw new TubainaException("Image doesn't exists");
    }

  }
View Full Code Here

        stream.append("");
      else
        stream.append(answer);
      stream.close();
    } catch (FileNotFoundException e) {
      throw new TubainaException("couldn't copy answer", e);
    } catch (UnsupportedEncodingException e) {
      throw new TubainaException("Invalid Encoding", e);
    }
  }
View Full Code Here

        stream.append("");
      else
        stream.append(answer);
      stream.close();
    } catch (FileNotFoundException e) {
      throw new TubainaException("couldn't copy answer", e);
    } catch (UnsupportedEncodingException e) {
      throw new TubainaException("Invalid Encoding", e);
    }   
  }
View Full Code Here

    try {
      BufferedImage src = ImageIO.read(srcImage);
      return src.getWidth();
    } catch (IOException e) {
      LOG.warn("Couldn't get image width for: " + srcImage.getPath());
      throw new TubainaException("Couldn't get image width");
    }
  }
View Full Code Here

                    LOG.debug("copying image: " + srcImage.getPath());

                } catch (IOException e) {
                    LOG.warn("Error while copying " + srcImage.getPath() + ":\n" + "\t\t"
                            + e.getMessage());
                    throw new TubainaException("Couldn't copy image", e);
                }
            } else {
                LOG.warn("Error while copying '" + srcImage.getPath() + "':\n"
                        + "\t\tDestination image '" + destinationFile.getPath()
                        + "' already exists");
            }
        } else {
            LOG.warn("Image: '" + srcImage.getPath() + "' doesn't exist");
            throw new TubainaException("Image Doesn't Exists");
        }
    }
View Full Code Here

    try {
      String jsonResult = extractJson(gistId);

      return converter.convert(jsonResult);
    } catch (ClientProtocolException e) {
      throw new TubainaException(e);
    } catch (IOException e) {
      throw new TubainaException(e);
    }
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.tubaina.TubainaException

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.