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

com.github.datalking.common.convert.editor.PatternEditor Maven / Gradle / Ivy

The newest version!
package com.github.datalking.common.convert.editor;

import java.beans.PropertyEditorSupport;
import java.util.regex.Pattern;

/**
 */
public class PatternEditor extends PropertyEditorSupport {

    private final int flags;

    public PatternEditor() {
        this.flags = 0;
    }

    public PatternEditor(int flags) {
        this.flags = flags;
    }

    @Override
    public void setAsText(String text) {
        setValue(text != null ? Pattern.compile(text, this.flags) : null);
    }

    @Override
    public String getAsText() {
        Pattern value = (Pattern) getValue();
        return (value != null ? value.pattern() : "");
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy