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

net.sf.ahtutils.controller.util.query.StatusQuery Maven / Gradle / Ivy

package net.sf.ahtutils.controller.util.query;

import java.util.Hashtable;
import java.util.Map;

import net.sf.ahtutils.xml.aht.Query;
import net.sf.ahtutils.xml.status.Description;
import net.sf.ahtutils.xml.status.Descriptions;
import net.sf.ahtutils.xml.status.Lang;
import net.sf.ahtutils.xml.status.Langs;
import net.sf.ahtutils.xml.status.Scope;
import net.sf.ahtutils.xml.status.Scopes;
import net.sf.ahtutils.xml.status.Status;
import net.sf.ahtutils.xml.status.Type;

public class StatusQuery
{
	public static enum Key {StatusExport,Langs,extractType}
	
	private static Map mQueries;
	
	public static Query get(Key key,String lang)
	{
		if(mQueries==null){mQueries = new Hashtable();}
		if(!mQueries.containsKey(key))
		{
			Query q = new Query();
			switch(key)
			{
				case StatusExport: q.setStatus(statusExport());break;
				case Langs: q.setLangs(langs());break;
				case extractType: q.setType(extractType());break;
			}
			mQueries.put(key, q);
		}
		Query q = mQueries.get(key);
		q.setLang(lang);
		return q;
	}
	
	public static Status statusExport()
	{
		Status xml = new Status();
		xml.setCode("");
		xml.setImage("");
		xml.setPosition(0);
		xml.setVisible(true);
		xml.setLangs(langs());
		xml.setDescriptions(descriptions());
		return xml;
	}
	
	public static Scopes scopes()
	{
		Scope scope = new Scope();
		scope.setCode("");
		scope.setLabel("");
		
		Scopes scopes = new Scopes();
		scopes.getScope().add(scope);
		return scopes;
	}
	
	public static Descriptions descriptions()
	{
		Descriptions xml = new Descriptions();
		
		Description d = new Description();
		d.setKey("");
		d.setValue("");
		
		xml.getDescription().add(d);
		
    	return xml;
	}
	
	public static Langs langs()
	{
		Langs xml = new Langs();
		
		Lang l = new Lang();
		l.setKey("");
		l.setTranslation("");
		
		xml.getLang().add(l);
		
    	return xml;
	}
	
	public static Type extractType()
	{
		Type xml = new Type();
		xml.setCode("");
		xml.setLangs(langs());
		return xml;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy