public static marcRecord createFrommarc4j(Record marc4jRecord,leader.Type defaultType,marcVersion marcVersion,boolean fixalephseq) {
marcRecord record = new marcRecord();
if (defaultType == null)
record.setleader(new leader(marc4jRecord.getleader().marshal()));
else
record.setleader(new leader(marc4jRecord.getleader().marshal(),defaultType));
if (record.getType() == null) {
throw new InvalidParameterException(
String.format(
"Error in '%s': no type has been detected. leader: '%s'",marc4jRecord.getControlNumberField(),record.getleader().getleaderString()));
}
importmarc4jControlFields(marc4jRecord,record,fixalephseq);
importmarc4jdatafields(marc4jRecord,marcVersion);
return record;
}
项目:KantaCDA-API
文件:OidGenerator.java
/**
* Asettaa base oid:in,jota käytetään root oid:n generointiin.<br/>
* <b>Huom. Luokka on singleton ja muutenkin muutetaan staattista muuttujaa,joten tämä vaikuttaa kaikkiin luokan
* instansseihin.</b>
*
* @param baSEOid
* Root oid:n generointiin käytetty 'base oid'
*/
public static void setBaSEOid(String baSEOid) {
if ( baSEOid != null && baSEOid.trim().length() > 0 ) {
if ( !baSEOid.endsWith(Character.toString(OidGenerator.SEPR)) ) {
OidGenerator.baSEOid = baSEOid + OidGenerator.SEPR;
}
else {
OidGenerator.baSEOid = baSEOid;
}
}
else {
// Ei muuteta arvoa jos annettu tyhjä String
throw new InvalidParameterException("Base oid ei saa olla tyhjä");
}
}
项目:Remindy
文件:TaskUtil.java
public static Calendar getRepeatingReminderNextCalendar(RepeatingReminder repeatingReminder) {
Calendar today = Calendar.getInstance();
Calendar endDate = getRepeatingReminderEndCalendar(repeatingReminder);
Calendar cal = CalendarUtil.getCalendarFromDateAndTime( repeatingReminder.getDate(),repeatingReminder.getTime());
//Todo: Cant use getDateFieldFromrepeatType(),Gives off a weird warning
//final int dateField = getDateFieldFromrepeatType(repeatingReminder.getRepeatType());
while(true) {
if (cal.compareto(endDate) >= 0) //If cal passed endDate,reminder is overdue,return null
return null;
if(cal.compareto(today) >= 0) {
return cal;
}
//Todo: Cant use getDateFieldFromrepeatType(),Gives off a weird warning
//cal.add(dateField,repeatingReminder.getRepeatInterval()); break;
switch (repeatingReminder.getRepeatType()) {
case DAILY: cal.add(Calendar.DAY_OF_WEEK,repeatingReminder.getRepeatInterval()); break;
case WEEKLY: cal.add(Calendar.WEEK_OF_YEAR,repeatingReminder.getRepeatInterval()); break;
case MONTHLY: cal.add(Calendar.MONTH,repeatingReminder.getRepeatInterval()); break;
case YEARLY: cal.add(Calendar.YEAR,repeatingReminder.getRepeatInterval()); break;
default: throw new InvalidParameterException("Invalid RepeatType parameter in TaskUtil.getRepeatingReminderEndCalendar()");
}
}
}
项目:Sticky-Header-Grid
文件:StickyHeaderGridAdapter.java
@Override
final public void onBindViewHolder(ViewHolder holder,int position) {
if (mSections == null) {
calculateSections();
}
final int section = mSectionIndices[position];
final int internalType = internalViewType(holder.getItemViewType());
final int externalType = externalViewType(holder.getItemViewType());
switch (internalType) {
case TYPE_HEADER:
onBindHeaderViewHolder((HeaderViewHolder)holder,section);
break;
case TYPE_ITEM:
final ItemViewHolder itemHolder = (ItemViewHolder)holder;
final int offset = getItemSectionOffset(section,position);
onBindItemViewHolder((ItemViewHolder)holder,section,offset);
break;
default:
throw new InvalidParameterException("invalid viewType: " + internalType);
}
}
项目:jmt
文件:Convex3DGraph.java
/**
* Formats a floating point value with the specified number of decimals.
*
* @param value
* Value to convert into string.
* @param decimals
* Number of decimals.
* @return
*/
protected static String floatString(float value,int decimals) {
String res = (value >= 0 ? " " : "") + String.valueOf(value);
int point = res.indexOf(".") + 1;
if (decimals < 0) {
throw new InvalidParameterException("decimals < 0");
} else if (decimals == 0) {
return res.substring(0,point - 2);
} else {
while (res.length() - point < decimals) {
res += "0";
}
if (res.length() - point > decimals) {
res = res.substring(0,point + decimals);
}
return res;
}
}
项目:keepass2android
文件:MyMSAAuthenticator.java
/**
* Log the current user out.
* @param logoutCallback The callback to be called when the logout is complete.
*/
@Override
public void logout(final ICallback<Void> logoutCallback) {
if (!mInitialized) {
throw new IllegalStateException("init must be called");
}
if (logoutCallback == null) {
throw new InvalidParameterException("logoutCallback");
}
mLogger.logDebug("Starting logout async");
mExecutors.performOnBackground(new Runnable() {
@Override
public void run() {
try {
logout();
mExecutors.performOnForeground((Void) null,logoutCallback);
} catch (final ClientException e) {
mExecutors.performOnForeground(e,logoutCallback);
}
}
});
}
/**
* Constructor.
*
* @param keysize the length of a Goppa code
* @throws InvalidParameterException if <tt>keysize < 1</tt>.
*/
public ECCKeyGenParameterSpec(int keysize)
throws InvalidParameterException
{
if (keysize < 1)
{
throw new InvalidParameterException("key size must be positive");
}
m = 0;
n = 1;
while (n < keysize)
{
n <<= 1;
m++;
}
t = n >>> 1;
t /= m;
fieldpoly = polynomialRingGF2.getIrreduciblepolynomial(m);
}
/**
* Constructor.
*
* @param m degree of the finite field GF(2^m)
* @param t error correction capability of the code
* @throws InvalidParameterException if <tt>m < 1</tt> or <tt>m > 32</tt> or
* <tt>t < 0</tt> or <tt>t > n</tt>.
*/
public ECCKeyGenParameterSpec(int m,int t)
throws InvalidParameterException
{
if (m < 1)
{
throw new InvalidParameterException("m must be positive");
}
if (m > 32)
{
throw new InvalidParameterException("m is too large");
}
this.m = m;
n = 1 << m;
if (t < 0)
{
throw new InvalidParameterException("t must be positive");
}
if (t > n)
{
throw new InvalidParameterException("t must be less than n = 2^m");
}
this.t = t;
fieldpoly = polynomialRingGF2.getIrreduciblepolynomial(m);
}
/**
* Initializes this parameter generator for a certain strength
* and source of randomness.
*
* @param strength the strength (size of prime) in bits
* @param random the source of randomness
*/
@Override
protected void engineInit(int strength,SecureRandom random) {
if ((strength >= 512) && (strength <= 1024) && (strength % 64 == 0)) {
this.valueN = 160;
} else if (strength == 2048) {
this.valueN = 224;
} else if (strength == 3072) {
this.valueN = 256;
} else {
throw new InvalidParameterException(
"Unexpected strength (size of prime): " + strength + ". " +
"Prime size should be 512 - 1024,or 2048,3072");
}
this.valueL = strength;
this.seedLen = valueN;
this.random = random;
}
项目:Remindy
文件:TaskUtil.java
public static Calendar getReminderEndCalendar(Reminder reminder) {
switch (reminder.getType()) {
case NONE:
case LOCATION_BASED:
return null;
case ONE_TIME:
return CalendarUtil.getCalendarFromDateAndTime( ((OneTimeReminder)reminder).getDate(),((OneTimeReminder)reminder).getTime() );
case REPEATING:
return getRepeatingReminderEndCalendar(((RepeatingReminder)reminder));
default:
throw new InvalidParameterException("Invalid ReminderType param on TaskUtil.getReminderEndCalendar()");
}
}
项目:powertext
文件:SpellDictionaryASpell.java
/**
* When we don't come up with any suggestions (probably because the threshold was too strict),* then pick the best guesses from the those words that have the same phonetic code.
* @param word - the word we are trying spell correct
* @param Two dimensional array of int used to calculate
* edit distance. Allocating this memory outside of the function will greatly improve efficiency.
* @param wordList - the linked list that will get the best guess
*/
private void addBestGuess(String word,Vector<Word> wordList,int[][] matrix) {
if(matrix == null)
matrix = new int[0][0];
if (wordList.size() != 0)
throw new InvalidParameterException("the wordList vector must be empty");
int bestscore = Integer.MAX_VALUE;
String code = getCode(word);
List<String> simwordlist = getWords(code);
LinkedList<Word> candidates = new LinkedList<Word>();
for (String similar : simwordlist) {
int distance = Editdistance.getdistance(word,similar,matrix);
if (distance <= bestscore) {
bestscore = distance;
Word goodGuess = new Word(similar,distance);
candidates.add(goodGuess);
}
}
//Now,only pull out the guesses that had the best score
for (Iterator<Word> iter = candidates.iterator(); iter.hasNext();) {
Word candidate = iter.next();
if (candidate.getCost() == bestscore)
wordList.add(candidate);
}
}
项目:ipack
文件:KeyPairGeneratorSpi.java
public void initialize(
int strength,SecureRandom random)
{
this.strength = strength;
this.random = random;
if (ecParams != null)
{
try
{
initialize((ECGenParameterSpec)ecParams,random);
}
catch (InvalidAlgorithmParameterException e)
{
throw new InvalidParameterException("key size not configurable.");
}
}
else
{
throw new InvalidParameterException("unkNown key size.");
}
}
项目:hyperscan-java
文件:Util.java
static Throwable hsErrorIntToException(int hsError) {
switch (hsError) {
case -1: return new InvalidParameterException("An invalid parameter has been passed. Is scratch allocated?");
case -2: return new OutOfMemoryError("Hyperscan was unable to allocate memory");
case -3: return new Exception("The engine was terminated by callback.");
case -4: return new Exception("The pattern compiler Failed.");
case -5: return new Exception("The given database was built for a different version of Hyperscan.");
case -6: return new Exception("The given database was built for a different platform.");
case -7: return new Exception("The given database was built for a different mode of operation.");
case -8: return new Exception("A parameter passed to this function was not correctly aligned.");
case -9: return new Exception("The allocator did not return memory suitably aligned for the largest representable data type on this platform.");
case -10: return new Exception("The scratch region was already in use.");
case -11: return new UnsupportedOperationException("Unsupported cpu architecture. At least SSE3 is needed");
case -12: return new Exception("Provided buffer was too small.");
default: return new Exception("Unexpected error: " + hsError);
}
}
项目:android-api
文件:PositionerApi.java
@WorkerThread
int createPositioner(PositionerOptions positionerOptions,Positioner.AllowHandleAccess allowHandleAccess) throws InvalidParameterException {
if (allowHandleAccess == null)
throw new NullPointerException("Null access token. Method is intended for internal use by Positioner");
LatLng location = positionerOptions.getPosition();
if (location == null)
throw new InvalidParameterException("PositionerOptions position must be set");
return nativeCreatePositioner(
m_jniEegeoMapApiPtr,location.latitude,location.longitude,positionerOptions.getElevation(),positionerOptions.getElevationMode().ordinal(),positionerOptions.getIndoorMapId(),positionerOptions.getIndoorMapFloorId()
);
}
项目:yii2inspections
文件:InheritanceChainExtractUtil.java
private static void processClass(@NotNull PHPClass clazz,@NotNull Set<PHPClass> processed) {
if (clazz.isInterface()) {
throw new InvalidParameterException("Interface shall not be provided");
}
processed.add(clazz);
/* re-delegate interface handling */
for (PHPClass anInterface : clazz.getImplementedInterfaces()) {
processInterface(anInterface,processed);
}
/* handle parent class */
if (null != clazz.getSuperClass()) {
processClass(clazz.getSuperClass(),processed);
}
}
@WorkerThread
public int create(polygonoptions polygonoptions,polygon.AllowHandleAccess allowHandleAccess) throws InvalidParameterException {
if (allowHandleAccess == null)
throw new NullPointerException("Null access token. Method is intended for internal use by polygon");
if (polygonoptions.getPoints().size() < 2)
throw new InvalidParameterException("polygonoptions points must contain at least two elements");
List<LatLng> exteriorPoints = polygonoptions.getPoints();
List<List<LatLng>> holes = polygonoptions.getHoles();
final int[] ringVertexCounts = buildringVertexCounts(exteriorPoints,holes);
final double[] allPointsDoubleArray = buildPointsArray(exteriorPoints,holes,ringVertexCounts);
return nativeCreatepolygon(
m_jniEegeoMapApiPtr,polygonoptions.getIndoorMapId(),polygonoptions.getIndoorFloorId(),polygonoptions.getElevation(),polygonoptions.getElevationMode().ordinal(),allPointsDoubleArray,ringVertexCounts,polygonoptions.getFillColor()
);
}
项目:Fatigue-Detection
文件:MiscUtils.java
public static byte[] generaterandomByteArr(int var0) {
if(var0 % 4 != 0) {
throw new InvalidParameterException("length must be in multiples of four");
} else {
byte[] var1 = new byte[var0];
Random var2 = new Random();
for(int var3 = 0; var3 < var0; var3 += 4) {
int var4 = var2.nextInt();
var1[var3] = (byte)(var4 >> 24);
var1[var3 + 1] = (byte)(var4 >> 16);
var1[var3 + 2] = (byte)(var4 >> 8);
var1[var3 + 3] = (byte)var4;
}
return var1;
}
}
项目:raven
文件:JaxbUtils.java
public static String obj2xml(Object o,Class<?> clazz) throws JAXBException {
if(null == o){
throw new InvalidParameterException();
}
JAXBContext context = JAXBContext.newInstance(clazz);
Marshaller marshaller = context.createMarshaller();
//
marshaller.setProperty(Marshaller.JAXB_ENCODING,"UTF-8");
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true);
// 是否去掉头部信息
marshaller.setProperty(Marshaller.JAXB_FRAGMENT,true);
StringWriter writer = new StringWriter();
marshaller.marshal(o,writer);
return writer.toString();
}
项目:Remindy
文件:TaskUtil.java
private static int getDateFieldFromrepeatType(ReminderRepeatType repeatType) {
switch (repeatType) {
case DAILY: return Calendar.DAY_OF_MONTH;
case WEEKLY: return Calendar.WEEK_OF_YEAR;
case MONTHLY: return Calendar.MONTH;
case YEARLY: return Calendar.YEAR;
default: throw new InvalidParameterException("Invalid RepeatType parameter in TaskUtil.getRepeatingReminderEndCalendar()");
}
}
项目:Remindy
文件:HomeAdapter.java
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent,int viewType) {
TaskviewmodelType viewmodelType = TaskviewmodelType.values()[viewType];
switch (viewmodelType) {
case HEADER:
return new TaskHeaderViewHolder(mInflater.inflate(R.layout.list_item_task_header,parent,false));
case UNPROGRAMMED_REMINDER:
return new UnprogrammedTaskViewHolder(mInflater.inflate(R.layout.list_item_task_unprogrammed,false),mFragment);
case ONE_TIME_REMINDER:
return new ProgrammedOneTiMetaskViewHolder(mInflater.inflate(R.layout.list_item_task_programmed_one_time,mFragment);
case REPEATING_REMINDER:
return new ProgrammedRepeatingTaskViewHolder(mInflater.inflate(R.layout.list_item_task_programmed_repeating,mFragment);
case LOCATION_BASED_REMINDER:
return new ProgrammedLocationBasedTaskViewHolder(mInflater.inflate(R.layout.list_item_task_programmed_location_based,mFragment);
default:
throw new InvalidParameterException("Wrong viewType passed to onCreateViewHolder in HomeAdapter");
}
}
项目:lams
文件:EventNotificationService.java
@Override
public boolean isSubscribed(String scope,String name,Long eventSessionId,Long userId)
throws InvalidParameterException {
if (scope == null) {
throw new InvalidParameterException("Scope should not be null.");
}
if (StringUtils.isBlank(name)) {
throw new InvalidParameterException("Name should not be blank.");
}
if (userId == null) {
throw new InvalidParameterException("User ID should not be null.");
}
Event event = eventDAO.getEvent(scope,name,eventSessionId);
if (event != null) {
for (Subscription subscription : event.getSubscriptions()) {
if (subscription.getUserId().equals(Integer.valueOf(userId.intValue()))) {
return true;
}
}
}
return false;
}
项目:lams
文件:EventNotificationService.java
/**
* See {@link IEventNotificationService#subscribe(String,String,Long,AbstractDeliveryMethod,Long)
*
*/
private void subscribe(Event event,Integer userId,AbstractDeliveryMethod deliveryMethod)
throws InvalidParameterException {
if (userId == null) {
throw new InvalidParameterException("User ID can not be null.");
}
if (deliveryMethod == null) {
throw new InvalidParameterException("Delivery method can not be null.");
}
boolean substriptionFound = false;
List<Subscription> subscriptionList = new ArrayList<Subscription>(event.getSubscriptions());
for (int index = 0; index < subscriptionList.size(); index++) {
Subscription subscription = subscriptionList.get(index);
if (subscription.getUserId().equals(userId) && subscription.getDeliveryMethod().equals(deliveryMethod)) {
substriptionFound = true;
break;
}
}
if (!substriptionFound) {
event.getSubscriptions().add(new Subscription(userId,deliveryMethod));
}
eventDAO.insertOrUpdate(event);
}
项目:lams
文件:EventNotificationService.java
@Override
public void subscribe(String scope,AbstractDeliveryMethod deliveryMethod) throws InvalidParameterException {
if (scope == null) {
throw new InvalidParameterException("Scope should not be null.");
}
if (StringUtils.isBlank(name)) {
throw new InvalidParameterException("Name should not be blank.");
}
if (userId == null) {
throw new InvalidParameterException("User ID should not be null.");
}
if (deliveryMethod == null) {
throw new InvalidParameterException("Delivery method should not be null.");
}
Event event = eventDAO.getEvent(scope,eventSessionId);
if (event == null) {
throw new InvalidParameterException("An event with the given parameters does not exist.");
}
subscribe(event,userId,deliveryMethod);
}
项目:lams
文件:EventNotificationService.java
@Override
public void trigger(String scope,Object[] parameterValues)
throws InvalidParameterException {
if (scope == null) {
throw new InvalidParameterException("Scope should not be null.");
}
if (StringUtils.isBlank(name)) {
throw new InvalidParameterException("Name should not be blank.");
}
Event event = eventDAO.getEvent(scope,eventSessionId);
if (event == null) {
throw new InvalidParameterException("An event with the given parameters does not exist.");
}
String message = event.getMessage();
if ((parameterValues != null) && (parameterValues.length > 0)) {
for (int index = 0; index < parameterValues.length; index++) {
Object value = parameterValues[index];
String replacement = value == null ? "" : value.toString();
message = message.replace("{" + index + "}",replacement);
}
}
trigger(event,null,message);
}
项目:lams
文件:EventNotificationService.java
@Override
public void triggerForSingleUser(String scope,Object[] parameterValues) throws InvalidParameterException {
if (scope == null) {
throw new InvalidParameterException("Scope should not be null.");
}
if (StringUtils.isBlank(name)) {
throw new InvalidParameterException("Name should not be blank.");
}
if (userId == null) {
throw new InvalidParameterException("User ID should not be null.");
}
Event event = eventDAO.getEvent(scope,replacement);
}
}
triggerForSingleUser(event,String subject,String message) throws InvalidParameterException {
if (scope == null) {
throw new InvalidParameterException("Scope should not be null.");
}
if (StringUtils.isBlank(name)) {
throw new InvalidParameterException("Name should not be blank.");
}
if (userId == null) {
throw new InvalidParameterException("User ID should not be null.");
}
Event event = eventDAO.getEvent(scope,eventSessionId);
if (event == null) {
throw new InvalidParameterException("An event with the given parameters does not exist.");
}
triggerForSingleUser(event,subject,message);
}
项目:openjdk-jdk10
文件:Sasl.java
private static Object loadFactory(Service service)
throws SaslException {
try {
/*
* Load the implementation class with the same class loader
* that was used to load the provider.
* In order to get the class loader of a class,the
* caller's class loader must be the same as or an ancestor of
* the class loader being returned. Otherwise,the caller must
* have "getClassLoader" permission,or a SecurityException
* will be thrown.
*/
return service.newInstance(null);
} catch (InvalidParameterException | NoSuchAlgorithmException e) {
throw new SaslException("Cannot instantiate service " + service,e);
}
}
项目:lams
文件:EventNotificationService.java
@Override
public void unsubscribe(String scope,AbstractDeliveryMethod deliveryMethod) throws InvalidParameterException {
if (scope == null) {
throw new InvalidParameterException("Scope should not be null.");
}
if (StringUtils.isBlank(name)) {
throw new InvalidParameterException("Name should not be blank.");
}
if (userId == null) {
throw new InvalidParameterException("User ID should not be null.");
}
if (deliveryMethod == null) {
throw new InvalidParameterException("Delivery nethod should not be null.");
}
Event event = eventDAO.getEvent(scope,eventSessionId);
if (event == null) {
throw new InvalidParameterException("An event with the given parameters does not exist.");
}
unsubscribe(event,deliveryMethod);
}
项目:Remindy
文件:RemindyDAO.java
private ContentValues getValuesFromAttachment(Attachment attachment) {
ContentValues values = new ContentValues();
values.put(RemindyContract.AttachmentTable.COLUMN_NAME_TASK_FK.getName(),attachment.getTaskId());
values.put(RemindyContract.AttachmentTable.COLUMN_NAME_TYPE.getName(),attachment.getType().name());
switch (attachment.getType()) {
case AUdio:
values.put(RemindyContract.AttachmentTable.COLUMN_NAME_CONTENT_TEXT.getName(),((AudioAttachment) attachment).getAudioFilename());
break;
case IMAGE:
values.put(RemindyContract.AttachmentTable.COLUMN_NAME_CONTENT_BLOB.getName(),((ImageAttachment) attachment).getThumbnail());
values.put(RemindyContract.AttachmentTable.COLUMN_NAME_CONTENT_TEXT.getName(),((ImageAttachment) attachment).getimageFilename());
break;
case TEXT:
values.put(RemindyContract.AttachmentTable.COLUMN_NAME_CONTENT_TEXT.getName(),((TextAttachment) attachment).getText());
break;
case LIST:
values.put(RemindyContract.AttachmentTable.COLUMN_NAME_CONTENT_TEXT.getName(),((ListAttachment) attachment).getItemsJson());
break;
case LINK:
values.put(RemindyContract.AttachmentTable.COLUMN_NAME_CONTENT_TEXT.getName(),((LinkAttachment) attachment).getLink());
break;
default:
throw new InvalidParameterException("AttachmentType is invalid. Value = " + attachment.getType());
}
return values;
}
项目:LaunchEnr
文件:LoaderCursor.java
/**
* Make an ShortcutInfo object for a restored application or shortcut item that points
* to a package that is not yet installed on the system.
*/
public ShortcutInfo getRestoredItemInfo(Intent intent) {
final ShortcutInfo info = new ShortcutInfo();
info.user = user;
info.intent = intent;
info.iconBitmap = loadIcon(info);
// the fallback icon
if (info.iconBitmap == null) {
mIconCache.getTitleAndIcon(info,false /* useLowResIcon */);
}
if (hasRestoreFlag(ShortcutInfo.FLAG_RESTORED_ICON)) {
String title = getTitle();
if (!TextUtils.isEmpty(title)) {
info.title = Utilities.trim(title);
}
} else if (hasRestoreFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)) {
if (TextUtils.isEmpty(info.title)) {
info.title = getTitle();
}
} else {
throw new InvalidParameterException("Invalid restoreType " + restoreFlag);
}
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title,info.user);
info.itemType = itemType;
info.status = restoreFlag;
return info;
}
项目:jmt
文件:Matrix4.java
项目:pokequest
文件:MultipleChoiceQuizGenerator.java
/**
* Get random choices from the list
* @param numOfChoices number of choices to get
* @return choice list
*/
public List<T> getRandomChoices(int numOfChoices) {
if (numOfChoices < 0 || numOfChoices >= mChoices.length) {
throw new InvalidParameterException("numOfChoices must be in [0,length-1]");
}
List<T> res = new ArrayList<>();
for (int i = mChoices.length - 1; i > mChoices.length - 1 - numOfChoices; i--) {
int index = RANDOM.nextInt(i + 1);
T temp = mChoices[i];
mChoices[i] = mChoices[index];
mChoices[index] = temp;
res.add(mChoices[i]);
}
return res;
}
/**
* Constructor.
*
* @param m degree of the finite field GF(2^m)
* @param t error correction capability of the code
* @param poly the field polynomial
* @throws InvalidParameterException if <tt>m < 1</tt> or <tt>m > 32</tt> or
* <tt>t < 0</tt> or <tt>t > n</tt> or
* <tt>poly</tt> is not an irreducible field polynomial.
*/
public ECCKeyGenParameterSpec(int m,int t,int poly)
throws InvalidParameterException
{
this.m = m;
if (m < 1)
{
throw new InvalidParameterException("m must be positive");
}
if (m > 32)
{
throw new InvalidParameterException(" m is too large");
}
this.n = 1 << m;
this.t = t;
if (t < 0)
{
throw new InvalidParameterException("t must be positive");
}
if (t > n)
{
throw new InvalidParameterException("t must be less than n = 2^m");
}
if ((polynomialRingGF2.degree(poly) == m)
&& (polynomialRingGF2.isIrreducible(poly)))
{
this.fieldpoly = poly;
}
else
{
throw new InvalidParameterException(
"polynomial is not a field polynomial for GF(2^m)");
}
}
项目:AndroidTvDemo
文件:IjkMediaPlayer.java
@CalledByNative
private static boolean onNativeInvoke(Object weakThiz,int what,Bundle args) {
DebugLog.ifmt(TAG,"onNativeInvoke %d",what);
if (weakThiz == null || !(weakThiz instanceof WeakReference<?>))
throw new IllegalStateException("<null weakThiz>.onNativeInvoke()");
@SuppressWarnings("unchecked")
WeakReference<IjkMediaPlayer> weakPlayer = (WeakReference<IjkMediaPlayer>) weakThiz;
IjkMediaPlayer player = weakPlayer.get();
if (player == null)
throw new IllegalStateException("<null weakPlayer>.onNativeInvoke()");
OnNativeInvokeListener listener = player.mOnNativeInvokeListener;
if (listener != null && listener.onNativeInvoke(what,args))
return true;
switch (what) {
case OnNativeInvokeListener.ON_CONCAT_RESOLVE_SEGMENT: {
OnControlMessageListener onControlMessageListener = player.mOnControlMessageListener;
if (onControlMessageListener == null)
return false;
int segmentIndex = args.getInt(OnNativeInvokeListener.ARG_SEGMENT_INDEX,-1);
if (segmentIndex < 0)
throw new InvalidParameterException("onNativeInvoke(invalid segment index)");
String newUrl = onControlMessageListener.onControlResolveSegmentUrl(segmentIndex);
if (newUrl == null)
throw new RuntimeException(new IOException("onNativeInvoke() = <NULL newUrl>"));
args.putString(OnNativeInvokeListener.ARG_URL,newUrl);
return true;
}
default:
return false;
}
}
/**
* Initializes this key generator for a certain keysize,using the given
* source of randomness.
*
* @param keysize the keysize. This is an algorithm-specific
* metric specified in number of bits.
* @param random the source of randomness for this key generator
*/
protected void engineInit(int keysize,SecureRandom random) {
if (((keysize % 8) != 0) ||
(!AESCrypt.isKeySizeValid(keysize/8))) {
throw new InvalidParameterException
("Wrong keysize: must be equal to 128,192 or 256");
}
this.keySize = keysize/8;
this.engineInit(random);
}
项目:SocialLogin
文件:SocialLogin.java
/**
* Initialize SocialLogin with pre-configured AvailableTypeMap
*
* @param context
* @param availableTypeMap
*/
public static void init(Context context,Map<SocialType,SocialConfig> availableTypeMap) {
if (context instanceof Activity || context instanceof Service) {
throw new InvalidParameterException("Context must be Application Context,not Activity,Service Context.");
}
mContext = context;
if (!availableTypeMap.isEmpty()) {
SocialLogin.availableTypeMap = availableTypeMap;
initializeSDK();
}
}
项目:TOSCAna
文件:Range.java
/**
@param min the minimum allowed number of occurrences.
@param max the maximum allowed number of occurrences. Use Integer.MAX_VALUE to indicate `UNBOUNDED`.
Must not be less than min
*/
public Range(int min,int max) {
if (max < min) {
throw new InvalidParameterException(format("Constraint violation: min (%d) <= max (%d)",min,max));
}
if (max < 0 || min < 0) {
throw new InvalidParameterException(format("Constraint violation: min (%d) >= 0 && max (%d) >= 0",max));
}
this.min = min;
this.max = max;
}
private static void testDSAGenParameterSpec(DataTuple dataTuple)
throws NoSuchAlgorithmException,NoSuchProviderException,InvalidParameterSpecException,InvalidAlgorithmParameterException {
System.out.printf("Test case: primePLen=%d," + "subprimeQLen=%d%n",dataTuple.primePLen,dataTuple.subprimeQLen);
AlgorithmParameterGenerator apg =
AlgorithmParameterGenerator.getInstance(ALGORITHM_NAME,PROVIDER_NAME);
DSAGenParameterSpec genParamSpec = createGenParameterSpec(dataTuple);
// genParamSpec will be null if IllegalAE is thrown when expected.
if (genParamSpec == null) {
return;
}
try {
apg.init(genParamSpec,null);
AlgorithmParameters param = apg.generateParameters();
checkParam(param,genParamSpec);
System.out.println("Test case passed");
} catch (InvalidParameterException ipe) {
// The DSAGenParameterSpec API support this,but the real
// implementation in SUN doesn't
if (!dataTuple.isSunProviderSupported) {
System.out.println("Test case passed: expected "
+ "InvalidParameterException is caught");
} else {
throw new RuntimeException("Test case Failed.",ipe);
}
}
}
项目:openjdk-jdk10
文件:TestDH2048.java
private static void checkUnsupportedKeySize(KeyPairGenerator kpg,int ks)
throws Exception {
try {
kpg.initialize(ks);
throw new Exception("Expected IPE not thrown for " + ks);
} catch (InvalidParameterException ipe) {
}
}
项目:springentityprovider
文件:SpringEntityProvider.java
/**
* limit the maximum number of returned entities (limit the maximum numbers of rows if this is used in a Grid)
*
* @param resultLimit maximum number of entities
*/
public void setLimit(int resultLimit) {
if (resultLimit <= 0) {
throw new InvalidParameterException("maxSize must be positive");
}
this.resultLimit = resultLimit;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。