package jp.yoyoyoyo.webformmanager.model;

import java.util.StringTokenizer;

public class LoginInfo {
	private String operatorId;
	private String operatorName;
	private boolean roleRead;
	private boolean roleWrite;
	private boolean roleCSVDownload;
	private boolean roleUserManager;
	public String getOperatorId() {
		return operatorId;
	}
	public void setOperatorId(String operatorId) {
		this.operatorId = operatorId;
	}
	public String getOperatorName() {
		return operatorName;
	}
	public void setOperatorName(String operatorName) {
		this.operatorName = operatorName;
	}
	public boolean isRoleRead() {
		return roleRead;
	}
	public void setRoleRead(boolean roleRead) {
		this.roleRead = roleRead;
	}
	public boolean isRoleWrite() {
		return roleWrite;
	}
	public void setRoleWrite(boolean roleWrite) {
		this.roleWrite = roleWrite;
	}
	public boolean isRoleCSVDownload() {
		return roleCSVDownload;
	}
	public void setRoleCSVDownload(boolean roleCSVDownload) {
		this.roleCSVDownload = roleCSVDownload;
	}
	public boolean isRoleUserManager() {
		return roleUserManager;
	}
	public void setRoleUserManager(boolean roleUserManager) {
		this.roleUserManager = roleUserManager;
	}
	
	public void setRole(String text){
		StringTokenizer st1 = new StringTokenizer(text, ",");
    	
    	roleRead = false;
    	roleWrite = false;
    	roleCSVDownload = false;
    	roleUserManager = false;
    	
    	while(st1.hasMoreTokens()) {
    		String tmp = st1.nextToken();
    		if(tmp.equals("1")){
    			roleRead = true;
    		}
    		if(tmp.equals("2")){
    			roleWrite = true;
    		}
    		if(tmp.equals("3")){
    			roleCSVDownload = true;
    		}
    		if(tmp.equals("4")){
    			roleUserManager = true;
    		}
    	}	
	}
}
