ExceptionalDataContext.java

  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. import org.orekit.bodies.LazyLoadedCelestialBodies;
  19. import org.orekit.errors.OrekitException;
  20. import org.orekit.errors.OrekitMessages;
  21. import org.orekit.forces.gravity.potential.LazyLoadedGravityFields;
  22. import org.orekit.frames.LazyLoadedFrames;
  23. import org.orekit.models.earth.LazyLoadedGeoMagneticFields;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.time.LazyLoadedTimeScales;

  26. /**
  27.  * A data context that always throws a runtime exception when it's methods are used. Can
  28.  * be useful for determining if the default data context is used. E.g. {@code
  29.  * DataContext.setDefault(new ExceptionalDataContext());}. The following classes have
  30.  * static fields that are initialized using the default data context:
  31.  *
  32.  * <ul>
  33.  *     <li>{@link AbsoluteDate}
  34.  * </ul>
  35.  *
  36.  * @author Evan Ward
  37.  * @see DataContext#setDefault(LazyLoadedDataContext)
  38.  * @since 10.1
  39.  */
  40. public class ExceptionalDataContext extends LazyLoadedDataContext implements DataContext {

  41.     /** Empty constructor.
  42.      * <p>
  43.      * This constructor is not strictly necessary, but it prevents spurious
  44.      * javadoc warnings with JDK 18 and later.
  45.      * </p>
  46.      * @since 12.0
  47.      */
  48.     public ExceptionalDataContext() {
  49.         // nothing to do
  50.     }

  51.     @Override
  52.     public LazyLoadedTimeScales getTimeScales() {
  53.         throw new OrekitException(OrekitMessages.EXCEPTIONAL_DATA_CONTEXT);
  54.     }

  55.     @Override
  56.     public LazyLoadedFrames getFrames() {
  57.         throw new OrekitException(OrekitMessages.EXCEPTIONAL_DATA_CONTEXT);
  58.     }

  59.     @Override
  60.     public LazyLoadedCelestialBodies getCelestialBodies() {
  61.         throw new OrekitException(OrekitMessages.EXCEPTIONAL_DATA_CONTEXT);
  62.     }

  63.     @Override
  64.     public LazyLoadedGravityFields getGravityFields() {
  65.         throw new OrekitException(OrekitMessages.EXCEPTIONAL_DATA_CONTEXT);
  66.     }

  67.     @Override
  68.     public LazyLoadedGeoMagneticFields getGeoMagneticFields() {
  69.         throw new OrekitException(OrekitMessages.EXCEPTIONAL_DATA_CONTEXT);
  70.     }

  71. }