KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joda > time > MockPartial


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  */

16 package org.joda.time;
17
18 import org.joda.time.chrono.ISOChronology;
19
20 /**
21  * A basic mock testing class for a PartialInstant that doesn't extend AbstractPartialInstant.
22  *
23  * @author Stephen Colebourne
24  */

25 public class MockPartial implements ReadablePartial {
26     
27     public static final ReadablePartial EMPTY_INSTANCE = new MockPartial();
28     
29     public Chronology getChronology() {
30         return ISOChronology.getInstanceUTC();
31     }
32     public int size() {
33         return getFields().length;
34     }
35     public DateTimeFieldType getFieldType(int index) {
36         return getFields()[index].getType();
37     }
38     public DateTimeField getField(int index) {
39         return getFields()[index];
40     }
41     public int getValue(int index) {
42         return getValues()[index];
43     }
44     public int get(DateTimeFieldType field) {
45         return 0;
46     }
47     public boolean isSupported(DateTimeFieldType field) {
48         return false;
49     }
50     public DateTime toDateTime(DateTimeZone zone) {
51         return null;
52     }
53     public DateTime toDateTime(ReadableInstant base) {
54         return null;
55     }
56     public DateTimeField[] getFields() {
57         return new DateTimeField[0];
58     }
59     public int[] getValues() {
60         return new int[0];
61     }
62 }
63
Popular Tags