joptsimple.internal.Strings.surround()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(213)

本文整理了Java中joptsimple.internal.Strings.surround()方法的一些代码示例,展示了Strings.surround()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Strings.surround()方法的具体详情如下:
包路径:joptsimple.internal.Strings
类名称:Strings
方法名:surround

Strings.surround介绍

[英]Gives a string consisting of a given string prepended and appended with surrounding characters.
[中]给出一个由给定字符串组成的字符串,该字符串的前面加上周围的字符。

代码示例

代码示例来源:origin: org.apache.geode/geode-joptsimple

private void addHelpLineWithArgument( OptionDescriptor descriptor, char begin, char end ) {
  String argDescription = descriptor.argumentDescription();
  String typeIndicator = typeIndicator( descriptor );
  StringBuilder collector = new StringBuilder();
  if ( typeIndicator.length() > 0 ) {
    collector.append( typeIndicator );
    if ( argDescription.length() > 0 )
      collector.append( ": " ).append( argDescription );
  }
  else if ( argDescription.length() > 0 )
    collector.append( argDescription );
  String helpLine = collector.length() == 0
    ? ""
    : ' ' + surround( collector.toString(), begin, end );
  addHelpLineFor( descriptor, helpLine );
}

代码示例来源:origin: io.snappydata/gemfire-util

private void addHelpLineWithArgument( OptionDescriptor descriptor, char begin, char end ) {
  String argDescription = descriptor.argumentDescription();
  String typeIndicator = typeIndicator( descriptor );
  StringBuilder collector = new StringBuilder();
  if ( typeIndicator.length() > 0 ) {
    collector.append( typeIndicator );
    if ( argDescription.length() > 0 )
      collector.append( ": " ).append( argDescription );
  }
  else if ( argDescription.length() > 0 )
    collector.append( argDescription );
  String helpLine = collector.length() == 0
    ? ""
    : ' ' + surround( collector.toString(), begin, end );
  addHelpLineFor( descriptor, helpLine );
}

代码示例来源:origin: io.snappydata/gemfire-joptsimple

private void addHelpLineWithArgument( OptionDescriptor descriptor, char begin, char end ) {
  String argDescription = descriptor.argumentDescription();
  String typeIndicator = typeIndicator( descriptor );
  StringBuilder collector = new StringBuilder();
  if ( typeIndicator.length() > 0 ) {
    collector.append( typeIndicator );
    if ( argDescription.length() > 0 )
      collector.append( ": " ).append( argDescription );
  }
  else if ( argDescription.length() > 0 )
    collector.append( argDescription );
  String helpLine = collector.length() == 0
    ? ""
    : ' ' + surround( collector.toString(), begin, end );
  addHelpLineFor( descriptor, helpLine );
}

代码示例来源:origin: io.snappydata/gemfire-util

private String createDescriptionDisplay( OptionDescriptor descriptor ) {
  List<?> defaultValues = descriptor.defaultValues();
  if ( defaultValues.isEmpty() )
    return descriptor.description();
  String defaultValuesDisplay = createDefaultValuesDisplay( defaultValues );
  return descriptor.description() + ' ' + surround( "default: " + defaultValuesDisplay, '(', ')' );
}

代码示例来源:origin: io.snappydata/gemfire-joptsimple

private String createDescriptionDisplay( OptionDescriptor descriptor ) {
  List<?> defaultValues = descriptor.defaultValues();
  if ( defaultValues.isEmpty() )
    return descriptor.description();
  String defaultValuesDisplay = createDefaultValuesDisplay( defaultValues );
  return descriptor.description() + ' ' + surround( "default: " + defaultValuesDisplay, '(', ')' );
}

代码示例来源:origin: org.apache.geode/geode-joptsimple

private String createDescriptionDisplay( OptionDescriptor descriptor ) {
  List<?> defaultValues = descriptor.defaultValues();
  if ( defaultValues.isEmpty() )
    return descriptor.description();
  String defaultValuesDisplay = createDefaultValuesDisplay( defaultValues );
  return descriptor.description() + ' ' + surround( "default: " + defaultValuesDisplay, '(', ')' );
}

代码示例来源:origin: jopt-simple/jopt-simple

return ( descriptor.description()
  + ' '
  + surround( message( "default.value.header" ) + ' ' + defaultValuesDisplay, '(', ')' )
).trim();

代码示例来源:origin: net.sf.jopt-simple/jopt-simple

/**
 * <p>Gives a string representing a description of the option with the given descriptor.</p>
 *
 * <p>This implementation:</p>
 * <ul>
 *     <li>Asks for the descriptor's {@link OptionDescriptor#defaultValues()}</li>
 *     <li>If they're not present, answers the descriptor's {@link OptionDescriptor#description()}.</li>
 *     <li>If they are present, concatenates and returns:
 *         <ul>
 *             <li>the descriptor's {@link OptionDescriptor#description()}</li>
 *             <li>{@code ' '}</li>
 *             <li>{@code "default: "} plus the result of {@link #createDefaultValuesDisplay(java.util.List)},
 *             surrounded by parentheses</li>
 *         </ul>
 *     </li>
 * </ul>
 *
 * @param descriptor a descriptor for a configured option of a parser
 * @return display text for the option's description
 */
protected String createDescriptionDisplay( OptionDescriptor descriptor ) {
  List<?> defaultValues = descriptor.defaultValues();
  if ( defaultValues.isEmpty() )
    return descriptor.description();
  String defaultValuesDisplay = createDefaultValuesDisplay( defaultValues );
  return ( descriptor.description()
    + ' '
    + surround( message( "default.value.header" ) + ' ' + defaultValuesDisplay, '(', ')' )
  ).trim();
}

相关文章

微信公众号

最新文章

更多