id stringlengths 7 14 | text stringlengths 1 37.2k |
|---|---|
6493570_1 | public ChannelGroupFuture kill() {
if (serverChannel == null) {
throw new IllegalStateException("Server is not running.");
}
channelGroup.add(serverChannel);
final ChannelGroupFuture future = channelGroup.close();
channelGroup.remove(serverChannel);
serverChannel = null;
return future;
} |
6500041_18 | @Override
public void map(LongWritable k, Text v,Context c) throws IOException, InterruptedException {
String line=v.toString();
if (line.startsWith("@prefix")) {
incrementCounter(c,FreebasePrefilterCounter.PREFIX_DECL,1L);
return;
}
try {
List<String> parts = expandTripleParts... |
6505114_0 | public static <T> T createInstanceOfGenericType(Class clazz){
return createInstanceOfGenericType(clazz,0);
} |
6552338_4 | public RecordFactory getRecordFactory() throws ResourceException {
try {
if (recordFactory == null) {
JCoRepository repository = ((ConnectionImpl)getConnection()).getDestination().getRepository();
recordFactory = CciFactoryImpl.eINSTANCE.createRecordFactory();
((org.jboss.jca.adapters.sap.cci.impl.RecordFac... |
6563886_6 | public Object convert(String value) {
return value;
} |
6603193_10 | @Override
public boolean remove(@Nullable Object element)
{
int length = array.length;
int index = indexOf(element, array, 0, length);
if (index < 0)
{
return false;
}
Object[] newArray = new Object[length - 1];
System.arraycopy(array, 0, newArray, 0, index);
System.arraycopy(arr... |
6605842_1 | @Override
public void stop() {
logger.info("Stopping Topic manager.");
// we just unregister it with zookeeper to make it unavailable from hub servers list
try {
hubManager.unregisterSelf();
} catch (IOException e) {
logger.error("Error unregistering hub server :", e);
}
super.st... |
6662839_98 | @Override
public Map<String, Object> parse(Map<String, Object> params) {
String line = (String) params.get("line");
if (line == null)
return null;
try {
Map<String, Object> m = new HashMap<String, Object>();
Scanner scanner = new Scanner(line);
scanner.useDelimiter("`");
// log header
m.put("version", ... |
6682280_276 | public static <T> KijiResult<T> create(
final EntityId entityId,
final KijiDataRequest dataRequest,
final Result unpagedRawResult,
final HBaseKijiTable table,
final KijiTableLayout layout,
final HBaseColumnNameTranslator columnTranslator,
final CellDecoderProvider decoderProvider
) throws IO... |
6682435_0 | void writeTimestamp(File directory, Long timestamp) throws IOException {
File timestampFile = new File(directory, TIMESTAMP_FILE_NAME);
CheckinUtils.writeObjectToFile(timestampFile, timestamp);
} |
6691222_1119 | @Override
public DendroNode getRight() {
return right;
} |
6719207_30 | public long uniqueVersionId() {
IdGenerator idGenerator = hz.getIdGenerator(CoordinationStructures.VERSION_GENERATOR);
long id = idGenerator.newId();
int timeSeconds = (int) (System.currentTimeMillis() / 1000);
long paddedId = id << 32;
return paddedId + timeSeconds;
} |
6725438_4 | public static void transfer(final InputStream input, final OutputStream output, final BuffersPool buffersPool) throws IOException {
final InputStream in = buffersPool == null
? new BufferedInputStream(input, BUFFER_SIZE_8K)
: new PoolableBufferedInputStream(input, BUFFER_SIZE_8K, buffersPool);
final by... |
6726370_93 | public boolean isGreaterThan(String version) {
JenkinsVersion create = create(version);
return this.cv.compareTo(create.cv) > 0;
} |
6733624_195 | public static List<FunctionSignature> parseFunctionRegistryAndValidateTypes(AptUtils aptUtils, TypeElement elm, GlobalParsingContext context) {
final List<ExecutableElement> methods = ElementFilter.methodsIn(elm.getEnclosedElements());
final Optional<String> keyspace = AnnotationTree.findKeyspaceForFunctionRegi... |
6752107_4 | public static long parseDuration(String duration) {
if (duration == null || duration.isEmpty()) {
throw new IllegalArgumentException("duration may not be null");
}
long toAdd = -1;
if (days.matcher(duration).matches()) {
Matcher matcher = days.matcher(duration);
matcher.matches()... |
6764581_1 | @Override
public void destroy(final Object instance) {
if (instance != null) {
try {
invokeAnnotatedLifecycleMethod(instance, instance.getClass(), PreDestroy.class);
} catch (Exception e) {
LOGGER.failToDestroyArtifact(e, instance);
}
}
} |
6780534_29 | @Override public Observable<Void> delete(String messageId) {
return apiService.deleteMessage(messageId);
} |
6791064_5 | public void triggle(Date now) {
Map<String, Task> tasks = scheduler.getAllRegistedTask();
Transaction t = Cat.newTransaction("Time-2", "CronTabTriggle");
for (Task task : tasks.values()) {
Cat.logEvent("For","");
if (task.getStatus() != TaskStatus.RUNNING) {
continue;
}... |
6804081_10 | Class<?>[] getAllInterfacesAndClasses(Class<?> clazz) {
return getAllInterfacesAndClasses(new Class[] { clazz } );
} |
6810283_20 | public void validate(Object obj, Errors errors) {
AppointmentType appointmentType = (AppointmentType) obj;
if (appointmentType == null) {
errors.rejectValue("appointmentType", "error.general");
} else {
validateDurationField(errors, appointmentType);
validateFieldName(errors, appointmentType);
validateDescri... |
6821657_32 | @Override
public MatchField matches(StubMessage request) {
String expected = JsonUtils.prettyPrint(pattern);
String actual = JsonUtils.prettyPrint(request.getBody());
MatchResult result = matchResult(request);
MatchField field = new MatchField(FieldType.BODY, "body", expected);
if (result.isMatch())... |
6822394_1121 | public List<Handler> buildHandlerChainFromClass(Class<?> clz, List<Handler> existingHandlers,
QName portQName, QName serviceQName, String bindingID) {
LOG.fine("building handler chain");
classLoader = clz.getClassLoader();
HandlerChainAnnotation hcAnn = findHa... |
6827663_4 | @Override
public long calculate(int order) {
return order < 3 ? 1 : calculate(order-1) + calculate(order-2);
} |
6830643_0 | @Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.activity_main, menu);
return true;
} |
6833345_0 | NGSession take() {
synchronized (lock) {
if (done) {
throw new UnsupportedOperationException("NGSession pool is shutting down");
}
NGSession session = idlePool.poll();
if (session == null) {
session = instanceCreator.get();
session.start();
}
workingPool.add(session);
ret... |
6848534_3 | public TopWordCounts findTop(int number, Comparator<Integer> comparator) {
return analyse(new FindTopAnalysis(number, comparator));
} |
6863498_22 | public static List<IssueDTO> getIssues(String url, String username, String password, String path, String query) {
WebClient client = createClient(url);
checkAutherization(client, username, password);
// Go to baseURI
client.back(true);
client.path(path);
if ( !query.isEmpty() ) {
cl... |
6867673_30 | public Set<String> getKeys() {
@SuppressWarnings("unchecked")
final Set<String> result = new HashSet<String>(this.values.keySet());
return result;
} |
6872642_22 | public String edit() {
if (id == null) {
id = new Long(getParameter("id"));
}
person = personManager.get(id);
return "edit";
} |
6879138_0 | @Override
public Model open(Assembler a, Resource root, Mode mode) {
List<Statement> lst = root.listProperties().toList();
Resource rootModel = getUniqueResource( root, BASE_MODEL );
if (rootModel == null)
{
throw new AssemblerException( root, String.format( "No %s provided for %s", BASE_MODEL, root ));
}
Mode... |
6900541_1 | public static String readableFileSize(long size) {
if(size <= 0) return "0 KB";
final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" };
int digitGroups = (int) (Math.log10(size)/Math.log10(1000));
return new DecimalFormat("#,##0.#").format(size/Math.pow(1000, digitGroups)) + " " + units[dig... |
6921975_21 | public static String createRequestSignature(final String method, final String dateHeader, final String requestUri, ByteSource body, final String secretKey) {
final String signatureBase = createSignatureBase(method, dateHeader, requestUri, body);
return createRequestSignature(signatureBase, secretKey);
} |
6944525_585 | @Override
public void handleRequest(RestRequest request, RequestContext requestContext, Callback<RestResponse> callback)
{
//This code path cannot accept content types or accept types that contain
//multipart/related. This is because these types of requests will usually have very large payloads and therefore
//wo... |
6946733_5 | public final byte[] getNextJobHandle() {
String handle = "H:".concat(clusterHostname).concat(":").concat(String.valueOf(jobHandleCounter.incrementAndGet()));
return handle.getBytes();
} |
6951233_116 | @RequestMapping(method = RequestMethod.POST)
@ResponseBody
@ResponseStatus(value = HttpStatus.OK)
public void post(HttpServletRequest request, @RequestBody Map<String, String> body) {
String localeStr = body.get("locale");
if (localeStr != null) {
Locale locale = null;
try {
locale = LocaleUtils.toLocale(local... |
6961882_16 | public static String parseCharset(Map<String, String> headers, String defaultCharset) {
String contentType = headers.get(HTTP.CONTENT_TYPE);
if (contentType != null) {
String[] params = contentType.split(";");
for (int i = 1; i < params.length; i++) {
String[] pair = params[i].trim()... |
6963527_2 | @Override
public void validate(Problems problems, String compName, String model) {
if (model.length() == 0) {
problems.add(NbBundle.getMessage(StringValidators.class,
"INVALID_HOST_NAME", compName, model)); //NOI18N
return;
}
if (model.startsWith(".") || model.endsWith(".")) ... |
6969798_0 | public static AisStoreQueryBuilder forTime() {
return new AisStoreQueryBuilder(null, null);
} |
6972004_6 | public static <T, V> Matcher<T> compose(final Function<T, ? extends V> transformer, final Matcher<V> matcher) {
checkNotNull(transformer, "transformer");
checkNotNull(matcher, "matcher");
return new TypeSafeMatcher<T>() {
@Override
public void describeTo(final Description description) {
... |
7010395_8 | @JsonCreator
public static Duration valueOf(String text) {
String trimmed = WHITESPACE.removeFrom(text).trim();
return new Duration(quantity(trimmed), unit(trimmed));
} |
7014975_0 | @Override
public TimeOut newTimeout(TimerTask task, long delay, TimeUnit unit) {
start();
if (task == null) {
throw new NullPointerException("task");
}
if (unit == null) {
throw new NullPointerException("unit");
}
long deadline = System.nanoTime() + unit.toNanos(delay) - startTime;
// Add the timeout to t... |
7015517_16 | public static boolean isValid(String pluginKey) {
return StringUtils.isNotBlank(pluginKey) && StringUtils.isAlphanumeric(pluginKey);
} |
7022775_194 | public byte[] getExtensionBytes() {
return Arrays.copyOf(extensionBytes, extensionBytes.length);
} |
7028076_1 | public RequestToken getRequestToken() {
final Twitter twitter = factory.getInstance();
try {
return twitter.getOAuthRequestToken();
} catch (TwitterException e) {
throw this.wrapException(e);
}
} |
7031510_60 | protected static int maxFileNumber(String baseDir, String database, String date, String prefix, String suffix) {
File[] files = visitFiles(baseDir, database, date, prefix, suffix);
int max = -1;
for (File file : files) {
int number = parseNumber(file, prefix, suffix);
max = number > max ? nu... |
7033568_0 | public MinigamePlayerManager getPlayerManager() {
return this.playerManager;
} |
7043506_11 | public static Observable<GroupedObservable<TypeAndNameKey, Map<String, Object>>> aggregateGroupedStreams(Observable<GroupedObservable<InstanceKey, Map<String, Object>>> stream) {
return aggregateUsingFlattenedGroupBy(stream);
} |
7056723_44 | public MethodCaller create() {
Object key = KEY_FACTORY.newInstance(callTarget.getTargetMethod(), null);
try {
return (MethodCaller) super.create(key);
}
catch (Mock4AjException error) { // NOPMD
throw error;
}
catch (Exception error) {
throw new Mock4AjException("An erro... |
7072487_3 | public String createEntitlement() {
List<String> entitlementStrings = listEntitlements();
if (entitlementStrings.isEmpty()) {
return null;
}
return StringUtils.join(entitlementStrings, ENTITLEMENT_SEPARATOR);
} |
7091762_2 | public static String getDescription(String expression) throws ParseException {
return getDescription(DescriptionTypeEnum.FULL, expression, new Options(), I18nMessages.DEFAULT_LOCALE);
} |
7095532_15 | public static final void log() {
log.info("\n{}", asText());
} |
7109191_7 | public static final JavaScriptSettingsBuilder newBuilder() {
return new JavaScriptSettingsBuilder() {
private JQueryUiBuilder jqueryUiBuilder;
private BootstrapJsBuilder bootstrapJsBuilder;
@Override
public JQueryUiBuilder withJqueryUi(JQueryUiBuilderFactory factory) {
j... |
7137340_9 | public synchronized void add(T item) {
if (item == null) {
throw new IllegalArgumentException("item is null");
}
buffer[tail++] = item;
tail %= buffer.length;
if (tail == head) {
head = (head + 1) % buffer.length;
}
} |
7139471_49 | @Override public void onItemSelected(AdapterView<?> viewAdapter, View view, int position, long id) {
if (view == null) {
return;
}
setMultiViewVideoActivity(activity);
findViews();
CategoryInfo item = (CategoryInfo) viewAdapter.getItemAtPosition(position);
if (savedInstanceCategory != null) {
in... |
7144342_0 | Future(MessagePack messagePack, FutureImpl impl) {
this(messagePack, impl, null);
} |
7170387_1 | @Override
public void validate(@Nullable String database, String role) throws ConfigurationException {
/*
* Rule only applies to rules in per database policy file
*/
if(database != null) {
Iterable<Authorizable> authorizables = parseRole(role);
/*
* Each permission in a non-global file must have... |
7212262_3 | @Override
public int getPhase() {
return Integer.MAX_VALUE;
} |
7220231_1 | public static TimeZone getTimeZone(int index, boolean observeDaylightSaving, String tzId) throws IOException {
if (index < 0 || index > 59)
return null;
int bias = 0; // UTC offset in minutes
int standardBias = 0; // offset in minutes from bias during standard time.; has a value of 0 in most ca... |
7257232_7 | public static String canonicaliseURL(String url) {
return canonicaliseURL(url, true, true);
} |
7263059_8 | static HttpDownloadContinuationMarker validateInitialExchange(final Pair<String, Request> requestHints,
final int responseCode,
final Pair<String, Response> responseFingerprint)
throws Pro... |
7272424_1 | public void applyShippingPromotions(ShoppingCart shoppingCart) {
if ( shoppingCart != null ) {
//PROMO: if cart total is greater than 75, free shipping
if ( shoppingCart.getCartItemTotal() >= 75) {
shoppingCart.setShippingPromoSavings(shoppingCart.getShippingTotal() * -1);
shoppingCart.setShippingTo... |
7276954_28 | public static AlluxioURI getTablePathUdb(String dbName, String tableName, String udbType) {
return new AlluxioURI(PathUtils
.concatPath(ServerConfiguration.get(PropertyKey.TABLE_CATALOG_PATH), dbName, TABLES_ROOT,
tableName, udbType));
} |
7286420_7 | public Module wrap(final Module module) {
if (module instanceof PrivateModule) {
return new PrivateModule() {
@Override
protected void configure() {
if (modules.add(module)) {
module.configure(createForwardingBinder(binder()));
install(ProviderMethodsModule.forModule(module));
}
}
};
}
... |
7308129_2 | @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().write(String.valueOf(new Date().getTime()));
} |
7316492_0 | public String get(Locale locale) {
return localized.get(locale);
} |
7321072_139 | public LinkedList<Token> tokenize(String text) {
if (logger.isDebugEnabled())
logger.debug("Tokenizing text: '" + text + "'");
text = text.replaceAll(" +", " "); // remove multiple consequent space chars
text = text.trim();
final LinkedList<TextBlock> textBlocks = textBlockSplitter.splitToTex... |
7324677_12 | public static SRTInfo read(File srtFile) throws InvalidSRTException, SRTReaderException {
if (!srtFile.exists()) {
throw new SRTReaderException(srtFile.getAbsolutePath() + " does not exist");
}
if (!srtFile.isFile()) {
throw new SRTReaderException(srtFile.getAbsolutePath() + " is not a regul... |
7337208_1 | public static Map<String, Long> readHashes( File file ) throws FileNotFoundException {
return readHashes( new FileInputStream(file) );
} |
7352878_9 | static ConfigObject mergeConfigObjects(ConfigObject lowPriorityCO,
ConfigObject highPriorityCO) {
return (ConfigObject) lowPriorityCO.merge(highPriorityCO);
} |
7386322_2 | @ResourceMapping(GET_TEMPLATES)
public void getTemplates(ResourceRequest request, ResourceResponse response, @RequestParam("page") int page, @RequestParam("rows") int rows)
throws Exception {
try {
User user = liferayService.getUser(request, response);
if (user == null) return;
List<... |
7393690_23 | public static byte[] split(byte[] bytes, int start, int end) {
if (bytes == null) {
return null;
}
if (start < 0) {
throw new IllegalArgumentException("start < 0");
}
if (end > bytes.length) {
throw new IllegalArgumentException("end > size");
}
if (start > end) {
throw new IllegalArgumentException("star... |
7403823_41 | @SuppressWarnings("rawtypes")
public static List<Class> getCheckClasses() {
return CLASSES;
} |
7403873_31 | @Override
public void execute(SensorContext context) {
List<InputFile> inputFiles = new ArrayList<>();
fileSystem.inputFiles(mainFilesPredicate).forEach(inputFiles::add);
if (inputFiles.isEmpty()) {
return;
}
boolean isSonarLintContext = context.runtime().getProduct() == SonarProduct.SONARLINT;
Progr... |
7410462_0 | public List<String> extract(String[] tokens) throws IOException {
return extract(parser.parse(tokens));
} |
7416235_10 | public static GraphName of(String name) {
return new GraphName(canonicalize(name));
} |
7416278_0 | @Override
public synchronized int read(byte[] buffer, int offset, int length) throws IOException {
int bytesRead = 0;
if (length > 0) {
while (available() == 0) {
// Block until there are bytes to read.
Thread.yield();
}
synchronized (readBuffer) {
bytesRead = Math.min(length, availabl... |
7416746_1 | public synchronized Channel getFreeChannel() {
for (Channel c : channels) {
if (c.isFree()) {
c.setFree(false);
return c;
}
}
return null;
} |
7420937_193 | @Override
public Optional<String> apply(Optional<String> springApplicationName) {
Optional<String> processApplicationName = GetProcessApplicationNameFromAnnotation.getProcessApplicationName.apply(applicationContext);
if (processApplicationName.isPresent()) {
return processApplicationName;
} else if (springAp... |
7422160_52 | public static String backupFile(File source) {
File backup = new File(source.getParent() + "/~" + source.getName());
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(source)));
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(new FileOutputStrea... |
7436396_4 | @Override
public User addUser(final User user) {
// create date set to now(), only work for mysql
final String INSERT_SQL = "insert into t_user (imei, imsi, phone_name,createdate) values (?, ?, ?, now())";
/ return this.jdbcTemplate.update(INSERT_SQL, user.getImei(),
/ user.getImsi(), user.getPhoneName());
... |
7438954_5 | public PlungerArguments merge(String cmdTarget, Config config, CommandLine line, Options options) throws Exception {
PlungerArguments result = new PlungerArguments();
Target commandTarget = new TargetParser().parse(cmdTarget);
Entry entry = config.getEntry(commandTarget.getHost());
if ((entry != null) && (entry.get... |
7450263_2 | @Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
if (!(msg instanceof ChannelBuffer)) {
return msg;
}
ChannelBuffer buf = (ChannelBuffer) msg;
if (buf.hasArray()) {
ByteArrayInputStream bis = new ByteArrayInputStream(buf.array(), buf.a... |
7455819_22 | @Override
public boolean isApplicable(HandlerContext handlerContext) {
// Retrieves the content type from the filtered response
String mimeType = handlerContext.getResponse().getContentType();
// Required conditions
boolean gzipEnabled = handlerContext.getContext().getConfiguration().isToolGzipEnabled();
... |
7465720_23 | protected static List<AndroidElement> searchViews(AbstractNativeElementContext context, View root,
Predicate predicate, boolean findJustOne) {
List<AndroidElement> elements = new ArrayList<AndroidElement>();
if (root == null) {
return elements;
}
ArrayDeque<... |
7480345_95 | protected static String createCallbackCWrapper(FunctionType functionType, String name, String innerName) {
// We order structs by name in reverse order. The names are constructed
// such that nested structs get names which are naturally ordered after
// their parent struct.
Map<String, String> structs =... |
7481569_302 | public Set<Project> getUngroupedRepositories() {
return cacheProjects(PROJECT_HELPER_UNGROUPED_REPOSITORIES, ungroupedRepositories);
} |
7482468_0 | @Override
public String toString()
{
return Visitors.readable(this);
} |
7499734_214 | @Deprecated
public static <E> IList<E> getList(String name) {
return getDefaultInstance().getList(name);
} |
7506968_32 | public Class getColumnClass( final int column ) {
if ( column == 2 ) {
return Date.class;
}
return String.class;
} |
7530419_1 | @Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupActionBar();
setContentView(R.layout.directory_chooser_activity);
final DirectoryChooserConfig config = getIntent().getParcelableExtra(EXTRA_CONFIG);
if (config == null) {
throw n... |
7575297_13 | public static String removeTag(String html, String tagName) {
Element bodyElement = Jsoup.parse(html).body();
bodyElement.getElementsByTag(tagName).remove();
return bodyElement.html();
} |
7576522_23 | public static Consolidator createConsolidator(final Class<? extends Consolidator> type, final int maxSamples) {
Preconditions.checkNotNull(type, "null type");
Preconditions2.checkSize(maxSamples);
try {
//First look for a constructor accepting int as argument
try {
return type.getConstructor(int.cl... |
7589324_102 | @Transactional
@Override
public void deleteFromIndex(Long id) {
LOGGER.debug("Deleting an existing document with id: {}", id);
repository.delete(id.toString());
} |
7593542_1 | public String sayHello(String name, boolean hipster) {
return (hipster) ? ("Yo " + name) : ("Hello " + name);
} |
7612313_0 | @Override
public synchronized DerivedKey getKey() throws IOException, GeneralSecurityException {
if (derivedKey == null)
createDerivedKey();
return derivedKey;
} |
7616158_12 | public static <T> T newInstance(Class<T> aClass) {
try {
return aClass.newInstance();
} catch (Exception e) {
throw new RibbonProxyException("Cannot instantiate object from class " + aClass, e);
}
} |
7623114_51 | public static int acompare(double x1, double x2) {
if (isZero(x1 - x2)) {
return 0;
} else {
return Double.compare(x1, x2);
}
} |
7638504_10 | public void addSymbol(String name, SymbolType type, ScopeType scopeType) {
if (scopes.isEmpty()) {
throw new IllegalStateException("Called addSymbol before adding any scope levels");
}
getTop().add(new Symbol(name, type, scopeType));
} |
7676364_12 | public static synchronized ThreadPoolExecutor getExecutor(ThreadPoolBuilder builder,
RegionCoprocessorEnvironment env) {
return getExecutor(builder, env.getSharedData());
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.