code
stringlengths
73
34.1k
label
stringclasses
1 value
public static sdx_network_config get(nitro_service client) throws Exception { sdx_network_config resource = new sdx_network_config(); resource.validate("get"); return ((sdx_network_config[]) resource.get_resources(client))[0]; }
java
protected HashSet<String> getVulnerabilities(int recordId) throws SQLException { HashSet<String> cves = new HashSet<String>(); Connection connection = getConnection(); try { PreparedStatement ps = setObjects(connection, Query.FIND_CVES, recordId); ...
java
protected HashSet<Integer> getEmbeddedRecords(Set<String> hashes) throws SQLException { HashSet<Integer> results = new HashSet<Integer>(); Connection connection = getConnection(); PreparedStatement ps = setObjects(connection, Query.FILEHASH_EMBEDDED_MATCH, (Object) ha...
java
public synchronized void connect() { if (state != State.NONE) { eventHandler.onError(new WebSocketException("connect() already called")); close(); return; } getIntializer().setName(getInnerThread(), THREAD_BASE_NAME + "Reader-" + clientId); stat...
java
public synchronized void close() { switch (state) { case NONE: state = State.DISCONNECTED; return; case CONNECTING: // don't wait for an established connection, just close the tcp socket closeSocket(); ...
java
public void blockClose() throws InterruptedException { // If the thread is new, it will never run, since we closed the connection before we actually connected if (writer.getInnerThread().getState() != Thread.State.NEW) { writer.getInnerThread().join(); } getInnerThread()...
java
public static ns_image[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { ns_image obj = new ns_image(); options option = new options(); option.set_filter(filter); ns_image[] response = (ns_image[]) obj.getfiltered(service, option); return response; }
java
public static xen_health_resource[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { xen_health_resource obj = new xen_health_resource(); options option = new options(); option.set_filter(filter); xen_health_resource[] response = (xen_health_resource[]) obj.getfiltered(service,...
java
protected <T> T convert(final String value, final Class<T> type) { Assert.notNull(type, "The Class type to convert the String value to cannot be null!"); if (getConversionService().canConvert(String.class, type)) { return getConversionService().convert(value, type); } throw new ConversionExcepti...
java
protected String defaultIfUnset(final String value, final String defaultValue) { return (StringUtils.hasText(value) ? value : defaultValue); }
java
public boolean isPresent(final String propertyName) { for (String configurationPropertyName : this) { if (configurationPropertyName.equals(propertyName)) { return true; } } return false; }
java
public String getPropertyValue(final String propertyName, final boolean required) { String propertyValue = doGetPropertyValue(propertyName); if (StringUtils.isBlank(propertyValue) && getParent() != null) { propertyValue = getParent().getPropertyValue(propertyName, required); } if (StringUtils.is...
java
public String getPropertyValue(final String propertyName, final String defaultPropertyValue) { return defaultIfUnset(getPropertyValue(propertyName, NOT_REQUIRED), defaultPropertyValue); }
java
public <T> T getPropertyValueAs(final String propertyName, final Class<T> type) { return convert(getPropertyValue(propertyName, DEFAULT_REQUIRED), type); }
java
public <T> T getPropertyValueAs(final String propertyName, final boolean required, final Class<T> type) { try { return convert(getPropertyValue(propertyName, required), type); } catch (ConversionException e) { if (required) { throw new ConfigurationException(String.format( "Fai...
java
@SuppressWarnings("unchecked") public <T> T getPropertyValueAs(final String propertyName, final T defaultPropertyValue, final Class<T> type) { try { return ObjectUtils.defaultIfNull(convert(getPropertyValue(propertyName, NOT_REQUIRED), type), defaultPropertyValue); } catch (ConversionExcepti...
java
@SuppressWarnings("unchecked") public static <T extends Sorter> T createSorter(final SortType type) { switch (ObjectUtils.defaultIfNull(type, SortType.UNKONWN)) { case BUBBLE_SORT: return (T) new BubbleSort(); case COMB_SORT: return (T) new CombSort(); case HEAP_SORT: ret...
java
public static <T extends Sorter> T createSorterElseDefault(final SortType type, final T defaultSorter) { try { return createSorter(type); } catch (IllegalArgumentException ignore) { return defaultSorter; } }
java
@Override public void start() { super.start(); // If disabled we do not create a publisher to graphite but error counts are still collected. if(enabled) { metricPublishing.start(new GraphiteConfigImpl(host, port, pollintervalseconds, queuesize, sendasrate)); } thi...
java
@Override public void stop() { if(enabled) { metricPublishing.stop(); } if(startUpMetric != null) { startUpMetric.stop(); } super.stop(); }
java
protected String getFieldName(String propertyName) { return ObjectUtils.defaultIfNull(propertyNameToFieldNameMapping.get(propertyName), propertyName); }
java
@SuppressWarnings("unchecked") public void setModifiedBy(USER modifiedBy) { processChange("modifiedBy", this.modifiedBy, modifiedBy); this.lastModifiedBy = ObjectUtils.defaultIfNull(this.lastModifiedBy, this.modifiedBy); }
java
void changeState(String propertyName, Object newValue) { try { ObjectUtils.setField(this, getFieldName(propertyName), newValue); } catch (IllegalArgumentException e) { throw new PropertyNotFoundException(String.format( "The property (%1$s) corresponding to field (%2$s) was not found in t...
java
@SuppressWarnings("all") public int compareTo(Bean<ID, USER, PROCESS> obj) { Assert.isInstanceOf(obj, getClass(), new ClassCastException(String.format( "The Bean being compared with this Bean must be an instance of %1$s!", getClass().getName()))); return ComparatorUtils.compareIgnoreNull(getId(), obj.ge...
java
protected PropertyChangeEvent newPropertyChangeEvent(String propertyName, Object oldValue, Object newValue) { if (isEventDispatchEnabled()) { if (vetoableChangeSupport.hasListeners(propertyName) || propertyChangeSupport.hasListeners(propertyName)) { return new PropertyChangeEvent(this, propertyName, o...
java
protected void firePropertyChange(PropertyChangeEvent event) { if (isEventDispatchEnabled()) { Assert.notNull(event, "The PropertyChangeEvent cannot be null!"); if (propertyChangeSupport.hasListeners(event.getPropertyName())) { propertyChangeSupport.firePropertyChange(event); } } }
java
protected void fireVetoableChange(PropertyChangeEvent event) throws PropertyVetoException { if (isEventDispatchEnabled()) { Assert.notNull(event, "The PropertyChangeEvent cannot be null!"); if (vetoableChangeSupport.hasListeners(event.getPropertyName())) { vetoableChangeSupport.fireVetoableChang...
java
protected boolean mapPropertyNameToFieldName(final String propertyName, final String fieldName) { // TODO add possible validation for the property name and field name of this Bean class. propertyNameToFieldNameMapping.put(propertyName, fieldName); return propertyNameToFieldNameMapping.containsKey(propertyNa...
java
protected boolean mapPropertyNameToParameterizedStateChangeCallback(String propertyName, ParameterizedStateChangeCallback callback) { propertyNameToParameterizedStateChangeCallbackMapping.put(propertyName, callback); return propertyNameToParameterizedStateChangeCallbackMapping.containsKey(propertyName); ...
java
public static snmp_manager[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { snmp_manager obj = new snmp_manager(); options option = new options(); option.set_filter(filter); snmp_manager[] response = (snmp_manager[]) obj.getfiltered(service, option); return response; }
java
public static long count(nitro_service service) throws Exception { sms_server obj = new sms_server(); options option = new options(); option.set_count(true); sms_server[] response = (sms_server[])obj.get_resources(service, option); if (response != null && response.length > 0) return response[0].__c...
java
public void set_filter(filtervalue[] filter) { String str = null; for (int i = 0; i < filter.length; i++) { if (str != null) str = str + ","; if (str == null) str = filter[i].get_name() + ":" + nitro_util.encode(filter[i].get_value()); else str = str + filter[i].get_name() + ":" +...
java
public static task_device_log get(nitro_service client, task_device_log resource) throws Exception { resource.validate("get"); return ((task_device_log[]) resource.get_resources(client))[0]; }
java
public static <T> T withFields(Class<T> clazz, Object... keysAndValues) { return Mockito.mock(clazz, new FakerAnswer(keysAndValues)); }
java
public Collection<String> getAllProperties() { return wrappedSubmit(new Callable<Collection<String>>() { @Override public Collection<String> call() throws Exception { Collection<String> allProperties = new HashSet<String>(); ObjectMapper mapper = new ObjectMapper(); List<XmlProperty> xmlproperties =...
java
public Collection<String> getAllTags() { return wrappedSubmit(new Callable<Collection<String>>() { @Override public Collection<String> call() throws Exception { Collection<String> allTags = new HashSet<String>(); ObjectMapper mapper = new ObjectMapper(); List<XmlTag> xmltags = new ArrayList<XmlTag>...
java
public void set(Collection<Builder> channels) throws ChannelFinderException { wrappedSubmit(new SetChannels(ChannelUtil.toCollectionXmlChannels(channels))); }
java
@SuppressWarnings("all") @NullSafe public static boolean and(Boolean... values) { boolean result = (values != null); // innocent until proven guilty if (result) { for (Boolean value : values) { result &= valueOf(value); if (!result) { // short-circuit if we find a false value ...
java
@SuppressWarnings("all") @NullSafe public static boolean or(Boolean... values) { boolean result = false; // guilty until proven innocent for (Boolean value : nullSafeArray(values, Boolean.class)) { result |= valueOf(value); if (result) { // short-circuit if we find a true value break; ...
java
@NullSafe public static boolean xor(Boolean... values) { boolean result = false; // guilty until proven innocent. for (Boolean value : nullSafeArray(values, Boolean.class)) { boolean primitiveValue = valueOf(value); if (result && primitiveValue) { return false; // short-circuit if we fin...
java
public static <V> StrategicBlockingQueue<V> newStrategicLinkedBlockingQueue(QueueingStrategy<V> queueingStrategy) { return new StrategicBlockingQueue<V>(new LinkedBlockingQueue<V>(), queueingStrategy); }
java
public static <V> StrategicBlockingQueue<V> newStrategicArrayBlockingQueue(int capacity, QueueingStrategy<V> queueingStrategy) { return new StrategicBlockingQueue<V>(new ArrayBlockingQueue<V>(capacity), queueingStrategy); }
java
public static <V> StrategicBlockingQueue<V> newStrategicBlockingQueue(BlockingQueue<V> blockingQueue, QueueingStrategy<V> queueingStrategy) { return new StrategicBlockingQueue<V>(blockingQueue, queueingStrategy); }
java
public void show() { if (isVisible()) { return; } resetToInitialState(); setVisible(true); final Timeline phaseOne = new Timeline(); phaseOne.getKeyFrames().addAll( new KeyFrame(Duration.ZERO, new KeyValue(transformRadius, fromRadius), new K...
java
public static void setupMenuButton(ButtonBase button, RadialMenuParams params, Node graphic, String tooltip, boolean addStyle) { button.minWidthProperty().bind(params.buttonSizeProperty()); button.minHeightProperty().bind(params.buttonSizeProperty()); button.prefWidthProperty().bind(params.butto...
java
public static <T> @NonNull CompletableFuture<T> immediateFailedFuture(final @NonNull Throwable ex) { final CompletableFuture<T> future = new CompletableFuture<>(); future.completeExceptionally(ex); return future; }
java
public static ping get(nitro_service client, ping resource) throws Exception { resource.validate("get"); return ((ping[]) resource.get_resources(client))[0]; }
java
public static inventory get(nitro_service client, inventory resource) throws Exception { resource.validate("get"); return ((inventory[]) resource.get_resources(client))[0]; }
java
public static inventory[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { inventory obj = new inventory(); options option = new options(); option.set_filter(filter); inventory[] response = (inventory[]) obj.getfiltered(service, option); return response; }
java
public final void setId(final ID id) { Assert.notNull(id, "The identifier for Rule ({0}) cannot be null!", getClass().getName()); this.id = id; }
java
public static void scan(String source, OutputStream os) throws IOException { scanSource(source, new StringOutputStream(os)); }
java
public static ArrayList<VictimsRecord> getRecords(String source) throws IOException { ArrayList<VictimsRecord> records = new ArrayList<VictimsRecord>(); scan(source, records); return records; }
java
public static boolean isIdentical(final String expected, final String actual) { final Diff diff = createDiffResult(expected, actual, false); return diff.identical(); }
java
public static boolean isSimilar(final String expected, final String actual) { final Diff diff = createDiffResult(expected, actual, true); return diff.similar(); }
java
@SuppressWarnings("unchecked") public <T> @NonNull Collection<Collection<T>> components() { return (Collection<Collection<T>>) this.components; }
java
public static mps_doc_image[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { mps_doc_image obj = new mps_doc_image(); options option = new options(); option.set_filter(filter); mps_doc_image[] response = (mps_doc_image[]) obj.getfiltered(service, option); return response; ...
java
@SuppressWarnings("unchecked") protected <T> T configure(final T object) { if (object instanceof Configurable && isConfigurationAvailable()) { ((Configurable) object).configure(getConfiguration()); } return object; }
java
protected <T> T initialize(final T object, final Map<?, ?> parameters) { if (object instanceof ParameterizedInitable) { ((ParameterizedInitable) object).init(parameters); return object; } else { return initialize(object, parameters.values()); } }
java
protected <T> T initialize(final T object, final Object... args) { if (object instanceof ParameterizedInitable) { ((ParameterizedInitable) object).init(args); } else if (object instanceof Initable) { ((Initable) object).init(); } return object; }
java
public static br_device_profile[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { br_device_profile obj = new br_device_profile(); options option = new options(); option.set_filter(filter); br_device_profile[] response = (br_device_profile[]) obj.getfiltered(service, option); ...
java
public static hostcpu get(nitro_service client, hostcpu resource) throws Exception { resource.validate("get"); return ((hostcpu[]) resource.get_resources(client))[0]; }
java
private static String getPropertyValue(String key) { String env = System.getProperty(key); if (env == null) { if (DEFAULT_PROPS.containsKey(key)) { return DEFAULT_PROPS.get(key); } else { return null; } } return env; ...
java
public static String serviceURI() throws VictimsException { URL merged; try { merged = new URL(new URL(uri()), entry()); return merged.toString(); } catch (MalformedURLException e) { throw new VictimsException( "Invalid configuration for se...
java
public static File home() throws VictimsException { File directory = new File(getPropertyValue(Key.HOME)); if (!directory.exists()) { try { FileUtils.forceMkdir(directory); } catch (IOException e) { throw new VictimsException("Could not create home...
java
public static ArrayList<Algorithms> algorithms() { ArrayList<Algorithms> algorithms = new ArrayList<Algorithms>(); for (String alg : getPropertyValue(Key.ALGORITHMS).split(",")) { alg = alg.trim(); try { algorithms.add(Algorithms.valueOf(alg)); } catch...
java
public static String dbUrl() { String dbUrl = getPropertyValue(Key.DB_URL); if (dbUrl == null) { if (VictimsDB.Driver.exists(dbDriver())) { return VictimsDB.defaultURL(dbDriver()); } return VictimsDB.defaultURL(); } return dbUrl; }
java
public static <K, V> Map<K, V> transform(Map<K, V> map, Transformer<V> transformer) { Assert.notNull(map, "Map is required"); Assert.notNull(transformer, "Transformer is required"); return map.entrySet().stream().collect(Collectors.toMap(Map.Entry::<K>getKey, (entry) -> transformer.transform(entry.g...
java
public static String toIso8601(Date date) { if (date == null) return null; return ISODateTimeFormat.dateTimeNoMillis().withZoneUTC().print(date.getTime()); }
java
public void clean() { if (!remove(this)) return; try { thunk.run(); } catch (final Throwable x) { AccessController.doPrivileged(new PrivilegedAction<Void>() { public Void run() { if (System.err != null) ...
java
private boolean shouldPrettyPrint(HttpRequest request) { QueryStringDecoder decoder = new QueryStringDecoder(request.getUri(), Charsets.UTF_8, true, 2); Map<String, List<String>> parameters = decoder.parameters(); if (parameters.containsKey(PP_PARAMETER)) { return parseBoolean(parameters.get(PP_PARAME...
java
public static String constantValue(int index, ConstantPool cp) { Constant type = cp.getConstant(index); if (type != null) { switch (type.getTag()) { case Constants.CONSTANT_Class: ConstantClass cls = (ConstantClass) type; return constantValue(cls.g...
java
public static byte[] normalize(byte[] bytes, String fileName) throws IOException { ByteArrayInputStream is = new ByteArrayInputStream(bytes); ClassParser parser = new ClassParser(is, fileName); StringBuffer buf = new StringBuffer(); JavaClass klass = parser.parse(); C...
java
public static <T extends Comparable<T>> RelationalOperator<T> equalTo(T value) { return new EqualToOperator<>(value); }
java
public static <T extends Comparable<T>> RelationalOperator<T> greaterThan(T lowerBound) { return new GreaterThanOperator<>(lowerBound); }
java
public static <T extends Comparable<T>> RelationalOperator<T> greaterThanAndLessThan(T lowerBound, T upperBound) { return ComposableRelationalOperator.compose(greaterThan(lowerBound), LogicalOperator.AND, lessThan(upperBound)); }
java
public static <T extends Comparable<T>> RelationalOperator<T> greaterThanAndLessThanEqualTo(T lowerBound, T upperBound) { return ComposableRelationalOperator.compose(greaterThan(lowerBound), LogicalOperator.AND, lessThanEqualTo(upperBound)); }
java
public static <T extends Comparable<T>> RelationalOperator<T> greaterThanEqualTo(T lowerBound) { return new GreaterThanEqualToOperator<>(lowerBound); }
java
public static <T extends Comparable<T>> RelationalOperator<T> greaterThanEqualToAndLessThan(T lowerBound, T upperBound) { return ComposableRelationalOperator.compose(greaterThanEqualTo(lowerBound), LogicalOperator.AND, lessThan(upperBound)); }
java
public static <T extends Comparable<T>> RelationalOperator<T> greaterThanEqualToAndLessThanEqualTo(T lowerBound, T upperBound) { return ComposableRelationalOperator.compose(greaterThanEqualTo(lowerBound), LogicalOperator.AND, lessThanEqualTo(upperBound)); }
java
public static <T extends Comparable<T>> RelationalOperator<T> lessThan(T lowerBound) { return new LessThanOperator<>(lowerBound); }
java
public static <T extends Comparable<T>> RelationalOperator<T> lessThanOrGreaterThan(T lowerBound, T upperBound) { return ComposableRelationalOperator.compose(lessThan(lowerBound), LogicalOperator.OR, greaterThan(upperBound)); }
java
public static <T extends Comparable<T>> RelationalOperator<T> lessThanOrGreaterThanEqualTo(T lowerBound, T upperBound) { return ComposableRelationalOperator.compose(lessThan(lowerBound), LogicalOperator.OR, greaterThanEqualTo(upperBound)); }
java
public static <T extends Comparable<T>> RelationalOperator<T> lessThanEqualTo(T lowerBound) { return new LessThanEqualToOperator<>(lowerBound); }
java
public static <T extends Comparable<T>> RelationalOperator<T> lessThanEqualToOrGreaterThan(T lowerBound, T upperBound) { return ComposableRelationalOperator.compose(lessThanEqualTo(lowerBound), LogicalOperator.OR, greaterThan(upperBound)); }
java
public static <T extends Comparable<T>> RelationalOperator<T> lessThanEqualToOrGreaterThanEqualTo(T lowerBound, T upperBound) { return ComposableRelationalOperator.compose(lessThanEqualTo(lowerBound), LogicalOperator.OR, greaterThanEqualTo(upperBound)); }
java
@Override public <E> List<E> sort(final List<E> elements) { int position = elements.size(); do { int lastSwapPosition = 0; for (int index = 1; index < position; index++) { if (getOrderBy().compare(elements.get(index - 1), elements.get(index)) > 0) { swap(elements, index - 1, in...
java
@Override public <E> E search(final Collection<E> collection) { for (E element : collection) { if (getMatcher().isMatch(element)) { return element; } } return null; }
java
@NullSafe @SuppressWarnings("all") public static boolean areAllNull(Object... values) { for (Object value : nullSafeArray(values)) { if (value != null) { return false; } } return true; }
java
@NullSafe public static boolean areAnyNull(Object... values) { for (Object value : nullSafeArray(values)) { if (value == null) { return true; } } return false; }
java
@NullSafe @SuppressWarnings({ "unchecked", "varargs" }) public static <T> T defaultIfNull(T... values) { for (T value : nullSafeArray(values)) { if (value != null) { return value; } } return null; }
java
public static RadialMenuSection add(ContextRadialMenu owner, RadialPane pane, Menu menu, RadialMenuSection parentSection, Double angularAxisDeg) { final RadialMenuSection section = new RadialMenuSection(owner, pane, menu, parentSection, angularAxisDeg); pane.addSection(menu, section); return ...
java
public static mps_ssl_certkey[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { mps_ssl_certkey obj = new mps_ssl_certkey(); options option = new options(); option.set_filter(filter); mps_ssl_certkey[] response = (mps_ssl_certkey[]) obj.getfiltered(service, option); return ...
java
@Override @SuppressWarnings({ "unchecked", "varargs" }) public <E> E[] sort(final E... elements) { Arrays.sort(elements, getOrderBy()); return elements; }
java
@Override public <E> List<E> sort(final List<E> elements) { Collections.sort(elements, getOrderBy()); return elements; }
java
public static ns_conf_download_policy get(nitro_service client) throws Exception { ns_conf_download_policy resource = new ns_conf_download_policy(); resource.validate("get"); return ((ns_conf_download_policy[]) resource.get_resources(client))[0]; }
java
@Override @SuppressWarnings("unchecked") public <E> Matcher<E> getMatcher() { Matcher<E> localMatcher = (Matcher<E>) MatcherHolder.get(); Assert.state(localMatcher != null || matcher != null, "A reference to a Matcher used by this Searcher ({0}) for searching and matching elements in the collection w...
java
public void setMatcher(final Matcher matcher) { Assert.notNull(matcher, "The Matcher used to match elements in the collection during the search operation by this Searcher ({0}) cannot be null!", getClass().getName()); this.matcher = matcher; }
java
@Override @SuppressWarnings({ "unchecked", "varargs" }) public <E> E search(final E... array) { return search(Arrays.asList(array)); }
java
@Override public <E> E search(final Searchable<E> searchable) { try { return search(configureMatcher(searchable).asList()); } finally { MatcherHolder.unset(); } }
java
@SuppressWarnings({ "unchecked", "varargs" }) public <E> Iterable<E> searchForAll(final E... array) { return searchForAll(Arrays.asList(array)); }
java