java.lang.IllegalArgumentException Java Examples
The following examples show how to use
java.lang.IllegalArgumentException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VectorSearcher.java From semanticvectors with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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; }
Example #2
Source File: Weather_Table.java From WeatherStream with Apache License 2.0 | 6 votes |
@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"); } } }
Example #3
Source File: SmsCipher.java From Silence with GNU General Public License v3.0 | 6 votes |
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); } }
Example #4
Source File: AbstractProtoMapper.java From conductor with Apache License 2.0 | 6 votes |
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; }
Example #5
Source File: WeatherForecastData_Table.java From WeatherStream with Apache License 2.0 | 6 votes |
@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"); } } }
Example #6
Source File: Rain_Table.java From WeatherStream with Apache License 2.0 | 6 votes |
@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"); } } }
Example #7
Source File: VectorSearcher.java From semanticvectors with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @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."); } }
Example #8
Source File: ForecastList_Table.java From WeatherStream with Apache License 2.0 | 6 votes |
@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"); } } }
Example #9
Source File: VectorSearcher.java From semanticvectors with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @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."); } }
Example #10
Source File: Wind_Table.java From WeatherStream with Apache License 2.0 | 6 votes |
@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"); } } }
Example #11
Source File: RepairnatorProcessBuilder.java From repairnator with MIT License | 6 votes |
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"); } }
Example #12
Source File: MainFragmentArgs.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
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; }
Example #13
Source File: FastIntBuffer.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 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"); } }
Example #14
Source File: OpenTsdbMetric.java From metrics-opentsdb with Apache License 2.0 | 6 votes |
/** * 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; }
Example #15
Source File: LocationProviderFactory.java From background-geolocation-android with Apache License 2.0 | 6 votes |
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; }
Example #16
Source File: FrameSet.java From OpenCue with Apache License 2.0 | 6 votes |
/** * 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)); }
Example #17
Source File: AbstractProtoMapper.java From conductor with Apache License 2.0 | 5 votes |
public TaskResultPb.TaskResult.Status toProto(TaskResult.Status from) { TaskResultPb.TaskResult.Status to; switch (from) { case IN_PROGRESS: to = TaskResultPb.TaskResult.Status.IN_PROGRESS; break; case FAILED: to = TaskResultPb.TaskResult.Status.FAILED; break; case FAILED_WITH_TERMINAL_ERROR: to = TaskResultPb.TaskResult.Status.FAILED_WITH_TERMINAL_ERROR; break; case COMPLETED: to = TaskResultPb.TaskResult.Status.COMPLETED; break; default: throw new IllegalArgumentException("Unexpected enum constant: " + from); } return to; }
Example #18
Source File: AbstractProtoMapper.java From conductor with Apache License 2.0 | 5 votes |
public TaskResult.Status fromProto(TaskResultPb.TaskResult.Status from) { TaskResult.Status to; switch (from) { case IN_PROGRESS: to = TaskResult.Status.IN_PROGRESS; break; case FAILED: to = TaskResult.Status.FAILED; break; case FAILED_WITH_TERMINAL_ERROR: to = TaskResult.Status.FAILED_WITH_TERMINAL_ERROR; break; case COMPLETED: to = TaskResult.Status.COMPLETED; break; default: throw new IllegalArgumentException("Unexpected enum constant: " + from); } return to; }
Example #19
Source File: FastLongBuffer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * Construct a FastLongBuffer instance with specified page size * @param e int (so that pageSize = (1<<e)) * @param c int (suggest initial capacity of ArrayList */ public FastLongBuffer(int e,int c) { if (e <= 0) { throw new IllegalArgumentException(); } capacity = size = 0; pageSize = (1<<e); exp = e; r = pageSize -1; bufferArrayList = new arrayList(c); }
Example #20
Source File: Foo.java From coming with MIT License | 5 votes |
public AudioFormat colorized(Book b1, Book b2, int random) throws Exception, IllegalArgumentException { LinkedList<Point2D> points = new LinkedList<Point2D>(); points.add(new Point(10, 20)); points.add(new Point(20, 20)); points.add(new Point(30, 20)); if(random > 100) { Bar barInstance = new Bar(); barInstance.returnField(new JLabel("I am a JLabel object")); if(random < 150) { for(int i = 0 ; i < 10 ; ++i) { JButton button = new JButton("I am a JButton object"); } barInstance = new Bar(new JTextArea()); return new AudioFormat(Encoding.ALAW, (float)1.0, 8, 2, 1, (float)1.0, true, new HashMap<String, Object>()); } else { throw new Exception("a test exception"); } } else { throw new IllegalArgumentException("a test illegal format exception"); } }
Example #21
Source File: FastLongBuffer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * Construct a FastLongBuffer instance with specified page size * @param e int (so that pageSize = (1<<e)) */ public FastLongBuffer(int e) { if (e <= 0) { throw new IllegalArgumentException(); } capacity = size = 0; pageSize = (1<<e); exp = e; r = pageSize -1; bufferArrayList = new arrayList(); }
Example #22
Source File: VectorSearcher.java From semanticvectors with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @param queryVecStore Vector store to use for query generation. * @param searchVecStore The vector store to search. * @param permutationCache The permutations * @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, VectorStore permutationCache, LuceneUtils luceneUtils, FlagConfig flagConfig, String[] queryTerms) throws IllegalArgumentException, ZeroVectorException { super(queryVecStore, searchVecStore, luceneUtils, flagConfig); try { String[] permStrings = queryTerms[1].split(":"); Vector toSuperpose = queryVecStore.getVector(queryTerms[0]).copy(); for (String permString:permStrings) { theAvg = VectorFactory.createZeroVector(flagConfig.vectortype(), flagConfig.dimension()); int[] thePermutation = ((PermutationVector) permutationCache.getVector(permString)).getCoordinates(); theAvg.superpose(toSuperpose,1, thePermutation); toSuperpose = theAvg.copy(); } //int[] thePermutation2 = PermutationUtils.getInversePermutation(thePermutation); } 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."); } }
Example #23
Source File: SQLiteAndroidDatabase.java From AvI with MIT License | 5 votes |
static QueryType getQueryType(String query) { Matcher matcher = FIRST_WORD.matcher(query); if (matcher.find()) { try { return QueryType.valueOf(matcher.group(1).toLowerCase()); } catch (IllegalArgumentException ignore) { // unknown verb } } return QueryType.other; }
Example #24
Source File: AbstractProtoMapper.java From conductor with Apache License 2.0 | 5 votes |
public TaskDef.TimeoutPolicy fromProto(TaskDefPb.TaskDef.TimeoutPolicy from) { TaskDef.TimeoutPolicy to; switch (from) { case RETRY: to = TaskDef.TimeoutPolicy.RETRY; break; case TIME_OUT_WF: to = TaskDef.TimeoutPolicy.TIME_OUT_WF; break; case ALERT_ONLY: to = TaskDef.TimeoutPolicy.ALERT_ONLY; break; default: throw new IllegalArgumentException("Unexpected enum constant: " + from); } return to; }
Example #25
Source File: AbstractProtoMapper.java From conductor with Apache License 2.0 | 5 votes |
public TaskDefPb.TaskDef.TimeoutPolicy toProto(TaskDef.TimeoutPolicy from) { TaskDefPb.TaskDef.TimeoutPolicy to; switch (from) { case RETRY: to = TaskDefPb.TaskDef.TimeoutPolicy.RETRY; break; case TIME_OUT_WF: to = TaskDefPb.TaskDef.TimeoutPolicy.TIME_OUT_WF; break; case ALERT_ONLY: to = TaskDefPb.TaskDef.TimeoutPolicy.ALERT_ONLY; break; default: throw new IllegalArgumentException("Unexpected enum constant: " + from); } return to; }
Example #26
Source File: AbstractProtoMapper.java From conductor with Apache License 2.0 | 5 votes |
public TaskDef.RetryLogic fromProto(TaskDefPb.TaskDef.RetryLogic from) { TaskDef.RetryLogic to; switch (from) { case FIXED: to = TaskDef.RetryLogic.FIXED; break; case EXPONENTIAL_BACKOFF: to = TaskDef.RetryLogic.EXPONENTIAL_BACKOFF; break; default: throw new IllegalArgumentException("Unexpected enum constant: " + from); } return to; }
Example #27
Source File: AbstractProtoMapper.java From conductor with Apache License 2.0 | 5 votes |
public TaskDefPb.TaskDef.RetryLogic toProto(TaskDef.RetryLogic from) { TaskDefPb.TaskDef.RetryLogic to; switch (from) { case FIXED: to = TaskDefPb.TaskDef.RetryLogic.FIXED; break; case EXPONENTIAL_BACKOFF: to = TaskDefPb.TaskDef.RetryLogic.EXPONENTIAL_BACKOFF; break; default: throw new IllegalArgumentException("Unexpected enum constant: " + from); } return to; }
Example #28
Source File: AbstractProtoMapper.java From conductor with Apache License 2.0 | 5 votes |
public EventHandler.Action.Type fromProto(EventHandlerPb.EventHandler.Action.Type from) { EventHandler.Action.Type to; switch (from) { case START_WORKFLOW: to = EventHandler.Action.Type.start_workflow; break; case COMPLETE_TASK: to = EventHandler.Action.Type.complete_task; break; case FAIL_TASK: to = EventHandler.Action.Type.fail_task; break; default: throw new IllegalArgumentException("Unexpected enum constant: " + from); } return to; }
Example #29
Source File: AbstractProtoMapper.java From conductor with Apache License 2.0 | 5 votes |
public EventHandlerPb.EventHandler.Action.Type toProto(EventHandler.Action.Type from) { EventHandlerPb.EventHandler.Action.Type to; switch (from) { case start_workflow: to = EventHandlerPb.EventHandler.Action.Type.START_WORKFLOW; break; case complete_task: to = EventHandlerPb.EventHandler.Action.Type.COMPLETE_TASK; break; case fail_task: to = EventHandlerPb.EventHandler.Action.Type.FAIL_TASK; break; default: throw new IllegalArgumentException("Unexpected enum constant: " + from); } return to; }
Example #30
Source File: AbstractProtoMapper.java From conductor with Apache License 2.0 | 5 votes |
public EventExecution.Status fromProto(EventExecutionPb.EventExecution.Status from) { EventExecution.Status to; switch (from) { case IN_PROGRESS: to = EventExecution.Status.IN_PROGRESS; break; case COMPLETED: to = EventExecution.Status.COMPLETED; break; case FAILED: to = EventExecution.Status.FAILED; break; case SKIPPED: to = EventExecution.Status.SKIPPED; break; default: throw new IllegalArgumentException("Unexpected enum constant: " + from); } return to; }