List of usage examples for java.lang IllegalArgumentException toString
public String toString()
From source file:com.paras.amazonadvertice.SwipeableModelessInterstitialAdActivity.java
/** * When the activity starts, set up the pager adapter for handling fragments and swipe interactions. *//*from w w w . j a v a 2s . c o m*/ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_swipeble); // For debugging purposes enable logging, but disable for production builds. AdRegistration.enableLogging(true); // For debugging purposes flag all ad requests as tests, but set to false for production builds. AdRegistration.enableTesting(true); try { AdRegistration.setAppKey(APP_KEY); } catch (final IllegalArgumentException e) { Log.e(LOG_TAG, "IllegalArgumentException thrown: " + e.toString()); return; } // assign a fragment pager adapter to the activity this.pagerAdapter = new ModelessInterstitialFragmentPagerAdapter(getSupportFragmentManager()); final ViewPager viewPager = (ViewPager) findViewById(R.id.modeless_interstitials_pager); viewPager.setAdapter(this.pagerAdapter); viewPager.setOnPageChangeListener(new ModelessInterstitialOnPageChangeListener()); }
From source file:StringManager.java
/** * Retrieve the localized string for the passed key and format it with the * passed arguments.//from ww w .ja v a2 s .co m * * @param key Key to retrieve string for. * @param args Any string arguments that should be used as values to * parameters found in the localized string. * * @return Localized string or error message. * * @throws IllegalArgumentException * Thrown if <TT>null</TT> <TT>key</TT> passed. */ public String getString(String key, Object... args) { if (key == null) { throw new IllegalArgumentException("key == null"); } if (args == null) { args = new Object[0]; } final String str = getString(key); try { return MessageFormat.format(str, args); } catch (IllegalArgumentException ex) { String msg = "Error formatting i18 string. Key is '" + key + "'"; return msg + ": " + ex.toString(); } }
From source file:no.ntnu.osnap.social.Request.java
/** * Returns the {@link RequestCode} of this request. * If the request has an invalid request code, {@link RequestCode#SELF} * is returned.//from w w w.j a va 2 s . c om */ public RequestCode getRequestCode() { RequestCode ret = RequestCode.SELF; String buf = mBundle.getString("request-code"); try { ret = RequestCode.valueOf(buf); } catch (IllegalArgumentException ex) { Log.e(TAG, ex.toString()); } return ret; }
From source file:org.mule.transport.ldap.util.EndpointURIExpressionEvaluator.java
public Object evaluate(final String expression, final MuleMessage message) { logger.debug(expression + " on " + message); final int i = expression.indexOf("."); String endpointName;/*from w ww . j a va 2 s.c o m*/ String property; if (i > 0) { endpointName = expression.substring(0, i); property = expression.substring(i + 1); } else { throw new IllegalArgumentException( CoreMessages.expressionMalformed(expression, getName()).getMessage()); } EndpointURI uri = null; // looking for endpoint in the registry, if not look for an // EndpointBuilder Object tmp = null; final Collection<ImmutableEndpoint> endpoints = message.getMuleContext().getRegistry().getEndpoints(); for (final Iterator iterator = endpoints.iterator(); iterator.hasNext();) { final ImmutableEndpoint ep = (ImmutableEndpoint) iterator.next(); logger.debug("found endpoint: " + ep.getName()); if (ep.getName().equals(endpointName)) { tmp = ep; break; } } if (tmp == null) { tmp = message.getMuleContext().getRegistry().lookupObject(endpointName); } logger.debug(tmp); if (tmp != null) { logger.debug(tmp.getClass()); } if ((tmp != null) && (tmp instanceof ImmutableEndpoint)) { final ImmutableEndpoint ep = (ImmutableEndpoint) tmp; uri = ep.getEndpointURI(); } else if (((tmp = message.getMuleContext().getRegistry().lookupObject(endpointName)) != null) && (tmp instanceof ImmutableEndpoint)) { final ImmutableEndpoint ep = (ImmutableEndpoint) tmp; uri = ep.getEndpointURI(); } else { logger.warn("There is no endpoint registered with name: " + endpointName + " Will look for an global one ..."); final AbstractEndpointBuilder eb = (AbstractEndpointBuilder) message.getMuleContext().getRegistry() .lookupEndpointBuilder(endpointName); final AbstractEndpointBuilder eb2 = (AbstractEndpointBuilder) message.getMuleContext().getRegistry() .lookupEndpointBuilder(endpointName); if (eb != null) { uri = eb.getEndpointBuilder().getEndpoint(); } else if (eb2 != null) { uri = eb2.getEndpointBuilder().getEndpoint(); } else { logger.error("There is no endpointbuilder or endpoint registered with name: " + endpointName); } } if (uri != null) { // ${endpointuri:testendpoint.params:xxx} if (property.toLowerCase().startsWith("params:")) { final String[] sa = property.split(":"); return uri.getParams().getProperty(sa[1]); } // ${endpointuri:testendpoint.params:xxx} if (property.toLowerCase().startsWith("userparams:")) { final String[] sa = property.split(":"); return uri.getUserParams().getProperty(sa[1]); } // resovles dynamically to getXXX Method try { return uri.getClass() .getMethod("get" + org.apache.commons.lang.StringUtils.capitalize(property.toLowerCase()), new Class[0]) .invoke(uri, (Object[]) null); } catch (final IllegalArgumentException e) { logger.error(e.toString(), e); } catch (final SecurityException e) { logger.error(e.toString(), e); } catch (final IllegalAccessException e) { logger.error(e.toString(), e); } catch (final InvocationTargetException e) { logger.error(e.toString(), e); } catch (final NoSuchMethodException e) { logger.error(e.toString(), e); } throw new IllegalArgumentException( CoreMessages.expressionInvalidForProperty(property, expression).getMessage()); } else { return null; } }
From source file:com.google.android.car.kitchensink.bluetooth.MapMceTestFragment.java
private void getMessages() { synchronized (mLock) { BluetoothDevice remoteDevice;//w w w .j ava2 s . c o m try { remoteDevice = mBluetoothAdapter.getRemoteDevice(mBluetoothDevice.getText().toString()); } catch (java.lang.IllegalArgumentException e) { Log.e(TAG, e.toString()); return; } if (mMapProfile != null) { Log.d(TAG, "Getting Messages"); mMapProfile.getUnreadMessages(remoteDevice); } } }
From source file:org.sonar.plugins.cxx.compiler.CxxCompilerSensor.java
@Override protected void processReport(final Project project, final SensorContext context, File report) throws javax.xml.stream.XMLStreamException { int countViolations = 0; final CompilerParser parser = getCompilerParser(); final String reportCharset = getParserStringProperty(REPORT_CHARSET_DEF, parser.defaultCharset()); final String reportRegEx = getParserStringProperty(REPORT_REGEX_DEF, parser.defaultRegexp()); final List<CompilerParser.Warning> warnings = new LinkedList<CompilerParser.Warning>(); // Iterate through the lines of the input file CxxUtils.LOG.info("Scanner '" + parser.key() + "' initialized with report '{}'" + ", CharSet= '" + reportCharset + "'", report); try {//from w w w . j av a 2 s . co m parser.ParseReport(report, reportCharset, reportRegEx, warnings); for (CompilerParser.Warning w : warnings) { // get filename from file system - e.g. VC writes case insensitive file name to html if (isInputValid(w.filename, w.line, w.id, w.msg)) { if (saveUniqueViolation(project, context, parser.rulesRepositoryKey(), w.filename, w.line, w.id, w.msg)) { countViolations++; } } else { CxxUtils.LOG.warn("C-Compiler warning: {}", w.msg); } } CxxUtils.LOG.info("C-Compiler warnings processed = " + countViolations); } catch (java.io.FileNotFoundException e) { CxxUtils.LOG.error("processReport Exception: " + "report.getName" + " - not processed '{}'", e.toString()); } catch (java.lang.IllegalArgumentException e1) { CxxUtils.LOG.error("processReport Exception: " + "report.getName" + " - not processed '{}'", e1.toString()); } }
From source file:gobblin.metrics.event.sla.SlaEventSubmitter.java
/** * Submit the sla event by calling {@link SlaEventSubmitter#EventSubmitter#submit()}. If * {@link SlaEventSubmitter#eventName}, {@link SlaEventSubmitter#eventSubmitter}, {@link SlaEventSubmitter#datasetUrn} * are not available the method is a no-op. *//*from w ww .jav a 2 s. c o m*/ public void submit() { try { Preconditions.checkArgument(Predicates.notNull().apply(eventSubmitter), "EventSubmitter needs to be set"); Preconditions.checkArgument(NOT_NULL_OR_EMPTY_PREDICATE.apply(eventName), "Eventname is required"); Preconditions.checkArgument(NOT_NULL_OR_EMPTY_PREDICATE.apply(datasetUrn), "DatasetUrn is required"); eventSubmitter.submit(eventName, buildEventMap()); } catch (IllegalArgumentException e) { log.info("Required arguments to submit an SLA event is not available. No Sla event will be submitted. " + e.toString()); } }
From source file:com.neiljbrown.brighttalk.channels.reportingapi.client.spring.ApiResponseErrorHandlerTest.java
/** * Tests constructor {@link ApiResponseErrorHandler#ApiResponseErrorHandler(java.util.List)} in the error case where * one of the {@link HttpMessageConverter} isn't capable of reading an {@link ApiError} object. *///w w w . jav a2 s . c o m @Test public void testApiResponseErrorHandlerForUnsupportedConverter() { HttpMessageConverter<?> supportedConverter = new Jaxb2RootElementHttpMessageConverter(); HttpMessageConverter<?> unsupportedConveter = new StringHttpMessageConverter(); try { this.errorHandler = new ApiResponseErrorHandler( Arrays.asList(new HttpMessageConverter<?>[] { supportedConverter, unsupportedConveter })); fail("Expected IllegalArgumentException to be thrown for HttpMessageConverter that doesn't support reading an ApiError."); } catch (IllegalArgumentException e) { assertTrue("Unexpected exception [" + e.toString() + "].", e.getMessage().matches("HttpMessageConverter.*must support reading.*")); } }
From source file:org.openhab.binding.dscalarm.internal.discovery.EnvisalinkBridgeDiscovery.java
/** * Method for Bridge Discovery.//from ww w .j ava2s.c o m */ public synchronized void discoverBridge() { logger.debug("Starting Envisalink Bridge Discovery."); SubnetUtils subnetUtils = null; SubnetInfo subnetInfo = null; long lowIP = 0; long highIP = 0; try { InetAddress localHost = InetAddress.getLocalHost(); NetworkInterface networkInterface = NetworkInterface.getByInetAddress(localHost); subnetUtils = new SubnetUtils(localHost.getHostAddress() + "/" + networkInterface.getInterfaceAddresses().get(0).getNetworkPrefixLength()); subnetInfo = subnetUtils.getInfo(); lowIP = convertIPToNumber(subnetInfo.getLowAddress()); highIP = convertIPToNumber(subnetInfo.getHighAddress()); } catch (IllegalArgumentException e) { logger.error("discoverBridge(): Illegal Argument Exception - {}", e.toString()); return; } catch (Exception e) { logger.error("discoverBridge(): Error - Unable to get Subnet Information! {}", e.toString()); return; } logger.debug(" Local IP Address: {} - {}", subnetInfo.getAddress(), convertIPToNumber(subnetInfo.getAddress())); logger.debug(" Subnet: {} - {}", subnetInfo.getNetworkAddress(), convertIPToNumber(subnetInfo.getNetworkAddress())); logger.debug(" Network Prefix: {}", subnetInfo.getCidrSignature().split("/")[1]); logger.debug(" Network Mask: {}", subnetInfo.getNetmask()); logger.debug(" Low IP: {}", convertNumberToIP(lowIP)); logger.debug(" High IP: {}", convertNumberToIP(highIP)); for (long ip = lowIP; ip <= highIP; ip++) { try (Socket socket = new Socket()) { ipAddress = convertNumberToIP(ip); socket.setReuseAddress(true); socket.setReceiveBufferSize(32); socket.connect(new InetSocketAddress(ipAddress, ENVISALINK_BRIDGE_PORT), CONNECTION_TIMEOUT); if (socket.isConnected()) { String message = ""; socket.setSoTimeout(SO_TIMEOUT); try (BufferedReader input = new BufferedReader( new InputStreamReader(socket.getInputStream()))) { message = input.readLine(); } catch (SocketTimeoutException e) { logger.error("discoverBridge(): No Message Read from Socket at [{}] - {}", ipAddress, e.getMessage()); continue; } catch (Exception e) { logger.error("discoverBridge(): Exception Reading from Socket! {}", e.toString()); continue; } if (message.substring(0, 3).equals(ENVISALINK_DISCOVERY_RESPONSE)) { logger.debug("discoverBridge(): Bridge Found - [{}]! Message - '{}'", ipAddress, message); dscAlarmBridgeDiscovery.addEnvisalinkBridge(ipAddress); } else { logger.debug("discoverBridge(): No Response from Connection - [{}]! Message - '{}'", ipAddress, message); } } } catch (IllegalArgumentException e) { logger.error("discoverBridge(): Illegal Argument Exception - {}", e.toString()); } catch (SocketTimeoutException e) { logger.trace("discoverBridge(): No Connection on Port 4025! [{}]", ipAddress); } catch (SocketException e) { logger.error("discoverBridge(): Socket Exception! [{}] - {}", ipAddress, e.toString()); } catch (IOException e) { logger.error("discoverBridge(): IO Exception! [{}] - {}", ipAddress, e.toString()); } } }
From source file:com.google.android.car.kitchensink.bluetooth.MapMceTestFragment.java
private void sendMessage(Uri[] recipients, String message) { synchronized (mLock) { BluetoothDevice remoteDevice;/* www.j ava2 s . co m*/ try { remoteDevice = mBluetoothAdapter.getRemoteDevice(mBluetoothDevice.getText().toString()); } catch (java.lang.IllegalArgumentException e) { Log.e(TAG, e.toString()); return; } mSent.setChecked(false); mDelivered.setChecked(false); if (mMapProfile != null) { Log.d(TAG, "Sending reply"); if (recipients == null) { Log.d(TAG, "Recipients is null"); return; } if (mBluetoothDevice == null) { Log.d(TAG, "BluetoothDevice is null"); return; } mSentIntent = PendingIntent.getBroadcast(getContext(), 0, mSendIntent, PendingIntent.FLAG_ONE_SHOT); mDeliveredIntent = PendingIntent.getBroadcast(getContext(), 0, mDeliveryIntent, PendingIntent.FLAG_ONE_SHOT); mMapProfile.sendMessage(remoteDevice, recipients, message, mSentIntent, mDeliveredIntent); } } }