_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q13600 | AopUtils.createProxyBean | train | public static Object createProxyBean(Class<?> clazz, BeanBox box, BeanBoxContext ctx) {
BeanBoxException.assureNotNull(clazz, "Try to create a proxy bean, but beanClass not found.");
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(clazz);
if (box.getConstructorParams() != null && box.getConstructorParams().length > 0) {
BeanBox[] boxes = box.getConstructorParams();
Class<?>[] argsTypes = new Class<?>[boxes.length];
Object[] realArgsValue = new Object[boxes.length];
for (int i = 0; i < boxes.length; i++) {
argsTypes[i] = boxes[i].getType();
Object realValue = ctx.getBean(boxes[i]);
if (realValue != null && realValue instanceof String)
realValue = ctx.getValueTranslator().translate((String) realValue, boxes[i].getType());
realArgsValue[i] = realValue;
}
enhancer.setCallback(new ProxyBean(box, ctx));
return enhancer.create(argsTypes, realArgsValue);
} else {
enhancer.setCallback(new ProxyBean(box, ctx));
return enhancer.create();
}
} | java | {
"resource": ""
} |
q13601 | Light.getProps | train | public Map<Prop.Names, String> getProps(Prop.Names[] props) throws CommandExecutionException {
Prop prop = new Prop(props);
return prop.parseResponse(sendToArray("get_prop", prop.getRequestArray()));
} | java | {
"resource": ""
} |
q13602 | Light.getSingleProp | train | public String getSingleProp(Prop.Names prop) throws CommandExecutionException {
Map<Prop.Names, String> value = getProps(new Prop.Names[]{prop});
String valueString = value.get(prop);
if (valueString == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return valueString;
} | java | {
"resource": ""
} |
q13603 | Light.getIntProp | train | public int getIntProp(Prop.Names prop) throws CommandExecutionException {
String value = getSingleProp(prop);
if (value.equals("")) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
try {
return Integer.valueOf(value);
} catch (Exception e){
throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
}
} | java | {
"resource": ""
} |
q13604 | Light.powerOffAfterTime | train | public boolean powerOffAfterTime(int minutes) throws CommandExecutionException {
JSONArray col = new JSONArray();
col.put(0);
col.put(minutes);
return sendOk("cron_add", col);
} | java | {
"resource": ""
} |
q13605 | BeanBoxUtils.getUniqueBeanBox | train | public static BeanBox getUniqueBeanBox(BeanBoxContext ctx, Class<?> clazz) {
BeanBoxException.assureNotNull(clazz, "Target class can not be null");
BeanBox box = ctx.beanBoxMetaCache.get(clazz);
if (box != null)
return box;
if (BeanBox.class.isAssignableFrom(clazz))
try {
box = (BeanBox) clazz.newInstance();
if (box.singleton == null)
box.singleton = true;
} catch (Exception e) {
BeanBoxException.throwEX(e);
}
else
box = doCreateBeanBox(ctx, clazz);
ctx.beanBoxMetaCache.put(clazz, box);
return box;
} | java | {
"resource": ""
} |
q13606 | BeanBoxUtils.getAnnotations | train | private static Annotation[] getAnnotations(Object targetClass) {
if (targetClass instanceof Field)
return ((Field) targetClass).getAnnotations();
else if (targetClass instanceof Method)
return ((Method) targetClass).getAnnotations();
else if (targetClass instanceof Constructor)
return ((Constructor<?>) targetClass).getAnnotations();
else if (targetClass instanceof Class)
return ((Class<?>) targetClass).getAnnotations();
else
return BeanBoxException.throwEX("targetClass should be Field, Method, Constructor or Class");
} | java | {
"resource": ""
} |
q13607 | BeanBoxUtils.getAnnoAsMap | train | private static Map<String, Object> getAnnoAsMap(Object targetClass, String annoFullName) {
Annotation[] anno = getAnnotations(targetClass);
for (Annotation a : anno) {
Class<? extends Annotation> type = a.annotationType();
if (annoFullName.equals(type.getName()))
return changeAnnotationValuesToMap(a);
}
return null;
} | java | {
"resource": ""
} |
q13608 | BeanBoxUtils.checkAnnoExist | train | private static boolean checkAnnoExist(Object targetClass, Class<?> annoClass) {
Annotation[] anno = getAnnotations(targetClass);
for (Annotation annotation : anno) {
Class<? extends Annotation> type = annotation.annotationType();
if (annoClass.equals(type))
return true;
}
return false;
} | java | {
"resource": ""
} |
q13609 | BeanBoxUtils.wrapParamToBox | train | protected static BeanBox wrapParamToBox(Object param) {
if (param != null) {
if (param instanceof Class)
return new BeanBox().setTarget(param);
if (param instanceof BeanBox)
return (BeanBox) param;
}
return new BeanBox().setAsValue(param);
} | java | {
"resource": ""
} |
q13610 | AdditionalWebAppJettyConfigurationUtil.addConfigurationClasses | train | public static String[] addConfigurationClasses(String[] configurationClasses, AdditionalWebAppJettyConfigurationClass[] optionalAdditionalsWebappConfigurationClasses) {
List<String> newConfigurationClasses = new ArrayList<>(Arrays.asList(configurationClasses));
for (AdditionalWebAppJettyConfigurationClass additionalWebappConfigurationClass : optionalAdditionalsWebappConfigurationClasses) {
if (additionalWebappConfigurationClass.getClasses() == null || additionalWebappConfigurationClass.getPosition() == null) {
LOG.warn("Bad support class name");
} else {
if (ClassUtil.classesExists(additionalWebappConfigurationClass.getClasses())) {
int index = 0;
if (additionalWebappConfigurationClass.getReferenceClass() == null) {
if (additionalWebappConfigurationClass.getPosition() == Position.AFTER) {
index = newConfigurationClasses.size();
}
} else {
index = newConfigurationClasses.indexOf(additionalWebappConfigurationClass.getReferenceClass());
if (index == -1) {
if (additionalWebappConfigurationClass.getPosition() == Position.AFTER) {
LOG.warn("[{}] reference unreachable, add at the end", additionalWebappConfigurationClass.getReferenceClass());
index = newConfigurationClasses.size();
} else {
LOG.warn("[{}] reference unreachable, add at the top", additionalWebappConfigurationClass.getReferenceClass());
index = 0;
}
} else {
if (additionalWebappConfigurationClass.getPosition() == Position.AFTER) {
index++;
}
}
}
newConfigurationClasses.addAll(index, additionalWebappConfigurationClass.getClasses());
for (String className : additionalWebappConfigurationClass.getClasses()) {
LOG.debug("[{}] support added", className);
}
} else {
for (String className : additionalWebappConfigurationClass.getClasses()) {
LOG.debug("[{}] not available", className);
}
}
}
}
// List configurations
for (String configurationClasse : newConfigurationClasses) {
LOG.trace("Jetty WebAppContext Configuration => " + configurationClasse);
}
return newConfigurationClasses.toArray(new String[newConfigurationClasses.size()]);
} | java | {
"resource": ""
} |
q13611 | GeneratorAdapter.catchException | train | public void catchException(final Label start, final Label end,
final Type exception) {
if (exception == null) {
mv.visitTryCatchBlock(start, end, mark(), null);
} else {
mv.visitTryCatchBlock(start, end, mark(),
exception.getInternalName());
}
} | java | {
"resource": ""
} |
q13612 | StringSwitcher.create | train | public static StringSwitcher create(String[] strings, int[] ints, boolean fixedInput) {
Generator gen = new Generator();
gen.setStrings(strings);
gen.setInts(ints);
gen.setFixedInput(fixedInput);
return gen.create();
} | java | {
"resource": ""
} |
q13613 | BridgeMethodResolver.resolveAll | train | public Map/*<Signature, Signature>*/resolveAll() {
Map resolved = new HashMap();
for (Iterator entryIter = declToBridge.entrySet().iterator(); entryIter.hasNext(); ) {
Map.Entry entry = (Map.Entry)entryIter.next();
Class owner = (Class)entry.getKey();
Set bridges = (Set)entry.getValue();
try {
new ClassReader(owner.getName())
.accept(new BridgedFinder(bridges, resolved),
ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);
} catch(IOException ignored) {}
}
return resolved;
} | java | {
"resource": ""
} |
q13614 | FieldNode.check | train | public void check(final int api) {
if (api == Opcodes.ASM4) {
if (visibleTypeAnnotations != null
&& visibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
if (invisibleTypeAnnotations != null
&& invisibleTypeAnnotations.size() > 0) {
throw new RuntimeException();
}
}
} | java | {
"resource": ""
} |
q13615 | FieldNode.accept | train | public void accept(final ClassVisitor cv) {
FieldVisitor fv = cv.visitField(access, name, desc, signature, value);
if (fv == null) {
return;
}
int i, n;
n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
for (i = 0; i < n; ++i) {
AnnotationNode an = visibleAnnotations.get(i);
an.accept(fv.visitAnnotation(an.desc, true));
}
n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
for (i = 0; i < n; ++i) {
AnnotationNode an = invisibleAnnotations.get(i);
an.accept(fv.visitAnnotation(an.desc, false));
}
n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size();
for (i = 0; i < n; ++i) {
TypeAnnotationNode an = visibleTypeAnnotations.get(i);
an.accept(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc,
true));
}
n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations
.size();
for (i = 0; i < n; ++i) {
TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
an.accept(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc,
false));
}
n = attrs == null ? 0 : attrs.size();
for (i = 0; i < n; ++i) {
fv.visitAttribute(attrs.get(i));
}
fv.visitEnd();
} | java | {
"resource": ""
} |
q13616 | SerialVersionUIDAdder.computeSVUID | train | protected long computeSVUID() throws IOException {
ByteArrayOutputStream bos;
DataOutputStream dos = null;
long svuid = 0;
try {
bos = new ByteArrayOutputStream();
dos = new DataOutputStream(bos);
/*
* 1. The class name written using UTF encoding.
*/
dos.writeUTF(name.replace('/', '.'));
/*
* 2. The class modifiers written as a 32-bit integer.
*/
dos.writeInt(access
& (Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL
| Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT));
/*
* 3. The name of each interface sorted by name written using UTF
* encoding.
*/
Arrays.sort(interfaces);
for (int i = 0; i < interfaces.length; i++) {
dos.writeUTF(interfaces[i].replace('/', '.'));
}
/*
* 4. For each field of the class sorted by field name (except
* private static and private transient fields):
*
* 1. The name of the field in UTF encoding. 2. The modifiers of the
* field written as a 32-bit integer. 3. The descriptor of the field
* in UTF encoding
*
* Note that field signatures are not dot separated. Method and
* constructor signatures are dot separated. Go figure...
*/
writeItems(svuidFields, dos, false);
/*
* 5. If a class initializer exists, write out the following: 1. The
* name of the method, <clinit>, in UTF encoding. 2. The modifier of
* the method, java.lang.reflect.Modifier.STATIC, written as a
* 32-bit integer. 3. The descriptor of the method, ()V, in UTF
* encoding.
*/
if (hasStaticInitializer) {
dos.writeUTF("<clinit>");
dos.writeInt(Opcodes.ACC_STATIC);
dos.writeUTF("()V");
} // if..
/*
* 6. For each non-private constructor sorted by method name and
* signature: 1. The name of the method, <init>, in UTF encoding. 2.
* The modifiers of the method written as a 32-bit integer. 3. The
* descriptor of the method in UTF encoding.
*/
writeItems(svuidConstructors, dos, true);
/*
* 7. For each non-private method sorted by method name and
* signature: 1. The name of the method in UTF encoding. 2. The
* modifiers of the method written as a 32-bit integer. 3. The
* descriptor of the method in UTF encoding.
*/
writeItems(svuidMethods, dos, true);
dos.flush();
/*
* 8. The SHA-1 algorithm is executed on the stream of bytes
* produced by DataOutputStream and produces five 32-bit values
* sha[0..4].
*/
byte[] hashBytes = computeSHAdigest(bos.toByteArray());
/*
* 9. The hash value is assembled from the first and second 32-bit
* values of the SHA-1 message digest. If the result of the message
* digest, the five 32-bit words H0 H1 H2 H3 H4, is in an array of
* five int values named sha, the hash value would be computed as
* follows:
*
* long hash = ((sha[0] >>> 24) & 0xFF) | ((sha[0] >>> 16) & 0xFF)
* << 8 | ((sha[0] >>> 8) & 0xFF) << 16 | ((sha[0] >>> 0) & 0xFF) <<
* 24 | ((sha[1] >>> 24) & 0xFF) << 32 | ((sha[1] >>> 16) & 0xFF) <<
* 40 | ((sha[1] >>> 8) & 0xFF) << 48 | ((sha[1] >>> 0) & 0xFF) <<
* 56;
*/
for (int i = Math.min(hashBytes.length, 8) - 1; i >= 0; i--) {
svuid = (svuid << 8) | (hashBytes[i] & 0xFF);
}
} finally {
// close the stream (if open)
if (dos != null) {
dos.close();
}
}
return svuid;
} | java | {
"resource": ""
} |
q13617 | SerialVersionUIDAdder.computeSHAdigest | train | protected byte[] computeSHAdigest(final byte[] value) {
try {
return MessageDigest.getInstance("SHA").digest(value);
} catch (Exception e) {
throw new UnsupportedOperationException(e.toString());
}
} | java | {
"resource": ""
} |
q13618 | SerialVersionUIDAdder.writeItems | train | private static void writeItems(final Collection<Item> itemCollection,
final DataOutput dos, final boolean dotted) throws IOException {
int size = itemCollection.size();
Item[] items = itemCollection.toArray(new Item[size]);
Arrays.sort(items);
for (int i = 0; i < size; i++) {
dos.writeUTF(items[i].name);
dos.writeInt(items[i].access);
dos.writeUTF(dotted ? items[i].desc.replace('/', '.')
: items[i].desc);
}
} | java | {
"resource": ""
} |
q13619 | Vacuum.status | train | public VacuumStatus status() throws CommandExecutionException {
JSONArray resp = sendToArray("get_status");
JSONObject stat = resp.optJSONObject(0);
if (stat == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return new VacuumStatus(stat);
} | java | {
"resource": ""
} |
q13620 | Vacuum.getTimezone | train | public TimeZone getTimezone() throws CommandExecutionException {
JSONArray resp = sendToArray("get_timezone");
String zone = resp.optString(0, null);
if (zone == null ) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return TimeZone.getTimeZone(zone);
} | java | {
"resource": ""
} |
q13621 | Vacuum.setTimezone | train | public boolean setTimezone(TimeZone zone) throws CommandExecutionException {
if (zone == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray tz = new JSONArray();
tz.put(zone.getID());
return sendOk("set_timezone", tz);
} | java | {
"resource": ""
} |
q13622 | Vacuum.consumableStatus | train | public VacuumConsumableStatus consumableStatus() throws CommandExecutionException {
JSONArray resp = sendToArray("get_consumable");
JSONObject stat = resp.optJSONObject(0);
if (stat == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return new VacuumConsumableStatus(stat);
} | java | {
"resource": ""
} |
q13623 | Vacuum.resetConsumable | train | public boolean resetConsumable(VacuumConsumableStatus.Names consumable) throws CommandExecutionException {
if (consumable == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray params = new JSONArray();
params.put(consumable.toString());
return sendOk("reset_consumable", params);
} | java | {
"resource": ""
} |
q13624 | Vacuum.getFanSpeed | train | public int getFanSpeed() throws CommandExecutionException {
int resp = sendToArray("get_custom_mode").optInt(0, -1);
if ((resp < 0) || (resp > 100)) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return resp;
} | java | {
"resource": ""
} |
q13625 | Vacuum.setFanSpeed | train | public boolean setFanSpeed(int speed) throws CommandExecutionException {
if (speed < 0 || speed > 100) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray params = new JSONArray();
params.put(speed);
return sendOk("set_custom_mode", params);
} | java | {
"resource": ""
} |
q13626 | Vacuum.getTimers | train | public VacuumTimer[] getTimers() throws CommandExecutionException {
JSONArray tm = sendToArray("get_timer");
if (tm == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
VacuumTimer[] timers = new VacuumTimer[tm.length()];
for (int i = 0; i < tm.length(); i++){
timers[i] = new VacuumTimer(tm.optJSONArray(i));
}
return timers;
} | java | {
"resource": ""
} |
q13627 | Vacuum.addTimer | train | public boolean addTimer(VacuumTimer timer) throws CommandExecutionException {
if (timer == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray tm = timer.construct();
if (tm == null) return false;
JSONArray payload = new JSONArray();
payload.put(tm);
return sendOk("set_timer", payload);
} | java | {
"resource": ""
} |
q13628 | Vacuum.setTimerEnabled | train | public boolean setTimerEnabled(VacuumTimer timer) throws CommandExecutionException {
if (timer == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray payload = new JSONArray();
payload.put(timer.getID());
payload.put(timer.getOnOff());
return sendOk("upd_timer", payload);
} | java | {
"resource": ""
} |
q13629 | Vacuum.removeTimer | train | public boolean removeTimer(VacuumTimer timer) throws CommandExecutionException {
if (timer == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray payload = new JSONArray();
payload.put(timer.getID());
return sendOk("del_timer", payload);
} | java | {
"resource": ""
} |
q13630 | Vacuum.setDoNotDisturb | train | public boolean setDoNotDisturb(VacuumDoNotDisturb dnd) throws CommandExecutionException {
if (dnd == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
return sendOk("set_dnd_timer", dnd.construct());
} | java | {
"resource": ""
} |
q13631 | Vacuum.goTo | train | public boolean goTo(int[] p) throws CommandExecutionException {
if (p == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
if (p.length != 2) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONArray payload = new JSONArray();
payload.put(p[0]);
payload.put(p[1]);
return sendOk("app_goto_target" , payload);
} | java | {
"resource": ""
} |
q13632 | Vacuum.getAllCleanups | train | public VacuumCleanup[] getAllCleanups() throws CommandExecutionException {
JSONArray cleanupIDs = getCleaningSummary().optJSONArray(3);
if (cleanupIDs == null) return null;
VacuumCleanup[] res = new VacuumCleanup[cleanupIDs.length()];
for (int i = 0; i < cleanupIDs.length(); i++){
JSONArray send = new JSONArray();
send.put(cleanupIDs.optLong(i));
JSONArray ar = sendToArray("get_clean_record", send).optJSONArray(0);
res[i] = new VacuumCleanup(ar);
}
return res;
} | java | {
"resource": ""
} |
q13633 | Vacuum.getSoundVolume | train | public int getSoundVolume() throws CommandExecutionException {
JSONArray res = sendToArray("get_sound_volume");
if (res == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
int vol = res.optInt(0, -1);
if (vol < 0) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_RESPONSE);
return vol;
} | java | {
"resource": ""
} |
q13634 | Vacuum.setSoundVolume | train | public boolean setSoundVolume(int volume) throws CommandExecutionException {
if (volume < 0) volume = 0;
if (volume > 100) volume = 100;
JSONArray payload = new JSONArray();
payload.put(volume);
return sendOk("change_sound_volume", payload);
} | java | {
"resource": ""
} |
q13635 | Vacuum.manualControlMove | train | public boolean manualControlMove(float rotationSpeed, float speed, int runDuration) throws CommandExecutionException {
if (manualControlSequence < 1) manualControlStart();
JSONObject payload = new JSONObject();
if (rotationSpeed > 180.0f) rotationSpeed = 180.0f;
if (rotationSpeed < -180.0f) rotationSpeed = -180.0f;
float rotationRadians = Math.round((rotationSpeed / 180.0f) * 272.0d) / 100.0f; //Found out after LOADS of tests.
payload.put("omega", rotationRadians);
if (speed >= 0.3f) speed = 0.29f;
if (speed <= -0.3f) speed = -0.29f;
payload.put("velocity", speed);
if (runDuration < 0) runDuration = 1000;
payload.put("duration", runDuration);
payload.put("seqnum", manualControlSequence);
manualControlSequence++;
JSONArray send = new JSONArray();
send.put(payload);
return sendOk("app_rc_move", send);
} | java | {
"resource": ""
} |
q13636 | Vacuum.installSoundpack | train | public VacuumSounpackInstallState installSoundpack(String url, String md5, int soundId) throws CommandExecutionException {
if (url == null || md5 == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
JSONObject install = new JSONObject();
install.put("url", url);
install.put("md5", md5);
install.put("sid", soundId);
JSONArray ret = sendToArray("dnld_install_sound", install);
if (ret == null) return null;
return new VacuumSounpackInstallState(ret.optJSONObject(0));
} | java | {
"resource": ""
} |
q13637 | Vacuum.soundpackInstallStatus | train | public VacuumSounpackInstallState soundpackInstallStatus() throws CommandExecutionException {
JSONArray ret = sendToArray("get_sound_progress");
if (ret == null) return null;
return new VacuumSounpackInstallState(ret.optJSONObject(0));
} | java | {
"resource": ""
} |
q13638 | Vacuum.getCarpetModeState | train | public JSONObject getCarpetModeState() throws CommandExecutionException {
JSONArray ret = sendToArray("get_carpet_mode");
if (ret == null) return null;
return ret.optJSONObject(0);
} | java | {
"resource": ""
} |
q13639 | Vacuum.setCarpetMode | train | public boolean setCarpetMode(boolean enabled, int high, int low, int integral, int stallTime) throws CommandExecutionException {
JSONObject payload = new JSONObject();
payload.put("enable", enabled ? 1:0);
payload.put("current_high", high);
payload.put("current_low", low);
payload.put("current_integral", integral);
payload.put("stall_time", stallTime);
JSONArray send = new JSONArray();
send.put(payload);
return sendOk("set_carpet_mode", send);
} | java | {
"resource": ""
} |
q13640 | Vacuum.getSerialnumber | train | public String getSerialnumber() throws CommandExecutionException {
JSONArray ret = sendToArray("get_serial_number");
if (ret == null) return null;
return ret.optJSONObject(0).optString("serial_number");
} | java | {
"resource": ""
} |
q13641 | LocalVariablesSorter.newLocal | train | public int newLocal(final Type type) {
Object t;
switch (type.getSort()) {
case Type.BOOLEAN:
case Type.CHAR:
case Type.BYTE:
case Type.SHORT:
case Type.INT:
t = Opcodes.INTEGER;
break;
case Type.FLOAT:
t = Opcodes.FLOAT;
break;
case Type.LONG:
t = Opcodes.LONG;
break;
case Type.DOUBLE:
t = Opcodes.DOUBLE;
break;
case Type.ARRAY:
t = type.getDescriptor();
break;
// case Type.OBJECT:
default:
t = type.getInternalName();
break;
}
int local = newLocalMapping(type);
setLocalType(local, type);
setFrameLocal(local, t);
changed = true;
return local;
} | java | {
"resource": ""
} |
q13642 | FighterParser.getFights | train | private List<Fight> getFights(Elements trs, Fighter fighter) throws ArrayIndexOutOfBoundsException {
List<Fight> fights = new ArrayList<>();
logger.info("{} TRs to parse through", trs.size());
SherdogBaseObject sFighter = new SherdogBaseObject();
sFighter.setName(fighter.getName());
sFighter.setSherdogUrl(fighter.getSherdogUrl());
// removing header row...
if (trs.size() > 0) {
trs.remove(0);
trs.forEach(tr -> {
Fight fight = new Fight();
fight.setFighter1(sFighter);
Elements tds = tr.select("td");
fight.setResult(getFightResult(tds.get(COLUMN_RESULT)));
fight.setFighter2(getOpponent(tds.get(COLUMN_OPPONENT)));
fight.setEvent(getEvent(tds.get(COLUMN_EVENT)));
fight.setDate(getDate(tds.get(COLUMN_EVENT)));
fight.setWinMethod(getWinMethod(tds.get(COLUMN_METHOD)));
fight.setWinRound(getWinRound(tds.get(COLUMN_ROUND)));
fight.setWinTime(getWinTime(tds.get(COLUMN_TIME)));
fights.add(fight);
logger.info("{}", fight);
});
}
return fights;
} | java | {
"resource": ""
} |
q13643 | FighterParser.getOpponent | train | private SherdogBaseObject getOpponent(Element td) {
SherdogBaseObject opponent = new SherdogBaseObject();
Element opponentLink = td.select("a").get(0);
opponent.setName(opponentLink.html());
opponent.setSherdogUrl(opponentLink.attr("abs:href"));
return opponent;
} | java | {
"resource": ""
} |
q13644 | FighterParser.getEvent | train | private SherdogBaseObject getEvent(Element td) {
Element link = td.select("a").get(0);
SherdogBaseObject event = new SherdogBaseObject();
event.setName(link.html().replaceAll("<span itemprop=\"award\">|</span>", ""));
event.setSherdogUrl(link.attr("abs:href"));
return event;
} | java | {
"resource": ""
} |
q13645 | FighterParser.getDate | train | private ZonedDateTime getDate(Element td) {
//date
Element date = td.select("span.sub_line").first();
return ParserUtils.getDateFromStringToZoneId(date.html(), ZONE_ID, DateTimeFormatter.ofPattern("MMM / dd / yyyy", Locale.US));
} | java | {
"resource": ""
} |
q13646 | SignatureReader.parseType | train | private static int parseType(final String signature, int pos,
final SignatureVisitor v) {
char c;
int start, end;
boolean visited, inner;
String name;
switch (c = signature.charAt(pos++)) {
case 'Z':
case 'C':
case 'B':
case 'S':
case 'I':
case 'F':
case 'J':
case 'D':
case 'V':
v.visitBaseType(c);
return pos;
case '[':
return parseType(signature, pos, v.visitArrayType());
case 'T':
end = signature.indexOf(';', pos);
v.visitTypeVariable(signature.substring(pos, end));
return end + 1;
default: // case 'L':
start = pos;
visited = false;
inner = false;
for (;;) {
switch (c = signature.charAt(pos++)) {
case '.':
case ';':
if (!visited) {
name = signature.substring(start, pos - 1);
if (inner) {
v.visitInnerClassType(name);
} else {
v.visitClassType(name);
}
}
if (c == ';') {
v.visitEnd();
return pos;
}
start = pos;
visited = false;
inner = true;
break;
case '<':
name = signature.substring(start, pos - 1);
if (inner) {
v.visitInnerClassType(name);
} else {
v.visitClassType(name);
}
visited = true;
top: for (;;) {
switch (c = signature.charAt(pos)) {
case '>':
break top;
case '*':
++pos;
v.visitTypeArgument();
break;
case '+':
case '-':
pos = parseType(signature, pos + 1,
v.visitTypeArgument(c));
break;
default:
pos = parseType(signature, pos,
v.visitTypeArgument('='));
break;
}
}
}
}
}
} | java | {
"resource": ""
} |
q13647 | IndexedSortableDataProvider.getSortFieldIndex | train | protected int getSortFieldIndex() {
SortParam sp = getSort();
Integer index = fieldNameToIndex.get(sp.getProperty());
if (index == null) {
index = 1;
}
return index;
} | java | {
"resource": ""
} |
q13648 | DefaultBeanManager.getBeanToValidate | train | @Override
public Map<BeanId, Bean> getBeanToValidate(Collection<Bean> beans) throws AbortRuntimeException {
Map<BeanId, Bean> beansToValidate = new HashMap<>();
for (Bean bean : beans) {
Map<BeanId, Bean> predecessors = new HashMap<>();
// beans read from xml storage will only have their basic properties initialized...
// ... but we also need set the direct references/predecessors for beans to validate
Map<BeanId, Bean> beansToValidateSubset = getDirectSuccessors(bean);
beansToValidateSubset.put(bean.getId(), bean);
for (Bean toValidate : beansToValidateSubset.values()) {
predecessors.putAll(getDirectPredecessors(toValidate));
}
for (Bean predecessor : predecessors.values()) {
for (BeanId ref : predecessor.getReferences()) {
Bean b = storage.get(ref);
if (b == null) {
throw CFG301_MISSING_RUNTIME_REF(predecessor.getId());
}
ref.setBean(b);
}
}
for (Bean toValidate : beansToValidateSubset.values()) {
// list references of beansToValidate should now
// be available in predecessors.
for (BeanId ref : toValidate.getReferences()) {
Bean predecessor = predecessors.get(ref);
if (predecessor == null) {
throw new IllegalStateException("Bug in algorithm. Reference [" + ref
+ "] of [" + toValidate.getId()
+ "] should be available in predecessors.");
}
ref.setBean(predecessor);
}
}
beansToValidate.putAll(predecessors);
}
return beansToValidate;
} | java | {
"resource": ""
} |
q13649 | BaseJob.getApplicationContext | train | protected ApplicationContext getApplicationContext(JobExecutionContext context)
throws SchedulerException {
final SchedulerContext schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
// show keys in context
if(applicationContext==null) {
logger.error(APPLICATION_CONTEXT_KEY+" is empty in "+ schedulerContext+":");
if(schedulerContext.getKeys()!=null) {
for (String key : schedulerContext.getKeys()) {
Object value = schedulerContext.get(key);
String valueText = value!=null ? value.toString() : "<NULL>";
logger.info(" {} = {}", key, valueText);
}
}
}
return applicationContext;
} | java | {
"resource": ""
} |
q13650 | ConsoleScanner.checkSystemInput | train | private void checkSystemInput()
throws IOException
{
while ( System.in.available() > 0 )
{
int input = System.in.read();
if ( input >= 0 )
{
char c = (char) input;
if ( c == '\n' )
{
synchronized ( lock )
{
finished = true;
lock.notifyAll();
}
}
}
else
{
synchronized ( lock )
{
finished = true;
lock.notifyAll();
}
}
}
} | java | {
"resource": ""
} |
q13651 | CommonsHttpInvokerRequestExecutor.executePostMethod | train | protected void executePostMethod(
HttpInvokerClientConfiguration config, HttpClient httpClient, PostMethod postMethod)
throws IOException {
httpClient.executeMethod(postMethod);
} | java | {
"resource": ""
} |
q13652 | HBeanReferences.getReferenceKeyValue | train | public static KeyValue getReferenceKeyValue(byte[] rowkey, String propertyName,
String schemaName, List<BeanId> refs, UniqueIds uids) {
final byte[] pid = uids.getUsid().getId(propertyName);
final byte[] sid = uids.getUsid().getId(schemaName);
final byte[] qual = new byte[] { sid[0], sid[1], pid[0], pid[1] };
final byte[] iids = getIids2(refs, uids);
return new KeyValue(rowkey, REF_COLUMN_FAMILY, qual, iids);
} | java | {
"resource": ""
} |
q13653 | HBeanReferences.setReferencesOn | train | public void setReferencesOn(Bean bean) {
for (KeyValue ref : references.values()) {
final byte[] sidpid = ref.getQualifier();
final byte[] iids = ref.getValue();
final byte[] sid = new byte[] { sidpid[0], sidpid[1] };
final byte[] pid = new byte[] { sidpid[2], sidpid[3] };
final String schemaName = uids.getUsid().getName(sid);
final String propertyName = uids.getUsid().getName(pid);
for (int i = 0; i < iids.length; i += IID_WIDTH) {
final byte[] iid = new byte[] { iids[i], iids[i + 1], iids[i + 2], iids[i + 3] };
final String instanceId = uids.getUiid().getName(iid);
bean.addReference(propertyName, BeanId.create(instanceId, schemaName));
}
}
} | java | {
"resource": ""
} |
q13654 | HBeanReferences.isReference | train | public static boolean isReference(KeyValue kv) {
if (Bytes.equals(kv.getFamily(), REF_COLUMN_FAMILY)) {
return true;
}
return false;
} | java | {
"resource": ""
} |
q13655 | HBeanReferences.getIids | train | public static byte[] getIids(final List<String> ids, final UniqueIds uids) {
final int size = ids.size();
final byte[] iids = new byte[IID_WIDTH * size];
for (int i = 0; i < size; i++) {
final String instanceId = ids.get(i);
final byte[] iid = uids.getUiid().getId(instanceId);
System.arraycopy(iid, 0, iids, i * IID_WIDTH, IID_WIDTH);
}
return iids;
} | java | {
"resource": ""
} |
q13656 | HBeanReferences.getIids2 | train | private static byte[] getIids2(final List<BeanId> ids, final UniqueIds uids) {
if (ids == null) {
return new byte[0];
}
final AbstractList<String> list = new AbstractList<String>() {
@Override
public String get(int index) {
return ids.get(index).getInstanceId();
}
@Override
public int size() {
return ids.size();
}
};
return getIids(list, uids);
} | java | {
"resource": ""
} |
q13657 | DateLabels.forDateTime | train | public static DateLabel forDateTime(String id, Date date) {
return DateLabel.forDatePattern(id, new Model<Date>(date),
DATE_TIME_PATTERN);
} | java | {
"resource": ""
} |
q13658 | BaseFileSystem.get | train | protected Entry get( DirectoryEntry parent, String name )
{
parent.getClass();
Entry[] entries = listEntries( parent );
if ( entries != null )
{
for ( int i = 0; i < entries.length; i++ )
{
if ( name.equals( entries[i].getName() ) )
{
return entries[i];
}
}
}
return null;
} | java | {
"resource": ""
} |
q13659 | DiskFileSystem.toFile | train | private File toFile( Entry entry )
{
Stack<String> stack = new Stack<String>();
Entry entryRoot = entry.getFileSystem().getRoot();
while ( entry != null && !entryRoot.equals( entry ) )
{
String name = entry.getName();
if ( "..".equals( name ) )
{
if ( !stack.isEmpty() )
{
stack.pop();
}
}
else if ( !".".equals( name ) )
{
stack.push( name );
}
entry = entry.getParent();
}
File file = this.root;
while ( !stack.empty() )
{
file = new File( file, (String) stack.pop() );
}
return file;
} | java | {
"resource": ""
} |
q13660 | SchemaValidator.validateSchema | train | public static void validateSchema(Bean bean) {
validateId(bean);
validatePropertyNames(bean);
validateReferences(bean);
validateProperties(bean);
validatePropertyList(bean);
validatePropertyReferences(bean);
validatePropertyRefList(bean);
validatePropertyRefMap(bean);
} | java | {
"resource": ""
} |
q13661 | BeanManager.initializeReferences | train | public final void initializeReferences(Collection<Bean> beans) {
Map<BeanId, Bean> indexed = BeanUtils.uniqueIndex(beans);
for (Bean bean : beans) {
for (String name : bean.getReferenceNames()) {
List<BeanId> ids = bean.getReference(name);
if (ids == null) {
continue;
}
for (BeanId id : ids) {
Bean ref = indexed.get(id);
if (ref == null) {
Optional<Bean> optionalRef = getEager(id);
if (optionalRef.isPresent()) {
ref = optionalRef.get();
}
}
id.setBean(ref);
}
}
}
} | java | {
"resource": ""
} |
q13662 | Schema.create | train | public static Schema create(SchemaId id, final String classType, final String name,
final String description) {
return new Schema(id, classType, name, description);
} | java | {
"resource": ""
} |
q13663 | Schema.getClassType | train | public Class<?> getClassType() {
try {
return Class.forName(getType(), true, ClassLoaderHolder.getClassLoader());
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
} | java | {
"resource": ""
} |
q13664 | Schema.add | train | public void add(AbstractSchemaProperty property) {
Class type = property.getClass();
properties.put(type, property);
if (SchemaProperty.class.isAssignableFrom(type)) {
propertyNames.add(property.getName());
} else if (SchemaPropertyList.class.isAssignableFrom(type)) {
propertyNames.add(property.getName());
} else if (SchemaPropertyRef.class.isAssignableFrom(type)) {
referenceNames.add(property.getName());
} else if (SchemaPropertyRefList.class.isAssignableFrom(type)) {
referenceNames.add(property.getName());
} else if (SchemaPropertyRefMap.class.isAssignableFrom(type)) {
referenceNames.add(property.getName());
} else {
throw new IllegalArgumentException("Unknown property type " + type.getName());
}
} | java | {
"resource": ""
} |
q13665 | Schema.getIndexed | train | public <T extends AbstractSchemaProperty> Set<T> getIndexed() {
HashSet<AbstractSchemaProperty> indexed = new HashSet<>();
for (AbstractSchemaProperty prop : properties.values()) {
if (prop.isIndexed()) indexed.add(prop);
}
return (Set<T>) indexed;
} | java | {
"resource": ""
} |
q13666 | Schema.get | train | @SuppressWarnings({ "unchecked", "rawtypes" })
public <T extends AbstractSchemaProperty> Set<T> get(final Class<T> clazz) {
return (Set<T>) properties.get(clazz);
} | java | {
"resource": ""
} |
q13667 | Schema.get | train | public <T extends AbstractSchemaProperty> T get(final Class<T> clazz, final String name) {
Set<T> propertyCollection = get(clazz);
for (T property : propertyCollection) {
if (property.getName().equals(name)) {
return property;
}
}
return null;
} | java | {
"resource": ""
} |
q13668 | VelocityEngineFactory.setVelocityPropertiesMap | train | public void setVelocityPropertiesMap(Map<String, Object> velocityPropertiesMap) {
if (velocityPropertiesMap != null) {
this.velocityProperties.putAll(velocityPropertiesMap);
}
} | java | {
"resource": ""
} |
q13669 | VelocityEngineFactory.createVelocityEngine | train | public VelocityEngine createVelocityEngine() throws IOException, VelocityException {
VelocityEngine velocityEngine = newVelocityEngine();
Map<String, Object> props = new HashMap<String, Object>();
// Load config file if set.
if (this.configLocation != null) {
if (logger.isInfoEnabled()) {
logger.info("Loading Velocity config from [" + this.configLocation + "]");
}
CollectionUtils.mergePropertiesIntoMap(PropertiesLoaderUtils.loadProperties(this.configLocation), props);
}
// Merge local properties if set.
if (!this.velocityProperties.isEmpty()) {
props.putAll(this.velocityProperties);
}
// Set a resource loader path, if required.
if (this.resourceLoaderPath != null) {
initVelocityResourceLoader(velocityEngine, this.resourceLoaderPath);
}
// Log via Commons Logging?
if (this.overrideLogging) {
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new CommonsLogLogChute());
}
// Apply properties to VelocityEngine.
for (Map.Entry<String, Object> entry : props.entrySet()) {
velocityEngine.setProperty(entry.getKey(), entry.getValue());
}
postProcessVelocityEngine(velocityEngine);
// Perform actual initialization.
velocityEngine.init();
return velocityEngine;
} | java | {
"resource": ""
} |
q13670 | MockArtifactStore.set | train | private synchronized void set( Artifact artifact, Content content )
{
Map<String, Map<String, Map<Artifact, Content>>> artifactMap = contents.get( artifact.getGroupId() );
if ( artifactMap == null )
{
artifactMap = new HashMap<String, Map<String, Map<Artifact, Content>>>();
contents.put( artifact.getGroupId(), artifactMap );
}
Map<String, Map<Artifact, Content>> versionMap = artifactMap.get( artifact.getArtifactId() );
if ( versionMap == null )
{
versionMap = new HashMap<String, Map<Artifact, Content>>();
artifactMap.put( artifact.getArtifactId(), versionMap );
}
Map<Artifact, Content> filesMap = versionMap.get( artifact.getVersion() );
if ( filesMap == null )
{
filesMap = new HashMap<Artifact, Content>();
versionMap.put( artifact.getVersion(), filesMap );
}
filesMap.put( artifact, content );
} | java | {
"resource": ""
} |
q13671 | BeanId.create | train | public static BeanId create(final String instanceId, final String schemaName) {
if (instanceId == null || "".equals(instanceId)) {
throw CFG107_MISSING_ID();
}
return new BeanId(instanceId, schemaName);
} | java | {
"resource": ""
} |
q13672 | HBeanPredecessors.isPredecessor | train | public static boolean isPredecessor(KeyValue kv) {
if (Bytes.equals(kv.getFamily(), PRED_COLUMN_FAMILY)) {
return true;
}
return false;
} | java | {
"resource": ""
} |
q13673 | HOTPProviderUtils.instantiateProvider | train | public static HOTPProvider instantiateProvider(boolean allowTestProvider) {
HOTPProvider resultProvider = null;
ServiceLoader<HOTPProvider> loader = ServiceLoader.load(HOTPProvider.class);
Iterator<HOTPProvider> iterator = loader.iterator();
if (iterator.hasNext()) {
while (iterator.hasNext()) {
HOTPProvider provider = iterator.next();
if (!"com.payneteasy.superfly.spring.TestHOTPProvider".equals(provider.getClass().getName())
|| allowTestProvider) {
resultProvider = provider;
break;
}
}
}
return resultProvider;
} | java | {
"resource": ""
} |
q13674 | Lookup.get | train | public static Lookup get() {
if (LOOKUP != null) {
return LOOKUP;
}
synchronized (Lookup.class) {
// allow for override of the Lookup.class
String overrideClassName = System.getProperty(Lookup.class.getName());
ClassLoader l = Thread.currentThread().getContextClassLoader();
try {
if (overrideClassName != null && !"".equals(overrideClassName)) {
LOOKUP = (Lookup) Class.forName(overrideClassName, true, l).newInstance();
} else {
LOOKUP = new Lookup();
}
} catch (Exception e) {
// ignore
}
// ServiceLoader and CDI are used by defaults, important that
// CDI is used first so that beans are enabled for injection
CdiLookup cdiLookup = new CdiLookup();
LOOKUP.lookupProviders.add(cdiLookup);
ServiceLoaderLookup serviceLoaderLookup = new ServiceLoaderLookup();
LOOKUP.lookupProviders.add(serviceLoaderLookup);
// Use ServiceLoader to find other LookupProviders
Collection<LookupProvider> providers = serviceLoaderLookup
.lookupAll(LookupProvider.class);
LOOKUP.lookupProviders.addAll(providers);
}
return LOOKUP;
} | java | {
"resource": ""
} |
q13675 | FileSystemServlet.formatName | train | private static String formatName( String name )
{
if ( name.length() < NAME_COL_WIDTH )
{
return name;
}
return name.substring( 0, NAME_COL_WIDTH - 1 ) + ">";
} | java | {
"resource": ""
} |
q13676 | ConfigProxyGenerator.instrument | train | private void instrument(CtClass proxy, final SchemaPropertyRef ref) throws Exception {
final Schema schema = schemas.get(ref.getSchemaName());
checkNotNull(schema, "Schema not found for SchemaPropertyRef ["+ref+"]");
final String fieldName = ref.getFieldName();
// for help on javassist syntax, see chapter around javassist.expr.FieldAccess at
// http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/tutorial/tutorial2.html#before
proxy.instrument(new ExprEditor() {
public void edit(FieldAccess f) throws CannotCompileException {
if (f.getFieldName().equals(ref.getFieldName())) {
StringBuilder code = new StringBuilder();
code.append("{");
code.append("$_=("+schema.getType()+") this."+PROXY_FIELD_NAME+".getObjectReference(\""+fieldName+"\", \""+schema.getName()+"\");");
code.append("}");
f.replace(code.toString());
}
}
});
} | java | {
"resource": ""
} |
q13677 | BytesUtils.remove | train | public static byte[] remove(byte[] arr, int n) {
int index = binarySearch(arr, n);
byte[] arr2 = new byte[arr.length - 4];
System.arraycopy(arr, 0, arr2, 0, index);
System.arraycopy(arr, index + 4, arr2, index, arr.length - index - 4);
return arr2;
} | java | {
"resource": ""
} |
q13678 | BytesUtils.binarySearch | train | public static int binarySearch(byte[] a, int key) {
int low = 0;
int high = a.length;
while (low < high) {
int mid = (low + high) >>> 1;
if (mid % 4 != 0) {
if (high == a.length) {
mid = low;
} else {
mid = high;
}
}
int midVal = getInt(a, mid);
if (midVal < key)
low = mid + 4;
else if (midVal > key)
high = mid - 4;
else
return mid; // key found
}
if (low == a.length) {
return low;
}
return key > getInt(a, low) ? low + 4 : low;
} | java | {
"resource": ""
} |
q13679 | AbstractStartMojo.createFileSystemServer | train | protected FileSystemServer createFileSystemServer( ArtifactStore artifactStore )
{
return new FileSystemServer( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ),
Math.max( 0, Math.min( port, 65535 ) ),
new AutoDigestFileSystem( new ArtifactStoreFileSystem( artifactStore ) ),
getSettingsServletPath() );
} | java | {
"resource": ""
} |
q13680 | JpaProperty.deleteProperties | train | public static void deleteProperties(BeanId id) {
Query query = getEmOrFail().createNamedQuery(DELETE_ALL_PROPERTIES_FOR_BEANID_NAME);
query.setParameter(1, id.getInstanceId());
query.setParameter(2, id.getSchemaName());
query.setParameter(3, BEAN_MARKER_PROPERTY_NAME);
query.executeUpdate();
} | java | {
"resource": ""
} |
q13681 | JpaProperty.deletePropertiesAndMarker | train | public static void deletePropertiesAndMarker(BeanId id) {
Query query = getEmOrFail().createNamedQuery(DELETE_ALL_PROPERTIES_FOR_BEANID_NAME);
query.setParameter(1, id.getInstanceId());
query.setParameter(2, id.getSchemaName());
// empty will marker will delete the marker aswell
query.setParameter(3, "");
query.executeUpdate();
} | java | {
"resource": ""
} |
q13682 | JpaProperty.filterMarkerProperty | train | public static void filterMarkerProperty(List<JpaProperty> properties) {
ListIterator<JpaProperty> propIt = properties.listIterator();
while (propIt.hasNext()) {
if (BEAN_MARKER_PROPERTY_NAME.equals(propIt.next().getPropertyName())) {
propIt.remove();
}
}
} | java | {
"resource": ""
} |
q13683 | BeanQueryBuilder.between | train | public static <A extends Comparable<A>> BeanRestriction between(String property, A lower, A upper) {
return new Between<>(property, lower, upper);
} | java | {
"resource": ""
} |
q13684 | NotificationManager.fireCreate | train | public final void fireCreate(Collection<Bean> beans) {
ConfigChanges changes = new ConfigChanges();
for (Bean bean : beans) {
changes.add(ConfigChange.created(bean));
}
fire(changes);
} | java | {
"resource": ""
} |
q13685 | NotificationManager.deleted | train | public final ConfigChanges deleted(String schemaName, Collection<String> instanceIds) {
ConfigChanges changes = new ConfigChanges();
for (String instanceId : instanceIds) {
BeanId id = BeanId.create(instanceId, schemaName);
Optional<Bean> before = beanManager.getEager(id);
if (!before.isPresent()) {
throw Events.CFG304_BEAN_DOESNT_EXIST(id);
}
Bean bean = before.get();
schemaManager.setSchema(Arrays.asList(bean));
changes.add(ConfigChange.deleted(bean));
}
return changes;
} | java | {
"resource": ""
} |
q13686 | NotificationManager.fireDelete | train | public final void fireDelete(List<Bean> beans) {
ConfigChanges changes = new ConfigChanges();
for (Bean bean : beans) {
changes.add(ConfigChange.deleted(bean));
}
fire(changes);
} | java | {
"resource": ""
} |
q13687 | NotificationManager.updated | train | public final ConfigChanges updated(Collection<Bean> after) {
ConfigChanges changes = new ConfigChanges();
for (Bean bean : after) {
Optional<Bean> optional = beanManager.getEager(bean.getId());
if (!optional.isPresent()) {
throw Events.CFG304_BEAN_DOESNT_EXIST(bean.getId());
}
Bean before = optional.get();
schemaManager.setSchema(Arrays.asList(before));
changes.add(ConfigChange.updated(before, bean));
}
return changes;
} | java | {
"resource": ""
} |
q13688 | Parser.parsePathExpression | train | private static Path parsePathExpression(Iterator<Token> expression,
ConfigOrigin origin, String originalText) {
// each builder in "buf" is an element in the path.
List<Element> buf = new ArrayList<Element>();
buf.add(new Element("", false));
if (!expression.hasNext()) {
throw new ConfigException.BadPath(origin, originalText,
"Expecting a field name or path here, but got nothing");
}
while (expression.hasNext()) {
Token t = expression.next();
if (Tokens.isValueWithType(t, ConfigValueType.STRING)) {
AbstractConfigValue v = Tokens.getValue(t);
// this is a quoted string; so any periods
// in here don't count as path separators
String s = v.transformToString();
addPathText(buf, true, s);
} else if (t == Tokens.END) {
// ignore this; when parsing a file, it should not happen
// since we're parsing a token list rather than the main
// token iterator, and when parsing a path expression from the
// API, it's expected to have an END.
} else {
// any periods outside of a quoted string count as
// separators
String text;
if (Tokens.isValue(t)) {
// appending a number here may add
// a period, but we _do_ count those as path
// separators, because we basically want
// "foo 3.0bar" to parse as a string even
// though there's a number in it. The fact that
// we tokenize non-string values is largely an
// implementation detail.
AbstractConfigValue v = Tokens.getValue(t);
text = v.transformToString();
} else if (Tokens.isUnquotedText(t)) {
text = Tokens.getUnquotedText(t);
} else {
throw new ConfigException.BadPath(
origin,
originalText,
"Token not allowed in path expression: "
+ t
+ " (you can double-quote this token if you really want it here)");
}
addPathText(buf, false, text);
}
}
PathBuilder pb = new PathBuilder();
for (Element e : buf) {
if (e.sb.length() == 0 && !e.canBeEmpty) {
throw new ConfigException.BadPath(
origin,
originalText,
"path has a leading, trailing, or two adjacent period '.' (use quoted \"\" empty string if you want an empty element)");
} else {
pb.appendKey(e.sb.toString());
}
}
return pb.result();
} | java | {
"resource": ""
} |
q13689 | Parser.hasUnsafeChars | train | private static boolean hasUnsafeChars(String s) {
for (int i = 0; i < s.length(); ++i) {
char c = s.charAt(i);
if (Character.isLetter(c) || c == '.')
continue;
else
return true;
}
return false;
} | java | {
"resource": ""
} |
q13690 | Bytes.setShort | train | public static void setShort(final byte[] b, final short n, final int offset) {
b[offset + 0] = (byte) (n >>> 8);
b[offset + 1] = (byte) (n >>> 0);
} | java | {
"resource": ""
} |
q13691 | Bytes.setInt | train | public static void setInt(final byte[] b, final int n, final int offset) {
b[offset + 0] = (byte) (n >>> 24);
b[offset + 1] = (byte) (n >>> 16);
b[offset + 2] = (byte) (n >>> 8);
b[offset + 3] = (byte) (n >>> 0);
} | java | {
"resource": ""
} |
q13692 | Bytes.setLong | train | public static void setLong(final byte[] b, final long n, final int offset) {
b[offset + 0] = (byte) (n >>> 56);
b[offset + 1] = (byte) (n >>> 48);
b[offset + 2] = (byte) (n >>> 40);
b[offset + 3] = (byte) (n >>> 32);
b[offset + 4] = (byte) (n >>> 24);
b[offset + 5] = (byte) (n >>> 16);
b[offset + 6] = (byte) (n >>> 8);
b[offset + 7] = (byte) (n >>> 0);
} | java | {
"resource": ""
} |
q13693 | HBeanRowCollector.filterUnvisted | train | public Set<HBeanRow> filterUnvisted(Set<HBeanRow> rows) {
Set<HBeanRow> unvisted = new HashSet<>();
for (HBeanRow row : rows) {
if (!references.containsKey(row) && !inital.containsKey(row)) {
unvisted.add(row);
}
}
return unvisted;
} | java | {
"resource": ""
} |
q13694 | HBeanRowCollector.getBeans | train | public List<Bean> getBeans() {
Map<BeanId, Bean> referenceMap = new HashMap<>();
List<Bean> result = new ArrayList<>();
for (HBeanRow row : inital.keySet()) {
Bean bean = row.getBean();
result.add(bean);
referenceMap.put(bean.getId(), bean);
}
for (HBeanRow row : references.keySet()) {
Bean bean = row.getBean();
referenceMap.put(bean.getId(), bean);
}
for (Bean bean : referenceMap.values()) {
for (BeanId id : bean.getReferences()) {
Bean ref = referenceMap.get(id);
id.setBean(ref);
}
}
return result;
} | java | {
"resource": ""
} |
q13695 | PGPKeyValidator.validatePublicKey | train | public static void validatePublicKey(String value, PublicKeyCrypto crypto) throws BadPublicKeyException {
if (org.springframework.util.StringUtils.hasText(value)) {
int open = value.indexOf("-----BEGIN PGP PUBLIC KEY BLOCK-----");
int close = value.indexOf("-----END PGP PUBLIC KEY BLOCK-----");
if (open < 0) {
throw new BadPublicKeyException("PublicKeyValidator.noBeginBlock");
}
if (close < 0) {
throw new BadPublicKeyException("PublicKeyValidator.noEndBlock");
}
if (open >= 0 && close >= 0 &&open >= close) {
throw new BadPublicKeyException("PublicKeyValidator.wrongBlockOrder");
}
if (!crypto.isPublicKeyValid(value)) {
throw new BadPublicKeyException("PublicKeyValidator.invalidKey");
}
}
} | java | {
"resource": ""
} |
q13696 | YamlBeanManager.hasReferences | train | private static boolean hasReferences(Bean target, BeanId reference) {
for (String name : target.getReferenceNames()) {
for (BeanId ref : target.getReference(name)) {
if (ref.equals(reference)) {
return true;
}
}
}
return false;
} | java | {
"resource": ""
} |
q13697 | HBeanRow.getId | train | public static long getId(final byte[] rowkey) {
return (rowkey[0] & 0xFFL) << 40 | (rowkey[1] & 0xFFL) << 32 | (rowkey[2] & 0xFFL) << 24
| (rowkey[3] & 0xFFL) << 16 | (rowkey[4] & 0xFFL) << 8 | (rowkey[5] & 0xFFL) << 0;
} | java | {
"resource": ""
} |
q13698 | HBeanRow.getRowKey | train | private static byte[] getRowKey(long id) {
final byte[] b = new byte[6];
b[0] = (byte) (id >>> 40);
b[1] = (byte) (id >>> 32);
b[2] = (byte) (id >>> 24);
b[3] = (byte) (id >>> 16);
b[4] = (byte) (id >>> 8);
b[5] = (byte) (id >>> 0);
return b;
} | java | {
"resource": ""
} |
q13699 | HBeanRow.getRowKey | train | public static byte[] getRowKey(final BeanId id, final UniqueIds uids) {
final byte[] iid = uids.getUiid().getId(id.getInstanceId());
final byte[] sid = uids.getUsid().getId(id.getSchemaName());
final byte[] rowkey = new byte[sid.length + iid.length];
System.arraycopy(sid, 0, rowkey, 0, sid.length);
System.arraycopy(iid, 0, rowkey, sid.length, iid.length);
return rowkey;
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.