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

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

The newest version!
package cz.jalasoft.util.text;

import cz.jalasoft.util.converter.ConversionException;
import cz.jalasoft.util.converter.Converter;

/**
 * Created by honzales on 9.6.15.
 */
public interface 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);
            }

            @Override
            public Class sourceType() {
                return
            }

            @Override
            public Class targetType() {
                return TextFragment.class;
            }
        };
    }*/

    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);
            }

            @Override
            public Class sourceType() {
                return TextFragment.class;
            }

            @Override
            public Class targetType() {
                return TextFragment.class;
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy