Java Code Examples for org.apache.commons.lang.WordUtils

The following are top voted examples for showing how to use org.apache.commons.lang.WordUtils. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: hadoop-oss   File: TableListing.java   View source code 7 votes vote down vote up
/**
 * Return the ith row of the column as a set of wrapped strings, each at
 * most wrapWidth in length.
 */
String[] getRow(int idx) {
  String raw = rows.get(idx);
  // Line-wrap if it's too long
  String[] lines = new String[] {raw};
  if (wrap) {
    lines = WordUtils.wrap(lines[0], wrapWidth, "\n", true).split("\n");
  }
  for (int i=0; i<lines.length; i++) {
    if (justification == Justification.LEFT) {
      lines[i] = StringUtils.rightPad(lines[i], maxWidth);
    } else if (justification == Justification.RIGHT) {
      lines[i] = StringUtils.leftPad(lines[i], maxWidth);
    }
  }
  return lines;
}
 
Example 2
Project: hadoop   File: TableListing.java   View source code 7 votes vote down vote up
/**
 * Return the ith row of the column as a set of wrapped strings, each at
 * most wrapWidth in length.
 */
String[] getRow(int idx) {
  String raw = rows.get(idx);
  // Line-wrap if it's too long
  String[] lines = new String[] {raw};
  if (wrap) {
    lines = WordUtils.wrap(lines[0], wrapWidth, "\n", true).split("\n");
  }
  for (int i=0; i<lines.length; i++) {
    if (justification == Justification.LEFT) {
      lines[i] = StringUtils.rightPad(lines[i], maxWidth);
    } else if (justification == Justification.RIGHT) {
      lines[i] = StringUtils.leftPad(lines[i], maxWidth);
    }
  }
  return lines;
}
 
Example 3
Project: rapidminer   File: ActivationSuccessfulCard.java   View source code 6 votes vote down vote up
private void fillContent(String owner, String edition, String expires, String additionalInformation) {
    if(owner != null) {
        this.lbRegisteredToResult.setText(owner);
    } else {
        this.lbRegisteredToResult.setText("-");
    }

    if(edition != null) {
        this.lbStatus.setText(WordUtils.capitalize(edition) + " " + LICENSE_INSTALLED);
    } else {
        this.lbStatus.setText("- " + LICENSE_INSTALLED);
    }

    if(expires != null) {
        this.lbExpiresResult.setText(expires);
    } else {
        this.lbExpiresResult.setText("-");
    }

    if(additionalInformation != null && additionalInformation.trim().isEmpty()) {
        this.lbAdditionalInfo.setText((String)null);
    } else {
        this.lbAdditionalInfo.setText(additionalInformation);
    }

}
 
Example 4
Project: ProjectAres   File: KDMListener.java   View source code 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onMatchEnd(MatchEndEvent event) {
    Match match = event.getMatch();
    Tourney plugin = Tourney.get();
    this.session.appendMatch(match, plugin.getMatchManager().getTeamManager().teamToEntrant(Iterables.getOnlyElement(event.getMatch().needMatchModule(VictoryMatchModule.class).winners(), null)));

    Entrant winningParticipation = this.session.calculateWinner();
    int matchesPlayed = this.session.getMatchesPlayed();
    if (winningParticipation != null) {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "A winner has been determined!");
        Bukkit.broadcastMessage(ChatColor.AQUA + WordUtils.capitalize(winningParticipation.team().name()) + ChatColor.RESET + ChatColor.YELLOW + " wins! Congratulations!");
        plugin.clearKDMSession();
    } else if (matchesPlayed < 3) {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "A winner has not yet been determined! Beginning match #" + (matchesPlayed + 1) + "...");
        match.needMatchModule(CycleMatchModule.class).startCountdown(Duration.ofSeconds(15), session.getMap());
    } else {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "There is a tie! Congratulations to both teams!");
        Tourney.get().clearKDMSession();
    }
}
 
Example 5
Project: magento2-phpstorm-plugin   File: PluginLineMarkerProvider.java   View source code 6 votes vote down vote up
@Override
public List<Method> collect(@NotNull Method psiElement) {
    List<Method> results = new ArrayList<>();

    PhpClass methodClass = psiElement.getContainingClass();
    if (methodClass == null) {
        return results;
    }

    List<PhpClass> pluginsList = pluginClassCache.getPluginsForClass(methodClass);
    List<Method> pluginMethods = pluginClassCache.getPluginMethods(pluginsList);

    String classMethodName = WordUtils.capitalize(psiElement.getName());
    for (Method pluginMethod: pluginMethods) {
        if (isPluginMethodName(pluginMethod.getName(), classMethodName)) {
            results.add(pluginMethod);
        }
    }
    return results;
}
 
Example 6
Project: mxisd   File: EmailConfig.java   View source code 6 votes vote down vote up
@PostConstruct
public void build() {
    log.info("--- E-mail config ---");

    if (StringUtils.isBlank(getGenerator())) {
        throw new ConfigurationException("generator");
    }

    if (StringUtils.isBlank(getConnector())) {
        throw new ConfigurationException("connector");
    }

    log.info("From: {}", identity.getFrom());

    if (StringUtils.isBlank(identity.getName())) {
        identity.setName(WordUtils.capitalize(mxCfg.getDomain()) + " Identity Server");
    }
    log.info("Name: {}", identity.getName());
    log.info("Generator: {}", getGenerator());
    log.info("Connector: {}", getConnector());
}
 
Example 7
Project: hadoop   File: CacheAdmin.java   View source code 6 votes vote down vote up
@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 8
Project: PA   File: PlayerListener.java   View source code 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onPlayerChat(AsyncPlayerChatEvent e) {
    PAUser u = PAServer.getUser(e.getPlayer());

    //AdminChat
    if (PAServer.getAdminChatMode().contains(u)) {
        Utils.sendAdminMsg(u.getName(), e.getMessage());
        e.setCancelled(true);
    }

    //Format
    String name = u.getDisplayName().equalsIgnoreCase("") ? u.getName() : u.getDisplayName();
    String tag = "[&" + PACmd.Grupo.groupColor(u.getUserData().getGrupo()) + WordUtils.capitalizeFully(u.getUserData().getGrupo().toString().toLowerCase()) + "&r] &" + PACmd.Grupo.groupColor(u.getUserData().getGrupo()) + name + "&r: ";
    if (u.isOnRank(PACmd.Grupo.ORIGIN)) e.setMessage(Utils.colorize(e.getMessage()));

    e.setFormat(Utils.colorize(tag) + e.getMessage().replace("%", ""));
}
 
Example 9
Project: AsgardAscension   File: MainInventory.java   View source code 6 votes vote down vote up
public static void setupRankUpMenu(Player player) {
	Inventory inv = Bukkit.createInventory(player, 9, ChatColor.BOLD + "Rank-Up");
	int challenge = plugin.getPlayerManager().getRank(player) + 1;
	inv.setItem(2, ItemStackGenerator.createItem(Material.DIAMOND_HELMET, 0, 0, 
			ChatColor.LIGHT_PURPLE + "I trust my strength!",
			Arrays.asList(	ChatColor.RED 	+ "Earn rankup by completing the challenge",
							ChatColor.RED 	+ "for lesser amount of money!"), true));
	inv.setItem(4, ItemStackGenerator.createItem(Material.BOOK, 0, 0, 
			ChatColor.LIGHT_PURPLE + "RankUp Information",
			Arrays.asList(	ChatColor.RED + "Next rank: " + plugin.getChallengesFile().getTitle(challenge),
							ChatColor.RED + "Challenge type: " + WordUtils.capitalize(plugin.getChallengesFile().getType(challenge)),
							ChatColor.RED + "Price: " + Convert.toPrice(plugin.getChallengesFile().getPrice(challenge) * (plugin.getPlayerManager().getPrestige(player) + 1), true))));
	inv.setItem(6, ItemStackGenerator.createItem(Material.GOLD_INGOT, 0, 0, 
			ChatColor.LIGHT_PURPLE + "I can buy anything!",
			Arrays.asList(	ChatColor.RED 	+ "Skip the challenge by",
							ChatColor.RED + "paying 2 times more!")));
	player.openInventory(inv);
}
 
Example 10
Project: Word2VecfJava   File: ContextInstance.java   View source code 6 votes vote down vote up
public ContextInstance(String line, boolean noPosFlag) {
	this.line = line;
	String[] tokens = line.split("\t");
	this.targetInd = Integer.parseInt(tokens[TARGET_INDEX]);
	this.words = tokens[3].split(" ");
	this.target = this.words[this.targetInd];
	this.fullTargetKey = tokens[0];
	this.pos = this.fullTargetKey.split(".")[this.fullTargetKey.split(".").length - 1];
	String[] tmp = this.fullTargetKey.split(".");
	this.targetKey = String.join(".", Arrays.asList(tmp[0], tmp[1])); // remove suffix in cases of bar.n.v
	this.targetLemma = this.fullTargetKey.split(".")[0];
	this.targetId = Integer.parseInt(tokens[1]);
	if (validPOS.contains(this.pos)) this.pos = WordUtils.capitalize(this.pos);
	if (noPosFlag) this.targetPos = String.join(".", Arrays.asList(this.target, "*"));
	else this.targetPos = String.join(".", Arrays.asList(this.target, this.pos));
}
 
Example 11
Project: aliyun-oss-hadoop-fs   File: CacheAdmin.java   View source code 6 votes vote down vote up
@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 12
Project: aliyun-oss-hadoop-fs   File: TableListing.java   View source code 6 votes vote down vote up
/**
 * Return the ith row of the column as a set of wrapped strings, each at
 * most wrapWidth in length.
 */
String[] getRow(int idx) {
  String raw = rows.get(idx);
  // Line-wrap if it's too long
  String[] lines = new String[] {raw};
  if (wrap) {
    lines = WordUtils.wrap(lines[0], wrapWidth, "\n", true).split("\n");
  }
  for (int i=0; i<lines.length; i++) {
    if (justification == Justification.LEFT) {
      lines[i] = StringUtils.rightPad(lines[i], maxWidth);
    } else if (justification == Justification.RIGHT) {
      lines[i] = StringUtils.leftPad(lines[i], maxWidth);
    }
  }
  return lines;
}
 
Example 13
Project: bioasq   File: GoPubMedTripleRetrievalExecutor.java   View source code 6 votes vote down vote up
private void addQueryWord(String s){
    if(s==null)return;
    if(s.length()==0)return;
    if(queryWords.contains(s))
        return;
    else
        queryWords.add(s);
    
    if(sb.length()>0) sb.append(" OR ");
    sb.append(s+"[obj] OR "+ s + "[subj]");
    List<String> ls = new LinkedList<String>();
    ls.add(s.toUpperCase());
    ls.add(s.toLowerCase());
    ls.add(WordUtils.capitalize(s));
    for(String x:ls){
        sb.append(" OR ");
        sb.append(x);
        sb.append("[obj] OR ");
        sb.append(x);
        sb.append("[subj]");
    }
}
 
Example 14
Project: NametagEdit   File: Converter.java   View source code 6 votes vote down vote up
private void handleGroup(YamlConfiguration config, String line) {
    String[] lineContents = line.replace("=", "").split(" ");
    String[] permissionSplit = lineContents[0].split("\\.");
    String group = WordUtils.capitalizeFully(permissionSplit[permissionSplit.length - 1]);
    String permission = lineContents[0];
    String type = lineContents[1];
    String value = line.substring(line.indexOf("\"") + 1);
    value = value.substring(0, value.indexOf("\""));
    config.set("Groups." + group + ".Permission", permission);
    config.set("Groups." + group + ".SortPriority", -1);
    if (type.equals("prefix")) {
        config.set("Groups." + group + ".Prefix", value);
    } else {
        config.set("Groups." + group + ".Suffix", value);
    }
}
 
Example 15
Project: OSCAR-ConCert   File: SpringUtils.java   View source code 6 votes vote down vote up
/**
 * Attempts to find a Spring bean based of the specified class. This method first attempts to load a bean
 * following the default Spring auto-naming conventions (de-capitalizing class simple name). In case the bean with 
 * this name can't be found, the method returns the first available bean of this class.
 * <p/>
 * Such logic is required in order to enable this method to lookup components from legacy contexts. "Older" beans seems to 
 * have identifiers hard-coded in the bean definition file, while "newer" bean identifiers are auto-generated by Spring based on the
 * annotations.
 * 
 * @param clazz
 * 		Class of the bean to be looked up
 * @return
 * 		Returns the bean instance
 * @throws NoSuchBeanDefinitionException if there is no bean definition with the specified name
 */
@SuppressWarnings("unchecked")
public static <T> T getBean(Class<?> clazz) {
	// legacy code - I wonder if it's necessary since we are looking up a bean based directly on the class name anyways
	// but to keep legacy logic working properly attempt to locate component based on the Spring conventions 
	String className = WordUtils.uncapitalize(clazz.getSimpleName());
	if (beanFactory.containsBean(className))
		return (T) beanFactory.getBean(className);
	
	if (ListableBeanFactory.class.isAssignableFrom(beanFactory.getClass())) {
		ListableBeanFactory listableBeanFactory = (ListableBeanFactory) beanFactory;
		String[] beanNames = listableBeanFactory.getBeanNamesForType(clazz);
		if (beanNames.length > 0)
			return (T) listableBeanFactory.getBean(beanNames[0]);
	}
	throw new NoSuchBeanDefinitionException(clazz);
}
 
Example 16
Project: OSCAR-ConCert   File: CodeSearchService.java   View source code 6 votes vote down vote up
@Override
  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
List<LabelValueBean> results = new ArrayList<LabelValueBean>();
String codingSystem = request.getParameter("codingSystem");

AbstractCodeSystemDao dao = (AbstractCodeSystemDao)SpringUtils.getBean(WordUtils.uncapitalize(codingSystem) + "Dao");

if(request.getParameter("term") != null && request.getParameter("term").length() > 0) {
	List<AbstractCodeSystemModel> r = dao.searchCode(request.getParameter("term"));
	for(AbstractCodeSystemModel result:r) {
		results.add(new LabelValueBean(result.getDescription(),result.getCode()));
	}
}
response.setContentType("text/x-json");
      JSONArray jsonArray = JSONArray.fromObject( results );
      jsonArray.write(response.getWriter());

   return null;
  }
 
Example 17
Project: big-c   File: CacheAdmin.java   View source code 6 votes vote down vote up
@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 18
Project: big-c   File: TableListing.java   View source code 6 votes vote down vote up
/**
 * Return the ith row of the column as a set of wrapped strings, each at
 * most wrapWidth in length.
 */
String[] getRow(int idx) {
  String raw = rows.get(idx);
  // Line-wrap if it's too long
  String[] lines = new String[] {raw};
  if (wrap) {
    lines = WordUtils.wrap(lines[0], wrapWidth, "\n", true).split("\n");
  }
  for (int i=0; i<lines.length; i++) {
    if (justification == Justification.LEFT) {
      lines[i] = StringUtils.rightPad(lines[i], maxWidth);
    } else if (justification == Justification.RIGHT) {
      lines[i] = StringUtils.leftPad(lines[i], maxWidth);
    }
  }
  return lines;
}
 
Example 19
Project: hive-phoenix-handler   File: Utilities.java   View source code 6 votes vote down vote up
/**
 * convert "From src insert blah blah" to "From src insert ... blah"
 */
public static String abbreviate(String str, int max) {
  str = str.trim();

  int len = str.length();
  int suffixlength = 20;

  if (len <= max) {
    return str;
  }

  suffixlength = Math.min(suffixlength, (max - 3) / 2);
  String rev = StringUtils.reverse(str);

  // get the last few words
  String suffix = WordUtils.abbreviate(rev, 0, suffixlength, "");
  suffix = StringUtils.reverse(suffix);

  // first few ..
  String prefix = StringUtils.abbreviate(str, max - suffix.length());

  return prefix + suffix;
}
 
Example 20
Project: dal   File: AbstractJavaDataPreparer.java   View source code 6 votes vote down vote up
protected String getPojoClassName(String prefix, String suffix, String tableName) {
    String className = tableName;
    if (null != prefix && !prefix.isEmpty() && className.indexOf(prefix) == 0) {
        className = className.replaceFirst(prefix, "");
    }
    if (null != suffix && !suffix.isEmpty()) {
        className = className + WordUtils.capitalize(suffix);
    }

    StringBuilder result = new StringBuilder();
    for (String str : StringUtils.split(className, "_")) {
        result.append(WordUtils.capitalize(str));
    }

    return WordUtils.capitalize(result.toString());
}
 
Example 21
Project: dal   File: AbstractCSharpDataPreparer.java   View source code 6 votes vote down vote up
protected String getPojoClassName(String prefix, String suffix, String table) {
    String className = table;
    if (null != prefix && !prefix.isEmpty() && className.indexOf(prefix) == 0) {
        className = className.replaceFirst(prefix, "");
    }
    if (null != suffix && !suffix.isEmpty()) {
        className = className + WordUtils.capitalize(suffix);
    }

    StringBuilder result = new StringBuilder();
    for (String str : StringUtils.split(className, "_")) {
        result.append(WordUtils.capitalize(str));
    }

    return WordUtils.capitalize(result.toString());
}
 
Example 22
Project: dal   File: CSharpDataPreparerOfFreeSqlProcessor.java   View source code 6 votes vote down vote up
private void prepareDbFromFreeSql(CodeGenContext codeGenCtx, List<GenTaskByFreeSql> freeSqls) throws Exception {
    CSharpCodeGenContext ctx = (CSharpCodeGenContext) codeGenCtx;
    Map<String, DatabaseHost> _dbHosts = ctx.getDbHosts();
    Set<String> _freeDaos = ctx.getFreeDaos();
    for (GenTaskByFreeSql task : freeSqls) {
        addDatabaseSet(ctx, task.getDatabaseSetName());
        _freeDaos.add(WordUtils.capitalize(task.getClass_name()));
        if (!_dbHosts.containsKey(task.getAllInOneName())) {
            String provider = "sqlProvider";
            String dbType = DbUtils.getDbType(task.getAllInOneName());
            if (null != dbType && !dbType.equalsIgnoreCase("Microsoft SQL Server")) {
                provider = "mySqlProvider";
            }
            DatabaseHost host = new DatabaseHost();
            host.setAllInOneName(task.getAllInOneName());
            host.setProviderType(provider);
            host.setDatasetName(task.getDatabaseSetName());
            _dbHosts.put(task.getAllInOneName(), host);
        }
    }
}
 
Example 23
Project: dal   File: CSharpMethodHost.java   View source code 6 votes vote down vote up
public String getParameterDeclaration() {
    List<String> paramsDeclaration = new ArrayList<>();
    for (CSharpParameterHost parameter : parameters) {
        ConditionType conditionType = parameter.getConditionType();
        if (conditionType == ConditionType.In || parameter.isInParameter()) {
            paramsDeclaration.add(String.format("List<%s> %s", parameter.getType(), WordUtils.uncapitalize(parameter.getAlias())));
        } else if (conditionType == ConditionType.IsNull || conditionType == ConditionType.IsNotNull
                || conditionType == ConditionType.And || conditionType == ConditionType.Or
                || conditionType == ConditionType.Not || conditionType == ConditionType.LeftBracket
                || conditionType == ConditionType.RightBracket) {
            continue;// is null、is not null don't hava param
        } else {
            paramsDeclaration.add(String.format("%s %s", parameter.getType(), WordUtils.uncapitalize(parameter.getAlias())));
        }
    }
    if (this.paging && this.crud_type.equalsIgnoreCase("select")) {
        paramsDeclaration.add("int pageNo");
        paramsDeclaration.add("int pageSize");
    }
    return StringUtils.join(paramsDeclaration, ", ");
}
 
Example 24
Project: SonarPet   File: PetOwnerListener.java   View source code 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event) {
    final Player p = event.getPlayer();
    final IPet pi = EchoPet.getManager().getPet(p);
    Iterator<IPet> i = EchoPet.getManager().getPets().iterator();
    while (i.hasNext()) {
        IPet pet = i.next();
        if (pet.getEntityPet() instanceof IEntityPacketPet && ((IEntityPacketPet) pet.getEntityPet()).hasInititiated()) {
            if (GeometryUtil.getNearbyEntities(event.getTo(), 50).contains(pet)) {
                ((IEntityPacketPet) pet.getEntityPet()).updatePosition();
            }
        }
    }
    if (pi != null) {
        if (!WorldUtil.allowPets(event.getTo())) {
            Lang.sendTo(p, Lang.PETS_DISABLED_HERE.toString().replace("%world%", WordUtils.capitalizeFully(event.getTo().getWorld().getName())));
            EchoPet.getManager().saveFileData("autosave", pi);
            EchoPet.getSqlManager().saveToDatabase(pi, false);
            EchoPet.getManager().removePet(pi, false);
        }
    }
}
 
Example 25
Project: hadoop-2.6.0-cdh5.4.3   File: CacheAdmin.java   View source code 6 votes vote down vote up
@Override
public String getLongUsage() {
  TableListing listing = 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.",
      MAX_LINE_WIDTH) + "\n\n" +
      listing.toString();
}
 
Example 26
Project: hadoop-2.6.0-cdh5.4.3   File: TableListing.java   View source code 6 votes vote down vote up
/**
 * Return the ith row of the column as a set of wrapped strings, each at
 * most wrapWidth in length.
 */
String[] getRow(int idx) {
  String raw = rows.get(idx);
  // Line-wrap if it's too long
  String[] lines = new String[] {raw};
  if (wrap) {
    lines = WordUtils.wrap(lines[0], wrapWidth, "\n", true).split("\n");
  }
  for (int i=0; i<lines.length; i++) {
    if (justification == Justification.LEFT) {
      lines[i] = StringUtils.rightPad(lines[i], maxWidth);
    } else if (justification == Justification.RIGHT) {
      lines[i] = StringUtils.leftPad(lines[i], maxWidth);
    }
  }
  return lines;
}
 
Example 27
Project: magento2plugin   File: PluginLineMarkerProvider.java   View source code 6 votes vote down vote up
@Override
public List<Method> collect(@NotNull Method psiElement) {
    List<Method> results = new ArrayList<>();

    PhpClass methodClass = psiElement.getContainingClass();
    if (methodClass == null) {
        return results;
    }

    List<PhpClass> pluginsList = pluginClassCache.getPluginsForClass(methodClass);
    List<Method> pluginMethods = pluginClassCache.getPluginMethods(pluginsList);

    String classMethodName = WordUtils.capitalize(psiElement.getName());
    for (Method pluginMethod: pluginMethods) {
        if (isPluginMethodName(pluginMethod.getName(), classMethodName)) {
            results.add(pluginMethod);
        }
    }
    return results;
}
 
Example 28
Project: Tank   File: ExceptionHandler.java   View source code 6 votes vote down vote up
public void handle(Throwable t) {
    Throwable root = getRoot(t);
    if (root instanceof ConstraintViolationException) {
        ConstraintViolationException c = (ConstraintViolationException) root;
        for (@SuppressWarnings("rawtypes") ConstraintViolation v : c.getConstraintViolations()) {
            StringBuilder sb = new StringBuilder();
            sb.append(WordUtils.capitalize(v.getPropertyPath().iterator().next().getName()));
            sb.append(' ').append(v.getMessage()).append('.');
            messages.error(sb.toString());
        }
    } else if (!StringUtils.isEmpty(root.getMessage())) {
        messages.error(root.getMessage());
    } else {
        messages.error(root.toString());
    }
}
 
Example 29
Project: bts   File: BTSCommentAnnotation.java   View source code 6 votes vote down vote up
@Override
public String getText() {
	if (comment != null)
	{
		String text = "";
		if (comment.getName() != null)
		{
			text=  comment.getName() + "\n";
		}
		if (comment.getComment() != null && !"".equals(comment.getComment()))
		{
			text += WordUtils.wrap(comment.getComment(), 60);
		}
		return text;
	}
	return super.getText();
}
 
Example 30
Project: bts   File: RelatedObjectGroupComment.java   View source code 6 votes vote down vote up
@Override
protected void fillContentComposite(Composite composite) {
	if (!getObject().getRevisions().isEmpty())
	{
		BTSRevision rev = getObject().getRevision(0);
		setGroupTitle(userController.getUserDisplayName(rev
				.getUserId()));
	}
	commentText = new Text(composite, SWT.WRAP | SWT.READ_ONLY | SWT.MULTI);
	commentText.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
			true, true, 1, 1));
	BTSObject o = getObject();
	if (o instanceof BTSComment)
	{
		refreshContent((BTSComment) getObject());
	}
	commentText.setToolTipText( WordUtils.wrap(((BTSComment) getObject()).getComment(), 60));
	setExpandBarIcon(resourceProvider.getImage(Display.getCurrent(), BTSResourceProvider.IMG_COMMENT));
	setExpandBarBackground(BTSUIConstants.COLOR_WIHTE);
}
 
Example 31
Project: openmrs-module-legacyui   File: FormatTag.java   View source code 6 votes vote down vote up
/**
 * Apply a case conversion to an input string
 * @param source
 * @return
 */
private String applyConversion(String source) {
	
	String result = source;
	
	// Find global property 
	if ("global".equalsIgnoreCase(caseConversion)) {
		AdministrationService adminService = Context.getAdministrationService();
		caseConversion = adminService.getGlobalProperty(OpenmrsConstants.GP_DASHBOARD_METADATA_CASE_CONVERSION);
	}
	
	// Apply conversion
	if ("lowercase".equalsIgnoreCase(caseConversion)) {
		result = StringUtils.lowerCase(result);
	} else if ("uppercase".equalsIgnoreCase(caseConversion)) {
		result = StringUtils.upperCase(result);
	} else if ("capitalize".equalsIgnoreCase(caseConversion)) {
		result = WordUtils.capitalize(StringUtils.lowerCase(result));
	}
	return result;
}
 
Example 32
Project: Zephyr   File: SpellTome.java   View source code 6 votes vote down vote up
public static ItemStack getSpellTome(Spell spell, User user) {
	ItemStack stack = new ItemStack(Material.WRITTEN_BOOK);
	BookMeta meta = (BookMeta) stack.getItemMeta();

	StringBuilder page = new StringBuilder();

	page.append("Spell: " + spell.getName() + "\n");
	page.append(spell.getDescription() + "\n");
	page.append("Mana Cost: " + spell.getManaCost());
	page.append("\n\n");
	page.append("Cast this spell with /cast " + WordUtils.capitalize(spell.getName()) + "\n\n");
	page.append("Learn this spell by left clicking the book");

	meta.setPages(page.toString());
	meta.setAuthor(user.<Player> getPlayer().getName());
	meta.setDisplayName(ChatColor.GOLD + "Spell Tome" + ChatColor.GRAY + SEPERATOR
			+ WordUtils.capitalize(spell.getName()));
	meta.setLore(Lists.newArrayList(ChatColor.GRAY + "Learn by left clicking"));
	stack.setItemMeta(meta);
	return stack;
}
 
Example 33
Project: powop   File: FormHelper.java   View source code 6 votes vote down vote up
public CharSequence radioGroup(Object obj, String field, String values, Options options) {
	StringBuilder radios = new StringBuilder();
	String labelClass = options.hash("labelClass");

	String tmpl = "<label class=\"%s\"><input type=\"radio\" name=\"%s\" value=\"%s\"%s>%s</label>";

	for(String value : values.split(",")) {
		try {
			String checked = "";
			if(BeanUtils.getSimpleProperty(obj, field).equalsIgnoreCase(value)) {
				checked = " checked";
			}
			radios.append(String.format(tmpl, labelClass, field, value, checked, WordUtils.capitalize(value)));
		} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
			log.warn("Could not find property {} on object {}", field, obj);
		}
	}

	return new Handlebars.SafeString(radios);
}
 
Example 34
Project: openhab-hdl   File: WeatherPublisher.java   View source code 6 votes vote down vote up
/**
 * Publishes the item with the value.
 */
private void publishValue(String itemName, Object value, WeatherBindingConfig bindingConfig) {
	if (value == null) {
		context.getEventPublisher().postUpdate(itemName, UnDefType.UNDEF);
	} else if (value instanceof Calendar) {
		Calendar calendar = (Calendar) value;
		context.getEventPublisher().postUpdate(itemName, new DateTimeType(calendar));
	} else if (value instanceof Number) {
		context.getEventPublisher().postUpdate(itemName, new DecimalType(round(value.toString(), bindingConfig)));
	} else if (value instanceof String || value instanceof Enum) {
		if (value instanceof Enum) {
			String enumValue = WordUtils.capitalizeFully(StringUtils.replace(value.toString(), "_", " "));
			context.getEventPublisher().postUpdate(itemName, new StringType(enumValue));
		} else {
			context.getEventPublisher().postUpdate(itemName, new StringType(value.toString()));
		}
	} else {
		logger.warn("Unsupported value type {}", value.getClass().getSimpleName());
	}
}
 
Example 35
Project: raptor-chess-interface   File: ConnectorMessageBlockPage.java   View source code 6 votes vote down vote up
@Override
protected void createFieldEditors() {
	Label textLabel = new Label(getFieldEditorParent(), SWT.WRAP);
	textLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false,
			false, 2, 1));
	textLabel
			.setText(WordUtils
					.wrap( local.getString("messBlockLbl"),
							70)
					+ local.getString("regexPathDesc"));

	Label label = new Label(getFieldEditorParent(), SWT.NONE);
	label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false,
			2, 1));

	addField(new ListFieldEditor(connectorShortName + "-"
			+ PreferenceKeys.REGULAR_EXPRESSIONS_TO_BLOCK,
			local.getString("regexMatchMess"),
			getFieldEditorParent(), ',', 300));
}
 
Example 36
Project: raptor-chess-interface   File: SpeechPage.java   View source code 6 votes vote down vote up
@Override
protected void createFieldEditors() {
	LabelFieldEditor userHomeDir = new LabelFieldEditor(
			"NONE",
			WordUtils
					.wrap(local.getString("speechAns"),	70), 
					getFieldEditorParent());
	addField(userHomeDir);

	final StringFieldEditor speechProcessName = new StringFieldEditor(
			PreferenceKeys.SPEECH_PROCESS_NAME, local.getString("speechPrcN"),
			getFieldEditorParent());
	addField(speechProcessName);

	labelButtonFieldEditor = new LabelButtonFieldEditor(
			"NONE",
			local.getString("testSet"),
			getFieldEditorParent(), local.getString("test"), new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					SoundService.getInstance().textToSpeech(
							local.getString("speechStpCrct"));
				}
			});
	addField(labelButtonFieldEditor);
}
 
Example 37
Project: raptor-chess-interface   File: SoundPage.java   View source code 6 votes vote down vote up
@Override
protected void createFieldEditors() {
	LabelFieldEditor userHomeDir = new LabelFieldEditor(
			"NONE",
			WordUtils
					.wrap(local.getString("soundP1"),
							70), getFieldEditorParent());
	addField(userHomeDir);

	final StringFieldEditor soundProcessName = new StringFieldEditor(
			PreferenceKeys.SOUND_PROCESS_NAME, local.getString("soundP2"),
			getFieldEditorParent());
	addField(soundProcessName);

	labelButtonFieldEditor = new LabelButtonFieldEditor(
			"NONE",
			local.getString("soundP3"),
			getFieldEditorParent(), local.getString("test"), new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					SoundService.getInstance().initSoundPlayer();
					SoundService.getInstance().playSound("win");
				}
			});
	addField(labelButtonFieldEditor);
}
 
Example 38
Project: FlexMap   File: CacheAdmin.java   View source code 6 votes vote down vote up
@Override
public String getLongUsage() {
  TableListing listing = 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.",
      MAX_LINE_WIDTH) + "\n\n" +
      listing.toString();
}
 
Example 39
Project: google-cloud-intellij   File: IntegratedIntellijGoogleLoginService.java   View source code 6 votes vote down vote up
@Override
public boolean askYesOrNo(String title, String message) {
  StringBuilder updatedMessageBuilder = new StringBuilder(message);
  if (message.equals(AccountMessageBundle.message("login.service.are.you.sure.key.text"))) {
    updatedMessageBuilder.append(
        AccountMessageBundle.message("login.service.are.you.sure.append.text"));
    for (GoogleLoginMessageExtender messageExtender : messageExtenders) {
      String additionalLogoutMessage = messageExtender.additionalLogoutMessage();
      if (!Strings.isNullOrEmpty(additionalLogoutMessage)) {
        updatedMessageBuilder.append(" ").append(additionalLogoutMessage);
      }
    }
  }
  String updatedMessage =
      WordUtils.wrap(
          updatedMessageBuilder.toString(),
          WRAP_LENGTH,
          /* newLinestr */ null,
          /* wrapLongWords */ false);
  return (Messages.showYesNoDialog(updatedMessage, title, GoogleLoginIcons.GOOGLE_FAVICON)
      == Messages.YES);
}
 
Example 40
Project: tellervo   File: RediscoveryExportEx.java   View source code 6 votes vote down vote up
/**
 * Extract the county from the Origin field
 * 
 * @return
 */
public String getCounty()
{
	String origin = this.getOrigin();
	String[] parts = origin.split("__");
	if(parts.length==4)
	{
		
		 String county = parts[1].trim();
		 return WordUtils.capitalize(county.toLowerCase().replace("--", " - "));	
		
	}
	
	log.error("Unable to extract County information from origin field from '"+this.getCatalogCode()+"'");

	return null;
	
}