Updated JavaDoc of LocalizedString
parent
f62ece6de1
commit
69de594da6
|
|
@ -37,35 +37,38 @@ import java.util.Set;
|
||||||
|
|
||||||
import static org.libreccm.l10n.L10NConstants.L10N_XML_NS;
|
import static org.libreccm.l10n.L10NConstants.L10N_XML_NS;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Type;
|
||||||
|
|
||||||
import javax.json.Json;
|
import javax.json.Json;
|
||||||
import javax.json.JsonObject;
|
import javax.json.JsonObject;
|
||||||
import javax.json.JsonObjectBuilder;
|
import javax.json.JsonObjectBuilder;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper class for localisable string properties. This class is declared as
|
* A helper class for localisable string properties. For using this class a
|
||||||
* embeddable, so that it can be used in every other entity. The localised
|
* Hibernate User type is provided ({@link LocalizedStringType} which maps
|
||||||
|
* instances of this class to a JSONB column in the database. The localised
|
||||||
* values are stored in a {@link Map}. This class is <em>not</em> designed to be
|
* values are stored in a {@link Map}. This class is <em>not</em> designed to be
|
||||||
* overwritten. But because it is an entity class we can't make the class final.
|
* overwritten. But because it is an entity class we can't make the class final.
|
||||||
*
|
*
|
||||||
|
* To use this class you must annoate this property with the {@link Type}
|
||||||
|
* annotation provided by hibernate. The {@link Column} annotation can used
|
||||||
|
* a usual to set the name of the database column. Example
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* @Column(name = "DESCRIPTION")
|
||||||
|
@Type(type = "org.libreccm.l10n.LocalizedStringType")
|
||||||
|
private LocalizedString description;
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
//@Embeddable
|
|
||||||
@XmlRootElement(name = "localized-string", namespace = L10N_XML_NS)
|
@XmlRootElement(name = "localized-string", namespace = L10N_XML_NS)
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class LocalizedString implements Serializable {
|
public class LocalizedString implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7378282657084330425L;
|
private static final long serialVersionUID = 7378282657084330425L;
|
||||||
|
|
||||||
/**
|
|
||||||
* The localised values of the string.
|
|
||||||
*/
|
|
||||||
// @ElementCollection(fetch = FetchType.LAZY)
|
|
||||||
// @MapKeyColumn(name = "LOCALE")
|
|
||||||
// @Column(name = "LOCALIZED_VALUE")
|
|
||||||
// @Basic
|
|
||||||
// @Lob
|
|
||||||
// @Type(type = "org.hibernate.type.TextType")
|
|
||||||
// @Field
|
|
||||||
@XmlElement(name = "values", namespace = L10N_XML_NS)
|
@XmlElement(name = "values", namespace = L10N_XML_NS)
|
||||||
@XmlJavaTypeAdapter(LocalizedStringValuesAdapter.class)
|
@XmlJavaTypeAdapter(LocalizedStringValuesAdapter.class)
|
||||||
private Map<Locale, String> values;
|
private Map<Locale, String> values;
|
||||||
|
|
@ -228,7 +231,7 @@ public class LocalizedString implements Serializable {
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonObject toJson() {
|
public JsonObject toJson() {
|
||||||
return buildJson().build();
|
return buildJson().build();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue