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

org.minijax.db.UrlEncodedMapConverter Maven / Gradle / Ivy

There is a newer version: 0.4.14
Show newest version
package org.minijax.db;

import java.util.Map;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

import org.minijax.util.UrlUtils;

/**
 * The UrlEncodedMapConverter class implements the JPA converter from Map to URL-encoded String.
 */
@Converter
public class UrlEncodedMapConverter implements AttributeConverter, String> {

    @Override
    public String convertToDatabaseColumn(final Map map) {
        if (map == null) {
            return null;
        }
        return UrlUtils.urlEncodeParams(map);
    }

    @Override
    public Map convertToEntityAttribute(final String str) {
        if (str == null) {
            return null;
        }
        return UrlUtils.urlDecodeParams(str);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy