List of usage examples for org.apache.commons.lang3 StringUtils stripEnd
public static String stripEnd(final String str, final String stripChars)
Strips any of a set of characters from the end of a String.
A null input String returns null .
From source file:com.nridge.core.app.mgr.ServiceTimer.java
private Date getNextTS(String aFieldName, Date aTS) { String timeString = getAppString(aFieldName); if (StringUtils.isNotEmpty(timeString)) { if (StringUtils.endsWithIgnoreCase(timeString, "m")) { String minuteString = StringUtils.stripEnd(timeString, "m"); if ((StringUtils.isNotEmpty(minuteString)) && (StringUtils.isNumeric(minuteString))) { int minuteAmount = Integer.parseInt(minuteString); return DateUtils.addMinutes(aTS, minuteAmount); }/*w ww. j a v a2 s . co m*/ } else if (StringUtils.endsWithIgnoreCase(timeString, "h")) { String hourString = StringUtils.stripEnd(timeString, "h"); if ((StringUtils.isNotEmpty(hourString)) && (StringUtils.isNumeric(hourString))) { int hourAmount = Integer.parseInt(hourString); return DateUtils.addHours(aTS, hourAmount); } } else // we assume days { String dayString = StringUtils.stripEnd(timeString, "d"); if ((StringUtils.isNotEmpty(dayString)) && (StringUtils.isNumeric(dayString))) { int dayAmount = Integer.parseInt(dayString); return DateUtils.addDays(aTS, dayAmount); } } } // Push 1 hour ahead to avoid triggering a match with TS return DateUtils.addHours(new Date(), 1); }
From source file:com.sri.ai.expresso.core.DefaultSyntaxLeaf.java
/** * Escape a String that is intended to be converted to a symbol of value * string so that it can be parsed safely. * /*from w ww .ja v a 2s .c o m*/ * @param aStringSymbol * a string that is intended to be used to instantiate a string * valued symbol. * @return a string that can be safely parsed with surrounding ' and * embedded escape characters, as necessary. */ public static String makeStringValuedSymbolParseSafe(String aStringSymbol) { String result = aStringSymbol; boolean containsSpace = aStringSymbol.contains(" "); // Note: trailing ''' are allowed for symbol names, e.g. aSymbol' boolean containsSingleQuote = StringUtils.stripEnd(aStringSymbol, "'").contains("'"); if (containsSpace || containsSingleQuote) { StringBuilder sb = new StringBuilder(); if (!aStringSymbol.startsWith("'")) { sb.insert(0, "'"); } sb.append(aStringSymbol); if (!aStringSymbol.endsWith("'")) { sb.append("'"); } String substring; for (int i = 1; i < sb.length() - 1; i++) { substring = sb.substring(i, i + 1); if ("'".equals(substring)) { if (!escapedAlready(sb, i)) { sb.insert(i, "\\"); // move forward an additional 1 as have inserted i++; } } } result = sb.toString(); } return result; }
From source file:it.gulch.linuxday.android.fragments.EventDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_event_details, container, false); holder = new ViewHolder(); holder.inflater = inflater;/*from www . j a v a 2 s .c o m*/ ((TextView) view.findViewById(R.id.title)).setText(event.getTitle()); TextView textView = (TextView) view.findViewById(R.id.subtitle); String text = event.getSubtitle(); if (TextUtils.isEmpty(text)) { textView.setVisibility(View.GONE); } else { textView.setText(text); } MovementMethod linkMovementMethod = LinkMovementMethod.getInstance(); // Set the persons summary text first; replace it with the clickable text when the loader completes holder.personsTextView = (TextView) view.findViewById(R.id.persons); String personsSummary = ""; if (CollectionUtils.isEmpty(event.getPeople())) { holder.personsTextView.setVisibility(View.GONE); } else { personsSummary = StringUtils.join(event.getPeople(), ", "); holder.personsTextView.setText(personsSummary); holder.personsTextView.setMovementMethod(linkMovementMethod); holder.personsTextView.setVisibility(View.VISIBLE); } ((TextView) view.findViewById(R.id.track)).setText(event.getTrack().getTitle()); Date startTime = event.getStartDate(); Date endTime = event.getEndDate(); text = String.format("%1$s, %2$s %3$s", event.getTrack().getDay().getName(), (startTime != null) ? TIME_DATE_FORMAT.format(startTime) : "?", (endTime != null) ? TIME_DATE_FORMAT.format(endTime) : "?"); ((TextView) view.findViewById(R.id.time)).setText(text); final String roomName = event.getTrack().getRoom().getName(); TextView roomTextView = (TextView) view.findViewById(R.id.room); Spannable roomText = new SpannableString(String.format("%1$s", roomName)); // final int roomImageResId = getResources() // .getIdentifier(StringUtils.roomNameToResourceName(roomName), "drawable", // getActivity().getPackageName()); // // If the room image exists, make the room text clickable to display it // if(roomImageResId != 0) { // roomText.setSpan(new UnderlineSpan(), 0, roomText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // roomTextView.setOnClickListener(new View.OnClickListener() // { // // @Override // public void onClick(View view) // { // RoomImageDialogFragment.newInstance(roomName, roomImageResId).show(getFragmentManager()); // } // }); // roomTextView.setFocusable(true); // } roomTextView.setText(roomText); textView = (TextView) view.findViewById(R.id.abstract_text); text = event.getEventAbstract(); if (TextUtils.isEmpty(text)) { textView.setVisibility(View.GONE); } else { String strippedText = StringUtils.stripEnd(Html.fromHtml(text).toString(), " \n"); textView.setText(strippedText); textView.setMovementMethod(linkMovementMethod); } textView = (TextView) view.findViewById(R.id.description); text = event.getDescription(); if (TextUtils.isEmpty(text)) { textView.setVisibility(View.GONE); } else { String strippedText = StringUtils.stripEnd(Html.fromHtml(text).toString(), " \n"); textView.setText(strippedText); textView.setMovementMethod(linkMovementMethod); } holder.linksContainer = (ViewGroup) view.findViewById(R.id.links_container); return view; }
From source file:io.hawkcd.agent.services.FileManagementService.java
@Override public String urlCombine(String... args) { String output = null;/*w ww . j a v a2s.com*/ StringBuilder argsHolder = new StringBuilder(); for (String arg : args) { arg = this.normalizePath(arg); argsHolder.append(arg); argsHolder.append("/"); } output = argsHolder.toString(); output = StringUtils.stripEnd(output, "/"); return output; }
From source file:edu.buffalo.fusim.TranscriptRecord.java
private static int[] toIntArray(String str) throws NumberFormatException { str = StringUtils.stripEnd(str, ","); String[] vals = str.split(","); int[] numbers = new int[vals.length]; for (int i = 0; i < vals.length; i++) { numbers[i] = Integer.valueOf(vals[i]); }/*from ww w . j a v a 2s . co m*/ return numbers; }
From source file:com.nridge.connector.ws.con_ws.task.TaskConnectorWS.java
/** * If this task is scheduled to be executed (e.g. its run/test * name matches the command line arguments), then this method * is guaranteed to be executed prior to the thread being * started./* w ww . ja v a 2s. co m*/ * * @param anAppMgr Application manager instance. * * @throws com.nridge.core.base.std.NSException Application specific exception. */ @Override public void init(AppMgr anAppMgr) throws NSException { mAppMgr = anAppMgr; Logger appLogger = mAppMgr.getLogger(this, "init"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); mIsAlive = new AtomicBoolean(false); // Write our configuration properties for troubleshooting purposes. mAppMgr.writeCfgProperties(appLogger); // Assign our between crawl sleep time. mSleepTimeInMinutes = 15; String sleepTimeString = mAppMgr.getString(Constants.CFG_PROPERTY_PREFIX + ".run_sleep_between"); if (StringUtils.endsWithIgnoreCase(sleepTimeString, "m")) { String minuteString = StringUtils.stripEnd(sleepTimeString, "m"); if ((StringUtils.isNotEmpty(minuteString)) && (StringUtils.isNumeric(minuteString))) mSleepTimeInMinutes = Integer.parseInt(minuteString); } else if ((StringUtils.isNotEmpty(sleepTimeString)) && (StringUtils.isNumeric(sleepTimeString))) mSleepTimeInMinutes = Integer.parseInt(sleepTimeString); // The extract queue holds documents that have been extracted from the content source. int extractQueueSize = mAppMgr.getInt(Constants.CFG_PROPERTY_PREFIX + ".extract.queue_length", Connector.QUEUE_LENGTH_DEFAULT); BlockingQueue extractQueue = new ArrayBlockingQueue(extractQueueSize); mAppMgr.addProperty(Connector.QUEUE_EXTRACT_NAME, extractQueue); // The transform queue holds documents that have been transformed after extraction. int transformQueueSize = mAppMgr.getInt(Constants.CFG_PROPERTY_PREFIX + ".transform.queue_length", Connector.QUEUE_LENGTH_DEFAULT); BlockingQueue transformQueue = new ArrayBlockingQueue(transformQueueSize); mAppMgr.addProperty(Connector.QUEUE_TRANSFORM_NAME, transformQueue); // The publish queue holds documents that have been published to the search index. int publishQueueSize = mAppMgr.getInt(Constants.CFG_PROPERTY_PREFIX + ".publish.queue_length", Connector.QUEUE_LENGTH_DEFAULT); BlockingQueue publishQueue = new ArrayBlockingQueue(publishQueueSize); mAppMgr.addProperty(Connector.QUEUE_PUBLISH_NAME, publishQueue); // Load our schema definition from the data source folder. DataBag schemaBag; String schemaPathFileName = String.format("%s%c%s", mAppMgr.getString(mAppMgr.APP_PROPERTY_DS_PATH), File.separatorChar, Constants.SCHEMA_FILE_NAME); DataBagXML dataBagXML = new DataBagXML(); try { dataBagXML.load(schemaPathFileName); schemaBag = dataBagXML.getBag(); } catch (Exception e) { String msgStr = String.format("%s: %s", schemaPathFileName, e.getMessage()); appLogger.error(msgStr); appLogger.warn("Using internal document schema as alternative - data source schema ignored."); schemaBag = schemaBag(); } mAppMgr.addProperty(Connector.PROPERTY_SCHEMA_NAME, schemaBag); // Create our mail manager instance. MailManager mailManager = new MailManager(mAppMgr, Constants.CFG_PROPERTY_PREFIX + ".mail"); mAppMgr.addProperty(Connector.PROPERTY_MAIL_NAME, mailManager); // Create/Load service time tracking file. mServiceTimer = new ServiceTimer(mAppMgr); mServiceTimer.setPropertyPrefix(Constants.CFG_PROPERTY_PREFIX); String stPathFileName = mServiceTimer.createServicePathFileName(); File stFile = new File(stPathFileName); if (stFile.exists()) mServiceTimer.load(); // Is there an explicit list of phases to execute? String propertyName = Constants.CFG_PROPERTY_PREFIX + ".phase_list"; String phaseProperty = mAppMgr.getString(propertyName); if (StringUtils.isNotEmpty(phaseProperty)) { if (mAppMgr.isPropertyMultiValue(propertyName)) mPhases = mAppMgr.getStringArray(propertyName); else { mPhases = new String[1]; mPhases[0] = phaseProperty; } } // Load and assign our crawl follow and ignore instances. CrawlFollow crawlFollow = new CrawlFollow(mAppMgr); crawlFollow.setCfgPropertyPrefix(Constants.CFG_PROPERTY_PREFIX + ".extract"); try { crawlFollow.load(); } catch (NSException | IOException e) { String msgStr = String.format("Crawl Follow: %s", e.getMessage()); appLogger.error(msgStr); } mAppMgr.addProperty(Constants.PROPERTY_CRAWL_FOLLOW, crawlFollow); CrawlIgnore crawlIgnore = new CrawlIgnore(mAppMgr); crawlIgnore.setCfgPropertyPrefix(Constants.CFG_PROPERTY_PREFIX + ".extract"); try { crawlIgnore.load(); } catch (NSException | IOException e) { String msgStr = String.format("Crawl Ignore: %s", e.getMessage()); appLogger.error(msgStr); } mAppMgr.addProperty(Constants.PROPERTY_CRAWL_IGNORE, crawlIgnore); // Clear out crawl queue from previous service sessions. CrawlQueue crawlQueue = new CrawlQueue(mAppMgr); crawlQueue.reset(); appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); mIsAlive.set(true); }
From source file:com.nridge.connector.fs.con_fs.task.TaskConnectorFS.java
/** * If this task is scheduled to be executed (e.g. its run/test * name matches the command line arguments), then this method * is guaranteed to be executed prior to the thread being * started./*from ww w.j ava 2 s. c om*/ * * @param anAppMgr Application manager instance. * * @throws com.nridge.core.base.std.NSException Application specific exception. */ @Override public void init(AppMgr anAppMgr) throws NSException { mAppMgr = anAppMgr; Logger appLogger = mAppMgr.getLogger(this, "init"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); mIsAlive = new AtomicBoolean(false); // Write our configuration properties for troubleshooting purposes. mAppMgr.writeCfgProperties(appLogger); // Assign our between crawl sleep time. mSleepTimeInMinutes = 15; String sleepTimeString = mAppMgr.getString(Constants.CFG_PROPERTY_PREFIX + ".run_sleep_between"); if (StringUtils.endsWithIgnoreCase(sleepTimeString, "m")) { String minuteString = StringUtils.stripEnd(sleepTimeString, "m"); if ((StringUtils.isNotEmpty(minuteString)) && (StringUtils.isNumeric(minuteString))) mSleepTimeInMinutes = Integer.parseInt(minuteString); } else if ((StringUtils.isNotEmpty(sleepTimeString)) && (StringUtils.isNumeric(sleepTimeString))) mSleepTimeInMinutes = Integer.parseInt(sleepTimeString); // The extract queue holds documents that have been extracted from the content source. int extractQueueSize = mAppMgr.getInt(Constants.CFG_PROPERTY_PREFIX + ".extract.queue_length", Connector.QUEUE_LENGTH_DEFAULT); BlockingQueue extractQueue = new ArrayBlockingQueue(extractQueueSize); mAppMgr.addProperty(Connector.QUEUE_EXTRACT_NAME, extractQueue); // The transform queue holds documents that have been transformed after extraction. int transformQueueSize = mAppMgr.getInt(Constants.CFG_PROPERTY_PREFIX + ".transform.queue_length", Connector.QUEUE_LENGTH_DEFAULT); BlockingQueue transformQueue = new ArrayBlockingQueue(transformQueueSize); mAppMgr.addProperty(Connector.QUEUE_TRANSFORM_NAME, transformQueue); // The publish queue holds documents that have been published to the search index. int publishQueueSize = mAppMgr.getInt(Constants.CFG_PROPERTY_PREFIX + ".publish.queue_length", Connector.QUEUE_LENGTH_DEFAULT); BlockingQueue publishQueue = new ArrayBlockingQueue(publishQueueSize); mAppMgr.addProperty(Connector.QUEUE_PUBLISH_NAME, publishQueue); // Load our schema definition from the data source folder. DataBag schemaBag; String schemaPathFileName = String.format("%s%c%s", mAppMgr.getString(mAppMgr.APP_PROPERTY_DS_PATH), File.separatorChar, Constants.SCHEMA_FILE_NAME); DataBagXML dataBagXML = new DataBagXML(); try { dataBagXML.load(schemaPathFileName); schemaBag = dataBagXML.getBag(); } catch (Exception e) { String msgStr = String.format("%s: %s", schemaPathFileName, e.getMessage()); appLogger.error(msgStr); appLogger.warn("Using internal document schema as alternative - data source schema ignored."); schemaBag = schemaBag(); } mAppMgr.addProperty(Connector.PROPERTY_SCHEMA_NAME, schemaBag); // Create our mail manager instance. MailManager mailManager = new MailManager(mAppMgr, Constants.CFG_PROPERTY_PREFIX + ".mail"); mAppMgr.addProperty(Connector.PROPERTY_MAIL_NAME, mailManager); // Create/Load service time tracking file. mServiceTimer = new ServiceTimer(mAppMgr); mServiceTimer.setPropertyPrefix(Constants.CFG_PROPERTY_PREFIX); String stPathFileName = mServiceTimer.createServicePathFileName(); File stFile = new File(stPathFileName); if (stFile.exists()) mServiceTimer.load(); // Is there an explicit list of phases to execute? String propertyName = Constants.CFG_PROPERTY_PREFIX + ".phase_list"; String phaseProperty = mAppMgr.getString(propertyName); if (StringUtils.isNotEmpty(phaseProperty)) { if (mAppMgr.isPropertyMultiValue(propertyName)) mPhases = mAppMgr.getStringArray(propertyName); else { mPhases = new String[1]; mPhases[0] = phaseProperty; } } // Clear out crawl queue from previous service sessions. CrawlQueue crawlQueue = new CrawlQueue(mAppMgr); crawlQueue.reset(); // Create Restlet server instance. int portNumber = mAppMgr.getInt(Constants.CFG_PROPERTY_PREFIX + ".restlet.port_number", Constants.APPLICATION_PORT_NUMBER_DEFAULT); RestletApplication restletApplication = new RestletApplication(mAppMgr); appLogger.info("Starting Restlet Server."); mServer = new Server(Protocol.HTTP, portNumber, restletApplication); try { mServer.start(); } catch (Exception e) { appLogger.error("Restlet Server (start): " + e.getMessage(), e); throw new NSException(e.getMessage()); } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); mIsAlive.set(true); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlSerializer.java
private void appendHtmlTextArea(final HtmlTextArea htmlTextArea) { if (isVisible(htmlTextArea)) { String text = htmlTextArea.getText(); final BrowserVersion browser = htmlTextArea.getPage().getWebClient().getBrowserVersion(); if (browser.hasFeature(HTMLTEXTAREA_REMOVE_NEWLINE_FROM_TEXT)) { text = TEXT_AREA_PATTERN.matcher(text).replaceAll(""); text = StringUtils.replace(text, "\r", ""); text = StringUtils.normalizeSpace(text); } else {//w ww . j a v a 2 s. co m text = StringUtils.stripEnd(text, null); text = TEXT_AREA_PATTERN.matcher(text).replaceAll(AS_TEXT_NEW_LINE); text = StringUtils.replace(text, "\r", AS_TEXT_NEW_LINE); } text = StringUtils.replace(text, " ", AS_TEXT_BLANK); doAppend(text); } }
From source file:by.lang.StringUtilsTest.java
public static void main(String[] args) { System.out.println("?,...."); System.out.println(StringUtils.abbreviate("The quick brown fox jumps over the lazy dog.", 10)); System.out.println("."); System.out.println(StringUtils.chomp("1,2,3,", ",")); System.out.println("???."); System.out.println(StringUtils.contains("defg", "ef")); System.out.println(StringUtils.contains("ef", "defg")); System.out.println("??nulltoString()."); System.out.println(StringUtils.defaultString(null, "defaultIfEmpty")); System.out.println("."); System.out.println(StringUtils.deleteWhitespace("aa bb cc")); System.out.println("??."); System.out.println(StringUtils.isAlpha("ab")); System.out.println(StringUtils.isAlphanumeric("12")); System.out.println(StringUtils.isBlank("")); System.out.println(StringUtils.isNumeric("123")); System.out.println("?Null \"\""); System.out.println(StringUtils.isEmpty(null)); System.out.println(StringUtils.isNotEmpty(null)); System.out.println("?null \"\" "); System.out.println(StringUtils.isBlank(" ")); System.out.println(StringUtils.isNotBlank(null)); System.out.println(".Nullnull"); System.out.println(StringUtils.trim(null)); System.out.println("Null\"\" ?Null"); System.out.println(StringUtils.trimToNull("")); // NULL "" ?"" // System.out.println(StringUtils.trimToEmpty(null)); // ??/*from w w w . ja v a 2 s . com*/ // System.out.println(StringUtils.strip(" \t")); // ?""null?Null // System.out.println(StringUtils.stripToNull(" \t")); // ?""null?"" // System.out.println(StringUtils.stripToEmpty(null)); // ""Null ? "" // System.out.println(StringUtils.defaultString(null)); // Null ?(?) // System.out.println(StringUtils.defaultString("", "df")); // null""?(?) // System.out.println(StringUtils.defaultIfEmpty(null, "sos")); // .~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ?null(?2?) // System.out.println(StringUtils.strip("fsfsdf", "f")); // ?null???(????) // System.out.println(StringUtils.stripStart("ddsuuu ", "d")); // ?null???(????) // System.out.println(StringUtils.stripEnd("dabads", "das")); // // ArrayToList(StringUtils.stripAll(new String[]{" ? ", " ", // " "})); // ?null.?(??) // ArrayToList(StringUtils.stripAll(new String[]{" ? ", " ", ""}, // "")); // ,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 2?,Null // System.out.println(StringUtils.equals(null, null)); // ?? // System.out.println(StringUtils.equalsIgnoreCase("abc", "ABc")); // ????~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ?null""-1 // System.out.println(StringUtils.indexOf(null, "a")); // ?(?)2k // System.out.println(StringUtils.indexOf("akfekcd?", "k", 2)); // ??? // System.out.println(StringUtils.ordinalIndexOf("akfekcd?", "k", 2)); // ,?? // System.out.println(StringUtils.indexOfIgnoreCase("adfs", "D")); // ?(?),?? // System.out.println(StringUtils.indexOfIgnoreCase("adfs", "a", 3)); // ?? // System.out.println(StringUtils.lastIndexOf("adfas", "a")); // ?,2 // System.out.println(StringUtils.lastIndexOf("dabasdafs", "a", 3)); // ,-1 // System.out.println(StringUtils.lastOrdinalIndexOf("yksdfdht", "f", // 2)); // ???? // System.out.println(StringUtils.lastIndexOfIgnoreCase("sdffet", "E")); // ,1 // System.out.println(StringUtils.lastIndexOfIgnoreCase("efefrfs", "F" // , 2)); // ?boolean,null? // System.out.println(StringUtils.contains("sdf", "dg")); // ?boolean,null?,?? // System.out.println(StringUtils.containsIgnoreCase("sdf", "D")); // ??,boolean // System.out.println(StringUtils.containsWhitespace(" d")); // ??? // System.out.println(StringUtils.indexOfAny("absfekf", new // String[]{"f", "b"})); // (?) // System.out.println(StringUtils.indexOfAny("afefes", "e")); // ??boolean // System.out.println(StringUtils.containsAny("asfsd", new char[]{'k', // 'e', 's'})); // ?lastIndexOf???boolean // System.out.println(StringUtils.containsAny("f", "")); // // System.out.println(StringUtils.indexOfAnyBut("seefaff", "af")); // ? // System.out.println(StringUtils.containsOnly("??", "?")); // ? // System.out.println(StringUtils.containsOnly("?", new char[]{'', // '?'})); // ?? // System.out.println(StringUtils.containsNone("??", "")); // ?? // System.out.println(StringUtils.containsNone("?", new char[]{'', // ''})); // ????4 // System.out.println(StringUtils.lastIndexOfAny("", new // String[]{"", ""})); // ?indexOfAny?? (?) // System.out.println(StringUtils.countMatches("", "")); // ?CharSequence??Unicode?falseCharSequence= // 0true // System.out.println(StringUtils.isAlpha("2")); // ???UnicodeCharSequence?''CharSequence?= // 0true // System.out.println(StringUtils.isAlphaSpace("NBA ")); // ???UnicodeCharSequence?falseCharSequence= // 0true // System.out.println(StringUtils.isAlphanumeric("NBA")); // Unicode // CharSequence???''falseCharSequence= // 0true // System.out.println(StringUtils.isAlphanumericSpace("NBA")); // ???ASCII?CharSequencefalseCharSequence= // 0true // System.out.println(StringUtils.isAsciiPrintable("NBA")); // ??? // System.out.println(StringUtils.isNumeric("NBA")); // ??? // System.out.println(StringUtils.isNumericSpace("33 545")); // ??"" // System.out.println(StringUtils.isWhitespace(" ")); // ?? // System.out.println(StringUtils.isAllLowerCase("kjk33")); // ? // System.out.println(StringUtils.isAllUpperCase("KJKJ")); // ?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ?2?: // System.out.println(StringUtils.difference("", "")); // 2 // System.out.println(StringUtils.indexOfDifference("ww.taobao", // "www.taobao.com")); // ? // System.out.println(StringUtils.indexOfDifference(new String[] // {"", "", ""})); // ??? // System.out.println(StringUtils.getCommonPrefix(new String[] {"", // "", ""})); // ?????? // System.out.println(StringUtils.getLevenshteinDistance("?", // "")); // ??? // System.out.println(StringUtils.startsWith("", "")); // ????? // System.out.println(StringUtils.startsWithIgnoreCase("", // "")); // ??? // System.out.println(StringUtils.startsWithAny("abef", new // String[]{"ge", "af", "ab"})); // ?? // System.out.println(StringUtils.endsWith("abcdef", "def")); // ???? // System.out.println(StringUtils.endsWithIgnoreCase("abcdef", "Def")); // ?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ??nullnull."""" // System.out.println(StringUtils.substring("", 2)); // ? // System.out.println(StringUtils.substring("", 2, 4)); // ? // System.out.println(StringUtils.left("", 3)); // ?? // System.out.println(StringUtils.right("", 3)); // ??? // System.out.println(StringUtils.mid("", 3, 2)); // ?? // System.out.println(StringUtils.substringBefore("", "")); // ????? // System.out.println(StringUtils.substringAfter("", "")); // ??. // System.out.println(StringUtils.substringBeforeLast("", "")); // ????? // System.out.println(StringUtils.substringAfterLast("", "")); // ???null:2010? // System.out.println(StringUtils.substringBetween("??2010?????", // "??")); // ??? // ArrayToList(StringUtils.substringsBetween("[a][b][c]", "[", "]")); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ?nullnull // ArrayToList(StringUtils.split("? ")); // ? // ArrayToList(StringUtils.split("? ,,", ",")); // ???0 // ArrayToList(StringUtils.split("? ", "", 2)); // ???,? // ArrayToList(StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", // "-!-")); // ???,??? // ArrayToList(StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", "-!-", // 2)); // " "?,?null // ArrayToList(StringUtils.splitByWholeSeparatorPreserveAllTokens(" ab // de fg ", // null)); // ?," "?? // ArrayToList(StringUtils.splitByWholeSeparatorPreserveAllTokens("ab de // fg", // null, 3)); // ???, // ArrayToList(StringUtils.splitPreserveAllTokens(" ab de fg ")); // ???,? // ArrayToList(StringUtils.splitPreserveAllTokens(" ab de fg ", // null)); // ???,??? // ArrayToList(StringUtils.splitPreserveAllTokens(" ab de fg ", null, // 2)); // ?? // ArrayToList(StringUtils.splitByCharacterType("AEkjKr i39:")); // // ArrayToList(StringUtils.splitByCharacterTypeCamelCase("ASFSRules234")); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ?? // System.out.println(StringUtils.concat(getArrayData())); // ?.?null // System.out.println(StringUtils.concatWith(",", getArrayData())); // ? // System.out.println(StringUtils.join(getArrayData())); // ? // System.out.println(StringUtils.join(getArrayData(), ":")); // (?)?(?,??) // System.out.println(StringUtils.join(getArrayData(), ":", 1, 3)); // ?.? // System.out.println(StringUtils.join(getListData(), ":")); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // System.out.println(StringUtils.deleteWhitespace(" s 4j")); // ? // System.out.println(StringUtils.removeStart("www.baidu.com", "www.")); // ?,?? // System.out.println(StringUtils.removeStartIgnoreCase("www.baidu.com", // "WWW")); // ??? // System.out.println(StringUtils.removeEnd("www.baidu.com", ".com")); // ????? // System.out.println(StringUtils.removeEndIgnoreCase("www.baidu.com", // ".COM")); // ? // System.out.println(StringUtils.remove("www.baidu.com/baidu", "bai")); // "\n", "\r", "\r\n". // System.out.println(StringUtils.chomp("abcrabc\r")); // ? // System.out.println(StringUtils.chomp("baidu.com", "com")); // ?."\n", "\r", "\r\n" // System.out.println(StringUtils.chop("wwe.baidu")); // ?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ??? // System.out.println(StringUtils.replaceOnce("www.baidu.com/baidu", // "baidu", "hao123")); // ? // System.out.println(StringUtils.replace("www.baidu.com/baidu", // "baidu", "hao123")); // ???? // System.out.println(StringUtils.replace("www.baidu.com/baidu", // "baidu", "hao123", 1)); // ?????:baidu?taobaocom?net // System.out.println(StringUtils.replaceEach("www.baidu.com/baidu", new // String[]{"baidu", "com"}, new String[]{"taobao", "net"})); // ???? // System.out.println(StringUtils.replaceEachRepeatedly("www.baidu.com/baidu", // new String[]{"baidu", "com"}, new String[]{"taobao", "net"})); // ????.(????) // System.out.println(StringUtils.replaceChars("www.baidu.com", "bdm", // "qo")); // ?(?)?(?) // System.out.println(StringUtils.overlay("www.baidu.com", "hao123", 4, // 9)); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ???? // System.out.println(StringUtils.repeat("ba", 3)); // ?????? // System.out.println(StringUtils.repeat("ab", "ou", 3)); // ??(???) // System.out.println(StringUtils.rightPad("?", 4)); // ????(?) // System.out.println(StringUtils.rightPad("?", 4, "?")); // ??? // System.out.println(StringUtils.leftPad("?", 4)); // ??????(?) // System.out.println(StringUtils.leftPad("?", 4, "")); // ????? // System.out.println(StringUtils.center("?", 3)); // ?????? // System.out.println(StringUtils.center("?", 5, "?")); // ??(?),??(??+=?) // System.out.println(StringUtils.abbreviate("?", 5)); // 2: ...ijklmno // System.out.println(StringUtils.abbreviate("abcdefghijklmno", 12, // 10)); // ???.: ab.f // System.out.println(StringUtils.abbreviateMiddle("abcdef", ".", 4)); // ?,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ?. // System.out.println(StringUtils.capitalize("Ddf")); // ?. // System.out.println(StringUtils.uncapitalize("DTf")); // ???????? // System.out.println(StringUtils.swapCase("I am Jiang, Hello")); // ? // System.out.println(StringUtils.reverse("")); // ?(?)?? // System.out.println(StringUtils.reverseDelimited("::", ':')); // isEmpty System.out.println(StringUtils.isEmpty(null)); // true System.out.println(StringUtils.isEmpty("")); // true System.out.println(StringUtils.isEmpty(" ")); // false System.out.println(StringUtils.isEmpty("bob")); // false System.out.println(StringUtils.isEmpty(" bob ")); // false // isBlank System.out.println(StringUtils.isBlank(null)); // true System.out.println(StringUtils.isBlank("")); // true System.out.println(StringUtils.isBlank(" ")); // true System.out.println(StringUtils.isBlank("bob")); // false System.out.println(StringUtils.isBlank(" bob ")); // false // trim System.out.println(StringUtils.trim(null)); // null System.out.println(StringUtils.trim("")); // "" System.out.println(StringUtils.trim(" ")); // "" System.out.println(StringUtils.trim("abc")); // "abc" System.out.println(StringUtils.trim(" abc")); // "abc" System.out.println(StringUtils.trim(" abc ")); // "abc" System.out.println(StringUtils.trim(" ab c ")); // "ab c" // strip System.out.println(StringUtils.strip(null)); // null System.out.println(StringUtils.strip("")); // "" System.out.println(StringUtils.strip(" ")); // "" System.out.println(StringUtils.strip("abc")); // "abc" System.out.println(StringUtils.strip(" abc")); // "abc" System.out.println(StringUtils.strip("abc ")); // "abc" System.out.println(StringUtils.strip(" abc ")); // "abc" System.out.println(StringUtils.strip(" ab c ")); // "ab c" System.out.println(StringUtils.strip(" abcyx", "xyz")); // " abc" System.out.println(StringUtils.stripStart("yxabcxyz ", "xyz")); // "abcxyz // " System.out.println(StringUtils.stripEnd(" xyzabcyx", "xyz")); // " // xyzabc" // ? String str1 = "aaa bbb ccc"; String[] dim1 = StringUtils.split(str1); // => ["aaa", "bbb", "ccc"] System.out.println(dim1.length);// 3 System.out.println(dim1[0]);// "aaa" System.out.println(dim1[1]);// "bbb" System.out.println(dim1[2]);// "ccc" // String str2 = "aaa,bbb,ccc"; String[] dim2 = StringUtils.split(str2, ","); // => ["aaa", "bbb", // "ccc"] System.out.println(dim2.length);// 3 System.out.println(dim2[0]);// "aaa" System.out.println(dim2[1]);// "bbb" System.out.println(dim2[2]);// "ccc" // String str3 = "aaa,,bbb"; String[] dim3 = StringUtils.split(str3, ","); // => ["aaa", "bbb"] System.out.println(dim3.length);// 2 System.out.println(dim3[0]);// "aaa" System.out.println(dim3[1]);// "bbb" // ? String str4 = "aaa,,bbb"; String[] dim4 = StringUtils.splitPreserveAllTokens(str4, ","); // => // ["aaa", // "", // "bbb"] System.out.println(dim4.length);// 3 System.out.println(dim4[0]);// "aaa" System.out.println(dim4[1]);// "" System.out.println(dim4[2]);// "bbb" // ?? String str5 = "aaa,bbb,ccc"; String[] dim5 = StringUtils.split(str5, ",", 2); // => ["aaa", // "bbb,ccc"] System.out.println(dim5.length);// 2 System.out.println(dim5[0]);// "aaa" System.out.println(dim5[1]);// "bbb,ccc" // String[] array = { "aaa", "bbb", "ccc" }; String result1 = StringUtils.join(array, ","); System.out.println(result1);// "aaa,bbb,ccc" // ? List<String> list = new ArrayList<String>(); list.add("aaa"); list.add("bbb"); list.add("ccc"); String result2 = StringUtils.join(list, ","); System.out.println(result2);// "aaa,bbb,ccc" }
From source file:com.norconex.commons.lang.url.URLNormalizer.java
/** * <p>Converts <code>https</code> scheme to <code>http</code>.</p> * <code>https://www.example.com/ → http://www.example.com/</code> * @return this instance// w w w .java2 s . c o m */ public URLNormalizer unsecureScheme() { Matcher m = PATTERN_SCHEMA.matcher(url); if (m.find()) { String schema = m.group(1); if ("https".equalsIgnoreCase(schema)) { url = m.replaceFirst(StringUtils.stripEnd(schema, "Ss") + "$2"); } } return this; }