CPD Results

The following document contains the results of PMD's CPD 5.3.5.

Duplications

File Line
info/limpet/operations/spatial/DopplerShiftBetweenTracksOperation.java 592
info/limpet/operations/spatial/TwoTrackOperation.java 313
  }

  public CollectionComplianceTests getATests()
  {
    return aTests;
  }

  /**
   * utility operation to extract the location datasets from the selection (walking down into groups
   * as necessary)
   * 
   * @param selection
   * @return
   */
  protected List<IStoreItem> getLocationDatasets(
      final List<IStoreItem> selection)
  {
    final List<IStoreItem> collatedTracks = new ArrayList<IStoreItem>();

    // hmm, they may be composite tracks - extract the location data
    final Iterator<IStoreItem> sIter = selection.iterator();
    while (sIter.hasNext())
    {
      final IStoreItem iStoreItem = sIter.next();
      if (iStoreItem instanceof IStoreGroup)
      {
        final IStoreGroup group = (IStoreGroup) iStoreItem;
        final Iterator<IStoreItem> kids = group.iterator();
        while (kids.hasNext())
        {
          final IStoreItem thisItem = kids.next();
          if (thisItem instanceof LocationDocument)
          {
            final IStoreItem thisI = thisItem;
            collatedTracks.add(thisI);
          }
        }
      }
      else if (iStoreItem instanceof LocationDocument)
      {
        collatedTracks.add(iStoreItem);
      }
    }
    return collatedTracks;
  }
File Line
info/limpet/persistence/rep/RepParser.java 559
info/limpet/persistence/rep/RepParser.java 820
    final String symbology = st.nextToken(normalDelimiters);

    latDeg = Double.parseDouble(st.nextToken());
    latMin = Double.parseDouble(st.nextToken());
    latSec = Double.parseDouble(st.nextToken());

    /**
     * now, we may have trouble here, since there may not be a space between the hemisphere
     * character and a 3-digit latitude value - so BE CAREFUL
     */
    final String vDiff = st.nextToken();
    if (vDiff.length() > 3)
    {
      // hmm, they are combined
      latHem = vDiff.charAt(0);
      final String secondPart = vDiff.substring(1, vDiff.length());
      longDeg = Double.parseDouble(secondPart);
    }
    else
    {
      // they are separate, so only the hem is in this one
      latHem = vDiff.charAt(0);
      longDeg = Double.parseDouble(st.nextToken());
    }
    longMin = Double.parseDouble(st.nextToken());
    longSec = Double.parseDouble(st.nextToken());
    longHem = st.nextToken().charAt(0);
File Line
info/limpet/persistence/rep/RepParser.java 561
info/limpet/persistence/rep/RepParser.java 669
info/limpet/persistence/rep/RepParser.java 823
    latDeg = Double.parseDouble(st.nextToken());
    latMin = Double.parseDouble(st.nextToken());
    latSec = Double.parseDouble(st.nextToken());

    /**
     * now, we may have trouble here, since there may not be a space between the hemisphere
     * character and a 3-digit latitude value - so BE CAREFUL
     */
    final String vDiff = st.nextToken();
    if (vDiff.length() > 3)
    {
      // hmm, they are combined
      latHem = vDiff.charAt(0);
      final String secondPart = vDiff.substring(1, vDiff.length());
      longDeg = Double.parseDouble(secondPart);
    }
    else
    {
      // they are separate, so only the hem is in this one
      latHem = vDiff.charAt(0);
      longDeg = Double.parseDouble(st.nextToken());
    }
    longMin = Double.parseDouble(st.nextToken());
    longSec = Double.parseDouble(st.nextToken());
    longHem = st.nextToken().charAt(0);
File Line
info/limpet/analysis/QuantityFrequencyBins.java 174
info/limpet/analysis/TimeFrequencyBins.java 164
                (QuantityFrequencyBins.Bin) bIter.next();
            freqBins.append((int) bin.getLowerVal());
            freqBins.append("-");
            freqBins.append((int) bin.getUpperVal());
            freqBins.append(": ");
            freqBins.append(bin.getFreqVal());
            freqBins.append(", ");

          }

          titles.add("Frequency bins");
          values.add(freqBins.toString());
        }
      }
    }

    if (titles.size() > 0)
    {
      presentResults(titles, values);
    }

  }

  private boolean appliesTo(List<IStoreItem> selection)
  {
    return aTests.allCollections(selection) && aTests.allQuantity(selection)
File Line
info/limpet/analysis/QuantityFrequencyBins.java 139
info/limpet/analysis/TimeFrequencyBins.java 130
      for (int i = 0; i < histogram.length; i++)
      {
        long l = histogram[i];
        res.add(new Bin(rangeSoFar, rangeSoFar + rangeStep, l));
        rangeSoFar += rangeStep;
      }
    }
    return res;
  }

  @Override
  public void analyse(List<IStoreItem> selection)
  {
    List<String> titles = new ArrayList<String>();
    List<String> values = new ArrayList<String>();

    // check compatibility
    if (appliesTo(selection) && selection.size() == 1)
    {
      // ok, let's go for it.
      for (Iterator<IStoreItem> iter = selection.iterator(); iter.hasNext();)
      {
File Line
info/limpet/operations/arithmetic/BinaryQuantityOperation.java 279
info/limpet/operations/arithmetic/BulkQuantityOperation.java 291
      final boolean allIndexed = getATests().allEqualIndexed(selection);
      final boolean suitableForIndexedInterpolation =
          getATests().suitableForIndexedInterpolation(selection);
      // final boolean hasIndexed = getATests().hasIndexed(selection);
      if (allIndexed && suitableForIndexedInterpolation /* || hasIndexed */)
      {
        addInterpolatedCommands(selection, destination, res, context);
      }
      else if (getATests().allEqualLengthOrSingleton(selection))
      {
        // instead, offer our indexed commands?
        addIndexedCommands(selection, destination, res, context);
      }
    }
    return res;
  }

  /**
   * produce any new commands for this s election
   * 
   * @param selection
   *          current selection
   * @param destination
   *          where the results will end up
   * @param commands
   *          the list of commands
   */
  protected abstract void addIndexedCommands(List<IStoreItem> selection,
      IStoreGroup destination, Collection<ICommand> commands, IContext context);

  /**
   * add any commands that require temporal interpolation
   * 
   * @param selection
   * @param destination
   * @param res
   */
  protected abstract void addInterpolatedCommands(List<IStoreItem> selection,
      IStoreGroup destination, Collection<ICommand> res, IContext context);

  /**
   * determine if this dataset is suitable
   * 
   * @param selection
   * @return
   */
  protected abstract boolean appliesTo(List<IStoreItem> selection);

  protected IDocument<?> getLongestIndexedCollection(
File Line
info/limpet/impl/LocationDocument.java 109
info/limpet/impl/StringDocument.java 46
    ObjectDataset dataset = (ObjectDataset) this.getDataset();
    final AxesMetadata axesMetadata =
        dataset.getFirstMetadata(AxesMetadata.class);
    final IndexIterator iterator = dataset.getIterator();

    final DoubleDataset axisDataset;
    if (axesMetadata != null && axesMetadata.getAxes().length > 0)
    {
      DoubleDataset doubleAxis = (DoubleDataset) axesMetadata.getAxes()[0];
      axisDataset = doubleAxis != null ? doubleAxis : null;
    }
    else
    {
      axisDataset = null;
    }

    res.append(dataset.getName() + ":\n");
    while (iterator.hasNext())
    {
      final String indexVal;
      if (axisDataset != null)
      {
        indexVal = "" + axisDataset.getElementDoubleAbs(iterator.index);
File Line
info/limpet/persistence/csv/CsvParser.java 445
info/limpet/persistence/csv/CsvParser.java 537
    protected StringImporter()
    {
      super(null, null, (String) null);
    }

    @Override
    public void consume(final IDocumentBuilder<?> series,
        final double theIndex, final int colStart, final CSVRecord row)
    {
      final String thisVal = row.get(colStart);
      final StringDocumentBuilder builder = (StringDocumentBuilder) series;
      builder.add(theIndex, thisVal);
    }

    @Override
    public IDocumentBuilder<?> create(final String name,
        final Unit<?> indexUnits)
    {
      final StringDocumentBuilder res =
          new StringDocumentBuilder(name, null, indexUnits);
      return res;
    }
  }