类org.apache.commons.lang.WordUtils源码实例Demo

下面列出了怎么用org.apache.commons.lang.WordUtils的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: das   文件: AbstractDataPreparer.java
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());
}
 
源代码2 项目: openregistry   文件: NameSuffixAspect.java
@Around("set(@org.openregistry.core.domain.normalization.NameSuffix * *)")
public Object transformFieldValue(final ProceedingJoinPoint joinPoint) throws Throwable {
	final String value = (String) joinPoint.getArgs()[0];

       if (isDisabled() || value == null || value.isEmpty()) {
           return joinPoint.proceed();
       }

       final String overrideValue = getCustomMapping().get(value);

       if (overrideValue != null) {
          return joinPoint.proceed(new Object[] {overrideValue});
       }
        
       final String casifyValue;
       if (value.matches("^[IiVv]+$")) { //TODO Generalize II - VIII
       	casifyValue = value.toUpperCase();
       } else {
       	casifyValue = WordUtils.capitalizeFully(value);
       }

       return joinPoint.proceed(new Object[] {casifyValue});
   }
 
源代码3 项目: ProjectAres   文件: KDMListener.java
@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();
    }
}
 
源代码4 项目: CardinalPGM   文件: ScoreboardModule.java
public void renderObjective(GameObjective objective) {
    if (!objective.showOnScoreboard()) return;
    int score = currentScore;
    Team team = scoreboard.getTeam(objective.getScoreboardHandler().getNumber() + "-o");
    String prefix = objective.getScoreboardHandler().getPrefix(this.team);
    team.setPrefix(prefix);
    if (team.getEntries().size() > 0) {
        setScore(this.objective, new ArrayList<>(team.getEntries()).get(0), score);
    } else {
        String raw = (objective instanceof HillObjective ? "" : ChatColor.RESET) + " " + WordUtils.capitalizeFully(objective.getName().replaceAll("_", " "));
        while (used.contains(raw)) {
            raw =  raw + ChatColor.RESET;
        }
        team.addEntry(raw);
        setScore(this.objective, raw, score);
        used.add(raw);
    }
    currentScore++;
}
 
源代码5 项目: hadoop   文件: CacheAdmin.java
@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();
}
 
源代码6 项目: openhab1-addons   文件: WeatherPublisher.java
/**
 * 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());
    }
}
 
源代码7 项目: hadoop   文件: TableListing.java
/**
 * 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;
}
 
源代码8 项目: openregistry   文件: FirstNameAspect.java
@Around("set(@org.openregistry.core.domain.normalization.FirstName * *)")
public Object transformFieldValue(final ProceedingJoinPoint joinPoint) throws Throwable {
    final String value = (String) joinPoint.getArgs()[0];

    if (isDisabled() || value == null || value.isEmpty()) {
        return joinPoint.proceed();
    }

    final String overrideValue = getCustomMapping().get(value);

    if (overrideValue != null) {
        return joinPoint.proceed(new Object[] {overrideValue});
    }

    return joinPoint.proceed(new Object[] {WordUtils.capitalizeFully(value)});
}
 
源代码9 项目: bioasq   文件: GoPubMedTripleRetrievalExecutor.java
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]");
    }
}
 
源代码10 项目: kfs   文件: ExtractPaymentServiceImpl.java
/**
  * @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;
}
 
源代码11 项目: pentaho-kettle   文件: RepositoryCleanupUtil.java
/**
 * 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();
}
 
源代码12 项目: ant-ivy   文件: HelloIvy.java
public static void main(String[] args) throws Exception {
    String  message = "Hello Ivy!";
    System.out.println("standard message : " + message);
    System.out.println("capitalized by " + WordUtils.class.getName()
        + " : " + WordUtils.capitalizeFully(message));

    HttpClient client = new HttpClient();
    HeadMethod head = new HeadMethod("http://www.ibiblio.org/");
    client.executeMethod(head);

    int status = head.getStatusCode();
    System.out.println("head status code with httpclient: " + status);
    head.releaseConnection();

    System.out.println(
        "now check if httpclient dependency on commons-logging has been realized");
    Class<?> clss = Class.forName("org.apache.commons.logging.Log");
    System.out.println("found logging class in classpath: " + clss);
}
 
源代码13 项目: big-c   文件: TableListing.java
/**
 * 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;
}
 
源代码14 项目: dal   文件: AbstractJavaDataPreparer.java
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());
}
 
源代码15 项目: dal   文件: AbstractCSharpDataPreparer.java
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());
}
 
源代码16 项目: dal   文件: CSharpDataPreparerOfFreeSqlProcessor.java
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);
        }
    }
}
 
源代码17 项目: dal   文件: CSharpMethodHost.java
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, ", ");
}
 
源代码18 项目: oodt   文件: RSSUtils.java
public static Element emitRSSTag(RSSTag tag, Metadata prodMet, Document doc,
    Element item) {
  String outputTag = tag.getName();
  if (outputTag.contains(" ")) {
    outputTag = StringUtils.join(WordUtils.capitalizeFully(outputTag).split(
        " "));
  }
  Element rssMetElem = XMLUtils.addNode(doc, item, outputTag);

  // first check if there is a source defined, if so, use that as the value
  if (tag.getSource() != null) {
    rssMetElem.appendChild(doc.createTextNode(StringEscapeUtils.escapeXml(PathUtils.replaceEnvVariables(
        tag.getSource(), prodMet))));
  }

  // check if there are attributes defined, and if so, add to the attributes
  for (RSSTagAttribute attr : tag.getAttrs()) {
    rssMetElem.setAttribute(attr.getName(), PathUtils.replaceEnvVariables(
        attr.getValue(), prodMet));
  }

  return rssMetElem;
}
 
源代码19 项目: SonarPet   文件: PetOwnerListener.java
@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);
        }
    }
}
 
源代码20 项目: ant-ivy   文件: HelloConsole.java
public static void main(String[] args) throws Exception {
    Option msg = Option.builder("m")
        .longOpt("message")
        .hasArg()
        .desc("the message to capitalize")
        .build();
    Options options = new Options();
    options.addOption(msg);

    CommandLineParser parser = new DefaultParser();
    CommandLine line = parser.parse(options, args);

    String  message = line.getOptionValue("m", "Hello Ivy!");
    System.out.println("standard message : " + message);
    System.out.println("capitalized by " + WordUtils.class.getName()
        + " : " + WordUtils.capitalizeFully(message));
}
 
源代码21 项目: das   文件: GenUtils.java
/**
 * 组建最基本的VelocityContext
 *
 * @return
 */
public static VelocityContext buildDefaultVelocityContext() {
    VelocityContext context = new VelocityContext();
    context.put("WordUtils", WordUtils.class);
    context.put("StringUtils", StringUtils.class);
    context.put("helper", VelocityHelper.class);

    return context;
}
 
源代码22 项目: das   文件: JavaParameterHost.java
public String getCapitalizedName() {
    String tempName = name.replace("@", "");
    // if (tempName.contains("_")) {
    // tempName = WordUtils.capitalizeFully(tempName.replace('_', ' ')).replace(" ", "");
    // }
    return WordUtils.capitalize(tempName);
}
 
源代码23 项目: das   文件: JavaParameterHost.java
public String getCamelCaseCapitalizedName() {
    String temp = name.replace("@", "");
    if (temp.contains("_")) {
        temp = WordUtils.capitalizeFully(temp.replace('_', ' ')).replace(" ", "");
    }
    return WordUtils.capitalize(temp);
}
 
源代码24 项目: das   文件: JavaParameterHost.java
public String getUncapitalizedName() {
    String tempName = name.replace("@", "");
    // if (tempName.contains("_")) {
    // tempName = WordUtils.capitalizeFully(tempName.replace('_', ' ')).replace(" ", "");
    // }
    return WordUtils.uncapitalize(tempName);
}
 
源代码25 项目: das   文件: JavaParameterHost.java
public String getCamelCaseUncapitalizedName() {
    String temp = name.replace("@", "");
    temp = WordUtils.capitalizeFully(temp);
    if (temp.contains("_")) {
        temp = WordUtils.capitalizeFully(temp.replace('_', ' ')).replace(" ", "");
    }
    return WordUtils.uncapitalize(temp);
}
 
源代码26 项目: smart-admin   文件: CodeGeneratorService.java
/**
 * 表名转 java变量前缀
 *
 * @param tableName
 * @param tablePrefix
 * @return
 */
private String tableName2Var(String tableName, String tablePrefix) {
    if (StringUtils.isNotBlank(tablePrefix)) {
        tableName = tableName.replaceFirst(tablePrefix, "");
    }
    String transName = WordUtils.capitalizeFully(tableName, new char[]{'_'}).replace("_", "");
    return WordUtils.uncapitalize(transName);
}
 
源代码27 项目: ant-ivy   文件: Hello.java
public static void main(String[] args) {
    String  message = "example world !";
    System.out.println("standard message :" + message);
    System.out.println("capitalized by " + WordUtils.class.getName()
        + " : " + WordUtils.capitalizeFully(message));
    System.out.println("upperCased by " + test.StringUtils.class.getName()
        + " : " + test.StringUtils.upperCase(message));
}
 
源代码28 项目: weixin4j   文件: MaterialComponent.java
/**
 * 新增临时素材
 *
 * @param mediaType 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb)
 * @param file form-data中媒体文件标识,有filename、filelength、content-type等信息
 * @return 上传成功返回素材Id,否则返回null
 * @throws org.weixin4j.WeixinException 微信操作异常
 * @since 0.1.4
 */
public Media upload(MediaType mediaType, File file) throws WeixinException {
    //创建请求对象
    HttpsClient http = new HttpsClient();
    //上传素材,返回JSON数据包
    String jsonStr = http.uploadHttps("https://api.weixin.qq.com/cgi-bin/media/upload?access_token=" + weixin.getToken().getAccess_token() + "&type=" + mediaType.toString(), file);
    JSONObject jsonObj = JSONObject.parseObject(jsonStr);
    if (jsonObj != null) {
        if (Configuration.isDebug()) {
            System.out.println("新增临时素材返回json:" + jsonObj.toString());
        }
        Object errcode = jsonObj.get("errcode");
        if (errcode != null && !errcode.toString().equals("0")) {
            //返回异常信息
            throw new WeixinException(getCause(jsonObj.getIntValue("errcode")));
        } else {
            //转换为Media对象
            Media media = new Media();
            media.setMediaType(MediaType.valueOf(WordUtils.capitalize(jsonObj.getString("type"))));
            media.setMediaId(jsonObj.getString("media_id"));
            //转换为毫秒数
            long time = jsonObj.getLongValue("created_at") * 1000L;
            media.setCreatedAt(new Date(time));
            //返回多媒体文件id
            return media;
        }
    }
    return null;
}
 
源代码29 项目: code-generator   文件: Column.java
public void setColumnName(String columnName) {
    this.columnName = columnName;
    if (this.columnName != null) {
        this.uppercaseAttributeName = WordUtils.capitalizeFully(this.columnName.toLowerCase(), new char[]{'_'})
                .replace("_", "");
        this.attributeName = StringUtils.uncapitalize(this.uppercaseAttributeName);
    }
}
 
源代码30 项目: java-study   文件: CommonsTest.java
/**
 * 其他的测试
 */
private static void otherTest(){
	System.out.println("十位数字随机数:"+RandomStringUtils.randomNumeric(10)); //0534110685
	System.out.println("十位字母随机数:"+RandomStringUtils.randomAlphabetic(10)); //jLWiHdQhHg
	System.out.println("十位ASCII随机数:"+RandomStringUtils.randomAscii(10));  //8&[bxy%h_-
	String str="hello world,why are you so happy";
	System.out.println("首字符大写:"+WordUtils.capitalize(str));  //:Hello World,why Are You So Happy
}
 
 类所在包
 同包方法