hexsha stringlengths 40 40 | size int64 3 1.05M | ext stringclasses 1 value | lang stringclasses 1 value | max_stars_repo_path stringlengths 5 1.02k | max_stars_repo_name stringlengths 4 126 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses list | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 5 1.02k | max_issues_repo_name stringlengths 4 114 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses list | max_issues_count float64 1 92.2k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 5 1.02k | max_forks_repo_name stringlengths 4 136 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses list | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | avg_line_length float64 2.55 99.9 | max_line_length int64 3 1k | alphanum_fraction float64 0.25 1 | index int64 0 1M | content stringlengths 3 1.05M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3e1d5c01a2d886116110dc2dd453cd934dbdc0b1 | 2,131 | java | Java | pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/SinkRecord.java | atlantic2099/pulsar | 66f56f11b9dc9db4c9aeb2caaa40c0ddf542b22b | [
"Apache-2.0"
] | 3 | 2016-10-03T19:47:18.000Z | 2017-11-01T21:05:05.000Z | pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/SinkRecord.java | atlantic2099/pulsar | 66f56f11b9dc9db4c9aeb2caaa40c0ddf542b22b | [
"Apache-2.0"
] | 116 | 2021-08-10T15:25:12.000Z | 2021-08-11T01:05:18.000Z | pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/SinkRecord.java | atlantic2099/pulsar | 66f56f11b9dc9db4c9aeb2caaa40c0ddf542b22b | [
"Apache-2.0"
] | 1 | 2019-03-15T09:34:50.000Z | 2019-03-15T09:34:50.000Z | 25.070588 | 63 | 0.690286 | 12,450 | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.pulsar.functions.instance;
import java.util.Map;
import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.pulsar.functions.api.Record;
@Data
@AllArgsConstructor
public class SinkRecord<T> implements Record<T> {
private final Record<T> sourceRecord;
private final T value;
public Record<T> getSourceRecord() {
return sourceRecord;
}
@Override
public Optional<String> getTopicName() {
return sourceRecord.getTopicName();
}
@Override
public Optional<String> getKey() {
return sourceRecord.getKey();
}
@Override
public T getValue() {
return value;
}
@Override
public Optional<String> getPartitionId() {
return sourceRecord.getPartitionId();
}
@Override
public Optional<Long> getRecordSequence() {
return sourceRecord.getRecordSequence();
}
@Override
public Map<String, String> getProperties() {
return sourceRecord.getProperties();
}
@Override
public void ack() {
sourceRecord.ack();
}
@Override
public void fail() {
sourceRecord.fail();
}
@Override
public Optional<String> getDestinationTopic() {
return sourceRecord.getDestinationTopic();
}
}
|
3e1d5c0a73e257475b031080d37a58e455cbec23 | 2,095 | java | Java | library/src/main/java/com/github/peejweej/androidsideloading/adapters/ShareAdapter.java | PeeJWeeJ/AndroidSideLoading | 0db76a0eb1bf8829d18f5413ad6c838c54fa280a | [
"MIT"
] | 2 | 2015-11-18T22:26:15.000Z | 2015-12-08T14:10:34.000Z | library/src/main/java/com/github/peejweej/androidsideloading/adapters/ShareAdapter.java | PeeJWeeJ/AndroidSideLoading | 0db76a0eb1bf8829d18f5413ad6c838c54fa280a | [
"MIT"
] | null | null | null | library/src/main/java/com/github/peejweej/androidsideloading/adapters/ShareAdapter.java | PeeJWeeJ/AndroidSideLoading | 0db76a0eb1bf8829d18f5413ad6c838c54fa280a | [
"MIT"
] | null | null | null | 29.928571 | 118 | 0.685442 | 12,451 | package com.github.peejweej.androidsideloading.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
import com.github.peejweej.androidsideloading.R;
import com.github.peejweej.androidsideloading.model.SideLoadType;
/**
* Created by PJ Fechner on 7/8/15.
*
*/
public class ShareAdapter extends ArrayAdapter<SideLoadType> {
public ShareAdapter(Context context, List<SideLoadType> objects) {
super(context, R.layout.row_sideloading_share, objects);
}
@Override
public SideLoadType getItem(int position) {
return super.getItem(position);
}
@Override
public View getView(int position, View view, ViewGroup parent) {
// view = super.getView(position, view, parent);
final SideLoadType currentRow = getItem(position);
ViewHolderForGroup holder;
if (view == null) {
holder = new ViewHolderForGroup();
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.row_sideloading_share, null);
holder.labelTextView = (TextView) view.findViewById(R.id.share_label);
holder.iconView = (ImageView) view.findViewById(R.id.share_icon);
view.setTag(holder);
} else {
holder = (ViewHolderForGroup) view.getTag();
}
holder.labelTextView.setText(SideLoadType.getSideLoadName(currentRow));
int icon = SideLoadType.getResourceForType(currentRow);
if(icon > -1){
holder.iconView.setImageResource(icon);
holder.iconView.setVisibility(View.VISIBLE);
}
else{
holder.iconView.setVisibility(View.INVISIBLE);
}
return view;
}
private class ViewHolderForGroup {
private TextView labelTextView;
private ImageView iconView;
}
}
|
3e1d5c56e63e1c1344b1a49efda24a92a2dee5b4 | 236 | java | Java | EvoMaster/e2e-tests/spring-examples/src/test/java/com/foo/rest/examples/spring/positiveinteger/PIController.java | mitchellolsthoorn/ASE-Technical-2021-api-linkage-replication | 50e9fb327fe918cc64c6b5e30d0daa2d9d5d923f | [
"MIT"
] | null | null | null | EvoMaster/e2e-tests/spring-examples/src/test/java/com/foo/rest/examples/spring/positiveinteger/PIController.java | mitchellolsthoorn/ASE-Technical-2021-api-linkage-replication | 50e9fb327fe918cc64c6b5e30d0daa2d9d5d923f | [
"MIT"
] | 7 | 2021-07-15T12:42:54.000Z | 2021-07-15T12:44:15.000Z | EvoMaster/e2e-tests/spring-examples/src/test/java/com/foo/rest/examples/spring/positiveinteger/PIController.java | mitchellolsthoorn/ASE-Technical-2021-api-linkage-replication | 50e9fb327fe918cc64c6b5e30d0daa2d9d5d923f | [
"MIT"
] | 1 | 2021-08-17T06:49:07.000Z | 2021-08-17T06:49:07.000Z | 21.454545 | 53 | 0.758475 | 12,452 | package com.foo.rest.examples.spring.positiveinteger;
import com.foo.rest.examples.spring.SpringController;
public class PIController extends SpringController {
public PIController() {
super(PIApplication.class);
}
}
|
3e1d5cef02082850c6177a49c0cc190a31607caa | 1,445 | java | Java | jdbc/src/main/java/com/kylinolap/jdbc/KylinPrepareImpl.java | oguennec/Kylin | 81eb205ceeab7f5064d18d81a71d34a4c19d0889 | [
"Apache-2.0"
] | null | null | null | jdbc/src/main/java/com/kylinolap/jdbc/KylinPrepareImpl.java | oguennec/Kylin | 81eb205ceeab7f5064d18d81a71d34a4c19d0889 | [
"Apache-2.0"
] | 1 | 2022-01-21T23:48:05.000Z | 2022-01-21T23:48:05.000Z | jdbc/src/main/java/com/kylinolap/jdbc/KylinPrepareImpl.java | oguennec/Kylin | 81eb205ceeab7f5064d18d81a71d34a4c19d0889 | [
"Apache-2.0"
] | null | null | null | 31.413043 | 119 | 0.678201 | 12,453 | /*
* Copyright 2013-2014 eBay Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.kylinolap.jdbc;
import java.util.ArrayList;
import java.util.List;
import net.hydromatic.avatica.AvaticaParameter;
import net.hydromatic.avatica.ColumnMetaData;
/**
* @author xduo
*
*/
public class KylinPrepareImpl implements KylinPrepare {
@Override
public PrepareResult prepare(String sql) {
List<AvaticaParameter> aps = new ArrayList<AvaticaParameter>();
int startIndex = 0;
while (sql.indexOf("?", startIndex) >= 0) {
AvaticaParameter ap = new AvaticaParameter(false, 0, 0, 0, null, null, null);
aps.add(ap);
startIndex = sql.indexOf("?", startIndex) + 1;
}
return new KylinPrepare.PrepareResult(sql, aps, null, ColumnMetaData.struct(new ArrayList<ColumnMetaData>()));
}
}
|
3e1d5d41e4ea8ef1f72650fd647278189f45a26e | 16,594 | java | Java | subprojects/core/src/main/java/org/gradle/api/internal/classpath/DefaultModuleRegistry.java | cldvr/gradle | 91ab08e89cf7cd3c80fbec706eb5629f28e531b6 | [
"Apache-2.0"
] | 2 | 2020-04-01T18:40:33.000Z | 2021-04-23T12:06:15.000Z | subprojects/core/src/main/java/org/gradle/api/internal/classpath/DefaultModuleRegistry.java | richard1230/gradle | f69c3019f27e25ec3b6b462f7fb3d903932351a8 | [
"Apache-2.0"
] | 12 | 2020-07-11T15:43:32.000Z | 2020-10-13T23:39:44.000Z | subprojects/core/src/main/java/org/gradle/api/internal/classpath/DefaultModuleRegistry.java | richard1230/gradle | f69c3019f27e25ec3b6b462f7fb3d903932351a8 | [
"Apache-2.0"
] | 1 | 2020-05-18T14:01:39.000Z | 2020-05-18T14:01:39.000Z | 39.985542 | 203 | 0.635953 | 12,454 | /*
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.api.internal.classpath;
import com.google.common.collect.ImmutableList;
import org.gradle.api.UncheckedIOException;
import org.gradle.api.specs.Spec;
import org.gradle.internal.classpath.ClassPath;
import org.gradle.internal.classpath.DefaultClassPath;
import org.gradle.internal.installation.GradleInstallation;
import org.gradle.internal.vfs.AdditiveCache;
import org.gradle.util.GUtil;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* Determines the classpath for a module by looking for a '${module}-classpath.properties' resource with 'name' set to the name of the module.
*/
public class DefaultModuleRegistry implements ModuleRegistry, AdditiveCache {
private static final Spec<File> SATISFY_ALL = element -> true;
@Nullable
private final GradleInstallation gradleInstallation;
private final Map<String, Module> modules = new HashMap<>();
private final Map<String, Module> externalModules = new HashMap<>();
private final List<File> classpath = new ArrayList<>();
private final Map<String, File> classpathJars = new LinkedHashMap<>();
public DefaultModuleRegistry(@Nullable GradleInstallation gradleInstallation) {
this(ClassPath.EMPTY, gradleInstallation);
}
public DefaultModuleRegistry(ClassPath additionalModuleClassPath, @Nullable GradleInstallation gradleInstallation) {
this(DefaultModuleRegistry.class.getClassLoader(), additionalModuleClassPath, gradleInstallation);
}
private DefaultModuleRegistry(ClassLoader classLoader, ClassPath additionalModuleClassPath, @Nullable GradleInstallation gradleInstallation) {
this.gradleInstallation = gradleInstallation;
for (File classpathFile : new EffectiveClassPath(classLoader).plus(additionalModuleClassPath).getAsFiles()) {
classpath.add(classpathFile);
if (classpathFile.isFile() && !classpathJars.containsKey(classpathFile.getName())) {
classpathJars.put(classpathFile.getName(), classpathFile);
}
}
}
@Override
public List<File> getAdditiveCacheRoots() {
ImmutableList.Builder<File> builder = ImmutableList.builder();
if (gradleInstallation != null) {
builder.addAll(gradleInstallation.getLibDirs());
}
builder.addAll(classpath);
return builder.build();
}
@Override
public ClassPath getAdditionalClassPath() {
return gradleInstallation == null ? DefaultClassPath.of(classpath) : ClassPath.EMPTY;
}
@Override
public Module getExternalModule(String name) {
Module module = externalModules.get(name);
if (module == null) {
module = loadExternalModule(name);
externalModules.put(name, module);
}
return module;
}
private Module loadExternalModule(String name) {
File externalJar = findJar(name, SATISFY_ALL);
if (externalJar == null) {
if (gradleInstallation == null) {
throw new UnknownModuleException(String.format("Cannot locate JAR for module '%s' in classpath: %s.", name, classpath));
}
throw new UnknownModuleException(String.format("Cannot locate JAR for module '%s' in distribution directory '%s'.", name, gradleInstallation.getGradleHome()));
}
return new DefaultModule(name, Collections.singleton(externalJar), Collections.emptySet());
}
@Override
public Module getModule(String name) {
Module module = modules.get(name);
if (module == null) {
module = loadModule(name);
modules.put(name, module);
}
return module;
}
@Override
@Nullable
public Module findModule(String name) {
Module module = modules.get(name);
if (module == null) {
module = loadOptionalModule(name);
if (module != null) {
modules.put(name, module);
}
}
return module;
}
private Module loadModule(String moduleName) {
Module module = loadOptionalModule(moduleName);
if (module != null) {
return module;
}
if (gradleInstallation == null) {
throw new UnknownModuleException(String.format("Cannot locate manifest for module '%s' in classpath: %s.", moduleName, classpath));
}
throw new UnknownModuleException(String.format("Cannot locate JAR for module '%s' in distribution directory '%s'.", moduleName, gradleInstallation.getGradleHome()));
}
private Module loadOptionalModule(final String moduleName) {
File jarFile = findJar(moduleName, jarFile1 -> hasModuleProperties(moduleName, jarFile1));
if (jarFile != null) {
Set<File> implementationClasspath = new LinkedHashSet<>();
implementationClasspath.add(jarFile);
Properties properties = loadModuleProperties(moduleName, jarFile);
return module(moduleName, properties, implementationClasspath);
}
String resourceName = getClasspathManifestName(moduleName);
Set<File> implementationClasspath = new LinkedHashSet<>();
findImplementationClasspath(moduleName, implementationClasspath);
for (File file : implementationClasspath) {
if (file.isDirectory()) {
File propertiesFile = new File(file, resourceName);
if (propertiesFile.isFile()) {
Properties properties = GUtil.loadProperties(propertiesFile);
return module(moduleName, properties, implementationClasspath);
}
}
}
return null;
}
private Module module(String moduleName, Properties properties, Set<File> implementationClasspath) {
String[] runtimeJarNames = split(properties.getProperty("runtime"));
Set<File> runtimeClasspath = findDependencyJars(moduleName, runtimeJarNames);
String[] projects = split(properties.getProperty("projects"));
String[] optionalProjects = split(properties.getProperty("optional"));
return new DefaultModule(moduleName, implementationClasspath, runtimeClasspath, projects, optionalProjects);
}
private Set<File> findDependencyJars(String moduleName, String[] jarNames) {
Set<File> runtimeClasspath = new LinkedHashSet<>();
for (String jarName : jarNames) {
runtimeClasspath.add(findDependencyJar(moduleName, jarName));
}
return runtimeClasspath;
}
private Set<Module> getModules(String[] projectNames) {
Set<Module> modules = new LinkedHashSet<>();
for (String project : projectNames) {
modules.add(getModule(project));
}
return modules;
}
private String[] split(String value) {
if (value == null) {
return new String[0];
}
value = value.trim();
if (value.length() == 0) {
return new String[0];
}
return value.split(",");
}
private void findImplementationClasspath(String name, Collection<File> implementationClasspath) {
String projectDirName = name.startsWith("kotlin-compiler-embeddable-")
? "kotlin-compiler-embeddable"
: projectDirNameFrom(name);
List<String> suffixesForProjectDir = getClasspathSuffixesForProjectDir(projectDirName);
for (File file : classpath) {
if (file.isDirectory()) {
String path = file.getAbsolutePath();
for (String suffix : suffixesForProjectDir) {
if (path.endsWith(suffix)) {
implementationClasspath.add(file);
}
}
}
}
}
private static String projectDirNameFrom(String moduleName) {
Matcher matcher = Pattern.compile("gradle-(.+)").matcher(moduleName);
matcher.matches();
return matcher.group(1);
}
/**
* Provides the locations where the classes and resources of a Gradle module can be found
* when running in embedded mode from the IDE.
*
* <ul>
* <li>In Eclipse, they are in the bin/ folder.</li>
* <li>In IDEA (native import), they are in in the out/production/ folder.</li>
* </ul>
* <li>In both cases we also include the static and generated resources of the project.</li>
*/
private List<String> getClasspathSuffixesForProjectDir(String projectDirName) {
List<String> suffixes = new ArrayList<>();
suffixes.add(("/" + projectDirName + "/out/production/classes").replace('/', File.separatorChar));
suffixes.add(("/" + projectDirName + "/out/production/resources").replace('/', File.separatorChar));
suffixes.add(("/" + projectDirName + "/bin").replace('/', File.separatorChar));
suffixes.add(("/" + projectDirName + "/src/main/resources").replace('/', File.separatorChar));
suffixes.add(("/" + projectDirName + "/build/classes/java/main").replace('/', File.separatorChar));
suffixes.add(("/" + projectDirName + "/build/classes/groovy/main").replace('/', File.separatorChar));
suffixes.add(("/" + projectDirName + "/build/resources/main").replace('/', File.separatorChar));
suffixes.add(("/" + projectDirName + "/build/generated-resources/main").replace('/', File.separatorChar));
suffixes.add(("/" + projectDirName + "/build/generated-resources/test").replace('/', File.separatorChar));
return suffixes;
}
private Properties loadModuleProperties(String name, File jarFile) {
try (ZipFile zipFile = new ZipFile(jarFile)) {
String entryName = getClasspathManifestName(name);
ZipEntry entry = zipFile.getEntry(entryName);
if (entry == null) {
throw new IllegalStateException("Did not find " + entryName + " in " + jarFile.getAbsolutePath());
}
return GUtil.loadProperties(zipFile.getInputStream(entry));
} catch (IOException e) {
throw new UncheckedIOException(String.format("Could not load properties for module '%s' from %s", name, jarFile), e);
}
}
private boolean hasModuleProperties(String name, File jarFile) {
try (ZipFile zipFile = new ZipFile(jarFile)) {
String entryName = getClasspathManifestName(name);
ZipEntry entry = zipFile.getEntry(entryName);
return entry != null;
} catch (IOException e) {
throw new UncheckedIOException(String.format("Could not load properties for module '%s' from %s", name, jarFile), e);
}
}
private String getClasspathManifestName(String moduleName) {
return moduleName + "-classpath.properties";
}
private File findJar(String name, Spec<File> allowedJarFiles) {
Pattern pattern = Pattern.compile(Pattern.quote(name) + "-\\d.*\\.jar");
if (gradleInstallation != null) {
for (File libDir : gradleInstallation.getLibDirs()) {
for (File file : libDir.listFiles()) {
if (pattern.matcher(file.getName()).matches()) {
return file;
}
}
}
}
for (File file : classpath) {
if (pattern.matcher(file.getName()).matches() && allowedJarFiles.isSatisfiedBy(file)) {
return file;
}
}
return null;
}
private File findDependencyJar(String module, String name) {
File jarFile = classpathJars.get(name);
if (jarFile != null) {
return jarFile;
}
if (gradleInstallation == null) {
throw new IllegalArgumentException(String.format("Cannot find JAR '%s' required by module '%s' using classpath.", name, module));
}
for (File libDir : gradleInstallation.getLibDirs()) {
jarFile = new File(libDir, name);
if (jarFile.isFile()) {
return jarFile;
}
}
throw new IllegalArgumentException(String.format("Cannot find JAR '%s' required by module '%s' using classpath or distribution directory '%s'", name, module, gradleInstallation.getGradleHome()));
}
private class DefaultModule implements Module {
private final String name;
private final String[] projects;
private final String[] optionalProjects;
private final ClassPath implementationClasspath;
private final ClassPath runtimeClasspath;
private final ClassPath classpath;
public DefaultModule(String name, Set<File> implementationClasspath, Set<File> runtimeClasspath, String[] projects, String[] optionalProjects) {
this.name = name;
this.projects = projects;
this.optionalProjects = optionalProjects;
this.implementationClasspath = DefaultClassPath.of(implementationClasspath);
this.runtimeClasspath = DefaultClassPath.of(runtimeClasspath);
Set<File> classpath = new LinkedHashSet<>();
classpath.addAll(implementationClasspath);
classpath.addAll(runtimeClasspath);
this.classpath = DefaultClassPath.of(classpath);
}
public DefaultModule(String name, Set<File> singleton, Set<File> files) {
this(name, singleton, files, NO_PROJECTS, NO_PROJECTS);
}
@Override
public String toString() {
return "module '" + name + "'";
}
@Override
public Set<Module> getRequiredModules() {
return getModules(projects);
}
@Override
public ClassPath getImplementationClasspath() {
return implementationClasspath;
}
@Override
public ClassPath getRuntimeClasspath() {
return runtimeClasspath;
}
@Override
public ClassPath getClasspath() {
return classpath;
}
@Override
public Set<Module> getAllRequiredModules() {
Set<Module> modules = new LinkedHashSet<>();
collectRequiredModules(modules);
return modules;
}
@Override
public ClassPath getAllRequiredModulesClasspath() {
ClassPath classPath = ClassPath.EMPTY;
for (Module module : getAllRequiredModules()) {
classPath = classPath.plus(module.getClasspath());
}
return classPath;
}
private void collectRequiredModules(Set<Module> modules) {
if (!modules.add(this)) {
return;
}
for (Module module : getRequiredModules()) {
collectDependenciesOf(module, modules);
}
for (String optionalProject : optionalProjects) {
Module module = findModule(optionalProject);
if (module != null) {
collectDependenciesOf(module, modules);
}
}
}
private void collectDependenciesOf(Module module, Set<Module> modules) {
((DefaultModule) module).collectRequiredModules(modules);
}
private Module findModule(String optionalProject) {
try {
return getModule(optionalProject);
} catch (UnknownModuleException ex) {
return null;
}
}
}
private static final String[] NO_PROJECTS = new String[0];
}
|
3e1d5dc43d65967b3d2ef6e4af8b5fd57808d870 | 883 | java | Java | src/data/event/InstructionGoShop.java | heyao-yang/VOOGASALAD | 2a9322b5cb1edb7221a24bcf459e9a1589af82fc | [
"MIT"
] | 1 | 2021-11-19T12:47:36.000Z | 2021-11-19T12:47:36.000Z | src/data/event/InstructionGoShop.java | NathanBlaise/VoogaSalad-Pokemon-Creator | 2a9322b5cb1edb7221a24bcf459e9a1589af82fc | [
"MIT"
] | null | null | null | src/data/event/InstructionGoShop.java | NathanBlaise/VoogaSalad-Pokemon-Creator | 2a9322b5cb1edb7221a24bcf459e9a1589af82fc | [
"MIT"
] | null | null | null | 24.527778 | 129 | 0.753114 | 12,455 | package data.event;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import data.map.GameMap;
import data.player.Player;
import engine.game.GameScene;
import engine.shop.ShopScene;
/**
* show the shop to the player
* @author cy122
*
*/
public class InstructionGoShop extends Instruction{
private static final long serialVersionUID = 3425297418577947868L; //for serialization
/**
* for serialization
*/
public InstructionGoShop(){
}
@Override
public void execute(int SCREEN_WIDTH, int SCREEN_HEIGHT, Player mainPlayer, GameMap mainMap, Event event, GameScene gameScene) {
ShopScene shopScene = new ShopScene(720,480, gameScene, gameScene.getDatabase().getModel().getItems(), Color.WHITE,mainPlayer);
Stage stage = gameScene.getStage();
stage.setScene(shopScene.getScene());
stage.setHeight(480+20);
stage.setWidth(720);
stage.show();
}
}
|
3e1d5dd5cdf3a3b16b57a23e74a881d2484e39df | 836 | java | Java | src/main/java/chefmod/cards/attacks/FryPan.java | arasmus8/ChefMod | cb0760417c5527e00a1d276809def731ec844d50 | [
"MIT"
] | null | null | null | src/main/java/chefmod/cards/attacks/FryPan.java | arasmus8/ChefMod | cb0760417c5527e00a1d276809def731ec844d50 | [
"MIT"
] | null | null | null | src/main/java/chefmod/cards/attacks/FryPan.java | arasmus8/ChefMod | cb0760417c5527e00a1d276809def731ec844d50 | [
"MIT"
] | null | null | null | 26.967742 | 67 | 0.666268 | 12,456 | package chefmod.cards.attacks;
import chefmod.cards.AbstractChefCard;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import static chefmod.ChefMod.makeID;
public class FryPan extends AbstractChefCard {
public static String ID = makeID(FryPan.class.getSimpleName());
public FryPan() {
super(ID,
1,
CardType.ATTACK,
CardRarity.COMMON,
CardTarget.ENEMY
);
baseDamage = damage = 9;
upgradeDamageBy = 3;
damages = true;
nofreeze = true;
}
@Override
public void use(AbstractPlayer p, AbstractMonster m) {
dealDamage(m, AbstractGameAction.AttackEffect.BLUNT_HEAVY);
}
}
|
3e1d5f1bfbef54439f4bf74a7ff497e230205692 | 1,424 | java | Java | xcloud-iam-security/src/main/java/com/wl4g/iam/sns/CallbackResult.java | wl4g/dopaas-iam | 45d426d5c3459169b59dd3f1b8cf793008e55ce8 | [
"Apache-2.0"
] | 3 | 2020-08-02T13:39:06.000Z | 2021-11-05T09:16:00.000Z | xcloud-iam-security/src/main/java/com/wl4g/iam/sns/CallbackResult.java | wl4g/dopaas-iam | 45d426d5c3459169b59dd3f1b8cf793008e55ce8 | [
"Apache-2.0"
] | null | null | null | xcloud-iam-security/src/main/java/com/wl4g/iam/sns/CallbackResult.java | wl4g/dopaas-iam | 45d426d5c3459169b59dd3f1b8cf793008e55ce8 | [
"Apache-2.0"
] | 1 | 2021-12-23T06:32:14.000Z | 2021-12-23T06:32:14.000Z | 26.886792 | 95 | 0.712281 | 12,457 | /*
* Copyright 2017 ~ 2025 the original author or authors. <efpyi@example.com, ychag@example.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wl4g.iam.sns;
import static com.wl4g.component.common.lang.Assert2.hasTextOf;
import static org.apache.commons.lang3.StringUtils.isBlank;
/**
* {@link CallbackResult}
*
* @author Wangl.sir <efpyi@example.com, 983708408@qq.com>
* @version 2020年2月7日 v1.0.0
* @see
*/
public class CallbackResult {
/**
* OAuth2 callback refreshUrl
*/
final private String refreshUrl;
public CallbackResult(String refreshUrl) {
hasTextOf(refreshUrl, "SNS oauth2 refreshUrl");
this.refreshUrl = refreshUrl;
}
public boolean hasRefreshUrl() {
return !isBlank(getRefreshUrl());
}
public String getRefreshUrl() {
return refreshUrl;
}
@Override
public String toString() {
return refreshUrl;
}
} |
3e1d5f304660c51267e9f342fb88607ba62bb905 | 3,824 | java | Java | app/src/main/java/com/daydream/lazyloadfragment/fragment/LazyLoadFragment.java | 10ydaydream/LazyLoadFragment | 5b11d6469c22fa83aaf526fa93f15c41af451a2e | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/daydream/lazyloadfragment/fragment/LazyLoadFragment.java | 10ydaydream/LazyLoadFragment | 5b11d6469c22fa83aaf526fa93f15c41af451a2e | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/daydream/lazyloadfragment/fragment/LazyLoadFragment.java | 10ydaydream/LazyLoadFragment | 5b11d6469c22fa83aaf526fa93f15c41af451a2e | [
"Apache-2.0"
] | null | null | null | 26.191781 | 132 | 0.648797 | 12,458 | package com.daydream.lazyloadfragment.fragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
*
* ViewPager + 多Fragment 会造成Fragment的生命周期回调与常规单独显示Fragment不同
* 所以在ViewPager + 多Fragment的情况下, 需要重新定义生命周期过程内的操作
* 将一些特定的操作(耗时的)放到在Fragment显示的时候才进行
*
* Fragment显示、隐藏的api有两种:setUserVisibleHint和通过FragmentTransaction的show和hide的方法
* 后者实际显示和生命周期基本是相对应的
*
* 注意:
* 1.有可能setUserVisibleHint方法执行时,onCreateView、onViewCreated并未执行完(也就是UI没有创建好)
* 2.当ViewPager中Fragment列表有3个及以上的实例时, 默认情况下系统只会保存当前显示Fragment实例和左右相邻的Fragment实例的Layout
* 其他的Fragment会执行onPause->onStop->onDestroyView对layout进行回收来节省内存。
*
* */
public class LazyLoadFragment extends Fragment {
public String TAG = "LazyLoadingFragment";
/**
* 上一次可见状态
*/
protected boolean mLastVisible;
/**
* 标志是否第一次调用setUserVisibleHint方法
*/
private boolean isFirstSetVisible = true;
/**
* 是否第一次可见
* */
private boolean isFirstVisible = false;
/**
* Fragment实例载入的Layout
* */
private View mRootView = null;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
Log.i(TAG, "onCreateView: ");
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
/*在onCreateView之后调用*/
super.onViewCreated(view, savedInstanceState);
mRootView = view;
/**
* 第一次加载的时候, 可能会先调用了setUserVisibleHint方法, 再创建布局UI
* */
if (getUserVisibleHint() && isFirstVisible) {
isFirstVisible = false;
onVisible();
}
}
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
/*
* 调用setUserVisibleHint方法的情况:
* 1.创建Fragment实例时,会调用一次,传入false
* 2.当前Fragment可见,会调用一次,传入true
* 3.当前Fragment从可见->不可见, 会调用一次,传入false
* 4.当前Fragment不可见时,其他Fragment切换可见状态时也有可能导致当前Fragment会调用一次setUserVisibleHint方法,传入false;一般是相邻的Fragment实例可见状态变化的情况下发生
* (也就是说受影响的是当前正在显示的Fragment以及左右相邻两个的Fragment)
* */
mLastVisible = getUserVisibleHint();
super.setUserVisibleHint(isVisibleToUser);
if (isFirstSetVisible) {
mLastVisible = getUserVisibleHint();
isFirstSetVisible = false;
return;
}
if (mLastVisible == getUserVisibleHint()) {
return;
}
/*
* 1.第一次显示时, 由于setUserVisibleHint和onCreateView方法的调用顺序问题(先setUserVisibleHint, 后onCreateView)
* 导致可能在这个判断就返回
* 2.当Fragment切换到隐藏的状态时, 长时间没有切换回显示状态,系统可能会回收Fragment的Layout, 回收后再切换回显示状态的话需要重新加载Layout
*
* mRootView不为null时, 表示Fragment已经加载过layout
* */
Log.i(TAG, "setUserVisibleHint: mRootView:"+ mRootView);
if (mRootView == null) {
isFirstVisible = true;
return;
}else{
isFirstVisible = false;
}
/*
*
* */
if (getUserVisibleHint()) {
onVisible();
} else {
onInvisible();
}
}
/**
* 不可见->可见
*/
public void onVisible() {
}
/**
* 可见->不可见
*/
public void onInvisible() {
}
/*
* 在多个Fragment的情况下, Android系统为了减少内存占用,会调用onDestroyView方法来销毁UI显示
* 这也是为什么有时候从一个FragmentA切换到其他Fragment一段时间后,再切换回FragmentA时FragmentA的界面是空白
* */
@Override
public void onDestroyView() {
super.onDestroyView();
mRootView = null;
}
}
|
3e1d5ffaed6ead0505f2a751e9d0a8dc3668d083 | 1,409 | java | Java | src/main/java8/net/finmath/modelling/descriptor/InterestRateSwapProductDescriptor.java | xiayingfeng/finmath-lib | 49b71c512775b786f54d33dc828c2e0d1e701883 | [
"Apache-2.0"
] | 373 | 2015-01-01T11:27:51.000Z | 2022-03-29T21:51:49.000Z | src/main/java8/net/finmath/modelling/descriptor/InterestRateSwapProductDescriptor.java | xiayingfeng/finmath-lib | 49b71c512775b786f54d33dc828c2e0d1e701883 | [
"Apache-2.0"
] | 67 | 2015-01-21T08:52:23.000Z | 2021-09-22T20:13:11.000Z | src/main/java8/net/finmath/modelling/descriptor/InterestRateSwapProductDescriptor.java | xiayingfeng/finmath-lib | 49b71c512775b786f54d33dc828c2e0d1e701883 | [
"Apache-2.0"
] | 184 | 2015-01-05T17:30:18.000Z | 2022-03-28T10:55:29.000Z | 22.725806 | 90 | 0.753016 | 12,459 | package net.finmath.modelling.descriptor;
import net.finmath.modelling.InterestRateProductDescriptor;
/**
* Product descriptor for an interest rate swap.
*
* @author Christian Fries
* @author Roland Bachl
* @version 1.0
*/
public class InterestRateSwapProductDescriptor implements InterestRateProductDescriptor {
private static final String productName = "Interest Rate Swap";
private final InterestRateProductDescriptor legReceiver;
private final InterestRateProductDescriptor legPayer;
/**
* Construct a swap product descriptor from the descriptors of its legs.
*
* @param legReceiver The descriptor of the receiver leg.
* @param legPayer The descriptor of the payer leg.
*/
public InterestRateSwapProductDescriptor(final InterestRateProductDescriptor legReceiver,
final InterestRateProductDescriptor legPayer) {
super();
this.legReceiver = legReceiver;
this.legPayer = legPayer;
}
/**
* Return the descriptor of the receiver leg of this swap.
*
* @return The leg descriptor.
*/
public InterestRateProductDescriptor getLegReceiver() {
return legReceiver;
}
/**
* Return the descriptor of the payer leg of this swap.
*
* @return The leg descriptor.
*/
public InterestRateProductDescriptor getLegPayer() {
return legPayer;
}
@Override
public Integer version() {
return 1;
}
@Override
public String name() {
return productName;
}
}
|
3e1d602df9b850a689fc9e6f9d72ab447a745ae3 | 2,467 | java | Java | platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SdkSetupNotificationProvider.java | nokok/intellij-community | 84443a8468565db7fc719e077093059740456982 | [
"Apache-2.0"
] | 1 | 2018-10-13T19:43:36.000Z | 2018-10-13T19:43:36.000Z | platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SdkSetupNotificationProvider.java | nokok/intellij-community | 84443a8468565db7fc719e077093059740456982 | [
"Apache-2.0"
] | null | null | null | platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SdkSetupNotificationProvider.java | nokok/intellij-community | 84443a8468565db7fc719e077093059740456982 | [
"Apache-2.0"
] | null | null | null | 38.546875 | 140 | 0.773814 | 12,460 | // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.daemon.impl;
import com.intellij.ProjectTopics;
import com.intellij.codeInsight.daemon.ProjectSdkSetupValidator;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.ModuleRootEvent;
import com.intellij.openapi.roots.ModuleRootListener;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorNotificationPanel;
import com.intellij.ui.EditorNotifications;
import org.jetbrains.annotations.NotNull;
/**
* @author Danila Ponomarenko
*/
public class SdkSetupNotificationProvider extends EditorNotifications.Provider<EditorNotificationPanel> implements DumbAware {
public static final Key<EditorNotificationPanel> KEY = Key.create("SdkSetupNotification");
private final Project myProject;
public SdkSetupNotificationProvider(Project project, final EditorNotifications notifications) {
myProject = project;
myProject.getMessageBus().connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
@Override
public void rootsChanged(@NotNull ModuleRootEvent event) {
notifications.updateAllNotifications();
}
});
}
@NotNull
@Override
public Key<EditorNotificationPanel> getKey() {
return KEY;
}
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
for (ProjectSdkSetupValidator validator : ProjectSdkSetupValidator.PROJECT_SDK_SETUP_VALIDATOR_EP.getExtensionList()) {
if (validator.isApplicableFor(myProject, file)) {
final String errorMessage = validator.getErrorMessage(myProject, file);
if (errorMessage != null) {
return createPanel(errorMessage, () -> validator.doFix(myProject, file));
}
return null;
}
}
return null;
}
@NotNull
private static EditorNotificationPanel createPanel(@NotNull String message, @NotNull Runnable fix) {
EditorNotificationPanel panel = new EditorNotificationPanel();
panel.setText(message);
panel.createActionLabel(ProjectBundle.message("project.sdk.setup"), fix);
return panel;
}
} |
3e1d60fd65e9eb079b91cccc1e47fb393fa54d7e | 1,588 | java | Java | library/src/main/java/com/github/siyamed/shapeimageview/ShapeImageView.java | eaaomk/android-shape-imageview | c4e0a94a62bdcf123506e4596e648265a9c12a26 | [
"MIT"
] | 2,541 | 2015-01-01T00:25:52.000Z | 2022-03-29T01:14:43.000Z | library/src/main/java/com/github/siyamed/shapeimageview/ShapeImageView.java | eaaomk/android-shape-imageview | c4e0a94a62bdcf123506e4596e648265a9c12a26 | [
"MIT"
] | 79 | 2015-01-09T06:49:39.000Z | 2021-11-02T23:40:34.000Z | library/src/main/java/com/github/siyamed/shapeimageview/ShapeImageView.java | eaaomk/android-shape-imageview | c4e0a94a62bdcf123506e4596e648265a9c12a26 | [
"MIT"
] | 660 | 2015-01-03T09:38:20.000Z | 2022-03-29T01:14:47.000Z | 24.060606 | 78 | 0.617128 | 12,461 | package com.github.siyamed.shapeimageview;
import android.content.Context;
import android.util.AttributeSet;
import com.github.siyamed.shapeimageview.shader.ShaderHelper;
import com.github.siyamed.shapeimageview.shader.SvgShader;
public class ShapeImageView extends ShaderImageView {
private SvgShader shader;
public ShapeImageView(Context context) {
super(context);
}
public ShapeImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ShapeImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public ShaderHelper createImageViewHelper() {
shader = new SvgShader();
return shader;
}
public void setStrokeMiter(int strokeMiter) {
if(shader != null) {
shader.setStrokeMiter(strokeMiter);
invalidate();
}
}
public void setStrokeCap(int strokeCap) {
if(shader != null) {
shader.setStrokeCap(strokeCap);
invalidate();
}
}
public void setStrokeJoin(int strokeJoin) {
if(shader != null) {
shader.setStrokeJoin(strokeJoin);
invalidate();
}
}
public void setBorderType(int borderType) {
if(shader != null) {
shader.setBorderType(borderType);
invalidate();
}
}
public void setShapeResId(int resId) {
if(shader != null) {
shader.setShapeResId(getContext(), resId);
invalidate();
}
}
}
|
3e1d61ca7002327f005ca89d6ab1a2d4d1349cbc | 1,478 | java | Java | ghost.framework.core/src/main/java/ghost/framework/core/module/maven/ModuleFileArtifact.java | guoshucan/mpaas | 8949c0c484987d9c030595b24d62a10585a814ce | [
"Apache-2.0"
] | 1 | 2020-09-29T10:24:03.000Z | 2020-09-29T10:24:03.000Z | ghost.framework.core/src/main/java/ghost/framework/core/module/maven/ModuleFileArtifact.java | guoshucan/mpaas | 8949c0c484987d9c030595b24d62a10585a814ce | [
"Apache-2.0"
] | null | null | null | ghost.framework.core/src/main/java/ghost/framework/core/module/maven/ModuleFileArtifact.java | guoshucan/mpaas | 8949c0c484987d9c030595b24d62a10585a814ce | [
"Apache-2.0"
] | 3 | 2020-11-05T15:52:17.000Z | 2021-07-27T04:37:00.000Z | 19.972973 | 85 | 0.602842 | 12,462 | package ghost.framework.core.module.maven;
import ghost.framework.context.module.IModule;
import ghost.framework.maven.FileArtifact;
import org.eclipse.aether.artifact.Artifact;
/**
* package: ghost.framework.core.module.maven
*
* @Author: 郭树灿{guo-w541}
* @link: 手机:13715848993, QQ 27048384
* @Description:模块文件包信息
* @Date: 11:10 2020/1/24
*/
public class ModuleFileArtifact extends FileArtifact implements IModuleFileArtifact {
/**
* 初始化模块文件包信息
* @param artifact 包信息
*/
public ModuleFileArtifact(String artifact) {
super(artifact);
}
/**
* 初始化模块文件包信息
* @param artifact 包信息
*/
public ModuleFileArtifact(Artifact artifact) {
super(artifact);
}
/**
* 初始化模块文件包信息
* @param artifact 包信息
* @param module 模块接口
*/
public ModuleFileArtifact(String artifact, IModule module) {
super(artifact);
this.module = module;
}
/**
* 初始化模块文件包信息
* @param artifact 包信息
* @param module 模块接口
*/
public ModuleFileArtifact(Artifact artifact, IModule module) {
super(artifact);
this.module = module;
}
/**
* 模块接口
*/
private IModule module;
/**
* 获取模块接口
* @return
*/
@Override
public IModule getModule() {
return module;
}
/**
* 设置模块接口
* @param module
*/
@Override
public void setModule(IModule module) {
this.module = module;
}
} |
3e1d6253dc7670108137853cb1d0f485cdb0ff3c | 51,655 | java | Java | lab4/src/main/antlr4/GrammarParser.java | AlexeyShik/Translation-Methods | c205ec471c097517f3551480d6a2dd31e8de677d | [
"MIT"
] | null | null | null | lab4/src/main/antlr4/GrammarParser.java | AlexeyShik/Translation-Methods | c205ec471c097517f3551480d6a2dd31e8de677d | [
"MIT"
] | null | null | null | lab4/src/main/antlr4/GrammarParser.java | AlexeyShik/Translation-Methods | c205ec471c097517f3551480d6a2dd31e8de677d | [
"MIT"
] | null | null | null | 34.16336 | 453 | 0.653257 | 12,463 | // Generated from Grammar.g4 by ANTLR 4.9.2
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class GrammarParser extends Parser {
static { RuntimeMetaData.checkVersion("4.9.2", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
WS=1, ENDL=2, COLON=3, ARROW=4, TYPE=5, BEFORE=6, INSIDE=7, AFTER=8, TERMINAL_OPS=9,
NON_TERMINAL=10, TERMINAL=11, NUMBER=12, REGEXP=13, EPS=14, LBRACKET=15,
RBRACKET=16, SHARP=17, OTHER=18, ALPHANUM=19, ALL=20, REG_CONTENT=21;
public static final int
RULE_prog = 0, RULE_parser_rules = 1, RULE_attributes = 2, RULE_lexer_rules = 3,
RULE_right_part_parser = 4, RULE_right_part_lexer = 5, RULE_field_declarations = 6;
private static String[] makeRuleNames() {
return new String[] {
"prog", "parser_rules", "attributes", "lexer_rules", "right_part_parser",
"right_part_lexer", "field_declarations"
};
}
public static final String[] ruleNames = makeRuleNames();
private static String[] makeLiteralNames() {
return new String[] {
null, "' '", null, "':'", "'->'", null, "'@before'", "'@inside'", "'@after'",
null, null, null, null, "'\\\\reg'", "'\\\\eps'", "'{'", "'}'", "'#'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, "WS", "ENDL", "COLON", "ARROW", "TYPE", "BEFORE", "INSIDE", "AFTER",
"TERMINAL_OPS", "NON_TERMINAL", "TERMINAL", "NUMBER", "REGEXP", "EPS",
"LBRACKET", "RBRACKET", "SHARP", "OTHER", "ALPHANUM", "ALL", "REG_CONTENT"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
/**
* @deprecated Use {@link #VOCABULARY} instead.
*/
@Deprecated
public static final String[] tokenNames;
static {
tokenNames = new String[_SYMBOLIC_NAMES.length];
for (int i = 0; i < tokenNames.length; i++) {
tokenNames[i] = VOCABULARY.getLiteralName(i);
if (tokenNames[i] == null) {
tokenNames[i] = VOCABULARY.getSymbolicName(i);
}
if (tokenNames[i] == null) {
tokenNames[i] = "<INVALID>";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
public Vocabulary getVocabulary() {
return VOCABULARY;
}
@Override
public String getGrammarFileName() { return "Grammar.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public ATN getATN() { return _ATN; }
public GrammarParser(TokenStream input) {
super(input);
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
public static class ProgContext extends ParserRuleContext {
public java.util.List<model.ParserRule> parserRules;
public java.util.List<model.LexerRule> lexerRules;
public java.util.Map<String, String> fieldDeclarations;
public java.util.Set<String> inherited;
public Field_declarationsContext field_declarations;
public Parser_rulesContext parser_rules;
public Lexer_rulesContext lexer_rules;
public Field_declarationsContext field_declarations() {
return getRuleContext(Field_declarationsContext.class,0);
}
public Parser_rulesContext parser_rules() {
return getRuleContext(Parser_rulesContext.class,0);
}
public Lexer_rulesContext lexer_rules() {
return getRuleContext(Lexer_rulesContext.class,0);
}
public List<TerminalNode> ENDL() { return getTokens(GrammarParser.ENDL); }
public TerminalNode ENDL(int i) {
return getToken(GrammarParser.ENDL, i);
}
public ProgContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_prog; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterProg(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitProg(this);
}
}
public final ProgContext prog() throws RecognitionException {
ProgContext _localctx = new ProgContext(_ctx, getState());
enterRule(_localctx, 0, RULE_prog);
((ProgContext)_localctx).parserRules = new java.util.ArrayList<>();
((ProgContext)_localctx).lexerRules = new java.util.ArrayList<>();
((ProgContext)_localctx).fieldDeclarations = new java.util.HashMap<>();
((ProgContext)_localctx).inherited = new java.util.HashSet<>();
int _la;
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(14);
((ProgContext)_localctx).field_declarations = field_declarations();
((ProgContext)_localctx).fieldDeclarations = new java.util.HashMap<>();
for (java.util.Map.Entry<String, java.util.Set<String>> entry : ((ProgContext)_localctx).field_declarations.value.entrySet()) {
String accum = "";
for (String s : entry.getValue()) {
accum += s;
}
_localctx.fieldDeclarations.put(entry.getKey(), accum);
}
((ProgContext)_localctx).inherited = ((ProgContext)_localctx).field_declarations.inherited;
setState(19);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,0,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(16);
match(ENDL);
}
}
}
setState(21);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,0,_ctx);
}
setState(22);
((ProgContext)_localctx).parser_rules = parser_rules(_localctx.inherited);
((ProgContext)_localctx).parserRules = ((ProgContext)_localctx).parser_rules.rules;
setState(27);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,1,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(24);
match(ENDL);
}
}
}
setState(29);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,1,_ctx);
}
setState(30);
((ProgContext)_localctx).lexer_rules = lexer_rules();
((ProgContext)_localctx).lexerRules = ((ProgContext)_localctx).lexer_rules.rules;
setState(35);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==ENDL) {
{
{
setState(32);
match(ENDL);
}
}
setState(37);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class Parser_rulesContext extends ParserRuleContext {
public java.util.Set<String> inherited;
public java.util.List<model.ParserRule> rules;
public String pre;
public String in;
public String post;
public Integer pos;
public Token NON_TERMINAL;
public Right_part_parserContext right_part_parser;
public AttributesContext before;
public Token NUMBER;
public AttributesContext inside;
public AttributesContext after;
public List<TerminalNode> NON_TERMINAL() { return getTokens(GrammarParser.NON_TERMINAL); }
public TerminalNode NON_TERMINAL(int i) {
return getToken(GrammarParser.NON_TERMINAL, i);
}
public List<TerminalNode> ARROW() { return getTokens(GrammarParser.ARROW); }
public TerminalNode ARROW(int i) {
return getToken(GrammarParser.ARROW, i);
}
public List<Right_part_parserContext> right_part_parser() {
return getRuleContexts(Right_part_parserContext.class);
}
public Right_part_parserContext right_part_parser(int i) {
return getRuleContext(Right_part_parserContext.class,i);
}
public List<TerminalNode> WS() { return getTokens(GrammarParser.WS); }
public TerminalNode WS(int i) {
return getToken(GrammarParser.WS, i);
}
public List<TerminalNode> BEFORE() { return getTokens(GrammarParser.BEFORE); }
public TerminalNode BEFORE(int i) {
return getToken(GrammarParser.BEFORE, i);
}
public List<TerminalNode> INSIDE() { return getTokens(GrammarParser.INSIDE); }
public TerminalNode INSIDE(int i) {
return getToken(GrammarParser.INSIDE, i);
}
public List<TerminalNode> NUMBER() { return getTokens(GrammarParser.NUMBER); }
public TerminalNode NUMBER(int i) {
return getToken(GrammarParser.NUMBER, i);
}
public List<TerminalNode> AFTER() { return getTokens(GrammarParser.AFTER); }
public TerminalNode AFTER(int i) {
return getToken(GrammarParser.AFTER, i);
}
public List<AttributesContext> attributes() {
return getRuleContexts(AttributesContext.class);
}
public AttributesContext attributes(int i) {
return getRuleContext(AttributesContext.class,i);
}
public Parser_rulesContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
public Parser_rulesContext(ParserRuleContext parent, int invokingState, java.util.Set<String> inherited) {
super(parent, invokingState);
this.inherited = inherited;
}
@Override public int getRuleIndex() { return RULE_parser_rules; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterParser_rules(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitParser_rules(this);
}
}
public final Parser_rulesContext parser_rules(java.util.Set<String> inherited) throws RecognitionException {
Parser_rulesContext _localctx = new Parser_rulesContext(_ctx, getState(), inherited);
enterRule(_localctx, 2, RULE_parser_rules);
((Parser_rulesContext)_localctx).rules = new java.util.ArrayList<>();
((Parser_rulesContext)_localctx).pre = null;
((Parser_rulesContext)_localctx).in = null;
((Parser_rulesContext)_localctx).post = null;
((Parser_rulesContext)_localctx).pos = -1;
int _la;
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(98);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==NON_TERMINAL) {
{
{
setState(38);
((Parser_rulesContext)_localctx).NON_TERMINAL = match(NON_TERMINAL);
setState(40);
_errHandler.sync(this);
_la = _input.LA(1);
do {
{
{
setState(39);
match(WS);
}
}
setState(42);
_errHandler.sync(this);
_la = _input.LA(1);
} while ( _la==WS );
setState(44);
match(ARROW);
setState(46);
_errHandler.sync(this);
_alt = 1;
do {
switch (_alt) {
case 1:
{
{
setState(45);
match(WS);
}
}
break;
default:
throw new NoViableAltException(this);
}
setState(48);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,4,_ctx);
} while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER );
setState(50);
((Parser_rulesContext)_localctx).right_part_parser = right_part_parser(_localctx.inherited);
setState(54);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,5,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(51);
match(WS);
}
}
}
setState(56);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,5,_ctx);
}
{
setState(61);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==BEFORE) {
{
setState(57);
match(BEFORE);
setState(58);
((Parser_rulesContext)_localctx).before = attributes();
((Parser_rulesContext)_localctx).pre = ((Parser_rulesContext)_localctx).before.value;
}
}
setState(66);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,7,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(63);
match(WS);
}
}
}
setState(68);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,7,_ctx);
}
setState(80);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==INSIDE) {
{
setState(69);
match(INSIDE);
setState(73);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS) {
{
{
setState(70);
match(WS);
}
}
setState(75);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(76);
((Parser_rulesContext)_localctx).NUMBER = match(NUMBER);
setState(77);
((Parser_rulesContext)_localctx).inside = attributes();
((Parser_rulesContext)_localctx).in = ((Parser_rulesContext)_localctx).inside.value;
((Parser_rulesContext)_localctx).pos = Integer.parseInt((((Parser_rulesContext)_localctx).NUMBER!=null?((Parser_rulesContext)_localctx).NUMBER.getText():null));
}
}
setState(85);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS) {
{
{
setState(82);
match(WS);
}
}
setState(87);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(92);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==AFTER) {
{
setState(88);
match(AFTER);
setState(89);
((Parser_rulesContext)_localctx).after = attributes();
((Parser_rulesContext)_localctx).post = ((Parser_rulesContext)_localctx).after.value;
}
}
}
_localctx.rules.add(new model.ParserRule(new model.NonTerm((((Parser_rulesContext)_localctx).NON_TERMINAL!=null?((Parser_rulesContext)_localctx).NON_TERMINAL.getText():null), _localctx.inherited.contains((((Parser_rulesContext)_localctx).NON_TERMINAL!=null?((Parser_rulesContext)_localctx).NON_TERMINAL.getText():null))), ((Parser_rulesContext)_localctx).right_part_parser.value, _localctx.pre, _localctx.in, _localctx.post, _localctx.pos));
((Parser_rulesContext)_localctx).pre = null;
((Parser_rulesContext)_localctx).in = null;
((Parser_rulesContext)_localctx).post = null;
((Parser_rulesContext)_localctx).pos = -1;
}
}
setState(100);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class AttributesContext extends ParserRuleContext {
public String value;
public String accum;
public Token WS;
public Token ENDL;
public Token TERMINAL;
public Token NON_TERMINAL;
public Token NUMBER;
public Token LBRACKET;
public Token RBRACKET;
public Token TERMINAL_OPS;
public Token TYPE;
public Token OTHER;
public TerminalNode COLON() { return getToken(GrammarParser.COLON, 0); }
public TerminalNode SHARP() { return getToken(GrammarParser.SHARP, 0); }
public List<TerminalNode> WS() { return getTokens(GrammarParser.WS); }
public TerminalNode WS(int i) {
return getToken(GrammarParser.WS, i);
}
public List<TerminalNode> ENDL() { return getTokens(GrammarParser.ENDL); }
public TerminalNode ENDL(int i) {
return getToken(GrammarParser.ENDL, i);
}
public List<TerminalNode> TERMINAL() { return getTokens(GrammarParser.TERMINAL); }
public TerminalNode TERMINAL(int i) {
return getToken(GrammarParser.TERMINAL, i);
}
public List<TerminalNode> NON_TERMINAL() { return getTokens(GrammarParser.NON_TERMINAL); }
public TerminalNode NON_TERMINAL(int i) {
return getToken(GrammarParser.NON_TERMINAL, i);
}
public List<TerminalNode> NUMBER() { return getTokens(GrammarParser.NUMBER); }
public TerminalNode NUMBER(int i) {
return getToken(GrammarParser.NUMBER, i);
}
public List<TerminalNode> LBRACKET() { return getTokens(GrammarParser.LBRACKET); }
public TerminalNode LBRACKET(int i) {
return getToken(GrammarParser.LBRACKET, i);
}
public List<TerminalNode> RBRACKET() { return getTokens(GrammarParser.RBRACKET); }
public TerminalNode RBRACKET(int i) {
return getToken(GrammarParser.RBRACKET, i);
}
public List<TerminalNode> TERMINAL_OPS() { return getTokens(GrammarParser.TERMINAL_OPS); }
public TerminalNode TERMINAL_OPS(int i) {
return getToken(GrammarParser.TERMINAL_OPS, i);
}
public List<TerminalNode> TYPE() { return getTokens(GrammarParser.TYPE); }
public TerminalNode TYPE(int i) {
return getToken(GrammarParser.TYPE, i);
}
public List<TerminalNode> OTHER() { return getTokens(GrammarParser.OTHER); }
public TerminalNode OTHER(int i) {
return getToken(GrammarParser.OTHER, i);
}
public AttributesContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_attributes; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterAttributes(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitAttributes(this);
}
}
public final AttributesContext attributes() throws RecognitionException {
AttributesContext _localctx = new AttributesContext(_ctx, getState());
enterRule(_localctx, 4, RULE_attributes);
((AttributesContext)_localctx).value = ""; ((AttributesContext)_localctx).accum = "";
int _la;
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(104);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS) {
{
{
setState(101);
((AttributesContext)_localctx).WS = match(WS);
}
}
setState(106);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(107);
match(COLON);
setState(111);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,14,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(108);
((AttributesContext)_localctx).ENDL = match(ENDL);
}
}
}
setState(113);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,14,_ctx);
}
setState(117);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,15,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(114);
((AttributesContext)_localctx).WS = match(WS);
}
}
}
setState(119);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,15,_ctx);
}
setState(140);
_errHandler.sync(this);
_la = _input.LA(1);
do {
{
setState(140);
_errHandler.sync(this);
switch (_input.LA(1)) {
case TERMINAL:
{
setState(120);
((AttributesContext)_localctx).TERMINAL = match(TERMINAL);
_localctx.accum += (((AttributesContext)_localctx).TERMINAL!=null?((AttributesContext)_localctx).TERMINAL.getText():null);
}
break;
case NON_TERMINAL:
{
setState(122);
((AttributesContext)_localctx).NON_TERMINAL = match(NON_TERMINAL);
_localctx.accum += (((AttributesContext)_localctx).NON_TERMINAL!=null?((AttributesContext)_localctx).NON_TERMINAL.getText():null);
}
break;
case NUMBER:
{
setState(124);
((AttributesContext)_localctx).NUMBER = match(NUMBER);
_localctx.accum += (((AttributesContext)_localctx).NUMBER!=null?((AttributesContext)_localctx).NUMBER.getText():null);
}
break;
case LBRACKET:
{
setState(126);
((AttributesContext)_localctx).LBRACKET = match(LBRACKET);
_localctx.accum += (((AttributesContext)_localctx).LBRACKET!=null?((AttributesContext)_localctx).LBRACKET.getText():null);
}
break;
case RBRACKET:
{
setState(128);
((AttributesContext)_localctx).RBRACKET = match(RBRACKET);
_localctx.accum += (((AttributesContext)_localctx).RBRACKET!=null?((AttributesContext)_localctx).RBRACKET.getText():null);
}
break;
case TERMINAL_OPS:
{
setState(130);
((AttributesContext)_localctx).TERMINAL_OPS = match(TERMINAL_OPS);
_localctx.accum += (((AttributesContext)_localctx).TERMINAL_OPS!=null?((AttributesContext)_localctx).TERMINAL_OPS.getText():null);
}
break;
case TYPE:
{
setState(132);
((AttributesContext)_localctx).TYPE = match(TYPE);
_localctx.accum += (((AttributesContext)_localctx).TYPE!=null?((AttributesContext)_localctx).TYPE.getText():null);
}
break;
case OTHER:
{
setState(134);
((AttributesContext)_localctx).OTHER = match(OTHER);
_localctx.accum += (((AttributesContext)_localctx).OTHER!=null?((AttributesContext)_localctx).OTHER.getText():null);
}
break;
case WS:
{
setState(136);
((AttributesContext)_localctx).WS = match(WS);
_localctx.accum += (((AttributesContext)_localctx).WS!=null?((AttributesContext)_localctx).WS.getText():null);
}
break;
case ENDL:
{
setState(138);
((AttributesContext)_localctx).ENDL = match(ENDL);
_localctx.accum += (((AttributesContext)_localctx).ENDL!=null?((AttributesContext)_localctx).ENDL.getText():null);
}
break;
default:
throw new NoViableAltException(this);
}
}
setState(142);
_errHandler.sync(this);
_la = _input.LA(1);
} while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << WS) | (1L << ENDL) | (1L << TYPE) | (1L << TERMINAL_OPS) | (1L << NON_TERMINAL) | (1L << TERMINAL) | (1L << NUMBER) | (1L << LBRACKET) | (1L << RBRACKET) | (1L << OTHER))) != 0) );
setState(144);
match(SHARP);
setState(148);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,18,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(145);
((AttributesContext)_localctx).ENDL = match(ENDL);
}
}
}
setState(150);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,18,_ctx);
}
setState(154);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,19,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(151);
((AttributesContext)_localctx).WS = match(WS);
}
}
}
setState(156);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,19,_ctx);
}
((AttributesContext)_localctx).value = _localctx.accum;
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class Lexer_rulesContext extends ParserRuleContext {
public java.util.List<model.LexerRule> rules;
public Token TERMINAL;
public Right_part_lexerContext right_part_lexer;
public List<TerminalNode> TERMINAL() { return getTokens(GrammarParser.TERMINAL); }
public TerminalNode TERMINAL(int i) {
return getToken(GrammarParser.TERMINAL, i);
}
public List<TerminalNode> COLON() { return getTokens(GrammarParser.COLON); }
public TerminalNode COLON(int i) {
return getToken(GrammarParser.COLON, i);
}
public List<Right_part_lexerContext> right_part_lexer() {
return getRuleContexts(Right_part_lexerContext.class);
}
public Right_part_lexerContext right_part_lexer(int i) {
return getRuleContext(Right_part_lexerContext.class,i);
}
public List<TerminalNode> WS() { return getTokens(GrammarParser.WS); }
public TerminalNode WS(int i) {
return getToken(GrammarParser.WS, i);
}
public Lexer_rulesContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_lexer_rules; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterLexer_rules(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitLexer_rules(this);
}
}
public final Lexer_rulesContext lexer_rules() throws RecognitionException {
Lexer_rulesContext _localctx = new Lexer_rulesContext(_ctx, getState());
enterRule(_localctx, 6, RULE_lexer_rules);
((Lexer_rulesContext)_localctx).rules = new java.util.ArrayList<>();
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(176);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==TERMINAL) {
{
{
setState(159);
((Lexer_rulesContext)_localctx).TERMINAL = match(TERMINAL);
setState(161);
_errHandler.sync(this);
_la = _input.LA(1);
do {
{
{
setState(160);
match(WS);
}
}
setState(163);
_errHandler.sync(this);
_la = _input.LA(1);
} while ( _la==WS );
setState(165);
match(COLON);
setState(167);
_errHandler.sync(this);
_la = _input.LA(1);
do {
{
{
setState(166);
match(WS);
}
}
setState(169);
_errHandler.sync(this);
_la = _input.LA(1);
} while ( _la==WS );
setState(171);
((Lexer_rulesContext)_localctx).right_part_lexer = right_part_lexer();
_localctx.rules.add(new model.LexerRule(new model.Term((((Lexer_rulesContext)_localctx).TERMINAL!=null?((Lexer_rulesContext)_localctx).TERMINAL.getText():null)), ((Lexer_rulesContext)_localctx).right_part_lexer.value));
}
}
setState(178);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class Right_part_parserContext extends ParserRuleContext {
public java.util.Set<String> inherited;
public java.util.List<model.RuleElement> value;
public Token NON_TERMINAL;
public Token TERMINAL;
public List<TerminalNode> ENDL() { return getTokens(GrammarParser.ENDL); }
public TerminalNode ENDL(int i) {
return getToken(GrammarParser.ENDL, i);
}
public TerminalNode EPS() { return getToken(GrammarParser.EPS, 0); }
public List<TerminalNode> NON_TERMINAL() { return getTokens(GrammarParser.NON_TERMINAL); }
public TerminalNode NON_TERMINAL(int i) {
return getToken(GrammarParser.NON_TERMINAL, i);
}
public List<TerminalNode> TERMINAL() { return getTokens(GrammarParser.TERMINAL); }
public TerminalNode TERMINAL(int i) {
return getToken(GrammarParser.TERMINAL, i);
}
public List<TerminalNode> WS() { return getTokens(GrammarParser.WS); }
public TerminalNode WS(int i) {
return getToken(GrammarParser.WS, i);
}
public Right_part_parserContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); }
public Right_part_parserContext(ParserRuleContext parent, int invokingState, java.util.Set<String> inherited) {
super(parent, invokingState);
this.inherited = inherited;
}
@Override public int getRuleIndex() { return RULE_right_part_parser; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterRight_part_parser(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitRight_part_parser(this);
}
}
public final Right_part_parserContext right_part_parser(java.util.Set<String> inherited) throws RecognitionException {
Right_part_parserContext _localctx = new Right_part_parserContext(_ctx, getState(), inherited);
enterRule(_localctx, 8, RULE_right_part_parser);
((Right_part_parserContext)_localctx).value = new java.util.ArrayList<>();
int _la;
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(210);
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,28,_ctx) ) {
case 1:
{
setState(197);
_errHandler.sync(this);
_alt = 1;
do {
switch (_alt) {
case 1:
{
setState(197);
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,25,_ctx) ) {
case 1:
{
{
setState(182);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS) {
{
{
setState(179);
match(WS);
}
}
setState(184);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(185);
((Right_part_parserContext)_localctx).NON_TERMINAL = match(NON_TERMINAL);
}
_localctx.value.add(new model.NonTerm((((Right_part_parserContext)_localctx).NON_TERMINAL!=null?((Right_part_parserContext)_localctx).NON_TERMINAL.getText():null), _localctx.inherited.contains((((Right_part_parserContext)_localctx).NON_TERMINAL!=null?((Right_part_parserContext)_localctx).NON_TERMINAL.getText():null))));
}
break;
case 2:
{
{
setState(191);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS) {
{
{
setState(188);
match(WS);
}
}
setState(193);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(194);
((Right_part_parserContext)_localctx).TERMINAL = match(TERMINAL);
}
_localctx.value.add(new model.Term((((Right_part_parserContext)_localctx).TERMINAL!=null?((Right_part_parserContext)_localctx).TERMINAL.getText():null)));
}
break;
}
}
break;
default:
throw new NoViableAltException(this);
}
setState(199);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,26,_ctx);
} while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER );
}
break;
case 2:
{
{
setState(204);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS) {
{
{
setState(201);
match(WS);
}
}
setState(206);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(207);
match(EPS);
}
_localctx.value.add(model.Term.EPS);
}
break;
}
setState(215);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,29,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(212);
match(ENDL);
}
}
}
setState(217);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,29,_ctx);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class Right_part_lexerContext extends ParserRuleContext {
public java.lang.String value;
public Token REGEXP;
public Token REG_CONTENT;
public Token TERMINAL;
public Token TERMINAL_OPS;
public TerminalNode REGEXP() { return getToken(GrammarParser.REGEXP, 0); }
public TerminalNode REG_CONTENT() { return getToken(GrammarParser.REG_CONTENT, 0); }
public TerminalNode TERMINAL() { return getToken(GrammarParser.TERMINAL, 0); }
public TerminalNode TERMINAL_OPS() { return getToken(GrammarParser.TERMINAL_OPS, 0); }
public List<TerminalNode> ENDL() { return getTokens(GrammarParser.ENDL); }
public TerminalNode ENDL(int i) {
return getToken(GrammarParser.ENDL, i);
}
public Right_part_lexerContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_right_part_lexer; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterRight_part_lexer(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitRight_part_lexer(this);
}
}
public final Right_part_lexerContext right_part_lexer() throws RecognitionException {
Right_part_lexerContext _localctx = new Right_part_lexerContext(_ctx, getState());
enterRule(_localctx, 10, RULE_right_part_lexer);
((Right_part_lexerContext)_localctx).value = "";
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(225);
_errHandler.sync(this);
switch (_input.LA(1)) {
case REGEXP:
{
setState(218);
((Right_part_lexerContext)_localctx).REGEXP = match(REGEXP);
setState(219);
((Right_part_lexerContext)_localctx).REG_CONTENT = match(REG_CONTENT);
((Right_part_lexerContext)_localctx).value = (((Right_part_lexerContext)_localctx).REGEXP!=null?((Right_part_lexerContext)_localctx).REGEXP.getText():null) + (((Right_part_lexerContext)_localctx).REG_CONTENT!=null?((Right_part_lexerContext)_localctx).REG_CONTENT.getText():null);
}
break;
case TERMINAL:
{
setState(221);
((Right_part_lexerContext)_localctx).TERMINAL = match(TERMINAL);
((Right_part_lexerContext)_localctx).value = (((Right_part_lexerContext)_localctx).TERMINAL!=null?((Right_part_lexerContext)_localctx).TERMINAL.getText():null);
}
break;
case TERMINAL_OPS:
{
setState(223);
((Right_part_lexerContext)_localctx).TERMINAL_OPS = match(TERMINAL_OPS);
((Right_part_lexerContext)_localctx).value = (((Right_part_lexerContext)_localctx).TERMINAL_OPS!=null?((Right_part_lexerContext)_localctx).TERMINAL_OPS.getText():null);
}
break;
default:
throw new NoViableAltException(this);
}
setState(228);
_errHandler.sync(this);
_alt = 1;
do {
switch (_alt) {
case 1:
{
{
setState(227);
match(ENDL);
}
}
break;
default:
throw new NoViableAltException(this);
}
setState(230);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,31,_ctx);
} while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER );
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class Field_declarationsContext extends ParserRuleContext {
public java.util.Map<String, java.util.Set<String>> value;
public java.util.Set<String> inherited;
public Token NON_TERMINAL;
public Token TYPE;
public Token TERMINAL;
public List<TerminalNode> NON_TERMINAL() { return getTokens(GrammarParser.NON_TERMINAL); }
public TerminalNode NON_TERMINAL(int i) {
return getToken(GrammarParser.NON_TERMINAL, i);
}
public List<TerminalNode> COLON() { return getTokens(GrammarParser.COLON); }
public TerminalNode COLON(int i) {
return getToken(GrammarParser.COLON, i);
}
public List<TerminalNode> LBRACKET() { return getTokens(GrammarParser.LBRACKET); }
public TerminalNode LBRACKET(int i) {
return getToken(GrammarParser.LBRACKET, i);
}
public List<TerminalNode> RBRACKET() { return getTokens(GrammarParser.RBRACKET); }
public TerminalNode RBRACKET(int i) {
return getToken(GrammarParser.RBRACKET, i);
}
public List<TerminalNode> SHARP() { return getTokens(GrammarParser.SHARP); }
public TerminalNode SHARP(int i) {
return getToken(GrammarParser.SHARP, i);
}
public List<TerminalNode> WS() { return getTokens(GrammarParser.WS); }
public TerminalNode WS(int i) {
return getToken(GrammarParser.WS, i);
}
public List<TerminalNode> ENDL() { return getTokens(GrammarParser.ENDL); }
public TerminalNode ENDL(int i) {
return getToken(GrammarParser.ENDL, i);
}
public List<TerminalNode> TYPE() { return getTokens(GrammarParser.TYPE); }
public TerminalNode TYPE(int i) {
return getToken(GrammarParser.TYPE, i);
}
public List<TerminalNode> TERMINAL() { return getTokens(GrammarParser.TERMINAL); }
public TerminalNode TERMINAL(int i) {
return getToken(GrammarParser.TERMINAL, i);
}
public Field_declarationsContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_field_declarations; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).enterField_declarations(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof GrammarListener ) ((GrammarListener)listener).exitField_declarations(this);
}
}
public final Field_declarationsContext field_declarations() throws RecognitionException {
Field_declarationsContext _localctx = new Field_declarationsContext(_ctx, getState());
enterRule(_localctx, 12, RULE_field_declarations);
((Field_declarationsContext)_localctx).value = new java.util.HashMap<>();
((Field_declarationsContext)_localctx).inherited = new java.util.HashSet<>();
int _la;
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(299);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,42,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(232);
((Field_declarationsContext)_localctx).NON_TERMINAL = match(NON_TERMINAL);
_localctx.value.putIfAbsent((((Field_declarationsContext)_localctx).NON_TERMINAL!=null?((Field_declarationsContext)_localctx).NON_TERMINAL.getText():null), new java.util.HashSet<>());
setState(236);
_errHandler.sync(this);
_la = _input.LA(1);
if (_la==SHARP) {
{
setState(234);
match(SHARP);
_localctx.inherited.add((((Field_declarationsContext)_localctx).NON_TERMINAL!=null?((Field_declarationsContext)_localctx).NON_TERMINAL.getText():null));
}
}
setState(241);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS) {
{
{
setState(238);
match(WS);
}
}
setState(243);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(244);
match(COLON);
setState(248);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS) {
{
{
setState(245);
match(WS);
}
}
setState(250);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(251);
match(LBRACKET);
setState(255);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,35,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(252);
match(ENDL);
}
}
}
setState(257);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,35,_ctx);
}
setState(281);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS || _la==TYPE) {
{
{
setState(261);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS) {
{
{
setState(258);
match(WS);
}
}
setState(263);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(264);
((Field_declarationsContext)_localctx).TYPE = match(TYPE);
setState(268);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==WS) {
{
{
setState(265);
match(WS);
}
}
setState(270);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(271);
((Field_declarationsContext)_localctx).TERMINAL = match(TERMINAL);
setState(275);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,38,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(272);
match(ENDL);
}
}
}
setState(277);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,38,_ctx);
}
_localctx.value.get((((Field_declarationsContext)_localctx).NON_TERMINAL!=null?((Field_declarationsContext)_localctx).NON_TERMINAL.getText():null)).add("public " + (((Field_declarationsContext)_localctx).TYPE!=null?((Field_declarationsContext)_localctx).TYPE.getText():null) + " " + (((Field_declarationsContext)_localctx).TERMINAL!=null?((Field_declarationsContext)_localctx).TERMINAL.getText():null) + ";\n");
}
}
setState(283);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(287);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==ENDL) {
{
{
setState(284);
match(ENDL);
}
}
setState(289);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(290);
match(RBRACKET);
setState(294);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,41,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
{
{
setState(291);
match(ENDL);
}
}
}
setState(296);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,41,_ctx);
}
}
}
}
setState(301);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,42,_ctx);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\27\u0131\4\2\t\2"+
"\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\3\2\3\2\3\2\7\2\24\n"+
"\2\f\2\16\2\27\13\2\3\2\3\2\3\2\7\2\34\n\2\f\2\16\2\37\13\2\3\2\3\2\3"+
"\2\7\2$\n\2\f\2\16\2\'\13\2\3\3\3\3\6\3+\n\3\r\3\16\3,\3\3\3\3\6\3\61"+
"\n\3\r\3\16\3\62\3\3\3\3\7\3\67\n\3\f\3\16\3:\13\3\3\3\3\3\3\3\3\3\5\3"+
"@\n\3\3\3\7\3C\n\3\f\3\16\3F\13\3\3\3\3\3\7\3J\n\3\f\3\16\3M\13\3\3\3"+
"\3\3\3\3\3\3\5\3S\n\3\3\3\7\3V\n\3\f\3\16\3Y\13\3\3\3\3\3\3\3\3\3\5\3"+
"_\n\3\3\3\3\3\7\3c\n\3\f\3\16\3f\13\3\3\4\7\4i\n\4\f\4\16\4l\13\4\3\4"+
"\3\4\7\4p\n\4\f\4\16\4s\13\4\3\4\7\4v\n\4\f\4\16\4y\13\4\3\4\3\4\3\4\3"+
"\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\6\4"+
"\u008f\n\4\r\4\16\4\u0090\3\4\3\4\7\4\u0095\n\4\f\4\16\4\u0098\13\4\3"+
"\4\7\4\u009b\n\4\f\4\16\4\u009e\13\4\3\4\3\4\3\5\3\5\6\5\u00a4\n\5\r\5"+
"\16\5\u00a5\3\5\3\5\6\5\u00aa\n\5\r\5\16\5\u00ab\3\5\3\5\3\5\7\5\u00b1"+
"\n\5\f\5\16\5\u00b4\13\5\3\6\7\6\u00b7\n\6\f\6\16\6\u00ba\13\6\3\6\3\6"+
"\3\6\3\6\7\6\u00c0\n\6\f\6\16\6\u00c3\13\6\3\6\3\6\3\6\6\6\u00c8\n\6\r"+
"\6\16\6\u00c9\3\6\7\6\u00cd\n\6\f\6\16\6\u00d0\13\6\3\6\3\6\3\6\5\6\u00d5"+
"\n\6\3\6\7\6\u00d8\n\6\f\6\16\6\u00db\13\6\3\7\3\7\3\7\3\7\3\7\3\7\3\7"+
"\5\7\u00e4\n\7\3\7\6\7\u00e7\n\7\r\7\16\7\u00e8\3\b\3\b\3\b\3\b\5\b\u00ef"+
"\n\b\3\b\7\b\u00f2\n\b\f\b\16\b\u00f5\13\b\3\b\3\b\7\b\u00f9\n\b\f\b\16"+
"\b\u00fc\13\b\3\b\3\b\7\b\u0100\n\b\f\b\16\b\u0103\13\b\3\b\7\b\u0106"+
"\n\b\f\b\16\b\u0109\13\b\3\b\3\b\7\b\u010d\n\b\f\b\16\b\u0110\13\b\3\b"+
"\3\b\7\b\u0114\n\b\f\b\16\b\u0117\13\b\3\b\7\b\u011a\n\b\f\b\16\b\u011d"+
"\13\b\3\b\7\b\u0120\n\b\f\b\16\b\u0123\13\b\3\b\3\b\7\b\u0127\n\b\f\b"+
"\16\b\u012a\13\b\7\b\u012c\n\b\f\b\16\b\u012f\13\b\3\b\2\2\t\2\4\6\b\n"+
"\f\16\2\2\2\u015d\2\20\3\2\2\2\4d\3\2\2\2\6j\3\2\2\2\b\u00b2\3\2\2\2\n"+
"\u00d4\3\2\2\2\f\u00e3\3\2\2\2\16\u012d\3\2\2\2\20\21\5\16\b\2\21\25\b"+
"\2\1\2\22\24\7\4\2\2\23\22\3\2\2\2\24\27\3\2\2\2\25\23\3\2\2\2\25\26\3"+
"\2\2\2\26\30\3\2\2\2\27\25\3\2\2\2\30\31\5\4\3\2\31\35\b\2\1\2\32\34\7"+
"\4\2\2\33\32\3\2\2\2\34\37\3\2\2\2\35\33\3\2\2\2\35\36\3\2\2\2\36 \3\2"+
"\2\2\37\35\3\2\2\2 !\5\b\5\2!%\b\2\1\2\"$\7\4\2\2#\"\3\2\2\2$\'\3\2\2"+
"\2%#\3\2\2\2%&\3\2\2\2&\3\3\2\2\2\'%\3\2\2\2(*\7\f\2\2)+\7\3\2\2*)\3\2"+
"\2\2+,\3\2\2\2,*\3\2\2\2,-\3\2\2\2-.\3\2\2\2.\60\7\6\2\2/\61\7\3\2\2\60"+
"/\3\2\2\2\61\62\3\2\2\2\62\60\3\2\2\2\62\63\3\2\2\2\63\64\3\2\2\2\648"+
"\5\n\6\2\65\67\7\3\2\2\66\65\3\2\2\2\67:\3\2\2\28\66\3\2\2\289\3\2\2\2"+
"9?\3\2\2\2:8\3\2\2\2;<\7\b\2\2<=\5\6\4\2=>\b\3\1\2>@\3\2\2\2?;\3\2\2\2"+
"?@\3\2\2\2@D\3\2\2\2AC\7\3\2\2BA\3\2\2\2CF\3\2\2\2DB\3\2\2\2DE\3\2\2\2"+
"ER\3\2\2\2FD\3\2\2\2GK\7\t\2\2HJ\7\3\2\2IH\3\2\2\2JM\3\2\2\2KI\3\2\2\2"+
"KL\3\2\2\2LN\3\2\2\2MK\3\2\2\2NO\7\16\2\2OP\5\6\4\2PQ\b\3\1\2QS\3\2\2"+
"\2RG\3\2\2\2RS\3\2\2\2SW\3\2\2\2TV\7\3\2\2UT\3\2\2\2VY\3\2\2\2WU\3\2\2"+
"\2WX\3\2\2\2X^\3\2\2\2YW\3\2\2\2Z[\7\n\2\2[\\\5\6\4\2\\]\b\3\1\2]_\3\2"+
"\2\2^Z\3\2\2\2^_\3\2\2\2_`\3\2\2\2`a\b\3\1\2ac\3\2\2\2b(\3\2\2\2cf\3\2"+
"\2\2db\3\2\2\2de\3\2\2\2e\5\3\2\2\2fd\3\2\2\2gi\7\3\2\2hg\3\2\2\2il\3"+
"\2\2\2jh\3\2\2\2jk\3\2\2\2km\3\2\2\2lj\3\2\2\2mq\7\5\2\2np\7\4\2\2on\3"+
"\2\2\2ps\3\2\2\2qo\3\2\2\2qr\3\2\2\2rw\3\2\2\2sq\3\2\2\2tv\7\3\2\2ut\3"+
"\2\2\2vy\3\2\2\2wu\3\2\2\2wx\3\2\2\2x\u008e\3\2\2\2yw\3\2\2\2z{\7\r\2"+
"\2{\u008f\b\4\1\2|}\7\f\2\2}\u008f\b\4\1\2~\177\7\16\2\2\177\u008f\b\4"+
"\1\2\u0080\u0081\7\21\2\2\u0081\u008f\b\4\1\2\u0082\u0083\7\22\2\2\u0083"+
"\u008f\b\4\1\2\u0084\u0085\7\13\2\2\u0085\u008f\b\4\1\2\u0086\u0087\7"+
"\7\2\2\u0087\u008f\b\4\1\2\u0088\u0089\7\24\2\2\u0089\u008f\b\4\1\2\u008a"+
"\u008b\7\3\2\2\u008b\u008f\b\4\1\2\u008c\u008d\7\4\2\2\u008d\u008f\b\4"+
"\1\2\u008ez\3\2\2\2\u008e|\3\2\2\2\u008e~\3\2\2\2\u008e\u0080\3\2\2\2"+
"\u008e\u0082\3\2\2\2\u008e\u0084\3\2\2\2\u008e\u0086\3\2\2\2\u008e\u0088"+
"\3\2\2\2\u008e\u008a\3\2\2\2\u008e\u008c\3\2\2\2\u008f\u0090\3\2\2\2\u0090"+
"\u008e\3\2\2\2\u0090\u0091\3\2\2\2\u0091\u0092\3\2\2\2\u0092\u0096\7\23"+
"\2\2\u0093\u0095\7\4\2\2\u0094\u0093\3\2\2\2\u0095\u0098\3\2\2\2\u0096"+
"\u0094\3\2\2\2\u0096\u0097\3\2\2\2\u0097\u009c\3\2\2\2\u0098\u0096\3\2"+
"\2\2\u0099\u009b\7\3\2\2\u009a\u0099\3\2\2\2\u009b\u009e\3\2\2\2\u009c"+
"\u009a\3\2\2\2\u009c\u009d\3\2\2\2\u009d\u009f\3\2\2\2\u009e\u009c\3\2"+
"\2\2\u009f\u00a0\b\4\1\2\u00a0\7\3\2\2\2\u00a1\u00a3\7\r\2\2\u00a2\u00a4"+
"\7\3\2\2\u00a3\u00a2\3\2\2\2\u00a4\u00a5\3\2\2\2\u00a5\u00a3\3\2\2\2\u00a5"+
"\u00a6\3\2\2\2\u00a6\u00a7\3\2\2\2\u00a7\u00a9\7\5\2\2\u00a8\u00aa\7\3"+
"\2\2\u00a9\u00a8\3\2\2\2\u00aa\u00ab\3\2\2\2\u00ab\u00a9\3\2\2\2\u00ab"+
"\u00ac\3\2\2\2\u00ac\u00ad\3\2\2\2\u00ad\u00ae\5\f\7\2\u00ae\u00af\b\5"+
"\1\2\u00af\u00b1\3\2\2\2\u00b0\u00a1\3\2\2\2\u00b1\u00b4\3\2\2\2\u00b2"+
"\u00b0\3\2\2\2\u00b2\u00b3\3\2\2\2\u00b3\t\3\2\2\2\u00b4\u00b2\3\2\2\2"+
"\u00b5\u00b7\7\3\2\2\u00b6\u00b5\3\2\2\2\u00b7\u00ba\3\2\2\2\u00b8\u00b6"+
"\3\2\2\2\u00b8\u00b9\3\2\2\2\u00b9\u00bb\3\2\2\2\u00ba\u00b8\3\2\2\2\u00bb"+
"\u00bc\7\f\2\2\u00bc\u00bd\3\2\2\2\u00bd\u00c8\b\6\1\2\u00be\u00c0\7\3"+
"\2\2\u00bf\u00be\3\2\2\2\u00c0\u00c3\3\2\2\2\u00c1\u00bf\3\2\2\2\u00c1"+
"\u00c2\3\2\2\2\u00c2\u00c4\3\2\2\2\u00c3\u00c1\3\2\2\2\u00c4\u00c5\7\r"+
"\2\2\u00c5\u00c6\3\2\2\2\u00c6\u00c8\b\6\1\2\u00c7\u00b8\3\2\2\2\u00c7"+
"\u00c1\3\2\2\2\u00c8\u00c9\3\2\2\2\u00c9\u00c7\3\2\2\2\u00c9\u00ca\3\2"+
"\2\2\u00ca\u00d5\3\2\2\2\u00cb\u00cd\7\3\2\2\u00cc\u00cb\3\2\2\2\u00cd"+
"\u00d0\3\2\2\2\u00ce\u00cc\3\2\2\2\u00ce\u00cf\3\2\2\2\u00cf\u00d1\3\2"+
"\2\2\u00d0\u00ce\3\2\2\2\u00d1\u00d2\7\20\2\2\u00d2\u00d3\3\2\2\2\u00d3"+
"\u00d5\b\6\1\2\u00d4\u00c7\3\2\2\2\u00d4\u00ce\3\2\2\2\u00d5\u00d9\3\2"+
"\2\2\u00d6\u00d8\7\4\2\2\u00d7\u00d6\3\2\2\2\u00d8\u00db\3\2\2\2\u00d9"+
"\u00d7\3\2\2\2\u00d9\u00da\3\2\2\2\u00da\13\3\2\2\2\u00db\u00d9\3\2\2"+
"\2\u00dc\u00dd\7\17\2\2\u00dd\u00de\7\27\2\2\u00de\u00e4\b\7\1\2\u00df"+
"\u00e0\7\r\2\2\u00e0\u00e4\b\7\1\2\u00e1\u00e2\7\13\2\2\u00e2\u00e4\b"+
"\7\1\2\u00e3\u00dc\3\2\2\2\u00e3\u00df\3\2\2\2\u00e3\u00e1\3\2\2\2\u00e4"+
"\u00e6\3\2\2\2\u00e5\u00e7\7\4\2\2\u00e6\u00e5\3\2\2\2\u00e7\u00e8\3\2"+
"\2\2\u00e8\u00e6\3\2\2\2\u00e8\u00e9\3\2\2\2\u00e9\r\3\2\2\2\u00ea\u00eb"+
"\7\f\2\2\u00eb\u00ee\b\b\1\2\u00ec\u00ed\7\23\2\2\u00ed\u00ef\b\b\1\2"+
"\u00ee\u00ec\3\2\2\2\u00ee\u00ef\3\2\2\2\u00ef\u00f3\3\2\2\2\u00f0\u00f2"+
"\7\3\2\2\u00f1\u00f0\3\2\2\2\u00f2\u00f5\3\2\2\2\u00f3\u00f1\3\2\2\2\u00f3"+
"\u00f4\3\2\2\2\u00f4\u00f6\3\2\2\2\u00f5\u00f3\3\2\2\2\u00f6\u00fa\7\5"+
"\2\2\u00f7\u00f9\7\3\2\2\u00f8\u00f7\3\2\2\2\u00f9\u00fc\3\2\2\2\u00fa"+
"\u00f8\3\2\2\2\u00fa\u00fb\3\2\2\2\u00fb\u00fd\3\2\2\2\u00fc\u00fa\3\2"+
"\2\2\u00fd\u0101\7\21\2\2\u00fe\u0100\7\4\2\2\u00ff\u00fe\3\2\2\2\u0100"+
"\u0103\3\2\2\2\u0101\u00ff\3\2\2\2\u0101\u0102\3\2\2\2\u0102\u011b\3\2"+
"\2\2\u0103\u0101\3\2\2\2\u0104\u0106\7\3\2\2\u0105\u0104\3\2\2\2\u0106"+
"\u0109\3\2\2\2\u0107\u0105\3\2\2\2\u0107\u0108\3\2\2\2\u0108\u010a\3\2"+
"\2\2\u0109\u0107\3\2\2\2\u010a\u010e\7\7\2\2\u010b\u010d\7\3\2\2\u010c"+
"\u010b\3\2\2\2\u010d\u0110\3\2\2\2\u010e\u010c\3\2\2\2\u010e\u010f\3\2"+
"\2\2\u010f\u0111\3\2\2\2\u0110\u010e\3\2\2\2\u0111\u0115\7\r\2\2\u0112"+
"\u0114\7\4\2\2\u0113\u0112\3\2\2\2\u0114\u0117\3\2\2\2\u0115\u0113\3\2"+
"\2\2\u0115\u0116\3\2\2\2\u0116\u0118\3\2\2\2\u0117\u0115\3\2\2\2\u0118"+
"\u011a\b\b\1\2\u0119\u0107\3\2\2\2\u011a\u011d\3\2\2\2\u011b\u0119\3\2"+
"\2\2\u011b\u011c\3\2\2\2\u011c\u0121\3\2\2\2\u011d\u011b\3\2\2\2\u011e"+
"\u0120\7\4\2\2\u011f\u011e\3\2\2\2\u0120\u0123\3\2\2\2\u0121\u011f\3\2"+
"\2\2\u0121\u0122\3\2\2\2\u0122\u0124\3\2\2\2\u0123\u0121\3\2\2\2\u0124"+
"\u0128\7\22\2\2\u0125\u0127\7\4\2\2\u0126\u0125\3\2\2\2\u0127\u012a\3"+
"\2\2\2\u0128\u0126\3\2\2\2\u0128\u0129\3\2\2\2\u0129\u012c\3\2\2\2\u012a"+
"\u0128\3\2\2\2\u012b\u00ea\3\2\2\2\u012c\u012f\3\2\2\2\u012d\u012b\3\2"+
"\2\2\u012d\u012e\3\2\2\2\u012e\17\3\2\2\2\u012f\u012d\3\2\2\2-\25\35%"+
",\628?DKRW^djqw\u008e\u0090\u0096\u009c\u00a5\u00ab\u00b2\u00b8\u00c1"+
"\u00c7\u00c9\u00ce\u00d4\u00d9\u00e3\u00e8\u00ee\u00f3\u00fa\u0101\u0107"+
"\u010e\u0115\u011b\u0121\u0128\u012d";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
}
}
} |
3e1d627f81c6b76ed6d1b2ac13cc0e59d407ee14 | 2,087 | java | Java | app/src/main/java/com/wd/utils/sdk/fragment/SampleFragment.java | MayankParyani/UtilsSdk | 7450b61d32abf80dce5f08b7c8fae836ae00170e | [
"MIT"
] | null | null | null | app/src/main/java/com/wd/utils/sdk/fragment/SampleFragment.java | MayankParyani/UtilsSdk | 7450b61d32abf80dce5f08b7c8fae836ae00170e | [
"MIT"
] | null | null | null | app/src/main/java/com/wd/utils/sdk/fragment/SampleFragment.java | MayankParyani/UtilsSdk | 7450b61d32abf80dce5f08b7c8fae836ae00170e | [
"MIT"
] | null | null | null | 30.691176 | 109 | 0.657882 | 12,464 | package com.wd.utils.sdk.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;
import com.wd.utils.sdk.R;
import com.wd.utils.sdk.basecontrols.BaseFragment;
import sdk.utils.wd.network.NetworkListener;
import sdk.utils.wd.network.NetworkUtility;
public class SampleFragment extends BaseFragment implements NetworkListener {
View view;
Button statusButton;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_sample, container, false);
//registering a callback to be notified in this fragment whenever there is a change in network status
NetworkUtility.getInstance().registerCallback(this);
initViews(view);
return view;
}
private void initViews(View view) {
statusButton = (Button) view.findViewById(R.id.statusButton);
if (NetworkUtility.getInstance().isNetworkAvailable(getContext())) {
statusButton.setText("Online");
} else {
statusButton.setText("Offline");
}
statusButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (statusButton != null) {
Toast.makeText(getActivity(), statusButton.getText(), Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
public void onInternetReceive() {
if (statusButton != null) {
statusButton.setText("Online");
}
}
@Override
public void onInternetGone() {
if (statusButton != null) {
statusButton.setText("Offline");
}
}
@Override
public void onDestroy() {
super.onDestroy();
//unregister a callback to when this fragment destroys to prevent memory overloading
NetworkUtility.getInstance().unregisterCallback(this);
}
}
|
3e1d6304d88c174a2cc7c320ef345577d6d1b374 | 14,148 | java | Java | src/main/java/org/hcjf/io/net/NetServiceConsumer.java | armedina/HolandaCatalinaFw | c5b8138bfaefe784f79630e29374510082ebd1a1 | [
"Apache-2.0"
] | 21 | 2017-05-19T11:49:17.000Z | 2022-02-25T12:49:26.000Z | src/main/java/org/hcjf/io/net/NetServiceConsumer.java | armedina/HolandaCatalinaFw | c5b8138bfaefe784f79630e29374510082ebd1a1 | [
"Apache-2.0"
] | 26 | 2017-01-20T14:13:59.000Z | 2022-03-16T19:42:07.000Z | src/main/java/org/hcjf/io/net/NetServiceConsumer.java | armedina/HolandaCatalinaFw | c5b8138bfaefe784f79630e29374510082ebd1a1 | [
"Apache-2.0"
] | 16 | 2016-11-11T10:09:42.000Z | 2022-01-06T18:37:32.000Z | 34.091566 | 131 | 0.62136 | 12,465 | package org.hcjf.io.net;
import org.hcjf.errors.HCJFRuntimeException;
import org.hcjf.log.Log;
import org.hcjf.properties.SystemProperties;
import org.hcjf.service.Service;
import org.hcjf.service.ServiceConsumer;
import org.hcjf.service.ServiceSession;
import javax.net.ssl.SSLEngine;
import java.io.IOException;
import java.net.SocketOption;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
/**
* This consumer provide an interface for the net service.
* @author javaito
*/
public abstract class NetServiceConsumer<S extends NetSession, D extends Object> implements ServiceConsumer {
private static final String NAME_TEMPLATE = "%s %s %d";
private final String name;
private final Integer port;
private final NetService.TransportLayerProtocol protocol;
private NetService service;
private long writeWaitForTimeout;
private Boolean decoupledIoAction;
private Queue<DecoupledAction> actionsQueue;
public NetServiceConsumer(Integer port, NetService.TransportLayerProtocol protocol) {
this.port = port;
this.protocol = protocol;
writeWaitForTimeout = SystemProperties.getLong(SystemProperties.Net.WRITE_TIMEOUT);
name = String.format(NAME_TEMPLATE, getClass().getName(), protocol.toString(), port);
decoupledIoAction = false;
}
public final Boolean isDecoupledIoAction() {
return decoupledIoAction;
}
/**
* This method activate the decoupled io actions.
* @param actionQueueSize Size of the actions queue.
* @param workersNumber Number of workers to execute the actions.
*/
public final void decoupleIoAction(Integer actionQueueSize, Integer workersNumber) {
if(actionQueueSize <= 10) {
throw new HCJFRuntimeException("The actions queue size can't be smaller than 11 places");
}
if(workersNumber <= 0) {
throw new HCJFRuntimeException("The decoupled function must have at least one worker");
}
decoupledIoAction = true;
actionsQueue = new ArrayBlockingQueue<>(actionQueueSize);
for (int i = 0; i < workersNumber; i++) {
Service.run(() -> {
DecoupledAction decoupledAction;
while (!Thread.currentThread().isInterrupted()) {
synchronized (actionsQueue) {
decoupledAction = actionsQueue.poll();
}
if(decoupledAction != null) {
try {
ServiceSession.runAs(decoupledAction::onAction, decoupledAction.getServiceSession().currentIdentity());
} catch (Throwable throwable) {
Log.w(SystemProperties.get(SystemProperties.Net.LOG_TAG), "Decoupled action error", throwable);
}
} else {
try {
synchronized (actionsQueue) {
actionsQueue.wait();
}
} catch (Exception ex) {
break;
}
}
}
}, ServiceSession.getSystemSession());
}
}
/**
* Add a new decoupled action into the queue.
* @param decoupledAction Decoupled action instance.
*/
protected final void addDecoupledAction(DecoupledAction decoupledAction) {
if(isDecoupledIoAction()) {
synchronized (actionsQueue) {
actionsQueue.add(decoupledAction);
actionsQueue.notifyAll();
}
} else {
decoupledAction.onAction();
}
}
/**
* This method return a name to identify the consumer.
* @return Consumer name.
*/
public String getName() {
return name;
}
/**
* Return the waiting time to write a package.
* @return Waiting time to write a apackage.
*/
public long getWriteWaitForTimeout() {
return writeWaitForTimeout;
}
/**
* Set the waiting time to write a package.
* @param writeWaitForTimeout Waiting time to write a package.
*/
public void setWriteWaitForTimeout(long writeWaitForTimeout) {
this.writeWaitForTimeout = writeWaitForTimeout;
}
/**
* This method ser the reference to net service,
* this method only can be called from the net service
* that will be associated
* @param service Net service that will be associated.
* @throws SecurityException If the method was called from other
* method that not is NetService.registerConsumer().
*/
public final void setService(NetService service) {
StackTraceElement element = Thread.currentThread().getStackTrace()[2];
if(element.getClassName().equals(NetService.class.getName()) &&
element.getMethodName().equals("registerConsumer")) {
this.service = service;
} else {
throw new SecurityException("The method 'NetServiceConsumer.setService() only can be called from " +
"the net service that will be associated.'");
}
}
/**
* Returns the net service instance of the consumer.
* @return Net service instance.
*/
protected final NetService getService() {
return service;
}
/**
* Return the port of the consumer.
* @return Port.
*/
public final Integer getPort() {
return port;
}
/**
* This method should create the ssl engine for the consumer.
* @return SSL engine implementation.
*/
protected SSLEngine getSSLEngine() {
throw new UnsupportedOperationException("Unsupported ssl engine");
}
/**
* Return the transport layer protocol of the consumer.
* @return Transport layer consumer.
*/
public final NetService.TransportLayerProtocol getProtocol() {
return protocol;
}
/**
* Disconnect the specific session.
* @param session Net session.
* @param message Disconnection message.
*/
protected final void disconnect(S session, String message) {
service.disconnect(session, message);
}
/**
* Returns the shutdown frame to send before the net service shutdown.
* @param session Session to create the shutdown frame.
* @return Shutdown frame
*/
public final byte[] getShutdownFrame(S session) {
byte[] result = null;
try {
D shutdownPackage = getShutdownPackage(session);
if (shutdownPackage != null) {
result = encode(shutdownPackage);
}
} catch (Exception ex){
//This exception is totally ignored because the shutdown procedure must be go on
}
return result;
}
/**
* Returns the shutdown package to send before the net service shutdown.
* @param session Session to create the package.
* @return Shutdown package.
*/
protected D getShutdownPackage(S session) {
return null;
}
/**
* This method writes some data over the session indicated,
* this operation generate a blocking until the net service confirm
* that the data was written over the communication channel
* @param session Net session.
* @param payLoad Data to be written
* @throws IOException Exception for the io operations
*/
protected final void write(S session, D payLoad) throws IOException {
write(session, payLoad, true);
}
/**
* This method writes some data over the session indicated.
* @param session Net session.
* @param payLoad Data to be written.
* @param waitFor If this parameter is true then the operation generate
* a blocking over the communication channel.
* @throws IOException Exception for io operations
*/
protected final void write(S session, D payLoad, boolean waitFor) throws IOException {
if(waitFor) {
NetPackage netPackage = service.writeData(session, encode(payLoad));
synchronized (netPackage) {
try {
netPackage.wait(getWriteWaitForTimeout());
} catch (InterruptedException e) {
Log.w(SystemProperties.get(SystemProperties.Net.LOG_TAG), "Write wait for interrupted", e);
}
}
switch (netPackage.getPackageStatus()) {
case CONNECTION_CLOSE: {
throw new IOException("Connection Close");
}
case IO_ERROR: {
throw new IOException("IO Error");
}
case REJECTED_SESSION_LOCK: {
throw new IOException("Session locked");
}
case UNKNOWN_SESSION: {
throw new IOException("Unknown session");
}
}
} else {
NetPackage netPackage = service.writeData(session, encode(payLoad));
}
}
/**
* This method abstracts the connection event to use the entities of the domain's implementation.
* @param netPackage Connection package.
*/
public final void onConnect(NetPackage netPackage) {
onConnect((S) netPackage.getSession(), decode(netPackage), netPackage);
}
/**
* Method that must be implemented by the custom implementation to know when a session is connected
* @param session Connected session.
* @param payLoad Decoded package payload.
* @param netPackage Original package.
*/
protected void onConnect(S session, D payLoad, NetPackage netPackage) {}
/**
* This method abstracts the disconnection event to use the entities of the domain's implementation.
* @param netPackage Disconnection package.
*/
public final void onDisconnect(NetPackage netPackage) {
synchronized (netPackage) {
netPackage.notify();
}
onDisconnect((S) netPackage.getSession(), netPackage);
}
/**
* Method must be implemented by the custom implementation to known when a session is disconnected
* @param session Disconnected session.
* @param netPackage Original package.
*/
protected void onDisconnect(S session, NetPackage netPackage) {}
/**
* When the net service receive data call this method to process the package
* @param netPackage Net package.
*/
public final void onRead(NetPackage netPackage) {
S session = (S) netPackage.getSession();
D decodedPackage = decode(netPackage);
try {
session = checkSession(session, decodedPackage, netPackage);
session.setChecked(true);
try {
onRead(session, decodedPackage, netPackage);
} catch (Exception ex) {
Log.w(SystemProperties.get(SystemProperties.Net.LOG_TAG), "On read method fail", ex);
}
} catch (Exception ex){
Log.w(SystemProperties.get(SystemProperties.Net.LOG_TAG), "Check session fail", ex);
session.setChecked(false);
onCheckSessionError(session, decodedPackage, netPackage, ex);
}
}
/**
* When the net service receive data, this method is called to process the package.
* @param session Net session.
* @param payLoad Net package decoded
* @param netPackage Net package.
*/
protected void onRead(S session, D payLoad, NetPackage netPackage) {}
/**
* When an exception is occurred while checking session,
* this method is called to process the package according the exception information.
* @param session Net session.
* @param payLoad Net package decoded
* @param netPackage Net package.
* @param cause Error cause.
*/
protected void onCheckSessionError(S session, D payLoad, NetPackage netPackage, Throwable cause) {}
/**
* When the net service write data then call this method to process the package.
* @param netPackage Net package.
*/
public final void onWrite(NetPackage netPackage) {
synchronized (netPackage) {
netPackage.notify();
}
onWrite((S)netPackage.getSession(), netPackage);
}
/**
* When the net service write data then call this method to process the package.
* @param session Net session.
* @param netPackage Net package.
*/
protected void onWrite(S session, NetPackage netPackage){}
/**
* This method decode the implementation data.
* @param payLoad Implementation data.
* @return Implementation data encoded.
*/
protected abstract byte[] encode(D payLoad);
/**
* This method decode the net package to obtain the implementation data
* @param netPackage Net package.
* @return Return the implementation data.
*/
protected abstract D decode(NetPackage netPackage);
/**
* Destroy the session.
* @param session Net session to be destroyed
*/
public abstract void destroySession(NetSession session);
/**
* Check the channel session.
* @param session Created session.
* @param payLoad Decoded package.
* @param netPackage Net package.
* @return Updated session.
*/
public abstract S checkSession(S session, D payLoad, NetPackage netPackage);
/**
* Return the socket options of the implementation.
* @return Socket options.
*/
public Map<SocketOption, Object> getSocketOptions() {
return null;
}
/**
* Interface to decoupled the read action.
*/
public static abstract class DecoupledAction {
public final ServiceSession serviceSession;
public DecoupledAction(ServiceSession serviceSession) {
this.serviceSession = serviceSession;
}
public ServiceSession getServiceSession() {
return serviceSession;
}
public abstract void onAction();
}
} |
3e1d63674f24b9af76c5c2215ae763661ea349f7 | 6,921 | java | Java | HelloJava/src/containers/ListPerformance.java | william396-co/ThinkInJava | cb1be9fab2c44416203fd98b4cd8a02f3040afcb | [
"MIT"
] | null | null | null | HelloJava/src/containers/ListPerformance.java | william396-co/ThinkInJava | cb1be9fab2c44416203fd98b4cd8a02f3040afcb | [
"MIT"
] | null | null | null | HelloJava/src/containers/ListPerformance.java | william396-co/ThinkInJava | cb1be9fab2c44416203fd98b4cd8a02f3040afcb | [
"MIT"
] | null | null | null | 30.897321 | 99 | 0.472186 | 12,466 | package containers;
import com.thinkinjava.util.CountingGenerator;
import com.thinkinjava.util.CountingIntegerList;
import com.thinkinjava.util.Generated;
import com.thinkinjava.util.Generator;
import java.awt.*;
import java.util.*;
import java.util.List;
import static com.thinkinjava.util.Print.*;
public class ListPerformance {
static Random random = new Random();
static int reps = 1000;
static List<Test<List<Integer>>> tests
= new ArrayList<Test<List<Integer>>>();
static List<Test<LinkedList<Integer>>> qTests =
new ArrayList<Test<LinkedList<Integer>>>();
static
{
tests.add(new Test<List<Integer>>("add") {
@Override
int test(List<Integer> container, TestParam tp) {
int loops = tp.loops;
int listsize = tp.size;
for(int i =0; i < loops;i++)
{
container.clear();
for(int j=0; j < listsize;j++)
container.add(j);
}
return listsize * loops;
}
});
tests.add(new Test<List<Integer>>("get") {
@Override
int test(List<Integer> container, TestParam tp) {
int loops =tp.loops* reps;
int listsize = container.size();
for(int i =0;i < loops;i++)
container.get(random.nextInt(listsize));
return loops;
}
});
tests.add(new Test<List<Integer>>("set") {
@Override
int test(List<Integer> container, TestParam tp) {
int loops = tp.loops * reps;
int listsize= container.size();
for(int i =0; i < loops;i++)
container.set(random.nextInt(listsize),47);
return loops;
}
});
tests.add(new Test<List<Integer>>("iteradd")
{
int test(List<Integer> container, TestParam tp) {
final int LOOPS = 1000000;
int half = container.size()/2;
ListIterator<Integer> it = container.listIterator(half);
for(int i =0; i < LOOPS;i++)
it.add(47);
return LOOPS;
}
});
tests.add(new Test<List<Integer>>("insert")
{
int test(List<Integer> list,TestParam tp)
{
int loops = tp.loops;
for(int i =0; i < loops;i++)
list.add(47);
return loops;
}
});
tests.add(new Test<List<Integer>>("remove"){
int test(List<Integer> list,TestParam tp)
{
int loops = tp.loops;
int size = tp.size;
for(int i = 0; i < loops;i++)
{
list.clear();
list.addAll(new CountingIntegerList(size));
while(list.size()>5)
list.remove(5);
}
return loops*size;
}
});
qTests.add(new Test<LinkedList<Integer>>("addFirst")
{
int test(LinkedList<Integer> list,TestParam tp) {
int loops = tp.loops;
int size = tp.size;
for (int i = 0; i < size; i++) {
list.clear();
for (int j = 0; j < size; j++)
list.addFirst(47);
}
return loops * size;
}
});
qTests.add(new Test<LinkedList<Integer>>("addLast")
{
int test(LinkedList<Integer> list, TestParam tp)
{
int loops = tp.loops;
int size = tp.size;
for(int i= 0; i < loops;i++)
{
list.clear();
for(int j =0;j <size;j++)
list.addLast(46);
}
return loops *size;
}
});
qTests.add(new Test<LinkedList<Integer>>("rmFirst")
{
int test(LinkedList<Integer>list, TestParam tp)
{
int loops = tp.loops;
int size= tp.size;
for(int i = 0; i < loops;i++)
{
list.clear();
list.addAll(new CountingIntegerList(size));
while(list.size()>0)
list.removeFirst();
}
return loops *size;
}
});
qTests.add(new Test<LinkedList<Integer>>("rmLast") {
@Override
int test(LinkedList<Integer> list, TestParam tp) {
int loops = tp.loops;
int size= tp.size;
for(int i = 0;i < loops;i++)
{
list.clear();
list.addAll(new CountingIntegerList(size));
while(list.size()>0)
list.removeLast();
}
return loops*size;
}
});
}
static class ListTester extends Tester<List<Integer>>
{
public ListTester(List<Integer> container, List<Test<List<Integer>>> tests) {
super(container, tests);
}
protected List<Integer> initialize(int size)
{
container.clear();
container.addAll(new CountingIntegerList(size));
return container;
}
public static void run(List<Integer> list,List<Test<List<Integer>>> tests)
{
new ListTester(list,tests).timedTest();
}
}
public static void main(String[] args) {
if(args.length > 0)
Tester.defaultParams = TestParam.array(args);
Tester<List<Integer>> arrayTest
=new Tester<List<Integer>>(null,tests.subList(1,3))
{
@Override protected
List<Integer> initialize(int size)
{
Integer[] ia = Generated.array(Integer.class,new CountingGenerator.Integer(),size);
return Arrays.asList(ia);
}
};
arrayTest.setHeadline("Array as List");
arrayTest.timedTest();
Tester.defaultParams = TestParam.array(10,5000,100,5000,1000,5000,10000,200);
if(args.length>0)
Tester.defaultParams= TestParam.array(args);
ListTester.run(new ArrayList<Integer>(),tests);
ListTester.run(new LinkedList<Integer>(),tests);
ListTester.run(new Vector<Integer>(),tests);
Tester.fieldwidth = 12;
Tester<LinkedList<Integer>> qTest
= new Tester<LinkedList<Integer>>(new LinkedList<Integer>(),qTests);
qTest.setHeadline("Queue test");
qTest.timedTest();
}
}
|
3e1d63b19bb470bd2280df5daa93ebf104d73212 | 2,136 | java | Java | src/main/java/com/dsi/parallax/ml/trees/GreaterThanSplitCondition.java | jattenberg/parallax | 372c7d02d1f5bad055014c418bd238b7413aa4f8 | [
"FSFAP"
] | null | null | null | src/main/java/com/dsi/parallax/ml/trees/GreaterThanSplitCondition.java | jattenberg/parallax | 372c7d02d1f5bad055014c418bd238b7413aa4f8 | [
"FSFAP"
] | null | null | null | src/main/java/com/dsi/parallax/ml/trees/GreaterThanSplitCondition.java | jattenberg/parallax | 372c7d02d1f5bad055014c418bd238b7413aa4f8 | [
"FSFAP"
] | null | null | null | 25.73494 | 80 | 0.651217 | 12,467 | /*******************************************************************************
* Copyright 2012 Josh Attenberg. Not for re-use or redistribution.
******************************************************************************/
package com.dsi.parallax.ml.trees;
import com.dsi.parallax.ml.dictionary.ReversableDictionary;
import com.dsi.parallax.ml.instance.Instance;
import static com.google.common.base.Preconditions.checkArgument;
/**
* {@link SplitCondition} which returns true if the input feature value is
* greather than the split criteria
*
* @author jattenberg
*/
public class GreaterThanSplitCondition extends SplitCondition {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -8283058708390210632L;
/**
* Instantiates a new greater than split condition.
*
* @param index
* dimension being queried by the split point
* @param splitValue
* the split criteria
*/
public GreaterThanSplitCondition(int index, double splitValue) {
super(index, splitValue);
}
/*
* (non-Javadoc)
*
* @see
* com.parallax.ml.trees.SplitCondition#satisfiesSplit(com.parallax.ml.instance
* .Instanze)
*/
@Override
public boolean satisfiesSplit(Instance<?> inst) {
checkArgument(
inst.getDimension() > index,
"instance not large enough (%s dimensions) to be split at index: %s",
inst.getDimension(), index);
return inst.getFeatureValue(index) > splitValue;
}
/*
* (non-Javadoc)
*
* @see com.parallax.ml.trees.SplitCondition#representInequality()
*/
@Override
public String representInequality() {
return "x[" + index + "] > " + splitValue;
}
/*
* (non-Javadoc)
*
* @see com.parallax.ml.trees.SplitCondition#naturalOrder()
*/
@Override
public int naturalOrder() {
return 1;
}
/*
* (non-Javadoc)
*
* @see
* com.parallax.ml.trees.SplitCondition#representInequality(com.parallax
* .ml.dictionary.ReversableDictionary)
*/
@Override
public String representInequality(ReversableDictionary dict) {
String name = dict.getFeatureFromIndex(index);
return name + " > " + splitValue;
}
}
|
3e1d63de8e1cfbc9abed90111290c310c1096074 | 5,353 | java | Java | src/main/java/com/tale/service/ContentsService.java | NightsiX/tale | a012a5b61bc6ba09b9dd9856011f0bcf99556f8a | [
"MIT"
] | 5,594 | 2017-02-24T12:15:09.000Z | 2022-03-30T00:42:57.000Z | src/main/java/com/tale/service/ContentsService.java | zhouzhisheng/tale | 9845919c8089ad03a1190698982fda8da5a765c6 | [
"MIT"
] | 458 | 2017-02-24T16:35:04.000Z | 2022-03-12T12:33:19.000Z | src/main/java/com/tale/service/ContentsService.java | zhouzhisheng/tale | 9845919c8089ad03a1190698982fda8da5a765c6 | [
"MIT"
] | 2,171 | 2017-02-24T16:29:11.000Z | 2022-03-29T03:03:46.000Z | 31.304094 | 97 | 0.62096 | 12,468 | package com.tale.service;
import com.blade.exception.ValidatorException;
import com.blade.ioc.annotation.Bean;
import com.blade.ioc.annotation.Inject;
import com.blade.kit.DateKit;
import com.blade.kit.StringKit;
import com.tale.model.dto.Types;
import com.tale.model.entity.Comments;
import com.tale.model.entity.Contents;
import com.tale.model.entity.Relationships;
import com.tale.model.params.ArticleParam;
import com.vdurmont.emoji.EmojiParser;
import io.github.biezhi.anima.Anima;
import io.github.biezhi.anima.core.AnimaQuery;
import io.github.biezhi.anima.page.Page;
import static com.tale.bootstrap.TaleConst.SQL_QUERY_ARTICLES;
import static io.github.biezhi.anima.Anima.deleteById;
import static io.github.biezhi.anima.Anima.select;
/**
* 文章Service
*
* @author biezhi
* @since 1.3.1
*/
@Bean
public class ContentsService {
@Inject
private MetasService metasService;
/**
* 根据id或slug获取文章
*
* @param id 唯一标识
*/
public Contents getContents(String id) {
Contents contents = null;
if (StringKit.isNotBlank(id)) {
if (StringKit.isNumber(id)) {
contents = select().from(Contents.class).byId(id);
} else {
contents = select().from(Contents.class).where(Contents::getSlug, id).one();
}
if (null != contents) {
return this.mapContent(contents);
}
}
return contents;
}
/**
* 发布文章
*
* @param contents 文章对象
*/
public Integer publish(Contents contents) {
if (null == contents.getAuthorId()) {
throw new ValidatorException("请登录后发布文章");
}
contents.setContent(EmojiParser.parseToAliases(contents.getContent()));
int time = DateKit.nowUnix();
contents.setCreated(time);
contents.setModified(time);
contents.setHits(0);
String tags = contents.getTags();
String categories = contents.getCategories();
Integer cid = contents.save().asInt();
metasService.saveMetas(cid, tags, Types.TAG);
metasService.saveMetas(cid, categories, Types.CATEGORY);
return cid;
}
/**
* 编辑文章
*
* @param contents 文章对象
*/
public void updateArticle(Contents contents) {
contents.setCreated(contents.getCreated());
contents.setModified(DateKit.nowUnix());
contents.setContent(EmojiParser.parseToAliases(contents.getContent()));
contents.setTags(contents.getTags() != null ? contents.getTags() : "");
contents.setCategories(contents.getCategories() != null ? contents.getCategories() : "");
Integer cid = contents.getCid();
contents.updateById(cid);
String tags = contents.getTags();
String categories = contents.getCategories();
if (null != contents.getType() && !contents.getType().equals(Types.PAGE)) {
Anima.delete().from(Relationships.class).where(Relationships::getCid, cid).execute();
}
metasService.saveMetas(cid, tags, Types.TAG);
metasService.saveMetas(cid, categories, Types.CATEGORY);
}
/**
* 根据文章id删除
*
* @param cid 文章id
*/
public void delete(int cid) {
Contents contents = this.getContents(cid + "");
if (null != contents) {
deleteById(Contents.class, cid);
Anima.delete().from(Relationships.class).where(Relationships::getCid, cid).execute();
Anima.delete().from(Comments.class).where(Comments::getCid, cid).execute();
}
}
/**
* 查询分类/标签下的文章归档
*
* @param mid 分类、标签id
* @param page 页码
* @param limit 每页条数
* @return
*/
public Page<Contents> getArticles(Integer mid, int page, int limit) {
return select().bySQL(Contents.class, SQL_QUERY_ARTICLES, mid).page(page, limit);
}
public Page<Contents> findArticles(ArticleParam articleParam) {
AnimaQuery<Contents> query = select().from(Contents.class).exclude(Contents::getContent);
if (StringKit.isNotEmpty(articleParam.getStatus())) {
query.and(Contents::getStatus, articleParam.getStatus());
}
if (StringKit.isNotEmpty(articleParam.getTitle())) {
query.and(Contents::getTitle).like("%" + articleParam.getTitle() + "%");
}
if (StringKit.isNotEmpty(articleParam.getCategories())) {
query.and(Contents::getCategories).like("%" + articleParam.getCategories() + "%");
}
query.and(Contents::getType, articleParam.getType());
query.order(articleParam.getOrderBy());
Page<Contents> articles = query.page(articleParam.getPage(), articleParam.getLimit());
return articles.map(this::mapContent);
}
private Contents mapContent(Contents contents) {
if (StringKit.isNotEmpty(contents.getSlug())) {
String url = "/" + contents.getSlug();
contents.setUrl(url.replaceAll("[/]+", "/"));
} else {
contents.setUrl("/article/" + contents.getCid());
}
String content = contents.getContent();
if (StringKit.isNotEmpty(content)) {
content = content.replaceAll("\\\\\"", "\\\"");
contents.setContent(content);
}
return contents;
}
}
|
3e1d642f16b7e7abd004d364cf8703e126759357 | 2,020 | java | Java | core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/MyJPAJSONPlainSchemaDAO.java | mmoayyed/syncope | 597d8e86f7c6b2eba7c8785192b44297cfd2e57e | [
"Apache-2.0"
] | 176 | 2015-01-31T09:42:29.000Z | 2022-03-30T08:25:32.000Z | core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/MyJPAJSONPlainSchemaDAO.java | mmoayyed/syncope | 597d8e86f7c6b2eba7c8785192b44297cfd2e57e | [
"Apache-2.0"
] | 169 | 2015-04-14T15:02:12.000Z | 2022-03-03T15:57:58.000Z | core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/dao/MyJPAJSONPlainSchemaDAO.java | mmoayyed/syncope | 597d8e86f7c6b2eba7c8785192b44297cfd2e57e | [
"Apache-2.0"
] | 285 | 2015-03-03T12:04:35.000Z | 2022-03-24T14:15:06.000Z | 42.978723 | 106 | 0.737129 | 12,469 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.syncope.core.persistence.jpa.dao;
import javax.persistence.Query;
import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
public class MyJPAJSONPlainSchemaDAO extends AbstractJPAJSONPlainSchemaDAO {
public MyJPAJSONPlainSchemaDAO(
final AnyUtilsFactory anyUtilsFactory,
final PlainAttrDAO plainAttrDAO,
final ExternalResourceDAO resourceDAO) {
super(anyUtilsFactory, plainAttrDAO, resourceDAO);
}
@Override
public <T extends PlainAttr<?>> boolean hasAttrs(final PlainSchema schema, final Class<T> reference) {
Query query = entityManager().createNativeQuery(
"SELECT COUNT(id) FROM " + new SearchSupport(getAnyTypeKind(reference)).field().name
+ " WHERE JSON_CONTAINS(plainAttrs, '[{\"schema\":\"" + schema.getKey() + "\"}]')");
return ((Number) query.getSingleResult()).intValue() > 0;
}
}
|
3e1d64a0039505354da8b38719f43b908c399ad2 | 3,199 | java | Java | Fusion Engine V2/src/shaders/Shader.java | StepperDox/Fusion-Engine-V2 | 831ff3a72046939a8a4bae807b952fc8ba5a8485 | [
"MIT"
] | null | null | null | Fusion Engine V2/src/shaders/Shader.java | StepperDox/Fusion-Engine-V2 | 831ff3a72046939a8a4bae807b952fc8ba5a8485 | [
"MIT"
] | null | null | null | Fusion Engine V2/src/shaders/Shader.java | StepperDox/Fusion-Engine-V2 | 831ff3a72046939a8a4bae807b952fc8ba5a8485 | [
"MIT"
] | null | null | null | 26.438017 | 81 | 0.698343 | 12,470 | package shaders;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector2f;
import org.lwjgl.util.vector.Vector3f;
import utility.Console;
public abstract class Shader {
private static FloatBuffer matBuf = BufferUtils.createFloatBuffer(16);
private int program;
private int vertex;
private int fragment;
public Shader(){
vertex = compileShader("res/Shaders/VERTEX.shd", GL20.GL_VERTEX_SHADER);
fragment = compileShader("res/Shaders/FRAGMENT.shd", GL20.GL_FRAGMENT_SHADER);
program = GL20.glCreateProgram();
GL20.glAttachShader(program, vertex);
GL20.glAttachShader(program, fragment);
callAttribs();
GL20.glLinkProgram(program);
GL20.glValidateProgram(program);
callUniforms();
}
public void callStart(){
GL20.glUseProgram(program);
}
public void callStop(){
GL20.glUseProgram(0);
}
public void callExit(){
callStop();
GL20.glDetachShader(program, vertex);
GL20.glDetachShader(program, fragment);
GL20.glDeleteShader(vertex);
GL20.glDeleteShader(fragment);
GL20.glDeleteProgram(program);
}
protected abstract void callAttribs();
protected abstract void callUniforms();
protected int callUniformLocation(String loc){
return GL20.glGetUniformLocation(program, loc);
}
protected void callBind(int attr, String name){
GL20.glBindAttribLocation(program, attr, name);
}
protected void callBindFloat(float data, int loc){
GL20.glUniform1f(loc, data);
}
protected void callBindInt(int data, int loc){
GL20.glUniform1i(loc, data);
}
protected void callBindVector(Vector2f data, int loc){
GL20.glUniform2f(loc, data.x, data.y);
}
protected void callBindVector(Vector3f data, int loc){
GL20.glUniform3f(loc, data.x, data.y, data.z);
}
protected void callBindBoolean(boolean data, int loc){
if(data){
GL20.glUniform1i(loc, 1);
}else{
GL20.glUniform1i(loc, 0);
}
}
protected void callBindMatrix(Matrix4f data, int loc){
data.store(matBuf);
matBuf.flip();
GL20.glUniformMatrix4(loc, false, matBuf);
}
@SuppressWarnings("deprecation")
private static int compileShader(String location, int type){
StringBuilder src = new StringBuilder();
try{
BufferedReader dat = new BufferedReader(new FileReader(location));
String line;
while((line = dat.readLine()) != null){
src.append(line).append("\n");
}
dat.close();
}catch(IOException e){
Console.printerr("Could not load Shader: " + location + "!");
Console.printerr(e.getMessage());
return 0;
}
int ret = 0;
int SID = GL20.glCreateShader(type);
GL20.glShaderSource(SID, src);
GL20.glCompileShader(SID);
if(GL20.glGetShader(SID, GL20.GL_COMPILE_STATUS) != GL11.GL_FALSE){
ret = SID;
}else{
Console.printerr("Couldn't compile shader: " + location + "!");
Console.printerr(GL20.glGetShaderInfoLog(SID, 750));
return 0;
}
return ret;
}
}
|
3e1d64bc63119451712c4356f22306a76518a6e0 | 1,847 | java | Java | org.conqat.engine.dotnet/src/org/conqat/engine/dotnet/test/xunit/EXUnitAttribute.java | assessorgeneral/ConQAT | 2a462f23f22c22aa9d01a7a204453d1be670ba60 | [
"Apache-2.0"
] | 1 | 2020-04-28T20:06:30.000Z | 2020-04-28T20:06:30.000Z | org.conqat.engine.dotnet/src/org/conqat/engine/dotnet/test/xunit/EXUnitAttribute.java | assessorgeneral/ConQAT | 2a462f23f22c22aa9d01a7a204453d1be670ba60 | [
"Apache-2.0"
] | null | null | null | org.conqat.engine.dotnet/src/org/conqat/engine/dotnet/test/xunit/EXUnitAttribute.java | assessorgeneral/ConQAT | 2a462f23f22c22aa9d01a7a204453d1be670ba60 | [
"Apache-2.0"
] | null | null | null | 36.215686 | 76 | 0.455333 | 12,471 | /*-------------------------------------------------------------------------+
| |
| Copyright 2005-2011 The ConQAT Project |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+-------------------------------------------------------------------------*/
package org.conqat.engine.dotnet.test.xunit;
/**
* Enumeration of XML attributes required to read XUnit XML files.
*
* @author $Author: streitel $
* @version $Rev: 50686 $
* @ConQAT.Rating GREEN Hash: 7243E62A3224E14A24C82E914C2F43D8
*/
/* package */enum EXUnitAttribute {
/** The name of the test. */
NAME,
/** The time of the test run. */
TIME,
/** The test outcome. */
OUTCOME,
/** The test result. */
RESULT,
/** The test-method name. */
METHOD,
/** Test type of the test (class). */
TYPE,
/** The time the test was run. */
RUN_TIME,
/** The date the test was run. */
RUN_DATE;
} |
3e1d64f0a6b06bbb23eb3d34a200165cec9d190f | 3,776 | java | Java | src/main/java/net/minecraft/inventory/ContainerBeacon.java | AspireWorld-Project/AspireCore | 61dfc4f6cc7bca4ed7fd4de1413b7c8030a72042 | [
"WTFPL"
] | null | null | null | src/main/java/net/minecraft/inventory/ContainerBeacon.java | AspireWorld-Project/AspireCore | 61dfc4f6cc7bca4ed7fd4de1413b7c8030a72042 | [
"WTFPL"
] | null | null | null | src/main/java/net/minecraft/inventory/ContainerBeacon.java | AspireWorld-Project/AspireCore | 61dfc4f6cc7bca4ed7fd4de1413b7c8030a72042 | [
"WTFPL"
] | null | null | null | 28.606061 | 109 | 0.717161 | 12,472 | package net.minecraft.inventory;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityBeacon;
public class ContainerBeacon extends Container {
private final TileEntityBeacon tileBeacon;
private final ContainerBeacon.BeaconSlot beaconSlot;
private final int field_82865_g;
private final int field_82867_h;
private final int field_82868_i;
private static final String __OBFID = "CL_00001735";
public ContainerBeacon(InventoryPlayer p_i1802_1_, TileEntityBeacon p_i1802_2_) {
tileBeacon = p_i1802_2_;
addSlotToContainer(beaconSlot = new ContainerBeacon.BeaconSlot(p_i1802_2_, 0, 136, 110));
byte b0 = 36;
short short1 = 137;
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
addSlotToContainer(new Slot(p_i1802_1_, j + i * 9 + 9, b0 + j * 18, short1 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
addSlotToContainer(new Slot(p_i1802_1_, i, b0 + i * 18, 58 + short1));
}
field_82865_g = p_i1802_2_.getLevels();
field_82867_h = p_i1802_2_.getPrimaryEffect();
field_82868_i = p_i1802_2_.getSecondaryEffect();
}
@Override
public void addCraftingToCrafters(ICrafting p_75132_1_) {
super.addCraftingToCrafters(p_75132_1_);
p_75132_1_.sendProgressBarUpdate(this, 0, field_82865_g);
p_75132_1_.sendProgressBarUpdate(this, 1, field_82867_h);
p_75132_1_.sendProgressBarUpdate(this, 2, field_82868_i);
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int p_75137_1_, int p_75137_2_) {
if (p_75137_1_ == 0) {
tileBeacon.func_146005_c(p_75137_2_);
}
if (p_75137_1_ == 1) {
tileBeacon.setPrimaryEffect(p_75137_2_);
}
if (p_75137_1_ == 2) {
tileBeacon.setSecondaryEffect(p_75137_2_);
}
}
public TileEntityBeacon func_148327_e() {
return tileBeacon;
}
@Override
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return tileBeacon.isUseableByPlayer(p_75145_1_);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
ItemStack itemstack = null;
Slot slot = (Slot) inventorySlots.get(p_82846_2_);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (p_82846_2_ == 0) {
if (!mergeItemStack(itemstack1, 1, 37, true))
return null;
slot.onSlotChange(itemstack1, itemstack);
} else if (!beaconSlot.getHasStack() && beaconSlot.isItemValid(itemstack1) && itemstack1.stackSize == 1) {
if (!mergeItemStack(itemstack1, 0, 1, false))
return null;
} else if (p_82846_2_ >= 1 && p_82846_2_ < 28) {
if (!mergeItemStack(itemstack1, 28, 37, false))
return null;
} else if (p_82846_2_ >= 28 && p_82846_2_ < 37) {
if (!mergeItemStack(itemstack1, 1, 28, false))
return null;
} else if (!mergeItemStack(itemstack1, 1, 37, false))
return null;
if (itemstack1.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
return null;
slot.onPickupFromSlot(p_82846_1_, itemstack1);
}
return itemstack;
}
class BeaconSlot extends Slot {
private static final String __OBFID = "CL_00001736";
public BeaconSlot(IInventory p_i1801_2_, int p_i1801_3_, int p_i1801_4_, int p_i1801_5_) {
super(p_i1801_2_, p_i1801_3_, p_i1801_4_, p_i1801_5_);
}
@Override
public boolean isItemValid(ItemStack p_75214_1_) {
return p_75214_1_ != null && p_75214_1_.getItem() != null
&& p_75214_1_.getItem().isBeaconPayment(p_75214_1_);
}
@Override
public int getSlotStackLimit() {
return 1;
}
}
} |
3e1d675ff0792a2a0bdd01e51a2d58973df68257 | 798 | java | Java | core/src/main/java/com/alibaba/alink/params/tensorflow/bert/HasNumFineTunedLayersDefaultAs1.java | java-app-scans/Alink | 462ca6b6fbc9de2839ba2e6c14f5f0ed19036561 | [
"Apache-2.0"
] | 1 | 2022-01-24T07:42:54.000Z | 2022-01-24T07:42:54.000Z | core/src/main/java/com/alibaba/alink/params/tensorflow/bert/HasNumFineTunedLayersDefaultAs1.java | java-app-scans/Alink | 462ca6b6fbc9de2839ba2e6c14f5f0ed19036561 | [
"Apache-2.0"
] | null | null | null | core/src/main/java/com/alibaba/alink/params/tensorflow/bert/HasNumFineTunedLayersDefaultAs1.java | java-app-scans/Alink | 462ca6b6fbc9de2839ba2e6c14f5f0ed19036561 | [
"Apache-2.0"
] | null | null | null | 29.555556 | 76 | 0.769424 | 12,473 | package com.alibaba.alink.params.tensorflow.bert;
import org.apache.flink.ml.api.misc.param.ParamInfo;
import org.apache.flink.ml.api.misc.param.ParamInfoFactory;
import org.apache.flink.ml.api.misc.param.WithParams;
public interface HasNumFineTunedLayersDefaultAs1<T> extends WithParams <T> {
/**
* @cn 微调层数
* @cn-name 微调层数
*/
ParamInfo <Integer> NUM_FINE_TUNED_LAYERS = ParamInfoFactory
.createParamInfo("numFineTunedLayers", Integer.class)
.setDescription("number of fine-tuned layers, counting from last one")
.setAlias(new String[] {"numFinetunedLayers"})
.setHasDefaultValue(1)
.build();
default Integer getNumFineTunedLayers() {
return get(NUM_FINE_TUNED_LAYERS);
}
default T setNumFineTunedLayers(Integer value) {
return set(NUM_FINE_TUNED_LAYERS, value);
}
}
|
3e1d67bd334371cfaac02973308c16ad0b4b798a | 1,540 | java | Java | src/main/java/com/yyu/akka/study/xmlparser/actor/AggregateActor.java | yang030405/yyufwk | 266da33b824fceb9ef72abc2d33abbc9384de2f4 | [
"Unlicense"
] | null | null | null | src/main/java/com/yyu/akka/study/xmlparser/actor/AggregateActor.java | yang030405/yyufwk | 266da33b824fceb9ef72abc2d33abbc9384de2f4 | [
"Unlicense"
] | null | null | null | src/main/java/com/yyu/akka/study/xmlparser/actor/AggregateActor.java | yang030405/yyufwk | 266da33b824fceb9ef72abc2d33abbc9384de2f4 | [
"Unlicense"
] | null | null | null | 38.5 | 138 | 0.703896 | 12,474 | package com.yyu.akka.study.xmlparser.actor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.routing.RoundRobinRouter;
import com.yyu.akka.study.xmlparser.action.ColumnParseAction;
import com.yyu.akka.study.xmlparser.action.PropertyParseAction;
import com.yyu.akka.study.xmlparser.message.Result;
public class AggregateActor extends UntypedActor {
private List<Map<String, String>> fieldsInfo = new ArrayList<Map<String, String>>();
private ActorRef columnActor = getContext().actorOf(new Props(ColumnActor.class).withRouter(new RoundRobinRouter(5)), "column");
private ActorRef propertyActor = getContext().actorOf(new Props(PropertyActor.class).withRouter(new RoundRobinRouter(5)), "property");
@SuppressWarnings("unchecked")
@Override
public void onReceive(Object message) throws Exception {
if (message instanceof String) {
String filePath = (String) message;
columnActor.tell(new ColumnParseAction(filePath), getSelf());
propertyActor.tell(new PropertyParseAction(filePath), getSelf());
} else if (message instanceof List) {
fieldsInfo.addAll((List<Map<String, String>>)message);
} else if (message instanceof Result) {
System.out.println("result size = " + fieldsInfo.size());
getSender().tell(fieldsInfo);
} else {
unhandled(message);
}
}
}
|
3e1d680f941c82371dce3754c0a1c99b93835b33 | 6,023 | java | Java | src/extends-parent/jetty-all/src/main/java/org/eclipse/jetty/continuation/ContinuationSupport.java | ivanDannels/hasor | 3b9f4ae6355c6dad2ea8818750b3e04e90cc3e39 | [
"Apache-2.0"
] | 1 | 2018-12-03T09:07:44.000Z | 2018-12-03T09:07:44.000Z | src/extends-parent/jetty-all/src/main/java/org/eclipse/jetty/continuation/ContinuationSupport.java | ivanDannels/hasor | 3b9f4ae6355c6dad2ea8818750b3e04e90cc3e39 | [
"Apache-2.0"
] | null | null | null | src/extends-parent/jetty-all/src/main/java/org/eclipse/jetty/continuation/ContinuationSupport.java | ivanDannels/hasor | 3b9f4ae6355c6dad2ea8818750b3e04e90cc3e39 | [
"Apache-2.0"
] | null | null | null | 36.50303 | 191 | 0.590071 | 12,475 | //
// ========================================================================
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.continuation;
import java.lang.reflect.Constructor;
import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestWrapper;
import javax.servlet.ServletResponse;
/* ------------------------------------------------------------ */
/** ContinuationSupport.
*
* Factory class for accessing Continuation instances, which with either be
* native to the container (jetty >= 6), a servlet 3.0 or a faux continuation.
*
*/
public class ContinuationSupport
{
static final boolean __jetty6;
static final boolean __servlet3;
static final Class<?> __waitingContinuation;
static final Constructor<? extends Continuation> __newServlet3Continuation;
static final Constructor<? extends Continuation> __newJetty6Continuation;
static
{
boolean servlet3Support=false;
Constructor<? extends Continuation>s3cc=null;
try
{
boolean servlet3=ServletRequest.class.getMethod("startAsync")!=null;
if (servlet3)
{
Class<? extends Continuation> s3c = ContinuationSupport.class.getClassLoader().loadClass("org.eclipse.jetty.continuation.Servlet3Continuation").asSubclass(Continuation.class);
s3cc=s3c.getConstructor(ServletRequest.class);
servlet3Support=true;
}
}
catch (Exception e)
{}
finally
{
__servlet3=servlet3Support;
__newServlet3Continuation=s3cc;
}
boolean jetty6Support=false;
Constructor<? extends Continuation>j6cc=null;
try
{
Class<?> jetty6ContinuationClass = ContinuationSupport.class.getClassLoader().loadClass("org.mortbay.util.ajax.Continuation");
boolean jetty6=jetty6ContinuationClass!=null;
if (jetty6)
{
Class<? extends Continuation> j6c = ContinuationSupport.class.getClassLoader().loadClass("org.eclipse.jetty.continuation.Jetty6Continuation").asSubclass(Continuation.class);
j6cc=j6c.getConstructor(ServletRequest.class, jetty6ContinuationClass);
jetty6Support=true;
}
}
catch (Exception e)
{}
finally
{
__jetty6=jetty6Support;
__newJetty6Continuation=j6cc;
}
Class<?> waiting=null;
try
{
waiting=ContinuationSupport.class.getClassLoader().loadClass("org.mortbay.util.ajax.WaitingContinuation");
}
catch (Exception e)
{
}
finally
{
__waitingContinuation=waiting;
}
}
/* ------------------------------------------------------------ */
/**
* Get a Continuation. The type of the Continuation returned may
* vary depending on the container in which the application is
* deployed. It may be an implementation native to the container (eg
* org.eclipse.jetty.server.AsyncContinuation) or one of the utility
* implementations provided such as an internal <code>FauxContinuation</code>
* or a real implementation like {@link org.eclipse.jetty.continuation.Servlet3Continuation}.
* @param request The request
* @return a Continuation instance
*/
public static Continuation getContinuation(ServletRequest request)
{
Continuation continuation = (Continuation) request.getAttribute(Continuation.ATTRIBUTE);
if (continuation!=null)
return continuation;
while (request instanceof ServletRequestWrapper)
request=((ServletRequestWrapper)request).getRequest();
if (__servlet3 )
{
try
{
continuation=__newServlet3Continuation.newInstance(request);
request.setAttribute(Continuation.ATTRIBUTE,continuation);
return continuation;
}
catch(Exception e)
{
throw new RuntimeException(e);
}
}
if (__jetty6)
{
Object c=request.getAttribute("org.mortbay.jetty.ajax.Continuation");
try
{
if (c==null || __waitingContinuation==null || __waitingContinuation.isInstance(c))
continuation=new FauxContinuation(request);
else
continuation= __newJetty6Continuation.newInstance(request,c);
request.setAttribute(Continuation.ATTRIBUTE,continuation);
return continuation;
}
catch(Exception e)
{
throw new RuntimeException(e);
}
}
throw new IllegalStateException("!(Jetty || Servlet 3.0 || ContinuationFilter)");
}
/* ------------------------------------------------------------ */
/**
* @param request the servlet request
* @param response the servlet response
* @deprecated use {@link #getContinuation(ServletRequest)}
* @return the continuation
*/
@Deprecated
public static Continuation getContinuation(final ServletRequest request, final ServletResponse response)
{
return getContinuation(request);
}
}
|
3e1d68656fe762351249c4be971f9b615894bdc7 | 8,458 | java | Java | aws-java-sdk-lexmodelbuilding/src/main/java/com/amazonaws/services/lexmodelbuilding/model/GetIntentVersionsRequest.java | ericvincent83/aws-sdk-java | c491416f3ea9411a04d9bafedee6c6874a79e48d | [
"Apache-2.0"
] | 3,372 | 2015-01-03T00:35:43.000Z | 2022-03-31T15:56:24.000Z | aws-java-sdk-lexmodelbuilding/src/main/java/com/amazonaws/services/lexmodelbuilding/model/GetIntentVersionsRequest.java | ericvincent83/aws-sdk-java | c491416f3ea9411a04d9bafedee6c6874a79e48d | [
"Apache-2.0"
] | 2,391 | 2015-01-01T12:55:24.000Z | 2022-03-31T08:01:50.000Z | aws-java-sdk-lexmodelbuilding/src/main/java/com/amazonaws/services/lexmodelbuilding/model/GetIntentVersionsRequest.java | ericvincent83/aws-sdk-java | c491416f3ea9411a04d9bafedee6c6874a79e48d | [
"Apache-2.0"
] | 2,876 | 2015-01-01T14:38:37.000Z | 2022-03-29T19:53:10.000Z | 34.522449 | 120 | 0.630173 | 12,476 | /*
* Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.lexmodelbuilding.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.AmazonWebServiceRequest;
/**
*
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/lex-models-2017-04-19/GetIntentVersions" target="_top">AWS API
* Documentation</a>
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class GetIntentVersionsRequest extends com.amazonaws.AmazonWebServiceRequest implements Serializable, Cloneable {
/**
* <p>
* The name of the intent for which versions should be returned.
* </p>
*/
private String name;
/**
* <p>
* A pagination token for fetching the next page of intent versions. If the response to this call is truncated,
* Amazon Lex returns a pagination token in the response. To fetch the next page of versions, specify the pagination
* token in the next request.
* </p>
*/
private String nextToken;
/**
* <p>
* The maximum number of intent versions to return in the response. The default is 10.
* </p>
*/
private Integer maxResults;
/**
* <p>
* The name of the intent for which versions should be returned.
* </p>
*
* @param name
* The name of the intent for which versions should be returned.
*/
public void setName(String name) {
this.name = name;
}
/**
* <p>
* The name of the intent for which versions should be returned.
* </p>
*
* @return The name of the intent for which versions should be returned.
*/
public String getName() {
return this.name;
}
/**
* <p>
* The name of the intent for which versions should be returned.
* </p>
*
* @param name
* The name of the intent for which versions should be returned.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public GetIntentVersionsRequest withName(String name) {
setName(name);
return this;
}
/**
* <p>
* A pagination token for fetching the next page of intent versions. If the response to this call is truncated,
* Amazon Lex returns a pagination token in the response. To fetch the next page of versions, specify the pagination
* token in the next request.
* </p>
*
* @param nextToken
* A pagination token for fetching the next page of intent versions. If the response to this call is
* truncated, Amazon Lex returns a pagination token in the response. To fetch the next page of versions,
* specify the pagination token in the next request.
*/
public void setNextToken(String nextToken) {
this.nextToken = nextToken;
}
/**
* <p>
* A pagination token for fetching the next page of intent versions. If the response to this call is truncated,
* Amazon Lex returns a pagination token in the response. To fetch the next page of versions, specify the pagination
* token in the next request.
* </p>
*
* @return A pagination token for fetching the next page of intent versions. If the response to this call is
* truncated, Amazon Lex returns a pagination token in the response. To fetch the next page of versions,
* specify the pagination token in the next request.
*/
public String getNextToken() {
return this.nextToken;
}
/**
* <p>
* A pagination token for fetching the next page of intent versions. If the response to this call is truncated,
* Amazon Lex returns a pagination token in the response. To fetch the next page of versions, specify the pagination
* token in the next request.
* </p>
*
* @param nextToken
* A pagination token for fetching the next page of intent versions. If the response to this call is
* truncated, Amazon Lex returns a pagination token in the response. To fetch the next page of versions,
* specify the pagination token in the next request.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public GetIntentVersionsRequest withNextToken(String nextToken) {
setNextToken(nextToken);
return this;
}
/**
* <p>
* The maximum number of intent versions to return in the response. The default is 10.
* </p>
*
* @param maxResults
* The maximum number of intent versions to return in the response. The default is 10.
*/
public void setMaxResults(Integer maxResults) {
this.maxResults = maxResults;
}
/**
* <p>
* The maximum number of intent versions to return in the response. The default is 10.
* </p>
*
* @return The maximum number of intent versions to return in the response. The default is 10.
*/
public Integer getMaxResults() {
return this.maxResults;
}
/**
* <p>
* The maximum number of intent versions to return in the response. The default is 10.
* </p>
*
* @param maxResults
* The maximum number of intent versions to return in the response. The default is 10.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public GetIntentVersionsRequest withMaxResults(Integer maxResults) {
setMaxResults(maxResults);
return this;
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getName() != null)
sb.append("Name: ").append(getName()).append(",");
if (getNextToken() != null)
sb.append("NextToken: ").append(getNextToken()).append(",");
if (getMaxResults() != null)
sb.append("MaxResults: ").append(getMaxResults());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof GetIntentVersionsRequest == false)
return false;
GetIntentVersionsRequest other = (GetIntentVersionsRequest) obj;
if (other.getName() == null ^ this.getName() == null)
return false;
if (other.getName() != null && other.getName().equals(this.getName()) == false)
return false;
if (other.getNextToken() == null ^ this.getNextToken() == null)
return false;
if (other.getNextToken() != null && other.getNextToken().equals(this.getNextToken()) == false)
return false;
if (other.getMaxResults() == null ^ this.getMaxResults() == null)
return false;
if (other.getMaxResults() != null && other.getMaxResults().equals(this.getMaxResults()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode());
hashCode = prime * hashCode + ((getNextToken() == null) ? 0 : getNextToken().hashCode());
hashCode = prime * hashCode + ((getMaxResults() == null) ? 0 : getMaxResults().hashCode());
return hashCode;
}
@Override
public GetIntentVersionsRequest clone() {
return (GetIntentVersionsRequest) super.clone();
}
}
|
3e1d6a2d164936353c28ed24e02c97a6b756ea5d | 1,710 | java | Java | bdnav-common/common-utils/src/main/java/com/bdxh/common/helper/weixiao/qrcode/QRCodeUtils.java | kichenn/bdnav_platform | 9154a3ba121bcc3cca5f71907fccd6a198589809 | [
"Apache-2.0"
] | 1 | 2019-09-28T06:31:00.000Z | 2019-09-28T06:31:00.000Z | bdnav-common/common-utils/src/main/java/com/bdxh/common/helper/weixiao/qrcode/QRCodeUtils.java | kichenn/bdnav_platform | 9154a3ba121bcc3cca5f71907fccd6a198589809 | [
"Apache-2.0"
] | 5 | 2020-03-04T23:19:32.000Z | 2021-06-04T22:02:09.000Z | bdnav-common/common-utils/src/main/java/com/bdxh/common/helper/weixiao/qrcode/QRCodeUtils.java | kichenn/bdnav_platform | 9154a3ba121bcc3cca5f71907fccd6a198589809 | [
"Apache-2.0"
] | 1 | 2021-01-10T11:07:05.000Z | 2021-01-10T11:07:05.000Z | 29.482759 | 79 | 0.618713 | 12,477 | package com.bdxh.common.helper.weixiao.qrcode;
import com.bdxh.common.helper.baidu.yingyan.constant.FenceConstant;
import com.bdxh.common.helper.baidu.yingyan.request.CreateFenceRoundRequest;
import com.bdxh.common.helper.weixiao.qrcode.constant.CodeConstant;
import com.bdxh.common.helper.weixiao.qrcode.request.CampusCodeRequest;
import com.bdxh.common.utils.HttpClientUtils;
import org.apache.commons.beanutils.BeanMap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* @Description: 校园码相关
* @Author: Kang
* @Date: 2019/7/11 14:46
*/
public class QRCodeUtils {
/**
* @Description: 解码接口
* @Author: Kang
* @Date: 2019/7/11 14:46
*/
public static String campusCode(CampusCodeRequest campusCodeRequest) {
Map<String, Object> map = toMap(campusCodeRequest);
String result = "";
try {
result = HttpClientUtils.doPost(CodeConstant.CAMPUS_CODE_URL, map);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
private static Map<String, Object> toMap(Object obj) {
Map<String, Object> map = new HashMap<>();
if (obj == null) {
return map;
} else if (obj instanceof Map) {
return (Map<String, Object>) obj;
}
BeanMap beanMap = new BeanMap(obj);
Iterator<String> it = beanMap.keyIterator();
while (it.hasNext()) {
String name = it.next();
Object value = beanMap.get(name);
// 转换时会将类名也转换成属性,此处去掉
if (value != null && !name.equals("class")) {
map.put(name, value);
}
}
return map;
}
}
|
3e1d6a800f28a5c63937f24d39b310e65c5bbe69 | 1,161 | java | Java | pinot-common/src/main/java/com/linkedin/pinot/common/config/ChildKeyTransformer.java | TomMD/pinot | efe3d0f0ddd8a4adcdde4bcdf4533b124400cd18 | [
"Apache-2.0"
] | null | null | null | pinot-common/src/main/java/com/linkedin/pinot/common/config/ChildKeyTransformer.java | TomMD/pinot | efe3d0f0ddd8a4adcdde4bcdf4533b124400cd18 | [
"Apache-2.0"
] | 2 | 2018-05-18T22:14:59.000Z | 2018-05-18T22:16:27.000Z | pinot-common/src/main/java/com/linkedin/pinot/common/config/ChildKeyTransformer.java | TomMD/pinot | efe3d0f0ddd8a4adcdde4bcdf4533b124400cd18 | [
"Apache-2.0"
] | null | null | null | 38.9 | 118 | 0.741217 | 12,478 | /**
* Copyright (C) 2014-2016 LinkedIn Corp. (upchh@example.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.linkedin.pinot.common.config;
import io.vavr.collection.Map;
/**
* Transforms the child keys of a given configuration path into a new set of child keys. This can be used to implement
* complex DSLs that depend on combination of keys, as well as other operations like splitting, merging, and filtering
* of configuration keys.
*/
public interface ChildKeyTransformer {
Map<String, ?> apply(Map<String, ?> childKeys, String pathPrefix);
Map<String, ?> unapply(Map<String, ?> childKeys, String pathPrefix);
}
|
3e1d6b34ef6995a55c26a3db421f950924ba6d9a | 14,019 | java | Java | src/main/java/org/rcsb/cif/schema/mm/Publ.java | rcsb/ciftools-java | d2da0bc67b94cda2af7309590eed1c4d1e55a161 | [
"MIT"
] | 9 | 2019-05-02T22:42:35.000Z | 2021-12-14T11:19:32.000Z | src/main/java/org/rcsb/cif/schema/mm/Publ.java | rcsb/ciftools-java | d2da0bc67b94cda2af7309590eed1c4d1e55a161 | [
"MIT"
] | 9 | 2019-11-20T18:39:34.000Z | 2021-11-23T14:42:44.000Z | src/main/java/org/rcsb/cif/schema/mm/Publ.java | rcsb/ciftools-java | d2da0bc67b94cda2af7309590eed1c4d1e55a161 | [
"MIT"
] | 6 | 2019-11-18T07:59:40.000Z | 2021-07-02T02:23:28.000Z | 36.318653 | 88 | 0.666667 | 12,479 | package org.rcsb.cif.schema.mm;
import org.rcsb.cif.model.*;
import org.rcsb.cif.schema.*;
import javax.annotation.Generated;
/**
* Data items in the PUBL category are used when submitting a
* manuscript for publication.
*/
@Generated("org.rcsb.cif.schema.generator.SchemaGenerator")
public class Publ extends DelegatingCategory {
public Publ(Category delegate) {
super(delegate);
}
@Override
protected Column createDelegate(String columnName, Column column) {
switch (columnName) {
case "entry_id":
return getEntryId();
case "contact_author":
return getContactAuthor();
case "contact_author_address":
return getContactAuthorAddress();
case "contact_author_email":
return getContactAuthorEmail();
case "contact_author_fax":
return getContactAuthorFax();
case "contact_author_name":
return getContactAuthorName();
case "contact_author_phone":
return getContactAuthorPhone();
case "contact_letter":
return getContactLetter();
case "manuscript_creation":
return getManuscriptCreation();
case "manuscript_processed":
return getManuscriptProcessed();
case "manuscript_text":
return getManuscriptText();
case "requested_category":
return getRequestedCategory();
case "requested_coeditor_name":
return getRequestedCoeditorName();
case "requested_journal":
return getRequestedJournal();
case "section_abstract":
return getSectionAbstract();
case "section_acknowledgements":
return getSectionAcknowledgements();
case "section_comment":
return getSectionComment();
case "section_discussion":
return getSectionDiscussion();
case "section_experimental":
return getSectionExperimental();
case "section_exptl_prep":
return getSectionExptlPrep();
case "section_exptl_refinement":
return getSectionExptlRefinement();
case "section_exptl_solution":
return getSectionExptlSolution();
case "section_figure_captions":
return getSectionFigureCaptions();
case "section_introduction":
return getSectionIntroduction();
case "section_references":
return getSectionReferences();
case "section_synopsis":
return getSectionSynopsis();
case "section_table_legends":
return getSectionTableLegends();
case "section_title":
return getSectionTitle();
case "section_title_footnote":
return getSectionTitleFootnote();
default:
return new DelegatingColumn(column);
}
}
/**
* This data item is a pointer to _entry.id in the ENTRY category.
* @return StrColumn
*/
public StrColumn getEntryId() {
return delegate.getColumn("entry_id", DelegatingStrColumn::new);
}
/**
* The name and address of the author submitting the manuscript and
* data block. This is the person contacted by the journal
* editorial staff. It is preferable to use the separate data items
* _publ.contact_author_name and _publ.contact_author_address.
* @return StrColumn
*/
public StrColumn getContactAuthor() {
return delegate.getColumn("contact_author", DelegatingStrColumn::new);
}
/**
* The address of the author submitting the manuscript and data
* block. This is the person contacted by the journal editorial
* staff.
* @return StrColumn
*/
public StrColumn getContactAuthorAddress() {
return delegate.getColumn("contact_author_address", DelegatingStrColumn::new);
}
/**
* E-mail address in a form recognizable to international networks.
* The format of e-mail addresses is given in Section 3.4, Address
* Specification, of Internet Message Format, RFC 2822, P. Resnick
* (Editor), Network Standards Group, April 2001.
* @return StrColumn
*/
public StrColumn getContactAuthorEmail() {
return delegate.getColumn("contact_author_email", DelegatingStrColumn::new);
}
/**
* Facsimile telephone number of the author submitting the
* manuscript and data block.
*
* The recommended style starts with the international dialing
* prefix, followed by the area code in parentheses, followed by the
* local number with no spaces. The earlier convention of including
* the international dialing prefix in parentheses is no longer
* recommended.
* @return StrColumn
*/
public StrColumn getContactAuthorFax() {
return delegate.getColumn("contact_author_fax", DelegatingStrColumn::new);
}
/**
* The name of the author submitting the manuscript and data
* block. This is the person contacted by the journal editorial
* staff.
* @return StrColumn
*/
public StrColumn getContactAuthorName() {
return delegate.getColumn("contact_author_name", DelegatingStrColumn::new);
}
/**
* Telephone number of the author submitting the manuscript and
* data block.
*
* The recommended style starts with the international dialing
* prefix, followed by the area code in parentheses, followed by the
* local number and any extension number prefixed by 'x',
* with no spaces. The earlier convention of including
* the international dialing prefix in parentheses is no longer
* recommended.
* @return StrColumn
*/
public StrColumn getContactAuthorPhone() {
return delegate.getColumn("contact_author_phone", DelegatingStrColumn::new);
}
/**
* A letter submitted to the journal editor by the contact author.
* @return StrColumn
*/
public StrColumn getContactLetter() {
return delegate.getColumn("contact_letter", DelegatingStrColumn::new);
}
/**
* A description of the word-processor package and computer used to
* create the word-processed manuscript stored as
* _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getManuscriptCreation() {
return delegate.getColumn("manuscript_creation", DelegatingStrColumn::new);
}
/**
* The full manuscript of a paper (excluding possibly the figures
* and the tables) output in ASCII characters from a word processor.
* Information about the generation of this data item must be
* specified in the data item _publ.manuscript_creation.
* @return StrColumn
*/
public StrColumn getManuscriptProcessed() {
return delegate.getColumn("manuscript_processed", DelegatingStrColumn::new);
}
/**
* The full manuscript of a paper (excluding figures and possibly
* the tables) output as standard ASCII text.
* @return StrColumn
*/
public StrColumn getManuscriptText() {
return delegate.getColumn("manuscript_text", DelegatingStrColumn::new);
}
/**
* The category of paper submitted. For submission to
* Acta Crystallographica Section C or
* Acta Crystallographica Section E, ONLY the codes indicated
* for use with these journals should be used.
* @return StrColumn
*/
public StrColumn getRequestedCategory() {
return delegate.getColumn("requested_category", DelegatingStrColumn::new);
}
/**
* The name of the co-editor whom the authors would like to
* handle the submitted manuscript.
* @return StrColumn
*/
public StrColumn getRequestedCoeditorName() {
return delegate.getColumn("requested_coeditor_name", DelegatingStrColumn::new);
}
/**
* The name of the journal to which the manuscript is being
* submitted.
* @return StrColumn
*/
public StrColumn getRequestedJournal() {
return delegate.getColumn("requested_journal", DelegatingStrColumn::new);
}
/**
* The abstract section of a manuscript if the manuscript is
* submitted in parts. As an alternative see _publ.manuscript_text
* and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionAbstract() {
return delegate.getColumn("section_abstract", DelegatingStrColumn::new);
}
/**
* The acknowledgements section of a manuscript if the manuscript is
* submitted in parts. As an alternative see _publ.manuscript_text
* and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionAcknowledgements() {
return delegate.getColumn("section_acknowledgements", DelegatingStrColumn::new);
}
/**
* The comment section of a manuscript if the manuscript is
* submitted in parts. As an alternative see _publ.manuscript_text
* and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionComment() {
return delegate.getColumn("section_comment", DelegatingStrColumn::new);
}
/**
* The discussion section of a manuscript if the manuscript is
* submitted in parts. As an alternative see _publ.manuscript_text
* and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionDiscussion() {
return delegate.getColumn("section_discussion", DelegatingStrColumn::new);
}
/**
* The experimental section of a manuscript if the manuscript is
* submitted in parts. As an alternative see _publ.manuscript_text
* and _publ.manuscript_processed.
* The _publ.section_exptl_prep, _publ.section_exptl_solution and
* _publ.section_exptl_refinement items are preferred for
* separating the chemical preparation, structure solution and
* refinement aspects of the description of the experiment.
* @return StrColumn
*/
public StrColumn getSectionExperimental() {
return delegate.getColumn("section_experimental", DelegatingStrColumn::new);
}
/**
* The experimental preparation section of a manuscript if the
* manuscript is submitted in parts. As an alternative see
* _publ.manuscript_text and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionExptlPrep() {
return delegate.getColumn("section_exptl_prep", DelegatingStrColumn::new);
}
/**
* The experimental refinement section of a manuscript if the
* manuscript is submitted in parts. As an alternative see
* _publ.manuscript_text and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionExptlRefinement() {
return delegate.getColumn("section_exptl_refinement", DelegatingStrColumn::new);
}
/**
* The experimental solution section of a manuscript if the
* manuscript is submitted in parts. As an alternative see
* _publ.manuscript_text and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionExptlSolution() {
return delegate.getColumn("section_exptl_solution", DelegatingStrColumn::new);
}
/**
* The figure captions section of a manuscript if the manuscript is
* submitted in parts. As an alternative see _publ.manuscript_text
* and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionFigureCaptions() {
return delegate.getColumn("section_figure_captions", DelegatingStrColumn::new);
}
/**
* The introduction section of a manuscript if the manuscript is
* submitted in parts. As an alternative see _publ.manuscript_text
* and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionIntroduction() {
return delegate.getColumn("section_introduction", DelegatingStrColumn::new);
}
/**
* The references section of a manuscript if the manuscript is
* submitted in parts. As an alternative see _publ.manuscript_text
* and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionReferences() {
return delegate.getColumn("section_references", DelegatingStrColumn::new);
}
/**
* The synopsis section of a manuscript if the manuscript is
* submitted in parts. As an alternative see _publ.manuscript_text
* and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionSynopsis() {
return delegate.getColumn("section_synopsis", DelegatingStrColumn::new);
}
/**
* The table legends section of a manuscript if the manuscript
* is submitted in parts. As an alternative see
* _publ.manuscript_text and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionTableLegends() {
return delegate.getColumn("section_table_legends", DelegatingStrColumn::new);
}
/**
* The title of a manuscript if the manuscript is submitted in
* parts. As an alternative see _publ.manuscript_text and
* _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionTitle() {
return delegate.getColumn("section_title", DelegatingStrColumn::new);
}
/**
* The footnote to the title of a manuscript if the manuscript
* is submitted in parts. As an alternative see
* _publ.manuscript_text and _publ.manuscript_processed.
* @return StrColumn
*/
public StrColumn getSectionTitleFootnote() {
return delegate.getColumn("section_title_footnote", DelegatingStrColumn::new);
}
} |
3e1d6c57a284a416e07f6ecca57dbb054ed9a4fa | 735 | java | Java | Images/app/src/main/java/com/example/hafizhamza/images/MainActivity.java | HafizHamza19/ImageView-in-Android | 1441b4e02666c64fd4cc2882b1f1354565a0f0fb | [
"MIT"
] | null | null | null | Images/app/src/main/java/com/example/hafizhamza/images/MainActivity.java | HafizHamza19/ImageView-in-Android | 1441b4e02666c64fd4cc2882b1f1354565a0f0fb | [
"MIT"
] | null | null | null | Images/app/src/main/java/com/example/hafizhamza/images/MainActivity.java | HafizHamza19/ImageView-in-Android | 1441b4e02666c64fd4cc2882b1f1354565a0f0fb | [
"MIT"
] | null | null | null | 23.709677 | 70 | 0.727891 | 12,480 | package com.example.hafizhamza.images;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
public void Next(View view)
{
ImageView imageImageView=(ImageView)findViewById(R.id.iImageView);
imageImageView.setImageResource(R.drawable.second);
}
public void Previous(View view)
{
ImageView i=(ImageView)findViewById(R.id.iImageView);
i.setImageResource(R.drawable.first);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
|
3e1d6c79832efb704d1c65a9ecec6a3d5147a66e | 2,844 | java | Java | exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DirectPlan.java | idvp-project/drill | 94e86d19407b0a66cfe432f45fb91a880eae4ea9 | [
"Apache-2.0"
] | 1,510 | 2015-01-04T01:35:19.000Z | 2022-03-28T23:36:02.000Z | exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DirectPlan.java | idvp-project/drill | 94e86d19407b0a66cfe432f45fb91a880eae4ea9 | [
"Apache-2.0"
] | 1,979 | 2015-01-28T03:18:38.000Z | 2022-03-31T13:49:32.000Z | exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DirectPlan.java | zhangxiangyang/drill | 97a321d8dc7430d8840fb4e0ee805b9fd2a0c329 | [
"Apache-2.0"
] | 940 | 2015-01-01T01:39:39.000Z | 2022-03-25T08:46:59.000Z | 44.4375 | 117 | 0.789733 | 12,481 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.drill.exec.planner.sql;
import org.apache.drill.common.logical.PlanProperties;
import org.apache.drill.common.logical.PlanProperties.Generator.ResultMode;
import org.apache.drill.common.logical.PlanProperties.PlanPropertiesBuilder;
import org.apache.drill.common.logical.PlanProperties.PlanType;
import org.apache.drill.exec.ops.QueryContext;
import org.apache.drill.exec.physical.PhysicalPlan;
import org.apache.drill.exec.physical.config.Screen;
import org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler;
import org.apache.drill.exec.planner.sql.handlers.SimpleCommandResult;
import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
import org.apache.drill.exec.store.direct.DirectGroupScan;
import org.apache.drill.exec.store.pojo.PojoRecordReader;
import java.util.Collections;
import java.util.List;
public class DirectPlan {
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DirectPlan.class);
public static PhysicalPlan createDirectPlan(QueryContext context, boolean result, String message){
return createDirectPlan(context, new SimpleCommandResult(result, message));
}
@SuppressWarnings("unchecked")
public static <T> PhysicalPlan createDirectPlan(QueryContext context, T obj){
return createDirectPlan(context.getCurrentEndpoint(), Collections.singletonList(obj), (Class<T>) obj.getClass());
}
public static <T> PhysicalPlan createDirectPlan(DrillbitEndpoint endpoint, List<T> records, Class<T> clazz){
PojoRecordReader<T> reader = new PojoRecordReader<>(clazz, records);
DirectGroupScan scan = new DirectGroupScan(reader);
Screen screen = new Screen(scan, endpoint);
PlanPropertiesBuilder propsBuilder = PlanProperties.builder();
propsBuilder.type(PlanType.APACHE_DRILL_PHYSICAL);
propsBuilder.version(1);
propsBuilder.resultMode(ResultMode.EXEC);
propsBuilder.generator(DirectPlan.class.getSimpleName(), "");
return new PhysicalPlan(propsBuilder.build(), DefaultSqlHandler.getPops(screen));
}
}
|
3e1d6cad9595432e3ff186ea37deeac7c54ba61d | 1,873 | java | Java | oscm-portal/javasrc/org/oscm/ui/dialog/common/ldapsettings/LdapSettingConverter.java | srinathjiinfotach/billingdevelopment | 564e66593c9d272b8e04804410b633bc089aa203 | [
"Apache-2.0"
] | 56 | 2015-10-06T15:09:39.000Z | 2021-08-09T01:18:03.000Z | oscm-portal/javasrc/org/oscm/ui/dialog/common/ldapsettings/LdapSettingConverter.java | srinathjiinfotach/billingdevelopment | 564e66593c9d272b8e04804410b633bc089aa203 | [
"Apache-2.0"
] | 845 | 2016-02-10T14:06:17.000Z | 2020-10-20T07:44:09.000Z | oscm-portal/javasrc/org/oscm/ui/dialog/common/ldapsettings/LdapSettingConverter.java | srinathjiinfotach/billingdevelopment | 564e66593c9d272b8e04804410b633bc089aa203 | [
"Apache-2.0"
] | 41 | 2015-10-22T14:22:23.000Z | 2022-03-18T07:55:15.000Z | 34.685185 | 82 | 0.583022 | 12,482 | /*******************************************************************************
* Copyright FUJITSU LIMITED 2017
*******************************************************************************/
package org.oscm.ui.dialog.common.ldapsettings;
import java.util.Collection;
import java.util.Properties;
import org.oscm.internal.usermanagement.POLdapSetting;
public class LdapSettingConverter {
/**
* Converts the server settings to the model representation and adds them to
* the collection.
*
* @param modelSettings
* The model settings to add the converted settings to.
* @param serverSettings
* The server settings to convert to model representation.
*/
void addToModel(Collection<LdapSetting> modelSettings,
Collection<POLdapSetting> serverSettings) {
for (POLdapSetting serverSetting : serverSettings) {
modelSettings.add(new LdapSetting(serverSetting));
}
}
/**
* Converts the provided settings to a property structure.
*
* @param modelSettings
* The settings to convert.
* @param keepValueForPlatformDefault
* keep the value of the settings even if they are platform
* settings
*/
Properties toProperties(Collection<LdapSetting> modelSettings,
boolean keepValueForPlatformDefault) {
Properties properties = new Properties();
for (LdapSetting ldapSetting : modelSettings) {
if (ldapSetting.isPlatformDefault() && !keepValueForPlatformDefault) {
properties.setProperty(ldapSetting.getSettingKey(), "");
} else {
properties.setProperty(ldapSetting.getSettingKey(),
ldapSetting.getSettingValue());
}
}
return properties;
}
}
|
3e1d6e94a21e88f55f04f4a7ba411020f17ca1d9 | 5,304 | java | Java | my-quartz/src/main/java/org/quartz/Scheduler.java | sharplook/microservice | 31c91c31504ca1cf5ac15a445a618b988b3a52df | [
"MIT"
] | null | null | null | my-quartz/src/main/java/org/quartz/Scheduler.java | sharplook/microservice | 31c91c31504ca1cf5ac15a445a618b988b3a52df | [
"MIT"
] | null | null | null | my-quartz/src/main/java/org/quartz/Scheduler.java | sharplook/microservice | 31c91c31504ca1cf5ac15a445a618b988b3a52df | [
"MIT"
] | null | null | null | 31.384615 | 133 | 0.76678 | 12,484 |
/*
* Copyright 2001-2009 Terracotta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
package org.quartz;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface Scheduler {
String DEFAULT_GROUP = Key.DEFAULT_GROUP;
String DEFAULT_RECOVERY_GROUP = "RECOVERING_JOBS";
String DEFAULT_FAIL_OVER_GROUP = "FAILED_OVER_JOBS";
String FAILED_JOB_ORIGINAL_TRIGGER_NAME = "QRTZ_FAILED_JOB_ORIG_TRIGGER_NAME";
String FAILED_JOB_ORIGINAL_TRIGGER_GROUP = "QRTZ_FAILED_JOB_ORIG_TRIGGER_GROUP";
String FAILED_JOB_ORIGINAL_TRIGGER_FIRETIME_IN_MILLISECONDS = "QRTZ_FAILED_JOB_ORIG_TRIGGER_FIRETIME_IN_MILLISECONDS_AS_STRING";
String getSchedulerName() throws SchedulerException;
String getSchedulerInstanceId() throws SchedulerException;
SchedulerContext getContext() throws SchedulerException;
void start() throws SchedulerException;
void startDelayed(int seconds) throws SchedulerException;
boolean isStarted() throws SchedulerException;
void standby() throws SchedulerException;
boolean isInStandbyMode() throws SchedulerException;
void shutdown() throws SchedulerException;
void shutdown(boolean waitForJobsToComplete)
throws SchedulerException;
boolean isShutdown() throws SchedulerException;
SchedulerMetaData getMetaData() throws SchedulerException;
List<JobExecutionContext> getCurrentlyExecutingJobs() throws SchedulerException;
void setJobFactory(JobFactory factory) throws SchedulerException;
ListenerManager getListenerManager() throws SchedulerException;
Date scheduleJob(JobDetail jobDetail, Trigger trigger)
throws SchedulerException;
Date scheduleJob(Trigger trigger) throws SchedulerException;
void scheduleJobs(Map<JobDetail, List<Trigger>> triggersAndJobs, boolean replace) throws SchedulerException;
boolean unscheduleJob(TriggerKey triggerKey)
throws SchedulerException;
boolean unscheduleJobs(List<TriggerKey> triggerKeys)
throws SchedulerException;
Date rescheduleJob(TriggerKey triggerKey, Trigger newTrigger)
throws SchedulerException;
void addJob(JobDetail jobDetail, boolean replace)
throws SchedulerException;
boolean deleteJob(JobKey jobKey)
throws SchedulerException;
boolean deleteJobs(List<JobKey> jobKeys)
throws SchedulerException;
void triggerJob(JobKey jobKey)
throws SchedulerException;
void triggerJob(JobKey jobKey, JobDataMap data)
throws SchedulerException;
void pauseJob(JobKey jobKey)
throws SchedulerException;
void pauseJobs(GroupMatcher<JobKey> matcher) throws SchedulerException;
void pauseTrigger(TriggerKey triggerKey)
throws SchedulerException;
void pauseTriggers(GroupMatcher<TriggerKey> matcher) throws SchedulerException;
void resumeJob(JobKey jobKey)
throws SchedulerException;
void resumeJobs(GroupMatcher<JobKey> matcher) throws SchedulerException;
void resumeTrigger(TriggerKey triggerKey)
throws SchedulerException;
void resumeTriggers(GroupMatcher<TriggerKey> matcher) throws SchedulerException;
void pauseAll() throws SchedulerException;
void resumeAll() throws SchedulerException;
List<String> getJobGroupNames() throws SchedulerException;
Set<JobKey> getJobKeys(GroupMatcher<JobKey> matcher) throws SchedulerException;
List<? extends Trigger> getTriggersOfJob(JobKey jobKey)
throws SchedulerException;
List<String> getTriggerGroupNames() throws SchedulerException;
Set<TriggerKey> getTriggerKeys(GroupMatcher<TriggerKey> matcher) throws SchedulerException;
Set<String> getPausedTriggerGroups() throws SchedulerException;
JobDetail getJobDetail(JobKey jobKey)
throws SchedulerException;
Trigger getTrigger(TriggerKey triggerKey)
throws SchedulerException;
TriggerState getTriggerState(TriggerKey triggerKey)
throws SchedulerException;
void addCalendar(String calName, Calendar calendar, boolean replace, boolean updateTriggers)
throws SchedulerException;
boolean deleteCalendar(String calName) throws SchedulerException;
Calendar getCalendar(String calName) throws SchedulerException;
List<String> getCalendarNames() throws SchedulerException;
boolean interrupt(JobKey jobKey) throws UnableToInterruptJobException;
boolean interrupt(String fireInstanceId) throws UnableToInterruptJobException;
boolean checkExists(JobKey jobKey) throws SchedulerException;
boolean checkExists(TriggerKey triggerKey) throws SchedulerException;
void clear() throws SchedulerException;
}
|
3e1d6e95651f6367869b1f5e79bf6d11be242e2f | 188 | java | Java | lottery-module/src/module-info.java | deepcloudlabs/dcl350-2021-jun-07 | 05332025909e49b8067657d02eed1bef08c03a92 | [
"MIT"
] | 1 | 2021-06-07T09:57:43.000Z | 2021-06-07T09:57:43.000Z | lottery-module/src/module-info.java | deepcloudlabs/dcl350-2021-jun-07 | 05332025909e49b8067657d02eed1bef08c03a92 | [
"MIT"
] | null | null | null | lottery-module/src/module-info.java | deepcloudlabs/dcl350-2021-jun-07 | 05332025909e49b8067657d02eed1bef08c03a92 | [
"MIT"
] | null | null | null | 23.5 | 54 | 0.81383 | 12,485 | import com.example.random.service.RandomNumberService;
module com.example.lottery {
requires java.base;
requires java.logging;
requires com.example.random;
uses RandomNumberService;
} |
3e1d720d4bbb010d4d0ff77358323005beef42b4 | 744 | java | Java | app/src/main/java/com/fantasystock/fantasystock/Onboarding/OnboardingFragment4.java | ted7726/FantasyStock | dd4942bc0a5af75e71351309795f7e215ed583c6 | [
"Apache-2.0"
] | 4 | 2016-03-03T00:06:16.000Z | 2018-08-02T16:48:11.000Z | app/src/main/java/com/fantasystock/fantasystock/Onboarding/OnboardingFragment4.java | ted7726/FantasyStock | dd4942bc0a5af75e71351309795f7e215ed583c6 | [
"Apache-2.0"
] | 11 | 2016-03-03T05:10:15.000Z | 2016-03-19T05:16:26.000Z | app/src/main/java/com/fantasystock/fantasystock/Onboarding/OnboardingFragment4.java | ted7726/FantasyStock | dd4942bc0a5af75e71351309795f7e215ed583c6 | [
"Apache-2.0"
] | 3 | 2016-04-03T02:11:30.000Z | 2021-02-08T17:19:49.000Z | 25.655172 | 100 | 0.747312 | 12,487 | package com.fantasystock.fantasystock.Onboarding;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.fantasystock.fantasystock.R;
import butterknife.ButterKnife;
/**
* Created by wilsonsu on 3/23/16.
*/
public class OnboardingFragment4 extends OnboardingFragment2{
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.onboarding_fragment_4, parent, false);
ButterKnife.bind(this, view);
tvTitle.setAlpha(0.0f);
tvSubTitle.setAlpha(0.0f);
return view;
}
}
|
3e1d721921c70137488c2f8546543c02b9a3a335 | 4,726 | java | Java | app/src/main/java/cn/incongress/endorcrinemagazine/utils/HttpUtils.java | lingchendehuxi/endorcrine | 748442bbabfce6174c99c4f3ca8b288ad00111fa | [
"Apache-2.0"
] | null | null | null | app/src/main/java/cn/incongress/endorcrinemagazine/utils/HttpUtils.java | lingchendehuxi/endorcrine | 748442bbabfce6174c99c4f3ca8b288ad00111fa | [
"Apache-2.0"
] | null | null | null | app/src/main/java/cn/incongress/endorcrinemagazine/utils/HttpUtils.java | lingchendehuxi/endorcrine | 748442bbabfce6174c99c4f3ca8b288ad00111fa | [
"Apache-2.0"
] | 1 | 2020-07-09T16:18:25.000Z | 2020-07-09T16:18:25.000Z | 38.422764 | 114 | 0.582522 | 12,488 | package cn.incongress.endorcrinemagazine.utils;
import android.content.Context;
import android.util.Log;
import android.widget.Toast;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Map;
/**
* Created by Administrator on 25/10/2016.
*/
public class HttpUtils {
private static URL url;
/* Function : 发送Post请求到服务器
* Param : params请求体内容,encode编码格式
* Author : 博客园-依旧淡然
*/
public static String submitPostData(Context context, String url1, Map<String, String> params, String encode) {
try {
url = new URL(url1);
} catch (MalformedURLException e) {
e.printStackTrace();
}
byte[] data = getRequestData(params, encode).toString().getBytes();//获得请求体
try {
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setConnectTimeout(10000); //设置连接超时时间
httpURLConnection.setDoInput(true); //打开输入流,以便从服务器获取数据
httpURLConnection.setDoOutput(true); //打开输出流,以便向服务器提交数据
httpURLConnection.setRequestMethod("POST"); //设置以Post方式提交数据
httpURLConnection.setUseCaches(false); //使用Post方式不能使用缓存
//设置请求体的类型是文本类型
httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
//设置请求体的长度
//httpURLConnection.setRequestProperty("Content-Length", String.valueOf(data.length));
//获得输出流,向服务器写入数据
OutputStream outputStream = httpURLConnection.getOutputStream();
outputStream.write(data);
int response = httpURLConnection.getResponseCode(); //获得服务器的响应码
Log.e("GYW","-----响应码"+response+HttpURLConnection.HTTP_OK);
if(response == HttpURLConnection.HTTP_OK) {
InputStream inptStream = httpURLConnection.getInputStream();
return dealResponseResult(inptStream); //处理服务器的响应结果
}
} catch (IOException e) {
e.printStackTrace();
}
return "";
}
public static String submitGetData(String url,String encode) {
try {
HttpURLConnection urlConnection = (HttpURLConnection) new URL(url).openConnection();
urlConnection.setRequestMethod("GET");// 设置请求的方式
urlConnection.setReadTimeout(5000);// 设置超时的时间
urlConnection.setConnectTimeout(5000);// 设置链接超时的时间
// 获取响应的状态码 404 200 505 302
if (urlConnection.getResponseCode() == 200) {
// 获取响应的输入流对象
return dealResponseResult(urlConnection.getInputStream());
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/*
2 * Function : 封装请求体信息
3 * Param : params请求体内容,encode编码格式
4 * Author : 博客园-依旧淡然
5 */
public static StringBuffer getRequestData(Map<String, String> params, String encode) {
StringBuffer stringBuffer = new StringBuffer(); //存储封装好的请求体信息
try {
for(Map.Entry<String, String> entry : params.entrySet()) {
stringBuffer.append(entry.getKey())
.append("=")
.append(URLEncoder.encode(entry.getValue(),encode))
.append("&");
}
stringBuffer.deleteCharAt(stringBuffer.length() - 1); //删除最后的一个"&"
} catch (Exception e) {
e.printStackTrace();
}
return stringBuffer;
}
/*
* Function : 处理服务器的响应结果(将输入流转化成字符串)
* Param : inputStream服务器的响应输入流
* Author : 博客园-依旧淡然
*/
public static String dealResponseResult(InputStream inputStream) {
String resultData = null; //存储处理结果
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] data = new byte[1024];
int len = 0;
try {
while((len = inputStream.read(data)) != -1) {
byteArrayOutputStream.write(data, 0, len);
}
resultData = new String(byteArrayOutputStream.toByteArray(),"GBK");
} catch (IOException e) {
e.printStackTrace();
}
return resultData;
}
}
|
3e1d7221507e8ccf4c9ec7ec5c9c75d0b63aafc3 | 1,790 | java | Java | src/main/java/org/apache/hdfs/mgmt/HDFSMgmtBean.java | gss2002/hdfsmgmt | 8ae7564c0ef47627baffe0ead4635450eb4e7e27 | [
"Apache-2.0"
] | null | null | null | src/main/java/org/apache/hdfs/mgmt/HDFSMgmtBean.java | gss2002/hdfsmgmt | 8ae7564c0ef47627baffe0ead4635450eb4e7e27 | [
"Apache-2.0"
] | null | null | null | src/main/java/org/apache/hdfs/mgmt/HDFSMgmtBean.java | gss2002/hdfsmgmt | 8ae7564c0ef47627baffe0ead4635450eb4e7e27 | [
"Apache-2.0"
] | null | null | null | 36.530612 | 79 | 0.760894 | 12,489 | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hdfs.mgmt;
import org.apache.hadoop.conf.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HDFSMgmtBean {
private static final Logger LOG = LoggerFactory.getLogger(HDFSMgmtBean.class);
static boolean userFolder = false;
public static String ldapGroup = "hdpdev-user";
public static String gcbaseDn = "dc=hdpusr,dc=senia,dc=org";
public static String gcldapURL = "ldap://seniadc1.hdpusr.senia.org:3268";
public static String hdfs_keytab = null;
public static String hdfs_keytabupn = null;
public static boolean useHdfsKeytab = false;
public static boolean daemon = false;
public static String ad_keytab = null;
public static String ad_keytabupn = null;
public static boolean useAdKeytab = false;
public static boolean lcaseUid = true;
public static Configuration hdpConfig;
public HDFSMgmtBean() {
hdpConfig = new Configuration();
}
public static void init() {
hdpConfig = new Configuration();
}
}
|
3e1d73c550d6e9f30b6ecef13114e0427570312e | 4,062 | java | Java | engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/migration/util/TimerEventFactory.java | mrFranklin/camunda-bpm-platform | 7c5bf37307d3eeac3aee5724b6e4669a9992eaba | [
"Apache-2.0"
] | 2,577 | 2015-01-02T07:43:55.000Z | 2022-03-31T22:31:45.000Z | engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/migration/util/TimerEventFactory.java | mrFranklin/camunda-bpm-platform | 7c5bf37307d3eeac3aee5724b6e4669a9992eaba | [
"Apache-2.0"
] | 839 | 2015-01-12T22:06:28.000Z | 2022-03-24T13:26:29.000Z | engine/src/test/java/org/camunda/bpm/engine/test/api/runtime/migration/util/TimerEventFactory.java | mrFranklin/camunda-bpm-platform | 7c5bf37307d3eeac3aee5724b6e4669a9992eaba | [
"Apache-2.0"
] | 1,270 | 2015-01-02T03:39:25.000Z | 2022-03-31T06:04:37.000Z | 37.611111 | 169 | 0.769079 | 12,490 | /*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.camunda.bpm.engine.test.api.runtime.migration.util;
import org.camunda.bpm.engine.ManagementService;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.ProcessEngineException;
import org.camunda.bpm.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler;
import org.camunda.bpm.engine.impl.jobexecutor.TimerStartEventSubprocessJobHandler;
import org.camunda.bpm.engine.runtime.Job;
import org.camunda.bpm.engine.test.api.runtime.migration.MigrationTestRule;
import org.camunda.bpm.engine.test.api.runtime.migration.ModifiableBpmnModelInstance;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
/**
* @author Thorben Lindhauer
*
*/
public class TimerEventFactory implements BpmnEventFactory {
public static final String TIMER_DATE = "2016-02-11T12:13:14Z";
@Override
public MigratingBpmnEventTrigger addBoundaryEvent(ProcessEngine engine, BpmnModelInstance modelInstance, String activityId, String boundaryEventId) {
ModifiableBpmnModelInstance.wrap(modelInstance)
.activityBuilder(activityId)
.boundaryEvent(boundaryEventId)
.timerWithDate(TIMER_DATE)
.done();
TimerEventTrigger trigger = new TimerEventTrigger();
trigger.engine = engine;
trigger.activityId = boundaryEventId;
trigger.handlerType = TimerExecuteNestedActivityJobHandler.TYPE;
return trigger;
}
@Override
public MigratingBpmnEventTrigger addEventSubProcess(ProcessEngine engine, BpmnModelInstance modelInstance, String parentId, String subProcessId, String startEventId) {
ModifiableBpmnModelInstance.wrap(modelInstance)
.addSubProcessTo(parentId)
.id(subProcessId)
.triggerByEvent()
.embeddedSubProcess()
.startEvent(startEventId).timerWithDuration("PT10M")
.subProcessDone()
.done();
TimerEventTrigger trigger = new TimerEventTrigger();
trigger.engine = engine;
trigger.activityId = startEventId;
trigger.handlerType = TimerStartEventSubprocessJobHandler.TYPE;
return trigger;
}
protected static class TimerEventTrigger implements MigratingBpmnEventTrigger {
protected ProcessEngine engine;
protected String activityId;
protected String handlerType;
@Override
public void trigger(String processInstanceId) {
ManagementService managementService = engine.getManagementService();
Job timerJob = managementService.createJobQuery().processInstanceId(processInstanceId).activityId(activityId).singleResult();
if (timerJob == null) {
throw new ProcessEngineException("No job for this event found in context of process instance " + processInstanceId);
}
managementService.executeJob(timerJob.getId());
}
@Override
public void assertEventTriggerMigrated(MigrationTestRule migrationContext, String targetActivityId) {
migrationContext.assertJobMigrated(activityId, targetActivityId, handlerType);
}
@Override
public MigratingBpmnEventTrigger inContextOf(String newActivityId) {
TimerEventTrigger newTrigger = new TimerEventTrigger();
newTrigger.activityId = newActivityId;
newTrigger.engine = engine;
newTrigger.handlerType = handlerType;
return newTrigger;
}
}
}
|
3e1d743078b8df4deff893cae9998caf4ed96bc7 | 4,865 | java | Java | codebase/projects/test-report/src/java/edu/duke/cabig/catrip/test/report/ant/JUnitDocReport.java | NCIP/catrip | 1615ab2598cf5ce060e98d69052ae0e52eaf9148 | [
"BSD-3-Clause"
] | null | null | null | codebase/projects/test-report/src/java/edu/duke/cabig/catrip/test/report/ant/JUnitDocReport.java | NCIP/catrip | 1615ab2598cf5ce060e98d69052ae0e52eaf9148 | [
"BSD-3-Clause"
] | 1 | 2019-04-30T06:37:01.000Z | 2019-04-30T06:37:01.000Z | codebase/projects/test-report/src/java/edu/duke/cabig/catrip/test/report/ant/JUnitDocReport.java | NCIP/catrip | 1615ab2598cf5ce060e98d69052ae0e52eaf9148 | [
"BSD-3-Clause"
] | null | null | null | 24.570707 | 93 | 0.703186 | 12,491 | /*L
* Copyright Duke Comprehensive Cancer Center
*
* Distributed under the OSI-approved BSD 3-Clause License.
* See http://ncip.github.com/catrip/LICENSE.txt for details.
*/
/*
* Created on Jul 18, 2006
*/
package edu.duke.cabig.catrip.test.report.ant;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import edu.duke.cabig.catrip.test.report.JUnitDoclet;
import edu.duke.cabig.catrip.test.report.JUnitXmlParser;
import edu.duke.cabig.catrip.test.report.data.TestSuite;
import edu.duke.cabig.catrip.test.report.report.JUnitHtmlReport;
import edu.duke.cabig.catrip.test.report.report.JUnitReport;
import edu.duke.cabig.catrip.test.report.report.JUnitTextReport;
public class JUnitDocReport
extends Task
{
private File destfile;
private String format;
private String reportClass;
private boolean useTestType = false;
private List<JUnitResults> resultsList = new ArrayList<JUnitResults>();
private List<JUnitDocs> docsList = new ArrayList<JUnitDocs>();
public void execute()
throws BuildException
{
// hack the classpath
//String javaHome = System.getProperty("java.home");
//if (javaHome.endsWith("jre")) javaHome = new File(javaHome).getParent();
//System.setProperty("env.class.path",
// "build\\classes" + File.pathSeparator +
// javaHome + File.separator + "lib" + File.separator + "tools.jar" + File.pathSeparator +
// System.getProperty("env.class.path")
//);
//System.out.println(System.getProperty("env.class.path"));
System.out.println(System.getProperty("java.class.path"));
//if (true) return;
// parse results
JUnitXmlParser parser = new JUnitXmlParser();
try {
for (JUnitResults results : resultsList) {
for (File file : getFiles(getProject(), results.fileSetList)) {
parser.parse(file);
}
}
} catch (Exception e) {
e.printStackTrace();
throw new BuildException(e);
}
TestSuite[] suites = parser.getTestSuites();
// parse docs
try {
for (JUnitDocs docs : docsList) {
File[] files = getFiles(getProject(), docs.fileSetList);
JUnitDoclet.addDocs(files, suites);
}
} catch (Exception e) {
e.printStackTrace();
throw new BuildException(e);
}
// get reporter
JUnitReport report = null;
if (reportClass != null) {
try {
report = (JUnitReport) Class.forName(reportClass).newInstance();
} catch (Exception e) {
e.printStackTrace();
throw new BuildException(e);
}
} else if ("html".equals(format)) {
report = new JUnitHtmlReport();
} else {
report = new JUnitTextReport();
}
// write report
PrintStream out = null;
boolean shouldClose = false;
try {
if (destfile == null) {
out = System.out;
} else {
destfile.getParentFile().mkdirs();
out = new PrintStream(new BufferedOutputStream(new FileOutputStream(destfile)));
shouldClose = true;
}
report.writeReport(suites, useTestType, out);
} catch (Exception e) {
e.printStackTrace();
throw new BuildException(e);
} finally {
if (out != null && shouldClose) {
out.flush();
out.close();
}
}
}
private static File[] getFiles(Project project, List<FileSet> fileSetList)
{
ArrayList<File> fileList = new ArrayList<File>();
for (FileSet fs : fileSetList) {
Collections.addAll(fileList, getFiles(project, fs));
}
return fileList.toArray(new File[0]);
}
private static File[] getFiles(Project project, FileSet fs)
{
ArrayList<File> fileList = new ArrayList<File>();
DirectoryScanner ds = fs.getDirectoryScanner(project);
for (String file : ds.getIncludedFiles()) {
fileList.add(new File(ds.getBasedir(), file));
}
for (String file : ds.getIncludedDirectories()) {
fileList.add(new File(ds.getBasedir(), file));
}
return fileList.toArray(new File[0]);
}
public File getDestfile()
{
return destfile;
}
public void setDestfile(File destfile)
{
this.destfile = destfile;
}
public void addConfiguredJunitResults(JUnitResults results)
{
resultsList.add(results);
}
public void addConfiguredJunitDocs(JUnitDocs docs)
{
docsList.add(docs);
}
public String getFormat()
{
return format;
}
public void setFormat(String format)
{
this.format = format;
}
public String getReportClass()
{
return reportClass;
}
public void setReportClass(String reportClass)
{
this.reportClass = reportClass;
}
public boolean isUseTestType()
{
return useTestType;
}
public void setUseTestType(boolean useTestType)
{
this.useTestType = useTestType;
}
}
|
3e1d74b794b0570db64859745f68293746288657 | 1,942 | java | Java | src/main/java/com/elytradev/davincisvessels/movingworld/common/chunk/mobilechunk/MobileChunkServer.java | ferreusveritas/DavincisVessels | 3e49bd8f0fc274e0421fcd7d2371000606c4457c | [
"Apache-2.0"
] | null | null | null | src/main/java/com/elytradev/davincisvessels/movingworld/common/chunk/mobilechunk/MobileChunkServer.java | ferreusveritas/DavincisVessels | 3e49bd8f0fc274e0421fcd7d2371000606c4457c | [
"Apache-2.0"
] | null | null | null | src/main/java/com/elytradev/davincisvessels/movingworld/common/chunk/mobilechunk/MobileChunkServer.java | ferreusveritas/DavincisVessels | 3e49bd8f0fc274e0421fcd7d2371000606c4457c | [
"Apache-2.0"
] | null | null | null | 26.60274 | 81 | 0.678167 | 12,492 | package com.elytradev.davincisvessels.movingworld.common.chunk.mobilechunk;
import com.elytradev.davincisvessels.movingworld.common.entity.EntityMovingWorld;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class MobileChunkServer extends MobileChunk {
private Set<BlockPos> blockQueue;
private Set<BlockPos> tileQueue;
public MobileChunkServer(World world, EntityMovingWorld entityMovingWorld) {
super(world, entityMovingWorld);
blockQueue = new HashSet<>();
tileQueue = new HashSet<>();
}
public Collection<BlockPos> getBlockQueue() {
return blockQueue;
}
public Collection<BlockPos> getTileQueue() {
return tileQueue;
}
@Override
public boolean addBlockWithState(BlockPos pos, IBlockState blockState) {
if (super.addBlockWithState(pos, blockState)) {
blockQueue.add(pos);
return true;
}
return false;
}
@Override
public boolean setBlockState(BlockPos pos, IBlockState state) {
if (super.setBlockState(pos, state)) {
blockQueue.add(pos);
return true;
}
return false;
}
@Override
public void setTileEntity(BlockPos pos, TileEntity tileentity) {
tileQueue.add(pos);
super.setTileEntity(pos, tileentity);
}
@Override
public void removeChunkBlockTileEntity(BlockPos pos) {
tileQueue.add(pos);
super.removeChunkBlockTileEntity(pos);
}
@Override
public void markTileDirty(BlockPos pos) {
tileQueue.add(pos);
super.markTileDirty(pos);
}
@Override
public Side side() {
return Side.SERVER;
}
}
|
3e1d74ccfc762e2483872ccccdc7e63aaee5c47d | 3,414 | java | Java | src/main/java/com/alibaba/compileflow/idea/graph/nodeview/dialog/TransitionPropertiesDialog.java | CatkinLi/compileflow-idea-designer | 883c27d6b30f3036480d672b10e9edabbc822b2a | [
"Apache-2.0"
] | 171 | 2020-07-24T09:10:24.000Z | 2022-03-31T06:53:42.000Z | src/main/java/com/alibaba/compileflow/idea/graph/nodeview/dialog/TransitionPropertiesDialog.java | CatkinLi/compileflow-idea-designer | 883c27d6b30f3036480d672b10e9edabbc822b2a | [
"Apache-2.0"
] | 20 | 2020-08-17T10:08:32.000Z | 2022-01-25T06:48:34.000Z | src/main/java/com/alibaba/compileflow/idea/graph/nodeview/dialog/TransitionPropertiesDialog.java | CatkinLi/compileflow-idea-designer | 883c27d6b30f3036480d672b10e9edabbc822b2a | [
"Apache-2.0"
] | 50 | 2020-07-27T09:19:07.000Z | 2022-03-30T15:40:47.000Z | 31.036364 | 110 | 0.635032 | 12,493 | package com.alibaba.compileflow.idea.graph.nodeview.dialog;
import com.alibaba.compileflow.idea.graph.mxgraph.GraphComponent;
import com.alibaba.compileflow.idea.graph.model.EdgeModel;
import com.intellij.openapi.project.Project;
import com.mxgraph.model.mxCell;
import com.mxgraph.util.mxEvent;
import com.mxgraph.util.mxEventObject;
import com.mxgraph.util.mxUndoableEdit;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.event.*;
/**
* @author wuxiang
* @since 2019-02-08
*
*/
public class TransitionPropertiesDialog extends JDialog {
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
private JTextField nameField;
private JTextField expressionField;
private JTextField priorityField;
private EdgeModel edgeObject;
private GraphComponent graphComponent;
public TransitionPropertiesDialog(@Nullable Project project, GraphComponent graphComponent, mxCell cell) {
setContentPane(contentPane);
if (cell.getValue() instanceof EdgeModel) {
this.edgeObject = (EdgeModel) cell.getValue();
}
// 让对话框居中
setLocationRelativeTo(null);
setModal(true);
getRootPane().setDefaultButton(buttonOK);
this.graphComponent = graphComponent;
// 初始化值
if (this.edgeObject != null) {
nameField.setText(this.edgeObject.getTransition().getName());
expressionField.setText(this.edgeObject.getTransition().getExpression());
priorityField.setText(this.edgeObject.getTransition().getPriority());
}
expressionField.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
super.keyReleased(e);
}
});
nameField.addMouseListener(new MouseAdapter() {
@Override
public void mouseExited(MouseEvent e) {
super.mouseExited(e);
}
});
buttonOK.addActionListener((e) ->{
onOK();
});
buttonCancel.addActionListener((e)-> {
onCancel();
});
// call onCancel() when cross is clicked
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
onCancel();
}
});
// call onCancel() on ESCAPE
contentPane.registerKeyboardAction((e)-> {
onCancel();
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
private void onOK() {
if (edgeObject != null) {
edgeObject.getTransition().setExpression(expressionField.getText().trim());
edgeObject.getTransition().setName(nameField.getText().trim());
edgeObject.getTransition().setPriority(priorityField.getText().trim());
graphComponent.refresh();
// 触发一个事件,进行存储更新
mxUndoableEdit edit = new mxUndoableEdit(graphComponent.getGraph().getModel());
graphComponent.getGraph().getModel().fireEvent(new mxEventObject(mxEvent.CHANGE,
"edit", edit, "changes", edit.getChanges()));
}
dispose();
}
private void onCancel() {
dispose();
}
}
|
3e1d74eaf022fb032193e2b2fcfd7870be8c2a0b | 242 | java | Java | CoreFeatures/MessageProcessingInterfaces/IMessage/src/main/java/info/smart_tools/smartactors/message_processing_interfaces/imessage/IMessage.java | asatuchin/smartactors-core | 35d6cae61144305e80b22db04264c14be8405c3f | [
"Apache-2.0"
] | 21 | 2017-09-29T09:45:37.000Z | 2021-09-21T14:12:54.000Z | CoreFeatures/MessageProcessingInterfaces/IMessage/src/main/java/info/smart_tools/smartactors/message_processing_interfaces/imessage/IMessage.java | asatuchin/smartactors-core | 35d6cae61144305e80b22db04264c14be8405c3f | [
"Apache-2.0"
] | 310 | 2019-04-11T16:42:11.000Z | 2021-05-23T08:14:16.000Z | CoreFeatures/MessageProcessingInterfaces/IMessage/src/main/java/info/smart_tools/smartactors/message_processing_interfaces/imessage/IMessage.java | asatuchin/smartactors-core | 35d6cae61144305e80b22db04264c14be8405c3f | [
"Apache-2.0"
] | 12 | 2017-09-29T09:50:30.000Z | 2022-02-09T08:08:29.000Z | 24.2 | 76 | 0.822314 | 12,494 | package info.smart_tools.smartactors.message_processing_interfaces.imessage;
import info.smart_tools.smartactors.iobject.iobject.IObject;
/**
* Interface for objects representing messages.
*/
public interface IMessage extends IObject {
}
|
3e1d7625b9dadc6802bd884145289144167ad4f1 | 458 | java | Java | shugomall-auth/src/main/java/com/sen/shugomall/auth/feign/ThirdFeignService.java | Raven-633/shugomall | c44af3c2d15350aacd6c0b86174bf14dd163da1a | [
"Apache-2.0"
] | null | null | null | shugomall-auth/src/main/java/com/sen/shugomall/auth/feign/ThirdFeignService.java | Raven-633/shugomall | c44af3c2d15350aacd6c0b86174bf14dd163da1a | [
"Apache-2.0"
] | 1 | 2022-03-13T06:00:31.000Z | 2022-03-13T06:00:31.000Z | shugomall-auth/src/main/java/com/sen/shugomall/auth/feign/ThirdFeignService.java | Raven-633/shugomall | c44af3c2d15350aacd6c0b86174bf14dd163da1a | [
"Apache-2.0"
] | null | null | null | 32.714286 | 86 | 0.796943 | 12,495 | package com.sen.shugomall.auth.feign;
import com.sen.shugomall.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient("shugomall-third-service")
public interface ThirdFeignService {
@GetMapping("/sms/send/code")
R sendCode(@RequestParam("phone")String phone, @RequestParam("code") String code);
}
|
3e1d76566c8a65c7e968ff72afa89c5fba77c594 | 5,751 | java | Java | acceptanceTests/src/test/java/org/mifos/test/acceptance/loan/ClientLoanStatusChangeTest.java | sureshkrishnamoorthy/suresh-mifos | 88e7df964688ca3955b38125213090297d4171a4 | [
"Apache-2.0"
] | 7 | 2016-06-23T12:50:58.000Z | 2020-12-21T18:39:55.000Z | acceptanceTests/src/test/java/org/mifos/test/acceptance/loan/ClientLoanStatusChangeTest.java | sureshkrishnamoorthy/suresh-mifos | 88e7df964688ca3955b38125213090297d4171a4 | [
"Apache-2.0"
] | 8 | 2019-02-04T14:15:49.000Z | 2022-02-01T01:04:00.000Z | acceptanceTests/src/test/java/org/mifos/test/acceptance/loan/ClientLoanStatusChangeTest.java | sureshkrishnamoorthy/suresh-mifos | 88e7df964688ca3955b38125213090297d4171a4 | [
"Apache-2.0"
] | 20 | 2015-02-11T06:31:19.000Z | 2020-03-04T15:24:52.000Z | 51.810811 | 148 | 0.791862 | 12,496 | /*
* Copyright (c) 2005-2011 Grameen Foundation USA
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* See also http://www.apache.org/licenses/LICENSE-2.0.html for an
* explanation of the license and how it is applied.
*/
package org.mifos.test.acceptance.loan;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.mifos.test.acceptance.framework.MifosPage;
import org.mifos.test.acceptance.framework.UiTestCaseBase;
import org.mifos.test.acceptance.framework.account.AccountStatus;
import org.mifos.test.acceptance.framework.account.EditAccountStatusParameters;
import org.mifos.test.acceptance.framework.loan.AccountChangeStatusPage;
import org.mifos.test.acceptance.framework.loan.EditLoanAccountStatusParameters;
import org.mifos.test.acceptance.framework.loan.LoanAccountPage;
import org.mifos.test.acceptance.framework.loan.QuestionResponseParameters;
import org.mifos.test.acceptance.framework.testhelpers.CustomPropertiesHelper;
import org.mifos.test.acceptance.framework.testhelpers.LoanTestHelper;
import org.mifos.test.acceptance.framework.testhelpers.QuestionGroupTestHelper;
import org.mifos.test.acceptance.remote.DateTimeUpdaterRemoteTestingService;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@ContextConfiguration(locations = {"classpath:ui-test-context.xml"})
@Test(singleThreaded = true, groups = {"acceptance", "ui", "loan", "no_db_unit"})
public class ClientLoanStatusChangeTest extends UiTestCaseBase {
private LoanTestHelper loanTestHelper;
private CustomPropertiesHelper customPropertiesHelper;
@Override
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
// one of the dependent methods throws Exception
@BeforeMethod
public void setUp() throws Exception {
super.setUp();
DateTimeUpdaterRemoteTestingService dateTimeUpdaterRemoteTestingService = new DateTimeUpdaterRemoteTestingService(selenium);
DateTime targetTime = new DateTime(2009, 7, 1, 12, 0, 0, 0);
dateTimeUpdaterRemoteTestingService.setDateTime(targetTime);
loanTestHelper = new LoanTestHelper(selenium);
customPropertiesHelper = new CustomPropertiesHelper(selenium);
}
@AfterMethod
public void logOut() {
(new MifosPage(selenium)).logout();
}
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void pendingApprovalToApplicationRejected() throws Exception {
EditLoanAccountStatusParameters statusParameters = new EditLoanAccountStatusParameters();
statusParameters.setStatus(EditLoanAccountStatusParameters.CANCEL);
statusParameters.setCancelReason(EditLoanAccountStatusParameters.CANCEL_REASON_REJECTED);
statusParameters.setNote("Test");
String loanId = "000100000000054";
loanTestHelper.changeLoanAccountStatus(loanId, statusParameters);
loanTestHelper.verifyLastEntryInStatusHistory(loanId, EditLoanAccountStatusParameters.PENDING_APPROVAL,
EditLoanAccountStatusParameters.CANCEL);
}
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void pendingApprovalToApplicationApprovedWithQuestionGroup() throws Exception {
String qgForLoanApproval = "QGForLoanApproval";
QuestionGroupTestHelper questionGroupTestHelper = new QuestionGroupTestHelper(selenium);
questionGroupTestHelper.markQuestionGroupAsActive(qgForLoanApproval);
EditLoanAccountStatusParameters statusParameters = new EditLoanAccountStatusParameters();
statusParameters.setStatus(EditLoanAccountStatusParameters.APPROVED);
statusParameters.setNote("Test");
QuestionResponseParameters responseParameters = new QuestionResponseParameters();
responseParameters.addTextAnswer("create_ClientPersonalInfo.input.customField", "testResponse");
loanTestHelper.changeLoanAccountStatusProvidingQuestionGroupResponses("000100000000055", statusParameters, responseParameters);
questionGroupTestHelper.markQuestionGroupAsInactive(qgForLoanApproval);
}
public void testBackDatedApprovals() {
customPropertiesHelper.setAllowBackdatedApproval(true);
LoanAccountPage loanAccountPage = loanTestHelper.createLoanAccount("Stu1233171716380 Client1233171716380", "WeeklyFlatLoanWithOneTimeFees");
loanAccountPage.verifyStatus("Application Pending Approval");
AccountChangeStatusPage changeStatusPage = loanAccountPage.navigateToEditAccountStatus();
LocalDate approvalDate = new LocalDate(2009, 6, 1);
EditAccountStatusParameters editAccountStatusParams = new EditAccountStatusParameters();
editAccountStatusParams.setNote("test note");
editAccountStatusParams.setAccountStatus(AccountStatus.LOAN_APPROVED);
editAccountStatusParams.setTrxnDate(approvalDate);
loanAccountPage = changeStatusPage.setChangeStatusParametersAndSubmit(editAccountStatusParams).submitAndNavigateToLoanAccountPage();
loanAccountPage.verifyStatus("Application Approved");
loanAccountPage.verifyLastNoteDate(approvalDate);
}
}
|
3e1d779204b45679e18ac87cd88c5cc8bbf0b086 | 18,836 | java | Java | src/main/java/org/znerd/xmlenc/XMLEncoder.java | znerd/xmlenc | 6ff483777d9467db9990b7c7ae0158f21a243c31 | [
"BSD-2-Clause"
] | null | null | null | src/main/java/org/znerd/xmlenc/XMLEncoder.java | znerd/xmlenc | 6ff483777d9467db9990b7c7ae0158f21a243c31 | [
"BSD-2-Clause"
] | null | null | null | src/main/java/org/znerd/xmlenc/XMLEncoder.java | znerd/xmlenc | 6ff483777d9467db9990b7c7ae0158f21a243c31 | [
"BSD-2-Clause"
] | 2 | 2015-11-14T23:18:09.000Z | 2019-01-08T01:48:42.000Z | 43.400922 | 248 | 0.569441 | 12,497 | // See the COPYRIGHT.txt file for copyright and license information
package org.znerd.xmlenc;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
/**
* Encodes character streams for an XML document.
* <p>
* The following encodings are supported:
* <ul>
* <li><code>UTF-8</code>
* <li><code>UTF-16</code>
* <li><code>US-ASCII</code>, with alias <code>ASCII</code>
* <li>all <code>ISO-8859</code> encodings
* </ul>
*
* @since XMLenc 0.1
*/
public class XMLEncoder extends Object {
/**
* Retrieves an <code>XMLEncoder</code> for the specified encoding. If no
* suitable instance can be returned, then an exception is thrown.
*
* @param encoding the name of the encoding, not <code>null</code>.
* @return an <code>XMLEncoder</code> instance that matches the specified encoding, never
* <code>null</code>.
* @throws IllegalArgumentException if <code>encoding == null</code>.
* @throws UnsupportedEncodingException if the specified encoding is not supported.
*/
public static final XMLEncoder getEncoder(String encoding) throws IllegalArgumentException, UnsupportedEncodingException {
return new XMLEncoder(encoding);
}
/**
* Character array representing the string <code>">"</code>.
*/
private static final char[] ESC_GREATER_THAN = new char[] { '&', 'g', 't', ';' };
/**
* Character array representing the string <code>"<"</code>.
*/
private static final char[] ESC_LESS_THAN = new char[] { '&', 'l', 't', ';' };
/**
* Character array representing the string <code>"&amp;"</code>.
*/
private static final char[] ESC_AMPERSAND = new char[] { '&', 'a', 'm', 'p', ';' };
/**
* Character array representing the string <code>"&apos;"</code>.
*/
private static final char[] ESC_APOSTROPHE = new char[] { '&', 'a', 'p', 'o', 's', ';' };
/**
* Character array representing the string <code>"&apos;"</code>.
*/
private static final char[] ESC_QUOTE = new char[] { '&', 'q', 'u', 'o', 't', ';' };
/**
* Character array representing the string <code>"&#"</code>.
*/
private static final char[] AMPERSAND_HASH = new char[] { '&', '#' };
/**
* Character array representing the string <code>"='"</code>.
*/
private static final char[] EQUALS_APOSTROPHE = new char[] { '=', '\'' };
/**
* Character array representing the string <code>"=\""</code>.
*/
private static final char[] EQUALS_QUOTE = new char[] { '=', '"' };
/**
* Constructs a new <code>XMLEncoder</code> instance.
*
* @param encoding the name of the encoding, not <code>null</code>.
* @throws IllegalArgumentException if <code>encoding == null</code>.
* @throws UnsupportedEncodingException if the specified encoding is not supported.
* @deprecated Deprecated since XMLenc 0.47. Use the factory method {@link #getEncoder(String)}
* instead.
*/
@Deprecated
public XMLEncoder(String encoding) throws IllegalArgumentException, UnsupportedEncodingException {
// Check argument
if (encoding == null) {
throw new IllegalArgumentException("encoding == null");
}
// Uppercase encoding to compare it with supported encodings in a case-insensitive manner
String ucEncoding = encoding.toUpperCase();
// Check if the encoding supports all Unicode characters
if (ucEncoding.equals("UTF-8") || ucEncoding.equals("UTF-16")) {
_sevenBitEncoding = false;
// Check if this is an ISO 646-based character set (7-bit ASCII)
} else if (ucEncoding.equals("US-ASCII") || ucEncoding.equals("ASCII") || ucEncoding.startsWith("ISO-8859-")) {
_sevenBitEncoding = true;
// Otherwise fail
} else {
throw new UnsupportedEncodingException(encoding);
}
// Store encoding literally as passed
_encoding = encoding;
_declarationDoubleQuotes = ("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>").toCharArray();
_declarationSingleQuotes = ("<?xml version='1.0' encoding='" + encoding + "'?>").toCharArray();
}
/**
* The name of the encoding. Cannot be <code>null</code>.
*/
private final String _encoding;
private final char[] _declarationDoubleQuotes;
private final char[] _declarationSingleQuotes;
/**
* Flag that indicates whether the encoding is based on the ISO 646
* character set. The value is <code>true</code> if the encoding is a 7 bit
* encoding, or <code>false</code> if the encoding supports all Unicode
* characters.
*/
private final boolean _sevenBitEncoding;
/**
* Returns the encoding.
*
* @return the encoding passed to the constructor, never <code>null</code>.
*/
public String getEncoding() {
return _encoding;
}
/**
* Writes an XML declaration with double quotes.
*
* @param out the character stream to write to, not <code>null</code>.
* @throws NullPointerException if <code>out == null</code>.
* @throws IOException if an I/O error occurs.
* @deprecated Deprecated since XMLenc 0.54. Use {@link #declaration(Writer, char)} instead,
* which also requires the quotation mark character to use.
*/
@Deprecated
public void declaration(Writer out) throws NullPointerException, IOException {
out.write(_declarationDoubleQuotes);
}
/**
* Writes an XML declaration with double quotes.
*
* @param out the character stream to write to, not <code>null</code>.
* @param quotationMark the quotationMark to use, either <code>'\''</code> or <code>'"'</code>.
* @throws IllegalArgumentException if
* <code>quotationMark != '\'' && quotationMark != '"'</code>
* @throws NullPointerException if <code>out == null</code>.
* @throws IOException if an I/O error occurs.
* @since XMLenc 0.54
*/
public void declaration(Writer out, char quotationMark) throws IllegalArgumentException, NullPointerException, IOException {
if (quotationMark == '"') {
out.write(_declarationDoubleQuotes);
} else if (quotationMark == '\'') {
out.write(_declarationSingleQuotes);
}
}
/**
* Writes the specified text. Any characters that are non-printable in this
* encoding will be escaped.
* <p />
* It must be specified whether ampersands should be escaped. Unless ampersands are escaped,
* entity references can be written.
*
* @param out the character stream to write to, not <code>null</code>.
* @param text the text to be written, not <code>null</code>.
* @param escapeAmpersands flag that indicates whether ampersands should be escaped.
* @throws NullPointerException if <code>out == null || text == null</code>.
* @throws InvalidXMLException if the specified text contains an invalid character.
* @throws IOException if an I/O error occurs.
*/
public void text(Writer out, String text, boolean escapeAmpersands) throws NullPointerException, InvalidXMLException, IOException {
text(out, text.toCharArray(), 0, text.length(), escapeAmpersands);
}
/**
* Writes text from the specified character array. Any characters that are
* non-printable in this encoding will be escaped.
* <p />
* It must be specified whether ampersands should be escaped. Unless ampersands are escaped,
* entity references can be written.
*
* @param out the character stream to write to, not <code>null</code>.
* @param ch the character array from which to retrieve the text to be written,
* not <code>null</code>.
* @param start the start index into <code>ch</code>, must be >= 0.
* @param length the number of characters to take from <code>ch</code>, starting at
* the <code>start</code> index.
* @param escapeAmpersands flag that indicates if ampersands should be escaped.
* @throws NullPointerException if <code>out == null || ch == null</code>.
* @throws IndexOutOfBoundsException if <code>start < 0
* || start + length > ch.length</code>; this may not be
* checked before the character stream is written to, so this may
* cause a <em>partial</em> failure.
* @throws InvalidXMLException if the specified text contains an invalid character.
* @throws IOException if an I/O error occurs.
*/
public void text(Writer out, char[] ch, int start, int length, boolean escapeAmpersands) throws NullPointerException, IndexOutOfBoundsException, InvalidXMLException, IOException {
int end = start + length;
// The position after the last escaped character
int lastEscaped = start;
for (int i = start; i < end; i++) {
int c = ch[i];
if (c >= 63 && c <= 127 || c >= 39 && c <= 59 || c >= 32 && c <= 37 || c == 38 && !escapeAmpersands || c > 127 && !_sevenBitEncoding || c == 10 || c == 13 || c == 61 || c == 9) {
continue;
} else {
out.write(ch, lastEscaped, i - lastEscaped);
if (c == 60) {
out.write(ESC_LESS_THAN, 0, 4);
} else if (c == 62) {
out.write(ESC_GREATER_THAN, 0, 4);
} else if (c == 38) {
out.write(ESC_AMPERSAND, 0, 5);
} else if (c > 127) {
out.write(AMPERSAND_HASH, 0, 2);
out.write(Integer.toString(c));
out.write(';');
} else {
throw new InvalidXMLException("The character 0x" + Integer.toHexString(c) + " is not valid.");
}
lastEscaped = i + 1;
}
}
out.write(ch, lastEscaped, end - lastEscaped);
}
/**
* Writes the specified character. If the character is non-printable in
* this encoding, then it will be escaped.
* <p />
* It is safe for this method to assume that the specified character does not need to be escaped
* unless the encoding does not support the character.
*
* @param out the character stream to write to, not <code>null</code>.
* @param c the character to be written.
* @throws InvalidXMLException if the specified text contains an invalid character.
* @throws IOException if an I/O error occurs.
* @deprecated Deprecated since XMLenc 0.51. Use the text method
* {@link #text(Writer, char, boolean)} instead.
*/
@Deprecated
public void text(Writer out, char c) throws InvalidXMLException, IOException {
if (c >= 63 && c <= 127 || c >= 39 && c <= 59 || c >= 32 && c <= 37 || c == 38 || c > 127 && !_sevenBitEncoding || c == 10 || c == 13 || c == 61 || c == 9) {
out.write(c);
} else {
if (c == 60) {
out.write(ESC_LESS_THAN, 0, 4);
} else if (c == 62) {
out.write(ESC_GREATER_THAN, 0, 4);
} else if (c > 127) {
out.write(AMPERSAND_HASH, 0, 2);
out.write(Integer.toString(c));
out.write(';');
} else {
throw new InvalidXMLException("The character 0x" + Integer.toHexString(c) + " is not valid.");
}
}
}
/**
* Writes the specified character. If the character is non-printable in
* this encoding, then it will be escaped.
* <p />
* It is safe for this method to assume that the specified character does not need to be escaped
* unless the encoding does not support the character.
*
* @param out the character stream to write to, not <code>null</code>.
* @param c the character to be written.
* @param escapeAmpersands flag that indicates if ampersands should be escaped.
* @throws InvalidXMLException if the specified text contains an invalid character.
* @throws IOException if an I/O error occurs.
*/
public void text(Writer out, char c, boolean escapeAmpersands) throws InvalidXMLException, IOException {
if (c >= 63 && c <= 127 || c >= 39 && c <= 59 || c >= 32 && c <= 37 || c == 38 && escapeAmpersands || c > 127 && !_sevenBitEncoding || c == 10 || c == 13 || c == 61 || c == 9) {
out.write(c);
} else {
if (c == 60) {
out.write(ESC_LESS_THAN, 0, 4);
} else if (c == 62) {
out.write(ESC_GREATER_THAN, 0, 4);
} else if (c == 38) {
out.write(ESC_AMPERSAND, 0, 5);
} else if (c > 127) {
out.write(AMPERSAND_HASH, 0, 2);
out.write(Integer.toString(c));
out.write(';');
} else {
throw new InvalidXMLException("The character 0x" + Integer.toHexString(c) + " is not valid.");
}
}
}
/**
* Writes the specified whitespace string.
*
* @param out the character stream to write to, not <code>null</code>.
* @param s the character string to be written, not <code>null</code>.
* @throws NullPointerException if <code>out == null || s == null</code>.
* @throws InvalidXMLException if the specified character string contains a character that is
* invalid as whitespace.
* @throws IOException if an I/O error occurs.
*/
public void whitespace(Writer out, String s) throws NullPointerException, InvalidXMLException, IOException {
char[] ch = s.toCharArray();
int length = ch.length;
whitespace(out, ch, 0, length);
}
/**
* Writes whitespace from the specified character array.
*
* @param out the character stream to write to, not <code>null</code>.
* @param ch the character array from which to retrieve the text to be written,
* not <code>null</code>.
* @param start the start index into <code>ch</code>, must be >= 0.
* @param length the number of characters to take from <code>ch</code>, starting at
* the <code>start</code> index.
* @throws NullPointerException if <code>out == null || ch == null</code>.
* @throws IndexOutOfBoundsException if <code>start < 0
* || start + length > ch.length</code>; this may not be
* checked before the character stream is written to, so this may
* cause a <em>partial</em> failure.
* @throws InvalidXMLException if the specified character array contains a character that is invalid
* as whitespace.
* @throws IOException if an I/O error occurs.
*/
public void whitespace(Writer out, char[] ch, int start, int length) throws NullPointerException, IndexOutOfBoundsException, InvalidXMLException, IOException {
// Check the string
XMLChecker.checkS(ch, start, length);
// Write the complete character string at once
out.write(ch, start, length);
}
/**
* Writes an attribute assignment.
*
* @param out the character stream to write to, not <code>null</code>.
* @param name the name of the attribute, not <code>null</code>.
* @param value the value of the attribute, not <code>null</code>.
* @param quotationMark the quotation mark, must be either the apostrophe (<code>'\''</code>)
* or the quote character (<code>'"'</code>).
* @throws NullPointerException if <code>out == null || value == null</code>.
* @throws IllegalArgumentException if <code>quotationMark != '\'' && quotationMark != '"'</code>.
* @throws IOException if an I/O error occurs.
*/
public void attribute(Writer out, String name, String value, char quotationMark, boolean escapeAmpersands) throws NullPointerException, IOException {
char[] ch = value.toCharArray();
int length = ch.length;
int start = 0;
int end = start + length;
// TODO: Call overloaded attribute method that accepts char[]
// The position after the last escaped character
int lastEscaped = 0;
boolean useQuote;
if (quotationMark == '"') {
useQuote = true;
} else if (quotationMark == '\'') {
useQuote = false;
} else {
String error = "Character 0x" + Integer.toHexString(quotationMark) + " ('" + quotationMark + "') is not a valid quotation mark.";
throw new IllegalArgumentException(error);
}
out.write(' ');
out.write(name);
if (useQuote) {
out.write(EQUALS_QUOTE, 0, 2);
} else {
out.write(EQUALS_APOSTROPHE, 0, 2);
}
for (int i = start; i < end; i++) {
int c = ch[i];
if (c >= 63 && c <= 127 || c >= 40 && c <= 59 || c >= 32 && c <= 37 && c != 34 || c == 38 && !escapeAmpersands || c > 127 && !_sevenBitEncoding || !useQuote && c == 34 || useQuote && c == 39 || c == 10 || c == 13 || c == 61 || c == 9) {
continue;
} else {
out.write(ch, lastEscaped, i - lastEscaped);
if (c == 60) {
out.write(ESC_LESS_THAN, 0, 4);
} else if (c == 62) {
out.write(ESC_GREATER_THAN, 0, 4);
} else if (c == 34) {
out.write(ESC_QUOTE, 0, 6);
} else if (c == 39) {
out.write(ESC_APOSTROPHE, 0, 6);
} else if (c == 38) {
out.write(ESC_AMPERSAND, 0, 5);
} else if (c > 127) {
out.write(AMPERSAND_HASH, 0, 2);
out.write(Integer.toString(c));
out.write(';');
} else {
throw new InvalidXMLException("The character 0x" + Integer.toHexString(c) + " is not valid.");
}
lastEscaped = i + 1;
}
}
out.write(ch, lastEscaped, length - lastEscaped);
out.write(quotationMark);
}
}
|
3e1d79217e4396a741a5cb523c5065b41e40be4e | 8,806 | java | Java | preference/src/main/java/androidx/preference/CollapsiblePreferenceGroupController.java | aosp-caf-upstream/platform_frameworks_support | 46bd3eb63bba8f52560a41db3cca3ff607edb7e4 | [
"Apache-2.0"
] | 992 | 2015-01-05T03:03:25.000Z | 2017-10-10T12:24:28.000Z | preference/src/main/java/androidx/preference/CollapsiblePreferenceGroupController.java | aosp-caf-upstream/platform_frameworks_support | 46bd3eb63bba8f52560a41db3cca3ff607edb7e4 | [
"Apache-2.0"
] | 22 | 2018-11-05T22:59:25.000Z | 2021-10-17T18:03:34.000Z | preference/src/main/java/androidx/preference/CollapsiblePreferenceGroupController.java | aosp-caf-upstream/platform_frameworks_support | 46bd3eb63bba8f52560a41db3cca3ff607edb7e4 | [
"Apache-2.0"
] | 499 | 2015-01-05T02:36:32.000Z | 2017-10-09T07:19:05.000Z | 40.394495 | 100 | 0.633659 | 12,498 | /*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.preference;
import android.content.Context;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.List;
/**
* A controller to handle advanced children display logic with collapsible functionality.
*/
final class CollapsiblePreferenceGroupController {
private final PreferenceGroupAdapter mPreferenceGroupAdapter;
private final Context mContext;
/**
* Whether there is a child PreferenceGroup that has an expandable preference. This is used to
* avoid unnecessary preference tree rebuilds when no such group exists.
*/
private boolean mHasExpandablePreference = false;
CollapsiblePreferenceGroupController(PreferenceGroup preferenceGroup,
PreferenceGroupAdapter preferenceGroupAdapter) {
mPreferenceGroupAdapter = preferenceGroupAdapter;
mContext = preferenceGroup.getContext();
}
/**
* Generates the visible section of the PreferenceGroup.
*
* @param group the root preference group to be processed
* @return the flattened and visible section of the PreferenceGroup
*/
public List<Preference> createVisiblePreferencesList(PreferenceGroup group) {
return createInnerVisiblePreferencesList(group);
}
private List<Preference> createInnerVisiblePreferencesList(PreferenceGroup group) {
mHasExpandablePreference = false;
int visiblePreferenceCount = 0;
final boolean hasExpandablePreference =
group.getInitialExpandedChildrenCount() != Integer.MAX_VALUE;
final List<Preference> visiblePreferences = new ArrayList<>();
final List<Preference> collapsedPreferences = new ArrayList<>();
final int groupSize = group.getPreferenceCount();
for (int i = 0; i < groupSize; i++) {
final Preference preference = group.getPreference(i);
if (!preference.isVisible()) {
continue;
}
if (!hasExpandablePreference
|| visiblePreferenceCount < group.getInitialExpandedChildrenCount()) {
visiblePreferences.add(preference);
} else {
collapsedPreferences.add(preference);
}
// PreferenceGroups do not count towards the maximal number of preferences to show
if (!(preference instanceof PreferenceGroup)) {
visiblePreferenceCount++;
continue;
}
PreferenceGroup innerGroup = (PreferenceGroup) preference;
if (!innerGroup.isOnSameScreenAsChildren()) {
continue;
}
// Recursively generate nested list of visible preferences
final List<Preference> innerList = createInnerVisiblePreferencesList(innerGroup);
if (hasExpandablePreference && mHasExpandablePreference) {
throw new IllegalArgumentException("Nested expand buttons are not supported!");
}
for (Preference inner : innerList) {
if (!hasExpandablePreference
|| visiblePreferenceCount < group.getInitialExpandedChildrenCount()) {
visiblePreferences.add(inner);
} else {
collapsedPreferences.add(inner);
}
visiblePreferenceCount++;
}
}
// If there are any visible preferences being hidden, add an expand button to show the rest
// of the preferences. Clicking the expand button will show all the visible preferences.
if (hasExpandablePreference
&& visiblePreferenceCount > group.getInitialExpandedChildrenCount()) {
final ExpandButton expandButton = createExpandButton(group, collapsedPreferences);
visiblePreferences.add(expandButton);
}
mHasExpandablePreference |= hasExpandablePreference;
return visiblePreferences;
}
/**
* Called when a preference has changed its visibility.
*
* @param preference The preference whose visibility has changed.
* @return {@code true} if view update has been handled by this controller.
*/
public boolean onPreferenceVisibilityChange(Preference preference) {
if (mHasExpandablePreference) {
// We only want to show up to the maximal number of preferences. Preference visibility
// change can result in the expand button being added/removed, as well as changes to
// its summary. Rebuild to ensure that the correct data is shown.
mPreferenceGroupAdapter.onPreferenceHierarchyChange(preference);
return true;
}
return false;
}
private ExpandButton createExpandButton(final PreferenceGroup group,
List<Preference> collapsedPreferences) {
final ExpandButton preference = new ExpandButton(mContext, collapsedPreferences,
group.getId());
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
group.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
mPreferenceGroupAdapter.onPreferenceHierarchyChange(preference);
return true;
}
});
return preference;
}
/**
* A {@link Preference} that provides capability to expand the collapsed items in the
* {@link PreferenceGroup}.
*/
static class ExpandButton extends Preference {
private long mId;
ExpandButton(Context context, List<Preference> collapsedPreferences, long parentId) {
super(context);
initLayout();
setSummary(collapsedPreferences);
// Since IDs are unique, using the parentId as a reference ensures that this expand
// button will have a unique ID and hence transitions will be correctly animated by
// RecyclerView when there are multiple ExpandButtons.
mId = parentId + 1000000;
}
private void initLayout() {
setLayoutResource(R.layout.expand_button);
setIcon(R.drawable.ic_arrow_down_24dp);
setTitle(R.string.expand_button_title);
// Sets a high order so that the expand button will be placed at the bottom of the group
setOrder(999);
}
/*
* The summary of this will be the list of title for collapsed preferences. Iterate through
* the preferences not in the visible list and add its title to the summary text. If
* there are any nested groups with titles, ignore their children.
*/
private void setSummary(List<Preference> collapsedPreferences) {
CharSequence summary = null;
final List<PreferenceGroup> parents = new ArrayList<>();
for (Preference preference : collapsedPreferences) {
final CharSequence title = preference.getTitle();
if (preference instanceof PreferenceGroup && !TextUtils.isEmpty(title)) {
parents.add((PreferenceGroup) preference);
}
if (parents.contains(preference.getParent())) {
if (preference instanceof PreferenceGroup) {
parents.add((PreferenceGroup) preference);
}
continue;
}
if (!TextUtils.isEmpty(title)) {
if (summary == null) {
summary = title;
} else {
summary = getContext().getString(
R.string.summary_collapsed_preference_list, summary, title);
}
}
}
setSummary(summary);
}
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
holder.setDividerAllowedAbove(false);
}
@Override
public long getId() {
return mId;
}
}
} |
3e1d792b0221b364bc567ec5282d956ce5fd8814 | 2,621 | java | Java | app/src/main/java/cmput301f18t18/health_detective/presentation/view/activity/presenters/CameraPresenter.java | CMPUT301F18T18/Health-Detective | e79c49abf0019ee2254c7fd8dc0b026943e1b946 | [
"Apache-2.0"
] | 1 | 2018-11-11T04:02:45.000Z | 2018-11-11T04:02:45.000Z | app/src/main/java/cmput301f18t18/health_detective/presentation/view/activity/presenters/CameraPresenter.java | CMPUT301F18T18/Health-Detective | e79c49abf0019ee2254c7fd8dc0b026943e1b946 | [
"Apache-2.0"
] | 15 | 2018-10-17T00:50:56.000Z | 2018-12-03T19:23:58.000Z | app/src/main/java/cmput301f18t18/health_detective/presentation/view/activity/presenters/CameraPresenter.java | CMPUT301F18T18/Health-Detective | e79c49abf0019ee2254c7fd8dc0b026943e1b946 | [
"Apache-2.0"
] | null | null | null | 28.802198 | 85 | 0.716139 | 12,499 | package cmput301f18t18.health_detective.presentation.view.activity.presenters;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Base64;
import java.io.ByteArrayOutputStream;
import cmput301f18t18.health_detective.domain.interactors.AddPhoto;
import cmput301f18t18.health_detective.domain.interactors.GetLoggedInUser;
import cmput301f18t18.health_detective.domain.interactors.impl.AddPhotoImpl;
import cmput301f18t18.health_detective.domain.interactors.impl.GetLoggedInUserImpl;
import cmput301f18t18.health_detective.domain.model.CareProvider;
import cmput301f18t18.health_detective.domain.model.DomainImage;
import cmput301f18t18.health_detective.domain.model.Patient;
public class CameraPresenter implements AddPhoto.Callback, GetLoggedInUser.Callback {
private View view;
private boolean type;
private boolean leftRight;
public static Bitmap toBitmap(String base64String){
byte[] decodedBytes = Base64.decode(
base64String,
Base64.DEFAULT
);
return BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
}
public static String byteArrayToString(byte [] byteArray){
return Base64.encodeToString(byteArray, Base64.DEFAULT);
}
@Override
public void onAPhInvalidPermissions() {}
@Override
public void onAPhNoImage() {}
@Override
public void onAPhSuccess(DomainImage image) {
view.onDone();
}
public interface View {
void onDone();
void onPView();
void onCPView();
}
public CameraPresenter(View view, boolean type, boolean leftRight) {
this.view = view;
this.type = type;
this.leftRight = leftRight;
new GetLoggedInUserImpl(this).execute();
}
public void onImage(Bitmap image, String blLabel) {
byte[] byteImage = toByteArray(image);
String base64String = byteArrayToString(byteImage);
new AddPhotoImpl(this, blLabel, base64String, type, leftRight).execute();
}
private byte[] toByteArray(Bitmap bitmap){
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
byte[] byteArray = outputStream.toByteArray();
return byteArray;
}
@Override
public void onGLIUNoUserLoggedIn() {}
@Override
public void onGLIUPatient(Patient patient) {
this.view.onPView();
}
@Override
public void onGLIUCareProvider(CareProvider careProvider) {
this.view.onCPView();
}
}
|
3e1d79301dcd9981c1e0dde668bdd9003b67383b | 1,701 | java | Java | backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNextRunGraphicsDevicesQuery.java | emesika/ovirt-engine | db6458e688eeb385b683a0c9c5530917cd6dfe5f | [
"Apache-2.0"
] | 347 | 2015-01-20T14:13:21.000Z | 2022-03-31T17:53:11.000Z | backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNextRunGraphicsDevicesQuery.java | emesika/ovirt-engine | db6458e688eeb385b683a0c9c5530917cd6dfe5f | [
"Apache-2.0"
] | 128 | 2015-05-22T19:14:32.000Z | 2022-03-31T08:11:18.000Z | backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetNextRunGraphicsDevicesQuery.java | emesika/ovirt-engine | db6458e688eeb385b683a0c9c5530917cd6dfe5f | [
"Apache-2.0"
] | 202 | 2015-01-04T06:20:49.000Z | 2022-03-08T15:30:08.000Z | 40.5 | 144 | 0.723104 | 12,500 | package org.ovirt.engine.core.bll;
import java.util.LinkedList;
import java.util.List;
import org.ovirt.engine.core.bll.context.EngineContext;
import org.ovirt.engine.core.common.businessentities.GraphicsDevice;
import org.ovirt.engine.core.common.businessentities.GraphicsType;
import org.ovirt.engine.core.common.businessentities.VM;
import org.ovirt.engine.core.common.businessentities.VmDevice;
import org.ovirt.engine.core.common.queries.IdQueryParameters;
import org.ovirt.engine.core.common.queries.QueryReturnValue;
import org.ovirt.engine.core.common.queries.QueryType;
import org.ovirt.engine.core.common.utils.VmDeviceCommonUtils;
public class GetNextRunGraphicsDevicesQuery<P extends IdQueryParameters> extends GetGraphicsDevicesQuery<P> {
public GetNextRunGraphicsDevicesQuery(P parameters, EngineContext context) {
super(parameters, context);
}
@Override
protected void executeQueryCommand() {
QueryReturnValue nextRun = runInternalQuery(QueryType.GetVmNextRunConfiguration, new IdQueryParameters(getParameters().getId()));
VM vm = nextRun.getReturnValue();
if (vm != null && vm.isNextRunConfigurationExists()) {
List<GraphicsDevice> result = new LinkedList<>();
for (GraphicsType graphicsType : GraphicsType.values()) {
VmDevice device = VmDeviceCommonUtils.findVmDeviceByType(vm.getManagedVmDeviceMap(), graphicsType.getCorrespondingDeviceType());
if (device != null) {
result.add(new GraphicsDevice(device));
}
}
setReturnValue(result);
} else {
super.executeQueryCommand();
}
}
}
|
3e1d7a4badc2877f8551b4a61f26d9f6c98be59c | 1,211 | java | Java | src/test/java/org/liveontologies/puli/pinpointing/input/Cycles.java | liveontologies/proof-utils | 9dce2a3427a10cbc410b8c47170a4e02bbf810cc | [
"Apache-2.0"
] | null | null | null | src/test/java/org/liveontologies/puli/pinpointing/input/Cycles.java | liveontologies/proof-utils | 9dce2a3427a10cbc410b8c47170a4e02bbf810cc | [
"Apache-2.0"
] | null | null | null | src/test/java/org/liveontologies/puli/pinpointing/input/Cycles.java | liveontologies/proof-utils | 9dce2a3427a10cbc410b8c47170a4e02bbf810cc | [
"Apache-2.0"
] | null | null | null | 31.051282 | 76 | 0.657308 | 12,501 | /*-
* #%L
* Proof Utility Library
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2014 - 2017 Live Ontologies Project
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package org.liveontologies.puli.pinpointing.input;
public class Cycles extends BaseEnumeratorTestInput {
@Override
protected void build() {
conclusion("A").premise("B").axiom(1).add();
conclusion("B").premise("C").axiom(2).add();
conclusion("C").premise("D").axiom(3).add();
conclusion("D").premise("E").axiom(4).add();
conclusion("C").premise("E").axiom(5).add();
conclusion("E").premise("B").axiom(6).add();
conclusion("D").axiom(7).add();
query("A");
}
}
|
3e1d7b36f5878b1abc8abad0d4face3b80408459 | 2,028 | java | Java | stomp-client/src/main/java/org/projectodd/stilts/stomp/client/protocol/AbstractClientControlFrameHandler.java | artri/stilts | 6ba81d4162325b98f591c206520476cf575d0567 | [
"Apache-2.0"
] | 20 | 2015-01-15T10:31:54.000Z | 2021-08-02T09:20:53.000Z | stomp-client/src/main/java/org/projectodd/stilts/stomp/client/protocol/AbstractClientControlFrameHandler.java | artri/stilts | 6ba81d4162325b98f591c206520476cf575d0567 | [
"Apache-2.0"
] | 6 | 2015-02-08T17:49:54.000Z | 2019-07-02T17:24:15.000Z | stomp-client/src/main/java/org/projectodd/stilts/stomp/client/protocol/AbstractClientControlFrameHandler.java | artri/stilts | 6ba81d4162325b98f591c206520476cf575d0567 | [
"Apache-2.0"
] | 13 | 2015-05-03T16:56:00.000Z | 2020-08-05T12:50:08.000Z | 36.872727 | 104 | 0.737179 | 12,502 | /*
* Copyright 2011 Red Hat, Inc, and individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.projectodd.stilts.stomp.client.protocol;
import org.jboss.logging.Logger;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
import org.projectodd.stilts.stomp.protocol.StompFrame;
import org.projectodd.stilts.stomp.protocol.StompFrame.Command;
public abstract class AbstractClientControlFrameHandler extends AbstractClientHandler {
private static Logger log = Logger.getLogger(AbstractClientControlFrameHandler.class);
public AbstractClientControlFrameHandler(ClientContext clientContext, Command command) {
super( clientContext );
this.command = command;
}
@Override
public void messageReceived(ChannelHandlerContext channelContext, MessageEvent e) throws Exception {
log.trace( "received: " + e.getMessage() );
if ( e.getMessage() instanceof StompFrame ) {
handleStompFrame( channelContext, (StompFrame) e.getMessage() );
}
super.messageReceived( channelContext, e );
}
protected void handleStompFrame(ChannelHandlerContext channelContext, StompFrame frame) {
if ( frame.getCommand().equals( this.command ) ) {
handleControlFrame( channelContext, frame );
}
}
protected abstract void handleControlFrame(ChannelHandlerContext channelContext, StompFrame frame);
private Command command;
}
|
3e1d7c1d1e88b88753b2d31f6b5f96af5b246b2c | 902 | java | Java | modules/core/src/java/no/kantega/publishing/common/exception/InvalidTemplateReferenceException.java | kantega/Flyt-cms | bb1786a92903208d070bd64a84473acadde9bd19 | [
"Apache-2.0"
] | 10 | 2015-03-12T18:06:00.000Z | 2018-04-09T03:50:43.000Z | modules/core/src/java/no/kantega/publishing/common/exception/InvalidTemplateReferenceException.java | kantega/Flyt-cms | bb1786a92903208d070bd64a84473acadde9bd19 | [
"Apache-2.0"
] | 13 | 2016-04-28T09:01:53.000Z | 2021-08-23T20:41:09.000Z | modules/core/src/java/no/kantega/publishing/common/exception/InvalidTemplateReferenceException.java | kantega/Flyt-cms | bb1786a92903208d070bd64a84473acadde9bd19 | [
"Apache-2.0"
] | 3 | 2015-03-12T18:08:33.000Z | 2017-05-04T12:23:24.000Z | 36.08 | 103 | 0.752772 | 12,503 | /*
* Copyright 2009 Kantega AS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package no.kantega.publishing.common.exception;
public class InvalidTemplateReferenceException extends no.kantega.commons.exception.KantegaException {
public InvalidTemplateReferenceException (int templateId) {
super("Reference to none existing template with id:" + templateId, null);
}
}
|
3e1d7c4d3bf4e0db5efd8fdc17ccdecacb63775d | 2,013 | java | Java | bboss-taglib/src/com/frameworkset/common/tag/pager/tags/EmptyTag.java | besom/bbossgroups-3.5 | d1c6fcec93c62ae6ca58eb00225f287a49ce1772 | [
"Apache-2.0"
] | 246 | 2015-10-29T03:02:48.000Z | 2022-03-31T03:58:17.000Z | bboss-taglib/src/com/frameworkset/common/tag/pager/tags/EmptyTag.java | besom/bbossgroups-3.5 | d1c6fcec93c62ae6ca58eb00225f287a49ce1772 | [
"Apache-2.0"
] | 4 | 2016-11-17T08:27:47.000Z | 2021-07-28T09:31:56.000Z | bboss-taglib/src/com/frameworkset/common/tag/pager/tags/EmptyTag.java | besom/bbossgroups-3.5 | d1c6fcec93c62ae6ca58eb00225f287a49ce1772 | [
"Apache-2.0"
] | 148 | 2015-01-19T06:35:15.000Z | 2022-01-07T04:53:04.000Z | 21.645161 | 89 | 0.665176 | 12,504 | /**
* Copyright 2008 biaoping.yin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.frameworkset.common.tag.pager.tags;
import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Map;
/**
* <p>EmptyTag.java</p>
* <p> Description: 判断指定的字段的值是否是null或者是空串,如果条件成立,则执行标签体得逻辑</p>
* <p> bboss workgroup </p>
* <p> Copyright (c) 2009 </p>
*
* @Date 2011-5-26
* @author biaoping.yin
* @version 1.0
*/
public class EmptyTag extends MatchTag
{
@Override
protected boolean match()
{
if(this.actualValue == null )
return true;
if(actualValue instanceof String )
{
if(this.actualValue.equals(""))
return true;
else
return false;
}
else if(actualValue instanceof Collection )
{
if(((Collection)actualValue).size() == 0)
return true;
else
return false;
}
else if(actualValue instanceof Map )
{
if( ((Map)actualValue).size() == 0)
return true;
else
return false;
}
else if(actualValue instanceof com.frameworkset.util.ListInfo)
{
com.frameworkset.util.ListInfo listinfo = (com.frameworkset.util.ListInfo)actualValue;
if(listinfo.getTotalSize() <= 0 )
{
if(listinfo.getSize() <= 0)
return true;
else
return false;
}
else
return false;
}
else if(actualValue.getClass().isArray())
{
int length = Array.getLength(actualValue);
if(length <= 0)
{
return true;
}
else
return false;
}
else
{
return false;
}
}
}
|
3e1d7cd6d31f7c73d6f54b4d9aff9233184ad2bb | 596 | java | Java | src/main/java/com/rbkmoney/fraudbusters/config/properties/KafkaTopics.java | fraudbusters/fraudbusters | 8afd73d4b237012a071f6ba7d15ee3922afbce27 | [
"Apache-2.0"
] | 35 | 2020-01-24T10:40:29.000Z | 2022-03-03T20:32:41.000Z | src/main/java/com/rbkmoney/fraudbusters/config/properties/KafkaTopics.java | fraudbusters/fraudbusters | 8afd73d4b237012a071f6ba7d15ee3922afbce27 | [
"Apache-2.0"
] | 8 | 2019-11-18T09:21:42.000Z | 2021-05-13T13:55:32.000Z | src/main/java/com/rbkmoney/fraudbusters/config/properties/KafkaTopics.java | fraudbusters/fraudbusters | 8afd73d4b237012a071f6ba7d15ee3922afbce27 | [
"Apache-2.0"
] | 13 | 2019-11-28T23:11:51.000Z | 2022-02-17T06:59:45.000Z | 23.84 | 75 | 0.79698 | 12,505 | package com.rbkmoney.fraudbusters.config.properties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "kafka.topic")
public class KafkaTopics {
private String template;
private String reference;
private String groupList;
private String groupReference;
private String fullTemplate;
private String fullReference;
private String fullGroupList;
private String fullGroupReference;
}
|
3e1d7e7f36bdda3faf399a1e0e70c20e0b43edfb | 28,154 | java | Java | server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java | GaiserChan/elasticsearch | dcd4667e955666837e2cd9b6177ffb9ebfdcc249 | [
"Apache-2.0"
] | 1,125 | 2016-09-11T17:27:35.000Z | 2022-03-29T13:41:58.000Z | server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java | GaiserChan/elasticsearch | dcd4667e955666837e2cd9b6177ffb9ebfdcc249 | [
"Apache-2.0"
] | 346 | 2016-12-03T18:37:07.000Z | 2022-03-29T08:33:04.000Z | server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java | GaiserChan/elasticsearch | dcd4667e955666837e2cd9b6177ffb9ebfdcc249 | [
"Apache-2.0"
] | 190 | 2016-12-15T13:46:19.000Z | 2022-03-04T05:17:11.000Z | 66.400943 | 140 | 0.688463 | 12,506 | /*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.rest.action.cat;
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest;
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.Table;
import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.http.HttpInfo;
import org.elasticsearch.index.cache.query.QueryCacheStats;
import org.elasticsearch.index.cache.request.RequestCacheStats;
import org.elasticsearch.index.engine.SegmentsStats;
import org.elasticsearch.index.fielddata.FieldDataStats;
import org.elasticsearch.index.flush.FlushStats;
import org.elasticsearch.index.get.GetStats;
import org.elasticsearch.index.merge.MergeStats;
import org.elasticsearch.index.refresh.RefreshStats;
import org.elasticsearch.index.search.stats.SearchStats;
import org.elasticsearch.index.shard.IndexingStats;
import org.elasticsearch.indices.NodeIndicesStats;
import org.elasticsearch.monitor.fs.FsInfo;
import org.elasticsearch.monitor.jvm.JvmInfo;
import org.elasticsearch.monitor.jvm.JvmStats;
import org.elasticsearch.monitor.os.OsStats;
import org.elasticsearch.monitor.process.ProcessStats;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.action.RestActionListener;
import org.elasticsearch.rest.action.RestResponseListener;
import org.elasticsearch.script.ScriptStats;
import org.elasticsearch.search.suggest.completion.CompletionStats;
import java.util.Locale;
import java.util.stream.Collectors;
import static org.elasticsearch.rest.RestRequest.Method.GET;
public class RestNodesAction extends AbstractCatAction {
public RestNodesAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(GET, "/_cat/nodes", this);
}
@Override
public String getName() {
return "cat_nodes_action";
}
@Override
protected void documentation(StringBuilder sb) {
sb.append("/_cat/nodes\n");
}
@Override
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
clusterStateRequest.clear().nodes(true);
clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
final boolean fullId = request.paramAsBoolean("full_id", false);
return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
@Override
public void processResponse(final ClusterStateResponse clusterStateResponse) {
NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
nodesInfoRequest.clear().jvm(true).os(true).process(true).http(true);
client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
@Override
public void processResponse(final NodesInfoResponse nodesInfoResponse) {
NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
nodesStatsRequest.clear().jvm(true).os(true).fs(true).indices(true).process(true).script(true);
client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
@Override
public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception {
return RestTable.buildResponse(buildTable(fullId, request, clusterStateResponse, nodesInfoResponse,
nodesStatsResponse), channel);
}
});
}
});
}
});
}
@Override
protected Table getTableWithHeader(final RestRequest request) {
Table table = new Table();
table.startHeaders();
table.addCell("id", "default:false;alias:id,nodeId;desc:unique node id");
table.addCell("pid", "default:false;alias:p;desc:process id");
table.addCell("ip", "alias:i;desc:ip address");
table.addCell("port", "default:false;alias:po;desc:bound transport port");
table.addCell("http_address", "default:false;alias:http;desc:bound http address");
table.addCell("version", "default:false;alias:v;desc:es version");
table.addCell("flavor", "default:false;alias:f;desc:es distribution flavor");
table.addCell("type", "default:false;alias:t;desc:es distribution type");
table.addCell("build", "default:false;alias:b;desc:es build hash");
table.addCell("jdk", "default:false;alias:j;desc:jdk version");
table.addCell("disk.total", "default:false;alias:dt,diskTotal;text-align:right;desc:total disk space");
table.addCell("disk.used", "default:false;alias:du,diskUsed;text-align:right;desc:used disk space");
table.addCell("disk.avail", "default:false;alias:d,da,disk,diskAvail;text-align:right;desc:available disk space");
table.addCell("disk.used_percent", "default:false;alias:dup,diskUsedPercent;text-align:right;desc:used disk space percentage");
table.addCell("heap.current", "default:false;alias:hc,heapCurrent;text-align:right;desc:used heap");
table.addCell("heap.percent", "alias:hp,heapPercent;text-align:right;desc:used heap ratio");
table.addCell("heap.max", "default:false;alias:hm,heapMax;text-align:right;desc:max configured heap");
table.addCell("ram.current", "default:false;alias:rc,ramCurrent;text-align:right;desc:used machine memory");
table.addCell("ram.percent", "alias:rp,ramPercent;text-align:right;desc:used machine memory ratio");
table.addCell("ram.max", "default:false;alias:rm,ramMax;text-align:right;desc:total machine memory");
table.addCell("file_desc.current", "default:false;alias:fdc,fileDescriptorCurrent;text-align:right;desc:used file descriptors");
table.addCell("file_desc.percent",
"default:false;alias:fdp,fileDescriptorPercent;text-align:right;desc:used file descriptor ratio");
table.addCell("file_desc.max", "default:false;alias:fdm,fileDescriptorMax;text-align:right;desc:max file descriptors");
table.addCell("cpu", "alias:cpu;text-align:right;desc:recent cpu usage");
table.addCell("load_1m", "alias:l;text-align:right;desc:1m load avg");
table.addCell("load_5m", "alias:l;text-align:right;desc:5m load avg");
table.addCell("load_15m", "alias:l;text-align:right;desc:15m load avg");
table.addCell("uptime", "default:false;alias:u;text-align:right;desc:node uptime");
table.addCell("node.role",
"alias:r,role,nodeRole;desc:m:master eligible node, d:data node, i:ingest node, -:coordinating node only");
table.addCell("master", "alias:m;desc:*:current master");
table.addCell("name", "alias:n;desc:node name");
table.addCell("completion.size", "alias:cs,completionSize;default:false;text-align:right;desc:size of completion");
table.addCell("fielddata.memory_size", "alias:fm,fielddataMemory;default:false;text-align:right;desc:used fielddata cache");
table.addCell("fielddata.evictions", "alias:fe,fielddataEvictions;default:false;text-align:right;desc:fielddata evictions");
table.addCell("query_cache.memory_size", "alias:qcm,queryCacheMemory;default:false;text-align:right;desc:used query cache");
table.addCell("query_cache.evictions", "alias:qce,queryCacheEvictions;default:false;text-align:right;desc:query cache evictions");
table.addCell("request_cache.memory_size", "alias:rcm,requestCacheMemory;default:false;text-align:right;desc:used request cache");
table.addCell("request_cache.evictions",
"alias:rce,requestCacheEvictions;default:false;text-align:right;desc:request cache evictions");
table.addCell("request_cache.hit_count",
"alias:rchc,requestCacheHitCount;default:false;text-align:right;desc:request cache hit counts");
table.addCell("request_cache.miss_count",
"alias:rcmc,requestCacheMissCount;default:false;text-align:right;desc:request cache miss counts");
table.addCell("flush.total", "alias:ft,flushTotal;default:false;text-align:right;desc:number of flushes");
table.addCell("flush.total_time", "alias:ftt,flushTotalTime;default:false;text-align:right;desc:time spent in flush");
table.addCell("get.current", "alias:gc,getCurrent;default:false;text-align:right;desc:number of current get ops");
table.addCell("get.time", "alias:gti,getTime;default:false;text-align:right;desc:time spent in get");
table.addCell("get.total", "alias:gto,getTotal;default:false;text-align:right;desc:number of get ops");
table.addCell("get.exists_time", "alias:geti,getExistsTime;default:false;text-align:right;desc:time spent in successful gets");
table.addCell("get.exists_total", "alias:geto,getExistsTotal;default:false;text-align:right;desc:number of successful gets");
table.addCell("get.missing_time", "alias:gmti,getMissingTime;default:false;text-align:right;desc:time spent in failed gets");
table.addCell("get.missing_total", "alias:gmto,getMissingTotal;default:false;text-align:right;desc:number of failed gets");
table.addCell("indexing.delete_current",
"alias:idc,indexingDeleteCurrent;default:false;text-align:right;desc:number of current deletions");
table.addCell("indexing.delete_time", "alias:idti,indexingDeleteTime;default:false;text-align:right;desc:time spent in deletions");
table.addCell("indexing.delete_total", "alias:idto,indexingDeleteTotal;default:false;text-align:right;desc:number of delete ops");
table.addCell("indexing.index_current",
"alias:iic,indexingIndexCurrent;default:false;text-align:right;desc:number of current indexing ops");
table.addCell("indexing.index_time", "alias:iiti,indexingIndexTime;default:false;text-align:right;desc:time spent in indexing");
table.addCell("indexing.index_total", "alias:iito,indexingIndexTotal;default:false;text-align:right;desc:number of indexing ops");
table.addCell("indexing.index_failed",
"alias:iif,indexingIndexFailed;default:false;text-align:right;desc:number of failed indexing ops");
table.addCell("merges.current", "alias:mc,mergesCurrent;default:false;text-align:right;desc:number of current merges");
table.addCell("merges.current_docs",
"alias:mcd,mergesCurrentDocs;default:false;text-align:right;desc:number of current merging docs");
table.addCell("merges.current_size", "alias:mcs,mergesCurrentSize;default:false;text-align:right;desc:size of current merges");
table.addCell("merges.total", "alias:mt,mergesTotal;default:false;text-align:right;desc:number of completed merge ops");
table.addCell("merges.total_docs", "alias:mtd,mergesTotalDocs;default:false;text-align:right;desc:docs merged");
table.addCell("merges.total_size", "alias:mts,mergesTotalSize;default:false;text-align:right;desc:size merged");
table.addCell("merges.total_time", "alias:mtt,mergesTotalTime;default:false;text-align:right;desc:time spent in merges");
table.addCell("refresh.total", "alias:rto,refreshTotal;default:false;text-align:right;desc:total refreshes");
table.addCell("refresh.time", "alias:rti,refreshTime;default:false;text-align:right;desc:time spent in refreshes");
table.addCell("refresh.listeners", "alias:rli,refreshListeners;default:false;text-align:right;"
+ "desc:number of pending refresh listeners");
table.addCell("script.compilations", "alias:scrcc,scriptCompilations;default:false;text-align:right;desc:script compilations");
table.addCell("script.cache_evictions",
"alias:scrce,scriptCacheEvictions;default:false;text-align:right;desc:script cache evictions");
table.addCell("search.fetch_current", "alias:sfc,searchFetchCurrent;default:false;text-align:right;desc:current fetch phase ops");
table.addCell("search.fetch_time", "alias:sfti,searchFetchTime;default:false;text-align:right;desc:time spent in fetch phase");
table.addCell("search.fetch_total", "alias:sfto,searchFetchTotal;default:false;text-align:right;desc:total fetch ops");
table.addCell("search.open_contexts", "alias:so,searchOpenContexts;default:false;text-align:right;desc:open search contexts");
table.addCell("search.query_current", "alias:sqc,searchQueryCurrent;default:false;text-align:right;desc:current query phase ops");
table.addCell("search.query_time", "alias:sqti,searchQueryTime;default:false;text-align:right;desc:time spent in query phase");
table.addCell("search.query_total", "alias:sqto,searchQueryTotal;default:false;text-align:right;desc:total query phase ops");
table.addCell("search.scroll_current", "alias:scc,searchScrollCurrent;default:false;text-align:right;desc:open scroll contexts");
table.addCell("search.scroll_time",
"alias:scti,searchScrollTime;default:false;text-align:right;desc:time scroll contexts held open");
table.addCell("search.scroll_total", "alias:scto,searchScrollTotal;default:false;text-align:right;desc:completed scroll contexts");
table.addCell("segments.count", "alias:sc,segmentsCount;default:false;text-align:right;desc:number of segments");
table.addCell("segments.memory", "alias:sm,segmentsMemory;default:false;text-align:right;desc:memory used by segments");
table.addCell("segments.index_writer_memory",
"alias:siwm,segmentsIndexWriterMemory;default:false;text-align:right;desc:memory used by index writer");
table.addCell("segments.version_map_memory",
"alias:svmm,segmentsVersionMapMemory;default:false;text-align:right;desc:memory used by version map");
table.addCell("segments.fixed_bitset_memory",
"alias:sfbm,fixedBitsetMemory;default:false;text-align:right;desc:memory used by fixed bit sets for nested object field types" +
" and type filters for types referred in _parent fields");
table.addCell("suggest.current", "alias:suc,suggestCurrent;default:false;text-align:right;desc:number of current suggest ops");
table.addCell("suggest.time", "alias:suti,suggestTime;default:false;text-align:right;desc:time spend in suggest");
table.addCell("suggest.total", "alias:suto,suggestTotal;default:false;text-align:right;desc:number of suggest ops");
table.endHeaders();
return table;
}
Table buildTable(boolean fullId, RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo,
NodesStatsResponse nodesStats) {
DiscoveryNodes nodes = state.getState().nodes();
String masterId = nodes.getMasterNodeId();
Table table = getTableWithHeader(req);
for (DiscoveryNode node : nodes) {
NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
NodeStats stats = nodesStats.getNodesMap().get(node.getId());
JvmInfo jvmInfo = info == null ? null : info.getJvm();
JvmStats jvmStats = stats == null ? null : stats.getJvm();
FsInfo fsInfo = stats == null ? null : stats.getFs();
OsStats osStats = stats == null ? null : stats.getOs();
ProcessStats processStats = stats == null ? null : stats.getProcess();
NodeIndicesStats indicesStats = stats == null ? null : stats.getIndices();
table.startRow();
table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4));
table.addCell(info == null ? null : info.getProcess().getId());
table.addCell(node.getHostAddress());
table.addCell(node.getAddress().address().getPort());
final HttpInfo httpInfo = info == null ? null : info.getHttp();
if (httpInfo != null) {
TransportAddress transportAddress = httpInfo.getAddress().publishAddress();
table.addCell(NetworkAddress.format(transportAddress.address()));
} else {
table.addCell("-");
}
table.addCell(node.getVersion().toString());
table.addCell(info == null ? null : info.getBuild().flavor().displayName());
table.addCell(info == null ? null : info.getBuild().type().displayName());
table.addCell(info == null ? null : info.getBuild().shortHash());
table.addCell(jvmInfo == null ? null : jvmInfo.version());
ByteSizeValue diskTotal = null;
ByteSizeValue diskUsed = null;
ByteSizeValue diskAvailable = null;
String diskUsedPercent = null;
if (fsInfo != null) {
diskTotal = fsInfo.getTotal().getTotal();
diskAvailable = fsInfo.getTotal().getAvailable();
diskUsed = new ByteSizeValue(diskTotal.getBytes() - diskAvailable.getBytes());
double diskUsedRatio = diskTotal.getBytes() == 0 ? 1.0 : (double) diskUsed.getBytes() / diskTotal.getBytes();
diskUsedPercent = String.format(Locale.ROOT, "%.2f", 100.0 * diskUsedRatio);
}
table.addCell(diskTotal);
table.addCell(diskUsed);
table.addCell(diskAvailable);
table.addCell(diskUsedPercent);
table.addCell(jvmStats == null ? null : jvmStats.getMem().getHeapUsed());
table.addCell(jvmStats == null ? null : jvmStats.getMem().getHeapUsedPercent());
table.addCell(jvmInfo == null ? null : jvmInfo.getMem().getHeapMax());
table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getUsed());
table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getUsedPercent());
table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getTotal());
table.addCell(processStats == null ? null : processStats.getOpenFileDescriptors());
table.addCell(processStats == null ? null : calculatePercentage(processStats.getOpenFileDescriptors(),
processStats.getMaxFileDescriptors()));
table.addCell(processStats == null ? null : processStats.getMaxFileDescriptors());
table.addCell(osStats == null ? null : Short.toString(osStats.getCpu().getPercent()));
boolean hasLoadAverage = osStats != null && osStats.getCpu().getLoadAverage() != null;
table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[0] == -1 ? null :
String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[0]));
table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[1] == -1 ? null :
String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[1]));
table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[2] == -1 ? null :
String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[2]));
table.addCell(jvmStats == null ? null : jvmStats.getUptime());
final String roles;
if (node.getRoles().isEmpty()) {
roles = "-";
} else {
roles = node.getRoles().stream().map(DiscoveryNode.Role::getAbbreviation).collect(Collectors.joining());
}
table.addCell(roles);
table.addCell(masterId == null ? "x" : masterId.equals(node.getId()) ? "*" : "-");
table.addCell(node.getName());
CompletionStats completionStats = indicesStats == null ? null : stats.getIndices().getCompletion();
table.addCell(completionStats == null ? null : completionStats.getSize());
FieldDataStats fdStats = indicesStats == null ? null : stats.getIndices().getFieldData();
table.addCell(fdStats == null ? null : fdStats.getMemorySize());
table.addCell(fdStats == null ? null : fdStats.getEvictions());
QueryCacheStats fcStats = indicesStats == null ? null : indicesStats.getQueryCache();
table.addCell(fcStats == null ? null : fcStats.getMemorySize());
table.addCell(fcStats == null ? null : fcStats.getEvictions());
RequestCacheStats qcStats = indicesStats == null ? null : indicesStats.getRequestCache();
table.addCell(qcStats == null ? null : qcStats.getMemorySize());
table.addCell(qcStats == null ? null : qcStats.getEvictions());
table.addCell(qcStats == null ? null : qcStats.getHitCount());
table.addCell(qcStats == null ? null : qcStats.getMissCount());
FlushStats flushStats = indicesStats == null ? null : indicesStats.getFlush();
table.addCell(flushStats == null ? null : flushStats.getTotal());
table.addCell(flushStats == null ? null : flushStats.getTotalTime());
GetStats getStats = indicesStats == null ? null : indicesStats.getGet();
table.addCell(getStats == null ? null : getStats.current());
table.addCell(getStats == null ? null : getStats.getTime());
table.addCell(getStats == null ? null : getStats.getCount());
table.addCell(getStats == null ? null : getStats.getExistsTime());
table.addCell(getStats == null ? null : getStats.getExistsCount());
table.addCell(getStats == null ? null : getStats.getMissingTime());
table.addCell(getStats == null ? null : getStats.getMissingCount());
IndexingStats indexingStats = indicesStats == null ? null : indicesStats.getIndexing();
table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteCurrent());
table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteTime());
table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteCount());
table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexCurrent());
table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexTime());
table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexCount());
table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexFailedCount());
MergeStats mergeStats = indicesStats == null ? null : indicesStats.getMerge();
table.addCell(mergeStats == null ? null : mergeStats.getCurrent());
table.addCell(mergeStats == null ? null : mergeStats.getCurrentNumDocs());
table.addCell(mergeStats == null ? null : mergeStats.getCurrentSize());
table.addCell(mergeStats == null ? null : mergeStats.getTotal());
table.addCell(mergeStats == null ? null : mergeStats.getTotalNumDocs());
table.addCell(mergeStats == null ? null : mergeStats.getTotalSize());
table.addCell(mergeStats == null ? null : mergeStats.getTotalTime());
RefreshStats refreshStats = indicesStats == null ? null : indicesStats.getRefresh();
table.addCell(refreshStats == null ? null : refreshStats.getTotal());
table.addCell(refreshStats == null ? null : refreshStats.getTotalTime());
table.addCell(refreshStats == null ? null : refreshStats.getListeners());
ScriptStats scriptStats = stats == null ? null : stats.getScriptStats();
table.addCell(scriptStats == null ? null : scriptStats.getCompilations());
table.addCell(scriptStats == null ? null : scriptStats.getCacheEvictions());
SearchStats searchStats = indicesStats == null ? null : indicesStats.getSearch();
table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchCurrent());
table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchTime());
table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchCount());
table.addCell(searchStats == null ? null : searchStats.getOpenContexts());
table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryCurrent());
table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryTime());
table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryCount());
table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollCurrent());
table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollTime());
table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollCount());
SegmentsStats segmentsStats = indicesStats == null ? null : indicesStats.getSegments();
table.addCell(segmentsStats == null ? null : segmentsStats.getCount());
table.addCell(segmentsStats == null ? null : segmentsStats.getMemory());
table.addCell(segmentsStats == null ? null : segmentsStats.getIndexWriterMemory());
table.addCell(segmentsStats == null ? null : segmentsStats.getVersionMapMemory());
table.addCell(segmentsStats == null ? null : segmentsStats.getBitsetMemory());
table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestCurrent());
table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestTime());
table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestCount());
table.endRow();
}
return table;
}
/**
* Calculate the percentage of {@code used} from the {@code max} number.
* @param used The currently used number.
* @param max The maximum number.
* @return 0 if {@code max} is <= 0. Otherwise 100 * {@code used} / {@code max}.
*/
private short calculatePercentage(long used, long max) {
return max <= 0 ? 0 : (short)((100d * used) / max);
}
}
|
3e1d7ee53f42bb775d005a517f8d0a11e7abdde0 | 2,377 | java | Java | huntbugs/src/test/java/one/util/huntbugs/testdata/TestSelfComputation.java | amaembo/huntbugs | 05e7ebd511c99e7d19bd194757e8d6e92732e125 | [
"Apache-2.0"
] | 345 | 2016-04-15T18:09:18.000Z | 2021-11-09T09:36:36.000Z | huntbugs/src/test/java/one/util/huntbugs/testdata/TestSelfComputation.java | amaembo/huntbugs | 05e7ebd511c99e7d19bd194757e8d6e92732e125 | [
"Apache-2.0"
] | 37 | 2016-05-05T09:31:35.000Z | 2017-10-28T08:09:45.000Z | huntbugs/src/test/java/one/util/huntbugs/testdata/TestSelfComputation.java | amaembo/huntbugs | 05e7ebd511c99e7d19bd194757e8d6e92732e125 | [
"Apache-2.0"
] | 40 | 2016-04-28T14:50:47.000Z | 2022-03-04T08:42:56.000Z | 27.639535 | 120 | 0.615061 | 12,507 | /*
* Copyright 2016 HuntBugs contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package one.util.huntbugs.testdata;
import java.util.List;
import org.junit.Assert;
import one.util.huntbugs.registry.anno.AssertNoWarning;
import one.util.huntbugs.registry.anno.AssertWarning;
/**
* @author Tagir Valeev
*
*/
public class TestSelfComputation {
@AssertWarning("SelfComputation")
public int test(int a, int b) {
return (a - b) / (a - b);
}
@AssertWarning("SelfComputation")
public int test(int[] x) {
return x[1] - x[1];
}
@AssertWarning("SelfComparison")
public boolean testCmp(int[] x) {
return x[1] == x[1];
}
@AssertWarning("SelfComparison")
public boolean testCmp(double[] x, double[] y) {
return x[1] + y[0] >= x[1] + y[0];
}
@AssertWarning("SelfEquals")
public boolean testEquals(String s1) {
return s1.equals(s1);
}
@AssertNoWarning("SelfEquals")
public void testMyEquals(Object obj) {
Assert.assertTrue(obj.equals(obj));
}
@AssertNoWarning("SelfComputation")
public int test(int[] x, int idx) {
return x[idx++] - x[idx++];
}
@AssertNoWarning("*")
public void testLambdas(List<Integer> l1, List<Integer> l2) {
l1.forEach(a -> {
l2.forEach(b -> {
System.out.println(a - b);
});
});
}
// Fails due to Procyon bug, reported https://bitbucket.org/mstrobel/procyon/issues/287/variables-incorerctly-merged
// @AssertNoWarning("SelfComputation")
// public int appendDigits(long num, int maxdigits) {
// char[] buf = new char[maxdigits];
// int ix = maxdigits;
// while (ix > 0) {
// buf[--ix] = '0';
// }
// return maxdigits - ix;
// }
}
|
3e1d7f8ddb6865ada1825ca9354dbfcaa4e4bdf0 | 1,973 | java | Java | src/pizzaria/java/persistencia/IngredienteMySQL.java | juliano-araujo/pizzaarriba | 5311355276bc134d44854995f1dc8ca398bf6d38 | [
"Apache-2.0"
] | null | null | null | src/pizzaria/java/persistencia/IngredienteMySQL.java | juliano-araujo/pizzaarriba | 5311355276bc134d44854995f1dc8ca398bf6d38 | [
"Apache-2.0"
] | null | null | null | src/pizzaria/java/persistencia/IngredienteMySQL.java | juliano-araujo/pizzaarriba | 5311355276bc134d44854995f1dc8ca398bf6d38 | [
"Apache-2.0"
] | null | null | null | 27.788732 | 88 | 0.709579 | 12,508 | package pizzaria.java.persistencia;
import java.util.ArrayList;
import pizzaria.java.exception.PizzariaException;
import pizzaria.java.modelo.Ingrediente;
public class IngredienteMySQL implements IngredienteDAO{
@Override
public Ingrediente selecionar(int id) throws PizzariaException {
ConexaoMySQL con = new ConexaoMySQL();
String sql = "SELECT * FROM Ingrediente WHERE Ingrediente_ID = ?";
con.prepararPst(sql);
con.setParam(1, id);
ArrayList<ArrayList<String>> dados = con.selecionar();
con.close();
if (dados.size() > 0) {
return getIngrediente(dados, 0);
} else
throw new PizzariaException("Ingrediente não cadastrado: " + id);
}
@Override
public Ingrediente selecionar(String nome) throws PizzariaException {
ConexaoMySQL con = new ConexaoMySQL();
String sql = "SELECT * FROM Ingrediente WHERE Ingrediente_nome = ?";
con.prepararPst(sql);
con.setParam(1, nome);
ArrayList<ArrayList<String>> dados = con.selecionar();
con.close();
if (dados.size() > 0) {
return getIngrediente(dados, 0);
} else
throw new PizzariaException("Ingrediente não cadastrado: " + nome);
}
@Override
public Ingrediente getIngrediente(ArrayList<?> dados, int i) throws PizzariaException {
Ingrediente b = new Ingrediente();
ArrayList<?> li = (ArrayList<?>) dados.get(i);
b.setID(li.get(0).toString());
b.setNome(li.get(1).toString());
b.setValor(li.get(2).toString());
b.setEstoque(li.get(3).toString());
return b;
}
@Override
public ArrayList<Ingrediente> listar() throws PizzariaException {
ConexaoMySQL con = new ConexaoMySQL();
String sql = "SELECT * FROM Ingrediente ORDER BY Ingrediente_nome";
con.prepararPst(sql);
ArrayList<ArrayList<String>> dados = con.selecionar();
con.close();
ArrayList<Ingrediente> resposta = new ArrayList<Ingrediente>();
for (int i = 0; i < dados.size(); i++) {
Ingrediente b = getIngrediente(dados, i);
resposta.add(b);
}
return resposta;
}
}
|
3e1d7fb7978090f8b188660e68c3c3858ea21cb4 | 1,432 | java | Java | Chapter 4/cache/src/main/java/com/example/cache/CacheApplication.java | Du-Feng/SpringFamily | fcb155bdd8f4df6aef692e105a6fd2e01b093008 | [
"MIT"
] | 1 | 2020-09-30T00:16:01.000Z | 2020-09-30T00:16:01.000Z | Chapter 4/cache/src/main/java/com/example/cache/CacheApplication.java | Du-Feng/SpringFamily | fcb155bdd8f4df6aef692e105a6fd2e01b093008 | [
"MIT"
] | null | null | null | Chapter 4/cache/src/main/java/com/example/cache/CacheApplication.java | Du-Feng/SpringFamily | fcb155bdd8f4df6aef692e105a6fd2e01b093008 | [
"MIT"
] | null | null | null | 35.8 | 87 | 0.757682 | 12,509 | package com.example.cache;
import com.example.cache.service.CoffeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Slf4j
@EnableTransactionManagement
@SpringBootApplication
@EnableJpaRepositories
@EnableCaching(proxyTargetClass = true)
public class CacheApplication implements ApplicationRunner {
@Autowired
private CoffeeService coffeeService;
public static void main(String[] args) {
SpringApplication.run(CacheApplication.class, args);
}
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("Count: {}", coffeeService.findAllCoffee().size());
for (int i = 0; i < 10; i++) {
log.info("Reading from cache.");
coffeeService.findAllCoffee();
}
coffeeService.reloadCoffee();
log.info("Reading after refresh.");
coffeeService.findAllCoffee().forEach(c -> log.info("Coffee {}", c.getName()));
}
}
|
3e1d814381a1cb11cce021b0a50fb4233c21bb5b | 908 | java | Java | selenium/test/java/com/thoughtworks/selenium/corebased/TestOpenInTargetFrame.java | epall/selenium | 273260522efb84116979da2a499f64510250249b | [
"Apache-2.0"
] | 4 | 2015-10-26T01:43:04.000Z | 2018-05-12T17:39:32.000Z | selenium/test/java/com/thoughtworks/selenium/corebased/TestOpenInTargetFrame.java | hugs/selenium | 9fa09c04294bd43099aa8461b027148ba81be7b7 | [
"Apache-2.0"
] | 1 | 2021-06-18T00:45:52.000Z | 2021-06-18T00:45:52.000Z | selenium/test/java/com/thoughtworks/selenium/corebased/TestOpenInTargetFrame.java | hugs/selenium | 9fa09c04294bd43099aa8461b027148ba81be7b7 | [
"Apache-2.0"
] | 2 | 2016-07-11T20:19:31.000Z | 2018-11-17T22:36:54.000Z | 39.478261 | 84 | 0.759912 | 12,510 | package com.thoughtworks.selenium.corebased;
import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;
import java.util.regex.Pattern;
public class TestOpenInTargetFrame extends SeleneseTestNgHelper {
@Test public void testOpenInTargetFrame() throws Exception {
selenium.open("../tests/html/test_open_in_target_frame.html");
selenium.selectFrame("rightFrame");
selenium.click("link=Show new frame in leftFrame");
// we are forced to do a pause instead of clickandwait here,
// for currently we can not detect target frame loading in ie yet
Thread.sleep(1500);
verifyTrue(selenium.isTextPresent("Show new frame in leftFrame"));
selenium.selectFrame("relative=top");
selenium.selectFrame("leftFrame");
verifyTrue(selenium.isTextPresent("content loaded"));
verifyFalse(selenium.isTextPresent("This is frame LEFT"));
}
}
|
3e1d82a0b72ffb0b2a166b49d5c9893c1f0059b7 | 685 | java | Java | core/src/main/java/io/nixer/nixerplugin/core/detection/rules/threshold/ThresholdLoginRule.java | gcwiak/nixer-spring-plugin | bc2f5540fa8203f949257e8b9f87b7d268bf4a1a | [
"Apache-2.0"
] | 9 | 2019-11-19T15:01:09.000Z | 2022-02-17T13:10:23.000Z | core/src/main/java/io/nixer/nixerplugin/core/detection/rules/threshold/ThresholdLoginRule.java | gcwiak/nixer-spring-plugin | bc2f5540fa8203f949257e8b9f87b7d268bf4a1a | [
"Apache-2.0"
] | 6 | 2020-01-08T16:25:20.000Z | 2022-03-28T08:17:42.000Z | core/src/main/java/io/nixer/nixerplugin/core/detection/rules/threshold/ThresholdLoginRule.java | gcwiak/nixer-spring-plugin | bc2f5540fa8203f949257e8b9f87b7d268bf4a1a | [
"Apache-2.0"
] | 2 | 2019-11-12T09:32:25.000Z | 2019-11-27T08:16:00.000Z | 27.4 | 73 | 0.734307 | 12,511 | package io.nixer.nixerplugin.core.detection.rules.threshold;
import java.util.concurrent.atomic.AtomicInteger;
import io.nixer.nixerplugin.core.detection.rules.LoginRule;
import org.springframework.util.Assert;
abstract class ThresholdLoginRule implements LoginRule {
private final AtomicInteger threshold;
ThresholdLoginRule(final int threshold) {
this.threshold = new AtomicInteger(threshold);
}
boolean isOverThreshold(int value) {
return value > threshold.get();
}
public void setThreshold(final int threshold) {
Assert.isTrue(threshold > 1, "Threshold must be greater than 1");
this.threshold.set(threshold);
}
}
|
3e1d83d5bb16a5340b882b2d46cdc1fae2c7431b | 2,595 | java | Java | src/main/java/com/dritanium/delegates/AbstractFunction3.java | DrItanium/Java-Delegates | bfb46d9473db42aa1bf8af1b9179602d58f304c0 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | src/main/java/com/dritanium/delegates/AbstractFunction3.java | DrItanium/Java-Delegates | bfb46d9473db42aa1bf8af1b9179602d58f304c0 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | src/main/java/com/dritanium/delegates/AbstractFunction3.java | DrItanium/Java-Delegates | bfb46d9473db42aa1bf8af1b9179602d58f304c0 | [
"BSD-2-Clause-FreeBSD"
] | 1 | 2019-04-23T03:25:22.000Z | 2019-04-23T03:25:22.000Z | 40.546875 | 129 | 0.733333 | 12,512 | //Copyright 2012-2013 Joshua Scoggins. All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are
//permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY Joshua Scoggins ``AS IS'' AND ANY EXPRESS OR IMPLIED
//WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins OR
//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
//CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
//ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
//ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//The views and conclusions contained in the software and documentation are those of the
//authors and should not be interpreted as representing official policies, either expressed
//or implied, of Joshua Scoggins.
package com.dritanium.delegates;
/**
* A three argument function
* @author Joshua Scoggins
*/
public abstract class AbstractFunction3<T0,T1,T2,R> extends DefaultAbstractIntelligentDelegate implements Function3<T0,T1,T2,R> {
public AbstractFunction3() {
super(new Class[] {
((T0)new Object()).getClass(),
((T1)new Object()).getClass(),
((T2)new Object()).getClass(),
});
}
@Override
protected Object invokeImpl(Object[] input) {
return invoke((T0)input[0],
(T1)input[1],
(T2)input[2]);
}
public Function2<T0, T1, R> curry(T2 input) {
final NonLocalClosure<T2> in = new NonLocalClosure<T2>(input);
final NonLocalClosure<AbstractFunction3<T0,T1,T2,R>> fn =
new NonLocalClosure<AbstractFunction3<T0,T1,T2,R>>(this);
return new AbstractFunction2<T0,T1,R>() {
//use it as a transfer medium
AbstractFunction3<T0,T1,T2,R> func = fn.getActualValue();
T2 value = in.getActualValue();
public R invoke(T0 a0, T1 a1) {
return func.invoke(a0, a1, value);
}
};
}
}
|
3e1d848260b5c9639e204f143015b2c1e5a072df | 1,331 | java | Java | src/main/java/cn/badguy/dream/vo/StudentVo.java | SoftpaseFar/Java_MINI_Dreamer | d8cb2df0651123ab5ee7cfca27b84e9efa511461 | [
"Apache-2.0"
] | 2 | 2018-01-25T04:57:59.000Z | 2018-01-25T04:58:02.000Z | src/main/java/cn/badguy/dream/vo/StudentVo.java | SoftpaseFar/Java_MINI_Dreamer | d8cb2df0651123ab5ee7cfca27b84e9efa511461 | [
"Apache-2.0"
] | null | null | null | src/main/java/cn/badguy/dream/vo/StudentVo.java | SoftpaseFar/Java_MINI_Dreamer | d8cb2df0651123ab5ee7cfca27b84e9efa511461 | [
"Apache-2.0"
] | null | null | null | 18.746479 | 51 | 0.609316 | 12,513 | package cn.badguy.dream.vo;
public class StudentVo {
private String name;
private String id;
private String university;
private String college;
private String profession;
private boolean StuCertify;
private String phoneNum;
public StudentVo() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUniversity() {
return university;
}
public void setUniversity(String university) {
this.university = university;
}
public String getCollege() {
return college;
}
public void setCollege(String college) {
this.college = college;
}
public String getProfession() {
return profession;
}
public void setProfession(String profession) {
this.profession = profession;
}
public boolean isStuCertify() {
return StuCertify;
}
public void setStuCertify(boolean stuCertify) {
StuCertify = stuCertify;
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}
}
|
3e1d84d4407b2c652996b79241d17f2753c25b2c | 430 | java | Java | ls-jdbc/src/test/java/com/ls/framework/jdbc/ResultBean.java | zdj666666/springcode | 2f88df64561166ada268e29d8103f505fc7e6f19 | [
"MIT"
] | 55 | 2018-07-27T06:20:14.000Z | 2021-05-17T02:02:56.000Z | ls-jdbc/src/test/java/com/ls/framework/jdbc/ResultBean.java | zdj666666/springcode | 2f88df64561166ada268e29d8103f505fc7e6f19 | [
"MIT"
] | null | null | null | ls-jdbc/src/test/java/com/ls/framework/jdbc/ResultBean.java | zdj666666/springcode | 2f88df64561166ada268e29d8103f505fc7e6f19 | [
"MIT"
] | 3 | 2020-09-28T03:37:18.000Z | 2021-03-30T04:00:23.000Z | 20.47619 | 49 | 0.504651 | 12,514 | package com.ls.framework.jdbc;
import com.ls.framework.jdbc.annotation.LSColumn;
public class ResultBean {
public long id;
public String day;
@LSColumn("col_result")
public String result;
@Override
public String toString() {
return "ResultBean{" +
"id=" + id +
", day='" + day + '\'' +
", result='" + result + '\'' +
'}';
}
}
|
3e1d8589ec0c7a1ddba655c29291de7c0bf2a78e | 832 | java | Java | spring-boot/src/main/java/com/sampleapp/Repos/UserRepository.java | cyberark/identity-demo-angular | 61176afbce632fbe2550895d688324c5f4e037d1 | [
"Apache-2.0"
] | null | null | null | spring-boot/src/main/java/com/sampleapp/Repos/UserRepository.java | cyberark/identity-demo-angular | 61176afbce632fbe2550895d688324c5f4e037d1 | [
"Apache-2.0"
] | null | null | null | spring-boot/src/main/java/com/sampleapp/Repos/UserRepository.java | cyberark/identity-demo-angular | 61176afbce632fbe2550895d688324c5f4e037d1 | [
"Apache-2.0"
] | null | null | null | 34.666667 | 75 | 0.764423 | 12,515 | /*
* Copyright (c) 2022 CyberArk Software Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sampleapp.repos;
import com.sampleapp.entity.DBUser;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserRepository extends JpaRepository<DBUser, Integer>{
}
|
3e1d85c1bd5960997b93341bfeea8f679a707862 | 668 | java | Java | LeakCanaryDemo/app/src/main/java/com/yxhuang/leakcanarydemo/LeakingSingleton.java | yxhuangCH/AndroidDemo | 78871ad11736febf48c6e895d9b7256c1516cbd2 | [
"MIT"
] | null | null | null | LeakCanaryDemo/app/src/main/java/com/yxhuang/leakcanarydemo/LeakingSingleton.java | yxhuangCH/AndroidDemo | 78871ad11736febf48c6e895d9b7256c1516cbd2 | [
"MIT"
] | null | null | null | LeakCanaryDemo/app/src/main/java/com/yxhuang/leakcanarydemo/LeakingSingleton.java | yxhuangCH/AndroidDemo | 78871ad11736febf48c6e895d9b7256c1516cbd2 | [
"MIT"
] | null | null | null | 18.555556 | 55 | 0.60479 | 12,516 | package com.yxhuang.leakcanarydemo;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
/**
* Created by yxhuang
* Date: 2020/10/25
* Description:
*/
public class LeakingSingleton {
private static volatile LeakingSingleton sInstance;
public static LeakingSingleton getInstance(){
if (sInstance == null){
synchronized (LeakingSingleton.class){
if (sInstance == null){
sInstance = new LeakingSingleton();
}
}
}
return sInstance;
}
private LeakingSingleton(){
}
List<View> leakedViews = new ArrayList<>();
}
|
3e1d85c2f0ccaff99366fb355e6e46b87089dca3 | 7,342 | java | Java | agrirouter-middleware-business/src/main/java/de/agrirouter/middleware/business/TenantService.java | agrirouter-middleware/agrirouter-middleware | 0e50461d72164cd217e9a0c5ebc3cf8e999c3e19 | [
"Apache-2.0"
] | 3 | 2022-02-08T15:17:30.000Z | 2022-03-15T07:25:05.000Z | agrirouter-middleware-business/src/main/java/de/agrirouter/middleware/business/TenantService.java | agrirouter-middleware/agrirouter-middleware | 0e50461d72164cd217e9a0c5ebc3cf8e999c3e19 | [
"Apache-2.0"
] | 31 | 2022-01-31T18:43:18.000Z | 2022-03-31T17:18:56.000Z | agrirouter-middleware-business/src/main/java/de/agrirouter/middleware/business/TenantService.java | agrirouter-middleware/agrirouter-middleware | 0e50461d72164cd217e9a0c5ebc3cf8e999c3e19 | [
"Apache-2.0"
] | 3 | 2022-02-02T00:09:03.000Z | 2022-02-23T22:07:21.000Z | 50.634483 | 180 | 0.574367 | 12,517 | package de.agrirouter.middleware.business;
import de.agrirouter.middleware.api.IdFactory;
import de.agrirouter.middleware.api.errorhandling.BusinessException;
import de.agrirouter.middleware.api.errorhandling.error.ErrorMessageFactory;
import de.agrirouter.middleware.business.dto.TenantRegistrationResult;
import de.agrirouter.middleware.business.security.TenantPrincipal;
import de.agrirouter.middleware.domain.Tenant;
import de.agrirouter.middleware.persistence.TenantRepository;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.List;
/**
* Handle all business requests regarding the tenant.
*/
@Slf4j
@Service
public class TenantService implements UserDetailsService {
public static final int DEFAULT_ACCESS_TOKEN_LENGTH = 32;
private final TenantRepository tenantRepository;
private final PasswordEncoder passwordEncoder;
public TenantService(TenantRepository tenantRepository,
PasswordEncoder passwordEncoder) {
this.tenantRepository = tenantRepository;
this.passwordEncoder = passwordEncoder;
}
/**
* Initialize the default tenant.
*/
@PostConstruct
protected void generateDefaultTenant() {
if (tenantRepository.findTenantByGeneratedTenantIsTrue().isEmpty()) {
Tenant tenant = new Tenant();
tenant.setTenantId(IdFactory.tenantId());
tenant.setName(generateAccessToken(24));
tenant.setGeneratedTenant(true);
final var accessToken = generateAccessToken(DEFAULT_ACCESS_TOKEN_LENGTH);
tenant.setAccessToken(passwordEncoder.encode(accessToken));
tenantRepository.save(tenant);
log.info("#######################################################################################################################################################");
log.info("#");
log.info("# Generated default tenant!");
log.info("# Tenant ID: {}", tenant.getTenantId());
log.info("# Name: {}", tenant.getName());
log.info("# Access token: {}", accessToken);
log.info("#");
log.info("# NOTE");
log.info("# The password for the default tenant is stored as hash, therefore it will be printed only (!) THIS (!) time and never again.");
log.info("# If you need to reset the password and generate a new one, remove the default tenant from the database so it will be generated and printed again.");
log.info("#######################################################################################################################################################");
} else {
final var generatedTenant = tenantRepository.findTenantByGeneratedTenantIsTrue();
log.info("#######################################################################################################################################################");
log.info("#");
log.info("# Generated default tenant!");
//noinspection OptionalGetWithoutIsPresent
log.info("# Tenant ID: {}", generatedTenant.get().getTenantId());
log.info("# Name: {}", generatedTenant.get().getName());
log.info("#");
log.info("# NOTE");
log.info("# The password for the default tenant is stored as hash, therefore it will be printed only during setup.");
log.info("# If you need to reset the password and generate a new one, remove the default tenant from the database so it will be generated and printed again.");
log.info("#######################################################################################################################################################");
}
}
/**
* Register a tenant.
*
* @param name Name of the tenant, has to be unique.
* @return The access token for the tenant.
*/
public TenantRegistrationResult register(String name) {
name = name.trim();
if (StringUtils.isBlank(name)) {
throw new BusinessException(ErrorMessageFactory.invalidParameterForAction("name"));
} else {
if (tenantRepository.findTenantByNameIgnoreCase(name).isPresent()) {
throw new BusinessException(ErrorMessageFactory.tenantAlreadyExists(name));
} else {
String accessToken = generateAccessToken(DEFAULT_ACCESS_TOKEN_LENGTH);
String tenantId = IdFactory.tenantId();
final var tenant = new Tenant();
tenant.setName(name);
tenant.setAccessToken(passwordEncoder.encode(accessToken));
tenant.setTenantId(tenantId);
final var t = tenantRepository.save(tenant);
TenantRegistrationResult tenantRegistrationResult = new TenantRegistrationResult();
tenantRegistrationResult.setTenantId(t.getTenantId());
tenantRegistrationResult.setAccessToken(accessToken);
log.info("#######################################################################################################################################################");
log.info("#");
log.info("# A new tenant was registered!");
log.info("# Tenant ID: {}", tenant.getTenantId());
log.info("# Name: {}", tenant.getName());
log.info("#");
log.info("# NOTE");
log.info("# The password for the tenant is stored as hash, therefore it will be printed only during setup.");
log.info("# If you need to reset the password and generate a new one, remove the default tenant from the database so it will be generated and printed again.");
log.info("#######################################################################################################################################################");
return tenantRegistrationResult;
}
}
}
@NotNull
private String generateAccessToken(int defaultAccessTokenLength) {
return RandomStringUtils.random(defaultAccessTokenLength, true, true);
}
@Override
public UserDetails loadUserByUsername(String tenantId) throws UsernameNotFoundException {
final var optionalTenant = tenantRepository.findTenantByTenantId(tenantId);
if (optionalTenant.isEmpty()) {
throw new UsernameNotFoundException(String.format("Tenant with name '%s' has not been found.", tenantId));
} else {
return new TenantPrincipal(optionalTenant.get());
}
}
/**
* List all existing tenants.
*
* @return -
*/
public List<Tenant> findAll() {
return tenantRepository.findAll();
}
}
|
3e1d86be187ebf01434252c6d4dc9de7def453f6 | 7,727 | java | Java | src/main/java/com/rultor/Entry.java | Piterden/rultor | 6282be86a628683e2916f906a0d4348746b17377 | [
"BSD-3-Clause"
] | 419 | 2015-01-04T00:37:38.000Z | 2022-03-23T19:50:37.000Z | src/main/java/com/rultor/Entry.java | Piterden/rultor | 6282be86a628683e2916f906a0d4348746b17377 | [
"BSD-3-Clause"
] | 687 | 2015-01-01T12:49:12.000Z | 2022-03-14T02:00:51.000Z | src/main/java/com/rultor/Entry.java | Piterden/rultor | 6282be86a628683e2916f906a0d4348746b17377 | [
"BSD-3-Clause"
] | 168 | 2015-01-03T16:47:03.000Z | 2022-02-22T10:13:16.000Z | 32.334728 | 79 | 0.617624 | 12,518 | /**
* Copyright (c) 2009-2021 Yegor Bugayenko
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met: 1) Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer. 2) Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution. 3) Neither the name of the rultor.com nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.rultor;
import co.stateful.RtSttc;
import co.stateful.Sttc;
import co.stateful.cached.CdSttc;
import co.stateful.retry.ReSttc;
import com.google.common.collect.EvictingQueue;
import com.jcabi.aspects.Cacheable;
import com.jcabi.aspects.LogExceptions;
import com.jcabi.aspects.Tv;
import com.jcabi.dynamo.Credentials;
import com.jcabi.dynamo.Region;
import com.jcabi.dynamo.retry.ReRegion;
import com.jcabi.github.Github;
import com.jcabi.github.RtGithub;
import com.jcabi.github.mock.MkGithub;
import com.jcabi.github.wire.RetryCarefulWire;
import com.jcabi.log.Logger;
import com.jcabi.manifests.Manifests;
import com.jcabi.urn.URN;
import com.rultor.cached.CdTalks;
import com.rultor.dynamo.DyTalks;
import com.rultor.spi.Pulse;
import com.rultor.spi.Talks;
import com.rultor.spi.Tick;
import com.rultor.web.TkApp;
import io.sentry.Sentry;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
import org.takes.http.Exit;
import org.takes.http.FtCli;
/**
* Command line entry.
*
* @author Yegor Bugayenko (nnheo@example.com)
* @version $Id: 3e1d86be187ebf01434252c6d4dc9de7def453f6 $
* @since 1.50
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
@SuppressWarnings("PMD.ExcessiveImports")
public final class Entry {
/**
* Arguments.
*/
private final transient Iterable<String> arguments;
/**
* Ctor.
* @param args Command line args
*/
public Entry(final String... args) {
this.arguments = Arrays.asList(args);
}
/**
* Main entry point.
* @param args Arguments
* @throws IOException If fails
*/
@LogExceptions
public static void main(final String... args) throws IOException {
Logger.info(Entry.class, "Starting Rultor on the command line...");
new Entry(args).exec();
}
/**
* Run it all.
* @throws IOException If fails
*/
public void exec() throws IOException {
final String dsn = Manifests.read("Rultor-SentryDsn");
if (!dsn.startsWith("test")) {
Sentry.init(dsn);
}
final Talks talks = new CdTalks(
new DyTalks(
this.dynamo(), this.sttc().counters().get("rt-talk")
)
);
Logger.info(this, "Starting the Routine...");
final Routine routine = new Routine(
talks, Entry.pulse(), this.github(), this.sttc()
);
Logger.info(this, "Starting the web front to run forever...");
try {
new FtCli(
new TkApp(talks, Entry.pulse(), new Toggles.InFile()),
this.arguments
).start(Exit.NEVER);
} finally {
routine.close();
}
}
/**
* Make github.
* @return Github
* @throws IOException If fails
*/
@Cacheable(forever = true)
private Github github() throws IOException {
Logger.info(this, "Connecting GitHub...");
final String token = Manifests.read("Rultor-GithubToken");
final Github github;
if (token.startsWith("${")) {
github = new MkGithub();
} else {
github = new RtGithub(
new RtGithub(token).entry().through(
RetryCarefulWire.class,
Tv.HUNDRED
)
);
}
Logger.info(this, "GitHub object instantiated...");
Logger.info(
this, "GitHub connected as @%s",
github.users().self().login()
);
return github;
}
/**
* Sttc.
* @return Sttc
*/
@Cacheable(forever = true)
private Sttc sttc() {
Logger.info(this, "Connecting Sttc...");
final Sttc sttc = new CdSttc(
new ReSttc(
RtSttc.make(
URN.create(Manifests.read("Rultor-SttcUrn")),
Manifests.read("Rultor-SttcToken")
)
)
);
Logger.info(this, "Sttc connected as %s", sttc);
return sttc;
}
/**
* Dynamo DB region.
* @return Region
*/
@Cacheable(forever = true)
private Region dynamo() {
Logger.info(this, "Connecting DynamoDB...");
final String key = Manifests.read("Rultor-DynamoKey");
Credentials creds = new Credentials.Simple(
key,
Manifests.read("Rultor-DynamoSecret")
);
if (key.startsWith("AAAAA")) {
final int port = Integer.parseInt(
System.getProperty("dynamo.port")
);
creds = new Credentials.Direct(creds, port);
Logger.warn(this, "test DynamoDB at port #%d", port);
}
Logger.info(this, "DynamoDB connected as %s", key);
return new Region.Prefixed(
new ReRegion(new Region.Simple(creds)), "rt-"
);
}
/**
* Create pulse.
* @return Pulse
*/
@Cacheable(forever = true)
private static Pulse pulse() {
final Collection<Tick> ticks = Collections.synchronizedCollection(
EvictingQueue.<Tick>create((int) TimeUnit.HOURS.toMinutes(1L))
);
final Collection<Throwable> error = Collections.synchronizedCollection(
new ArrayList<Throwable>(1)
);
// @checkstyle AnonInnerLengthCheck (50 lines)
return new Pulse() {
@Override
public void add(final Tick tick) {
ticks.add(tick);
}
@Override
public Iterable<Tick> ticks() {
return Collections.unmodifiableCollection(ticks);
}
@Override
public Iterable<Throwable> error() {
return Collections.unmodifiableCollection(error);
}
@Override
public void error(final Iterable<Throwable> errors) {
error.clear();
for (final Throwable err : errors) {
error.add(err);
}
}
};
}
}
|
3e1d8751737a7aa6b99646375bbeae8cd1d57f24 | 3,727 | java | Java | src/main/java/nz/ac/lconz/irr/curate/task/MakeThesisPrimaryBitstream.java | lconz-irr/Curation-Tasks | 7dcea9fe23525e2e74d7d0180717c7b5bc3c439f | [
"BSD-3-Clause"
] | 3 | 2018-08-21T09:59:09.000Z | 2020-10-03T03:09:38.000Z | src/main/java/nz/ac/lconz/irr/curate/task/MakeThesisPrimaryBitstream.java | lconz-irr/Curation-Tasks | 7dcea9fe23525e2e74d7d0180717c7b5bc3c439f | [
"BSD-3-Clause"
] | null | null | null | src/main/java/nz/ac/lconz/irr/curate/task/MakeThesisPrimaryBitstream.java | lconz-irr/Curation-Tasks | 7dcea9fe23525e2e74d7d0180717c7b5bc3c439f | [
"BSD-3-Clause"
] | null | null | null | 31.584746 | 131 | 0.715052 | 12,519 | package nz.ac.lconz.irr.curate.task;
import org.apache.log4j.Logger;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Bitstream;
import org.dspace.content.Bundle;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.curate.AbstractCurationTask;
import org.dspace.curate.Curator;
import org.dspace.curate.Mutative;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
/**
* @author Andrea Schweer for the LCoNZ Institutional Research Repositories
*
* Curation task to make a bitstream with the name thesis.pdf the primary bitstream in the content bundle.
* It will also re-order the bitstreams in the content bundle to ensure that the primary bitstream is first in the bitstream order.
*/
@Mutative
public class MakeThesisPrimaryBitstream extends AbstractCurationTask {
private final static Logger log = Logger.getLogger(MakeThesisPrimaryBitstream.class);
@Override
public int perform(DSpaceObject dso) throws IOException {
if (dso.getType() != Constants.ITEM) {
return Curator.CURATE_SKIP;
}
Item item = (Item) dso;
Bitstream thesisBitstream = null;
Bundle thesisBundle = null;
try {
Bundle[] contentBundles = item.getBundles(Constants.CONTENT_BUNDLE_NAME);
for (Bundle bundle : contentBundles) {
if (bundle.getPrimaryBitstreamID() > 0) {
String message = "Item id=" + item.getID() + " already has a primary bitstream";
log.info(message);
report(message);
setResult(message);
return Curator.CURATE_SKIP;
}
Bitstream thesisCandidate = bundle.getBitstreamByName("thesis.pdf");
if (thesisCandidate != null) {
thesisBitstream = thesisCandidate;
thesisBundle = bundle;
break;
}
}
} catch (SQLException e) {
String message = "Problem getting bundles for item id=" + item.getID();
log.warn(message, e);
report(message);
setResult(e.getMessage());
return Curator.CURATE_ERROR;
}
if (thesisBitstream != null && thesisBundle != null) {
try {
thesisBundle.setPrimaryBitstreamID(thesisBitstream.getID());
thesisBundle.update();
makePrimaryBitstreamFirst(thesisBundle);
thesisBundle.update();
} catch (SQLException | AuthorizeException e) {
String message = "Problem setting primary bitstream id=" + thesisBitstream.getID() + " for item id=" + item.getID();
log.warn(message, e);
report(message);
setResult(e.getMessage());
return Curator.CURATE_ERROR;
}
String message = "Set primary bitstream id=" + thesisBitstream.getID() + " for item id=" + item.getID();
setResult(message);
report(message);
log.info(message);
return Curator.CURATE_SUCCESS;
} else {
String message = "No thesis.pdf file found for item " + item.getID();
setResult(message);
report(message);
log.info(message);
return Curator.CURATE_FAIL;
}
}
private void makePrimaryBitstreamFirst(Bundle bundle) throws AuthorizeException, SQLException {
int primaryBitstreamID = bundle.getPrimaryBitstreamID();
if (primaryBitstreamID < 0) {
return; // no primary bitstream -> nothing to be done
}
Bitstream[] bitstreams = bundle.getBitstreams();
ArrayList<Integer> ids = new ArrayList<Integer>(bitstreams.length);
for (Bitstream bitstream : bitstreams) {
int bitstreamID = bitstream.getID();
if (bitstreamID == primaryBitstreamID) {
ids.add(0, bitstreamID); // insert as first
} else {
ids.add(bitstreamID); // insert in order
}
}
int[] newOrder = new int[ids.size()];
for (int i = 0; i < ids.size(); i++) {
newOrder[i] = ids.get(i);
}
bundle.setOrder(newOrder);
}
}
|
3e1d875d359eebcac878f1be2e285779bfd08acc | 1,544 | java | Java | src/main/java/com/github/avalon/packet/packet/status/PacketPong.java | Avalon-Minecraft/Avalon | 352c97e6f0f6c402de50ee5af0921d14dcb93b2f | [
"MIT"
] | 3 | 2021-07-27T07:02:19.000Z | 2021-10-09T12:43:00.000Z | src/main/java/com/github/avalon/packet/packet/status/PacketPong.java | Avalon-Minecraft/Avalon | 352c97e6f0f6c402de50ee5af0921d14dcb93b2f | [
"MIT"
] | null | null | null | src/main/java/com/github/avalon/packet/packet/status/PacketPong.java | Avalon-Minecraft/Avalon | 352c97e6f0f6c402de50ee5af0921d14dcb93b2f | [
"MIT"
] | 2 | 2021-07-14T12:55:28.000Z | 2021-08-17T23:26:13.000Z | 24.507937 | 96 | 0.728627 | 12,520 | package com.github.avalon.packet.packet.status;
import com.github.avalon.common.data.DataType;
import com.github.avalon.network.ProtocolType;
import com.github.avalon.packet.annotation.PacketRegister;
import com.github.avalon.packet.packet.Packet;
import com.github.avalon.packet.schema.FunctionScheme;
import com.github.avalon.packet.schema.PacketStrategy;
import com.github.avalon.player.PlayerConnection;
/**
* Packet client ping is used for sending packet that will be sent to the client to verify ping.
* There is also packet for reading ping of player {@link PacketPing}
*
* <h3>Packet Strategy</h3>
*
* <ul>
* <li>1. Time that is this packet being sent.
* </ul>
*
* @version 1.0
*/
@PacketRegister(
operationCode = 0x01,
protocolType = ProtocolType.STATUS,
direction = PacketRegister.Direction.CLIENT)
public class PacketPong extends Packet<PacketPong> {
public PacketStrategy strategy =
new PacketStrategy(new FunctionScheme<>(DataType.LONG, this::getTime, this::setTime));
private long time;
public PacketPong(long time) {
this.time = time;
}
public PacketPong() {}
@Override
public boolean isAsync() {
return true;
}
@Override
public void handle(PlayerConnection session, PacketPong packet) {
throw new UnsupportedOperationException("This operation is not supported");
}
@Override
public PacketStrategy getStrategy() {
return strategy;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
}
|
3e1d88194c540978f8dfd22c8512a2fc203dc4ee | 3,814 | java | Java | core/src/test/java/com/delmar/core/test/PeopleServiceImpl.java | ldlqdsdcn/wms | 0be5e05d65bf76d226e32d7d438f0036e3f47beb | [
"Apache-2.0"
] | 20 | 2016-08-23T08:31:42.000Z | 2022-03-14T13:44:57.000Z | core/src/test/java/com/delmar/core/test/PeopleServiceImpl.java | ldlqdsdcn/wms | 0be5e05d65bf76d226e32d7d438f0036e3f47beb | [
"Apache-2.0"
] | null | null | null | core/src/test/java/com/delmar/core/test/PeopleServiceImpl.java | ldlqdsdcn/wms | 0be5e05d65bf76d226e32d7d438f0036e3f47beb | [
"Apache-2.0"
] | 12 | 2016-08-23T08:31:43.000Z | 2019-06-28T08:58:56.000Z | 26.289655 | 109 | 0.658972 | 12,521 | /******************************************************************************
* 版权所有 刘大磊 2013-07-01 *
* 作者:刘大磊 *
* 电话:13336390671 *
* email:lyhxr@example.com *
*****************************************************************************/
package com.delmar.core.test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.delmar.core.model.Language;
import com.delmar.core.model.LanguageTrl;
import com.delmar.core.service.LanguageService;
/**
* @author 刘大磊 2015年7月28日 上午11:21:21
*/
@Service("peopleService")
public class PeopleServiceImpl implements LanguageService{
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#getByExample(java.util.Map)
*/
public Language getByExample(Map example) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#insert(java.lang.Object)
*/
public Integer insert(Language model) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#update(java.lang.Object)
*/
//FIXME 测试事务
public void update(Language model) {
List<Integer> list=new ArrayList();
list.add(1);
list.add(2);
list.add(3);
System.out.println(list.get(10));
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#updateAll(java.lang.Object)
*/
public void updateAll(Language model) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#save(java.lang.Object)
*/
public Integer save(Language model) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#deleteByExample(java.util.Map)
*/
public Integer deleteByExample(Map example) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#countObjects(java.util.Map)
*/
public Integer countObjects(Map example) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#insertSelective(java.lang.Object)
*/
public Integer insertSelective(Language model) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#deleteByPrimaryKey(java.lang.Integer)
*/
public Integer deleteByPrimaryKey(Integer id) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#selectByPrimaryKey(java.lang.Integer)
*/
public Language selectByPrimaryKey(Integer id) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#selectFieldsByPrimaryKey(java.lang.String, java.lang.Integer)
*/
public Language selectFieldsByPrimaryKey(String fieldColumns, Integer id) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.delmar.core.service.CoreService#selectByExample(java.util.Map)
*/
public List<Language> selectByExample(Map example) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see com.delmar.core.service.LanguageService#deleteLanguageList(java.lang.Integer[])
*/
public void deleteLanguageList(Integer[] ids) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.delmar.core.service.LanguageService#saveLanguage(com.delmar.core.model.Language, java.util.List)
*/
public void saveLanguage(Language language, List<LanguageTrl> trlList) {
// TODO Auto-generated method stub
}
}
|
3e1d8a0c3931a6ea23dfe4c98e06d714384e6bbf | 595 | java | Java | src/test/java/redis/clients/jedis/commands/unified/pooled/PooledAllKindOfValuesCommandsTest.java | sebdehne/jedis | 83af8c19fd360f299eae7c54d7fc14f2a6cb3f6d | [
"MIT"
] | 8,456 | 2015-01-02T02:31:37.000Z | 2020-10-20T06:57:17.000Z | src/test/java/redis/clients/jedis/commands/unified/pooled/PooledAllKindOfValuesCommandsTest.java | sebdehne/jedis | 83af8c19fd360f299eae7c54d7fc14f2a6cb3f6d | [
"MIT"
] | 1,550 | 2015-01-01T03:34:02.000Z | 2020-10-15T05:21:13.000Z | src/test/java/redis/clients/jedis/commands/unified/pooled/PooledAllKindOfValuesCommandsTest.java | sebdehne/jedis | 83af8c19fd360f299eae7c54d7fc14f2a6cb3f6d | [
"MIT"
] | 3,198 | 2015-01-02T06:58:09.000Z | 2020-10-20T10:41:07.000Z | 23.8 | 88 | 0.781513 | 12,522 | package redis.clients.jedis.commands.unified.pooled;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import redis.clients.jedis.commands.unified.AllKindOfValuesCommandsTestBase;
public class PooledAllKindOfValuesCommandsTest extends AllKindOfValuesCommandsTestBase {
@BeforeClass
public static void prepare() throws InterruptedException {
jedis = PooledCommandsTestHelper.getPooled();
}
@AfterClass
public static void closeCluster() {
jedis.close();
}
@Before
public void setUp() {
PooledCommandsTestHelper.clearData();
}
}
|
3e1d8b4e745c0da5de25d96db63f0d2933032132 | 776 | java | Java | yygh_parent/service/service_msm/src/main/java/com/atguigu/yygh/msm/service/aliyunSms/ConstantPropertiesUtils.java | Giaming/yygh-project | 8b7ed18d6b4c810f7c468767893b8c72ea931de9 | [
"Apache-2.0"
] | 2 | 2022-03-01T03:08:51.000Z | 2022-03-13T10:57:02.000Z | yygh_parent/service/service_msm/src/main/java/com/atguigu/yygh/msm/service/aliyunSms/ConstantPropertiesUtils.java | Giaming/yygh-project | 8b7ed18d6b4c810f7c468767893b8c72ea931de9 | [
"Apache-2.0"
] | null | null | null | yygh_parent/service/service_msm/src/main/java/com/atguigu/yygh/msm/service/aliyunSms/ConstantPropertiesUtils.java | Giaming/yygh-project | 8b7ed18d6b4c810f7c468767893b8c72ea931de9 | [
"Apache-2.0"
] | null | null | null | 25.032258 | 66 | 0.739691 | 12,523 | package com.atguigu.yygh.msm.service.aliyunSms;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class ConstantPropertiesUtils implements InitializingBean {
@Value("${aliyun.sms.regionId}")
private String regionId;
@Value("${aliyun.sms.accessKeyId}")
private String accessKeyId;
@Value("${aliyun.sms.secret}")
private String secret;
public static String REGION_Id;
public static String ACCESS_KEY_ID;
public static String SECRECT;
@Override
public void afterPropertiesSet() throws Exception {
REGION_Id=regionId;
ACCESS_KEY_ID=accessKeyId;
SECRECT=secret;
}
}
|
3e1d8ccf6e723a4151cf95d9fe9ffac5a6c6728d | 3,672 | java | Java | app/src/main/java/de/uni_stuttgart/informatik/sopra/sopraapp/db/DAOs/EventUserPuzzleListJoinDAO.java | GeoCodingApp/geocoding | 7022421b7890fae1014d8055949c06c3b3246d39 | [
"MIT"
] | null | null | null | app/src/main/java/de/uni_stuttgart/informatik/sopra/sopraapp/db/DAOs/EventUserPuzzleListJoinDAO.java | GeoCodingApp/geocoding | 7022421b7890fae1014d8055949c06c3b3246d39 | [
"MIT"
] | null | null | null | app/src/main/java/de/uni_stuttgart/informatik/sopra/sopraapp/db/DAOs/EventUserPuzzleListJoinDAO.java | GeoCodingApp/geocoding | 7022421b7890fae1014d8055949c06c3b3246d39 | [
"MIT"
] | null | null | null | 35.650485 | 231 | 0.738562 | 12,524 | package de.uni_stuttgart.informatik.sopra.sopraapp.db.DAOs;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.RoomWarnings;
import android.arch.persistence.room.Update;
import java.util.List;
import java.util.Optional;
import de.uni_stuttgart.informatik.sopra.sopraapp.db.entitys.EventUserPuzzleListJoin;
import de.uni_stuttgart.informatik.sopra.sopraapp.db.entitys.PuzzleList;
/**
* Data Access Object for the EventUserPuzzleListJoinDAO table.
*
* @author Mike Ashi
*/
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
@Dao
public interface EventUserPuzzleListJoinDAO {
/**
* Gets a EventUserPuzzleListJoin from the table using its id.
*
* @param id EventUserPuzzleListJoin's id
* @return EventUserPuzzleListJoin with given id
*/
@Query("select * from event_user_puzzlelist_join where id=:id")
Optional<EventUserPuzzleListJoin> getById(String id);
/**
* Gets a EventUserPuzzleListJoin from the table using event id.
*
* @param eventId event's id
* @return EventUserPuzzleListJoin for a given event
*/
@Query("select * from event_user_puzzlelist_join where eventId=:eventId")
List<EventUserPuzzleListJoin> getByEvent(String eventId);
/**
* Gets a EventUserPuzzleListJoin from the table using user id.
*
* @param userId users's id
* @return EventUserPuzzleListJoin for a given event
*/
@Query("select * from event_user_puzzlelist_join where userId=:userId")
List<EventUserPuzzleListJoin> getByUserId(String userId);
/**
* Gets all EventUserPuzzleListJoin from the table .
*
* @return all EventUserPuzzleListJoins.
*/
@Query("select * from event_user_puzzlelist_join")
List<EventUserPuzzleListJoin> getAll();
/**
* Inserts one or more EventUserPuzzleListJoin to the table.
*
* @param eventUserPuzzleListJoin EventUserPuzzleListJoin/s to be saved
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
void add(EventUserPuzzleListJoin... eventUserPuzzleListJoin);
/**
* Updates a given EventUserPuzzleListJoin.
*
* @param eventUserPuzzleListJoin EventUserPuzzleListJoin to be updated
*/
@Update
void update(EventUserPuzzleListJoin eventUserPuzzleListJoin);
/**
* Deletes a given EventUserPuzzleListJoin.
*
* @param eventUserPuzzleListJoin EventUserPuzzleListJoin to be deleted
*/
@Delete
void delete(EventUserPuzzleListJoin eventUserPuzzleListJoin);
/**
* Returns a list of all PuzzleLists for a given Event.
*
* @param eventId event id
* @return list of all PuzzleLists for a given Event
*/
@Query("select * from puzzlelists inner join event_user_puzzlelist_join on puzzlelists.id=event_user_puzzlelist_join.puzzleListId where event_user_puzzlelist_join.eventId=:eventId")
List<PuzzleList> getAllPuzzleListForEvent(String eventId);
/**
* Returns a list of all PuzzleLists for a given Event and user.
*
* @param eventId event id
* @param userId user id
* @return ist of all PuzzleLists for a given Event and user
*/
@Query("select * from puzzlelists inner join event_user_puzzlelist_join on puzzlelists.id=event_user_puzzlelist_join.puzzleListId where event_user_puzzlelist_join.eventId=:eventId and event_user_puzzlelist_join.userId=:userId")
Optional<PuzzleList> getPuzzleListForEventUser(String eventId, String userId);
}
|
3e1d8d04df4cde45ee226a531ee1b00dc2c85e30 | 96 | java | Java | src/org/tiefaces/components/websheet/utility/package-info.java | singgih88/TieFaces | 9401dcc4c09cd55ab4b3aff88c26c8088a22963e | [
"MIT"
] | 20 | 2017-01-09T15:43:57.000Z | 2020-07-14T16:12:10.000Z | src/org/tiefaces/components/websheet/utility/package-info.java | singgih88/TieFaces | 9401dcc4c09cd55ab4b3aff88c26c8088a22963e | [
"MIT"
] | 38 | 2017-01-13T19:18:01.000Z | 2019-03-27T22:06:25.000Z | src/org/tiefaces/components/websheet/utility/package-info.java | singgih88/TieFaces | 9401dcc4c09cd55ab4b3aff88c26c8088a22963e | [
"MIT"
] | 5 | 2017-11-20T09:56:27.000Z | 2021-06-20T00:08:37.000Z | 12 | 49 | 0.5625 | 12,525 | /**
*
*/
/**
* @author JASON
*
*/
package org.tiefaces.components.websheet.utility; |
3e1d8dfc14144f81b7be6f87c7842d3aff731b46 | 2,137 | java | Java | src-lib/no/npolar/common/forms/view/FilterLink.java | paulflakstad/opencms-module-forms | 68f6fb019da45da97ce885ef0e5d4c62531a5bbb | [
"MIT"
] | null | null | null | src-lib/no/npolar/common/forms/view/FilterLink.java | paulflakstad/opencms-module-forms | 68f6fb019da45da97ce885ef0e5d4c62531a5bbb | [
"MIT"
] | null | null | null | src-lib/no/npolar/common/forms/view/FilterLink.java | paulflakstad/opencms-module-forms | 68f6fb019da45da97ce885ef0e5d4c62531a5bbb | [
"MIT"
] | null | null | null | 33.920635 | 159 | 0.668694 | 12,526 | package no.npolar.common.forms.view;
/*import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Arrays;
import java.util.Iterator;*/
/**
* Convenience class to simplify working with "filter links", that is; regular
* links used to narrow down a result list when viewing form (database) entries.
* <p>
* The links will typically all point to the same result page, only the
* parameters will vary.
* <p>
* An example "filter link":
* <a href="#country=no">Norway</a>
* <p>
* When multiple filters are active, it may look like this:
* <a href="#country=no&gender=male">Norway</a>
* <p>
* If the current "Country = Norway" filter is active, it should be a "remove"
* link, like this:
* <a href="#gender=male">Norway</a>. (Note the missing country
* parameter.)
*
* @author Paul-Inge Flakstad, Norwegian Polar Institute
*/
public class FilterLink {
/** Internal flag indicating if this filter link is active or not. */
private boolean active = false;
/** The parameter(s) associated with this filter link. */
private String param = null;
/**
* Creates a new filter link with the given active state and parameters.
*
* @param active If <code>true</code>, the filter link is instantiated as active, otherwise it will be inactive.
* @param parameters The string defining all parameters associated with this filter link (e.g. "country=no&country=en&country=se" or "gender=male")
*/
public FilterLink(boolean active, String parameters) {
this.active = active;
this.param = parameters;
}
/**
* Gets the parameters associated with this filter link.
*
* @return the parameters associated with this filter link.
*/
public String getParam() { return this.param; }
/**
* Used to determine if this filter link is active or not.
*
* @return <code>true</code> if this filter link is active, <code>false</code> if not.
*/
public boolean isActive() { return this.active; }
} |
3e1d8e791b055ea014d1bbf7f48a53b70772b16f | 2,547 | java | Java | src/main/java/br/org/casa/pedidosimples/service/ItemVendaService.java | jrjosecarlos/pedido-simples | 2f89ac99f749ab2b7b189fb4108cfec36573706e | [
"MIT"
] | null | null | null | src/main/java/br/org/casa/pedidosimples/service/ItemVendaService.java | jrjosecarlos/pedido-simples | 2f89ac99f749ab2b7b189fb4108cfec36573706e | [
"MIT"
] | null | null | null | src/main/java/br/org/casa/pedidosimples/service/ItemVendaService.java | jrjosecarlos/pedido-simples | 2f89ac99f749ab2b7b189fb4108cfec36573706e | [
"MIT"
] | null | null | null | 33.96 | 106 | 0.759325 | 12,527 | /**
*
*/
package br.org.casa.pedidosimples.service;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import br.org.casa.pedidosimples.exception.EntidadeNaoEncontradaException;
import br.org.casa.pedidosimples.exception.OperacaoInvalidaException;
import br.org.casa.pedidosimples.model.ItemPedido;
import br.org.casa.pedidosimples.model.ItemVenda;
import br.org.casa.pedidosimples.model.Pedido;
/**
* Contrato para os serviços relacionados a {@link ItemVenda}.
*
* @author jrjosecarlos
*
*/
public interface ItemVendaService {
/**
* Busca todos os {@link ItemVenda} existentes, podendo incluir opções de paginação e parâmetros de busca
* para retornar registros específicos.
*
* @param pageable interface de definição da paginação da busca
* @param parametrosBusca parâmetros para filtragem dos resultados encontrados
* @return um {@link Page} contendo os registros da página atual, de acordo com os parâmetros de busca
*/
Page<ItemVenda> buscarTodos(Pageable pageable, Map<String, String> parametrosBusca);
/**
* Busca um {@link ItemVenda} pelo seu uuid.
*
* @param uuid id do ItemVenda a ser buscado.
* @return um Optional contendo o ItemVenda com o id informado, se existir, ou um Optional
* vazio, caso não exista.
*/
Optional<ItemVenda> buscarPorId(UUID uuid);
/**
* Inclui um novo ItemVenda.
*
* @param itemVenda ItemVenda a ser incluído.
* @return a versão persistida (com uuid preenchido) deste itemVenda
*/
ItemVenda incluir(ItemVenda itemVenda);
/**
* Altera um ItemVenda existente. Se o valor do itemVenda for alterado, os {@link ItemPedido}
* associados serão recalculados.
*
* @param uuid o id do ItemVenda a ser alterado
* @param itemVenda os novos dados para o itemVenda
* @return a versão persistida deste itemVenda
* @throws EntidadeNaoEncontradaException se não existir ItemVenda com o uuid informado
* @throws OperacaoInvalidaException se houver uma tentativa de desativar o itemVenda e houver
* {@link Pedido}s em aberto com {@link ItemPedido}s associados a este itemVenda
*/
ItemVenda alterar(UUID uuid, ItemVenda itemVenda);
/**
* Exclui um ItemVenda existente.
*
* @param uuid id do ItemVenda a ser excluído
* @throws EntidadeNaoEncontradaException se não existir ItemVenda com o uuid informado
* @throws OperacaoInvalidaException se existir algum ItemPedido já associado ao itemVenda
*/
void excluir(UUID uuid);
}
|
3e1d8ea0c310ea85d64cc5a4002c1aa5ebbbb44e | 1,344 | java | Java | mysol/Category/Array/E119_Pascals_Triangle_II/src/E119_Pascals_Triangle_II.java | specter01wj/Leetcode_Java | 1f017f6a7093d13c7a62b62d52755392dfff959d | [
"MIT"
] | 2 | 2019-07-07T02:18:11.000Z | 2021-04-03T16:10:07.000Z | mysol/Easy/E119_Pascals_Triangle_II/src/E119_Pascals_Triangle_II.java | specter01wj/Leetcode_Java | 1f017f6a7093d13c7a62b62d52755392dfff959d | [
"MIT"
] | null | null | null | mysol/Easy/E119_Pascals_Triangle_II/src/E119_Pascals_Triangle_II.java | specter01wj/Leetcode_Java | 1f017f6a7093d13c7a62b62d52755392dfff959d | [
"MIT"
] | null | null | null | 22.4 | 95 | 0.512649 | 12,528 | import java.util.*;
/*Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.
Note that the row index starts from 0.
In Pascal's triangle, each number is the sum of the two numbers directly above it.
Example:
Input: 3
Output: [1,3,3,1]
*/
public class E119_Pascals_Triangle_II {
public static void main(String[] args) {
int input = 5;
ArrayList<Integer> output = new ArrayList<Integer>();
output = getRow(input);
System.out.println("input: " + (input) + "\noutput: " + (output));
}
/*
solution:
*/
/**
* @param numRows: an integer
* @return: an Array
*/
public static ArrayList<Integer> getRow(int rowIndex) {
ArrayList<Integer> rst = new ArrayList<Integer>();
rowIndex += 1;
if (rowIndex == 0) {
return rst;
}
rst.add(1);
for (int i = 1; i < rowIndex; i++) {
ArrayList<Integer> tmp = new ArrayList<Integer>(i + 1);
for (int j = 0; j < i + 1; j++) {
tmp.add(-1);
}
tmp.set(0, rst.get(0));
tmp.set(i, rst.get(i - 1));
for (int j = 1; j < i; j++) {
tmp.set(j, rst.get(j - 1) + rst.get(j));
}
rst = tmp;
}
return rst;
}
}
|
3e1d8ee4e128001d07eea45076fefdef8cef7fa7 | 82 | java | Java | src/test/java/de/fh/kiel/advancedjava/pojomodel/exampleData/Here.java | MaltePetersen/pojoverse | aacaefd03892a0c5cf40fd7a9af3acd08b4f703d | [
"Apache-2.0"
] | null | null | null | src/test/java/de/fh/kiel/advancedjava/pojomodel/exampleData/Here.java | MaltePetersen/pojoverse | aacaefd03892a0c5cf40fd7a9af3acd08b4f703d | [
"Apache-2.0"
] | null | null | null | src/test/java/de/fh/kiel/advancedjava/pojomodel/exampleData/Here.java | MaltePetersen/pojoverse | aacaefd03892a0c5cf40fd7a9af3acd08b4f703d | [
"Apache-2.0"
] | null | null | null | 16.4 | 54 | 0.804878 | 12,529 | package de.fh.kiel.advancedjava.pojomodel.exampleData;
public interface Here {
}
|
3e1d8f3373008294fb69663d2f3c1192d3298a3d | 20,257 | java | Java | rbac-distributed-service-impl/src/test/java/com/dwarfeng/rbacds/impl/service/PermissionLookupServiceImplTest.java | DwArFeng/rbac-distributed-service | 43378467f007f85c6ca0633ada97ed8f3f842293 | [
"Apache-2.0"
] | null | null | null | rbac-distributed-service-impl/src/test/java/com/dwarfeng/rbacds/impl/service/PermissionLookupServiceImplTest.java | DwArFeng/rbac-distributed-service | 43378467f007f85c6ca0633ada97ed8f3f842293 | [
"Apache-2.0"
] | null | null | null | rbac-distributed-service-impl/src/test/java/com/dwarfeng/rbacds/impl/service/PermissionLookupServiceImplTest.java | DwArFeng/rbac-distributed-service | 43378467f007f85c6ca0633ada97ed8f3f842293 | [
"Apache-2.0"
] | null | null | null | 56.113573 | 136 | 0.690132 | 12,530 | package com.dwarfeng.rbacds.impl.service;
import com.dwarfeng.rbacds.stack.bean.entity.Permission;
import com.dwarfeng.rbacds.stack.bean.entity.Pexp;
import com.dwarfeng.rbacds.stack.bean.entity.Role;
import com.dwarfeng.rbacds.stack.bean.entity.User;
import com.dwarfeng.rbacds.stack.service.*;
import com.dwarfeng.subgrade.stack.bean.key.LongIdKey;
import com.dwarfeng.subgrade.stack.bean.key.StringIdKey;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring/application-context*.xml")
public class PermissionLookupServiceImplTest {
@Autowired
private UserMaintainService userMaintainService;
@Autowired
private RoleMaintainService roleMaintainService;
@Autowired
private PexpMaintainService pexpMaintainService;
@Autowired
private PermissionMaintainService permissionMaintainService;
@Autowired
private PermissionLookupService permissionLookupService;
private User zhangSan;
private User liSi;
private User wangWu;
private Role roleA;
private Role roleB;
private Role roleC;
private Pexp pexp1;
private Pexp pexp2;
private Pexp pexp3;
private Pexp pexp4;
private Pexp pexp5;
private Pexp pexp6;
private Permission permission1;
private Permission permission2;
private Permission permission3;
private Permission permission4;
private Permission permission5;
private Permission permission6;
private Permission permission7;
private Permission permission8;
private Permission permission9;
@Before
public void setUp() {
zhangSan = new User(new StringIdKey("zhang_san"), "测试用账号");
liSi = new User(new StringIdKey("li_si"), "测试用账号");
wangWu = new User(new StringIdKey("wang_wu"), "测试用账号");
roleA = new Role(new StringIdKey("role.a"), "角色A", true, "测试用角色");
roleB = new Role(new StringIdKey("role.b"), "角色B", false, "测试用角色");
roleC = new Role(new StringIdKey("role.c"), "角色C", true, "测试用角色");
pexp1 = new Pexp(new LongIdKey(1L), roleA.getKey(), "+id_regex@^.*\\.1$", "正则:匹配所有以1结尾的权限");
pexp2 = new Pexp(new LongIdKey(2L), roleA.getKey(), "!exact@permission.a.1", "精确:去除permission.a.1");
pexp3 = new Pexp(new LongIdKey(3L), roleB.getKey(), "!id_regex@^.*$", "正则:去除所有权限");
pexp4 = new Pexp(new LongIdKey(4L), roleB.getKey(), "!id_regex@^.*$", "正则:去除所有权限");
pexp5 = new Pexp(new LongIdKey(5L), roleC.getKey(), "+id_regex@^.*\\.3$", "正则:匹配所有以3结尾的权限");
pexp6 = new Pexp(new LongIdKey(6L), roleC.getKey(), "!exact@permission.c.3", "精确:去除permission.c.3");
permission1 = new Permission(new StringIdKey("permission.a.1"), null, "测试权限a.1", "测试用权限");
permission2 = new Permission(new StringIdKey("permission.a.2"), null, "测试权限a.2", "测试用权限");
permission3 = new Permission(new StringIdKey("permission.a.3"), null, "测试权限a.3", "测试用权限");
permission4 = new Permission(new StringIdKey("permission.b.1"), null, "测试权限b.1", "测试用权限");
permission5 = new Permission(new StringIdKey("permission.b.2"), null, "测试权限b.2", "测试用权限");
permission6 = new Permission(new StringIdKey("permission.b.3"), null, "测试权限b.3", "测试用权限");
permission7 = new Permission(new StringIdKey("permission.c.1"), null, "测试权限c.1", "测试用权限");
permission8 = new Permission(new StringIdKey("permission.c.2"), null, "测试权限c.2", "测试用权限");
permission9 = new Permission(new StringIdKey("permission.c.3"), null, "测试权限c.3", "测试用权限");
}
@After
public void tearDown() {
zhangSan = null;
liSi = null;
wangWu = null;
roleA = null;
roleB = null;
roleC = null;
pexp1 = null;
pexp2 = null;
pexp3 = null;
pexp4 = null;
pexp5 = null;
pexp6 = null;
permission1 = null;
permission2 = null;
permission3 = null;
permission4 = null;
permission5 = null;
permission6 = null;
permission7 = null;
permission8 = null;
permission9 = null;
}
@Test
public void testLookupForUser() throws Exception {
try {
userMaintainService.insertOrUpdate(zhangSan);
userMaintainService.insertOrUpdate(liSi);
userMaintainService.insertOrUpdate(wangWu);
roleMaintainService.insertOrUpdate(roleA);
roleMaintainService.insertOrUpdate(roleB);
roleMaintainService.insertOrUpdate(roleC);
userMaintainService.batchAddRoleRelations(zhangSan.getKey(), Arrays.asList(roleA.getKey(), roleB.getKey(), roleC.getKey()));
userMaintainService.batchAddRoleRelations(liSi.getKey(), Arrays.asList(roleB.getKey(), roleC.getKey()));
userMaintainService.batchAddRoleRelations(wangWu.getKey(), Collections.singletonList(roleC.getKey()));
pexpMaintainService.insertOrUpdate(pexp1);
pexpMaintainService.insertOrUpdate(pexp2);
pexpMaintainService.insertOrUpdate(pexp3);
pexpMaintainService.insertOrUpdate(pexp4);
pexpMaintainService.insertOrUpdate(pexp5);
pexpMaintainService.insertOrUpdate(pexp6);
permissionMaintainService.insertOrUpdate(permission1);
permissionMaintainService.insertOrUpdate(permission2);
permissionMaintainService.insertOrUpdate(permission3);
permissionMaintainService.insertOrUpdate(permission4);
permissionMaintainService.insertOrUpdate(permission5);
permissionMaintainService.insertOrUpdate(permission6);
permissionMaintainService.insertOrUpdate(permission7);
permissionMaintainService.insertOrUpdate(permission8);
permissionMaintainService.insertOrUpdate(permission9);
List<StringIdKey> permissionKeys = permissionLookupService.lookupForUser(zhangSan.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertTrue(permissionKeys.contains(permission3.getKey()));
assertTrue(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertTrue(permissionKeys.contains(permission6.getKey()));
assertTrue(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
permissionKeys = permissionLookupService.lookupForUser(liSi.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertTrue(permissionKeys.contains(permission3.getKey()));
assertFalse(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertTrue(permissionKeys.contains(permission6.getKey()));
assertFalse(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
permissionKeys = permissionLookupService.lookupForUser(wangWu.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertTrue(permissionKeys.contains(permission3.getKey()));
assertFalse(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertTrue(permissionKeys.contains(permission6.getKey()));
assertFalse(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
// 重复一遍,分析命中缓存时的性能。
permissionKeys = permissionLookupService.lookupForUser(zhangSan.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertTrue(permissionKeys.contains(permission3.getKey()));
assertTrue(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertTrue(permissionKeys.contains(permission6.getKey()));
assertTrue(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
permissionKeys = permissionLookupService.lookupForUser(liSi.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertTrue(permissionKeys.contains(permission3.getKey()));
assertFalse(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertTrue(permissionKeys.contains(permission6.getKey()));
assertFalse(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
permissionKeys = permissionLookupService.lookupForUser(wangWu.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertTrue(permissionKeys.contains(permission3.getKey()));
assertFalse(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertTrue(permissionKeys.contains(permission6.getKey()));
assertFalse(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
} finally {
if (Objects.nonNull(zhangSan)) userMaintainService.deleteIfExists(zhangSan.getKey());
if (Objects.nonNull(liSi)) userMaintainService.deleteIfExists(liSi.getKey());
if (Objects.nonNull(wangWu)) userMaintainService.deleteIfExists(wangWu.getKey());
roleMaintainService.deleteIfExists(roleA.getKey());
roleMaintainService.deleteIfExists(roleB.getKey());
roleMaintainService.deleteIfExists(roleC.getKey());
pexpMaintainService.deleteIfExists(pexp1.getKey());
pexpMaintainService.deleteIfExists(pexp2.getKey());
pexpMaintainService.deleteIfExists(pexp3.getKey());
pexpMaintainService.deleteIfExists(pexp4.getKey());
pexpMaintainService.deleteIfExists(pexp5.getKey());
pexpMaintainService.deleteIfExists(pexp6.getKey());
permissionMaintainService.deleteIfExists(permission1.getKey());
permissionMaintainService.deleteIfExists(permission2.getKey());
permissionMaintainService.deleteIfExists(permission3.getKey());
permissionMaintainService.deleteIfExists(permission4.getKey());
permissionMaintainService.deleteIfExists(permission5.getKey());
permissionMaintainService.deleteIfExists(permission6.getKey());
permissionMaintainService.deleteIfExists(permission7.getKey());
permissionMaintainService.deleteIfExists(permission8.getKey());
permissionMaintainService.deleteIfExists(permission9.getKey());
}
}
@Test
public void testLookupForRole() throws Exception {
try {
roleMaintainService.insertOrUpdate(roleA);
roleMaintainService.insertOrUpdate(roleB);
roleMaintainService.insertOrUpdate(roleC);
pexpMaintainService.insertOrUpdate(pexp1);
pexpMaintainService.insertOrUpdate(pexp2);
pexpMaintainService.insertOrUpdate(pexp3);
pexpMaintainService.insertOrUpdate(pexp4);
pexpMaintainService.insertOrUpdate(pexp5);
pexpMaintainService.insertOrUpdate(pexp6);
permissionMaintainService.insertOrUpdate(permission1);
permissionMaintainService.insertOrUpdate(permission2);
permissionMaintainService.insertOrUpdate(permission3);
permissionMaintainService.insertOrUpdate(permission4);
permissionMaintainService.insertOrUpdate(permission5);
permissionMaintainService.insertOrUpdate(permission6);
permissionMaintainService.insertOrUpdate(permission7);
permissionMaintainService.insertOrUpdate(permission8);
permissionMaintainService.insertOrUpdate(permission9);
List<StringIdKey> permissionKeys = permissionLookupService.lookupForRole(roleA.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertFalse(permissionKeys.contains(permission3.getKey()));
assertTrue(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertFalse(permissionKeys.contains(permission6.getKey()));
assertTrue(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
permissionKeys = permissionLookupService.lookupForRole(roleB.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertFalse(permissionKeys.contains(permission3.getKey()));
assertFalse(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertFalse(permissionKeys.contains(permission6.getKey()));
assertFalse(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
permissionKeys = permissionLookupService.lookupForRole(roleC.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertTrue(permissionKeys.contains(permission3.getKey()));
assertFalse(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertTrue(permissionKeys.contains(permission6.getKey()));
assertFalse(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
// 重复一遍,分析命中缓存时的性能。
permissionKeys = permissionLookupService.lookupForRole(roleA.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertFalse(permissionKeys.contains(permission3.getKey()));
assertTrue(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertFalse(permissionKeys.contains(permission6.getKey()));
assertTrue(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
permissionKeys = permissionLookupService.lookupForRole(roleB.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertFalse(permissionKeys.contains(permission3.getKey()));
assertFalse(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertFalse(permissionKeys.contains(permission6.getKey()));
assertFalse(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
permissionKeys = permissionLookupService.lookupForRole(roleC.getKey())
.stream().map(Permission::getKey).collect(Collectors.toList());
assertFalse(permissionKeys.contains(permission1.getKey()));
assertFalse(permissionKeys.contains(permission2.getKey()));
assertTrue(permissionKeys.contains(permission3.getKey()));
assertFalse(permissionKeys.contains(permission4.getKey()));
assertFalse(permissionKeys.contains(permission5.getKey()));
assertTrue(permissionKeys.contains(permission6.getKey()));
assertFalse(permissionKeys.contains(permission7.getKey()));
assertFalse(permissionKeys.contains(permission8.getKey()));
assertFalse(permissionKeys.contains(permission9.getKey()));
} finally {
roleMaintainService.deleteIfExists(roleA.getKey());
roleMaintainService.deleteIfExists(roleB.getKey());
roleMaintainService.deleteIfExists(roleC.getKey());
pexpMaintainService.deleteIfExists(pexp1.getKey());
pexpMaintainService.deleteIfExists(pexp2.getKey());
pexpMaintainService.deleteIfExists(pexp3.getKey());
pexpMaintainService.deleteIfExists(pexp4.getKey());
pexpMaintainService.deleteIfExists(pexp5.getKey());
pexpMaintainService.deleteIfExists(pexp6.getKey());
permissionMaintainService.deleteIfExists(permission1.getKey());
permissionMaintainService.deleteIfExists(permission2.getKey());
permissionMaintainService.deleteIfExists(permission3.getKey());
permissionMaintainService.deleteIfExists(permission4.getKey());
permissionMaintainService.deleteIfExists(permission5.getKey());
permissionMaintainService.deleteIfExists(permission6.getKey());
permissionMaintainService.deleteIfExists(permission7.getKey());
permissionMaintainService.deleteIfExists(permission8.getKey());
permissionMaintainService.deleteIfExists(permission9.getKey());
}
}
}
|
3e1d8f5ff9e6cbc630cb858a5ba66166f79dbf43 | 699 | java | Java | Java/JUnitExamples/src/test/java/edu/bu/met/cs665/SimpleTest.java | SStepurko/MET-CS665 | bd425d73cd36e4e138ae23f4e8fa552f8ef24b11 | [
"Apache-2.0"
] | 80 | 2018-07-04T00:47:21.000Z | 2021-10-02T20:25:20.000Z | Java/JUnitExamples/src/test/java/edu/bu/met/cs665/SimpleTest.java | SStepurko/MET-CS665 | bd425d73cd36e4e138ae23f4e8fa552f8ef24b11 | [
"Apache-2.0"
] | 3 | 2018-07-30T01:22:50.000Z | 2020-07-29T18:57:17.000Z | Java/JUnitExamples/src/test/java/edu/bu/met/cs665/SimpleTest.java | SStepurko/MET-CS665 | bd425d73cd36e4e138ae23f4e8fa552f8ef24b11 | [
"Apache-2.0"
] | 43 | 2018-06-04T23:32:34.000Z | 2021-09-24T14:55:05.000Z | 20.558824 | 65 | 0.663805 | 12,531 | package edu.bu.met.cs665;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import edu.bu.met.cs665.example1.Order;
import edu.bu.met.cs665.example1.Product;
public class SimpleTest {
@Test
public void test() {
List<Product> products = new ArrayList<Product>();
// Generate 10 products.
for (int i = 0; i < 10; i++) {
Product product = new Product("Product-" + i, i, i + 1, i);
products.add(product);
}
Order testOrder = new Order();
testOrder.setProducts(products);
// These two values should be equal.
assertEquals(testOrder.calTotalPrice(), 55.0, 0.0001d);
}
}
|
3e1d902204de371d71c4536f1d9050ee67fb83f8 | 6,390 | java | Java | app/src/main/java/com/vv/uweather/activity/WeatherActivity.java | MMarking/UWeather | f49cc6f8c101c6a4720e3976ec80c6d59ec5c88a | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/vv/uweather/activity/WeatherActivity.java | MMarking/UWeather | f49cc6f8c101c6a4720e3976ec80c6d59ec5c88a | [
"Apache-2.0"
] | null | null | null | app/src/main/java/com/vv/uweather/activity/WeatherActivity.java | MMarking/UWeather | f49cc6f8c101c6a4720e3976ec80c6d59ec5c88a | [
"Apache-2.0"
] | null | null | null | 35.5 | 94 | 0.603599 | 12,532 | package com.vv.uweather.activity;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.vv.uweather.R;
import com.vv.uweather.service.AutoUpdateService;
import com.vv.uweather.util.HttpCallbackListener;
import com.vv.uweather.util.HttpUtil;
import com.vv.uweather.util.Utility;
public class WeatherActivity extends Activity implements View.OnClickListener {
private LinearLayout weatherInfoLayout;
private TextView cityNameText;
private TextView publishText;
private TextView weatherDespText;
private TextView temp1Text;
private TextView temp2Text;
private TextView currentDateText;
private Button switchCity;
private Button refreshWeather;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.weather_layout);
weatherInfoLayout = findViewById(R.id.weather_info_layout);
cityNameText = findViewById(R.id.city_name);
publishText = findViewById(R.id.publish_text);
weatherDespText = findViewById(R.id.weather_desp);
temp1Text = findViewById(R.id.temp1);
temp2Text = findViewById(R.id.temp2);
currentDateText = findViewById(R.id.current_date);
switchCity = findViewById(R.id.switch_city);
refreshWeather = findViewById(R.id.refresh_weather);
switchCity.setOnClickListener(this);
refreshWeather.setOnClickListener(this);
// 尝试从 Intent 中取出县级代号,如果可以取到就会调用 queryWeatherCode()方法,如果不能取到则会调用 showWeather()方法
String countyCode = getIntent().getStringExtra("county_code");
if (!TextUtils.isEmpty(countyCode)) {
// 有县级代号时候,就去查询天气
publishText.setText("同步中……");
weatherInfoLayout.setVisibility(View.INVISIBLE);
cityNameText.setVisibility(View.INVISIBLE);
queryWeatherCode(countyCode);
} else {
// 没有县级代号时候,就直接显示本地天气
showWeather();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.switch_city:
Intent intent = new Intent(this, ChooseAreaActivity.class);
intent.putExtra("from_weather_activity", true);
startActivity(intent);
finish();
break;
case R.id.refresh_weather:
publishText.setText("同步中……");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String weatherCode = prefs.getString("weather_code", "");
if (!TextUtils.isEmpty(weatherCode)) {
queryWeatherInfo(weatherCode);
}
break;
default:
break;
}
}
/**
* 查询县级代号所对应的天气代号
* @param countyCode
*/
private void queryWeatherCode(String countyCode) {
String address = "http://www.weather.com.cn/data/list3/city" + countyCode + ".xml";
queryFromServer(address, "countyCode");
}
/**
* 查询天气代号所对应的天气
* @param weatherCode
*/
private void queryWeatherInfo(String weatherCode) {
String address = "http://www.weather.com.cn/data/cityinfo/" + weatherCode + ".html";
queryFromServer(address, "weatherCode");
}
/**
* 根据传入的地址和类型去向服务器查询天气代号或者天气信息
* @param address
* @param type
*/
private void queryFromServer(final String address, final String type) {
HttpUtil.sendHttpRequest(address, new HttpCallbackListener() {
@Override
public void onFinish(final String response) {
if ("countyCode".equals(type)) {
if (!TextUtils.isEmpty(response)) {
// 从服务器返回的数据中解析出来天气代号
String[] array = response.split("\\|");
if (array != null && array.length == 2) {
String weatherCode = array[1];
queryWeatherInfo(weatherCode);
}
}
} else if ("weatherCode".equals(type)) {
// 处理服务器返回的天气信息
Utility.handleWeatherResponse(WeatherActivity.this, response);
runOnUiThread(new Runnable() {
@Override
public void run() {
showWeather();
}
});
}
}
@Override
public void onError(Exception e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
publishText.setText("同步失败");
}
});
}
});
}
/**
* 从 SharedPreferences 文件中读取存储的天气信息,并显示到界面上
*/
private void showWeather() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
cityNameText.setText(prefs.getString("city_name", ""));
temp1Text.setText(prefs.getString("temp1", ""));
temp2Text.setText(prefs.getString("temp2", ""));
weatherDespText.setText(prefs.getString("weather_desp", ""));
publishText.setText("今天" + prefs.getString("publish_time", "")+"发布");
currentDateText.setText(prefs.getString("current_date", ""));
weatherInfoLayout.setVisibility(View.VISIBLE);
cityNameText.setVisibility(View.VISIBLE);
// 激活更新天气的服务
Intent intent = new Intent(this, AutoUpdateService.class);
startService(intent);
}
/**
* TODO List
* 比如说以下功能是你可以考虑加入到酷欧天气中的。
* 1. 增加设置选项,让用户选择是否允许后台自动更新天气,以及设定更新的频率。
* 2. 优化软件界面,提供多套与天气对应的图片,让程序可以根据不同的天气自动切换背景图。
* 3. 允许选择多个城市,可以同时观察多个城市的天气信息,不用来回切换。
* 4. 提供更加完整的天气信息,包括未来几天的天气情况、风力指数、生活建议等。
* 4->data:view-source:http://www.weather.com.cn/data/zs/101180904.html
*
*/
}
|
3e1d905e727b0de8f9911e2a54a2eb43fab1a0bb | 819 | java | Java | dbflute-runtime/src/main/java/org/dbflute/helper/secretary/DateCompareCallback.java | dbflute/dbflute-core | 06eea8fdb4a2fe489b717d035bfb8f92c7e1c8c1 | [
"Apache-1.1"
] | 23 | 2016-01-22T06:56:17.000Z | 2022-03-13T23:20:27.000Z | dbflute-runtime/src/main/java/org/dbflute/helper/secretary/DateCompareCallback.java | dbflute/dbflute-core | 06eea8fdb4a2fe489b717d035bfb8f92c7e1c8c1 | [
"Apache-1.1"
] | 18 | 2015-03-04T07:48:13.000Z | 2020-12-30T10:12:16.000Z | dbflute-runtime/src/main/java/org/dbflute/helper/secretary/DateCompareCallback.java | dbflute/dbflute-core | 06eea8fdb4a2fe489b717d035bfb8f92c7e1c8c1 | [
"Apache-1.1"
] | 20 | 2015-03-04T01:04:44.000Z | 2020-02-09T06:42:45.000Z | 29.25 | 71 | 0.742369 | 12,533 | /*
* Copyright 2014-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package org.dbflute.helper.secretary;
import java.util.Date;
/**
* @author jflute
*/
@FunctionalInterface
public interface DateCompareCallback {
boolean isTarget(Date current, Date date);
}
|
3e1d9138298066e88ce2cc224f630029c32edb81 | 20,322 | java | Java | library/core/src/main/java/com/google/android/exoplayer2/Renderer.java | harismexis/ExoPlayer | 8430965723ab9afe511ad7f507f535076fa7f24d | [
"Apache-2.0"
] | 19,920 | 2015-01-02T16:05:01.000Z | 2022-03-31T16:18:05.000Z | library/core/src/main/java/com/google/android/exoplayer2/Renderer.java | harismexis/ExoPlayer | 8430965723ab9afe511ad7f507f535076fa7f24d | [
"Apache-2.0"
] | 9,682 | 2015-01-02T17:31:39.000Z | 2022-03-31T17:12:41.000Z | library/core/src/main/java/com/google/android/exoplayer2/Renderer.java | harismexis/ExoPlayer | 8430965723ab9afe511ad7f507f535076fa7f24d | [
"Apache-2.0"
] | 6,627 | 2015-01-01T12:47:35.000Z | 2022-03-31T16:18:09.000Z | 41.728953 | 100 | 0.71863 | 12,534 | /*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2;
import android.media.MediaCodec;
import android.view.Surface;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.PlayerMessage.Target;
import com.google.android.exoplayer2.audio.AuxEffectInfo;
import com.google.android.exoplayer2.source.SampleStream;
import com.google.android.exoplayer2.util.MediaClock;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer;
import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import java.io.IOException;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Renders media read from a {@link SampleStream}.
*
* <p>Internally, a renderer's lifecycle is managed by the owning {@link ExoPlayer}. The renderer is
* transitioned through various states as the overall playback state and enabled tracks change. The
* valid state transitions are shown below, annotated with the methods that are called during each
* transition.
*
* <p style="align:center"><img src="doc-files/renderer-states.svg" alt="Renderer state
* transitions">
*/
public interface Renderer extends PlayerMessage.Target {
/**
* Some renderers can signal when {@link #render(long, long)} should be called.
*
* <p>That allows the player to sleep until the next wakeup, instead of calling {@link
* #render(long, long)} in a tight loop. The aim of this interrupt based scheduling is to save
* power.
*/
interface WakeupListener {
/**
* The renderer no longer needs to render until the next wakeup.
*
* <p>Must be called from the thread ExoPlayer invokes the renderer from.
*
* @param wakeupDeadlineMs Maximum time in milliseconds until {@link #onWakeup()} will be
* called.
*/
void onSleep(long wakeupDeadlineMs);
/**
* The renderer needs to render some frames. The client should call {@link #render(long, long)}
* at its earliest convenience.
*
* <p>Can be called from any thread.
*/
void onWakeup();
}
/**
* The type of a message that can be passed to a video renderer via {@link
* ExoPlayer#createMessage(Target)}. The message payload is normally a {@link Surface}, however
* some video renderers may accept other outputs (e.g., {@link VideoDecoderOutputBufferRenderer}).
*
* <p>If the receiving renderer does not support the payload type as an output, then it will clear
* any existing output that it has.
*/
@SuppressWarnings("deprecation")
int MSG_SET_VIDEO_OUTPUT = C.MSG_SET_SURFACE;
/**
* A type of a message that can be passed to an audio renderer via {@link
* ExoPlayer#createMessage(Target)}. The message payload should be a {@link Float} with 0 being
* silence and 1 being unity gain.
*/
@SuppressWarnings("deprecation")
int MSG_SET_VOLUME = C.MSG_SET_VOLUME;
/**
* A type of a message that can be passed to an audio renderer via {@link
* ExoPlayer#createMessage(Target)}. The message payload should be an {@link
* com.google.android.exoplayer2.audio.AudioAttributes} instance that will configure the
* underlying audio track. If not set, the default audio attributes will be used. They are
* suitable for general media playback.
*
* <p>Setting the audio attributes during playback may introduce a short gap in audio output as
* the audio track is recreated. A new audio session id will also be generated.
*
* <p>If tunneling is enabled by the track selector, the specified audio attributes will be
* ignored, but they will take effect if audio is later played without tunneling.
*
* <p>If the device is running a build before platform API version 21, audio attributes cannot be
* set directly on the underlying audio track. In this case, the usage will be mapped onto an
* equivalent stream type using {@link Util#getStreamTypeForAudioUsage(int)}.
*
* <p>To get audio attributes that are equivalent to a legacy stream type, pass the stream type to
* {@link Util#getAudioUsageForStreamType(int)} and use the returned {@link C.AudioUsage} to build
* an audio attributes instance.
*/
@SuppressWarnings("deprecation")
int MSG_SET_AUDIO_ATTRIBUTES = C.MSG_SET_AUDIO_ATTRIBUTES;
/**
* The type of a message that can be passed to a {@link MediaCodec}-based video renderer via
* {@link ExoPlayer#createMessage(Target)}. The message payload should be one of the integer
* scaling modes in {@link C.VideoScalingMode}.
*
* <p>Note that the scaling mode only applies if the {@link Surface} targeted by the renderer is
* owned by a {@link android.view.SurfaceView}.
*/
@SuppressWarnings("deprecation")
int MSG_SET_SCALING_MODE = C.MSG_SET_SCALING_MODE;
/**
* A type of a message that can be passed to an audio renderer via {@link
* ExoPlayer#createMessage(Target)}. The message payload should be an {@link AuxEffectInfo}
* instance representing an auxiliary audio effect for the underlying audio track.
*/
@SuppressWarnings("deprecation")
int MSG_SET_AUX_EFFECT_INFO = C.MSG_SET_AUX_EFFECT_INFO;
/**
* The type of a message that can be passed to a video renderer via {@link
* ExoPlayer#createMessage(Target)}. The message payload should be a {@link
* VideoFrameMetadataListener} instance, or null.
*/
@SuppressWarnings("deprecation")
int MSG_SET_VIDEO_FRAME_METADATA_LISTENER = C.MSG_SET_VIDEO_FRAME_METADATA_LISTENER;
/**
* The type of a message that can be passed to a camera motion renderer via {@link
* ExoPlayer#createMessage(Target)}. The message payload should be a {@link CameraMotionListener}
* instance, or null.
*/
@SuppressWarnings("deprecation")
int MSG_SET_CAMERA_MOTION_LISTENER = C.MSG_SET_CAMERA_MOTION_LISTENER;
/**
* The type of a message that can be passed to an audio renderer via {@link
* ExoPlayer#createMessage(Target)}. The message payload should be a {@link Boolean} instance
* telling whether to enable or disable skipping silences in the audio stream.
*/
int MSG_SET_SKIP_SILENCE_ENABLED = 101;
/**
* The type of a message that can be passed to audio and video renderers via {@link
* ExoPlayer#createMessage(Target)}. The message payload should be an {@link Integer} instance
* representing the audio session ID that will be attached to the underlying audio track. Video
* renderers that support tunneling will use the audio session ID when tunneling is enabled.
*/
int MSG_SET_AUDIO_SESSION_ID = 102;
/**
* The type of a message that can be passed to a {@link Renderer} via {@link
* ExoPlayer#createMessage(Target)}, to inform the renderer that it can schedule waking up another
* component.
*
* <p>The message payload must be a {@link WakeupListener} instance.
*/
int MSG_SET_WAKEUP_LISTENER = 103;
/**
* Applications or extensions may define custom {@code MSG_*} constants that can be passed to
* renderers. These custom constants must be greater than or equal to this value.
*/
@SuppressWarnings("deprecation")
int MSG_CUSTOM_BASE = C.MSG_CUSTOM_BASE;
/** @deprecated Use {@link C.VideoScalingMode}. */
// VIDEO_SCALING_MODE_DEFAULT is an intentionally duplicated constant.
@SuppressWarnings({"UniqueConstants", "Deprecation"})
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef(
value = {
VIDEO_SCALING_MODE_DEFAULT,
VIDEO_SCALING_MODE_SCALE_TO_FIT,
VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING
})
@Deprecated
@interface VideoScalingMode {}
/** @deprecated Use {@link C#VIDEO_SCALING_MODE_SCALE_TO_FIT}. */
@Deprecated int VIDEO_SCALING_MODE_SCALE_TO_FIT = C.VIDEO_SCALING_MODE_SCALE_TO_FIT;
/** @deprecated Use {@link C#VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}. */
@Deprecated
int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING =
C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING;
/** @deprecated Use {@code C.VIDEO_SCALING_MODE_DEFAULT}. */
@Deprecated int VIDEO_SCALING_MODE_DEFAULT = C.VIDEO_SCALING_MODE_DEFAULT;
/**
* The renderer states. One of {@link #STATE_DISABLED}, {@link #STATE_ENABLED} or {@link
* #STATE_STARTED}.
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef({STATE_DISABLED, STATE_ENABLED, STATE_STARTED})
@interface State {}
/**
* The renderer is disabled. A renderer in this state will not proactively acquire resources that
* it requires for rendering (e.g., media decoders), but may continue to hold any that it already
* has. {@link #reset()} can be called to force the renderer to release such resources.
*/
int STATE_DISABLED = 0;
/**
* The renderer is enabled but not started. A renderer in this state may render media at the
* current position (e.g. an initial video frame), but the position will not advance. A renderer
* in this state will typically hold resources that it requires for rendering (e.g. media
* decoders).
*/
int STATE_ENABLED = 1;
/**
* The renderer is started. Calls to {@link #render(long, long)} will cause media to be rendered.
*/
int STATE_STARTED = 2;
/**
* Returns the name of this renderer, for logging and debugging purposes. Should typically be the
* renderer's (un-obfuscated) class name.
*
* @return The name of this renderer.
*/
String getName();
/**
* Returns the track type that the renderer handles.
*
* @see ExoPlayer#getRendererType(int)
* @return One of the {@code TRACK_TYPE_*} constants defined in {@link C}.
*/
int getTrackType();
/**
* Returns the capabilities of the renderer.
*
* @return The capabilities of the renderer.
*/
RendererCapabilities getCapabilities();
/**
* Sets the index of this renderer within the player.
*
* @param index The renderer index.
*/
void setIndex(int index);
/**
* If the renderer advances its own playback position then this method returns a corresponding
* {@link MediaClock}. If provided, the player will use the returned {@link MediaClock} as its
* source of time during playback. A player may have at most one renderer that returns a {@link
* MediaClock} from this method.
*
* @return The {@link MediaClock} tracking the playback position of the renderer, or null.
*/
@Nullable
MediaClock getMediaClock();
/**
* Returns the current state of the renderer.
*
* @return The current state. One of {@link #STATE_DISABLED}, {@link #STATE_ENABLED} and {@link
* #STATE_STARTED}.
*/
@State
int getState();
/**
* Enables the renderer to consume from the specified {@link SampleStream}.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_DISABLED}.
*
* @param configuration The renderer configuration.
* @param formats The enabled formats.
* @param stream The {@link SampleStream} from which the renderer should consume.
* @param positionUs The player's current position.
* @param joining Whether this renderer is being enabled to join an ongoing playback.
* @param mayRenderStartOfStream Whether this renderer is allowed to render the start of the
* stream even if the state is not {@link #STATE_STARTED} yet.
* @param startPositionUs The start position of the stream in renderer time (microseconds).
* @param offsetUs The offset to be added to timestamps of buffers read from {@code stream} before
* they are rendered.
* @throws ExoPlaybackException If an error occurs.
*/
void enable(
RendererConfiguration configuration,
Format[] formats,
SampleStream stream,
long positionUs,
boolean joining,
boolean mayRenderStartOfStream,
long startPositionUs,
long offsetUs)
throws ExoPlaybackException;
/**
* Starts the renderer, meaning that calls to {@link #render(long, long)} will cause media to be
* rendered.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}.
*
* @throws ExoPlaybackException If an error occurs.
*/
void start() throws ExoPlaybackException;
/**
* Replaces the {@link SampleStream} from which samples will be consumed.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*
* @param formats The enabled formats.
* @param stream The {@link SampleStream} from which the renderer should consume.
* @param startPositionUs The start position of the new stream in renderer time (microseconds).
* @param offsetUs The offset to be added to timestamps of buffers read from {@code stream} before
* they are rendered.
* @throws ExoPlaybackException If an error occurs.
*/
void replaceStream(Format[] formats, SampleStream stream, long startPositionUs, long offsetUs)
throws ExoPlaybackException;
/** Returns the {@link SampleStream} being consumed, or null if the renderer is disabled. */
@Nullable
SampleStream getStream();
/**
* Returns whether the renderer has read the current {@link SampleStream} to the end.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*/
boolean hasReadStreamToEnd();
/**
* Returns the renderer time up to which the renderer has read samples, in microseconds, or {@link
* C#TIME_END_OF_SOURCE} if the renderer has read the current {@link SampleStream} to the end.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*/
long getReadingPositionUs();
/**
* Signals to the renderer that the current {@link SampleStream} will be the final one supplied
* before it is next disabled or reset.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*/
void setCurrentStreamFinal();
/**
* Returns whether the current {@link SampleStream} will be the final one supplied before the
* renderer is next disabled or reset.
*/
boolean isCurrentStreamFinal();
/**
* Throws an error that's preventing the renderer from reading from its {@link SampleStream}. Does
* nothing if no such error exists.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*
* @throws IOException An error that's preventing the renderer from making progress or buffering
* more data.
*/
void maybeThrowStreamError() throws IOException;
/**
* Signals to the renderer that a position discontinuity has occurred.
*
* <p>After a position discontinuity, the renderer's {@link SampleStream} is guaranteed to provide
* samples starting from a key frame.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*
* @param positionUs The new playback position in microseconds.
* @throws ExoPlaybackException If an error occurs handling the reset.
*/
void resetPosition(long positionUs) throws ExoPlaybackException;
/**
* Indicates the playback speed to this renderer.
*
* <p>The default implementation is a no-op.
*
* @param currentPlaybackSpeed The factor by which playback is currently sped up.
* @param targetPlaybackSpeed The target factor by which playback should be sped up. This may be
* different from {@code currentPlaybackSpeed}, for example, if the speed is temporarily
* adjusted for live playback.
* @throws ExoPlaybackException If an error occurs handling the playback speed.
*/
default void setPlaybackSpeed(float currentPlaybackSpeed, float targetPlaybackSpeed)
throws ExoPlaybackException {}
/**
* Incrementally renders the {@link SampleStream}.
*
* <p>If the renderer is in the {@link #STATE_ENABLED} state then each call to this method will do
* work toward being ready to render the {@link SampleStream} when the renderer is started. If the
* renderer is in the {@link #STATE_STARTED} state then calls to this method will render the
* {@link SampleStream} in sync with the specified media positions.
*
* <p>The renderer may also render the very start of the media at the current position (e.g. the
* first frame of a video stream) while still in the {@link #STATE_ENABLED} state, unless it's the
* initial start of the media after calling {@link #enable(RendererConfiguration, Format[],
* SampleStream, long, boolean, boolean, long, long)} with {@code mayRenderStartOfStream} set to
* {@code false}.
*
* <p>This method should return quickly, and should not block if the renderer is unable to make
* useful progress.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*
* @param positionUs The current media time in microseconds, measured at the start of the current
* iteration of the rendering loop.
* @param elapsedRealtimeUs {@link android.os.SystemClock#elapsedRealtime()} in microseconds,
* measured at the start of the current iteration of the rendering loop.
* @throws ExoPlaybackException If an error occurs.
*/
void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException;
/**
* Whether the renderer is able to immediately render media from the current position.
*
* <p>If the renderer is in the {@link #STATE_STARTED} state then returning true indicates that
* the renderer has everything that it needs to continue playback. Returning false indicates that
* the player should pause until the renderer is ready.
*
* <p>If the renderer is in the {@link #STATE_ENABLED} state then returning true indicates that
* the renderer is ready for playback to be started. Returning false indicates that it is not.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*
* @return Whether the renderer is ready to render media.
*/
boolean isReady();
/**
* Whether the renderer is ready for the {@link ExoPlayer} instance to transition to {@link
* Player#STATE_ENDED}. The player will make this transition as soon as {@code true} is returned
* by all of its renderers.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*
* @return Whether the renderer is ready for the player to transition to the ended state.
*/
boolean isEnded();
/**
* Stops the renderer, transitioning it to the {@link #STATE_ENABLED} state.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_STARTED}.
*/
void stop();
/**
* Disable the renderer, transitioning it to the {@link #STATE_DISABLED} state.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}.
*/
void disable();
/**
* Forces the renderer to give up any resources (e.g. media decoders) that it may be holding. If
* the renderer is not holding any resources, the call is a no-op.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_DISABLED}.
*/
void reset();
}
|
3e1d919cfcdef827e33790bd657eaab183c2c883 | 1,418 | java | Java | app/src/main/java/com/ardiya/simpleweather/Helper/HttpDataHandler.java | DariusWong94/mhci_doublejey | f91766823dce76a2d6f6b5a04e7d862494ddd732 | [
"MIT"
] | null | null | null | app/src/main/java/com/ardiya/simpleweather/Helper/HttpDataHandler.java | DariusWong94/mhci_doublejey | f91766823dce76a2d6f6b5a04e7d862494ddd732 | [
"MIT"
] | null | null | null | app/src/main/java/com/ardiya/simpleweather/Helper/HttpDataHandler.java | DariusWong94/mhci_doublejey | f91766823dce76a2d6f6b5a04e7d862494ddd732 | [
"MIT"
] | null | null | null | 25.781818 | 89 | 0.595205 | 12,535 | package com.ardiya.simpleweather.Helper;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Created by reale on 2/28/2017.
*/
public class HttpDataHandler {
static String stream= null;
public HttpDataHandler() {
}
public String GetHTTPData(String urlString)
{
try{
URL url = new URL(urlString);
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
if(urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK)
{
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
BufferedReader r = new BufferedReader(new InputStreamReader(in));
StringBuilder sb = new StringBuilder();
String line;
while((line = r.readLine())!=null)
sb.append(line);
stream = sb.toString();
urlConnection.disconnect();
}
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally {
}
return stream;
}
}
|
3e1d92da6e869dbe460f7e35d3c6bbfb4f243823 | 18,894 | java | Java | protos/gen/main/java/org/tensorflow/metadata/v0/InfinityNorm.java | jakubhava/feast | 9d556bd78b1b61b1ac6aa2122c5579066ede90c6 | [
"Apache-2.0"
] | null | null | null | protos/gen/main/java/org/tensorflow/metadata/v0/InfinityNorm.java | jakubhava/feast | 9d556bd78b1b61b1ac6aa2122c5579066ede90c6 | [
"Apache-2.0"
] | null | null | null | protos/gen/main/java/org/tensorflow/metadata/v0/InfinityNorm.java | jakubhava/feast | 9d556bd78b1b61b1ac6aa2122c5579066ede90c6 | [
"Apache-2.0"
] | null | null | null | 33.739286 | 127 | 0.692707 | 12,536 | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: tensorflow_metadata/proto/v0/schema.proto
package org.tensorflow.metadata.v0;
/**
* <pre>
* Checks that the L-infinity norm is below a certain threshold between the
* two discrete distributions. Since this is applied to a FeatureNameStatistics,
* it only considers the top k.
* L_infty(p,q) = max_i |p_i-q_i|
* </pre>
*
* Protobuf type {@code tensorflow.metadata.v0.InfinityNorm}
*/
public final class InfinityNorm extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:tensorflow.metadata.v0.InfinityNorm)
InfinityNormOrBuilder {
private static final long serialVersionUID = 0L;
// Use InfinityNorm.newBuilder() to construct.
private InfinityNorm(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private InfinityNorm() {
}
@java.lang.Override
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(
UnusedPrivateParameter unused) {
return new InfinityNorm();
}
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private InfinityNorm(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new java.lang.NullPointerException();
}
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 9: {
bitField0_ |= 0x00000001;
threshold_ = input.readDouble();
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return org.tensorflow.metadata.v0.SchemaOuterClass.internal_static_tensorflow_metadata_v0_InfinityNorm_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return org.tensorflow.metadata.v0.SchemaOuterClass.internal_static_tensorflow_metadata_v0_InfinityNorm_fieldAccessorTable
.ensureFieldAccessorsInitialized(
org.tensorflow.metadata.v0.InfinityNorm.class, org.tensorflow.metadata.v0.InfinityNorm.Builder.class);
}
private int bitField0_;
public static final int THRESHOLD_FIELD_NUMBER = 1;
private double threshold_;
/**
* <pre>
* The InfinityNorm is in the interval [0.0, 1.0] so sensible bounds should
* be in the interval [0.0, 1.0).
* </pre>
*
* <code>optional double threshold = 1;</code>
* @return Whether the threshold field is set.
*/
@java.lang.Override
public boolean hasThreshold() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
* <pre>
* The InfinityNorm is in the interval [0.0, 1.0] so sensible bounds should
* be in the interval [0.0, 1.0).
* </pre>
*
* <code>optional double threshold = 1;</code>
* @return The threshold.
*/
@java.lang.Override
public double getThreshold() {
return threshold_;
}
private byte memoizedIsInitialized = -1;
@java.lang.Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@java.lang.Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (((bitField0_ & 0x00000001) != 0)) {
output.writeDouble(1, threshold_);
}
unknownFields.writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (((bitField0_ & 0x00000001) != 0)) {
size += com.google.protobuf.CodedOutputStream
.computeDoubleSize(1, threshold_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@java.lang.Override
public boolean equals(final java.lang.Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof org.tensorflow.metadata.v0.InfinityNorm)) {
return super.equals(obj);
}
org.tensorflow.metadata.v0.InfinityNorm other = (org.tensorflow.metadata.v0.InfinityNorm) obj;
if (hasThreshold() != other.hasThreshold()) return false;
if (hasThreshold()) {
if (java.lang.Double.doubleToLongBits(getThreshold())
!= java.lang.Double.doubleToLongBits(
other.getThreshold())) return false;
}
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@java.lang.Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
if (hasThreshold()) {
hash = (37 * hash) + THRESHOLD_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
java.lang.Double.doubleToLongBits(getThreshold()));
}
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static org.tensorflow.metadata.v0.InfinityNorm parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static org.tensorflow.metadata.v0.InfinityNorm parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@java.lang.Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(org.tensorflow.metadata.v0.InfinityNorm prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@java.lang.Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@java.lang.Override
protected Builder newBuilderForType(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* <pre>
* Checks that the L-infinity norm is below a certain threshold between the
* two discrete distributions. Since this is applied to a FeatureNameStatistics,
* it only considers the top k.
* L_infty(p,q) = max_i |p_i-q_i|
* </pre>
*
* Protobuf type {@code tensorflow.metadata.v0.InfinityNorm}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:tensorflow.metadata.v0.InfinityNorm)
org.tensorflow.metadata.v0.InfinityNormOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return org.tensorflow.metadata.v0.SchemaOuterClass.internal_static_tensorflow_metadata_v0_InfinityNorm_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return org.tensorflow.metadata.v0.SchemaOuterClass.internal_static_tensorflow_metadata_v0_InfinityNorm_fieldAccessorTable
.ensureFieldAccessorsInitialized(
org.tensorflow.metadata.v0.InfinityNorm.class, org.tensorflow.metadata.v0.InfinityNorm.Builder.class);
}
// Construct using org.tensorflow.metadata.v0.InfinityNorm.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
@java.lang.Override
public Builder clear() {
super.clear();
threshold_ = 0D;
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return org.tensorflow.metadata.v0.SchemaOuterClass.internal_static_tensorflow_metadata_v0_InfinityNorm_descriptor;
}
@java.lang.Override
public org.tensorflow.metadata.v0.InfinityNorm getDefaultInstanceForType() {
return org.tensorflow.metadata.v0.InfinityNorm.getDefaultInstance();
}
@java.lang.Override
public org.tensorflow.metadata.v0.InfinityNorm build() {
org.tensorflow.metadata.v0.InfinityNorm result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public org.tensorflow.metadata.v0.InfinityNorm buildPartial() {
org.tensorflow.metadata.v0.InfinityNorm result = new org.tensorflow.metadata.v0.InfinityNorm(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) != 0)) {
result.threshold_ = threshold_;
to_bitField0_ |= 0x00000001;
}
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
}
@java.lang.Override
public Builder clone() {
return super.clone();
}
@java.lang.Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.setField(field, value);
}
@java.lang.Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@java.lang.Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@java.lang.Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, java.lang.Object value) {
return super.setRepeatedField(field, index, value);
}
@java.lang.Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.addRepeatedField(field, value);
}
@java.lang.Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof org.tensorflow.metadata.v0.InfinityNorm) {
return mergeFrom((org.tensorflow.metadata.v0.InfinityNorm)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(org.tensorflow.metadata.v0.InfinityNorm other) {
if (other == org.tensorflow.metadata.v0.InfinityNorm.getDefaultInstance()) return this;
if (other.hasThreshold()) {
setThreshold(other.getThreshold());
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@java.lang.Override
public final boolean isInitialized() {
return true;
}
@java.lang.Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
org.tensorflow.metadata.v0.InfinityNorm parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (org.tensorflow.metadata.v0.InfinityNorm) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private int bitField0_;
private double threshold_ ;
/**
* <pre>
* The InfinityNorm is in the interval [0.0, 1.0] so sensible bounds should
* be in the interval [0.0, 1.0).
* </pre>
*
* <code>optional double threshold = 1;</code>
* @return Whether the threshold field is set.
*/
@java.lang.Override
public boolean hasThreshold() {
return ((bitField0_ & 0x00000001) != 0);
}
/**
* <pre>
* The InfinityNorm is in the interval [0.0, 1.0] so sensible bounds should
* be in the interval [0.0, 1.0).
* </pre>
*
* <code>optional double threshold = 1;</code>
* @return The threshold.
*/
@java.lang.Override
public double getThreshold() {
return threshold_;
}
/**
* <pre>
* The InfinityNorm is in the interval [0.0, 1.0] so sensible bounds should
* be in the interval [0.0, 1.0).
* </pre>
*
* <code>optional double threshold = 1;</code>
* @param value The threshold to set.
* @return This builder for chaining.
*/
public Builder setThreshold(double value) {
bitField0_ |= 0x00000001;
threshold_ = value;
onChanged();
return this;
}
/**
* <pre>
* The InfinityNorm is in the interval [0.0, 1.0] so sensible bounds should
* be in the interval [0.0, 1.0).
* </pre>
*
* <code>optional double threshold = 1;</code>
* @return This builder for chaining.
*/
public Builder clearThreshold() {
bitField0_ = (bitField0_ & ~0x00000001);
threshold_ = 0D;
onChanged();
return this;
}
@java.lang.Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@java.lang.Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:tensorflow.metadata.v0.InfinityNorm)
}
// @@protoc_insertion_point(class_scope:tensorflow.metadata.v0.InfinityNorm)
private static final org.tensorflow.metadata.v0.InfinityNorm DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new org.tensorflow.metadata.v0.InfinityNorm();
}
public static org.tensorflow.metadata.v0.InfinityNorm getDefaultInstance() {
return DEFAULT_INSTANCE;
}
@java.lang.Deprecated public static final com.google.protobuf.Parser<InfinityNorm>
PARSER = new com.google.protobuf.AbstractParser<InfinityNorm>() {
@java.lang.Override
public InfinityNorm parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new InfinityNorm(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<InfinityNorm> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<InfinityNorm> getParserForType() {
return PARSER;
}
@java.lang.Override
public org.tensorflow.metadata.v0.InfinityNorm getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
|
3e1d939b6d565d2b835848f574fa9daa917d2d1f | 312 | java | Java | chapter_005/src/main/java/ru/job4j/h3list/t3simplestackandqueue/SimpleStack.java | Ravmouse/vvasilyev | 2e38c7131326e96afff7271c8eab773d25c9ce64 | [
"Apache-2.0"
] | null | null | null | chapter_005/src/main/java/ru/job4j/h3list/t3simplestackandqueue/SimpleStack.java | Ravmouse/vvasilyev | 2e38c7131326e96afff7271c8eab773d25c9ce64 | [
"Apache-2.0"
] | 2 | 2022-02-16T00:55:36.000Z | 2022-02-16T00:56:04.000Z | chapter_005/src/main/java/ru/job4j/h3list/t3simplestackandqueue/SimpleStack.java | Ravmouse/vvasilyev | 2e38c7131326e96afff7271c8eab773d25c9ce64 | [
"Apache-2.0"
] | null | null | null | 22.285714 | 55 | 0.634615 | 12,537 | package ru.job4j.h3list.t3simplestackandqueue;
/**
* @param <E> is the name of type parameter.
*/
public class SimpleStack<E> extends SimpleAbstract<E> {
/**
* @param value to be pushed in the stack.
*/
@Override
public void push(E value) {
getLinkList().addFirst(value);
}
} |
3e1d93e14f982c7a699d6addf1dd56a3ee70f35e | 2,421 | java | Java | src/main/java/collections/NoCategoryYet/FMSketch.java | BookerLoL/JLibrary | 1e29ba1bd62c37d8808e62582a2e233deb3d6619 | [
"MIT"
] | 3 | 2020-10-17T18:53:25.000Z | 2021-03-28T00:35:44.000Z | src/main/java/collections/NoCategoryYet/FMSketch.java | BookerLoL/JLibrary | 1e29ba1bd62c37d8808e62582a2e233deb3d6619 | [
"MIT"
] | null | null | null | src/main/java/collections/NoCategoryYet/FMSketch.java | BookerLoL/JLibrary | 1e29ba1bd62c37d8808e62582a2e233deb3d6619 | [
"MIT"
] | null | null | null | 23.057143 | 93 | 0.670384 | 12,538 | package main.collections.NoCategoryYet;
import java.util.Arrays;
import java.util.Collection;
//Also known as a Simple Counter
public class FMSketch<T> {
public interface Hasher<T> {
long hash(T obj);
}
private int[] bits;
private Hasher<T> hasher;
public FMSketch(Hasher<T> hasher) {
this(32, hasher); // 32 for long
}
private FMSketch(int numBits, Hasher<T> hasher) {
bits = new int[numBits];
this.hasher = hasher;
}
private static int rank(long hashcode) {
return findLeftmostOneBit(addPadding(Long.toBinaryString(hashcode)));
}
private static String addPadding(String binaryRepresentation) {
return "0".repeat(32 - binaryRepresentation.length()) + binaryRepresentation;
}
private static int findLeftmostOneBit(String binaryStr) {
return binaryStr.indexOf('1');
}
private int findLeftmostZeroBit() {
for (int i = 0; i < bits.length; i++) {
if (bits[i] == 0) {
return i;
}
}
return 32;
}
public void add(T object) {
String bitStr = addPadding(Long.toBinaryString(hasher.hash(object)));
int rank = findLeftmostOneBit(bitStr);
if (rank == -1) { // zero case
rank = bits.length - 1;
}
if (bits[rank] == 0) {
bits[rank] = 1;
}
}
public void add(T object, long value) {
int rank = rank(value);
System.out.println(rank);
if (rank == -1) { // zero case
rank = bits.length - 1;
}
if (bits[rank] == 0) {
bits[rank] = 1;
}
}
public double cardinality() {
return (1 / 0.77351) * Math.pow(2, findLeftmostZeroBit());
}
// Assert that they use the same hash function
// There are corrected formulas such as Bjorn Scheurermann 2007
public static <T> double pcsaCardinality(Collection<T> dataset, FMSketch<T>... counters) {
Hasher<T> hasher = counters[0].hasher;
int totalCounters = counters.length;
for (T data : dataset) {
int counterIndex = (int) hasher.hash(data) % totalCounters;
int boundedHash = (int) hasher.hash(data) / totalCounters;
int rank = rank(boundedHash);
if (counters[counterIndex].bits[rank] == 0) {
counters[counterIndex].bits[rank] = 1;
}
}
int leftMostZeroSum = 0;
for (FMSketch<T> counter : counters) {
leftMostZeroSum += counter.findLeftmostZeroBit();
}
return (totalCounters / 0.77351) * Math.pow(2, (leftMostZeroSum) / (double) totalCounters);
}
public int[] getBits() {
return bits;
}
public String toString() {
return Arrays.toString(bits);
}
}
|
3e1d93e8f282bb5c5acbdf20fb6885414fbea108 | 210 | java | Java | documentation/src/main/asciidoc/topics/code_examples/InfinispanContainer.java | clara0/infinispan | f2cb717bbd51dd8e3e4265679585cd637a55bed5 | [
"Apache-2.0"
] | 713 | 2015-01-06T02:14:17.000Z | 2022-03-29T10:22:07.000Z | documentation/src/main/asciidoc/topics/code_examples/InfinispanContainer.java | clara0/infinispan | f2cb717bbd51dd8e3e4265679585cd637a55bed5 | [
"Apache-2.0"
] | 5,732 | 2015-01-01T19:13:35.000Z | 2022-03-31T16:31:11.000Z | documentation/src/main/asciidoc/topics/code_examples/InfinispanContainer.java | clara0/infinispan | f2cb717bbd51dd8e3e4265679585cd637a55bed5 | [
"Apache-2.0"
] | 402 | 2015-01-05T23:23:42.000Z | 2022-03-25T08:14:32.000Z | 30 | 78 | 0.733333 | 12,539 | try (InfinispanContainer container = new InfinispanContainer()) {
container.start();
try (RemoteCacheManager cacheManager = container.getRemoteCacheManager()) {
// Use the RemoteCacheManager
}
}
|
3e1d9492dc1c75e829a9eedb5deb7e549f1c36cd | 1,535 | java | Java | engine/src/main/java/de/hpi/des/hdes/engine/window/assigner/TumblingWindow.java | hpides/zeus | a8143ae2a7dea6b9ede36a87c32f1be91804113f | [
"MIT"
] | null | null | null | engine/src/main/java/de/hpi/des/hdes/engine/window/assigner/TumblingWindow.java | hpides/zeus | a8143ae2a7dea6b9ede36a87c32f1be91804113f | [
"MIT"
] | null | null | null | engine/src/main/java/de/hpi/des/hdes/engine/window/assigner/TumblingWindow.java | hpides/zeus | a8143ae2a7dea6b9ede36a87c32f1be91804113f | [
"MIT"
] | null | null | null | 26.016949 | 80 | 0.732248 | 12,540 | package de.hpi.des.hdes.engine.window.assigner;
import de.hpi.des.hdes.engine.window.Time;
import de.hpi.des.hdes.engine.window.TimeWindow;
import java.util.List;
public abstract class TumblingWindow implements WindowAssigner<TimeWindow> {
private final long size;
protected TumblingWindow(final long size) {
this.size = size;
}
protected List<TimeWindow> calculateWindow(final long current) {
final long windowStart = current - (current + this.size) % this.size;
return List.of(new TimeWindow(windowStart, windowStart + this.size));
}
/**
* Factory method for TumblingProcessingTimeWindow
*
* @see TumblingProcessingTimeWindow
*/
public static TumblingProcessingTimeWindow ofProcessingTime(final Time time) {
return new TumblingProcessingTimeWindow(time.getNanos());
}
/**
* Factory method for TumblingEventTimeWindow
*
* @see TumblingEventTimeWindow
*/
public static TumblingEventTimeWindow ofEventTime(final long time) {
return new TumblingEventTimeWindow(time);
}
/**
* Factory method for TumblingEventTimeWindow
*
* @see TumblingEventTimeWindow
*/
public static TumblingEventTimeWindow ofEventTime(final Time time) {
return new TumblingEventTimeWindow(time.getNanos());
}
@Override
public long nextWindowStart(final long watermark) {
final long windowStart = watermark - (watermark + this.size) % this.size;
return windowStart - this.size;
}
@Override
public long maximumSliceSize() {
return this.size;
}
}
|
3e1d96721534ceacbce1e36f37cebd99a008f5e5 | 3,345 | java | Java | javar/jdk8-analysis/src/sun/rmi/server/ActivationGroupInit.java | vitahlin/kennen | b0de36d3b6e766b59291d885a0699b6be59318a7 | [
"MIT"
] | 12 | 2018-04-04T12:47:40.000Z | 2022-01-02T04:36:38.000Z | jdk/src/main/java/sun/rmi/server/ActivationGroupInit.java | dibt/spring-framework | ce2dfa68e2331a07d36bdcf7aa92597c91a391ee | [
"Apache-2.0"
] | 2 | 2020-07-19T08:29:50.000Z | 2020-07-21T01:20:56.000Z | jdk/src/main/java/sun/rmi/server/ActivationGroupInit.java | dibt/spring-framework | ce2dfa68e2331a07d36bdcf7aa92597c91a391ee | [
"Apache-2.0"
] | 1 | 2020-11-04T07:02:06.000Z | 2020-11-04T07:02:06.000Z | 38.895349 | 79 | 0.681315 | 12,541 | /*
* Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.rmi.server;
import java.rmi.activation.ActivationGroupDesc;
import java.rmi.activation.ActivationGroupID;
import java.rmi.activation.ActivationGroup;
/**
* This is the bootstrap code to start a VM executing an activation
* group.
*
* The activator spawns (as a child process) an activation group as needed
* and directs activation requests to the appropriate activation
* group. After spawning the VM, the activator passes some
* information to the bootstrap code via its stdin: <p>
* <ul>
* <li> the activation group's id,
* <li> the activation group's descriptor (an instance of the class
* java.rmi.activation.ActivationGroupDesc) for the group, adn
* <li> the group's incarnation number.
* </ul><p>
*
* When the bootstrap VM starts executing, it reads group id and
* descriptor from its stdin so that it can create the activation
* group for the VM.
*
* @author Ann Wollrath
*/
public abstract class ActivationGroupInit
{
/**
* Main program to start a VM for an activation group.
*/
public static void main(String args[])
{
try {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
// read group id, descriptor, and incarnation number from stdin
MarshalInputStream in = new MarshalInputStream(System.in);
ActivationGroupID id = (ActivationGroupID)in.readObject();
ActivationGroupDesc desc = (ActivationGroupDesc)in.readObject();
long incarnation = in.readLong();
// create and set group for the VM
ActivationGroup.createGroup(id, desc, incarnation);
} catch (Exception e) {
System.err.println("Exception in starting ActivationGroupInit:");
e.printStackTrace();
} finally {
try {
System.in.close();
// note: system out/err shouldn't be closed
// since the parent may want to read them.
} catch (Exception ex) {
// ignore exceptions
}
}
}
}
|
3e1d982fd7a2d8e36a1420bf3d6e8e0fa54a55fd | 2,704 | java | Java | pro-admin/src/main/java/senntyou/sbs/admin/controller/AdminPermissionController.java | senntyou/spring-boot-starter | d760b9daf965bfacb7e8d9358e1b6cd6269b6268 | [
"MIT"
] | 4 | 2020-05-09T07:04:39.000Z | 2021-05-19T11:00:55.000Z | pro-admin/src/main/java/senntyou/sbs/admin/controller/AdminPermissionController.java | senntyou/spring-boot-starter | d760b9daf965bfacb7e8d9358e1b6cd6269b6268 | [
"MIT"
] | null | null | null | pro-admin/src/main/java/senntyou/sbs/admin/controller/AdminPermissionController.java | senntyou/spring-boot-starter | d760b9daf965bfacb7e8d9358e1b6cd6269b6268 | [
"MIT"
] | 1 | 2020-11-11T16:00:15.000Z | 2020-11-11T16:00:15.000Z | 36.053333 | 94 | 0.768121 | 12,542 | package senntyou.sbs.admin.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import senntyou.sbs.admin.dto.AdminPermissionNode;
import senntyou.sbs.admin.service.AdminPermissionService;
import senntyou.sbs.common.CommonResult;
import senntyou.sbs.mbg.model.AdminPermission;
/** 后台用户权限管理 */
@Controller
@Api(tags = "AdminPermissionController", description = "后台用户权限管理")
@RequestMapping("/adminPermission")
public class AdminPermissionController {
@Autowired private AdminPermissionService permissionService;
@ApiOperation("添加权限")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody AdminPermission permission) {
int count = permissionService.create(permission);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改权限")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody AdminPermission permission) {
int count = permissionService.update(id, permission);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("根据id批量删除权限")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = permissionService.delete(ids);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("以层级结构返回所有权限")
@RequestMapping(value = "/treeList", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<AdminPermissionNode>> treeList() {
List<AdminPermissionNode> permissionNodeList = permissionService.treeList();
return CommonResult.success(permissionNodeList);
}
@ApiOperation("获取所有权限列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<AdminPermission>> list() {
List<AdminPermission> permissionList = permissionService.list();
return CommonResult.success(permissionList);
}
}
|
3e1d98aa81edeb4b6cebac31476a7dfcb06dc5aa | 6,121 | java | Java | spock-core/src/main/java/org/spockframework/util/TeePrintStream.java | sencrest/SpockFrame | 5b48fa811002703a9ec0216bbb4259cefd5bb003 | [
"Apache-2.0"
] | 2,863 | 2015-01-02T07:08:15.000Z | 2022-03-31T16:38:09.000Z | spock-core/src/main/java/org/spockframework/util/TeePrintStream.java | i32jiprd/spock | d222bd2f805ed93369a9acde8b1c75bc69377d76 | [
"Apache-2.0"
] | 989 | 2015-01-12T20:20:15.000Z | 2022-03-29T10:19:25.000Z | spock-core/src/main/java/org/spockframework/util/TeePrintStream.java | i32jiprd/spock | d222bd2f805ed93369a9acde8b1c75bc69377d76 | [
"Apache-2.0"
] | 465 | 2015-01-22T22:55:53.000Z | 2022-03-27T06:39:23.000Z | 20.609428 | 75 | 0.634373 | 12,543 | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.spockframework.util;
import org.spockframework.runtime.GroovyRuntimeUtil;
import java.io.*;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import groovy.lang.MissingMethodException;
@ThreadSafe
public class TeePrintStream extends PrintStream {
private final List<PrintStream> delegates;
public TeePrintStream(PrintStream... delegates) {
this(Arrays.asList(delegates));
}
public TeePrintStream(List<PrintStream> delegates) {
super(new ByteArrayOutputStream(0));
this.delegates = new CopyOnWriteArrayList<>(delegates);
}
public List<PrintStream> getDelegates() {
return delegates;
}
public void stopDelegation() {
delegates.clear();
}
@Override
public void flush() {
for (PrintStream stream : delegates) {
stream.flush();
}
}
@Override
public void close() {
for (PrintStream stream : delegates) {
stream.close();
}
}
@Override
public boolean checkError() {
for (PrintStream stream : delegates) {
if (stream.checkError()) return true;
}
return false;
}
@Override
protected void setError() {
throw new UnsupportedOperationException("setError");
}
@Override
protected void clearError() {
for (PrintStream stream : delegates) {
try {
GroovyRuntimeUtil.invokeMethod(stream, "clearError");
} catch (MissingMethodException e) {
// method doesn't exist in JDK 1.5
if (!"clearError".equals(e.getMethod())) {
throw e;
}
}
}
}
@Override
public void write(int b) {
for (PrintStream stream : delegates) {
stream.write(b);
}
}
@Override
public void write(byte[] buf, int off, int len) {
for (PrintStream stream : delegates) {
stream.write(buf, off, len);
}
}
@Override
public void print(boolean b) {
for (PrintStream stream : delegates) {
stream.print(b);
}
}
@Override
public void print(char c) {
for (PrintStream stream : delegates) {
stream.print(c);
}
}
@Override
public void print(int i) {
for (PrintStream stream : delegates) {
stream.print(i);
}
}
@Override
public void print(long l) {
for (PrintStream stream : delegates) {
stream.print(l);
}
}
@Override
public void print(float f) {
for (PrintStream stream : delegates) {
stream.print(f);
}
}
@Override
public void print(double d) {
for (PrintStream stream : delegates) {
stream.print(d);
}
}
@Override
public void print(char[] s) {
for (PrintStream stream : delegates) {
stream.print(s);
}
}
@Override
public void print(String s) {
for (PrintStream stream : delegates) {
stream.print(s);
}
}
@Override
public void print(Object obj) {
for (PrintStream stream : delegates) {
stream.print(obj);
}
}
@Override
public void println() {
for (PrintStream stream : delegates) {
stream.println();
}
}
@Override
public void println(boolean x) {
for (PrintStream stream : delegates) {
stream.println(x);
}
}
@Override
public void println(char x) {
for (PrintStream stream : delegates) {
stream.println(x);
}
}
@Override
public void println(int x) {
for (PrintStream stream : delegates) {
stream.println(x);
}
}
@Override
public void println(long x) {
for (PrintStream stream : delegates) {
stream.println(x);
}
}
@Override
public void println(float x) {
for (PrintStream stream : delegates) {
stream.println(x);
}
}
@Override
public void println(double x) {
for (PrintStream stream : delegates) {
stream.println(x);
}
}
@Override
public void println(char[] x) {
for (PrintStream stream : delegates) {
stream.println(x);
}
}
@Override
public void println(String x) {
for (PrintStream stream : delegates) {
stream.println(x);
}
}
@Override
public void println(Object x) {
for (PrintStream stream : delegates) {
stream.println(x);
}
}
@Override
public PrintStream printf(String format, Object... args) {
for (PrintStream stream : delegates) {
stream.printf(format, args);
}
return this;
}
@Override
public PrintStream printf(Locale l, String format, Object... args) {
for (PrintStream stream : delegates) {
stream.printf(l, format, args);
}
return this;
}
@Override
public PrintStream format(String format, Object... args) {
for (PrintStream stream : delegates) {
stream.printf(format, args);
}
return this;
}
@Override
public PrintStream format(Locale l, String format, Object... args) {
for (PrintStream stream : delegates) {
stream.printf(format, args);
}
return this;
}
@Override
public PrintStream append(CharSequence csq) {
for (PrintStream stream : delegates) {
stream.append(csq);
}
return this;
}
@Override
public PrintStream append(CharSequence csq, int start, int end) {
for (PrintStream stream : delegates) {
stream.append(csq, start, end);
}
return this;
}
@Override
public PrintStream append(char c) {
for (PrintStream stream : delegates) {
stream.append(c);
}
return this;
}
@Override
public void write(byte[] b) throws IOException {
for (PrintStream stream : delegates) {
stream.write(b);
}
}
}
|
3e1d99433aed070cb9d7fbfa64dd147f894fa8ab | 186 | java | Java | src/main/java/org/opencds/cqf/cds/exceptions/InvalidHookException.java | maxsibilla/org-opencds-cqf-cds | 116c48acdf29dc17a002e3d2cb7ef510e7c35ee7 | [
"Apache-2.0"
] | 3 | 2021-02-22T18:27:46.000Z | 2021-10-01T08:00:20.000Z | src/main/java/org/opencds/cqf/cds/exceptions/InvalidHookException.java | maxsibilla/org-opencds-cqf-cds | 116c48acdf29dc17a002e3d2cb7ef510e7c35ee7 | [
"Apache-2.0"
] | 14 | 2020-02-26T19:34:12.000Z | 2022-02-09T16:08:25.000Z | src/main/java/org/opencds/cqf/cds/exceptions/InvalidHookException.java | maxsibilla/org-opencds-cqf-cds | 116c48acdf29dc17a002e3d2cb7ef510e7c35ee7 | [
"Apache-2.0"
] | 2 | 2020-04-27T15:17:10.000Z | 2020-11-10T19:50:26.000Z | 18.6 | 60 | 0.741935 | 12,544 | package org.opencds.cqf.cds.exceptions;
public class InvalidHookException extends RuntimeException {
public InvalidHookException(String message) {
super(message);
}
}
|
3e1d994cc81cbea12ad93a40a86849b012e8f4f7 | 2,174 | java | Java | hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRegionReplicasGet.java | unozawah/hbase | 00075ea4fc0ca13a763a1acf8bcb52b7f168018a | [
"Apache-2.0"
] | 4,857 | 2015-01-02T11:45:14.000Z | 2022-03-31T14:00:55.000Z | hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRegionReplicasGet.java | unozawah/hbase | 00075ea4fc0ca13a763a1acf8bcb52b7f168018a | [
"Apache-2.0"
] | 4,070 | 2015-05-01T02:52:57.000Z | 2022-03-31T23:54:50.000Z | hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncTableRegionReplicasGet.java | unozawah/hbase | 00075ea4fc0ca13a763a1acf8bcb52b7f168018a | [
"Apache-2.0"
] | 3,611 | 2015-01-02T11:33:55.000Z | 2022-03-31T11:12:19.000Z | 38.821429 | 95 | 0.774609 | 12,545 | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.client;
import static org.junit.Assert.assertArrayEquals;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
@Category({ MediumTests.class, ClientTests.class })
public class TestAsyncTableRegionReplicasGet extends AbstractTestAsyncTableRegionReplicasRead {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestAsyncTableRegionReplicasGet.class);
@BeforeClass
public static void setUpBeforeClass() throws Exception {
startClusterAndCreateTable();
AsyncTable<?> table = ASYNC_CONN.getTable(TABLE_NAME);
table.put(new Put(ROW).addColumn(FAMILY, QUALIFIER, VALUE)).get();
waitUntilAllReplicasHaveRow(ROW);
}
@Override
protected void readAndCheck(AsyncTable<?> table, int replicaId) throws Exception {
Get get = new Get(ROW).setConsistency(Consistency.TIMELINE);
if (replicaId >= 0) {
get.setReplicaId(replicaId);
}
assertArrayEquals(VALUE, table.get(get).get().getValue(FAMILY, QUALIFIER));
}
}
|
3e1d9b84110cd6c61b0d9033211a57c9a483543c | 4,452 | java | Java | wasd-http/src/main/java/com/spotify/wasd/service/ServiceResource.java | spotify/wasd | d5f8b1aff6413df7180ad8c1dca28b41744ce389 | [
"ISC"
] | 3 | 2015-07-13T13:07:14.000Z | 2017-08-09T03:32:35.000Z | wasd-http/src/main/java/com/spotify/wasd/service/ServiceResource.java | spotify/wasd | d5f8b1aff6413df7180ad8c1dca28b41744ce389 | [
"ISC"
] | null | null | null | wasd-http/src/main/java/com/spotify/wasd/service/ServiceResource.java | spotify/wasd | d5f8b1aff6413df7180ad8c1dca28b41744ce389 | [
"ISC"
] | 4 | 2015-06-24T17:15:44.000Z | 2022-03-19T16:22:10.000Z | 31.8 | 108 | 0.646226 | 12,546 | package com.spotify.wasd.service;
import com.spotify.wasd.db.*;
import com.sun.jersey.api.NotFoundException;
import java.util.HashSet;
import lombok.extern.slf4j.Slf4j;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.Map;
import java.util.Set;
@SuppressWarnings("UnusedDeclaration")
@Slf4j
@Path("/services")
public class ServiceResource {
private final DatabaseHolder holder;
public ServiceResource(DatabaseHolder holder) {
this.holder = holder;
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public JSONArray getServices() {
final JSONArray res = new JSONArray();
for (Service srv : holder.current().getServices().getServiceSet())
res.add(srv.getName());
return res;
}
@GET
@Path("/{name}")
@Produces(MediaType.APPLICATION_JSON)
public JSONArray getService(@PathParam("name") String name) {
final Service service = holder.current().getServices().getNameServiceMap().get(name);
if (service == null)
throw new NotFoundException("No such service");
final JSONArray res = new JSONArray();
for (Host host : service.getHostSet())
res.add(host.getReverseName());
return res;
}
@GET
@Path("/{name}/by_site")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getServiceForSite(@PathParam("name") String name) {
final Database current = holder.current();
final Service service = current.getServices().getNameServiceMap().get(name);
if (service == null)
throw new NotFoundException("No such service");
final Map<Site, Set<Host>> hostSetBySite = service.getHostSetBySite();
final JSONObject res = new JSONObject();
for (Map.Entry<Site, Set<Host>> entry : hostSetBySite.entrySet()) {
final JSONArray siteArray = new JSONArray();
for (Host host : entry.getValue())
siteArray.add(host.getReverseName());
res.put(entry.getKey().getName(), siteArray);
}
return res;
}
@GET
@Path("/{name}/for/{site}")
@Produces(MediaType.APPLICATION_JSON)
public JSONArray getServiceForSite(@PathParam("name") String name, @PathParam("site") String siteName) {
final Database current = holder.current();
final Service service = current.getServices().getNameServiceMap().get(name);
final Site site = current.getSites().getAliasSiteMap().get(siteName);
if (service == null)
throw new NotFoundException("No such service");
if (site == null)
throw new NotFoundException("No such site");
final JSONArray res = new JSONArray();
for (Host host : service.getHostSetForSite(site))
res.add(host.getReverseName());
return res;
}
@GET
@Path("/{name}/in/{site}")
@Produces(MediaType.APPLICATION_JSON)
public JSONArray getServiceInSite(@PathParam("name") String name, @PathParam("site") String siteName) {
final Database current = holder.current();
final Service service = current.getServices().getNameServiceMap().get(name);
final Site site = current.getSites().getAliasSiteMap().get(siteName);
if (service == null)
throw new NotFoundException("No such service");
if (site == null)
throw new NotFoundException("No such site");
final JSONArray res = new JSONArray();
for (Host host : service.getHostSetInSite(site))
res.add(host.getReverseName());
return res;
}
@GET
@Path("/{name}/contacts")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getServiceContacts(@PathParam("name") String name) {
final Database current = holder.current();
final Service service = current.getServices().getNameServiceMap().get(name);
if (service == null)
throw new NotFoundException("No such service");
final Map<String, HashSet<Contact>> contactMap = service.getContactMap();
final JSONObject res = new JSONObject();
for (Map.Entry<String, HashSet<Contact>> entry : contactMap.entrySet())
res.put(entry.getKey(), entry.getValue());
return res;
}
}
|
3e1d9b8f89941f46e76f11e12655f3826fa3b87c | 4,123 | java | Java | src/main/java/com/py/py/domain/Tag.java | tomjbarry/penstro-domain | 1ffc09c695572fc9f6880ac76b19b73923a0ffca | [
"MIT"
] | null | null | null | src/main/java/com/py/py/domain/Tag.java | tomjbarry/penstro-domain | 1ffc09c695572fc9f6880ac76b19b73923a0ffca | [
"MIT"
] | null | null | null | src/main/java/com/py/py/domain/Tag.java | tomjbarry/penstro-domain | 1ffc09c695572fc9f6880ac76b19b73923a0ffca | [
"MIT"
] | null | null | null | 29.45 | 73 | 0.71089 | 12,547 | package com.py.py.domain;
import java.util.Date;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import com.py.py.domain.constants.CollectionNames;
import com.py.py.domain.constants.IndexNames;
import com.py.py.domain.constants.SharedFields;
import com.py.py.domain.subdomain.TagId;
import com.py.py.domain.subdomain.TallyApproximation;
import com.py.py.domain.subdomain.TimeSumAggregate;
@CompoundIndexes({
@CompoundIndex(name = IndexNames.TAG_NAME_LANGUAGE_LOCKED,
def = "{'" + Tag.ID + "." + TagId.NAME + "':1,'"
+ Tag.ID + "." + TagId.LANGUAGE + "':1,'"
+ Tag.LOCKED + "':1}"),
@CompoundIndex(name = IndexNames.TAG_AGGREGATE_HOUR_TIME_LANGUAGE,
def = "{'" + Tag.AGGREGATE + "." + TimeSumAggregate.HOUR + "':-1,'"
+ Tag.LAST_PROMOTION + "':-1,'"
+ Tag.ID + "." + TagId.LANGUAGE + "':1}"),
@CompoundIndex(name = IndexNames.TAG_AGGREGATE_DAY_TIME_LANGUAGE,
def = "{'" + Tag.AGGREGATE + "." + TimeSumAggregate.DAY + "':-1,'"
+ Tag.LAST_PROMOTION + "':-1,'"
+ Tag.ID + "." + TagId.LANGUAGE + "':1}"),
@CompoundIndex(name = IndexNames.TAG_AGGREGATE_MONTH_TIME_LANGUAGE,
def = "{'" + Tag.AGGREGATE + "." + TimeSumAggregate.MONTH + "':-1,'"
+ Tag.LAST_PROMOTION + "':-1,'"
+ Tag.ID + "." + TagId.LANGUAGE + "':1}"),
@CompoundIndex(name = IndexNames.TAG_AGGREGATE_YEAR_TIME_LANGUAGE,
def = "{'" + Tag.AGGREGATE + "." + TimeSumAggregate.YEAR + "':-1,'"
+ Tag.LAST_PROMOTION + "':-1,'"
+ Tag.ID + "." + TagId.LANGUAGE + "':1}"),
@CompoundIndex(name = IndexNames.TAG_VALUE_TIME_LANGUAGE,
def = "{'" + Tag.VALUE + "':-1,'"
+ Tag.LAST_PROMOTION + "':-1,'"
+ Tag.ID + "." + TagId.LANGUAGE + "':1}"),
})
@Document(collection = CollectionNames.TAG)
public class Tag {
public static final String ID = SharedFields.ID;
public static final String VALUE = SharedFields.VALUE;
public static final String APPRECIATION = SharedFields.APPRECIATION;
public static final String COMMENT_COUNT = SharedFields.COMMENT_COUNT;
public static final String COMMENT_TALLY = SharedFields.COMMENT_TALLY;
public static final String AGGREGATE = SharedFields.AGGREGATE;
public static final String LAST_PROMOTION = SharedFields.LAST_PROMOTION;
public static final String LOCKED = SharedFields.LOCKED;
@Id
private TagId id;
@Field(VALUE)
private long value = 0L;
@Field(APPRECIATION)
private long appreciation = 0L;
@Field(COMMENT_COUNT)
private long commentCount = 0L;
@Field(COMMENT_TALLY)
private TallyApproximation commentTally = new TallyApproximation();
@Field(AGGREGATE)
private TimeSumAggregate aggregate = new TimeSumAggregate();
@Field(LAST_PROMOTION)
private Date lastPromotion = new Date();
@Field(LOCKED)
private boolean locked = false;
public Tag() {
}
public TagId getId() {
return id;
}
public void setId(TagId id) {
this.id = id;
}
public long getValue() {
return value;
}
public void setValue(long value) {
this.value = value;
}
public long getAppreciation() {
return appreciation;
}
public void setAppreciation(long appreciation) {
this.appreciation = appreciation;
}
public long getCommentCount() {
return commentCount;
}
public void setCommentCount(long commentCount) {
this.commentCount = commentCount;
}
public TallyApproximation getCommentTally() {
return commentTally;
}
public void setCommentTally(TallyApproximation commentTally) {
this.commentTally = commentTally;
}
public Date getLastPromotion() {
return lastPromotion;
}
public void setLastPromotion(Date lastPromotion) {
this.lastPromotion = lastPromotion;
}
public boolean isLocked() {
return locked;
}
public void setLocked(boolean locked) {
this.locked = locked;
}
public TimeSumAggregate getAggregate() {
return aggregate;
}
public void setAggregate(TimeSumAggregate aggregate) {
this.aggregate = aggregate;
}
}
|
3e1d9c0c38d0cd11984a149090ab0289e4ae7ac2 | 141 | java | Java | _fixtures/java/src/main/java/com/phodal/pepper/refactor/parser/JsonParser.java | Fedomn/guarding | 91a6c074a3479a8881d2a697ea1fa665d1311257 | [
"MIT"
] | 31 | 2021-05-13T09:37:58.000Z | 2021-10-31T11:19:26.000Z | _fixtures/java/src/main/java/com/phodal/pepper/refactor/parser/JsonParser.java | Fedomn/guarding | 91a6c074a3479a8881d2a697ea1fa665d1311257 | [
"MIT"
] | null | null | null | _fixtures/java/src/main/java/com/phodal/pepper/refactor/parser/JsonParser.java | Fedomn/guarding | 91a6c074a3479a8881d2a697ea1fa665d1311257 | [
"MIT"
] | 4 | 2021-05-14T07:59:09.000Z | 2021-08-13T03:16:26.000Z | 15.666667 | 47 | 0.70922 | 12,548 | package com.phodal.pepper.refactor.parser;
public class JsonParser implements BaseParser {
@Override
public void parse() {
}
}
|
3e1d9d65a304eea3c98ec8c863fe479da23bd5ba | 1,756 | java | Java | monitor/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/monitor/v2016_03_01/implementation/MetricDefinitionImpl.java | minaltolpadi/azure-sdk-for-java | a6bb33fc71f21ee92d4246d6b5fe30ad8a5689cb | [
"MIT"
] | 3 | 2021-09-15T16:25:19.000Z | 2021-12-17T05:41:00.000Z | monitor/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/monitor/v2016_03_01/implementation/MetricDefinitionImpl.java | minaltolpadi/azure-sdk-for-java | a6bb33fc71f21ee92d4246d6b5fe30ad8a5689cb | [
"MIT"
] | 306 | 2019-09-27T06:41:56.000Z | 2019-10-14T08:19:57.000Z | monitor/resource-manager/v2016_03_01/src/main/java/com/microsoft/azure/management/monitor/v2016_03_01/implementation/MetricDefinitionImpl.java | minaltolpadi/azure-sdk-for-java | a6bb33fc71f21ee92d4246d6b5fe30ad8a5689cb | [
"MIT"
] | 1 | 2019-10-05T04:59:12.000Z | 2019-10-05T04:59:12.000Z | 28.322581 | 99 | 0.724374 | 12,549 | /**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/
package com.microsoft.azure.management.monitor.v2016_03_01.implementation;
import com.microsoft.azure.management.monitor.v2016_03_01.MetricDefinition;
import com.microsoft.azure.arm.model.implementation.WrapperImpl;
import java.util.List;
import com.microsoft.azure.management.monitor.v2016_03_01.MetricAvailability;
import com.microsoft.azure.management.monitor.v2016_03_01.LocalizableString;
import com.microsoft.azure.management.monitor.v2016_03_01.AggregationType;
import com.microsoft.azure.management.monitor.v2016_03_01.Unit;
class MetricDefinitionImpl extends WrapperImpl<MetricDefinitionInner> implements MetricDefinition {
private final MonitorManager manager;
MetricDefinitionImpl(MetricDefinitionInner inner, MonitorManager manager) {
super(inner);
this.manager = manager;
}
@Override
public MonitorManager manager() {
return this.manager;
}
@Override
public String id() {
return this.inner().id();
}
@Override
public List<MetricAvailability> metricAvailabilities() {
return this.inner().metricAvailabilities();
}
@Override
public LocalizableString name() {
return this.inner().name();
}
@Override
public AggregationType primaryAggregationType() {
return this.inner().primaryAggregationType();
}
@Override
public String resourceId() {
return this.inner().resourceId();
}
@Override
public Unit unit() {
return this.inner().unit();
}
}
|
3e1d9dc948f3d0c31c2e6174159b16ff89f3ce4c | 10,164 | java | Java | src/main/java/pl/coderslab/cls_wms_app/controller/LocationController.java | beomir/WMS | e4f503bedd4515a2b2ed787896d3c851d564c3a6 | [
"Apache-2.0"
] | null | null | null | src/main/java/pl/coderslab/cls_wms_app/controller/LocationController.java | beomir/WMS | e4f503bedd4515a2b2ed787896d3c851d564c3a6 | [
"Apache-2.0"
] | null | null | null | src/main/java/pl/coderslab/cls_wms_app/controller/LocationController.java | beomir/WMS | e4f503bedd4515a2b2ed787896d3c851d564c3a6 | [
"Apache-2.0"
] | 1 | 2021-01-24T18:22:41.000Z | 2021-01-24T18:22:41.000Z | 48.4 | 448 | 0.75915 | 12,550 | package pl.coderslab.cls_wms_app.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import pl.coderslab.cls_wms_app.app.SecurityUtils;
import pl.coderslab.cls_wms_app.entity.Company;
import pl.coderslab.cls_wms_app.entity.Location;
import pl.coderslab.cls_wms_app.entity.StorageZone;
import pl.coderslab.cls_wms_app.entity.Warehouse;
import pl.coderslab.cls_wms_app.repository.ExtremelyRepository;
import pl.coderslab.cls_wms_app.repository.LocationRepository;
import pl.coderslab.cls_wms_app.repository.StockRepository;
import pl.coderslab.cls_wms_app.repository.StorageZoneRepository;
import pl.coderslab.cls_wms_app.service.storage.LocationService;
import pl.coderslab.cls_wms_app.service.userSettings.UsersService;
import pl.coderslab.cls_wms_app.service.wmsValues.CompanyService;
import pl.coderslab.cls_wms_app.service.wmsValues.WarehouseService;
import pl.coderslab.cls_wms_app.temporaryObjects.AddLocationToStorageZone;
import pl.coderslab.cls_wms_app.temporaryObjects.LocationNameConstruction;
import pl.coderslab.cls_wms_app.temporaryObjects.LocationSearch;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;
import java.util.List;
@Controller
public class LocationController {
private final LocationService locationService;
private final UsersService usersService;
private final WarehouseService warehouseService;
private final StorageZoneRepository storageZoneRepository;
public LocationSearch locationSearch;
private final LocationNameConstruction locationNameConstruction;
private final AddLocationToStorageZone addLocationToStorageZone;
private final LocationRepository locationRepository;
private final StockRepository stockRepository;
private final ExtremelyRepository extremelyRepository;
private CompanyService companyService;
@Autowired
public LocationController(LocationService locationService, UsersService usersService, WarehouseService warehouseService, StorageZoneRepository storageZoneRepository, LocationSearch locationSearch, LocationNameConstruction locationNameConstruction, AddLocationToStorageZone addLocationToStorageZone, LocationRepository locationRepository, StockRepository stockRepository, ExtremelyRepository extremelyRepository, CompanyService companyService) {
this.locationService = locationService;
this.usersService = usersService;
this.warehouseService = warehouseService;
this.storageZoneRepository = storageZoneRepository;
this.locationSearch = locationSearch;
this.locationNameConstruction = locationNameConstruction;
this.addLocationToStorageZone = addLocationToStorageZone;
this.locationRepository = locationRepository;
this.stockRepository = stockRepository;
this.extremelyRepository = extremelyRepository;
this.companyService = companyService;
}
@GetMapping("/user/locations")
public String locationList(Model model) {
List<Location> locations;
if(locationSearch.getLocationName() == null){
locations = locationService.getLocations();
}
else{
locations = locationService.getLocationsByAllCriteria(locationSearch.getLocationName(), locationSearch.getLocationType(), locationSearch.getStorageZoneName(), locationSearch.getWarehouse());
}
model.addAttribute("locations", locations);
model.addAttribute("locationSearch",locationSearch);
model.addAttribute("locationExistsMessage",locationNameConstruction.message);
model.addAttribute("addToStorageZoneMessage",addLocationToStorageZone.message);
String token = usersService.FindUsernameByToken(SecurityUtils.username());
model.addAttribute("token", token);
model.addAttribute("localDateTime", LocalDateTime.now());
List<Company> companies = companyService.getCompanyByUsername(SecurityUtils.username());
model.addAttribute("companies",companies);
return "storage/location/locations";
}
@GetMapping("/config/locationsDeactivatedList")
public String locationDeactivatedList(Model model) {
List<Location> locations = locationService.getDeactivatedLocations();
model.addAttribute("locations", locations);
return "storage/location/locationsDeactivatedList";
}
@GetMapping("/user/formLocation")
public String locationForm(Model model, HttpSession session){
List<Warehouse> warehouses = warehouseService.getWarehouse();
model.addAttribute("warehouses", warehouses);
List<StorageZone> storageZones = storageZoneRepository.getStorageZones();
model.addAttribute("storageZones", storageZones);
model.addAttribute("localDateTime", LocalDateTime.now());
model.addAttribute("location", new Location());
model.addAttribute("locationNameConstruction", new LocationNameConstruction());
usersService.loggedUserData(model,session);
return "storage/location/formLocation";
}
@PostMapping("/user/formLocation")
public String locationAdd(Location location, LocationNameConstruction locationNameConstruction) {
locationService.addLocation(location, locationNameConstruction);
return "redirect:/user/locations";
}
@GetMapping("/deactivateLocation/{id}")
public String deactivateLocation(@PathVariable Long id) {
locationService.deactivate(id);
return "redirect:/user/locations";
}
@GetMapping("/config/activateLocation/{id}")
public String activateLocation(@PathVariable Long id) {
locationService.activate(id);
return "redirect:/config/locationsDeactivatedList";
}
@GetMapping("/config/removeLocation/{id}")
public String deleteLocation(@PathVariable Long id) {
//TODO if location is empty
locationService.remove(id);
return "redirect:/config/locationsDeactivatedList";
}
@GetMapping("/user/formEditLocation/{id}")
public String updateLocation(@PathVariable Long id, Model model,HttpSession session) {
Location location = locationService.findById(id);
model.addAttribute(location);
List<Warehouse> warehouses = warehouseService.getWarehouse();
model.addAttribute("warehouses", warehouses);
List<StorageZone> storageZones = storageZoneRepository.getStorageZones();
LocationNameConstruction lCN = locationService.lCN(location);
model.addAttribute("locationNameConstruction", lCN);
model.addAttribute("storageZones", storageZones);
model.addAttribute("localDateTime", LocalDateTime.now());
usersService.loggedUserData(model,session);
return "storage/location/formEditLocation";
}
@PostMapping("/user/formEditLocation")
public String edit(Location location, LocationNameConstruction locationNameConstruction) {
locationService.editLocation(location, locationNameConstruction);
return "redirect:/user/locations";
}
@GetMapping("/user/locations-browser")
public String browser(Model model,HttpSession session) {
model.addAttribute("locationSearching", new LocationSearch());
List<Warehouse> warehouses = warehouseService.getWarehouse();
model.addAttribute("warehouses", warehouses);
List<StorageZone> storageZones = storageZoneRepository.getStorageZones();
model.addAttribute("storageZones", storageZones);
usersService.loggedUserData(model,session);
return "storage/location/locations-browser";
}
@PostMapping("/user/locations-browser")
public String findLocation(LocationSearch locationSearching) {
locationService.save(locationSearching);
return "redirect:/user/locations";
}
@GetMapping("/user/formLocationPack")
public String locationPack(Model model,HttpSession session) {
List<Warehouse> warehouses = warehouseService.getWarehouse();
model.addAttribute("warehouses", warehouses);
List<StorageZone> storageZones = storageZoneRepository.getStorageZones();
model.addAttribute("storageZones", storageZones);
model.addAttribute("localDateTime", LocalDateTime.now());
model.addAttribute("location", new Location());
model.addAttribute("locationNameConstruction", new LocationNameConstruction());
model.addAttribute("extremelyValue",extremelyRepository.listCheckLocationScopeMax("%","Location Scope"));
usersService.loggedUserData(model,session);
return "storage/location/formLocationPack";
}
@PostMapping("/user/formLocationPack")
public String formLocationPack(Location location, LocationNameConstruction locationNameConstruction) {
locationService.createLocationPack(location, locationNameConstruction);
return "redirect:/user/locations";
}
@GetMapping("/user/addLocToStorageZones")
public String addLocationToStorageZone(Model model,HttpSession session) {
List<Warehouse> warehouses = warehouseService.getWarehouse();
model.addAttribute("warehouses", warehouses);
List<StorageZone> storageZones = storageZoneRepository.getStorageZones();
model.addAttribute("storageZones", storageZones);
List<Location> LocationAndStorageZones = locationRepository.LocationsPlusStorageZone();
model.addAttribute("lasz", LocationAndStorageZones);
model.addAttribute("localDateTime", LocalDateTime.now());
model.addAttribute("location", new AddLocationToStorageZone());
usersService.loggedUserData(model, session);
return "storage/location/addLocToStorageZones";
}
@PostMapping("/user/addLocToStorageZones")
public String addLocationToStoragePost(AddLocationToStorageZone aLTSZ) {
locationService.addLocationsToStorageZone(aLTSZ);
return "redirect:/user/locations";
}
}
|
3e1d9de908b7656b8ee4b6b69d5314145a7b0e5b | 1,171 | java | Java | src/main/java/sh/okx/rankup/placeholders/Placeholders.java | arantesxyz/Rankup3 | 1dedb151efcae29ec655fe444e6494ff5f10cedc | [
"MIT"
] | null | null | null | src/main/java/sh/okx/rankup/placeholders/Placeholders.java | arantesxyz/Rankup3 | 1dedb151efcae29ec655fe444e6494ff5f10cedc | [
"MIT"
] | null | null | null | src/main/java/sh/okx/rankup/placeholders/Placeholders.java | arantesxyz/Rankup3 | 1dedb151efcae29ec655fe444e6494ff5f10cedc | [
"MIT"
] | 1 | 2020-11-02T10:17:30.000Z | 2020-11-02T10:17:30.000Z | 27.880952 | 104 | 0.736123 | 12,551 | package sh.okx.rankup.placeholders;
import lombok.Getter;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit;
import sh.okx.rankup.Rankup;
import java.text.DecimalFormat;
public class Placeholders {
private final Rankup plugin;
@Getter
private final DecimalFormat moneyFormat;
@Getter
private final DecimalFormat percentFormat;
@Getter
private final DecimalFormat simpleFormat;
private boolean registered;
public Placeholders(Rankup plugin) {
this.plugin = plugin;
this.moneyFormat = new DecimalFormat(plugin.getConfig().getString("placeholders.money-format"));
this.percentFormat = new DecimalFormat(plugin.getConfig().getString("placeholders.percent-format"));
this.simpleFormat = new DecimalFormat(plugin.getConfig().getString("placeholders.simple-format"));
}
public void register() {
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new RankupExpansion(plugin, this).register();
registered = true;
} else {
registered = false;
}
}
public void unregister() {
if (registered) {
PlaceholderAPI.unregisterPlaceholderHook("rankup");
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.