com.hiperium.web.common.dto.PopupMessageDTO.java Source code

Java tutorial

Introduction

Here is the source code for com.hiperium.web.common.dto.PopupMessageDTO.java

Source

/**
 * Product  : Hiperium Project
 * Architect: Andres Solorzano.
 * Created  : 08-05-2009 - 23:30:00
 * 
 * The contents of this file are copyrighted by Andres Solorzano 
 * and it is protected by the license: "GPL V3." You can find a copy of this 
 * license at: http://www.hiperium.com/about/licence.html
 * 
 * Copyright 2014 Andres Solorzano. All rights reserved.
 * 
 */
package com.hiperium.web.common.dto;

import java.io.Serializable;

import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;

import org.apache.commons.lang.StringUtils;

/**
 * 
 * @author Andres Solorzano
 *
 */
public class PopupMessageDTO implements Serializable {

    /** */
    private static final long serialVersionUID = -5557736669808397286L;
    /** */
    public static final String REPLACEMENT = "REPLACEMENT";

    /** */
    private Severity severity;
    /** */
    private String clientId;
    /** */
    private String message;

    /**
     */
    public PopupMessageDTO() {
        super();
        this.clear();
    }

    /**
     * 
     * @param clientId
     * @param message
     * @param severity
     * @param label
     */
    public PopupMessageDTO(String clientId, String message, Severity severity, String label) {
        this.clientId = clientId;
        this.message = message;
        this.severity = severity;
        if (StringUtils.contains(this.message, REPLACEMENT) && StringUtils.isNotBlank(label)) {
            this.message = this.message.replaceFirst(REPLACEMENT, label);
        }
    }

    /**
     */
    public void clear() {
        this.severity = FacesMessage.SEVERITY_FATAL;
        this.message = "";
    }

    /**
     * 
     * @return
     */
    public Boolean isEmpty() {
        Boolean res = Boolean.FALSE;
        if (this.severity.equals(FacesMessage.SEVERITY_FATAL)) {
            res = Boolean.TRUE;
        }
        return res;
    }

    /**
     * 
     * @return
     */
    public Severity getSeverity() {
        return severity;
    }

    /**
     * 
     * @param severity
     */
    public void setSeverity(Severity severity) {
        this.severity = severity;
    }

    /**
     * 
     * @return
     */
    public String getMessage() {
        return message;
    }

    /**
     * 
     * @param message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * 
     * @return
     */
    public String getClientId() {
        return clientId;
    }

    /**
     * 
     * @param clientId
     */
    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

}