001: /*
002: * Created on 16/03/2005
003: *
004: * Swing Components - visit http://sf.net/projects/gfd
005: *
006: * Copyright (C) 2005 Igor Regis da Silva Simões
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or (at your option) any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: */
022:
023: package br.com.gfp.data;
024:
025: import java.sql.SQLException;
026: import java.util.Map;
027:
028: import br.com.gfp.internationalization.ErrosDeDadosMessages;
029: import br.com.gfpshare.db.Column;
030: import br.com.gfpshare.db.Table;
031:
032: /**
033: * Classe que representa um banco, com os dados que nos interessam guardar a seu respeito
034: * @author Igor Regis da Silva Simoes
035: */
036: @Table(name="TipoDeConta")
037: public class AccountType extends BasicGFPDataObject {
038: /**
039: * Nome do Tipo de conta
040: */
041: @Column(nome="Nome",isPk=false,writeMethodName="setNome",readMethodName="getNome")
042: private String nome = null;
043:
044: /**
045: * Cria uma nova instância de Banco
046: */
047: public AccountType() {
048: //Não fazemos nada
049: }
050:
051: /**
052: * Cria uma nova instância de Banco
053: * @param nome Nome do banco
054: */
055: public AccountType(String nome) {
056: setNome(nome);
057: }
058:
059: /**
060: * Cria uma nova instância de Banco
061: * @param dados Map contendo os dados que serão usados para inicializar uma instancia desta classe
062: */
063: public AccountType(Map<String, Object> dados) {
064: setDados(dados);
065: }
066:
067: /**
068: * Cria uma nova instância de Banco
069: * @param id Id do Banco no banco de dados
070: */
071: public AccountType(Integer id) {
072: setId(id);
073: }
074:
075: /**
076: * Getter for property nome.
077: * @return Value of property nome.
078: */
079: public String getNome() {
080: return nome;
081: }
082:
083: /**
084: * Setter for property nome.
085: * @param nome New value of property nome.
086: */
087: public void setNome(String nome) {
088: this .nome = nome == null || nome.equals("") ? null : nome;
089: }
090:
091: /**
092: * @see br.com.gfpshare.db.PersistentObject#validate()
093: */
094: public void validate() throws SQLException {
095: if (this .nome == null)
096: throw new SQLException(ErrosDeDadosMessages.getMessages()
097: .getString("NomeInvalido"));
098: }
099:
100: /**
101: * @see br.com.gfpshare.db.PersistentObject#getAsString(int)
102: */
103: public String getAsString(int format) {
104: switch (format) {
105: case AccountSaving.CURTO:
106: return getNome();
107: case AccountSaving.MEDIO:
108: return getNome();
109: case AccountSaving.LONGO:
110: return toString();
111: }
112: return "";
113: }
114: }
|