类java.lang.IllegalArgumentException源码实例Demo

下面列出了怎么用java.lang.IllegalArgumentException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android_9.0.0_r45   文件: MainFragmentArgs.java
public static MainFragmentArgs fromBundle(Bundle bundle) {
    MainFragmentArgs result = new MainFragmentArgs();
    if (bundle.containsKey("main")) {
        result.main = bundle.getString("main");
    } else {
        throw new IllegalArgumentException("Required argument \"main\" is missing and does not have an android:defaultValue");
    }
    if (bundle.containsKey("optional")) {
        result.optional = bundle.getInt("optional");
    }
    if (bundle.containsKey("reference")) {
        result.reference = bundle.getInt("reference");
    }
    if (bundle.containsKey("floatArg")) {
        result.floatArg = bundle.getFloat("floatArg");
    }
    if (bundle.containsKey("boolArg")) {
        result.boolArg = bundle.getBoolean("boolArg");
    }
    return result;
}
 
源代码2 项目: OpenCue   文件: FrameSet.java
/**
 * Return a sub-FrameSet object starting at startFrame with max chunkSize members
 * @param startFrameIndex Index of frame to start at; not the frame itself
 * @param chunkSize       Max number of frames per chunk
 * @return                String representation of the chunk, e.g. 1-1001x3
 */
public String getChunk(int startFrameIndex, int chunkSize) {
    if (frameList.size() <= startFrameIndex || startFrameIndex < 0) {
        String sf = String.valueOf(startFrameIndex);
        String sz = String.valueOf(frameList.size() - 1);
        throw new IllegalArgumentException("startFrameIndex " + sf + " is not in range 0-" + sz);
    }
    if (chunkSize == 1) {
        // Chunksize of 1 so the FrameSet is just the startFrame
        return String.valueOf(frameList.get(startFrameIndex));
    }
    int finalFrameIndex = frameList.size() - 1;
    int endFrameIndex = startFrameIndex + chunkSize - 1;
    if (endFrameIndex > finalFrameIndex) {
        // We don't have enough frames, so return the remaining frames.
        endFrameIndex = finalFrameIndex;
    }

    return framesToFrameRanges(frameList.subList(startFrameIndex, endFrameIndex+1));
}
 
public LocationProvider getInstance (Integer locationProvider) {
    LocationProvider provider;
    switch (locationProvider) {
        case Config.DISTANCE_FILTER_PROVIDER:
            provider = new DistanceFilterLocationProvider(mContext);
            break;
        case Config.ACTIVITY_PROVIDER:
            provider = new ActivityRecognitionLocationProvider(mContext);
            break;
        case Config.RAW_PROVIDER:
            provider = new RawLocationProvider(mContext);
            break;
        default:
            throw new IllegalArgumentException("Provider not found");
    }

    return provider;
}
 
源代码4 项目: metrics-opentsdb   文件: OpenTsdbMetric.java
/**
 * Convert a tag string into a tag map.
 *
 * @param tagString a space-delimited string of key-value pairs. For example, {@code "key1=value1 key_n=value_n"}
 * @return a tag {@link Map}
 * @throws IllegalArgumentException if the tag string is corrupted.
 */
public static Map<String, String> parseTags(final String tagString) throws IllegalArgumentException {
    // delimit by whitespace or '='
    Scanner scanner = new Scanner(tagString).useDelimiter("\\s+|=");

    Map<String, String> tagMap = new HashMap<String, String>();
    try {
        while (scanner.hasNext()) {
            String tagName = scanner.next();
            String tagValue = scanner.next();
            tagMap.put(tagName, tagValue);
        }
    } catch (NoSuchElementException e) {
        // The tag string is corrupted.
        throw new IllegalArgumentException("Invalid tag string '" + tagString + "'");
    } finally {
        scanner.close();
    }

    return tagMap;
}
 
源代码5 项目: WeatherStream   文件: Weather_Table.java
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`wId`":  {
      return wId;
    }
    case "`id`":  {
      return id;
    }
    case "`icon`":  {
      return icon;
    }
    case "`description`":  {
      return description;
    }
    case "`main`":  {
      return main;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
 
源代码6 项目: WeatherStream   文件: WeatherForecastData_Table.java
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`id`":  {
      return id;
    }
    case "`message`":  {
      return message;
    }
    case "`cnt`":  {
      return cnt;
    }
    case "`cod`":  {
      return cod;
    }
    case "`dt`":  {
      return dt;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
 
源代码7 项目: WeatherStream   文件: Rain_Table.java
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`id`":  {
      return id;
    }
    case "`dt`":  {
      return dt;
    }
    case "`rainCount`":  {
      return rainCount;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
 
源代码8 项目: WeatherStream   文件: ForecastList_Table.java
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`id`":  {
      return id;
    }
    case "`dt`":  {
      return dt;
    }
    case "`dt_txt`":  {
      return dt_txt;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
 
源代码9 项目: WeatherStream   文件: Wind_Table.java
@Override
public final Property getProperty(String columnName) {
  columnName = QueryBuilder.quoteIfNeeded(columnName);
  switch ((columnName)) {
    case "`id`":  {
      return id;
    }
    case "`speed`":  {
      return speed;
    }
    case "`deg`":  {
      return deg;
    }
    default: {
      throw new IllegalArgumentException("Invalid column name passed. Ensure you are calling the correct table's column");
    }
  }
}
 
源代码10 项目: conductor   文件: AbstractProtoMapper.java
public Task.Status fromProto(TaskPb.Task.Status from) {
    Task.Status to;
    switch (from) {
        case IN_PROGRESS: to = Task.Status.IN_PROGRESS; break;
        case CANCELED: to = Task.Status.CANCELED; break;
        case FAILED: to = Task.Status.FAILED; break;
        case FAILED_WITH_TERMINAL_ERROR: to = Task.Status.FAILED_WITH_TERMINAL_ERROR; break;
        case COMPLETED: to = Task.Status.COMPLETED; break;
        case COMPLETED_WITH_ERRORS: to = Task.Status.COMPLETED_WITH_ERRORS; break;
        case SCHEDULED: to = Task.Status.SCHEDULED; break;
        case TIMED_OUT: to = Task.Status.TIMED_OUT; break;
        case SKIPPED: to = Task.Status.SKIPPED; break;
        default: throw new IllegalArgumentException("Unexpected enum constant: " + from);
    }
    return to;
}
 
源代码11 项目: repairnator   文件: RepairnatorProcessBuilder.java
public void checkValid() {
	if (this.javaExec == null || this.javaExec.equals("")) {
		throw new IllegalArgumentException("Repairnator Process building failed: java executable location is null");
	}

	if (this.jarLocation == null || this.jarLocation.equals("")) {
		throw new IllegalArgumentException("Repairnator Process building failed: repairnator JAR location is null");
	}

	if (this.gitUrl == null || this.gitUrl.equals("")) {
		throw new IllegalArgumentException("Repairnator Process building failed: no git url provided");
	}

	if (this.gitBranch == null || this.gitBranch.equals("")) {
		throw new IllegalArgumentException("Repairnator Process building failed: no git branch provided");
	}

	if (this.repairTools == null || this.repairTools.equals("")) {
		throw new IllegalArgumentException("Repairnator Process building failed: no repair tools specified");
	}
}
 
源代码12 项目: Silence   文件: SmsCipher.java
public IncomingTextMessage decrypt(Context context, IncomingTextMessage message)
    throws LegacyMessageException, InvalidMessageException, DuplicateMessageException,
           NoSessionException, UntrustedIdentityException
{
  try {
    byte[]        decoded       = transportDetails.getDecodedMessage(message.getMessageBody().getBytes());
    SignalMessage signalMessage = new SignalMessage(decoded);
    SessionCipher sessionCipher = new SessionCipher(signalProtocolStore, new SignalProtocolAddress(message.getSender(), 1));
    byte[]        padded        = sessionCipher.decrypt(signalMessage);
    byte[]        plaintext     = transportDetails.getStrippedPaddingMessageBody(padded);

    if (message.isEndSession() && "TERMINATE".equals(new String(plaintext))) {
      signalProtocolStore.deleteSession(new SignalProtocolAddress(message.getSender(), 1));
    }

    return message.withMessageBody(new String(plaintext));
  } catch (IOException | IllegalArgumentException | NullPointerException e) {
    throw new InvalidMessageException(e);
  }
}
 
源代码13 项目: semanticvectors   文件: VectorSearcher.java
/**
 * @param queryVecStore Vector store to use for query generation.
 * @param searchVecStore The vector store to search.
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed into a query
 * expression. If the string "?" appears, terms best fitting into this position will be returned
 */
public VectorSearcherPerm(VectorStore queryVecStore,
    VectorStore searchVecStore,
    LuceneUtils luceneUtils,
    FlagConfig flagConfig,
    String[] queryTerms)
        throws IllegalArgumentException, ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);

  try {
    theAvg = pitt.search.semanticvectors.CompoundVectorBuilder.
        getPermutedQueryVector(queryVecStore, luceneUtils, flagConfig, queryTerms);
  } catch (IllegalArgumentException e) {
    logger.info("Couldn't create permutation VectorSearcher ...");
    throw e;
  }

  if (theAvg.isZeroVector()) {
    throw new ZeroVectorException("Permutation query vector is zero ... no results.");
  }
}
 
源代码14 项目: semanticvectors   文件: VectorSearcher.java
/**
 * @param queryVecStore Vector store to use for query generation (this is also reversed).
 * @param searchVecStore The vector store to search (this is also reversed).
 * @param luceneUtils LuceneUtils object to use for query weighting. (May be null.)
 * @param queryTerms Terms that will be parsed into a query
 * expression. If the string "?" appears, terms best fitting into this position will be returned
 */
public BalancedVectorSearcherPerm(
    VectorStore queryVecStore, VectorStore searchVecStore, LuceneUtils luceneUtils,
    FlagConfig flagConfig, String[] queryTerms)
        throws IllegalArgumentException, ZeroVectorException {
  super(queryVecStore, searchVecStore, luceneUtils, flagConfig);
  specialFlagConfig = flagConfig;
  specialLuceneUtils = luceneUtils;
  try {
    oneDirection = pitt.search.semanticvectors.CompoundVectorBuilder.
        getPermutedQueryVector(queryVecStore, luceneUtils, flagConfig, queryTerms);
    otherDirection = pitt.search.semanticvectors.CompoundVectorBuilder.
        getPermutedQueryVector(searchVecStore, luceneUtils, flagConfig, queryTerms);
  } catch (IllegalArgumentException e) {
    logger.info("Couldn't create balanced permutation VectorSearcher ...");
    throw e;
  }

  if (oneDirection.isZeroVector()) {
    throw new ZeroVectorException("Permutation query vector is zero ... no results.");
  }
}
 
源代码15 项目: semanticvectors   文件: VectorSearcher.java
/**
  * Lucene search, no semantic vectors required
  * @param luceneUtils LuceneUtils object to use for query weighting. (May not be null.)
  * @param queryTerms Terms that will be parsed into a query expression
  */
 public VectorSearcherLucene(LuceneUtils luceneUtils,
     FlagConfig flagConfig, String[] queryTerms)
         throws IllegalArgumentException, ZeroVectorException {
   
  super(null, null, luceneUtils, flagConfig);
  this.specialLuceneUtils = luceneUtils;
  this.specialFlagConfig = flagConfig;
  Directory dir;
try {
	dir = FSDirectory.open(FileSystems.getDefault().getPath(flagConfig.luceneindexpath()));
	this.iSearcher = new IndexSearcher(DirectoryReader.open(dir));
    
	if (!flagConfig.elementalvectorfile().equals("elementalvectors"))
	{this.acceptableTerms = new VectorStoreRAM(flagConfig);
    acceptableTerms.initFromFile(flagConfig.elementalvectorfile());
	}
} catch (IOException e) {
	logger.info("Lucene index initialization failed: "+e.getMessage());
}
  
  this.queryTerms = queryTerms;
  
 }
 
源代码16 项目: translationstudio8   文件: FastIntBuffer.java
/**
 * Sort the integers in the buffer 
 * @param order (as of version 2.9) 
 * it can be either ASCENDING or DESCENDING
 */
public void sort(int order) {
	switch (order) {
	case ASCENDING:
		if (size > 0)
			quickSort_ascending(0, size - 1);
		break;
	case DESCENDING:
		if (size > 0)
			quickSort_descending(0, size - 1);
		break;
	default:
		throw new IllegalArgumentException("Sort type undefined");
	}

}
 
源代码17 项目: Android-utils   文件: NumberUtils.java
/**
 * Checks if the specified array is neither null nor empty.
 *
 * @param array  the array to check
 * @throws IllegalArgumentException if {@code array} is either {@code null} or empty
 */
private static void validateArray(final Object array) {
    if (array == null) {
        throw new IllegalArgumentException("The Array must not be null");
    } else if (Array.getLength(array) == 0) {
        throw new IllegalArgumentException("Array cannot be empty.");
    }
}
 
源代码18 项目: data-transfer-project   文件: JWTTokenManager.java
/** Create the {@link Algorithm} to be used for signing and parsing tokens. */
private static Algorithm createAlgorithm(String secret) {
  try {
    return Algorithm.HMAC256(secret);
  } catch (IllegalArgumentException e) {
    throw new RuntimeException(e); // TODO: Better error handling
  }
}
 
源代码19 项目: tmxeditor8   文件: ContextBuffer.java
/**
 * ContextBuffer constructor comment.
 * inc is the # of int to be pushed/pop to/from the underlying storage
 * @param i int
 */
public ContextBuffer(int i) {
	super();
	pageSize =1024;
	n = 10; //1<<10 == 1024
	r = pageSize - 1;
	incSize = i;
	if (incSize<0)
	  throw new IllegalArgumentException();
	bufferArrayList = new arrayList();	
}
 
源代码20 项目: netbeans   文件: ZOrderManager.java
public void windowActivated(WindowEvent e) {
    logger.entering(getClass().getName(), "windowActivated");

    WeakReference<RootPaneContainer> ww = getWeak((RootPaneContainer)e.getWindow());
    if (ww != null) {
        // place as last item in zOrder list
        zOrder.remove(ww);
        zOrder.add(ww);
    } else {
        throw new IllegalArgumentException("Window not attached: " + e.getWindow()); //NOI18N
    }
}
 
源代码21 项目: lams   文件: UndertowServletMessages_$bundle.java
@Override
public final IllegalArgumentException paramCannotBeNull(final String param) {
    final IllegalArgumentException result = new IllegalArgumentException(String.format(getLoggingLocale(), paramCannotBeNull1$str(), param));
    final StackTraceElement[] st = result.getStackTrace();
    result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
    return result;
}
 
源代码22 项目: lams   文件: UndertowServletMessages_$bundle.java
@Override
public final IllegalArgumentException paramCannotBeNull(final String param, final String componentType, final String name) {
    final IllegalArgumentException result = new IllegalArgumentException(String.format(getLoggingLocale(), paramCannotBeNull3$str(), param, componentType, name));
    final StackTraceElement[] st = result.getStackTrace();
    result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
    return result;
}
 
源代码23 项目: lams   文件: UndertowServletMessages_$bundle.java
@Override
public final IllegalArgumentException twoServletsWithSameMapping(final String path) {
    final IllegalArgumentException result = new IllegalArgumentException(String.format(getLoggingLocale(), twoServletsWithSameMapping$str(), path));
    final StackTraceElement[] st = result.getStackTrace();
    result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
    return result;
}
 
源代码24 项目: lams   文件: UndertowServletMessages_$bundle.java
@Override
public final IllegalArgumentException headerCannotBeConvertedToDate(final String header) {
    final IllegalArgumentException result = new IllegalArgumentException(String.format(getLoggingLocale(), headerCannotBeConvertedToDate$str(), header));
    final StackTraceElement[] st = result.getStackTrace();
    result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
    return result;
}
 
源代码25 项目: lams   文件: UndertowServletMessages_$bundle.java
@Override
public final IllegalArgumentException servletMustImplementServlet(final String name, final Class<? extends javax.servlet.Servlet> servletClass) {
    final IllegalArgumentException result = new IllegalArgumentException(String.format(getLoggingLocale(), servletMustImplementServlet$str(), name, servletClass));
    final StackTraceElement[] st = result.getStackTrace();
    result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
    return result;
}
 
源代码26 项目: lams   文件: UndertowServletMessages_$bundle.java
@Override
public final IllegalArgumentException componentMustHaveDefaultConstructor(final String componentType, final Class<?> componentClass) {
    final IllegalArgumentException result = new IllegalArgumentException(String.format(getLoggingLocale(), componentMustHaveDefaultConstructor$str(), componentType, componentClass));
    final StackTraceElement[] st = result.getStackTrace();
    result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
    return result;
}
 
源代码27 项目: tmxeditor8   文件: ContextBuffer.java
/**
 * ContextBuffer constructor comment.
 * incSize is the # of int to be pushed/pop to/from the underlying storage
 * Creation date: (11/16/03 8:02:21 PM)
 * @param p int (pageSize equals (1<<p)
 * @param i int
 */
public ContextBuffer(int p, int i) {
	if (p<0)throw new IllegalArgumentException("invalid Buffer size");
    pageSize = (1<<p);
    r = pageSize - 1;
    n = p;
    incSize = i;
    if (incSize < 0)
        throw new IllegalArgumentException("context buffer's incremental size must be greater than zero");
    bufferArrayList = new ArrayList();
}
 
源代码28 项目: lams   文件: UndertowServletMessages_$bundle.java
@Override
public final IllegalArgumentException listenerMustImplementListenerClass(final Class<?> listenerClass) {
    final IllegalArgumentException result = new IllegalArgumentException(String.format(getLoggingLocale(), listenerMustImplementListenerClass$str(), listenerClass));
    final StackTraceElement[] st = result.getStackTrace();
    result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
    return result;
}
 
源代码29 项目: docker-maven-plugin   文件: NginxIT.java
@Test(expected = IllegalArgumentException.class)
public void testName() throws Exception {
    String baseUrl = System.getProperty("cache.base.url");
    HttpGet get = new HttpGet(baseUrl);
    CloseableHttpClient httpClient = HttpClients.createDefault();

    try (CloseableHttpResponse response = httpClient.execute(get)) {
        HttpEntity entity = response.getEntity();
        EntityUtils.consume(entity);
    }
}
 
源代码30 项目: lams   文件: UndertowServletMessages_$bundle.java
@Override
public final IllegalArgumentException responseWasNotOriginalOrWrapper(final ServletResponse response) {
    final IllegalArgumentException result = new IllegalArgumentException(String.format(getLoggingLocale(), responseWasNotOriginalOrWrapper$str(), response));
    final StackTraceElement[] st = result.getStackTrace();
    result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
    return result;
}
 
 类所在包
 同包方法