List of usage examples for java.lang CharSequence toString
public String toString();
From source file:RadixTree.java
/** * Finds the substring of the string that is in the set * /* w w w. ja v a 2s. c om*/ * @param string * @return The substring that belongs */ public String findPredecessor(CharSequence string) { if (!caseSensitive) { string = string.toString().toLowerCase(); } StringBuilder buff = new StringBuilder(); root.findPredecessor(string, buff); return buff.toString(); }
From source file:com.android.google.demo.result.supplement.BookResultInfoRetriever.java
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp( "https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return;/*from w w w .j av a 2 s .co m*/ } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<String>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e.toString()); } Collection<String> newTexts = new ArrayList<String>(); maybeAddText(title, newTexts); maybeAddTextSeries(authors, newTexts); maybeAddText(pages == null || pages.length() == 0 ? null : pages + "pp.", newTexts); String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
From source file:com.apecat.shoppingadvisor.scan.result.supplement.BookResultInfoRetriever.java
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp( "https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return;/*from www . ja v a2s .c om*/ } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<String>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e); } Collection<String> newTexts = new ArrayList<String>(); maybeAddText(title, newTexts); maybeAddTextSeries(authors, newTexts); maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts); String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
From source file:com.opemind.cartspage.client.android.result.supplement.BookResultInfoRetriever.java
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp( "https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return;/* ww w . j a va2 s .co m*/ } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e); } Collection<String> newTexts = new ArrayList<>(); maybeAddText(title, newTexts); maybeAddTextSeries(authors, newTexts); maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts); String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
From source file:com.flavik.barcode.recognizer.client.android.result.supplement.BookResultInfoRetriever.java
@Override void retrieveSupplementalInfo() throws IOException { CharSequence contents = HttpHelper.downloadViaHttp( "https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn, HttpHelper.ContentType.JSON); if (contents.length() == 0) { return;/* w ww .j a va2 s . co m*/ } String title; String pages; Collection<String> authors = null; try { JSONObject topLevel = (JSONObject) new JSONTokener(contents.toString()).nextValue(); JSONArray items = topLevel.optJSONArray("items"); if (items == null || items.isNull(0)) { return; } JSONObject volumeInfo = ((JSONObject) items.get(0)).getJSONObject("volumeInfo"); if (volumeInfo == null) { return; } title = volumeInfo.optString("title"); pages = volumeInfo.optString("pageCount"); JSONArray authorsArray = volumeInfo.optJSONArray("authors"); if (authorsArray != null && !authorsArray.isNull(0)) { authors = new ArrayList<String>(authorsArray.length()); for (int i = 0; i < authorsArray.length(); i++) { authors.add(authorsArray.getString(i)); } } } catch (JSONException e) { throw new IOException(e.toString()); } Collection<String> newTexts = new ArrayList<String>(); maybeAddText(title, newTexts); maybeAddTextSeries(authors, newTexts); maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts); String baseBookUri = "http://www.google." + LocaleManager.getBookSearchCountryTLD(context) + "/search?tbm=bks&source=zxing&q="; append(isbn, source, newTexts.toArray(new String[newTexts.size()]), baseBookUri + isbn); }
From source file:org.shredzone.cilla.plugin.flattr.FlattrPublicationServiceImpl.java
/** * Creates a {@link Submission} object for the {@link Page}. * * @param page//from ww w. ja va 2 s . c o m * {@link Page} to create a {@link Submission} for * @return generated {@link Submission}, or {@code null} if a {@link Submission} could * not be generated because of lacking information or other problems. */ private Submission createSubmissionForPage(Page page) { Submission thing = new Submission(); thing.setCategory(org.shredzone.flattr4j.model.Category.withId(category)); CharSequence title = prepare(page.getTitle(), 100); if (title.length() < 5) { // Title would be too short... return null; } thing.setTitle(title.toString()); CharSequence description = textFormatter.format(page.getTeaser()); description = prepare(description, 1000); if (description.length() < 5) { // Description would be too short... return null; } thing.setDescription(description.toString()); LanguageId language = flattrLanguage.findLanguageId(page.getLanguage().getLocale()); if (language == null) { // No matching language was found... return null; } thing.setLanguage(language); page.getCategories().stream().map(Category::getName).forEach(thing::addTag); page.getTags().stream().map(Tag::getName).forEach(thing::addTag); if (flattrAutotags != null && !flattrAutotags.isEmpty()) { Arrays.stream(flattrAutotags.split(",")).map(String::trim).forEach(thing::addTag); } thing.setHidden(flattrHidden); thing.setUrl(linkService.linkTo().page(page).external().toString()); return thing; }
From source file:com.jaspersoft.android.jaspermobile.activities.profile.ServerProfileActivity.java
@TextChange(R.id.aliasEdit) void onAliasTextChanges(CharSequence text) { alias = text.toString(); aliasEdit.setError(null); setSubmitActionState(); }
From source file:RadixTree.java
/** * Finds possible completions that fit in the set * // ww w. ja v a2 s.c o m * @param string * @param depth * How deeply to search the tree, the maximum number of * decisions that need to be made to type any one * completion * @return A list of possible completions */ public List<String> findSuccessors(CharSequence string, int depth) { if (!caseSensitive) { string = string.toString().toLowerCase(); } List<String> completions = new LinkedList<String>(); root.findSuccessors(string, depth, completions); return completions; }
From source file:com.jaspersoft.android.jaspermobile.activities.profile.ServerProfileActivity.java
@TextChange(R.id.usernameEdit) void onUsernameUrlTextChanges(CharSequence text) { username = text.toString(); usernameEdit.setError(null); setSubmitActionState(); }
From source file:com.jaspersoft.android.jaspermobile.activities.profile.ServerProfileActivity.java
@TextChange(R.id.passwordEdit) void onPasswordUrlTextChanges(CharSequence text) { password = text.toString(); passwordEdit.setError(null); setSubmitActionState(); }