_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q168400 | JavaWriter.beginInitializer | validation | public JavaWriter beginInitializer(boolean isStatic) throws IOException {
indent();
if (isStatic) {
out.write("static");
out.write(" {\n");
} else {
out.write("{\n");
}
scopes.push(Scope.INITIALIZER);
return this;
} | java | {
"resource": ""
} |
q168401 | JavaWriter.endType | validation | public JavaWriter endType() throws IOException {
popScope(Scope.TYPE_DECLARATION, Scope.INTERFACE_DECLARATION);
types.pop();
indent();
out.write("}\n");
return this;
} | java | {
"resource": ""
} |
q168402 | JavaWriter.emitSingleLineComment | validation | public JavaWriter emitSingleLineComment(String comment, Object... args) throws IOException {
indent();
out.write("// ");
out.write(String.format(comment, args));
out.write("\n");
return this;
} | java | {
"resource": ""
} |
q168403 | JavaWriter.emitAnnotationValue | validation | private JavaWriter emitAnnotationValue(Object value) throws IOException {
if (value instanceof Object[]) {
out.write("{");
boolean firstValue = true;
scopes.push(Scope.ANNOTATION_ARRAY_VALUE);
for (Object o : ((Object[]) value)) {
if (firstValue) {
firstValue = false;
out.write("\n");
} else {
out.write(",\n");
}
indent();
out.write(o.toString());
}
popScope(Scope.ANNOTATION_ARRAY_VALUE);
out.write("\n");
indent();
out.write("}");
} else {
out.write(value.toString());
}
return this;
} | java | {
"resource": ""
} |
q168404 | JavaWriter.endMethod | validation | public JavaWriter endMethod() throws IOException {
Scope popped = scopes.pop();
// support calling a constructor a "method" to support the legacy code
if (popped == Scope.NON_ABSTRACT_METHOD || popped == Scope.CONSTRUCTOR) {
indent();
out.write("}\n");
} else if (popped != Scope.ABSTRACT_METHOD) {
throw new IllegalStateException();
}
return this;
} | java | {
"resource": ""
} |
q168405 | JavaWriter.type | validation | public static String type(Class<?> raw, String... parameters) {
if (parameters.length == 0) {
return raw.getCanonicalName();
}
if (raw.getTypeParameters().length != parameters.length) {
throw new IllegalArgumentException();
}
StringBuilder result = new StringBuilder();
result.append(raw.getCanonicalName());
result.append("<");
result.append(parameters[0]);
for (int i = 1; i < parameters.length; i++) {
result.append(", ");
result.append(parameters[i]);
}
result.append(">");
return result.toString();
} | java | {
"resource": ""
} |
q168406 | JavaWriter.emitModifiers | validation | private void emitModifiers(Set<Modifier> modifiers) throws IOException {
if (modifiers.isEmpty()) {
return;
}
// Use an EnumSet to ensure the proper ordering
if (!(modifiers instanceof EnumSet)) {
modifiers = EnumSet.copyOf(modifiers);
}
for (Modifier modifier : modifiers) {
out.append(modifier.toString()).append(' ');
}
} | java | {
"resource": ""
} |
q168407 | ParcelablePleaseAction.getPsiClassFromContext | validation | private PsiClass getPsiClassFromContext(AnActionEvent e) {
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
Editor editor = e.getData(PlatformDataKeys.EDITOR);
if (psiFile == null || editor == null) {
return null;
}
int offset = editor.getCaretModel().getOffset();
PsiElement element = psiFile.findElementAt(offset);
return PsiTreeUtil.getParentOfType(element, PsiClass.class);
} | java | {
"resource": ""
} |
q168408 | CodeGenerator.findAndRemoveMethod | validation | private void findAndRemoveMethod(String methodName, String... arguments) {
// Maybe there's an easier way to do this with mClass.findMethodBySignature(), but I'm not an expert on Psi*
PsiMethod[] methods = psiClass.findMethodsByName(methodName, false);
for (PsiMethod method : methods) {
PsiParameterList parameterList = method.getParameterList();
if (parameterList.getParametersCount() == arguments.length) {
boolean shouldDelete = true;
PsiParameter[] parameters = parameterList.getParameters();
for (int i = 0; i < arguments.length; i++) {
if (!parameters[i].getType().getCanonicalText().equals(arguments[i])) {
shouldDelete = false;
}
}
if (shouldDelete) {
method.delete();
}
}
}
} | java | {
"resource": ""
} |
q168409 | CodeGenerator.generate | validation | public void generate() {
PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(psiClass.getProject());
JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(psiClass.getProject());
// Clear any previous
clearPrevious();
// Implements parcelable
makeClassImplementParcelable(elementFactory, styleManager);
// @ParcelablePlease Annotation
addAnnotation(elementFactory, styleManager);
// Creator
PsiField creatorField = elementFactory.createFieldFromText(generateCreator(), psiClass);
// Describe contents method
PsiMethod describeContentsMethod =
elementFactory.createMethodFromText(generateDescribeContents(), psiClass);
// Method for writing to the parcel
PsiMethod writeToParcelMethod =
elementFactory.createMethodFromText(generateWriteToParcel(), psiClass);
styleManager.shortenClassReferences(
psiClass.addBefore(describeContentsMethod, psiClass.getLastChild()));
styleManager.shortenClassReferences(
psiClass.addBefore(writeToParcelMethod, psiClass.getLastChild()));
styleManager.shortenClassReferences(psiClass.addBefore(creatorField, psiClass.getLastChild()));
} | java | {
"resource": ""
} |
q168410 | CodeGenerator.makeClassImplementParcelable | validation | private void makeClassImplementParcelable(PsiElementFactory elementFactory, JavaCodeStyleManager styleManager) {
final PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes();
final String implementsType = "android.os.Parcelable";
for (PsiClassType implementsListType : implementsListTypes) {
PsiClass resolved = implementsListType.resolve();
// Already implements Parcelable, no need to add it
if (resolved != null && implementsType.equals(resolved.getQualifiedName())) {
return;
}
}
PsiJavaCodeReferenceElement implementsReference =
elementFactory.createReferenceFromText(implementsType, psiClass);
PsiReferenceList implementsList = psiClass.getImplementsList();
if (implementsList != null) {
styleManager.shortenClassReferences(implementsList.add(implementsReference));
}
} | java | {
"resource": ""
} |
q168411 | ParcelablePleaseProcessor.isClass | validation | private boolean isClass(Element element) {
if (element.getKind() == ElementKind.CLASS) {
if (element.getModifiers().contains(Modifier.ABSTRACT)) {
ProcessorMessage.error(element,
"Element %s is annotated with @%s but is an abstract class. "
+ "Abstract classes can not be annotated. Annotate the concrete class "
+ "that implements all abstract methods with @%s", element.getSimpleName(),
ParcelablePlease.class.getSimpleName(), ParcelablePlease.class.getSimpleName());
return false;
}
if (element.getModifiers().contains(Modifier.PRIVATE)) {
ProcessorMessage.error(element, "The private class %s is annotated with @%s. "
+ "Private classes are not supported because of lacking visibility.",
element.getSimpleName(), ParcelablePlease.class.getSimpleName());
return false;
}
// Ok, its a valid class
return true;
} else {
ProcessorMessage.error(element,
"Element %s is annotated with @%s but is not a class. Only Classes are supported",
element.getSimpleName(), ParcelablePlease.class.getSimpleName());
return false;
}
} | java | {
"resource": ""
} |
q168412 | TypeUtils.isTypeOf | validation | public static boolean isTypeOf(TypeMirror type, Class<?> clazz) {
return type.toString().equals(clazz.getCanonicalName());
} | java | {
"resource": ""
} |
q168413 | TypeUtils.isTypeOf | validation | public static Class<?> isTypeOf(TypeMirror type, List<Class<?>> classList) {
for (Class<?> c : classList) {
if (isTypeOf(type, c)) {
return c;
}
}
return null;
} | java | {
"resource": ""
} |
q168414 | TypeUtils.getPackageName | validation | public static String getPackageName(Elements elementUtils, TypeElement type) throws IOException {
PackageElement pkg = elementUtils.getPackageOf(type);
if (!pkg.isUnnamed()) {
return pkg.getQualifiedName().toString();
} else {
return ""; // Default package
}
} | java | {
"resource": ""
} |
q168415 | TypeUtils.getBinaryName | validation | public static String getBinaryName(Elements elementUtils, TypeElement type) throws IOException {
String packageName = getPackageName(elementUtils, type);
String qualifiedName = type.getQualifiedName().toString();
if (packageName.length() > 0) {
return packageName + '.' + qualifiedName.substring(packageName.length() + 1).replace('.', '$');
} else {
return qualifiedName.replace('.', '$');
}
} | java | {
"resource": ""
} |
q168416 | CodeGenerator.generateWriteToParcel | validation | private void generateWriteToParcel(JavaWriter jw, String originClass,
List<ParcelableField> fields) throws IOException {
jw.beginMethod("void", "writeToParcel", EnumSet.of(Modifier.PUBLIC, Modifier.STATIC),
originClass, PARAM_SOURCE, "Parcel", PARAM_PARCEL, "int", PARAM_FLAGS);
for (ParcelableField field : fields) {
FieldCodeGen gen = field.getCodeGenerator();
if (gen == null) { // Already checked before, but let's check it again
ProcessorMessage.error(field.getElement(),
"The field %s is not Parcelable or of unsupported type. Use a @%s",
field.getFieldName(),
Bagger.class.getSimpleName() + " to provide your own serialisation mechanism");
throw new IOException("Unparcelable Field " + field.getFieldName());
}
jw.emitEmptyLine();
gen.generateWriteToParcel(field, jw);
}
jw.endMethod();
} | java | {
"resource": ""
} |
q168417 | ParcelableField.isPublicClass | validation | private boolean isPublicClass(DeclaredType type) {
Element element = type.asElement();
return element.getModifiers().contains(javax.lang.model.element.Modifier.PUBLIC);
} | java | {
"resource": ""
} |
q168418 | ParcelableField.hasPublicEmptyConstructor | validation | private boolean hasPublicEmptyConstructor(DeclaredType type) {
Element element = type.asElement();
List<? extends Element> containing = element.getEnclosedElements();
for (Element e : containing) {
if (e.getKind() == ElementKind.CONSTRUCTOR) {
ExecutableElement c = (ExecutableElement) e;
if ((c.getParameters() == null || c.getParameters().isEmpty()) && c.getModifiers()
.contains(javax.lang.model.element.Modifier.PUBLIC)) {
return true;
}
}
}
return false;
} | java | {
"resource": ""
} |
q168419 | Determinants.determinant3x3 | validation | public static double determinant3x3(
final double r0c0,
final double r0c1,
final double r0c2,
final double r1c0,
final double r1c1,
final double r1c2,
final double r2c0,
final double r2c1,
final double r2c2)
{
double sum = 0.0;
sum += r0c0 * ((r1c1 * r2c2) - (r1c2 * r2c1));
sum -= r0c1 * ((r1c0 * r2c2) - (r1c2 * r2c0));
sum += r0c2 * ((r1c0 * r2c1) - (r1c1 * r2c0));
return sum;
} | java | {
"resource": ""
} |
q168420 | Hunter.findBy | validation | public R findBy(ClassFileScanConfiguration scanConfig, SearchCriteria criteria) {
scanConfig = scanConfig.createCopy();
criteria = criteria.createCopy();
C context = createContext(scanConfig, criteria);
criteria.init(this.classHelper, context.pathMemoryClassLoader, this.memberFinder, this.pathHelper);
scanConfig.init();
fileSystemHelper.scan(
scanConfig.toScanConfiguration(context, this)
);
Collection<String> skippedClassesNames = context.getSkippedClassNames();
if (!skippedClassesNames.isEmpty()) {
logWarn("Skipped classes count: {}", skippedClassesNames.size());
}
return resultSupplier.apply(context);
} | java | {
"resource": ""
} |
q168421 | Matrix4x4DGenerator.createOrthogonal | validation | public static Generator<Matrix4x4D> createOrthogonal()
{
return () -> {
final SecureRandom rng = new SecureRandom();
final double r0c0 = 1.0;
final double r0c1 = 0.0;
final double r0c2 = 0.0;
final double r0c3 = rng.nextDouble();
final double r1c0 = 0.0;
final double r1c1 = 1.0;
final double r1c2 = 0.0;
final double r1c3 = rng.nextDouble();
final double r2c0 = 0.0;
final double r2c1 = 0.0;
final double r2c2 = 1.0;
final double r2c3 = rng.nextDouble();
final double r3c0 = 0.0;
final double r3c1 = 0.0;
final double r3c2 = 0.0;
final double r3c3 = 1.0;
return Matrix4x4D.of(
r0c0, r0c1, r0c2, r0c3,
r1c0, r1c1, r1c2, r1c3,
r2c0, r2c1, r2c2, r2c3,
r3c0, r3c1, r3c2, r3c3);
};
} | java | {
"resource": ""
} |
q168422 | RedisConnectionAsync.getBinaryMultiBulkReply | validation | @SuppressWarnings("unchecked")
public static List<byte[]> getBinaryMultiBulkReply(byte[] input) {
return (List<byte[]>) RedisProtocol.read(
new RedisInputStream(new ByteArrayInputStream(input)));
} | java | {
"resource": ""
} |
q168423 | BinaryRedisCluster.getBinaryTupledSet | validation | private Set<Tuple> getBinaryTupledSet() {
List<byte[]> membersWithScores = client.getBinaryMultiBulkReply();
Set<Tuple> set = new LinkedHashSet<Tuple>();
if (membersWithScores == null) {
return set;
}
Iterator<byte[]> iterator = membersWithScores.iterator();
if (iterator == null) {
return set;
}
while (iterator.hasNext()) {
set.add(new Tuple(iterator.next(), Double.valueOf(SafeEncoder.encode(iterator.next()))));
}
return set;
} | java | {
"resource": ""
} |
q168424 | AbstractOperations.rawKey | validation | @SuppressWarnings("unchecked")
byte[] rawKey(Object key) {
Assert.notNull(key, "non null key required");
return keySerializer().serialize(key);
} | java | {
"resource": ""
} |
q168425 | AbstractOperations.rawHashKey | validation | @SuppressWarnings("unchecked")
<HK> byte[] rawHashKey(HK hashKey) {
Assert.notNull(hashKey, "non null hash key required");
return hashKeySerializer().serialize(hashKey);
} | java | {
"resource": ""
} |
q168426 | AbstractOperations.deserializeTupleValues | validation | @SuppressWarnings("unchecked")
Set<TypedTuple<V>> deserializeTupleValues(Set<Tuple> rawValues) {
Set<TypedTuple<V>> set = new LinkedHashSet<TypedTuple<V>>(rawValues.size());
for (Tuple rawValue : rawValues) {
set.add(new DefaultTypedTuple(valueSerializer().deserialize(rawValue.getValue()), rawValue.getScore()));
}
return set;
} | java | {
"resource": ""
} |
q168427 | AbstractOperations.deserializeHashKeys | validation | @SuppressWarnings("unchecked")
<T> Set<T> deserializeHashKeys(Set<byte[]> rawKeys) {
return SerializationUtils.deserialize(rawKeys, hashKeySerializer());
} | java | {
"resource": ""
} |
q168428 | AbstractOperations.deserializeHashValues | validation | @SuppressWarnings("unchecked")
<T> List<T> deserializeHashValues(List<byte[]> rawValues) {
return SerializationUtils.deserialize(rawValues, hashValueSerializer());
} | java | {
"resource": ""
} |
q168429 | AbstractOperations.deserializeHashMap | validation | @SuppressWarnings("unchecked")
<HK, HV> Map<HK, HV> deserializeHashMap(Map<byte[], byte[]> entries) {
// connection in pipeline/multi mode
if (entries == null) {
return null;
}
Map<HK, HV> map = new LinkedHashMap<HK, HV>(entries.size());
for (Map.Entry<byte[], byte[]> entry : entries.entrySet()) {
map.put((HK) deserializeHashKey(entry.getKey()), (HV) deserializeHashValue(entry.getValue()));
}
return map;
} | java | {
"resource": ""
} |
q168430 | AbstractOperations.deserializeHashList | validation | <HK, HV> Map<HK, List<HV>> deserializeHashList(Map<byte[], List<byte[]>> entries) {
// connection in pipeline/multi mode
if (entries == null) {
return null;
}
Map<HK, List<HV>> map = new LinkedHashMap<HK, List<HV>>(entries.size());
for (Map.Entry<byte[], List<byte[]>> entry : entries.entrySet()) {
map.put((HK) deserializeHashKey(entry.getKey()), (List<HV>) deserializeHashValues(entry.getValue()));
}
return map;
} | java | {
"resource": ""
} |
q168431 | AbstractOperations.deserializeHashSet | validation | <HK, HV> Map<HK, Set<HV>> deserializeHashSet(Map<byte[], Set<byte[]>> entries) {
// connection in pipeline/multi mode
if (entries == null) {
return null;
}
Map<HK, Set<HV>> map = new LinkedHashMap<HK, Set<HV>>(entries.size());
for (Map.Entry<byte[], Set<byte[]>> entry : entries.entrySet()) {
map.put((HK) deserializeHashKey(entry.getKey()), (Set<HV>) deserializeValues(entry.getValue()));
}
return map;
} | java | {
"resource": ""
} |
q168432 | GatewayAddress.asListFromDomain | validation | public static List<GatewayAddress> asListFromDomain(final String domainAddress) {
if (domainAddress == null) {
throw new IllegalArgumentException("domain address must not be null");
}
GatewayAddress domain = new GatewayAddress(0, domainAddress);
InetAddress[] addresses;
try {
addresses = InetAddress.getAllByName(domain.getHost());
} catch (Exception e) {
throw new IllegalArgumentException("invalid domain '" + domain + "' " + e.getMessage());
}
List<GatewayAddress> list = new ArrayList<GatewayAddress>();
int id = 1;
for (InetAddress address : addresses) {
list.add(new GatewayAddress(id++, address.getHostAddress(), domain.getPort()));
}
return list;
} | java | {
"resource": ""
} |
q168433 | GatewayAddress.parseHost | validation | public static String parseHost(final String address) {
int ep = address.indexOf(":");
if (ep == -1 || ep == 0) {
throw new IllegalArgumentException("invalid address '" + address + "'");
}
return address.substring(0, ep).trim();
} | java | {
"resource": ""
} |
q168434 | GatewayAddress.parsePort | validation | public static int parsePort(final String address) {
int sp = address.indexOf(":");
if (sp == -1 && sp + 1 >= address.length()) {
throw new IllegalArgumentException("not found port '" + address + "'");
}
try {
return Integer.parseInt(address.substring(sp + 1, address.length()).trim());
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("bad port number '" + address + "'");
}
} | java | {
"resource": ""
} |
q168435 | RedisClusterClient.set | validation | public void set(final String key, final String value) {
set(SafeEncoder.encode(key), SafeEncoder.encode(value));
} | java | {
"resource": ""
} |
q168436 | RedisClusterPipeline.sync | validation | public void sync() {
if (this.client == null) {
return;
}
List<Object> unformatted = null;
try {
unformatted = this.client.getAll();
} catch (Exception e) {
this.brokenResource = true;
throw new GatewayException("gateway=" + this.server + ", connect=" + this.redis.connectInfo(), e);
}
if (unformatted == null) {
return;
}
for (Object o : unformatted) {
try {
generateResponse(o);
} catch (Exception ignored) {
}
}
} | java | {
"resource": ""
} |
q168437 | RedisCluster.getTupledSet | validation | private Set<Tuple> getTupledSet() {
List<String> membersWithScores = client.getMultiBulkReply();
Set<Tuple> set = new LinkedHashSet<Tuple>();
Iterator<String> iterator = membersWithScores.iterator();
while (iterator.hasNext()) {
set.add(new Tuple(iterator.next(), Double.valueOf(iterator.next())));
}
return set;
} | java | {
"resource": ""
} |
q168438 | LeaderElectionSupport.stop | validation | public synchronized void stop() {
state = State.STOP;
dispatchEvent(LeaderElectionEventType.STOP_START);
logger.info("Stopping leader election support");
if (leaderOffer != null) {
try {
zooKeeper.delete(leaderOffer.getNodePath(), -1);
logger.info("Removed leader offer {}",
leaderOffer.getNodePath());
} catch (InterruptedException e) {
becomeFailed(e);
} catch (KeeperException e) {
becomeFailed(e);
}
}
dispatchEvent(LeaderElectionEventType.STOP_COMPLETE);
} | java | {
"resource": ""
} |
q168439 | GatewayClient.toExecuteInfo | validation | String toExecuteInfo(final int tryCount, final long startedTime, final GatewayServer server,
final RedisCluster redis) {
final StringBuilder sb = new StringBuilder();
final long executedTime = System.currentTimeMillis() - startedTime;
sb.append("time=").append(executedTime).append(", ");
sb.append("retry=").append(tryCount).append(", ");
sb.append("gateway=").append(server);
if (redis != null) {
sb.append(", ").append("connect=").append(redis.connectInfo());
}
return sb.toString();
} | java | {
"resource": ""
} |
q168440 | MGSetquorum.setquorum | validation | public void setquorum(PartitionGroupServer master, int q,
String quorumMembers) throws MgmtSetquorumException,
MgmtSmrCommandException {
master.setQuorum(q, quorumMembers);
} | java | {
"resource": ""
} |
q168441 | ThreadLocalVariableHolder.checkPermission | validation | public static void checkPermission(String path, LockType type) throws MgmtZooKeeperException {
if (znodePermission.get() != null) {
znodePermission.get().checkPermission(path, type);
}
} | java | {
"resource": ""
} |
q168442 | BinaryRedisClusterClient.joinParameters | validation | private byte[][] joinParameters(byte[] first, byte[][] rest) {
byte[][] result = new byte[rest.length + 1][];
result[0] = first;
for (int i = 0; i < rest.length; i++) {
result[i + 1] = rest[i];
}
return result;
} | java | {
"resource": ""
} |
q168443 | BinaryRedisClusterClient.expireAt | validation | public void expireAt(final byte[] key, final long millisecondsTimestamp) {
sendCommand(Command.EXPIREAT, key, RedisProtocol.toByteArray(millisecondsTimestamp));
} | java | {
"resource": ""
} |
q168444 | BinaryRedisClusterClient.decrBy | validation | public void decrBy(final byte[] key, final long integer) {
sendCommand(Command.DECRBY, key, RedisProtocol.toByteArray(integer));
} | java | {
"resource": ""
} |
q168445 | BinaryRedisClusterClient.incrBy | validation | public void incrBy(final byte[] key, final long integer) {
sendCommand(Command.INCRBY, key, RedisProtocol.toByteArray(integer));
} | java | {
"resource": ""
} |
q168446 | BinaryRedisClusterClient.zaddBinary | validation | public void zaddBinary(final byte[] key, Map<Double, byte[]> scoreMembers) {
ArrayList<byte[]> args = new ArrayList<byte[]>(scoreMembers.size() * 2 + 1);
args.add(key);
for (Map.Entry<Double, byte[]> entry : scoreMembers.entrySet()) {
args.add(RedisProtocol.toByteArray(entry.getKey()));
args.add(entry.getValue());
}
byte[][] argsArray = new byte[args.size()][];
args.toArray(argsArray);
sendCommand(Command.ZADD, argsArray);
} | java | {
"resource": ""
} |
q168447 | BinaryRedisClusterClient.zrangeByScore | validation | public void zrangeByScore(final byte[] key, final byte[] min, final byte[] max) {
sendCommand(Command.ZRANGEBYSCORE, key, min, max);
} | java | {
"resource": ""
} |
q168448 | BinaryRedisClusterClient.zrangeByScoreWithScores | validation | public void zrangeByScoreWithScores(final byte[] key, final byte[] min, final byte[] max, final int offset,
final int count) {
sendCommand(Command.ZRANGEBYSCORE, key, min, max, Keyword.LIMIT.raw, RedisProtocol.toByteArray(offset), RedisProtocol.toByteArray(count), Keyword.WITHSCORES.raw);
} | java | {
"resource": ""
} |
q168449 | BinaryRedisClusterClient.slaveofNoOne | validation | public void slaveofNoOne() {
sendCommand(Command.SLAVEOF, Keyword.NO.raw, Keyword.ONE.raw);
} | java | {
"resource": ""
} |
q168450 | BinaryRedisClusterClient.configSet | validation | public void configSet(final byte[] parameter, final byte[] value) {
sendCommand(Command.CONFIG, Keyword.SET.raw, parameter, value);
} | java | {
"resource": ""
} |
q168451 | BinaryRedisClusterClient.getbit | validation | public void getbit(byte[] key, long offset) {
sendCommand(Command.GETBIT, key, RedisProtocol.toByteArray(offset));
} | java | {
"resource": ""
} |
q168452 | BinaryRedisClusterClient.getrange | validation | public void getrange(byte[] key, long startOffset, long endOffset) {
sendCommand(Command.GETRANGE, key, RedisProtocol.toByteArray(startOffset), RedisProtocol.toByteArray(endOffset));
} | java | {
"resource": ""
} |
q168453 | EventSelector.shutdown | validation | public void shutdown() throws IOException {
try {
selector.close();
} catch (IOException e) {
Logger.error("Close nio event selector fail.", e);
throw e;
}
} | java | {
"resource": ""
} |
q168454 | EventSelector.process | validation | public ElapsedTime process() {
try {
long start = System.currentTimeMillis();
ioProcess();
long ioDone = System.currentTimeMillis();
loopProcess();
long end = System.currentTimeMillis();
return new ElapsedTime(start, ioDone, end);
} catch (Exception e) {
Logger.error("-ERR error occurs in hbMain", e);
}
return null;
} | java | {
"resource": ""
} |
q168455 | EventSelector.ioProcess | validation | public void ioProcess()
{
int numberOfKeys;
try {
numberOfKeys = selector.select(selectTimeout);
} catch (IOException e) {
Logger.error("Selector.select error.", e);
return;
}
if (0 == numberOfKeys) {
return;
}
Iterator<SelectionKey> keyIter = selector.selectedKeys().iterator();
while (keyIter.hasNext())
{
SelectionKey key = keyIter.next();
Session session = (Session) key.attachment();
long timeMillis = System.currentTimeMillis();
try {
if (key.isValid() && key.isReadable()) {
long start = System.currentTimeMillis();
session.callbackRead(key, timeMillis);
long end = System.currentTimeMillis();
Statistics.updateNioRead(end - start);
}
if (key.isValid() && key.isWritable()) {
long start = System.currentTimeMillis();
session.callbackWrite(key, timeMillis);
long end = System.currentTimeMillis();
Statistics.updateNioWrite(end - start);
}
if (key.isValid() && key.isAcceptable()) {
session.callbackAccept(key, timeMillis);
}
if (key.isValid() && key.isConnectable()) {
session.callbackConnect(key, timeMillis);
}
} catch (CancelledKeyException e) {
Logger.warn("Closed connection {}", session, e);
} catch (ClosedChannelException e) {
Logger.warn("Closed connection {}", session, e);
} catch (IOException e) {
Logger.warn("Closed connection {}", session, e);
} catch (Exception e) {
Logger.error("Exception occurs on {}", session, e);
}
keyIter.remove();
}
} | java | {
"resource": ""
} |
q168456 | EventSelector.loopProcess | validation | public void loopProcess()
{
for (Session session : sessions.values())
{
long timeMillis = System.currentTimeMillis();
try {
session.callbackOnLoop(timeMillis);
} catch (Exception e) {
Logger.error("Exception occurs while callbackOnLoop on {}", session, e);
}
}
} | java | {
"resource": ""
} |
q168457 | EventSelector.register | validation | public void register(Session session, int ops) throws ClosedChannelException {
if (sessions.containsKey(session.getID())) {
throw new IllegalStateException("Altready registered session");
}
SelectionKey selKey;
try {
selKey = session.getChannel().register(selector, ops, session);
} catch (ClosedChannelException e) {
Logger.error("Error while register channel to selector. {}", session, e);
throw e;
}
session.setSelectionKey(selKey);
} | java | {
"resource": ""
} |
q168458 | JadlerMocker.addDefaultHeader | validation | public void addDefaultHeader(final String name, final String value) {
Validate.notEmpty(name, "header name cannot be empty");
Validate.notNull(value, "header value cannot be null, use an empty string instead");
this.checkConfigurable();
this.defaultHeaders.put(name, value);
} | java | {
"resource": ""
} |
q168459 | Verifying.receivedTimes | validation | public void receivedTimes(final Matcher<Integer> nrRequestsPredicate) {
Validate.notNull(nrRequestsPredicate, "predicate cannot be null");
this.requestManager.evaluateVerification(predicates, nrRequestsPredicate);
} | java | {
"resource": ""
} |
q168460 | KeyValues.getValue | validation | public String getValue(final String key) {
Validate.notEmpty(key, "key cannot be empty");
final List<String> allValues = this.getValues(key);
return allValues != null ? allValues.get(0) : null;
} | java | {
"resource": ""
} |
q168461 | KeyValues.getValues | validation | public List<String> getValues(final String key) {
Validate.notEmpty(key, "name cannot be empty");
@SuppressWarnings("unchecked")
final List<String> result = (List<String>) values.get(key.toLowerCase());
return result == null || result.isEmpty() ? null : new ArrayList<String>(result);
} | java | {
"resource": ""
} |
q168462 | RequestUtils.addEncoding | validation | static void addEncoding(final Request.Builder builder, final HttpExchange httpExchange) {
final String contentType = httpExchange.getRequestHeaders().getFirst("Content-Type");
if (contentType != null) {
final Matcher matcher = CHARSET_PATTERN.matcher(contentType);
if (matcher.matches()) {
try {
builder.encoding(Charset.forName(matcher.group(1)));
}
catch (UnsupportedCharsetException e) {
//just ignore, fallback encoding will be used instead
}
}
}
} | java | {
"resource": ""
} |
q168463 | StubbingFactory.createStubbing | validation | public Stubbing createStubbing(final Charset defaultEncoding, final int defaultStatus,
final MultiMap defaultHeaders) {
return new Stubbing(defaultEncoding, defaultStatus, defaultHeaders);
} | java | {
"resource": ""
} |
q168464 | JWTEncoder.encode | validation | public static String encode(JSONObject claims, String secret) {
String encodedHeader = getCommonHeader();
String encodedClaims = encodeJson(claims);
String secureBits = new StringBuilder(encodedHeader).append(TOKEN_SEP).append(encodedClaims).toString();
String sig = sign(secret, secureBits);
return new StringBuilder(secureBits).append(TOKEN_SEP).append(sig).toString();
} | java | {
"resource": ""
} |
q168465 | TokenOptions.copyDate | validation | private Date copyDate(Date date) {
return (date != null) ? new Date(date.getTime()) : null;
} | java | {
"resource": ""
} |
q168466 | TokenGenerator.createToken | validation | public String createToken(Map<String, Object> data, TokenOptions options) {
if ((data == null || data.size() == 0) && (options == null || (!options.isAdmin() && !options.isDebug()))) {
throw new IllegalArgumentException("TokenGenerator.createToken: data is empty and no options are set. This token will have no effect on Firebase.");
}
JSONObject claims = new JSONObject();
try {
claims.put("v", TOKEN_VERSION);
claims.put("iat", new Date().getTime() / 1000);
boolean isAdminToken = (options != null && options.isAdmin());
validateToken("TokenGenerator.createToken", data, isAdminToken);
if (data != null && data.size() > 0) {
claims.put("d", new JSONObject(data));
}
// Handle options
if (options != null) {
if (options.getExpires() != null) {
claims.put("exp", options.getExpires().getTime() / 1000);
}
if (options.getNotBefore() != null) {
claims.put("nbf", options.getNotBefore().getTime() / 1000);
}
// Only add these claims if they're true to avoid sending them over the wire when false.
if (options.isAdmin()) {
claims.put("admin", options.isAdmin());
}
if (options.isDebug()) {
claims.put("debug", options.isDebug());
}
}
} catch (JSONException e) {
throw new RuntimeException(e);
}
String token = computeToken(claims);
if (token.length() > 1024) {
throw new IllegalArgumentException("TokenGenerator.createToken: Generated token is too long. The token cannot be longer than 1024 bytes.");
}
return token;
} | java | {
"resource": ""
} |
q168467 | GoogleAPI.getErrorDialog | validation | Dialog getErrorDialog(int errorCode, int requestCode) {
final Dialog dialog = GoogleApiAvailability.getInstance().getErrorDialog(activity, errorCode, requestCode);
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
resolvingError = false;
}
});
return dialog;
} | java | {
"resource": ""
} |
q168468 | GoogleAPI.connectAndRequestGoogleAccount | validation | void connectAndRequestGoogleAccount(int signInRequestCode, int errorResolutionRequestCode) {
if (client.isConnected()) {
requestGoogleAccount(signInRequestCode);
} else if (!client.isConnecting()) {
this.signInRequestCode = signInRequestCode;
this.errorResolutionRequestCode = errorResolutionRequestCode;
client.connect();
}
} | java | {
"resource": ""
} |
q168469 | GoogleAPI.logoutAndClearState | validation | public void logoutAndClearState() {
if (client != null && client.isConnected()) {
logout();
client.disconnect();
}
activity = null;
client = null;
} | java | {
"resource": ""
} |
q168470 | CloudflareEdgeCache.invalidateIfNecessary | validation | @Override
public boolean invalidateIfNecessary(BaragonRequest request) {
if (request.getLoadBalancerService().getEdgeCacheDomains().isEmpty()) {
return false;
}
try {
boolean allSucceeded = true;
for (String edgeCacheDNS : request.getLoadBalancerService().getEdgeCacheDomains()) {
List<CloudflareZone> matchingZones = getCloudflareZone(edgeCacheDNS);
if (matchingZones.isEmpty()) {
LOG.warn("`edgeCacheDNS` was defined on the request, but no matching Cloudflare Zone was found!");
return false;
}
for (CloudflareZone matchingZone : matchingZones) {
String zoneId = matchingZone.getId();
Optional<CloudflareDnsRecord> matchingDnsRecord = getCloudflareDnsRecord(edgeCacheDNS, zoneId);
if (!matchingDnsRecord.isPresent()) {
LOG.warn("`edgeCacheDNS` was defined on the request, but no matching Cloudflare DNS Record was found!");
return false;
}
if (!matchingDnsRecord.get().isProxied()) {
LOG.warn("`edgeCacheDNS` was defined on the request, but {} is not a proxied DNS record!", edgeCacheDNS);
return false;
}
String cacheTag = String.format(
edgeCacheConfiguration.getIntegrationSettings().get("cacheTagFormat"),
request.getLoadBalancerService().getServiceId()
);
LOG.debug("Sending cache purge request against {} for {} to Cloudflare...", matchingDnsRecord.get().getName(), cacheTag);
allSucceeded = cf.purgeEdgeCache(zoneId, Collections.singletonList(cacheTag)) && allSucceeded;
}
}
return allSucceeded;
} catch (CloudflareClientException e) {
LOG.error("Unable to invalidate Cloudflare cache for request {}", request, e);
return false;
}
} | java | {
"resource": ""
} |
q168471 | BaragonServiceClient.getBaragonServiceStatus | validation | public Optional<BaragonServiceStatus> getBaragonServiceStatus(String baseUrl) {
final String uri = String.format(STATUS_FORMAT, baseUrl);
return getSingle(uri, "status", "", BaragonServiceStatus.class);
} | java | {
"resource": ""
} |
q168472 | BaragonServiceClient.getGlobalState | validation | public Collection<BaragonServiceState> getGlobalState() {
final String uri = String.format(STATE_FORMAT, getBaseUrl());
return getCollection(uri, "global state", BARAGON_SERVICE_STATE_COLLECTION);
} | java | {
"resource": ""
} |
q168473 | BaragonServiceClient.getLoadBalancerGroups | validation | public Collection<String> getLoadBalancerGroups() {
final String requestUri = String.format(LOAD_BALANCER_FORMAT, getBaseUrl());
return getCollection(requestUri, "load balancer groups", STRING_COLLECTION);
} | java | {
"resource": ""
} |
q168474 | BaragonServiceClient.getOccupiedBasePaths | validation | public Collection<String> getOccupiedBasePaths(String loadBalancerGroupName) {
final String requestUri = String.format(LOAD_BALANCER_ALL_BASE_PATHS_FORMAT, getBaseUrl(), loadBalancerGroupName);
return getCollection(requestUri, "occupied base paths", STRING_COLLECTION);
} | java | {
"resource": ""
} |
q168475 | BaragonServiceClient.getRequest | validation | public Optional<BaragonResponse> getRequest(String requestId) {
final String uri = String.format(REQUEST_ID_FORMAT, getBaseUrl(), requestId);
return getSingle(uri, "request", requestId, BaragonResponse.class);
} | java | {
"resource": ""
} |
q168476 | BaragonServiceClient.getQueuedRequests | validation | public Collection<QueuedRequestId> getQueuedRequests() {
final String uri = String.format(REQUEST_FORMAT, getBaseUrl());
return getCollection(uri, "queued requests", QUEUED_REQUEST_COLLECTION);
} | java | {
"resource": ""
} |
q168477 | ApplicationLoadBalancer.guaranteeRegistered | validation | private void guaranteeRegistered(TrafficSource trafficSource,
TargetGroup targetGroup,
Collection<TargetDescription> targets,
Collection<BaragonAgentMetadata> baragonAgents,
Collection<LoadBalancer> loadBalancers) {
/*
- Check that load balancers, baragon agents, target groups are on same VPC
- Check that load balancers, targets are on same subnet (== AZ)
- Check that all baragon agents are associated with a target on target group
- Check that load balancers has listeners, rules to make talk to target group
*/
if (configuration.isPresent() && configuration.get().isCheckForCorrectVpc()) {
guaranteeSameVPC(targetGroup, baragonAgents, loadBalancers);
}
guaranteeAzEnabled(baragonAgents, loadBalancers);
guaranteeHasAllTargets(trafficSource, targetGroup, targets, baragonAgents);
//guaranteeListenersPresent(targetGroup, loadBalancers);
} | java | {
"resource": ""
} |
q168478 | ApplicationLoadBalancer.deregisterRemovableTargets | validation | private void deregisterRemovableTargets(TrafficSource trafficSource,
BaragonGroup baragonGroup,
TargetGroup targetGroup,
Collection<BaragonAgentMetadata> agents,
Collection<TargetDescription> targets) {
Collection<TargetDescription> removableTargets = listRemovableTargets(trafficSource, baragonGroup, targets, agents);
for (TargetDescription removableTarget : removableTargets) {
try {
if (configuration.isPresent()
&& !configuration.get().isRemoveLastHealthyEnabled()
&& isLastHealthyInstance(removableTarget, targetGroup)) {
LOG.info("Will not de-register target {} because it is last healthy instance in {}", removableTarget, targetGroup);
} else {
elbClient.deregisterTargets(new DeregisterTargetsRequest()
.withTargetGroupArn(targetGroup.getTargetGroupArn())
.withTargets(removableTarget));
LOG.info("De-registered target {} from target group {}", removableTarget, targetGroup);
}
} catch (AmazonClientException acexn) {
LOG.error("Could not de-register target {} from target group {} due to error",
removableTarget, targetGroup, acexn);
exceptionNotifier.notify(acexn, ImmutableMap
.of("targetGroup", targetGroup.getTargetGroupName()));
}
}
} | java | {
"resource": ""
} |
q168479 | ApplicationLoadBalancer.guaranteeSameVPC | validation | private void guaranteeSameVPC(TargetGroup targetGroup,
Collection<BaragonAgentMetadata> agents,
Collection<LoadBalancer> loadBalancers) {
String vpcId = targetGroup.getVpcId();
for (BaragonAgentMetadata agent : agents) {
if (agent.getEc2().getVpcId().isPresent()) {
if (! agent.getEc2().getVpcId().get().equals(vpcId)) {
LOG.error("Agent {} not on same VPC as its target group {}", agent, targetGroup);
throw new IllegalStateException(String.format("Agent %s not on same VPC as its target group %s", agent, targetGroup));
}
} else {
LOG.error("Agent {} not assigned to a VPC", agent);
throw new IllegalStateException(String.format("Agent %s not assigned to a VPC", agent));
}
}
for (LoadBalancer loadBalancer : loadBalancers) {
if (!vpcId.equals(loadBalancer.getVpcId())) {
LOG.error("Load balancer {} on different VPC from target group {}", loadBalancer, targetGroup);
throw new IllegalStateException(String.format("Load balancer %s on different VPC from target group %s", loadBalancer, targetGroup));
}
}
} | java | {
"resource": ""
} |
q168480 | ApplicationLoadBalancer.guaranteeHasAllTargets | validation | private void guaranteeHasAllTargets(TrafficSource trafficSource,
TargetGroup targetGroup,
Collection<TargetDescription> targets,
Collection<BaragonAgentMetadata> baragonAgents) {
Collection<TargetDescription> targetDescriptions = new HashSet<>();
for (BaragonAgentMetadata agent : baragonAgents) {
try {
if ((trafficSource.getRegisterBy() == RegisterBy.INSTANCE_ID && agent.getEc2().getInstanceId().isPresent())
|| (trafficSource.getRegisterBy() == RegisterBy.PRIVATE_IP && agent.getEc2().getPrivateIp().isPresent())) {
String id = trafficSource.getRegisterBy() == RegisterBy.INSTANCE_ID ? agent.getEc2().getInstanceId().get() : agent.getEc2().getPrivateIp().get();
if (agentShouldRegisterInTargetGroup(id, targets)) {
targetDescriptions.add(new TargetDescription()
.withId(id));
LOG.info("Will register agent {} to target in group {}", agent, targetGroup);
} else {
LOG.debug("Agent {} is already registered", agent);
}
}
} catch (Exception exn) {
LOG.error("Could not create request to register agent {} due to error", agent, exn);
exceptionNotifier.notify(exn, ImmutableMap.of("agent", agent.toString()));
}
}
if (targetDescriptions.isEmpty()) {
LOG.debug("No new instances to register with target group");
} else {
try {
RegisterTargetsRequest registerTargetsRequest = new RegisterTargetsRequest()
.withTargetGroupArn(targetGroup.getTargetGroupArn())
.withTargets(targetDescriptions);
elbClient.registerTargets(registerTargetsRequest);
LOG.info("Registered targets {} onto target group {}", targetDescriptions, targetGroup);
} catch (AmazonClientException acexn) {
LOG.error("Failed to register targets {} onto target group {}", targetDescriptions, targetGroup);
exceptionNotifier.notify(acexn, ImmutableMap.of(
"targets", targetDescriptions.toString(),
"targetGroup", targetGroup.toString()));
}
}
} | java | {
"resource": ""
} |
q168481 | SchemaLink.setHref | validation | public void setHref(String href) {
if (href.contains("%7B")) {
try {
href = URLDecoder.decode(href, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
this.href = new UriTemplate(href);
} | java | {
"resource": ""
} |
q168482 | MemberKey.newInstance | validation | static MemberKey newInstance(Object contextObject, String name) {
if (contextObject instanceof Class<?>) {
Class<?> clazz = (Class<?>) contextObject;
if (clazz.isEnum() && ("values".equals(name) || Reflections.isConstantName(clazz, name))) {
// Special handling for enums - allows to access values() and constants
return new MemberKey(clazz, name);
}
}
return new MemberKey(contextObject.getClass(), name);
} | java | {
"resource": ""
} |
q168483 | DefaultParser.lineSeparatorFound | validation | private void lineSeparatorFound(String lineSeparator) {
flushText();
flushLineSeparator(lineSeparator);
line++;
state = State.TEXT;
separatorIdx = 0;
} | java | {
"resource": ""
} |
q168484 | DefaultParser.flushTag | validation | private void flushTag() {
state = State.TEXT;
handler.tag(deriveTag(buffer.toString()));
delimiterIdx = 0;
clearBuffer();
} | java | {
"resource": ""
} |
q168485 | DefaultParser.extractContent | validation | private String extractContent(MustacheTagType tagType, String buffer) {
switch (tagType) {
case VARIABLE:
return buffer.trim();
case UNESCAPE_VARIABLE:
return (buffer.charAt(0) == ((String) EngineConfigurationKey.START_DELIMITER
.getDefaultValue()).charAt(0) ? buffer.substring(1,
buffer.length() - 1).trim() : buffer.substring(1).trim());
case SECTION:
case INVERTED_SECTION:
case PARTIAL:
case EXTEND:
case EXTEND_SECTION:
case SECTION_END:
case NESTED_TEMPLATE:
case COMMENT:
return buffer.substring(1).trim();
case DELIMITER:
return buffer.trim();
default:
return null;
}
} | java | {
"resource": ""
} |
q168486 | SegmentBases.readSegmentLines | validation | private static List<List<SegmentBase>> readSegmentLines(
ContainerSegmentBase container) {
List<List<SegmentBase>> lines = new ArrayList<>();
// Add the last line manually - there is no line separator to trigger
// flush
lines.add(readSegmentLines(lines, null, container));
return lines;
} | java | {
"resource": ""
} |
q168487 | Patterns.newMustacheTagPattern | validation | public static Pattern newMustacheTagPattern(Configuration configuration) {
StringBuilder regex = new StringBuilder();
regex.append(Pattern.quote(configuration
.getStringPropertyValue(EngineConfigurationKey.START_DELIMITER)));
regex.append(".*?");
regex.append(Pattern.quote(configuration
.getStringPropertyValue(EngineConfigurationKey.END_DELIMITER)));
return Pattern.compile(regex.toString());
} | java | {
"resource": ""
} |
q168488 | Decorator.decorate | validation | public static <T> Decorator<T> decorate(T delegate, Map<String, Function<T, Object>> mappings, String delegateKey,
Configuration configuration) {
return IterableDecorator.isIterable(delegate)
? new IterableDecorator<>(delegate, ImmutableMap.copyOf(mappings), delegateKey, configuration)
: new Decorator<>(delegate, ImmutableMap.copyOf(mappings), delegateKey, configuration);
} | java | {
"resource": ""
} |
q168489 | Decorator.unwrap | validation | @SuppressWarnings("unchecked")
public static <T> T unwrap(T instance) {
return instance instanceof Decorator ? unwrap(((Decorator<T>) instance).delegate) : instance;
} | java | {
"resource": ""
} |
q168490 | MustacheEngineBuilder.build | validation | public synchronized MustacheEngine build() {
MustacheEngine engine = new DefaultMustacheEngine(this);
for (EngineBuiltCallback callback : engineReadyCallbacks) {
callback.engineBuilt(engine);
}
BuildInfo buildInfo = BuildInfo.load();
LOGGER.info("Engine built {} ({})", buildInfo.getVersion(), buildInfo.getTimestampDate());
LOGGER.debug("Engine configuration: {}",
engine.getConfiguration().getInfo());
isBuilt = true;
return engine;
} | java | {
"resource": ""
} |
q168491 | MustacheEngineBuilder.addTemplateLocator | validation | public MustacheEngineBuilder addTemplateLocator(TemplateLocator locator) {
checkArgumentNotNull(locator);
checkNotBuilt();
this.templateLocators.add(locator);
return this;
} | java | {
"resource": ""
} |
q168492 | MustacheEngineBuilder.addResolver | validation | public MustacheEngineBuilder addResolver(Resolver resolver) {
checkArgumentNotNull(resolver);
checkNotBuilt();
this.resolvers.add(resolver);
return this;
} | java | {
"resource": ""
} |
q168493 | MustacheEngineBuilder.registerCallback | validation | public MustacheEngineBuilder registerCallback(
EngineBuiltCallback callback) {
checkArgumentNotNull(callback);
checkNotBuilt();
this.engineReadyCallbacks.add(callback);
return this;
} | java | {
"resource": ""
} |
q168494 | MustacheEngineBuilder.addValueConverter | validation | public MustacheEngineBuilder addValueConverter(ValueConverter converter) {
checkArgumentNotNull(converter);
checkNotBuilt();
this.valueConverters.add(converter);
return this;
} | java | {
"resource": ""
} |
q168495 | MustacheEngineBuilder.addContextConverter | validation | public MustacheEngineBuilder addContextConverter(ContextConverter converter) {
checkArgumentNotNull(converter);
checkNotBuilt();
this.contextConverters.add(converter);
return this;
} | java | {
"resource": ""
} |
q168496 | Strings.capitalizeFully | validation | public static String capitalizeFully(String text, Character delimiter) {
if (isEmpty(text)) {
return text;
}
text = text.toLowerCase();
boolean capitalizeNext = true;
StringBuilder builder = new StringBuilder();
for (int i = 0; i < text.length(); i++) {
final char ch = text.charAt(i);
if (delimiter.equals(ch)) {
capitalizeNext = true;
builder.append(ch);
} else if (capitalizeNext) {
builder.append(Character.toTitleCase(ch));
capitalizeNext = false;
} else {
builder.append(ch);
}
}
return builder.toString();
} | java | {
"resource": ""
} |
q168497 | AbstractHelper.append | validation | protected void append(Options options, CharSequence sequence) {
TextSupport textSupport = this.textSupport;
if (textSupport == null || isUnescapeVariable(options)) {
options.append(sequence);
} else {
try {
textSupport.appendEscapedHtml(sequence.toString(),
options.getAppendable());
} catch (IOException e) {
throw new MustacheException(MustacheProblem.RENDER_IO_ERROR, e);
}
}
} | java | {
"resource": ""
} |
q168498 | DefaultMustacheEngine.buildSourceCache | validation | private ComputingCache<String, Optional<String>> buildSourceCache() {
return buildCache("Source",
key ->
Optional.ofNullable(locateAndRead(key)),
(key, cause) ->
LOGGER.debug("Removed template source from cache [templateId: {}, cause: {}]", key, cause));
} | java | {
"resource": ""
} |
q168499 | DefaultParsingHandler.push | validation | private void push(ContainerSegmentBase container) {
containerStack.addFirst(container);
LOGGER.trace("Push {} [name: {}]", container.getType(),
container.getContent());
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.