Java 类java.security.InvalidParameterException 实例源码

项目:metadata-qa-marc    文件:MarcFactory.java   
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, record, 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);
            }
        }
    });
}
项目:ipack    文件:ECCKeyGenParameterSpec.java   
/**
 * Constructor.
 *
 * @param keysize the length of a Goppa code
 * @throws InvalidParameterException if <tt>keysize &lt; 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);
}
项目:ipack    文件:ECCKeyGenParameterSpec.java   
/**
 * Constructor.
 *
 * @param m degree of the finite field GF(2^m)
 * @param t error correction capability of the code
 * @throws InvalidParameterException if <tt>m &lt; 1</tt> or <tt>m &gt; 32</tt> or
 * <tt>t &lt; 0</tt> or <tt>t &gt; 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);
}
项目:openjdk-jdk10    文件:DSAParameterGenerator.java   
/**
 * 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);
    }
}
项目:android-api    文件:PolygonApi.java   
@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, parent, false), mFragment);
        case ONE_TIME_REMINDER:
            return new ProgrammedOneTimeTaskViewHolder(mInflater.inflate(R.layout.list_item_task_programmed_one_time, parent, false), mFragment);
        case REPEATING_REMINDER:
            return new ProgrammedRepeatingTaskViewHolder(mInflater.inflate(R.layout.list_item_task_programmed_repeating, parent, false), mFragment);
        case LOCATION_BASED_REMINDER:
            return new ProgrammedLocationBasedTaskViewHolder(mInflater.inflate(R.layout.list_item_task_programmed_location_based, parent, false), 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, 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, String name, Long eventSessionId, Integer userId,
    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, name, 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, String name, Long eventSessionId, 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, name, 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, String name, Long eventSessionId, Integer userId,
    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, name, 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);
    }
}
triggerForSingleUser(event, userId, null, message);
   }
项目:lams    文件:EventNotificationService.java   
@Override
   public void triggerForSingleUser(String scope, String name, Long eventSessionId, Integer userId, 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, name, eventSessionId);
if (event == null) {
    throw new InvalidParameterException("An event with the given parameters does not exist.");
}
triggerForSingleUser(event, userId, 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, String name, Long eventSessionId, Integer userId,
    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, name, eventSessionId);
if (event == null) {
    throw new InvalidParameterException("An event with the given parameters does not exist.");
}
unsubscribe(event, userId, 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   
/**
 * Sets all values from a given matrix in column-major vector array form.
 * 
 * @param a
 *            Array to be converted into a matrix.
 */
public void set( float[] a ) {
    if ( a.length != 16 ) {
        throw new InvalidParameterException( "Array length != 16" );
    }
    for ( int i = 0; i < 16; i++ ) {
        m[i] = a[i];
    }
}
项目: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;
}
项目:ipack    文件:ECCKeyGenParameterSpec.java   
/**
 * 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 &lt; 1</tt> or <tt>m &gt; 32</tt> or
 * <tt>t &lt; 0</tt> or <tt>t &gt; 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;
    }
}
项目:OpenJSharp    文件:AESKeyGenerator.java   
/**
 * 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", min, max));
    }
    this.min = min;
    this.max = max;
}
项目:jdk8u-jdk    文件:TestDSAGenParameterSpec.java   
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;
}