List of usage examples for org.apache.commons.lang3 Validate validIndex
public static <T extends CharSequence> T validIndex(final T chars, final int index, final String message, final Object... values)
Validates that the index is within the bounds of the argument character sequence; otherwise throwing an exception with the specified message.
Validate.validIndex(myStr, 2, "The string index is invalid: ");
If the character sequence is null , then the message of the exception is "The validated object is null".
From source file:edu.umich.flowfence.service.Sandbox.java
public static Sandbox get(int id) { Validate.validIndex(s_mSandboxesById, id, "Invalid sandbox ID %d", id); synchronized (s_mSandboxesById) { Sandbox sb = s_mSandboxesById[id]; if (sb == null) { sb = new Sandbox(id); s_mSandboxesById[id] = sb;//from w w w . j av a 2s. c o m if (s_mExtrasBundle.isEmpty()) { s_mExtrasBundle.putBinder(SandboxService.EXTRA_TRUSTED_API, TrustedAPI.getInstance().asBinder()); s_mExtrasBundle.putBinder(SandboxService.EXTRA_ROOT_SERVICE, FlowfenceApplication.getInstance().getBinder().asBinder()); } } return sb; } }
From source file:edu.umich.oasis.service.Sandbox.java
public static Sandbox get(int id) { Validate.validIndex(s_mSandboxesById, id, "Invalid sandbox ID %d", id); synchronized (s_mSandboxesById) { Sandbox sb = s_mSandboxesById[id]; if (sb == null) { sb = new Sandbox(id); s_mSandboxesById[id] = sb;//from w w w.j a v a 2 s . c o m if (s_mExtrasBundle.isEmpty()) { s_mExtrasBundle.putBinder(SandboxService.EXTRA_TRUSTED_API, TrustedAPI.getInstance().asBinder()); s_mExtrasBundle.putBinder(SandboxService.EXTRA_ROOT_SERVICE, OASISApplication.getInstance().getBinder().asBinder()); } } return sb; } }