_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q170800 | HttpRequest.hostUrl | test | public String hostUrl() {
StringBand url = new StringBand(8);
if (protocol != null) {
url.append(protocol);
url.append("://");
}
if (host != null) {
url.append(host);
}
if (port != Defaults.DEFAULT_PORT) {
url.append(':');
url.append(port);
}
return url.toString();
} | java | {
"resource": ""
} |
q170801 | HttpRequest.basicAuthentication | test | public HttpRequest basicAuthentication(final String username, final String password) {
if (username != null && password != null) {
String data = username.concat(StringPool.COLON).concat(password);
String base64 = Base64.encodeToString(data);
headerOverwrite(HEADER_AUTHORIZATION, "Basic " + base64);
}
return this;
} | java | {
"resource": ""
} |
q170802 | HttpRequest.setHostHeader | test | public HttpRequest setHostHeader() {
String hostPort = this.host;
if (port != Defaults.DEFAULT_PORT) {
hostPort += StringPool.COLON + port;
}
headerOverwrite(HEADER_HOST, hostPort);
return this;
} | java | {
"resource": ""
} |
q170803 | HttpRequest.buffer | test | @Override
protected Buffer buffer(final boolean fullRequest) {
// INITIALIZATION
// host port
if (header(HEADER_HOST) == null) {
setHostHeader();
}
// form
Buffer formBuffer = formBuffer();
// query string
String queryString = queryString();
// user-agent
if (header("User-Agent") == null) {
header("User-Agent", Defaults.userAgent);
}
// POST method requires Content-Type to be set
if (method.equals("POST") && (contentLength() == null)) {
contentLength(0);
}
// BUILD OUT
Buffer request = new Buffer();
request.append(method)
.append(SPACE)
.append(path);
if (query != null && !query.isEmpty()) {
request.append('?');
request.append(queryString);
}
request.append(SPACE)
.append(httpVersion)
.append(CRLF);
populateHeaderAndBody(request, formBuffer, fullRequest);
return request;
} | java | {
"resource": ""
} |
q170804 | HttpRequest.sendAndReceive | test | public <R> R sendAndReceive(final Function<HttpResponse, R> responseHandler) {
return responseHandler.apply(send());
} | java | {
"resource": ""
} |
q170805 | Handler.removeRange | test | static Handler removeRange(final Handler firstHandler, final Label start, final Label end) {
if (firstHandler == null) {
return null;
} else {
firstHandler.nextHandler = removeRange(firstHandler.nextHandler, start, end);
}
int handlerStart = firstHandler.startPc.bytecodeOffset;
int handlerEnd = firstHandler.endPc.bytecodeOffset;
int rangeStart = start.bytecodeOffset;
int rangeEnd = end == null ? Integer.MAX_VALUE : end.bytecodeOffset;
// Return early if [handlerStart,handlerEnd[ and [rangeStart,rangeEnd[ don't intersect.
if (rangeStart >= handlerEnd || rangeEnd <= handlerStart) {
return firstHandler;
}
if (rangeStart <= handlerStart) {
if (rangeEnd >= handlerEnd) {
// If [handlerStart,handlerEnd[ is included in [rangeStart,rangeEnd[, remove firstHandler.
return firstHandler.nextHandler;
} else {
// [handlerStart,handlerEnd[ - [rangeStart,rangeEnd[ = [rangeEnd,handlerEnd[
return new Handler(firstHandler, end, firstHandler.endPc);
}
} else if (rangeEnd >= handlerEnd) {
// [handlerStart,handlerEnd[ - [rangeStart,rangeEnd[ = [handlerStart,rangeStart[
return new Handler(firstHandler, firstHandler.startPc, start);
} else {
// [handlerStart,handlerEnd[ - [rangeStart,rangeEnd[ =
// [handlerStart,rangeStart[ + [rangeEnd,handerEnd[
firstHandler.nextHandler = new Handler(firstHandler, end, firstHandler.endPc);
return new Handler(firstHandler, firstHandler.startPc, start);
}
} | java | {
"resource": ""
} |
q170806 | Handler.getExceptionTableLength | test | static int getExceptionTableLength(final Handler firstHandler) {
int length = 0;
Handler handler = firstHandler;
while (handler != null) {
length++;
handler = handler.nextHandler;
}
return length;
} | java | {
"resource": ""
} |
q170807 | MadvocConfigurations.collectActionInterceptors | test | protected void collectActionInterceptors() {
final Collection<? extends ActionInterceptor> interceptorValues = interceptorsManager.getAllInterceptors();
interceptors = new ArrayList<>();
interceptors.addAll(interceptorValues);
interceptors.sort(Comparator.comparing(a -> a.getClass().getSimpleName()));
} | java | {
"resource": ""
} |
q170808 | MadvocConfigurations.collectActionFilters | test | protected void collectActionFilters() {
final Collection<? extends ActionFilter> filterValues = filtersManager.getAllFilters();
filters = new ArrayList<>();
filters.addAll(filterValues);
filters.sort(Comparator.comparing(a -> a.getClass().getSimpleName()));
} | java | {
"resource": ""
} |
q170809 | MadvocConfigurations.collectActionResults | test | protected void collectActionResults() {
final Collection<ActionResult> resultsValues = resultsManager.getAllActionResults();
results = new ArrayList<>();
results.addAll(resultsValues);
results.sort(Comparator.comparing(a -> a.getClass().getSimpleName()));
} | java | {
"resource": ""
} |
q170810 | MadvocConfigurations.collectActionRuntimes | test | protected void collectActionRuntimes() {
actions = actionsManager.getAllActionRuntimes();
actions.sort(Comparator.comparing(ActionRuntime::getActionPath));
} | java | {
"resource": ""
} |
q170811 | BeanUtilBean.setSimpleProperty | test | @SuppressWarnings({"unchecked"})
protected void setSimpleProperty(final BeanProperty bp, final Object value) {
Setter setter = bp.getSetter(isDeclared);
// try: setter
if (setter != null) {
invokeSetter(setter, bp, value);
return;
}
// try: put("property", value)
if (bp.isMap()) {
((Map) bp.bean).put(bp.name, value);
return;
}
if (isSilent) {
return;
}
throw new BeanException("Simple property not found: " + bp.name, bp);
} | java | {
"resource": ""
} |
q170812 | BeanUtilBean.getProperty | test | @Override
public <T> T getProperty(final Object bean, final String name) {
BeanProperty beanProperty = new BeanProperty(this, bean, name);
if (!isSilent) {
resolveNestedProperties(beanProperty);
return (T) getIndexProperty(beanProperty);
}
else {
try {
resolveNestedProperties(beanProperty);
return (T) getIndexProperty(beanProperty);
}
catch (Exception ignore) {
return null;
}
}
} | java | {
"resource": ""
} |
q170813 | BeanUtilBean.extractThisReference | test | @Override
public String extractThisReference(final String propertyName) {
int ndx = StringUtil.indexOfChars(propertyName, INDEX_CHARS);
if (ndx == -1) {
return propertyName;
}
return propertyName.substring(0, ndx);
} | java | {
"resource": ""
} |
q170814 | CharArrayResponseWrapper.getWriter | test | @Override
public PrintWriter getWriter() {
if (writer == null) {
writer = new FastCharArrayWriter();
printWriter = new PrintWriter(writer);
}
return printWriter;
} | java | {
"resource": ""
} |
q170815 | TemplateData.setObjectReference | test | public void setObjectReference(final String name, final Object object) {
if (objectRefs == null) {
objectRefs = new HashMap<>();
}
objectRefs.put(name, object);
} | java | {
"resource": ""
} |
q170816 | TemplateData.getObjectReference | test | public Object getObjectReference(final String name) {
if (objectRefs == null) {
return null;
}
return objectRefs.get(name);
} | java | {
"resource": ""
} |
q170817 | TemplateData.lookupObject | test | public Object lookupObject(final String ref) {
Object value = getObjectReference(ref);
if (value == null) {
throw new DbSqlBuilderException("Invalid object reference: " + ref);
}
return value;
} | java | {
"resource": ""
} |
q170818 | TemplateData.getTableDescriptor | test | public DbEntityDescriptor getTableDescriptor(final String tableRef) {
if (tableRefs == null) {
return null;
}
TableRefData t = tableRefs.get(tableRef);
return t == null ? null : t.desc;
} | java | {
"resource": ""
} |
q170819 | TemplateData.findTableDescriptorByColumnRef | test | public DbEntityDescriptor findTableDescriptorByColumnRef(final String columnRef) {
for (Map.Entry<String, TableRefData> entry : tableRefs.entrySet()) {
DbEntityDescriptor ded = entry.getValue().desc;
if (ded.findByPropertyName(columnRef) != null) {
return ded;
}
}
return null;
} | java | {
"resource": ""
} |
q170820 | TemplateData.getTableAlias | test | public String getTableAlias(final String tableRef) {
if (tableRefs == null) {
return null;
}
TableRefData t = tableRefs.get(tableRef);
return t == null ? null : t.alias;
} | java | {
"resource": ""
} |
q170821 | TemplateData.registerTableReference | test | public void registerTableReference(final String tableReference, final DbEntityDescriptor ded, final String tableAlias) {
if (tableRefs == null) {
tableRefs = new HashMap<>();
}
TableRefData t = new TableRefData(ded, tableAlias);
if (tableRefs.put(tableReference, t) != null) {
throw new DbSqlBuilderException("Duplicated table reference: " + tableReference);
}
} | java | {
"resource": ""
} |
q170822 | TemplateData.lookupTableRef | test | protected DbEntityDescriptor lookupTableRef(final String tableRef) {
DbEntityDescriptor ded = getTableDescriptor(tableRef);
if (ded == null) {
throw new DbSqlBuilderException("Table reference not used in this query: " + tableRef);
}
return ded;
} | java | {
"resource": ""
} |
q170823 | TemplateData.registerHint | test | public void registerHint(final String hint) {
if (hints == null) {
hints = new ArrayList<>(hintCount);
}
hints.add(hint);
} | java | {
"resource": ""
} |
q170824 | ValueJsonSerializer.serialize | test | @Override
public final boolean serialize(final JsonContext jsonContext, final T value) {
if (jsonContext.pushValue(value)) {
// prevent circular dependencies
return false;
}
serializeValue(jsonContext, value);
jsonContext.popValue();
return true;
} | java | {
"resource": ""
} |
q170825 | RequestScope.injectAttributes | test | protected void injectAttributes(final HttpServletRequest servletRequest, final Targets targets) {
final Enumeration<String> attributeNames = servletRequest.getAttributeNames();
while (attributeNames.hasMoreElements()) {
final String attrName = attributeNames.nextElement();
targets.forEachTargetAndIn(this, (target, in) -> {
final String name = in.matchedName(attrName);
if (name != null) {
final Object attrValue = servletRequest.getAttribute(attrName);
target.writeValue(name, attrValue, true);
}
});
}
} | java | {
"resource": ""
} |
q170826 | RequestScope.injectParameters | test | protected void injectParameters(final HttpServletRequest servletRequest, final Targets targets) {
final boolean encode = encodeGetParams && servletRequest.getMethod().equals("GET");
final Enumeration<String> paramNames = servletRequest.getParameterNames();
while (paramNames.hasMoreElements()) {
final String paramName = paramNames.nextElement();
if (servletRequest.getAttribute(paramName) != null) {
continue;
}
targets.forEachTargetAndIn(this, (target, in) -> {
final String name = in.matchedName(paramName);
if (name != null) {
String[] paramValues = servletRequest.getParameterValues(paramName);
paramValues = ServletUtil.prepareParameters(
paramValues, treatEmptyParamsAsNull, ignoreEmptyRequestParams);
if (paramValues != null) {
if (encode) {
for (int j = 0; j < paramValues.length; j++) {
final String p = paramValues[j];
if (p != null) {
final String encoding = madvocEncoding.getEncoding();
paramValues[j] = StringUtil.convertCharset(p, StringPool.ISO_8859_1, encoding);
}
}
}
final Object value = (paramValues.length != 1 ? paramValues : paramValues[0]);
target.writeValue(name, value, true);
}
}
});
}
} | java | {
"resource": ""
} |
q170827 | RequestScope.injectUploadedFiles | test | protected void injectUploadedFiles(final HttpServletRequest servletRequest, final Targets targets) {
if (!(servletRequest instanceof MultipartRequestWrapper)) {
return;
}
final MultipartRequestWrapper multipartRequest = (MultipartRequestWrapper) servletRequest;
if (!multipartRequest.isMultipart()) {
return;
}
final Enumeration<String> paramNames = multipartRequest.getFileParameterNames();
while (paramNames.hasMoreElements()) {
final String paramName = paramNames.nextElement();
if (servletRequest.getAttribute(paramName) != null) {
continue;
}
targets.forEachTargetAndIn(this, (target, in) -> {
final String name = in.matchedName(paramName);
if (name != null) {
final FileUpload[] paramValues = multipartRequest.getFiles(paramName);
if (ignoreInvalidUploadFiles) {
for (int j = 0; j < paramValues.length; j++) {
final FileUpload paramValue = paramValues[j];
if ((!paramValue.isValid()) || (!paramValue.isUploaded())) {
paramValues[j] = null;
}
}
}
final Object value = (paramValues.length == 1 ? paramValues[0] : paramValues);
target.writeValue(name, value, true);
}
});
}
} | java | {
"resource": ""
} |
q170828 | ColumnNamingStrategy.convertPropertyNameToColumnName | test | public String convertPropertyNameToColumnName(final String propertyName) {
StringBuilder tableName = new StringBuilder(propertyName.length() * 2);
if (splitCamelCase) {
String convertedTableName = Format.fromCamelCase(propertyName, separatorChar);
tableName.append(convertedTableName);
} else {
tableName.append(propertyName);
}
if (!changeCase) {
return tableName.toString();
}
return uppercase ?
toUppercase(tableName).toString() :
toLowercase(tableName).toString();
} | java | {
"resource": ""
} |
q170829 | ColumnNamingStrategy.convertColumnNameToPropertyName | test | public String convertColumnNameToPropertyName(final String columnName) {
StringBuilder propertyName = new StringBuilder(columnName.length());
int len = columnName.length();
if (splitCamelCase) {
boolean toUpper = false;
for (int i = 0; i < len; i++) {
char c = columnName.charAt(i);
if (c == separatorChar) {
toUpper = true;
continue;
}
if (toUpper) {
propertyName.append(Character.toUpperCase(c));
toUpper = false;
} else {
propertyName.append(Character.toLowerCase(c));
}
}
return propertyName.toString();
}
return columnName;
} | java | {
"resource": ""
} |
q170830 | ColumnNamingStrategy.applyToColumnName | test | public String applyToColumnName(final String columnName) {
String propertyName = convertColumnNameToPropertyName(columnName);
return convertPropertyNameToColumnName(propertyName);
} | java | {
"resource": ""
} |
q170831 | SqlType.storeValue | test | public void storeValue(final PreparedStatement st, final int index, final Object value, final int dbSqlType) throws SQLException {
T t = TypeConverterManager.get().convertType(value, sqlType);
set(st, index, t, dbSqlType);
} | java | {
"resource": ""
} |
q170832 | SqlType.prepareGetValue | test | @SuppressWarnings({"unchecked"})
protected <E> E prepareGetValue(final T t, final Class<E> destinationType) {
if (t == null) {
return null;
}
if (destinationType == null) {
return (E) t;
}
return TypeConverterManager.get().convertType(t, destinationType);
} | java | {
"resource": ""
} |
q170833 | WrapperManager.getAll | test | protected Set<T> getAll() {
final Set<T> set = new HashSet<>(wrappers.size());
set.addAll(wrappers.values());
return set;
} | java | {
"resource": ""
} |
q170834 | WrapperManager.resolve | test | public T resolve(final Class<? extends T> wrapperClass) {
String wrapperClassName = wrapperClass.getName();
T wrapper = lookup(wrapperClassName);
if (wrapper == null) {
wrapper = createWrapper(wrapperClass);
initializeWrapper(wrapper);
wrappers.put(wrapperClassName, wrapper);
}
return wrapper;
} | java | {
"resource": ""
} |
q170835 | WrapperManager.createWrapper | test | protected <R extends T> R createWrapper(final Class<R> wrapperClass) {
try {
return ClassUtil.newInstance(wrapperClass);
} catch (Exception ex) {
throw new MadvocException("Invalid Madvoc wrapper: " + wrapperClass, ex);
}
} | java | {
"resource": ""
} |
q170836 | FileNameUtil.separatorsToSystem | test | public static String separatorsToSystem(final String path) {
if (path == null) {
return null;
}
if (SYSTEM_SEPARATOR == WINDOWS_SEPARATOR) {
return separatorsToWindows(path);
} else {
return separatorsToUnix(path);
}
} | java | {
"resource": ""
} |
q170837 | FileNameUtil.doGetPath | test | private static String doGetPath(final String filename, final int separatorAdd) {
if (filename == null) {
return null;
}
int prefix = getPrefixLength(filename);
if (prefix < 0) {
return null;
}
int index = indexOfLastSeparator(filename);
int endIndex = index + separatorAdd;
if (prefix >= filename.length() || index < 0 || prefix >= endIndex) {
return StringPool.EMPTY;
}
return filename.substring(prefix, endIndex);
} | java | {
"resource": ""
} |
q170838 | FileNameUtil.split | test | public static String[] split(final String filename) {
String prefix = getPrefix(filename);
if (prefix == null) {
prefix = StringPool.EMPTY;
}
int lastSeparatorIndex = indexOfLastSeparator(filename);
int lastExtensionIndex = indexOfExtension(filename);
String path;
String baseName;
String extension;
if (lastSeparatorIndex == -1) {
path = StringPool.EMPTY;
if (lastExtensionIndex == -1) {
baseName = filename.substring(prefix.length());
extension = StringPool.EMPTY;
} else {
baseName = filename.substring(prefix.length(), lastExtensionIndex);
extension = filename.substring(lastExtensionIndex + 1);
}
} else {
path = filename.substring(prefix.length(), lastSeparatorIndex + 1);
if (lastExtensionIndex == -1) {
baseName = filename.substring(prefix.length() + path.length());
extension = StringPool.EMPTY;
} else {
baseName = filename.substring(prefix.length() + path.length(), lastExtensionIndex);
extension = filename.substring(lastExtensionIndex + 1);
}
}
return new String[] {prefix, path, baseName, extension};
} | java | {
"resource": ""
} |
q170839 | FileNameUtil.relativePath | test | public static String relativePath(final String targetPath, final String basePath) {
return new File(basePath).toPath().relativize(new File(targetPath).toPath()).toString();
} | java | {
"resource": ""
} |
q170840 | WebApp.registerComponent | test | public WebApp registerComponent(final Class<?> madvocComponent) {
Objects.requireNonNull(madvocComponent);
madvocComponents.add(ClassConsumer.of(madvocComponent));
return this;
} | java | {
"resource": ""
} |
q170841 | WebApp.withActionConfig | test | public <A extends ActionConfig> WebApp withActionConfig(final Class<A> actionConfigType, final Consumer<A> actionConfigConsumer) {
withRegisteredComponent(ActionConfigManager.class, acm -> acm.with(actionConfigType, actionConfigConsumer));
return this;
} | java | {
"resource": ""
} |
q170842 | WebApp.start | test | public WebApp start() {
log = LoggerFactory.getLogger(WebApp.class);
log.debug("Initializing Madvoc WebApp");
//// params & props
for (final Map<String, Object> params : paramsList) {
madvocContainer.defineParams(params);
}
for (final Props props : propsList) {
madvocContainer.defineParams(props);
}
propsList = null;
//// components
registerMadvocComponents();
madvocComponents.forEach(
madvocComponent -> madvocContainer.registerComponent(madvocComponent.type(), madvocComponent.consumer()));
madvocComponents = null;
madvocComponentInstances.forEach(madvocContainer::registerComponentInstance);
madvocComponentInstances = null;
configureDefaults();
//// listeners
madvocContainer.fireEvent(Init.class);
//// component configuration
componentConfigs.accept(madvocContainer);
componentConfigs = null;
initialized();
madvocContainer.fireEvent(Start.class);
if (!madvocRouterConsumers.isEmpty()) {
final MadvocRouter madvocRouter = MadvocRouter.create();
madvocContainer.registerComponentInstance(madvocRouter);
madvocRouterConsumers.accept(madvocRouter);
}
madvocRouterConsumers = null;
started();
madvocContainer.fireEvent(Ready.class);
ready();
return this;
} | java | {
"resource": ""
} |
q170843 | WebApp.configureDefaults | test | protected void configureDefaults() {
final ActionConfigManager actionConfigManager =
madvocContainer.lookupComponent(ActionConfigManager.class);
actionConfigManager.registerAnnotation(Action.class);
actionConfigManager.registerAnnotation(RestAction.class);
} | java | {
"resource": ""
} |
q170844 | WebApp.registerMadvocComponents | test | protected void registerMadvocComponents() {
if (madvocContainer == null) {
throw new MadvocException("Madvoc WebApp not initialized.");
}
log.debug("Registering Madvoc WebApp components");
madvocContainer.registerComponent(MadvocEncoding.class);
madvocContainer.registerComponentInstance(new ServletContextProvider(servletContext));
madvocContainer.registerComponent(ActionConfigManager.class);
madvocContainer.registerComponent(ActionMethodParamNameResolver.class);
madvocContainer.registerComponent(ActionMethodParser.class);
madvocContainer.registerComponent(ActionPathRewriter.class);
madvocContainer.registerComponent(ActionsManager.class);
madvocContainer.registerComponent(ContextInjectorComponent.class);
madvocContainer.registerComponent(InterceptorsManager.class);
madvocContainer.registerComponent(FiltersManager.class);
madvocContainer.registerComponent(MadvocController.class);
madvocContainer.registerComponent(RootPackages.class);
madvocContainer.registerComponent(ResultsManager.class);
madvocContainer.registerComponent(ResultMapper.class);
madvocContainer.registerComponent(ScopeResolver.class);
madvocContainer.registerComponent(ScopeDataInspector.class);
madvocContainer.registerComponent(AsyncActionExecutor.class);
madvocContainer.registerComponent(FileUploader.class);
} | java | {
"resource": ""
} |
q170845 | ClassScanner.excludeJars | test | public ClassScanner excludeJars(final String... excludedJars) {
for (final String excludedJar : excludedJars) {
rulesJars.exclude(excludedJar);
}
return this;
} | java | {
"resource": ""
} |
q170846 | ClassScanner.includeJars | test | public ClassScanner includeJars(final String... includedJars) {
for (final String includedJar : includedJars) {
rulesJars.include(includedJar);
}
return this;
} | java | {
"resource": ""
} |
q170847 | ClassScanner.includeEntries | test | public ClassScanner includeEntries(final String... includedEntries) {
for (final String includedEntry : includedEntries) {
rulesEntries.include(includedEntry);
}
return this;
} | java | {
"resource": ""
} |
q170848 | ClassScanner.excludeEntries | test | public ClassScanner excludeEntries(final String... excludedEntries) {
for (final String excludedEntry : excludedEntries) {
rulesEntries.exclude(excludedEntry);
}
return this;
} | java | {
"resource": ""
} |
q170849 | ClassScanner.scanJarFile | test | protected void scanJarFile(final File file) {
final ZipFile zipFile;
try {
zipFile = new ZipFile(file);
} catch (IOException ioex) {
if (!ignoreException) {
throw new FindFileException("Invalid zip: " + file.getName(), ioex);
}
return;
}
final Enumeration entries = zipFile.entries();
while (entries.hasMoreElements()) {
final ZipEntry zipEntry = (ZipEntry) entries.nextElement();
final String zipEntryName = zipEntry.getName();
try {
if (StringUtil.endsWithIgnoreCase(zipEntryName, CLASS_FILE_EXT)) {
final String entryName = prepareEntryName(zipEntryName, true);
final ClassPathEntry classPathEntry = new ClassPathEntry(entryName, zipFile, zipEntry);
try {
scanEntry(classPathEntry);
} finally {
classPathEntry.closeInputStream();
}
} else if (includeResources) {
final String entryName = prepareEntryName(zipEntryName, false);
final ClassPathEntry classPathEntry = new ClassPathEntry(entryName, zipFile, zipEntry);
try {
scanEntry(classPathEntry);
} finally {
classPathEntry.closeInputStream();
}
}
} catch (RuntimeException rex) {
if (!ignoreException) {
ZipUtil.close(zipFile);
throw rex;
}
}
}
ZipUtil.close(zipFile);
} | java | {
"resource": ""
} |
q170850 | ClassScanner.scanClassPath | test | protected void scanClassPath(final File root) {
String rootPath = root.getAbsolutePath();
if (!rootPath.endsWith(File.separator)) {
rootPath += File.separatorChar;
}
final FindFile ff = FindFile.create().includeDirs(false).recursive(true).searchPath(rootPath);
File file;
while ((file = ff.nextFile()) != null) {
final String filePath = file.getAbsolutePath();
try {
if (StringUtil.endsWithIgnoreCase(filePath, CLASS_FILE_EXT)) {
scanClassFile(filePath, rootPath, file, true);
} else if (includeResources) {
scanClassFile(filePath, rootPath, file, false);
}
} catch (RuntimeException rex) {
if (!ignoreException) {
throw rex;
}
}
}
} | java | {
"resource": ""
} |
q170851 | ClassScanner.bytecodeSignatureOfType | test | public static byte[] bytecodeSignatureOfType(final Class type) {
final String name = 'L' + type.getName().replace('.', '/') + ';';
return name.getBytes();
} | java | {
"resource": ""
} |
q170852 | ClassScanner.scan | test | public ClassScanner scan(final String... paths) {
for (final String path : paths) {
filesToScan.add(new File(path));
}
return this;
} | java | {
"resource": ""
} |
q170853 | ClassScanner.start | test | public void start() {
if (detectEntriesMode) {
rulesEntries.detectMode();
}
filesToScan.forEach(file -> {
final String path = file.getAbsolutePath();
if (StringUtil.endsWithIgnoreCase(path, JAR_FILE_EXT)) {
if (!acceptJar(file)) {
return;
}
scanJarFile(file);
} else if (file.isDirectory()) {
scanClassPath(file);
}
});
} | java | {
"resource": ""
} |
q170854 | DbJtxTransactionManager.createNewTransaction | test | @Override
protected JtxTransaction createNewTransaction(final JtxTransactionMode tm, final Object scope, final boolean active) {
return new DbJtxTransaction(this, tm, scope, active);
} | java | {
"resource": ""
} |
q170855 | ScopeResolver.defaultOrScopeType | test | @SuppressWarnings("unchecked")
public <S extends MadvocScope> S defaultOrScopeType(final Class<S> scopeClass) {
if (scopeClass == null) {
return (S) getOrInitScope(RequestScope.class);
}
return (S) getOrInitScope(scopeClass);
} | java | {
"resource": ""
} |
q170856 | ScopeResolver.getOrInitScope | test | protected MadvocScope getOrInitScope(final Class<? extends MadvocScope> madvocScopeType) {
for (final MadvocScope s : allScopes) {
if (s.getClass().equals(madvocScopeType)) {
return s;
}
}
// new scope detected
final MadvocScope newScope;
try {
newScope = madpc.createBean(madvocScopeType);
} catch (Exception ex) {
throw new MadvocException("Unable to create scope: " + madvocScopeType, ex);
}
allScopes.add(newScope);
return newScope;
} | java | {
"resource": ""
} |
q170857 | ScopeResolver.forScope | test | public void forScope(final Class<? extends MadvocScope> scopeType, final Consumer<MadvocScope> madvocScopeConsumer) {
final MadvocScope scope = getOrInitScope(scopeType);
madvocScopeConsumer.accept(scope);
} | java | {
"resource": ""
} |
q170858 | Base64.decode | test | public static byte[] decode(final char[] arr) {
int length = arr.length;
if (length == 0) {
return new byte[0];
}
int sndx = 0, endx = length - 1;
int pad = arr[endx] == '=' ? (arr[endx - 1] == '=' ? 2 : 1) : 0;
int cnt = endx - sndx + 1;
int sepCnt = length > 76 ? (arr[76] == '\r' ? cnt / 78 : 0) << 1 : 0;
int len = ((cnt - sepCnt) * 6 >> 3) - pad;
byte[] dest = new byte[len];
int d = 0;
for (int cc = 0, eLen = (len / 3) * 3; d < eLen;) {
int i = INV[arr[sndx++]] << 18 | INV[arr[sndx++]] << 12 | INV[arr[sndx++]] << 6 | INV[arr[sndx++]];
dest[d++] = (byte) (i >> 16);
dest[d++] = (byte) (i >> 8);
dest[d++] = (byte) i;
if (sepCnt > 0 && ++cc == 19) {
sndx += 2;
cc = 0;
}
}
if (d < len) {
int i = 0;
for (int j = 0; sndx <= endx - pad; j++) {
i |= INV[arr[sndx++]] << (18 - j * 6);
}
for (int r = 16; d < len; r -= 8) {
dest[d++] = (byte) (i >> r);
}
}
return dest;
} | java | {
"resource": ""
} |
q170859 | CsrfShield.prepareCsrfToken | test | @SuppressWarnings({"unchecked"})
public static String prepareCsrfToken(final HttpSession session, final int timeToLive) {
Set<Token> tokenSet = (Set<Token>) session.getAttribute(CSRF_TOKEN_SET);
if (tokenSet == null) {
tokenSet = new HashSet<>();
session.setAttribute(CSRF_TOKEN_SET, tokenSet);
}
String value;
boolean unique;
do {
value = RandomString.get().randomAlphaNumeric(32);
assureSize(tokenSet);
unique = tokenSet.add(new Token(value, timeToLive));
} while (!unique);
return value;
} | java | {
"resource": ""
} |
q170860 | CsrfShield.assureSize | test | protected static void assureSize(final Set<Token> tokenSet) {
if (tokenSet.size() < maxTokensPerSession) {
return;
}
long validUntilMin = Long.MAX_VALUE;
Token tokenToRemove = null;
Iterator<Token> iterator = tokenSet.iterator();
while (iterator.hasNext()) {
Token token = iterator.next();
if (token.isExpired()) {
iterator.remove();
continue;
}
if (token.validUntil < validUntilMin) {
validUntilMin = token.validUntil;
tokenToRemove = token;
}
}
if ((tokenToRemove != null) && (tokenSet.size() >= maxTokensPerSession)) {
tokenSet.remove(tokenToRemove);
}
} | java | {
"resource": ""
} |
q170861 | CsrfShield.checkCsrfToken | test | @SuppressWarnings({"unchecked"})
public static boolean checkCsrfToken(final HttpSession session, final String tokenValue) {
Set<Token> tokenSet = (Set<Token>) session.getAttribute(CSRF_TOKEN_SET);
if ((tokenSet == null) && (tokenValue == null)) {
return true;
}
if ((tokenSet == null) || (tokenValue == null)) {
return false;
}
boolean found = false;
Iterator<Token> it = tokenSet.iterator();
while (it.hasNext()) {
Token t = it.next();
if (t.isExpired()) {
it.remove();
continue;
}
if (t.getValue().equals(tokenValue)) {
it.remove();
found = true;
}
}
return found;
} | java | {
"resource": ""
} |
q170862 | BeanCopy.from | test | public static BeanCopy from(final Object source) {
BeanCopy beanCopy = new BeanCopy(source);
beanCopy.isSourceMap = source instanceof Map;
return beanCopy;
} | java | {
"resource": ""
} |
q170863 | BeanCopy.copy | test | public void copy() {
beanUtil = new BeanUtilBean()
.declared(declared)
.forced(forced)
.silent(true);
visit();
} | java | {
"resource": ""
} |
q170864 | BeanCopy.visitProperty | test | @Override
protected boolean visitProperty(String name, final Object value) {
if (isTargetMap) {
name = LEFT_SQ_BRACKET + name + RIGHT_SQ_BRACKET;
}
beanUtil.setProperty(destination, name, value);
return true;
} | java | {
"resource": ""
} |
q170865 | TableChunk.init | test | @Override
public void init(final TemplateData templateData) {
super.init(templateData);
if (entity != null) {
ded = lookupType(entity);
} else {
Object object = templateData.getObjectReference(entityName);
if (object != null) {
ded = lookupType(resolveClass(object));
} else {
ded = lookupName(entityName);
}
}
String tableReference = this.tableReference;
if (tableReference == null) {
tableReference = tableAlias;
}
if (tableReference == null) {
tableReference = entityName;
}
if (tableReference == null) {
tableReference = ded.getEntityName();
}
templateData.registerTableReference(tableReference, ded, tableAlias);
} | java | {
"resource": ""
} |
q170866 | PetiteBeans.resolveScope | test | @SuppressWarnings("unchecked")
public <S extends Scope> S resolveScope(final Class<S> scopeType) {
S scope = (S) scopes.get(scopeType);
if (scope == null) {
try {
scope = newInternalInstance(scopeType, (PetiteContainer) this);
} catch (Exception ex) {
throw new PetiteException("Invalid Petite scope: " + scopeType.getName(), ex);
}
registerScope(scopeType, scope);
scopes.put(scopeType, scope);
}
return scope;
} | java | {
"resource": ""
} |
q170867 | PetiteBeans.registerPetiteBean | test | public <T> BeanDefinition<T> registerPetiteBean(
final Class<T> type, String name,
Class<? extends Scope> scopeType,
WiringMode wiringMode,
final boolean define,
final Consumer<T> consumer
) {
if (name == null) {
name = resolveBeanName(type);
}
if (wiringMode == null) {
wiringMode = annotationResolver.resolveBeanWiringMode(type);
}
if (wiringMode == WiringMode.DEFAULT) {
wiringMode = petiteConfig.getDefaultWiringMode();
}
if (scopeType == null) {
scopeType = annotationResolver.resolveBeanScopeType(type);
}
if (scopeType == null) {
scopeType = SingletonScope.class;
}
// remove existing bean
BeanDefinition existing = removeBean(name);
if (existing != null) {
if (petiteConfig.getDetectDuplicatedBeanNames()) {
throw new PetiteException(
"Duplicated bean name detected while registering class '" + type.getName() + "'. Petite bean class '" +
existing.type.getName() + "' is already registered with the name: " + name);
}
}
// check if type is valid
if (type.isInterface()) {
throw new PetiteException("PetiteBean can not be an interface: " + type.getName());
}
// registration
if (log.isDebugEnabled()) {
log.info("Petite bean: [" + name +
"] --> " + type.getName() +
" @ " + scopeType.getSimpleName() +
":" + wiringMode.toString());
}
// register
Scope scope = resolveScope(scopeType);
BeanDefinition<T> beanDefinition = createBeanDefinitionForRegistration(name, type, scope, wiringMode, consumer);
registerBean(name, beanDefinition);
// providers
ProviderDefinition[] providerDefinitions = petiteResolvers.resolveProviderDefinitions(type, name);
if (providerDefinitions != null) {
for (ProviderDefinition providerDefinition : providerDefinitions) {
providers.put(providerDefinition.name, providerDefinition);
}
}
// define
if (define) {
beanDefinition.ctor = petiteResolvers.resolveCtorInjectionPoint(beanDefinition.type());
beanDefinition.properties = PropertyInjectionPoint.EMPTY;
beanDefinition.methods = MethodInjectionPoint.EMPTY;
beanDefinition.initMethods = InitMethodPoint.EMPTY;
beanDefinition.destroyMethods = DestroyMethodPoint.EMPTY;
}
// return
return beanDefinition;
} | java | {
"resource": ""
} |
q170868 | PetiteBeans.registerBean | test | protected void registerBean(final String name, final BeanDefinition beanDefinition) {
beans.put(name, beanDefinition);
if (!petiteConfig.isUseAltBeanNames()) {
return;
}
Class type = beanDefinition.type();
if (annotationResolver.beanHasAnnotationName(type)) {
return;
}
Class[] interfaces = ClassUtil.resolveAllInterfaces(type);
for (Class anInterface : interfaces) {
String altName = annotationResolver.resolveBeanName(anInterface, petiteConfig.getUseFullTypeNames());
if (name.equals(altName)) {
continue;
}
if (beans.containsKey(altName)) {
continue;
}
if (beansAlt.containsKey(altName)) {
BeanDefinition existing = beansAlt.get(altName);
if (existing != null) {
beansAlt.put(altName, null); // store null as value to mark that alt name is duplicate
}
}
else {
beansAlt.put(altName, beanDefinition);
}
}
} | java | {
"resource": ""
} |
q170869 | PetiteBeans.removeBean | test | public void removeBean(final Class type) {
// collect bean names
Set<String> beanNames = new HashSet<>();
for (BeanDefinition def : beans.values()) {
if (def.type.equals(type)) {
beanNames.add(def.name);
}
}
// remove collected bean names
for (String beanName : beanNames) {
removeBean(beanName);
}
} | java | {
"resource": ""
} |
q170870 | PetiteBeans.resolveBeanNamesForType | test | protected String[] resolveBeanNamesForType(final Class type) {
String[] beanNames = beanCollections.get(type);
if (beanNames != null) {
return beanNames;
}
ArrayList<String> list = new ArrayList<>();
for (Map.Entry<String, BeanDefinition> entry : beans.entrySet()) {
BeanDefinition beanDefinition = entry.getValue();
if (ClassUtil.isTypeOf(beanDefinition.type, type)) {
String beanName = entry.getKey();
list.add(beanName);
}
}
if (list.isEmpty()) {
beanNames = StringPool.EMPTY_ARRAY;
} else {
beanNames = list.toArray(new String[0]);
}
beanCollections.put(type, beanNames);
return beanNames;
} | java | {
"resource": ""
} |
q170871 | PetiteBeans.registerPetiteCtorInjectionPoint | test | public void registerPetiteCtorInjectionPoint(final String beanName, final Class[] paramTypes, final String[] references) {
BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
Constructor constructor = null;
if (paramTypes == null) {
CtorDescriptor[] ctors = cd.getAllCtorDescriptors();
if (ctors != null && ctors.length > 0) {
if (ctors.length > 1) {
throw new PetiteException(ctors.length + " suitable constructor found as injection point for: " + beanDefinition.type.getName());
}
constructor = ctors[0].getConstructor();
}
} else {
CtorDescriptor ctorDescriptor = cd.getCtorDescriptor(paramTypes, true);
if (ctorDescriptor != null) {
constructor = ctorDescriptor.getConstructor();
}
}
if (constructor == null) {
throw new PetiteException("Constructor not found: " + beanDefinition.type.getName());
}
BeanReferences[] ref = referencesResolver.resolveReferenceFromValues(constructor, references);
beanDefinition.ctor = new CtorInjectionPoint(constructor, ref);
} | java | {
"resource": ""
} |
q170872 | PetiteBeans.registerPetitePropertyInjectionPoint | test | public void registerPetitePropertyInjectionPoint(final String beanName, final String property, final String reference) {
BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
PropertyDescriptor propertyDescriptor = cd.getPropertyDescriptor(property, true);
if (propertyDescriptor == null) {
throw new PetiteException("Property not found: " + beanDefinition.type.getName() + '#' + property);
}
BeanReferences ref = referencesResolver.resolveReferenceFromValue(propertyDescriptor, reference);
PropertyInjectionPoint pip = new PropertyInjectionPoint(propertyDescriptor, ref);
beanDefinition.addPropertyInjectionPoint(pip);
} | java | {
"resource": ""
} |
q170873 | PetiteBeans.registerPetiteSetInjectionPoint | test | public void registerPetiteSetInjectionPoint(final String beanName, final String property) {
BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
PropertyDescriptor propertyDescriptor = cd.getPropertyDescriptor(property, true);
if (propertyDescriptor == null) {
throw new PetiteException("Property not found: " + beanDefinition.type.getName() + '#' + property);
}
SetInjectionPoint sip = new SetInjectionPoint(propertyDescriptor);
beanDefinition.addSetInjectionPoint(sip);
} | java | {
"resource": ""
} |
q170874 | PetiteBeans.registerPetiteMethodInjectionPoint | test | public void registerPetiteMethodInjectionPoint(final String beanName, final String methodName, final Class[] arguments, final String[] references) {
BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
Method method = null;
if (arguments == null) {
MethodDescriptor[] methods = cd.getAllMethodDescriptors(methodName);
if (methods != null && methods.length > 0) {
if (methods.length > 1) {
throw new PetiteException(methods.length + " suitable methods found as injection points for: " + beanDefinition.type.getName() + '#' + methodName);
}
method = methods[0].getMethod();
}
} else {
MethodDescriptor md = cd.getMethodDescriptor(methodName, arguments, true);
if (md != null) {
method = md.getMethod();
}
}
if (method == null) {
throw new PetiteException("Method not found: " + beanDefinition.type.getName() + '#' + methodName);
}
BeanReferences[] ref = referencesResolver.resolveReferenceFromValues(method, references);
MethodInjectionPoint mip = new MethodInjectionPoint(method, ref);
beanDefinition.addMethodInjectionPoint(mip);
} | java | {
"resource": ""
} |
q170875 | PetiteBeans.registerPetiteInitMethods | test | public void registerPetiteInitMethods(final String beanName, final InitMethodInvocationStrategy invocationStrategy, String... initMethodNames) {
BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
if (initMethodNames == null) {
initMethodNames = StringPool.EMPTY_ARRAY;
}
int total = initMethodNames.length;
InitMethodPoint[] initMethodPoints = new InitMethodPoint[total];
int i;
for (i = 0; i < initMethodNames.length; i++) {
MethodDescriptor md = cd.getMethodDescriptor(initMethodNames[i], ClassUtil.EMPTY_CLASS_ARRAY, true);
if (md == null) {
throw new PetiteException("Init method not found: " + beanDefinition.type.getName() + '#' + initMethodNames[i]);
}
initMethodPoints[i] = new InitMethodPoint(md.getMethod(), i, invocationStrategy);
}
beanDefinition.addInitMethodPoints(initMethodPoints);
} | java | {
"resource": ""
} |
q170876 | PetiteBeans.registerPetiteDestroyMethods | test | public void registerPetiteDestroyMethods(final String beanName, String... destroyMethodNames) {
BeanDefinition beanDefinition = lookupExistingBeanDefinition(beanName);
ClassDescriptor cd = ClassIntrospector.get().lookup(beanDefinition.type);
if (destroyMethodNames == null) {
destroyMethodNames = StringPool.EMPTY_ARRAY;
}
int total = destroyMethodNames.length;
DestroyMethodPoint[] destroyMethodPoints = new DestroyMethodPoint[total];
int i;
for (i = 0; i < destroyMethodNames.length; i++) {
MethodDescriptor md = cd.getMethodDescriptor(destroyMethodNames[i], ClassUtil.EMPTY_CLASS_ARRAY, true);
if (md == null) {
throw new PetiteException("Destroy method not found: " + beanDefinition.type.getName() + '#' + destroyMethodNames[i]);
}
destroyMethodPoints[i] = new DestroyMethodPoint(md.getMethod());
}
beanDefinition.addDestroyMethodPoints(destroyMethodPoints);
} | java | {
"resource": ""
} |
q170877 | PetiteBeans.registerPetiteProvider | test | public void registerPetiteProvider(final String providerName, final String beanName, final String methodName, final Class[] arguments) {
BeanDefinition beanDefinition = lookupBeanDefinition(beanName);
if (beanDefinition == null) {
throw new PetiteException("Bean not found: " + beanName);
}
Class beanType = beanDefinition.type;
ClassDescriptor cd = ClassIntrospector.get().lookup(beanType);
MethodDescriptor md = cd.getMethodDescriptor(methodName, arguments, true);
if (md == null) {
throw new PetiteException("Provider method not found: " + methodName);
}
ProviderDefinition providerDefinition = new ProviderDefinition(providerName, beanName, md.getMethod());
providers.put(providerName, providerDefinition);
} | java | {
"resource": ""
} |
q170878 | PetiteBeans.registerPetiteProvider | test | public void registerPetiteProvider(final String providerName, final Class type, final String staticMethodName, final Class[] arguments) {
ClassDescriptor cd = ClassIntrospector.get().lookup(type);
MethodDescriptor md = cd.getMethodDescriptor(staticMethodName, arguments, true);
if (md == null) {
throw new PetiteException("Provider method not found: " + staticMethodName);
}
ProviderDefinition providerDefinition = new ProviderDefinition(providerName, md.getMethod());
providers.put(providerName, providerDefinition);
} | java | {
"resource": ""
} |
q170879 | PetiteBeans.forEachBeanType | test | public void forEachBeanType(final Class type, final Consumer<String> beanNameConsumer) {
forEachBean(bd -> {
if (ClassUtil.isTypeOf(bd.type, type)) {
beanNameConsumer.accept(bd.name);
}
});
} | java | {
"resource": ""
} |
q170880 | PetiteBeans.defineParameters | test | public void defineParameters(final Map<?, ?> properties) {
for (Map.Entry<?, ?> entry : properties.entrySet()) {
defineParameter(entry.getKey().toString(), entry.getValue());
}
} | java | {
"resource": ""
} |
q170881 | EchoInterceptor.intercept | test | @Override
public Object intercept(final ActionRequest actionRequest) throws Exception {
printBefore(actionRequest);
long startTime = System.currentTimeMillis();
Object result = null;
try {
result = actionRequest.invoke();
} catch (Exception ex) {
result = "<exception>";
throw ex;
} catch (Throwable th) {
result = "<throwable>";
throw new Exception(th);
} finally {
long executionTime = System.currentTimeMillis() - startTime;
printAfter(actionRequest, executionTime, result);
}
return result;
} | java | {
"resource": ""
} |
q170882 | ProxettaAsmUtil.resolveJavaVersion | test | public static int resolveJavaVersion(final int version) {
final int javaVersionNumber = SystemUtil.info().getJavaVersionNumber();
final int platformVersion = javaVersionNumber - 8 + 52;
return version > platformVersion ? version : platformVersion;
} | java | {
"resource": ""
} |
q170883 | ProxettaAsmUtil.pushInt | test | public static void pushInt(final MethodVisitor mv, final int value) {
if (value <= 5) {
mv.visitInsn(ICONST_0 + value);
} else if (value <= Byte.MAX_VALUE) {
mv.visitIntInsn(BIPUSH, value);
} else {
mv.visitIntInsn(SIPUSH, value);
}
} | java | {
"resource": ""
} |
q170884 | ProxettaAsmUtil.checkArgumentIndex | test | public static void checkArgumentIndex(final MethodInfo methodInfo, final int argIndex) {
if ((argIndex < 1) || (argIndex > methodInfo.getArgumentsCount())) {
throw new ProxettaException("Invalid argument index: " + argIndex);
}
} | java | {
"resource": ""
} |
q170885 | ProxettaAsmUtil.adviceFieldName | test | public static String adviceFieldName(final String name, final int index) {
return ProxettaNames.fieldPrefix + name + ProxettaNames.fieldDivider + index;
} | java | {
"resource": ""
} |
q170886 | ProxettaAsmUtil.adviceMethodName | test | public static String adviceMethodName(final String name, final int index) {
return ProxettaNames.methodPrefix + name + ProxettaNames.methodDivider + index;
} | java | {
"resource": ""
} |
q170887 | ProxettaAsmUtil.loadSpecialMethodArguments | test | public static void loadSpecialMethodArguments(final MethodVisitor mv, final MethodInfo methodInfo) {
mv.visitVarInsn(ALOAD, 0);
for (int i = 1; i <= methodInfo.getArgumentsCount(); i++) {
loadMethodArgument(mv, methodInfo, i);
}
} | java | {
"resource": ""
} |
q170888 | ProxettaAsmUtil.loadStaticMethodArguments | test | public static void loadStaticMethodArguments(final MethodVisitor mv, final MethodInfo methodInfo) {
for (int i = 0; i < methodInfo.getArgumentsCount(); i++) {
loadMethodArgument(mv, methodInfo, i);
}
} | java | {
"resource": ""
} |
q170889 | ProxettaAsmUtil.loadVirtualMethodArguments | test | public static void loadVirtualMethodArguments(final MethodVisitor mv, final MethodInfo methodInfo) {
for (int i = 1; i <= methodInfo.getArgumentsCount(); i++) {
loadMethodArgument(mv, methodInfo, i);
}
} | java | {
"resource": ""
} |
q170890 | ProxettaAsmUtil.loadMethodArgument | test | public static void loadMethodArgument(final MethodVisitor mv, final MethodInfo methodInfo, final int index) {
int offset = methodInfo.getArgumentOffset(index);
int type = methodInfo.getArgument(index).getOpcode();
switch (type) {
case 'V':
break;
case 'B':
case 'C':
case 'S':
case 'I':
case 'Z':
mv.visitVarInsn(ILOAD, offset);
break;
case 'J':
mv.visitVarInsn(LLOAD, offset);
break;
case 'F':
mv.visitVarInsn(FLOAD, offset);
break;
case 'D':
mv.visitVarInsn(DLOAD, offset);
break;
default:
mv.visitVarInsn(ALOAD, offset);
}
} | java | {
"resource": ""
} |
q170891 | ProxettaAsmUtil.storeMethodArgument | test | public static void storeMethodArgument(final MethodVisitor mv, final MethodInfo methodInfo, final int index) {
int offset = methodInfo.getArgumentOffset(index);
int type = methodInfo.getArgument(index).getOpcode();
switch (type) {
case 'V':
break;
case 'B':
case 'C':
case 'S':
case 'I':
case 'Z':
mv.visitVarInsn(ISTORE, offset); break;
case 'J':
mv.visitVarInsn(LSTORE, offset); break;
case 'F':
mv.visitVarInsn(FSTORE, offset); break;
case 'D':
mv.visitVarInsn(DSTORE, offset); break;
default:
mv.visitVarInsn(ASTORE, offset);
}
} | java | {
"resource": ""
} |
q170892 | ProxettaAsmUtil.prepareReturnValue | test | public static void prepareReturnValue(final MethodVisitor mv, final MethodInfo methodInfo, int varOffset) {
varOffset += methodInfo.getAllArgumentsSize();
switch (methodInfo.getReturnType().getOpcode()) {
case 'V':
mv.visitInsn(ACONST_NULL);
break;
case 'B':
AsmUtil.valueOfByte(mv);
break;
case 'C':
AsmUtil.valueOfCharacter(mv);
break;
case 'S':
AsmUtil.valueOfShort(mv);
break;
case 'I':
AsmUtil.valueOfInteger(mv);
break;
case 'Z':
AsmUtil.valueOfBoolean(mv);
break;
case 'J':
AsmUtil.valueOfLong(mv);
break;
case 'F':
AsmUtil.valueOfFloat(mv);
break;
case 'D':
AsmUtil.valueOfDouble(mv);
break;
}
} | java | {
"resource": ""
} |
q170893 | ProxettaAsmUtil.createMethodSignaturesKey | test | public static String createMethodSignaturesKey(final int access, final String methodName, final String description, final String className) {
return new StringBand(7)
.append(access)
.append(COLON)
.append(description)
.append(StringPool.UNDERSCORE)
.append(className)
.append(StringPool.HASH)
.append(methodName)
.toString();
} | java | {
"resource": ""
} |
q170894 | ProxettaAsmUtil.newArray | test | public static void newArray(final MethodVisitor mv, final Class componentType) {
if (componentType == int.class) {
mv.visitIntInsn(NEWARRAY, T_INT);
return;
}
if (componentType == long.class) {
mv.visitIntInsn(NEWARRAY, T_LONG);
return;
}
if (componentType == float.class) {
mv.visitIntInsn(NEWARRAY, T_FLOAT);
return;
}
if (componentType == double.class) {
mv.visitIntInsn(NEWARRAY, T_DOUBLE);
return;
}
if (componentType == byte.class) {
mv.visitIntInsn(NEWARRAY, T_BYTE);
return;
}
if (componentType == short.class) {
mv.visitIntInsn(NEWARRAY, T_SHORT);
return;
}
if (componentType == boolean.class) {
mv.visitIntInsn(NEWARRAY, T_BOOLEAN);
return;
}
if (componentType == char.class) {
mv.visitIntInsn(NEWARRAY, T_CHAR);
return;
}
mv.visitTypeInsn(ANEWARRAY, AsmUtil.typeToSignature(componentType));
} | java | {
"resource": ""
} |
q170895 | ProxettaAsmUtil.storeIntoArray | test | public static void storeIntoArray(final MethodVisitor mv, final Class componentType) {
if (componentType == int.class) {
mv.visitInsn(IASTORE);
return;
}
if (componentType == long.class) {
mv.visitInsn(LASTORE);
return;
}
if (componentType == float.class) {
mv.visitInsn(FASTORE);
return;
}
if (componentType == double.class) {
mv.visitInsn(DASTORE);
return;
}
if (componentType == byte.class) {
mv.visitInsn(BASTORE);
return;
}
if (componentType == short.class) {
mv.visitInsn(SASTORE);
return;
}
if (componentType == boolean.class) {
mv.visitInsn(BASTORE);
return;
}
if (componentType == char.class) {
mv.visitInsn(CASTORE);
return;
}
mv.visitInsn(AASTORE);
} | java | {
"resource": ""
} |
q170896 | EmailUtil.extractEncoding | test | public static String extractEncoding(final String contentType, String defaultEncoding) {
String encoding = extractEncoding(contentType);
if (encoding == null) {
if (defaultEncoding == null) {
defaultEncoding = JoddCore.encoding;
}
encoding = defaultEncoding;
}
return encoding;
} | java | {
"resource": ""
} |
q170897 | EmailUtil.isEmptyFlags | test | public static boolean isEmptyFlags(Flags flags) {
if (flags == null) return true;
Flags.Flag[] systemFlags = flags.getSystemFlags();
if (systemFlags != null && systemFlags.length > 0) {
return false;
}
String[] userFlags = flags.getUserFlags();
if (userFlags != null && userFlags.length > 0) {
return false;
}
return true;
} | java | {
"resource": ""
} |
q170898 | ServletUtil.resolveAuthBearerToken | test | public static String resolveAuthBearerToken(final HttpServletRequest request) {
String header = request.getHeader(HEADER_AUTHORIZATION);
if (header == null) {
return null;
}
int ndx = header.indexOf("Bearer ");
if (ndx == -1) {
return null;
}
return header.substring(ndx + 7).trim();
} | java | {
"resource": ""
} |
q170899 | ServletUtil.requireAuthentication | test | public static void requireAuthentication(final HttpServletResponse resp, final String realm) throws IOException {
resp.setHeader(WWW_AUTHENTICATE, "Basic realm=\"" + realm + '\"');
resp.sendError(HttpServletResponse.SC_UNAUTHORIZED);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.