org.jfree.data.general.SeriesException Java Examples

The following examples show how to use org.jfree.data.general.SeriesException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimeSeriesTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Test that the addOrUpdate() method won't allow multiple time period
 * classes.
 */
@Test
public void testAddOrUpdate3() {
    TimeSeries s1 = new TimeSeries("S1");
    s1.addOrUpdate(new Year(2010), 1.1);
    assertEquals(Year.class, s1.getTimePeriodClass());

    boolean pass = false;
    try {
        s1.addOrUpdate(new Month(1, 2009), 0.0);
    }
    catch (SeriesException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #2
Source File: Cardumen_00199_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #3
Source File: TimeSeriesTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Test that the addOrUpdate() method won't allow multiple time period
 * classes.
 */
@Test
public void testAddOrUpdate3() {
    TimeSeries s1 = new TimeSeries("S1");
    s1.addOrUpdate(new Year(2010), 1.1);
    assertEquals(Year.class, s1.getTimePeriodClass());

    boolean pass = false;
    try {
        s1.addOrUpdate(new Month(1, 2009), 0.0);
    }
    catch (SeriesException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
Example #4
Source File: XYSeriesTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Some checks for the update(Number, Number) method.
 */
@Test
public void testUpdate() {
    XYSeries series = new XYSeries("S1");
    series.add(new Integer(1), new Integer(2));
    assertEquals(new Integer(2), series.getY(0));
    series.update(new Integer(1), new Integer(3));
    assertEquals(new Integer(3), series.getY(0));
    try {
        series.update(new Integer(2), new Integer(99));
        assertTrue(false);
    }
    catch (SeriesException e) {
        // got the required exception
    }
}
 
Example #5
Source File: Chart_17_TimeSeries_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a 
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #6
Source File: Cardumen_0086_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #7
Source File: Cardumen_00247_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #8
Source File: XYSeriesTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Some checks for the update(Number, Number) method.
 */
@Test
public void testUpdate() {
    XYSeries series = new XYSeries("S1");
    series.add(new Integer(1), new Integer(2));
    assertEquals(new Integer(2), series.getY(0));
    series.update(new Integer(1), new Integer(3));
    assertEquals(new Integer(3), series.getY(0));
    try {
        series.update(new Integer(2), new Integer(99));
        assertTrue(false);
    }
    catch (SeriesException e) {
        // got the required exception
    }
}
 
Example #9
Source File: Elixir_006_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #10
Source File: Cardumen_0086_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #11
Source File: Cardumen_004_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a 
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #12
Source File: Cardumen_004_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a 
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #13
Source File: Chart_9_TimeSeries_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #14
Source File: Cardumen_00148_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #15
Source File: Cardumen_0013_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #16
Source File: Nopol2017_002_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a 
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index >= 0) {
        TimeSeriesDataItem pair = (TimeSeriesDataItem) this.data.get(index);
        pair.setValue(value);
        fireSeriesChanged();
    }
    else {
        throw new SeriesException(
            "TimeSeries.update(TimePeriod, Number):  period does not exist."
        );
    }

}
 
Example #17
Source File: arja2_two_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Updates an item in the series.
 *
 * @param x  the x-value (<code>null</code> not permitted).
 * @param y  the y-value (<code>null</code> permitted).
 *
 * @throws SeriesException if there is no existing item with the specified
 *         x-value.
 */
public void update(Number x, Number y) {
    int index = indexOf(x);
    if (index < 0) {
        throw new SeriesException("No observation for x = " + x);
    }
    else {
        XYDataItem item = getDataItem(index);
        item.setY(y);
        fireSeriesChanged();
    }
}
 
Example #18
Source File: Cardumen_00146_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Adds or updates an item in the series and sends a
 * {@link SeriesChangeEvent} to all registered listeners.
 *
 * @param x  the x-value (<code>null</code> not permitted).
 * @param y  the y-value (<code>null</code> permitted).
 *
 * @return A copy of the overwritten data item, or <code>null</code> if no
 *         item was overwritten.
 */
public XYDataItem addOrUpdate(Number x, Number y) {
    if (x == null) {
        throw new IllegalArgumentException("Null 'x' argument.");
    }

    // if we get to here, we know that duplicate X values are not permitted
    XYDataItem overwritten = null;
    int index = indexOf(x);
    if (index >= 0 && !this.allowDuplicateXValues) {
        XYDataItem existing = (XYDataItem) this.data.get(index);
        try {
            overwritten = (XYDataItem) existing.clone();
        }
        catch (CloneNotSupportedException e) {
            throw new SeriesException("Couldn't clone XYDataItem!");
        }
        existing.setY(y);
    }
    else {
        // if the series is sorted, the negative index is a result from
        // Collections.binarySearch() and tells us where to insert the
        // new item...otherwise it will be just -1 and we should just
        // append the value to the list...
        if (this.autoSort) {
            this.data.add(-index - 1, new XYDataItem(x, y));
        }
        else {
            this.data.add(new XYDataItem(x, y));
        }
        // check if this addition will exceed the maximum item count...
        if (getItemCount() > this.maximumItemCount) {
            this.data.remove(0);
        }
    }
    fireSeriesChanged();
    return overwritten;
}
 
Example #19
Source File: Cardumen_00197_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Adds or updates an item in the series and sends a
 * {@link SeriesChangeEvent} to all registered listeners.
 *
 * @param x  the x-value (<code>null</code> not permitted).
 * @param y  the y-value (<code>null</code> permitted).
 *
 * @return A copy of the overwritten data item, or <code>null</code> if no
 *         item was overwritten.
 */
public XYDataItem addOrUpdate(Number x, Number y) {
    if (x == null) {
        throw new IllegalArgumentException("Null 'x' argument.");
    }

    // if we get to here, we know that duplicate X values are not permitted
    XYDataItem overwritten = null;
    int index = indexOf(x);
    if (index >= 0 && !this.allowDuplicateXValues) {
        XYDataItem existing = (XYDataItem) this.data.get(index);
        try {
            overwritten = (XYDataItem) existing.clone();
        }
        catch (CloneNotSupportedException e) {
            throw new SeriesException("Couldn't clone XYDataItem!");
        }
        existing.setY(y);
    }
    else {
        // if the series is sorted, the negative index is a result from
        // Collections.binarySearch() and tells us where to insert the
        // new item...otherwise it will be just -1 and we should just
        // append the value to the list...
        if (this.autoSort) {
            this.data.add(-index - 1, new XYDataItem(x, y));
        }
        else {
            this.data.add(new XYDataItem(x, y));
        }
        // check if this addition will exceed the maximum item count...
        if (getItemCount() > this.maximumItemCount) {
            this.data.remove(0);
        }
    }
    fireSeriesChanged();
    return overwritten;
}
 
Example #20
Source File: JGenProg2017_0049_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index < 0) {
        throw new SeriesException("There is no existing value for the "
                + "specified 'period'.");
    }
    update(index, value);
}
 
Example #21
Source File: JGenProg2017_008_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Adds or updates an item in the series and sends a
 * {@link SeriesChangeEvent} to all registered listeners.
 *
 * @param x  the x-value (<code>null</code> not permitted).
 * @param y  the y-value (<code>null</code> permitted).
 *
 * @return A copy of the overwritten data item, or <code>null</code> if no
 *         item was overwritten.
 */
public XYDataItem addOrUpdate(Number x, Number y) {
    if (x == null) {
        throw new IllegalArgumentException("Null 'x' argument.");
    }

    // if we get to here, we know that duplicate X values are not permitted
    XYDataItem overwritten = null;
    int index = indexOf(x);
    if (index >= 0 && !this.allowDuplicateXValues) {
        XYDataItem existing = (XYDataItem) this.data.get(index);
        try {
            overwritten = (XYDataItem) existing.clone();
        }
        catch (CloneNotSupportedException e) {
            throw new SeriesException("Couldn't clone XYDataItem!");
        }
        existing.setY(y);
    }
    else {
        // if the series is sorted, the negative index is a result from
        // Collections.binarySearch() and tells us where to insert the
        // new item...otherwise it will be just -1 and we should just
        // append the value to the list...
        if (this.autoSort) {
            this.data.add(-index - 1, new XYDataItem(x, y));
        }
        else {
            this.data.add(new XYDataItem(x, y));
        }
        // check if this addition will exceed the maximum item count...
        if (getItemCount() > this.maximumItemCount) {
            this.data.remove(0);
        }
    }
    fireSeriesChanged();
    return overwritten;
}
 
Example #22
Source File: JGenProg2017_0083_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index < 0) {
        throw new SeriesException("There is no existing value for the "
                + "specified 'period'.");
    }
    update(index, value);
}
 
Example #23
Source File: arja2_two_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Adds or updates an item in the series and sends a
 * {@link SeriesChangeEvent} to all registered listeners.
 *
 * @param x  the x-value (<code>null</code> not permitted).
 * @param y  the y-value (<code>null</code> permitted).
 *
 * @return A copy of the overwritten data item, or <code>null</code> if no
 *         item was overwritten.
 */
public XYDataItem addOrUpdate(Number x, Number y) {
    if (x == null) {
        throw new IllegalArgumentException("Null 'x' argument.");
    }

    // if we get to here, we know that duplicate X values are not permitted
    XYDataItem overwritten = null;
    int index = indexOf(x);
    if (index >= 0 && !this.allowDuplicateXValues) {
        XYDataItem existing = (XYDataItem) this.data.get(index);
        try {
            overwritten = (XYDataItem) existing.clone();
        }
        catch (CloneNotSupportedException e) {
            throw new SeriesException("Couldn't clone XYDataItem!");
        }
        existing.setY(y);
    }
    else {
        // if the series is sorted, the negative index is a result from
        // Collections.binarySearch() and tells us where to insert the
        // new item...otherwise it will be just -1 and we should just
        // append the value to the list...
    		add(x,y,true);
        // check if this addition will exceed the maximum item count...
        if (getItemCount() > this.maximumItemCount) {
            this.data.remove(0);
        }
    }
    fireSeriesChanged();
    return overwritten;
}
 
Example #24
Source File: Cardumen_00244_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index < 0) {
        throw new SeriesException("There is no existing value for the "
                + "specified 'period'.");
    }
    update(index, value);
}
 
Example #25
Source File: JGenProg2017_007_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index < 0) {
        throw new SeriesException("There is no existing value for the "
                + "specified 'period'.");
    }
    update(index, value);
}
 
Example #26
Source File: Cardumen_00244_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index < 0) {
        throw new SeriesException("There is no existing value for the "
                + "specified 'period'.");
    }
    update(index, value);
}
 
Example #27
Source File: JGenProg2017_00128_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index < 0) {
        throw new SeriesException("There is no existing value for the "
                + "specified 'period'.");
    }
    update(index, value);
}
 
Example #28
Source File: Cardumen_008_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index < 0) {
        throw new SeriesException("There is no existing value for the "
                + "specified 'period'.");
    }
    update(index, value);
}
 
Example #29
Source File: JGenProg2017_00107_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index < 0) {
        throw new SeriesException("There is no existing value for the "
                + "specified 'period'.");
    }
    update(index, value);
}
 
Example #30
Source File: JGenProg2017_0049_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Updates (changes) the value for a time period.  Throws a
 * {@link SeriesException} if the period does not exist.
 *
 * @param period  the period (<code>null</code> not permitted).
 * @param value  the value (<code>null</code> permitted).
 */
public void update(RegularTimePeriod period, Number value) {
    TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value);
    int index = Collections.binarySearch(this.data, temp);
    if (index < 0) {
        throw new SeriesException("There is no existing value for the "
                + "specified 'period'.");
    }
    update(index, value);
}