Examples of SeamTextParser


Examples of org.jboss.seam.text.SeamTextParser

* @author Christian Bauer
*/
public class WikiFormattedTextValidator extends FormattedTextValidator {

    public SeamTextParser getSeamTextParser(String s) {
        SeamTextParser parser = super.getSeamTextParser(s);
        parser.setSanitizer(
            new SeamTextParser.DefaultSanitizer() {

                // Disable this method
                public void validateLinkTagURI(Token token, String s) throws SemanticException {}

View Full Code Here

Examples of org.jboss.seam.text.SeamTextParser

        lastValidationError = null;
        setValid(true);
        if (!isValuePlaintext()) {
            try {
                SeamTextParser parser = getValidationParser(value);
                parser.startRule();
                setValid(true);
            }
            // Error handling for ANTLR lexer/parser errors, see
            // http://www.doc.ic.ac.uk/lab/secondyear/Antlr/err.html
            catch (TokenStreamException tse) {
View Full Code Here

Examples of org.jboss.seam.text.SeamTextParser

    }

    protected SeamTextParser getValidationParser(String text) {
        Reader r = new StringReader(text);
        SeamTextLexer lexer = new SeamTextLexer(r);
        SeamTextParser parser = new SeamTextParser(lexer);
        parser.setSanitizer(
            new SeamTextParser.DefaultSanitizer() {
                @Override
                public void validateLinkTagURI(Token token, String s) throws SemanticException {
                    // Disable this part of the validation
                }
View Full Code Here

Examples of org.jboss.seam.text.SeamTextParser

      return "";
    }
    try {
      Reader r = new StringReader(value.toString());
      SeamTextLexer lexer = new SeamTextLexer(r);
      SeamTextParser parser = new SeamTextParser(lexer);
      parser.startRule();
      return parser.toString();

    } catch (Exception e) {
      FacesMessage message = new FacesMessage("An error occurred during conversion seam text to html",e.getMessage());
      throw new ConverterException(message,e);
    }
View Full Code Here

Examples of org.jboss.seam.text.SeamTextParser

        if (!(value instanceof String)) {
            throw new IllegalArgumentException("Value is not a string: "
                    + value);
        }
        String text = (String) value;
        SeamTextParser parser = getSeamTextParser(text);
        try {
            parser.startRule();
        }
        // Error handling for ANTLR lexer/parser errors, see
        // http://www.doc.ic.ac.uk/lab/secondyear/Antlr/err.html
        catch (TokenStreamException tse) {
            // Problem with the token input stream
View Full Code Here

Examples of org.jboss.seam.text.SeamTextParser

     * @return an instance of <tt>SeamTextParser</tt>
     */
    public SeamTextParser getSeamTextParser(String text) {
       Reader r = new StringReader(text);
       SeamTextLexer lexer = new SeamTextLexer(r);
       return new SeamTextParser(lexer);
    }
View Full Code Here

Examples of org.jboss.seam.text.SeamTextParser

   public String getFormattedText()
   {
      if ( getValue() == null) return null;
      Reader r = new StringReader( (String) getValue() );
      SeamTextLexer lexer = new SeamTextLexer(r);
      SeamTextParser parser = new SeamTextParser(lexer);
      try
      {
         parser.startRule();
      }
      catch (RecognitionException rex) {
          // Log a nice message for any lexer/parser errors, users can disable this if they want to
          log.warn( "Seam Text parse error: " + rex.getMessage() );
      } catch (ANTLRException ex) {
          // All other errors are fatal;
          throw new RuntimeException(ex);
      }
      return parser.toString();
   }
View Full Code Here

Examples of org.jboss.seam.text.SeamTextParser

public class SeamTextTest
{
    public static void main(String[] args) throws Exception {
        Reader r = new InputStreamReader( SeamTextTest.class.getResourceAsStream("SeamTextTest.txt") );
        SeamTextLexer lexer = new SeamTextLexer(r);
        SeamTextParser parser = new SeamTextParser(lexer);
        parser.startRule();
        System.out.println(parser);
    }
View Full Code Here

Examples of org.jboss.seam.text.SeamTextParser

                    + value);
        }
        String text = (String) value;
        Reader r = new StringReader(text);
        SeamTextLexer lexer = new SeamTextLexer(r);
        SeamTextParser parser = new SeamTextParser(lexer);
        try {
            parser.startRule();
        }
        // Error handling for ANTLR lexer/parser errors, see
        // http://www.doc.ic.ac.uk/lab/secondyear/Antlr/err.html
        catch (TokenStreamException tse) {
            // Problem with the token input stream
View Full Code Here

Examples of org.jboss.seam.text.SeamTextParser

       
        System.out.println("------------------- SeamText -------------------");
        final String seamText = convertHtmlToSeamText(htmlText);
        System.out.println("seamText = \n'" + seamText + "'");
       
        final SeamTextParser seamParser =
            new SeamTextParser(new SeamTextLexer(new StringReader(seamText)));
        seamParser.startRule();
       
        final String string = seamParser.toString();
        System.out.println("------------------- Html -----------------------");
        System.out.println("html = " + string);
       
        return string;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.