Package org.jamwiki.parser

Examples of org.jamwiki.parser.ParserException


    } else if (linkLower.startsWith("telnet://")) {
      protocol = "telnet://";
    } else if (linkLower.startsWith("file://")) {
      protocol = "file://";
    } else {
      throw new ParserException("Invalid protocol in link " + link);
    }
    String caption = link;
    if (!StringUtils.isBlank(text)) {
      caption = JFlexParserUtil.parseFragment(parserInput, text, mode);
    }
View Full Code Here


    validate(lexer);
    this.parserInput.incrementDepth();
    // avoid infinite loops
    if (this.parserInput.getDepth() > 100) {
      String topicName = (!StringUtils.isBlank(this.parserInput.getTopicName())) ? this.parserInput.getTopicName() : null;
      throw new ParserException("Infinite parsing loop - over " + this.parserInput.getDepth() + " parser iterations while parsing topic " + topicName);
    }
    long previous, current = 0;
    String line;
    try {
      previous = System.currentTimeMillis();
      while ((line = lexer.yylex()) != null) {
        lexer.append(line);
        current = System.currentTimeMillis();
        if ((current - previous) > 10) {
          // took longer than ten milliseconds, log warning
          logger.fine("WARNING: slow parsing (" + ((current - previous) / 1000.000) + " s) for input: " + lexer.yytext() + " (state: " + lexer.yystate() + ") result: " + line);
        }
        previous = current;
      }
    } catch (Exception e) {
      throw new ParserException(e);
    }
    this.parserInput.decrementDepth();
    return lexer.popAllTags();
  }
View Full Code Here

      if (!LinkUtil.isExistingArticle(virtualWiki, wikiLink.getDestination())) {
        style = "edit redirect";
      }
      return LinkUtil.buildInternalLinkHtml(this.parserInput.getContext(), virtualWiki, wikiLink, null, style, null, false);
    } catch (DataAccessException e) {
      throw new ParserException(e);
    }
  }
View Full Code Here

        logger.info("Failure while initializing parser: topic name is null.");
        validated = false;
      }
    }
    if (!validated) {
      throw new ParserException("Parser info not properly initialized");
    }
  }
View Full Code Here

  private String parseParamName(String raw) throws ParserException {
    int pos = raw.indexOf('|');
    String name = ((pos != -1) ? raw.substring(0, pos) : raw).trim();
    if (StringUtils.isBlank(name)) {
      // FIXME - no need for an exception
      throw new ParserException("No parameter name specified");
    }
    return name;
  }
View Full Code Here

      name = name.substring(0, pos);
    }
    name = Utilities.decodeTopicName(name.trim(), true);
    if (StringUtils.isBlank(name)) {
      // FIXME - no need for an exception
      throw new ParserException("No template name specified");
    }
    if (name.startsWith(NamespaceHandler.NAMESPACE_SEPARATOR)) {
      if (name.length() == 1) {
        // FIXME - no need for an exception
        throw new ParserException("No template name specified");
      }
    } else if (!name.startsWith(NamespaceHandler.NAMESPACE_TEMPLATE
        + NamespaceHandler.NAMESPACE_SEPARATOR)) {
      name = NamespaceHandler.NAMESPACE_TEMPLATE
          + NamespaceHandler.NAMESPACE_SEPARATOR + StringUtils.capitalize(name);
View Full Code Here

   */
  private void parseTemplateParameterValues(ParserInput parserInput,
      String templateContent) throws ParserException {
    List<String> tokens = JFlexParserUtil.tokenizeParamString(templateContent);
    if (tokens.isEmpty()) {
      throw new ParserException("No template name found in " + templateContent);
    }
    int count = -1;
    for (String token : tokens) {
      count++;
      if (count == 0) {
View Full Code Here

    }
    // do not escape html for caption since parser does it above
    try {
      return LinkUtil.buildImageLinkHtml(context, virtualWiki, wikiLink.getDestination(), frame, thumb, align, caption, maxDimension, false, null, false);
    } catch (IOException e) {
      throw new ParserException("I/O Failure while parsing image link", e);
    }
  }
View Full Code Here

TOP

Related Classes of org.jamwiki.parser.ParserException

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.