List of usage examples for org.apache.commons.lang3.text WordUtils wrap
public static String wrap(final String str, final int wrapLength)
Wraps a single line of text, identifying words by ' '
.
New lines will be separated by the system property line separator.
From source file:br.usp.poli.lta.cereda.macro.Application.java
/** * Mtodo principal.//from w w w. j a v a2 s . c o m * @param args Argumentos de linha de comando. */ public static void main(String[] args) { // imprime banner System.out.println(StringUtils.repeat("-", 50)); System.out.println(StringUtils.center("Expansor de macros", 50)); System.out.println(StringUtils.repeat("-", 50)); System.out.println(StringUtils.center("Laboratrio de linguagens e tcnicas adaptativas", 50)); System.out.println(StringUtils.center("Escola Politcnica - Universidade de So Paulo", 50)); System.out.println(); try { // faz o parsing dos argumentos de linha de comando CLIParser parser = new CLIParser(args); Pair<String, File> pair = parser.parse(); // se o par no nulo, possvel prosseguir com a expanso if (pair != null) { // obtm a expanso do texto fornecido na entrada String output = MacroExpander.parse(pair.getFirst()); // se foi definido um arquivo de sada, grava a expanso do // texto nele, ou imprime o resultado no terminal, caso // contrrio if (pair.getSecond() != null) { FileUtils.writeStringToFile(pair.getSecond(), output, Charset.forName("UTF-8")); System.out.println("Arquivo gerado com sucesso."); } else { System.out.println(output); } } else { // verifica se a execuo corresponde a uma chamada ao editor // embutido de macros if (parser.isEditor()) { // cria o editor e exibe SwingUtilities.invokeLater(new Runnable() { @Override public void run() { DisplayUtils.init(); Editor editor = new Editor(); editor.setVisible(true); } }); } } } catch (Exception exception) { // ocorreu uma exceo, imprime a mensagem de erro System.out.println(StringUtils.rightPad("ERRO: ", 50, "-")); System.out.println(WordUtils.wrap(exception.getMessage(), 50)); System.out.println(StringUtils.repeat(".", 50)); } }
From source file:localhost.potlatchserver.AutoGrading.java
public static void main(String[] args) throws Exception { // Ensure that this application is run within the correct working directory File f = new File("./src/main/java/localhost/potlatchserver/Application.java"); if (!f.exists()) { System.out.println(WordUtils.wrap("You must run the AutoGrading application from the root of the " + "project directory containing src/main/java. If you right-click->Run As->Java Application " + "in Eclipse, it will automatically use the correct classpath and working directory " + "(assuming that you have Gradle and the project setup correctly).", 80)); System.exit(1);/* ww w. j av a 2 s.c o m*/ } // Ensure that the server is running and accessible on port 8443 try { HttpClient client = UnsafeHttpsClient.createUnsafeClient(); HttpResponse response = client.execute(new HttpHost("127.0.0.1", 8443), new BasicHttpRequest("GET", "/")); response.getStatusLine(); } catch (NoHttpResponseException e) { // The server may have returned some JSON object } catch (Exception e) { System.out.println(WordUtils.wrap( "Unable to connect to your server on https://localhost:8443. Are you sure the server is running? " + "In order to run the autograder, you must first launch your application " + "by right-clicking on the Application class in Eclipse, and" + "choosing Run As->Java Application. If you have already done this, make sure that" + " you can access your server by opening the https://localhost:8443 url in a browser. " + "If you can't access the server in a browser, it probably indicates you have a firewall " + "or some other issue that is blocking access to port 8080 on localhost.", 80)); System.exit(1); } HandinUtil.generateHandinPackage("Asgn2", new File("./"), InternalAutoGradingTest.class); }
From source file:br.usp.poli.lta.cereda.macro.util.DisplayUtils.java
/** * Exibe mensagem na tela./* w w w . ja va 2 s .c o m*/ * @param title Ttulo da janela. * @param text Texto da mensagem. */ public static void showMessage(String title, String text) { JOptionPane.showMessageDialog(null, WordUtils.wrap(text, 70), title, JOptionPane.INFORMATION_MESSAGE); }
From source file:net.longfalcon.taglib.TextFunctions.java
public static String wordWrap(String s, int width) { return WordUtils.wrap(s, width); }
From source file:ac.ucy.cs.spdx.license.License.java
/** * License constructor that creates a new License based on the license name, * identifier and File containing the License text that are passed as * parameter. You can enter the category of the license but it is optional. * //from w w w . jav a2s .co m * @param String * @param String * @param File * @param Category */ public License(String licenseName, String identifier, File licenseText, Category... category) { this.setLicenseName(licenseName); this.setIdentifier(identifier); if (category.length != 0) this.setCategory(category[0]); String text = null; try { text = new String(Files.readAllBytes(Paths.get(licenseText.getAbsolutePath()))); } catch (IOException e) { e.printStackTrace(); } this.setLicenseText(WordUtils.wrap(text, 80)); licenses.add(this); }
From source file:net.dacce.commons.cli.HelpFormatter.java
public String printHelp() { StringBuffer sb = new StringBuffer(); if (usage) {/* w w w . j ava2 s . c o m*/ sb.append(generateUsage()); } if ((header != null) && (header.trim().length() > 0)) { sb.append(newLine); sb.append(newLine); sb.append(WordUtils.wrap(header, width)); sb.append(newLine); } sb.append(newLine); sb.append(printOptions()); if ((footer != null) && (footer.trim().length() > 0)) { sb.append(newLine); sb.append(newLine); sb.append(WordUtils.wrap(footer, width)); } return sb.toString(); }
From source file:ac.ucy.cs.spdx.license.License.java
/** * License constructor that creates a new License object based on the * license url and also the category parameters, which is optional. * /* w ww . jav a 2 s . c om*/ * @param String * @param Category */ public License(String url, Category... category) throws IOException { if (category.length != 0) this.setCategory(category[0]); Document doc = null; doc = Jsoup.connect(url).get(); Element fullName = doc.getElementsByAttributeValue("property", "rdfs:label").get(0); this.setLicenseName(fullName.text()); Element identifier = doc.getElementsByAttributeValue("property", "spdx:licenseId").get(0); this.setIdentifier(identifier.text()); Element licenseText = doc.getElementsByAttributeValue("property", "spdx:licenseText").get(0); this.setLicenseText(WordUtils.wrap(licenseText.text(), 80)); licenses.add(this); saveLicense(this); }
From source file:com.bluepowermod.client.gui.gate.GuiGate.java
@Override public final void drawScreen(int x, int y, float partialTick) { super.drawScreen(x, y, partialTick); for (IGuiWidget widget : widgets) widget.render(x, y, partialTick); renderGUI(x, y, partialTick);//from w w w . j a va 2s .c o m List<String> tooltip = new ArrayList<String>(); boolean shift = BluePower.proxy.isSneakingInGui(); for (IGuiWidget widget : widgets) { if (widget.getBounds().contains(x, y)) widget.addTooltip(x, y, tooltip, shift); } if (!tooltip.isEmpty()) { List<String> localizedTooltip = new ArrayList<String>(); for (String line : tooltip) { String localizedLine = I18n.format(line); String[] lines = WordUtils.wrap(localizedLine, 50).split(System.getProperty("line.separator")); for (String locLine : lines) { localizedTooltip.add(locLine); } } drawHoveringText(localizedTooltip, x, y, fontRendererObj); } }
From source file:com.liferay.blade.cli.ConvertThemeCommand.java
public void execute() throws Exception { final List<String> args = _options._arguments(); final String themeName = args.size() > 0 ? args.get(0) : null; if (!Util.isWorkspace(_blade)) { _blade.error("Please execute this in a Liferay Workspace Project"); return;//ww w . j a va 2 s. c o m } if (themeName == null) { List<String> themes = new ArrayList<>(); for (File file : _pluginsSDKThemesDir.listFiles()) { if (file.isDirectory()) { if (_options.all()) { importTheme(file.getCanonicalPath()); } else { themes.add(file.getName()); } } } if (!_options.all()) { if (themes.size() > 0) { String exampleTheme = themes.get(0); _blade.out().println("Please provide the theme project name to migrate, " + "e.g. \"blade migrateTheme " + exampleTheme + "\"\n"); _blade.out().println("Currently available themes:"); _blade.out().println(WordUtils.wrap(StringUtils.join(themes, ", "), 80)); } else { _blade.out() .println("Good news! All your themes have already been " + "migrated to " + _themesDir); } } } else { File themeDir = new File(_pluginsSDKThemesDir, themeName); if (themeDir.exists()) { importTheme(themeDir.getCanonicalPath()); } else { _blade.error("Theme does not exist"); } } }
From source file:buildcraftAdditions.armour.ItemKineticBackpack.java
@Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean sneaking) { list.add(Utils.getRFInfoTooltip(getEnergyStored(stack), getMaxEnergyStored(stack))); for (String line : WordUtils.wrap(Utils.localize("backpack.info"), 60) .split(System.getProperty("line.separator"))) list.add(Utils.colorText(line, EnumChatFormatting.AQUA)); }