method2testcases
stringlengths
118
3.08k
### Question: JdbcTriggerLoader extends AbstractJdbcLoader implements TriggerLoader { @Override public void addTrigger(Trigger t) throws TriggerLoaderException { logger.info("Inserting trigger " + t.toString() + " into db."); t.setLastModifyTime(System.currentTimeMillis()); Connection connection = getConnection(); ...
### Question: JdbcTriggerLoader extends AbstractJdbcLoader implements TriggerLoader { @Override public void removeTrigger(Trigger t) throws TriggerLoaderException { logger.info("Removing trigger " + t.toString() + " from db."); QueryRunner runner = createQueryRunner(); try { int removes = runner.update(REMOVE_TRIGG...
### Question: JdbcTriggerLoader extends AbstractJdbcLoader implements TriggerLoader { @Override public void updateTrigger(Trigger t) throws TriggerLoaderException { if (logger.isDebugEnabled()) { logger.debug("Updating trigger " + t.getTriggerId() + " into db."); } t.setLastModifyTime(System.currentTimeMillis()); C...
### Question: StringUtils { public static boolean isFromBrowser(String userAgent) { if (userAgent == null) { return false; } if (BROWSWER_PATTERN.matcher(userAgent).matches()) { return true; } else { return false; } } static String shellQuote(String s, char quoteCh); @Deprecated static String join(List<String> list, S...
### Question: StringUtils { public static boolean isRgbValue(String color){ Pattern pattern = Pattern.compile("^#(([0123456789abcdefABCDEF]{6})|([0123456789abcdefABCDEF]{8}))$"); Matcher matcher = pattern.matcher(color); return matcher.matches(); } static boolean isRgbValue(String color); }### Answer: @Test public vo...
### Question: EncodeUtils { public static String urlDecode(String encode){ try { return URLDecoder.decode(encode,"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; } private EncodeUtils(); static String urlEncode(String s); static String urlDecode(String encode); }### Answer: @Te...
### Question: Money implements Serializable { @Override public String toString() { return format.format(amount); } @Override String toString(); static final NumberFormat format; }### Answer: @Test public void go() { Money money = new Money(BigDecimal.valueOf(new Random().nextDouble()).multiply(BigDecimal.valueOf(10000...
### Question: ManageTagController { @PutMapping("/manage/tagList/disable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void disable(@RequestParam String name) { tagRepository.getOne(name).setDisabled(true); } @GetMapping("/manageTag") String index(); @GetMapping("/manageTagAdd") String toAdd(); @GetMa...
### Question: ManageTagController { @PutMapping("/manage/tagList/enable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void enable(@RequestParam String name) { tagRepository.getOne(name).setDisabled(false); } @GetMapping("/manageTag") String index(); @GetMapping("/manageTagAdd") String toAdd(); @GetMap...
### Question: ManageDepotController { @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/manageDepot") public String index() { return "_depotManage.html"; } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/manageD...
### Question: ManageDepotController { @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/manage/depotList") @RowCustom(distinct = true, dramatizer = JQueryDataTableDramatizer.class) public RowDefinition data() { return new DepotRows(time -> conversionService.convert(t...
### Question: InitService { @PostConstruct @Transactional @Order(Ordered.HIGHEST_PRECEDENCE) public void init() throws IOException, SQLException { commons(); database(); upgrade(); managers(); productTypes(); depots(); products(); others(); mainOrderService.createExecutorToForPayOrder(); applicationEventPublisher.publi...
### Question: ManageDepotController { @PostMapping("/manage/depotList") public String add(String name, Address address, String haierCode, String type, String chargePeopleName , String chargePeopleMobile) { Depot depot; if ("HaierDepot".equalsIgnoreCase(type)) { HaierDepot haierDepot = new HaierDepot(); haierDepot.setHa...
### Question: ManageDepotController { @PutMapping("/manage/depotList/{id}/disable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void disable(@PathVariable("id") long id) { depotRepository.getOne(id).setEnable(false); } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+...
### Question: ManageDepotController { @PutMapping("/manage/depotList/{id}/enable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void enable(@PathVariable("id") long id) { depotRepository.getOne(id).setEnable(true); } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')...
### Question: ManageFactoryController { @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/manageFactory") public String index() { return "_factoryManage.html"; } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LOOK+"')") @GetMapping("/m...
### Question: ManageFactoryController { @PostMapping("/manage/factoryList") public String add(String name, Address address, String chargePeopleName , String chargePeopleMobile) { Factory factory = new Factory(); factory.setEnable(true); factory.setCreateTime(LocalDateTime.now()); factory.setName(name); factory.setAddre...
### Question: ManageFactoryController { @PutMapping("/manage/factoryList/{id}/disable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void disable(@PathVariable("id") long id) { factoryRepository.getOne(id).setEnable(false); } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE...
### Question: ManageFactoryController { @PutMapping("/manage/factoryList/{id}/enable") @ResponseStatus(HttpStatus.NO_CONTENT) @Transactional public void enable(@PathVariable("id") long id) { factoryRepository.getOne(id).setEnable(true); } @PreAuthorize("hasAnyRole('ROOT','"+ Login.ROLE_SUPPLY_CHAIN+"','"+Login.ROLE_LO...
### Question: WechatShareController { @GetMapping(SystemService.wechatShareUri) public String share(@AuthenticationPrincipal Login loginInput, Model model) { Login login = loginService.get(loginInput.getId()); if (!loginService.isRegularLogin(login) && !loginService.allowShare(login)) return "redirect:" + SystemService...
### Question: MiscController { @RequestMapping(method = RequestMethod.POST, value = "/misc/sendRegisterCode") @ResponseBody public ApiResult sendRegisterCode(String mobile) throws IOException { if (loginService.byLoginName(mobile) != null) { return ApiResult.withCodeAndMessage(401, "该手机号码已被人使用", null); } verificationCo...
### Question: WechatCommonProblemController { @GetMapping(SystemService.helpCenterURi) public String index(){ return "wechat@helpCenter/index.html"; } @GetMapping("/commonProblemDetail/{id}") String commonProblemDetail(@PathVariable Long id, Model model); @GetMapping("/commonProblem/search") @ResponseBody Map<String, ...
### Question: WechatUpgradeController { @PostMapping("/wechatUpgrade") @Transactional public ModelAndView upgrade(@AuthenticationPrincipal Login login, String agentName, int newLevel, Address address , String cardFrontPath , String cardBackPath, String businessLicensePath, String upgradeMode, HttpServletRequest servlet...
### Question: WelcomeController { @RequestMapping(method = RequestMethod.GET, value = {"", "/"}) public String index(@AuthenticationPrincipal Login login, @HighestAgent AgentLevel agentLevel) { if (login.isManageable()) return "redirect:/manage"; if (agentLevel != null) return "redirect:/agentMain"; throw new IllegalSt...
### Question: CommissionController { public static String formatCommonInfo(Object origin) { String src = origin.toString(); int index = src.lastIndexOf("¥"); String first = src.substring(0, index - 1); return first + Money.format.format(new BigDecimal(src.substring(index + 1))); } static String formatCommonInfo(Object...
### Question: AgentNavigateController { @RequestMapping(method = RequestMethod.GET, value = "/agentMain") public String agentMain(@AuthenticationPrincipal Login login, @HighestAgent AgentLevel agentLevel, Model model) { if (login.isManageable()) { model.addAttribute("title", "管理后台"); model.addAttribute("loginAs", login...
### Question: ResourceController { @RequestMapping(method = RequestMethod.POST, value = "/webUploader") public ResponseEntity<?> webUploader(String id, MultipartFile file) throws IOException, URISyntaxException { try (InputStream inputStream = file.getInputStream()) { String path = uploadTempResource(inputStream, file)...
### Question: ManageTagController { @GetMapping("/manageTag") public String index() { return "_tagManage.html"; } @GetMapping("/manageTag") String index(); @GetMapping("/manageTagAdd") String toAdd(); @GetMapping("/manage/tagDetail") String detail(@RequestParam String name, Model model); @GetMapping("/manage/tagEdit")...
### Question: ManageTagController { @GetMapping("/manage/tagList") @RowCustom(distinct = true, dramatizer = JQueryDataTableDramatizer.class) public RowDefinition data() { return new TagRows(time -> conversionService.convert(time, String.class)) { @Override public Specification<Tag> specification() { return null; } }; }...
### Question: DrillOptiq { public static LogicalExpression toDrill(DrillParseContext context, RelNode input, RexNode expr) { final RexToDrill visitor = new RexToDrill(context, input); return expr.accept(visitor); } static LogicalExpression toDrill(DrillParseContext context, RelNode input, RexNode expr); static boolean...
### Question: Driver implements java.sql.Driver { @Override public int getMajorVersion() { return impl.getMajorVersion(); } Driver(); static boolean load(); @Override Connection connect( String url, Properties info ); @Override boolean acceptsURL( String url ); @Override DriverPropertyInfo[] getPropertyInfo( String url...
### Question: Driver implements java.sql.Driver { @Override public int getMinorVersion() { return impl.getMinorVersion(); } Driver(); static boolean load(); @Override Connection connect( String url, Properties info ); @Override boolean acceptsURL( String url ); @Override DriverPropertyInfo[] getPropertyInfo( String url...
### Question: PropertyUtils { public static <T> T get(String key, Function<String, T> parser, T defaultValue) { return get(System.getProperties(), key, parser, defaultValue); } private PropertyUtils(); static T get(String key, Function<String, T> parser, T defaultValue); static T get(Properties props, String key, Func...
### Question: PropertyUtils { public static <T> T getOrSet(Properties props, String key, Function<String, T> parser, T defaultValue) { final String str = props.getProperty(key); if (str == null) { props.setProperty(key, String.valueOf(defaultValue)); return defaultValue; } else { return parser.apply(str); } } private ...
### Question: PropertyUtils { public static Properties load(String resourceFile) throws IOException { final URL url = PropertyUtils.class.getClassLoader().getResource(resourceFile); if (url == null) throw new FileNotFoundException("Resource not found"); final Properties props = new Properties(); try (InputStream in = u...
### Question: QueryParameters { public QueryParameters setClassName(String className) { InputUtils.setClassName(this.values, className); return this; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParamet...
### Question: QueryParameters { public QueryParameters updateType(String key, Integer type) { this.types.put(processKey(key), type); return this; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(...
### Question: QueryParameters { public QueryParameters updateValue(String key, Object value) { this.values.put(processKey(key), value); return this; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParamete...
### Question: QueryParameters { public Direction getDirection(String key) { return this.direction.get(processKey(key)); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedIn...
### Question: QueryParameters { public Integer getType(String key) { return this.types.get(processKey(key)); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); Quer...
### Question: MidaoFactory { public static DataSource createDataSource(Properties poolProperties) throws SQLException { try { return MidaoFrameworkPoolBinder.createDataSource(poolProperties); } catch (NoClassDefFoundError ex) { throw new NoClassDefFoundError(ERROR_COULDNT_FIND_POOL_PROVIDER); } } static QueryRunnerSer...
### Question: QueryParameters { public Set<String> keySet() { return this.values.keySet(); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryParameters(Object...
### Question: QueryParameters { public String getNameByPosition(Integer position) { String name = null; name = this.order.get(position); return name; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParamet...
### Question: QueryParameters { public boolean containsKey(String key) { return this.values.containsKey(processKey(key)); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processed...
### Question: QueryParameters { public int size() { return this.values.size(); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryParameters(Object... params);...
### Question: QueryParameters { public boolean isCaseSensitive() { return this.isCaseSensitive; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedInput); QueryParameters(O...
### Question: QueryParameters { public void setReturn(Object queryOutput) { this.set(QUERY_PARAMS_RETURN, queryOutput); } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParameters(QueryParameters parameters); QueryParameters(ProcessedInput processedIn...
### Question: QueryParameters { public Object getReturn() { Object result = null; if (this.containsKey(QUERY_PARAMS_RETURN) == true) { result = this.getValue(QUERY_PARAMS_RETURN); } return result; } QueryParameters(); QueryParameters(Map<String, Object> map); QueryParameters(Class<?> clazz, Object bean); QueryParame...
### Question: BaseExceptionHandler implements ExceptionHandler { public BaseExceptionHandler(String dbName) { this.dbName = dbName; } BaseExceptionHandler(String dbName); MjdbcSQLException convert(Connection conn, SQLException cause, String sql, Object... params); }### Answer: @Test public void testBaseExceptionHandle...
### Question: ProcessedInput { public void addParameter(String parameterName, int parameterStart, int parameterEnd, String parameterType, String parameterDirection) { if (this.sqlParameterNames == null) { this.sqlParameterNames = new ArrayList<String>(); this.sqlParameterBoundaries = new ArrayList<int[]>(); } this.sqlP...
### Question: ProcessedInput { public String getOriginalSql() { return originalSql; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Object> sqlParameterVal...
### Question: ProcessedInput { public String getParsedSql() { return parsedSql; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Object> sqlParameterValues,...
### Question: ProcessedInput { public List<String> getSqlParameterNames() { return sqlParameterNames; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Objec...
### Question: ProcessedInput { public List<Object> getSqlParameterValues() { return sqlParameterValues; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Obj...
### Question: ProcessedInput { public void setParsedSql(String parsedSql) { this.parsedSql = parsedSql; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql, List<String> sqlParameterNames, List<int[]> sqlParameterBoundaries, List<Obj...
### Question: ProcessedInput { public void setSqlParameterValues(List<Object> sqlParameterValues) { if (sqlParameterValues != null) { this.sqlParameterValues = new ArrayList<Object>(sqlParameterValues); } else { this.sqlParameterValues = null; } } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput proce...
### Question: ProcessedInput { public Integer getPosition(String parameterName) { Integer position = null; for (int i = 0; i < this.sqlParameterNames.size(); i++) { if (this.sqlParameterNames.get(i).equals(parameterName) == true) { position = i; break; } } return position; } ProcessedInput(String originalSql); Process...
### Question: ProcessedInput { public String getParameterName(Integer position) { String name = null; if (this.sqlParameterNames != null) { name = this.sqlParameterNames.get(position); } return name; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql...
### Question: ExceptionUtils { public static void rethrow(MjdbcException cause) throws MjdbcSQLException { MjdbcSQLException ex = new MjdbcSQLException(cause.getMessage()); ex.setStackTrace(cause.getStackTrace()); throw ex; } static void rethrow(MjdbcException cause); }### Answer: @Test public void testRethrow() { tr...
### Question: ProcessedInput { public Integer getAmountOfParameters() { Integer size = 0; if (this.sqlParameterNames != null) { size = this.sqlParameterNames.size(); } return size; } ProcessedInput(String originalSql); ProcessedInput(ProcessedInput processedInput); ProcessedInput(String originalSql, String parsedSql,...
### Question: ProcessedInput { public boolean isFilled() { boolean isFilled = false; if (this.originalSql != null && this.originalSql.length() > 0) { if (this.parsedSql != null && this.parsedSql.length() > 0) { if (this.sqlParameterNames != null) { if (this.sqlParameterValues != null) { isFilled = true; } } } } return ...
### Question: EmptyTypeHandler implements TypeHandler { public QueryParameters processInput(Statement stmt, QueryParameters params) { return params; } EmptyTypeHandler(Overrider overrider); QueryParameters processInput(Statement stmt, QueryParameters params); void afterExecute(Statement stmt, QueryParameters processedI...
### Question: EmptyTypeHandler implements TypeHandler { public void afterExecute(Statement stmt, QueryParameters processedInput, QueryParameters params) { } EmptyTypeHandler(Overrider overrider); QueryParameters processInput(Statement stmt, QueryParameters params); void afterExecute(Statement stmt, QueryParameters proc...
### Question: EmptyTypeHandler implements TypeHandler { public List<QueryParameters> processOutput(Statement stmt, List<QueryParameters> paramsList) { return paramsList; } EmptyTypeHandler(Overrider overrider); QueryParameters processInput(Statement stmt, QueryParameters params); void afterExecute(Statement stmt, Query...
### Question: MidaoLogger extends Logger { public static MidaoLogger getLogger(String name) { MidaoLogger mjdbcLogger = new MidaoLogger(name, null); if (isSLF4jAvailable() == true) { try { mjdbcLogger = new MidaoLogger(name, null); mjdbcLogger.setSlfLogger(MappingUtils.invokeStaticFunction(Class.forName("org.slf4j.Logg...
### Question: MidaoLogger extends Logger { @Override public void info(String msg) { if (isSLF4jAvailable() == false) { super.info(msg); } else { try { MappingUtils.invokeFunction(slfLogger, "info", new Class[]{String.class}, new Object[]{msg}); } catch (MjdbcException e) { setSLF4jAvailable(false); super.info(msg); } }...
### Question: MidaoLogger extends Logger { @Override public void warning(String msg) { if (isSLF4jAvailable() == false) { super.warning(msg); } else { try { MappingUtils.invokeFunction(slfLogger, "warn", new Class[]{String.class}, new Object[]{msg}); } catch (MjdbcException e) { setSLF4jAvailable(false); super.warning(...
### Question: CallableUtils { public static boolean isFunctionCall(String decodedSql) { Pattern regexPattern = null; Matcher regexMatcher = null; regexPattern = Pattern.compile(REGEX_IS_FUNCTION, Pattern.CASE_INSENSITIVE); regexMatcher = regexPattern.matcher(decodedSql); return regexMatcher.find(); } static boolean is...
### Question: MidaoLogger extends Logger { @Override public void severe(String msg) { if (isSLF4jAvailable() == false) { super.severe(msg); } else { try { MappingUtils.invokeFunction(slfLogger, "error", new Class[]{String.class}, new Object[]{msg}); } catch (MjdbcException e) { setSLF4jAvailable(false); super.severe(ms...
### Question: CallableUtils { public static String getStoredProcedureShortNameFromSql(String decodedSql) { String spName = null; Pattern regexPattern = null; Matcher regexMatcher = null; String procedureFullName = getStoredProcedureFullName(decodedSql); String[] procedurePath = procedureFullName.split("[.]"); if (proce...
### Question: CallableUtils { public static String getStoredProcedureFullName(String decodedSql) { String spName = null; Pattern regexPattern = null; Matcher regexMatcher = null; regexPattern = Pattern.compile(REGEX_PROCEDURE_FULL_NAME, Pattern.CASE_INSENSITIVE); regexMatcher = regexPattern.matcher(decodedSql); if (reg...
### Question: CallableUtils { public static QueryParameters updateDirections(QueryParameters original, QueryParameters source) { QueryParameters updatedParams = new QueryParameters(original); Integer position = null; String originalKey = null; if (source != null) { for (String sourceKey : source.keySet()) { position = ...
### Question: CallableUtils { public static QueryParameters updateTypes(QueryParameters original, QueryParameters source) { QueryParameters updatedParams = new QueryParameters(original); Integer position = null; String originalKey = null; if (source != null) { for (String sourceKey : source.keySet()) { position = sourc...
### Question: CallableUtils { public static QueryParameters updateDirectionsByName(QueryParameters original, QueryParameters source) { QueryParameters updatedParams = new QueryParameters(original); if (source != null) { for (String sourceKey : source.keySet()) { if (updatedParams.containsKey(sourceKey) == true) { updat...
### Question: CallableUtils { public static QueryParameters updateTypesByName(QueryParameters original, QueryParameters source) { QueryParameters updatedParams = new QueryParameters(original); if (source != null) { for (String sourceKey : source.keySet()) { if (updatedParams.containsKey(sourceKey) == true) { updatedPar...
### Question: MappingUtils { public static Map<String, Object> toMap(Object inputParameter, PropertyDescriptor[] propertyDescriptors) { Map<String, Object> resultMap = new HashMap<String, Object>(); Object propertyValue = null; for (PropertyDescriptor property : propertyDescriptors) { propertyValue = callGetter(inputPa...
### Question: MappingUtils { public static PropertyDescriptor[] propertyDescriptors(Class<?> clazz) { BeanInfo beanInfo = null; try { beanInfo = Introspector.getBeanInfo(clazz); } catch (IntrospectionException ex) { throw new IllegalArgumentException( "Bean introspection failed: " + ex.getMessage()); } return beanInfo....
### Question: MappingUtils { public static Map<String, PropertyDescriptor> mapPropertyDescriptors(Class<?> clazz) { PropertyDescriptor[] properties = propertyDescriptors(clazz); Map<String, PropertyDescriptor> mappedProperties = new HashMap<String, PropertyDescriptor>(); for (PropertyDescriptor property : properties) {...
### Question: MidaoLogger extends Logger { public static boolean isSLF4jAvailable() { if (SLF4jAvailable == null) { try { Class.forName("org.slf4j.Logger"); setSLF4jAvailable(true); } catch (ClassNotFoundException e) { setSLF4jAvailable(false); } } return SLF4jAvailable; } private MidaoLogger(String name, String resou...
### Question: MappingUtils { public static <T> T newInstance(Class<T> clazz) throws MjdbcException { try { return clazz.newInstance(); } catch (InstantiationException ex) { throw new MjdbcException( "Failed to create instance: " + clazz.getName() + " - " + ex.getMessage()); } catch (IllegalAccessException ex) { throw n...
### Question: MappingUtils { public static Object invokeFunction(Object object, String functionName, Class[] parameters, Object[] values) throws MjdbcException { Object result = null; try { Method method = object.getClass().getMethod(functionName, parameters); method.setAccessible(true); result = method.invoke(object, ...
### Question: MappingUtils { public static Object invokeStaticFunction(Class clazz, String functionName, Class[] parameters, Object[] values) throws MjdbcException { Object result = null; try { Method method = clazz.getMethod(functionName, parameters); method.setAccessible(true); result = method.invoke(null, values); }...
### Question: MappingUtils { public static boolean hasFunction(Object object, String functionName, Class[] parameters) { boolean result = false; try { Method method = object.getClass().getMethod(functionName, parameters); if (method != null) { result = true; } } catch (NoSuchMethodException ex) { result = false; } retu...
### Question: MappingUtils { public static boolean objectImplements(Object object, String interfaceClass) { AssertUtils.assertNotNull(object); boolean result = false; Class[] interfaces = object.getClass().getInterfaces(); for (int i = 0; i < interfaces.length; i++) { if (interfaces[i].getName().equals(interfaceClass) ...
### Question: MappingUtils { public static boolean objectExtends(Object object, String superClassName) { AssertUtils.assertNotNull(object); boolean result = false; Class superClass = object.getClass().getSuperclass(); if (superClass.getName().equals(superClassName) == true) { result = true; } return result; } static M...
### Question: MappingUtils { public static Object returnStaticField(Class clazz, String fieldName) throws MjdbcException { Object result = null; Field field = null; try { field = clazz.getField(fieldName); result = field.get(null); } catch (NoSuchFieldException ex) { throw new MjdbcException(ex); } catch (IllegalAccess...
### Question: MidaoLogger extends Logger { public static boolean isSLF4jImplementationAvailable() { if (SLF4jImplementationAvailable == null) { if (isSLF4jAvailable() == true) { try { Object obj = MappingUtils.invokeStaticFunction(Class.forName("org.slf4j.LoggerFactory"), "getILoggerFactory", new Class[]{}, new Object[...
### Question: MappingUtils { public static boolean objectInstanceOf(Object object, String className) { AssertUtils.assertNotNull(object); boolean result = false; Class clazz = object.getClass(); if (clazz.getName().equals(className) == true) { result = true; } return result; } static Map<String, Object> toMap(Object i...
### Question: MappingUtils { public static boolean objectAssignableTo(Object object, String className) throws MjdbcException { AssertUtils.assertNotNull(object); boolean result = false; Class clazz = null; try { clazz = Class.forName(className); } catch (ClassNotFoundException ex) { throw new MjdbcException(ex); } resu...
### Question: MappingUtils { public static boolean isCustomBean(Object value) { assertNotNull(value); return !value.getClass().getName().startsWith("java"); } static Map<String, Object> toMap(Object inputParameter, PropertyDescriptor[] propertyDescriptors); static PropertyDescriptor[] propertyDescriptors(Class<?> claz...
### Question: InputUtils { public static void defineOrder(ProcessedInput processedInput, QueryParameters parameters) { String parameterName = null; for (int i = 0; i < processedInput.getAmountOfParameters(); i++) { parameterName = processedInput.getParameterName(i); if (parameterName != null) { parameters.updatePositio...
### Question: InputUtils { public static String getClassName(Map<String, Object> map) { String className = null; if (map.containsKey(MAP_CLASS_NAME) == true) { className = (String) map.get(MAP_CLASS_NAME); } return className; } static void defineOrder(ProcessedInput processedInput, QueryParameters parameters); static ...
### Question: InputUtils { public static void setClassName(Map<String, Object> map, String className) { String processedClassName = className; if (processedClassName != null) { processedClassName = processedClassName.replaceAll("\\.", "_"); } map.put(MAP_CLASS_NAME, processedClassName); } static void defineOrder(Proce...
### Question: InputUtils { public static boolean isClassNameKey(String key) { boolean equals = false; if (MAP_CLASS_NAME.equals(key) == true) { equals = true; } return equals; } static void defineOrder(ProcessedInput processedInput, QueryParameters parameters); static String getClassName(Map<String, Object> map); stat...
### Question: InputUtils { public static String addClassName(String className, String key) { return className.toLowerCase() + "." + key.toLowerCase(); } static void defineOrder(ProcessedInput processedInput, QueryParameters parameters); static String getClassName(Map<String, Object> map); static void setClassName(Map<...
### Question: InputUtils { public static String removeClassName(String classNameKey) { String[] splitKey = classNameKey.split("[.]"); String resultString = ""; for (int i = 1; i < splitKey.length; i++) { resultString = resultString.concat(splitKey[i]); if ((i + 1) < splitKey.length) { resultString = resultString.concat...
### Question: Overrider { public void overrideOnce(String operation, Object value) { this.overrideOnce.put(operation, value); } Overrider(); Overrider(Overrider overrider); void overrideOnce(String operation, Object value); void override(String operation, Object value); void removeOverride(String operation); boolean h...
### Question: InputUtils { public static String getParameterPrefix() { return PARAMETER_PREFIX; } static void defineOrder(ProcessedInput processedInput, QueryParameters parameters); static String getClassName(Map<String, Object> map); static void setClassName(Map<String, Object> map, String className); static boolean ...
### Question: InputUtils { public static String addParameterPrefix(String str) { return getParameterPrefix() + str; } static void defineOrder(ProcessedInput processedInput, QueryParameters parameters); static String getClassName(Map<String, Object> map); static void setClassName(Map<String, Object> map, String classNa...
### Question: InputUtils { public static String removeParameterPrefix(String str) { return str.substring(getParameterPrefix().length()); } static void defineOrder(ProcessedInput processedInput, QueryParameters parameters); static String getClassName(Map<String, Object> map); static void setClassName(Map<String, Object...