Commit 4eaad0f9 authored by Luc Maisonobe's avatar Luc Maisonobe

Fixed findbugs warnings.

parent 46ae6199
......@@ -18,6 +18,12 @@
<Bug pattern="SE_INNER_CLASS" />
</Match>
<!-- The following is an intentional behaviour, to be removed when class is suppressed -->
<Match>
<Class name="~.*\.SpacecraftFrame\$LocalProvider$"/>
<Bug pattern="SE_NO_SUITABLE_CONSTRUCTOR_FOR_EXTERNALIZATION" />
</Match>
<!-- the following are in fact false positives from findbugs -->
<!-- their occurrence depends on the java compiler used -->
<Match>
......@@ -63,7 +69,19 @@
<Local name="fiftyDays" />
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
</Match>
<Match>
<Class name="~.*\.JB2006$"/>
<Method name="getDensity" />
<Local name="FACT1" />
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
</Match>
<Match>
<Class name="~.*\.JB2006$"/>
<Method name="dTc" />
<Local name="HP" />
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
</Match>
<!-- The following is a false positive from findbugs -->
<Match>
<Class name="~.*\.IntegratedEphemeris\$LocalProvider$"/>
......@@ -87,25 +105,15 @@
They are used to pass data back and forth between classes
-->
<Match>
<Class name="org.orekit.propagation.numerical.AdditionalStateData"/>
<Class name="org.orekit.propagation.integration.AdditionalStateData"/>
<Method name ="getAdditionalState" params="" returns="double[]" />
<Bug pattern="EI_EXPOSE_REP" />
</Match>
<Match>
<Class name="org.orekit.propagation.numerical.AdditionalStateData"/>
<Class name="org.orekit.propagation.integration.AdditionalStateData"/>
<Method name ="getAdditionalStateDot" params="" returns="double[]" />
<Bug pattern="EI_EXPOSE_REP" />
</Match>
<Match>
<Class name="org.orekit.propagation.numerical.TimeDerivativesEquationsCartesian"/>
<Method name ="initDerivatives" params="double[],org.orekit.orbits.Orbit" returns="void" />
<Bug pattern="EI_EXPOSE_REP2" />
</Match>
<Match>
<Class name="org.orekit.propagation.numerical.TimeDerivativesEquationsEquinoctial"/>
<Method name ="initDerivatives" params="double[],org.orekit.orbits.Orbit" returns="void" />
<Bug pattern="EI_EXPOSE_REP2" />
</Match>
<!-- the following is an intended switch fall-through in the SP3Parser -->
<Match>
......
......@@ -51,7 +51,7 @@ class JPLCelestialBody implements CelestialBody {
private final JPLEphemeridesLoader.EphemerisType generateType;
/** Raw position-velocity provider. */
private final JPLEphemeridesLoader.RawPVProvider rawPVProvider;
private final transient JPLEphemeridesLoader.RawPVProvider rawPVProvider;
/** Attraction coefficient of the body (m<sup>3</sup>/s<sup>2</sup>). */
private final double gm;
......
......@@ -1031,7 +1031,7 @@ public class JPLEphemeridesLoader implements CelestialBodyLoader {
}
/** Raw position-velocity provider providing always zero. */
private class ZeroRawPVProvider implements RawPVProvider {
private static class ZeroRawPVProvider implements RawPVProvider {
/** {@inheritDoc} */
public PVCoordinates getRawPV(final AbsoluteDate date) {
......
......@@ -19,7 +19,6 @@ package org.orekit.data;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
......@@ -64,14 +63,11 @@ import org.orekit.errors.OrekitMessages;
* @see DirectoryCrawler
* @see ClasspathCrawler
*/
public class DataProvidersManager implements Serializable {
public class DataProvidersManager {
/** Name of the property defining the root directories or zip/jar files path for default configuration. */
public static final String OREKIT_DATA_PATH = "orekit.data.path";
/** Serializable UID. */
private static final long serialVersionUID = -6462388122735180273L;
/** Supported data providers. */
private final List<DataProvider> providers;
......
......@@ -90,7 +90,7 @@ public class PoissonSeries implements Serializable {
// setup the reader
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
String line = reader.readLine();
int lineNumber = 1;
......
......@@ -140,21 +140,28 @@ public class ZipJarCrawler implements DataProvider {
try {
// open the raw data stream
final InputStream rawStream;
if (file != null) {
rawStream = new FileInputStream(file);
} else if (resource != null) {
rawStream = classLoader.getResourceAsStream(resource);
} else {
rawStream = url.openConnection().getInputStream();
}
// add the zip format analysis layer and browse the archive
final ZipInputStream zip = new ZipInputStream(rawStream);
final boolean loaded = feed(name, supported, visitor, zip);
zip.close();
InputStream rawStream = null;
ZipInputStream zip = null;
try {
if (file != null) {
rawStream = new FileInputStream(file);
} else if (resource != null) {
rawStream = classLoader.getResourceAsStream(resource);
} else {
rawStream = url.openConnection().getInputStream();
}
return loaded;
// add the zip format analysis layer and browse the archive
zip = new ZipInputStream(rawStream);
return feed(name, supported, visitor, zip);
} finally {
if (zip != null) {
zip.close();
}
if (rawStream != null) {
rawStream.close();
}
}
} catch (IOException ioe) {
throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage()));
......
......@@ -92,7 +92,7 @@ public class SP3Parser implements OrbitFileParser {
private SP3File parseInternal(final InputStream stream)
throws OrekitException, IOException {
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
// initialize internal data structures
final ParseInfo pi = new ParseInfo();
......
......@@ -754,7 +754,7 @@ public class DTM2000 implements Atmosphere {
BufferedReader r = null;
try {
r = new BufferedReader(new InputStreamReader(in));
r = new BufferedReader(new InputStreamReader(in, "UTF-8"));
r.readLine();
r.readLine();
for (String line = r.readLine(); line != null; line = r.readLine()) {
......
......@@ -439,7 +439,7 @@ public class MarshallSolarActivityFutureEstimation implements DTM2000InputParame
}
// read the data
final BufferedReader reader = new BufferedReader(new InputStreamReader(input));
final BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
boolean inData = false;
final TimeScale utc = TimeScalesFactory.getUTC();
DateComponents fileDate = null;
......
......@@ -61,7 +61,7 @@ public class EGMFormatReader extends PotentialCoefficientsReader {
setAe(Constants.EGM96_EARTH_EQUATORIAL_RADIUS);
setMu(Constants.EGM96_EARTH_MU);
final BufferedReader r = new BufferedReader(new InputStreamReader(input));
final BufferedReader r = new BufferedReader(new InputStreamReader(input, "UTF-8"));
final List<List<Double>> c = new ArrayList<List<Double>>();
final List<List<Double>> s = new ArrayList<List<Double>>();
boolean okFields = true;
......
......@@ -120,7 +120,7 @@ public class GRGSFormatReader extends PotentialCoefficientsReader {
// 0 0 .99999999988600E+00 .00000000000000E+00 .153900E-09 .000000E+00
// 2 0 -0.48416511550920E-03 0.00000000000000E+00 .204904E-10 .000000E+00
final BufferedReader r = new BufferedReader(new InputStreamReader(input));
final BufferedReader r = new BufferedReader(new InputStreamReader(input, "UTF-8"));
int lineNumber = 0;
double[][] c = null;
double[][] s = null;
......
......@@ -177,7 +177,7 @@ public class ICGEMFormatReader extends PotentialCoefficientsReader {
// by default, the field is normalized (will be overridden later if non-default)
normalized = true;
final BufferedReader r = new BufferedReader(new InputStreamReader(input));
final BufferedReader r = new BufferedReader(new InputStreamReader(input, "UTF-8"));
boolean inHeader = true;
double[][] c = null;
double[][] s = null;
......
......@@ -86,7 +86,7 @@ public class SHMFormatReader extends PotentialCoefficientsReader {
cDot.clear();
sDot.clear();
final BufferedReader r = new BufferedReader(new InputStreamReader(input));
final BufferedReader r = new BufferedReader(new InputStreamReader(input, "UTF-8"));
boolean okEarth = false;
boolean okSHM = false;
boolean okCoeffs = false;
......
......@@ -240,7 +240,7 @@ class BulletinBFilesLoader implements EOP1980HistoryLoader, EOP2000HistoryLoader
// set up a reader for line-oriented bulletin B files
lineNumber = 0;
line = null;
final BufferedReader reader = new BufferedReader(new InputStreamReader(input));
final BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
synchronized (this) {
......
......@@ -120,7 +120,7 @@ class EOP05C04FilesLoader implements EOP1980HistoryLoader, EOP2000HistoryLoader
throws IOException, OrekitException {
// set up a reader for line-oriented bulletin B files
final BufferedReader reader = new BufferedReader(new InputStreamReader(input));
final BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
// read all file, ignoring header
synchronized (this) {
......
......@@ -145,7 +145,7 @@ class RapidDataAndPredictionColumnsLoader implements EOP1980HistoryLoader, EOP20
throws OrekitException, IOException {
// set up a reader for line-oriented bulletin B files
final BufferedReader reader = new BufferedReader(new InputStreamReader(input));
final BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
// Init
double x = 0;
......
......@@ -87,7 +87,7 @@ class RapidDataAndPredictionXMLLoader implements EOP1980HistoryLoader, EOP2000Hi
// read all file, ignoring header
synchronized (this) {
reader.parse(new InputSource(new InputStreamReader(input)));
reader.parse(new InputSource(new InputStreamReader(input, "UTF-8")));
}
} catch (SAXException se) {
......
......@@ -16,6 +16,12 @@
*/
package org.orekit.frames;
import java.io.Externalizable;
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.orekit.errors.OrekitException;
import org.orekit.propagation.Propagator;
import org.orekit.time.AbsoluteDate;
......@@ -25,6 +31,16 @@ import org.orekit.utils.PVCoordinatesProvider;
/** Spacecraft frame.
* <p>Frame associated to a satellite body, taking into account orbit and attitude.</p>
* <p>
* Use of this frame is not recommended, and it will probably be withdrawn in a future version.
* In many cases, rather than using this frame and its {@link #getTransformTo(Frame, AbsoluteDate)
* getTransformTo} method, users should directly get a {@link Transform} using
* {@link org.orekit.propagation.SpacecraftState#toTransform()}.
* </p>
* <p>
* Note that despite it extends {@link Frame}, this frame is <em>NOT</em> serializable,
* as it relies on {@link Propagator}.
* </p>
* @author Luc Maisonobe
*/
public class SpacecraftFrame extends Frame implements PVCoordinatesProvider {
......@@ -32,23 +48,19 @@ public class SpacecraftFrame extends Frame implements PVCoordinatesProvider {
/** Serializable UID. */
private static final long serialVersionUID = 6012707827832395314L;
/** Propagator to use. */
private final Propagator propagator;
/** Simple constructor.
* @param propagator orbit/attitude propagator computing spacecraft state evolution
* @param name name of the frame
*/
public SpacecraftFrame(final Propagator propagator, final String name) {
super(propagator.getFrame(), new LocalProvider(propagator), name, false);
this.propagator = propagator;
}
/** Get the underlying propagator.
* @return underlying propagator
*/
public Propagator getPropagator() {
return propagator;
return ((LocalProvider) getTransformProvider()).getPropagator();
}
/** Get the {@link PVCoordinates} of the spacecraft frame origin in the selected frame.
......@@ -59,17 +71,17 @@ public class SpacecraftFrame extends Frame implements PVCoordinatesProvider {
*/
public PVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame)
throws OrekitException {
return propagator.getPVCoordinates(date, frame);
return getPropagator().getPVCoordinates(date, frame);
}
/** Local provider for transforms. */
private static class LocalProvider implements TransformProvider {
private static class LocalProvider implements TransformProvider, Externalizable {
/** Serializable UID. */
private static final long serialVersionUID = 386815086579675823L;
/** Propagator to use. */
private final Propagator propagator;
private final transient Propagator propagator;
/** Simple constructor.
* @param propagator orbit/attitude propagator computing spacecraft state evolution
......@@ -83,6 +95,23 @@ public class SpacecraftFrame extends Frame implements PVCoordinatesProvider {
return propagator.propagate(date).toTransform();
}
/** Get the underlying propagator.
* @return underlying propagator
*/
public Propagator getPropagator() {
return propagator;
}
/** {@inheritDoc} */
public void readExternal(final ObjectInput input) throws IOException {
throw new NotSerializableException();
}
/** {@inheritDoc} */
public void writeExternal(final ObjectOutput output) throws IOException {
throw new NotSerializableException();
}
}
}
......@@ -16,7 +16,6 @@
*/
package org.orekit.frames;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
......@@ -38,10 +37,7 @@ import org.orekit.utils.TimeStampedGenerator;
* @author Pascal Parraud
* @author Evan Ward
*/
public class TidalCorrection implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 9143236723147294697L;
public class TidalCorrection {
/** pi;/2. */
private static final double HALF_PI = FastMath.PI / 2.0;
......
......@@ -70,7 +70,7 @@ public class GeoMagneticModelLoader implements DataLoader {
throws IOException, ParseException {
// open data file and parse values
final StreamTokenizer str = new StreamTokenizer(new InputStreamReader(input));
final StreamTokenizer str = new StreamTokenizer(new InputStreamReader(input, "UTF-8"));
while (true) {
final GeoMagneticField model = readModel(str);
......
......@@ -165,22 +165,10 @@ public abstract class AbstractPropagator implements Propagator {
/** {@inheritDoc} */
public SpacecraftState propagate(final AbsoluteDate target) throws PropagationException {
try {
if (startDate == null) {
startDate = getInitialState().getDate();
}
return propagate(startDate, target);
} catch (OrekitException oe) {
// recover a possible embedded PropagationException
for (Throwable t = oe; t != null; t = t.getCause()) {
if (t instanceof PropagationException) {
throw (PropagationException) t;
}
}
throw new PropagationException(oe);
if (startDate == null) {
startDate = getInitialState().getDate();
}
return propagate(startDate, target);
}
/** {@inheritDoc} */
......
......@@ -16,8 +16,6 @@
*/
package org.orekit.propagation;
import java.io.Serializable;
import org.orekit.time.AbsoluteDate;
/** This interface is intended for ephemerides valid only during a time range.
......@@ -31,7 +29,7 @@ import org.orekit.time.AbsoluteDate;
* @author Luc Maisonobe
*
*/
public interface BoundedPropagator extends Propagator, Serializable {
public interface BoundedPropagator extends Propagator {
/** Get the first date of the range.
* @return the first date of the range
......
......@@ -399,9 +399,6 @@ public abstract class AbstractAnalyticalPropagator extends AbstractPropagator {
/** {@link BoundedPropagator} view of the instance. */
private class BoundedPropagatorView extends AbstractAnalyticalPropagator implements BoundedPropagator {
/** Serializable UID. */
private static final long serialVersionUID = -3340036098040553110L;
/** Min date. */
private final AbsoluteDate minDate;
......@@ -465,9 +462,6 @@ public abstract class AbstractAnalyticalPropagator extends AbstractPropagator {
/** Internal class for local propagation. */
private class BasicStepInterpolator implements OrekitStepInterpolator {
/** Serializable UID. */
private static final long serialVersionUID = 26269718303505539L;
/** Global previous date. */
private AbsoluteDate globalPreviousDate;
......
......@@ -16,8 +16,6 @@
*/
package org.orekit.propagation.analytical;
import java.io.Serializable;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.util.MathUtils;
import org.orekit.attitudes.AttitudeProvider;
......@@ -40,10 +38,7 @@ import org.orekit.time.AbsoluteDate;
* @see Orbit
* @author Guylaine Prat
*/
public class EcksteinHechlerPropagator extends AbstractAnalyticalPropagator implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = -3473187502871065348L;
public class EcksteinHechlerPropagator extends AbstractAnalyticalPropagator {
/** Mean parameters at the initial date. */
private CircularOrbit mean;
......
......@@ -47,9 +47,6 @@ import org.orekit.utils.TimeStampedGenerator;
*/
public class Ephemeris extends AbstractAnalyticalPropagator implements BoundedPropagator {
/** Serializable UID. */
private static final long serialVersionUID = -7270780789524246722L;
/** First date in range. */
private final AbsoluteDate minDate;
......
......@@ -16,8 +16,6 @@
*/
package org.orekit.propagation.analytical;
import java.io.Serializable;
import org.orekit.attitudes.AttitudeProvider;
import org.orekit.errors.OrekitException;
import org.orekit.errors.PropagationException;
......@@ -29,10 +27,7 @@ import org.orekit.time.AbsoluteDate;
* @see Orbit
* @author Guylaine Prat
*/
public class KeplerianPropagator extends AbstractAnalyticalPropagator implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 6136628786648938677L;
public class KeplerianPropagator extends AbstractAnalyticalPropagator {
/** Initial state. */
private SpacecraftState initialState;
......
......@@ -39,9 +39,6 @@ import org.orekit.utils.Constants;
*/
class DeepSDP4 extends SDP4 {
/** Serializable UID. */
private static final long serialVersionUID = 7155645502511295218L;
// CHECKSTYLE: stop JavadocVariable check
// Internal constants
......
......@@ -38,9 +38,6 @@ import org.orekit.utils.Constants;
*/
abstract class SDP4 extends TLEPropagator {
/** Serializable UID. */
private static final long serialVersionUID = 6739431592307605737L;
// CHECKSTYLE: stop VisibilityModifierCheck
/** New perigee argument. */
......
......@@ -34,9 +34,6 @@ import org.orekit.errors.OrekitException;
*/
class SGP4 extends TLEPropagator {
/** Serializable UID. */
private static final long serialVersionUID = -7860984112560308900L;
/** If perige is less than 220 km, some calculus are avoided. */
private boolean lessThan220;
......
......@@ -16,8 +16,6 @@
*/
package org.orekit.propagation.analytical.tle;
import java.io.Serializable;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.util.MathUtils;
......@@ -60,10 +58,7 @@ import org.orekit.utils.PVCoordinates;
* @author Fabien Maussion (java translation)
* @see TLE
*/
public abstract class TLEPropagator extends AbstractAnalyticalPropagator implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 6389584529961457799L;
public abstract class TLEPropagator extends AbstractAnalyticalPropagator {
// CHECKSTYLE: stop VisibilityModifierCheck
......
......@@ -20,7 +20,6 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
......@@ -51,10 +50,7 @@ import org.orekit.utils.PVCoordinates;
* @author Fabien Maussion
* @author Luc Maisonobe
*/
public class TLESeries implements DataLoader, Serializable {
/** Serializable UID. */
private static final long serialVersionUID = -1120722267423537022L;
public class TLESeries implements DataLoader {
/** Default supported files name pattern. */
private static final String DEFAULT_SUPPORTED_NAMES = ".*\\.tle$";
......@@ -256,7 +252,7 @@ public class TLESeries implements DataLoader, Serializable {
public void loadData(final InputStream input, final String name)
throws IOException, OrekitException {
final BufferedReader r = new BufferedReader(new InputStreamReader(input));
final BufferedReader r = new BufferedReader(new InputStreamReader(input, "UTF-8"));
try {
int lineNumber = 0;
......
......@@ -741,9 +741,6 @@ public abstract class AbstractIntegratedPropagator extends AbstractPropagator {
private class AdaptedStepHandler
implements OrekitStepInterpolator, StepHandler, ModeHandler {
/** Serializable UID. */
private static final long serialVersionUID = -3674883225252719093L;
/** Additional state data list. */
private List <AdditionalStateData> addStateData;
......
......@@ -68,9 +68,6 @@ import org.orekit.utils.PVCoordinates;
public class IntegratedEphemeris
extends AbstractAnalyticalPropagator implements BoundedPropagator {
/** Serializable UID. */
private static final long serialVersionUID = 4297289148511923674L;
/** Mapper between raw double components and spacecraft state. */
private final StateMapper mapper;
......
......@@ -16,8 +16,6 @@
*/
package org.orekit.propagation.integration;
import java.io.Serializable;
import org.orekit.attitudes.AttitudeProvider;
import org.orekit.errors.OrekitException;
import org.orekit.frames.Frame;
......@@ -30,10 +28,7 @@ import org.orekit.time.AbsoluteDate;
* @author Luc Maisonobe
* @since 6.0
*/
public abstract class StateMapper implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = -6503521886256031804L;
public abstract class StateMapper {
/** Reference date. */
private final AbsoluteDate referenceDate;
......
......@@ -286,9 +286,6 @@ public class NumericalPropagator extends AbstractIntegratedPropagator {
/** Internal mapper using directly osculating parameters. */
private static class OsculatingMapper extends StateMapper {
/** Serializable UID. */
private static final long serialVersionUID = -1525946167852572811L;
/** Simple constructor.
* <p>
* The position parameter type is meaningful only if {@link
......
......@@ -28,9 +28,6 @@ import org.orekit.time.AbsoluteDate;
*/
public class BasicStepInterpolator implements OrekitStepInterpolator {
/** Serializable UID. */
private static final long serialVersionUID = 7847540541046397037L;
/** Underlying propagator. */
private final Propagator propagator;
......
......@@ -16,8 +16,6 @@
*/
package org.orekit.propagation.sampling;
import java.io.Serializable;
import org.orekit.errors.OrekitException;
import org.orekit.errors.PropagationException;
import org.orekit.propagation.SpacecraftState;
......@@ -30,7 +28,7 @@ import org.orekit.time.AbsoluteDate;
* provides a space-dynamics interface to the methods.</p>
* @author Luc Maisonobe
*/
public interface OrekitStepInterpolator extends Serializable {
public interface OrekitStepInterpolator {
/** Get the current grid date.
* @return current grid date
......
......@@ -267,9 +267,6 @@ public class DSSTPropagator extends AbstractIntegratedPropagator {
/** Internal mapper using mean parameters plus short periodic terms. */
private static class MeanPlusShortPeriodicMapper extends StateMapper {
/** Serializable UID. */
private static final long serialVersionUID = 5880502847862113166L;
/** Force models used to compute short periodic terms. */
private final List<DSSTForceModel> forceModels;
......
......@@ -101,7 +101,7 @@ public abstract class AbstractGaussianContribution implements DSSTForceModel {
/** 1 / (A * B) .*/
protected double ooAB;