net.anotheria.anosite.gen.images.data.ImageDocument Maven / Gradle / Ivy
/**
********************************************************************************
*** ImageDocument.java ***
*** generated by AnoSiteGenerator (ASG), Version: 2.6.3 ***
*** Copyright (C) 2005 - 2010 Anotheria.net, www.anotheria.net ***
*** All Rights Reserved. ***
********************************************************************************
*** Don't edit this code, if you aren't sure ***
*** that you do exactly know what you are doing! ***
*** It's better to invest time in the generator, as into the generated code. ***
********************************************************************************
*/
package net.anotheria.anosite.gen.images.data;
import net.anotheria.asg.data.AbstractASGDocument;
import net.anotheria.anodoc.util.context.ContextManager;
import net.anotheria.anodoc.data.NoSuchPropertyException;
import net.anotheria.anodoc.data.BooleanProperty;
import net.anotheria.util.crypt.MD5Util;
import net.anotheria.util.sorter.IComparable;
import net.anotheria.util.BasicComparable;
import net.anotheria.asg.data.MultilingualObject;
public class ImageDocument extends AbstractASGDocument implements Image, IComparable, MultilingualObject{
public ImageDocument() {
super("");
}
public ImageDocument(String id){
super(id);
}
public ImageDocument(ImageDocument toClone){
super(toClone);
}
ImageDocument(ImageBuilder builder){
super("");
setName(builder.name);
setTitle(builder.title);
setImage(builder.image);
setSize(builder.size);
}
public String getName(){
return getString(PROP_NAME);
}
public void setName(String value){
setString(PROP_NAME, value);
}
public String getTitleEN(){
return getString(PROP_TITLE_EN);
}
public String getTitleDE(){
return getString(PROP_TITLE_DE);
}
public String getTitle(){
return getString("title_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage()));
}
public void setTitleEN(String value){
setString(PROP_TITLE_EN, value);
}
public void setTitleDE(String value){
setString(PROP_TITLE_DE, value);
}
public void setTitle(String value){
setString(("title_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage())), value);
}
public String getImage(){
return getString(PROP_IMAGE);
}
public void setImage(String value){
setString(PROP_IMAGE, value);
}
public String getSize(){
return getString(PROP_SIZE);
}
public void setSize(String value){
setString(PROP_SIZE, value);
}
public String toString(){
String ret = "Image ";
ret += "["+getId()+"] ";
ret += "name: "+getName();
ret += ", ";
ret += "title: "+getTitle();
ret += ", ";
ret += "image: "+getImage();
ret += ", ";
ret += "size: "+getSize();
return ret;
}
public int compareTo(Image comparable){
return compareTo(comparable, ImageSortType.SORT_BY_DEFAULT);
}
public int compareTo(IComparable anotherComparable, int method){
ImageDocument anotherDoc = (ImageDocument) anotherComparable;
switch(method){
case ImageSortType.SORT_BY_ID:
return BasicComparable.compareString(getId(), anotherDoc.getId());
case ImageSortType.SORT_BY_NAME:
return BasicComparable.compareString(getName(), anotherDoc.getName());
case ImageSortType.SORT_BY_TITLE:
return BasicComparable.compareString(getTitle(), anotherDoc.getTitle());
case ImageSortType.SORT_BY_IMAGE:
return BasicComparable.compareString(getImage(), anotherDoc.getImage());
case ImageSortType.SORT_BY_SIZE:
return BasicComparable.compareString(getSize(), anotherDoc.getSize());
default:
throw new RuntimeException("Sort method "+method+" is not supported.");
}
}
public String getDefinedName(){
return "Image";
}
public String getDefinedParentName(){
return "Images";
}
public String getFootprint(){
StringBuilder footprint = new StringBuilder();
footprint.append(getName());
footprint.append(getTitleEN());
footprint.append(getTitleDE());
footprint.append(getImage());
footprint.append(getSize());
return MD5Util.getMD5Hash(footprint);
}
public void copyLANG2LANG(String sourceLanguage, String destLanguage){
if (sourceLanguage.equals("EN") && destLanguage.equals("DE"))
copyEN2DE();
if (sourceLanguage.equals("DE") && destLanguage.equals("EN"))
copyDE2EN();
}
/**
* Copies all multilingual properties from language EN to language DE
*/
public void copyEN2DE(){
setTitleDE(getTitleEN());
}
/**
* Copies all multilingual properties from language DE to language EN
*/
public void copyDE2EN(){
setTitleEN(getTitleDE());
}
public boolean isMultilingualDisabledInstance(){
try{
return ((BooleanProperty)getInternalProperty(INT_PROPERTY_MULTILINGUAL_DISABLED)).getboolean();
}catch(NoSuchPropertyException e){
return false;
}
}
public void setMultilingualDisabledInstance(boolean value){
setInternalProperty(new BooleanProperty(INT_PROPERTY_MULTILINGUAL_DISABLED, value));
}
public boolean equals(Object o){
return o == this || ((o instanceof ImageDocument) && ((ImageDocument)o).getId().equals(getId()));
}
}