List of usage examples for java.util ArrayList toString
public String toString()
From source file:com.github.lynxdb.server.api.http.handlers.EpUser.java
@RequestMapping(value = "", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity createUser(Authentication _authentication, @RequestBody @Valid UserCreationRequest _ucr, BindingResult _bindingResult) {// w ww .j ava 2 s .c om if (_bindingResult.hasErrors()) { ArrayList<String> errors = new ArrayList(); _bindingResult.getFieldErrors().forEach((FieldError t) -> { errors.add(t.getField() + ": " + t.getDefaultMessage()); }); return new ErrorResponse(mapper, HttpStatus.BAD_REQUEST, errors.toString()).response(); } User u = new User(_ucr); if (users.create(u)) { return ResponseEntity.ok(u); } else { return new ErrorResponse(mapper, HttpStatus.BAD_REQUEST, "User already exists").response(); } }
From source file:org.venice.piazza.servicecontroller.messaging.handlers.UpdateServiceHandlerTest.java
/** * Test what happens when there is an invalid update *//*from www.j av a 2 s . c o m*/ @Test public void testUnsuccessfulUpdate() { UpdateServiceJob job = new UpdateServiceJob(); job.data = service; job.jobId = "a842aae2-bd74-4c4b-9a65-c45e8cd9060"; ArrayList<String> resultList = new ArrayList<String>(); resultList.add(job.jobId); resultList.add(service.getServiceId()); ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultList.toString(), HttpStatus.UNPROCESSABLE_ENTITY); final UpdateServiceHandler ushMock = Mockito.spy(usHandler); Mockito.doReturn("").when(ushMock).handle(service); ResponseEntity<String> result = ushMock.handle(job); assertEquals("The item was not updated successfully.", responseEntity.getStatusCode(), result.getStatusCode()); }
From source file:com.github.lynxdb.server.api.http.handlers.EpUser.java
@RequestMapping(value = "/{userLogin}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity updateUser(Authentication _authentication, @PathVariable("userLogin") String userLogin, @RequestBody @Valid UserUpdateRequest _ucr, BindingResult _bindingResult) { if (_bindingResult.hasErrors()) { ArrayList<String> errors = new ArrayList(); _bindingResult.getFieldErrors().forEach((FieldError t) -> { errors.add(t.getField() + ": " + t.getDefaultMessage()); });//from w ww . ja v a 2 s .com return new ErrorResponse(mapper, HttpStatus.BAD_REQUEST, errors.toString()).response(); } User user = users.byLogin(userLogin); if (user == null) { return new ErrorResponse(mapper, HttpStatus.BAD_REQUEST, "User does not exist.", null).response(); } if (_ucr.password != null && !_ucr.password.isEmpty()) { user.setPassword(_ucr.password); } if (_ucr.rank != null) { user.setRank(_ucr.rank); } users.save(user); return ResponseEntity.ok(user); }
From source file:com.racoon.ampdroid.views.CurrentPlaylistView.java
@SuppressLint("InflateParams") @Override/*w w w . j a v a 2 s . c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { controller = Controller.getInstance(); ViewGroup root = (ViewGroup) inflater.inflate(R.layout.current_playlist, null); playlist = (ListView) root.findViewById(R.id.playNow_listview); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { playlist.setFastScrollAlwaysVisible(true); } seekBar = (SeekBar) root.findViewById(R.id.playNow_seekbar); songTitle = (TextView) root.findViewById(R.id.playNow_song); songArtist = (TextView) root.findViewById(R.id.playNow_artist); duration = (TextView) root.findViewById(R.id.playNow_duration); currentDuration = (TextView) root.findViewById(R.id.playNow_duration_current); togglePlayButton = (ImageButton) root.findViewById(R.id.playlist_play_pause); ArrayList<String> list = new ArrayList<String>(); for (Song s : controller.getPlayNow()) { list.add(s.toString()); } Log.d("songs:", list.toString()); CurrentlyPlayingPlaylistArrayAdapter adapter = new CurrentlyPlayingPlaylistArrayAdapter( getActivity().getApplicationContext(), list, controller.getPlayNow()); playlist.setAdapter(adapter); playlist.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { try { MainActivity main = (MainActivity) getActivity(); main.play(position); updateSongData(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); updateSongData(); setHasOptionsMenu(true); return root; }
From source file:com.crs4.roodin.moduletester.activities.DijkstraActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dijkstra); try {// w w w.jav a 2 s. c o m JSONObject jsonGraph = new JSONObject( "{\"BC\": {\"DB203_BC\": 1}, \"DB203_BC\": {\"B203\": 1, \"BC\": 1},\"AB\": {\"DB203_AB\": 1}, \"DB203_AB\": {\"AB\": 1, \"B203\": 1}, \"DB229\": {\"B203\": 1, \"B229\": 1}, \"DB228\": {\"B203\": 1, \"B228\": 1}, \"DB223\": {\"B203\": 1, \"B223\": 1}, \"DB222\": {\"B203\": 2, \"B222\": 3}, \"DB221\": {\"B203\": 1, \"B221\": 1}, \"DB220\": {\"B203\": 1, \"B220\": 1}, \"DB227\": {\"B227\": 1, \"B203\": 1}, \"DB226\": {\"B226\": 1, \"B203\": 1}, \"DB225\": {\"B203\": 1, \"B225\": 1}, \"DB224\": {\"B224\": 1, \"B203\": 1}, \"B203\": {\"DB203_BC\": 1, \"DB203_AB\": 1, \"DB229\": 1, \"DB228\": 1, \"DB223\": 1, \"DB222\": 1, \"DB221\": 1, \"DB220\": 1, \"DB227\": 1, \"DB226\": 1, \"DB225\": 1, \"DB224\": 1}, \"B228\": {\"DB228\": 1}, \"B229\": {\"DB229\": 1}, \"B226\": {\"DB226\": 1}, \"B227\": {\"DB227\": 1}, \"B224\": {\"DB224\": 1}, \"B225\": {\"DB225\": 1}, \"B222\": {\"DB222\": 1}, \"B223\": {\"DB223\": 1}, \"B220\": {\"DB220\": 1}, \"B221\": {\"DB221\": 1} }"); dijkstra = new DijkstraMain(); ArrayList<String> res = dijkstra.getDijkstraPath(jsonGraph, "BC", "DB224"); textViewTitle = (TextView) findViewById(R.id.textViewTitle); textViewTitle.setText("Example graph. Result expected: \nBC, DB203_BC, B203, DB224"); textViewDijkstraPath = (TextView) findViewById(R.id.textViewDijkstraPath); textViewDijkstraPath.setText(res.toString()); } catch (JSONException e) { e.printStackTrace(); } }
From source file:eu.cassandra.utils.Utils.java
public static void durationCheck(ArrayList<Event> events) { log.info("====================DURATIONS========================"); ArrayList<Integer> durations = new ArrayList<Integer>(); int start = -1, end = -1, counter = 0; int duration = -1; for (Event event : events) { start = event.getStartMinute();/*w w w. ja v a2s .c o m*/ end = event.getEndMinute(); duration = end - start; if (duration > Constants.MINUTES_PER_DAY) { counter++; log.info("Start:" + +start + " End: " + end + " Duration:" + duration); } durations.add(duration); } Collections.sort(durations); log.info("Durations:" + durations.toString()); log.info("Events over a day: " + counter); }
From source file:info.smartkit.hairy_batman.query.KJsonApiQuery.java
public void query() { // KJSON API testing using RestTemplate. RestTemplate restTemplate = new RestTemplate(); // restTemplate.getMessageConverters().add(new // StringHttpMessageConverter()); MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); // @see:/*from ww w. ja va 2 s . c o m*/ // http://stackoverflow.com/questions/22329368/spring-android-rest-template-parse-json-data-with-content-type-text-html converter.setSupportedMediaTypes(Collections.singletonList(MediaType.TEXT_HTML)); restTemplate.getMessageConverters().add(converter); // Spring batch for CSV reading. // WxBar api_query_resutls = new WxBar(); try { /*System.out.println("this.getParameters():" + this.getParameters()); api_query_resutls = restTemplate.postForObject( GlobalConsts.KJSON_API_URI, this.getParameters(), WxBar.class);*/ } catch (RestClientException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (api_query_resutls.getData() != null) {// FIXME: null JSON // exception handler // here. // WxBar returns = // restTemplate.getForObject(GlobalConsts.KJSON_API_URI, // WxBar.class); ArrayList<WxKJson> api_query_resutls_data = api_query_resutls.getData(); // System.out.println("ApiQuery result data: " + // api_query_resutls_data); LOG.info("ApiQuery result data: " + api_query_resutls_data.toString()); WxKJson wxKJson = api_query_resutls_data.get(0); // System.out.println("Parsed ApiQuery results,articleReadNum:" + // wxKJson.getRead() + ",articleLikeNum: " // + wxKJson.getLike()); LOG.info("Parsed ApiQuery results,articleReadNum:" + wxKJson.getRead() + ",articleLikeNum: " + wxKJson.getLike()); // this.readNum = Long.parseLong(wxKJson.getRead()); this.likeNum = Long.parseLong(wxKJson.getLike()); this.queriedSubscriber.setArticleReadNum(wxKJson.getRead()); this.queriedSubscriber.setArticleLikeNum(wxKJson.getLike()); double likeRate = (double) likeNum / readNum * 100; java.math.BigDecimal bigLikeRate = new java.math.BigDecimal(likeRate); String bigLikeRateStr = bigLikeRate .setScale(GlobalConsts.DEFINITION_PRECISION, java.math.BigDecimal.ROUND_HALF_UP).doubleValue() + "%"; this.queriedSubscriber.setArticleLikeRate(bigLikeRateStr); // this.queriedSubscriber.setMoniterTime(GlobalVariables.now()); this.queriedSubscriber.setArticleUrl(wxKJson.getUrl()); // GlobalVariables.wxFooListWithOpenIdArticleReadLike.add(this.queriedSubscriber); // File reporting... new FileReporter(GlobalConsts.REPORT_FILE_OUTPUT_OPENID_ARITICLE_READ_LIKE, GlobalVariables.wxFooListWithOpenIdArticleReadLike, FileReporter.REPORTER_TYPE.R_T_OPENID_ARTICLE_READ_LIKE, FileReporter.REPORTER_FILE_TYPE.EXCEL) .write(); // Save to DB. Object[] params = { likeNum.intValue(), readNum.intValue(), this.queriedSubscriber.getArticleLikeRate(), this.queriedSubscriber.getArticleUrl() }; int[] types = { Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR }; int rows = GlobalVariables.jdbcTempate.update(GlobalConsts.JDBC_QUERY_UPDATE_OPENID_ARTICLE_READ_LIKE, params, types); LOG.info("rows(s): " + rows + " updated." + ",likeNum: " + likeNum + ",readNum: " + readNum + ",bigLikeRateStr: " + bigLikeRateStr + ",articleUrl: " + this.queriedSubscriber.getArticleUrl()); // LOG.info("GlobalVariables.wxFooListWithOpenIdArticleReadLike(size):" + GlobalVariables.wxFooListWithOpenIdArticleReadLike.size() + ",raw: " + GlobalVariables.wxFooListWithOpenIdArticleReadLike.toString()); // if (this.subscribers.size() > 0) { this.query();// Recursively call. GlobalVariables.kjsonQueryCounter++; if (GlobalVariables.kjsonQueryCounter >= GlobalConsts.KJSON_API_QPM) { try { Thread.sleep(30000); GlobalVariables.kjsonQueryCounter = 0; } catch (InterruptedException e) { LOG.error(e.toString()); } } } else { // } } }
From source file:de.fhg.iais.asc.commons.exceptions.AscReportableErrorException.java
private String getAllErrorMessages(Throwable e, ArrayList<String> list) { if (e != null) { if (!Strings.isNullOrEmpty(e.getLocalizedMessage())) { String message = e.getLocalizedMessage().trim(); if (!list.contains(message)) { list.add(message);//from w w w .jav a 2 s . co m } } return getAllErrorMessages(e.getCause(), list); } else { return list.toString(); } }
From source file:org.venice.piazza.servicecontroller.messaging.handlers.DeleteServiceHandlerTest.java
@Test /**/*from w w w.j a v a2 s . c om*/ * Test that handle returns a valid value */ public void testValidDeletionResponse() { // Test Response String testResponse = "Test Response to see what happens"; // Setup the DeleteServiceJob DeleteServiceJob dsj = new DeleteServiceJob(); dsj.serviceID = "a842aae2-bd74-4c4b-9a65-c45e8cd9060"; dsj.jobId = "fd88cf85-9057-440d-91f0-796d3d398970"; // Try and build a response entity ArrayList<String> resultList = new ArrayList<String>(); resultList.add(dsj.jobId); resultList.add(dsj.serviceID); ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultList.toString(), HttpStatus.OK); // Create a mock and do a return instead of calling the actual handle method DeleteServiceHandler dshMock = Mockito.spy(dhHandler); Mockito.doReturn(testResponse).when(dshMock).handle("a842aae2-bd74-4c4b-9a65-c45e8cd9060", false); ResponseEntity<String> result = dshMock.handle(dsj); assertEquals("The response entity was correct for the deletion", responseEntity, result); }
From source file:org.eclipse.xtend.typesystem.xsd.builder.OawXSDResourceSet.java
@Override public String toString() { ArrayList<String> i = new ArrayList<String>(); for (EPackage pkg : getPackages()) { if (pkg != null) i.add(pkg.getName());//from w w w.ja v a 2 s .co m else i.add("(null!)"); } return getClass().getSimpleName() + id + i.toString(); }