读取模板并写入数据

@param option
@return
429825
private static List<String> readLines(Option option) {
        String optionStr = GsonUtil.format(option);
        InputStream is = null;
        InputStreamReader iReader = null;
        BufferedReader bufferedReader = null;
        List<String> lines = new ArrayList<String>();
        String line;
        try {
            is = OptionUtil.class.getResourceAsStream("/template");
            iReader = new InputStreamReader(is, "UTF-8");
            bufferedReader = new BufferedReader(iReader);
            while ((line = bufferedReader.readLine()) != null) {
                if (line.contains("##option##")) {
                    line = line.replace("##option##", optionStr);
                }
                lines.add(line);
            }
        } catch (Exception e) {
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    //ignore
                }
            }
        }
        return lines;
    }
1235067
private OptionElement readOption(char keyValueSeparator) {
    boolean isExtension = (peekChar() == '[');
    boolean isParenthesized = (peekChar() == '(');
    String name = readName(); // Option name.
    if (isExtension) {
      name = "[" + name + "]";
    }
    String subName = null;
    char c = readChar();
    if (c == '.') {
      // Read nested field name. For example "baz" in "(foo.bar).baz = 12".
      subName = readName();
      c = readChar();
    }
    if (c != keyValueSeparator) {
      throw unexpected("expected '" + keyValueSeparator + "' in option");
    }
    OptionKindAndValue kindAndValue = readKindAndValue();
    OptionElement.Kind kind = kindAndValue.kind();
    Object value = kindAndValue.value();
    if (subName != null) {
      value = OptionElement.create(subName, kind, value);
      kind = OptionElement.Kind.OPTION;
    }
    return OptionElement.create(name, kind, value, isParenthesized);
  }
316464
public Object getOptionValue( String name )
    {
        if (!hasOptionValue( name )) throw new IllegalArgumentException( "Don't know option: " + name );
        return getOptionValues().get( name );
    }
1036260
public <T> Option<T> findOption(Option<T> option) {
        for (Option candidateOption : options) {
            if (candidateOption.hasSameNameAs(option)) {
                return candidateOption;
            }
        }
        throw new RuntimeException("You tried to set an unexpected option");
    }
1316823
@SuppressWarnings("unchecked")
    public <T> T get(Option<T> key) {
        T v = (T) this.values.get(key);
        if (v == null) {
            v = key.defaultValue();
            this.values.put(key, v);
        }
        return v;
    }
852620
public String put(String optionName, String optionValue) {
        options.put(optionName, optionValue);
        return optionValue;
    }
899464
private Option getOption(final String opt) {
        for (Object o : getOptions().getOptions()) {
            Option opto=(Option) o;
            if (opto.getOpt().equals(opt)) {
                return opto;
            }
        }
        return null;
    }
1257519
public static String
value(String option) {
	if (table == null)
		return null;
	return ((String)table.get(option.toLowerCase()));
}
224649
public boolean hasOption(final String optionName) {
        if (optionName.length() == 1) {
            return hasOption(optionName.charAt(0));
        }
        return commandLine.hasOption("--" + optionName);
    }
1106201
private Option resolveOption(String name) {
        name = OptionUtils.stripLeadingHyphens(name);
        for (Option option : options) {
            if (name.equals(option.getName())) {
                return option;
            }
            if (name.equals(option.getLongName())) {
                return option;
            }
        }
        return null;
    }
1105816
@Override
  protected Object getOptionValue(Queue<String> argq) {
    return Long.parseLong(argq.remove());
  }
84750
public <T> B option(ClientOption<T> option, T value) {
        requireNonNull(option, "option");
        requireNonNull(value, "value");
        return option(option.newValue(value));
    }
1329653
public String selectOption(final String optionName, final String defaultValue) throws SQLException {
      Connection conn = null;
      PreparedStatement stmt = null;
      ResultSet rs = null;
      Timer.Context ctx = metrics.optionSelectTimer.time();
      try {
         conn = connectionSupplier.getConnection();
         stmt = conn.prepareStatement(selectOptionSQL);
         stmt.setString(1, optionName);
         rs = stmt.executeQuery();
         if(rs.next()) {
            String val = rs.getString(1);
            return val != null ? val.trim() : defaultValue;
         } else {
            return defaultValue;
         }
      } finally {
         ctx.stop();
         SQLUtil.closeQuietly(conn, stmt, rs);
      }
   }
1320116
public boolean hasLongOption(String opt)
    {
        opt = Util.stripLeadingHyphens(opt);

        return longOpts.containsKey(opt);
    }
314426
Option toOption() {
        DefaultOptionBuilder oBuilder = new DefaultOptionBuilder();

        oBuilder.withShortName(option).withDescription(description).withRequired(required);

        if (longOptionName != null) {
            oBuilder.withLongName(longOptionName);
        }

        if (hasArgs) {
            ArgumentBuilder aBuilder = new ArgumentBuilder();

            if (argName != null) {
                aBuilder.withName(argName);
            }

            if (argsAreOptional) {
                aBuilder.withMinimum(0);
            }

            if (argsCount != null) {
                aBuilder.withMaximum(argsCount);
            } else {
                aBuilder.withMaximum(1);
            }

            if (argsValueSeparator != null && argsValueSeparator.length() != 0) {
                aBuilder.withInitialSeparator(argsValueSeparator.charAt(0));
                aBuilder.withSubsequentSeparator(argsValueSeparator.charAt(0));
            }
            oBuilder.withArgument(aBuilder.create());
        }

        return oBuilder.create();
    }
792457
public static int
intValue(String option) {
	String s = value(option);
	if (s != null) {
		try {
			int val = Integer.parseInt(s);
			if (val > 0)
				return (val);
		}
		catch (NumberFormatException e) {
		}
	}
	return (-1);
}
110941
public boolean hasShortOption(String opt)
    {
        opt = Util.stripLeadingHyphens(opt);

        return shortOpts.containsKey(opt);
    }