before stringlengths 33 3.21M | after stringlengths 63 3.21M | repo stringlengths 1 56 | type stringclasses 1
value | __index_level_0__ int64 0 442k |
|---|---|---|---|---|
public static void loadModules(@Nonnull ASMDataTable table, boolean isClient) {
HashMap<String, Triple<String, String, String>> moduleData = new HashMap<>();
Set<String> enabled = new HashSet<>();
String annotationClassName = MCLoader.class.getCanonicalName();
Set<ASMData> asmDatas = new HashSet<>(table.getAll(annotationClassName));
asmLoop: for (ASMDataTable.ASMData asmData : asmDatas) {
try {
Map<String, Object> data = asmData.getAnnotationInfo();
String name = WordUtils.uncapitalize(asmData.getClassName().substring(asmData.getClassName().lastIndexOf('.') + 1).trim());
boolean isEnabledByDefault = !asmData.getClassName().contains("mariculture.modules.hardcore") && !asmData.getClassName().contains("mariculture.modules.debug");
name = asmData.getClassName().contains("mariculture.modules.hardcore") ? "hardcore-" + name : name;
String dependencies = data.get("modules") != null ? (String) data.get("modules") : "";
String type = "modules";
String mods = data.get("mods") != null ? (String) data.get("mods") : "";
if (mods != null && !mods.equals("")) {
String[] modList = mods.replace(" ", "").split(",");
for (String mod : modList) {
if (!Loader.isModLoaded(mod))
continue asmLoop;
}
type = "plugins";
}
if (isModuleEnabled(type, name, isEnabledByDefault)) {
enabled.add(name);
moduleData.put(name, Triple.of(asmData.getClassName(), type, dependencies));
}
} catch (Exception e) {
e.printStackTrace();
}
}
Set<ASMData> datas = new HashSet<>(table.getAll(MCApiImpl.class.getCanonicalName()));
for (ASMDataTable.ASMData data : datas) {
try {
Map<String, Object> theData = data.getAnnotationInfo();
String modules = theData.get("value") != null ? (String) theData.get("value") : "";
List<String> dependencies = Lists.newArrayList(modules.replace(" ", "").split(","));
if (modules.equals("") || enabled.containsAll(dependencies)) {
Class clazz = Class.forName(data.getClassName());
Object instance = clazz.getField("INSTANCE").get(null);
Class[] interfaces = clazz.getInterfaces();
if (interfaces != null && interfaces.length > 0) {
for (Class inter : interfaces) {
for (Field f : MaricultureAPI.class.getFields()) {
if (f.getType().equals(inter)) {
MCReflectionHelper.setFinalStatic(instance, f);
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
for (String module : enabled) {
Triple<String, String, String> data = moduleData.get(module);
String dependencyList = data.getRight().replace(" ", "");
List<String> dependencies = Lists.newArrayList(dependencyList.split(","));
if (dependencyList.equals("") || enabled.containsAll(dependencies)) {
try {
ModuleManager.enabled.put(module, Class.forName(data.getLeft()));
Mariculture.logger.log(Level.INFO, "Enabling the " + StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(WordUtils.capitalize(module)), ' ') + " " + data.getMiddle().replace("s", "") + "!");
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
}
}
String annotationClassName = MCEvents.class.getCanonicalName();
Set<ASMData> asmDatas = new HashSet<>(table.getAll(annotationClassName));
for (ASMDataTable.ASMData asmData : asmDatas) {
try {
Map<String, Object> data = asmData.getAnnotationInfo();
String side = data.get("value") != null ? ReflectionHelper.getPrivateValue(ModAnnotation.EnumHolder.class, (ModAnnotation.EnumHolder) data.get("value"), "value") : "";
String modules = data.get("modules") != null ? (String) data.get("modules") : "";
List<String> dependencies = Lists.newArrayList(modules.replace(" ", "").split(","));
if (modules.equals("") || enabled.keySet().containsAll(dependencies)) {
if ((side.equals("CLIENT") && isClient) || side.equals("")) {
Class clazz = Class.forName(asmData.getClassName());
Method register = MCReflectionHelper.getMethod(clazz, "register");
if (register == null || ((Boolean) register.invoke(null))) {
Field INSTANCE = MCReflectionHelper.getField(clazz, "INSTANCE");
if (INSTANCE == null)
MinecraftForge.EVENT_BUS.register(clazz.newInstance());
else
MinecraftForge.EVENT_BUS.register(INSTANCE.get(null));
}
}
}
} catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | InstantiationException ex) {
ex.printStackTrace();
}
}
} | public static void loadModules(@Nonnull ASMDataTable table, boolean isClient) {
HashMap<String, Triple<String, String, String>> moduleData = new HashMap<>();
Set<String> enabled = new HashSet<>();
String annotationClassName = MCLoader.class.getCanonicalName();
Set<ASMData> asmDatas = new HashSet<>(table.getAll(annotationClassName));
asmLoop: for (ASMDataTable.ASMData asmData : asmDatas) {
try {
Map<String, Object> data = asmData.getAnnotationInfo();
String name = WordUtils.uncapitalize(asmData.getClassName().substring(asmData.getClassName().lastIndexOf('.') + 1).trim());
boolean isEnabledByDefault = !asmData.getClassName().contains("mariculture.modules.hardcore") && !asmData.getClassName().contains("mariculture.modules.debug");
name = asmData.getClassName().contains("mariculture.modules.hardcore") ? "hardcore-" + name : name;
String dependencies = data.get("modules") != null ? (String) data.get("modules") : "";
String type = "modules";
String mods = data.get("mods") != null ? (String) data.get("mods") : "";
if (mods != null && !mods.equals("")) {
String[] modList = mods.replace(" ", "").split(",");
for (String mod : modList) {
if (!Loader.isModLoaded(mod))
continue asmLoop;
}
type = "plugins";
}
if (isModuleEnabled(type, name, isEnabledByDefault)) {
enabled.add(name);
moduleData.put(name, Triple.of(asmData.getClassName(), type, dependencies));
}
} catch (Exception e) {
e.printStackTrace();
}
}
Set<ASMData> datas = new HashSet<>(table.getAll(MCApiImpl.class.getCanonicalName()));
for (ASMDataTable.ASMData data : datas) {
try {
Map<String, Object> theData = data.getAnnotationInfo();
String modules = theData.get("value") != null ? (String) theData.get("value") : "";
List<String> dependencies = Lists.newArrayList(modules.replace(" ", "").split(","));
if (modules.equals("") || enabled.containsAll(dependencies)) {
Class clazz = Class.forName(data.getClassName());
Object instance = clazz.getField("INSTANCE").get(null);
Class[] interfaces = clazz.getInterfaces();
if (interfaces != null && interfaces.length > 0) {
for (Class inter : interfaces) {
for (Field f : MaricultureAPI.class.getFields()) {
if (f.getType().equals(inter)) {
MCReflectionHelper.setFinalStatic(instance, f);
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
for (String module : enabled) {
Triple<String, String, String> data = moduleData.get(module);
String dependencyList = data.getRight().replace(" ", "");
List<String> dependencies = Lists.newArrayList(dependencyList.split(","));
if (dependencyList.equals("") || enabled.containsAll(dependencies)) {
try {
ModuleManager.enabled.put(module, Class.forName(data.getLeft()));
Mariculture.logger.log(Level.INFO, "Enabling the " + StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(WordUtils.capitalize(module)), ' ') + " " + data.getMiddle().replace("s", "") + "!");
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
}
}
<DeepExtract>
String annotationClassName = MCEvents.class.getCanonicalName();
Set<ASMData> asmDatas = new HashSet<>(table.getAll(annotationClassName));
for (ASMDataTable.ASMData asmData : asmDatas) {
try {
Map<String, Object> data = asmData.getAnnotationInfo();
String side = data.get("value") != null ? ReflectionHelper.getPrivateValue(ModAnnotation.EnumHolder.class, (ModAnnotation.EnumHolder) data.get("value"), "value") : "";
String modules = data.get("modules") != null ? (String) data.get("modules") : "";
List<String> dependencies = Lists.newArrayList(modules.replace(" ", "").split(","));
if (modules.equals("") || enabled.keySet().containsAll(dependencies)) {
if ((side.equals("CLIENT") && isClient) || side.equals("")) {
Class clazz = Class.forName(asmData.getClassName());
Method register = MCReflectionHelper.getMethod(clazz, "register");
if (register == null || ((Boolean) register.invoke(null))) {
Field INSTANCE = MCReflectionHelper.getField(clazz, "INSTANCE");
if (INSTANCE == null)
MinecraftForge.EVENT_BUS.register(clazz.newInstance());
else
MinecraftForge.EVENT_BUS.register(INSTANCE.get(null));
}
}
}
} catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | InstantiationException ex) {
ex.printStackTrace();
}
}
</DeepExtract>
} | Mariculture | positive | 2,314 |
private void syncUserActionAndNotifyDispatcher(UserActionEntity userAction) {
mLogger.d(TAG, "syncUserActionAndNotifyDispatcher(); user action: " + userAction);
String entityType = userAction.getEntityType();
String actionType = userAction.getActionType();
boolean userActionSyncedSuccessfully = true;
try {
switch(entityType) {
case IDoCareContract.UserActions.ENTITY_TYPE_REQUEST:
switch(actionType) {
case IDoCareContract.UserActions.ACTION_TYPE_CREATE_REQUEST:
mRequestsSyncer.syncRequestCreated(userAction.getEntityId());
break;
case IDoCareContract.UserActions.ACTION_TYPE_PICKUP_REQUEST:
syncRequestPickedUpAction(PickUpRequestUserActionEntity.fromUserAction(userAction));
break;
case IDoCareContract.UserActions.ACTION_TYPE_CLOSE_REQUEST:
syncRequestClosedAction(CloseRequestUserActionEntity.fromUserAction(userAction));
break;
case IDoCareContract.UserActions.ACTION_TYPE_VOTE_FOR_REQUEST:
syncVoteForRequestUserAction(VoteForRequestUserActionEntity.fromUserAction(userAction));
break;
default:
throw new RuntimeException("unsupported action type: " + actionType);
}
break;
default:
throw new RuntimeException("unsupported entity type: " + entityType);
}
mUserActionCacher.deleteUserAction(userAction);
} catch (SyncFailedException e) {
e.printStackTrace();
userActionSyncedSuccessfully = false;
}
mLogger.d(TAG, "notifyUserActionSyncComplete(); user action: " + userAction + "; is success: " + userActionSyncedSuccessfully);
synchronized (DISPATCHER_LOCK) {
String entityId = userAction.getEntityId();
if (!mEntityIdToDispatchedUserActionsMap.get(entityId).contains(userAction)) {
throw new IllegalStateException("user action is not in the dispatched list");
}
mEntityIdToDispatchedUserActionsMap.get(entityId).remove(userAction);
if (isStallingAction(userAction)) {
mEntityIdToStallFlagMap.get(entityId).set(false);
DISPATCHER_LOCK.notifyAll();
}
cleanIfNoMoreActionsForEntity(entityId);
if (userActionSyncedSuccessfully) {
ensureConsistentEntityIds(userAction);
}
}
} | private void syncUserActionAndNotifyDispatcher(UserActionEntity userAction) {
mLogger.d(TAG, "syncUserActionAndNotifyDispatcher(); user action: " + userAction);
String entityType = userAction.getEntityType();
String actionType = userAction.getActionType();
boolean userActionSyncedSuccessfully = true;
try {
switch(entityType) {
case IDoCareContract.UserActions.ENTITY_TYPE_REQUEST:
switch(actionType) {
case IDoCareContract.UserActions.ACTION_TYPE_CREATE_REQUEST:
mRequestsSyncer.syncRequestCreated(userAction.getEntityId());
break;
case IDoCareContract.UserActions.ACTION_TYPE_PICKUP_REQUEST:
syncRequestPickedUpAction(PickUpRequestUserActionEntity.fromUserAction(userAction));
break;
case IDoCareContract.UserActions.ACTION_TYPE_CLOSE_REQUEST:
syncRequestClosedAction(CloseRequestUserActionEntity.fromUserAction(userAction));
break;
case IDoCareContract.UserActions.ACTION_TYPE_VOTE_FOR_REQUEST:
syncVoteForRequestUserAction(VoteForRequestUserActionEntity.fromUserAction(userAction));
break;
default:
throw new RuntimeException("unsupported action type: " + actionType);
}
break;
default:
throw new RuntimeException("unsupported entity type: " + entityType);
}
mUserActionCacher.deleteUserAction(userAction);
} catch (SyncFailedException e) {
e.printStackTrace();
userActionSyncedSuccessfully = false;
}
<DeepExtract>
mLogger.d(TAG, "notifyUserActionSyncComplete(); user action: " + userAction + "; is success: " + userActionSyncedSuccessfully);
synchronized (DISPATCHER_LOCK) {
String entityId = userAction.getEntityId();
if (!mEntityIdToDispatchedUserActionsMap.get(entityId).contains(userAction)) {
throw new IllegalStateException("user action is not in the dispatched list");
}
mEntityIdToDispatchedUserActionsMap.get(entityId).remove(userAction);
if (isStallingAction(userAction)) {
mEntityIdToStallFlagMap.get(entityId).set(false);
DISPATCHER_LOCK.notifyAll();
}
cleanIfNoMoreActionsForEntity(entityId);
if (userActionSyncedSuccessfully) {
ensureConsistentEntityIds(userAction);
}
}
</DeepExtract>
} | idocare-android | positive | 2,315 |
@Override
public void logout(Access access) {
if (access == null) {
throw new IllegalArgumentException("Parameter access cannot be empty.");
}
PrincipalInfo principalInfo = access.getPrincipalInfo();
if (principalInfo != null) {
this.onLogout(principalInfo);
}
Session session = access.getSession(false);
if (session != null) {
session.stop();
;
}
} | @Override
public void logout(Access access) {
if (access == null) {
throw new IllegalArgumentException("Parameter access cannot be empty.");
}
PrincipalInfo principalInfo = access.getPrincipalInfo();
if (principalInfo != null) {
this.onLogout(principalInfo);
}
<DeepExtract>
Session session = access.getSession(false);
if (session != null) {
session.stop();
;
}
</DeepExtract>
} | easylimit | positive | 2,316 |
public static int[] readInts() {
String[] fields = readAllStrings();
int[] vals = new int[fields.length];
for (int i = 0; i < fields.length; i++) vals[i] = Integer.parseInt(fields[i]);
return vals;
} | public static int[] readInts() {
<DeepExtract>
String[] fields = readAllStrings();
int[] vals = new int[fields.length];
for (int i = 0; i < fields.length; i++) vals[i] = Integer.parseInt(fields[i]);
return vals;
</DeepExtract>
} | skeleton-sp18 | positive | 2,317 |
private void setSlice(final long i) {
if (i == currentHyperSliceIndex)
return;
else
changeSliceAccess((int) i);
} | private void setSlice(final long i) {
<DeepExtract>
if (i == currentHyperSliceIndex)
return;
else
changeSliceAccess((int) i);
</DeepExtract>
} | bigdataprocessor2 | positive | 2,319 |
public Builder clearSectionId() {
java.lang.Object ref = sectionId_;
if (ref instanceof java.lang.String) {
sectionId_ = (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
sectionId_ = s;
sectionId_ = s;
}
onChanged();
return this;
} | public Builder clearSectionId() {
<DeepExtract>
java.lang.Object ref = sectionId_;
if (ref instanceof java.lang.String) {
sectionId_ = (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
sectionId_ = s;
sectionId_ = s;
}
</DeepExtract>
onChanged();
return this;
} | sharedstreets-builder | positive | 2,320 |
public Criteria andIdGreaterThan(Integer value) {
if (value == null) {
throw new RuntimeException("Value for " + "id" + " cannot be null");
}
criteria.add(new Criterion("id >", value));
return (Criteria) this;
} | public Criteria andIdGreaterThan(Integer value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "id" + " cannot be null");
}
criteria.add(new Criterion("id >", value));
</DeepExtract>
return (Criteria) this;
} | springcloud-e-book | positive | 2,321 |
@Override
public LocaleContext resolveLocaleContext(final HttpServletRequest request) {
if (request.getAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME) == null) {
Cookie cookie = WebUtils.getCookie(request, getCookieName());
Locale locale = null;
TimeZone timeZone = null;
if (cookie != null) {
String value = cookie.getValue();
value = StringUtils.replace(value, "%22", "");
String localePart = value;
String timeZonePart = null;
int spaceIndex = localePart.indexOf(' ');
if (spaceIndex != -1) {
localePart = value.substring(0, spaceIndex);
timeZonePart = value.substring(spaceIndex + 1);
}
locale = (!"-".equals(localePart) ? StringUtils.parseLocaleString(localePart.replace('-', '_')) : null);
if (timeZonePart != null) {
timeZone = StringUtils.parseTimeZoneString(timeZonePart);
}
if (logger.isTraceEnabled()) {
logger.trace("Parsed cookie value [" + cookie.getValue() + "] into locale '" + locale + "'" + (timeZone != null ? " and time zone '" + timeZone.getID() + "'" : ""));
}
}
request.setAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME, (locale != null ? locale : determineDefaultLocale(request)));
request.setAttribute(TIME_ZONE_REQUEST_ATTRIBUTE_NAME, (timeZone != null ? timeZone : determineDefaultTimeZone(request)));
}
return new TimeZoneAwareLocaleContext() {
@Override
public Locale getLocale() {
return (Locale) request.getAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME);
}
@Override
public TimeZone getTimeZone() {
return (TimeZone) request.getAttribute(TIME_ZONE_REQUEST_ATTRIBUTE_NAME);
}
};
} | @Override
public LocaleContext resolveLocaleContext(final HttpServletRequest request) {
<DeepExtract>
if (request.getAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME) == null) {
Cookie cookie = WebUtils.getCookie(request, getCookieName());
Locale locale = null;
TimeZone timeZone = null;
if (cookie != null) {
String value = cookie.getValue();
value = StringUtils.replace(value, "%22", "");
String localePart = value;
String timeZonePart = null;
int spaceIndex = localePart.indexOf(' ');
if (spaceIndex != -1) {
localePart = value.substring(0, spaceIndex);
timeZonePart = value.substring(spaceIndex + 1);
}
locale = (!"-".equals(localePart) ? StringUtils.parseLocaleString(localePart.replace('-', '_')) : null);
if (timeZonePart != null) {
timeZone = StringUtils.parseTimeZoneString(timeZonePart);
}
if (logger.isTraceEnabled()) {
logger.trace("Parsed cookie value [" + cookie.getValue() + "] into locale '" + locale + "'" + (timeZone != null ? " and time zone '" + timeZone.getID() + "'" : ""));
}
}
request.setAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME, (locale != null ? locale : determineDefaultLocale(request)));
request.setAttribute(TIME_ZONE_REQUEST_ATTRIBUTE_NAME, (timeZone != null ? timeZone : determineDefaultTimeZone(request)));
}
</DeepExtract>
return new TimeZoneAwareLocaleContext() {
@Override
public Locale getLocale() {
return (Locale) request.getAttribute(LOCALE_REQUEST_ATTRIBUTE_NAME);
}
@Override
public TimeZone getTimeZone() {
return (TimeZone) request.getAttribute(TIME_ZONE_REQUEST_ATTRIBUTE_NAME);
}
};
} | jhipster-experimental-microservices | positive | 2,323 |
public String getJobConfig() {
StringBuilder sb = new StringBuilder();
sb.append("job_id:").append(jobId);
sb.append(" status:").append(this.getStatusString(this.getStatus()));
sb.append(" taskcount:").append(this.getTaskCount());
sb.append(" starttime:").append(this.getStartTime());
sb.append(" lastTaskTime:").append(this.getLastTaskTime());
sb.append(" graphActivity:").append(this.getGraphActivity());
sb.append(" coordinatorid:").append(this.getCoordinatorId());
if (this.approvedAdapterNames != null) {
sb.append(" approvedadapterlist:").append(this.approvedAdapterNames.toString());
}
sb.append(" config:").append(this.getJobConfig());
sb.append(" history:").append(this.jobHistory.toString());
sb.append(" tasklist:").append(this.getTasks().toString());
sb.append("create_date:").append(this.getCreateDate().toString());
sb.append("expire_date:").append(this.getExpireDate());
sb.append("reset_date:").append(this.getResetDate());
sb.append("reason:").append(this.getReason());
return sb.toString();
} | public String getJobConfig() {
<DeepExtract>
StringBuilder sb = new StringBuilder();
sb.append("job_id:").append(jobId);
sb.append(" status:").append(this.getStatusString(this.getStatus()));
sb.append(" taskcount:").append(this.getTaskCount());
sb.append(" starttime:").append(this.getStartTime());
sb.append(" lastTaskTime:").append(this.getLastTaskTime());
sb.append(" graphActivity:").append(this.getGraphActivity());
sb.append(" coordinatorid:").append(this.getCoordinatorId());
if (this.approvedAdapterNames != null) {
sb.append(" approvedadapterlist:").append(this.approvedAdapterNames.toString());
}
sb.append(" config:").append(this.getJobConfig());
sb.append(" history:").append(this.jobHistory.toString());
sb.append(" tasklist:").append(this.getTasks().toString());
sb.append("create_date:").append(this.getCreateDate().toString());
sb.append("expire_date:").append(this.getExpireDate());
sb.append("reset_date:").append(this.getResetDate());
sb.append("reason:").append(this.getReason());
return sb.toString();
</DeepExtract>
} | lemongrenade | positive | 2,325 |
public Criteria andCouponTypeIn(List<Integer> values) {
if (values == null) {
throw new RuntimeException("Value for " + "couponType" + " cannot be null");
}
criteria.add(new Criterion("coupon_type in", values));
return (Criteria) this;
} | public Criteria andCouponTypeIn(List<Integer> values) {
<DeepExtract>
if (values == null) {
throw new RuntimeException("Value for " + "couponType" + " cannot be null");
}
criteria.add(new Criterion("coupon_type in", values));
</DeepExtract>
return (Criteria) this;
} | oauth2-resource | positive | 2,326 |
private void drawLabel(Canvas canvas) {
float yAxisBtm = mCanvasH - mOffBtm;
int offset = DensityUtil.dp2px(1);
int valueH = Util.getTextHeight(mXValues.get(0), mTextPaint);
float xAxisTxt_Y = yAxisBtm + valueH + offset;
mXAxisTxt_Y = xAxisTxt_Y;
for (int i = 0; i < mXAxisCount; i++) {
key = mXValues.get(i);
int valueW = Util.getTextWidth(key, mTextPaint);
if (i == 0) {
xOffset = start_x + mLabelWidth / 2 - valueW / 2;
} else {
xOffset = start_x + mLabelWidth * i - mInterSpace * i + (mLabelWidth / 2 - valueW / 2);
}
canvas.drawText(key, xOffset, xAxisTxt_Y, mTextPaint);
}
} | private void drawLabel(Canvas canvas) {
float yAxisBtm = mCanvasH - mOffBtm;
int offset = DensityUtil.dp2px(1);
int valueH = Util.getTextHeight(mXValues.get(0), mTextPaint);
float xAxisTxt_Y = yAxisBtm + valueH + offset;
<DeepExtract>
mXAxisTxt_Y = xAxisTxt_Y;
</DeepExtract>
for (int i = 0; i < mXAxisCount; i++) {
key = mXValues.get(i);
int valueW = Util.getTextWidth(key, mTextPaint);
if (i == 0) {
xOffset = start_x + mLabelWidth / 2 - valueW / 2;
} else {
xOffset = start_x + mLabelWidth * i - mInterSpace * i + (mLabelWidth / 2 - valueW / 2);
}
canvas.drawText(key, xOffset, xAxisTxt_Y, mTextPaint);
}
} | WidgetCase | positive | 2,327 |
public ForeignKeyConstraintClause addRefColumns(Column... columns) {
_refColumns.addObjects(Converter.CUSTOM_COLUMN_TO_OBJ, (Object[]) columns);
return this;
} | public ForeignKeyConstraintClause addRefColumns(Column... columns) {
<DeepExtract>
_refColumns.addObjects(Converter.CUSTOM_COLUMN_TO_OBJ, (Object[]) columns);
return this;
</DeepExtract>
} | sqlbuilder | positive | 2,328 |
@Override
public Boolean component2() {
return (Boolean) get(1);
} | @Override
public Boolean component2() {
<DeepExtract>
return (Boolean) get(1);
</DeepExtract>
} | wdumper | positive | 2,329 |
@Override
public void delete(int memberId, int index) throws GondolaException {
double r = Math.random();
if (enabled && r < .001) {
throw new GondolaException(GondolaException.Code.ERROR, "Nasty exception for index=" + index);
}
return r;
storage.delete(memberId, index);
} | @Override
public void delete(int memberId, int index) throws GondolaException {
<DeepExtract>
double r = Math.random();
if (enabled && r < .001) {
throw new GondolaException(GondolaException.Code.ERROR, "Nasty exception for index=" + index);
}
return r;
</DeepExtract>
storage.delete(memberId, index);
} | gondola | positive | 2,330 |
@Override
public DataProcessor handleError(ByteChannel socketChannel, Throwable e) throws IOException {
Peer self = myContext.getPeersStorage().getSelf();
Handshake handshake = Handshake.craft(myTorrentHash.getInfoHash(), self.getPeerIdArray());
if (handshake == null) {
logger.warn("can not craft handshake message. Self peer id is {}, torrent hash is {}", Arrays.toString(self.getPeerIdArray()), Arrays.toString(myTorrentHash.getInfoHash()));
return new ShutdownProcessor();
}
ByteBuffer messageToSend = ByteBuffer.wrap(handshake.getData().array());
logger.trace("try send handshake {} to {}", handshake, socketChannel);
while (messageToSend.hasRemaining()) {
socketChannel.write(messageToSend);
}
return new HandshakeReceiver(myContext, myRemotePeerIp, myRemotePeerPort, true);
} | @Override
public DataProcessor handleError(ByteChannel socketChannel, Throwable e) throws IOException {
<DeepExtract>
Peer self = myContext.getPeersStorage().getSelf();
Handshake handshake = Handshake.craft(myTorrentHash.getInfoHash(), self.getPeerIdArray());
if (handshake == null) {
logger.warn("can not craft handshake message. Self peer id is {}, torrent hash is {}", Arrays.toString(self.getPeerIdArray()), Arrays.toString(myTorrentHash.getInfoHash()));
return new ShutdownProcessor();
}
ByteBuffer messageToSend = ByteBuffer.wrap(handshake.getData().array());
logger.trace("try send handshake {} to {}", handshake, socketChannel);
while (messageToSend.hasRemaining()) {
socketChannel.write(messageToSend);
}
return new HandshakeReceiver(myContext, myRemotePeerIp, myRemotePeerPort, true);
</DeepExtract>
} | ttorrent | positive | 2,331 |
@Override
public File get(String imageUri) {
String fileName = fileNameGenerator.generate(imageUri);
File dir = cacheDir;
if (!cacheDir.exists() && !cacheDir.mkdirs()) {
if (reserveCacheDir != null && (reserveCacheDir.exists() || reserveCacheDir.mkdirs())) {
dir = reserveCacheDir;
}
}
return new File(dir, fileName);
} | @Override
public File get(String imageUri) {
<DeepExtract>
String fileName = fileNameGenerator.generate(imageUri);
File dir = cacheDir;
if (!cacheDir.exists() && !cacheDir.mkdirs()) {
if (reserveCacheDir != null && (reserveCacheDir.exists() || reserveCacheDir.mkdirs())) {
dir = reserveCacheDir;
}
}
return new File(dir, fileName);
</DeepExtract>
} | KM-Popup-Image-Slider | positive | 2,332 |
public Criteria andARealNameIsNull() {
if ("a_real_name is null" == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion("a_real_name is null"));
return (Criteria) this;
} | public Criteria andARealNameIsNull() {
<DeepExtract>
if ("a_real_name is null" == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion("a_real_name is null"));
</DeepExtract>
return (Criteria) this;
} | webike | positive | 2,333 |
@Override
public void onStop() {
super.onStop();
if (users != null)
users.deleteObserver(this);
BusProvider.getInstance().unregister(this);
} | @Override
public void onStop() {
super.onStop();
<DeepExtract>
if (users != null)
users.deleteObserver(this);
</DeepExtract>
BusProvider.getInstance().unregister(this);
} | QuasselDroid | positive | 2,334 |
public static void loadImageSmall(SimpleDraweeView simpleDraweeView, String url) {
if (TextUtils.isEmpty(url) || simpleDraweeView == null) {
return;
}
Uri uri = Uri.parse(url);
ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);
imageRequestBuilder.setRotationOptions(RotationOptions.autoRotate());
imageRequestBuilder.setProgressiveRenderingEnabled(false);
if (true) {
imageRequestBuilder.setCacheChoice(ImageRequest.CacheChoice.SMALL);
}
if (0 > 0 && 0 > 0) {
imageRequestBuilder.setResizeOptions(new ResizeOptions(0, 0));
}
if (UriUtil.isLocalFileUri(uri)) {
imageRequestBuilder.setLocalThumbnailPreviewsEnabled(true);
}
if (null != null) {
imageRequestBuilder.setPostprocessor(null);
}
ImageRequest imageRequest = imageRequestBuilder.build();
PipelineDraweeControllerBuilder draweeControllerBuilder = Fresco.newDraweeControllerBuilder();
draweeControllerBuilder.setOldController(simpleDraweeView.getController());
draweeControllerBuilder.setImageRequest(imageRequest);
if (null != null) {
draweeControllerBuilder.setControllerListener(null);
}
draweeControllerBuilder.setTapToRetryEnabled(false);
draweeControllerBuilder.setAutoPlayAnimations(true);
DraweeController draweeController = draweeControllerBuilder.build();
simpleDraweeView.setController(draweeController);
} | public static void loadImageSmall(SimpleDraweeView simpleDraweeView, String url) {
if (TextUtils.isEmpty(url) || simpleDraweeView == null) {
return;
}
Uri uri = Uri.parse(url);
<DeepExtract>
ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);
imageRequestBuilder.setRotationOptions(RotationOptions.autoRotate());
imageRequestBuilder.setProgressiveRenderingEnabled(false);
if (true) {
imageRequestBuilder.setCacheChoice(ImageRequest.CacheChoice.SMALL);
}
if (0 > 0 && 0 > 0) {
imageRequestBuilder.setResizeOptions(new ResizeOptions(0, 0));
}
if (UriUtil.isLocalFileUri(uri)) {
imageRequestBuilder.setLocalThumbnailPreviewsEnabled(true);
}
if (null != null) {
imageRequestBuilder.setPostprocessor(null);
}
ImageRequest imageRequest = imageRequestBuilder.build();
PipelineDraweeControllerBuilder draweeControllerBuilder = Fresco.newDraweeControllerBuilder();
draweeControllerBuilder.setOldController(simpleDraweeView.getController());
draweeControllerBuilder.setImageRequest(imageRequest);
if (null != null) {
draweeControllerBuilder.setControllerListener(null);
}
draweeControllerBuilder.setTapToRetryEnabled(false);
draweeControllerBuilder.setAutoPlayAnimations(true);
DraweeController draweeController = draweeControllerBuilder.build();
simpleDraweeView.setController(draweeController);
</DeepExtract>
} | fresco-helper | positive | 2,335 |
public static Field getFieldAnnotatedWith(Object object, Class<? extends Annotation> annotationType) {
assertObjectInGetInternalStateIsNotNull(object);
Field foundField = null;
final Class<?> originalStartClass = getType(object);
while (getType(object) != null) {
final Field[] declaredFields = getType(object).getDeclaredFields();
for (Field field : declaredFields) {
if (new FieldAnnotationMatcherStrategy(annotationType).matches(field) && hasFieldProperModifier(object, field)) {
if (foundField != null) {
throw new TooManyFieldsFoundException("Two or more fields matching " + new FieldAnnotationMatcherStrategy(annotationType) + ".");
}
foundField = field;
}
}
if (foundField != null) {
break;
} else if (!true) {
break;
}
getType(object) = getType(object).getSuperclass();
}
if (foundField == null) {
new FieldAnnotationMatcherStrategy(annotationType).notFound(originalStartClass, !isClass(object));
return null;
}
foundField.setAccessible(true);
return foundField;
} | public static Field getFieldAnnotatedWith(Object object, Class<? extends Annotation> annotationType) {
<DeepExtract>
assertObjectInGetInternalStateIsNotNull(object);
Field foundField = null;
final Class<?> originalStartClass = getType(object);
while (getType(object) != null) {
final Field[] declaredFields = getType(object).getDeclaredFields();
for (Field field : declaredFields) {
if (new FieldAnnotationMatcherStrategy(annotationType).matches(field) && hasFieldProperModifier(object, field)) {
if (foundField != null) {
throw new TooManyFieldsFoundException("Two or more fields matching " + new FieldAnnotationMatcherStrategy(annotationType) + ".");
}
foundField = field;
}
}
if (foundField != null) {
break;
} else if (!true) {
break;
}
getType(object) = getType(object).getSuperclass();
}
if (foundField == null) {
new FieldAnnotationMatcherStrategy(annotationType).notFound(originalStartClass, !isClass(object));
return null;
}
foundField.setAccessible(true);
return foundField;
</DeepExtract>
} | awaitility | positive | 2,337 |
@Test
public void resolveViewNameTabletDeviceNoSitePreferenceTabletPrefixAndSuffix() throws Exception {
device.setDeviceType(DeviceType.TABLET);
request.setAttribute(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, device);
viewResolver.setTabletPrefix("tablet/");
viewResolver.setTabletSuffix(".tab");
expect(delegateViewResolver.resolveViewName("tablet/" + viewName + ".tab", locale)).andReturn(view);
replay(delegateViewResolver, view);
View result = viewResolver.resolveViewName(viewName, locale);
assertSame("Invalid view", view, result);
verify(delegateViewResolver, view);
} | @Test
public void resolveViewNameTabletDeviceNoSitePreferenceTabletPrefixAndSuffix() throws Exception {
device.setDeviceType(DeviceType.TABLET);
request.setAttribute(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, device);
viewResolver.setTabletPrefix("tablet/");
viewResolver.setTabletSuffix(".tab");
<DeepExtract>
expect(delegateViewResolver.resolveViewName("tablet/" + viewName + ".tab", locale)).andReturn(view);
replay(delegateViewResolver, view);
View result = viewResolver.resolveViewName(viewName, locale);
assertSame("Invalid view", view, result);
verify(delegateViewResolver, view);
</DeepExtract>
} | spring-mobile | positive | 2,338 |
public ElementValue css(String css) {
new CssSelector(css).setSource(source);
actions.add(new CssSelector(css));
return new ElementValue(this, field);
} | public ElementValue css(String css) {
<DeepExtract>
new CssSelector(css).setSource(source);
actions.add(new CssSelector(css));
return new ElementValue(this, field);
</DeepExtract>
} | Elise | positive | 2,340 |
@Override
protected boolean matches(Object item, Description mismatch) {
Object actual;
try {
actual = field.get(item);
} catch (Exception e) {
throw new AssertionError(format("IllegalAccess, reading field '%s' from %s", field.getName(), item));
}
if (!matcher.matches(actual)) {
mismatch.appendText("'").appendText(field.getName()).appendText("' ");
matcher.describeMismatch(actual, mismatch);
return false;
}
return true;
} | @Override
protected boolean matches(Object item, Description mismatch) {
<DeepExtract>
Object actual;
try {
actual = field.get(item);
} catch (Exception e) {
throw new AssertionError(format("IllegalAccess, reading field '%s' from %s", field.getName(), item));
}
</DeepExtract>
if (!matcher.matches(actual)) {
mismatch.appendText("'").appendText(field.getName()).appendText("' ");
matcher.describeMismatch(actual, mismatch);
return false;
}
return true;
} | JavaHamcrest | positive | 2,341 |
private void onFoundReconnectionPeripheral(@NotNull final BluetoothPeripheral peripheral) {
final String peripheralAddress = peripheral.getAddress();
final BluetoothPeripheralCallback peripheralCallback = reconnectCallbacks.get(peripheralAddress);
logger.info(String.format("found peripheral to autoconnect '%s'", peripheralAddress));
autoScanActive = false;
reconnectPeripheralAddresses.remove(peripheralAddress);
reconnectCallbacks.remove(peripheralAddress);
unconnectedPeripherals.remove(peripheralAddress);
if (peripheral.getDevice() == null) {
peripheral.setDevice(Objects.requireNonNull(getDeviceByAddress(peripheralAddress)));
if (peripheral.getDevice() != null) {
peripheral.setName(peripheral.getDevice().getName());
}
}
Objects.requireNonNull(peripheral, NULL_PERIPHERAL_ERROR);
Objects.requireNonNull(peripheralCallback, "no valid peripheral callback specified");
peripheral.setPeripheralCallback(peripheralCallback);
if (connectedPeripherals.containsKey(peripheral.getAddress())) {
logger.warn(String.format("WARNING: Already connected to %s'", peripheral.getAddress()));
return;
}
if (unconnectedPeripherals.containsKey(peripheral.getAddress())) {
logger.warn(String.format("WARNING: Already connecting to %s'", peripheral.getAddress()));
return;
}
if (peripheral.getDevice() == null) {
logger.warn(String.format("WARNING: Peripheral '%s' doesn't have Bluez device", peripheral.getAddress()));
return;
}
unconnectedPeripherals.put(peripheral.getAddress(), peripheral);
enqueue(() -> {
scannedBluezDevices.remove(adapter.getPath(peripheral.getAddress()));
final BluezDevice bluezDevice = getDeviceByAddress(peripheral.getAddress());
if (bluezDevice != null) {
peripheral.setDevice(bluezDevice);
}
currentDeviceAddress = peripheral.getAddress();
currentCommand = PROPERTY_CONNECTED;
try {
peripheral.connect();
} catch (NullPointerException ignored) {
completedCommand();
}
});
if (!reconnectPeripheralAddresses.isEmpty()) {
autoScanActive = true;
startScanning();
} else if (normalScanActive) {
startScanning();
}
} | private void onFoundReconnectionPeripheral(@NotNull final BluetoothPeripheral peripheral) {
final String peripheralAddress = peripheral.getAddress();
final BluetoothPeripheralCallback peripheralCallback = reconnectCallbacks.get(peripheralAddress);
logger.info(String.format("found peripheral to autoconnect '%s'", peripheralAddress));
autoScanActive = false;
reconnectPeripheralAddresses.remove(peripheralAddress);
reconnectCallbacks.remove(peripheralAddress);
unconnectedPeripherals.remove(peripheralAddress);
if (peripheral.getDevice() == null) {
peripheral.setDevice(Objects.requireNonNull(getDeviceByAddress(peripheralAddress)));
if (peripheral.getDevice() != null) {
peripheral.setName(peripheral.getDevice().getName());
}
}
<DeepExtract>
Objects.requireNonNull(peripheral, NULL_PERIPHERAL_ERROR);
Objects.requireNonNull(peripheralCallback, "no valid peripheral callback specified");
peripheral.setPeripheralCallback(peripheralCallback);
if (connectedPeripherals.containsKey(peripheral.getAddress())) {
logger.warn(String.format("WARNING: Already connected to %s'", peripheral.getAddress()));
return;
}
if (unconnectedPeripherals.containsKey(peripheral.getAddress())) {
logger.warn(String.format("WARNING: Already connecting to %s'", peripheral.getAddress()));
return;
}
if (peripheral.getDevice() == null) {
logger.warn(String.format("WARNING: Peripheral '%s' doesn't have Bluez device", peripheral.getAddress()));
return;
}
unconnectedPeripherals.put(peripheral.getAddress(), peripheral);
enqueue(() -> {
scannedBluezDevices.remove(adapter.getPath(peripheral.getAddress()));
final BluezDevice bluezDevice = getDeviceByAddress(peripheral.getAddress());
if (bluezDevice != null) {
peripheral.setDevice(bluezDevice);
}
currentDeviceAddress = peripheral.getAddress();
currentCommand = PROPERTY_CONNECTED;
try {
peripheral.connect();
} catch (NullPointerException ignored) {
completedCommand();
}
});
</DeepExtract>
if (!reconnectPeripheralAddresses.isEmpty()) {
autoScanActive = true;
startScanning();
} else if (normalScanActive) {
startScanning();
}
} | blessed-bluez | positive | 2,343 |
public Criteria andIsmenuEqualTo(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "ismenu" + " cannot be null");
}
criteria.add(new Criterion("ISMENU =", value));
return (Criteria) this;
} | public Criteria andIsmenuEqualTo(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "ismenu" + " cannot be null");
}
criteria.add(new Criterion("ISMENU =", value));
</DeepExtract>
return (Criteria) this;
} | console | positive | 2,344 |
public static int createdmesgInfo(FlatBufferBuilder builder, byte level, long seconds, int message) {
builder.startObject(3);
builder.addLong(1, seconds, 0);
builder.addOffset(2, message, 0);
builder.addByte(0, level, 6);
int o = builder.endObject();
return o;
} | public static int createdmesgInfo(FlatBufferBuilder builder, byte level, long seconds, int message) {
builder.startObject(3);
builder.addLong(1, seconds, 0);
builder.addOffset(2, message, 0);
builder.addByte(0, level, 6);
<DeepExtract>
int o = builder.endObject();
return o;
</DeepExtract>
} | OSMonitor | positive | 2,345 |
protected boolean removeEldestEntry(Map.Entry eldest) {
if (removalPolicy != null && eldest != null) {
Stack locals = new Stack();
locals.push(eldest.getValue());
locals.push(SleepUtils.getScalar(eldest.getKey().toString()));
locals.push(SleepUtils.getHashScalar(this));
Scalar value = removalPolicy.callClosure("remove", null, locals);
return SleepUtils.isTrueScalar(value);
}
return false;
} | protected boolean removeEldestEntry(Map.Entry eldest) {
<DeepExtract>
if (removalPolicy != null && eldest != null) {
Stack locals = new Stack();
locals.push(eldest.getValue());
locals.push(SleepUtils.getScalar(eldest.getKey().toString()));
locals.push(SleepUtils.getHashScalar(this));
Scalar value = removalPolicy.callClosure("remove", null, locals);
return SleepUtils.isTrueScalar(value);
}
return false;
</DeepExtract>
} | sleep | positive | 2,346 |
private void jMenuItemDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int index = jTableHTTPHeaders.getSelectedRow();
manager.HTTPheaders.removeElementAt(index);
httpHeaderTableModel = new HTTPHeaderTableModel(this.manager.getHTTPHeaders());
jTableHTTPHeaders.setModel(httpHeaderTableModel);
htmlParseTableModel = new HTMLParseTableModel(manager.elementsToParse);
jTableHTMLParseElements.setModel(htmlParseTableModel);
} | private void jMenuItemDeleteActionPerformed(java.awt.event.ActionEvent evt) {
int index = jTableHTTPHeaders.getSelectedRow();
manager.HTTPheaders.removeElementAt(index);
<DeepExtract>
httpHeaderTableModel = new HTTPHeaderTableModel(this.manager.getHTTPHeaders());
jTableHTTPHeaders.setModel(httpHeaderTableModel);
htmlParseTableModel = new HTMLParseTableModel(manager.elementsToParse);
jTableHTMLParseElements.setModel(htmlParseTableModel);
</DeepExtract>
} | DirBuster | positive | 2,347 |
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) {
return;
}
g.translate(thumbBounds.x, thumbBounds.y);
final boolean vertical = isVertical();
int hGap = vertical ? 2 : 1;
int vGap = vertical ? 1 : 2;
int w = adjustThumbWidth(thumbBounds.width - hGap * 2);
int h = thumbBounds.height - vGap * 2;
if (vertical) {
h -= 1;
} else {
w -= 1;
}
final Paint paint;
final Color start = adjustColor(getGradientLightColor());
final Color end = adjustColor(getGradientDarkColor());
if (vertical) {
paint = UIUtil.getGradientPaint(1, 0, start, w + 1, 0, end);
} else {
paint = UIUtil.getGradientPaint(0, 1, start, 0, h + 1, end);
}
(Graphics2D) g.setPaint(paint);
(Graphics2D) g.fillRect(hGap + 1, vGap + 1, w - 1, h - 1);
final Stroke stroke = (Graphics2D) g.getStroke();
(Graphics2D) g.setStroke(BORDER_STROKE);
(Graphics2D) g.setColor(getGradientThumbBorderColor());
(Graphics2D) g.drawRoundRect(hGap, vGap, w, h, 3, 3);
(Graphics2D) g.setStroke(stroke);
g.translate(-thumbBounds.x, -thumbBounds.y);
} | @Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) {
return;
}
g.translate(thumbBounds.x, thumbBounds.y);
<DeepExtract>
final boolean vertical = isVertical();
int hGap = vertical ? 2 : 1;
int vGap = vertical ? 1 : 2;
int w = adjustThumbWidth(thumbBounds.width - hGap * 2);
int h = thumbBounds.height - vGap * 2;
if (vertical) {
h -= 1;
} else {
w -= 1;
}
final Paint paint;
final Color start = adjustColor(getGradientLightColor());
final Color end = adjustColor(getGradientDarkColor());
if (vertical) {
paint = UIUtil.getGradientPaint(1, 0, start, w + 1, 0, end);
} else {
paint = UIUtil.getGradientPaint(0, 1, start, 0, h + 1, end);
}
(Graphics2D) g.setPaint(paint);
(Graphics2D) g.fillRect(hGap + 1, vGap + 1, w - 1, h - 1);
final Stroke stroke = (Graphics2D) g.getStroke();
(Graphics2D) g.setStroke(BORDER_STROKE);
(Graphics2D) g.setColor(getGradientThumbBorderColor());
(Graphics2D) g.drawRoundRect(hGap, vGap, w, h, 3, 3);
(Graphics2D) g.setStroke(stroke);
</DeepExtract>
g.translate(-thumbBounds.x, -thumbBounds.y);
} | SequencePlugin | positive | 2,348 |
protected void initView(View view) {
mBackImageView = view.findViewById(R.id.iv_back);
mLineView = view.findViewById(R.id.view_line);
mFinishImageView = view.findViewById(R.id.iv_finish);
mTitleTextView = view.findViewById(R.id.toolbar_title);
mBackImageView.setOnClickListener(mOnClickListener);
mFinishImageView.setOnClickListener(mOnClickListener);
mMoreImageView = view.findViewById(R.id.iv_more);
mMoreImageView.setOnClickListener(mOnClickListener);
mBackImageView.setVisibility(View.GONE);
mLineView.setVisibility(View.GONE);
} | protected void initView(View view) {
mBackImageView = view.findViewById(R.id.iv_back);
mLineView = view.findViewById(R.id.view_line);
mFinishImageView = view.findViewById(R.id.iv_finish);
mTitleTextView = view.findViewById(R.id.toolbar_title);
mBackImageView.setOnClickListener(mOnClickListener);
mFinishImageView.setOnClickListener(mOnClickListener);
mMoreImageView = view.findViewById(R.id.iv_more);
mMoreImageView.setOnClickListener(mOnClickListener);
<DeepExtract>
mBackImageView.setVisibility(View.GONE);
mLineView.setVisibility(View.GONE);
</DeepExtract>
} | CloudBlindDate | positive | 2,349 |
public void retrievePlayerInfo(long queueId) {
JsonObject object = new JsonObject();
object.addProperty("queueId", queueId);
return client.sendRpcAndWait(SERVICE, "call", uuid, mode.name(), "retrievePlayerInfoV3", new JsonObject().toString());
} | public void retrievePlayerInfo(long queueId) {
JsonObject object = new JsonObject();
object.addProperty("queueId", queueId);
<DeepExtract>
return client.sendRpcAndWait(SERVICE, "call", uuid, mode.name(), "retrievePlayerInfoV3", new JsonObject().toString());
</DeepExtract>
} | riotapi | positive | 2,350 |
public static void main(String[] args) {
SpeedMonitor1 monitor = new SpeedMonitor1();
Speedometer1 speedo = new Speedometer1();
speedo.addObserver(monitor);
speedo.addObserver(new AutomaticGearbox());
speedo.setCurrentSpeed(50);
speedo.setCurrentSpeed(70);
speedo.setCurrentSpeed(40);
speedo.setCurrentSpeed(100);
speedo.setCurrentSpeed(69);
SpeedMonitor2 monitor = new SpeedMonitor2();
Speedometer2 speedo = new Speedometer2();
speedo.addSpeedometerListener(monitor);
speedo.setCurrentSpeed(50);
speedo.setCurrentSpeed(70);
speedo.setCurrentSpeed(40);
speedo.setCurrentSpeed(100);
speedo.setCurrentSpeed(69);
} | public static void main(String[] args) {
SpeedMonitor1 monitor = new SpeedMonitor1();
Speedometer1 speedo = new Speedometer1();
speedo.addObserver(monitor);
speedo.addObserver(new AutomaticGearbox());
speedo.setCurrentSpeed(50);
speedo.setCurrentSpeed(70);
speedo.setCurrentSpeed(40);
speedo.setCurrentSpeed(100);
speedo.setCurrentSpeed(69);
<DeepExtract>
SpeedMonitor2 monitor = new SpeedMonitor2();
Speedometer2 speedo = new Speedometer2();
speedo.addSpeedometerListener(monitor);
speedo.setCurrentSpeed(50);
speedo.setCurrentSpeed(70);
speedo.setCurrentSpeed(40);
speedo.setCurrentSpeed(100);
speedo.setCurrentSpeed(69);
</DeepExtract>
} | jdpe2 | positive | 2,351 |
@BeforeMethod
public void setUp() throws IOException {
tempFiles = new TempFiles();
communicationManagerList = new ArrayList<CommunicationManager>();
Logger.getRootLogger().setLevel(Utils.getLogLevel());
int port = 6969;
this.tracker = new Tracker(port, "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + port + "" + ANNOUNCE_URL);
tracker.setAnnounceInterval(5);
this.tracker.start(true);
} | @BeforeMethod
public void setUp() throws IOException {
tempFiles = new TempFiles();
communicationManagerList = new ArrayList<CommunicationManager>();
Logger.getRootLogger().setLevel(Utils.getLogLevel());
<DeepExtract>
int port = 6969;
this.tracker = new Tracker(port, "http://" + InetAddress.getLocalHost().getHostAddress() + ":" + port + "" + ANNOUNCE_URL);
tracker.setAnnounceInterval(5);
this.tracker.start(true);
</DeepExtract>
} | ttorrent | positive | 2,352 |
@Override
public void onServiceConnected(ComponentName name, IBinder binder) {
mBinder = (DownloadManagerService.DMBinder) binder;
mManager = setupDownloadManager(mBinder);
mAdapter = new MissionAdapter(mActivity, mBinder, mManager, mLinear);
if (mLinear) {
mList.setLayoutManager(mLinearManager);
} else {
mList.setLayoutManager(mGridManager);
}
mList.setAdapter(mAdapter);
if (mSwitch != null) {
mSwitch.setIcon(mLinear ? R.drawable.grid : R.drawable.list);
}
mPrefs.edit().putBoolean("linear", mLinear).commit();
} | @Override
public void onServiceConnected(ComponentName name, IBinder binder) {
mBinder = (DownloadManagerService.DMBinder) binder;
mManager = setupDownloadManager(mBinder);
<DeepExtract>
mAdapter = new MissionAdapter(mActivity, mBinder, mManager, mLinear);
if (mLinear) {
mList.setLayoutManager(mLinearManager);
} else {
mList.setLayoutManager(mGridManager);
}
mList.setAdapter(mAdapter);
if (mSwitch != null) {
mSwitch.setIcon(mLinear ? R.drawable.grid : R.drawable.list);
}
mPrefs.edit().putBoolean("linear", mLinear).commit();
</DeepExtract>
} | Float-Tube | positive | 2,353 |
@Override
public void onDestroy() {
super.onDestroy();
if (unreadTask != null) {
try {
if (unreadTask.isRunning())
unreadTask.cancel(true);
} catch (NullPointerException ignored) {
}
}
if (markAsReadTask != null) {
try {
if (markAsReadTask.isRunning())
markAsReadTask.cancel(true);
} catch (NullPointerException ignored) {
}
}
if (topicSummaries != null)
topicSummaries.clear();
} | @Override
public void onDestroy() {
super.onDestroy();
<DeepExtract>
if (unreadTask != null) {
try {
if (unreadTask.isRunning())
unreadTask.cancel(true);
} catch (NullPointerException ignored) {
}
}
</DeepExtract>
if (markAsReadTask != null) {
try {
if (markAsReadTask.isRunning())
markAsReadTask.cancel(true);
} catch (NullPointerException ignored) {
}
}
if (topicSummaries != null)
topicSummaries.clear();
} | mTHMMY | positive | 2,354 |
public void changedUpdate(DocumentEvent e) {
clickSaveConnection.setVisible(true);
DIRTY_ITEM = (String) comboConnectionList.getSelectedItem();
SAVE_NEEDED = true;
} | public void changedUpdate(DocumentEvent e) {
<DeepExtract>
clickSaveConnection.setVisible(true);
DIRTY_ITEM = (String) comboConnectionList.getSelectedItem();
SAVE_NEEDED = true;
</DeepExtract>
} | HBase-Manager | positive | 2,355 |
public static void mergearray(int[] arr1, int[] arr2) {
int i = arr1.length - 1, j = 0;
int i = arr1.length - 1, j = 0;
while (i >= 0 && j < arr2.length) {
if (arr1[i] > arr2[j]) {
int temp = arr1[i];
arr1[i] = arr2[j];
arr2[j] = temp;
i--;
j++;
} else {
break;
}
}
for (int i = 0; i < arr1.length - 1; i++) {
if (arr1[i] > arr1[i + 1]) {
int temp = arr1[i];
arr1[i] = arr1[i + 1];
arr1[i + 1] = temp;
}
}
for (int i = 0; i < arr2.length - 1; i++) {
if (arr2[i] > arr2[i + 1]) {
int temp = arr2[i];
arr2[i] = arr2[i + 1];
arr2[i + 1] = temp;
}
}
for (int j2 = 0; j2 < arr1.length; j2++) {
System.out.println(arr1[j2]);
}
System.out.println();
for (int j2 = 0; j2 < arr2.length; j2++) {
System.out.println(arr2[j2]);
}
} | public static void mergearray(int[] arr1, int[] arr2) {
int i = arr1.length - 1, j = 0;
int i = arr1.length - 1, j = 0;
while (i >= 0 && j < arr2.length) {
if (arr1[i] > arr2[j]) {
int temp = arr1[i];
arr1[i] = arr2[j];
arr2[j] = temp;
i--;
j++;
} else {
break;
}
}
for (int i = 0; i < arr1.length - 1; i++) {
if (arr1[i] > arr1[i + 1]) {
int temp = arr1[i];
arr1[i] = arr1[i + 1];
arr1[i + 1] = temp;
}
}
<DeepExtract>
for (int i = 0; i < arr2.length - 1; i++) {
if (arr2[i] > arr2[i + 1]) {
int temp = arr2[i];
arr2[i] = arr2[i + 1];
arr2[i + 1] = temp;
}
}
</DeepExtract>
for (int j2 = 0; j2 < arr1.length; j2++) {
System.out.println(arr1[j2]);
}
System.out.println();
for (int j2 = 0; j2 < arr2.length; j2++) {
System.out.println(arr2[j2]);
}
} | Java-Solutions | positive | 2,356 |
public Criteria andItemsnumLessThan(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "itemsnum" + " cannot be null");
}
criteria.add(new Criterion("itemsNum <", value));
return (Criteria) this;
} | public Criteria andItemsnumLessThan(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "itemsnum" + " cannot be null");
}
criteria.add(new Criterion("itemsNum <", value));
</DeepExtract>
return (Criteria) this;
} | Maven-Spring-SpringMVC-Mybatis | positive | 2,357 |
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (hasMultiTouch)
return false;
if (!imgLargeWidth && !imgLargeHeight)
return false;
if (mTranslate.isRunning)
return false;
float vx = velocityX;
float vy = velocityY;
if (Math.round(mImgRect.left) >= mCropRect.left || Math.round(mImgRect.right) <= mCropRect.right) {
vx = 0;
}
if (Math.round(mImgRect.top) >= mCropRect.top || Math.round(mImgRect.bottom) <= mCropRect.bottom) {
vy = 0;
}
if (canRotate || mDegrees % 90 != 0) {
float toDegrees = (int) (mDegrees / 90) * 90;
float remainder = mDegrees % 90;
if (remainder > 45)
toDegrees += 90;
else if (remainder < -45)
toDegrees -= 90;
mTranslate.withRotate((int) mDegrees, (int) toDegrees);
mDegrees = toDegrees;
}
mLastFlingX = vx < 0 ? Integer.MAX_VALUE : 0;
int distanceX = (int) (vx > 0 ? Math.abs(mImgRect.left) : mImgRect.right - mCropRect.right);
distanceX = vx < 0 ? Integer.MAX_VALUE - distanceX : distanceX;
int minX = vx < 0 ? distanceX : 0;
int maxX = vx < 0 ? Integer.MAX_VALUE : distanceX;
int overX = vx < 0 ? Integer.MAX_VALUE - minX : distanceX;
mLastFlingY = vy < 0 ? Integer.MAX_VALUE : 0;
int distanceY = (int) (vy > 0 ? Math.abs(mImgRect.top - mCropRect.top) : mImgRect.bottom - mCropRect.bottom);
distanceY = vy < 0 ? Integer.MAX_VALUE - distanceY : distanceY;
int minY = vy < 0 ? distanceY : 0;
int maxY = vy < 0 ? Integer.MAX_VALUE : distanceY;
int overY = vy < 0 ? Integer.MAX_VALUE - minY : distanceY;
if (vx == 0) {
maxX = 0;
minX = 0;
}
if (vy == 0) {
maxY = 0;
minY = 0;
}
mFlingScroller.fling(mLastFlingX, mLastFlingY, (int) vx, (int) vy, minX, maxX, minY, maxY, Math.abs(overX) < MAX_FLING_OVER_SCROLL * 2 ? 0 : MAX_FLING_OVER_SCROLL, Math.abs(overY) < MAX_FLING_OVER_SCROLL * 2 ? 0 : MAX_FLING_OVER_SCROLL);
return super.onFling(e1, e2, velocityX, velocityY);
} | @Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (hasMultiTouch)
return false;
if (!imgLargeWidth && !imgLargeHeight)
return false;
if (mTranslate.isRunning)
return false;
float vx = velocityX;
float vy = velocityY;
if (Math.round(mImgRect.left) >= mCropRect.left || Math.round(mImgRect.right) <= mCropRect.right) {
vx = 0;
}
if (Math.round(mImgRect.top) >= mCropRect.top || Math.round(mImgRect.bottom) <= mCropRect.bottom) {
vy = 0;
}
if (canRotate || mDegrees % 90 != 0) {
float toDegrees = (int) (mDegrees / 90) * 90;
float remainder = mDegrees % 90;
if (remainder > 45)
toDegrees += 90;
else if (remainder < -45)
toDegrees -= 90;
mTranslate.withRotate((int) mDegrees, (int) toDegrees);
mDegrees = toDegrees;
}
<DeepExtract>
mLastFlingX = vx < 0 ? Integer.MAX_VALUE : 0;
int distanceX = (int) (vx > 0 ? Math.abs(mImgRect.left) : mImgRect.right - mCropRect.right);
distanceX = vx < 0 ? Integer.MAX_VALUE - distanceX : distanceX;
int minX = vx < 0 ? distanceX : 0;
int maxX = vx < 0 ? Integer.MAX_VALUE : distanceX;
int overX = vx < 0 ? Integer.MAX_VALUE - minX : distanceX;
mLastFlingY = vy < 0 ? Integer.MAX_VALUE : 0;
int distanceY = (int) (vy > 0 ? Math.abs(mImgRect.top - mCropRect.top) : mImgRect.bottom - mCropRect.bottom);
distanceY = vy < 0 ? Integer.MAX_VALUE - distanceY : distanceY;
int minY = vy < 0 ? distanceY : 0;
int maxY = vy < 0 ? Integer.MAX_VALUE : distanceY;
int overY = vy < 0 ? Integer.MAX_VALUE - minY : distanceY;
if (vx == 0) {
maxX = 0;
minX = 0;
}
if (vy == 0) {
maxY = 0;
minY = 0;
}
mFlingScroller.fling(mLastFlingX, mLastFlingY, (int) vx, (int) vy, minX, maxX, minY, maxY, Math.abs(overX) < MAX_FLING_OVER_SCROLL * 2 ? 0 : MAX_FLING_OVER_SCROLL, Math.abs(overY) < MAX_FLING_OVER_SCROLL * 2 ? 0 : MAX_FLING_OVER_SCROLL);
</DeepExtract>
return super.onFling(e1, e2, velocityX, velocityY);
} | BaseDemo | positive | 2,358 |
public Criteria andNumberIsNull() {
if ("number is null" == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion("number is null"));
return (Criteria) this;
} | public Criteria andNumberIsNull() {
<DeepExtract>
if ("number is null" == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion("number is null"));
</DeepExtract>
return (Criteria) this;
} | BookLibrarySystem | positive | 2,359 |
public synchronized UploadRequest<T> option(String name, Object value) {
if (dispatched) {
throw new IllegalStateException("Request already dispatched");
}
if (options == null) {
synchronized (optionsLockObject) {
if (options == null) {
options = new HashMap<>();
}
}
}
options.put(name, value);
return this;
} | public synchronized UploadRequest<T> option(String name, Object value) {
if (dispatched) {
throw new IllegalStateException("Request already dispatched");
}
<DeepExtract>
if (options == null) {
synchronized (optionsLockObject) {
if (options == null) {
options = new HashMap<>();
}
}
}
</DeepExtract>
options.put(name, value);
return this;
} | cloudinary_android | positive | 2,360 |
private List<Item> tree2List(final Class<? extends Item> cla, final SmartForest<Item> forest) throws InstantiationException, IllegalAccessException {
final List<Item> all = new ArrayList<Item>();
final SmartForest<Item>[] branches = forest.getBranches();
if (branches == null) {
return;
}
for (final SmartForest<Item> branche : branches) {
if (branche == null) {
continue;
}
Item param = branche.getParam();
if (param == null) {
param = cla.newInstance();
param.name = "" + (branche.getC());
param.status = 1;
} else {
param.status = branche.getStatus();
}
all.add(param);
}
for (final SmartForest<Item> branche : branches) {
if (branche != null) {
treeToLibrary(cla, all, branche, "" + (branche.getC()));
}
}
return all;
} | private List<Item> tree2List(final Class<? extends Item> cla, final SmartForest<Item> forest) throws InstantiationException, IllegalAccessException {
final List<Item> all = new ArrayList<Item>();
<DeepExtract>
final SmartForest<Item>[] branches = forest.getBranches();
if (branches == null) {
return;
}
for (final SmartForest<Item> branche : branches) {
if (branche == null) {
continue;
}
Item param = branche.getParam();
if (param == null) {
param = cla.newInstance();
param.name = "" + (branche.getC());
param.status = 1;
} else {
param.status = branche.getStatus();
}
all.add(param);
}
for (final SmartForest<Item> branche : branches) {
if (branche != null) {
treeToLibrary(cla, all, branche, "" + (branche.getC()));
}
}
</DeepExtract>
return all;
} | nlp-lang | positive | 2,361 |
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
long nanos = unit.toNanos(timeout);
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
E x;
while ((x = unlinkFirst()) == null) {
if (nanos <= 0)
return null;
nanos = notEmpty.awaitNanos(nanos);
}
return x;
} finally {
lock.unlock();
}
} | public E poll(long timeout, TimeUnit unit) throws InterruptedException {
<DeepExtract>
long nanos = unit.toNanos(timeout);
final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
E x;
while ((x = unlinkFirst()) == null) {
if (nanos <= 0)
return null;
nanos = notEmpty.awaitNanos(nanos);
}
return x;
} finally {
lock.unlock();
}
</DeepExtract>
} | Android-Universal-Image-Loader-Modify | positive | 2,362 |
public static CarsDao carsDao() {
try {
Class<CarsDao> carsDaoClass = (Class<CarsDao>) Class.forName(properties.getProperty("dao.cars.classname"));
Constructor<CarsDao> carsDaoConstructor = carsDaoClass.getConstructor(DataSource.class);
return carsDaoConstructor.newInstance(dataSource());
} catch (ReflectiveOperationException e) {
throw new IllegalArgumentException(e);
}
} | public static CarsDao carsDao() {
<DeepExtract>
try {
Class<CarsDao> carsDaoClass = (Class<CarsDao>) Class.forName(properties.getProperty("dao.cars.classname"));
Constructor<CarsDao> carsDaoConstructor = carsDaoClass.getConstructor(DataSource.class);
return carsDaoConstructor.newInstance(dataSource());
} catch (ReflectiveOperationException e) {
throw new IllegalArgumentException(e);
}
</DeepExtract>
} | JAVA_IT_PARK_WORK_3 | positive | 2,363 |
private ObjectFormatter initFormatterForType(Class<?> fieldClazz, String[] params) {
if (fieldClazz.equals(String.class) || List.class.isAssignableFrom(fieldClazz)) {
return null;
}
Class<? extends ObjectFormatter> formatterClass = ObjectFormatters.get(BasicTypeFormatter.detectBasicClass(fieldClazz));
if (formatterClass == null) {
throw new IllegalStateException("Can't find formatter for field " + field.getName() + " of type " + fieldClazz);
}
try {
ObjectFormatter objectFormatter = formatterClass.newInstance();
objectFormatter.initParam(params);
return objectFormatter;
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | private ObjectFormatter initFormatterForType(Class<?> fieldClazz, String[] params) {
if (fieldClazz.equals(String.class) || List.class.isAssignableFrom(fieldClazz)) {
return null;
}
Class<? extends ObjectFormatter> formatterClass = ObjectFormatters.get(BasicTypeFormatter.detectBasicClass(fieldClazz));
if (formatterClass == null) {
throw new IllegalStateException("Can't find formatter for field " + field.getName() + " of type " + fieldClazz);
}
<DeepExtract>
try {
ObjectFormatter objectFormatter = formatterClass.newInstance();
objectFormatter.initParam(params);
return objectFormatter;
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
</DeepExtract>
} | webmagic | positive | 2,364 |
public void disconnect() {
reportReader.shutdown();
try {
if (!reportReader.awaitTermination(1000, TimeUnit.MILLISECONDS)) {
this.interrupt();
}
} catch (InterruptedException e2) {
logger.catching(e2);
}
functionLock.lock();
reportReader.shutdownNow();
try {
sendCommand("d");
} catch (InvalidKeyException | IOException e) {
}
base.disconnectClient(clientId);
boolean something = false;
if (out != null) {
try {
out.close();
} catch (IOException e) {
logger.catching(e);
}
logger.debug("Writer Shut Down");
something = true;
out = null;
}
if (socket != null) {
try {
socket.close();
logger.debug("Socket Shut Down");
} catch (IOException e) {
logger.error("Socket Failed to Close", e);
}
something = true;
socket = null;
}
if (in != null) {
try {
in.close();
logger.debug("Reader Shut Down");
} catch (IOException e) {
logger.error("Reader Failed to Close", e);
}
something = true;
in = null;
}
if (!something) {
logger.info("Streams Closed Already");
}
manager.sendAnnouncement(clientId, ":eject: - dropping Client", "Server removing Client");
functionLock.unlock();
} | public void disconnect() {
reportReader.shutdown();
try {
if (!reportReader.awaitTermination(1000, TimeUnit.MILLISECONDS)) {
this.interrupt();
}
} catch (InterruptedException e2) {
logger.catching(e2);
}
functionLock.lock();
reportReader.shutdownNow();
try {
sendCommand("d");
} catch (InvalidKeyException | IOException e) {
}
base.disconnectClient(clientId);
<DeepExtract>
boolean something = false;
if (out != null) {
try {
out.close();
} catch (IOException e) {
logger.catching(e);
}
logger.debug("Writer Shut Down");
something = true;
out = null;
}
if (socket != null) {
try {
socket.close();
logger.debug("Socket Shut Down");
} catch (IOException e) {
logger.error("Socket Failed to Close", e);
}
something = true;
socket = null;
}
if (in != null) {
try {
in.close();
logger.debug("Reader Shut Down");
} catch (IOException e) {
logger.error("Reader Failed to Close", e);
}
something = true;
in = null;
}
if (!something) {
logger.info("Streams Closed Already");
}
</DeepExtract>
manager.sendAnnouncement(clientId, ":eject: - dropping Client", "Server removing Client");
functionLock.unlock();
} | FoxTrotUpscaler | positive | 2,365 |
@Override
public void windowClosing(WindowEvent e) {
dispose();
} | @Override
public void windowClosing(WindowEvent e) {
<DeepExtract>
dispose();
</DeepExtract>
} | WeblocOpener | positive | 2,366 |
public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData, byte[] target, byte[] site, Bool8 device) {
int offset = PAYLOAD_OFFSET;
byte[] memberData;
memberData = target;
for (int i = 0; i < (memberData.length); i++) {
messageData[(offset + i)] = memberData[i];
}
offset += memberData.length;
memberData = site;
for (int i = 0; i < (memberData.length); i++) {
messageData[(offset + i)] = memberData[i];
}
offset += memberData.length;
memberData = device.getBytes();
for (int i = 0; i < (memberData.length); i++) {
messageData[(offset + i)] = memberData[i];
}
offset += memberData.length;
} | public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData, byte[] target, byte[] site, Bool8 device) {
int offset = PAYLOAD_OFFSET;
<DeepExtract>
byte[] memberData;
memberData = target;
for (int i = 0; i < (memberData.length); i++) {
messageData[(offset + i)] = memberData[i];
}
offset += memberData.length;
memberData = site;
for (int i = 0; i < (memberData.length); i++) {
messageData[(offset + i)] = memberData[i];
}
offset += memberData.length;
memberData = device.getBytes();
for (int i = 0; i < (memberData.length); i++) {
messageData[(offset + i)] = memberData[i];
}
offset += memberData.length;
</DeepExtract>
} | lifx-sdk-android | positive | 2,367 |
@Override
public void onSaveVideoSuccess(String filePath) {
Log.i(TAG, "save edit success filePath: " + filePath);
mProcessingDialog.dismiss();
Intent intent = new Intent(VideoEditActivity.this, VideoEditActivity.class);
intent.putExtra(MP4_PATH, filePath);
VideoEditActivity.this.startActivity(intent);
} | @Override
public void onSaveVideoSuccess(String filePath) {
Log.i(TAG, "save edit success filePath: " + filePath);
mProcessingDialog.dismiss();
<DeepExtract>
Intent intent = new Intent(VideoEditActivity.this, VideoEditActivity.class);
intent.putExtra(MP4_PATH, filePath);
VideoEditActivity.this.startActivity(intent);
</DeepExtract>
} | eden | positive | 2,368 |
public QueryRow setEventLocation(Object obj) {
mRow.put(CalendarContract.Instances.EVENT_LOCATION, new TypedValue(obj));
return this;
} | public QueryRow setEventLocation(Object obj) {
<DeepExtract>
mRow.put(CalendarContract.Instances.EVENT_LOCATION, new TypedValue(obj));
return this;
</DeepExtract>
} | calendar-widget | positive | 2,370 |
public Criteria andShorepicBetween(String value1, String value2) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + "shorepic" + " cannot be null");
}
criteria.add(new Criterion("shorePic between", value1, value2));
return (Criteria) this;
} | public Criteria andShorepicBetween(String value1, String value2) {
<DeepExtract>
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + "shorepic" + " cannot be null");
}
criteria.add(new Criterion("shorePic between", value1, value2));
</DeepExtract>
return (Criteria) this;
} | Ordering | positive | 2,371 |
public void loadIrregular(InputStream inputStream) {
this.init();
this.table.load(inputStream + File.separator + FILENAME.POS_TABLE);
this.observation.load(inputStream + File.separator + FILENAME.OBSERVATION);
this.transition.load(inputStream + File.separator + FILENAME.TRANSITION);
this.irrTrie.load(inputStream + File.separator + FILENAME.IRREGULAR_MODEL);
this.observation.getTrieDictionary().buildFailLink();
this.irrTrie.getTrieDictionary().buildFailLink();
this.irrTrie.getTrieDictionary().buildFailLink();
} | public void loadIrregular(InputStream inputStream) {
<DeepExtract>
this.init();
this.table.load(inputStream + File.separator + FILENAME.POS_TABLE);
this.observation.load(inputStream + File.separator + FILENAME.OBSERVATION);
this.transition.load(inputStream + File.separator + FILENAME.TRANSITION);
this.irrTrie.load(inputStream + File.separator + FILENAME.IRREGULAR_MODEL);
this.observation.getTrieDictionary().buildFailLink();
this.irrTrie.getTrieDictionary().buildFailLink();
</DeepExtract>
this.irrTrie.getTrieDictionary().buildFailLink();
} | KOMORAN | positive | 2,372 |
public void notifyCreated(String itemPath, String clientId) {
itemPath = StringUtil.trimEnd(StringUtil.trimStart(itemPath, "/"), "/");
final TextMessage textMessage = new TextMessage(new Notification(itemPath, "created").toString());
send(clientId, textMessage);
} | public void notifyCreated(String itemPath, String clientId) {
<DeepExtract>
itemPath = StringUtil.trimEnd(StringUtil.trimStart(itemPath, "/"), "/");
final TextMessage textMessage = new TextMessage(new Notification(itemPath, "created").toString());
send(clientId, textMessage);
</DeepExtract>
} | WebDAVServerSamplesJava | positive | 2,373 |
public static DefaultFuture newFuture(Channel channel, Request request, int timeout) {
final DefaultFuture future = new DefaultFuture(channel, request, timeout);
return future;
} | public static DefaultFuture newFuture(Channel channel, Request request, int timeout) {
<DeepExtract>
</DeepExtract>
final DefaultFuture future = new DefaultFuture(channel, request, timeout);
<DeepExtract>
</DeepExtract>
return future;
<DeepExtract>
</DeepExtract>
} | netty-action | positive | 2,374 |
public void setShadowLayer(float radius, float dx, float dy, int color) {
super.setShadowLayer(radius, dx, dy, color);
mBorderSize = radius;
mBorderColor = color;
requestLayout();
invalidate();
mTextPaint = new TextPaint();
mTextPaint.setAntiAlias(true);
mTextPaint.setTextSize(getTextSize());
mTextPaint.setColor(mColor);
mTextPaint.setStyle(Paint.Style.FILL);
mTextPaint.setTypeface(getTypeface());
mTextPaintOutline = new TextPaint();
mTextPaintOutline.setAntiAlias(true);
mTextPaintOutline.setTextSize(getTextSize());
mTextPaintOutline.setColor(mBorderColor);
mTextPaintOutline.setStyle(Paint.Style.STROKE);
mTextPaintOutline.setTypeface(getTypeface());
mTextPaintOutline.setStrokeWidth(mBorderSize);
} | public void setShadowLayer(float radius, float dx, float dy, int color) {
super.setShadowLayer(radius, dx, dy, color);
mBorderSize = radius;
mBorderColor = color;
requestLayout();
invalidate();
<DeepExtract>
mTextPaint = new TextPaint();
mTextPaint.setAntiAlias(true);
mTextPaint.setTextSize(getTextSize());
mTextPaint.setColor(mColor);
mTextPaint.setStyle(Paint.Style.FILL);
mTextPaint.setTypeface(getTypeface());
mTextPaintOutline = new TextPaint();
mTextPaintOutline.setAntiAlias(true);
mTextPaintOutline.setTextSize(getTextSize());
mTextPaintOutline.setColor(mBorderColor);
mTextPaintOutline.setStyle(Paint.Style.STROKE);
mTextPaintOutline.setTypeface(getTypeface());
mTextPaintOutline.setStrokeWidth(mBorderSize);
</DeepExtract>
} | MD-BiliBili | positive | 2,375 |
public void visitFeature(FeatureTree tree) {
Iterator<Tree> childrenIterator = tree.childrenIterator();
Tree child;
while (childrenIterator.hasNext()) {
child = childrenIterator.next();
if (child != null) {
child.accept(this);
}
}
} | public void visitFeature(FeatureTree tree) {
<DeepExtract>
Iterator<Tree> childrenIterator = tree.childrenIterator();
Tree child;
while (childrenIterator.hasNext()) {
child = childrenIterator.next();
if (child != null) {
child.accept(this);
}
}
</DeepExtract>
} | sonar-gherkin-plugin | positive | 2,376 |
public SQL function(String function, String column) {
keywords.add(function);
lastCall = KEYWORD;
return this;
lastCall = FUNCTION;
lastCall = "_OPEN_PAREN_";
return chars("(");
smartCommaFnField();
openParen();
field(column);
closeParen();
lastCall = FIELD;
return this;
lastCall = "_CLOSE_PAREN_";
return chars(")");
lastCall = FUNCTION;
return this;
} | public SQL function(String function, String column) {
keywords.add(function);
lastCall = KEYWORD;
return this;
lastCall = FUNCTION;
lastCall = "_OPEN_PAREN_";
return chars("(");
smartCommaFnField();
openParen();
field(column);
closeParen();
lastCall = FIELD;
return this;
<DeepExtract>
lastCall = "_CLOSE_PAREN_";
return chars(")");
</DeepExtract>
lastCall = FUNCTION;
return this;
} | java-crud-api | positive | 2,378 |
public String getExpressionSummary() {
StringBuilder buf = new StringBuilder();
buf.append("seconds: ");
buf.append(getExpressionSetSummary(seconds));
buf.append("\n");
buf.append("minutes: ");
buf.append(getExpressionSetSummary(minutes));
buf.append("\n");
buf.append("hours: ");
buf.append(getExpressionSetSummary(hours));
buf.append("\n");
buf.append("daysOfMonth: ");
buf.append(getExpressionSetSummary(daysOfMonth));
buf.append("\n");
buf.append("months: ");
buf.append(getExpressionSetSummary(months));
buf.append("\n");
buf.append("daysOfWeek: ");
buf.append(getExpressionSetSummary(daysOfWeek));
buf.append("\n");
buf.append("lastdayOfWeek: ");
buf.append(lastdayOfWeek);
buf.append("\n");
buf.append("nearestWeekday: ");
buf.append(nearestWeekday);
buf.append("\n");
buf.append("NthDayOfWeek: ");
buf.append(nthdayOfWeek);
buf.append("\n");
buf.append("lastdayOfMonth: ");
buf.append(lastdayOfMonth);
buf.append("\n");
buf.append("years: ");
buf.append(getExpressionSetSummary(years));
buf.append("\n");
return cronExpression;
} | public String getExpressionSummary() {
StringBuilder buf = new StringBuilder();
buf.append("seconds: ");
buf.append(getExpressionSetSummary(seconds));
buf.append("\n");
buf.append("minutes: ");
buf.append(getExpressionSetSummary(minutes));
buf.append("\n");
buf.append("hours: ");
buf.append(getExpressionSetSummary(hours));
buf.append("\n");
buf.append("daysOfMonth: ");
buf.append(getExpressionSetSummary(daysOfMonth));
buf.append("\n");
buf.append("months: ");
buf.append(getExpressionSetSummary(months));
buf.append("\n");
buf.append("daysOfWeek: ");
buf.append(getExpressionSetSummary(daysOfWeek));
buf.append("\n");
buf.append("lastdayOfWeek: ");
buf.append(lastdayOfWeek);
buf.append("\n");
buf.append("nearestWeekday: ");
buf.append(nearestWeekday);
buf.append("\n");
buf.append("NthDayOfWeek: ");
buf.append(nthdayOfWeek);
buf.append("\n");
buf.append("lastdayOfMonth: ");
buf.append(lastdayOfMonth);
buf.append("\n");
buf.append("years: ");
buf.append(getExpressionSetSummary(years));
buf.append("\n");
<DeepExtract>
return cronExpression;
</DeepExtract>
} | java-bucket | positive | 2,379 |
@Test
public void testAddCommand() {
catalog.addCommand("AddingCommand", new AddingCommand("", null));
catalog.addCommand("DelegatingCommand", new DelegatingCommand(""));
catalog.addCommand("DelegatingFilter", new DelegatingFilter("", ""));
catalog.addCommand("ExceptionCommand", new ExceptionCommand(""));
catalog.addCommand("ExceptionFilter", new ExceptionFilter("", ""));
catalog.addCommand("NonDelegatingCommand", new NonDelegatingCommand(""));
catalog.addCommand("NonDelegatingFilter", new NonDelegatingFilter("", ""));
catalog.addCommand("ChainBase", new ChainBase<String, Object, Context<String, Object>>());
assertThat(catalog, hasCommandCount(8));
} | @Test
public void testAddCommand() {
<DeepExtract>
catalog.addCommand("AddingCommand", new AddingCommand("", null));
catalog.addCommand("DelegatingCommand", new DelegatingCommand(""));
catalog.addCommand("DelegatingFilter", new DelegatingFilter("", ""));
catalog.addCommand("ExceptionCommand", new ExceptionCommand(""));
catalog.addCommand("ExceptionFilter", new ExceptionFilter("", ""));
catalog.addCommand("NonDelegatingCommand", new NonDelegatingCommand(""));
catalog.addCommand("NonDelegatingFilter", new NonDelegatingFilter("", ""));
catalog.addCommand("ChainBase", new ChainBase<String, Object, Context<String, Object>>());
</DeepExtract>
assertThat(catalog, hasCommandCount(8));
} | commons-chain | positive | 2,380 |
@Override
public Long value1() {
return (Long) get(0);
} | @Override
public Long value1() {
<DeepExtract>
return (Long) get(0);
</DeepExtract>
} | openvsx | positive | 2,381 |
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
mMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
mVideoView = (VideoView) findViewById(R.id.videoView);
mStartText = (TextView) findViewById(R.id.startText);
mEndText = (TextView) findViewById(R.id.endText);
mSeekbar = (SeekBar) findViewById(R.id.seekBar);
mPlayPause = (ImageView) findViewById(R.id.playpause);
mLoading = (ProgressBar) findViewById(R.id.progressBar);
mControllers = findViewById(R.id.controllers);
mContainer = findViewById(R.id.container);
mVideoView.setOnClickListener(mPlayPauseHandler);
int w = (int) (mMetrics.widthPixels * MEDIA_BAR_WIDTH);
int h = (int) (mMetrics.heightPixels * MEDIA_BAR_HEIGHT);
int marginLeft = (int) (mMetrics.widthPixels * MEDIA_BAR_LEFT_MARGIN);
int marginTop = (int) (mMetrics.heightPixels * MEDIA_BAR_TOP_MARGIN);
int marginRight = (int) (mMetrics.widthPixels * MEDIA_BAR_RIGHT_MARGIN);
int marginBottom = (int) (mMetrics.heightPixels * MEDIA_BAR_BOTTOM_MARGIN);
LayoutParams lp = new LayoutParams(w, h);
lp.setMargins(marginLeft, marginTop, marginRight, marginBottom);
mControllers.setLayoutParams(lp);
mStartText.setText(getResources().getString(R.string.init_text));
mEndText.setText(getResources().getString(R.string.init_text));
mVideoView.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
String msg = "";
if (extra == MediaPlayer.MEDIA_ERROR_TIMED_OUT) {
msg = getString(R.string.video_error_media_load_timeout);
} else if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
msg = getString(R.string.video_error_server_unaccessible);
} else {
msg = getString(R.string.video_error_unknown_error);
}
mVideoView.stopPlayback();
mPlaybackState = PlaybackState.IDLE;
return false;
}
});
mVideoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.d(TAG, "onPrepared is reached");
mDuration = mp.getDuration();
mEndText.setText(Utils.formatMillis(mDuration));
mSeekbar.setMax(mDuration);
restartSeekBarTimer();
}
});
mVideoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
stopSeekBarTimer();
mPlaybackState = PlaybackState.IDLE;
updatePlayButton(PlaybackState.IDLE);
mControllersTimer = new Timer();
mControllersTimer.schedule(new BackToDetailTask(), HIDE_CONTROLLER_TIME);
}
});
Bundle b = getIntent().getExtras();
mSelectedMovie = (Movie) getIntent().getSerializableExtra(getResources().getString(R.string.movie));
if (null != b) {
mShouldStartPlayback = b.getBoolean(getResources().getString(R.string.should_start));
int startPosition = b.getInt(getResources().getString(R.string.start_position), 0);
mVideoView.setVideoPath(mSelectedMovie.getVideoUrl());
if (mShouldStartPlayback) {
mPlaybackState = PlaybackState.PLAYING;
updatePlayButton(mPlaybackState);
if (startPosition > 0) {
mVideoView.seekTo(startPosition);
}
mVideoView.start();
mPlayPause.requestFocus();
startControllersTimer();
} else {
updatePlaybackLocation();
mPlaybackState = PlaybackState.PAUSED;
updatePlayButton(mPlaybackState);
}
}
mVideoView.invalidate();
} | @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
mMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
mVideoView = (VideoView) findViewById(R.id.videoView);
mStartText = (TextView) findViewById(R.id.startText);
mEndText = (TextView) findViewById(R.id.endText);
mSeekbar = (SeekBar) findViewById(R.id.seekBar);
mPlayPause = (ImageView) findViewById(R.id.playpause);
mLoading = (ProgressBar) findViewById(R.id.progressBar);
mControllers = findViewById(R.id.controllers);
mContainer = findViewById(R.id.container);
mVideoView.setOnClickListener(mPlayPauseHandler);
int w = (int) (mMetrics.widthPixels * MEDIA_BAR_WIDTH);
int h = (int) (mMetrics.heightPixels * MEDIA_BAR_HEIGHT);
int marginLeft = (int) (mMetrics.widthPixels * MEDIA_BAR_LEFT_MARGIN);
int marginTop = (int) (mMetrics.heightPixels * MEDIA_BAR_TOP_MARGIN);
int marginRight = (int) (mMetrics.widthPixels * MEDIA_BAR_RIGHT_MARGIN);
int marginBottom = (int) (mMetrics.heightPixels * MEDIA_BAR_BOTTOM_MARGIN);
LayoutParams lp = new LayoutParams(w, h);
lp.setMargins(marginLeft, marginTop, marginRight, marginBottom);
mControllers.setLayoutParams(lp);
mStartText.setText(getResources().getString(R.string.init_text));
mEndText.setText(getResources().getString(R.string.init_text));
mVideoView.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
String msg = "";
if (extra == MediaPlayer.MEDIA_ERROR_TIMED_OUT) {
msg = getString(R.string.video_error_media_load_timeout);
} else if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) {
msg = getString(R.string.video_error_server_unaccessible);
} else {
msg = getString(R.string.video_error_unknown_error);
}
mVideoView.stopPlayback();
mPlaybackState = PlaybackState.IDLE;
return false;
}
});
mVideoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.d(TAG, "onPrepared is reached");
mDuration = mp.getDuration();
mEndText.setText(Utils.formatMillis(mDuration));
mSeekbar.setMax(mDuration);
restartSeekBarTimer();
}
});
mVideoView.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
stopSeekBarTimer();
mPlaybackState = PlaybackState.IDLE;
updatePlayButton(PlaybackState.IDLE);
mControllersTimer = new Timer();
mControllersTimer.schedule(new BackToDetailTask(), HIDE_CONTROLLER_TIME);
}
});
Bundle b = getIntent().getExtras();
mSelectedMovie = (Movie) getIntent().getSerializableExtra(getResources().getString(R.string.movie));
if (null != b) {
mShouldStartPlayback = b.getBoolean(getResources().getString(R.string.should_start));
int startPosition = b.getInt(getResources().getString(R.string.start_position), 0);
mVideoView.setVideoPath(mSelectedMovie.getVideoUrl());
if (mShouldStartPlayback) {
mPlaybackState = PlaybackState.PLAYING;
updatePlayButton(mPlaybackState);
if (startPosition > 0) {
mVideoView.seekTo(startPosition);
}
mVideoView.start();
mPlayPause.requestFocus();
startControllersTimer();
} else {
updatePlaybackLocation();
mPlaybackState = PlaybackState.PAUSED;
updatePlayButton(mPlaybackState);
}
}
<DeepExtract>
mVideoView.invalidate();
</DeepExtract>
} | BuildingForAndroidTV | positive | 2,382 |
public static VertxCradlePlatform createDefaultInstance() {
if (cradlePlatform != null) {
cradlePlatform.shutdown();
cradlePlatform = null;
}
JsonDocumentReaderWriter jdrw = new JsonDocumentReaderWriter();
createVertxEnviornmentVariables();
platform = PlatformLocator.factory.createPlatformManager(port, host);
vertx = platform.vertx();
eventBus = vertx.eventBus();
routeMatcher = new RemovableRouteMatcher();
httpServer = vertx.createHttpServer();
httpServer.requestHandler(routeMatcher);
sockJSServer = vertx.createSockJSServer(httpServer);
Hashtable<String, DocumentReader> documentReaders = new Hashtable<String, DocumentReader>();
documentReaders.put("application/json", jdrw);
Hashtable<String, DocumentWriter> documentWriters = new Hashtable<String, DocumentWriter>();
documentWriters.put("application/json", jdrw);
File tempFolder = new File(VERTX_TEMP);
if (!tempFolder.exists() && !tempFolder.mkdir()) {
throw new RuntimeException("Could not create vertx temp folder");
}
cradlePlatform = new VertxCradlePlatform("vertx/home", "vertx/mods", VERTX_TEMP, "org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory", "localhost", 9090, documentReaders, documentWriters, null, null);
createVertxEnviornmentVariables();
platform = PlatformLocator.factory.createPlatformManager(port, host);
vertx = platform.vertx();
eventBus = vertx.eventBus();
routeMatcher = new RemovableRouteMatcher();
httpServer = vertx.createHttpServer();
httpServer.requestHandler(routeMatcher);
sockJSServer = vertx.createSockJSServer(httpServer);
return cradlePlatform;
} | public static VertxCradlePlatform createDefaultInstance() {
if (cradlePlatform != null) {
cradlePlatform.shutdown();
cradlePlatform = null;
}
JsonDocumentReaderWriter jdrw = new JsonDocumentReaderWriter();
<DeepExtract>
createVertxEnviornmentVariables();
platform = PlatformLocator.factory.createPlatformManager(port, host);
vertx = platform.vertx();
eventBus = vertx.eventBus();
routeMatcher = new RemovableRouteMatcher();
httpServer = vertx.createHttpServer();
httpServer.requestHandler(routeMatcher);
sockJSServer = vertx.createSockJSServer(httpServer);
</DeepExtract>
Hashtable<String, DocumentReader> documentReaders = new Hashtable<String, DocumentReader>();
documentReaders.put("application/json", jdrw);
Hashtable<String, DocumentWriter> documentWriters = new Hashtable<String, DocumentWriter>();
documentWriters.put("application/json", jdrw);
File tempFolder = new File(VERTX_TEMP);
if (!tempFolder.exists() && !tempFolder.mkdir()) {
throw new RuntimeException("Could not create vertx temp folder");
}
cradlePlatform = new VertxCradlePlatform("vertx/home", "vertx/mods", VERTX_TEMP, "org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory", "localhost", 9090, documentReaders, documentWriters, null, null);
<DeepExtract>
createVertxEnviornmentVariables();
platform = PlatformLocator.factory.createPlatformManager(port, host);
vertx = platform.vertx();
eventBus = vertx.eventBus();
routeMatcher = new RemovableRouteMatcher();
httpServer = vertx.createHttpServer();
httpServer.requestHandler(routeMatcher);
sockJSServer = vertx.createSockJSServer(httpServer);
</DeepExtract>
return cradlePlatform;
} | platform | positive | 2,383 |
public void prepare() {
if (rendererBuildingState == RENDERER_BUILDING_STATE_BUILT) {
player.stop();
}
rendererBuilder.cancel();
videoFormat = null;
videoRenderer = null;
rendererBuildingState = RENDERER_BUILDING_STATE_BUILDING;
boolean playWhenReady = player.getPlayWhenReady();
int playbackState = getPlaybackState();
if (lastReportedPlayWhenReady != playWhenReady || lastReportedPlaybackState != playbackState) {
for (Listener listener : listeners) {
listener.onStateChanged(playWhenReady, playbackState);
}
lastReportedPlayWhenReady = playWhenReady;
lastReportedPlaybackState = playbackState;
}
rendererBuilder.buildRenderers(this);
} | public void prepare() {
if (rendererBuildingState == RENDERER_BUILDING_STATE_BUILT) {
player.stop();
}
rendererBuilder.cancel();
videoFormat = null;
videoRenderer = null;
rendererBuildingState = RENDERER_BUILDING_STATE_BUILDING;
<DeepExtract>
boolean playWhenReady = player.getPlayWhenReady();
int playbackState = getPlaybackState();
if (lastReportedPlayWhenReady != playWhenReady || lastReportedPlaybackState != playbackState) {
for (Listener listener : listeners) {
listener.onStateChanged(playWhenReady, playbackState);
}
lastReportedPlayWhenReady = playWhenReady;
lastReportedPlaybackState = playbackState;
}
</DeepExtract>
rendererBuilder.buildRenderers(this);
} | androidtv-sample-inputs | positive | 2,385 |
public Criteria andC_enableNotEqualTo(Boolean value) {
if (value == null) {
throw new RuntimeException("Value for " + "c_enable" + " cannot be null");
}
criteria.add(new Criterion("c_enable <>", value));
return (Criteria) this;
} | public Criteria andC_enableNotEqualTo(Boolean value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "c_enable" + " cannot be null");
}
criteria.add(new Criterion("c_enable <>", value));
</DeepExtract>
return (Criteria) this;
} | BaiChengNews | positive | 2,386 |
public Criteria andCoursenameNotEqualTo(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "coursename" + " cannot be null");
}
criteria.add(new Criterion("courseName <>", value));
return (Criteria) this;
} | public Criteria andCoursenameNotEqualTo(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "coursename" + " cannot be null");
}
criteria.add(new Criterion("courseName <>", value));
</DeepExtract>
return (Criteria) this;
} | examination_system- | positive | 2,387 |
public static BoxType parse(String typeString) {
try {
type = BoxType.valueOf(typeString.toUpperCase());
} catch (Exception e) {
type = UNKNOWN;
}
this.typeString = typeString;
return type;
} | public static BoxType parse(String typeString) {
try {
type = BoxType.valueOf(typeString.toUpperCase());
} catch (Exception e) {
type = UNKNOWN;
}
<DeepExtract>
this.typeString = typeString;
</DeepExtract>
return type;
} | flazr | positive | 2,388 |
void completeFields() {
text = "";
for (Name name : person.getNames()) {
text += U.firstAndLastName(name, " ") + " ";
}
for (EventFact event : person.getEventsFacts()) {
if (!("SEX".equals(event.getTag()) || "Y".equals(event.getValue())))
text += ProfileFactsFragment.writeEventText(event) + " ";
}
text = text.toLowerCase();
List<Name> names = person.getNames();
if (!names.isEmpty()) {
Name name = names.get(0);
String value = name.getValue();
if (value != null || name.getGiven() != null || name.getSurname() != null) {
String given = "";
String surname = " ";
if (value != null) {
if (value.replace('/', ' ').trim().isEmpty())
surname = null;
if (value.indexOf('/') > 0)
given = value.substring(0, value.indexOf('/'));
if (value.lastIndexOf('/') - value.indexOf('/') > 1)
surname = value.substring(value.indexOf('/') + 1, value.lastIndexOf("/"));
String prefix = name.getPrefix();
if (prefix != null && given.startsWith(prefix))
given = given.substring(prefix.length()).trim();
} else {
if (name.getGiven() != null)
given = name.getGiven();
if (name.getSurname() != null)
surname = name.getSurname();
}
String surPrefix = name.getSurnamePrefix();
if (surPrefix != null && surname.startsWith(surPrefix))
surname = surname.substring(surPrefix.length()).trim();
surname = surname.concat(given).toLowerCase();
}
}
return null;
date = Integer.MAX_VALUE;
for (EventFact event : person.getEventsFacts()) {
if (event.getDate() != null) {
datator.analyze(event.getDate());
date = datator.getDateNumber();
}
}
age = Integer.MAX_VALUE;
GedcomDateConverter start = null, end = null;
GedcomDateConverter start = null, end = null;
for (EventFact event : person.getEventsFacts()) {
if (event.getTag() != null && event.getTag().equals("BIRT") && event.getDate() != null) {
start = new GedcomDateConverter(event.getDate());
break;
}
}
for (EventFact event : person.getEventsFacts()) {
if (event.getTag() != null && event.getTag().equals("DEAT") && event.getDate() != null) {
end = new GedcomDateConverter(event.getDate());
break;
}
}
if (start != null && start.isSingleKind() && !start.data1.isFormat(Format.D_M)) {
LocalDate startDate = new LocalDate(start.data1.date);
LocalDate now = LocalDate.now();
if (end == null && startDate.isBefore(now) && Years.yearsBetween(startDate, now).getYears() <= 120 && !U.isDead(person)) {
end = new GedcomDateConverter(now.toDate());
}
if (end != null && end.isSingleKind() && !end.data1.isFormat(Format.D_M)) {
LocalDate endDate = new LocalDate(end.data1.date);
if (startDate.isBefore(endDate) || startDate.isEqual(endDate)) {
age = Days.daysBetween(startDate, endDate).getDays();
}
}
}
int count = 0;
if (person != null) {
List<Family> listaFamiglie = person.getParentFamilies(gc);
for (Family famiglia : listaFamiglie) {
count += famiglia.getHusbandRefs().size();
count += famiglia.getWifeRefs().size();
for (Person fratello : famiglia.getChildren(gc)) if (!fratello.equals(person))
count++;
}
for (Family famiglia : person.getParentFamilies(gc)) {
for (Person padre : famiglia.getHusbands(gc)) {
List<Family> famigliePadre = padre.getSpouseFamilies(gc);
famigliePadre.removeAll(listaFamiglie);
for (Family fam : famigliePadre) count += fam.getChildRefs().size();
}
for (Person madre : famiglia.getWives(gc)) {
List<Family> famiglieMadre = madre.getSpouseFamilies(gc);
famiglieMadre.removeAll(listaFamiglie);
for (Family fam : famiglieMadre) count += fam.getChildRefs().size();
}
}
for (Family famiglia : person.getSpouseFamilies(gc)) {
count += famiglia.getWifeRefs().size();
count += famiglia.getHusbandRefs().size();
count--;
count += famiglia.getChildRefs().size();
}
}
return count;
} | void completeFields() {
text = "";
for (Name name : person.getNames()) {
text += U.firstAndLastName(name, " ") + " ";
}
for (EventFact event : person.getEventsFacts()) {
if (!("SEX".equals(event.getTag()) || "Y".equals(event.getValue())))
text += ProfileFactsFragment.writeEventText(event) + " ";
}
text = text.toLowerCase();
List<Name> names = person.getNames();
if (!names.isEmpty()) {
Name name = names.get(0);
String value = name.getValue();
if (value != null || name.getGiven() != null || name.getSurname() != null) {
String given = "";
String surname = " ";
if (value != null) {
if (value.replace('/', ' ').trim().isEmpty())
surname = null;
if (value.indexOf('/') > 0)
given = value.substring(0, value.indexOf('/'));
if (value.lastIndexOf('/') - value.indexOf('/') > 1)
surname = value.substring(value.indexOf('/') + 1, value.lastIndexOf("/"));
String prefix = name.getPrefix();
if (prefix != null && given.startsWith(prefix))
given = given.substring(prefix.length()).trim();
} else {
if (name.getGiven() != null)
given = name.getGiven();
if (name.getSurname() != null)
surname = name.getSurname();
}
String surPrefix = name.getSurnamePrefix();
if (surPrefix != null && surname.startsWith(surPrefix))
surname = surname.substring(surPrefix.length()).trim();
surname = surname.concat(given).toLowerCase();
}
}
return null;
date = Integer.MAX_VALUE;
for (EventFact event : person.getEventsFacts()) {
if (event.getDate() != null) {
datator.analyze(event.getDate());
date = datator.getDateNumber();
}
}
age = Integer.MAX_VALUE;
GedcomDateConverter start = null, end = null;
GedcomDateConverter start = null, end = null;
for (EventFact event : person.getEventsFacts()) {
if (event.getTag() != null && event.getTag().equals("BIRT") && event.getDate() != null) {
start = new GedcomDateConverter(event.getDate());
break;
}
}
for (EventFact event : person.getEventsFacts()) {
if (event.getTag() != null && event.getTag().equals("DEAT") && event.getDate() != null) {
end = new GedcomDateConverter(event.getDate());
break;
}
}
if (start != null && start.isSingleKind() && !start.data1.isFormat(Format.D_M)) {
LocalDate startDate = new LocalDate(start.data1.date);
LocalDate now = LocalDate.now();
if (end == null && startDate.isBefore(now) && Years.yearsBetween(startDate, now).getYears() <= 120 && !U.isDead(person)) {
end = new GedcomDateConverter(now.toDate());
}
if (end != null && end.isSingleKind() && !end.data1.isFormat(Format.D_M)) {
LocalDate endDate = new LocalDate(end.data1.date);
if (startDate.isBefore(endDate) || startDate.isEqual(endDate)) {
age = Days.daysBetween(startDate, endDate).getDays();
}
}
}
<DeepExtract>
int count = 0;
if (person != null) {
List<Family> listaFamiglie = person.getParentFamilies(gc);
for (Family famiglia : listaFamiglie) {
count += famiglia.getHusbandRefs().size();
count += famiglia.getWifeRefs().size();
for (Person fratello : famiglia.getChildren(gc)) if (!fratello.equals(person))
count++;
}
for (Family famiglia : person.getParentFamilies(gc)) {
for (Person padre : famiglia.getHusbands(gc)) {
List<Family> famigliePadre = padre.getSpouseFamilies(gc);
famigliePadre.removeAll(listaFamiglie);
for (Family fam : famigliePadre) count += fam.getChildRefs().size();
}
for (Person madre : famiglia.getWives(gc)) {
List<Family> famiglieMadre = madre.getSpouseFamilies(gc);
famiglieMadre.removeAll(listaFamiglie);
for (Family fam : famiglieMadre) count += fam.getChildRefs().size();
}
}
for (Family famiglia : person.getSpouseFamilies(gc)) {
count += famiglia.getWifeRefs().size();
count += famiglia.getHusbandRefs().size();
count--;
count += famiglia.getChildRefs().size();
}
}
return count;
</DeepExtract>
} | FamilyGem | positive | 2,389 |
public void subscribe(String channelName, Handler handler) {
if (runner != null && !internalIsSubscribed(channelName)) {
runner.subscribe(channelName);
}
if (channels.containsKey(channelName)) {
Handler h = channels.get(channelName);
if (h instanceof MultiHandler) {
MultiHandler mh = (MultiHandler) h;
mh.add(handler);
}
} else {
channels.put(channelName, new MultiHandler(handler));
}
} | public void subscribe(String channelName, Handler handler) {
if (runner != null && !internalIsSubscribed(channelName)) {
runner.subscribe(channelName);
}
<DeepExtract>
if (channels.containsKey(channelName)) {
Handler h = channels.get(channelName);
if (h instanceof MultiHandler) {
MultiHandler mh = (MultiHandler) h;
mh.add(handler);
}
} else {
channels.put(channelName, new MultiHandler(handler));
}
</DeepExtract>
} | oocsi | positive | 2,390 |
public Then thenCase() {
methodNode.instructions.add(new JumpInsnNode(GOTO, endIf));
if (logger.isLoggable(Level.FINE)) {
String s = "";
new JumpInsnNode(GOTO, endIf).accept(methodVisitor);
List<String> text = methodVisitor.getText();
for (; currentOp < text.size(); currentOp++) {
String t = text.get(currentOp);
while (t.length() > 0) {
String current;
int i = t.indexOf('\n');
if (i >= 0) {
current = t.substring(0, i);
t = t.substring(i + 1);
} else {
current = t;
t = "";
}
s += indent() + current;
if ("end else, skip then" != null && "end else, skip then".length > 0) {
s += " //";
for (Object c : "end else, skip then") {
s += " " + c;
}
}
if (t.length() > 0) {
s += "\n";
}
}
}
logger.fine(s);
}
addInstruction(thenCase, "then label");
return new Then(endIf);
} | public Then thenCase() {
methodNode.instructions.add(new JumpInsnNode(GOTO, endIf));
if (logger.isLoggable(Level.FINE)) {
String s = "";
new JumpInsnNode(GOTO, endIf).accept(methodVisitor);
List<String> text = methodVisitor.getText();
for (; currentOp < text.size(); currentOp++) {
String t = text.get(currentOp);
while (t.length() > 0) {
String current;
int i = t.indexOf('\n');
if (i >= 0) {
current = t.substring(0, i);
t = t.substring(i + 1);
} else {
current = t;
t = "";
}
s += indent() + current;
if ("end else, skip then" != null && "end else, skip then".length > 0) {
s += " //";
for (Object c : "end else, skip then") {
s += " " + c;
}
}
if (t.length() > 0) {
s += "\n";
}
}
}
logger.fine(s);
}
<DeepExtract>
addInstruction(thenCase, "then label");
</DeepExtract>
return new Then(endIf);
} | brennus | positive | 2,391 |
public void sendReset() throws IOException {
out.write(CMD_RESET.getBytes());
out.write(ln);
out.flush();
try {
Thread.sleep(5000);
} catch (InterruptedException ignored) {
}
} | public void sendReset() throws IOException {
<DeepExtract>
out.write(CMD_RESET.getBytes());
out.write(ln);
out.flush();
</DeepExtract>
try {
Thread.sleep(5000);
} catch (InterruptedException ignored) {
}
} | JErgometer | positive | 2,392 |
public Criteria andBz12LessThanOrEqualTo(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "bz12" + " cannot be null");
}
criteria.add(new Criterion("`bz12` <=", value));
return (Criteria) this;
} | public Criteria andBz12LessThanOrEqualTo(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "bz12" + " cannot be null");
}
criteria.add(new Criterion("`bz12` <=", value));
</DeepExtract>
return (Criteria) this;
} | blockhealth | positive | 2,394 |
public Criteria andOrderidNotEqualTo(Integer value) {
if (value == null) {
throw new RuntimeException("Value for " + "orderid" + " cannot be null");
}
criteria.add(new Criterion("orderid <>", value));
return (Criteria) this;
} | public Criteria andOrderidNotEqualTo(Integer value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "orderid" + " cannot be null");
}
criteria.add(new Criterion("orderid <>", value));
</DeepExtract>
return (Criteria) this;
} | SSM_VUE | positive | 2,395 |
public void run() {
boolean doaction;
init_stacks();
yynerrs = 0;
yyerrflag = 0;
yychar = -1;
yystate = 0;
state_push(yystate);
while (true) {
doaction = true;
if (yydebug)
debug("loop");
for (yyn = yydefred[yystate]; yyn == 0; yyn = yydefred[yystate]) {
if (yydebug)
debug("yyn:" + yyn + " state:" + yystate + " yychar:" + yychar);
if (yychar < 0) {
yychar = yylex();
if (yydebug)
debug(" next yychar:" + yychar);
if (yychar < 0) {
yychar = 0;
if (yydebug)
yylexdebug(yystate, yychar);
}
}
yyn = yysindex[yystate];
if ((yyn != 0) && ((yyn += yychar) >= 0) && (yyn <= YYTABLESIZE) && (yycheck[yyn] == yychar)) {
if (yydebug)
debug("state " + yystate + ", shifting to state " + yytable[yyn]);
yystate = yytable[yyn];
state_push(yystate);
val_push(yylval);
yychar = -1;
if (yyerrflag > 0)
--yyerrflag;
doaction = false;
break;
}
yyn = yyrindex[yystate];
if ((yyn != 0) && ((yyn += yychar) >= 0) && (yyn <= YYTABLESIZE) && (yycheck[yyn] == yychar)) {
if (yydebug)
debug("reduce");
yyn = yytable[yyn];
doaction = true;
break;
} else {
if (yyerrflag == 0) {
yyerror("syntax error");
yynerrs++;
}
if (yyerrflag < 3) {
yyerrflag = 3;
while (true) {
if (stateptr < 0) {
yyerror("stack underflow. aborting...");
return 1;
}
yyn = yysindex[state_peek(0)];
if ((yyn != 0) && ((yyn += YYERRCODE) >= 0) && (yyn <= YYTABLESIZE) && (yycheck[yyn] == YYERRCODE)) {
if (yydebug)
debug("state " + state_peek(0) + ", error recovery shifting to state " + yytable[yyn] + " ");
yystate = yytable[yyn];
state_push(yystate);
val_push(yylval);
doaction = false;
break;
} else {
if (yydebug)
debug("error recovery discarding state " + state_peek(0) + " ");
if (stateptr < 0) {
yyerror("Stack underflow. aborting...");
return 1;
}
state_pop();
val_pop();
}
}
} else {
if (yychar == 0)
return 1;
if (yydebug) {
yys = null;
if (yychar <= YYMAXTOKEN)
yys = yyname[yychar];
if (yys == null)
yys = "illegal-symbol";
debug("state " + yystate + ", error recovery discards token " + yychar + " (" + yys + ")");
}
yychar = -1;
}
}
}
if (!doaction)
continue;
yym = yylen[yyn];
if (yydebug)
debug("state " + yystate + ", reducing " + yym + " by rule " + yyn + " (" + yyrule[yyn] + ")");
if (yym > 0)
yyval = val_peek(yym - 1);
switch(yyn) {
case 1:
{
String mname = ((Variable) val_peek(0)).getName();
module = (Module) Module.getToplevels().get(mname);
if (module == null) {
module = new Module(mname, null);
module.putTag(lex.makePosition());
}
equations = new HashMap();
}
break;
case 2:
{
Normalizer nz = new Normalizer(module);
try {
nz.normalize(equations);
} catch (SymbolException ex) {
parseError("Cannot normalize equations :" + ex);
}
modules.add(module);
}
break;
case 3:
{
if (module == null)
module = new Module("Main", null);
module.putTag(lex.makePosition());
equations = new HashMap();
}
break;
case 4:
{
Normalizer nz = new Normalizer(module);
try {
nz.normalize(equations);
} catch (SymbolException ex) {
parseError("Cannot normalize equations :" + ex);
}
modules.add(module);
}
break;
case 8:
{
yyval = new ExpressionList();
}
break;
case 9:
{
yyval = val_peek(1);
}
break;
case 10:
{
if (val_peek(2) instanceof ExpressionList) {
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
} else {
ExpressionList decls = new ExpressionList();
if (val_peek(2) != null)
decls.add(val_peek(2));
if (val_peek(0) != null)
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 11:
{
ExpressionList el = new ExpressionList();
if (val_peek(0) != null)
el.add(val_peek(0));
yyval = el;
}
break;
case 12:
{
Type t = val_peek(2).getType();
String lname = null;
if (t instanceof TypeConstructor)
lname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
lname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(2).getClass() + "(" + val_peek(2) + ")");
DataDefinition ddef = new DataDefinition(lname, t, module);
ddef.putTag(lex.makePosition());
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) ddef.addConstructor((ConstructorDefinition) it.next());
}
break;
case 13:
{
if (val_peek(0) != null) {
Equation eq = (Equation) val_peek(0);
ExpressionList lhs = (ExpressionList) eq.getLhs();
String fname = ((Variable) lhs.get(0)).getName();
addEquation(fname, eq);
}
}
break;
case 14:
{
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) {
Definition def = (Definition) it.next();
module.bind(def.getName(), def);
}
}
break;
case 18:
{
Type t = val_peek(1).getType();
String lname = null;
if (t instanceof TypeConstructor)
lname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
lname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(1).getClass() + "(" + val_peek(1) + ")");
Class cls;
try {
cls = Class.forName(((StringLiteral) val_peek(0)).getString());
PrimitiveData ddef = new PrimitiveData(lname, t, cls, module);
} catch (ClassNotFoundException cnfex) {
System.err.println("Error in native datatype definition : cannot find class " + ((StringLiteral) val_peek(0)).getString());
}
}
break;
case 19:
{
Type t = val_peek(3).getType();
String tname = null;
if (t instanceof TypeConstructor)
tname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
tname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(3).getClass() + "(" + val_peek(3) + ")");
DataDefinition ddef = (DataDefinition) module.resolveType(tname);
if (ddef != null) {
try {
Class cls = Class.forName(((StringLiteral) val_peek(0)).getString());
String cname = null;
t = val_peek(1).getType();
if (t instanceof TypeConstructor)
cname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
cname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(3).getClass() + "(" + val_peek(3) + ")");
PrimitiveConstructor ctor = new PrimitiveConstructor(cname, ddef, new Type[0], cls, module);
} catch (ClassNotFoundException cnfex) {
System.err.println("Error in native constructor definition : cannot find class " + ((StringLiteral) val_peek(0)).getString());
}
} else
System.err.println("Error in native constructor definition : cannot find data definition for " + tname);
}
break;
case 20:
{
Type t = val_peek(4).getType();
String tname = null;
if (t instanceof TypeConstructor)
tname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
tname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(4).getClass() + "(" + val_peek(4) + ")");
DataDefinition ddef = (DataDefinition) module.resolveType(tname);
if (ddef != null) {
try {
Class cls = Class.forName(((StringLiteral) val_peek(0)).getString());
String cname = null;
t = val_peek(2).getType();
if (t instanceof TypeConstructor)
cname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
cname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(4).getClass() + "(" + val_peek(4) + ")");
PrimitiveConstructor cdef = new PrimitiveConstructor(cname, ddef, new Type[0], cls, module);
if (val_peek(1) != null) {
Iterator it = ((ExpressionList) val_peek(1)).iterator();
while (it.hasNext()) {
TypeExpression tex = (TypeExpression) it.next();
if (tex.isStrict())
cdef.addStrictParameter(tex.getType());
else
cdef.addParameter(tex.getType());
}
}
} catch (ClassNotFoundException cnfex) {
System.err.println("Error in native constructor definition : cannot find class " + ((StringLiteral) val_peek(1)).getString());
}
} else
System.err.println("Error in native constructor definition : cannot find data definition for " + tname);
}
break;
case 21:
{
String vname = ((Variable) val_peek(3)).getName();
Type t = val_peek(1).getType();
try {
Class cls = Class.forName(((StringLiteral) val_peek(0)).getString());
PrimitiveFunction pf = new PrimitiveFunction(vname, module, t, cls);
PrimitivesCodeGenerator.registerStaticPrimitive(pf);
} catch (ClassNotFoundException cnfex) {
System.err.println("Error in native function definition : cannot find class " + ((StringLiteral) val_peek(0)).getString());
}
}
break;
case 22:
{
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
}
break;
case 23:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(0));
yyval = el;
}
break;
case 24:
{
ConstructorDefinition cdef = new ConstructorDefinition(((Variable) val_peek(0)).getName(), null, module);
cdef.putTag(lex.makePosition());
yyval = cdef;
}
break;
case 25:
{
ConstructorDefinition cdef = new ConstructorDefinition(((Variable) val_peek(1)).getName(), null, module);
cdef.putTag(lex.makePosition());
if (val_peek(0) != null) {
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) {
TypeExpression tex = (TypeExpression) it.next();
if (tex.isStrict())
cdef.addStrictParameter(tex.getType());
else
cdef.addParameter(tex.getType());
}
}
yyval = cdef;
}
break;
case 26:
{
ConstructorDefinition cdef = new ConstructorDefinition(((Variable) val_peek(1)).getName(), null, module);
cdef.putTag(lex.makePosition());
TypeExpression tex = (TypeExpression) val_peek(2);
if (tex.isStrict())
cdef.addStrictParameter(tex.getType());
else
cdef.addParameter(tex.getType());
tex = (TypeExpression) val_peek(0);
if (tex.isStrict())
cdef.addStrictParameter(tex.getType());
else
cdef.addParameter(tex.getType());
yyval = cdef;
}
break;
case 27:
{
if (val_peek(1) != null) {
((ExpressionList) val_peek(1)).add(val_peek(0));
yyval = val_peek(1);
} else {
ExpressionList el = new ExpressionList();
el.add(val_peek(0));
yyval = el;
}
}
break;
case 28:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(0));
yyval = el;
}
break;
case 29:
{
((TypeExpression) val_peek(0)).setStrict(true);
yyval = val_peek(0);
}
break;
case 30:
{
yyval = val_peek(0);
}
break;
case 31:
{
yyval = val_peek(0);
}
break;
case 32:
{
((TypeExpression) val_peek(0)).setStrict(true);
yyval = val_peek(0);
}
break;
case 33:
{
Equation eq = new Equation();
eq.setLhs(val_peek(1));
eq.setRhs(val_peek(0));
yyval = eq;
}
break;
case 34:
{
Equation eq = new Equation();
eq.setLhs(val_peek(1));
eq.setRhs(val_peek(0));
yyval = eq;
}
break;
case 35:
{
yyerror("Syntax error");
yyval = null;
}
break;
case 36:
{
Iterator it = ((ExpressionList) val_peek(2)).iterator();
ExpressionList el = new ExpressionList();
while (it.hasNext()) {
Definition def = new Definition();
def.setName(((Variable) it.next()).getName());
if (val_peek(0) != null)
def.setType(val_peek(0).getType());
el.add(def);
}
yyval = el;
}
break;
case 37:
{
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
}
break;
case 38:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(0));
yyval = el;
}
break;
case 39:
{
yyval = val_peek(0);
}
break;
case 40:
{
yyval = new TypeExpression(Types.fun(val_peek(2).getType(), val_peek(0).getType()));
}
break;
case 41:
{
yyval = val_peek(0);
}
break;
case 42:
{
Type tcon = val_peek(1).getType().getConstructor();
if (!(tcon instanceof PrimitiveType))
tcon.setKind(null);
yyval = new TypeExpression(Types.apply(val_peek(1).getType(), val_peek(0).getType()));
}
break;
case 43:
{
yyval = val_peek(0);
}
break;
case 44:
{
yyval = val_peek(0);
}
break;
case 45:
{
yyval = val_peek(0);
}
break;
case 46:
{
int i = 1;
List l = new ArrayList();
l.add(val_peek(4).getType());
l.add(val_peek(2).getType());
Iterator it = ((ExpressionList) val_peek(1)).iterator();
while (it.hasNext()) {
l.add(it.next());
i++;
}
yyval = new TypeExpression(Types.apply(Types.tuple(i), l));
}
break;
case 47:
{
yyval = new TypeExpression(Types.apply(Primitives.LIST, val_peek(1).getType()));
}
break;
case 48:
{
yyval = val_peek(1);
}
break;
case 51:
{
yyval = new TypeExpression(Types.makeTycon(((Constructor) val_peek(0)).getName()));
}
break;
case 52:
{
yyval = new TypeExpression(Primitives.UNIT);
}
break;
case 53:
{
yyval = new TypeExpression(Primitives.LIST);
}
break;
case 54:
{
yyval = new TypeExpression(Primitives.FUNCTION);
}
break;
case 55:
{
yyval = new TypeExpression(Primitives.TUPLE_2);
}
break;
case 56:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(1));
if (val_peek(0) != null)
el.addAll((ExpressionList) val_peek(0));
yyval = el;
}
break;
case 57:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(1));
el.add(val_peek(2));
el.add(val_peek(0));
yyval = el;
}
break;
case 58:
{
yyval = val_peek(0);
}
break;
case 59:
{
yyval = val_peek(0);
}
break;
case 60:
{
Application app = new Application();
app.putTag(lex.makePosition());
app.setFunction(val_peek(1));
app.addArgument(val_peek(2));
app.addArgument(val_peek(0));
yyval = app;
}
break;
case 61:
{
yyval = val_peek(0);
}
break;
case 62:
{
yyval = val_peek(0);
}
break;
case 63:
{
Application app = new Application();
app.putTag(lex.makePosition());
QualifiedVariable qv = new QualifiedVariable("negate");
qv.putTag(lex.makePosition());
qv.addPathElement("Prelude");
app.setFunction(qv);
app.addArgument(val_peek(0));
yyval = app;
}
break;
case 64:
{
Application app = new Application();
app.putTag(lex.makePosition());
app.setFunction(val_peek(1));
app.addArgument(val_peek(2));
app.addArgument(val_peek(0));
yyval = app;
}
break;
case 65:
{
List l = null;
if (val_peek(2) != null) {
l = (ExpressionList) val_peek(2);
} else
l = new ArrayList();
l.add(0, val_peek(3));
List vars = new ArrayList();
Abstraction abs = new Abstraction();
abs.putTag(lex.makePosition());
for (int i = 0; i < l.size(); i++) {
LocalBinding lb = LocalBinding.freshBinding();
lb.putTag(lex.makePosition());
abs.bind(lb);
vars.add(lb);
}
List pm = new ArrayList();
PatternMatch pm1 = new PatternMatch();
pm1.patterns = l;
pm1.expr = val_peek(0);
pm.add(pm1);
abs.setBody(new Matcher().match(vars, pm, val_peek(0)));
yyval = abs;
}
break;
case 66:
{
Let let = new Let();
let.setBody(val_peek(0));
Map eqs = new HashMap();
Iterator it = ((ExpressionList) val_peek(2)).iterator();
while (it.hasNext()) {
Equation eq = (Equation) it.next();
ExpressionList lhs = (ExpressionList) eq.getLhs();
String fname = ((Variable) lhs.get(0)).getName();
List l = (List) eqs.get(fname);
if (l == null) {
l = new ArrayList();
eqs.put(fname, l);
}
l.add(eq);
}
Normalizer nz = new Normalizer(let);
try {
nz.normalize(eqs);
} catch (SymbolException ex) {
parseError("Cannot normalize equations :" + ex);
}
yyval = let;
}
break;
case 67:
{
Conditional cond = new Conditional();
cond.putTag(lex.makePosition());
cond.setCondition(val_peek(4));
cond.setIfTrue(val_peek(2));
cond.setIfFalse(val_peek(0));
yyval = cond;
}
break;
case 68:
{
Alternative alt = new Alternative();
alt.putTag(lex.makePosition());
alt.setExpression(val_peek(4));
Iterator it = ((ExpressionList) val_peek(1)).iterator();
while (it.hasNext()) {
PatternAlternative pa = (PatternAlternative) it.next();
alt.addPattern(pa.getPattern(), pa.getExpr());
}
yyval = alt;
}
break;
case 69:
{
yyval = val_peek(0);
}
break;
case 70:
{
if (val_peek(1) instanceof Application) {
((Application) val_peek(1)).addArgument(val_peek(0));
yyval = val_peek(1);
} else {
Application app = new Application();
app.putTag(lex.makePosition());
app.setFunction(val_peek(1));
app.addArgument(val_peek(0));
yyval = app;
}
}
break;
case 71:
{
yyval = val_peek(0);
}
break;
case 72:
{
yyval = val_peek(0);
}
break;
case 73:
{
yyval = val_peek(0);
}
break;
case 74:
{
yyval = val_peek(0);
}
break;
case 75:
{
yyval = val_peek(0);
}
break;
case 76:
{
yyval = val_peek(0);
}
break;
case 77:
{
yyval = val_peek(1);
}
break;
case 78:
{
Application app = new Application();
app.putTag(lex.makePosition());
StringBuffer tconsb = new StringBuffer("((,");
for (int i = 0; i < ((ExpressionList) val_peek(1)).size(); i++) tconsb.append(",");
tconsb.append("))");
QualifiedConstructor qv = new QualifiedConstructor(tconsb.toString());
qv.putTag(lex.makePosition());
qv.addPathElement("Prelude");
app.setFunction(qv);
app.addArgument(val_peek(3));
app.addArgument(val_peek(2));
for (Iterator it = ((ExpressionList) val_peek(1)).iterator(); it.hasNext(); ) app.addArgument((Expression) it.next());
yyval = app;
}
break;
case 79:
{
Application app = new Application();
app.putTag(lex.makePosition());
Application cur = app;
QualifiedConstructor qv = new QualifiedConstructor("(:)");
qv.putTag(lex.makePosition());
qv.addPathElement("Prelude");
app.setFunction(qv);
app.addArgument(val_peek(2));
for (Iterator it = ((ExpressionList) val_peek(1)).iterator(); it.hasNext(); ) {
Application tmp = new Application();
tmp.putTag(lex.makePosition());
tmp.setFunction(qv);
tmp.addArgument((Expression) it.next());
cur.addArgument(tmp);
cur = tmp;
}
qv = new QualifiedConstructor("([])");
qv.putTag(lex.makePosition());
qv.addPathElement("Prelude");
cur.addArgument(qv);
yyval = app;
}
break;
case 84:
{
Application app = new Application();
app.putTag(lex.makePosition());
app.setFunction(val_peek(1));
app.addArgument(val_peek(2));
yyval = app;
}
break;
case 85:
{
Application app = new Application();
app.putTag(lex.makePosition());
app.setFunction(val_peek(2));
app.addArgument(val_peek(1));
yyval = app;
}
break;
case 86:
{
((ExpressionList) val_peek(1)).add(val_peek(0));
yyval = val_peek(1);
}
break;
case 87:
{
yyval = new ExpressionList();
}
break;
case 88:
{
yyval = val_peek(0);
}
break;
case 89:
{
if (val_peek(2) instanceof ExpressionList) {
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
} else {
ExpressionList decls = new ExpressionList();
decls.add(val_peek(2));
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 90:
{
yyval = val_peek(0);
}
break;
case 91:
{
yyval = new PatternAlternative((Pattern) val_peek(2), val_peek(0));
}
break;
case 92:
{
if (val_peek(1) instanceof ExpressionList) {
((ExpressionList) val_peek(1)).add(val_peek(0));
yyval = val_peek(1);
} else if (val_peek(1) == null) {
ExpressionList decls = new ExpressionList();
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 93:
{
yyval = null;
}
break;
case 94:
{
yyval = val_peek(0);
}
break;
case 95:
{
ConstructorPattern pat = new ConstructorPattern();
pat.putTag(lex.makePosition());
pat.setConstructor((Constructor) val_peek(1));
pat.addPattern((Pattern) val_peek(2));
System.err.println("Type of rh arg : " + val_peek(0).getClass());
pat.addPattern((Pattern) val_peek(0));
yyval = pat;
}
break;
case 96:
{
yyval = val_peek(0);
}
break;
case 97:
{
yyval = val_peek(0);
}
break;
case 98:
{
if (val_peek(1) instanceof ExpressionList) {
((ExpressionList) val_peek(1)).add(val_peek(0));
yyval = val_peek(1);
} else if (val_peek(1) == null) {
ExpressionList decls = new ExpressionList();
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 99:
{
yyval = null;
}
break;
case 100:
{
LocalBinding bind = new LocalBinding(((Variable) val_peek(0)).getName());
bind.putTag(lex.makePosition());
yyval = bind;
}
break;
case 101:
{
ConstructorPattern pat = new ConstructorPattern();
pat.putTag(lex.makePosition());
pat.setConstructor((Constructor) val_peek(0));
yyval = pat;
}
break;
case 102:
{
ConstructorPattern pat = new ConstructorPattern();
pat.putTag(lex.makePosition());
pat.setConstructor((Constructor) val_peek(1));
if (val_peek(0) != null) {
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) pat.addPattern((Pattern) it.next());
}
yyval = pat;
}
break;
case 103:
{
yyval = val_peek(0);
}
break;
case 104:
{
yyval = LocalBinding.wildcard;
}
break;
case 105:
{
yyval = val_peek(1);
}
break;
case 106:
{
ConstructorPattern pat = new ConstructorPattern();
pat.putTag(lex.makePosition());
StringBuffer tconsb = new StringBuffer("((,");
for (int i = 0; i < ((ExpressionList) val_peek(1)).size(); i++) tconsb.append(",");
tconsb.append("))");
QualifiedConstructor qv = new QualifiedConstructor(tconsb.toString());
qv.putTag(lex.makePosition());
qv.addPathElement("Prelude");
pat.setConstructor(qv);
pat.addPattern((Pattern) val_peek(3));
pat.addPattern((Pattern) val_peek(2));
for (Iterator it = ((ExpressionList) val_peek(1)).iterator(); it.hasNext(); ) pat.addPattern((Pattern) it.next());
yyval = pat;
}
break;
case 107:
{
List l = new ArrayList();
l.add(val_peek(2));
l.addAll((ExpressionList) val_peek(1));
ConstructorPattern app = makeListPattern(l);
yyval = app;
}
break;
case 108:
{
yyval = val_peek(0);
}
break;
case 109:
{
if (val_peek(2) instanceof ExpressionList) {
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
} else if (val_peek(2) == null) {
ExpressionList decls = new ExpressionList();
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 110:
{
yyval = null;
}
break;
case 111:
{
yyval = val_peek(0);
}
break;
case 112:
{
ConstructorPattern cp = new ConstructorPattern();
QualifiedConstructor qv = new QualifiedConstructor("Event");
qv.addPathElement("Prelude");
cp.setConstructor(qv);
cp.addPattern(LocalBinding.wildcard);
ConstructorPattern cp2 = (ConstructorPattern) val_peek(1);
cp.putTag(lex.makePosition());
if (val_peek(0) != null) {
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) cp2.addPattern((Pattern) it.next());
}
cp.addPattern(cp2);
yyval = cp;
}
break;
case 113:
{
ConstructorPattern cp = new ConstructorPattern();
QualifiedConstructor qv = new QualifiedConstructor("Event");
qv.addPathElement("Prelude");
cp.setConstructor(qv);
cp.addPattern((Pattern) val_peek(2));
cp.putTag(lex.makePosition());
ConstructorPattern cp2 = (ConstructorPattern) val_peek(1);
QualifiedConstructor qc = new QualifiedConstructor(cp2.getConstructor().getName());
qc.addPathElement((String) ((Literal) val_peek(2)).unpack());
cp2.setConstructor(qc);
if (val_peek(1) != null) {
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) cp2.addPattern((Pattern) it.next());
}
cp.addPattern(cp2);
yyval = cp;
}
break;
case 114:
{
yyval = null;
}
break;
case 115:
{
yyval = val_peek(1);
}
break;
case 116:
{
yyval = val_peek(1);
}
break;
case 117:
{
ConstructorPattern pat = new ConstructorPattern();
Constructor ctor = new Constructor("Return$" + ((StringLiteral) val_peek(0)).getString());
pat.setConstructor(ctor);
pat.putTag(lex.makePosition());
ctor.putTag(lex.makePosition());
yyval = pat;
}
break;
case 118:
{
ConstructorPattern pat = new ConstructorPattern();
Constructor ctor = new Constructor("Call$" + ((StringLiteral) val_peek(0)).getString());
pat.setConstructor(ctor);
pat.putTag(lex.makePosition());
ctor.putTag(lex.makePosition());
yyval = pat;
}
break;
case 119:
{
ConstructorPattern pat = new ConstructorPattern();
Constructor ctor = new Constructor("Full$" + ((StringLiteral) val_peek(0)).getString());
pat.setConstructor(ctor);
pat.putTag(lex.makePosition());
ctor.putTag(lex.makePosition());
yyval = pat;
}
break;
case 120:
{
yyval = new StringLiteral(((Variable) val_peek(0)).getName());
}
break;
case 121:
{
yyval = LocalBinding.wildcard;
}
break;
case 122:
{
yyval = new StringLiteral(((Variable) val_peek(0)).getName());
}
break;
case 123:
{
yyval = LocalBinding.wildcard;
}
break;
case 124:
{
yyval = new StringLiteral(((Variable) val_peek(0)).getName());
}
break;
case 125:
{
yyval = LocalBinding.wildcard;
}
break;
case 126:
{
yyval = val_peek(0);
}
break;
case 127:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(0));
yyval = el;
}
break;
case 128:
{
((ExpressionList) val_peek(1)).add(val_peek(0));
yyval = val_peek(1);
}
break;
case 129:
{
ExpressionList el = new ExpressionList();
yyval = el;
}
break;
case 130:
{
if (val_peek(2) instanceof ExpressionList) {
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
} else if (val_peek(2) == null) {
ExpressionList decls = new ExpressionList();
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 131:
{
ExpressionList decls = new ExpressionList();
decls.add(val_peek(0));
yyval = decls;
}
break;
case 132:
{
yyval = val_peek(0);
}
break;
case 133:
{
yyval = val_peek(0);
}
break;
case 134:
{
yyval = null;
}
break;
case 135:
{
yyval = null;
}
break;
case 136:
{
Constructor ctor = new Constructor("(())");
ctor.putTag(lex.makePosition());
yyval = ctor;
}
break;
case 137:
{
Constructor ctor = new Constructor("([])");
ctor.putTag(lex.makePosition());
yyval = ctor;
}
break;
case 138:
{
yyval = val_peek(0);
}
break;
case 139:
{
yyval = val_peek(0);
}
break;
case 140:
{
yyval = val_peek(0);
}
break;
case 141:
{
yyval = val_peek(0);
}
break;
case 142:
{
yyval = val_peek(1);
}
break;
case 143:
{
yyval = val_peek(0);
}
break;
case 144:
{
yyval = val_peek(1);
}
break;
case 145:
{
yyval = val_peek(0);
}
break;
case 146:
{
yyval = val_peek(0);
}
break;
case 147:
{
yyval = val_peek(1);
}
break;
case 148:
{
yyval = val_peek(0);
}
break;
case 149:
{
yyval = val_peek(1);
}
break;
case 150:
{
yyval = val_peek(0);
}
break;
case 151:
{
yyval = val_peek(1);
}
break;
case 152:
{
yyval = val_peek(0);
}
break;
case 153:
{
yyval = val_peek(1);
}
break;
case 154:
{
yyval = val_peek(0);
}
break;
case 155:
{
yyval = val_peek(0);
}
break;
case 156:
{
yyval = val_peek(0);
}
break;
case 157:
{
yyval = val_peek(0);
}
break;
case 158:
{
Variable var = new Variable("(-)");
var.putTag(lex.makePosition());
yyval = var;
}
break;
case 159:
{
Constructor ctor = new Constructor("(:)");
ctor.putTag(lex.makePosition());
yyval = ctor;
}
break;
case 160:
{
yyval = val_peek(0);
}
break;
case 161:
{
yyval = val_peek(0);
}
break;
case 162:
{
yyval = val_peek(1);
}
break;
case 163:
{
yyval = val_peek(0);
}
break;
case 164:
{
yyval = new TypeExpression(TypeFactory.makeTypeVariable(((Variable) val_peek(0)).getName()));
}
break;
case 165:
{
yyval = val_peek(0);
}
break;
case 166:
{
yyval = val_peek(0);
}
break;
case 167:
{
yyval = val_peek(0);
}
break;
case 168:
{
yyval = val_peek(0);
}
break;
case 169:
{
yyval = val_peek(0);
}
break;
}
if (yydebug)
debug("reduce");
state_drop(yym);
yystate = state_peek(0);
val_drop(yym);
yym = yylhs[yyn];
if ((yystate == 0) && (yym == 0)) {
debug("After reduction, shifting from state 0 to state " + YYFINAL + "");
yystate = YYFINAL;
state_push(YYFINAL);
val_push(yyval);
if (yychar < 0) {
yychar = yylex();
if (yychar < 0)
yychar = 0;
if (yydebug)
yylexdebug(yystate, yychar);
}
if (yychar == 0)
break;
} else {
yyn = yygindex[yym];
if ((yyn != 0) && ((yyn += yystate) >= 0) && (yyn <= YYTABLESIZE) && (yycheck[yyn] == yystate))
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
debug("after reduction, shifting from state " + state_peek(0) + " to state " + yystate + "");
state_push(yystate);
val_push(yyval);
}
}
return 0;
} | public void run() {
<DeepExtract>
boolean doaction;
init_stacks();
yynerrs = 0;
yyerrflag = 0;
yychar = -1;
yystate = 0;
state_push(yystate);
while (true) {
doaction = true;
if (yydebug)
debug("loop");
for (yyn = yydefred[yystate]; yyn == 0; yyn = yydefred[yystate]) {
if (yydebug)
debug("yyn:" + yyn + " state:" + yystate + " yychar:" + yychar);
if (yychar < 0) {
yychar = yylex();
if (yydebug)
debug(" next yychar:" + yychar);
if (yychar < 0) {
yychar = 0;
if (yydebug)
yylexdebug(yystate, yychar);
}
}
yyn = yysindex[yystate];
if ((yyn != 0) && ((yyn += yychar) >= 0) && (yyn <= YYTABLESIZE) && (yycheck[yyn] == yychar)) {
if (yydebug)
debug("state " + yystate + ", shifting to state " + yytable[yyn]);
yystate = yytable[yyn];
state_push(yystate);
val_push(yylval);
yychar = -1;
if (yyerrflag > 0)
--yyerrflag;
doaction = false;
break;
}
yyn = yyrindex[yystate];
if ((yyn != 0) && ((yyn += yychar) >= 0) && (yyn <= YYTABLESIZE) && (yycheck[yyn] == yychar)) {
if (yydebug)
debug("reduce");
yyn = yytable[yyn];
doaction = true;
break;
} else {
if (yyerrflag == 0) {
yyerror("syntax error");
yynerrs++;
}
if (yyerrflag < 3) {
yyerrflag = 3;
while (true) {
if (stateptr < 0) {
yyerror("stack underflow. aborting...");
return 1;
}
yyn = yysindex[state_peek(0)];
if ((yyn != 0) && ((yyn += YYERRCODE) >= 0) && (yyn <= YYTABLESIZE) && (yycheck[yyn] == YYERRCODE)) {
if (yydebug)
debug("state " + state_peek(0) + ", error recovery shifting to state " + yytable[yyn] + " ");
yystate = yytable[yyn];
state_push(yystate);
val_push(yylval);
doaction = false;
break;
} else {
if (yydebug)
debug("error recovery discarding state " + state_peek(0) + " ");
if (stateptr < 0) {
yyerror("Stack underflow. aborting...");
return 1;
}
state_pop();
val_pop();
}
}
} else {
if (yychar == 0)
return 1;
if (yydebug) {
yys = null;
if (yychar <= YYMAXTOKEN)
yys = yyname[yychar];
if (yys == null)
yys = "illegal-symbol";
debug("state " + yystate + ", error recovery discards token " + yychar + " (" + yys + ")");
}
yychar = -1;
}
}
}
if (!doaction)
continue;
yym = yylen[yyn];
if (yydebug)
debug("state " + yystate + ", reducing " + yym + " by rule " + yyn + " (" + yyrule[yyn] + ")");
if (yym > 0)
yyval = val_peek(yym - 1);
switch(yyn) {
case 1:
{
String mname = ((Variable) val_peek(0)).getName();
module = (Module) Module.getToplevels().get(mname);
if (module == null) {
module = new Module(mname, null);
module.putTag(lex.makePosition());
}
equations = new HashMap();
}
break;
case 2:
{
Normalizer nz = new Normalizer(module);
try {
nz.normalize(equations);
} catch (SymbolException ex) {
parseError("Cannot normalize equations :" + ex);
}
modules.add(module);
}
break;
case 3:
{
if (module == null)
module = new Module("Main", null);
module.putTag(lex.makePosition());
equations = new HashMap();
}
break;
case 4:
{
Normalizer nz = new Normalizer(module);
try {
nz.normalize(equations);
} catch (SymbolException ex) {
parseError("Cannot normalize equations :" + ex);
}
modules.add(module);
}
break;
case 8:
{
yyval = new ExpressionList();
}
break;
case 9:
{
yyval = val_peek(1);
}
break;
case 10:
{
if (val_peek(2) instanceof ExpressionList) {
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
} else {
ExpressionList decls = new ExpressionList();
if (val_peek(2) != null)
decls.add(val_peek(2));
if (val_peek(0) != null)
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 11:
{
ExpressionList el = new ExpressionList();
if (val_peek(0) != null)
el.add(val_peek(0));
yyval = el;
}
break;
case 12:
{
Type t = val_peek(2).getType();
String lname = null;
if (t instanceof TypeConstructor)
lname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
lname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(2).getClass() + "(" + val_peek(2) + ")");
DataDefinition ddef = new DataDefinition(lname, t, module);
ddef.putTag(lex.makePosition());
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) ddef.addConstructor((ConstructorDefinition) it.next());
}
break;
case 13:
{
if (val_peek(0) != null) {
Equation eq = (Equation) val_peek(0);
ExpressionList lhs = (ExpressionList) eq.getLhs();
String fname = ((Variable) lhs.get(0)).getName();
addEquation(fname, eq);
}
}
break;
case 14:
{
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) {
Definition def = (Definition) it.next();
module.bind(def.getName(), def);
}
}
break;
case 18:
{
Type t = val_peek(1).getType();
String lname = null;
if (t instanceof TypeConstructor)
lname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
lname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(1).getClass() + "(" + val_peek(1) + ")");
Class cls;
try {
cls = Class.forName(((StringLiteral) val_peek(0)).getString());
PrimitiveData ddef = new PrimitiveData(lname, t, cls, module);
} catch (ClassNotFoundException cnfex) {
System.err.println("Error in native datatype definition : cannot find class " + ((StringLiteral) val_peek(0)).getString());
}
}
break;
case 19:
{
Type t = val_peek(3).getType();
String tname = null;
if (t instanceof TypeConstructor)
tname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
tname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(3).getClass() + "(" + val_peek(3) + ")");
DataDefinition ddef = (DataDefinition) module.resolveType(tname);
if (ddef != null) {
try {
Class cls = Class.forName(((StringLiteral) val_peek(0)).getString());
String cname = null;
t = val_peek(1).getType();
if (t instanceof TypeConstructor)
cname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
cname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(3).getClass() + "(" + val_peek(3) + ")");
PrimitiveConstructor ctor = new PrimitiveConstructor(cname, ddef, new Type[0], cls, module);
} catch (ClassNotFoundException cnfex) {
System.err.println("Error in native constructor definition : cannot find class " + ((StringLiteral) val_peek(0)).getString());
}
} else
System.err.println("Error in native constructor definition : cannot find data definition for " + tname);
}
break;
case 20:
{
Type t = val_peek(4).getType();
String tname = null;
if (t instanceof TypeConstructor)
tname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
tname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(4).getClass() + "(" + val_peek(4) + ")");
DataDefinition ddef = (DataDefinition) module.resolveType(tname);
if (ddef != null) {
try {
Class cls = Class.forName(((StringLiteral) val_peek(0)).getString());
String cname = null;
t = val_peek(2).getType();
if (t instanceof TypeConstructor)
cname = ((TypeConstructor) t).getName();
else if (t instanceof TypeApplication)
cname = ((TypeConstructor) t.getConstructor()).getName();
else
System.err.println("Type of optype :" + val_peek(4).getClass() + "(" + val_peek(4) + ")");
PrimitiveConstructor cdef = new PrimitiveConstructor(cname, ddef, new Type[0], cls, module);
if (val_peek(1) != null) {
Iterator it = ((ExpressionList) val_peek(1)).iterator();
while (it.hasNext()) {
TypeExpression tex = (TypeExpression) it.next();
if (tex.isStrict())
cdef.addStrictParameter(tex.getType());
else
cdef.addParameter(tex.getType());
}
}
} catch (ClassNotFoundException cnfex) {
System.err.println("Error in native constructor definition : cannot find class " + ((StringLiteral) val_peek(1)).getString());
}
} else
System.err.println("Error in native constructor definition : cannot find data definition for " + tname);
}
break;
case 21:
{
String vname = ((Variable) val_peek(3)).getName();
Type t = val_peek(1).getType();
try {
Class cls = Class.forName(((StringLiteral) val_peek(0)).getString());
PrimitiveFunction pf = new PrimitiveFunction(vname, module, t, cls);
PrimitivesCodeGenerator.registerStaticPrimitive(pf);
} catch (ClassNotFoundException cnfex) {
System.err.println("Error in native function definition : cannot find class " + ((StringLiteral) val_peek(0)).getString());
}
}
break;
case 22:
{
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
}
break;
case 23:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(0));
yyval = el;
}
break;
case 24:
{
ConstructorDefinition cdef = new ConstructorDefinition(((Variable) val_peek(0)).getName(), null, module);
cdef.putTag(lex.makePosition());
yyval = cdef;
}
break;
case 25:
{
ConstructorDefinition cdef = new ConstructorDefinition(((Variable) val_peek(1)).getName(), null, module);
cdef.putTag(lex.makePosition());
if (val_peek(0) != null) {
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) {
TypeExpression tex = (TypeExpression) it.next();
if (tex.isStrict())
cdef.addStrictParameter(tex.getType());
else
cdef.addParameter(tex.getType());
}
}
yyval = cdef;
}
break;
case 26:
{
ConstructorDefinition cdef = new ConstructorDefinition(((Variable) val_peek(1)).getName(), null, module);
cdef.putTag(lex.makePosition());
TypeExpression tex = (TypeExpression) val_peek(2);
if (tex.isStrict())
cdef.addStrictParameter(tex.getType());
else
cdef.addParameter(tex.getType());
tex = (TypeExpression) val_peek(0);
if (tex.isStrict())
cdef.addStrictParameter(tex.getType());
else
cdef.addParameter(tex.getType());
yyval = cdef;
}
break;
case 27:
{
if (val_peek(1) != null) {
((ExpressionList) val_peek(1)).add(val_peek(0));
yyval = val_peek(1);
} else {
ExpressionList el = new ExpressionList();
el.add(val_peek(0));
yyval = el;
}
}
break;
case 28:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(0));
yyval = el;
}
break;
case 29:
{
((TypeExpression) val_peek(0)).setStrict(true);
yyval = val_peek(0);
}
break;
case 30:
{
yyval = val_peek(0);
}
break;
case 31:
{
yyval = val_peek(0);
}
break;
case 32:
{
((TypeExpression) val_peek(0)).setStrict(true);
yyval = val_peek(0);
}
break;
case 33:
{
Equation eq = new Equation();
eq.setLhs(val_peek(1));
eq.setRhs(val_peek(0));
yyval = eq;
}
break;
case 34:
{
Equation eq = new Equation();
eq.setLhs(val_peek(1));
eq.setRhs(val_peek(0));
yyval = eq;
}
break;
case 35:
{
yyerror("Syntax error");
yyval = null;
}
break;
case 36:
{
Iterator it = ((ExpressionList) val_peek(2)).iterator();
ExpressionList el = new ExpressionList();
while (it.hasNext()) {
Definition def = new Definition();
def.setName(((Variable) it.next()).getName());
if (val_peek(0) != null)
def.setType(val_peek(0).getType());
el.add(def);
}
yyval = el;
}
break;
case 37:
{
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
}
break;
case 38:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(0));
yyval = el;
}
break;
case 39:
{
yyval = val_peek(0);
}
break;
case 40:
{
yyval = new TypeExpression(Types.fun(val_peek(2).getType(), val_peek(0).getType()));
}
break;
case 41:
{
yyval = val_peek(0);
}
break;
case 42:
{
Type tcon = val_peek(1).getType().getConstructor();
if (!(tcon instanceof PrimitiveType))
tcon.setKind(null);
yyval = new TypeExpression(Types.apply(val_peek(1).getType(), val_peek(0).getType()));
}
break;
case 43:
{
yyval = val_peek(0);
}
break;
case 44:
{
yyval = val_peek(0);
}
break;
case 45:
{
yyval = val_peek(0);
}
break;
case 46:
{
int i = 1;
List l = new ArrayList();
l.add(val_peek(4).getType());
l.add(val_peek(2).getType());
Iterator it = ((ExpressionList) val_peek(1)).iterator();
while (it.hasNext()) {
l.add(it.next());
i++;
}
yyval = new TypeExpression(Types.apply(Types.tuple(i), l));
}
break;
case 47:
{
yyval = new TypeExpression(Types.apply(Primitives.LIST, val_peek(1).getType()));
}
break;
case 48:
{
yyval = val_peek(1);
}
break;
case 51:
{
yyval = new TypeExpression(Types.makeTycon(((Constructor) val_peek(0)).getName()));
}
break;
case 52:
{
yyval = new TypeExpression(Primitives.UNIT);
}
break;
case 53:
{
yyval = new TypeExpression(Primitives.LIST);
}
break;
case 54:
{
yyval = new TypeExpression(Primitives.FUNCTION);
}
break;
case 55:
{
yyval = new TypeExpression(Primitives.TUPLE_2);
}
break;
case 56:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(1));
if (val_peek(0) != null)
el.addAll((ExpressionList) val_peek(0));
yyval = el;
}
break;
case 57:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(1));
el.add(val_peek(2));
el.add(val_peek(0));
yyval = el;
}
break;
case 58:
{
yyval = val_peek(0);
}
break;
case 59:
{
yyval = val_peek(0);
}
break;
case 60:
{
Application app = new Application();
app.putTag(lex.makePosition());
app.setFunction(val_peek(1));
app.addArgument(val_peek(2));
app.addArgument(val_peek(0));
yyval = app;
}
break;
case 61:
{
yyval = val_peek(0);
}
break;
case 62:
{
yyval = val_peek(0);
}
break;
case 63:
{
Application app = new Application();
app.putTag(lex.makePosition());
QualifiedVariable qv = new QualifiedVariable("negate");
qv.putTag(lex.makePosition());
qv.addPathElement("Prelude");
app.setFunction(qv);
app.addArgument(val_peek(0));
yyval = app;
}
break;
case 64:
{
Application app = new Application();
app.putTag(lex.makePosition());
app.setFunction(val_peek(1));
app.addArgument(val_peek(2));
app.addArgument(val_peek(0));
yyval = app;
}
break;
case 65:
{
List l = null;
if (val_peek(2) != null) {
l = (ExpressionList) val_peek(2);
} else
l = new ArrayList();
l.add(0, val_peek(3));
List vars = new ArrayList();
Abstraction abs = new Abstraction();
abs.putTag(lex.makePosition());
for (int i = 0; i < l.size(); i++) {
LocalBinding lb = LocalBinding.freshBinding();
lb.putTag(lex.makePosition());
abs.bind(lb);
vars.add(lb);
}
List pm = new ArrayList();
PatternMatch pm1 = new PatternMatch();
pm1.patterns = l;
pm1.expr = val_peek(0);
pm.add(pm1);
abs.setBody(new Matcher().match(vars, pm, val_peek(0)));
yyval = abs;
}
break;
case 66:
{
Let let = new Let();
let.setBody(val_peek(0));
Map eqs = new HashMap();
Iterator it = ((ExpressionList) val_peek(2)).iterator();
while (it.hasNext()) {
Equation eq = (Equation) it.next();
ExpressionList lhs = (ExpressionList) eq.getLhs();
String fname = ((Variable) lhs.get(0)).getName();
List l = (List) eqs.get(fname);
if (l == null) {
l = new ArrayList();
eqs.put(fname, l);
}
l.add(eq);
}
Normalizer nz = new Normalizer(let);
try {
nz.normalize(eqs);
} catch (SymbolException ex) {
parseError("Cannot normalize equations :" + ex);
}
yyval = let;
}
break;
case 67:
{
Conditional cond = new Conditional();
cond.putTag(lex.makePosition());
cond.setCondition(val_peek(4));
cond.setIfTrue(val_peek(2));
cond.setIfFalse(val_peek(0));
yyval = cond;
}
break;
case 68:
{
Alternative alt = new Alternative();
alt.putTag(lex.makePosition());
alt.setExpression(val_peek(4));
Iterator it = ((ExpressionList) val_peek(1)).iterator();
while (it.hasNext()) {
PatternAlternative pa = (PatternAlternative) it.next();
alt.addPattern(pa.getPattern(), pa.getExpr());
}
yyval = alt;
}
break;
case 69:
{
yyval = val_peek(0);
}
break;
case 70:
{
if (val_peek(1) instanceof Application) {
((Application) val_peek(1)).addArgument(val_peek(0));
yyval = val_peek(1);
} else {
Application app = new Application();
app.putTag(lex.makePosition());
app.setFunction(val_peek(1));
app.addArgument(val_peek(0));
yyval = app;
}
}
break;
case 71:
{
yyval = val_peek(0);
}
break;
case 72:
{
yyval = val_peek(0);
}
break;
case 73:
{
yyval = val_peek(0);
}
break;
case 74:
{
yyval = val_peek(0);
}
break;
case 75:
{
yyval = val_peek(0);
}
break;
case 76:
{
yyval = val_peek(0);
}
break;
case 77:
{
yyval = val_peek(1);
}
break;
case 78:
{
Application app = new Application();
app.putTag(lex.makePosition());
StringBuffer tconsb = new StringBuffer("((,");
for (int i = 0; i < ((ExpressionList) val_peek(1)).size(); i++) tconsb.append(",");
tconsb.append("))");
QualifiedConstructor qv = new QualifiedConstructor(tconsb.toString());
qv.putTag(lex.makePosition());
qv.addPathElement("Prelude");
app.setFunction(qv);
app.addArgument(val_peek(3));
app.addArgument(val_peek(2));
for (Iterator it = ((ExpressionList) val_peek(1)).iterator(); it.hasNext(); ) app.addArgument((Expression) it.next());
yyval = app;
}
break;
case 79:
{
Application app = new Application();
app.putTag(lex.makePosition());
Application cur = app;
QualifiedConstructor qv = new QualifiedConstructor("(:)");
qv.putTag(lex.makePosition());
qv.addPathElement("Prelude");
app.setFunction(qv);
app.addArgument(val_peek(2));
for (Iterator it = ((ExpressionList) val_peek(1)).iterator(); it.hasNext(); ) {
Application tmp = new Application();
tmp.putTag(lex.makePosition());
tmp.setFunction(qv);
tmp.addArgument((Expression) it.next());
cur.addArgument(tmp);
cur = tmp;
}
qv = new QualifiedConstructor("([])");
qv.putTag(lex.makePosition());
qv.addPathElement("Prelude");
cur.addArgument(qv);
yyval = app;
}
break;
case 84:
{
Application app = new Application();
app.putTag(lex.makePosition());
app.setFunction(val_peek(1));
app.addArgument(val_peek(2));
yyval = app;
}
break;
case 85:
{
Application app = new Application();
app.putTag(lex.makePosition());
app.setFunction(val_peek(2));
app.addArgument(val_peek(1));
yyval = app;
}
break;
case 86:
{
((ExpressionList) val_peek(1)).add(val_peek(0));
yyval = val_peek(1);
}
break;
case 87:
{
yyval = new ExpressionList();
}
break;
case 88:
{
yyval = val_peek(0);
}
break;
case 89:
{
if (val_peek(2) instanceof ExpressionList) {
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
} else {
ExpressionList decls = new ExpressionList();
decls.add(val_peek(2));
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 90:
{
yyval = val_peek(0);
}
break;
case 91:
{
yyval = new PatternAlternative((Pattern) val_peek(2), val_peek(0));
}
break;
case 92:
{
if (val_peek(1) instanceof ExpressionList) {
((ExpressionList) val_peek(1)).add(val_peek(0));
yyval = val_peek(1);
} else if (val_peek(1) == null) {
ExpressionList decls = new ExpressionList();
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 93:
{
yyval = null;
}
break;
case 94:
{
yyval = val_peek(0);
}
break;
case 95:
{
ConstructorPattern pat = new ConstructorPattern();
pat.putTag(lex.makePosition());
pat.setConstructor((Constructor) val_peek(1));
pat.addPattern((Pattern) val_peek(2));
System.err.println("Type of rh arg : " + val_peek(0).getClass());
pat.addPattern((Pattern) val_peek(0));
yyval = pat;
}
break;
case 96:
{
yyval = val_peek(0);
}
break;
case 97:
{
yyval = val_peek(0);
}
break;
case 98:
{
if (val_peek(1) instanceof ExpressionList) {
((ExpressionList) val_peek(1)).add(val_peek(0));
yyval = val_peek(1);
} else if (val_peek(1) == null) {
ExpressionList decls = new ExpressionList();
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 99:
{
yyval = null;
}
break;
case 100:
{
LocalBinding bind = new LocalBinding(((Variable) val_peek(0)).getName());
bind.putTag(lex.makePosition());
yyval = bind;
}
break;
case 101:
{
ConstructorPattern pat = new ConstructorPattern();
pat.putTag(lex.makePosition());
pat.setConstructor((Constructor) val_peek(0));
yyval = pat;
}
break;
case 102:
{
ConstructorPattern pat = new ConstructorPattern();
pat.putTag(lex.makePosition());
pat.setConstructor((Constructor) val_peek(1));
if (val_peek(0) != null) {
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) pat.addPattern((Pattern) it.next());
}
yyval = pat;
}
break;
case 103:
{
yyval = val_peek(0);
}
break;
case 104:
{
yyval = LocalBinding.wildcard;
}
break;
case 105:
{
yyval = val_peek(1);
}
break;
case 106:
{
ConstructorPattern pat = new ConstructorPattern();
pat.putTag(lex.makePosition());
StringBuffer tconsb = new StringBuffer("((,");
for (int i = 0; i < ((ExpressionList) val_peek(1)).size(); i++) tconsb.append(",");
tconsb.append("))");
QualifiedConstructor qv = new QualifiedConstructor(tconsb.toString());
qv.putTag(lex.makePosition());
qv.addPathElement("Prelude");
pat.setConstructor(qv);
pat.addPattern((Pattern) val_peek(3));
pat.addPattern((Pattern) val_peek(2));
for (Iterator it = ((ExpressionList) val_peek(1)).iterator(); it.hasNext(); ) pat.addPattern((Pattern) it.next());
yyval = pat;
}
break;
case 107:
{
List l = new ArrayList();
l.add(val_peek(2));
l.addAll((ExpressionList) val_peek(1));
ConstructorPattern app = makeListPattern(l);
yyval = app;
}
break;
case 108:
{
yyval = val_peek(0);
}
break;
case 109:
{
if (val_peek(2) instanceof ExpressionList) {
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
} else if (val_peek(2) == null) {
ExpressionList decls = new ExpressionList();
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 110:
{
yyval = null;
}
break;
case 111:
{
yyval = val_peek(0);
}
break;
case 112:
{
ConstructorPattern cp = new ConstructorPattern();
QualifiedConstructor qv = new QualifiedConstructor("Event");
qv.addPathElement("Prelude");
cp.setConstructor(qv);
cp.addPattern(LocalBinding.wildcard);
ConstructorPattern cp2 = (ConstructorPattern) val_peek(1);
cp.putTag(lex.makePosition());
if (val_peek(0) != null) {
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) cp2.addPattern((Pattern) it.next());
}
cp.addPattern(cp2);
yyval = cp;
}
break;
case 113:
{
ConstructorPattern cp = new ConstructorPattern();
QualifiedConstructor qv = new QualifiedConstructor("Event");
qv.addPathElement("Prelude");
cp.setConstructor(qv);
cp.addPattern((Pattern) val_peek(2));
cp.putTag(lex.makePosition());
ConstructorPattern cp2 = (ConstructorPattern) val_peek(1);
QualifiedConstructor qc = new QualifiedConstructor(cp2.getConstructor().getName());
qc.addPathElement((String) ((Literal) val_peek(2)).unpack());
cp2.setConstructor(qc);
if (val_peek(1) != null) {
Iterator it = ((ExpressionList) val_peek(0)).iterator();
while (it.hasNext()) cp2.addPattern((Pattern) it.next());
}
cp.addPattern(cp2);
yyval = cp;
}
break;
case 114:
{
yyval = null;
}
break;
case 115:
{
yyval = val_peek(1);
}
break;
case 116:
{
yyval = val_peek(1);
}
break;
case 117:
{
ConstructorPattern pat = new ConstructorPattern();
Constructor ctor = new Constructor("Return$" + ((StringLiteral) val_peek(0)).getString());
pat.setConstructor(ctor);
pat.putTag(lex.makePosition());
ctor.putTag(lex.makePosition());
yyval = pat;
}
break;
case 118:
{
ConstructorPattern pat = new ConstructorPattern();
Constructor ctor = new Constructor("Call$" + ((StringLiteral) val_peek(0)).getString());
pat.setConstructor(ctor);
pat.putTag(lex.makePosition());
ctor.putTag(lex.makePosition());
yyval = pat;
}
break;
case 119:
{
ConstructorPattern pat = new ConstructorPattern();
Constructor ctor = new Constructor("Full$" + ((StringLiteral) val_peek(0)).getString());
pat.setConstructor(ctor);
pat.putTag(lex.makePosition());
ctor.putTag(lex.makePosition());
yyval = pat;
}
break;
case 120:
{
yyval = new StringLiteral(((Variable) val_peek(0)).getName());
}
break;
case 121:
{
yyval = LocalBinding.wildcard;
}
break;
case 122:
{
yyval = new StringLiteral(((Variable) val_peek(0)).getName());
}
break;
case 123:
{
yyval = LocalBinding.wildcard;
}
break;
case 124:
{
yyval = new StringLiteral(((Variable) val_peek(0)).getName());
}
break;
case 125:
{
yyval = LocalBinding.wildcard;
}
break;
case 126:
{
yyval = val_peek(0);
}
break;
case 127:
{
ExpressionList el = new ExpressionList();
el.add(val_peek(0));
yyval = el;
}
break;
case 128:
{
((ExpressionList) val_peek(1)).add(val_peek(0));
yyval = val_peek(1);
}
break;
case 129:
{
ExpressionList el = new ExpressionList();
yyval = el;
}
break;
case 130:
{
if (val_peek(2) instanceof ExpressionList) {
((ExpressionList) val_peek(2)).add(val_peek(0));
yyval = val_peek(2);
} else if (val_peek(2) == null) {
ExpressionList decls = new ExpressionList();
decls.add(val_peek(0));
yyval = decls;
}
;
}
break;
case 131:
{
ExpressionList decls = new ExpressionList();
decls.add(val_peek(0));
yyval = decls;
}
break;
case 132:
{
yyval = val_peek(0);
}
break;
case 133:
{
yyval = val_peek(0);
}
break;
case 134:
{
yyval = null;
}
break;
case 135:
{
yyval = null;
}
break;
case 136:
{
Constructor ctor = new Constructor("(())");
ctor.putTag(lex.makePosition());
yyval = ctor;
}
break;
case 137:
{
Constructor ctor = new Constructor("([])");
ctor.putTag(lex.makePosition());
yyval = ctor;
}
break;
case 138:
{
yyval = val_peek(0);
}
break;
case 139:
{
yyval = val_peek(0);
}
break;
case 140:
{
yyval = val_peek(0);
}
break;
case 141:
{
yyval = val_peek(0);
}
break;
case 142:
{
yyval = val_peek(1);
}
break;
case 143:
{
yyval = val_peek(0);
}
break;
case 144:
{
yyval = val_peek(1);
}
break;
case 145:
{
yyval = val_peek(0);
}
break;
case 146:
{
yyval = val_peek(0);
}
break;
case 147:
{
yyval = val_peek(1);
}
break;
case 148:
{
yyval = val_peek(0);
}
break;
case 149:
{
yyval = val_peek(1);
}
break;
case 150:
{
yyval = val_peek(0);
}
break;
case 151:
{
yyval = val_peek(1);
}
break;
case 152:
{
yyval = val_peek(0);
}
break;
case 153:
{
yyval = val_peek(1);
}
break;
case 154:
{
yyval = val_peek(0);
}
break;
case 155:
{
yyval = val_peek(0);
}
break;
case 156:
{
yyval = val_peek(0);
}
break;
case 157:
{
yyval = val_peek(0);
}
break;
case 158:
{
Variable var = new Variable("(-)");
var.putTag(lex.makePosition());
yyval = var;
}
break;
case 159:
{
Constructor ctor = new Constructor("(:)");
ctor.putTag(lex.makePosition());
yyval = ctor;
}
break;
case 160:
{
yyval = val_peek(0);
}
break;
case 161:
{
yyval = val_peek(0);
}
break;
case 162:
{
yyval = val_peek(1);
}
break;
case 163:
{
yyval = val_peek(0);
}
break;
case 164:
{
yyval = new TypeExpression(TypeFactory.makeTypeVariable(((Variable) val_peek(0)).getName()));
}
break;
case 165:
{
yyval = val_peek(0);
}
break;
case 166:
{
yyval = val_peek(0);
}
break;
case 167:
{
yyval = val_peek(0);
}
break;
case 168:
{
yyval = val_peek(0);
}
break;
case 169:
{
yyval = val_peek(0);
}
break;
}
if (yydebug)
debug("reduce");
state_drop(yym);
yystate = state_peek(0);
val_drop(yym);
yym = yylhs[yyn];
if ((yystate == 0) && (yym == 0)) {
debug("After reduction, shifting from state 0 to state " + YYFINAL + "");
yystate = YYFINAL;
state_push(YYFINAL);
val_push(yyval);
if (yychar < 0) {
yychar = yylex();
if (yychar < 0)
yychar = 0;
if (yydebug)
yylexdebug(yystate, yychar);
}
if (yychar == 0)
break;
} else {
yyn = yygindex[yym];
if ((yyn != 0) && ((yyn += yystate) >= 0) && (yyn <= YYTABLESIZE) && (yycheck[yyn] == yystate))
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
debug("after reduction, shifting from state " + state_peek(0) + " to state " + yystate + "");
state_push(yystate);
val_push(yyval);
}
}
return 0;
</DeepExtract>
} | jaskell | positive | 2,397 |
@Override
public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws NotFoundException, ChecksumException, FormatException {
int width = image.getWidth();
int height = image.getHeight();
int halfWidth = width / 2;
int halfHeight = height / 2;
try {
return delegate.decode(image.crop(0, 0, halfWidth, halfHeight), hints);
} catch (NotFoundException re) {
}
try {
Result result = delegate.decode(image.crop(halfWidth, 0, halfWidth, halfHeight), hints);
makeAbsolute(result.getResultPoints(), halfWidth, 0);
return result;
} catch (NotFoundException re) {
}
try {
Result result = delegate.decode(image.crop(0, halfHeight, halfWidth, halfHeight), hints);
makeAbsolute(result.getResultPoints(), 0, halfHeight);
return result;
} catch (NotFoundException re) {
}
try {
Result result = delegate.decode(image.crop(halfWidth, halfHeight, halfWidth, halfHeight), hints);
makeAbsolute(result.getResultPoints(), halfWidth, halfHeight);
return result;
} catch (NotFoundException re) {
}
int quarterWidth = halfWidth / 2;
int quarterHeight = halfHeight / 2;
BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
Result result = delegate.decode(center, hints);
if (result.getResultPoints() != null) {
for (int i = 0; i < result.getResultPoints().length; i++) {
ResultPoint relative = result.getResultPoints()[i];
result.getResultPoints()[i] = new ResultPoint(relative.getX() + quarterWidth, relative.getY() + quarterHeight);
}
}
return result;
} | @Override
public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws NotFoundException, ChecksumException, FormatException {
int width = image.getWidth();
int height = image.getHeight();
int halfWidth = width / 2;
int halfHeight = height / 2;
try {
return delegate.decode(image.crop(0, 0, halfWidth, halfHeight), hints);
} catch (NotFoundException re) {
}
try {
Result result = delegate.decode(image.crop(halfWidth, 0, halfWidth, halfHeight), hints);
makeAbsolute(result.getResultPoints(), halfWidth, 0);
return result;
} catch (NotFoundException re) {
}
try {
Result result = delegate.decode(image.crop(0, halfHeight, halfWidth, halfHeight), hints);
makeAbsolute(result.getResultPoints(), 0, halfHeight);
return result;
} catch (NotFoundException re) {
}
try {
Result result = delegate.decode(image.crop(halfWidth, halfHeight, halfWidth, halfHeight), hints);
makeAbsolute(result.getResultPoints(), halfWidth, halfHeight);
return result;
} catch (NotFoundException re) {
}
int quarterWidth = halfWidth / 2;
int quarterHeight = halfHeight / 2;
BinaryBitmap center = image.crop(quarterWidth, quarterHeight, halfWidth, halfHeight);
Result result = delegate.decode(center, hints);
<DeepExtract>
if (result.getResultPoints() != null) {
for (int i = 0; i < result.getResultPoints().length; i++) {
ResultPoint relative = result.getResultPoints()[i];
result.getResultPoints()[i] = new ResultPoint(relative.getX() + quarterWidth, relative.getY() + quarterHeight);
}
}
</DeepExtract>
return result;
} | ScreenCapture | positive | 2,398 |
public void dismountSelf() {
this.dataManager.set(VICTIM_UNIQUE_ID, Optional.fromNullable(null));
this.getDataManager().set(ATTACK_DELAY, Integer.valueOf(20));
this.dismountRidingEntity();
} | public void dismountSelf() {
this.dataManager.set(VICTIM_UNIQUE_ID, Optional.fromNullable(null));
<DeepExtract>
this.getDataManager().set(ATTACK_DELAY, Integer.valueOf(20));
</DeepExtract>
this.dismountRidingEntity();
} | PrimitiveMobs | positive | 2,399 |
public void writeFileContent(WPBFile wbFile, OutputStream os) throws WPBException {
InputStream is;
WPBFilePath cloudFile = new WPBFilePath("public", wbFile.getBlobKey());
try {
is = cloudFileStorage.getFileContent(cloudFile);
} catch (IOException e) {
throw new WPBException("cannot get file content ", e);
}
try {
IOUtils.copy(is, os);
} catch (IOException e) {
throw new WPBIOException(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(is);
}
} | public void writeFileContent(WPBFile wbFile, OutputStream os) throws WPBException {
<DeepExtract>
InputStream is;
WPBFilePath cloudFile = new WPBFilePath("public", wbFile.getBlobKey());
try {
is = cloudFileStorage.getFileContent(cloudFile);
} catch (IOException e) {
throw new WPBException("cannot get file content ", e);
}
</DeepExtract>
try {
IOUtils.copy(is, os);
} catch (IOException e) {
throw new WPBIOException(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(is);
}
} | cms | positive | 2,400 |
@Override
public Publisher<News> createPublisher(long elements) {
if (elements <= 0) {
return;
}
Flowable<Success> successFlowable = Flowable.fromPublisher(collection.drop()).ignoreElements().andThen(Flowable.rangeLong(0L, elements).map(l -> NewsHarness.generate()).buffer(500, TimeUnit.MILLISECONDS).flatMap(collection::insertMany));
if (elements == Long.MAX_VALUE || elements == Integer.MAX_VALUE) {
successFlowable.subscribe();
} else {
successFlowable.blockingSubscribe();
}
return new DBPublisher(collection, "tech");
} | @Override
public Publisher<News> createPublisher(long elements) {
<DeepExtract>
if (elements <= 0) {
return;
}
Flowable<Success> successFlowable = Flowable.fromPublisher(collection.drop()).ignoreElements().andThen(Flowable.rangeLong(0L, elements).map(l -> NewsHarness.generate()).buffer(500, TimeUnit.MILLISECONDS).flatMap(collection::insertMany));
if (elements == Long.MAX_VALUE || elements == Integer.MAX_VALUE) {
successFlowable.subscribe();
} else {
successFlowable.blockingSubscribe();
}
</DeepExtract>
return new DBPublisher(collection, "tech");
} | Hands-On-Reactive-Programming-in-Spring-5 | positive | 2,401 |
public ResponseStatus removeMovieFromList(SessionToken sessionToken, String listId, Integer movieId) {
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId, "remove_item");
apiUrl.addParam(TmdbAccount.PARAM_SESSION, sessionToken);
String jsonBody = Utils.convertToJson(jsonMapper, Collections.singletonMap("media_id", movieId + ""));
return mapJsonResult(apiUrl, ResponseStatus.class, jsonBody);
} | public ResponseStatus removeMovieFromList(SessionToken sessionToken, String listId, Integer movieId) {
<DeepExtract>
ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_LIST, listId, "remove_item");
apiUrl.addParam(TmdbAccount.PARAM_SESSION, sessionToken);
String jsonBody = Utils.convertToJson(jsonMapper, Collections.singletonMap("media_id", movieId + ""));
return mapJsonResult(apiUrl, ResponseStatus.class, jsonBody);
</DeepExtract>
} | themoviedbapi | positive | 2,402 |
@Test
public void fileReadByteTest() throws IOException {
File tmpFile;
File tmpFile = null;
try {
tmpFile = File.createTempFile("RandomAccessObjectTest", "temp");
tmpFile.deleteOnExit();
FileOutputStream out = new FileOutputStream(tmpFile);
byte[] buffer = new byte[32768];
int numRead = 0;
while ((numRead = new ByteArrayInputStream(BLOB).read(buffer)) >= 0) {
out.write(buffer, 0, numRead);
}
out.flush();
out.close();
tmpFile = tmpFile;
} catch (IOException e) {
if (tmpFile != null) {
tmpFile.delete();
}
throw e;
}
try (RandomAccessObject obj = new RandomAccessObject.RandomAccessFileObject(tmpFile, "r")) {
for (int x = 0; x < BLOB.length; x++) {
Assert.assertEquals(x + 1, obj.readByte());
}
try {
obj.readByte();
Assert.fail("Should've thrown an IOException");
} catch (IOException expected) {
}
} finally {
tmpFile.delete();
}
} | @Test
public void fileReadByteTest() throws IOException {
<DeepExtract>
File tmpFile;
File tmpFile = null;
try {
tmpFile = File.createTempFile("RandomAccessObjectTest", "temp");
tmpFile.deleteOnExit();
FileOutputStream out = new FileOutputStream(tmpFile);
byte[] buffer = new byte[32768];
int numRead = 0;
while ((numRead = new ByteArrayInputStream(BLOB).read(buffer)) >= 0) {
out.write(buffer, 0, numRead);
}
out.flush();
out.close();
tmpFile = tmpFile;
} catch (IOException e) {
if (tmpFile != null) {
tmpFile.delete();
}
throw e;
}
</DeepExtract>
try (RandomAccessObject obj = new RandomAccessObject.RandomAccessFileObject(tmpFile, "r")) {
for (int x = 0; x < BLOB.length; x++) {
Assert.assertEquals(x + 1, obj.readByte());
}
try {
obj.readByte();
Assert.fail("Should've thrown an IOException");
} catch (IOException expected) {
}
} finally {
tmpFile.delete();
}
} | archive-patcher | positive | 2,403 |
@Override
public void onServicesDiscovered(Gatt gatt, int status) {
Log.d("Discovered services, enable notification");
mQueue.clear();
diggServices();
mService.setCharacteristicNotification(mFFF4, true);
GattTransaction t = new GattTransaction(mCCC, mCCC.getConstantBytes(GattDescriptor.ENABLE_NOTIFICATION_VALUE));
mQueue.add(t);
enableAirPatch();
} | @Override
public void onServicesDiscovered(Gatt gatt, int status) {
<DeepExtract>
Log.d("Discovered services, enable notification");
mQueue.clear();
diggServices();
mService.setCharacteristicNotification(mFFF4, true);
GattTransaction t = new GattTransaction(mCCC, mCCC.getConstantBytes(GattDescriptor.ENABLE_NOTIFICATION_VALUE));
mQueue.add(t);
enableAirPatch();
</DeepExtract>
} | Bluebit | positive | 2,404 |
private void drawTopLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
float right = mRadius - mMargin;
float bottom = paint - mMargin;
switch(mCornerType) {
case ALL:
new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter).drawRoundRect(new RectF(mMargin, mMargin, right, bottom), mRadius, mRadius, mRadius);
break;
case TOP_LEFT:
drawTopLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case TOP_RIGHT:
drawTopRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case BOTTOM_LEFT:
drawBottomLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case BOTTOM_RIGHT:
drawBottomRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case TOP:
drawTopRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case BOTTOM:
drawBottomRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case LEFT:
drawLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case RIGHT:
drawRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case OTHER_TOP_LEFT:
drawOtherTopLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case OTHER_TOP_RIGHT:
drawOtherTopRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case OTHER_BOTTOM_LEFT:
drawOtherBottomLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case OTHER_BOTTOM_RIGHT:
drawOtherBottomRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case DIAGONAL_FROM_TOP_LEFT:
drawDiagonalFromTopLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case DIAGONAL_FROM_TOP_RIGHT:
drawDiagonalFromTopRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
default:
new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter).drawRoundRect(new RectF(mMargin, mMargin, right, bottom), mRadius, mRadius, mRadius);
break;
}
canvas.drawRect(new RectF(mMargin, mMargin + mRadius, mMargin + mRadius, bottom), paint);
canvas.drawRect(new RectF(mMargin + mRadius, mMargin, right, bottom), paint);
} | private void drawTopLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
<DeepExtract>
float right = mRadius - mMargin;
float bottom = paint - mMargin;
switch(mCornerType) {
case ALL:
new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter).drawRoundRect(new RectF(mMargin, mMargin, right, bottom), mRadius, mRadius, mRadius);
break;
case TOP_LEFT:
drawTopLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case TOP_RIGHT:
drawTopRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case BOTTOM_LEFT:
drawBottomLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case BOTTOM_RIGHT:
drawBottomRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case TOP:
drawTopRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case BOTTOM:
drawBottomRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case LEFT:
drawLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case RIGHT:
drawRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case OTHER_TOP_LEFT:
drawOtherTopLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case OTHER_TOP_RIGHT:
drawOtherTopRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case OTHER_BOTTOM_LEFT:
drawOtherBottomLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case OTHER_BOTTOM_RIGHT:
drawOtherBottomRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case DIAGONAL_FROM_TOP_LEFT:
drawDiagonalFromTopLeftRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
case DIAGONAL_FROM_TOP_RIGHT:
drawDiagonalFromTopRightRoundRect(new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter), mRadius, right, bottom);
break;
default:
new RectF(mMargin, mMargin, mMargin + mDiameter, mMargin + mDiameter).drawRoundRect(new RectF(mMargin, mMargin, right, bottom), mRadius, mRadius, mRadius);
break;
}
</DeepExtract>
canvas.drawRect(new RectF(mMargin, mMargin + mRadius, mMargin + mRadius, bottom), paint);
canvas.drawRect(new RectF(mMargin + mRadius, mMargin, right, bottom), paint);
} | SteamGifts | positive | 2,405 |
@Test
public void testGetListObject() {
List<User> list = testService.getListObject(236);
Assert.assertNotNull(list);
list = testService.getListObject(236);
Assert.assertEquals(list.size(), 3);
try {
Thread.sleep(5 * 1000);
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
}
list = testService.getListObject(236);
Assert.assertEquals(list.size(), 3);
} | @Test
public void testGetListObject() {
List<User> list = testService.getListObject(236);
Assert.assertNotNull(list);
list = testService.getListObject(236);
Assert.assertEquals(list.size(), 3);
<DeepExtract>
try {
Thread.sleep(5 * 1000);
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
}
</DeepExtract>
list = testService.getListObject(236);
Assert.assertEquals(list.size(), 3);
} | layering-cache | positive | 2,408 |
public long skip(long n) throws IOException {
byte[] buffer = buf;
if (buffer == null)
throw new IOException("Stream closed");
return buffer;
if (n <= 0) {
return 0;
}
long avail = count - pos;
if (avail <= 0) {
if (markpos < 0)
return getInIfOpen().skip(n);
fill();
avail = count - pos;
if (avail <= 0)
return 0;
}
long skipped = (avail < n) ? avail : n;
pos += skipped;
return skipped;
} | public long skip(long n) throws IOException {
<DeepExtract>
byte[] buffer = buf;
if (buffer == null)
throw new IOException("Stream closed");
return buffer;
</DeepExtract>
if (n <= 0) {
return 0;
}
long avail = count - pos;
if (avail <= 0) {
if (markpos < 0)
return getInIfOpen().skip(n);
fill();
avail = count - pos;
if (avail <= 0)
return 0;
}
long skipped = (avail < n) ? avail : n;
pos += skipped;
return skipped;
} | btree4j | positive | 2,409 |
@Override
public InputStream getInputStream() throws IOException {
delegate().connect();
switch(state) {
case HANDSHAKE_SENT:
input = new TcpInputStream(socket);
@SuppressWarnings("resource")
LineReader reader = new LineReader(input);
String start = reader.readLine();
connection.addHeaderField(null, start);
if ((start == null) || start.isEmpty()) {
throw new IllegalStateException("Bad HTTP/1.1 syntax");
}
Matcher startMatcher = PATTERN_START.matcher(start);
if (!startMatcher.matches()) {
throw new IllegalStateException("Bad HTTP/1.1 syntax");
}
int responseCode = parseInt(startMatcher.group(1));
String responseMessage = startMatcher.group(2);
connection.setResponse(responseCode, responseMessage);
Map<String, List<String>> cookies = null;
List<String> challenges = null;
for (String header = reader.readLine(); !header.isEmpty() && header != null; header = reader.readLine()) {
int colonAt = header.indexOf(':');
if (colonAt == -1) {
throw new IllegalStateException("Bad HTTP/1.1 syntax");
}
String name = header.substring(0, colonAt).trim();
String value = header.substring(colonAt + 1).trim();
if ("Set-Cookie".equalsIgnoreCase(name) || "Set-Cookie2".equalsIgnoreCase(name)) {
if (cookies == null) {
cookies = new LinkedHashMap<String, List<String>>();
}
List<String> values = cookies.get(name);
if (values == null) {
values = new LinkedList<String>();
cookies.put(name, values);
}
values.add(value);
} else if ("WWW-Authenticate".equalsIgnoreCase(name)) {
if (challenges == null) {
challenges = new LinkedList<String>();
}
challenges.add(value);
} else {
connection.addHeaderField(name, value);
}
}
if (cookies != null && !cookies.isEmpty()) {
CookieHandler handler = CookieHandler.getDefault();
if (handler != null) {
connection.storeCookies(handler);
}
}
state = State.HANDSHAKE_RECEIVED;
switch(responseCode) {
case HTTP_SWITCHING_PROTOCOLS:
case HTTP_MOVED_PERM:
case HTTP_MOVED_TEMP:
case HTTP_SEE_OTHER:
break;
case HTTP_UNAUTHORIZED:
processChallenges(challenges);
break;
default:
throw new IllegalStateException(format("Upgrade failed (%d)", responseCode));
}
return input;
case HANDSHAKE_RECEIVED:
return input;
default:
throw new IllegalStateException(format("Unexpeced state: %s", state));
}
} | @Override
public InputStream getInputStream() throws IOException {
<DeepExtract>
delegate().connect();
</DeepExtract>
switch(state) {
case HANDSHAKE_SENT:
input = new TcpInputStream(socket);
@SuppressWarnings("resource")
LineReader reader = new LineReader(input);
String start = reader.readLine();
connection.addHeaderField(null, start);
if ((start == null) || start.isEmpty()) {
throw new IllegalStateException("Bad HTTP/1.1 syntax");
}
Matcher startMatcher = PATTERN_START.matcher(start);
if (!startMatcher.matches()) {
throw new IllegalStateException("Bad HTTP/1.1 syntax");
}
int responseCode = parseInt(startMatcher.group(1));
String responseMessage = startMatcher.group(2);
connection.setResponse(responseCode, responseMessage);
Map<String, List<String>> cookies = null;
List<String> challenges = null;
for (String header = reader.readLine(); !header.isEmpty() && header != null; header = reader.readLine()) {
int colonAt = header.indexOf(':');
if (colonAt == -1) {
throw new IllegalStateException("Bad HTTP/1.1 syntax");
}
String name = header.substring(0, colonAt).trim();
String value = header.substring(colonAt + 1).trim();
if ("Set-Cookie".equalsIgnoreCase(name) || "Set-Cookie2".equalsIgnoreCase(name)) {
if (cookies == null) {
cookies = new LinkedHashMap<String, List<String>>();
}
List<String> values = cookies.get(name);
if (values == null) {
values = new LinkedList<String>();
cookies.put(name, values);
}
values.add(value);
} else if ("WWW-Authenticate".equalsIgnoreCase(name)) {
if (challenges == null) {
challenges = new LinkedList<String>();
}
challenges.add(value);
} else {
connection.addHeaderField(name, value);
}
}
if (cookies != null && !cookies.isEmpty()) {
CookieHandler handler = CookieHandler.getDefault();
if (handler != null) {
connection.storeCookies(handler);
}
}
state = State.HANDSHAKE_RECEIVED;
switch(responseCode) {
case HTTP_SWITCHING_PROTOCOLS:
case HTTP_MOVED_PERM:
case HTTP_MOVED_TEMP:
case HTTP_SEE_OTHER:
break;
case HTTP_UNAUTHORIZED:
processChallenges(challenges);
break;
default:
throw new IllegalStateException(format("Upgrade failed (%d)", responseCode));
}
return input;
case HANDSHAKE_RECEIVED:
return input;
default:
throw new IllegalStateException(format("Unexpeced state: %s", state));
}
} | netx | positive | 2,410 |
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mDragController.setWindowToken(getWindowToken());
} | protected void onAttachedToWindow() {
<DeepExtract>
</DeepExtract>
super.onAttachedToWindow();
<DeepExtract>
</DeepExtract>
mDragController.setWindowToken(getWindowToken());
<DeepExtract>
</DeepExtract>
} | Open-Launcher-for-GTV | positive | 2,411 |
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
ServerJob serverJob = (ServerJob) ClassUtil.BytesToObject(Base64.decodeBase64((String) context.getJobDetail().getJobDataMap().get(CommonConstants.SERVER_JOB_INFO)));
serverJob.getJobDetail().getJobDataMap().put(CommonConstants.SERVER_JOB_INFO, context.getJobDetail().getJobDataMap().get(CommonConstants.SERVER_JOB_INFO));
serverJob.getJobDetail().getJobDataMap().put(CommonConstants.CLIENT_JOB_INFO, context.getJobDetail().getJobDataMap().get(CommonConstants.CLIENT_JOB_INFO));
String[] fixedServerIps = serverJob.getFixedServerIps();
if (fixedServerIps != null && fixedServerIps.length > 0) {
return isContainLocalIp(fixedServerIps) && handlerJobType(serverJob);
} else {
return handlerJobType(serverJob);
}
String jobKey = context.getJobDetail().getKey().toString();
if (context.getNextFireTime() != null) {
if (MongoDBUtil.isEnabledDB()) {
BasicDBObject document = getUpdateRemoteJobBasicDBObject(serverJob, jobKey);
MongoDBUtil.INSTANCE.update(document, DBTableInfo.TBL_CLOVER_JOB);
}
return;
}
BasicDBObject deleteCondition = new BasicDBObject();
deleteCondition.put(DBTableInfo.COL_JOB_KEY, jobKey);
deleteCondition.put(DBTableInfo.COL_JOB_TYPE, CommonConstants.JOB_TYPE_REMOTE);
MongoDBUtil.INSTANCE.delete(deleteCondition, DBTableInfo.TBL_CLOVER_JOB);
logger.info("ServerJob-->>deleteJobFromDB(" + jobKey + ") remove job [{}] from DB", jobKey);
} | @Override
public void execute(JobExecutionContext context) throws JobExecutionException {
ServerJob serverJob = (ServerJob) ClassUtil.BytesToObject(Base64.decodeBase64((String) context.getJobDetail().getJobDataMap().get(CommonConstants.SERVER_JOB_INFO)));
serverJob.getJobDetail().getJobDataMap().put(CommonConstants.SERVER_JOB_INFO, context.getJobDetail().getJobDataMap().get(CommonConstants.SERVER_JOB_INFO));
serverJob.getJobDetail().getJobDataMap().put(CommonConstants.CLIENT_JOB_INFO, context.getJobDetail().getJobDataMap().get(CommonConstants.CLIENT_JOB_INFO));
String[] fixedServerIps = serverJob.getFixedServerIps();
if (fixedServerIps != null && fixedServerIps.length > 0) {
return isContainLocalIp(fixedServerIps) && handlerJobType(serverJob);
} else {
return handlerJobType(serverJob);
}
<DeepExtract>
String jobKey = context.getJobDetail().getKey().toString();
if (context.getNextFireTime() != null) {
if (MongoDBUtil.isEnabledDB()) {
BasicDBObject document = getUpdateRemoteJobBasicDBObject(serverJob, jobKey);
MongoDBUtil.INSTANCE.update(document, DBTableInfo.TBL_CLOVER_JOB);
}
return;
}
BasicDBObject deleteCondition = new BasicDBObject();
deleteCondition.put(DBTableInfo.COL_JOB_KEY, jobKey);
deleteCondition.put(DBTableInfo.COL_JOB_TYPE, CommonConstants.JOB_TYPE_REMOTE);
MongoDBUtil.INSTANCE.delete(deleteCondition, DBTableInfo.TBL_CLOVER_JOB);
logger.info("ServerJob-->>deleteJobFromDB(" + jobKey + ") remove job [{}] from DB", jobKey);
</DeepExtract>
} | clover | positive | 2,412 |
@Test
public void findMinMax1() throws Exception {
expected = new MinMax(1, 5);
list = Arrays.asList(3, 2, 5, 1, 2, 4);
assertEquals(expected, FindMinAndMax.findMinMax(list));
} | @Test
public void findMinMax1() throws Exception {
expected = new MinMax(1, 5);
list = Arrays.asList(3, 2, 5, 1, 2, 4);
<DeepExtract>
assertEquals(expected, FindMinAndMax.findMinMax(list));
</DeepExtract>
} | Elements-of-programming-interviews | positive | 2,413 |
public Criteria andPasswordEqualTo(String value) {
if (value == null) {
throw new RuntimeException("Value for " + "password" + " cannot be null");
}
criteria.add(new Criterion("password =", value));
return (Criteria) this;
} | public Criteria andPasswordEqualTo(String value) {
<DeepExtract>
if (value == null) {
throw new RuntimeException("Value for " + "password" + " cannot be null");
}
criteria.add(new Criterion("password =", value));
</DeepExtract>
return (Criteria) this;
} | garbage-collection | positive | 2,414 |
@Override
public Sampler<T> copy() {
AverageRandomAccess ra = new AverageRandomAccess(numD);
ra.setPosition(this);
return ra;
} | @Override
public Sampler<T> copy() {
<DeepExtract>
AverageRandomAccess ra = new AverageRandomAccess(numD);
ra.setPosition(this);
return ra;
</DeepExtract>
} | BigStitcher | positive | 2,415 |
@Override
public void visitRelationshipPattern(final RelationshipPattern relationshipPattern) {
if (relationshipPattern.length instanceof ASTNode) {
walkASTNode(this, (ASTNode) relationshipPattern.length);
} else {
walkOtherObject(this, relationshipPattern.length);
}
if (relationshipPattern.properties instanceof ASTNode) {
walkASTNode(this, (ASTNode) relationshipPattern.properties);
} else {
walkOtherObject(this, relationshipPattern.properties);
}
if (relationshipPattern.variable instanceof ASTNode) {
walkASTNode(this, (ASTNode) relationshipPattern.variable);
} else {
walkOtherObject(this, relationshipPattern.variable);
}
if (relationshipPattern.types instanceof ASTNode) {
walkASTNode(this, (ASTNode) relationshipPattern.types);
} else {
walkOtherObject(this, relationshipPattern.types);
}
} | @Override
public void visitRelationshipPattern(final RelationshipPattern relationshipPattern) {
if (relationshipPattern.length instanceof ASTNode) {
walkASTNode(this, (ASTNode) relationshipPattern.length);
} else {
walkOtherObject(this, relationshipPattern.length);
}
if (relationshipPattern.properties instanceof ASTNode) {
walkASTNode(this, (ASTNode) relationshipPattern.properties);
} else {
walkOtherObject(this, relationshipPattern.properties);
}
if (relationshipPattern.variable instanceof ASTNode) {
walkASTNode(this, (ASTNode) relationshipPattern.variable);
} else {
walkOtherObject(this, relationshipPattern.variable);
}
<DeepExtract>
if (relationshipPattern.types instanceof ASTNode) {
walkASTNode(this, (ASTNode) relationshipPattern.types);
} else {
walkOtherObject(this, relationshipPattern.types);
}
</DeepExtract>
} | cytosm | positive | 2,416 |
public LinesChartModel create(final Iterable results, final ChartModelConfiguration configuration) {
TestDurationTrendSeriesBuilder builder = new TestDurationTrendSeriesBuilder();
LinesDataSet dataSet = builder.createDataSet(configuration, results);
LinesChartModel model = new LinesChartModel(dataSet);
LineSeries duration = new LineSeries(SECONDS, Palette.GREEN.getNormal(), LineSeries.StackedMode.STACKED, LineSeries.FilledMode.FILLED);
duration.addAll(dataSet.getSeries(SECONDS));
model.addSeries(duration);
return model;
} | public LinesChartModel create(final Iterable results, final ChartModelConfiguration configuration) {
TestDurationTrendSeriesBuilder builder = new TestDurationTrendSeriesBuilder();
LinesDataSet dataSet = builder.createDataSet(configuration, results);
<DeepExtract>
LinesChartModel model = new LinesChartModel(dataSet);
LineSeries duration = new LineSeries(SECONDS, Palette.GREEN.getNormal(), LineSeries.StackedMode.STACKED, LineSeries.FilledMode.FILLED);
duration.addAll(dataSet.getSeries(SECONDS));
model.addSeries(duration);
return model;
</DeepExtract>
} | junit-plugin | positive | 2,417 |
private void connect(@NonNull BluetoothPeripheral peripheral, @NonNull BleProtocol protocol) {
if (bluetoothState != BT_SCANNING) {
Log.e(TAG, "Invalid BT state: " + BT_STATES[bluetoothState]);
}
central.stopScan();
Log.d(TAG, "Rangefinder bluetooth state: " + BT_STATES[bluetoothState] + " -> " + BT_STATES[BT_CONNECTING]);
bluetoothState = BT_CONNECTING;
EventBus.getDefault().post(new BluetoothEvent());
central.connectPeripheral(peripheral, protocol);
} | private void connect(@NonNull BluetoothPeripheral peripheral, @NonNull BleProtocol protocol) {
if (bluetoothState != BT_SCANNING) {
Log.e(TAG, "Invalid BT state: " + BT_STATES[bluetoothState]);
}
central.stopScan();
<DeepExtract>
Log.d(TAG, "Rangefinder bluetooth state: " + BT_STATES[bluetoothState] + " -> " + BT_STATES[BT_CONNECTING]);
bluetoothState = BT_CONNECTING;
EventBus.getDefault().post(new BluetoothEvent());
</DeepExtract>
central.connectPeripheral(peripheral, protocol);
} | BASElineFlightComputer | positive | 2,418 |
public List<List<Integer>> levelOrderBottom2(TreeNode root) {
if (root == null)
return new LinkedList<>();
if (root == null)
return;
if (0 == allLevelValues.size())
allLevelValues.add(new LinkedList<>());
allLevelValues.get(0).add(root.val);
helper(root.left, 0 + 1);
helper(root.right, 0 + 1);
Collections.reverse(allLevelValues);
return allLevelValues;
} | public List<List<Integer>> levelOrderBottom2(TreeNode root) {
if (root == null)
return new LinkedList<>();
<DeepExtract>
if (root == null)
return;
if (0 == allLevelValues.size())
allLevelValues.add(new LinkedList<>());
allLevelValues.get(0).add(root.val);
helper(root.left, 0 + 1);
helper(root.right, 0 + 1);
</DeepExtract>
Collections.reverse(allLevelValues);
return allLevelValues;
} | AlgoCS | positive | 2,419 |
@Test
public void testPad29() throws Exception {
String toPad = "g1nger";
byte[] padded = this.getPadded(toPad, 29);
assertNotNull("The padded string should not be null.", padded);
assertEquals("The padded string has the wrong length.", 29 + 1, padded.length);
assertEquals("The last byte is wrong.", 29 - toPad.length() + 1, (int) padded[padded.length - 1]);
} | @Test
public void testPad29() throws Exception {
<DeepExtract>
String toPad = "g1nger";
byte[] padded = this.getPadded(toPad, 29);
assertNotNull("The padded string should not be null.", padded);
assertEquals("The padded string has the wrong length.", 29 + 1, padded.length);
assertEquals("The last byte is wrong.", 29 - toPad.length() + 1, (int) padded[padded.length - 1]);
</DeepExtract>
} | java-license-manager | positive | 2,420 |
@Override
public int getArrayIndex() {
if (inMap()) {
throw new IllegalStateException("Not traversing an array!");
}
checkList();
return ((ListIterator<?>) i).previousIndex();
} | @Override
public int getArrayIndex() {
if (inMap()) {
throw new IllegalStateException("Not traversing an array!");
}
<DeepExtract>
checkList();
return ((ListIterator<?>) i).previousIndex();
</DeepExtract>
} | hdocdb | positive | 2,422 |
@Override
public void init(final FilterConfig filterConfig, final Class<? extends Filter> filterClazz) {
this.simpleFilterName = filterClazz.getSimpleName();
final String fileLocationFromFilterConfig = filterConfig.getInitParameter(CONFIGURATION_FILE_LOCATION);
boolean filterConfigFileLoad;
if (CommonUtils.isEmpty(fileLocationFromFilterConfig)) {
filterConfigFileLoad = false;
}
FileInputStream fis = null;
try {
fis = new FileInputStream(fileLocationFromFilterConfig);
this.properties.load(fis);
filterConfigFileLoad = true;
} catch (final IOException e) {
LOGGER.warn("Unable to load properties for file {}", fileLocationFromFilterConfig, e);
filterConfigFileLoad = false;
} finally {
CommonUtils.closeQuietly(fis);
}
if (!filterConfigFileLoad) {
final String fileLocationFromServletConfig = filterConfig.getServletContext().getInitParameter(CONFIGURATION_FILE_LOCATION);
final boolean servletContextFileLoad = loadPropertiesFromFile(fileLocationFromServletConfig);
if (!servletContextFileLoad) {
final boolean defaultConfigFileLoaded = loadPropertiesFromFile(DEFAULT_CONFIGURATION_FILE_LOCATION);
CommonUtils.assertTrue(defaultConfigFileLoaded, "unable to load properties to configure CAS client");
}
}
} | @Override
public void init(final FilterConfig filterConfig, final Class<? extends Filter> filterClazz) {
this.simpleFilterName = filterClazz.getSimpleName();
final String fileLocationFromFilterConfig = filterConfig.getInitParameter(CONFIGURATION_FILE_LOCATION);
<DeepExtract>
boolean filterConfigFileLoad;
if (CommonUtils.isEmpty(fileLocationFromFilterConfig)) {
filterConfigFileLoad = false;
}
FileInputStream fis = null;
try {
fis = new FileInputStream(fileLocationFromFilterConfig);
this.properties.load(fis);
filterConfigFileLoad = true;
} catch (final IOException e) {
LOGGER.warn("Unable to load properties for file {}", fileLocationFromFilterConfig, e);
filterConfigFileLoad = false;
} finally {
CommonUtils.closeQuietly(fis);
}
</DeepExtract>
if (!filterConfigFileLoad) {
final String fileLocationFromServletConfig = filterConfig.getServletContext().getInitParameter(CONFIGURATION_FILE_LOCATION);
final boolean servletContextFileLoad = loadPropertiesFromFile(fileLocationFromServletConfig);
if (!servletContextFileLoad) {
final boolean defaultConfigFileLoaded = loadPropertiesFromFile(DEFAULT_CONFIGURATION_FILE_LOCATION);
CommonUtils.assertTrue(defaultConfigFileLoaded, "unable to load properties to configure CAS client");
}
}
} | java-cas-client | positive | 2,424 |
@Override
public void onViewTap(View view, float x, float y) {
if (!hasStop) {
onBackPressed();
}
return false;
} | @Override
public void onViewTap(View view, float x, float y) {
<DeepExtract>
if (!hasStop) {
onBackPressed();
}
return false;
</DeepExtract>
} | PhotoPick-Master | positive | 2,426 |
@Test
public void supportsHttpMethodOverride() throws IOException {
response = request.content(Form.urlEncoded().addField("_method", "DELETE")).post("/logout");
assertNoError();
assertThat(response).hasStatusCode(303);
} | @Test
public void supportsHttpMethodOverride() throws IOException {
response = request.content(Form.urlEncoded().addField("_method", "DELETE")).post("/logout");
<DeepExtract>
assertNoError();
assertThat(response).hasStatusCode(303);
</DeepExtract>
} | simple-petstore | positive | 2,427 |
@Test
public void eventWithDotInPropertyName() throws Exception {
Map<String, Object> event = new HashMap<String, Object>();
event.put("ab.cd", "whatever");
try {
client.validateAndBuildEvent(client.getDefaultProject(), "foo", event, null);
fail(". in property name");
} catch (KeenException e) {
assertEquals("An event cannot contain a property with the period (.) character in it.", e.getLocalizedMessage());
}
} | @Test
public void eventWithDotInPropertyName() throws Exception {
Map<String, Object> event = new HashMap<String, Object>();
event.put("ab.cd", "whatever");
<DeepExtract>
try {
client.validateAndBuildEvent(client.getDefaultProject(), "foo", event, null);
fail(". in property name");
} catch (KeenException e) {
assertEquals("An event cannot contain a property with the period (.) character in it.", e.getLocalizedMessage());
}
</DeepExtract>
} | KeenClient-Java | positive | 2,428 |
@Deprecated(forRemoval = true)
public Map<String, Map<String, Long>> getSlaveWorkspaceUsage() {
if (diskUsage.slaveWorkspacesUsage == null) {
checkWorkspaces();
}
return diskUsage.slaveWorkspacesUsage;
} | @Deprecated(forRemoval = true)
public Map<String, Map<String, Long>> getSlaveWorkspaceUsage() {
<DeepExtract>
if (diskUsage.slaveWorkspacesUsage == null) {
checkWorkspaces();
}
return diskUsage.slaveWorkspacesUsage;
</DeepExtract>
} | disk-usage-plugin | positive | 2,429 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.