1 /* Contributed in the public domain.
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.data;
18
19 import org.orekit.bodies.LazyLoadedCelestialBodies;
20 import org.orekit.errors.OrekitException;
21 import org.orekit.errors.OrekitMessages;
22 import org.orekit.forces.gravity.potential.LazyLoadedGravityFields;
23 import org.orekit.frames.LazyLoadedFrames;
24 import org.orekit.models.earth.LazyLoadedGeoMagneticFields;
25 import org.orekit.time.AbsoluteDate;
26 import org.orekit.time.LazyLoadedTimeScales;
27
28 /**
29 * A data context that always throws a runtime exception when it's methods are used. Can
30 * be useful for determining if the default data context is used. E.g. {@code
31 * DataContext.setDefault(new ExceptionalDataContext());}. The following classes have
32 * static fields that are initialized using the default data context:
33 *
34 * <ul>
35 * <li>{@link AbsoluteDate}
36 * </ul>
37 *
38 * @author Evan Ward
39 * @see DataContext#setDefault(LazyLoadedDataContext)
40 * @since 10.1
41 */
42 public class ExceptionalDataContext extends LazyLoadedDataContext implements DataContext {
43
44 /** Empty constructor.
45 * <p>
46 * This constructor is not strictly necessary, but it prevents spurious
47 * javadoc warnings with JDK 18 and later.
48 * </p>
49 * @since 12.0
50 */
51 public ExceptionalDataContext() {
52 // nothing to do
53 }
54
55 @Override
56 public LazyLoadedTimeScales getTimeScales() {
57 throw new OrekitException(OrekitMessages.EXCEPTIONAL_DATA_CONTEXT);
58 }
59
60 @Override
61 public LazyLoadedFrames getFrames() {
62 throw new OrekitException(OrekitMessages.EXCEPTIONAL_DATA_CONTEXT);
63 }
64
65 @Override
66 public LazyLoadedCelestialBodies getCelestialBodies() {
67 throw new OrekitException(OrekitMessages.EXCEPTIONAL_DATA_CONTEXT);
68 }
69
70 @Override
71 public LazyLoadedGravityFields getGravityFields() {
72 throw new OrekitException(OrekitMessages.EXCEPTIONAL_DATA_CONTEXT);
73 }
74
75 @Override
76 public LazyLoadedGeoMagneticFields getGeoMagneticFields() {
77 throw new OrekitException(OrekitMessages.EXCEPTIONAL_DATA_CONTEXT);
78 }
79
80 }