_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q17700 | Rechnungsmonat.letzterArbeitstag | train | public LocalDate letzterArbeitstag() {
LocalDate tag = letzterTag();
switch (tag.getDayOfWeek()) {
case SATURDAY:
return tag.minusDays(1);
case SUNDAY:
return tag.minusDays(2);
default:
return tag;
}
} | java | {
"resource": ""
} |
q17701 | Pipelines.pipeline | train | public static <T> Consumer<T> pipeline(Consumer<T> consumer) {
return new PipelinedConsumer<T>(Iterations.iterable(consumer));
} | java | {
"resource": ""
} |
q17702 | Pipelines.pipeline | train | public static <T> Consumer<T> pipeline(Consumer<T> former, Consumer<T> latter) {
return new PipelinedConsumer<T>(Iterations.iterable(former, latter));
} | java | {
"resource": ""
} |
q17703 | Pipelines.pipeline | train | public static <T> Consumer<T> pipeline(Consumer<T> first, Consumer<T> second, Consumer<T> third) {
return new PipelinedConsumer<T>(Iterations.iterable(first, second, third));
} | java | {
"resource": ""
} |
q17704 | Pipelines.pipeline | train | public static <T> Consumer<T> pipeline(Consumer<T>... actions) {
return new PipelinedConsumer<T>(Iterations.iterable(actions));
} | java | {
"resource": ""
} |
q17705 | Pipelines.pipeline | train | public static <T1, T2> BiConsumer<T1, T2> pipeline(BiConsumer<T1, T2> consumer) {
return new PipelinedBinaryConsumer<T1, T2>(Iterations.iterable(consumer));
} | java | {
"resource": ""
} |
q17706 | Pipelines.pipeline | train | public static <T1, T2> BiConsumer<T1, T2> pipeline(BiConsumer<T1, T2> former, BiConsumer<T1, T2> latter) {
return new PipelinedBinaryConsumer<T1, T2>(Iterations.iterable(former, latter));
} | java | {
"resource": ""
} |
q17707 | Pipelines.pipeline | train | public static <T1, T2> BiConsumer<T1, T2> pipeline(BiConsumer<T1, T2> first, BiConsumer<T1, T2> second, BiConsumer<T1, T2> third) {
return new PipelinedBinaryConsumer<T1, T2>(Iterations.iterable(first, second, third));
} | java | {
"resource": ""
} |
q17708 | Pipelines.pipeline | train | public static <T1, T2> BiConsumer<T1, T2> pipeline(BiConsumer<T1, T2>... actions) {
return new PipelinedBinaryConsumer<T1, T2>(Iterations.iterable(actions));
} | java | {
"resource": ""
} |
q17709 | Pipelines.pipeline | train | public static <T1, T2, T3> TriConsumer<T1, T2, T3> pipeline(TriConsumer<T1, T2, T3> consumer) {
return new PipelinedTernaryConsumer<T1, T2, T3>(Iterations.iterable(consumer));
} | java | {
"resource": ""
} |
q17710 | Pipelines.pipeline | train | public static <T1, T2, T3> TriConsumer<T1, T2, T3> pipeline(TriConsumer<T1, T2, T3> former, TriConsumer<T1, T2, T3> latter) {
return new PipelinedTernaryConsumer<T1, T2, T3>(Iterations.iterable(former, latter));
} | java | {
"resource": ""
} |
q17711 | Pipelines.pipeline | train | public static <T1, T2, T3> TriConsumer<T1, T2, T3> pipeline(TriConsumer<T1, T2, T3> first, TriConsumer<T1, T2, T3> second, TriConsumer<T1, T2, T3> third) {
return new PipelinedTernaryConsumer<T1, T2, T3>(Iterations.iterable(first, second, third));
} | java | {
"resource": ""
} |
q17712 | JCusparse.initialize | train | public static void initialize()
{
if (!initialized)
{
String libraryBaseName = "JCusparse-" + JCuda.getJCudaVersion();
String libraryName =
LibUtils.createPlatformLibraryName(libraryBaseName);
LibUtils.loadLibrary(libraryName);
initialized = true;
}
} | java | {
"resource": ""
} |
q17713 | JCusparse.checkResult | train | private static int checkResult(int result)
{
if (exceptionsEnabled && result !=
cusparseStatus.CUSPARSE_STATUS_SUCCESS)
{
throw new CudaException(cusparseStatus.stringFor(result));
}
return result;
} | java | {
"resource": ""
} |
q17714 | JCusparse.cusparseCsrmvEx_bufferSize | train | public static int cusparseCsrmvEx_bufferSize(
cusparseHandle handle,
int alg,
int transA,
int m,
int n,
int nnz,
Pointer alpha,
int alphatype,
cusparseMatDescr descrA,
Pointer csrValA,
int csrValAtype,
Pointer csrRowPtrA,
Pointer csrColIndA,
Pointer x,
int xtype,
Pointer beta,
int betatype,
Pointer y,
int ytype,
int executiontype,
long[] bufferSizeInBytes)
{
return checkResult(cusparseCsrmvEx_bufferSizeNative(handle, alg, transA, m, n, nnz, alpha, alphatype, descrA, csrValA, csrValAtype, csrRowPtrA, csrColIndA, x, xtype, beta, betatype, y, ytype, executiontype, bufferSizeInBytes));
} | java | {
"resource": ""
} |
q17715 | AbstractDecimal.add | train | public T add(T addend) {
if (addend == null) {
throw new IllegalArgumentException("invalid (null) addend");
}
BigDecimal sum = this.value.add(addend.value);
return newInstance(sum, sum.scale());
} | java | {
"resource": ""
} |
q17716 | AbstractDecimal.subtract | train | public T subtract(T subtrahend) {
if (subtrahend == null) {
throw new IllegalArgumentException("invalid (null) subtrahend");
}
BigDecimal difference = this.value.subtract(subtrahend.value);
return newInstance(difference, difference.scale());
} | java | {
"resource": ""
} |
q17717 | AbstractDecimal.multiply | train | public T multiply(T multiplier) {
if (multiplier == null) {
throw new IllegalArgumentException("invalid (null) multiplier");
}
BigDecimal product = this.value.multiply(multiplier.value);
return newInstance(product, this.value.scale());
} | java | {
"resource": ""
} |
q17718 | AbstractDecimal.mod | train | public T mod(T modulus) {
if (modulus == null) {
throw new IllegalArgumentException("invalid (null) modulus");
}
double difference = this.value.doubleValue() % modulus.doubleValue();
return newInstance(BigDecimal.valueOf(difference), this.value.scale());
} | java | {
"resource": ""
} |
q17719 | AbstractDecimal.divide | train | public T divide(T divisor) {
if (divisor == null) {
throw new IllegalArgumentException("invalid (null) divisor");
}
BigDecimal quotient = this.value.divide(divisor.value, ROUND_BEHAVIOR);
return newInstance(quotient, this.value.scale());
} | java | {
"resource": ""
} |
q17720 | MapperSourceGenerator.computeExtendedInterfaces | train | private static List<DAType> computeExtendedInterfaces(List<DAInterface> interfaces) {
Optional<DAType> functionInterface = from(interfaces)
.filter(DAInterfacePredicates.isGuavaFunction())
.transform(toDAType())
.filter(notNull())
.first();
if (functionInterface.isPresent()) {
return Collections.singletonList(functionInterface.get());
}
return Collections.emptyList();
} | java | {
"resource": ""
} |
q17721 | ClassReloader.start | train | public static void start(String path) {
classMonitor = new ClassReloader(path);
Thread thread = new Thread(classMonitor, ClassReloader.class.getSimpleName());
thread.setDaemon(true);
thread.start();
} | java | {
"resource": ""
} |
q17722 | Parameter.toInteger | train | public static Integer toInteger(String parameterValue) {
Integer result = null;
if (isDigits(parameterValue))
result = Integer.valueOf(parameterValue);
return result;
} | java | {
"resource": ""
} |
q17723 | Parameter.toInt | train | public static int toInt(String parameterValue) {
int result = -1;
if (isDigits(parameterValue))
result = Integer.parseInt(parameterValue);
return result;
} | java | {
"resource": ""
} |
q17724 | Adresse.validate | train | public static void validate(Ort ort, String strasse, String hausnummer) {
if (StringUtils.isBlank(strasse)) {
throw new InvalidValueException(strasse, "street");
}
validate(ort, strasse, hausnummer, VALIDATOR);
} | java | {
"resource": ""
} |
q17725 | Adresse.getStrasseKurz | train | public String getStrasseKurz() {
if (PATTERN_STRASSE.matcher(strasse).matches()) {
return strasse.substring(0, StringUtils.lastIndexOfIgnoreCase(strasse, "stra") + 3) + '.';
} else {
return strasse;
}
} | java | {
"resource": ""
} |
q17726 | Adresse.toMap | train | @Override
public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<>();
map.put("plz", getPLZ());
map.put("ortsname", getOrtsname());
map.put("strasse", getStrasse());
map.put("hausnummer", getHausnummer());
return map;
} | java | {
"resource": ""
} |
q17727 | DatamappingHelper.findDataMapping | train | public static Datamappingtype findDataMapping(Object data, String id, Datamappingstype dataMappingConfig) {
if (null != data) {
Class clazz = (Class) ((data instanceof Class) ? data : data.getClass());
for (Datamappingtype dt : dataMappingConfig.getDatamapping()) {
if (dt.isRegex() && Pattern.compile(dt.getClassname()).matcher(clazz.getName()).find() && idOK(id, dt.getId())) {
if (logger.isLoggable(Level.FINE)) {
logger.fine(String.format("Datamapping found: %s matches regex %s (requested id: %s)", clazz.getName(), dt.getClassname(), id));
}
return dt;
} else if (clazz.getName().equals(dt.getClassname()) && idOK(id, dt.getId())) {
if (logger.isLoggable(Level.FINE)) {
logger.fine(String.format("Datamapping found: %s matches %s (requested id: %s)", clazz.getName(), dt.getClassname(), id));
}
return dt;
}
if (logger.isLoggable(Level.FINE)) {
logger.fine(String.format("%s does not match %s (regex: %s, requested id %s)", dt.getClassname(), clazz.getName(), dt.isRegex(), id));
}
}
}
return null;
} | java | {
"resource": ""
} |
q17728 | DatamappingHelper.getContainers | train | public static List<StartContainerConfig> getContainers(Class clazz) {
if (!cacheSCC.containsKey(clazz)) {
cacheSCC.put(clazz, new ArrayList<>(1));
ContainerStart cs = (ContainerStart) clazz.getAnnotation(ContainerStart.class);
if (cs != null) {
cacheSCC.get(clazz).add(fromContainerStart(cs));
}
Containers c = (Containers) clazz.getAnnotation(com.vectorprint.report.itext.annotations.Containers.class);
if (c != null) {
for (ContainerStart s : c.containers()) {
cacheSCC.get(clazz).add(fromContainerStart(s));
}
}
}
return cacheSCC.get(clazz);
} | java | {
"resource": ""
} |
q17729 | DatamappingHelper.getElements | train | public static List<ElementConfig> getElements(Class clazz) {
if (!cacheEC.containsKey(clazz)) {
cacheEC.put(clazz, new ArrayList<>(1));
Element e = (Element) clazz.getAnnotation(Element.class);
if (e != null) {
cacheEC.get(clazz).add(fromAnnotation(e));
}
Elements es = (Elements) clazz.getAnnotation(com.vectorprint.report.itext.annotations.Elements.class);
if (es != null) {
for (Element s : es.elements()) {
cacheEC.get(clazz).add(fromAnnotation(s));
}
}
}
return cacheEC.get(clazz);
} | java | {
"resource": ""
} |
q17730 | IBAN.getFormatted | train | public String getFormatted() {
String input = this.getUnformatted() + " ";
StringBuilder buf = new StringBuilder();
for (int i = 0; i < this.getUnformatted().length(); i+= 4) {
buf.append(input, i, i+4);
buf.append(' ');
}
return buf.toString().trim();
} | java | {
"resource": ""
} |
q17731 | IBAN.getLand | train | @SuppressWarnings({"squid:SwitchLastCaseIsDefaultCheck", "squid:S1301"})
public Locale getLand() {
String country = this.getUnformatted().substring(0, 2);
String language = country.toLowerCase();
switch (country) {
case "AT":
case "CH":
language = "de";
break;
}
return new Locale(language, country);
} | java | {
"resource": ""
} |
q17732 | FachwertFactory.getFachwert | train | public Fachwert getFachwert(Class<? extends Fachwert> clazz, Object... args) {
Class[] argTypes = toTypes(args);
try {
Constructor<? extends Fachwert> ctor = clazz.getConstructor(argTypes);
return ctor.newInstance(args);
} catch (ReflectiveOperationException ex) {
Throwable cause = ex.getCause();
if (cause instanceof ValidationException) {
throw (ValidationException) cause;
} else if (cause instanceof IllegalArgumentException) {
throw new LocalizedValidationException(cause.getMessage(), cause);
} else {
throw new IllegalArgumentException("cannot create " + clazz + " with " + Arrays.toString(args), ex);
}
}
} | java | {
"resource": ""
} |
q17733 | DocxService.loadPackage | train | @Programmatic
public WordprocessingMLPackage loadPackage(final InputStream docxTemplate) throws LoadTemplateException {
final WordprocessingMLPackage docxPkg;
try {
docxPkg = WordprocessingMLPackage.load(docxTemplate);
} catch (final Docx4JException ex) {
throw new LoadTemplateException("Unable to load docx template from input stream", ex);
}
return docxPkg;
} | java | {
"resource": ""
} |
q17734 | AbstractFieldStyler.makeField | train | @Override
public PdfFormField makeField() throws IOException, DocumentException, VectorPrintException {
switch (getFieldtype()) {
case TEXT:
return ((TextField) bf).getTextField();
case COMBO:
return ((TextField) bf).getComboField();
case LIST:
return ((TextField) bf).getListField();
case BUTTON:
return ((PushbuttonField) bf).getField();
case CHECKBOX:
return ((RadioCheckField) bf).getCheckField();
case RADIO:
return ((RadioCheckField) bf).getRadioField();
}
throw new VectorPrintException(String.format("cannot create pdfformfield from %s and %s", (bf != null) ? bf.getClass() : null, String.valueOf(getFieldtype())));
} | java | {
"resource": ""
} |
q17735 | Help.getParameterizables | train | public static <P extends Parameterizable> Set<P> getParameterizables(Package javaPackage, Class<P> clazz) throws IOException, FileNotFoundException, ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
Set<P> parameterizables = new HashSet<>(50);
for (Class<?> c : ClassHelper.fromPackage(javaPackage)) {
if (clazz.isAssignableFrom(c) && !Modifier.isAbstract(c.getModifiers())) {
P p = (P) c.newInstance();
ParamAnnotationProcessor.PAP.initParameters(p);
parameterizables.add(p);
}
}
return parameterizables;
} | java | {
"resource": ""
} |
q17736 | JamMetricsDependencyProcessor.deploy | train | @Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
// ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
// final VirtualFile rootBeansXml = deploymentRoot.getRoot().getChild("META-INF/beans.xml");
// final boolean rootBeansXmlPresent = rootBeansXml.exists() && rootBeansXml.isFile();
// System.out.println("rootBeansXmlPresent " + rootBeansXmlPresent);
/* Map<ResourceRoot, ExplicitBeanArchiveMetadata> beanArchiveMetadata = new HashMap<>();
PropertyReplacingBeansXmlParser parser = new PropertyReplacingBeansXmlParser(deploymentUnit);
ResourceRoot classesRoot = null;
List<ResourceRoot> structure = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
for (ResourceRoot resourceRoot : structure) {
if (ModuleRootMarker.isModuleRoot(resourceRoot) && !SubDeploymentMarker.isSubDeployment(resourceRoot)) {
if (resourceRoot.getRootName().equals("classes")) {
// hack for dealing with war modules
classesRoot = resourceRoot;
deploymentUnit.putAttachment(WeldAttachments.CLASSES_RESOURCE_ROOT, resourceRoot);
} else {
VirtualFile beansXml = resourceRoot.getRoot().getChild("META-INF/beans.xml");
if (beansXml.exists() && beansXml.isFile()) {
System.out.println("rootBeansXmlPresent found");
beanArchiveMetadata.put(resourceRoot, new ExplicitBeanArchiveMetadata(beansXml, resourceRoot, parseBeansXml(beansXml, parser, deploymentUnit), false));
}
}
}
}
*/
// BeansXml beansXml = deployment.getBeanDeploymentArchive().getBeansXml();
if (!WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
return; // Skip if there are no beans.xml files in the deployment
}
ModuleDependency dep = new ModuleDependency(moduleLoader, ORG_JAM_METRICS, false, false, true, false);
dep.addImportFilter(PathFilters.getMetaInfFilter(), true);
dep.addExportFilter(PathFilters.getMetaInfFilter(), true);
moduleSpecification.addSystemDependency(dep);
ModuleDependency dep2 = new ModuleDependency(moduleLoader, ORG_JAM_METRICS_API, false, false, true, false);
dep2.addImportFilter(PathFilters.getMetaInfFilter(), true);
dep2.addExportFilter(PathFilters.getMetaInfFilter(), true);
moduleSpecification.addSystemDependency(dep2);
ModuleDependency dep3 = new ModuleDependency(moduleLoader, ORG_JAM_METRICS_PROPERTIES, false, false, true, false);
dep3.addImportFilter(PathFilters.getMetaInfFilter(), true);
dep3.addExportFilter(PathFilters.getMetaInfFilter(), true);
moduleSpecification.addSystemDependency(dep3);
ModuleDependency dep4 = new ModuleDependency(moduleLoader, ORG_JAM_METRICS_LIBRARY, false, false, true, false);
dep4.addImportFilter(PathFilters.getMetaInfFilter(), true);
dep4.addExportFilter(PathFilters.getMetaInfFilter(), true);
moduleSpecification.addSystemDependency(dep4);
ModuleDependency dep5 = new ModuleDependency(moduleLoader, ORG_JAM_METRICS_LIBRARY2, false, false, true, false);
dep5.addImportFilter(PathFilters.getMetaInfFilter(), true);
dep5.addExportFilter(PathFilters.getMetaInfFilter(), true);
moduleSpecification.addSystemDependency(dep5);
} | java | {
"resource": ""
} |
q17737 | WaehrungenSingletonSpi.getDefaultProviderChain | train | @Override
public List<String> getDefaultProviderChain() {
List<String> list = new ArrayList<>(getProviderNames());
return list;
} | java | {
"resource": ""
} |
q17738 | WaehrungenSingletonSpi.getCurrencies | train | @Override
public Set<CurrencyUnit> getCurrencies(CurrencyQuery query) {
Set<CurrencyUnit> result = new HashSet<>();
for (Locale locale : query.getCountries()) {
try {
result.add(Waehrung.of(Currency.getInstance(locale)));
} catch (IllegalArgumentException ex) {
LOG.log(Level.WARNING, "Cannot get currency for locale '" + locale + "':", ex);
}
}
for (String currencyCode : query.getCurrencyCodes()) {
try {
result.add(Waehrung.of(currencyCode));
} catch (IllegalArgumentException ex) {
LOG.log(Level.WARNING, "Cannot get currency '" + currencyCode + "':", ex);
}
}
for (CurrencyProviderSpi spi : Bootstrap.getServices(CurrencyProviderSpi.class)) {
result.addAll(spi.getCurrencies(query));
}
return result;
} | java | {
"resource": ""
} |
q17739 | Consumers.all | train | public static <E> List<E> all(E[] array) {
final Function<Iterator<E>, ArrayList<E>> consumer = new ConsumeIntoCollection<>(new ArrayListFactory<E>());
return consumer.apply(new ArrayIterator<>(array));
} | java | {
"resource": ""
} |
q17740 | Consumers.dict | train | public static <K, V> Map<K, V> dict(Pair<K, V>... array) {
final Function<Iterator<Pair<K, V>>, HashMap<K, V>> consumer = new ConsumeIntoMap<>(new HashMapFactory<K, V>());
return consumer.apply(new ArrayIterator<>(array));
} | java | {
"resource": ""
} |
q17741 | Consumers.pipe | train | public static <E> void pipe(Iterator<E> iterator, OutputIterator<E> outputIterator) {
new ConsumeIntoOutputIterator<>(outputIterator).apply(iterator);
} | java | {
"resource": ""
} |
q17742 | Consumers.pipe | train | public static <E> void pipe(Iterable<E> iterable, OutputIterator<E> outputIterator) {
dbc.precondition(iterable != null, "cannot call pipe with a null iterable");
new ConsumeIntoOutputIterator<>(outputIterator).apply(iterable.iterator());
} | java | {
"resource": ""
} |
q17743 | Consumers.pipe | train | public static <E> void pipe(E[] array, OutputIterator<E> outputIterator) {
new ConsumeIntoOutputIterator<>(outputIterator).apply(new ArrayIterator<>(array));
} | java | {
"resource": ""
} |
q17744 | Consumers.first | train | public static <E> E first(Iterator<E> iterator) {
return new FirstElement<E>().apply(iterator);
} | java | {
"resource": ""
} |
q17745 | Consumers.first | train | public static <E> E first(Iterable<E> iterable) {
dbc.precondition(iterable != null, "cannot call first with a null iterable");
return new FirstElement<E>().apply(iterable.iterator());
} | java | {
"resource": ""
} |
q17746 | Consumers.first | train | public static <E> E first(E[] array) {
return new FirstElement<E>().apply(new ArrayIterator<>(array));
} | java | {
"resource": ""
} |
q17747 | DefaultElementProducer.createElementByStyler | train | public <E extends Element> E createElementByStyler(Collection<? extends BaseStyler> stylers, Object data, Class<E> clazz) throws VectorPrintException {
// pdfptable, Section and others do not have a default constructor, a styler creates it
E e = null;
return styleHelper.style(e, data, stylers);
} | java | {
"resource": ""
} |
q17748 | DefaultElementProducer.createPhrase | train | public Phrase createPhrase(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException {
return initTextElementArray(styleHelper.style(new Phrase(Float.NaN), data, stylers), data, stylers);
} | java | {
"resource": ""
} |
q17749 | DefaultElementProducer.createParagraph | train | public Paragraph createParagraph(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException {
return initTextElementArray(styleHelper.style(new Paragraph(Float.NaN), data, stylers), data, stylers);
} | java | {
"resource": ""
} |
q17750 | DefaultElementProducer.createAnchor | train | public Anchor createAnchor(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException {
return initTextElementArray(styleHelper.style(new Anchor(Float.NaN), data, stylers), data, stylers);
} | java | {
"resource": ""
} |
q17751 | DefaultElementProducer.createListItem | train | public ListItem createListItem(Object data, Collection<? extends BaseStyler> stylers) throws VectorPrintException {
return initTextElementArray(styleHelper.style(new ListItem(Float.NaN), data, stylers), data, stylers);
} | java | {
"resource": ""
} |
q17752 | DefaultElementProducer.makeImageTranslucent | train | public static BufferedImage makeImageTranslucent(BufferedImage source, float opacity) {
if (opacity == 1) {
return source;
}
BufferedImage translucent = new BufferedImage(source.getWidth(), source.getHeight(), BufferedImage.TRANSLUCENT);
Graphics2D g = translucent.createGraphics();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
g.drawImage(source, null, 0, 0);
g.dispose();
return translucent;
} | java | {
"resource": ""
} |
q17753 | DefaultElementProducer.getIndex | train | @Override
public Section getIndex(String title, int nesting, List<? extends BaseStyler> stylers) throws VectorPrintException, InstantiationException, IllegalAccessException {
if (nesting < 1) {
throw new VectorPrintException("chapter numbering starts with 1, wrong number: " + nesting);
}
if (sections.get(nesting) == null) {
sections.put(nesting, new ArrayList<>(10));
}
Section current;
if (nesting == 1) {
List<Section> chapters = sections.get(1);
current = new Chapter(createElement(title, Paragraph.class, stylers), chapters.size() + 1);
chapters.add(current);
} else {
List<Section> parents = sections.get(nesting - 1);
Section parent = parents.get(parents.size() - 1);
current = parent.addSection(createParagraph(title, stylers));
sections.get(nesting).add(current);
}
return styleHelper.style(current, null, stylers);
} | java | {
"resource": ""
} |
q17754 | ComposableVisitor.visit | train | public void visit(Visitable visitable) {
StreamSupport.stream(this.spliterator(), false).forEach(visitor -> visitor.visit(visitable));
} | java | {
"resource": ""
} |
q17755 | br_broker.reboot | train | public static br_broker reboot(nitro_service client, br_broker resource) throws Exception
{
return ((br_broker[]) resource.perform_operation(client, "reboot"))[0];
} | java | {
"resource": ""
} |
q17756 | br_broker.stop | train | public static br_broker stop(nitro_service client, br_broker resource) throws Exception
{
return ((br_broker[]) resource.perform_operation(client, "stop"))[0];
} | java | {
"resource": ""
} |
q17757 | br_broker.force_reboot | train | public static br_broker force_reboot(nitro_service client, br_broker resource) throws Exception
{
return ((br_broker[]) resource.perform_operation(client, "force_reboot"))[0];
} | java | {
"resource": ""
} |
q17758 | br_broker.force_stop | train | public static br_broker force_stop(nitro_service client, br_broker resource) throws Exception
{
return ((br_broker[]) resource.perform_operation(client, "force_stop"))[0];
} | java | {
"resource": ""
} |
q17759 | br_broker.start | train | public static br_broker start(nitro_service client, br_broker resource) throws Exception
{
return ((br_broker[]) resource.perform_operation(client, "start"))[0];
} | java | {
"resource": ""
} |
q17760 | CommitVisitor.visit | train | @Override
public void visit(Visitable visitable) {
if (isCommitable(visitable)) {
ObjectUtils.setField(visitable, "lastModifiedBy", ((Auditable) visitable).getModifiedBy());
ObjectUtils.setField(visitable, "lastModifiedOn", ((Auditable) visitable).getModifiedOn());
ObjectUtils.setField(visitable, "lastModifiedWith", ((Auditable) visitable).getModifiedWith());
}
} | java | {
"resource": ""
} |
q17761 | CommitVisitor.isCommitable | train | protected boolean isCommitable(Object visitable) {
return (visitable instanceof Auditable && (target == null || identity(visitable) == identity(target)));
} | java | {
"resource": ""
} |
q17762 | PrettySharedPreferences.apply | train | @TargetApi(Build.VERSION_CODES.GINGERBREAD)
public void apply() {
if (editing == null) {
return;
}
try {
editing.apply();
} catch (Exception ex) {
editing.commit(); // Fallback in case low api lever.
}
editing = null;
} | java | {
"resource": ""
} |
q17763 | PrettySharedPreferences.commit | train | public boolean commit() {
if (editing == null) {
return false;
}
final boolean result = editing.commit();
editing = null;
return result;
} | java | {
"resource": ""
} |
q17764 | sdxtools_image.get_filtered | train | public static sdxtools_image[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception
{
sdxtools_image obj = new sdxtools_image();
options option = new options();
option.set_filter(filter);
sdxtools_image[] response = (sdxtools_image[]) obj.getfiltered(service, option);
return response;
} | java | {
"resource": ""
} |
q17765 | ObjectFactoryReferenceHolder.set | train | public static synchronized void set(final ObjectFactory objectFactory) {
Assert.state(objectFactoryReference == null, "The ObjectFactory reference is already set to ({0})",
objectFactoryReference);
objectFactoryReference = objectFactory;
} | java | {
"resource": ""
} |
q17766 | ns_ns_runningconfig.get | train | public static ns_ns_runningconfig get(nitro_service client, ns_ns_runningconfig resource) throws Exception
{
resource.validate("get");
return ((ns_ns_runningconfig[]) resource.get_resources(client))[0];
} | java | {
"resource": ""
} |
q17767 | VictimsSQL.setUp | train | protected void setUp() throws SQLException {
Connection connection = getConnection();
try {
if (!isSetUp(connection)) {
Statement stmt = connection.createStatement();
stmt.execute(Query.CREATE_TABLE_RECORDS);
stmt.execute(Query.CREATE_TABLE_FILEHASHES);
stmt.execute(Query.CREATE_TABLE_META);
stmt.execute(Query.CREATE_TABLE_CVES);
stmt.close();
}
} finally {
connection.close();
}
} | java | {
"resource": ""
} |
q17768 | VictimsSQL.statement | train | protected PreparedStatement statement(Connection connection, String query)
throws SQLException {
return connection.prepareStatement(query);
} | java | {
"resource": ""
} |
q17769 | VictimsSQL.setObjects | train | protected PreparedStatement setObjects(Connection connection, String query,
Object... objects) throws SQLException {
PreparedStatement ps = statement(connection, query);
setObjects(ps, objects);
return ps;
} | java | {
"resource": ""
} |
q17770 | VictimsSQL.selectRecordId | train | protected int selectRecordId(String hash) throws SQLException {
int id = -1;
Connection connection = getConnection();
try {
PreparedStatement ps = setObjects(connection, Query.GET_RECORD_ID,
hash);
ResultSet rs = ps.executeQuery();
try {
while (rs.next()) {
id = rs.getInt("id");
break;
}
} finally {
rs.close();
ps.close();
}
} finally {
connection.close();
}
return id;
} | java | {
"resource": ""
} |
q17771 | VictimsSQL.insertRecord | train | protected int insertRecord(Connection connection, String hash)
throws SQLException {
int id = -1;
PreparedStatement ps = setObjects(connection, Query.INSERT_RECORD, hash);
ps.execute();
ResultSet rs = ps.getGeneratedKeys();
try {
while (rs.next()) {
id = rs.getInt(1);
break;
}
} finally {
rs.close();
ps.close();
}
return id;
} | java | {
"resource": ""
} |
q17772 | VictimsSQL.deleteRecord | train | protected void deleteRecord(Connection connection, String hash)
throws SQLException {
int id = selectRecordId(hash);
if (id > 0) {
String[] queries = new String[] { Query.DELETE_FILEHASHES,
Query.DELETE_METAS, Query.DELETE_CVES,
Query.DELETE_RECORD_ID };
for (String query : queries) {
PreparedStatement ps = setObjects(connection, query, id);
ps.execute();
ps.close();
}
}
} | java | {
"resource": ""
} |
q17773 | AbstractCacheableService.withCaching | train | protected VALUE withCaching(KEY key, Supplier<VALUE> cacheLoader) {
return getCache()
.map(CachingTemplate::with)
.<VALUE>map(template -> template.withCaching(key, () -> {
setCacheMiss();
return cacheLoader.get();
}))
.orElseGet(cacheLoader);
} | java | {
"resource": ""
} |
q17774 | xen_websensevpx_image.get_filtered | train | public static xen_websensevpx_image[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception
{
xen_websensevpx_image obj = new xen_websensevpx_image();
options option = new options();
option.set_filter(filter);
xen_websensevpx_image[] response = (xen_websensevpx_image[]) obj.getfiltered(service, option);
return response;
} | java | {
"resource": ""
} |
q17775 | OrderedComparator.compare | train | @Override
public int compare(final Ordered ordered1, final Ordered ordered2) {
return (ordered1.getIndex() < ordered2.getIndex() ? -1 : (ordered1.getIndex() > ordered2.getIndex() ? 1 : 0));
} | java | {
"resource": ""
} |
q17776 | RunnableUtils.safeSleep | train | private static boolean safeSleep(long milliseconds) {
boolean interrupted = false;
long timeout = (System.currentTimeMillis() + milliseconds);
while (System.currentTimeMillis() < timeout) {
try {
Thread.sleep(milliseconds);
}
catch (InterruptedException cause) {
interrupted = true;
}
finally {
milliseconds = Math.min(timeout - System.currentTimeMillis(), 0);
}
}
if (interrupted) {
Thread.currentThread().interrupt();
}
return !Thread.currentThread().isInterrupted();
} | java | {
"resource": ""
} |
q17777 | Threshold.accumulate | train | public void accumulate(List<? extends StandardMetricResult> metricValues) {
if (metricValues == null || metricValues.isEmpty()) return;
for (StandardMetricResult v : metricValues) {
if (lastOffset < v.offset) values.put(v.value.intValue());
}
lastOffset = ListUtils.last(metricValues).offset;
} | java | {
"resource": ""
} |
q17778 | Threshold.isExceeded | train | public boolean isExceeded() {
lastAggregatedValue = getAggregatedValue();
lastExceededValue = false;
switch (operator) {
case lessThan:
lastExceededValue = (lastAggregatedValue < thresholdValue);
break;
case greaterThan: lastExceededValue = (lastAggregatedValue > thresholdValue);
break;
}
return lastExceededValue;
} | java | {
"resource": ""
} |
q17779 | Threshold.getReason | train | public String getReason() {
if (lastExceededValue) {
return String.format("Metric '%s' has aggregated-value=%d %s %d as threshold", metric.name(), lastAggregatedValue, operator.symbol, thresholdValue);
} else {
return String.format("Metric %s: aggregated-value=%d", metric.name(), lastAggregatedValue);
}
} | java | {
"resource": ""
} |
q17780 | ns_ssl_certkey_policy.get | train | public static ns_ssl_certkey_policy get(nitro_service client) throws Exception
{
ns_ssl_certkey_policy resource = new ns_ssl_certkey_policy();
resource.validate("get");
return ((ns_ssl_certkey_policy[]) resource.get_resources(client))[0];
} | java | {
"resource": ""
} |
q17781 | Exceptions.rethrowConsumer | train | public static <T, E extends Throwable> @NonNull Consumer<T> rethrowConsumer(final @NonNull ThrowingConsumer<T, E> consumer) {
return consumer;
} | java | {
"resource": ""
} |
q17782 | Exceptions.rethrowBiConsumer | train | public static <T, U, E extends Throwable> @NonNull BiConsumer<T, U> rethrowBiConsumer(final @NonNull ThrowingBiConsumer<T, U, E> consumer) {
return consumer;
} | java | {
"resource": ""
} |
q17783 | Exceptions.rethrowFunction | train | public static <T, R, E extends Throwable> @NonNull Function<T, R> rethrowFunction(final @NonNull ThrowingFunction<T, R, E> function) {
return function;
} | java | {
"resource": ""
} |
q17784 | Exceptions.rethrowBiFunction | train | public static <T, U, R, E extends Throwable> @NonNull BiFunction<T, U, R> rethrowBiFunction(final @NonNull ThrowingBiFunction<T, U, R, E> function) {
return function;
} | java | {
"resource": ""
} |
q17785 | Exceptions.rethrowPredicate | train | public static <T, E extends Throwable> @NonNull Predicate<T> rethrowPredicate(final @NonNull ThrowingPredicate<T, E> predicate) {
return predicate;
} | java | {
"resource": ""
} |
q17786 | Exceptions.rethrowRunnable | train | public static <E extends Throwable> @NonNull Runnable rethrowRunnable(final @NonNull ThrowingRunnable<E> runnable) {
return runnable;
} | java | {
"resource": ""
} |
q17787 | Exceptions.rethrowSupplier | train | public static <T, E extends Throwable> @NonNull Supplier<T> rethrowSupplier(final @NonNull ThrowingSupplier<T, E> supplier) {
return supplier;
} | java | {
"resource": ""
} |
q17788 | Exceptions.rethrow | train | public static <E extends Throwable> @NonNull RuntimeException rethrow(final @NonNull Throwable exception) throws E {
throw (E) exception;
} | java | {
"resource": ""
} |
q17789 | Exceptions.unwrap | train | public static @NonNull Throwable unwrap(final @NonNull Throwable throwable) {
if(throwable instanceof InvocationTargetException) {
final /* @Nullable */ Throwable cause = throwable.getCause();
if(cause != null) {
return cause;
}
}
return throwable;
} | java | {
"resource": ""
} |
q17790 | ns_ns_savedconfig.get | train | public static ns_ns_savedconfig get(nitro_service client, ns_ns_savedconfig resource) throws Exception
{
resource.validate("get");
return ((ns_ns_savedconfig[]) resource.get_resources(client))[0];
} | java | {
"resource": ""
} |
q17791 | VictimsResultCache.create | train | protected void create(File cache) throws VictimsException {
try {
FileUtils.forceMkdir(cache);
} catch (IOException e) {
throw new VictimsException("Could not create an on disk cache", e);
}
} | java | {
"resource": ""
} |
q17792 | VictimsResultCache.purge | train | public void purge() throws VictimsException {
try {
File cache = new File(location);
if (cache.exists()) {
FileUtils.deleteDirectory(cache);
}
create(cache);
} catch (IOException e) {
throw new VictimsException("Could not purge on disk cache.", e);
}
} | java | {
"resource": ""
} |
q17793 | VictimsResultCache.hash | train | protected String hash(String key) throws VictimsException {
try {
MessageDigest mda = MessageDigest
.getInstance(MessageDigestAlgorithms.SHA_256);
return Hex.encodeHexString(mda.digest(key.getBytes()));
} catch (NoSuchAlgorithmException e) {
throw new VictimsException(String.format("Could not hash key: %s",
key), e);
}
} | java | {
"resource": ""
} |
q17794 | VictimsResultCache.exists | train | public boolean exists(String key) {
try {
key = hash(key);
return FileUtils.getFile(location, key).exists();
} catch (VictimsException e) {
return false;
}
} | java | {
"resource": ""
} |
q17795 | VictimsResultCache.delete | train | public void delete(String key) throws VictimsException {
key = hash(key);
try {
FileUtils.forceDelete(FileUtils.getFile(location, key));
} catch (IOException e) {
throw new VictimsException(String.format(
"Could not delete the cached entry from disk: %s", key), e);
}
} | java | {
"resource": ""
} |
q17796 | VictimsResultCache.add | train | public void add(String key, Collection<String> cves)
throws VictimsException {
key = hash(key);
if (exists(key)) {
delete(key);
}
String result = "";
if (cves != null) {
result = StringUtils.join(cves, ",");
}
try {
FileOutputStream fos = new FileOutputStream(FileUtils.getFile(
location, key));
try {
fos.write(result.getBytes());
} finally {
fos.close();
}
} catch (IOException e) {
throw new VictimsException(String.format(
"Could not add disk entry for key: %s", key), e);
}
} | java | {
"resource": ""
} |
q17797 | VictimsResultCache.get | train | public HashSet<String> get(String key) throws VictimsException {
key = hash(key);
try {
HashSet<String> cves = new HashSet<String>();
String result = FileUtils.readFileToString(
FileUtils.getFile(location, key)).trim();
for (String cve : StringUtils.split(result, ",")) {
cves.add(cve);
}
return cves;
} catch (IOException e) {
throw new VictimsException(String.format(
"Could not read contents of entry with key: %s", key), e);
}
} | java | {
"resource": ""
} |
q17798 | Base64.decode | train | public final static byte[] decode(byte[] sArr) {
// Check special case
int sLen = sArr.length;
// Count illegal characters (including '\r', '\n') to know what size the returned array will be,
// so we don't have to reallocate & copy it later.
int sepCnt = 0; // Number of separator characters. (Actually illegal characters, but that's a bonus...)
for (int i = 0; i < sLen; i++) // If input is "pure" (I.e. no line separators or illegal chars) base64 this loop can be commented out.
{
if (IA[sArr[i] & 0xff] < 0) {
sepCnt++;
}
}
// Check so that legal chars (including '=') are evenly divideable by 4 as specified in RFC 2045.
if ((sLen - sepCnt) % 4 != 0) {
return null;
}
int pad = 0;
for (int i = sLen; i > 1 && IA[sArr[--i] & 0xff] <= 0; ) {
if (sArr[i] == '=') {
pad++;
}
}
int len = ((sLen - sepCnt) * 6 >> 3) - pad;
byte[] dArr = new byte[len]; // Preallocate byte[] of exact length
for (int s = 0, d = 0; d < len; ) {
// Assemble three bytes into an int from four "valid" characters.
int i = 0;
for (int j = 0; j < 4; j++) { // j only increased if a valid char was found.
int c = IA[sArr[s++] & 0xff];
if (c >= 0) {
i |= c << (18 - j * 6);
} else {
j--;
}
}
// Add the bytes
dArr[d++] = (byte) (i >> 16);
if (d < len) {
dArr[d++] = (byte) (i >> 8);
if (d < len) {
dArr[d++] = (byte) i;
}
}
}
return dArr;
} | java | {
"resource": ""
} |
q17799 | SelectionSort.sort | train | @Override
public <E> List<E> sort(final List<E> elements) {
for (int index = 0, size = elements.size(), length = (size - 1); index < length; index++) {
int minIndex = index;
for (int j = (index + 1); j < size; j++) {
if (getOrderBy().compare(elements.get(j), elements.get(minIndex)) < 0) {
minIndex = j;
}
}
if (minIndex != index) {
swap(elements, minIndex, index);
}
}
return elements;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.