net.jforum.formatters.NewLineToHtmlBreakFormatter.java Source code

Java tutorial

Introduction

Here is the source code for net.jforum.formatters.NewLineToHtmlBreakFormatter.java

Source

/*
 * Copyright (c) JForum Team. All rights reserved.
 *
 * The software in this package is published under the terms of the LGPL
 * license a copy of which has been included with this distribution in the
 * license.txt file.
 *
 * The JForum Project
 * http://www.jforum.net
 */
package net.jforum.formatters;

import org.apache.commons.lang.StringUtils;

import br.com.caelum.vraptor.ioc.ApplicationScoped;
import br.com.caelum.vraptor.ioc.Component;

/**
 * Convertes each \n to <br>
 * @author Rafael Steil
 */
@Component
@ApplicationScoped
public class NewLineToHtmlBreakFormatter implements Formatter {
    /**
     * @see net.jforum.formatters.Formatter#format(java.lang.String, PostOptions)
     */
    @Override
    public String format(String text, PostOptions postOptions) {
        return StringUtils.replace(text, "\n", "<br/> ");
    }
}