public FormValidation doCheckApiTokenId(@QueryParameter String value) { if (StringUtils.isEmptyOrNull(value)) { return FormValidation.error(Messages.apiToken_required()); } else { return FormValidation.ok(); } }
private static boolean eqIgnoreCase(String a, String b) { if (a == null && b == null) return true; if (a == null || b == null) return false; return StringUtils.equalsIgnoreCase(a, b); }
/** * Join a collection of Strings together using the specified separator. * * @param parts * Strings to join * @param separator * used to join * @return a String with all the joined parts */ public static String join(Collection<String> parts, String separator) { return StringUtils.join(parts, separator, separator); }
private static RenameDetectionType parseRenameDetectionType( final String renameString) { if (renameString == null) return RenameDetectionType.FALSE; else if (StringUtils.equalsIgnoreCase( ConfigConstants.CONFIG_RENAMELIMIT_COPY, renameString) || StringUtils .equalsIgnoreCase( ConfigConstants.CONFIG_RENAMELIMIT_COPIES, renameString)) return RenameDetectionType.COPY; else { final Boolean renameBoolean = StringUtils .toBooleanOrNull(renameString); if (renameBoolean == null) throw new IllegalArgumentException(MessageFormat.format( JGitText.get().enumValueNotSupported2, ConfigConstants.CONFIG_DIFF_SECTION, ConfigConstants.CONFIG_KEY_RENAMES, renameString)); else if (renameBoolean.booleanValue()) return RenameDetectionType.TRUE; else return RenameDetectionType.FALSE; } } }
super(options); if (StringUtils.isEmptyOrNull(SystemReader.getInstance().getenv( Constants.GIT_CONFIG_NOSYSTEM_KEY))) systemConfig = SystemReader.getInstance().openSystemConfig(null, "extensions", null, "refStorage"); //$NON-NLS-1$ //$NON-NLS-2$ if (repositoryFormatVersion >= 1 && reftype != null) { if (StringUtils.equalsIgnoreCase(reftype, "reftree")) { //$NON-NLS-1$ refs = new RefTreeDatabase(this, new RefDirectory(this)); } else {
T falseState = null; for (T e : all) { if (StringUtils.equalsIgnoreCase(e.name(), n)) { return e; } else if (StringUtils.equalsIgnoreCase(e.name(), "TRUE")) { //$NON-NLS-1$ trueState = e; } else if (StringUtils.equalsIgnoreCase(e.name(), "FALSE")) { //$NON-NLS-1$ falseState = e; return StringUtils.toBoolean(n) ? trueState : falseState; } catch (IllegalArgumentException err) {
/** {@inheritDoc} */ @Override public boolean getBoolean(Config config, String section, String subsection, String name, boolean defaultValue) { String n = config.getRawString(section, subsection, name); if (n == null) { return defaultValue; } if (Config.MAGIC_EMPTY_VALUE == n) { return true; } try { return StringUtils.toBoolean(n); } catch (IllegalArgumentException err) { throw new IllegalArgumentException(MessageFormat.format( JGitText.get().invalidBooleanValue, section, name, n)); } }
/** * Parse the tag message and return the first "line" of it. * <p> * The first line is everything up to the first pair of LFs. This is the * "oneline" format, suitable for output in a single line display. * <p> * This method parses and returns the message portion of the tag buffer, * after taking the tag's character set into account and decoding the buffer * using that character set. This method is a fairly expensive operation and * produces a new string on each invocation. * * @return decoded tag message as a string. Never null. The returned string * does not contain any LFs, even if the first paragraph spanned * multiple lines. Embedded LFs are converted to spaces. */ public final String getShortMessage() { byte[] raw = buffer; int msgB = RawParseUtils.tagMessage(raw, 0); if (msgB < 0) { return ""; //$NON-NLS-1$ } int msgE = RawParseUtils.endOfParagraph(raw, msgB); String str = RawParseUtils.decode(guessEncoding(), raw, msgB, msgE); if (RevCommit.hasLF(raw, msgB, msgE)) { str = StringUtils.replaceLineBreaksWithSpace(str); } return str; }
@Override public String toString() { return StringUtils.capitalize(name().toLowerCase().replace("_", " ")); }
super(options); if (StringUtils.isEmptyOrNull(SystemReader.getInstance().getenv( Constants.GIT_CONFIG_NOSYSTEM_KEY))) systemConfig = SystemReader.getInstance().openSystemConfig(null, "extensions", null, "refsStorage"); //$NON-NLS-1$ //$NON-NLS-2$ if (repositoryFormatVersion >= 1 && reftype != null) { if (StringUtils.equalsIgnoreCase(reftype, "reftree")) { //$NON-NLS-1$ refs = new RefTreeDatabase(this, new RefDirectory(this)); } else {
T falseState = null; for (T e : all) { if (StringUtils.equalsIgnoreCase(e.name(), n)) { return e; } else if (StringUtils.equalsIgnoreCase(e.name(), "TRUE")) { //$NON-NLS-1$ trueState = e; } else if (StringUtils.equalsIgnoreCase(e.name(), "FALSE")) { //$NON-NLS-1$ falseState = e; return StringUtils.toBoolean(n) ? trueState : falseState; } catch (IllegalArgumentException err) {
private static RenameDetectionType parseRenameDetectionType( final String renameString) { if (renameString == null) return RenameDetectionType.FALSE; else if (StringUtils.equalsIgnoreCase( ConfigConstants.CONFIG_RENAMELIMIT_COPY, renameString) || StringUtils .equalsIgnoreCase( ConfigConstants.CONFIG_RENAMELIMIT_COPIES, renameString)) return RenameDetectionType.COPY; else { final Boolean renameBoolean = StringUtils .toBooleanOrNull(renameString); if (renameBoolean == null) throw new IllegalArgumentException(MessageFormat.format( JGitText.get().enumValueNotSupported2, ConfigConstants.CONFIG_DIFF_SECTION, ConfigConstants.CONFIG_KEY_RENAMES, renameString)); else if (renameBoolean.booleanValue()) return RenameDetectionType.TRUE; else return RenameDetectionType.FALSE; } } }
private AtomicFileCreation getAtomicFileCreationSupportOption( FileBasedConfig config) { try { config.load(); String value = config.getString(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_SUPPORTSATOMICFILECREATION); if (value == null) { return AtomicFileCreation.UNDEFINED; } return StringUtils.toBoolean(value) ? AtomicFileCreation.SUPPORTED : AtomicFileCreation.NOT_SUPPORTED; } catch (IOException | ConfigInvalidException e) { return AtomicFileCreation.SUPPORTED; } }
/** * Parse the commit message and return the first "line" of it. * <p> * The first line is everything up to the first pair of LFs. This is the * "oneline" format, suitable for output in a single line display. * <p> * This method parses and returns the message portion of the commit buffer, * after taking the commit's character set into account and decoding the * buffer using that character set. This method is a fairly expensive * operation and produces a new string on each invocation. * * @return decoded commit message as a string. Never null. The returned * string does not contain any LFs, even if the first paragraph * spanned multiple lines. Embedded LFs are converted to spaces. */ public final String getShortMessage() { byte[] raw = buffer; int msgB = RawParseUtils.commitMessage(raw, 0); if (msgB < 0) { return ""; //$NON-NLS-1$ } int msgE = RawParseUtils.endOfParagraph(raw, msgB); String str = RawParseUtils.decode(guessEncoding(), raw, msgB, msgE); if (hasLF(raw, msgB, msgE)) { str = StringUtils.replaceLineBreaksWithSpace(str); } return str; }
/** * Apply options to archive output stream * * @param s * stream to apply options to * @param o * options map * @return stream with option applied * @throws IOException */ protected ArchiveOutputStream applyFormatOptions(ArchiveOutputStream s, Map<String, Object> o) throws IOException { for (Map.Entry<String, Object> p : o.entrySet()) { try { new Statement(s, "set" + StringUtils.capitalize(p.getKey()), //$NON-NLS-1$ new Object[] { p.getValue() }).execute(); } catch (Exception e) { throw new IOException(MessageFormat.format( ArchiveText.get().cannotSetOption, p.getKey()), e); } } return s; } }
public FormValidation doCheckUrl(@QueryParameter String value) { if (StringUtils.isEmptyOrNull(value)) { return FormValidation.error(Messages.url_required()); } else { return FormValidation.ok(); } }
return null; if (equalsIgnoreCase("yes", stringValue) //$NON-NLS-1$ || equalsIgnoreCase("true", stringValue) //$NON-NLS-1$ || equalsIgnoreCase("1", stringValue) //$NON-NLS-1$ || equalsIgnoreCase("on", stringValue)) //$NON-NLS-1$ return Boolean.TRUE; else if (equalsIgnoreCase("no", stringValue) //$NON-NLS-1$ || equalsIgnoreCase("false", stringValue) //$NON-NLS-1$ || equalsIgnoreCase("0", stringValue) //$NON-NLS-1$ || equalsIgnoreCase("off", stringValue)) //$NON-NLS-1$ return Boolean.FALSE; else
private static String joinNames(List<String> names, String singular, String plural) { if (names.size() == 1) return singular + " " + names.get(0); //$NON-NLS-1$ else return plural + " " + StringUtils.join(names, ", ", " and "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
T falseState = null; for (T e : all) { if (StringUtils.equalsIgnoreCase(e.name(), n)) return e; else if (StringUtils.equalsIgnoreCase(e.name(), "TRUE")) //$NON-NLS-1$ trueState = e; else if (StringUtils.equalsIgnoreCase(e.name(), "FALSE")) //$NON-NLS-1$ falseState = e; return StringUtils.toBoolean(n) ? trueState : falseState; } catch (IllegalArgumentException err) {
private static RenameDetectionType parseRenameDetectionType( final String renameString) { if (renameString == null) return RenameDetectionType.FALSE; else if (StringUtils.equalsIgnoreCase( ConfigConstants.CONFIG_RENAMELIMIT_COPY, renameString) || StringUtils .equalsIgnoreCase( ConfigConstants.CONFIG_RENAMELIMIT_COPIES, renameString)) return RenameDetectionType.COPY; else { final Boolean renameBoolean = StringUtils .toBooleanOrNull(renameString); if (renameBoolean == null) throw new IllegalArgumentException(MessageFormat.format( JGitText.get().enumValueNotSupported2, ConfigConstants.CONFIG_DIFF_SECTION, ConfigConstants.CONFIG_KEY_RENAMES, renameString)); else if (renameBoolean.booleanValue()) return RenameDetectionType.TRUE; else return RenameDetectionType.FALSE; } } }