_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q171300 | InExRules.apply | test | public boolean apply(final V value, final boolean blacklist, boolean flag) {
if (rules == null) {
return flag;
}
if (blacklist) {
flag = processExcludes(value, flag);
flag = processIncludes(value, flag);
}
else {
flag = processIncludes(value, flag);
flag = processExcludes(value, flag);
}
return flag;
} | java | {
"resource": ""
} |
q171301 | InExRules.processIncludes | test | protected boolean processIncludes(final V value, boolean include) {
if (includesCount > 0) {
if (!include) {
for (Rule<R> rule : rules) {
if (!rule.include) {
continue;
}
if (inExRuleMatcher.accept(value, rule.value, true)) {
include = true;
break;
}
}
}
}
return include;
} | java | {
"resource": ""
} |
q171302 | InExRules.processExcludes | test | protected boolean processExcludes(final V value, boolean include) {
if (excludesCount > 0) {
if (include) {
for (Rule<R> rule : rules) {
if (rule.include) {
continue;
}
if (inExRuleMatcher.accept(value, rule.value, false)) {
include = false;
break;
}
}
}
}
return include;
} | java | {
"resource": ""
} |
q171303 | PseudoClass.getPseudoClassName | test | public String getPseudoClassName() {
String name = getClass().getSimpleName().toLowerCase();
name = name.replace('_', '-');
return name;
} | java | {
"resource": ""
} |
q171304 | SortedArrayList.addAll | test | @Override
public boolean addAll(final Collection<? extends E> c) {
Iterator<? extends E> i = c.iterator();
boolean changed = false;
while (i.hasNext()) {
boolean ret = add(i.next());
if (!changed) {
changed = ret;
}
}
return changed;
} | java | {
"resource": ""
} |
q171305 | SortedArrayList.findInsertionPoint | test | protected int findInsertionPoint(final E o, int low, int high) {
while (low <= high) {
int mid = (low + high) >>> 1;
int delta = compare(get(mid), o);
if (delta > 0) {
high = mid - 1;
} else {
low = mid + 1;
}
}
return low;
} | java | {
"resource": ""
} |
q171306 | ActionConfigManager.bindAnnotationConfig | test | public void bindAnnotationConfig(final Class<? extends Annotation> annotationType, final Class<? extends ActionConfig> actionConfigClass) {
final ActionConfig actionConfig = registerNewActionConfiguration(actionConfigClass);
actionConfigs.put(annotationType, actionConfig);
for (final AnnotationParser annotationParser : annotationParsers) {
if (annotationType.equals(annotationParser.getAnnotationType())) {
// parser already exists
return;
}
}
annotationParsers = ArraysUtil.append(annotationParsers, new AnnotationParser(annotationType, Action.class));
} | java | {
"resource": ""
} |
q171307 | ActionConfigManager.registerNewActionConfiguration | test | protected ActionConfig registerNewActionConfiguration(final Class<? extends ActionConfig> actionConfigClass) {
final ActionConfig newActionConfig = createActionConfig(actionConfigClass);
actionConfigs.put(actionConfigClass, newActionConfig);
return newActionConfig;
} | java | {
"resource": ""
} |
q171308 | ActionConfigManager.lookup | test | public ActionConfig lookup(final Class actionTypeOrAnnotationType) {
final ActionConfig actionConfig = actionConfigs.get(actionTypeOrAnnotationType);
if (actionConfig == null) {
throw new MadvocException("ActionConfiguration not registered:" + actionTypeOrAnnotationType.getName());
}
return actionConfig;
} | java | {
"resource": ""
} |
q171309 | ActionConfigManager.with | test | public <T extends ActionConfig> void with(final Class<T> actionConfigType, final Consumer<T> actionConfigConsumer) {
final T actionConfig = (T) lookup(actionConfigType);
actionConfigConsumer.accept(actionConfig);
} | java | {
"resource": ""
} |
q171310 | MailSession.setupSystemMailProperties | test | protected static void setupSystemMailProperties() {
System.setProperty("mail.mime.encodefilename", Boolean.valueOf(Defaults.mailMimeEncodefilename).toString());
System.setProperty("mail.mime.decodefilename", Boolean.valueOf(Defaults.mailMimeDecodefilename).toString());
} | java | {
"resource": ""
} |
q171311 | ValidationConstraintContext.validateWithin | test | public void validateWithin(final ValidationContext vctx, final Object value) {
vtor.validate(vctx, value, name);
} | java | {
"resource": ""
} |
q171312 | HtmlFosterRules.findLastTable | test | protected Element findLastTable(final Node node) {
Node tableNode = node;
while (tableNode != null) {
if (tableNode.getNodeType() == Node.NodeType.ELEMENT) {
String tableNodeName = tableNode.getNodeName().toLowerCase();
if (tableNodeName.equals("table")) {
break;
}
}
tableNode = tableNode.getParentNode();
}
return (Element) tableNode;
} | java | {
"resource": ""
} |
q171313 | HtmlFosterRules.fixElements | test | protected void fixElements() {
for (Element fosterElement : fosterElements) {
// find parent table
Element lastTable = findLastTable(fosterElement);
Node fosterElementParent = fosterElement.getParentNode();
// filter our foster element
Node[] fosterChilds = fosterElement.getChildNodes();
for (Node fosterChild : fosterChilds) {
if (fosterChild.getNodeType() == Node.NodeType.ELEMENT) {
if (isOneOfTableElements((Element) fosterChild)) {
// move all child table elements outside
// the foster element
fosterChild.detachFromParent();
fosterElementParent.insertBefore(fosterChild, fosterElement);
}
}
}
// finally, move foster element above the table
fosterElement.detachFromParent();
lastTable.getParentNode().insertBefore(fosterElement, lastTable);
}
} | java | {
"resource": ""
} |
q171314 | SessionScope.registerSessionBeans | test | protected Map<String, BeanData> registerSessionBeans(final HttpSession httpSession) {
SessionBeans sessionBeans = new SessionBeans();
httpSession.setAttribute(SESSION_BEANS_NAME, sessionBeans);
return sessionBeans.getBeanMap();
} | java | {
"resource": ""
} |
q171315 | SessionScope.getSessionMap | test | @SuppressWarnings("unchecked")
protected Map<String, BeanData> getSessionMap(final HttpSession session) {
SessionBeans sessionBeans = (SessionBeans) session.getAttribute(SESSION_BEANS_NAME);
if (sessionBeans == null) {
return null;
}
return sessionBeans.getBeanMap();
} | java | {
"resource": ""
} |
q171316 | WorkData.init | test | public void init(String name, final String superName, final String suffix, final String reqProxyClassName) {
int lastSlash = name.lastIndexOf('/');
this.targetPackage = lastSlash == -1 ? StringPool.EMPTY : name.substring(0, lastSlash).replace('/', '.');
this.targetClassname = name.substring(lastSlash + 1);
this.nextSupername = superName;
this.superName = name;
// create proxy name
if (reqProxyClassName != null) {
if (reqProxyClassName.startsWith(DOT)) {
name = name.substring(0, lastSlash) + '/' + reqProxyClassName.substring(1);
} else if (reqProxyClassName.endsWith(DOT)) {
name = reqProxyClassName.replace('.', '/') + this.targetClassname;
} else {
name = reqProxyClassName.replace('.', '/');
}
}
// add optional suffix
if (suffix != null) {
name += suffix;
}
this.thisReference = name;
this.superReference = this.superName;
} | java | {
"resource": ""
} |
q171317 | WorkData.addAdviceInitMethod | test | void addAdviceInitMethod(final String name) {
if (adviceInits == null) {
adviceInits = new ArrayList<>();
}
adviceInits.add(name);
} | java | {
"resource": ""
} |
q171318 | BundleAction.end | test | public void end() {
if (newAction) {
bundleId = bundlesManager.registerBundle(contextPath, actionPath, bundleId, bundleContentType, sources);
}
} | java | {
"resource": ""
} |
q171319 | PropsParser.add | test | protected void add(
final String section, final String key,
final StringBuilder value, final boolean trim, final Operator operator) {
// ignore lines without : or =
if (key == null) {
return;
}
String fullKey = key;
if (section != null) {
if (fullKey.length() != 0) {
fullKey = section + '.' + fullKey;
} else {
fullKey = section;
}
}
String v = value.toString();
if (trim) {
if (valueTrimLeft && valueTrimRight) {
v = v.trim();
} else if (valueTrimLeft) {
v = StringUtil.trimLeft(v);
} else {
v = StringUtil.trimRight(v);
}
}
if (v.length() == 0 && skipEmptyProps) {
return;
}
extractProfilesAndAdd(fullKey, v, operator);
} | java | {
"resource": ""
} |
q171320 | PropsParser.extractProfilesAndAdd | test | protected void extractProfilesAndAdd(final String key, final String value, final Operator operator) {
String fullKey = key;
int ndx = fullKey.indexOf(PROFILE_LEFT);
if (ndx == -1) {
justAdd(fullKey, value, null, operator);
return;
}
// extract profiles
ArrayList<String> keyProfiles = new ArrayList<>();
while (true) {
ndx = fullKey.indexOf(PROFILE_LEFT);
if (ndx == -1) {
break;
}
final int len = fullKey.length();
int ndx2 = fullKey.indexOf(PROFILE_RIGHT, ndx + 1);
if (ndx2 == -1) {
ndx2 = len;
}
// remember profile
final String profile = fullKey.substring(ndx + 1, ndx2);
keyProfiles.add(profile);
// extract profile from key
ndx2++;
final String right = (ndx2 == len) ? StringPool.EMPTY : fullKey.substring(ndx2);
fullKey = fullKey.substring(0, ndx) + right;
}
if (fullKey.startsWith(StringPool.DOT)) {
// check for special case when only profile is defined in section
fullKey = fullKey.substring(1);
}
// add value to extracted profiles
justAdd(fullKey, value, keyProfiles, operator);
} | java | {
"resource": ""
} |
q171321 | PropsParser.justAdd | test | protected void justAdd(final String key, final String value, final ArrayList<String> keyProfiles, final Operator operator) {
if (operator == Operator.COPY) {
HashMap<String,Object> target = new HashMap<>();
String[] profiles = null;
if (keyProfiles != null) {
profiles = keyProfiles.toArray(new String[0]);
}
String[] sources = StringUtil.splitc(value, ',');
for (String source : sources) {
source = source.trim();
// try to extract profile for parsing
String[] lookupProfiles = profiles;
String lookupProfilesString = null;
int leftIndex = source.indexOf('<');
if (leftIndex != -1) {
int rightIndex = source.indexOf('>');
lookupProfilesString = source.substring(leftIndex + 1, rightIndex);
source = source.substring(0, leftIndex).concat(source.substring(rightIndex + 1));
lookupProfiles = StringUtil.splitc(lookupProfilesString, ',');
StringUtil.trimAll(lookupProfiles);
}
String[] wildcards = new String[] {source + ".*"};
propsData.extract(target, lookupProfiles, wildcards, null);
for (Map.Entry<String, Object> entry : target.entrySet()) {
String entryKey = entry.getKey();
String suffix = entryKey.substring(source.length());
String newKey = key + suffix;
String newValue = "${" + entryKey;
if (lookupProfilesString != null) {
newValue += "<" + lookupProfilesString + ">";
}
newValue += "}";
if (profiles == null) {
propsData.putBaseProperty(newKey, newValue, false);
} else {
for (final String p : profiles) {
propsData.putProfileProperty(newKey, newValue, p, false);
}
}
}
}
return;
}
boolean append = operator == Operator.QUICK_APPEND;
if (keyProfiles == null) {
propsData.putBaseProperty(key, value, append);
return;
}
for (final String p : keyProfiles) {
propsData.putProfileProperty(key, value, p, append);
}
} | java | {
"resource": ""
} |
q171322 | AsmUtil.typedesc2ClassName | test | public static String typedesc2ClassName(final String desc) {
String className = desc;
switch (desc.charAt(0)) {
case 'B':
case 'C':
case 'D':
case 'F':
case 'I':
case 'J':
case 'S':
case 'Z':
case 'V':
if (desc.length() != 1) {
throw new IllegalArgumentException(INVALID_BASE_TYPE + desc);
}
break;
case 'L':
className = className.substring(1, className.length() - 1); break;
case '[':
// uses less-known feature of class loaders for loading array types
// using bytecode-like signatures.
className = className.replace('/', '.');
break;
default: throw new IllegalArgumentException(INVALID_TYPE_DESCRIPTION + desc);
}
return className;
} | java | {
"resource": ""
} |
q171323 | AsmUtil.typeref2Name | test | public static String typeref2Name(final String desc) {
if (desc.charAt(0) != TYPE_REFERENCE) {
throw new IllegalArgumentException(INVALID_TYPE_DESCRIPTION + desc);
}
String name = desc.substring(1, desc.length() - 1);
return name.replace('/', '.');
} | java | {
"resource": ""
} |
q171324 | AsmUtil.typedescToSignature | test | public static String typedescToSignature(final String desc, final MutableInteger from) {
int fromIndex = from.get();
from.value++; // default usage for most cases
switch (desc.charAt(fromIndex)) {
case 'B': return "byte";
case 'C': return "char";
case 'D': return "double";
case 'F': return "float";
case 'I': return "int";
case 'J': return "long";
case 'S': return "short";
case 'Z': return "boolean";
case 'V': return "void";
case 'L':
int index = desc.indexOf(';', fromIndex);
if (index < 0) {
throw new IllegalArgumentException(INVALID_TYPE_DESCRIPTION + desc);
}
from.set(index + 1);
String str = desc.substring(fromIndex + 1, index);
return str.replace('/', '.');
case 'T':
return desc.substring(from.value);
case '[':
StringBuilder brackets = new StringBuilder();
int n = fromIndex;
while (desc.charAt(n) == '[') { // count opening brackets
brackets.append("[]");
n++;
}
from.value = n;
String type = typedescToSignature(desc, from); // the rest of the string denotes a `<field_type>'
return type + brackets;
default:
if (from.value == 0) {
throw new IllegalArgumentException(INVALID_TYPE_DESCRIPTION + desc);
}
// generics!
return desc.substring(from.value);
}
} | java | {
"resource": ""
} |
q171325 | AsmUtil.typeToTyperef | test | public static String typeToTyperef(final Class type) {
if (!type.isArray()) {
if (!type.isPrimitive()) {
return 'L' + typeToSignature(type) + ';';
}
if (type == int.class) {
return "I";
}
if (type == long.class) {
return "J";
}
if (type == boolean.class) {
return "Z";
}
if (type == double.class) {
return "D";
}
if (type == float.class) {
return "F";
}
if (type == short.class) {
return "S";
}
if (type == void.class) {
return "V";
}
if (type == byte.class) {
return "B";
}
if (type == char.class) {
return "C";
}
}
return type.getName();
} | java | {
"resource": ""
} |
q171326 | Consumers.addAll | test | public Consumers<T> addAll(final Consumer<T>... consumers) {
Collections.addAll(consumerList, consumers);
return this;
} | java | {
"resource": ""
} |
q171327 | CollectionConverter.createCollection | test | @SuppressWarnings("unchecked")
protected Collection<T> createCollection(final int length) {
if (collectionType.isInterface()) {
if (collectionType == List.class) {
if (length > 0) {
return new ArrayList<>(length);
} else {
return new ArrayList<>();
}
}
if (collectionType == Set.class) {
if (length > 0) {
return new HashSet<>(length);
} else {
return new HashSet<>();
}
}
throw new TypeConversionException("Unknown collection: " + collectionType.getName());
}
if (length > 0) {
try {
Constructor<Collection<T>> ctor = (Constructor<Collection<T>>) collectionType.getConstructor(int.class);
return ctor.newInstance(Integer.valueOf(length));
} catch (Exception ex) {
// ignore exception
}
}
try {
return collectionType.getDeclaredConstructor().newInstance();
} catch (Exception ex) {
throw new TypeConversionException(ex);
}
} | java | {
"resource": ""
} |
q171328 | CollectionConverter.convertToSingleElementCollection | test | protected Collection<T> convertToSingleElementCollection(final Object value) {
Collection<T> collection = createCollection(0);
//noinspection unchecked
collection.add((T) value);
return collection;
} | java | {
"resource": ""
} |
q171329 | CollectionConverter.convertValueToCollection | test | protected Collection<T> convertValueToCollection(Object value) {
if (value instanceof Iterable) {
Iterable iterable = (Iterable) value;
Collection<T> collection = createCollection(0);
for (Object element : iterable) {
collection.add(convertType(element));
}
return collection;
}
if (value instanceof CharSequence) {
value = CsvUtil.toStringArray(value.toString());
}
Class type = value.getClass();
if (type.isArray()) {
// convert arrays
Class componentType = type.getComponentType();
if (componentType.isPrimitive()) {
return convertPrimitiveArrayToCollection(value, componentType);
} else {
Object[] array = (Object[]) value;
Collection<T> result = createCollection(array.length);
for (Object a : array) {
result.add(convertType(a));
}
return result;
}
}
// everything else:
return convertToSingleElementCollection(value);
} | java | {
"resource": ""
} |
q171330 | CollectionConverter.convertCollectionToCollection | test | protected Collection<T> convertCollectionToCollection(final Collection value) {
Collection<T> collection = createCollection(value.size());
for (Object v : value) {
collection.add(convertType(v));
}
return collection;
} | java | {
"resource": ""
} |
q171331 | CollectionConverter.convertPrimitiveArrayToCollection | test | @SuppressWarnings("AutoBoxing")
protected Collection<T> convertPrimitiveArrayToCollection(final Object value, final Class primitiveComponentType) {
Collection<T> result = null;
if (primitiveComponentType == int.class) {
int[] array = (int[]) value;
result = createCollection(array.length);
for (int a : array) {
result.add(convertType(a));
}
}
else if (primitiveComponentType == long.class) {
long[] array = (long[]) value;
result = createCollection(array.length);
for (long a : array) {
result.add(convertType(a));
}
}
else if (primitiveComponentType == float.class) {
float[] array = (float[]) value;
result = createCollection(array.length);
for (float a : array) {
result.add(convertType(a));
}
}
else if (primitiveComponentType == double.class) {
double[] array = (double[]) value;
result = createCollection(array.length);
for (double a : array) {
result.add(convertType(a));
}
}
else if (primitiveComponentType == short.class) {
short[] array = (short[]) value;
result = createCollection(array.length);
for (short a : array) {
result.add(convertType(a));
}
}
else if (primitiveComponentType == byte.class) {
byte[] array = (byte[]) value;
result = createCollection(array.length);
for (byte a : array) {
result.add(convertType(a));
}
}
else if (primitiveComponentType == char.class) {
char[] array = (char[]) value;
result = createCollection(array.length);
for (char a : array) {
result.add(convertType(a));
}
}
else if (primitiveComponentType == boolean.class) {
boolean[] array = (boolean[]) value;
result = createCollection(array.length);
for (boolean a : array) {
result.add(convertType(a));
}
}
return result;
} | java | {
"resource": ""
} |
q171332 | Label.addLineNumber | test | final void addLineNumber(final int lineNumber) {
if (this.lineNumber == 0) {
this.lineNumber = (short) lineNumber;
} else {
if (otherLineNumbers == null) {
otherLineNumbers = new int[LINE_NUMBERS_CAPACITY_INCREMENT];
}
int otherLineNumberIndex = ++otherLineNumbers[0];
if (otherLineNumberIndex >= otherLineNumbers.length) {
int[] newLineNumbers = new int[otherLineNumbers.length + LINE_NUMBERS_CAPACITY_INCREMENT];
System.arraycopy(otherLineNumbers, 0, newLineNumbers, 0, otherLineNumbers.length);
otherLineNumbers = newLineNumbers;
}
otherLineNumbers[otherLineNumberIndex] = lineNumber;
}
} | java | {
"resource": ""
} |
q171333 | Label.accept | test | final void accept(final MethodVisitor methodVisitor, final boolean visitLineNumbers) {
methodVisitor.visitLabel(this);
if (visitLineNumbers && lineNumber != 0) {
methodVisitor.visitLineNumber(lineNumber & 0xFFFF, this);
if (otherLineNumbers != null) {
for (int i = 1; i <= otherLineNumbers[0]; ++i) {
methodVisitor.visitLineNumber(otherLineNumbers[i], this);
}
}
}
} | java | {
"resource": ""
} |
q171334 | Label.put | test | final void put(
final ByteVector code, final int sourceInsnBytecodeOffset, final boolean wideReference) {
if ((flags & FLAG_RESOLVED) == 0) {
if (wideReference) {
addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_WIDE, code.length);
code.putInt(-1);
} else {
addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_SHORT, code.length);
code.putShort(-1);
}
} else {
if (wideReference) {
code.putInt(bytecodeOffset - sourceInsnBytecodeOffset);
} else {
code.putShort(bytecodeOffset - sourceInsnBytecodeOffset);
}
}
} | java | {
"resource": ""
} |
q171335 | Label.addForwardReference | test | private void addForwardReference(
final int sourceInsnBytecodeOffset, final int referenceType, final int referenceHandle) {
if (forwardReferences == null) {
forwardReferences = new int[FORWARD_REFERENCES_CAPACITY_INCREMENT];
}
int lastElementIndex = forwardReferences[0];
if (lastElementIndex + 2 >= forwardReferences.length) {
int[] newValues = new int[forwardReferences.length + FORWARD_REFERENCES_CAPACITY_INCREMENT];
System.arraycopy(forwardReferences, 0, newValues, 0, forwardReferences.length);
forwardReferences = newValues;
}
forwardReferences[++lastElementIndex] = sourceInsnBytecodeOffset;
forwardReferences[++lastElementIndex] = referenceType | referenceHandle;
forwardReferences[0] = lastElementIndex;
} | java | {
"resource": ""
} |
q171336 | Label.resolve | test | final boolean resolve(final byte[] code, final int bytecodeOffset) {
this.flags |= FLAG_RESOLVED;
this.bytecodeOffset = bytecodeOffset;
if (forwardReferences == null) {
return false;
}
boolean hasAsmInstructions = false;
for (int i = forwardReferences[0]; i > 0; i -= 2) {
final int sourceInsnBytecodeOffset = forwardReferences[i - 1];
final int reference = forwardReferences[i];
final int relativeOffset = bytecodeOffset - sourceInsnBytecodeOffset;
int handle = reference & FORWARD_REFERENCE_HANDLE_MASK;
if ((reference & FORWARD_REFERENCE_TYPE_MASK) == FORWARD_REFERENCE_TYPE_SHORT) {
if (relativeOffset < Short.MIN_VALUE || relativeOffset > Short.MAX_VALUE) {
// Change the opcode of the jump instruction, in order to be able to find it later in
// ClassReader. These ASM specific opcodes are similar to jump instruction opcodes, except
// that the 2 bytes offset is unsigned (and can therefore represent values from 0 to
// 65535, which is sufficient since the size of a method is limited to 65535 bytes).
int opcode = code[sourceInsnBytecodeOffset] & 0xFF;
if (opcode < Opcodes.IFNULL) {
// Change IFEQ ... JSR to ASM_IFEQ ... ASM_JSR.
code[sourceInsnBytecodeOffset] = (byte) (opcode + Constants.ASM_OPCODE_DELTA);
} else {
// Change IFNULL and IFNONNULL to ASM_IFNULL and ASM_IFNONNULL.
code[sourceInsnBytecodeOffset] = (byte) (opcode + Constants.ASM_IFNULL_OPCODE_DELTA);
}
hasAsmInstructions = true;
}
code[handle++] = (byte) (relativeOffset >>> 8);
code[handle] = (byte) relativeOffset;
} else {
code[handle++] = (byte) (relativeOffset >>> 24);
code[handle++] = (byte) (relativeOffset >>> 16);
code[handle++] = (byte) (relativeOffset >>> 8);
code[handle] = (byte) relativeOffset;
}
}
return hasAsmInstructions;
} | java | {
"resource": ""
} |
q171337 | Label.markSubroutine | test | final void markSubroutine(final short subroutineId) {
// Data flow algorithm: put this basic block in a list of blocks to process (which are blocks
// belonging to subroutine subroutineId) and, while there are blocks to process, remove one from
// the list, mark it as belonging to the subroutine, and add its successor basic blocks in the
// control flow graph to the list of blocks to process (if not already done).
Label listOfBlocksToProcess = this;
listOfBlocksToProcess.nextListElement = EMPTY_LIST;
while (listOfBlocksToProcess != EMPTY_LIST) {
// Remove a basic block from the list of blocks to process.
Label basicBlock = listOfBlocksToProcess;
listOfBlocksToProcess = listOfBlocksToProcess.nextListElement;
basicBlock.nextListElement = null;
// If it is not already marked as belonging to a subroutine, mark it as belonging to
// subroutineId and add its successors to the list of blocks to process (unless already done).
if (basicBlock.subroutineId == 0) {
basicBlock.subroutineId = subroutineId;
listOfBlocksToProcess = basicBlock.pushSuccessors(listOfBlocksToProcess);
}
}
} | java | {
"resource": ""
} |
q171338 | Label.addSubroutineRetSuccessors | test | final void addSubroutineRetSuccessors(final Label subroutineCaller) {
// Data flow algorithm: put this basic block in a list blocks to process (which are blocks
// belonging to a subroutine starting with this label) and, while there are blocks to process,
// remove one from the list, put it in a list of blocks that have been processed, add a return
// edge to the successor of subroutineCaller if applicable, and add its successor basic blocks
// in the control flow graph to the list of blocks to process (if not already done).
Label listOfProcessedBlocks = EMPTY_LIST;
Label listOfBlocksToProcess = this;
listOfBlocksToProcess.nextListElement = EMPTY_LIST;
while (listOfBlocksToProcess != EMPTY_LIST) {
// Move a basic block from the list of blocks to process to the list of processed blocks.
Label basicBlock = listOfBlocksToProcess;
listOfBlocksToProcess = basicBlock.nextListElement;
basicBlock.nextListElement = listOfProcessedBlocks;
listOfProcessedBlocks = basicBlock;
// Add an edge from this block to the successor of the caller basic block, if this block is
// the end of a subroutine and if this block and subroutineCaller do not belong to the same
// subroutine.
if ((basicBlock.flags & FLAG_SUBROUTINE_END) != 0
&& basicBlock.subroutineId != subroutineCaller.subroutineId) {
basicBlock.outgoingEdges =
new Edge(
basicBlock.outputStackSize,
// By construction, the first outgoing edge of a basic block that ends with a jsr
// instruction leads to the jsr continuation block, i.e. where execution continues
// when ret is called (see {@link #FLAG_SUBROUTINE_CALLER}).
subroutineCaller.outgoingEdges.successor,
basicBlock.outgoingEdges);
}
// Add its successors to the list of blocks to process. Note that {@link #pushSuccessors} does
// not push basic blocks which are already in a list. Here this means either in the list of
// blocks to process, or in the list of already processed blocks. This second list is
// important to make sure we don't reprocess an already processed block.
listOfBlocksToProcess = basicBlock.pushSuccessors(listOfBlocksToProcess);
}
// Reset the {@link #nextListElement} of all the basic blocks that have been processed to null,
// so that this method can be called again with a different subroutine or subroutine caller.
while (listOfProcessedBlocks != EMPTY_LIST) {
Label newListOfProcessedBlocks = listOfProcessedBlocks.nextListElement;
listOfProcessedBlocks.nextListElement = null;
listOfProcessedBlocks = newListOfProcessedBlocks;
}
} | java | {
"resource": ""
} |
q171339 | NaturalOrderComparator.compareDigits | test | protected int[] compareDigits(final String str1, int ndx1, final String str2, int ndx2) {
// iterate all digits in the first string
int zeroCount1 = 0;
while (charAt(str1, ndx1) == '0') {
zeroCount1++;
ndx1++;
}
int len1 = 0;
while (true) {
final char char1 = charAt(str1, ndx1);
final boolean isDigitChar1 = CharUtil.isDigit(char1);
if (!isDigitChar1) {
break;
}
len1++;
ndx1++;
}
// iterate all digits in the second string and compare with the first
int zeroCount2 = 0;
while (charAt(str2, ndx2) == '0') {
zeroCount2++;
ndx2++;
}
int len2 = 0;
int ndx1_new = ndx1 - len1;
int equalNumbers = 0;
while (true) {
final char char2 = charAt(str2, ndx2);
final boolean isDigitChar2 = CharUtil.isDigit(char2);
if (!isDigitChar2) {
break;
}
if (equalNumbers == 0 && (ndx1_new < ndx1)) {
equalNumbers = charAt(str1, ndx1_new++) - char2;
}
len2++;
ndx2++;
}
// compare
if (len1 != len2) {
// numbers are not equals size
return new int[] {len1 - len2};
}
if (equalNumbers != 0) {
return new int[] {equalNumbers};
}
// numbers are equal, but number of zeros is different
return new int[] {0, zeroCount1 - zeroCount2, ndx1, ndx2};
} | java | {
"resource": ""
} |
q171340 | NaturalOrderComparator.fixAccent | test | private char fixAccent(final char c) {
for (int i = 0; i < ACCENT_CHARS.length; i+=2) {
final char accentChar = ACCENT_CHARS[i];
if (accentChar == c) {
return ACCENT_CHARS[i + 1];
}
}
return c;
} | java | {
"resource": ""
} |
q171341 | ByteVector.putByte | test | public ByteVector putByte(final int byteValue) {
int currentLength = length;
if (currentLength + 1 > data.length) {
enlarge(1);
}
data[currentLength++] = (byte) byteValue;
length = currentLength;
return this;
} | java | {
"resource": ""
} |
q171342 | ByteVector.put11 | test | final ByteVector put11(final int byteValue1, final int byteValue2) {
int currentLength = length;
if (currentLength + 2 > data.length) {
enlarge(2);
}
byte[] currentData = data;
currentData[currentLength++] = (byte) byteValue1;
currentData[currentLength++] = (byte) byteValue2;
length = currentLength;
return this;
} | java | {
"resource": ""
} |
q171343 | ByteVector.putShort | test | public ByteVector putShort(final int shortValue) {
int currentLength = length;
if (currentLength + 2 > data.length) {
enlarge(2);
}
byte[] currentData = data;
currentData[currentLength++] = (byte) (shortValue >>> 8);
currentData[currentLength++] = (byte) shortValue;
length = currentLength;
return this;
} | java | {
"resource": ""
} |
q171344 | ByteVector.put12 | test | final ByteVector put12(final int byteValue, final int shortValue) {
int currentLength = length;
if (currentLength + 3 > data.length) {
enlarge(3);
}
byte[] currentData = data;
currentData[currentLength++] = (byte) byteValue;
currentData[currentLength++] = (byte) (shortValue >>> 8);
currentData[currentLength++] = (byte) shortValue;
length = currentLength;
return this;
} | java | {
"resource": ""
} |
q171345 | ByteVector.put112 | test | final ByteVector put112(final int byteValue1, final int byteValue2, final int shortValue) {
int currentLength = length;
if (currentLength + 4 > data.length) {
enlarge(4);
}
byte[] currentData = data;
currentData[currentLength++] = (byte) byteValue1;
currentData[currentLength++] = (byte) byteValue2;
currentData[currentLength++] = (byte) (shortValue >>> 8);
currentData[currentLength++] = (byte) shortValue;
length = currentLength;
return this;
} | java | {
"resource": ""
} |
q171346 | ByteVector.putInt | test | public ByteVector putInt(final int intValue) {
int currentLength = length;
if (currentLength + 4 > data.length) {
enlarge(4);
}
byte[] currentData = data;
currentData[currentLength++] = (byte) (intValue >>> 24);
currentData[currentLength++] = (byte) (intValue >>> 16);
currentData[currentLength++] = (byte) (intValue >>> 8);
currentData[currentLength++] = (byte) intValue;
length = currentLength;
return this;
} | java | {
"resource": ""
} |
q171347 | ByteVector.put122 | test | final ByteVector put122(final int byteValue, final int shortValue1, final int shortValue2) {
int currentLength = length;
if (currentLength + 5 > data.length) {
enlarge(5);
}
byte[] currentData = data;
currentData[currentLength++] = (byte) byteValue;
currentData[currentLength++] = (byte) (shortValue1 >>> 8);
currentData[currentLength++] = (byte) shortValue1;
currentData[currentLength++] = (byte) (shortValue2 >>> 8);
currentData[currentLength++] = (byte) shortValue2;
length = currentLength;
return this;
} | java | {
"resource": ""
} |
q171348 | ByteVector.putLong | test | public ByteVector putLong(final long longValue) {
int currentLength = length;
if (currentLength + 8 > data.length) {
enlarge(8);
}
byte[] currentData = data;
int intValue = (int) (longValue >>> 32);
currentData[currentLength++] = (byte) (intValue >>> 24);
currentData[currentLength++] = (byte) (intValue >>> 16);
currentData[currentLength++] = (byte) (intValue >>> 8);
currentData[currentLength++] = (byte) intValue;
intValue = (int) longValue;
currentData[currentLength++] = (byte) (intValue >>> 24);
currentData[currentLength++] = (byte) (intValue >>> 16);
currentData[currentLength++] = (byte) (intValue >>> 8);
currentData[currentLength++] = (byte) intValue;
length = currentLength;
return this;
} | java | {
"resource": ""
} |
q171349 | ByteVector.putByteArray | test | public ByteVector putByteArray(
final byte[] byteArrayValue, final int byteOffset, final int byteLength) {
if (length + byteLength > data.length) {
enlarge(byteLength);
}
if (byteArrayValue != null) {
System.arraycopy(byteArrayValue, byteOffset, data, length, byteLength);
}
length += byteLength;
return this;
} | java | {
"resource": ""
} |
q171350 | ByteVector.enlarge | test | private void enlarge(final int size) {
int doubleCapacity = 2 * data.length;
int minimalCapacity = length + size;
byte[] newData = new byte[doubleCapacity > minimalCapacity ? doubleCapacity : minimalCapacity];
System.arraycopy(data, 0, newData, 0, length);
data = newData;
} | java | {
"resource": ""
} |
q171351 | AuthInterceptor.authenticateUserViaHttpSession | test | protected T authenticateUserViaHttpSession(final ActionRequest actionRequest) {
final HttpServletRequest servletRequest = actionRequest.getHttpServletRequest();
final UserSession<T> userSession = UserSession.get(servletRequest);
if (userSession == null) {
return null;
}
final T authToken = userSession.getAuthToken();
if (authToken == null) {
return null;
}
// granted
final T newAuthToken = userAuth().rotateToken(authToken);
if (newAuthToken != authToken) {
final UserSession<T> newUserSesion = new UserSession<>(newAuthToken, userAuth().tokenValue(newAuthToken));
newUserSesion.start(servletRequest, actionRequest.getHttpServletResponse());
}
return newAuthToken;
} | java | {
"resource": ""
} |
q171352 | AuthInterceptor.authenticateUserViaToken | test | protected T authenticateUserViaToken(final ActionRequest actionRequest) {
final HttpServletRequest servletRequest = actionRequest.getHttpServletRequest();
// then try the auth token
final String token = ServletUtil.resolveAuthBearerToken(servletRequest);
if (token == null) {
return null;
}
final T authToken = userAuth().validateToken(token);
if (authToken == null) {
return null;
}
// granted
final T newAuthToken = userAuth().rotateToken(authToken);
actionRequest.getHttpServletResponse().setHeader("Authentication", "Bearer: " + userAuth().tokenValue(newAuthToken));
return newAuthToken;
} | java | {
"resource": ""
} |
q171353 | AuthInterceptor.authenticateUserViaBasicAuth | test | protected T authenticateUserViaBasicAuth(final ActionRequest actionRequest) {
final HttpServletRequest servletRequest = actionRequest.getHttpServletRequest();
final String username = ServletUtil.resolveAuthUsername(servletRequest);
if (username == null) {
return null;
}
final String password = ServletUtil.resolveAuthPassword(servletRequest);
final T authToken = userAuth().login(username, password);
if (authToken == null) {
return null;
}
return authToken;
} | java | {
"resource": ""
} |
q171354 | ResourceBundleMessageResolver.findDefaultMessage | test | public String findDefaultMessage(final Locale locale, final String key) {
String indexedKey = calcIndexKey(key);
String msg = getMessage(fallbackBundlename, locale, key, indexedKey);
if (msg != null) {
return msg;
}
for (String bname : defaultBundles) {
msg = getMessage(bname, locale, key, indexedKey);
if (msg != null) {
return msg;
}
}
return null;
} | java | {
"resource": ""
} |
q171355 | ResourceBundleMessageResolver.getBundle | test | protected ResourceBundle getBundle(final String bundleName, final Locale locale, final ClassLoader classLoader) {
return ResourceBundle.getBundle(bundleName, locale, classLoader);
} | java | {
"resource": ""
} |
q171356 | ArraysJsonSerializer.get | test | protected K get(final K[] array, final int index) {
return (K) Array.get(array, index);
} | java | {
"resource": ""
} |
q171357 | GenericDao.setEntityId | test | protected <E, ID> void setEntityId(final DbEntityDescriptor<E> ded, final E entity, final ID newIdValue) {
ded.setIdValue(entity, newIdValue);
} | java | {
"resource": ""
} |
q171358 | GenericDao.save | test | public void save(final Object entity) {
final DbQuery q = query(dbOom.entities().insert(entity));
q.autoClose().executeUpdate();
} | java | {
"resource": ""
} |
q171359 | GenericDao.update | test | public void update(final Object entity) {
query(dbOom.entities().updateAll(entity)).autoClose().executeUpdate();
} | java | {
"resource": ""
} |
q171360 | GenericDao.updateProperty | test | public <E> E updateProperty(final E entity, final String name, final Object newValue) {
query(dbOom.entities().updateColumn(entity, name, newValue)).autoClose().executeUpdate();
BeanUtil.declared.setProperty(entity, name, newValue);
return entity;
} | java | {
"resource": ""
} |
q171361 | GenericDao.updateProperty | test | public <E> E updateProperty(final E entity, final String name) {
Object value = BeanUtil.declared.getProperty(entity, name);
query(dbOom.entities().updateColumn(entity, name, value)).autoClose().executeUpdate();
return entity;
} | java | {
"resource": ""
} |
q171362 | GenericDao.findById | test | public <E, ID> E findById(final Class<E> entityType, final ID id) {
return query(dbOom.entities().findById(entityType, id)).autoClose().find(entityType);
} | java | {
"resource": ""
} |
q171363 | GenericDao.findOneByProperty | test | public <E> E findOneByProperty(final Class<E> entityType, final String name, final Object value) {
return query(dbOom.entities().findByColumn(entityType, name, value)).autoClose().find(entityType);
} | java | {
"resource": ""
} |
q171364 | GenericDao.findOne | test | @SuppressWarnings({"unchecked"})
public <E> E findOne(final Object criteria) {
return (E) query(dbOom.entities().find(criteria)).autoClose().find(criteria.getClass());
} | java | {
"resource": ""
} |
q171365 | GenericDao.deleteById | test | public <ID> void deleteById(final Class entityType, final ID id) {
query(dbOom.entities().deleteById(entityType, id)).autoClose().executeUpdate();
} | java | {
"resource": ""
} |
q171366 | GenericDao.deleteById | test | public void deleteById(final Object entity) {
if (entity != null) {
int result = query(dbOom.entities().deleteById(entity)).autoClose().executeUpdate();
if (result != 0) {
// now reset the ID value
Class type = entity.getClass();
DbEntityDescriptor ded = dbOom.entityManager().lookupType(type);
setEntityId(ded, entity, 0);
}
}
} | java | {
"resource": ""
} |
q171367 | GenericDao.count | test | public long count(final Class entityType) {
return query(dbOom.entities().count(entityType)).autoClose().executeCount();
} | java | {
"resource": ""
} |
q171368 | GenericDao.increaseProperty | test | public <ID> void increaseProperty(final Class entityType, final ID id, final String name, final Number delta) {
query(dbOom.entities().increaseColumn(entityType, id, name, delta, true)).autoClose().executeUpdate();
} | java | {
"resource": ""
} |
q171369 | GenericDao.decreaseProperty | test | public <ID> void decreaseProperty(final Class entityType, final ID id, final String name, final Number delta) {
query(dbOom.entities().increaseColumn(entityType, id, name, delta, false)).autoClose().executeUpdate();
} | java | {
"resource": ""
} |
q171370 | GenericDao.findRelated | test | public <E> List<E> findRelated(final Class<E> target, final Object source) {
return query(dbOom.entities().findForeign(target, source)).autoClose().list(target);
} | java | {
"resource": ""
} |
q171371 | GenericDao.listAll | test | public <E> List<E> listAll(final Class<E> target) {
return query(dbOom.entities().from(target)).autoClose().list(target);
} | java | {
"resource": ""
} |
q171372 | StringKeyedMapAdapter.clear | test | @Override
public void clear() {
entries = null;
Iterator<String> keys = getAttributeNames();
while (keys.hasNext()) {
removeAttribute(keys.next());
}
} | java | {
"resource": ""
} |
q171373 | StringKeyedMapAdapter.entrySet | test | @Override
public Set<Entry<String, Object>> entrySet() {
if (entries == null) {
entries = new HashSet<>();
Iterator<String> iterator = getAttributeNames();
while (iterator.hasNext()) {
final String key = iterator.next();
final Object value = getAttribute(key);
entries.add(new Entry<String, Object>() {
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (this.getClass() != obj.getClass()) {
return false;
}
Entry entry = (Entry) obj;
return ((key == null) ? (entry.getKey() == null) : key.equals(entry.getKey())) && ((value == null) ? (entry.getValue() == null) : value.equals(entry.getValue()));
}
@Override
public int hashCode() {
return ((key == null) ? 0 : key.hashCode()) ^ ((value == null) ? 0 : value.hashCode());
}
@Override
public String getKey() {
return key;
}
@Override
public Object getValue() {
return value;
}
@Override
public Object setValue(final Object obj) {
setAttribute(key, obj);
return value;
}
});
}
}
return entries;
} | java | {
"resource": ""
} |
q171374 | StringKeyedMapAdapter.put | test | @Override
public Object put(final String key, final Object value) {
entries = null;
Object previous = get(key);
setAttribute(key, value);
return previous;
} | java | {
"resource": ""
} |
q171375 | StringKeyedMapAdapter.remove | test | @Override
public Object remove(final Object key) {
entries = null;
Object value = get(key);
removeAttribute(key.toString());
return value;
} | java | {
"resource": ""
} |
q171376 | ExceptionUtil.getCurrentStackTrace | test | @SuppressWarnings({"ThrowCaughtLocally"})
public static StackTraceElement[] getCurrentStackTrace() {
StackTraceElement[] ste = new Exception().getStackTrace();
if (ste.length > 1) {
StackTraceElement[] result = new StackTraceElement[ste.length - 1];
System.arraycopy(ste, 1, result, 0, ste.length - 1);
return result;
} else {
return ste;
}
} | java | {
"resource": ""
} |
q171377 | ExceptionUtil.getStackTrace | test | public static StackTraceElement[] getStackTrace(final Throwable t, final String[] allow, final String[] deny) {
StackTraceElement[] st = t.getStackTrace();
ArrayList<StackTraceElement> result = new ArrayList<>(st.length);
elementLoop:
for (StackTraceElement element : st) {
String className = element.getClassName();
if (allow != null) {
boolean validElemenet = false;
for (String filter : allow) {
if (className.contains(filter)) {
validElemenet = true;
break;
}
}
if (!validElemenet) {
continue;
}
}
if (deny != null) {
for (String filter : deny) {
if (className.contains(filter)) {
continue elementLoop;
}
}
}
result.add(element);
}
st = new StackTraceElement[result.size()];
return result.toArray(st);
} | java | {
"resource": ""
} |
q171378 | ExceptionUtil.getStackTraceChain | test | public static StackTraceElement[][] getStackTraceChain(Throwable t, final String[] allow, final String[] deny) {
ArrayList<StackTraceElement[]> result = new ArrayList<>();
while (t != null) {
StackTraceElement[] stack = getStackTrace(t, allow, deny);
result.add(stack);
t = t.getCause();
}
StackTraceElement[][] allStacks = new StackTraceElement[result.size()][];
for (int i = 0; i < allStacks.length; i++) {
allStacks[i] = result.get(i);
}
return allStacks;
} | java | {
"resource": ""
} |
q171379 | ExceptionUtil.getExceptionChain | test | public static Throwable[] getExceptionChain(Throwable throwable) {
ArrayList<Throwable> list = new ArrayList<>();
list.add(throwable);
while ((throwable = throwable.getCause()) != null) {
list.add(throwable);
}
Throwable[] result = new Throwable[list.size()];
return list.toArray(result);
} | java | {
"resource": ""
} |
q171380 | ExceptionUtil.exceptionStackTraceToString | test | public static String exceptionStackTraceToString(final Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
t.printStackTrace(pw);
StreamUtil.close(pw);
StreamUtil.close(sw);
return sw.toString();
} | java | {
"resource": ""
} |
q171381 | ExceptionUtil.exceptionChainToString | test | public static String exceptionChainToString(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
while (t != null) {
t.printStackTrace(pw);
t = t.getCause();
}
StreamUtil.close(pw);
StreamUtil.close(sw);
return sw.toString();
} | java | {
"resource": ""
} |
q171382 | ExceptionUtil.buildMessage | test | public static String buildMessage(final String message, Throwable cause) {
if (cause != null) {
cause = getRootCause(cause);
StringBuilder buf = new StringBuilder();
if (message != null) {
buf.append(message).append("; ");
}
buf.append("<--- ").append(cause);
return buf.toString();
} else {
return message;
}
} | java | {
"resource": ""
} |
q171383 | ExceptionUtil.unwrapThrowable | test | public static Throwable unwrapThrowable(final Throwable wrappedThrowable) {
Throwable unwrapped = wrappedThrowable;
while (true) {
if (unwrapped instanceof InvocationTargetException) {
unwrapped = ((InvocationTargetException) unwrapped).getTargetException();
}
else if (unwrapped instanceof UndeclaredThrowableException) {
unwrapped = ((UndeclaredThrowableException) unwrapped).getUndeclaredThrowable();
}
else {
return unwrapped;
}
}
} | java | {
"resource": ""
} |
q171384 | AutomagicMadvocConfigurator.registerAsConsumer | test | protected void registerAsConsumer(final ClassScanner classScanner) {
classScanner.registerEntryConsumer(classPathEntry -> {
final String entryName = classPathEntry.name();
if (entryName.endsWith(actionClassSuffix)) {
try {
acceptActionClass(classPathEntry.loadClass());
} catch (Exception ex) {
log.debug("Invalid Madvoc action, ignoring: " + entryName);
}
}
else if (classPathEntry.isTypeSignatureInUse(MADVOC_COMPONENT_ANNOTATION)) {
try {
acceptMadvocComponentClass(classPathEntry.loadClass());
} catch (Exception ex) {
log.debug("Invalid Madvoc component ignoring: {}" + entryName);
}
}
});
} | java | {
"resource": ""
} |
q171385 | AutomagicMadvocConfigurator.acceptMadvocComponentClass | test | protected void acceptMadvocComponentClass(final Class componentClass) {
if (componentClass == null) {
return;
}
if (!checkClass(componentClass)) {
return;
}
madvocComponents.add(() -> madvocContainer.registerComponent(componentClass));
} | java | {
"resource": ""
} |
q171386 | ClassLoaderUtil.getSystemClassLoader | test | public static ClassLoader getSystemClassLoader() {
if (System.getSecurityManager() == null) {
return ClassLoader.getSystemClassLoader();
}
else {
return AccessController.doPrivileged(
(PrivilegedAction<ClassLoader>) ClassLoader::getSystemClassLoader);
}
} | java | {
"resource": ""
} |
q171387 | ClassLoaderUtil.getResourceAsStream | test | public static InputStream getResourceAsStream(final String resourceName, final ClassLoader callingClass) throws IOException {
URL url = getResourceUrl(resourceName, callingClass);
if (url != null) {
return url.openStream();
}
return null;
} | java | {
"resource": ""
} |
q171388 | ClassLoaderUtil.getResourceAsStream | test | public static InputStream getResourceAsStream(final String resourceName, final ClassLoader callingClass, final boolean useCache) throws IOException {
URL url = getResourceUrl(resourceName, callingClass);
if (url != null) {
URLConnection urlConnection = url.openConnection();
urlConnection.setUseCaches(useCache);
return urlConnection.getInputStream();
}
return null;
} | java | {
"resource": ""
} |
q171389 | ClassLoaderUtil.getClassAsStream | test | public static InputStream getClassAsStream(final Class clazz) throws IOException {
return getResourceAsStream(ClassUtil.convertClassNameToFileName(clazz), clazz.getClassLoader());
} | java | {
"resource": ""
} |
q171390 | ClassLoaderUtil.getClassAsStream | test | public static InputStream getClassAsStream(final String className, final ClassLoader classLoader) throws IOException {
return getResourceAsStream(ClassUtil.convertClassNameToFileName(className), classLoader);
} | java | {
"resource": ""
} |
q171391 | RouteChunk.add | test | public RouteChunk add(final String newValue) {
RouteChunk routeChunk = new RouteChunk(routes, this, newValue);
if (children == null) {
children = new RouteChunk[] {routeChunk};
}
else {
children = ArraysUtil.append(children, routeChunk);
}
return routeChunk;
} | java | {
"resource": ""
} |
q171392 | RouteChunk.findOrCreateChild | test | public RouteChunk findOrCreateChild(final String value) {
if (children != null) {
for (RouteChunk child : children) {
if (child.get().equals(value)) {
return child;
}
}
}
return add(value);
} | java | {
"resource": ""
} |
q171393 | MultipartRequest.parseRequest | test | public void parseRequest() throws IOException {
if (ServletUtil.isMultipartRequest(request)) {
parseRequestStream(request.getInputStream(), characterEncoding);
} else {
Enumeration names = request.getParameterNames();
while (names.hasMoreElements()) {
String paramName = (String) names.nextElement();
String[] values = request.getParameterValues(paramName);
putParameters(paramName, values);
}
}
} | java | {
"resource": ""
} |
q171394 | BeanUtilUtil.convertToCollection | test | @SuppressWarnings("unchecked")
protected Object convertToCollection(final Object value, final Class destinationType, final Class componentType) {
return typeConverterManager.convertToCollection(value, destinationType, componentType);
} | java | {
"resource": ""
} |
q171395 | BeanUtilUtil.invokeSetter | test | protected Object invokeSetter(final Setter setter, final BeanProperty bp, Object value) {
try {
final MapperFunction setterMapperFunction = setter.getMapperFunction();
if (setterMapperFunction != null) {
value = setterMapperFunction.apply(value);
}
final Class type = setter.getSetterRawType();
if (ClassUtil.isTypeOf(type, Collection.class)) {
Class componentType = setter.getSetterRawComponentType();
value = convertToCollection(value, type, componentType);
} else {
// no collections
value = convertType(value, type);
}
setter.invokeSetter(bp.bean, value);
} catch (Exception ex) {
if (isSilent) {
return null;
}
throw new BeanException("Setter failed: " + setter, ex);
}
return value;
} | java | {
"resource": ""
} |
q171396 | BeanUtilUtil.arrayForcedSet | test | protected void arrayForcedSet(final BeanProperty bp, Object array, final int index, Object value) {
Class componentType = array.getClass().getComponentType();
array = ensureArraySize(bp, array, componentType, index);
value = convertType(value, componentType);
Array.set(array, index, value);
} | java | {
"resource": ""
} |
q171397 | BeanUtilUtil.createBeanProperty | test | protected Object createBeanProperty(final BeanProperty bp) {
Setter setter = bp.getSetter(true);
if (setter == null) {
return null;
}
Class type = setter.getSetterRawType();
Object newInstance;
try {
newInstance = ClassUtil.newInstance(type);
} catch (Exception ex) {
if (isSilent) {
return null;
}
throw new BeanException("Invalid property: " + bp.name, bp, ex);
}
newInstance = invokeSetter(setter, bp, newInstance);
return newInstance;
} | java | {
"resource": ""
} |
q171398 | BeanUtilUtil.extractType | test | protected Class extractType(final BeanProperty bp) {
Getter getter = bp.getGetter(isDeclared);
if (getter != null) {
if (bp.index != null) {
Class type = getter.getGetterRawComponentType();
return type == null ? Object.class : type;
}
return getter.getGetterRawType();
}
return null; // this should not happens
} | java | {
"resource": ""
} |
q171399 | UserSession.stop | test | public static void stop(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) {
final HttpSession httpSession = servletRequest.getSession(false);
if (httpSession != null) {
httpSession.removeAttribute(AUTH_SESSION_NAME);
}
final Cookie cookie = ServletUtil.getCookie(servletRequest, AUTH_COOKIE_NAME);
if (cookie == null) {
return;
}
cookie.setMaxAge(0);
cookie.setPath("/");
servletResponse.addCookie(cookie);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.