Commit 7bab4008 authored by Luc Maisonobe's avatar Luc Maisonobe

Fixed findbugs warnings.

parent 9cadf6c6
......@@ -6,16 +6,29 @@
-->
<FindBugsFilter>
<!-- the following inner classes serialization pattern are intentional -->
<!-- the inner classes and the enclosing classes should be serialized together -->
<!-- the following serialization classes already takes care of non-serializable parts. -->
<Match>
<Or>
<Class name="~.*\.ConstantThrustManeuver\$\w+Switch$" />
<Class name="~.*\.SolarRadiationPressure\$\w+Switch$" />
<Class name="~.*\.NumericalPropagator\$MappingSwitchingFunction$" />
<Class name="~.*\.AbstractPropagator\$LocalPVProvider$" />
<Class name="~.*\.DSSTPropagator\$MeanPlusShortPeriodicMapper\$DataTransferObject$" />
<Class name="~.*\.IntegratedEphemeris\$DataTransferObject$" />
</Or>
<Bug pattern="SE_INNER_CLASS" />
<Bug pattern="SE_BAD_FIELD" />
</Match>
<!-- the following classes are serialized using writeReplace/readResolve with proxy classes,
so the is no real problem about the base class not having a proper constructor.
This is test in the IntegratedEphemerisTest for both the ephemeris and bot propagators. -->
<Match>
<Or>
<Class name="~.*\.IntegratedEphemeris$" />
<Class name="~.*\.DSSTPropagator\$MeanPlusShortPeriodicMapper$" />
<Class name="~.*\.NumericalPropagator\$OsculatingMapper$" />
</Or>
<Bug pattern="SE_NO_SUITABLE_CONSTRUCTOR" />
</Match>
<Match>
<Class name="~.*\.DSSTPropagator\$MeanPlusShortPeriodicMapper$" />
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
<!-- The following is an intentional behaviour, to be removed when class is suppressed -->
......
......@@ -16,6 +16,8 @@
*/
package org.orekit.attitudes;
import java.io.NotSerializableException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
......@@ -41,9 +43,9 @@ public class TabulatedProvider implements AttitudeProvider {
private static final long serialVersionUID = 20131128L;
/** Cached attitude table. */
private final ImmutableTimeStampedCache<Attitude> table;
private final transient ImmutableTimeStampedCache<Attitude> table;
/** Indivator for rate use. */
/** Indicator for rate use. */
private final boolean useRotationRate;
/** Creates new instance.
......@@ -79,4 +81,47 @@ public class TabulatedProvider implements AttitudeProvider {
}
/** Replace the instance with a data transfer object for serialization.
* @return data transfer object that will be serialized
* @exception NotSerializableException if the state mapper cannot be serialized (typically for DSST propagator)
*/
private Object writeReplace() throws NotSerializableException {
return new DataTransferObject(table.getAll(), table.getNeighborsSize(), useRotationRate);
}
/** Internal class used only for serialization. */
private static class DataTransferObject implements Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20131205L;
/** Tabulated attitudes. */
private final List<Attitude> list;
/** Number of attitude to use for interpolation. */
private final int n;
/** Indicator for rate use. */
private final boolean useRotationRate;
/** Simple constructor.
* @param list tabulated attitudes
* @param n number of attitude to use for interpolation
* @param useRotationRate indicator for rate use
*/
public DataTransferObject(final List<Attitude> list, final int n, final boolean useRotationRate) {
this.list = list;
this.n = n;
this.useRotationRate = useRotationRate;
}
/** Replace the deserialized data transfer object with a {@link TabulatedProvider}.
* @return replacement {@link TabulatedProvider}
*/
private Object readResolve() {
return new TabulatedProvider(list, n, useRotationRate);
}
}
}
......@@ -245,7 +245,7 @@ public class ZipJarCrawler implements DataProvider {
}
/** Local class wrapping a zip archive. */
private final class Archive implements Closeable, Iterable<Archive.EntryStream> {
private static final class Archive implements Closeable, Iterable<Archive.EntryStream> {
/** Zip stream. */
private final ZipInputStream zip;
......
......@@ -29,7 +29,7 @@ import org.orekit.data.BodiesElements;
public class OceanTidesWave {
/** Waves of degree 0 and 1 do not affect spacecrafts. */
private final int START_DEGREE = 2;
private static final int START_DEGREE = 2;
/** Maximum supported degree. */
private final int degree;
......
......@@ -297,7 +297,7 @@ public class DSSTPropagator extends AbstractIntegratedPropagator {
private boolean initialIsOsculating;
/** Force models used to compute short periodic terms. */
private final List<DSSTForceModel> forceModels;
private final transient List<DSSTForceModel> forceModels;
/** Number of satellite revolutions in the averaging interval. */
private int satelliteRevolution;
......
......@@ -62,7 +62,7 @@ class TesseralContribution implements DSSTForceModel {
private static final double MIN_PERIOD_IN_SAT_REV = 10.;
/** Newcomb operators. */
private static NewcombOperators newcomb;
private final NewcombOperators newcomb;
/** Provider for spherical harmonics. */
private final UnnormalizedSphericalHarmonicsProvider provider;
......@@ -171,7 +171,7 @@ class TesseralContribution implements DSSTForceModel {
this.maxHansen = 0;
// Provider for Newcomb operators
TesseralContribution.newcomb = new NewcombOperators();
this.newcomb = new NewcombOperators();
// Factorials computation
final int maxFact = 2 * maxDegree + 1;
......@@ -641,7 +641,7 @@ class TesseralContribution implements DSSTForceModel {
* For a given eccentricity, the computed elements are stored in a map.
* </p>
*/
private static class HansenTesseral {
private class HansenTesseral {
/** Map to store every Hansen kernel value computed. */
private TreeMap<MNSKey, Double> values;
......@@ -718,13 +718,13 @@ class TesseralContribution implements DSSTForceModel {
*/
public void valueFromNewcomb(final int j, final int mnm1, final int s) {
// Initialization
final int a = FastMath.max(j - s, 0);
final int b = FastMath.max(s - j, 0);
final int aHT = FastMath.max(j - s, 0);
final int bHT = FastMath.max(s - j, 0);
// Expansion until maxNewcomb, the maximum power in e^2 for the Kernel value
double sum = newcomb.getValue(maxNewcomb + a, maxNewcomb + b, mnm1, s);
for (int alpha = maxNewcomb - 1; alpha >= 0; alpha--) {
double sum = newcomb.getValue(maxNewcomb + aHT, maxNewcomb + bHT, mnm1, s);
for (int alphaHT = maxNewcomb - 1; alphaHT >= 0; alphaHT--) {
sum *= e2;
sum += newcomb.getValue(alpha + a, alpha + b, mnm1, s);
sum += newcomb.getValue(alphaHT + aHT, alphaHT + bHT, mnm1, s);
}
// Kernel value from equation 2.7.3-(10)
final double value = FastMath.pow(chi2, -mnm1 - 1) * sum / chi;
......@@ -742,13 +742,13 @@ class TesseralContribution implements DSSTForceModel {
*/
public void derivFromNewcomb(final int j, final int mnm1, final int s) {
// Initialization
final int a = FastMath.max(j - s, 0);
final int b = FastMath.max(s - j, 0);
final int aHT = FastMath.max(j - s, 0);
final int bHT = FastMath.max(s - j, 0);
// Expansion until maxNewcomb-1, the maximum power in e^2 for the Kernel derivative
double sum = maxNewcomb * newcomb.getValue(maxNewcomb + a, maxNewcomb + b, mnm1, s);
for (int alpha = maxNewcomb - 1; alpha >= 1; alpha--) {
double sum = maxNewcomb * newcomb.getValue(maxNewcomb + aHT, maxNewcomb + bHT, mnm1, s);
for (int alphaHT = maxNewcomb - 1; alphaHT >= 1; alphaHT--) {
sum *= e2;
sum += alpha * newcomb.getValue(alpha + a, alpha + b, mnm1, s);
sum += alphaHT * newcomb.getValue(alphaHT + aHT, alphaHT + bHT, mnm1, s);
}
// Kernel derivative from equation 3.3-(5)
final MNSKey key = new MNSKey(j, mnm1, s);
......
......@@ -489,7 +489,7 @@ public class NewcombOperators {
/** {@inheritDoc} */
public int hashCode() {
return 0x25baa451 ^ (n << 32) ^ (s << 16) ^ (rho << 8) ^ sigma;
return 0x25baa451 ^ (n << 24) ^ (s << 16) ^ (rho << 8) ^ sigma;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment