org.apache.commons.attributes

Class ParameterIndexOutOfBoundsException


public class ParameterIndexOutOfBoundsException
extends IndexOutOfBoundsException

Thrown when attempting to get attributes for a parameter of a constructor or method and the parameter index is out of bounds.

Note: for performance reasons, this exception is only thrown when the Commons Attribute runtime can quickly determine that the index is out of bounds. Therefore, you may sometimes be able to pass an invalid index and not receive this exception. For example, if the runtime knows that the method or constructor has no attributes at all, an empty collection / null or false (as appropriate) will be returned instead. Put simply, don't use this exception to test how many parameters a method or constructor has.

Since:
2.2

Constructor Summary

ParameterIndexOutOfBoundsException(String methodOrConstructorName, int index, int maxIndex)
Create a new ParameterIndexOutOfBoundsException.

Method Summary

private static String
formatMessage(String methodOrConstructorName, int index, int maxIndex)

Constructor Details

ParameterIndexOutOfBoundsException

public ParameterIndexOutOfBoundsException(String methodOrConstructorName,
                                          int index,
                                          int maxIndex)
Create a new ParameterIndexOutOfBoundsException.
Parameters:
methodOrConstructorName - the name of the method or constructor whose parameter the client tried to get attributes for.
index - the index supplied by the client.
maxIndex - the maximum + 1 parameter index allowed. For example, if a method takes two parameters, the maximum allowed index is 1, and this parameter should be set to 2. There is no minIndex parameter - it is assumed to be 0.

Method Details

formatMessage

private static String formatMessage(String methodOrConstructorName,
                                    int index,
                                    int maxIndex)