List of usage examples for java.util List toString
public String toString()
From source file:ml.shifu.shifu.core.alg.TensorflowTrainer.java
private <T> String listToString(List<T> list) { if (CollectionUtils.isEmpty(list)) { return StringUtils.EMPTY; }//from w w w .j av a 2 s . co m String listStr = list.toString(); return listStr.substring(1, listStr.length() - 1).replaceAll(",", ""); }
From source file:com.tk.httpClientErp.headmandraw.DrawsListActivity.java
/** * /*ww w.ja v a 2 s. c o m*/ */ @SuppressWarnings("unchecked") @Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); List<NameValuePair> params = new ArrayList<NameValuePair>(); switch (item.getItemId()) // Id { case R.id.menu_item_buslist_yes: HashMap<String, Object> hashMapsYES = MyStore.subAndDel(MyStore.drawList); List<JSONObject> submitJsonArrayYES = (List<JSONObject>) hashMapsYES.get("submitJsonArray"); List<HashMap<String, Object>> delListYES = (List<HashMap<String, Object>>) hashMapsYES.get("delList"); params.add(new BasicNameValuePair("submitJsonArray", submitJsonArrayYES.toString())); String reultString = null; try { reultString = HttpClientUtil.postRequest("/android.do?method=updateDraws", params, MyStore.sessionID); } catch (TimeoutException e) { e.printStackTrace(); DrawsListActivity.this.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(DrawsListActivity.this, MyStore.TIMEOUTLOGIN, Toast.LENGTH_SHORT).show(); } }); } reultString = HttpClientUtil.callBackSuccOrFail(reultString, "resualt"); if (HttpClientUtil.reSUCCorFAILE) MyStore.drawList.removeAll(delListYES); final String MSG = reultString; DrawsListActivity.this.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(DrawsListActivity.this, MSG, Toast.LENGTH_SHORT).show(); } }); ((MySimpleAdapter) getListAdapter()).notifyDataSetChanged(); break; case R.id.menu_item_buslist_selectec_or_cancle: MyStore.selectORcancle(mResult, "mResult", MyStore.drawList); mResult = mResult == true ? false : true; ((MySimpleAdapter) getListAdapter()).notifyDataSetChanged(); break; } return true; }
From source file:com.frankdye.marvelgraphws2.MarvelGraphView.java
/** * Creates a new instance of SimpleGraphView */// ww w . ja v a 2s. c o m public MarvelGraphView() { try { Path fFilePath; /** * Assumes UTF-8 encoding. JDK 7+. */ String aFileName = "C:\\Users\\Frank Dye\\Desktop\\Programming Projects\\MarvelGraph\\data\\marvel_labeled_edges.tsv"; fFilePath = Paths.get(aFileName); // New code // Read words from file and put into a simulated multimap Map<String, List<String>> map1 = new HashMap<String, List<String>>(); Set<String> set1 = new HashSet<String>(); Scanner scan1 = null; try { scan1 = new Scanner(fFilePath, ENCODING.name()); while (scan1.hasNext()) { processLine(scan1.nextLine(), map1, set1); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Creating an URL object. JSONObject newObj = new JSONObject(); newObj.put("Heroes", set1); //Write out our set to a file PrintWriter fileWriter = null; try { fileWriter = new PrintWriter("heroes-json.txt", "UTF-8"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } fileWriter.println(newObj); fileWriter.close(); System.out.println(newObj); // Close our scanner scan1.close(); log("Done."); // Graph<V, E> where V is the type of the vertices // and E is the type of the edges g = new SparseMultigraph<String, String>(); // Add some vertices. From above we defined these to be type Integer. for (String s : set1) { g.addVertex(s); } for (Entry<String, List<String>> entry : map1.entrySet()) { String issue = entry.getKey(); ListIterator<String> heroes = entry.getValue().listIterator(); String firstHero = heroes.next(); while (heroes.hasNext()) { String secondHero = heroes.next(); if (!g.containsEdge(issue)) { g.addEdge(issue, firstHero, secondHero); } } } // Let's see what we have. Note the nice output from the // SparseMultigraph<V,E> toString() method // System.out.println("The graph g = " + g.toString()); // Note that we can use the same nodes and edges in two different // graphs. DijkstraShortestPath alg = new DijkstraShortestPath(g, true); Map<String, Number> distMap = new HashMap<String, Number>(); String n1 = "VOLSTAGG"; String n4 = "ROM, SPACEKNIGHT"; List<String> l = alg.getPath(n1, n4); distMap = alg.getDistanceMap(n1); System.out.println("The shortest unweighted path from " + n1 + " to " + n4 + " is:"); System.out.println(l.toString()); System.out.println("\nDistance Map: " + distMap.get(n4)); } catch (JSONException ex) { Logger.getLogger(MarvelGraphView.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.easemob.chatuidemo.activity.MainActivity.java
static void asyncFetchContactsFromServer() { HXSDKHelper.getInstance().asyncFetchContactsFromServer(new EMValueCallBack<List<String>>() { @Override/*from ww w.ja v a2 s. c o m*/ public void onSuccess(List<String> usernames) { Context context = HXSDKHelper.getInstance().getAppContext(); System.out.println("----------------" + usernames.toString()); EMLog.d("roster", "contacts size: " + usernames.size()); Map<String, User> userlist = new HashMap<String, User>(); for (String username : usernames) { User user = new User(); user.setUsername(username); setUserHearder(username, user); userlist.put(username, user); } // user"" User newFriends = new User(); newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME); String strChat = context.getString(R.string.Application_and_notify); newFriends.setNick(strChat); userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends); // "?" User groupUser = new User(); String strGroup = context.getString(R.string.group_chat); groupUser.setUsername(Constant.GROUP_USERNAME); groupUser.setNick(strGroup); groupUser.setHeader(""); userlist.put(Constant.GROUP_USERNAME, groupUser); // "?" User chatRoomItem = new User(); String strChatRoom = context.getString(R.string.chat_room); chatRoomItem.setUsername(Constant.CHAT_ROOM); chatRoomItem.setNick(strChatRoom); chatRoomItem.setHeader(""); userlist.put(Constant.CHAT_ROOM, chatRoomItem); // "Robot" User robotUser = new User(); String strRobot = context.getString(R.string.robot_chat); robotUser.setUsername(Constant.CHAT_ROBOT); robotUser.setNick(strRobot); robotUser.setHeader(""); userlist.put(Constant.CHAT_ROBOT, robotUser); // MyApplication.getInstance().setContactList(userlist); // db UserDao dao = new UserDao(context); List<User> users = new ArrayList<User>(userlist.values()); dao.saveContactList(users); HXSDKHelper.getInstance().notifyContactsSyncListener(true); if (HXSDKHelper.getInstance().isGroupsSyncedWithServer()) { HXSDKHelper.getInstance().notifyForRecevingEvents(); } } @Override public void onError(int error, String errorMsg) { HXSDKHelper.getInstance().notifyContactsSyncListener(false); } }); }
From source file:com.acciente.commons.htmlform.Parser.java
private static void addMapParameter2Form(Map oForm, ParameterSpec oParameterSpec, Object oData) throws ParserException, UnsupportedEncodingException { Object oDataAtIdentifier = oForm.get(oParameterSpec.getIdentifier()); Map oNestedMap;/*from w w w . j a v a 2 s. c o m*/ if (oDataAtIdentifier == null) { oForm.put(oParameterSpec.getIdentifier(), oNestedMap = new HashMap()); } else { // verify that this is a Map if (!(oDataAtIdentifier instanceof Map)) { throw new ParserException("Invalid reuse of non-map parameter: " + oParameterSpec.getIdentifier() + " as map, map key(s): " + oParameterSpec.getMapKeys() + ", new value: " + oData); } oNestedMap = (Map) oDataAtIdentifier; } List oMapKeys = oParameterSpec.getMapKeys(); for (int i = 0; i < oMapKeys.size(); i++) { String sKey = (String) oMapKeys.get(i); Object oDataAtKey = oNestedMap.get(sKey); // leaf contains the actual data value, or a list if (i + 1 == oMapKeys.size()) { if (oParameterSpec.isList()) { List oList; if (oDataAtKey == null) { oNestedMap.put(sKey, oList = new ArrayList()); } else if (oDataAtKey instanceof List) { oList = (List) oDataAtKey; } else { throw new ParserException("Map-list parameter: " + oParameterSpec.getIdentifier() + " attempt to use non-list value at key: " + oMapKeys.toString() + " as a list, value: " + oDataAtKey + " new value: " + oData); } oList.add(oData); } else { if (oDataAtKey != null) { throw new ParserException("Map parameter: " + oParameterSpec.getIdentifier() + " value overwrite at key: " + oMapKeys.toString() + " has value: " + oDataAtKey + " new value: " + oData); } oNestedMap.put(sKey, oData); } } else { if (oDataAtKey == null) { oNestedMap.put(sKey, new HashMap()); } else { // verify that this is a Map if (!(oDataAtKey instanceof Map)) { throw new ParserException("Map parameter: " + oParameterSpec.getIdentifier() + " type mismatch at key: " + sKey + " key chain: " + oMapKeys.toString() + " has value: " + oDataAtKey); } oNestedMap = (Map) oDataAtKey; } } } }
From source file:com.vmware.photon.controller.apife.backends.ProjectSqlBackend.java
@Transactional @Override/* ww w .j a v a 2 s .c om*/ public void replaceSecurityGroups(String id, List<SecurityGroup> securityGroups) throws ExternalException { logger.info("Setting the security groups of project {} to {}", id, securityGroups.toString()); ProjectEntity entity = findById(id); entity.setSecurityGroups(SecurityGroupUtils.fromApiRepresentation(securityGroups)); projectDao.update(entity); }
From source file:org.esupportail.portlet.filemanager.services.evaluators.ListUserAttributesEvaluatorEditor.java
/** * @param arg0 list of values/*from ww w . j av a 2 s . c o m*/ * @param arg1 attribute name * @param arg2 mode * @throws IllegalArgumentException * @see org.springframework.beans.propertyeditors.PropertiesEditor#setAsText(java.lang.String) */ private void setAsText(final List<String> arg0, final String arg1, final String arg2) throws IllegalArgumentException { List<UserAttributesEvaluator> list = new LinkedList<UserAttributesEvaluator>(); for (String value : arg0) { list.add(new UserAttributesEvaluator(arg1, value, arg2)); } if (LOG.isDebugEnabled()) { LOG.debug("In : [" + arg0 + ", " + arg1 + ", " + arg2 + "] out : " + list.toString()); } this.editedProperties = list; }
From source file:com.wso2telco.stepbasedsequencehandler.MIFEStepBasedSequenceHandler.java
@Override public void handle(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context) throws FrameworkException { if (log.isDebugEnabled()) { log.debug("Executing the Step Based Authentication..."); }//w w w . j a v a 2 s. co m while (!context.getSequenceConfig().isCompleted() && context.getCurrentStep() < 30) { int currentStep = context.getCurrentStep(); // let's initialize the step count to 1 if this the beginning of // the sequence if (currentStep == 0) { currentStep++; context.setCurrentStep(currentStep); } StepConfig stepConfig = context.getSequenceConfig().getStepMap().get(currentStep); if (null == stepConfig) { int curStep = context.getCurrentStep() + 1; context.setCurrentStep(curStep); continue; } stepConfig.setAuthenticatedUser(context.getSubject()); // if the current step is completed if (stepConfig.isCompleted()) { stepConfig.setCompleted(false); stepConfig.setRetrying(false); // if the request didn't fail during the step execution if (context.isRequestAuthenticated()) { if (log.isDebugEnabled()) { log.debug("Step " + stepConfig.getOrder() + " is completed. Going to get the next one."); } currentStep = context.getCurrentStep() + 1; context.setCurrentStep(currentStep); stepConfig = context.getSequenceConfig().getStepMap().get(currentStep); } else { if (log.isDebugEnabled()) { log.debug("Authentication has failed in the Step " + (context.getCurrentStep())); } // if the step contains multiple login options, we // should give the user to retry // authentication if (stepConfig.isMultiOption() && !context.isPassiveAuthenticate()) { stepConfig.setRetrying(true); context.setRequestAuthenticated(true); } else { context.getSequenceConfig().setCompleted(true); } } resetAuthenticationContext(context); } // if no further steps exists if (stepConfig == null) { if (log.isDebugEnabled()) { log.debug("There are no more steps to execute"); } // if no step failed at authentication we should do post // authentication work (e.g. // claim handling, provision etc) if (context.isRequestAuthenticated()) { if (log.isDebugEnabled()) { log.debug("Request is successfully authenticated"); } context.getSequenceConfig().setCompleted(true); handlePostAuthentication(request, response, context); } // we should get out of steps now. if (log.isDebugEnabled()) { log.debug("Step processing is completed"); } continue; } // if the sequence is not completed, we have work to do. if (log.isDebugEnabled()) { log.debug("Starting Step: " + String.valueOf(stepConfig.getOrder())); } FrameworkUtils.getStepHandler().handle(request, response, context); // if step is not completed, that means step wants to redirect // to outside if (!stepConfig.isCompleted()) { if (log.isDebugEnabled()) { log.debug("Step is not complete yet. Redirecting to outside."); } return; } context.setReturning(false); } try { String ipAddress = retriveIPAddress(request); String authenticatedUser = ""; String authenticators = ""; if (context.isRequestAuthenticated()) { // authenticators Object amrValue = context.getProperty("amr"); if (null != amrValue && amrValue instanceof ArrayList<?>) { @SuppressWarnings("unchecked") List<String> amr = (ArrayList<String>) amrValue; authenticators = amr.toString(); } authenticatedUser = context.getSequenceConfig().getAuthenticatedUser().getUserName(); } else { // authenticators Object amrValue = context.getProperty("failedamr"); if (null != amrValue && amrValue instanceof ArrayList<?>) { @SuppressWarnings("unchecked") List<String> amr = (ArrayList<String>) amrValue; authenticators = amr.toString(); } authenticatedUser = (String) context.getProperty("faileduser"); } DbTracelog.LogHistory(context.getRequestType(), context.isRequestAuthenticated(), context.getSequenceConfig().getApplicationId(), authenticatedUser, authenticators, ipAddress); } catch (LogHistoryException ex) { log.error("Error occured while Login SP LogHistory", ex); } // Need to call this deliberately as sequenceConfig gets completed // within step handler if (context.isRequestAuthenticated()) { handlePostAuthentication(request, response, context); } }
From source file:com.liferay.asset.publisher.service.test.AssetPublisherServiceTest.java
@Test public void testGetAssetEntriesFilteredByAssetTagNames() throws Exception { String[] allAssetTagNames = { _ASSET_TAG_NAMES[0], _ASSET_TAG_NAMES[1] }; List<AssetEntry> expectedAssetEntries = addAssetEntries(_NO_ASSET_CATEGORY_IDS, allAssetTagNames, 2, true); PortletPreferences portletPreferences = getAssetPublisherPortletPreferences(); List<AssetEntry> assetEntries = _assetPublisherHelper.getAssetEntries(new MockPortletRequest(), portletPreferences, _permissionChecker, new long[] { _group.getGroupId() }, false, false); Assert.assertEquals(assetEntries.toString(), _assetEntries.size() + expectedAssetEntries.size(), assetEntries.size());/*from ww w . ja v a 2s . c o m*/ List<AssetEntry> filteredAssetEntries = _assetPublisherHelper.getAssetEntries(new MockPortletRequest(), portletPreferences, _permissionChecker, new long[] { _group.getGroupId() }, _NO_ASSET_CATEGORY_IDS, allAssetTagNames, false, false); Assert.assertEquals(expectedAssetEntries, filteredAssetEntries); }
From source file:camelagent.AgentConsumer.java
/** * @param jasonAction/*from w w w . j av a 2s . co m*/ * @return * Maps external Jason agent actions to camel messages */ public boolean agentActed(JasonAction jasonAction) { boolean actionsucceeded = true; Exchange exchange = endpoint.createExchange(); if (endpoint.getUriOption().contains("action")) { try { ActionExec action = jasonAction.getAction(); String agName = jasonAction.getAgName(); List<String> paramsAsStrings = new ArrayList<String>(); for (Term t : action.getActionTerm().getTerms()) paramsAsStrings.add(t.toString()); //extract annotations List<Term> ann = action.getActionTerm().getAnnots(); String annots = ""; if (ann != null) annots = ann.toString();//StringUtils.join(ann, ','); exchange.getIn().setBody(action.getActionTerm().toString(), String.class); sendActionToCamel(agName, action.getActionTerm().getFunctor(), paramsAsStrings, exchange, annots); } catch (Exception e) { } finally { // log exception if an exception occurred and was not handled if (exchange.getException() != null) { getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException()); actionsucceeded = false; } else { String ep = endpoint.getExchangePattern().toString(); //Just send out camel message and inform success to agent if (ep.equals("InOnly")) actionsucceeded = true; else if (ep.equals("InOut")) { if (exchange.getOut() != null) actionsucceeded = true; else actionsucceeded = false; } } } } return actionsucceeded; }