code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static <T> Set<T> toSet(final Collection<T> collection) {
if (isEmpty(collection)) {
return new HashSet<T>(0);
} else {
return new HashSet<T>(collection);
}
} | java |
public static <T> T[] toArray(final Collection<T> collection) {
T next = getFirstNotNullValue(collection);
if (next != null) {
Object[] objects = collection.toArray();
@SuppressWarnings("unchecked")
T[] convertedObjects = (T[]) Array.newInstance(next.getClass(), obje... | java |
public void setMappings(List<String> mappings) {
if (mappings.size() > 0) {
@SuppressWarnings("unchecked") Pair<String, String>[] renames = (Pair<String, String>[])Array.newInstance(Pair.class, mappings.size());
for (int i = 0; i < _renames.length; ++i) {
String[] names =... | java |
@Nullable
@ReturnsMutableCopy
public static ICommonsNavigableSet <EContinent> getContinentsOfCountry (@Nullable final Locale aLocale)
{
final Locale aCountry = CountryCache.getInstance ().getCountry (aLocale);
if (aCountry != null)
{
final ICommonsNavigableSet <EContinent> ret = s_aMap.get (aCou... | java |
public boolean isLoadable() {
if (getPayload() instanceof NullPayload) {
return false;
}
try {
InputStream is = getInputStream();
try {
is.read();
return true;
} finally {
is.close();
}
} catch (IOException ex) {
return false;
}
} | java |
public String loadString(String encoding) throws IOException {
byte[] bytes = loadByteArray();
ByteOrderMask bom = ByteOrderMask.valueOf(bytes);
if(bom != null){
int offset = (bom.getBytes()).length;
return new String(bytes, offset, bytes.length - offset, bom.getEncoding());
}
return new String(bytes... | java |
public Result transfer(long count) {
if (count < 0L) throw new IllegalArgumentException("negative count");
return buffer == null ? transferNoBuffer(count) : transferBuffered(count);
} | java |
public static TreePath getPath(TreePath path, Tree target) {
path.getClass();
target.getClass();
class Result extends Error {
static final long serialVersionUID = -5942088234594905625L;
TreePath path;
Result(TreePath path) {
this.path = path;
... | java |
public Reifier addTypeSet(Class<?> spec) {
for (Field field: spec.getDeclaredFields()) {
if (Modifier.isPublic(field.getModifiers())) {
String name = field.getName();
try {
_named.put(name, new Validator(name, field.getType(), field));
... | java |
public <T extends DataObject> T collect(T data, Map<String, String> binder) throws SecurityException, DataValidationException {
return collect(data, binder, null);
} | java |
public static boolean localeSupportsCurrencyRetrieval (@Nullable final Locale aLocale)
{
return aLocale != null && aLocale.getCountry () != null && aLocale.getCountry ().length () == 2;
} | java |
@Nullable
public static BigDecimal parseCurrency (@Nullable final String sStr,
@Nonnull final DecimalFormat aFormat,
@Nullable final BigDecimal aDefault,
@Nonnull final RoundingMode eRoundingM... | java |
@Nullable
private static String _getTextValueForDecimalSeparator (@Nullable final String sTextValue,
@Nonnull final EDecimalSeparator eDecimalSep,
@Nonnull final EGroupingSeparator eGroupingSep)
{
... | java |
public static void setRoundingMode (@Nullable final ECurrency eCurrency, @Nullable final RoundingMode eRoundingMode)
{
getSettings (eCurrency).setRoundingMode (eRoundingMode);
} | java |
public List<Symbol> functionalInterfaceBridges(TypeSymbol origin) {
Assert.check(isFunctionalInterface(origin));
Symbol descSym = findDescriptorSymbol(origin);
CompoundScope members = membersClosure(origin.type, false);
ListBuffer<Symbol> overridden = new ListBuffer<>();
outer: f... | java |
public boolean isEqualityComparable(Type s, Type t, Warner warn) {
if (t.isNumeric() && s.isNumeric())
return true;
boolean tPrimitive = t.isPrimitive();
boolean sPrimitive = s.isPrimitive();
if (!tPrimitive && !sPrimitive) {
return isCastable(s, t, warn) || isCa... | java |
public Type elemtype(Type t) {
switch (t.getTag()) {
case WILDCARD:
return elemtype(wildUpperBound(t));
case ARRAY:
t = t.unannotatedType();
return ((ArrayType)t).elemtype;
case FORALL:
return elemtype(((ForAll)t).qtype);
case ERROR... | java |
public int rank(Type t) {
t = t.unannotatedType();
switch(t.getTag()) {
case CLASS: {
ClassType cls = (ClassType)t;
if (cls.rank_field < 0) {
Name fullname = cls.tsym.getQualifiedName();
if (fullname == names.java_lang_Object)
... | java |
public boolean covariantReturnType(Type t, Type s, Warner warner) {
return
isSameType(t, s) ||
allowCovariantReturns &&
!t.isPrimitive() &&
!s.isPrimitive() &&
isAssignable(t, s, warner);
} | java |
public ClassSymbol boxedClass(Type t) {
return reader.enterClass(syms.boxedName[t.getTag().ordinal()]);
} | java |
protected String getSpace(Request req) {
String spaceToken = req.headers(SPACE_TOKEN_HEADER);
if (StringUtils.isBlank(spaceToken)) {
throw new MissingSpaceTokenException("Missing header '" + SPACE_TOKEN_HEADER + "'.");
}
String space = this.spacesService.getSpaceForAuthentic... | java |
public WithCache.CacheState getCacheState() {
return new WithCache.CacheState(size(), _max, _get, _hit, _rep);
} | java |
static Class<?> resolveParameterName(String parameterName, Class<?> target) {
Map<Type, Type> typeVariableMap = getTypeVariableMap(target);
Set<Entry<Type, Type>> set = typeVariableMap.entrySet();
Type type = Object.class;
for (Entry<Type, Type> entry : set) {
if (entry.getKey().toString().equals... | java |
public List<Widget> putFactories(Iterable<? extends IWidgetFactory> factories) throws IndexOutOfBoundsException {
List<Widget> instances = new LinkedList<Widget>();
for (IWidgetFactory factory : factories) {
instances.add(put(factory));
}
return instances;
} | java |
protected List<File> getSpooledFileList()
{
final List<File> spooledFileList = new ArrayList<File>();
for (final File file : spoolDirectory.listFiles()) {
if (file.isFile()) {
spooledFileList.add(file);
}
}
return spooledFileList;
} | java |
public void add(Collection<Application> applications)
{
for(Application application : applications)
this.applications.put(application.getId(), application);
} | java |
public ApplicationHostCache applicationHosts(long applicationId)
{
ApplicationHostCache cache = applicationHosts.get(applicationId);
if(cache == null)
applicationHosts.put(applicationId, cache = new ApplicationHostCache(applicationId));
return cache;
} | java |
public KeyTransactionCache keyTransactions(long applicationId)
{
KeyTransactionCache cache = keyTransactions.get(applicationId);
if(cache == null)
keyTransactions.put(applicationId, cache = new KeyTransactionCache(applicationId));
return cache;
} | java |
public void addKeyTransactions(Collection<KeyTransaction> keyTransactions)
{
for(KeyTransaction keyTransaction : keyTransactions)
{
// Add the transaction to any applications it is associated with
long applicationId = keyTransaction.getLinks().getApplication();
Ap... | java |
public DeploymentCache deployments(long applicationId)
{
DeploymentCache cache = deployments.get(applicationId);
if(cache == null)
deployments.put(applicationId, cache = new DeploymentCache(applicationId));
return cache;
} | java |
public LabelCache labels(long applicationId)
{
LabelCache cache = labels.get(applicationId);
if(cache == null)
labels.put(applicationId, cache = new LabelCache(applicationId));
return cache;
} | java |
public void addLabel(Label label)
{
// Add the label to any applications it is associated with
List<Long> applicationIds = label.getLinks().getApplications();
for(long applicationId : applicationIds)
{
Application application = applications.get(applicationId);
... | java |
private static <T, R> Function<T, R> doThrow(Supplier<? extends RuntimeException> exceptionSupplier) {
return t -> {
throw exceptionSupplier.get();
};
} | java |
@SuppressWarnings("unchecked")
public <E extends BaseException> E put(String name, Object value) {
properties.put(name, value);
return (E) this;
} | java |
@GET
@PermitAll
@Path("uniquetag/{uniqueTag}")
public Response findByUniqueTag(@PathParam("uniqueTag") String uniqueTag) {
checkNotNull(uniqueTag);
DContact contact = dao.findByUniqueTag(null, uniqueTag);
return null != contact ? Response.ok(contact).build() : Response.status(Response.Status.NOT_FOU... | java |
public static void generate(ConfigurationImpl configuration) {
ProfileIndexFrameWriter profilegen;
DocPath filename = DocPaths.PROFILE_OVERVIEW_FRAME;
try {
profilegen = new ProfileIndexFrameWriter(configuration, filename);
profilegen.buildProfileIndexFile("doclet.Window_... | java |
protected Content getProfile(String profileName) {
Content profileLinkContent;
Content profileLabel;
profileLabel = new StringContent(profileName);
profileLinkContent = getHyperLink(DocPaths.profileFrame(profileName), profileLabel, "",
"packageListFrame");
Con... | java |
public void newRound(Context context) {
this.context = context;
this.log = Log.instance(context);
clearRoundState();
} | java |
public static GameSettings getInstance() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new GamePermission("readSettings"));
}
return INSTANCE;
} | java |
public static ClassFileReader newInstance(Path path, JarFile jf) throws IOException {
return new JarFileReader(path, jf);
} | java |
Type rawInstantiate(Env<AttrContext> env,
Type site,
Symbol m,
ResultInfo resultInfo,
List<Type> argtypes,
List<Type> typeargtypes,
boolean allowBoxing,
... | java |
@SuppressWarnings("fallthrough")
Symbol selectBest(Env<AttrContext> env,
Type site,
List<Type> argtypes,
List<Type> typeargtypes,
Symbol sym,
Symbol bestSoFar,
boolean allowBoxing,
... | java |
Symbol findMethod(Env<AttrContext> env,
Type site,
Name name,
List<Type> argtypes,
List<Type> typeargtypes,
boolean allowBoxing,
boolean useVarargs,
boolean operator)... | java |
public void printscopes(Scope s) {
while (s != null) {
if (s.owner != null)
System.err.print(s.owner + ": ");
for (Scope.Entry e = s.elems; e != null; e = e.sibling) {
if ((e.sym.flags() & ABSTRACT) != 0)
System.err.print("abstract ");
... | java |
Symbol resolveBinaryOperator(DiagnosticPosition pos,
JCTree.Tag optag,
Env<AttrContext> env,
Type left,
Type right) {
return resolveOperator(pos, optag, env, List.of(left, right));... | java |
private boolean matches(String classname, AccessFlags flags) {
if (options.apiOnly && !flags.is(AccessFlags.ACC_PUBLIC)) {
return false;
} else if (options.includePattern != null) {
return options.includePattern.matcher(classname.replace('/', '.')).matches();
} else {
... | java |
private String replacementFor(String cn) {
String name = cn;
String value = null;
while (value == null && name != null) {
try {
value = ResourceBundleHelper.jdkinternals.getString(name);
} catch (MissingResourceException e) {
// go up one s... | java |
@Override
public void setContract(Contract c) {
super.setContract(c);
for (Field f : params) {
f.setContract(c);
}
if (returns != null) {
returns.setContract(c);
}
} | java |
public Object invoke(RpcRequest req, Object handler)
throws RpcException, IllegalAccessException, InvocationTargetException {
if (contract == null) {
throw new IllegalStateException("contract cannot be null");
}
if (req == null) {
throw new IllegalArgumentExceptio... | java |
public Object[] marshalParams(RpcRequest req) throws RpcException {
Object[] converted = new Object[params.size()];
Object[] reqParams = req.getParams();
if (reqParams.length != converted.length) {
String msg = "Function '" + req.getMethod() + "' expects " +
param... | java |
public Object unmarshalResult(Object respObj) throws RpcException {
if (returns == null) {
if (respObj != null) {
throw new IllegalArgumentException("Function " + name +
" is a notification and should not have a result");
... | java |
public Object[] unmarshalParams(RpcRequest req) throws RpcException {
Object reqParams[] = req.getParams();
if (reqParams.length != params.size()) {
String msg = "Function '" + req.getMethod() + "' expects " +
params.size() + " param(s). " + reqParams.length + " given.";
... | java |
@Nullable
public static String getCompactMessage (final String sMsg)
{
UPCA.validateMessage (sMsg);
final String sUPCA = UPCA.handleChecksum (sMsg, EEANChecksumMode.AUTO);
final byte nNumberSystem = _extractNumberSystem (sUPCA);
if (nNumberSystem != 0 && nNumberSystem != 1)
return null;
f... | java |
@Nonnull
public static String getExpandedMessage (@Nonnull final String sMsg)
{
final char cCheck = sMsg.length () == 8 ? sMsg.charAt (7) : '\u0000';
final String sUpce = sMsg.substring (0, 0 + 7);
final byte nNumberSystem = _extractNumberSystem (sUpce);
if (nNumberSystem != 0 && nNumberSystem != 1)... | java |
@Nonnull
public static EValidity validateMessage (@Nullable final String sMsg)
{
final int nLen = StringHelper.getLength (sMsg);
if (nLen >= 7 && nLen <= 8)
{
final byte nNumberSystem = _extractNumberSystem (sMsg);
if (nNumberSystem >= 0 && nNumberSystem <= 1)
return EValidity.VALID;... | java |
public Iterable<DUser> queryByBirthInfo(java.lang.String birthInfo) {
return queryByField(null, DUserMapper.Field.BIRTHINFO.getFieldName(), birthInfo);
} | java |
public Iterable<DUser> queryByFriends(java.lang.Object friends) {
return queryByField(null, DUserMapper.Field.FRIENDS.getFieldName(), friends);
} | java |
public Iterable<DUser> queryByPassword(java.lang.String password) {
return queryByField(null, DUserMapper.Field.PASSWORD.getFieldName(), password);
} | java |
public Iterable<DUser> queryByPhoneNumber1(java.lang.String phoneNumber1) {
return queryByField(null, DUserMapper.Field.PHONENUMBER1.getFieldName(), phoneNumber1);
} | java |
public Iterable<DUser> queryByPhoneNumber2(java.lang.String phoneNumber2) {
return queryByField(null, DUserMapper.Field.PHONENUMBER2.getFieldName(), phoneNumber2);
} | java |
public Iterable<DUser> queryByPreferredLanguage(java.lang.String preferredLanguage) {
return queryByField(null, DUserMapper.Field.PREFERREDLANGUAGE.getFieldName(), preferredLanguage);
} | java |
public Iterable<DUser> queryByTimeZoneCanonicalId(java.lang.String timeZoneCanonicalId) {
return queryByField(null, DUserMapper.Field.TIMEZONECANONICALID.getFieldName(), timeZoneCanonicalId);
} | java |
public DUser findByUsername(java.lang.String username) {
return queryUniqueByField(null, DUserMapper.Field.USERNAME.getFieldName(), username);
} | java |
public <T> T executeSelect(Connection conn, DataObject object, ResultSetWorker<T> worker) throws Exception {
PreparedStatement statement = conn.prepareStatement(_sql);
try {
load(statement, object);
return worker.process(statement.executeQuery());
} finally {
... | java |
public ClassDoc[] enums() {
ListBuffer<ClassDocImpl> ret = new ListBuffer<ClassDocImpl>();
for (ClassDocImpl c : getClasses(true)) {
if (c.isEnum()) {
ret.append(c);
}
}
return ret.toArray(new ClassDocImpl[ret.length()]);
} | java |
public ClassDoc[] interfaces() {
ListBuffer<ClassDocImpl> ret = new ListBuffer<ClassDocImpl>();
for (ClassDocImpl c : getClasses(true)) {
if (c.isInterface()) {
ret.append(c);
}
}
return ret.toArray(new ClassDocImpl[ret.length()]);
} | java |
public Rejected acquirePermits(long number, long nanoTime) {
for (int i = 0; i < backPressureList.size(); ++i) {
BackPressure<Rejected> bp = backPressureList.get(i);
Rejected rejected = bp.acquirePermit(number, nanoTime);
if (rejected != null) {
rejectedCounts... | java |
public void releasePermitsWithoutResult(long number, long nanoTime) {
for (BackPressure<Rejected> backPressure : backPressureList) {
backPressure.releasePermit(number, nanoTime);
}
} | java |
@GET
@Path("{taskName}")
public Response enqueueTask(@PathParam("taskName") String taskName) {
checkNotNull(taskName);
taskQueue.enqueueTask(taskName, requestParamsProvider.get());
return Response.ok().build();
} | java |
@POST
@Path("{taskName}")
public Response processTask(@PathParam("taskName") String taskName) {
checkNotNull(requestParamsProvider.get());
checkNotNull(taskName);
LOGGER.info("Processing task for {}...", taskName);
for (AdminTask adminTask : adminTasks) {
final Object body = adminTask.process... | java |
public void run(Map<String, Object> extra) {
if (getParameterConfig() != null)
{
Boolean parametersRequired = false;
List<String> requiredParameters = new ArrayList<String>();
for (ParamConfig paramConfig : getParameterConfig())
{
if (Boole... | java |
public static Date getDateFromString(final String dateString, final String pattern) {
try {
SimpleDateFormat df = buildDateFormat(pattern);
return df.parse(dateString);
} catch (ParseException e) {
throw new DateException(String.format("Could not parse %s with pattern %s.", dateString,
... | java |
public static String getDateFormat(final Date date, final String pattern) {
SimpleDateFormat simpleDateFormat = buildDateFormat(pattern);
return simpleDateFormat.format(date);
} | java |
public static Date getDateOfSecondsBack(final int secondsBack, final Date date) {
return dateBack(Calendar.SECOND, secondsBack, date);
} | java |
public static Date getDateOfMinutesBack(final int minutesBack, final Date date) {
return dateBack(Calendar.MINUTE, minutesBack, date);
} | java |
public static Date getDateOfHoursBack(final int hoursBack, final Date date) {
return dateBack(Calendar.HOUR_OF_DAY, hoursBack, date);
} | java |
public static Date getDateOfDaysBack(final int daysBack, final Date date) {
return dateBack(Calendar.DAY_OF_MONTH, daysBack, date);
} | java |
public static Date getDateOfWeeksBack(final int weeksBack, final Date date) {
return dateBack(Calendar.WEEK_OF_MONTH, weeksBack, date);
} | java |
public static Date getDateOfMonthsBack(final int monthsBack, final Date date) {
return dateBack(Calendar.MONTH, monthsBack, date);
} | java |
public static Date getDateOfYearsBack(final int yearsBack, final Date date) {
return dateBack(Calendar.YEAR, yearsBack, date);
} | java |
public static boolean isLastDayOfTheMonth(final Date date) {
Date dateOfMonthsBack = getDateOfMonthsBack(-1, date);
int dayOfMonth = getDayOfMonth(dateOfMonthsBack);
Date dateOfDaysBack = getDateOfDaysBack(dayOfMonth, dateOfMonthsBack);
return dateOfDaysBack.equals(date);
} | java |
public static long subSeconds(final Date date1, final Date date2) {
return subTime(date1, date2, DatePeriod.SECOND);
} | java |
public static long subMinutes(final Date date1, final Date date2) {
return subTime(date1, date2, DatePeriod.MINUTE);
} | java |
public static long subHours(final Date date1, final Date date2) {
return subTime(date1, date2, DatePeriod.HOUR);
} | java |
public static long subDays(final Date date1, final Date date2) {
return subTime(date1, date2, DatePeriod.DAY);
} | java |
public static long subMonths(final String dateString1, final String dateString2) {
Date date1 = getDateFromString(dateString1, DEFAULT_DATE_SIMPLE_PATTERN);
Date date2 = getDateFromString(dateString2, DEFAULT_DATE_SIMPLE_PATTERN);
return subMonths(date1, date2);
} | java |
public static long subMonths(final Date date1, final Date date2) {
Calendar calendar1 = buildCalendar(date1);
int monthOfDate1 = calendar1.get(Calendar.MONTH);
int yearOfDate1 = calendar1.get(Calendar.YEAR);
Calendar calendar2 = buildCalendar(date2);
int monthOfDate2 = calendar2.get(Calendar.MONTH)... | java |
public static long subYears(final Date date1, final Date date2) {
return Math.abs(getYear(date1) - getYear(date2));
} | java |
private static SimpleDateFormat buildDateFormat(final String pattern) {
SimpleDateFormat simpleDateFormat = simpleDateFormatCache.get();
if (simpleDateFormat == null) {
simpleDateFormat = new SimpleDateFormat();
simpleDateFormatCache.set(simpleDateFormat);
}
simpleDateFormat.applyPattern(pa... | java |
Type fold1(int opcode, Type operand) {
try {
Object od = operand.constValue();
switch (opcode) {
case nop:
return operand;
case ineg: // unary -
return syms.intType.constType(-intValue(od));
case ixor: // ~
... | java |
public synchronized void addHandler(Class iface, Object handler) {
try {
iface.cast(handler);
}
catch (Exception e) {
throw new IllegalArgumentException("Handler: " + handler.getClass().getName() +
" does not implement: " + i... | java |
@SuppressWarnings("unchecked")
public void call(Serializer ser, InputStream is, OutputStream os)
throws IOException {
Object obj = null;
try {
obj = ser.readMapOrList(is);
}
catch (Exception e) {
String msg = "Unable to deserialize request: " + e.get... | java |
public RpcResponse call(RpcRequest req) {
for (Filter filter : filters) {
RpcRequest tmp = filter.alterRequest(req);
if (tmp != null) {
req = tmp;
}
}
RpcResponse resp = null;
for (Filter filter : filters) {
resp = filter.... | java |
public static String doGet(final String url, final int retryTimes) {
try {
return doGetByLoop(url, retryTimes);
} catch (HttpException e) {
throw new HttpException(format("Failed to download content for url: '%s'. Tried '%s' times",
url, Math.max(retryTimes + 1, 1)));
}
} | java |
public static String doPost(final String action, final Map<String, String> parameters,
final int retryTimes) {
try {
return doPostByLoop(action, parameters, retryTimes);
} catch (HttpException e) {
throw new HttpException(format(
"Failed to download content for action url: '%s' with par... | java |
public <A extends Appendable> A document(A output) throws IOException {
StringBuilder line = new StringBuilder();
for (Field field: Beans.getKnownInstanceFields(_prototype)) {
description d = field.getAnnotation(description.class);
if (d == null) continue;
placeholde... | java |
public static InetAddress getAddress(String host) throws UnknownHostException {
if (timeToClean()) {
synchronized (storedAddresses) {
if (timeToClean()) {
cleanOldAddresses();
}
}
}
Pair<InetAddress, Long> cachedAddress;... | java |
private VarSymbol enterConstant(String name, Type type) {
VarSymbol c = new VarSymbol(
PUBLIC | STATIC | FINAL,
names.fromString(name),
type,
predefClass);
c.setData(type.constValue());
predefClass.members().enter(c);
return c;
} | java |
private void enterBinop(String name,
Type left, Type right, Type res,
int opcode) {
predefClass.members().enter(
new OperatorSymbol(
makeOperatorName(name),
new MethodType(List.of(left, right), res,
... | java |
private OperatorSymbol enterUnop(String name,
Type arg,
Type res,
int opcode) {
OperatorSymbol sym =
new OperatorSymbol(makeOperatorName(name),
new MethodType... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.