use of java.security.InvalidParameterException in project UltimateAndroid by cymcsg.
the class SimpleMonthView method setMonthParams.
public void setMonthParams(HashMap<String, Integer> params) {
if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
throw new InvalidParameterException("You must specify month and year for this view");
}
setTag(params);
if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
if (mRowHeight < MIN_HEIGHT) {
mRowHeight = MIN_HEIGHT;
}
}
if (params.containsKey(VIEW_PARAMS_SELECTED_BEGIN_DAY)) {
mSelectedBeginDay = params.get(VIEW_PARAMS_SELECTED_BEGIN_DAY);
}
if (params.containsKey(VIEW_PARAMS_SELECTED_LAST_DAY)) {
mSelectedLastDay = params.get(VIEW_PARAMS_SELECTED_LAST_DAY);
}
if (params.containsKey(VIEW_PARAMS_SELECTED_BEGIN_MONTH)) {
mSelectedBeginMonth = params.get(VIEW_PARAMS_SELECTED_BEGIN_MONTH);
}
if (params.containsKey(VIEW_PARAMS_SELECTED_LAST_MONTH)) {
mSelectedLastMonth = params.get(VIEW_PARAMS_SELECTED_LAST_MONTH);
}
if (params.containsKey(VIEW_PARAMS_SELECTED_BEGIN_YEAR)) {
mSelectedBeginYear = params.get(VIEW_PARAMS_SELECTED_BEGIN_YEAR);
}
if (params.containsKey(VIEW_PARAMS_SELECTED_LAST_YEAR)) {
mSelectedLastYear = params.get(VIEW_PARAMS_SELECTED_LAST_YEAR);
}
mMonth = params.get(VIEW_PARAMS_MONTH);
mYear = params.get(VIEW_PARAMS_YEAR);
mHasToday = false;
mToday = -1;
mCalendar.set(Calendar.MONTH, mMonth);
mCalendar.set(Calendar.YEAR, mYear);
mCalendar.set(Calendar.DAY_OF_MONTH, 1);
mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
} else {
mWeekStart = mCalendar.getFirstDayOfWeek();
}
mNumCells = CalendarUtils.getDaysInMonth(mMonth, mYear);
for (int i = 0; i < mNumCells; i++) {
final int day = i + 1;
if (sameDay(day, today)) {
mHasToday = true;
mToday = day;
}
mIsPrev = prevDay(day, today);
}
mNumRows = calculateNumRows();
}
use of java.security.InvalidParameterException in project MaterialDateTimePicker by wdullaer.
the class MonthView method setMonthParams.
/**
* Sets all the parameters for displaying this week. The only required
* parameter is the week number. Other parameters have a default value and
* will only update if a new value is included, except for focus month,
* which will always default to no focus month if no value is passed in. See
* {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
*
* @param params A map of the new parameters, see
* {@link #VIEW_PARAMS_HEIGHT}
*/
public void setMonthParams(HashMap<String, Integer> params) {
if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
throw new InvalidParameterException("You must specify month and year for this view");
}
setTag(params);
// We keep the current value for any params not present
if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
if (mRowHeight < MIN_HEIGHT) {
mRowHeight = MIN_HEIGHT;
}
}
if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
}
// Allocate space for caching the day numbers and focus values
mMonth = params.get(VIEW_PARAMS_MONTH);
mYear = params.get(VIEW_PARAMS_YEAR);
// Figure out what day today is
//final Time today = new Time(Time.getCurrentTimezone());
//today.setToNow();
final Calendar today = Calendar.getInstance(mController.getTimeZone());
mHasToday = false;
mToday = -1;
mCalendar.set(Calendar.MONTH, mMonth);
mCalendar.set(Calendar.YEAR, mYear);
mCalendar.set(Calendar.DAY_OF_MONTH, 1);
mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);
if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
} else {
mWeekStart = mCalendar.getFirstDayOfWeek();
}
mNumCells = mCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
for (int i = 0; i < mNumCells; i++) {
final int day = i + 1;
if (sameDay(day, today)) {
mHasToday = true;
mToday = day;
}
}
mNumRows = calculateNumRows();
// Invalidate cached accessibility information.
mTouchHelper.invalidateRoot();
}
use of java.security.InvalidParameterException in project robovm by robovm.
the class SecurityTest method test_getProvidersLjava_lang_String.
/**
* java.security.Security#getProviders(String)
*/
public void test_getProvidersLjava_lang_String() {
try {
Security.getProviders("");
fail("No expected InvalidParameterException");
} catch (InvalidParameterException e) {
}
try {
Security.getProviders((String) null);
fail("No expected NullPointerException");
} catch (NullPointerException e) {
}
testGetProviders(Locale.US);
testGetProviders(new Locale("tr", "TR"));
}
use of java.security.InvalidParameterException in project robovm by robovm.
the class Signature2Test method test_setParameterLjava_lang_StringLjava_lang_Object.
/**
* java.security.Signature#setParameter(java.lang.String,
* java.lang.Object)
*/
@SuppressWarnings("deprecation")
public void test_setParameterLjava_lang_StringLjava_lang_Object() throws Exception {
Signature sig = Signature.getInstance("DSA");
try {
sig.setParameter("r", BigInteger.ONE);
sig.setParameter("s", BigInteger.ONE);
} catch (InvalidParameterException e) {
// Could be that it's an invalid param for the found algorithm
} catch (UnsupportedOperationException e) {
// Could be that the operation is not supported
}
}
use of java.security.InvalidParameterException in project robovm by robovm.
the class KeyPairGenerator1Test method testKeyPairGenerator13.
/**
* Test for methods: <code>initialize(int keysize)</code>
* <code>initialize(int keysize, SecureRandom random)</code>
* <code>initialize(AlgorithmParameterSpec param)</code>
* <code>initialize(AlgorithmParameterSpec param, SecureRandom random)</code>
* <code>generateKeyPair()</code>
* <code>genKeyPair()</code>
* Assertion: initialize(int ...) throws InvalidParameterException when
* keysize in incorrect Assertion: initialize(AlgorithmParameterSpec
* ...)throws UnsupportedOperationException Assertion: generateKeyPair() and
* genKeyPair() return not null KeyPair Additional class MyKeyPairGenerator2
* is used
*/
public void testKeyPairGenerator13() {
int[] keys = { -1, -250, 1, 63, -512, -1024 };
SecureRandom random = new SecureRandom();
KeyPairGenerator mKPG = new MyKeyPairGenerator2(null);
assertEquals("Algorithm must be null", mKPG.getAlgorithm(), MyKeyPairGenerator2.getResAlgorithm());
assertNull("genKeyPair() must return null", mKPG.genKeyPair());
assertNull("generateKeyPair() mut return null", mKPG.generateKeyPair());
for (int i = 0; i < keys.length; i++) {
try {
mKPG.initialize(keys[i]);
fail("InvalidParameterException must be thrown (key: " + Integer.toString(keys[i]) + ")");
} catch (InvalidParameterException e) {
}
try {
mKPG.initialize(keys[i], random);
fail("InvalidParameterException must be thrown (key: " + Integer.toString(keys[i]) + ")");
} catch (InvalidParameterException e) {
}
}
try {
mKPG.initialize(64);
} catch (InvalidParameterException e) {
fail("Unexpected InvalidParameterException was thrown");
}
try {
mKPG.initialize(64, null);
} catch (InvalidParameterException e) {
fail("Unexpected InvalidParameterException was thrown");
}
try {
mKPG.initialize(null, random);
} catch (UnsupportedOperationException e) {
// on j2se1.4 this exception is not thrown
} catch (InvalidAlgorithmParameterException e) {
fail("Unexpected InvalidAlgorithmParameterException was thrown");
}
}
Aggregations