Java Code Examples for java.util.ArrayList.toString()

The following are Jave code examples for showing how to use toString() of the java.util.ArrayList class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: java_mooc_fi   File: LotteryNumbersTest.java   Source Code and License Vote up 6 votes
@Test
public void testDrawNumbersCallRemovesOldNumbersAndDrawsNew() {
    LotteryNumbers lottoRivi;
    ArrayList<Integer> numerot;
    try {
        lottoRivi = new LotteryNumbers();
        numerot = lottoRivi.numbers();
    } catch (Throwable t) {
        fail("Something went wrong when creating a new LotteryNumbers object! More info: " + t);
        return;
    }
    String numerotString = numerot.toString();
    assertEquals("The size of number list should be seven!", 7, numerot.size());
    lottoRivi.drawNumbers();
    assertEquals("The size of number list should be seven after drawNumbers call!", 7, lottoRivi.numbers().size());
    assertFalse("New numbers should have been drawn with drawNumbers call! Numbers were " + numerotString,numerotString.equals(lottoRivi.numbers().toString()));
}
 
Example 2
Project: Divinity_Original_Sin_2_zhCN   File: SmithWaterman.java   Source Code and License Vote up 6 votes
/**
 * Smith-Waterman算法寻找两个字符串中匹配度最高的子串
 *
 * @param s1 第一个字符串
 * @param s2 第二个字符串
 * @return 匹配度最高的子串
 */
public static SeqResult find(String s1, String s2) {
	//initMatrix(s1.length(), s2.length());
	Info info = new Info();
	int i, j;
	info.H = new int[s1.length() + 1][s2.length() + 1];
	info.isEmpty = new int[s1.length() + 1][s2.length() + 1];
	for (i = 0; i <= s1.length(); i++)
		for (j = 0; j <= s2.length(); j++)
			info.isEmpty[i][j] = 1;
	calculateMatrix(info, s1, s2, s1.length(), s2.length());
	findMaxIndex(info, info.H.length, info.H[0].length);
	traceBack(info, s1, s2, info.maxIndexM, info.maxIndexN);
	ArrayList<Character> arr1 = new ArrayList<Character>();
	ArrayList<Character> arr2 = new ArrayList<Character>();
	while (!info.stk1.empty())
		arr1.add(info.stk1.pop());
	while (!info.stk2.empty())
		arr2.add(info.stk2.pop());
	return new SeqResult(arr1.toString(), arr2.toString());
}
 
Example 3
Project: microMathematics   File: FormulaResult.java   Source Code and License Vote up 6 votes
private String fillResultString()
{
    if (resultType == ResultType.NAN)
    {
        return TermParser.CONST_NAN;
    }

    if (resultType == ResultType.CONSTANT)
    {
        return constantResult.getResultDescription(getFormulaList().getDocumentSettings());
    }

    if (isArrayResult())
    {
        final ArrayList<ArrayList<String>> res = fillResultMatrixArray();
        if (res != null)
        {
            return res.toString();
        }
    }
    return "";
}
 
Example 4
Project: echo   File: Search.java   Source Code and License Vote up 5 votes
private String returnEntireCatalogue() {
  	ArrayList<String> items = Catalogue.returnAllItems();
  	String jsonResponse = null;
  	if(items.size() != 0)
	jsonResponse = Catalogue.baseString+",\"items\":"+items.toString()+"}";
else
	jsonResponse = Catalogue.baseString+"}";
  	return jsonResponse;
  }
 
Example 5
Project: echo   File: Search.java   Source Code and License Vote up 5 votes
private String prefixSearch(String prefixhref) {
  	ArrayList<String> items = Catalogue.searchByHrefPrefix(prefixhref);
  	String jsonResponse = null;
  	if(items.size() != 0)
	jsonResponse = Catalogue.baseString+",\"items\":"+items.toString()+"}";
else
	jsonResponse = Catalogue.baseString+"}";
  	return jsonResponse;
  }
 
Example 6
Project: incubator-netbeans   File: Pre90403Phase1CompatibilityTest.java   Source Code and License Vote up 5 votes
public void testColoringProfiles() {
    Set<String> profiles = EditorSettings.getDefault().getFontColorProfiles();
    ArrayList<String> sortedProfiles = new ArrayList<String>(profiles);
    Collections.sort(sortedProfiles);
    String currentProfiles = sortedProfiles.toString();
    assertEquals("Wrong coloring profiles",
        "[CityLights, NetBeans]",
        currentProfiles);
}
 
Example 7
Project: incubator-netbeans   File: Pre90403Phase1CompatibilityTest.java   Source Code and License Vote up 5 votes
public void testMimeTypesWithColorings() {
    Set<String> mimeTypes = EditorSettings.getDefault().getMimeTypes();
    ArrayList<String> sortedMimeTypes = new ArrayList<String>(mimeTypes);
    Collections.sort(sortedMimeTypes);
    String currentMimeTypes = sortedMimeTypes.toString();
    assertEquals("Wrong coloring mime types",
        "[application/xml-dtd, text/css, text/html, text/plain, text/x-el, text/x-java, text/x-jsp, text/x-properties, text/x-sql, text/x-tag, text/xml]",
        currentMimeTypes);
}
 
Example 8
Project: incubator-netbeans   File: Pre90403Phase1CompatibilityTest.java   Source Code and License Vote up 5 votes
public void testKeybindingsProfiles() {
    Set<String> profiles = EditorSettings.getDefault().getKeyMapProfiles();
    ArrayList<String> sortedProfiles = new ArrayList<String>(profiles);
    Collections.sort(sortedProfiles);
    String currentProfiles = sortedProfiles.toString();
    assertEquals("Wrong keybindings profiles",
        "[Eclipse, Emacs, NetBeans]",
        currentProfiles);
}
 
Example 9
Project: GCSApp   File: ChooseFriendsAdapter.java   Source Code and License Vote up 5 votes
public String getChooseIds() {
    ArrayList<String> ids = new ArrayList<>();
    for (ComMember info : mChoose) {
        ids.add(info.getId() + "");
    }
    return ids.toString();
}
 
Example 10
Project: java_mooc_fi   File: NumberOfItemsTest.java   Source Code and License Vote up 5 votes
public void test(int len, ArrayList in) {
    String s = in.toString();
    try {
        assertEquals("Counting the number of items in list "+s+" went wrong!",
                     len,
                     (int) ReflectionUtils.invokeMethod(Integer.TYPE, m, null, in));
    } catch (Throwable t) {
        fail("Something went wrong when countItems was called to list "+s+". \nMore info: "+t);
    }
}
 
Example 11
Project: oscm   File: UserRegisterMultipleTask.java   Source Code and License Vote up 5 votes
@Override
public void executeInternal() throws Exception {
    IdentityService idSvc = getServiceInterface(IdentityService.class);

    VOUserDetails user = new VOUserDetails();
    user.setOrganizationId(getOrganizationId());
    user.setEMail(getEmail());
    user.setLocale(getLocale());
    ArrayList<UserRoleType> userRoleTypes = getUserRoleTypes();

    ArrayList<String> userKeys = new ArrayList<String>();
    int i = 0;
    while (i < number) {
        user.setFirstName(getRandomFirstName());
        user.setLastName(getRandomLastName());
        user.setUserId(getUniqueUserId());
        try {
            VOUserDetails u = idSvc.createUser(user, userRoleTypes,
                    getMarketplaceId());
            if (userKeys.size() < numUserKeysReturned) {
                userKeys.add(String.valueOf(u.getKey()));
            }
            i++;
        } catch (NonUniqueBusinessKeyException e) {
            // new try with another random user id
        }
    }
    String string = userKeys.toString();
    getProject().setProperty(userKeyProp,
            string.substring(1, string.length() - 1));
}
 
Example 12
Project: sample.microservices.security.jwt   File: GreetingController.java   Source Code and License Vote up 5 votes
@RequestMapping("/Test")
public String greeting(@AuthenticationPrincipal JwtUserDetails userDetails,
                       @RequestParam(value="name", required=false, defaultValue="World") String name) {

    ArrayList<String> scopes = userDetails.getJwt().getClaims().getClaim("scopes", ArrayList.class);

    return "Spring RS App invoked with valid JWT "+name+
            "<br>You authenticated to me as "+userDetails.getUsername()+
            " and have scopes of "+scopes.toString();
}
 
Example 13
Project: monarch   File: ProxyFTableRegion.java   Source Code and License Vote up 5 votes
private void handleLowMemoryException(final GemFireException ge) {
  Set<DistributedMember> criticalMembers =
      ((LowMemoryException) ge.getRootCause()).getCriticalMembers();
  ArrayList<String> criticalMembersList = new ArrayList<>();
  criticalMembers.forEach(DM -> {
    criticalMembersList.add(DM.getName());
  });
  String errorMessage = "Members on Low Memory are " + criticalMembersList.toString();
  throw new MCacheLowMemoryException(errorMessage);
}
 
Example 14
Project: monarch   File: ProxyMTableRegion.java   Source Code and License Vote up 5 votes
private void handleLowMemoryException(final GemFireException ge) {
  Set<DistributedMember> criticalMembers =
      ((LowMemoryException) ge.getRootCause()).getCriticalMembers();
  ArrayList<String> criticalMembersList = new ArrayList<>();
  criticalMembers.forEach(DM -> {
    criticalMembersList.add(DM.getName());
  });
  String errorMessage = "Members on Low Memory are " + criticalMembersList.toString();
  throw new MCacheLowMemoryException(errorMessage);
}
 
Example 15
Project: openjdk-jdk10   File: GraalError.java   Source Code and License Vote up 5 votes
private static String format(String msg, Object... args) {
    if (args != null) {
        // expand Iterable parameters into a list representation
        for (int i = 0; i < args.length; i++) {
            if (args[i] instanceof Iterable<?>) {
                ArrayList<Object> list = new ArrayList<>();
                for (Object o : (Iterable<?>) args[i]) {
                    list.add(o);
                }
                args[i] = list.toString();
            }
        }
    }
    return String.format(Locale.ENGLISH, msg, args);
}
 
Example 16
Project: openjdk-jdk10   File: JVMCIError.java   Source Code and License Vote up 5 votes
private static String format(String msg, Object... args) {
    if (args != null) {
        // expand Iterable parameters into a list representation
        for (int i = 0; i < args.length; i++) {
            if (args[i] instanceof Iterable<?>) {
                ArrayList<Object> list = new ArrayList<>();
                for (Object o : (Iterable<?>) args[i]) {
                    list.add(o);
                }
                args[i] = list.toString();
            }
        }
    }
    return String.format(Locale.ENGLISH, msg, args);
}
 
Example 17
Project: TeamNote   File: CooperateServiceImpl.java   Source Code and License Vote up 5 votes
public String getGroupChatChunk(int notebookId, int lastChat) {
    ArrayList<String> resultList = new ArrayList<String>();
    ArrayList<String> contents = getGroupChat(notebookId);
    int iterator;
    for(iterator = lastChat; (iterator > lastChat - 10) && (iterator >= 0); iterator--) {
        resultList.add(convertUtil.formMessage(contents.get(iterator)));
    }
    return resultList.toString();
}
 
Example 18
Project: GCSApp   File: ReleaseDynPresenter.java   Source Code and License Vote up 5 votes
public String getAllIds()
{
    ArrayList<Integer> ids = new ArrayList<>();
    for (CircleInfo info :datas){
        ids.add(info.getId());
    }


    return ids.toString();
}
 
Example 19
Project: GCSApp   File: ReleaseDynActivity.java   Source Code and License Vote up 4 votes
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 8080) {
            ArrayList<CircleInfo> mChoose = (ArrayList<CircleInfo>) data.getExtras().getSerializable("CircleIds");
            if (null != mChoose) {
                ArrayList<String> ids = new ArrayList<>();
                String name = "";
                for (CircleInfo info : mChoose) {
                    ids.add(info.getId() + "");
                    if (StringUtils.isEmpty(name)) {
                        name = name + info.getCircleName();
                    } else {
                        name = name + "、" + info.getCircleName();
                    }
                }
                mCircleIds = ids.toString();
                if (StringUtils.isNotEmpty(name)) {

                    viewDelegate.mTvCircleChoose.setText(name);
                }
            }

        }
        if (resultCode == RESULT_OK) {
            String pathurl = null;
            if (requestCode == 1) {
                pathurl = mPhotoPath;
            } else {
                Uri uri = data.getData();
                if (!TextUtils.isEmpty(uri.getAuthority())) {
                    pathurl = getPathFromUri(uri);
                } else {
                    pathurl = uri.getPath();
                }
            }
            mvpPresenter.uploadphoto(BitmapUtil.saveBitmapFile(BitmapUtil.getBitmap(pathurl), pathurl));
//            MyUploadListener listener = new MyUploadListener();
//            listener.setUserTag(avatarPath);
//            PostRequest postRequest = OkGo.post(Config.FileUpload).params("file", new File(avatarPath));
//            uploadManager.addTask(avatarPath, postRequest, listener);

        }
    }
 
Example 20
Project: IslamicLibraryAndroid   File: UserDataDBHelper.java   Source Code and License Vote up 4 votes
private void deserializeHighlightsAndSave(String serializedHighlights, PageInfo pageInfo, int bookId) {
    ArrayList<ContentValues> highlights = Highlight.deserializeToContentValues(serializedHighlights,
            pageInfo,
            bookId);
    ArrayList<Integer> existingHighlightsId = new ArrayList<>(highlights.size());

    for (ContentValues highlight_current : highlights) {
        existingHighlightsId
                .add(highlight_current.getAsInteger(UserDataDBContract.HighlightEntry.COLUMN_NAME_HIGHLIGHT_ID));
    }
    String existingHighlightsIdString = existingHighlightsId.toString();

    existingHighlightsIdString = existingHighlightsIdString.replace('[', '(');
    existingHighlightsIdString = existingHighlightsIdString.replace(']', ')');
    SQLiteDatabase db = getWritableDatabase();

    db.beginTransaction();
    try {
        if (highlights.size() != 0) {
            db.delete(UserDataDBContract.HighlightEntry.TABLE_NAME,
                    UserDataDBContract.HighlightEntry.COLUMN_NAME_BOOK_ID + "=?" + " and " +
                            UserDataDBContract.HighlightEntry.COLUMN_NAME_PAGE_ID + "=?" + " and "
                            + UserDataDBContract.HighlightEntry.COLUMN_NAME_HIGHLIGHT_ID + " NOT IN  " +
                            existingHighlightsIdString,
                    new String[]{String.valueOf(bookId), String.valueOf(pageInfo.pageId)}
            );
        } else {
            db.delete(UserDataDBContract.HighlightEntry.TABLE_NAME,
                    UserDataDBContract.HighlightEntry.COLUMN_NAME_BOOK_ID + "=?" + " and " +
                            UserDataDBContract.HighlightEntry.COLUMN_NAME_PAGE_ID + "=?",
                    new String[]{String.valueOf(bookId), String.valueOf(pageInfo.pageId)}
            );
        }

        for (ContentValues highlight : highlights) {
            db.insertWithOnConflict(
                    UserDataDBContract.HighlightEntry.TABLE_NAME,
                    null,
                    highlight,
                    SQLiteDatabase.CONFLICT_IGNORE);
        }
        db.setTransactionSuccessful();
    } catch (SQLException e) {
        Timber.e("deserializeHighlightsAndSave: ", e);
    } finally {
        db.endTransaction();
    }

}