Java Code Examples for org.apache.commons.lang.WordUtils#wrap()
The following examples show how to use
org.apache.commons.lang.WordUtils#wrap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheAdmin.java From hadoop with Apache License 2.0 | 6 votes |
@Override public String getLongUsage() { TableListing listing = AdminHelper.getOptionDescriptionListing(); listing.addRow("<name>", "Name of the pool to modify."); listing.addRow("<owner>", "Username of the owner of the pool"); listing.addRow("<group>", "Groupname of the group of the pool."); listing.addRow("<mode>", "Unix-style permissions of the pool in octal."); listing.addRow("<limit>", "Maximum number of bytes that can be cached " + "by this pool."); listing.addRow("<maxTtl>", "The maximum allowed time-to-live for " + "directives being added to the pool."); return getShortUsage() + "\n" + WordUtils.wrap("Modifies the metadata of an existing cache pool. " + "See usage of " + AddCachePoolCommand.NAME + " for more details.", AdminHelper.MAX_LINE_WIDTH) + "\n\n" + listing.toString(); }
Example 2
Source File: CacheAdmin.java From big-c with Apache License 2.0 | 6 votes |
@Override public String getLongUsage() { TableListing listing = AdminHelper.getOptionDescriptionListing(); listing.addRow("<name>", "Name of the pool to modify."); listing.addRow("<owner>", "Username of the owner of the pool"); listing.addRow("<group>", "Groupname of the group of the pool."); listing.addRow("<mode>", "Unix-style permissions of the pool in octal."); listing.addRow("<limit>", "Maximum number of bytes that can be cached " + "by this pool."); listing.addRow("<maxTtl>", "The maximum allowed time-to-live for " + "directives being added to the pool."); return getShortUsage() + "\n" + WordUtils.wrap("Modifies the metadata of an existing cache pool. " + "See usage of " + AddCachePoolCommand.NAME + " for more details.", AdminHelper.MAX_LINE_WIDTH) + "\n\n" + listing.toString(); }
Example 3
Source File: ExtractPaymentServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * @see org.kuali.kfs.pdp.batch.service.ExtractPaymentService#formatCheckNoteLines(java.lang.String) * * Long check stub note */ @Override public List<String> formatCheckNoteLines(String checkNote) { List<String> formattedCheckNoteLines = new ArrayList<String>(); if (StringUtils.isBlank(checkNote)) { return formattedCheckNoteLines; } String[] textLines = StringUtils.split(checkNote, BusinessObjectReportHelper.LINE_BREAK); int maxLengthOfNoteLine = dataDictionaryService.getAttributeMaxLength(PaymentNoteText.class, "customerNoteText"); for (String textLine : textLines) { String text = WordUtils.wrap(textLine, maxLengthOfNoteLine, BusinessObjectReportHelper.LINE_BREAK, true); String[] wrappedTextLines = StringUtils.split(text, BusinessObjectReportHelper.LINE_BREAK); for (String wrappedText : wrappedTextLines) { formattedCheckNoteLines.add(wrappedText); } } return formattedCheckNoteLines; }
Example 4
Source File: RepositoryCleanupUtil.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Format strings for command line output * * @param unformattedText * @param indentFirstLine * @param indentBalance * @return */ private String indentFormat( String unformattedText, int indentFirstLine, int indentBalance ) { final int maxWidth = 79; String leadLine = WordUtils.wrap( unformattedText, maxWidth - indentFirstLine ); StringBuilder result = new StringBuilder(); result.append( "\n" ); if ( leadLine.indexOf( NEW_LINE ) == -1 ) { result.append( NEW_LINE ).append( StringUtils.repeat( " ", indentFirstLine ) ).append( unformattedText ); } else { int lineBreakPoint = leadLine.indexOf( NEW_LINE ); String indentString = StringUtils.repeat( " ", indentBalance ); result.append( NEW_LINE ).append( StringUtils.repeat( " ", indentFirstLine ) ).append( leadLine.substring( 0, lineBreakPoint ) ); String formattedText = WordUtils.wrap( unformattedText.substring( lineBreakPoint ), maxWidth - indentBalance ); for ( String line : formattedText.split( NEW_LINE ) ) { result.append( NEW_LINE ).append( indentString ).append( line ); } } return result.toString(); }
Example 5
Source File: CacheAdmin.java From hadoop with Apache License 2.0 | 5 votes |
@Override public String getLongUsage() { return getShortUsage() + "\n" + WordUtils.wrap("Remove a cache pool. This also uncaches paths " + "associated with the pool.\n\n", AdminHelper.MAX_LINE_WIDTH) + "<name> Name of the cache pool to remove.\n"; }
Example 6
Source File: CacheAdmin.java From hadoop with Apache License 2.0 | 5 votes |
@Override public String getLongUsage() { TableListing listing = AdminHelper.getOptionDescriptionListing(); listing.addRow("-stats", "Display additional cache pool statistics."); listing.addRow("<name>", "If specified, list only the named cache pool."); return getShortUsage() + "\n" + WordUtils.wrap("Display information about one or more cache pools, " + "e.g. name, owner, group, permissions, etc.", AdminHelper.MAX_LINE_WIDTH) + "\n\n" + listing.toString(); }
Example 7
Source File: CacheAdmin.java From big-c with Apache License 2.0 | 5 votes |
@Override public String getLongUsage() { return getShortUsage() + "\n" + WordUtils.wrap("Remove a cache pool. This also uncaches paths " + "associated with the pool.\n\n", AdminHelper.MAX_LINE_WIDTH) + "<name> Name of the cache pool to remove.\n"; }
Example 8
Source File: CacheAdmin.java From big-c with Apache License 2.0 | 5 votes |
@Override public String getLongUsage() { TableListing listing = AdminHelper.getOptionDescriptionListing(); listing.addRow("-stats", "Display additional cache pool statistics."); listing.addRow("<name>", "If specified, list only the named cache pool."); return getShortUsage() + "\n" + WordUtils.wrap("Display information about one or more cache pools, " + "e.g. name, owner, group, permissions, etc.", AdminHelper.MAX_LINE_WIDTH) + "\n\n" + listing.toString(); }
Example 9
Source File: PaymentSourceHelperServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * * @see org.kuali.kfs.sys.batch.service.PaymentSourceExtractionService#buildNoteForCheckStubText(java.lang.String) */ @Override public PaymentNoteText buildNoteForCheckStubText(String text, int previousLineCount) { PaymentNoteText pnt = null; final String maxNoteLinesParam = parameterService.getParameterValueAsString(KfsParameterConstants.PRE_DISBURSEMENT_ALL.class, PdpParameterConstants.MAX_NOTE_LINES); int maxNoteLines; try { maxNoteLines = Integer.parseInt(maxNoteLinesParam); } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Invalid Max Notes Lines parameter, value: "+maxNoteLinesParam+" cannot be converted to an integer"); } // The WordUtils should be sufficient for the majority of cases. This method will // word wrap the whole string based on the MAX_NOTE_LINE_SIZE, separating each wrapped // word by a newline character. The 'wrap' method adds line feeds to the end causing // the character length to exceed the max length by 1, hence the need for the replace // method before splitting. String wrappedText = WordUtils.wrap(text, KFSConstants.MAX_NOTE_LINE_SIZE); String[] noteLines = wrappedText.replaceAll("[\r]", "").split("\\n"); // Loop through all the note lines. for (String noteLine : noteLines) { if (previousLineCount < (maxNoteLines - 3) && !StringUtils.isEmpty(noteLine)) { // This should only happen if we encounter a word that is greater than the max length. // The only concern I have for this occurring is with URLs/email addresses. if (noteLine.length() >KFSConstants.MAX_NOTE_LINE_SIZE) { for (String choppedWord : chopWord(noteLine, KFSConstants.MAX_NOTE_LINE_SIZE)) { // Make sure we're still under the maximum number of note lines. if (previousLineCount < (maxNoteLines - 3) && !StringUtils.isEmpty(choppedWord)) { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(previousLineCount++)); pnt.setCustomerNoteText(choppedWord.replaceAll("\\n", "").trim()); } // We can't add any additional note lines, or we'll exceed the maximum, therefore // just break out of the loop early - there's nothing left to do. else { break; } } } // This should be the most common case. Simply create a new PaymentNoteText, // add the line at the correct line location. else { pnt = new PaymentNoteText(); pnt.setCustomerNoteLineNbr(new KualiInteger(previousLineCount++)); pnt.setCustomerNoteText(noteLine.replaceAll("\\n", "").trim()); } } } return pnt; }