EMMA Coverage Report (generated Tue Oct 28 00:01:11 GMT 2008)
[all classes][org.joda.time.tz]

COVERAGE SUMMARY FOR SOURCE FILE [FixedDateTimeZone.java]

nameclass, %method, %block, %line, %
FixedDateTimeZone.java100% (1/1)100% (11/11)100% (112/112)100% (23/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FixedDateTimeZone100% (1/1)100% (11/11)100% (112/112)100% (23/23)
FixedDateTimeZone (String, String, int, int): void 100% (1/1)100% (13/13)100% (5/5)
equals (Object): boolean 100% (1/1)100% (33/33)100% (6/6)
getNameKey (long): String 100% (1/1)100% (3/3)100% (1/1)
getOffset (long): int 100% (1/1)100% (3/3)100% (1/1)
getOffsetFromLocal (long): int 100% (1/1)100% (3/3)100% (1/1)
getStandardOffset (long): int 100% (1/1)100% (3/3)100% (1/1)
hashCode (): int 100% (1/1)100% (14/14)100% (1/1)
isFixed (): boolean 100% (1/1)100% (2/2)100% (1/1)
nextTransition (long): long 100% (1/1)100% (2/2)100% (1/1)
previousTransition (long): long 100% (1/1)100% (2/2)100% (1/1)
toTimeZone (): TimeZone 100% (1/1)100% (34/34)100% (4/4)

1/*
2 *  Copyright 2001-2005 Stephen Colebourne
3 *
4 *  Licensed under the Apache License, Version 2.0 (the "License");
5 *  you may not use this file except in compliance with the License.
6 *  You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *  Unless required by applicable law or agreed to in writing, software
11 *  distributed under the License is distributed on an "AS IS" BASIS,
12 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *  See the License for the specific language governing permissions and
14 *  limitations under the License.
15 */
16package org.joda.time.tz;
17 
18import org.joda.time.DateTimeZone;
19 
20/**
21 * Basic DateTimeZone implementation that has a fixed name key and offsets.
22 * <p>
23 * FixedDateTimeZone is thread-safe and immutable.
24 * 
25 * @author Brian S O'Neill
26 * @since 1.0
27 */
28public final class FixedDateTimeZone extends DateTimeZone {
29 
30    private static final long serialVersionUID = -3513011772763289092L;
31 
32    private final String iNameKey;
33    private final int iWallOffset;
34    private final int iStandardOffset;
35 
36    public FixedDateTimeZone(String id, String nameKey,
37                             int wallOffset, int standardOffset) {
38        super(id);
39        iNameKey = nameKey;
40        iWallOffset = wallOffset;
41        iStandardOffset = standardOffset;
42    }
43 
44    public String getNameKey(long instant) {
45        return iNameKey;
46    }
47 
48    public int getOffset(long instant) {
49        return iWallOffset;
50    }
51 
52    public int getStandardOffset(long instant) {
53        return iStandardOffset;
54    }
55 
56    public int getOffsetFromLocal(long instantLocal) {
57        return iWallOffset;
58    }
59 
60    public boolean isFixed() {
61        return true;
62    }
63 
64    public long nextTransition(long instant) {
65        return instant;
66    }
67 
68    public long previousTransition(long instant) {
69        return instant;
70    }
71 
72    /**
73     * Override to return the correct timzone instance.
74     * @since 1.5
75     */
76    public java.util.TimeZone toTimeZone() {
77        String id = getID();
78        if (id.length() == 6 && (id.startsWith("+") || id.startsWith("-"))) {
79            // standard format offset [+-]hh:mm
80            // our ID is without any prefix, so we need to add the GMT back
81            return java.util.TimeZone.getTimeZone("GMT" + getID());
82        }
83        // unusual offset, so setup a SimpleTimeZone as best we can
84        return new java.util.SimpleTimeZone(iWallOffset, getID());
85    }
86 
87    public boolean equals(Object obj) {
88        if (this == obj) {
89            return true;
90        }
91        if (obj instanceof FixedDateTimeZone) {
92            FixedDateTimeZone other = (FixedDateTimeZone)obj;
93            return
94                getID().equals(other.getID()) &&
95                iStandardOffset == other.iStandardOffset &&
96                iWallOffset == other.iWallOffset;
97        }
98        return false;
99    }
100 
101    public int hashCode() {
102        return getID().hashCode() + 37 * iStandardOffset + 31 * iWallOffset;
103    }
104 
105}

[all classes][org.joda.time.tz]
EMMA 2.0.5312 (C) Vladimir Roubtsov