PageRenderTime 29ms CodeModel.GetById 15ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/smpp/src/main/java/org/mobicents/protocols/smpp/util/RelativeSMPPDate.java

http://mobicents.googlecode.com/
Java | 113 lines | 72 code | 14 blank | 27 comment | 14 complexity | a3b4f045d8c50437906631ce66516bf1 MD5 | raw file
  1/*
  2 * JBoss, Home of Professional Open Source
  3 * Copyright 2011, Red Hat, Inc. and individual contributors
  4 * by the @authors tag. See the copyright.txt in the distribution for a
  5 * full listing of individual contributors.
  6 *
  7 * This is free software; you can redistribute it and/or modify it
  8 * under the terms of the GNU Lesser General Public License as
  9 * published by the Free Software Foundation; either version 2.1 of
 10 * the License, or (at your option) any later version.
 11 *
 12 * This software is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 15 * Lesser General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU Lesser General Public
 18 * License along with this software; if not, write to the Free
 19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 21 */
 22
 23package org.mobicents.protocols.smpp.util;
 24
 25/**
 26 * Implementation of {@link SMPPDate} representing a relative time
 27 * specification.
 28 * 
 29 * @version $Id: RelativeSMPPDate.java 452 2009-01-15 16:56:36Z orank $
 30 */
 31class RelativeSMPPDate extends SMPPDate {
 32    private static final long serialVersionUID = 2L;
 33    private int years;
 34    private int months;
 35    private int days;
 36    private int hours;
 37    private int minutes;
 38    private int seconds;
 39
 40    public RelativeSMPPDate(int years,
 41            int months,
 42            int days,
 43            int hours,
 44            int minutes,
 45            int seconds) {
 46        this.years = years;
 47        this.months = months;
 48        this.days = days;
 49        this.hours = hours;
 50        this.minutes = minutes;
 51        this.seconds = seconds;
 52    }
 53
 54    public int getDay() {
 55        return days;
 56    }
 57
 58    public int getHour() {
 59        return hours;
 60    }
 61
 62    public int getMinute() {
 63        return minutes;
 64    }
 65
 66    public int getMonth() {
 67        return months;
 68    }
 69
 70    public int getSecond() {
 71        return seconds;
 72    }
 73
 74    public int getYear() {
 75        return years;
 76    }
 77    
 78    public char getSign() {
 79        return 'R';
 80    }
 81    
 82    public boolean isRelative() {
 83        return true;
 84    }
 85    
 86    @Override
 87    public int getLength() {
 88        return 17;
 89    }
 90    
 91    public boolean equals(Object obj) {
 92        if (obj == null || !(obj instanceof RelativeSMPPDate)) {
 93            return false;
 94        }
 95        RelativeSMPPDate other = (RelativeSMPPDate) obj;
 96        return years == other.years
 97            && months == other.months
 98            && days == other.days
 99            && hours == other.hours
100            && minutes == other.minutes
101            && seconds == other.seconds;
102    }
103
104    public int hashCode() {
105        long val = (long) years * 10000000000L;
106        val += (long) months * 100000000L;
107        val += (long) days * 1000000L;
108        val += (long) hours * 10000L;
109        val += (long) minutes * 100;
110        val += seconds;
111        return new Long(val).hashCode();
112    }
113}