List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:com.servioticy.dispatcher.jsonprocessors.JsonPathReplacer.java
public String replace(Map<String, String> jsons) throws InvalidPathException { if (this.str == null) { this.str = ""; }/*from w w w . jav a 2 s . c o m*/ String result = this.str; int indexOffset = 0; StringBuilder sb = new StringBuilder(result); for (Map.Entry<Integer, LinkedList<Map.Entry<String, JsonPath>>> jpsReplacement : this.jsonPaths .entrySet()) { int index = jpsReplacement.getKey() + indexOffset; LinkedList<Map.Entry<String, JsonPath>> jps = jpsReplacement.getValue(); // String startStr = (index == 0) ? "" : result.substring(0, index); // String endStr = (index == result.length()) ? "" : result.substring(index, result.length()); String partial = ""; for (Map.Entry<String, JsonPath> jp : jps) { // if(jp.isPathDefinite()){ String json; String key = jp.getKey(); try { // If the path does not exist in the input json, throws InvalidPathException json = jsons.get(key); Object content = jp.getValue().read(json); if (content instanceof String) { partial += "'" + content + "'"; } else { partial += this.mapper.writeValueAsString(content); } } catch (java.lang.IllegalArgumentException e) { // The input is not a json // TODO This should be done *only* on queries. In navigations of implicit queries or selfdocument, it should be an error // and the document shouldn't be processed. e.printStackTrace(); partial += "null"; } catch (Exception e) { // Not a correct input json // TODO log this e.printStackTrace(); partial += "null"; } // } } if (index > sb.toString().length()) { sb.append(partial); } else { sb.replace(index, index, partial); } // result = startStr + partial + endStr; indexOffset += partial.length(); } result = sb.toString(); return result; }
From source file:com.ailk.oci.ocnosql.tools.load.mutiple.MutipleColumnImporterMapper.java
/** * Convert a line of TSV text into an HBase table row. *///from w ww .j ava2s . co m @Override public void map(LongWritable offset, Text value, Context context) throws IOException { byte[] lineBytes = value.getBytes(); ts = System.currentTimeMillis(); try { MutipleColumnImportTsv.TsvParser.ParsedLine parsed = parser.parse(lineBytes, value.getLength()); String newRowKey = rowkeyGenerator.generateByGenRKStep(value.toString(), false);//???rowkey Put put = new Put(newRowKey.getBytes()); for (int i = 0; i < parsed.getColumnCount(); i++) { String columnQualifierStr = new String(parser.getQualifier(i)); String rowStr = newRowKey + new String(parser.getFamily(i) + columnQualifierStr); if (notNeedLoadColumnQulifiers.contains(columnQualifierStr)) { continue; } KeyValue kv = new KeyValue(rowStr.getBytes(), 0, newRowKey.getBytes().length, //roffset,rofflength parser.getFamily(i), 0, parser.getFamily(i).length, parser.getQualifier(i), 0, parser.getQualifier(i).length, ts, KeyValue.Type.Put, lineBytes, parsed.getColumnOffset(i), parsed.getColumnLength(i)); KeyValue newKv = new KeyValue(newRowKey.getBytes(), kv.getFamily(), kv.getQualifier(), ts, kv.getValue()); kv = null; put.add(newKv); } context.write(new ImmutableBytesWritable(newRowKey.getBytes()), put); } catch (MutipleColumnImportTsv.TsvParser.BadTsvLineException badLine) { if (skipBadLines) { System.err.println("Bad line at offset: " + offset.get() + ":\n" + badLine.getMessage()); incrementBadLineCount(1); return; } else { throw new IOException(badLine); } } catch (IllegalArgumentException e) { if (skipBadLines) { System.err.println("Bad line at offset: " + offset.get() + ":\n" + e.getMessage()); incrementBadLineCount(1); return; } else { throw new IOException(e); } } catch (InterruptedException e) { e.printStackTrace(); } catch (RowKeyGeneratorException e) { System.err.println("gen rowkey error, please check config in the ocnosqlTab.xml." + e.getMessage()); throw new IOException(e); } finally { totalLineCount.increment(1); } }
From source file:fr.bmartel.android.dotti.DottiActivity.java
@Override protected void onPause() { super.onPause(); if (!toSecondLevel) { if (device_list_view != null) { device_list_view.setAdapter(null); }/* w w w . j a v a 2 s .co m*/ if (currentService != null) { currentService.disconnectall(); currentService.getListViewAdapter().clear(); currentService.getListViewAdapter().notifyDataSetChanged(); currentService.clearListAdapter(); } } if (dialog != null) { dialog.cancel(); dialog = null; } if (currentService != null) { currentService.removeScanListeners(); if (currentService.isScanning()) currentService.stopScan(); } try { if (bound) { // unregister receiver or you will have strong exception unbindService(mServiceConnection); bound = false; } } catch (IllegalArgumentException e) { e.printStackTrace(); } }
From source file:net.openwatch.acluaz.fragment.FormFragment.java
/** * Populate form given the db_id of an Incident in the database * This currently assumes that the database columns are equal to the view_tags (json keys) * @param container//from ww w . j a va 2 s .c o m * @param db_id */ protected void fillFormFromDatabase(ViewGroup container, int db_id) { String TAG = "FormFragment-fillFormFromDatabase"; Incident incident = Incident.objects(this.getActivity().getApplicationContext()).get(db_id); if (incident == null) return; ContentValues values = new ContentValues(); try { incident.collectData(getActivity().getApplicationContext(), values, Incident.class); } catch (IllegalArgumentException e) { Log.e(TAG, "Unable to collect ContentValues from Incident"); e.printStackTrace(); } catch (IllegalAccessException e) { Log.e(TAG, "Unable to collect ContentValues from Incident"); e.printStackTrace(); } View form_input; for (Entry<String, ?> entry : values.valueSet()) { if (entry.getKey().compareTo(getString(R.string.device_lat)) == 0 || entry.getKey().compareTo(getString(R.string.device_lon)) == 0) { // Combine lat and lon into a Location and tag the gps toggle form_input = container.findViewById(R.id.gps_toggle); Location loc = new Location("db"); loc.setLatitude(values.getAsDouble(DBConstants.DEVICE_LAT)); loc.setLongitude(values.getAsDouble(DBConstants.DEVICE_LON)); form_input.setTag(R.id.view_tag, loc); } else if (entry.getKey().compareTo(getString(R.string.date_tag)) == 0) { form_input = container.findViewById(R.id.date_input); if (form_input == null || entry.getValue() == null) continue; String date = (String) entry.getValue(); try { ((EditText) form_input) .setText(Constants.date_formatter.format(Constants.datetime_formatter.parse(date))); form_input = container.findViewById(R.id.time_input); if (form_input == null) continue; ((EditText) form_input) .setText(Constants.time_formatter.format(Constants.datetime_formatter.parse(date))); } catch (ParseException e) { Log.e(TAG, "Error setting date time form fields from database datetime"); e.printStackTrace(); } } else { // If the column value is simply bound to the view // with tag equal to column name... form_input = container.findViewWithTag(entry.getKey()); setFormFieldValue(form_input, entry); } } }
From source file:im.ene.lab.toro.player.widget.VideoPlayerView.java
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); try {/*from w ww .j av a2 s. c om*/ mAudioCapabilitiesReceiver.unregister(); mAudioCapabilitiesReceiver = null; } catch (IllegalArgumentException er) { // Have no idea, it crash by this Exception sometime. er.printStackTrace(); } mPlayerPosition = 0; mAudioCapabilities = null; releasePlayer(); }
From source file:edu.uw.sig.frames2owl.Converter.java
private boolean convertInsts(Cls rootCls, OWLClass owlClass) { // create individual converter if appropriate String clsName = rootCls.getName(); Class instConvClass = cReader.getInstConvMap().get(clsName); Map<String, String> instConvInitArgs = cReader.getInstConvInitArgsMap().get(clsName); if (instConvClass == null) return true; // this is not wrong, but there are no instances to convert if (instConvInitArgs == null) // use empty map instConvInitArgs = new HashMap<String, String>(); try {//from w w w . j a v a 2 s . co m InstanceConverter converter = (InstanceConverter) instConvClass .asSubclass(InstanceConverter.class).getConstructor(KnowledgeBase.class, Cls.class, OWLOntology.class, IRIUtils.class, ConvUtils.class) .newInstance(framesKB, rootCls, owlOnt, iriUtils, convUtils); // init with any args from the config file boolean initSuccess = converter.init(instConvInitArgs); if (!initSuccess) { System.err.println("Failed to initialize converter for instances of " + rootCls.getBrowserText()); System.exit(-1); } converter.convertInsts(); } catch (IllegalArgumentException e) { e.printStackTrace(); return false; } catch (SecurityException e) { e.printStackTrace(); return false; } catch (InstantiationException e) { e.printStackTrace(); return false; } catch (IllegalAccessException e) { e.printStackTrace(); return false; } catch (InvocationTargetException e) { e.printStackTrace(); return false; } catch (NoSuchMethodException e) { e.printStackTrace(); return false; } return true; }
From source file:com.jpeterson.littles3.S3ObjectRequestTest.java
/** * Test a basic <code>create</code> with an anonymous request. *///from w ww . j av a 2 s. c o m public void xtest_createAnonymousRequest() { S3ObjectRequest o; Mock mockHttpServletRequest = mock(HttpServletRequest.class); mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/myBucket/myKey.txt")); mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host")).will(returnValue("localhost")); mockHttpServletRequest.expects(once()).method("getRequestURL") .will(returnValue(new StringBuffer("http://localhost/context/myBucket/myKey.txt"))); mockHttpServletRequest.expects(once()).method("getUserPrincipal").will(returnValue(null)); mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null)); try { HackAuthenticator authenticator = new HackAuthenticator(); authenticator.setAuthenticator(new S3Authenticator()); o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "localhost", authenticator); } catch (IllegalArgumentException e) { e.printStackTrace(); fail("Unexpected exception"); return; } catch (AuthenticatorException e) { e.printStackTrace(); fail("Unexpected exception"); return; } assertEquals("Unexpected serviceEndpoint", "http://localhost/context", o.getServiceEndpoint()); assertEquals("Unexpected bucket", "myBucket", o.getBucket()); assertEquals("Unexpected key", "myKey.txt", o.getKey()); assertEquals("Unexpected requestor", new CanonicalUser(CanonicalUser.ID_ANONYMOUS), o.getRequestor()); }
From source file:com.jpeterson.littles3.S3ObjectRequestTest.java
/** * Test a basic <code>create</code> but with a space in the key. */// w w w .j ava 2s . c o m public void xtest_createWithSpace() { S3ObjectRequest o; Mock mockHttpServletRequest = mock(HttpServletRequest.class); mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/myBucket/my Key.txt")); mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host")).will(returnValue("localhost")); mockHttpServletRequest.expects(once()).method("getRequestURL") .will(returnValue(new StringBuffer("http://localhost/context/myBucket/my%20Key.txt"))); mockHttpServletRequest.expects(once()).method("getUserPrincipal") .will(returnValue(new CanonicalUser("unitTest"))); mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null)); try { HackAuthenticator authenticator = new HackAuthenticator(); authenticator.setAuthenticator(new S3Authenticator()); o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "localhost", authenticator); } catch (IllegalArgumentException e) { e.printStackTrace(); fail("Unexpected exception"); return; } catch (AuthenticatorException e) { e.printStackTrace(); fail("Unexpected exception"); return; } assertEquals("Unexpected serviceEndpoint", "http://localhost/context", o.getServiceEndpoint()); assertEquals("Unexpected bucket", "myBucket", o.getBucket()); assertEquals("Unexpected key", "my Key.txt", o.getKey()); }
From source file:com.jpeterson.littles3.S3ObjectRequestTest.java
/** * Test a <code>create</code> with no key but with a slash character after * the bucket./*from www . j a v a 2 s . co m*/ */ public void xtest_createNoKeyBucketEndsWithSlash() { S3ObjectRequest o; Mock mockHttpServletRequest = mock(HttpServletRequest.class); mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/myBucket/")); mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host")).will(returnValue("localhost")); mockHttpServletRequest.expects(once()).method("getRequestURL") .will(returnValue(new StringBuffer("http://localhost/context/myBucket/"))); mockHttpServletRequest.expects(once()).method("getUserPrincipal") .will(returnValue(new CanonicalUser("unitTest"))); mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null)); try { HackAuthenticator authenticator = new HackAuthenticator(); authenticator.setAuthenticator(new S3Authenticator()); o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "localhost", authenticator); } catch (IllegalArgumentException e) { e.printStackTrace(); fail("Unexpected exception"); return; } catch (AuthenticatorException e) { e.printStackTrace(); fail("Unexpected exception"); return; } assertEquals("Unexpected serviceEndpoint", "http://localhost/context", o.getServiceEndpoint()); assertEquals("Unexpected bucket", "myBucket", o.getBucket()); assertNull("Unexpected key", o.getKey()); }
From source file:com.jpeterson.littles3.S3ObjectRequestTest.java
/** * Test a <code>create</code> using virtual hosting of buckets. HTTP 1.0, * contains no Host header./*w w w . j av a 2 s . c o m*/ */ public void xtest_virtualHostingHTTP10() { S3ObjectRequest o; Mock mockHttpServletRequest = mock(HttpServletRequest.class); mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/johnsmith/homepage.html")); mockHttpServletRequest.expects(once()).method("getRequestURL") .will(returnValue(new StringBuffer("http://s3.amazonaws.com/johnsmith/homepage.html"))); mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host")).will(returnValue(null)); mockHttpServletRequest.expects(once()).method("getUserPrincipal") .will(returnValue(new CanonicalUser("unitTest"))); mockHttpServletRequest.expects(once()).method("getHeader").with(eq("x-hack-user")).will(returnValue(null)); try { HackAuthenticator authenticator = new HackAuthenticator(); authenticator.setAuthenticator(new S3Authenticator()); o = S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "s3.amazonaws.com", authenticator); } catch (IllegalArgumentException e) { e.printStackTrace(); fail("Unexpected exception"); return; } catch (AuthenticatorException e) { e.printStackTrace(); fail("Unexpected exception"); return; } assertEquals("Unexpected serviceEndpoint", "http://s3.amazonaws.com", o.getServiceEndpoint()); assertEquals("Unexpected bucket", "johnsmith", o.getBucket()); assertEquals("Unexpected key", "homepage.html", o.getKey()); }