All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cz.jalasoft.util.text.FragmentConverters Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package cz.jalasoft.util.text;

import com.google.common.base.CharMatcher;
import cz.jalasoft.util.converter.ConversionException;
import cz.jalasoft.util.converter.Converter;

/**
 * Created by honzales on 9.6.15.
 */
public class FragmentConverters {

    public static > Converter withoutCharacters(final CharMatcher matcher) {
        return new Converter() {
            @Override
            public TextFragment convert(T from) throws ConversionException {
                String newText = matcher.removeFrom(from.text());
                return Fragment.fromText(newText);
            }
        };
    }

    public static Converter toHtmlEscaped() {

        return new Converter() {
            @Override
            public TextFragment convert(TextFragment from) throws ConversionException {
                String text = from.text();
                String newText = text.replace("&", "&");
                return Fragment.fromText(newText);
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy