/** * @param text * to have the first line removed * @return less first line */ public static String removeFirstLine(String text) { return text.replaceFirst(".*?\n", ""); }
static String trimVersion(String version) { // TODO seems like there should be some trick with VersionNumber to do this return version.replaceFirst(" .+$", ""); }
@Override public String getIconFilePathPattern() { return (Jenkins.RESOURCE_PATH + "/images/:size/freestyleproject.png").replaceFirst("^/", ""); }
/** * @param text to have the first line removed * @return less first line */ public String of(String text) { return text.replaceFirst(".*?\n", ""); } }
String[] in = { "01234", // "[1234]" "0001234a", // "[1234a]" "101234", // "[101234]" "000002829839", // "[2829839]" "0", // "[0]" "0000000", // "[0]" "0000009", // "[9]" "000000z", // "[z]" "000000.z", // "[.z]" }; for (String s : in) { System.out.println("[" + s.replaceFirst("^0+(?!$)", "") + "]"); }
@Override public String next() { String value = internalIterator.next(); return value.replaceFirst(prefixRegex, ""); } };
/** * @param target something like {@code http://jenkins/cli?remoting=true} * which we then need to split into {@code http://jenkins/} + {@code cli?remoting=true} * in order to construct a crumb issuer request * @deprecated use {@link #FullDuplexHttpStream(URL, String, String)} instead */ @Deprecated public FullDuplexHttpStream(URL target, String authorization) throws IOException { this(new URL(target.toString().replaceFirst("/cli.*$", "/")), target.toString().replaceFirst("^.+/(cli.*)$", "$1"), authorization); }
private static String format(String from, Object... arguments) { if (from != null) { String computed = from; if (arguments != null && arguments.length != 0) { for (Object argument : arguments) { computed = computed.replaceFirst("\\{\\}", Matcher.quoteReplacement(argument.toString())); } } return computed; } return null; }
/** * The format is '{group}/{interfaceName/path}*{version}' * * @return */ public String getEncodedServiceKey() { String serviceKey = this.getServiceKey(); serviceKey = serviceKey.replaceFirst("/", "*"); return serviceKey; }
/** * The format is '{group}/{interfaceName/path}*{version}' * * @return */ public String getEncodedServiceKey() { String serviceKey = this.getServiceKey(); serviceKey = serviceKey.replaceFirst("/", "*"); return serviceKey; }
/** Normalize all number tokens to <num> in order to allow * for proper scoring of MSTParser productions. */ static protected String normalizeNumbers(String token) { String norm = token.replaceFirst("^([0-9]+)-([0-9]+)$", "<num>-$2"); if (!norm.equals(token)) { System.err.printf("Normalized numbers in token: %s => %s\n", token, norm); } return token; }
private static List<String[]> makeSVMLightLineInfos(List<String> lines) { List<String[]> lineInfos = new ArrayList<>(lines.size()); for (String line : lines) { line = line.replaceFirst("#.*$", ""); // remove any trailing comments // in principle, it'd be nice to save the comment, though, for possible use as a displayedColumn - make it column 1?? lineInfos.add(line.split("\\s+")); } return lineInfos; }
private static ClassReader getClassReader(Class<?> cls) { String className = cls.getName().replaceFirst("^.*\\.", "") + ".class"; try { return new ClassReader(cls.getResourceAsStream(className)); } catch (IOException e) { throw new RuntimeException("Could not create ClassReader: " + e.getMessage(), e); } }
private Method getGetterFromSetter(Method setter) { String getterName = setter.getName().replaceFirst("set", "get"); try { return setter.getDeclaringClass().getMethod(getterName); } catch (NoSuchMethodException ex) { // must be write only return null; } }
private static String fixTpchQuery(String s) { s = s.replaceFirst("(?m);$", ""); s = s.replaceAll("(?m)^:[xo]$", ""); s = s.replaceAll("(?m)^:n -1$", ""); s = s.replaceAll("(?m)^:n ([0-9]+)$", "LIMIT $1"); s = s.replace("day (3)", "day"); // for query 1 return s; } }
public boolean isForNewerHudson() { try { return requiredCore!=null && new VersionNumber(requiredCore).isNewerThan( new VersionNumber(Jenkins.VERSION.replaceFirst("SHOT *\\(private.*\\)", "SHOT"))); } catch (NumberFormatException nfe) { return true; // If unable to parse version } }
@Override public String toString() { StringBuilder stringBuilder = new StringBuilder(Modifier.toString(getModifiers())); if (getModifiers() != EMPTY_MASK) { stringBuilder.append(' '); } stringBuilder.append(isVarArgs() ? getType().asErasure().getName().replaceFirst("\\[\\]$", "...") : getType().asErasure().getName()); return stringBuilder.append(' ').append(getName()).toString(); } }
private void newArrayC () { p("public Object newArray (Type t, int size) {"); p(" if (t != null) {"); SwitchedCodeBlock pc = new SwitchedCodeBlock("t.id"); for (JType type : types) { if (type.getQualifiedSourceName().equals("void")) continue; if (type.getQualifiedSourceName().endsWith("Void")) continue; String arrayType = type.getErasedType().getQualifiedSourceName() + "[size]"; if (arrayType.contains("[]")) { arrayType = type.getErasedType().getQualifiedSourceName(); arrayType = arrayType.replaceFirst("\\[\\]", "[size]") + "[]"; } pc.add(typeNames2typeIds.get(type.getQualifiedSourceName()), "return new " + arrayType + ";"); } pc.print(); p(" }"); p(" throw new RuntimeException(\"Couldn't create array\");"); p("}"); }
private void newArrayC () { p("public Object newArray (Type t, int size) {"); p(" if (t != null) {"); SwitchedCodeBlock pc = new SwitchedCodeBlock("t.id"); for (JType type : types) { if (type.getQualifiedSourceName().equals("void")) continue; if (type.getQualifiedSourceName().endsWith("Void")) continue; String arrayType = type.getErasedType().getQualifiedSourceName() + "[size]"; if (arrayType.contains("[]")) { arrayType = type.getErasedType().getQualifiedSourceName(); arrayType = arrayType.replaceFirst("\\[\\]", "[size]") + "[]"; } pc.add(typeNames2typeIds.get(type.getQualifiedSourceName()), "return new " + arrayType + ";"); } pc.print(); p(" }"); p(" throw new RuntimeException(\"Couldn't create array\");"); p("}"); }
@Override public void call(EncoderWrapper encodingCodec, DecoderWrapper decodingCodec) throws IOException { String encodedString = encodingCodec.encode(instanceInfo); // convert the field from the json string to what the legacy json would encode as encodedString = encodedString.replaceFirst("lastRenewalTimestamp", "renewalTimestamp"); InstanceInfo decodedValue = decodingCodec.decode(encodedString, InstanceInfo.class); assertThat(EurekaEntityComparators.equal(instanceInfo, decodedValue, new EurekaEntityComparators.RawIdEqualFunc()), is(true)); assertThat(EurekaEntityComparators.equal(instanceInfo, decodedValue), is(true)); } };