本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.SUBARRAY_ENDS_AFTER_ARRAY_END属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.SUBARRAY_ENDS_AFTER_ARRAY_END属性的具体用法?Java LocalizedFormats.SUBARRAY_ENDS_AFTER_ARRAY_END怎么用?Java LocalizedFormats.SUBARRAY_ENDS_AFTER_ARRAY_END使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.SUBARRAY_ENDS_AFTER_ARRAY_END属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setData
/**
* Set the data array. The input array is copied, not referenced.
*
* @param values data array to store
* @param begin the index of the first element to include
* @param length the number of elements to include
* @throws MathIllegalArgumentException if values is null or the indices
* are not valid
* @see #evaluate()
*/
public void setData(final double[] values, final int begin, final int length)
throws MathIllegalArgumentException {
if (values == null) {
throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
}
if (begin < 0) {
throw new NotPositiveException(LocalizedFormats.START_POSITION, begin);
}
if (length < 0) {
throw new NotPositiveException(LocalizedFormats.LENGTH, length);
}
if (begin + length > values.length) {
throw new NumberIsTooLargeException(LocalizedFormats.SUBARRAY_ENDS_AFTER_ARRAY_END,
begin + length, values.length, true);
}
storedData = new double[length];
System.arraycopy(values, begin, storedData, 0, length);
}
示例2: verifyValues
/**
* This method is used
* to verify that the input parameters designate a subarray of positive length.
* <p>
* <ul>
* <li>returns <code>true</code> iff the parameters designate a subarray of
* non-negative length</li>
* <li>throws <code>IllegalArgumentException</code> if the array is null or
* or the indices are invalid</li>
* <li>returns <code>false</li> if the array is non-null, but
* <code>length</code> is 0 unless <code>allowEmpty</code> is <code>true</code>
* </ul></p>
*
* @param values the input array
* @param begin index of the first array element to include
* @param length the number of elements to include
* @param allowEmpty if <code>true</code> then zero length arrays are allowed
* @return true if the parameters are valid
* @throws MathIllegalArgumentException if the indices are invalid or the array is null
* @since 3.3
*/
public static boolean verifyValues(final double[] values, final int begin,
final int length, final boolean allowEmpty) throws MathIllegalArgumentException {
if (values == null) {
throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
}
if (begin < 0) {
throw new NotPositiveException(LocalizedFormats.START_POSITION, Integer.valueOf(begin));
}
if (length < 0) {
throw new NotPositiveException(LocalizedFormats.LENGTH, Integer.valueOf(length));
}
if (begin + length > values.length) {
throw new NumberIsTooLargeException(LocalizedFormats.SUBARRAY_ENDS_AFTER_ARRAY_END,
Integer.valueOf(begin + length), Integer.valueOf(values.length), true);
}
if (length == 0 && !allowEmpty) {
return false;
}
return true;
}