_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q19600 | Resolve.printscopes | train | 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 ");
System.err.print(e.sym + " ");
}
System.err.println();
s = s.next;
}
} | java | {
"resource": ""
} |
q19601 | Resolve.resolveBinaryOperator | train | Symbol resolveBinaryOperator(DiagnosticPosition pos,
JCTree.Tag optag,
Env<AttrContext> env,
Type left,
Type right) {
return resolveOperator(pos, optag, env, List.of(left, right));
} | java | {
"resource": ""
} |
q19602 | JdepsTask.matches | train | 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 {
return true;
}
} | java | {
"resource": ""
} |
q19603 | JdepsTask.replacementFor | train | 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 subpackage level
int i = name.lastIndexOf('.');
name = i > 0 ? name.substring(0, i) : null;
}
}
return value;
} | java | {
"resource": ""
} |
q19604 | Function.setContract | train | @Override
public void setContract(Contract c) {
super.setContract(c);
for (Field f : params) {
f.setContract(c);
}
if (returns != null) {
returns.setContract(c);
}
} | java | {
"resource": ""
} |
q19605 | Function.invoke | train | 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 IllegalArgumentException("req cannot be null");
}
if (handler == null) {
throw new IllegalArgumentException("handler cannot be null");
}
Method method = getMethod(handler);
Object reqParams[] = unmarshalParams(req, method);
return marshalResult(method.invoke(handler, reqParams));
} | java | {
"resource": ""
} |
q19606 | Function.marshalParams | train | 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 " +
params.size() + " param(s). " + reqParams.length + " given.";
throw invParams(msg);
}
for (int i = 0; i < converted.length; i++) {
converted[i] = params.get(i).getTypeConverter().marshal(reqParams[i]);
}
return converted;
} | java | {
"resource": ""
} |
q19607 | Function.unmarshalResult | train | 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");
}
}
return returns.getTypeConverter().unmarshal(respObj);
} | java | {
"resource": ""
} |
q19608 | Function.unmarshalParams | train | 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.";
throw invParams(msg);
}
Object convParams[] = new Object[reqParams.length];
for (int i = 0; i < convParams.length; i++) {
convParams[i] = params.get(i).getTypeConverter().unmarshal(reqParams[i]);
}
return convParams;
} | java | {
"resource": ""
} |
q19609 | UPCE.getCompactMessage | train | @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;
final byte nCheck = StringParser.parseByte (sUPCA.substring (11, 12), (byte) -1);
if (nCheck == (byte) -1)
return null;
final StringBuilder aSB = new StringBuilder ();
aSB.append (Byte.toString (nNumberSystem));
final String manufacturer = sUPCA.substring (1, 1 + 5);
final String product = sUPCA.substring (6, 6 + 5);
// Rule 1
String mtemp = manufacturer.substring (2, 2 + 3);
String ptemp = product.substring (0, 0 + 2);
if ("000|100|200".indexOf (mtemp) >= 0 && "00".equals (ptemp))
{
aSB.append (manufacturer.substring (0, 2));
aSB.append (product.substring (2, 2 + 3));
aSB.append (mtemp.charAt (0));
}
else
{
// Rule 2
ptemp = product.substring (0, 0 + 3);
if ("300|400|500|600|700|800|900".indexOf (mtemp) >= 0 && "000".equals (ptemp))
{
aSB.append (manufacturer.substring (0, 0 + 3));
aSB.append (product.substring (3, 3 + 2));
aSB.append ('3');
}
else
{
// Rule 3
mtemp = manufacturer.substring (3, 3 + 2);
ptemp = product.substring (0, 0 + 4);
if ("10|20|30|40|50|60|70|80|90".indexOf (mtemp) >= 0 && "0000".equals (ptemp))
{
aSB.append (manufacturer.substring (0, 0 + 4));
aSB.append (product.substring (4, 4 + 1));
aSB.append ('4');
}
else
{
// Rule 4
mtemp = manufacturer.substring (4, 4 + 1);
ptemp = product.substring (4, 4 + 1);
if (!"0".equals (mtemp) && "5|6|7|8|9".indexOf (ptemp) >= 0)
{
aSB.append (manufacturer);
aSB.append (ptemp);
}
else
{
return null;
}
}
}
}
aSB.append (Byte.toString (nCheck));
return aSB.toString ();
} | java | {
"resource": ""
} |
q19610 | UPCE.getExpandedMessage | train | @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)
throw new IllegalArgumentException ("Invalid UPC-E message: " + sMsg);
final StringBuilder aSB = new StringBuilder ();
aSB.append (Byte.toString (nNumberSystem));
final byte nMode = StringParser.parseByte (sUpce.substring (6, 6 + 1), (byte) -1);
if (nMode >= 0 && nMode <= 2)
{
aSB.append (sUpce.substring (1, 1 + 2));
aSB.append (Byte.toString (nMode));
aSB.append ("0000");
aSB.append (sUpce.substring (3, 3 + 3));
}
else
if (nMode == 3)
{
aSB.append (sUpce.substring (1, 1 + 3));
aSB.append ("00000");
aSB.append (sUpce.substring (4, 4 + 2));
}
else
if (nMode == 4)
{
aSB.append (sUpce.substring (1, 1 + 4));
aSB.append ("00000");
aSB.append (sUpce.substring (5, 5 + 1));
}
else
if (nMode >= 5 && nMode <= 9)
{
aSB.append (sUpce.substring (1, 1 + 5));
aSB.append ("0000");
aSB.append (Byte.toString (nMode));
}
else
{
// Shouldn't happen
throw new IllegalArgumentException ("Internal error");
}
final String sUpcaFinished = aSB.toString ();
final char cExpectedCheck = calcChecksumChar (sUpcaFinished, sUpcaFinished.length ());
if (cCheck != '\u0000' && cCheck != cExpectedCheck)
throw new IllegalArgumentException ("Invalid checksum. Expected " + cExpectedCheck + " but was " + cCheck);
return sUpcaFinished + cExpectedCheck;
} | java | {
"resource": ""
} |
q19611 | UPCE.validateMessage | train | @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;
}
return EValidity.INVALID;
} | java | {
"resource": ""
} |
q19612 | GeneratedDUserDaoImpl.queryByBirthInfo | train | public Iterable<DUser> queryByBirthInfo(java.lang.String birthInfo) {
return queryByField(null, DUserMapper.Field.BIRTHINFO.getFieldName(), birthInfo);
} | java | {
"resource": ""
} |
q19613 | GeneratedDUserDaoImpl.queryByFriends | train | public Iterable<DUser> queryByFriends(java.lang.Object friends) {
return queryByField(null, DUserMapper.Field.FRIENDS.getFieldName(), friends);
} | java | {
"resource": ""
} |
q19614 | GeneratedDUserDaoImpl.queryByPassword | train | public Iterable<DUser> queryByPassword(java.lang.String password) {
return queryByField(null, DUserMapper.Field.PASSWORD.getFieldName(), password);
} | java | {
"resource": ""
} |
q19615 | GeneratedDUserDaoImpl.queryByPhoneNumber1 | train | public Iterable<DUser> queryByPhoneNumber1(java.lang.String phoneNumber1) {
return queryByField(null, DUserMapper.Field.PHONENUMBER1.getFieldName(), phoneNumber1);
} | java | {
"resource": ""
} |
q19616 | GeneratedDUserDaoImpl.queryByPhoneNumber2 | train | public Iterable<DUser> queryByPhoneNumber2(java.lang.String phoneNumber2) {
return queryByField(null, DUserMapper.Field.PHONENUMBER2.getFieldName(), phoneNumber2);
} | java | {
"resource": ""
} |
q19617 | GeneratedDUserDaoImpl.queryByPreferredLanguage | train | public Iterable<DUser> queryByPreferredLanguage(java.lang.String preferredLanguage) {
return queryByField(null, DUserMapper.Field.PREFERREDLANGUAGE.getFieldName(), preferredLanguage);
} | java | {
"resource": ""
} |
q19618 | GeneratedDUserDaoImpl.queryByTimeZoneCanonicalId | train | public Iterable<DUser> queryByTimeZoneCanonicalId(java.lang.String timeZoneCanonicalId) {
return queryByField(null, DUserMapper.Field.TIMEZONECANONICALID.getFieldName(), timeZoneCanonicalId);
} | java | {
"resource": ""
} |
q19619 | GeneratedDUserDaoImpl.findByUsername | train | public DUser findByUsername(java.lang.String username) {
return queryUniqueByField(null, DUserMapper.Field.USERNAME.getFieldName(), username);
} | java | {
"resource": ""
} |
q19620 | ParametricQuery.executeSelect | train | 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 {
statement.close();
}
} | java | {
"resource": ""
} |
q19621 | PackageDocImpl.enums | train | 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 | {
"resource": ""
} |
q19622 | PackageDocImpl.interfaces | train | 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 | {
"resource": ""
} |
q19623 | GuardRail.acquirePermits | train | 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.write(rejected, number, nanoTime);
for (int j = 0; j < i; ++j) {
backPressureList.get(j).releasePermit(number, nanoTime);
}
return rejected;
}
}
return null;
} | java | {
"resource": ""
} |
q19624 | GuardRail.releasePermitsWithoutResult | train | public void releasePermitsWithoutResult(long number, long nanoTime) {
for (BackPressure<Rejected> backPressure : backPressureList) {
backPressure.releasePermit(number, nanoTime);
}
} | java | {
"resource": ""
} |
q19625 | AdminTaskResource.enqueueTask | train | @GET
@Path("{taskName}")
public Response enqueueTask(@PathParam("taskName") String taskName) {
checkNotNull(taskName);
taskQueue.enqueueTask(taskName, requestParamsProvider.get());
return Response.ok().build();
} | java | {
"resource": ""
} |
q19626 | AdminTaskResource.processTask | train | @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.processTask(taskName, requestParamsProvider.get());
LOGGER.info("Processed tasks for {}: {}", taskName, body);
}
return Response.ok().build();
} | java | {
"resource": ""
} |
q19627 | ReportConnector.run | train | public void run(Map<String, Object> extra) {
if (getParameterConfig() != null)
{
Boolean parametersRequired = false;
List<String> requiredParameters = new ArrayList<String>();
for (ParamConfig paramConfig : getParameterConfig())
{
if (BooleanUtils.isTrue(paramConfig.getRequired()))
{
try {
if (StringUtils.isBlank(ObjectUtils.toString(PropertyUtils.getProperty(paramConfig, "value"))))
{
parametersRequired = true;
requiredParameters.add(paramConfig.getName());
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
}
if (parametersRequired)
{
errors.add("Some required parameters weren't filled in: " + StringUtils.join(requiredParameters ,", ")+ ".");
return;
}
}
runReport(extra);
} | java | {
"resource": ""
} |
q19628 | DateUtils.getDateFromString | train | 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,
pattern), e);
}
} | java | {
"resource": ""
} |
q19629 | DateUtils.getDateFormat | train | public static String getDateFormat(final Date date, final String pattern) {
SimpleDateFormat simpleDateFormat = buildDateFormat(pattern);
return simpleDateFormat.format(date);
} | java | {
"resource": ""
} |
q19630 | DateUtils.getDateOfSecondsBack | train | public static Date getDateOfSecondsBack(final int secondsBack, final Date date) {
return dateBack(Calendar.SECOND, secondsBack, date);
} | java | {
"resource": ""
} |
q19631 | DateUtils.getDateOfMinutesBack | train | public static Date getDateOfMinutesBack(final int minutesBack, final Date date) {
return dateBack(Calendar.MINUTE, minutesBack, date);
} | java | {
"resource": ""
} |
q19632 | DateUtils.getDateOfHoursBack | train | public static Date getDateOfHoursBack(final int hoursBack, final Date date) {
return dateBack(Calendar.HOUR_OF_DAY, hoursBack, date);
} | java | {
"resource": ""
} |
q19633 | DateUtils.getDateOfDaysBack | train | public static Date getDateOfDaysBack(final int daysBack, final Date date) {
return dateBack(Calendar.DAY_OF_MONTH, daysBack, date);
} | java | {
"resource": ""
} |
q19634 | DateUtils.getDateOfWeeksBack | train | public static Date getDateOfWeeksBack(final int weeksBack, final Date date) {
return dateBack(Calendar.WEEK_OF_MONTH, weeksBack, date);
} | java | {
"resource": ""
} |
q19635 | DateUtils.getDateOfMonthsBack | train | public static Date getDateOfMonthsBack(final int monthsBack, final Date date) {
return dateBack(Calendar.MONTH, monthsBack, date);
} | java | {
"resource": ""
} |
q19636 | DateUtils.getDateOfYearsBack | train | public static Date getDateOfYearsBack(final int yearsBack, final Date date) {
return dateBack(Calendar.YEAR, yearsBack, date);
} | java | {
"resource": ""
} |
q19637 | DateUtils.isLastDayOfTheMonth | train | 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 | {
"resource": ""
} |
q19638 | DateUtils.subSeconds | train | public static long subSeconds(final Date date1, final Date date2) {
return subTime(date1, date2, DatePeriod.SECOND);
} | java | {
"resource": ""
} |
q19639 | DateUtils.subMinutes | train | public static long subMinutes(final Date date1, final Date date2) {
return subTime(date1, date2, DatePeriod.MINUTE);
} | java | {
"resource": ""
} |
q19640 | DateUtils.subHours | train | public static long subHours(final Date date1, final Date date2) {
return subTime(date1, date2, DatePeriod.HOUR);
} | java | {
"resource": ""
} |
q19641 | DateUtils.subDays | train | public static long subDays(final Date date1, final Date date2) {
return subTime(date1, date2, DatePeriod.DAY);
} | java | {
"resource": ""
} |
q19642 | DateUtils.subMonths | train | 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 | {
"resource": ""
} |
q19643 | DateUtils.subMonths | train | 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);
int yearOfDate2 = calendar2.get(Calendar.YEAR);
int subMonth = Math.abs(monthOfDate1 - monthOfDate2);
int subYear = Math.abs(yearOfDate1 - yearOfDate2);
return subYear * 12 + subMonth;
} | java | {
"resource": ""
} |
q19644 | DateUtils.subYears | train | public static long subYears(final Date date1, final Date date2) {
return Math.abs(getYear(date1) - getYear(date2));
} | java | {
"resource": ""
} |
q19645 | DateUtils.buildDateFormat | train | private static SimpleDateFormat buildDateFormat(final String pattern) {
SimpleDateFormat simpleDateFormat = simpleDateFormatCache.get();
if (simpleDateFormat == null) {
simpleDateFormat = new SimpleDateFormat();
simpleDateFormatCache.set(simpleDateFormat);
}
simpleDateFormat.applyPattern(pattern);
return simpleDateFormat;
} | java | {
"resource": ""
} |
q19646 | ConstFold.fold1 | train | 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: // ~
return syms.intType.constType(~intValue(od));
case bool_not: // !
return syms.booleanType.constType(b2i(intValue(od) == 0));
case ifeq:
return syms.booleanType.constType(b2i(intValue(od) == 0));
case ifne:
return syms.booleanType.constType(b2i(intValue(od) != 0));
case iflt:
return syms.booleanType.constType(b2i(intValue(od) < 0));
case ifgt:
return syms.booleanType.constType(b2i(intValue(od) > 0));
case ifle:
return syms.booleanType.constType(b2i(intValue(od) <= 0));
case ifge:
return syms.booleanType.constType(b2i(intValue(od) >= 0));
case lneg: // unary -
return syms.longType.constType(new Long(-longValue(od)));
case lxor: // ~
return syms.longType.constType(new Long(~longValue(od)));
case fneg: // unary -
return syms.floatType.constType(new Float(-floatValue(od)));
case dneg: // ~
return syms.doubleType.constType(new Double(-doubleValue(od)));
default:
return null;
}
} catch (ArithmeticException e) {
return null;
}
} | java | {
"resource": ""
} |
q19647 | Server.addHandler | train | 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: " + iface.getName());
}
if (contract.getInterfaces().get(iface.getSimpleName()) == null) {
throw new IllegalArgumentException("Interface: " + iface.getName() +
" is not a part of this Contract");
}
if (contract.getPackage() == null) {
setContractPackage(iface);
}
handlers.put(iface.getSimpleName(), handler);
} | java | {
"resource": ""
} |
q19648 | Server.call | train | @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.getMessage();
ser.write(new RpcResponse(null, RpcException.Error.PARSE.exc(msg)).marshal(), os);
return;
}
if (obj instanceof List) {
List list = (List)obj;
List respList = new ArrayList();
for (Object o : list) {
RpcRequest rpcReq = new RpcRequest((Map)o);
respList.add(call(rpcReq).marshal());
}
ser.write(respList, os);
}
else if (obj instanceof Map) {
RpcRequest rpcReq = new RpcRequest((Map)obj);
ser.write(call(rpcReq).marshal(), os);
}
else {
ser.write(new RpcResponse(null, RpcException.Error.INVALID_REQ.exc("Invalid Request")).marshal(), os);
}
} | java | {
"resource": ""
} |
q19649 | Server.call | train | 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.preInvoke(req);
if (resp != null) {
break;
}
}
if (resp == null) {
resp = callInternal(req);
}
for (int i = filters.size() - 1; i >= 0; i--) {
RpcResponse tmp = filters.get(i).postInvoke(req, resp);
if (tmp != null) {
resp = tmp;
}
}
return resp;
} | java | {
"resource": ""
} |
q19650 | HttpUtils.doGet | train | 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 | {
"resource": ""
} |
q19651 | HttpUtils.doPost | train | 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 parameters. Tried '%s' times",
action, parameters, Math.max(retryTimes + 1, 1)));
}
} | java | {
"resource": ""
} |
q19652 | Options.document | train | 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;
placeholder p = field.getAnnotation(placeholder.class);
String n = Strings.splitCamelCase(field.getName(), "-").toLowerCase();
char key = getShortOptionKey(field);
if ((field.getType() == Boolean.class || field.getType() == Boolean.TYPE) && _booleans.containsKey(key)) {
line.append(" -").append(key).append(", --").append(n);
} else {
line.append(" --").append(n).append('=').append(p != null ? p.value() : "value");
}
if (line.length() < 16) {
for (int i = line.length(); i < 16; ++i) line.append(' ');
line.append(d.value());
} else {
line.append("\n\t\t").append(d.value());
}
output.append(line.toString()).append('\n');
line.setLength(0);
}
return output;
} | java | {
"resource": ""
} |
q19653 | ExtraDNSCache.getAddress | train | public static InetAddress getAddress(String host) throws UnknownHostException {
if (timeToClean()) {
synchronized (storedAddresses) {
if (timeToClean()) {
cleanOldAddresses();
}
}
}
Pair<InetAddress, Long> cachedAddress;
synchronized (storedAddresses) {
cachedAddress = storedAddresses.get(host);
}
if (cachedAddress != null) {
//host DNS entry was cached
InetAddress address = cachedAddress.getFirst();
if (address == null) {
throw new UnknownHostException("Could not find host " + host + " (cached response)");
} else {
return address;
}
} else {
//host DNS entry was not cached
fetchDnsAddressLock.acquireUninterruptibly();
try {
InetAddress addr = InetAddress.getByName(host);
synchronized (storedAddresses) {
storedAddresses.put(host, new Pair<>(addr, System.currentTimeMillis()));
}
return addr;
} catch (UnknownHostException exp) {
synchronized (storedAddresses) {
storedAddresses.put(host, new Pair<InetAddress, Long>(null, System.currentTimeMillis()));
}
Log.i("[Dns lookup] " + host + " --> not found");
throw exp;
} finally {
fetchDnsAddressLock.release();
}
}
} | java | {
"resource": ""
} |
q19654 | Symtab.enterConstant | train | 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 | {
"resource": ""
} |
q19655 | Symtab.enterBinop | train | 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,
List.<Type>nil(), methodClass),
opcode,
predefClass));
} | java | {
"resource": ""
} |
q19656 | Symtab.enterUnop | train | private OperatorSymbol enterUnop(String name,
Type arg,
Type res,
int opcode) {
OperatorSymbol sym =
new OperatorSymbol(makeOperatorName(name),
new MethodType(List.of(arg),
res,
List.<Type>nil(),
methodClass),
opcode,
predefClass);
predefClass.members().enter(sym);
return sym;
} | java | {
"resource": ""
} |
q19657 | Symtab.makeOperatorName | train | private Name makeOperatorName(String name) {
Name opName = names.fromString(name);
operatorNames.add(opName);
return opName;
} | java | {
"resource": ""
} |
q19658 | NamedPanel.put | train | public Widget put(IWidgetFactory factory, String name) {
Widget widget = factory.getWidget();
put(widget, name);
return widget;
} | java | {
"resource": ""
} |
q19659 | XmlStreamReaderUtils.getEventTypeDescription | train | public static String getEventTypeDescription(final XMLStreamReader reader) {
final int eventType = reader.getEventType();
if (eventType == XMLStreamConstants.START_ELEMENT) {
final String namespace = reader.getNamespaceURI();
return "<" + reader.getLocalName()
+ (!StringUtils.isEmpty(namespace) ? "@" + namespace : StringUtils.EMPTY) + ">";
}
if (eventType == XMLStreamConstants.END_ELEMENT) {
final String namespace = reader.getNamespaceURI();
return "</" + reader.getLocalName()
+ (!StringUtils.isEmpty(namespace) ? "@" + namespace : StringUtils.EMPTY) + ">";
}
return NAMES_OF_EVENTS[reader.getEventType()];
} | java | {
"resource": ""
} |
q19660 | XmlStreamReaderUtils.isStartElement | train | public static boolean isStartElement(
final XMLStreamReader reader,
final String namespace,
final String localName) {
return reader.getEventType() == XMLStreamConstants.START_ELEMENT
&& nameEquals(reader, namespace, localName);
} | java | {
"resource": ""
} |
q19661 | XmlStreamReaderUtils.nameEquals | train | public static boolean nameEquals(
final XMLStreamReader reader,
final String namespace,
final String localName) {
if (!reader.getLocalName().equals(localName)) {
return false;
}
if (namespace == null) {
return true;
}
final String namespaceURI = reader.getNamespaceURI();
if (namespaceURI == null) {
return StringUtils.isEmpty(namespace);
}
return namespaceURI.equals(StringUtils.defaultString(namespace));
} | java | {
"resource": ""
} |
q19662 | XmlStreamReaderUtils.optionalClassAttribute | train | public static Class optionalClassAttribute(
final XMLStreamReader reader,
final String localName,
final Class defaultValue) throws XMLStreamException {
return optionalClassAttribute(reader, null, localName, defaultValue);
} | java | {
"resource": ""
} |
q19663 | XmlStreamReaderUtils.skipElement | train | public static void skipElement(final XMLStreamReader reader) throws XMLStreamException, IOException {
if (reader.getEventType() != XMLStreamConstants.START_ELEMENT) {
return;
}
final String namespace = reader.getNamespaceURI();
final String name = reader.getLocalName();
for (;;) {
switch (reader.nextTag()) {
case XMLStreamConstants.START_ELEMENT:
// call ourselves recursively if we encounter START_ELEMENT
skipElement(reader);
break;
case XMLStreamConstants.END_ELEMENT:
case XMLStreamConstants.END_DOCUMENT:
// discard events until we encounter matching END_ELEMENT
reader.require(XMLStreamConstants.END_ELEMENT, namespace, name);
reader.next();
return;
}
}
} | java | {
"resource": ""
} |
q19664 | UriBuilder.path | train | public UriBuilder path(String path) throws URISyntaxException {
path = path.trim();
if (getPath().endsWith("/")) {
return new UriBuilder(setPath(String.format("%s%s", getPath(), path)));
} else {
return new UriBuilder(setPath(String.format("%s/%s", getPath(), path)));
}
} | java | {
"resource": ""
} |
q19665 | ApruveClient.index | train | public <T> ApruveResponse<List<T>> index(String path,
GenericType<List<T>> resultType) {
Response response = restRequest(path).get();
List<T> responseObject = null;
ApruveResponse<List<T>> result;
if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
responseObject = response.readEntity(resultType);
result = new ApruveResponse<List<T>>(response.getStatus(),
responseObject);
} else {
result = new ApruveResponse<List<T>>(response.getStatus(), null,
response.readEntity(String.class));
}
return result;
} | java | {
"resource": ""
} |
q19666 | ApruveClient.get | train | public <T> ApruveResponse<T> get(String path, Class<T> resultType) {
Response response = restRequest(path).get();
return processResponse(response, resultType);
} | java | {
"resource": ""
} |
q19667 | NewRelicManager.sync | train | public boolean sync(NewRelicCache cache)
{
if(cache == null)
throw new IllegalArgumentException("null cache");
checkInitialize(cache);
boolean ret = isInitialized();
if(!ret)
throw new IllegalStateException("cache not initialized");
clear(cache);
if(ret)
ret = syncApplications(cache);
if(ret)
ret = syncPlugins(cache);
if(ret)
ret = syncMonitors(cache);
if(ret)
ret = syncServers(cache);
if(ret)
ret = syncLabels(cache);
if(ret)
ret = syncAlerts(cache);
if(ret)
ret = syncDashboards(cache);
return ret;
} | java | {
"resource": ""
} |
q19668 | NewRelicManager.syncAlerts | train | public boolean syncAlerts(NewRelicCache cache)
{
boolean ret = true;
if(apiClient == null)
throw new IllegalArgumentException("null API client");
// Get the alert configuration using the REST API
if(cache.isAlertsEnabled())
{
ret = false;
// Get the alert policies
logger.info("Getting the alert policies");
Collection<AlertPolicy> policies = apiClient.alertPolicies().list();
for(AlertPolicy policy : policies)
{
cache.alertPolicies().add(policy);
// Add the alert conditions
if(cache.isApmEnabled() || cache.isServersEnabled() || cache.isBrowserEnabled() || cache.isMobileEnabled())
cache.alertPolicies().alertConditions(policy.getId()).add(apiClient.alertConditions().list(policy.getId()));
cache.alertPolicies().nrqlAlertConditions(policy.getId()).add(apiClient.nrqlAlertConditions().list(policy.getId()));
if(cache.isApmEnabled() || cache.isMobileEnabled())
cache.alertPolicies().externalServiceAlertConditions(policy.getId()).add(apiClient.externalServiceAlertConditions().list(policy.getId()));
if(cache.isSyntheticsEnabled())
cache.alertPolicies().syntheticsAlertConditions(policy.getId()).add(apiClient.syntheticsAlertConditions().list(policy.getId()));
if(cache.isPluginsEnabled())
cache.alertPolicies().pluginsAlertConditions(policy.getId()).add(apiClient.pluginsAlertConditions().list(policy.getId()));
if(cache.isInfrastructureEnabled())
cache.alertPolicies().infraAlertConditions(policy.getId()).add(infraApiClient.infraAlertConditions().list(policy.getId()));
}
// Get the alert channels
logger.info("Getting the alert channels");
Collection<AlertChannel> channels = apiClient.alertChannels().list();
cache.alertChannels().set(channels);
cache.alertPolicies().setAlertChannels(channels);
cache.setUpdatedAt();
ret = true;
}
return ret;
} | java | {
"resource": ""
} |
q19669 | NewRelicManager.syncApplications | train | public boolean syncApplications(NewRelicCache cache)
{
boolean ret = true;
if(apiClient == null)
throw new IllegalArgumentException("null API client");
// Get the application configuration using the REST API
if(cache.isApmEnabled() || cache.isBrowserEnabled() || cache.isMobileEnabled())
{
ret = false;
if(cache.isApmEnabled())
{
logger.info("Getting the applications");
Collection<Application> applications = apiClient.applications().list();
for(Application application : applications)
{
cache.applications().add(application);
logger.fine("Getting the hosts for application: "+application.getId());
cache.applications().applicationHosts(application.getId()).add(apiClient.applicationHosts().list(application.getId()));
logger.fine("Getting the instances for application: "+application.getId());
cache.applications().applicationHosts(application.getId()).addApplicationInstances(apiClient.applicationInstances().list(application.getId()));
logger.fine("Getting the deployments for application: "+application.getId());
cache.applications().deployments(application.getId()).add(apiClient.deployments().list(application.getId()));
}
// Get the key transaction configuration using the REST API
try
{
logger.info("Getting the key transactions");
cache.applications().addKeyTransactions(apiClient.keyTransactions().list());
}
catch(ErrorResponseException e)
{
if(e.getStatus() == 403) // throws 403 if not allowed by subscription
logger.warning("Error in get key transactions: "+e.getMessage());
else
throw e;
}
}
if(cache.isBrowserEnabled())
{
logger.info("Getting the browser applications");
cache.browserApplications().add(apiClient.browserApplications().list());
}
if(cache.isBrowserEnabled())
{
logger.info("Getting the mobile applications");
cache.mobileApplications().add(apiClient.mobileApplications().list());
}
cache.setUpdatedAt();
ret = true;
}
return ret;
} | java | {
"resource": ""
} |
q19670 | NewRelicManager.syncPlugins | train | public boolean syncPlugins(NewRelicCache cache)
{
boolean ret = true;
if(apiClient == null)
throw new IllegalArgumentException("null API client");
// Get the Plugins configuration using the REST API
if(cache.isPluginsEnabled())
{
ret = false;
logger.info("Getting the plugins");
Collection<Plugin> plugins = apiClient.plugins().list(true);
for(Plugin plugin : plugins)
{
cache.plugins().add(plugin);
logger.fine("Getting the components for plugin: "+plugin.getId());
Collection<PluginComponent> components = apiClient.pluginComponents().list(PluginComponentService.filters().pluginId(plugin.getId()).build());
cache.plugins().components(plugin.getId()).add(components);
}
cache.setUpdatedAt();
ret = true;
}
return ret;
} | java | {
"resource": ""
} |
q19671 | NewRelicManager.syncMonitors | train | public boolean syncMonitors(NewRelicCache cache)
{
boolean ret = true;
if(apiClient == null)
throw new IllegalArgumentException("null API client");
// Get the Synthetics configuration using the REST API
if(cache.isSyntheticsEnabled())
{
ret = false;
logger.info("Getting the monitors");
cache.monitors().add(syntheticsApiClient.monitors().list());
cache.setUpdatedAt();
ret = true;
}
return ret;
} | java | {
"resource": ""
} |
q19672 | NewRelicManager.syncServers | train | public boolean syncServers(NewRelicCache cache)
{
boolean ret = true;
if(apiClient == null)
throw new IllegalArgumentException("null API client");
// Get the server configuration using the REST API
if(cache.isServersEnabled())
{
ret = false;
logger.info("Getting the servers");
cache.servers().add(apiClient.servers().list());
cache.setUpdatedAt();
ret = true;
}
return ret;
} | java | {
"resource": ""
} |
q19673 | NewRelicManager.syncLabels | train | public boolean syncLabels(NewRelicCache cache)
{
boolean ret = true;
if(apiClient == null)
throw new IllegalArgumentException("null API client");
// Get the label configuration using the REST API
if(cache.isApmEnabled() || cache.isSyntheticsEnabled())
{
ret = false;
logger.info("Getting the labels");
Collection<Label> labels = apiClient.labels().list();
for(Label label : labels)
{
cache.applications().addLabel(label);
try
{
// Also check to see if this label is associated with any monitors
Collection<Monitor> monitors = syntheticsApiClient.monitors().list(label);
for(Monitor monitor : monitors)
cache.monitors().labels(monitor.getId()).add(label);
}
catch(NullPointerException e)
{
logger.severe("Unable to get monitor labels: "+e.getClass().getName()+": "+e.getMessage());
}
}
cache.setUpdatedAt();
ret = true;
}
return ret;
} | java | {
"resource": ""
} |
q19674 | NewRelicManager.syncDashboards | train | public boolean syncDashboards(NewRelicCache cache)
{
boolean ret = true;
if(apiClient == null)
throw new IllegalArgumentException("null API client");
// Get the dashboard configuration using the REST API
if(cache.isInsightsEnabled())
{
ret = false;
logger.info("Getting the dashboards");
cache.dashboards().set(apiClient.dashboards().list());
cache.setUpdatedAt();
ret = true;
}
return ret;
} | java | {
"resource": ""
} |
q19675 | cufftResult.stringFor | train | public static String stringFor(int m)
{
switch (m)
{
case CUFFT_SUCCESS : return "CUFFT_SUCCESS";
case CUFFT_INVALID_PLAN : return "CUFFT_INVALID_PLAN";
case CUFFT_ALLOC_FAILED : return "CUFFT_ALLOC_FAILED";
case CUFFT_INVALID_TYPE : return "CUFFT_INVALID_TYPE";
case CUFFT_INVALID_VALUE : return "CUFFT_INVALID_VALUE";
case CUFFT_INTERNAL_ERROR : return "CUFFT_INTERNAL_ERROR";
case CUFFT_EXEC_FAILED : return "CUFFT_EXEC_FAILED";
case CUFFT_SETUP_FAILED : return "CUFFT_SETUP_FAILED";
case CUFFT_INVALID_SIZE : return "CUFFT_INVALID_SIZE";
case CUFFT_UNALIGNED_DATA : return "CUFFT_UNALIGNED_DATA";
case CUFFT_INCOMPLETE_PARAMETER_LIST : return "CUFFT_INCOMPLETE_PARAMETER_LIST";
case CUFFT_INVALID_DEVICE : return "CUFFT_INVALID_DEVICE";
case CUFFT_PARSE_ERROR : return "CUFFT_PARSE_ERROR";
case CUFFT_NO_WORKSPACE : return "CUFFT_NO_WORKSPACE";
case CUFFT_NOT_IMPLEMENTED : return "CUFFT_NOT_IMPLEMENTED";
case CUFFT_LICENSE_ERROR : return "CUFFT_LICENSE_ERROR";
case CUFFT_NOT_SUPPORTED : return "CUFFT_NOT_SUPPORTED";
case JCUFFT_INTERNAL_ERROR : return "JCUFFT_INTERNAL_ERROR";
}
return "INVALID cufftResult: " + m;
} | java | {
"resource": ""
} |
q19676 | SocialTemplate.parseProfile | train | protected SocialProfile parseProfile(Map<String, Object> props) {
if (!props.containsKey("id")) {
throw new IllegalArgumentException("No id in profile");
}
SocialProfile profile = SocialProfile.with(props)
.displayName("name")
.first("first_name")
.last("last_name")
.id("id")
.username("username")
.profileUrl("link")
.build();
profile.setThumbnailUrl(getBaseUrl() + "/" + profile.getId() + "/picture");
return profile;
} | java | {
"resource": ""
} |
q19677 | JavadocTool.parsePackageClasses | train | private void parsePackageClasses(String name,
List<JavaFileObject> files,
ListBuffer<JCCompilationUnit> trees,
List<String> excludedPackages)
throws IOException {
if (excludedPackages.contains(name)) {
return;
}
docenv.notice("main.Loading_source_files_for_package", name);
if (files == null) {
Location location = docenv.fileManager.hasLocation(StandardLocation.SOURCE_PATH)
? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;
ListBuffer<JavaFileObject> lb = new ListBuffer<JavaFileObject>();
for (JavaFileObject fo: docenv.fileManager.list(
location, name, EnumSet.of(JavaFileObject.Kind.SOURCE), false)) {
String binaryName = docenv.fileManager.inferBinaryName(location, fo);
String simpleName = getSimpleName(binaryName);
if (isValidClassName(simpleName)) {
lb.append(fo);
}
}
files = lb.toList();
}
if (files.nonEmpty()) {
for (JavaFileObject fo : files) {
parse(fo, trees, false);
}
} else {
messager.warning(Messager.NOPOS, "main.no_source_files_for_package",
name.replace(File.separatorChar, '.'));
}
} | java | {
"resource": ""
} |
q19678 | JavadocTool.isValidJavaClassFile | train | private static boolean isValidJavaClassFile(String file) {
if (!file.endsWith(".class")) return false;
String clazzName = file.substring(0, file.length() - ".class".length());
return isValidClassName(clazzName);
} | java | {
"resource": ""
} |
q19679 | Scope.enter | train | public void enter(Symbol sym, Scope s, Scope origin, boolean staticallyImported) {
Assert.check(shared == 0);
if (nelems * 3 >= hashMask * 2)
dble();
int hash = getIndex(sym.name);
Entry old = table[hash];
if (old == null) {
old = sentinel;
nelems++;
}
Entry e = makeEntry(sym, old, elems, s, origin, staticallyImported);
table[hash] = e;
elems = e;
//notify listeners
for (List<ScopeListener> l = listeners; l.nonEmpty(); l = l.tail) {
l.head.symbolAdded(sym, this);
}
} | java | {
"resource": ""
} |
q19680 | ResolveWithDeps.reportDependence | train | @Override
public void reportDependence(Symbol from, Symbol to) {
// Capture dependencies between the packages.
deps.collect(from.packge().fullname, to.packge().fullname);
} | java | {
"resource": ""
} |
q19681 | CRTable.put | train | public void put(Object tree, int flags, int startPc, int endPc) {
entries.append(new CRTEntry(tree, flags, startPc, endPc));
} | java | {
"resource": ""
} |
q19682 | CRTable.writeCRT | train | public int writeCRT(ByteBuffer databuf, Position.LineMap lineMap, Log log) {
int crtEntries = 0;
// compute source positions for the method
new SourceComputer().csp(methodTree);
for (List<CRTEntry> l = entries.toList(); l.nonEmpty(); l = l.tail) {
CRTEntry entry = l.head;
// eliminate entries that do not produce bytecodes:
// for example, empty blocks and statements
if (entry.startPc == entry.endPc)
continue;
SourceRange pos = positions.get(entry.tree);
Assert.checkNonNull(pos, "CRT: tree source positions are undefined");
if ((pos.startPos == Position.NOPOS) || (pos.endPos == Position.NOPOS))
continue;
if (crtDebug) {
System.out.println("Tree: " + entry.tree + ", type:" + getTypes(entry.flags));
System.out.print("Start: pos = " + pos.startPos + ", pc = " + entry.startPc);
}
// encode startPos into line/column representation
int startPos = encodePosition(pos.startPos, lineMap, log);
if (startPos == Position.NOPOS)
continue;
if (crtDebug) {
System.out.print("End: pos = " + pos.endPos + ", pc = " + (entry.endPc - 1));
}
// encode endPos into line/column representation
int endPos = encodePosition(pos.endPos, lineMap, log);
if (endPos == Position.NOPOS)
continue;
// write attribute
databuf.appendChar(entry.startPc);
// 'endPc - 1' because endPc actually points to start of the next command
databuf.appendChar(entry.endPc - 1);
databuf.appendInt(startPos);
databuf.appendInt(endPos);
databuf.appendChar(entry.flags);
crtEntries++;
}
return crtEntries;
} | java | {
"resource": ""
} |
q19683 | CRTable.getTypes | train | private String getTypes(int flags) {
String types = "";
if ((flags & CRT_STATEMENT) != 0) types += " CRT_STATEMENT";
if ((flags & CRT_BLOCK) != 0) types += " CRT_BLOCK";
if ((flags & CRT_ASSIGNMENT) != 0) types += " CRT_ASSIGNMENT";
if ((flags & CRT_FLOW_CONTROLLER) != 0) types += " CRT_FLOW_CONTROLLER";
if ((flags & CRT_FLOW_TARGET) != 0) types += " CRT_FLOW_TARGET";
if ((flags & CRT_INVOKE) != 0) types += " CRT_INVOKE";
if ((flags & CRT_CREATE) != 0) types += " CRT_CREATE";
if ((flags & CRT_BRANCH_TRUE) != 0) types += " CRT_BRANCH_TRUE";
if ((flags & CRT_BRANCH_FALSE) != 0) types += " CRT_BRANCH_FALSE";
return types;
} | java | {
"resource": ""
} |
q19684 | UserResource.read | train | @GET
@Path("{id}")
@RolesAllowed({"ROLE_ADMIN"})
public Response read(@PathParam("id") Long id) {
checkNotNull(id);
return Response.ok(userService.getById(id)).build();
} | java | {
"resource": ""
} |
q19685 | UserResource.search | train | @GET
@Path("search")
@RolesAllowed({"ROLE_ADMIN"})
public Response search(@QueryParam("email") String email,
@QueryParam("username") String username,
@QueryParam("pageSize") @DefaultValue("10") int pageSize,
@QueryParam("cursorKey") String cursorKey) {
final CursorPage<DUser> page;
if (null != email) {
page = userService.findMatchingUsersByEmail(email, pageSize, cursorKey);
} else if (null != username) {
page = userService.findMatchingUsersByUserName(username, pageSize, cursorKey);
} else {
throw new BadRequestRestException("No search key provided");
}
return Response.ok(page).build();
} | java | {
"resource": ""
} |
q19686 | UserResource.readPage | train | @GET
@RolesAllowed({"ROLE_ADMIN"})
public Response readPage(@QueryParam("pageSize") @DefaultValue("10") int pageSize,
@QueryParam("cursorKey") String cursorKey) {
CursorPage<DUser> page = userService.readPage(pageSize, cursorKey);
return Response.ok(page).build();
} | java | {
"resource": ""
} |
q19687 | UserResource.changeUsername | train | @POST
@Path("{id}/username")
@RolesAllowed({"ROLE_ADMIN"})
public Response changeUsername(@PathParam("id") Long id, UsernameRequest usernameRequest) {
checkUsernameFormat(usernameRequest.username);
userService.changeUsername(id, usernameRequest.getUsername());
return Response.ok(id).build();
} | java | {
"resource": ""
} |
q19688 | UserResource.changePassword | train | @POST
@Path("{id}/password")
@PermitAll
public Response changePassword(@PathParam("id") Long userId, PasswordRequest request) {
checkNotNull(userId);
checkNotNull(request.getToken());
checkPasswordFormat(request.getNewPassword());
boolean isSuccess = userService.confirmResetPasswordUsingToken(userId, request.getNewPassword(), request.getToken());
return isSuccess ? Response.noContent().build() : Response.status(Response.Status.BAD_REQUEST).build();
} | java | {
"resource": ""
} |
q19689 | UserResource.resetPassword | train | @POST
@Path("password/reset")
@PermitAll
public Response resetPassword(PasswordRequest request) {
checkNotNull(request.getEmail());
userService.resetPassword(request.getEmail());
return Response.noContent().build();
} | java | {
"resource": ""
} |
q19690 | UserResource.confirmAccount | train | @POST
@Path("{id}/account/confirm")
@PermitAll
public Response confirmAccount(@PathParam("id") Long userId, AccountRequest request) {
checkNotNull(userId);
checkNotNull(request.getToken());
boolean isSuccess = userService.confirmAccountUsingToken(userId, request.getToken());
return isSuccess ? Response.noContent().build() : Response.status(Response.Status.BAD_REQUEST).build();
} | java | {
"resource": ""
} |
q19691 | UserResource.resendVerifyAccountEmail | train | @POST
@Path("{id}/account/resend")
@PermitAll
public Response resendVerifyAccountEmail(@PathParam("id") Long userId) {
checkNotNull(userId);
boolean isSuccess = userService.resendVerifyAccountEmail(userId);
return isSuccess ? Response.noContent().build() : Response.status(Response.Status.BAD_REQUEST).build();
} | java | {
"resource": ""
} |
q19692 | UserResource.changeEmail | train | @POST
@Path("{id}/email")
@RolesAllowed({"ROLE_ADMIN"})
public Response changeEmail(@PathParam("id") Long userId, EmailRequest request) {
checkNotNull(userId);
checkEmailFormat(request.getEmail());
boolean isSuccess = userService.changeEmailAddress(userId, request.getEmail());
return isSuccess ? Response.noContent().build() : Response.status(Response.Status.BAD_REQUEST).build();
} | java | {
"resource": ""
} |
q19693 | UserResource.confirmChangeEmail | train | @POST
@Path("{id}/email/confirm")
@PermitAll
public Response confirmChangeEmail(@PathParam("id") Long userId, EmailRequest request) {
checkNotNull(userId);
checkNotNull(request.getToken());
boolean isSuccess = userService.confirmEmailAddressChangeUsingToken(userId, request.getToken());
return isSuccess ? Response.noContent().build() : Response.status(Response.Status.BAD_REQUEST).build();
} | java | {
"resource": ""
} |
q19694 | ProtocolFactory.createInstance | train | public static Protocol createInstance(ProtocolVersion version, SocketManager socketManager)
{
switch (version)
{
case _63:
return new Protocol63(socketManager);
case _72:
return new Protocol72(socketManager);
case _73:
return new Protocol73(socketManager);
case _74:
return new Protocol74(socketManager);
default:
throw new IllegalArgumentException("Unknown protocol version: " + version);
}
} | java | {
"resource": ""
} |
q19695 | ReportConfig.prepareParameters | train | public void prepareParameters(Map<String, Object> extra) {
if (paramConfig == null) return;
for (ParamConfig param : paramConfig)
{
param.prepareParameter(extra);
}
} | java | {
"resource": ""
} |
q19696 | ValueTaglet.getFieldDoc | train | private FieldDoc getFieldDoc(Configuration config, Tag tag, String name) {
if (name == null || name.length() == 0) {
//Base case: no label.
if (tag.holder() instanceof FieldDoc) {
return (FieldDoc) tag.holder();
} else {
// If the value tag does not specify a parameter which is a valid field and
// it is not used within the comments of a valid field, return null.
return null;
}
}
StringTokenizer st = new StringTokenizer(name, "#");
String memberName = null;
ClassDoc cd = null;
if (st.countTokens() == 1) {
//Case 2: @value in same class.
Doc holder = tag.holder();
if (holder instanceof MemberDoc) {
cd = ((MemberDoc) holder).containingClass();
} else if (holder instanceof ClassDoc) {
cd = (ClassDoc) holder;
}
memberName = st.nextToken();
} else {
//Case 3: @value in different class.
cd = config.root.classNamed(st.nextToken());
memberName = st.nextToken();
}
if (cd == null) {
return null;
}
FieldDoc[] fields = cd.fields();
for (int i = 0; i < fields.length; i++) {
if (fields[i].name().equals(memberName)) {
return fields[i];
}
}
return null;
} | java | {
"resource": ""
} |
q19697 | Configuration.constructed | train | @Constructed
public void constructed() {
Context context = factory.enterContext();
try {
scope = new ImporterTopLevel(context);
} finally {
Context.exit();
}
Container container = Jaguar.component(Container.class);
Object store = container.component(container.contexts().get(Application.class)).store();
if (store instanceof ServletContext) {
org.eiichiro.bootleg.Configuration configuration = new DefaultConfiguration();
configuration.init((ServletContext) store);
this.configuration = configuration;
}
} | java | {
"resource": ""
} |
q19698 | Configuration.activated | train | @Activated
public void activated() {
logger.info("Importing core packages ['org.eiichiro.gig', 'org.eiichiro.bootleg', 'org.eiichiro.jaguar', 'org.eiichiro.jaguar.deployment'] into JavaScript context");
Context context = factory.enterContext();
try {
context.evaluateString(scope, "importPackage(Packages.org.eiichiro.gig)", Configuration.class.getSimpleName(), 146, null);
context.evaluateString(scope, "importPackage(Packages.org.eiichiro.bootleg)", Configuration.class.getSimpleName(), 147, null);
context.evaluateString(scope, "importPackage(Packages.org.eiichiro.jaguar)", Configuration.class.getSimpleName(), 148, null);
context.evaluateString(scope, "importPackage(Packages.org.eiichiro.jaguar.deployment)", Configuration.class.getSimpleName(), 149, null);
} finally {
Context.exit();
}
load(COMPONENTS_JS);
load(ROUTING_JS);
load(SETTINGS_JS);
} | java | {
"resource": ""
} |
q19699 | Configuration.load | train | public void load(String file) {
Context context = factory.enterContext();
try {
URL url = Thread.currentThread().getContextClassLoader().getResource(file);
if (url == null) {
logger.debug("Configuration [" + file + "] does not exist");
return;
}
File f = new File(url.getPath());
if (f.exists()) {
logger.info("Loading configuration [" + file + "]");
context.evaluateReader(scope, new FileReader(f), file.substring(file.lastIndexOf("/") + 1), 1, null);
}
} catch (Exception e) {
logger.error("Failed to load configuration [" + file + "]", e);
throw new UncheckedException(e);
} finally {
Context.exit();
}
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.