[6785] | 1 | /** |
---|
| 2 | * MailArchiver is an application that provides services for storing and managing e-mail messages through a Web Services SOAP interface. |
---|
| 3 | * Copyright (C) 2012 Marcio Andre Scholl Levien and Fernando Alberto Reuter Wendt and Jose Ronaldo Nogueira Fonseca Junior |
---|
| 4 | * |
---|
| 5 | * This program is free software: you can redistribute it and/or modify |
---|
| 6 | * it under the terms of the GNU Affero General Public License as |
---|
| 7 | * published by the Free Software Foundation, either version 3 of the |
---|
| 8 | * License, or (at your option) any later version. |
---|
| 9 | * |
---|
| 10 | * This program is distributed in the hope that it will be useful, |
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | * GNU Affero General Public License for more details. |
---|
| 14 | * |
---|
| 15 | * You should have received a copy of the GNU Affero General Public License |
---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | /******************************************************************************\ |
---|
| 20 | * |
---|
| 21 | * This product was developed by |
---|
| 22 | * |
---|
| 23 | * SERVIÃO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO), |
---|
| 24 | * |
---|
| 25 | * a government company established under Brazilian law (5.615/70), |
---|
| 26 | * at Department of Development of Porto Alegre. |
---|
| 27 | * |
---|
| 28 | \******************************************************************************/ |
---|
| 29 | |
---|
| 30 | package serpro.mailarchiver.domain.metaarchive; |
---|
| 31 | |
---|
| 32 | import java.text.SimpleDateFormat; |
---|
| 33 | import java.util.Date; |
---|
| 34 | |
---|
| 35 | import javax.jdo.JDOHelper; |
---|
| 36 | import javax.jdo.annotations.NotPersistent; |
---|
| 37 | import javax.jdo.annotations.PersistenceCapable; |
---|
| 38 | |
---|
| 39 | import serpro.mailarchiver.util.Logger; |
---|
| 40 | |
---|
| 41 | @PersistenceCapable |
---|
| 42 | public class DateTimeField |
---|
| 43 | extends Field |
---|
| 44 | { |
---|
| 45 | /* |
---|
| 46 | * "Date", "Resent-Date" |
---|
| 47 | */ |
---|
| 48 | |
---|
| 49 | @NotPersistent |
---|
| 50 | private static final Logger log = Logger.getLocalLogger(); |
---|
| 51 | |
---|
| 52 | //**** P E R S I S T E N T **** |
---|
| 53 | private Date date; |
---|
| 54 | //***************************** |
---|
| 55 | |
---|
| 56 | public final Date getDate() { |
---|
| 57 | return date; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | public final void setDate(Date date) { |
---|
| 61 | this.date = date; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | //-------------------------------------------------------------------------- |
---|
| 65 | @Override |
---|
| 66 | final void dumpTree(StringBuilder sb, String pad) { |
---|
| 67 | sb.append(toString(pad + " ")); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | @NotPersistent |
---|
| 71 | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z"); |
---|
| 72 | |
---|
| 73 | @Override |
---|
| 74 | final String toString(String pad) { |
---|
| 75 | String idx = (getEntity() == null) ? "" : ("[" + String.valueOf(getEntityIdx()) + "]"); |
---|
| 76 | return String.format( |
---|
| 77 | "DateTimeField %1$s%n" |
---|
| 78 | + "%2$sjdoState: %3$s%n" |
---|
| 79 | + "%2$soid: %4$s%n" |
---|
| 80 | + "%2$shash: %5$x%n" |
---|
| 81 | + "%2$sname: %6$s%n" |
---|
| 82 | + "%2$sdate: %7$s%n" |
---|
| 83 | + "%2$svalid: %8$b" |
---|
| 84 | , idx |
---|
| 85 | , pad |
---|
| 86 | , JDOHelper.getObjectState(this) |
---|
| 87 | , getOid() |
---|
| 88 | , hashCode() |
---|
| 89 | , getName() |
---|
| 90 | , (getDate() == null) ? null : dateFormat.format(getDate()) |
---|
| 91 | , isValid()); |
---|
| 92 | } |
---|
| 93 | } |
---|