code
stringlengths
73
34.1k
label
stringclasses
1 value
private static int[] string2Ints(String st, int target_length) { int[] numbers = new int[target_length]; int st_len = st.length(); char ch; for (int i = 0; i < st_len; i++) { ch = st.charAt(i); numbers[target_length - st_len + i] = ch - '0'; } re...
java
public static BigDecimal string2BigDecimal(String st) { BigDecimal result = new BigDecimal(st); result.setScale(2, BigDecimal.ROUND_HALF_EVEN); return result; }
java
static CloudResourceBundle loadBundle(ServiceAccount serviceAccount, String bundleId, Locale locale) { CloudResourceBundle crb = null; ServiceClient client = ServiceClient.getInstance(serviceAccount); try { Map<String, String> resStrings = client.getResourceStrings(bundleId, locale.t...
java
public void checkDirectivesForKeyword(DirectiveParser directiveParser, KeyWord keyWord) throws ParseException { checkNoStepDirectiveBeforeKeyword(directiveParser, keyWord); checkForInvalidKeywordDirective(directiveParser, keyWord); }
java
public void checkForUnprocessedDirectives() throws ParseException { List<LineNumberAndDirective> remaining = new LinkedList<>(); remaining.addAll(bufferedKeyWordDirectives); remaining.addAll(bufferedStepDirectives); if (!remaining.isEmpty()) { LineNumberAndDirective exampleEr...
java
public ChorusHandlerJmxExporter export() { if (Boolean.getBoolean(JMX_EXPORTER_ENABLED_PROPERTY)) { //export this object as an MBean if (exported.getAndSet(true) == false) { try { log.info(String.format("Exporting ChorusHandlerJmxExporter with jmx name...
java
protected MultipleSyntaxElements createAndAppendNewChildContainer(Node ref, Document document) { MultipleSyntaxElements ret = null; if (((Element) ref).getAttribute("minnum").equals("0")) { log.trace("will not create container " + getPath() + " -> " + ((Element) ref).getAttribute("type") + ...
java
private String[] getRefSegId(Node segref, Document document) { String segname = ((Element) segref).getAttribute("type"); // versuch, daten aus dem cache zu lesen String[] ret = new String[]{"", ""}; // segid noch nicht im cache Element segdef = document.getElementById(segname);...
java
public static <T extends Enum<T>> Pattern createValidationPatternFromEnumType(Class<T> enumType) { String regEx = Stream.of(enumType.getEnumConstants()) .map(Enum::name) .collect(Collectors.joining("|", "(?i)", "")); //Enum constants may contain $ which needs to be esca...
java
private AccountReport22 createDay(BTag tag) throws Exception { AccountReport22 report = new AccountReport22(); if (tag != null) { report.getBal().add(this.createSaldo(tag.start, true)); report.getBal().add(this.createSaldo(tag.end, false)); } if (tag != null && ...
java
private CashBalance8 createSaldo(Saldo saldo, boolean start) throws Exception { CashBalance8 bal = new CashBalance8(); BalanceType13 bt = new BalanceType13(); bt.setCdOrPrtry(new BalanceType10Choice()); bt.getCdOrPrtry().setCd(start ? "PRCD" : "CLBD"); bal.setTp(bt); Ac...
java
private XMLGregorianCalendar createCalendar(Long timestamp) throws Exception { DatatypeFactory df = DatatypeFactory.newInstance(); GregorianCalendar cal = new GregorianCalendar(); cal.setTimeInMillis(timestamp != null ? timestamp.longValue() : System.currentTimeMillis()); return df.newXM...
java
@Step(".*wait (?:for )?([0-9]*) seconds?.*") @Documentation(order = 10, description = "Wait for a number of seconds", example = "And I wait for 6 seconds") public void waitForSeconds(int seconds) { try { Thread.sleep(seconds * 1000); } catch (InterruptedException e) { log...
java
public static XMLGregorianCalendar createCalendar(String isoDate) throws Exception { if (isoDate == null) { SimpleDateFormat format = new SimpleDateFormat(DATETIME_FORMAT); isoDate = format.format(new Date()); } DatatypeFactory df = DatatypeFactory.newInstance(); ...
java
public static String format(XMLGregorianCalendar cal, String format) { if (cal == null) return null; if (format == null) format = DATE_FORMAT; SimpleDateFormat df = new SimpleDateFormat(format); return df.format(cal.toGregorianCalendar().getTime()); }
java
public static Date toDate(XMLGregorianCalendar cal) { if (cal == null) return null; return cal.toGregorianCalendar().getTime(); }
java
public static Integer maxIndex(HashMap<String, String> properties) { Integer max = null; for (String key : properties.keySet()) { Matcher m = INDEX_PATTERN.matcher(key); if (m.matches()) { int index = Integer.parseInt(m.group(1)); if (max == null |...
java
public static String insertIndex(String key, Integer index) { if (index == null) return key; int pos = key.indexOf('.'); if (pos >= 0) { return key.substring(0, pos) + '[' + index + ']' + key.substring(pos); } else { return key + '[' + index + ']'; ...
java
public static Value sumBtgValueObject(HashMap<String, String> properties) { Integer maxIndex = maxIndex(properties); BigDecimal btg = sumBtgValue(properties, maxIndex); String curr = properties.get(insertIndex("btg.curr", maxIndex == null ? null : 0)); return new Value(btg, curr); }
java
public static String getProperty(HashMap<String, String> props, String name, String defaultValue) { String value = props.get(name); return value != null && value.length() > 0 ? value : defaultValue; }
java
protected PrintWriter getPrintWriter() { if ( printWriter == null || printStream != ChorusOut.out) { printWriter = new PrintWriter(ChorusOut.out); printStream = ChorusOut.out; } return printWriter; }
java
public Object invoke(final String stepTokenId, final List<String> args) { final AtomicReference resultRef = new AtomicReference(); PolledAssertion p = new PolledAssertion() { protected void validate() throws Exception { Object r = wrappedInvoker.invoke(stepTokenId, args); ...
java
private String waitForPattern(long timeout, TailLogBufferedReader bufferedReader, Pattern pattern, boolean searchWithinLines, long timeoutInSeconds) throws IOException { StringBuilder sb = new StringBuilder(); String result; label: while(true) { while ( bufferedReader.ready()...
java
static BankInfo parse(String text) { BankInfo info = new BankInfo(); if (text == null || text.length() == 0) return info; String[] cols = text.split("\\|"); info.setName(getValue(cols, 0)); info.setLocation(getValue(cols, 1)); info.setBic(getValue(cols, 2)); ...
java
private static String getValue(String[] cols, int idx) { if (cols == null || idx >= cols.length) return null; return cols[idx]; }
java
public GroupedPropertyLoader splitKeyAndGroup(final String keyDelimiter) { return group(new BiFunction<String, String, Tuple3<String, String, String>>() { public Tuple3<String, String, String> apply(String key, String value) { String[] keyTokens = key.split(keyDelimiter, 2); ...
java
@Override public void execute() throws BuildException { Java javaTask = (Java) getProject().createTask("java"); javaTask.setTaskName(getTaskName()); javaTask.setClassname("org.chorusbdd.chorus.Main"); javaTask.setClasspath(classpath); //if log4j config is set then pass this ...
java
public void addConfiguredFileset(FileSet fs) { File dir = fs.getDir(); DirectoryScanner ds = fs.getDirectoryScanner(); String[] fileNames = ds.getIncludedFiles(); for (String fileName : fileNames) { featureFiles.add(new File(dir, fileName)); } }
java
protected void marshal(JAXBElement e, OutputStream os, boolean validate) throws Exception { JAXBContext jaxbContext = JAXBContext.newInstance(e.getDeclaredType()); Marshaller marshaller = jaxbContext.createMarshaller(); // Wir verwenden hier hart UTF-8. Siehe http://www.onlinebanking-forum.de/f...
java
public static QRCode tryParse(String hhd, String msg) { try { return new QRCode(hhd, msg); } catch (Exception e) { return null; } }
java
private String decode(byte[] bytes) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < bytes.length; ++i) { sb.append(Integer.toString(bytes[i], 10)); } return sb.toString(); }
java
public Map<String, Object> getServiceCredentials() { if (serviceCredentials == null) { return null; } return Collections.unmodifiableMap(serviceCredentials); }
java
public Properties loadPropertiesForSubGroup(ConfigurationManager configurationManager, String handlerPrefix, String groupName) { PropertyOperations handlerProps = properties(loadProperties(configurationManager, handlerPrefix)); PropertyOperations defaultProps = handlerProps.filterByAndRemoveKeyPrefix(C...
java
private String replaceVariablesWithPatterns(String pattern) { int group = 0; Matcher findVariablesMatcher = variablePattern.matcher(pattern); while(findVariablesMatcher.find()) { String variable = findVariablesMatcher.group(0); pattern = pattern.replaceFirst(variable, "(....
java
public boolean processStep(StepToken scenarioStep, List<StepMacro> macros, boolean alreadymatched) { boolean stepMacroMatched = doProcessStep(scenarioStep, macros, 0, alreadymatched); return stepMacroMatched; }
java
private String replaceVariablesInMacroStep(Matcher macroMatcher, String action) { for (Map.Entry<String, Integer> e : variableToGroupNumber.entrySet()) { action = action.replace(e.getKey(), "<$" + e.getValue() + ">"); } return action; }
java
private String replaceGroupsInMacroStep(Matcher macroMatcher, String action) { Matcher groupMatcher = groupPattern.matcher(action); while(groupMatcher.find()) { String match = groupMatcher.group(); String groupString = match.substring(2, match.length() - 1); int group...
java
public static StepEndState calculateStepMacroEndState(List<StepToken> executedSteps) { StepEndState stepMacroEndState = StepEndState.PASSED; for ( StepToken s : executedSteps) { if ( s.getEndState() != StepEndState.PASSED) { stepMacroEndState = s.getEndState(); ...
java
private boolean isBooleanSwitchProperty(ExecutionProperty property) { return property.hasDefaults() && property.getDefaults().length == 1 && property.getDefaults()[0].equals("false"); }
java
public static boolean alg_24(int[] blz, int[] number) { int[] weights = {1, 2, 3, 1, 2, 3, 1, 2, 3}; int crc = 0; int idx = 0; switch (number[0]) { case 3: case 4: case 5: case 6: number[0] = 0; break; ...
java
private List<HashMap<String, String>> createSegmentListFromMessage(String msg) { List<HashMap<String, String>> segmentList = new ArrayList<HashMap<String, String>>(); boolean quoteNext = false; int startPosi = 0; for (int i = 0; i < msg.length(); i++) { char ch = msg.charAt...
java
private static Gson createGson(String className) { GsonBuilder builder = new GsonBuilder(); // ISO8601 date format support builder.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX"); builder.registerTypeAdapter(TranslationStatus.class, new EnumWithFallbackAdapter<TranslationSt...
java
public void writeToStdIn(String text, boolean newLine) { if ( outputStream == null) { outputStream = new BufferedOutputStream(process.getOutputStream()); outputWriter = new BufferedWriter(new OutputStreamWriter(outputStream)); } try { outputWriter.write(text)...
java
private void suppressLog4jLogging() { if ( ! log4jLoggingSuppressed.getAndSet(true) ) { Logger logger = Logger.getLogger("org.apache.http"); logger.setLevel(Level.ERROR); logger.addAppender(new ConsoleAppender()); } }
java
private void suppressSeleniumJavaUtilLogging() { if ( ! seleniumLoggingSuppressed.getAndSet(true) ) { try { // Log4j logging is annoyingly difficult to turn off, it usually requires a config file but we can also do it with an InputStream Properties properties = new Pr...
java
public void setSuiteIdsUsingZeroBasedIndex() { synchronized (cachedSuites) { List<WebAgentTestSuite> s = new ArrayList<>(cachedSuites.values()); cachedSuites.clear(); for ( int index=0; index < s.size(); index++) { WebAgentTestSuite suite = s.get(index); ...
java
public void setSegVersion(int version) { if (version < 1) { log.warn("tried to change segment version for task " + this.jobName + " explicit, but no version given"); return; } // Wenn sich die Versionsnummer nicht geaendert hat, muessen wir die // Huehner ja nich...
java
public Konto getOrderAccount() { // Checken, ob wir das Konto unter "My.[number/iban]" haben String prefix = this.getName() + ".My."; String number = this.getLowlevelParam(prefix + "number"); String iban = this.getLowlevelParam(prefix + "iban"); if ((number == null || number.leng...
java
void put(HashMap<String, String> props, Names name, String value) { // BUGZILLA 1610 - "java.util.Properties" ist von Hashtable abgeleitet und unterstuetzt keine NULL-Werte if (value == null) return; props.put(name.getValue(), value); }
java
public DocumentTranslationRequestDataChangeSet setTargetLanguagesMap( Map<String, Map<String, Set<String>>> targetLanguagesMap) { // TODO - check empty map? if (targetLanguagesMap == null) { throw new NullPointerException("The input map is null."); } this.targetLa...
java
public EndState getEndState() { EndState result = EndState.PASSED; for ( ScenarioToken s : scenarios) { if ( s.getEndState() == EndState.FAILED) { result = EndState.FAILED; break; } } if ( result != EndState.FAILED) { f...
java
@Override public boolean propagateValue(String destPath, String valueString, boolean tryToCreate, boolean allowOverwrite) { boolean ret = false; // wenn dieses de gemeint ist if (destPath.equals(getPath())) { if (this.value != null) { // es gibt schon einen Wert ...
java
private void parseValue(StringBuffer res, HashMap<String, String> predefs, char preDelim, HashMap<String, String> valids) { int len = res.length(); if (preDelim != (char) 0 && res.charAt(0) != preDelim) { if (len == 0) { throw new ParseErrorExcept...
java
static ObjectMapper getMapper() { ObjectMapper mapper = new ObjectMapper(); // do not write null values mapper.setSerializationInclusion(Include.NON_NULL); mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); mapper.setVisibility(PropertyAccessor.FIELD, J...
java
public Map<String, Set<String>> getTargetLanguagesByBundle() { if (targetLanguagesByBundle == null) { assert false; return Collections.emptyMap(); } return Collections.unmodifiableMap(targetLanguagesByBundle); }
java
private void setMsgSizeValue(int value, boolean allowOverwrite) { String absPath = getPath() + ".MsgHead.msgsize"; SyntaxElement msgsizeElem = getElement(absPath); if (msgsizeElem == null) throw new NoSuchPathException(absPath); int size = ((DE) msgsizeElem).getMinSize(); ...
java
static String[] getClasspathFileNames() throws IOException { //for performance we most likely only want to do this once for each interpreter session, //classpath should not change dynamically ChorusLog log = ChorusLogFactory.getLog(ClasspathScanner.class); log.debug("Getting file names "...
java
static TokenLifeCycleManager getInstance(final String iamEndpoint, final String apiKey) { if (iamEndpoint == null || iamEndpoint.isEmpty()) { throw new IllegalArgumentException( "Cannot initialize with null or empty IAM endpoint."); } if (apiKey == nul...
java
static TokenLifeCycleManager getInstance(final String jsonCredentials) { final JsonObject credentials = new JsonParser().parse(jsonCredentials) .getAsJsonObject(); if(credentials.get("apikey")==null || credentials.get("apikey").isJsonNull()||credentials.get("apikey").getAsString().isEmpt...
java
private static BigInteger adjustJ(BigInteger J, BigInteger modulus) { byte[] ba = J.toByteArray(); int last = ba[ba.length - 1]; if ((last & 0x0F) == 0x0C) { return J; } BigInteger twelve = new BigInteger("12"); byte[] modulus2 = modulus.subtract(twelve).toB...
java
public static List<String> getNames(String nameList) { String[] names = nameList.split(","); List<String> results = new LinkedList<>(); for ( String p : names) { String configName = p.trim(); if ( configName.length() > 0) { results.add(configName); ...
java
public void applyParams(AbstractHBCIJob task, AbstractHBCIJob hktan, HBCITwoStepMechanism hbciTwoStepMechanism) { String code = task.getHBCICode(); // Code des Geschaeftsvorfalls // Job-Parameter holen Job job = this.getData(code); // Den Geschaeftsvorfall kennen wir nicht. Dann brauch...
java
private Optional<String> findClientIdForWebSocket(WebSocket conn) { return clientIdToSocket.entrySet().stream() .filter(e -> e.getValue() == conn) .map(Map.Entry::getKey) .findFirst(); }
java
private void mergeProperties(Map<ExecutionConfigSource, Map<ExecutionProperty, List<String>>> sourceToPropertiesMap) { for ( ExecutionConfigSource s : propertySources) { Map<ExecutionProperty, List<String>> properties = sourceToPropertiesMap.get(s); for ( ExecutionProperty p : properties...
java
public boolean isTrue(ExecutionProperty property) { return isSet(property) && propertyMap.get(property).size() == 1 && "true".equalsIgnoreCase(propertyMap.get(property).get(0)); }
java
@Initialize(scope = Scope.SCENARIO) public void initializeContextVariables() { Properties p = new HandlerConfigLoader().loadProperties(configurationManager, "context"); for ( Map.Entry e : p.entrySet()) { ChorusContext.getContext().put(e.getKey().toString(), e.getValue().toString()); ...
java
void updateBPD(HashMap<String, String> result) { log.debug("extracting BPD from results"); HashMap<String, String> newBPD = new HashMap<>(); result.keySet().forEach(key -> { if (key.startsWith("BPD.")) { newBPD.put(key.substring(("BPD.").length()), result.get(key)); ...
java
void extractKeys(HashMap<String, String> result) { boolean foundChanges = false; try { log.debug("extracting public institute keys from results"); for (int i = 0; i < 3; i++) { String head = HBCIUtils.withCounter("SendPubKey", i); String keyType ...
java
private boolean isBPDExpired() { Map<String, String> bpd = passport.getBPD(); log.info("[BPD] max age: " + maxAge + " days"); long maxMillis = -1L; try { int days = Integer.parseInt(maxAge); if (days == 0) { log.info("[BPD] auto-expiry disabled");...
java
void fetchBPDAnonymous() { // BPD abholen, wenn nicht vorhanden oder HBCI-Version geaendert Map<String, String> bpd = passport.getBPD(); String hbciVersionOfBPD = (bpd != null) ? bpd.get(BPD_KEY_HBCIVERSION) : null; final String version = passport.getBPDVersion(); if (version.eq...
java
private List<FeatureToken> getFeaturesWithConfigurations(List<String> configurationNames, FeatureToken parsedFeature) { List<FeatureToken> results = new ArrayList<>(); if (parsedFeature != null) { if (configurationNames == null) { results.add(parsedFeature); } els...
java
private List<String> extractTagsAndResetLastTagsLineField() { String tags = lastTagsLine; List<String> result = extractTags(tags); resetLastTagsLine(); return result; }
java
public TranslationRequestDataChangeSet setTargetLanguagesByBundle( Map<String, Set<String>> targetLanguagesByBundle) { // TODO - check empty map? if (targetLanguagesByBundle == null) { throw new NullPointerException("The input map is null."); } this.targetLanguage...
java
private void addFeaturesRecursively(File directory, List<File> targetList, FileFilter fileFilter) { File[] files = directory.listFiles(); //sort the files here, since otherwise we get differences in execution order between 'nix, case sensitive //and win, case insensitive, toys 'r us Arr...
java
public int await(TimeUnit unit, long length) { int pollPeriodMillis = getPollPeriodMillis(); long startTime = System.currentTimeMillis(); long expireTime = startTime + unit.toMillis(length); int iteration = 0; boolean success = false; while(true) { i...
java
public int check(TimeUnit timeUnit, long count) { int pollPeriodMillis = getPollPeriodMillis(); long startTime = System.currentTimeMillis(); long expireTime = startTime + timeUnit.toMillis(count); int iteration = 0; while(true) { iteration++; try ...
java
private void propagateAsError(Throwable t) { if ( t instanceof InvocationTargetException) { t = t.getCause(); } if ( Error.class.isAssignableFrom(t.getClass())) { throw (Error)t; } throw new PolledAssertionError(t); }
java
public static Object stripDeep(Object decorated) { Object stripped = stripShallow(decorated); if (stripped == decorated) { return stripped; } else { return stripDeep(stripped); } }
java
public static <T> void writeObject(final T entity, final Object destination, final String comment) { try { JAXBContext jaxbContext; if (entity instanceof JAXBElement) { jaxbContext = JAXBContext.newInstance(((JAXBElement) entity).getValue().getClass()); } else...
java
public static <T> String writeObjectToString(final T entity) { ByteArrayOutputStream destination = new ByteArrayOutputStream(); writeObject(entity, destination, null); return destination.toString(); }
java
public static String generateRegId(final String domainCreationDate, final String reverseDomainName) { return generateRegId(domainCreationDate, reverseDomainName, null); }
java
public static String generateRegId(final String domainCreationDate, final String reverseDomainName, final String suffix) { if (StringUtils.isBlank(domainCreationDate)) { throw new SwidException("domainCreationDate isn't defined"); } if (StringUtils.isBlank(reverseDomainNa...
java
public void setGenerator(final IdGenerator generator) { if (generator != null) { this.idGenerator = generator; swidTag.setId(idGenerator.nextId()); } }
java
public void validate() { if (swidTag.getEntitlementRequiredIndicator() == null) { throw new SwidException("'entitlement_required_indicator' is not set"); } if (swidTag.getProductTitle() == null) { throw new SwidException("'product_title' is not set"); } if...
java
public void write(final SoftwareIdentificationTagComplexType swidTag, final java.io.OutputStream output) { JAXBUtils.writeObject(objectFactory.createSoftwareIdentificationTag(swidTag), output, getComment()); }
java
public void write(final SoftwareIdentificationTagComplexType swidTag, final File file) { JAXBUtils.writeObject(objectFactory.createSoftwareIdentificationTag(swidTag), file, getComment()); }
java
public void write(final SoftwareIdentificationTagComplexType swidTag, final java.io.Writer writer) { JAXBUtils.writeObject(objectFactory.createSoftwareIdentificationTag(swidTag), writer, getComment()); }
java
public static URLConnection post(String url, String encodedCredentials, String jsonPayloadObject, Charset charset, ProxyConfig proxy, TrustStoreConfig customTrustStore, ConnectionSettings connectionSettings) throws Exception { if (url == null || encodedCredentials == null |...
java
private void submitPayload(String url, HttpRequestUtil.ConnectionSettings connectionSettings, String jsonPayloadObject, String pushApplicationId, String masterSecret, MessageResponseCallback callback, List<String> redirectUrls) { if (redirectUrls.contains(url)) { throw...
java
public void prePersist() { this.createdAt = getCurrentTime(); if (this.createdBy == null || this.createdBy.trim().length()<1) { this.createdBy = getUserName(); } }
java
private static String concatOverrides(String annotation, Collection<String> attributeOverrides) { if (attributeOverrides == null || attributeOverrides.size() < 1) { return annotation; } if (annotation == null) { annotation = ""; } else { Matche...
java
public static void schemaExportPerform (String[] sqlCommands, List exporters, SchemaExport schemaExport) { if (schemaExportPerform == null) { try { schemaExportPerform = SchemaExport.class.getMethod("performApi", String[].class, List.class, String.class); } catch (NoSuchM...
java
@Override public void run() { stopped = false; try { try { serverSocket = new ServerSocket(port); serverSocket.setSoTimeout(TIMEOUT); // Block for maximum of 1.5 seconds } finally { // Notify when server socket has been created startupBarrier.countDown(); } // Server: loop until stoppe...
java
public synchronized void stop() { // Mark us closed stopped = true; try { // Kick the server accept loop serverSocket.close(); // acquire all semaphores so that we wait for all connections to finish before we report back as closed semaphore.acquireUninterruptibly(MAXIMUM_CONCURRENT_READERS); } catc...
java
private List<SmtpMessage> handleTransaction(PrintWriter out, BufferedReader input) throws IOException { // Initialize the state machine SmtpState smtpState = SmtpState.CONNECT; SmtpRequest smtpRequest = new SmtpRequest(SmtpActionType.CONNECT, "", smtpState); // Execute the connection request SmtpResponse smt...
java
private static void sendResponse(PrintWriter out, SmtpResponse smtpResponse) { if (smtpResponse.getCode() > 0) { int code = smtpResponse.getCode(); String message = smtpResponse.getMessage(); out.print(code + " " + message + "\r\n"); out.flush(); } }
java
public static SafeCloseSmtpServer start(int port) { SafeCloseSmtpServer server = new SafeCloseSmtpServer(port); Thread t = new Thread(server, "Mock SMTP Server Thread"); t.start(); // Block until the server socket is created try { server.startupBarrier.await(); } catch (InterruptedException e) { log....
java
public static Integer findFree(int lowIncluse, int highInclusive) { int low = Math.max(1, Math.min(lowIncluse, highInclusive)); int high = Math.min(65535, Math.max(lowIncluse, highInclusive)); Integer result = null; int split = RandomUtils.nextInt(low, high + 1); for (int port = split; port <= high; port++) {...
java
public static void addDefaultHeader(String key, String value) { if (isNotBlank(key) && isNotBlank(value)) { if (defaultHeader == null) { defaultHeader = new HashMap<String, String>(); } defaultHeader.put(key, value); } }
java
public static HttpBuilder request(String protocol, String host, Integer port, String path) { return defaults(createClient().request(protocol, host, port, path)); }
java