/*
 *  T-Mass FIPA Speech Act data class
 *
 *  2004 - 2011 Frantisek Zboril jr.
 *  Faculty of Information Technology
 *  zborilf@fit.vutbr.cz
 *  http://www.fit.vutbr.cz/~zborilf
 *
 * (C) Brno University of Technology
 * Freeware licence VUT v Brně
 * https://wis.fit.vutbr.cz/FIT/db/dir.php/dr/VZ2007/externiInformace/softwareNaWebu/Priloha2_rozh23.pdf

 */

package jTMass.core.jTMassModel.jModelData;

import jTMass.core.jALLL.jTObjects.TObject;

public class TSpeechAct extends TModelData{

    // performatives
    public final static int _SA_Accept_Proposal=1;
    public final static int _SA_Agree=2;
    public final static int _SA_Cancel=3;
    public final static int _SA_Call_for_Proposal=4;
    public final static int _SA_Confirm=5;
    public final static int _SA_Disconfirm=6;
    public final static int _SA_Failure=7;
    public final static int _SA_Inform=8;
    public final static int _SA_Inform_If=9;
    public final static int _SA_Inform_Ref=10;
    public final static int _SA_Not_Understood=11;
    public final static int _SA_Propagate=12;
    public final static int _SA_Propose=13;
    public final static int _SA_Proxy=14;
    public final static int _SA_Query_If=15;
    public final static int _SA_Query_Ref=16;
    public final static int _SA_Refuse=17;
    public final static int _SA_Reject_Proposal=18;
    public final static int _SA_Request=19;
    public final static int _SA_Request_When=20;
    public final static int _SA_Request_Whenever=21;
    public final static int _SA_Subscribe=22;

    public final static String[] _SA_Codes={"ACC","AGR","CNC","CFP","CON","DCO",
        "FAI","INF","INI","INR","NOU","PPG","PPS","PXY","QUI","QUR","REF","REJ",
        "REQ","RQW","RWV","SUB"};

    public final static String[] _SA_Texts={"ACCEPT","AGREE","CANCEL",
        "CALL FOR PROPOSALS","CONFIRM","DISCONFIRM","FAIL","INFORM","INFORM IF",
        "INFORM REF","NOT UNDERSTOOD","PROPAGATE","PROPOSE","PROXY","QUERY IF",
        "QUERY REF","REFUSE","REJECT PROPOSAL","REQUEST","REQUEST WHEN",
        "REQUEST WHENEVER","SUBSCRIBE"};

    public final static String[] _CL_Texts={"Params", "ALLL", "PROLOG"};

    // CONTENT LANGUAGES
    public final static int _CL_Params=0;
    public final static int _CL_ALLL=1;
    public final static int _CL_Prolog=2;

    int PContentLanguage;
    int PSpeechAct;
    // Ontology
    // Protocol
    String PReplyWith="";
    String PInReplyTo="";
    String PConversationID="";

    // ===== CLONING ACT =====

    @Override
    public TSpeechAct cloneData(){
        TSpeechAct newAct=new TSpeechAct(PSpeechAct, PSender, PReceiver, PContentLanguage,
                PContent.getContent(), PReplyWith, PInReplyTo);
        return(newAct);
    }
    
    // ===== READERS, WRITERS =====

    @Override
    public String getContentEx(){
        String result=_SA_Codes[PSpeechAct-1]+":";
        result=result.concat(super.getContentEx());
        return(result);
    }

    public static String getSAText(int act){
        return(_SA_Texts[act-1]);
    }

    public static String getCLText(int language){
        return(_CL_Texts[language]);
    }

    public int getAct(){
        return(PSpeechAct);
    }

    public int getLanguage(){
        return(PContentLanguage);
    }

    public String getSender(){
        return(PSender);
    }

    @Override
    public String getReceiver(){
        return(PReceiver);
    }

    public String getReplyWith(){
        return(PReplyWith);
    }

    public String getInReplyTo(){
        return(PInReplyTo);
    }

    public void setReplyWithSender(String sender){
        PReplyWith=sender;
        return;
    }

    public void setInReplyTo(String sender){
        PInReplyTo=sender;
        return;
    }

    public void setType(int actType){
        PSpeechAct=actType;
        return;
    }

    // ===== CONSTRUCTORS =====

    public TSpeechAct(int act, String sender, String receiver,
                        int language, String stringContent){
        super(sender,receiver,null);
        PSpeechAct=act;
        PContentLanguage=language;

        switch (PContentLanguage){
            case _CL_ALLL:
                PContent=new TALLLContent(stringContent);
                return;
            default :
                PContent=new TContent(stringContent);
        }
    };

    public TSpeechAct(int act, String sender, String receiver,
            int language, String stringContent, String replyWith, String inReplyTo){
        this(act, sender, receiver, language, stringContent);
        PReplyWith=replyWith;
        PInReplyTo=inReplyTo;
    }

    public TSpeechAct(int act, String sender, String receiver, TObject alllContent){
        super(sender,receiver,null);
        PSpeechAct=act;
        PContentLanguage=_CL_ALLL;
        PContent=new TALLLContent(alllContent);
    }

}