code
stringlengths
130
281k
code_dependency
stringlengths
182
306k
public class class_name { private static void createFacetBase(ComponentFacet cf, int level, MtasDataCollector<?, ?> dataCollector, Map<Integer, Integer> positionsData, Map<MtasSpanQuery, Map<Integer, Integer>> spansNumberData, Map<String, SortedMap<String, int[]>> facetData, Integer[] docSet) throws IOException { for (MtasFunctionParserFunction function : cf.baseFunctionParserFunctions[level]) { if (function.needArgumentsNumber() > cf.spanQueries.length) { throw new IOException("function " + function + " expects (at least) " + function.needArgumentsNumber() + " queries"); } } Map<String, int[]> list = facetData.get(cf.baseFields[level]); if (dataCollector != null) { MtasDataCollector<?, ?> subDataCollector = null; dataCollector.initNewList(1); if (cf.baseFunctionList[level] != null) { SubComponentFunction[] tmpList; if (!cf.baseFunctionList[level].containsKey(dataCollector)) { tmpList = new SubComponentFunction[cf.baseFunctionParserFunctions[level].length]; cf.baseFunctionList[level].put(dataCollector, tmpList); for (int i = 0; i < cf.baseFunctionParserFunctions[level].length; i++) { try { tmpList[i] = new SubComponentFunction( DataCollector.COLLECTOR_TYPE_LIST, cf.baseFunctionKeys[level][i], cf.baseFunctionTypes[level][i], cf.baseFunctionParserFunctions[level][i], null, null, 0, Integer.MAX_VALUE, null, null); } catch (ParseException e) { throw new IOException(e.getMessage()); } } } else { tmpList = cf.baseFunctionList[level].get(dataCollector); } for (SubComponentFunction function : tmpList) { function.dataCollector.initNewList(1); } } // check type if (dataCollector.getCollectorType() .equals(DataCollector.COLLECTOR_TYPE_LIST)) { dataCollector.setWithTotal(); // only if documents and facets if (docSet.length > 0 && list.size() > 0) { HashMap<String, Integer[]> docLists = new HashMap<>(); HashMap<String, String> groupedKeys = new HashMap<>(); boolean documentsInFacets = false; // compute intersections for (Entry<String, int[]> entry : list.entrySet()) { // fill grouped keys if (!groupedKeys.containsKey(entry.getKey())) { groupedKeys.put(entry.getKey(), groupedKeyName(entry.getKey(), cf.baseRangeSizes[level], cf.baseRangeBases[level])); } // intersect docSet with docList Integer[] docList = intersectedDocList(entry.getValue(), docSet); if (docList != null && docList.length > 0) { documentsInFacets = true; } // update docLists if (docLists.containsKey(groupedKeys.get(entry.getKey()))) { docLists.put(groupedKeys.get(entry.getKey()), mergeDocLists( docLists.get(groupedKeys.get(entry.getKey())), docList)); } else { docLists.put(groupedKeys.get(entry.getKey()), docList); } } // compute stats for each key if (documentsInFacets) { Map<Integer, long[]> args = computeArguments(spansNumberData, cf.spanQueries, docSet); if (cf.baseDataTypes[level].equals(CodecUtil.DATA_TYPE_LONG)) { // check functions boolean applySumRule = false; if (cf.baseStatsTypes[level].equals(CodecUtil.STATS_BASIC) && cf.baseParsers[level].sumRule() && (cf.baseMinimumLongs[level] == null) && (cf.baseMaximumLongs[level] == null)) { applySumRule = true; if (cf.baseFunctionList[level].get(dataCollector) != null) { for (SubComponentFunction function : cf.baseFunctionList[level] .get(dataCollector)) { if (!function.statsType.equals(CodecUtil.STATS_BASIC) || !function.parserFunction.sumRule() || function.parserFunction.needPositions()) { applySumRule = false; break; } } } } if (applySumRule) { for (String key : new LinkedHashSet<String>( groupedKeys.values())) { if (docLists.get(key).length > 0) { // initialise Integer[] subDocSet = docLists.get(key); int length = cf.baseParsers[level].needArgumentsNumber(); long[] valueSum = new long[length]; long valuePositions = 0; // collect if (subDocSet.length > 0) { long[] tmpArgs; for (int docId : subDocSet) { tmpArgs = args.get(docId); if (positionsData != null && positionsData.containsKey(docId) && positionsData.get(docId) != null) { valuePositions += positionsData.get(docId) .longValue(); } if (tmpArgs != null) { for (int i = 0; i < length; i++) { valueSum[i] += tmpArgs[i]; } } } long value; try { value = cf.baseParsers[level].getValueLong(valueSum, valuePositions); subDataCollector = dataCollector.add(key, value, subDocSet.length); } catch (IOException e) { log.debug(e); dataCollector.error(key, e.getMessage()); subDataCollector = null; } if (cf.baseFunctionList[level] != null && cf.baseFunctionList[level] .containsKey(dataCollector)) { SubComponentFunction[] functionList = cf.baseFunctionList[level] .get(dataCollector); for (SubComponentFunction function : functionList) { if (function.dataType .equals(CodecUtil.DATA_TYPE_LONG)) { try { long valueLong = function.parserFunction .getValueLong(valueSum, valuePositions); function.dataCollector.add(key, valueLong, subDocSet.length); } catch (IOException e) { log.debug(e); function.dataCollector.error(key, e.getMessage()); } } else if (function.dataType .equals(CodecUtil.DATA_TYPE_DOUBLE)) { try { double valueDouble = function.parserFunction .getValueDouble(valueSum, valuePositions); function.dataCollector.add(key, valueDouble, subDocSet.length); } catch (IOException e) { log.debug(e); function.dataCollector.error(key, e.getMessage()); } } } } if (subDataCollector != null) { createFacetBase(cf, (level + 1), subDataCollector, positionsData, spansNumberData, facetData, subDocSet); } } } } } else { for (String key : new LinkedHashSet<String>( groupedKeys.values())) { if (docLists.get(key).length > 0) { // initialise Integer[] subDocSet = docLists.get(key); // collect if (subDocSet.length > 0 && cf.baseDataTypes[level] .equals(CodecUtil.DATA_TYPE_LONG)) { // check for functions long[][] functionValuesLong = null; double[][] functionValuesDouble = null; int[] functionNumber = null; SubComponentFunction[] functionList = null; if (cf.baseFunctionList[level] != null && cf.baseFunctionList[level] .containsKey(dataCollector)) { functionList = cf.baseFunctionList[level] .get(dataCollector); functionValuesLong = new long[functionList.length][]; functionValuesDouble = new double[functionList.length][]; functionNumber = new int[functionList.length]; for (int i = 0; i < functionList.length; i++) { functionValuesLong[i] = new long[subDocSet.length]; functionValuesDouble[i] = new double[subDocSet.length]; } } // check main int number = 0; Integer[] restrictedSubDocSet = new Integer[subDocSet.length]; long[] values = new long[subDocSet.length]; for (int docId : subDocSet) { long[] tmpArgs = args.get(docId); int tmpPositions = (positionsData == null) ? 0 : (positionsData.get(docId) == null ? 0 : positionsData.get(docId)); long value = cf.baseParsers[level].getValueLong(tmpArgs, tmpPositions); if ((cf.baseMinimumLongs[level] == null || value >= cf.baseMinimumLongs[level]) && (cf.baseMaximumLongs[level] == null || value <= cf.baseMaximumLongs[level])) { values[number] = value; restrictedSubDocSet[number] = docId; number++; if (functionList != null) { for (int i = 0; i < functionList.length; i++) { SubComponentFunction function = functionList[i]; if (function.dataType .equals(CodecUtil.DATA_TYPE_LONG)) { try { functionValuesLong[i][functionNumber[i]] = function.parserFunction .getValueLong(tmpArgs, tmpPositions); functionNumber[i]++; } catch (IOException e) { log.debug(e); function.dataCollector.error(key, e.getMessage()); } } else if (function.dataType .equals(CodecUtil.DATA_TYPE_DOUBLE)) { try { functionValuesDouble[i][functionNumber[i]] = function.parserFunction .getValueDouble(tmpArgs, tmpPositions); functionNumber[i]++; } catch (IOException e) { log.debug(e); function.dataCollector.error(key, e.getMessage()); } } } } } } if (number > 0) { subDataCollector = dataCollector.add(key, values, number); if (cf.baseFunctionList[level] != null && cf.baseFunctionList[level] .containsKey(dataCollector)) { for (int i = 0; i < functionList.length; i++) { SubComponentFunction function = functionList[i]; if (function.dataType .equals(CodecUtil.DATA_TYPE_LONG)) { function.dataCollector.add(key, functionValuesLong[i], functionNumber[i]); } else if (function.dataType .equals(CodecUtil.DATA_TYPE_DOUBLE)) { function.dataCollector.add(key, functionValuesDouble[i], functionNumber[i]); } } } if (subDataCollector != null) { createFacetBase(cf, (level + 1), subDataCollector, positionsData, spansNumberData, facetData, Arrays .copyOfRange(restrictedSubDocSet, 0, number)); } } } } } } } else { throw new IOException( "unexpected dataType " + cf.baseDataTypes[level]); } } } } else { throw new IOException( "unexpected type " + dataCollector.getCollectorType()); } dataCollector.closeNewList(); if (cf.baseFunctionList[level] != null && cf.baseFunctionList[level].containsKey(dataCollector)) { SubComponentFunction[] tmpList = cf.baseFunctionList[level] .get(dataCollector); for (SubComponentFunction function : tmpList) { function.dataCollector.closeNewList(); } } } } }
public class class_name { private static void createFacetBase(ComponentFacet cf, int level, MtasDataCollector<?, ?> dataCollector, Map<Integer, Integer> positionsData, Map<MtasSpanQuery, Map<Integer, Integer>> spansNumberData, Map<String, SortedMap<String, int[]>> facetData, Integer[] docSet) throws IOException { for (MtasFunctionParserFunction function : cf.baseFunctionParserFunctions[level]) { if (function.needArgumentsNumber() > cf.spanQueries.length) { throw new IOException("function " + function + " expects (at least) " + function.needArgumentsNumber() + " queries"); } } Map<String, int[]> list = facetData.get(cf.baseFields[level]); if (dataCollector != null) { MtasDataCollector<?, ?> subDataCollector = null; dataCollector.initNewList(1); if (cf.baseFunctionList[level] != null) { SubComponentFunction[] tmpList; if (!cf.baseFunctionList[level].containsKey(dataCollector)) { tmpList = new SubComponentFunction[cf.baseFunctionParserFunctions[level].length]; cf.baseFunctionList[level].put(dataCollector, tmpList); for (int i = 0; i < cf.baseFunctionParserFunctions[level].length; i++) { try { tmpList[i] = new SubComponentFunction( DataCollector.COLLECTOR_TYPE_LIST, cf.baseFunctionKeys[level][i], cf.baseFunctionTypes[level][i], cf.baseFunctionParserFunctions[level][i], null, null, 0, Integer.MAX_VALUE, null, null); // depends on control dependency: [try], data = [none] } catch (ParseException e) { throw new IOException(e.getMessage()); } // depends on control dependency: [catch], data = [none] } } else { tmpList = cf.baseFunctionList[level].get(dataCollector); } for (SubComponentFunction function : tmpList) { function.dataCollector.initNewList(1); } } // check type if (dataCollector.getCollectorType() .equals(DataCollector.COLLECTOR_TYPE_LIST)) { dataCollector.setWithTotal(); // only if documents and facets if (docSet.length > 0 && list.size() > 0) { HashMap<String, Integer[]> docLists = new HashMap<>(); HashMap<String, String> groupedKeys = new HashMap<>(); boolean documentsInFacets = false; // compute intersections for (Entry<String, int[]> entry : list.entrySet()) { // fill grouped keys if (!groupedKeys.containsKey(entry.getKey())) { groupedKeys.put(entry.getKey(), groupedKeyName(entry.getKey(), cf.baseRangeSizes[level], cf.baseRangeBases[level])); } // intersect docSet with docList Integer[] docList = intersectedDocList(entry.getValue(), docSet); if (docList != null && docList.length > 0) { documentsInFacets = true; } // update docLists if (docLists.containsKey(groupedKeys.get(entry.getKey()))) { docLists.put(groupedKeys.get(entry.getKey()), mergeDocLists( docLists.get(groupedKeys.get(entry.getKey())), docList)); } else { docLists.put(groupedKeys.get(entry.getKey()), docList); } } // compute stats for each key if (documentsInFacets) { Map<Integer, long[]> args = computeArguments(spansNumberData, cf.spanQueries, docSet); if (cf.baseDataTypes[level].equals(CodecUtil.DATA_TYPE_LONG)) { // check functions boolean applySumRule = false; if (cf.baseStatsTypes[level].equals(CodecUtil.STATS_BASIC) && cf.baseParsers[level].sumRule() && (cf.baseMinimumLongs[level] == null) && (cf.baseMaximumLongs[level] == null)) { applySumRule = true; if (cf.baseFunctionList[level].get(dataCollector) != null) { for (SubComponentFunction function : cf.baseFunctionList[level] .get(dataCollector)) { if (!function.statsType.equals(CodecUtil.STATS_BASIC) || !function.parserFunction.sumRule() || function.parserFunction.needPositions()) { applySumRule = false; break; } } } } if (applySumRule) { for (String key : new LinkedHashSet<String>( groupedKeys.values())) { if (docLists.get(key).length > 0) { // initialise Integer[] subDocSet = docLists.get(key); int length = cf.baseParsers[level].needArgumentsNumber(); long[] valueSum = new long[length]; long valuePositions = 0; // collect if (subDocSet.length > 0) { long[] tmpArgs; for (int docId : subDocSet) { tmpArgs = args.get(docId); if (positionsData != null && positionsData.containsKey(docId) && positionsData.get(docId) != null) { valuePositions += positionsData.get(docId) .longValue(); } if (tmpArgs != null) { for (int i = 0; i < length; i++) { valueSum[i] += tmpArgs[i]; } } } long value; try { value = cf.baseParsers[level].getValueLong(valueSum, valuePositions); subDataCollector = dataCollector.add(key, value, subDocSet.length); } catch (IOException e) { log.debug(e); dataCollector.error(key, e.getMessage()); subDataCollector = null; } if (cf.baseFunctionList[level] != null && cf.baseFunctionList[level] .containsKey(dataCollector)) { SubComponentFunction[] functionList = cf.baseFunctionList[level] .get(dataCollector); for (SubComponentFunction function : functionList) { if (function.dataType .equals(CodecUtil.DATA_TYPE_LONG)) { try { long valueLong = function.parserFunction .getValueLong(valueSum, valuePositions); function.dataCollector.add(key, valueLong, subDocSet.length); } catch (IOException e) { log.debug(e); function.dataCollector.error(key, e.getMessage()); } } else if (function.dataType .equals(CodecUtil.DATA_TYPE_DOUBLE)) { try { double valueDouble = function.parserFunction .getValueDouble(valueSum, valuePositions); function.dataCollector.add(key, valueDouble, subDocSet.length); } catch (IOException e) { log.debug(e); function.dataCollector.error(key, e.getMessage()); } } } } if (subDataCollector != null) { createFacetBase(cf, (level + 1), subDataCollector, positionsData, spansNumberData, facetData, subDocSet); } } } } } else { for (String key : new LinkedHashSet<String>( groupedKeys.values())) { if (docLists.get(key).length > 0) { // initialise Integer[] subDocSet = docLists.get(key); // collect if (subDocSet.length > 0 && cf.baseDataTypes[level] .equals(CodecUtil.DATA_TYPE_LONG)) { // check for functions long[][] functionValuesLong = null; double[][] functionValuesDouble = null; int[] functionNumber = null; SubComponentFunction[] functionList = null; if (cf.baseFunctionList[level] != null && cf.baseFunctionList[level] .containsKey(dataCollector)) { functionList = cf.baseFunctionList[level] .get(dataCollector); functionValuesLong = new long[functionList.length][]; functionValuesDouble = new double[functionList.length][]; functionNumber = new int[functionList.length]; for (int i = 0; i < functionList.length; i++) { functionValuesLong[i] = new long[subDocSet.length]; functionValuesDouble[i] = new double[subDocSet.length]; } } // check main int number = 0; Integer[] restrictedSubDocSet = new Integer[subDocSet.length]; long[] values = new long[subDocSet.length]; for (int docId : subDocSet) { long[] tmpArgs = args.get(docId); int tmpPositions = (positionsData == null) ? 0 : (positionsData.get(docId) == null ? 0 : positionsData.get(docId)); long value = cf.baseParsers[level].getValueLong(tmpArgs, tmpPositions); if ((cf.baseMinimumLongs[level] == null || value >= cf.baseMinimumLongs[level]) && (cf.baseMaximumLongs[level] == null || value <= cf.baseMaximumLongs[level])) { values[number] = value; restrictedSubDocSet[number] = docId; number++; if (functionList != null) { for (int i = 0; i < functionList.length; i++) { SubComponentFunction function = functionList[i]; if (function.dataType .equals(CodecUtil.DATA_TYPE_LONG)) { try { functionValuesLong[i][functionNumber[i]] = function.parserFunction .getValueLong(tmpArgs, tmpPositions); functionNumber[i]++; } catch (IOException e) { log.debug(e); function.dataCollector.error(key, e.getMessage()); } } else if (function.dataType .equals(CodecUtil.DATA_TYPE_DOUBLE)) { try { functionValuesDouble[i][functionNumber[i]] = function.parserFunction .getValueDouble(tmpArgs, tmpPositions); functionNumber[i]++; } catch (IOException e) { log.debug(e); function.dataCollector.error(key, e.getMessage()); } } } } } } if (number > 0) { subDataCollector = dataCollector.add(key, values, number); if (cf.baseFunctionList[level] != null && cf.baseFunctionList[level] .containsKey(dataCollector)) { for (int i = 0; i < functionList.length; i++) { SubComponentFunction function = functionList[i]; if (function.dataType .equals(CodecUtil.DATA_TYPE_LONG)) { function.dataCollector.add(key, functionValuesLong[i], functionNumber[i]); } else if (function.dataType .equals(CodecUtil.DATA_TYPE_DOUBLE)) { function.dataCollector.add(key, functionValuesDouble[i], functionNumber[i]); } } } if (subDataCollector != null) { createFacetBase(cf, (level + 1), subDataCollector, positionsData, spansNumberData, facetData, Arrays .copyOfRange(restrictedSubDocSet, 0, number)); } } } } } } } else { throw new IOException( "unexpected dataType " + cf.baseDataTypes[level]); } } } } else { throw new IOException( "unexpected type " + dataCollector.getCollectorType()); } dataCollector.closeNewList(); if (cf.baseFunctionList[level] != null && cf.baseFunctionList[level].containsKey(dataCollector)) { SubComponentFunction[] tmpList = cf.baseFunctionList[level] .get(dataCollector); for (SubComponentFunction function : tmpList) { function.dataCollector.closeNewList(); } } } } }
public class class_name { @Override public final boolean configure(FeatureContext featureContext) { HashMap<Integer, String> errorMap = Maps.newHashMap(); Map<String, Object> config = featureContext.getConfiguration().getProperties(); String defaultTemplate = null; String clazz = (String) config.get(GEN_CONF_KEY); Class clz; if (StringUtils.isBlank(clazz)) { clz = ErrorPageGenerator.class; } else { try { clz = ClassUtils.getClass(clazz); } catch (ClassNotFoundException e) { throw new ConfigErrorException(GEN_CONF_KEY + "config error,not found class " + clazz, GEN_CONF_KEY, e); } } for (String key : config.keySet()) { if (StringUtils.isNotBlank(key) && key.startsWith("http.error.page.")) { int startIndex = key.lastIndexOf("."); String statusCodeStr = key.substring(startIndex + 1); if (StringUtils.isNotBlank(statusCodeStr)) { if (statusCodeStr.toLowerCase().equals("default")) { defaultTemplate = (String) config.get(key); defaultTemplate = defaultTemplate.startsWith("/") ? defaultTemplate : "/" + defaultTemplate; } else if (!statusCodeStr.toLowerCase().equals("generator")) { try { String va = (String) config.get(key); int statusCode = Integer.parseInt(statusCodeStr); if (StringUtils.isNotBlank(va)) errorMap.put(statusCode, va.startsWith("/") ? va : "/" + va); } catch (Exception e) { logger.error("parse error status mapping error", e); } } } } } ErrorPageGenerator.setDefaultErrorTemplate(defaultTemplate); ErrorPageGenerator.pushAllErrorMap(errorMap); featureContext.register(clz); return true; } }
public class class_name { @Override public final boolean configure(FeatureContext featureContext) { HashMap<Integer, String> errorMap = Maps.newHashMap(); Map<String, Object> config = featureContext.getConfiguration().getProperties(); String defaultTemplate = null; String clazz = (String) config.get(GEN_CONF_KEY); Class clz; if (StringUtils.isBlank(clazz)) { clz = ErrorPageGenerator.class; // depends on control dependency: [if], data = [none] } else { try { clz = ClassUtils.getClass(clazz); // depends on control dependency: [try], data = [none] } catch (ClassNotFoundException e) { throw new ConfigErrorException(GEN_CONF_KEY + "config error,not found class " + clazz, GEN_CONF_KEY, e); } // depends on control dependency: [catch], data = [none] } for (String key : config.keySet()) { if (StringUtils.isNotBlank(key) && key.startsWith("http.error.page.")) { int startIndex = key.lastIndexOf("."); String statusCodeStr = key.substring(startIndex + 1); if (StringUtils.isNotBlank(statusCodeStr)) { if (statusCodeStr.toLowerCase().equals("default")) { defaultTemplate = (String) config.get(key); defaultTemplate = defaultTemplate.startsWith("/") ? defaultTemplate : "/" + defaultTemplate; } else if (!statusCodeStr.toLowerCase().equals("generator")) { try { String va = (String) config.get(key); int statusCode = Integer.parseInt(statusCodeStr); if (StringUtils.isNotBlank(va)) errorMap.put(statusCode, va.startsWith("/") ? va : "/" + va); } catch (Exception e) { logger.error("parse error status mapping error", e); } } } } } ErrorPageGenerator.setDefaultErrorTemplate(defaultTemplate); ErrorPageGenerator.pushAllErrorMap(errorMap); featureContext.register(clz); return true; } }
public class class_name { private void createDatabaseIfNotExist(boolean drop) throws URISyntaxException, IOException, ClientProtocolException { boolean exist = checkForDBExistence(); if (exist && drop) { dropDatabase(); exist = false; } if (!exist) { URI uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(), CouchDBConstants.URL_SEPARATOR + databaseName.toLowerCase(), null, null); HttpPut put = new HttpPut(uri); HttpResponse putRes = null; try { // creating database. putRes = httpClient.execute(httpHost, put, CouchDBUtils.getContext(httpHost)); } finally { CouchDBUtils.closeContent(putRes); } } } }
public class class_name { private void createDatabaseIfNotExist(boolean drop) throws URISyntaxException, IOException, ClientProtocolException { boolean exist = checkForDBExistence(); if (exist && drop) { dropDatabase(); exist = false; } if (!exist) { URI uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(), CouchDBConstants.URL_SEPARATOR + databaseName.toLowerCase(), null, null); HttpPut put = new HttpPut(uri); HttpResponse putRes = null; try { // creating database. putRes = httpClient.execute(httpHost, put, CouchDBUtils.getContext(httpHost)); // depends on control dependency: [try], data = [none] } finally { CouchDBUtils.closeContent(putRes); } } } }
public class class_name { private void rotateLeft(TreeEntry<E> p) { if (p != null) { TreeEntry<E> r = p.right; p.right = r.left; if (r.left != null) { r.left.parent = p; } r.parent = p.parent; if (p.parent == null) { root = r; } else if (p.parent.left == p) { p.parent.left = r; } else { p.parent.right = r; } r.left = p; p.parent = r; // Original C code: // x->maxHigh=ITMax(x->left->maxHigh,ITMax(x->right->maxHigh,x->high)) // Original C Code: // y->maxHigh=ITMax(x->maxHigh,ITMax(y->right->maxHigh,y->high)) p.maxHigh = Math.max( p.left != null ? p.left.maxHigh : Long.MIN_VALUE, Math.max(p.right != null ? p.right.maxHigh : Long.MIN_VALUE, p.high)); r.maxHigh = Math.max(p.maxHigh, Math.max(r.right != null ? r.right.maxHigh : Long.MIN_VALUE, r.high)); } } }
public class class_name { private void rotateLeft(TreeEntry<E> p) { if (p != null) { TreeEntry<E> r = p.right; p.right = r.left; // depends on control dependency: [if], data = [none] if (r.left != null) { r.left.parent = p; // depends on control dependency: [if], data = [none] } r.parent = p.parent; // depends on control dependency: [if], data = [none] if (p.parent == null) { root = r; // depends on control dependency: [if], data = [none] } else if (p.parent.left == p) { p.parent.left = r; // depends on control dependency: [if], data = [none] } else { p.parent.right = r; // depends on control dependency: [if], data = [none] } r.left = p; // depends on control dependency: [if], data = [none] p.parent = r; // depends on control dependency: [if], data = [none] // Original C code: // x->maxHigh=ITMax(x->left->maxHigh,ITMax(x->right->maxHigh,x->high)) // Original C Code: // y->maxHigh=ITMax(x->maxHigh,ITMax(y->right->maxHigh,y->high)) p.maxHigh = Math.max( p.left != null ? p.left.maxHigh : Long.MIN_VALUE, Math.max(p.right != null ? p.right.maxHigh : Long.MIN_VALUE, p.high)); // depends on control dependency: [if], data = [none] r.maxHigh = Math.max(p.maxHigh, Math.max(r.right != null ? r.right.maxHigh : Long.MIN_VALUE, r.high)); // depends on control dependency: [if], data = [(p] } } }
public class class_name { private static String[] tokenize(String string) { if (string.indexOf("?") == -1 && string.indexOf("*") == -1) { return new String[] { string }; } char[] textArray = string.toCharArray(); List<String> tokens = new ArrayList<String>(); StringBuilder tokenBuilder = new StringBuilder(); for (int i = 0; i < textArray.length; i++) { if (textArray[i] != '?' && textArray[i] != '*') { // collect non wild card characters tokenBuilder.append(textArray[i]); continue; } if (tokenBuilder.length() != 0) { tokens.add(tokenBuilder.toString()); tokenBuilder.setLength(0); } if (textArray[i] == '?') { tokens.add("?"); } else if (tokens.size() == 0 || (i > 0 && tokens.get(tokens.size() - 1).equals("*") == false)) { tokens.add("*"); } } if (tokenBuilder.length() != 0) { tokens.add(tokenBuilder.toString()); } return (String[]) tokens.toArray(new String[tokens.size()]); } }
public class class_name { private static String[] tokenize(String string) { if (string.indexOf("?") == -1 && string.indexOf("*") == -1) { return new String[] { string }; // depends on control dependency: [if], data = [none] } char[] textArray = string.toCharArray(); List<String> tokens = new ArrayList<String>(); StringBuilder tokenBuilder = new StringBuilder(); for (int i = 0; i < textArray.length; i++) { if (textArray[i] != '?' && textArray[i] != '*') { // collect non wild card characters tokenBuilder.append(textArray[i]); // depends on control dependency: [if], data = [(textArray[i]] continue; } if (tokenBuilder.length() != 0) { tokens.add(tokenBuilder.toString()); // depends on control dependency: [if], data = [none] tokenBuilder.setLength(0); // depends on control dependency: [if], data = [0)] } if (textArray[i] == '?') { tokens.add("?"); // depends on control dependency: [if], data = [none] } else if (tokens.size() == 0 || (i > 0 && tokens.get(tokens.size() - 1).equals("*") == false)) { tokens.add("*"); // depends on control dependency: [if], data = [none] } } if (tokenBuilder.length() != 0) { tokens.add(tokenBuilder.toString()); // depends on control dependency: [if], data = [none] } return (String[]) tokens.toArray(new String[tokens.size()]); } }
public class class_name { protected Field createIndexField(String key, Object value) { if (key == null || value == null) { return null; } if (value instanceof Boolean) { return new IntPoint(key, ((Boolean) value).booleanValue() ? 1 : 0); } if (value instanceof Character) { return new StringField(key, value.toString(), Store.NO); } if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long) { Number v = (Number) value; return new LongPoint(key, v.longValue()); } if (value instanceof Float || value instanceof Double) { Number v = (Number) value; return new DoublePoint(key, v.doubleValue()); } if (value instanceof Date) { return new StringField(key, DateFormatUtils.toString((Date) value, DATETIME_FORMAT), Store.NO); } if (value instanceof String) { String v = value.toString().trim(); return v.indexOf(' ') >= 0 ? new TextField(key, v, Store.NO) : new StringField(key, v, Store.NO); } return null; } }
public class class_name { protected Field createIndexField(String key, Object value) { if (key == null || value == null) { return null; // depends on control dependency: [if], data = [none] } if (value instanceof Boolean) { return new IntPoint(key, ((Boolean) value).booleanValue() ? 1 : 0); // depends on control dependency: [if], data = [none] } if (value instanceof Character) { return new StringField(key, value.toString(), Store.NO); // depends on control dependency: [if], data = [none] } if (value instanceof Byte || value instanceof Short || value instanceof Integer || value instanceof Long) { Number v = (Number) value; return new LongPoint(key, v.longValue()); // depends on control dependency: [if], data = [none] } if (value instanceof Float || value instanceof Double) { Number v = (Number) value; return new DoublePoint(key, v.doubleValue()); // depends on control dependency: [if], data = [none] } if (value instanceof Date) { return new StringField(key, DateFormatUtils.toString((Date) value, DATETIME_FORMAT), Store.NO); // depends on control dependency: [if], data = [none] } if (value instanceof String) { String v = value.toString().trim(); return v.indexOf(' ') >= 0 ? new TextField(key, v, Store.NO) : new StringField(key, v, Store.NO); // depends on control dependency: [if], data = [none] } return null; } }
public class class_name { public <Value> PushMeasure<Value> createPushFromPull( PullMeasure<Value> pull, final long period) { SimplePushMeasure<Value> push = new SimplePushMeasure<>(pull.getName(), pull.getDescription()); final WeakReference<PullMeasure<Value>> weakPull = new WeakReference<PullMeasure<Value>>( pull); final WeakReference<SimplePushMeasure<Value>> weakPush = new WeakReference<SimplePushMeasure<Value>>( push); final Value initialValue = pull.get(); /* * TODO Use a static thread to run the checks of all the measures * created that way. Using a WeakHashMap could probably do the trick. */ Thread thread = new Thread(new Runnable() { private Value lastValue = initialValue; @Override public void run() { boolean isThreadNeeded = true; long alreadyConsumed = 0; while (isThreadNeeded) { if (alreadyConsumed > period) { long realConsumption = alreadyConsumed; long missed = alreadyConsumed / period; alreadyConsumed = alreadyConsumed % period; log.warning("Too much time consumed in the last measuring (" + realConsumption + ">" + period + "), ignore the " + missed + " pushes missed and consider it has consumed " + alreadyConsumed); } else { // usual case. } try { Thread.sleep(period - alreadyConsumed); } catch (InterruptedException e) { throw new JMetalException("Error in run method: ", e) ; } long measureStart = System.currentTimeMillis(); PullMeasure<Value> pull = weakPull.get(); SimplePushMeasure<Value> push = weakPush.get(); if (pull == null || push == null) { isThreadNeeded = false; } else { Value value = pull.get(); if (value == lastValue || value != null && value.equals(lastValue)) { // still the same, don't notify } else { lastValue = value; push.push(value); } } pull = null; push = null; long measureEnd = System.currentTimeMillis(); alreadyConsumed = measureEnd - measureStart; } } }); thread.setDaemon(true); thread.start(); return push; } }
public class class_name { public <Value> PushMeasure<Value> createPushFromPull( PullMeasure<Value> pull, final long period) { SimplePushMeasure<Value> push = new SimplePushMeasure<>(pull.getName(), pull.getDescription()); final WeakReference<PullMeasure<Value>> weakPull = new WeakReference<PullMeasure<Value>>( pull); final WeakReference<SimplePushMeasure<Value>> weakPush = new WeakReference<SimplePushMeasure<Value>>( push); final Value initialValue = pull.get(); /* * TODO Use a static thread to run the checks of all the measures * created that way. Using a WeakHashMap could probably do the trick. */ Thread thread = new Thread(new Runnable() { private Value lastValue = initialValue; @Override public void run() { boolean isThreadNeeded = true; long alreadyConsumed = 0; while (isThreadNeeded) { if (alreadyConsumed > period) { long realConsumption = alreadyConsumed; long missed = alreadyConsumed / period; alreadyConsumed = alreadyConsumed % period; // depends on control dependency: [if], data = [none] log.warning("Too much time consumed in the last measuring (" + realConsumption + ">" + period + "), ignore the " + missed + " pushes missed and consider it has consumed " + alreadyConsumed); // depends on control dependency: [if], data = [none] } else { // usual case. } try { Thread.sleep(period - alreadyConsumed); // depends on control dependency: [try], data = [none] } catch (InterruptedException e) { throw new JMetalException("Error in run method: ", e) ; } // depends on control dependency: [catch], data = [none] long measureStart = System.currentTimeMillis(); PullMeasure<Value> pull = weakPull.get(); SimplePushMeasure<Value> push = weakPush.get(); if (pull == null || push == null) { isThreadNeeded = false; // depends on control dependency: [if], data = [none] } else { Value value = pull.get(); if (value == lastValue || value != null && value.equals(lastValue)) { // still the same, don't notify } else { lastValue = value; // depends on control dependency: [if], data = [none] push.push(value); // depends on control dependency: [if], data = [(value] } } pull = null; // depends on control dependency: [while], data = [none] push = null; // depends on control dependency: [while], data = [none] long measureEnd = System.currentTimeMillis(); alreadyConsumed = measureEnd - measureStart; // depends on control dependency: [while], data = [none] } } }); thread.setDaemon(true); thread.start(); return push; } }
public class class_name { @Override final protected void addRange(int left, int right, int additionalId, long additionalRef, Integer id, Long ref) { String key = left + "_" + right; if (index.containsKey(key)) { index.get(key).addIdAndRef(id, ref, additionalId, additionalRef); } else { root = addRange(root, left, right, additionalId, additionalRef, id, ref); root.color = MtasRBTreeNode.BLACK; } } }
public class class_name { @Override final protected void addRange(int left, int right, int additionalId, long additionalRef, Integer id, Long ref) { String key = left + "_" + right; if (index.containsKey(key)) { index.get(key).addIdAndRef(id, ref, additionalId, additionalRef); // depends on control dependency: [if], data = [none] } else { root = addRange(root, left, right, additionalId, additionalRef, id, ref); // depends on control dependency: [if], data = [none] root.color = MtasRBTreeNode.BLACK; // depends on control dependency: [if], data = [none] } } }
public class class_name { @SuppressLint("NewApi") private void applyTintForDrawable(@NonNull Drawable drawable, @Nullable ColorStateList tint, boolean hasTint, @Nullable PorterDuff.Mode tintMode, boolean hasTintMode) { if (hasTint || hasTintMode) { if (hasTint) { if (drawable instanceof TintableDrawable) { //noinspection RedundantCast ((TintableDrawable) drawable).setTintList(tint); } else { logDrawableTintWarning(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { drawable.setTintList(tint); } } } if (hasTintMode) { if (drawable instanceof TintableDrawable) { //noinspection RedundantCast ((TintableDrawable) drawable).setTintMode(tintMode); } else { logDrawableTintWarning(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { drawable.setTintMode(tintMode); } } } // The drawable (or one of its children) may not have been // stateful before applying the tint, so let's try again. if (drawable.isStateful()) { drawable.setState(getDrawableState()); } } } }
public class class_name { @SuppressLint("NewApi") private void applyTintForDrawable(@NonNull Drawable drawable, @Nullable ColorStateList tint, boolean hasTint, @Nullable PorterDuff.Mode tintMode, boolean hasTintMode) { if (hasTint || hasTintMode) { if (hasTint) { if (drawable instanceof TintableDrawable) { //noinspection RedundantCast ((TintableDrawable) drawable).setTintList(tint); // depends on control dependency: [if], data = [none] } else { logDrawableTintWarning(); // depends on control dependency: [if], data = [none] if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { drawable.setTintList(tint); // depends on control dependency: [if], data = [none] } } } if (hasTintMode) { if (drawable instanceof TintableDrawable) { //noinspection RedundantCast ((TintableDrawable) drawable).setTintMode(tintMode); // depends on control dependency: [if], data = [none] } else { logDrawableTintWarning(); // depends on control dependency: [if], data = [none] if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { drawable.setTintMode(tintMode); // depends on control dependency: [if], data = [none] } } } // The drawable (or one of its children) may not have been // stateful before applying the tint, so let's try again. if (drawable.isStateful()) { drawable.setState(getDrawableState()); // depends on control dependency: [if], data = [none] } } } }
public class class_name { @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"}) @Pure public final void toPath2D(Path2d path, double startPosition, double endPosition) { final double length = getLength(); // For performance purpose if ((Double.isNaN(startPosition) || startPosition < 0f) && (Double.isNaN(endPosition) || endPosition >= length)) { toPath2D(path); return; } final double p1; final double p2; if (Double.isNaN(startPosition) || startPosition <= 0f) { p1 = 0.; } else { p1 = startPosition; } if (Double.isNaN(endPosition) || endPosition >= length) { p2 = length; } else { p2 = endPosition; } if (p2 <= p1) { return; } boolean firstDrawn; double curvilinePosition = 0.; double previousCurvilinePosition = 0.; for (final PointGroup grp : groups()) { firstDrawn = true; Point2d previous = null; for (final Point2d pts : grp) { if (p2 <= previousCurvilinePosition) { return; } if (previous != null) { curvilinePosition += previous.getDistance(pts); } if (curvilinePosition >= p1) { final Point2d f; double curvilineDiff; if (previous == null || previousCurvilinePosition >= p1) { f = pts; } else { curvilineDiff = curvilinePosition - previousCurvilinePosition; if (curvilineDiff <= 0.) { f = pts; } else { f = new Point2d(); Segment2afp.interpolates(previous.getX(), previous.getY(), pts.getX(), pts.getY(), (p1 - previousCurvilinePosition) / curvilineDiff, f); } } final Point2d l; if (p2 < curvilinePosition) { assert previous != null && p2 >= previousCurvilinePosition && p2 <= curvilinePosition; curvilineDiff = curvilinePosition - previousCurvilinePosition; if (curvilineDiff <= 0.) { l = null; } else { l = new Point2d(); Segment2afp.interpolates(previous.getX(), previous.getY(), pts.getX(), pts.getY(), (p2 - previousCurvilinePosition) / curvilineDiff, l); } } else { l = null; } if (l == null) { if (firstDrawn) { firstDrawn = false; path.moveTo(f.getX(), f.getY()); } else { path.lineTo(f.getX(), f.getY()); } if (f != pts) { path.lineTo(pts.getX(), pts.getY()); } } else { if (firstDrawn) { firstDrawn = false; path.moveTo(l.getX(), l.getY()); } else { path.lineTo(l.getX(), l.getY()); } } } previous = pts; previousCurvilinePosition = curvilinePosition; } } } }
public class class_name { @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"}) @Pure public final void toPath2D(Path2d path, double startPosition, double endPosition) { final double length = getLength(); // For performance purpose if ((Double.isNaN(startPosition) || startPosition < 0f) && (Double.isNaN(endPosition) || endPosition >= length)) { toPath2D(path); // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } final double p1; final double p2; if (Double.isNaN(startPosition) || startPosition <= 0f) { p1 = 0.; // depends on control dependency: [if], data = [none] } else { p1 = startPosition; // depends on control dependency: [if], data = [none] } if (Double.isNaN(endPosition) || endPosition >= length) { p2 = length; // depends on control dependency: [if], data = [none] } else { p2 = endPosition; // depends on control dependency: [if], data = [none] } if (p2 <= p1) { return; // depends on control dependency: [if], data = [none] } boolean firstDrawn; double curvilinePosition = 0.; double previousCurvilinePosition = 0.; for (final PointGroup grp : groups()) { firstDrawn = true; // depends on control dependency: [for], data = [none] Point2d previous = null; for (final Point2d pts : grp) { if (p2 <= previousCurvilinePosition) { return; // depends on control dependency: [if], data = [none] } if (previous != null) { curvilinePosition += previous.getDistance(pts); // depends on control dependency: [if], data = [none] } if (curvilinePosition >= p1) { final Point2d f; double curvilineDiff; if (previous == null || previousCurvilinePosition >= p1) { f = pts; // depends on control dependency: [if], data = [none] } else { curvilineDiff = curvilinePosition - previousCurvilinePosition; // depends on control dependency: [if], data = [none] if (curvilineDiff <= 0.) { f = pts; // depends on control dependency: [if], data = [none] } else { f = new Point2d(); // depends on control dependency: [if], data = [none] Segment2afp.interpolates(previous.getX(), previous.getY(), pts.getX(), pts.getY(), (p1 - previousCurvilinePosition) / curvilineDiff, f); // depends on control dependency: [if], data = [none] } } final Point2d l; if (p2 < curvilinePosition) { assert previous != null && p2 >= previousCurvilinePosition && p2 <= curvilinePosition; // depends on control dependency: [if], data = [none] curvilineDiff = curvilinePosition - previousCurvilinePosition; // depends on control dependency: [if], data = [none] if (curvilineDiff <= 0.) { l = null; // depends on control dependency: [if], data = [none] } else { l = new Point2d(); // depends on control dependency: [if], data = [none] Segment2afp.interpolates(previous.getX(), previous.getY(), pts.getX(), pts.getY(), (p2 - previousCurvilinePosition) / curvilineDiff, l); // depends on control dependency: [if], data = [none] } } else { l = null; // depends on control dependency: [if], data = [none] } if (l == null) { if (firstDrawn) { firstDrawn = false; // depends on control dependency: [if], data = [none] path.moveTo(f.getX(), f.getY()); // depends on control dependency: [if], data = [none] } else { path.lineTo(f.getX(), f.getY()); // depends on control dependency: [if], data = [none] } if (f != pts) { path.lineTo(pts.getX(), pts.getY()); // depends on control dependency: [if], data = [none] } } else { if (firstDrawn) { firstDrawn = false; // depends on control dependency: [if], data = [none] path.moveTo(l.getX(), l.getY()); // depends on control dependency: [if], data = [none] } else { path.lineTo(l.getX(), l.getY()); // depends on control dependency: [if], data = [none] } } } previous = pts; // depends on control dependency: [for], data = [pts] previousCurvilinePosition = curvilinePosition; // depends on control dependency: [for], data = [none] } } } }
public class class_name { private static Double[] double2DToDouble ( double[][] dd ) { Double[] d = new Double[ dd.length*dd[0].length ]; for ( int n = 0; n < dd[0].length; n++ ) { for ( int m = 0; m < dd.length; m++ ) { d[ m+n*dd.length ] = dd[m][n]; } } return d; } }
public class class_name { private static Double[] double2DToDouble ( double[][] dd ) { Double[] d = new Double[ dd.length*dd[0].length ]; for ( int n = 0; n < dd[0].length; n++ ) { for ( int m = 0; m < dd.length; m++ ) { d[ m+n*dd.length ] = dd[m][n]; // depends on control dependency: [for], data = [m] } } return d; } }
public class class_name { private static Segment parseSegment(final String path, final String token) { int separator = token.indexOf(':'); String name; String parameter; if (separator == -1) { name = token.trim(); parameter = null; } else { name = token.substring(0, separator).trim(); parameter = token.substring(separator + 1).trim(); } if ("date".equals(name)) { return new DateSegment(parameter == null ? DEFAULT_DATE_FORMAT_PATTERN : parameter); } else if ("count".equals(name) && parameter == null) { return new CountSegment(); } else if ("pid".equals(name) && parameter == null) { return new ProcessIdSegment(); } else { throw new IllegalArgumentException("Invalid token '" + token + "' in '" + path + "'"); } } }
public class class_name { private static Segment parseSegment(final String path, final String token) { int separator = token.indexOf(':'); String name; String parameter; if (separator == -1) { name = token.trim(); // depends on control dependency: [if], data = [none] parameter = null; // depends on control dependency: [if], data = [none] } else { name = token.substring(0, separator).trim(); // depends on control dependency: [if], data = [none] parameter = token.substring(separator + 1).trim(); // depends on control dependency: [if], data = [(separator] } if ("date".equals(name)) { return new DateSegment(parameter == null ? DEFAULT_DATE_FORMAT_PATTERN : parameter); // depends on control dependency: [if], data = [none] } else if ("count".equals(name) && parameter == null) { return new CountSegment(); // depends on control dependency: [if], data = [none] } else if ("pid".equals(name) && parameter == null) { return new ProcessIdSegment(); // depends on control dependency: [if], data = [none] } else { throw new IllegalArgumentException("Invalid token '" + token + "' in '" + path + "'"); } } }
public class class_name { public Response handle(AuthleteApi api, MultivaluedMap<String, String> parameters) { try { // Create a handler. IntrospectionRequestHandler handler = new IntrospectionRequestHandler(api); // Delegate the task to the handler. return handler.handle(parameters); } catch (WebApplicationException e) { // An error occurred in the handler. onError(e); // Convert the error to a Response. return e.getResponse(); } } }
public class class_name { public Response handle(AuthleteApi api, MultivaluedMap<String, String> parameters) { try { // Create a handler. IntrospectionRequestHandler handler = new IntrospectionRequestHandler(api); // Delegate the task to the handler. return handler.handle(parameters); // depends on control dependency: [try], data = [none] } catch (WebApplicationException e) { // An error occurred in the handler. onError(e); // Convert the error to a Response. return e.getResponse(); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public int expect(String Data, int NumBytes) { byte target = 0; int cnt = 0; try { while ((NumBytes--) != 0) { target = file.readByte(); if (target != Data.charAt(cnt++)) return DDC_FILE_ERROR; } } catch (IOException ioe) { return DDC_FILE_ERROR; } return DDC_SUCCESS; } }
public class class_name { public int expect(String Data, int NumBytes) { byte target = 0; int cnt = 0; try { while ((NumBytes--) != 0) { target = file.readByte(); // depends on control dependency: [while], data = [none] if (target != Data.charAt(cnt++)) return DDC_FILE_ERROR; } } catch (IOException ioe) { return DDC_FILE_ERROR; } // depends on control dependency: [catch], data = [none] return DDC_SUCCESS; } }
public class class_name { protected AstNode parseCreateCollationStatement( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; markStartOfStatement(tokens); tokens.consume(STMT_CREATE_COLLATION); String name = parseName(tokens); AstNode node = nodeFactory().node(name, parentNode, TYPE_CREATE_COLLATION_STATEMENT); // character set attribute tokens.consume("FOR"); String charSetName = parseName(tokens); node.setProperty(COLLATION_CHARACTER_SET_NAME, charSetName); // collation source // TODO author=Horia Chiorean date=1/4/12 description=Only parsing a string atm (should probably be some nested nodes - // see StandardDdl.cnd tokens.consume("FROM"); String collationSource = null; if (tokens.canConsume("EXTERNAL") || tokens.canConsume("DESC")) { collationSource = consumeParenBoundedTokens(tokens, false); } else if (tokens.canConsume("TRANSLATION")) { StringBuilder translationCollation = new StringBuilder("TRANSLATION ").append(tokens.consume()); if (tokens.canConsume("THEN", "COLLATION")) { translationCollation.append(" THEN COLLATION "); translationCollation.append(parseName(tokens)); } collationSource = translationCollation.toString(); } else { collationSource = parseName(tokens); } node.setProperty(COLLATION_SOURCE, collationSource); // pad attribute if (tokens.canConsume("PAD", "SPACE")) { node.setProperty(PAD_ATTRIBUTE, PAD_ATTRIBUTE_PAD); } else if (tokens.canConsume("NO", "PAD")) { node.setProperty(PAD_ATTRIBUTE, PAD_ATTRIBUTE_NO_PAD); } parseUntilTerminator(tokens); markEndOfStatement(tokens, node); return node; } }
public class class_name { protected AstNode parseCreateCollationStatement( DdlTokenStream tokens, AstNode parentNode ) throws ParsingException { assert tokens != null; assert parentNode != null; markStartOfStatement(tokens); tokens.consume(STMT_CREATE_COLLATION); String name = parseName(tokens); AstNode node = nodeFactory().node(name, parentNode, TYPE_CREATE_COLLATION_STATEMENT); // character set attribute tokens.consume("FOR"); String charSetName = parseName(tokens); node.setProperty(COLLATION_CHARACTER_SET_NAME, charSetName); // collation source // TODO author=Horia Chiorean date=1/4/12 description=Only parsing a string atm (should probably be some nested nodes - // see StandardDdl.cnd tokens.consume("FROM"); String collationSource = null; if (tokens.canConsume("EXTERNAL") || tokens.canConsume("DESC")) { collationSource = consumeParenBoundedTokens(tokens, false); } else if (tokens.canConsume("TRANSLATION")) { StringBuilder translationCollation = new StringBuilder("TRANSLATION ").append(tokens.consume()); if (tokens.canConsume("THEN", "COLLATION")) { translationCollation.append(" THEN COLLATION "); // depends on control dependency: [if], data = [none] translationCollation.append(parseName(tokens)); // depends on control dependency: [if], data = [none] } collationSource = translationCollation.toString(); } else { collationSource = parseName(tokens); } node.setProperty(COLLATION_SOURCE, collationSource); // pad attribute if (tokens.canConsume("PAD", "SPACE")) { node.setProperty(PAD_ATTRIBUTE, PAD_ATTRIBUTE_PAD); } else if (tokens.canConsume("NO", "PAD")) { node.setProperty(PAD_ATTRIBUTE, PAD_ATTRIBUTE_NO_PAD); } parseUntilTerminator(tokens); markEndOfStatement(tokens, node); return node; } }
public class class_name { public String getSample(int line, int column, Janitor janitor) { String sample = null; String text = source.getLine(line, janitor); if (text != null) { if (column > 0) { String marker = Utilities.repeatString(" ", column - 1) + "^"; if (column > 40) { int start = column - 30 - 1; int end = (column + 10 > text.length() ? text.length() : column + 10 - 1); sample = " " + text.substring(start, end) + Utilities.eol() + " " + marker.substring(start, marker.length()); } else { sample = " " + text + Utilities.eol() + " " + marker; } } else { sample = text; } } return sample; } }
public class class_name { public String getSample(int line, int column, Janitor janitor) { String sample = null; String text = source.getLine(line, janitor); if (text != null) { if (column > 0) { String marker = Utilities.repeatString(" ", column - 1) + "^"; if (column > 40) { int start = column - 30 - 1; int end = (column + 10 > text.length() ? text.length() : column + 10 - 1); sample = " " + text.substring(start, end) + Utilities.eol() + " " + marker.substring(start, marker.length()); // depends on control dependency: [if], data = [none] } else { sample = " " + text + Utilities.eol() + " " + marker; // depends on control dependency: [if], data = [none] } } else { sample = text; // depends on control dependency: [if], data = [none] } } return sample; } }
public class class_name { public HeaderValues fiCurrent(long cookie) { try { final Object[] table = this.table; int ri = (int) (cookie >> 32); int ci = (int) cookie; final Object item = table[ri]; if (item instanceof HeaderValues[]) { return ((HeaderValues[])item)[ci]; } else if (ci == 0) { return (HeaderValues) item; } else { throw new NoSuchElementException(); } } catch (RuntimeException e) { throw new NoSuchElementException(); } } }
public class class_name { public HeaderValues fiCurrent(long cookie) { try { final Object[] table = this.table; int ri = (int) (cookie >> 32); int ci = (int) cookie; final Object item = table[ri]; if (item instanceof HeaderValues[]) { return ((HeaderValues[])item)[ci]; // depends on control dependency: [if], data = [none] } else if (ci == 0) { return (HeaderValues) item; // depends on control dependency: [if], data = [none] } else { throw new NoSuchElementException(); } } catch (RuntimeException e) { throw new NoSuchElementException(); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public EClass getIfcCharacterStyleSelect() { if (ifcCharacterStyleSelectEClass == null) { ifcCharacterStyleSelectEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc2x3tc1Package.eNS_URI) .getEClassifiers().get(940); } return ifcCharacterStyleSelectEClass; } }
public class class_name { public EClass getIfcCharacterStyleSelect() { if (ifcCharacterStyleSelectEClass == null) { ifcCharacterStyleSelectEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc2x3tc1Package.eNS_URI) .getEClassifiers().get(940); // depends on control dependency: [if], data = [none] } return ifcCharacterStyleSelectEClass; } }
public class class_name { public CMASpaceMembership addRole(CMALink role) { if (role == null) { throw new IllegalArgumentException("Role cannot be null!"); } if (roles == null) { roles = new ArrayList<CMALink>(); } this.roles.add(role); return this; } }
public class class_name { public CMASpaceMembership addRole(CMALink role) { if (role == null) { throw new IllegalArgumentException("Role cannot be null!"); } if (roles == null) { roles = new ArrayList<CMALink>(); // depends on control dependency: [if], data = [none] } this.roles.add(role); return this; } }
public class class_name { public static byte[] encrypt(PublicKey key, byte[] plainBytes) { ByteArrayOutputStream out = null; try { Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); cipher.init(Cipher.ENCRYPT_MODE, key); int inputLen = plainBytes.length; if(inputLen <= MAX_ENCRYPT_BLOCK){ return cipher.doFinal(plainBytes); } out = new ByteArrayOutputStream(); int offSet = 0; byte[] cache; int i = 0; // 对数据分段加密 while (inputLen - offSet > 0) { if (inputLen - offSet > MAX_ENCRYPT_BLOCK) { cache = cipher.doFinal(plainBytes, offSet, MAX_ENCRYPT_BLOCK); } else { cache = cipher.doFinal(plainBytes, offSet, inputLen - offSet); } out.write(cache, 0, cache.length); i++; offSet = i * MAX_ENCRYPT_BLOCK; } return out.toByteArray(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("无此解密算法"); } catch (NoSuchPaddingException e) { e.printStackTrace(); return null; } catch (InvalidKeyException e) { throw new RuntimeException("解密私钥非法,请检查"); } catch (IllegalBlockSizeException e) { throw new RuntimeException("密文长度非法"); } catch (BadPaddingException e) { throw new RuntimeException("密文数据已损坏"); }finally{ try {if(out != null)out.close(); } catch (Exception e2) {} } } }
public class class_name { public static byte[] encrypt(PublicKey key, byte[] plainBytes) { ByteArrayOutputStream out = null; try { Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); cipher.init(Cipher.ENCRYPT_MODE, key); // depends on control dependency: [try], data = [none] int inputLen = plainBytes.length; if(inputLen <= MAX_ENCRYPT_BLOCK){ return cipher.doFinal(plainBytes); // depends on control dependency: [if], data = [none] } out = new ByteArrayOutputStream(); // depends on control dependency: [try], data = [none] int offSet = 0; byte[] cache; int i = 0; // 对数据分段加密 while (inputLen - offSet > 0) { if (inputLen - offSet > MAX_ENCRYPT_BLOCK) { cache = cipher.doFinal(plainBytes, offSet, MAX_ENCRYPT_BLOCK); // depends on control dependency: [if], data = [MAX_ENCRYPT_BLOCK)] } else { cache = cipher.doFinal(plainBytes, offSet, inputLen - offSet); // depends on control dependency: [if], data = [none] } out.write(cache, 0, cache.length); // depends on control dependency: [while], data = [none] i++; // depends on control dependency: [while], data = [none] offSet = i * MAX_ENCRYPT_BLOCK; // depends on control dependency: [while], data = [none] } return out.toByteArray(); // depends on control dependency: [try], data = [none] } catch (NoSuchAlgorithmException e) { throw new RuntimeException("无此解密算法"); } catch (NoSuchPaddingException e) { // depends on control dependency: [catch], data = [none] e.printStackTrace(); return null; } catch (InvalidKeyException e) { // depends on control dependency: [catch], data = [none] throw new RuntimeException("解密私钥非法,请检查"); } catch (IllegalBlockSizeException e) { // depends on control dependency: [catch], data = [none] throw new RuntimeException("密文长度非法"); } catch (BadPaddingException e) { // depends on control dependency: [catch], data = [none] throw new RuntimeException("密文数据已损坏"); }finally{ // depends on control dependency: [catch], data = [none] try {if(out != null)out.close(); } catch (Exception e2) {} // depends on control dependency: [catch], data = [none] } } }
public class class_name { public static Class<?> getPropertyType(Class<?> clazz, String propertyName) { if (clazz == null || !StringUtils.hasText(propertyName)) { return null; } try { PropertyDescriptor desc=BeanUtils.getPropertyDescriptor(clazz, propertyName); if (desc != null) { return desc.getPropertyType(); } return null; } catch (Exception e) { // if there are any errors in instantiating just return null for the moment return null; } } }
public class class_name { public static Class<?> getPropertyType(Class<?> clazz, String propertyName) { if (clazz == null || !StringUtils.hasText(propertyName)) { return null; } try { PropertyDescriptor desc=BeanUtils.getPropertyDescriptor(clazz, propertyName); if (desc != null) { return desc.getPropertyType(); // depends on control dependency: [if], data = [none] } return null; } catch (Exception e) { // if there are any errors in instantiating just return null for the moment return null; } } }
public class class_name { public final ProtoParser.header_syntax_return header_syntax(Proto proto) throws RecognitionException { ProtoParser.header_syntax_return retval = new ProtoParser.header_syntax_return(); retval.start = input.LT(1); Object root_0 = null; Token SYNTAX32=null; Token ASSIGN33=null; Token STRING_LITERAL34=null; Token SEMICOLON35=null; Object SYNTAX32_tree=null; Object ASSIGN33_tree=null; Object STRING_LITERAL34_tree=null; Object SEMICOLON35_tree=null; try { // com/dyuproject/protostuff/parser/ProtoParser.g:117:5: ( SYNTAX ASSIGN STRING_LITERAL SEMICOLON ) // com/dyuproject/protostuff/parser/ProtoParser.g:117:9: SYNTAX ASSIGN STRING_LITERAL SEMICOLON { root_0 = (Object)adaptor.nil(); SYNTAX32=(Token)match(input,SYNTAX,FOLLOW_SYNTAX_in_header_syntax854); if (state.failed) return retval; if ( state.backtracking==0 ) { SYNTAX32_tree = (Object)adaptor.create(SYNTAX32); adaptor.addChild(root_0, SYNTAX32_tree); } ASSIGN33=(Token)match(input,ASSIGN,FOLLOW_ASSIGN_in_header_syntax856); if (state.failed) return retval; if ( state.backtracking==0 ) { ASSIGN33_tree = (Object)adaptor.create(ASSIGN33); adaptor.addChild(root_0, ASSIGN33_tree); } STRING_LITERAL34=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_header_syntax858); if (state.failed) return retval; if ( state.backtracking==0 ) { STRING_LITERAL34_tree = (Object)adaptor.create(STRING_LITERAL34); adaptor.addChild(root_0, STRING_LITERAL34_tree); } SEMICOLON35=(Token)match(input,SEMICOLON,FOLLOW_SEMICOLON_in_header_syntax860); if (state.failed) return retval; if ( state.backtracking==0 ) { if(!"proto2".equals(getStringFromStringLiteral((STRING_LITERAL34!=null?STRING_LITERAL34.getText():null)))) { throw new IllegalStateException("Syntax isn't proto2: '" + getStringFromStringLiteral((STRING_LITERAL34!=null?STRING_LITERAL34.getText():null))+"'"); } if(!proto.annotations.isEmpty()) throw new IllegalStateException("Misplaced annotations: " + proto.annotations); } } retval.stop = input.LT(-1); if ( state.backtracking==0 ) { retval.tree = (Object)adaptor.rulePostProcessing(root_0); adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); } } catch (RecognitionException re) { reportError(re); recover(input,re); retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re); } finally { } return retval; } }
public class class_name { public final ProtoParser.header_syntax_return header_syntax(Proto proto) throws RecognitionException { ProtoParser.header_syntax_return retval = new ProtoParser.header_syntax_return(); retval.start = input.LT(1); Object root_0 = null; Token SYNTAX32=null; Token ASSIGN33=null; Token STRING_LITERAL34=null; Token SEMICOLON35=null; Object SYNTAX32_tree=null; Object ASSIGN33_tree=null; Object STRING_LITERAL34_tree=null; Object SEMICOLON35_tree=null; try { // com/dyuproject/protostuff/parser/ProtoParser.g:117:5: ( SYNTAX ASSIGN STRING_LITERAL SEMICOLON ) // com/dyuproject/protostuff/parser/ProtoParser.g:117:9: SYNTAX ASSIGN STRING_LITERAL SEMICOLON { root_0 = (Object)adaptor.nil(); SYNTAX32=(Token)match(input,SYNTAX,FOLLOW_SYNTAX_in_header_syntax854); if (state.failed) return retval; if ( state.backtracking==0 ) { SYNTAX32_tree = (Object)adaptor.create(SYNTAX32); // depends on control dependency: [if], data = [none] adaptor.addChild(root_0, SYNTAX32_tree); // depends on control dependency: [if], data = [none] } ASSIGN33=(Token)match(input,ASSIGN,FOLLOW_ASSIGN_in_header_syntax856); if (state.failed) return retval; if ( state.backtracking==0 ) { ASSIGN33_tree = (Object)adaptor.create(ASSIGN33); // depends on control dependency: [if], data = [none] adaptor.addChild(root_0, ASSIGN33_tree); // depends on control dependency: [if], data = [none] } STRING_LITERAL34=(Token)match(input,STRING_LITERAL,FOLLOW_STRING_LITERAL_in_header_syntax858); if (state.failed) return retval; if ( state.backtracking==0 ) { STRING_LITERAL34_tree = (Object)adaptor.create(STRING_LITERAL34); // depends on control dependency: [if], data = [none] adaptor.addChild(root_0, STRING_LITERAL34_tree); // depends on control dependency: [if], data = [none] } SEMICOLON35=(Token)match(input,SEMICOLON,FOLLOW_SEMICOLON_in_header_syntax860); if (state.failed) return retval; if ( state.backtracking==0 ) { if(!"proto2".equals(getStringFromStringLiteral((STRING_LITERAL34!=null?STRING_LITERAL34.getText():null)))) { throw new IllegalStateException("Syntax isn't proto2: '" + getStringFromStringLiteral((STRING_LITERAL34!=null?STRING_LITERAL34.getText():null))+"'"); } if(!proto.annotations.isEmpty()) throw new IllegalStateException("Misplaced annotations: " + proto.annotations); } } retval.stop = input.LT(-1); if ( state.backtracking==0 ) { retval.tree = (Object)adaptor.rulePostProcessing(root_0); // depends on control dependency: [if], data = [none] adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop); // depends on control dependency: [if], data = [none] } } catch (RecognitionException re) { reportError(re); recover(input,re); retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re); } finally { } return retval; } }
public class class_name { public void switchToParentWindow() { String action = "Switching back to parent window"; String expected = "Parent window is available and selected"; try { driver.switchTo().window(parentWindow); } catch (Exception e) { reporter.fail(action, expected, "Parent window was unable to be selected. " + e.getMessage()); log.warn(e); return; } reporter.pass(action, expected, expected); } }
public class class_name { public void switchToParentWindow() { String action = "Switching back to parent window"; String expected = "Parent window is available and selected"; try { driver.switchTo().window(parentWindow); // depends on control dependency: [try], data = [none] } catch (Exception e) { reporter.fail(action, expected, "Parent window was unable to be selected. " + e.getMessage()); log.warn(e); return; } // depends on control dependency: [catch], data = [none] reporter.pass(action, expected, expected); } }
public class class_name { protected int handleComputeMonthStart(int eyear, int month, boolean useMonth) { // Resolve out-of-range months. This is necessary in order to // obtain the correct year. We correct to // a 12- or 13-month year (add/subtract 12 or 13, depending // on the year) but since we _always_ number from 0..12, and // the leap year determines whether or not month 5 (Adar 1) // is present, we allow 0..12 in any given year. while (month < 0) { month += monthsInYear(--eyear); } // Careful: allow 0..12 in all years while (month > 12) { month -= monthsInYear(eyear++); } long day = startOfYear(eyear); if (month != 0) { if (isLeapYear(eyear)) { day += LEAP_MONTH_START[month][yearType(eyear)]; } else { day += MONTH_START[month][yearType(eyear)]; } } return (int) (day + 347997); } }
public class class_name { protected int handleComputeMonthStart(int eyear, int month, boolean useMonth) { // Resolve out-of-range months. This is necessary in order to // obtain the correct year. We correct to // a 12- or 13-month year (add/subtract 12 or 13, depending // on the year) but since we _always_ number from 0..12, and // the leap year determines whether or not month 5 (Adar 1) // is present, we allow 0..12 in any given year. while (month < 0) { month += monthsInYear(--eyear); // depends on control dependency: [while], data = [none] } // Careful: allow 0..12 in all years while (month > 12) { month -= monthsInYear(eyear++); // depends on control dependency: [while], data = [none] } long day = startOfYear(eyear); if (month != 0) { if (isLeapYear(eyear)) { day += LEAP_MONTH_START[month][yearType(eyear)]; // depends on control dependency: [if], data = [none] } else { day += MONTH_START[month][yearType(eyear)]; // depends on control dependency: [if], data = [none] } } return (int) (day + 347997); } }
public class class_name { private Object populateEmbeddedObject(SuperColumn sc, EntityMetadata m) throws Exception { Field embeddedCollectionField = null; Object embeddedObject = null; String scName = PropertyAccessorFactory.STRING.fromBytes(String.class, sc.getName()); String scNamePrefix = null; // Get a name->field map for super-columns Map<String, Field> columnNameToFieldMap = new HashMap<String, Field>(); Map<String, Field> superColumnNameToFieldMap = new HashMap<String, Field>(); MetadataUtils.populateColumnAndSuperColumnMaps(m, columnNameToFieldMap, superColumnNameToFieldMap, kunderaMetadata); // If this super column is variable in number (name#sequence format) if (scName.indexOf(Constants.EMBEDDED_COLUMN_NAME_DELIMITER) != -1) { StringTokenizer st = new StringTokenizer(scName, Constants.EMBEDDED_COLUMN_NAME_DELIMITER); if (st.hasMoreTokens()) { scNamePrefix = st.nextToken(); } embeddedCollectionField = superColumnNameToFieldMap.get(scNamePrefix); Class<?> embeddedClass = PropertyAccessorHelper.getGenericClass(embeddedCollectionField); // must have a default no-argument constructor try { embeddedClass.getConstructor(); } catch (NoSuchMethodException nsme) { throw new PersistenceException(embeddedClass.getName() + " is @Embeddable and must have a default no-argument constructor."); } embeddedObject = embeddedClass.newInstance(); for (Column column : sc.getColumns()) { String name = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); byte[] value = column.getValue(); if (value == null) { continue; } Field columnField = columnNameToFieldMap.get(name); PropertyAccessorHelper.set(embeddedObject, columnField, value); } } else { Field superColumnField = superColumnNameToFieldMap.get(scName); Class superColumnClass = superColumnField.getType(); embeddedObject = superColumnClass.newInstance(); for (Column column : sc.getColumns()) { String name = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); byte[] value = column.getValue(); if (value == null) { continue; } // set value of the field in the bean Field columnField = columnNameToFieldMap.get(name); PropertyAccessorHelper.set(embeddedObject, columnField, value); } } return embeddedObject; } }
public class class_name { private Object populateEmbeddedObject(SuperColumn sc, EntityMetadata m) throws Exception { Field embeddedCollectionField = null; Object embeddedObject = null; String scName = PropertyAccessorFactory.STRING.fromBytes(String.class, sc.getName()); String scNamePrefix = null; // Get a name->field map for super-columns Map<String, Field> columnNameToFieldMap = new HashMap<String, Field>(); Map<String, Field> superColumnNameToFieldMap = new HashMap<String, Field>(); MetadataUtils.populateColumnAndSuperColumnMaps(m, columnNameToFieldMap, superColumnNameToFieldMap, kunderaMetadata); // If this super column is variable in number (name#sequence format) if (scName.indexOf(Constants.EMBEDDED_COLUMN_NAME_DELIMITER) != -1) { StringTokenizer st = new StringTokenizer(scName, Constants.EMBEDDED_COLUMN_NAME_DELIMITER); if (st.hasMoreTokens()) { scNamePrefix = st.nextToken(); // depends on control dependency: [if], data = [none] } embeddedCollectionField = superColumnNameToFieldMap.get(scNamePrefix); Class<?> embeddedClass = PropertyAccessorHelper.getGenericClass(embeddedCollectionField); // must have a default no-argument constructor try { embeddedClass.getConstructor(); // depends on control dependency: [try], data = [none] } catch (NoSuchMethodException nsme) { throw new PersistenceException(embeddedClass.getName() + " is @Embeddable and must have a default no-argument constructor."); } // depends on control dependency: [catch], data = [none] embeddedObject = embeddedClass.newInstance(); for (Column column : sc.getColumns()) { String name = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); byte[] value = column.getValue(); if (value == null) { continue; } Field columnField = columnNameToFieldMap.get(name); PropertyAccessorHelper.set(embeddedObject, columnField, value); // depends on control dependency: [for], data = [column] } } else { Field superColumnField = superColumnNameToFieldMap.get(scName); Class superColumnClass = superColumnField.getType(); embeddedObject = superColumnClass.newInstance(); for (Column column : sc.getColumns()) { String name = PropertyAccessorFactory.STRING.fromBytes(String.class, column.getName()); byte[] value = column.getValue(); if (value == null) { continue; } // set value of the field in the bean Field columnField = columnNameToFieldMap.get(name); PropertyAccessorHelper.set(embeddedObject, columnField, value); // depends on control dependency: [for], data = [column] } } return embeddedObject; } }
public class class_name { public static <T> T[] concatAll(final T[] empty, Iterable<T[]> arrayList) { assert(empty.length == 0); if (arrayList.iterator().hasNext() == false) { return empty; } int len = 0; for (T[] subArray : arrayList) { len += subArray.length; } int pos = 0; T[] result = Arrays.copyOf(empty, len); for (T[] subArray : arrayList) { System.arraycopy(subArray, 0, result, pos, subArray.length); pos += subArray.length; } return result; } }
public class class_name { public static <T> T[] concatAll(final T[] empty, Iterable<T[]> arrayList) { assert(empty.length == 0); if (arrayList.iterator().hasNext() == false) { return empty; // depends on control dependency: [if], data = [none] } int len = 0; for (T[] subArray : arrayList) { len += subArray.length; // depends on control dependency: [for], data = [subArray] } int pos = 0; T[] result = Arrays.copyOf(empty, len); for (T[] subArray : arrayList) { System.arraycopy(subArray, 0, result, pos, subArray.length); // depends on control dependency: [for], data = [subArray] pos += subArray.length; // depends on control dependency: [for], data = [subArray] } return result; } }
public class class_name { public EList<GCRLINERG> getRg() { if (rg == null) { rg = new EObjectContainmentEList.Resolving<GCRLINERG>(GCRLINERG.class, this, AfplibPackage.GCRLINE__RG); } return rg; } }
public class class_name { public EList<GCRLINERG> getRg() { if (rg == null) { rg = new EObjectContainmentEList.Resolving<GCRLINERG>(GCRLINERG.class, this, AfplibPackage.GCRLINE__RG); // depends on control dependency: [if], data = [none] } return rg; } }
public class class_name { @FFDCIgnore(InjectionException.class) private void processPostConstruct() { ApplicationClient appClient = ((ClientModuleMetaData) cmd.getModuleMetaData()).getAppClient(); boolean isMetadataComplete = appClient.isMetadataComplete(); LifecycleCallbackHelper helper = new LifecycleCallbackHelper(isMetadataComplete); List<LifecycleCallback> postConstruct = appClient.getPostConstruct(); CallbackHandler loginCallbackHandler = cmi.getCallbackHandler(); try { if (loginCallbackHandler != null) { helper.doPostConstruct(loginCallbackHandler, postConstruct); } helper.doPostConstruct(mainClass, postConstruct); } catch (InjectionException e) { Tr.error(tc, "INJECTION_POSTCONSTRUCT_CWWKC2452E", new Object[] { e.getLocalizedMessage() }); } } }
public class class_name { @FFDCIgnore(InjectionException.class) private void processPostConstruct() { ApplicationClient appClient = ((ClientModuleMetaData) cmd.getModuleMetaData()).getAppClient(); boolean isMetadataComplete = appClient.isMetadataComplete(); LifecycleCallbackHelper helper = new LifecycleCallbackHelper(isMetadataComplete); List<LifecycleCallback> postConstruct = appClient.getPostConstruct(); CallbackHandler loginCallbackHandler = cmi.getCallbackHandler(); try { if (loginCallbackHandler != null) { helper.doPostConstruct(loginCallbackHandler, postConstruct); // depends on control dependency: [if], data = [(loginCallbackHandler] } helper.doPostConstruct(mainClass, postConstruct); // depends on control dependency: [try], data = [none] } catch (InjectionException e) { Tr.error(tc, "INJECTION_POSTCONSTRUCT_CWWKC2452E", new Object[] { e.getLocalizedMessage() }); } // depends on control dependency: [catch], data = [none] } }
public class class_name { private JClassType getHandlerForEvent(JClassType eventType) { // All handlers event must have an overrided method getAssociatedType(). // We take advantage of this information to get the associated handler. // Ex: // com.google.gwt.event.dom.client.ClickEvent // ---> com.google.gwt.event.dom.client.ClickHandler // // com.google.gwt.event.dom.client.BlurEvent // ---> com.google.gwt.event.dom.client.BlurHandler if (eventType == null) { return null; } JMethod method = eventType .findMethod("getAssociatedType", new JType[0]); if (method == null) { logger.warn( "Method 'getAssociatedType()' could not be found in the event '%s'.", eventType.getName()); return null; } JType returnType = method.getReturnType(); if (returnType == null) { logger.warn( "The method 'getAssociatedType()' in the event '%s' returns void.", eventType.getName()); return null; } JParameterizedType isParameterized = returnType.isParameterized(); if (isParameterized == null) { logger.warn( "The method 'getAssociatedType()' in '%s' does not return Type<? extends EventHandler>.", eventType.getName()); return null; } JClassType[] argTypes = isParameterized.getTypeArgs(); if ((argTypes.length != 1) && !argTypes[0].isAssignableTo(eventHandlerJClass)) { logger.warn( "The method 'getAssociatedType()' in '%s' does not return Type<? extends EventHandler>.", eventType.getName()); return null; } return argTypes[0]; } }
public class class_name { private JClassType getHandlerForEvent(JClassType eventType) { // All handlers event must have an overrided method getAssociatedType(). // We take advantage of this information to get the associated handler. // Ex: // com.google.gwt.event.dom.client.ClickEvent // ---> com.google.gwt.event.dom.client.ClickHandler // // com.google.gwt.event.dom.client.BlurEvent // ---> com.google.gwt.event.dom.client.BlurHandler if (eventType == null) { return null; // depends on control dependency: [if], data = [none] } JMethod method = eventType .findMethod("getAssociatedType", new JType[0]); if (method == null) { logger.warn( "Method 'getAssociatedType()' could not be found in the event '%s'.", eventType.getName()); // depends on control dependency: [if], data = [none] return null; // depends on control dependency: [if], data = [none] } JType returnType = method.getReturnType(); if (returnType == null) { logger.warn( "The method 'getAssociatedType()' in the event '%s' returns void.", eventType.getName()); // depends on control dependency: [if], data = [none] return null; // depends on control dependency: [if], data = [none] } JParameterizedType isParameterized = returnType.isParameterized(); if (isParameterized == null) { logger.warn( "The method 'getAssociatedType()' in '%s' does not return Type<? extends EventHandler>.", eventType.getName()); return null; } JClassType[] argTypes = isParameterized.getTypeArgs(); if ((argTypes.length != 1) && !argTypes[0].isAssignableTo(eventHandlerJClass)) { logger.warn( "The method 'getAssociatedType()' in '%s' does not return Type<? extends EventHandler>.", eventType.getName()); // depends on control dependency: [if], data = [none] return null; // depends on control dependency: [if], data = [none] } return argTypes[0]; } }
public class class_name { private Object[] getArgumentsValues() { Argument[] args = getArguments(); Object[] result = new Object[args.length]; for (int i = 0; i < args.length; ++i) { result[i] = args[i].getValue(); } return result; } }
public class class_name { private Object[] getArgumentsValues() { Argument[] args = getArguments(); Object[] result = new Object[args.length]; for (int i = 0; i < args.length; ++i) { result[i] = args[i].getValue(); // depends on control dependency: [for], data = [i] } return result; } }
public class class_name { public void startSettingActivity(Context context, Bundle extras) { if (!startDelegateActivity(context, delegate.getSettingsIntent(), extras)) { startActivity(context, extras, MyProfileActivity.class); } } }
public class class_name { public void startSettingActivity(Context context, Bundle extras) { if (!startDelegateActivity(context, delegate.getSettingsIntent(), extras)) { startActivity(context, extras, MyProfileActivity.class); // depends on control dependency: [if], data = [none] } } }
public class class_name { protected void renameItem(final ItemState state, final ItemState lastDelete) { ItemData data = state.getData(); ItemData prevData = getFromBufferedCacheById.run(data.getIdentifier()); if (data.isNode()) { if (state.isPersisted()) { // it is state where name can be changed by rename operation, so re-add node removeItem(lastDelete.getData()); putItem(state.getData()); } else { // update item data with new name only cache.put(new CacheId(getOwnerId(), data.getIdentifier()), data, false); } } else { PropertyData prop = (PropertyData)data; if (prevData != null && !(prevData instanceof NullItemData)) { PropertyData newProp = new PersistedPropertyData(prop.getIdentifier(), prop.getQPath(), prop.getParentIdentifier(), prop.getPersistedVersion(), prop.getType(), prop.isMultiValued(), ((PropertyData)prevData).getValues(), new SimplePersistedSize( ((PersistedPropertyData)prevData).getPersistedSize())); // update item data with new name and old values only cache.put(new CacheId(getOwnerId(), newProp.getIdentifier()), newProp, false); } else { // remove item to avoid inconsistency in cluster mode since we have not old values cache.remove(new CacheId(getOwnerId(), data.getIdentifier())); } } } }
public class class_name { protected void renameItem(final ItemState state, final ItemState lastDelete) { ItemData data = state.getData(); ItemData prevData = getFromBufferedCacheById.run(data.getIdentifier()); if (data.isNode()) { if (state.isPersisted()) { // it is state where name can be changed by rename operation, so re-add node removeItem(lastDelete.getData()); // depends on control dependency: [if], data = [none] putItem(state.getData()); // depends on control dependency: [if], data = [none] } else { // update item data with new name only cache.put(new CacheId(getOwnerId(), data.getIdentifier()), data, false); // depends on control dependency: [if], data = [none] } } else { PropertyData prop = (PropertyData)data; if (prevData != null && !(prevData instanceof NullItemData)) { PropertyData newProp = new PersistedPropertyData(prop.getIdentifier(), prop.getQPath(), prop.getParentIdentifier(), prop.getPersistedVersion(), prop.getType(), prop.isMultiValued(), ((PropertyData)prevData).getValues(), new SimplePersistedSize( ((PersistedPropertyData)prevData).getPersistedSize())); // update item data with new name and old values only cache.put(new CacheId(getOwnerId(), newProp.getIdentifier()), newProp, false); // depends on control dependency: [if], data = [none] } else { // remove item to avoid inconsistency in cluster mode since we have not old values cache.remove(new CacheId(getOwnerId(), data.getIdentifier())); // depends on control dependency: [if], data = [none] } } } }
public class class_name { private <T> Converter<T> lookupConverter(Type targetType) { // Try with complete type Converter<T> converter = getConverter(targetType); // Try with simple class if (converter == null && targetType instanceof ParameterizedType) { Class<?> targetClass = ReflectionUtils.getTypeClass(targetType); converter = getConverter(targetClass); } if (converter == null) { if (targetType instanceof Class && Enum.class.isAssignableFrom((Class<?>) targetType)) { // It's an Enum converter = (Converter<T>) this.enumConverter; } else { // Fallback on default converter this.logger.debug("Using the default Converter for type [{}]", targetType); converter = this.defaultConverter; } } return converter; } }
public class class_name { private <T> Converter<T> lookupConverter(Type targetType) { // Try with complete type Converter<T> converter = getConverter(targetType); // Try with simple class if (converter == null && targetType instanceof ParameterizedType) { Class<?> targetClass = ReflectionUtils.getTypeClass(targetType); converter = getConverter(targetClass); } if (converter == null) { if (targetType instanceof Class && Enum.class.isAssignableFrom((Class<?>) targetType)) { // It's an Enum converter = (Converter<T>) this.enumConverter; // depends on control dependency: [if], data = [none] } else { // Fallback on default converter this.logger.debug("Using the default Converter for type [{}]", targetType); converter = this.defaultConverter; // depends on control dependency: [if], data = [none] } } return converter; } }
public class class_name { public void set(String name, Object value) { if (value != null) { attributes.put(name, String.valueOf(value)); } else { attributes.remove(name); } } }
public class class_name { public void set(String name, Object value) { if (value != null) { attributes.put(name, String.valueOf(value)); // depends on control dependency: [if], data = [(value] } else { attributes.remove(name); // depends on control dependency: [if], data = [none] } } }
public class class_name { private XmlNode pullXmlNode() { // read from queue if(! nodeQueue.isEmpty()) { return nodeQueue.poll(); } // read from stream try { while(reader.hasNext()) { int event = reader.next(); switch(event) { case XMLStreamConstants.START_ELEMENT: return new XmlStartElement(reader.getLocalName(), getAttributes(reader)); case XMLStreamConstants.CHARACTERS: // capture XML? String text = filterWhitespace(reader.getText()); if(text.length() > 0) { return new XmlContent(text); } break; case XMLStreamConstants.END_ELEMENT: return new XmlEndElement(reader.getLocalName()); default: // do nothing } } } catch (XMLStreamException e) { throw new XmlReaderException(e); } // nothing to return return null; } }
public class class_name { private XmlNode pullXmlNode() { // read from queue if(! nodeQueue.isEmpty()) { return nodeQueue.poll(); // depends on control dependency: [if], data = [none] } // read from stream try { while(reader.hasNext()) { int event = reader.next(); switch(event) { case XMLStreamConstants.START_ELEMENT: return new XmlStartElement(reader.getLocalName(), getAttributes(reader)); case XMLStreamConstants.CHARACTERS: // capture XML? String text = filterWhitespace(reader.getText()); if(text.length() > 0) { return new XmlContent(text); // depends on control dependency: [if], data = [none] } break; case XMLStreamConstants.END_ELEMENT: return new XmlEndElement(reader.getLocalName()); default: // do nothing } } } catch (XMLStreamException e) { throw new XmlReaderException(e); } // depends on control dependency: [catch], data = [none] // nothing to return return null; } }
public class class_name { private boolean isEncodeable(final String location) { if (location == null) return (false); // Is this an intra-document reference? if (location.startsWith("#")) return (false); // Are we in a valid session that is not using cookies? final HttpServletRequestImpl hreq = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getOriginalRequest(); // Is URL encoding permitted if (!originalServletContext.getEffectiveSessionTrackingModes().contains(SessionTrackingMode.URL)) { return false; } final HttpSession session = hreq.getSession(false); if (session == null) { return false; } else if(hreq.isRequestedSessionIdFromCookie()) { return false; } else if (!hreq.isRequestedSessionIdFromURL() && !session.isNew()) { return false; } return doIsEncodeable(hreq, session, location); } }
public class class_name { private boolean isEncodeable(final String location) { if (location == null) return (false); // Is this an intra-document reference? if (location.startsWith("#")) return (false); // Are we in a valid session that is not using cookies? final HttpServletRequestImpl hreq = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getOriginalRequest(); // Is URL encoding permitted if (!originalServletContext.getEffectiveSessionTrackingModes().contains(SessionTrackingMode.URL)) { return false; // depends on control dependency: [if], data = [none] } final HttpSession session = hreq.getSession(false); if (session == null) { return false; // depends on control dependency: [if], data = [none] } else if(hreq.isRequestedSessionIdFromCookie()) { return false; // depends on control dependency: [if], data = [none] } else if (!hreq.isRequestedSessionIdFromURL() && !session.isNew()) { return false; // depends on control dependency: [if], data = [none] } return doIsEncodeable(hreq, session, location); } }
public class class_name { @XmlTransient public Field getField(String fieldNameParam) { if (fieldNameParam == null || fieldNameParam.trim().isEmpty()) { return null; } if (this.userFields == null || this.userFields.isEmpty()) { return null; } String fieldNameParamLower = fieldNameParam.trim().toLowerCase(); for (Field field : this.userFields) { String fieldName = field.getFieldName(); if (fieldName == null || fieldName.trim().isEmpty()) { continue; } String fieldNameLower = fieldName.trim().toLowerCase(); if (fieldNameParamLower.equals(fieldNameLower)) { return field; } } return null; } }
public class class_name { @XmlTransient public Field getField(String fieldNameParam) { if (fieldNameParam == null || fieldNameParam.trim().isEmpty()) { return null; // depends on control dependency: [if], data = [none] } if (this.userFields == null || this.userFields.isEmpty()) { return null; // depends on control dependency: [if], data = [none] } String fieldNameParamLower = fieldNameParam.trim().toLowerCase(); for (Field field : this.userFields) { String fieldName = field.getFieldName(); if (fieldName == null || fieldName.trim().isEmpty()) { continue; } String fieldNameLower = fieldName.trim().toLowerCase(); if (fieldNameParamLower.equals(fieldNameLower)) { return field; // depends on control dependency: [if], data = [none] } } return null; } }
public class class_name { public static void getCookies(URLConnection conn, Map store) { // let's determine the domain from where these cookies are being sent String domain = getCookieDomainFromHost(conn.getURL().getHost()); Map domainStore; // this is where we will store cookies for this domain // now let's check the store to see if we have an entry for this domain if (store.containsKey(domain)) { // we do, so lets retrieve it from the store domainStore = (Map) store.get(domain); } else { // we don't, so let's create it and put it in the store domainStore = new ConcurrentHashMap(); store.put(domain, domainStore); } if (domainStore.containsKey("JSESSIONID")) { // No need to continually get the JSESSIONID (and set-cookies header) as this does not change throughout the session. return; } // OK, now we are ready to get the cookies out of the URLConnection String headerName; for (int i = 1; (headerName = conn.getHeaderFieldKey(i)) != null; i++) { if (headerName.equalsIgnoreCase(SET_COOKIE)) { Map cookie = new ConcurrentHashMap(); StringTokenizer st = new StringTokenizer(conn.getHeaderField(i), COOKIE_VALUE_DELIMITER); // the specification dictates that the first name/value pair // in the string is the cookie name and value, so let's handle // them as a special case: if (st.hasMoreTokens()) { String token = st.nextToken(); String key = token.substring(0, token.indexOf(NAME_VALUE_SEPARATOR)).trim(); String value = token.substring(token.indexOf(NAME_VALUE_SEPARATOR) + 1); domainStore.put(key, cookie); cookie.put(key, value); } while (st.hasMoreTokens()) { String token = st.nextToken(); int pos = token.indexOf(NAME_VALUE_SEPARATOR); if (pos != -1) { String key = token.substring(0, pos).toLowerCase().trim(); String value = token.substring(token.indexOf(NAME_VALUE_SEPARATOR) + 1); cookie.put(key, value); } } } } } }
public class class_name { public static void getCookies(URLConnection conn, Map store) { // let's determine the domain from where these cookies are being sent String domain = getCookieDomainFromHost(conn.getURL().getHost()); Map domainStore; // this is where we will store cookies for this domain // now let's check the store to see if we have an entry for this domain if (store.containsKey(domain)) { // we do, so lets retrieve it from the store domainStore = (Map) store.get(domain); // depends on control dependency: [if], data = [none] } else { // we don't, so let's create it and put it in the store domainStore = new ConcurrentHashMap(); // depends on control dependency: [if], data = [none] store.put(domain, domainStore); // depends on control dependency: [if], data = [none] } if (domainStore.containsKey("JSESSIONID")) { // No need to continually get the JSESSIONID (and set-cookies header) as this does not change throughout the session. return; // depends on control dependency: [if], data = [none] } // OK, now we are ready to get the cookies out of the URLConnection String headerName; for (int i = 1; (headerName = conn.getHeaderFieldKey(i)) != null; i++) { if (headerName.equalsIgnoreCase(SET_COOKIE)) { Map cookie = new ConcurrentHashMap(); StringTokenizer st = new StringTokenizer(conn.getHeaderField(i), COOKIE_VALUE_DELIMITER); // the specification dictates that the first name/value pair // in the string is the cookie name and value, so let's handle // them as a special case: if (st.hasMoreTokens()) { String token = st.nextToken(); String key = token.substring(0, token.indexOf(NAME_VALUE_SEPARATOR)).trim(); String value = token.substring(token.indexOf(NAME_VALUE_SEPARATOR) + 1); domainStore.put(key, cookie); // depends on control dependency: [if], data = [none] cookie.put(key, value); // depends on control dependency: [if], data = [none] } while (st.hasMoreTokens()) { String token = st.nextToken(); int pos = token.indexOf(NAME_VALUE_SEPARATOR); if (pos != -1) { String key = token.substring(0, pos).toLowerCase().trim(); String value = token.substring(token.indexOf(NAME_VALUE_SEPARATOR) + 1); cookie.put(key, value); // depends on control dependency: [if], data = [none] } } } } } }
public class class_name { public void init(Properties properties) { super.init(properties); if (client == null) client = new HttpClient(); String strBaseURL = properties.getProperty(BASE_URL_PARAM); if (strBaseURL == null) { strBaseURL = "http://localhost/uploads/"; properties.setProperty(BASE_URL_PARAM, strBaseURL); } } }
public class class_name { public void init(Properties properties) { super.init(properties); if (client == null) client = new HttpClient(); String strBaseURL = properties.getProperty(BASE_URL_PARAM); if (strBaseURL == null) { strBaseURL = "http://localhost/uploads/"; properties.setProperty(BASE_URL_PARAM, strBaseURL); // depends on control dependency: [if], data = [none] } } }
public class class_name { @Override protected JSONObject convertToObject(HTTPResponse httpResponse) { //get response text JSONObject jsonObject=null; String content=httpResponse.getContent(); if(content!=null) { try { //convert to JSON jsonObject=new JSONObject(content); } catch(JSONException exception) { throw new FaxException("Unable to parse HTTP response text as JSON.",exception); } } return jsonObject; } }
public class class_name { @Override protected JSONObject convertToObject(HTTPResponse httpResponse) { //get response text JSONObject jsonObject=null; String content=httpResponse.getContent(); if(content!=null) { try { //convert to JSON jsonObject=new JSONObject(content); // depends on control dependency: [try], data = [none] } catch(JSONException exception) { throw new FaxException("Unable to parse HTTP response text as JSON.",exception); } // depends on control dependency: [catch], data = [none] } return jsonObject; } }
public class class_name { protected String getPrefix(String namespace, boolean generatePrefix, boolean nonEmpty) { // assert namespace != null; if (!namesInterned) { // when String is interned we can do much faster namespace stack // lookups ... namespace = namespace.intern(); } else if (checkNamesInterned) { checkInterning(namespace); // assert namespace != namespace.intern(); } if (namespace == null) { throw new IllegalArgumentException("namespace must be not null" + getLocation()); } else if (namespace.length() == 0) { throw new IllegalArgumentException("default namespace cannot have prefix" + getLocation()); } // first check if namespace is already in scope for (int i = namespaceEnd - 1; i >= 0; --i) { if (namespace == namespaceUri[i]) { final String prefix = namespacePrefix[i]; if (nonEmpty && prefix.length() == 0) continue; // now check that prefix is still in scope for (int p = namespaceEnd - 1; p > i; --p) { if (prefix == namespacePrefix[p]) continue; // too bad - prefix is redeclared with // different namespace } return prefix; } } // so not found it ... if (!generatePrefix) { return null; } return generatePrefix(namespace); } }
public class class_name { protected String getPrefix(String namespace, boolean generatePrefix, boolean nonEmpty) { // assert namespace != null; if (!namesInterned) { // when String is interned we can do much faster namespace stack // lookups ... namespace = namespace.intern(); // depends on control dependency: [if], data = [none] } else if (checkNamesInterned) { checkInterning(namespace); // depends on control dependency: [if], data = [none] // assert namespace != namespace.intern(); } if (namespace == null) { throw new IllegalArgumentException("namespace must be not null" + getLocation()); } else if (namespace.length() == 0) { throw new IllegalArgumentException("default namespace cannot have prefix" + getLocation()); } // first check if namespace is already in scope for (int i = namespaceEnd - 1; i >= 0; --i) { if (namespace == namespaceUri[i]) { final String prefix = namespacePrefix[i]; if (nonEmpty && prefix.length() == 0) continue; // now check that prefix is still in scope for (int p = namespaceEnd - 1; p > i; --p) { if (prefix == namespacePrefix[p]) continue; // too bad - prefix is redeclared with // different namespace } return prefix; // depends on control dependency: [if], data = [none] } } // so not found it ... if (!generatePrefix) { return null; // depends on control dependency: [if], data = [none] } return generatePrefix(namespace); } }
public class class_name { public Vector select(int[] indices) { int newLength = indices.length; if (newLength == 0) { fail("No elements selected."); } Vector result = blankOfLength(newLength); for (int i = 0; i < newLength; i++) { result.set(i, get(indices[i])); } return result; } }
public class class_name { public Vector select(int[] indices) { int newLength = indices.length; if (newLength == 0) { fail("No elements selected."); // depends on control dependency: [if], data = [none] } Vector result = blankOfLength(newLength); for (int i = 0; i < newLength; i++) { result.set(i, get(indices[i])); // depends on control dependency: [for], data = [i] } return result; } }
public class class_name { public java.util.List<InstanceSummary> getInstancesSummary() { if (instancesSummary == null) { instancesSummary = new com.amazonaws.internal.SdkInternalList<InstanceSummary>(); } return instancesSummary; } }
public class class_name { public java.util.List<InstanceSummary> getInstancesSummary() { if (instancesSummary == null) { instancesSummary = new com.amazonaws.internal.SdkInternalList<InstanceSummary>(); // depends on control dependency: [if], data = [none] } return instancesSummary; } }
public class class_name { @Nonnull public UserDetails loadUserByUsername(String idOrFullName) throws UsernameNotFoundException, DataAccessException, ExecutionException { Boolean exists = existenceCache.getIfPresent(idOrFullName); if(exists != null && !exists) { throw new UsernameNotFoundException(String.format("\"%s\" does not exist", idOrFullName)); } else { try { return detailsCache.get(idOrFullName, new Retriever(idOrFullName)); } catch (ExecutionException | UncheckedExecutionException e) { if (e.getCause() instanceof UsernameNotFoundException) { throw ((UsernameNotFoundException)e.getCause()); } else if (e.getCause() instanceof DataAccessException) { throw ((DataAccessException)e.getCause()); } else { throw e; } } } } }
public class class_name { @Nonnull public UserDetails loadUserByUsername(String idOrFullName) throws UsernameNotFoundException, DataAccessException, ExecutionException { Boolean exists = existenceCache.getIfPresent(idOrFullName); if(exists != null && !exists) { throw new UsernameNotFoundException(String.format("\"%s\" does not exist", idOrFullName)); } else { try { return detailsCache.get(idOrFullName, new Retriever(idOrFullName)); // depends on control dependency: [try], data = [none] } catch (ExecutionException | UncheckedExecutionException e) { if (e.getCause() instanceof UsernameNotFoundException) { throw ((UsernameNotFoundException)e.getCause()); } else if (e.getCause() instanceof DataAccessException) { throw ((DataAccessException)e.getCause()); } else { throw e; } } // depends on control dependency: [catch], data = [none] } } }
public class class_name { public synchronized void enqueueRobots() { if (! RuntimeConfiguration.FETCH_ROBOTS) return; if (nextFetch == Long.MAX_VALUE) return; synchronized(this) { if (pathQueries.isEmpty()) { pathQueries.enqueueFirst(ROBOTS_PATH); putInEntryIfNotAcquired(); } else { final byte[] first = pathQueries.dequeue(); pathQueries.enqueueFirst(ROBOTS_PATH); pathQueries.enqueueFirst(first); } } } }
public class class_name { public synchronized void enqueueRobots() { if (! RuntimeConfiguration.FETCH_ROBOTS) return; if (nextFetch == Long.MAX_VALUE) return; synchronized(this) { if (pathQueries.isEmpty()) { pathQueries.enqueueFirst(ROBOTS_PATH); // depends on control dependency: [if], data = [none] putInEntryIfNotAcquired(); // depends on control dependency: [if], data = [none] } else { final byte[] first = pathQueries.dequeue(); pathQueries.enqueueFirst(ROBOTS_PATH); // depends on control dependency: [if], data = [none] pathQueries.enqueueFirst(first); // depends on control dependency: [if], data = [none] } } } }
public class class_name { final void setInputFrameFromApiFormat( final SymbolTable symbolTable, final int numLocal, final Object[] local, final int numStack, final Object[] stack) { int inputLocalIndex = 0; for (int i = 0; i < numLocal; ++i) { inputLocals[inputLocalIndex++] = getAbstractTypeFromApiFormat(symbolTable, local[i]); if (local[i] == Opcodes.LONG || local[i] == Opcodes.DOUBLE) { inputLocals[inputLocalIndex++] = TOP; } } while (inputLocalIndex < inputLocals.length) { inputLocals[inputLocalIndex++] = TOP; } int numStackTop = 0; for (int i = 0; i < numStack; ++i) { if (stack[i] == Opcodes.LONG || stack[i] == Opcodes.DOUBLE) { ++numStackTop; } } inputStack = new int[numStack + numStackTop]; int inputStackIndex = 0; for (int i = 0; i < numStack; ++i) { inputStack[inputStackIndex++] = getAbstractTypeFromApiFormat(symbolTable, stack[i]); if (stack[i] == Opcodes.LONG || stack[i] == Opcodes.DOUBLE) { inputStack[inputStackIndex++] = TOP; } } outputStackTop = 0; initializationCount = 0; } }
public class class_name { final void setInputFrameFromApiFormat( final SymbolTable symbolTable, final int numLocal, final Object[] local, final int numStack, final Object[] stack) { int inputLocalIndex = 0; for (int i = 0; i < numLocal; ++i) { inputLocals[inputLocalIndex++] = getAbstractTypeFromApiFormat(symbolTable, local[i]); // depends on control dependency: [for], data = [i] if (local[i] == Opcodes.LONG || local[i] == Opcodes.DOUBLE) { inputLocals[inputLocalIndex++] = TOP; // depends on control dependency: [if], data = [none] } } while (inputLocalIndex < inputLocals.length) { inputLocals[inputLocalIndex++] = TOP; // depends on control dependency: [while], data = [none] } int numStackTop = 0; for (int i = 0; i < numStack; ++i) { if (stack[i] == Opcodes.LONG || stack[i] == Opcodes.DOUBLE) { ++numStackTop; // depends on control dependency: [if], data = [none] } } inputStack = new int[numStack + numStackTop]; int inputStackIndex = 0; for (int i = 0; i < numStack; ++i) { inputStack[inputStackIndex++] = getAbstractTypeFromApiFormat(symbolTable, stack[i]); // depends on control dependency: [for], data = [i] if (stack[i] == Opcodes.LONG || stack[i] == Opcodes.DOUBLE) { inputStack[inputStackIndex++] = TOP; // depends on control dependency: [if], data = [none] } } outputStackTop = 0; initializationCount = 0; } }
public class class_name { private static void addPanel(TabbedPanel2 tabbedPanel, AbstractPanel panel, boolean visible) { if (visible) { tabbedPanel.addTab(panel); } else { tabbedPanel.addTabHidden(panel); } } }
public class class_name { private static void addPanel(TabbedPanel2 tabbedPanel, AbstractPanel panel, boolean visible) { if (visible) { tabbedPanel.addTab(panel); // depends on control dependency: [if], data = [none] } else { tabbedPanel.addTabHidden(panel); // depends on control dependency: [if], data = [none] } } }
public class class_name { @Override public EClass getIfcStackTerminal() { if (ifcStackTerminalEClass == null) { ifcStackTerminalEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI) .getEClassifiers().get(622); } return ifcStackTerminalEClass; } }
public class class_name { @Override public EClass getIfcStackTerminal() { if (ifcStackTerminalEClass == null) { ifcStackTerminalEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI) .getEClassifiers().get(622); // depends on control dependency: [if], data = [none] } return ifcStackTerminalEClass; } }
public class class_name { public static boolean isHexidecimal(String str) { if (str == null) { return false; } return Pattern.compile("[0-9a-fA-F]*").matcher(str).matches(); } }
public class class_name { public static boolean isHexidecimal(String str) { if (str == null) { return false; // depends on control dependency: [if], data = [none] } return Pattern.compile("[0-9a-fA-F]*").matcher(str).matches(); } }
public class class_name { public ContextUserAuthManager getContextUserAuthManager(int contextId) { ContextUserAuthManager manager = contextManagers.get(contextId); if (manager == null) { manager = new ContextUserAuthManager(contextId); contextManagers.put(contextId, manager); } return manager; } }
public class class_name { public ContextUserAuthManager getContextUserAuthManager(int contextId) { ContextUserAuthManager manager = contextManagers.get(contextId); if (manager == null) { manager = new ContextUserAuthManager(contextId); // depends on control dependency: [if], data = [none] contextManagers.put(contextId, manager); // depends on control dependency: [if], data = [none] } return manager; } }
public class class_name { public static <T> void remove(List<T> list, List<Integer> removes) { // 不是ArrayList的先转换为ArrayList if (!(list instanceof ArrayList)) { list = new ArrayList<>(list); } int flag = 0; // 删除 for (int i = 0; i < removes.size(); i++) { if (flag < removes.get(i)) { flag = removes.get(i); list.remove(flag - i); } else { throw new CollectionException("删除集合中多个元素时指针应该按照从小到大的顺序排序"); } } } }
public class class_name { public static <T> void remove(List<T> list, List<Integer> removes) { // 不是ArrayList的先转换为ArrayList if (!(list instanceof ArrayList)) { list = new ArrayList<>(list); // depends on control dependency: [if], data = [none] } int flag = 0; // 删除 for (int i = 0; i < removes.size(); i++) { if (flag < removes.get(i)) { flag = removes.get(i); // depends on control dependency: [if], data = [none] list.remove(flag - i); // depends on control dependency: [if], data = [(flag] } else { throw new CollectionException("删除集合中多个元素时指针应该按照从小到大的顺序排序"); } } } }
public class class_name { public List<String> getSemanticHeads() { int headSemanticVariable = syntax.getHeadVariable(); int[] allSemanticVariables = getSemanticVariables(); for (int i = 0; i < allSemanticVariables.length; i++) { if (allSemanticVariables[i] == headSemanticVariable) { return Lists.newArrayList(variableAssignments.get(i)); } } return Collections.emptyList(); } }
public class class_name { public List<String> getSemanticHeads() { int headSemanticVariable = syntax.getHeadVariable(); int[] allSemanticVariables = getSemanticVariables(); for (int i = 0; i < allSemanticVariables.length; i++) { if (allSemanticVariables[i] == headSemanticVariable) { return Lists.newArrayList(variableAssignments.get(i)); // depends on control dependency: [if], data = [none] } } return Collections.emptyList(); } }
public class class_name { public EEnum getIOBYoaOrent() { if (iobYoaOrentEEnum == null) { iobYoaOrentEEnum = (EEnum)EPackage.Registry.INSTANCE.getEPackage(AfplibPackage.eNS_URI).getEClassifiers().get(40); } return iobYoaOrentEEnum; } }
public class class_name { public EEnum getIOBYoaOrent() { if (iobYoaOrentEEnum == null) { iobYoaOrentEEnum = (EEnum)EPackage.Registry.INSTANCE.getEPackage(AfplibPackage.eNS_URI).getEClassifiers().get(40); // depends on control dependency: [if], data = [none] } return iobYoaOrentEEnum; } }
public class class_name { private String insertFormats(final String pattern, final ArrayList<String> customPatterns) { if (!containsElements(customPatterns)) { return pattern; } final StringBuilder sb = new StringBuilder(pattern.length() * 2); final ParsePosition pos = new ParsePosition(0); int fe = -1; int depth = 0; while (pos.getIndex() < pattern.length()) { final char c = pattern.charAt(pos.getIndex()); switch (c) { case QUOTE: appendQuotedString(pattern, pos, sb); break; case START_FE: depth++; sb.append(START_FE).append(readArgumentIndex(pattern, next(pos))); // do not look for custom patterns when they are embedded, e.g. in a choice if (depth == 1) { fe++; final String customPattern = customPatterns.get(fe); if (customPattern != null) { sb.append(START_FMT).append(customPattern); } } break; case END_FE: depth--; //$FALL-THROUGH$ default: sb.append(c); next(pos); } } return sb.toString(); } }
public class class_name { private String insertFormats(final String pattern, final ArrayList<String> customPatterns) { if (!containsElements(customPatterns)) { return pattern; // depends on control dependency: [if], data = [none] } final StringBuilder sb = new StringBuilder(pattern.length() * 2); final ParsePosition pos = new ParsePosition(0); int fe = -1; int depth = 0; while (pos.getIndex() < pattern.length()) { final char c = pattern.charAt(pos.getIndex()); switch (c) { case QUOTE: appendQuotedString(pattern, pos, sb); break; case START_FE: depth++; sb.append(START_FE).append(readArgumentIndex(pattern, next(pos))); // do not look for custom patterns when they are embedded, e.g. in a choice if (depth == 1) { fe++; // depends on control dependency: [if], data = [none] final String customPattern = customPatterns.get(fe); if (customPattern != null) { sb.append(START_FMT).append(customPattern); // depends on control dependency: [if], data = [(customPattern] } } break; case END_FE: depth--; //$FALL-THROUGH$ default: sb.append(c); next(pos); } } return sb.toString(); } }
public class class_name { private int flush(int offset) { try { _os.write(_buffer, 0, offset); _offset = 0; return 0; } catch (IOException e) { throw new H3ExceptionOut(e); } } }
public class class_name { private int flush(int offset) { try { _os.write(_buffer, 0, offset); // depends on control dependency: [try], data = [none] _offset = 0; // depends on control dependency: [try], data = [none] return 0; // depends on control dependency: [try], data = [none] } catch (IOException e) { throw new H3ExceptionOut(e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { static boolean isAssignableTo(ClassNode type, ClassNode toBeAssignedTo) { if (UNKNOWN_PARAMETER_TYPE == type) return true; if (type == toBeAssignedTo) return true; if (toBeAssignedTo.redirect() == STRING_TYPE && type.redirect() == GSTRING_TYPE) { return true; } if (isPrimitiveType(toBeAssignedTo)) toBeAssignedTo = getWrapper(toBeAssignedTo); if (isPrimitiveType(type)) type = getWrapper(type); if (NUMBER_TYPES.containsKey(type.redirect()) && NUMBER_TYPES.containsKey(toBeAssignedTo.redirect())) { return NUMBER_TYPES.get(type.redirect()) <= NUMBER_TYPES.get(toBeAssignedTo.redirect()); } if (type.isArray() && toBeAssignedTo.isArray()) { return isAssignableTo(type.getComponentType(), toBeAssignedTo.getComponentType()); } if (type.isDerivedFrom(GSTRING_TYPE) && STRING_TYPE.equals(toBeAssignedTo)) { return true; } if (toBeAssignedTo.isDerivedFrom(GSTRING_TYPE) && STRING_TYPE.equals(type)) { return true; } if (implementsInterfaceOrIsSubclassOf(type, toBeAssignedTo)) { if (OBJECT_TYPE.equals(toBeAssignedTo)) return true; if (toBeAssignedTo.isUsingGenerics()) { // perform additional check on generics // ? extends toBeAssignedTo GenericsType gt = GenericsUtils.buildWildcardType(toBeAssignedTo); return gt.isCompatibleWith(type); } return true; } //SAM check if (type.isDerivedFrom(CLOSURE_TYPE) && isSAMType(toBeAssignedTo)) { return true; } return false; } }
public class class_name { static boolean isAssignableTo(ClassNode type, ClassNode toBeAssignedTo) { if (UNKNOWN_PARAMETER_TYPE == type) return true; if (type == toBeAssignedTo) return true; if (toBeAssignedTo.redirect() == STRING_TYPE && type.redirect() == GSTRING_TYPE) { return true; // depends on control dependency: [if], data = [none] } if (isPrimitiveType(toBeAssignedTo)) toBeAssignedTo = getWrapper(toBeAssignedTo); if (isPrimitiveType(type)) type = getWrapper(type); if (NUMBER_TYPES.containsKey(type.redirect()) && NUMBER_TYPES.containsKey(toBeAssignedTo.redirect())) { return NUMBER_TYPES.get(type.redirect()) <= NUMBER_TYPES.get(toBeAssignedTo.redirect()); // depends on control dependency: [if], data = [none] } if (type.isArray() && toBeAssignedTo.isArray()) { return isAssignableTo(type.getComponentType(), toBeAssignedTo.getComponentType()); // depends on control dependency: [if], data = [none] } if (type.isDerivedFrom(GSTRING_TYPE) && STRING_TYPE.equals(toBeAssignedTo)) { return true; // depends on control dependency: [if], data = [none] } if (toBeAssignedTo.isDerivedFrom(GSTRING_TYPE) && STRING_TYPE.equals(type)) { return true; // depends on control dependency: [if], data = [none] } if (implementsInterfaceOrIsSubclassOf(type, toBeAssignedTo)) { if (OBJECT_TYPE.equals(toBeAssignedTo)) return true; if (toBeAssignedTo.isUsingGenerics()) { // perform additional check on generics // ? extends toBeAssignedTo GenericsType gt = GenericsUtils.buildWildcardType(toBeAssignedTo); return gt.isCompatibleWith(type); // depends on control dependency: [if], data = [none] } return true; // depends on control dependency: [if], data = [none] } //SAM check if (type.isDerivedFrom(CLOSURE_TYPE) && isSAMType(toBeAssignedTo)) { return true; // depends on control dependency: [if], data = [none] } return false; } }
public class class_name { public void setBasicTraceDetail(SIDestinationAddress destinationAddress, DestinationType destinationType, SIBusMessage message) { if (destinationAddress == null) { validateAndPutProperty("BusName", ""); validateAndPutProperty("DestinationName", ""); } else { validateAndPutProperty("BusName", destinationAddress.getBusName()); validateAndPutProperty("DestinationName", destinationAddress.getDestinationName()); } validateAndPutProperty("DestinationType", destinationType); if (message == null) { validateAndPutProperty("SystemMessageID", ""); validateAndPutProperty("Priority", ""); validateAndPutProperty("Reliability", ""); validateAndPutProperty("Discriminator",""); } else { validateAndPutProperty("SystemMessageID", message.getSystemMessageId()); validateAndPutProperty("Priority", message.getPriority()); validateAndPutProperty("Reliability", message.getReliability()); validateAndPutProperty("Discriminator",message.getDiscriminator()); } } }
public class class_name { public void setBasicTraceDetail(SIDestinationAddress destinationAddress, DestinationType destinationType, SIBusMessage message) { if (destinationAddress == null) { validateAndPutProperty("BusName", ""); // depends on control dependency: [if], data = [none] validateAndPutProperty("DestinationName", ""); // depends on control dependency: [if], data = [none] } else { validateAndPutProperty("BusName", destinationAddress.getBusName()); // depends on control dependency: [if], data = [none] validateAndPutProperty("DestinationName", destinationAddress.getDestinationName()); // depends on control dependency: [if], data = [none] } validateAndPutProperty("DestinationType", destinationType); if (message == null) { validateAndPutProperty("SystemMessageID", ""); // depends on control dependency: [if], data = [none] validateAndPutProperty("Priority", ""); // depends on control dependency: [if], data = [none] validateAndPutProperty("Reliability", ""); // depends on control dependency: [if], data = [none] validateAndPutProperty("Discriminator",""); // depends on control dependency: [if], data = [none] } else { validateAndPutProperty("SystemMessageID", message.getSystemMessageId()); // depends on control dependency: [if], data = [none] validateAndPutProperty("Priority", message.getPriority()); // depends on control dependency: [if], data = [none] validateAndPutProperty("Reliability", message.getReliability()); // depends on control dependency: [if], data = [none] validateAndPutProperty("Discriminator",message.getDiscriminator()); // depends on control dependency: [if], data = [none] } } }
public class class_name { public boolean validateMetadataContent( Object contentObject, StringBuilder out) { boolean ok = true; ArrayList catGenConfigList = (ArrayList) contentObject; Iterator iter = catGenConfigList.iterator(); while ( iter.hasNext()) { CatalogGenConfig catGenConf = (CatalogGenConfig) iter.next(); ok &= catGenConf.validate( out); } return ok; } }
public class class_name { public boolean validateMetadataContent( Object contentObject, StringBuilder out) { boolean ok = true; ArrayList catGenConfigList = (ArrayList) contentObject; Iterator iter = catGenConfigList.iterator(); while ( iter.hasNext()) { CatalogGenConfig catGenConf = (CatalogGenConfig) iter.next(); ok &= catGenConf.validate( out); // depends on control dependency: [while], data = [none] } return ok; } }
public class class_name { private ManagedBuffer getSortBasedShuffleBlockData( ExecutorShuffleInfo executor, int shuffleId, int mapId, int reduceId) { File indexFile = getFile(executor.localDirs, executor.subDirsPerLocalDir, "shuffle_" + shuffleId + "_" + mapId + "_0.index"); try { ShuffleIndexInformation shuffleIndexInformation = shuffleIndexCache.get(indexFile); ShuffleIndexRecord shuffleIndexRecord = shuffleIndexInformation.getIndex(reduceId); return new FileSegmentManagedBuffer( conf, getFile(executor.localDirs, executor.subDirsPerLocalDir, "shuffle_" + shuffleId + "_" + mapId + "_0.data"), shuffleIndexRecord.getOffset(), shuffleIndexRecord.getLength()); } catch (ExecutionException e) { throw new RuntimeException("Failed to open file: " + indexFile, e); } } }
public class class_name { private ManagedBuffer getSortBasedShuffleBlockData( ExecutorShuffleInfo executor, int shuffleId, int mapId, int reduceId) { File indexFile = getFile(executor.localDirs, executor.subDirsPerLocalDir, "shuffle_" + shuffleId + "_" + mapId + "_0.index"); try { ShuffleIndexInformation shuffleIndexInformation = shuffleIndexCache.get(indexFile); ShuffleIndexRecord shuffleIndexRecord = shuffleIndexInformation.getIndex(reduceId); return new FileSegmentManagedBuffer( conf, getFile(executor.localDirs, executor.subDirsPerLocalDir, "shuffle_" + shuffleId + "_" + mapId + "_0.data"), shuffleIndexRecord.getOffset(), shuffleIndexRecord.getLength()); // depends on control dependency: [try], data = [none] } catch (ExecutionException e) { throw new RuntimeException("Failed to open file: " + indexFile, e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { static int[] join(int[] pathToY, int[] pathToZ) { int[] path = copyOf(pathToY, pathToY.length + pathToZ.length); int j = path.length - 1; for (int i = 0; i < pathToZ.length; i++) { path[j--] = pathToZ[i]; } return path; } }
public class class_name { static int[] join(int[] pathToY, int[] pathToZ) { int[] path = copyOf(pathToY, pathToY.length + pathToZ.length); int j = path.length - 1; for (int i = 0; i < pathToZ.length; i++) { path[j--] = pathToZ[i]; // depends on control dependency: [for], data = [i] } return path; } }
public class class_name { private static SerializedLambda serializedLambda( Serializable lambda ) { try { Method replaceMethod = lambda.getClass().getDeclaredMethod( "writeReplace" ); replaceMethod.setAccessible( true ); return (SerializedLambda) replaceMethod.invoke( lambda ); } catch ( Exception e ) { throw new IllegalStateException( "Reflection failed." ); } } }
public class class_name { private static SerializedLambda serializedLambda( Serializable lambda ) { try { Method replaceMethod = lambda.getClass().getDeclaredMethod( "writeReplace" ); replaceMethod.setAccessible( true ); // depends on control dependency: [try], data = [none] return (SerializedLambda) replaceMethod.invoke( lambda ); // depends on control dependency: [try], data = [none] } catch ( Exception e ) { throw new IllegalStateException( "Reflection failed." ); } // depends on control dependency: [catch], data = [none] } }
public class class_name { protected int findTotalOffset(ArrayList aligments, byte position) { int total = 0; for (Object aligment : aligments) { HorizontalBandAlignment currentAlignment = (HorizontalBandAlignment) aligment; int aux = 0; for (AutoText autotext : getReport().getAutoTexts()) { if (autotext.getPosition() == position && currentAlignment.equals(autotext.getAlignment())) { aux += autotext.getHeight(); } } if (aux > total) total = aux; } return total; } }
public class class_name { protected int findTotalOffset(ArrayList aligments, byte position) { int total = 0; for (Object aligment : aligments) { HorizontalBandAlignment currentAlignment = (HorizontalBandAlignment) aligment; int aux = 0; for (AutoText autotext : getReport().getAutoTexts()) { if (autotext.getPosition() == position && currentAlignment.equals(autotext.getAlignment())) { aux += autotext.getHeight(); // depends on control dependency: [if], data = [none] } } if (aux > total) total = aux; } return total; } }
public class class_name { private void renderData() { QrCodeMaskPattern mask = qr.mask; int count = 0; int length = bitLocations.size() - bitLocations.size()%8; while( count < length ) { int bits = qr.rawbits[count/8]&0xFF; int N = Math.min(8,bitLocations.size()-count); for (int i = 0; i < N; i++) { Point2D_I32 coor = bitLocations.get(count+i); int value = mask.apply(coor.y,coor.x, ((bits >> i ) & 0x01)); // int value = ((bits >> i ) & 0x01); if( value > 0 ) { square(coor.y,coor.x); } } count += 8; } } }
public class class_name { private void renderData() { QrCodeMaskPattern mask = qr.mask; int count = 0; int length = bitLocations.size() - bitLocations.size()%8; while( count < length ) { int bits = qr.rawbits[count/8]&0xFF; int N = Math.min(8,bitLocations.size()-count); for (int i = 0; i < N; i++) { Point2D_I32 coor = bitLocations.get(count+i); int value = mask.apply(coor.y,coor.x, ((bits >> i ) & 0x01)); // int value = ((bits >> i ) & 0x01); if( value > 0 ) { square(coor.y,coor.x); // depends on control dependency: [if], data = [none] } } count += 8; // depends on control dependency: [while], data = [none] } } }
public class class_name { public boolean acceptsURL(String url) { if (url == null) { return false; } return url.regionMatches(true, 0, DatabaseURL.S_URL_PREFIX, 0, DatabaseURL.S_URL_PREFIX.length()); } }
public class class_name { public boolean acceptsURL(String url) { if (url == null) { return false; // depends on control dependency: [if], data = [none] } return url.regionMatches(true, 0, DatabaseURL.S_URL_PREFIX, 0, DatabaseURL.S_URL_PREFIX.length()); } }
public class class_name { public static String toStr(Document doc, String charset, boolean isPretty) { final StringWriter writer = StrUtil.getWriter(); try { write(doc, writer, charset, isPretty ? INDENT_DEFAULT : 0); } catch (Exception e) { throw new UtilException(e, "Trans xml document to string error!"); } return writer.toString(); } }
public class class_name { public static String toStr(Document doc, String charset, boolean isPretty) { final StringWriter writer = StrUtil.getWriter(); try { write(doc, writer, charset, isPretty ? INDENT_DEFAULT : 0); // depends on control dependency: [try], data = [none] } catch (Exception e) { throw new UtilException(e, "Trans xml document to string error!"); } // depends on control dependency: [catch], data = [none] return writer.toString(); } }
public class class_name { @Override public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { if (detailedTransformTrace && tc.isEntryEnabled()) Tr.entry(this, tc, "transform", loader, className, classBeingRedefined, protectionDomain); byte[] newClassBytes = null; if (isTransformPossible(classfileBuffer)) { boolean traceEnabledForClass = injectAtTransform; if (!injectAtTransform && classBeingRedefined != null) { WeakReference<TraceComponent> tcReference = traceComponentByClass.get(classBeingRedefined); TraceComponent traceComponent = tcReference == null ? null : tcReference.get(); traceEnabledForClass |= (traceComponent != null && traceComponent.isEntryEnabled()); } if (traceEnabledForClass) { try { newClassBytes = transform(classfileBuffer); } catch (Throwable t) { Tr.error(tc, "INSTRUMENTATION_TRANSFORM_FAILED_FOR_CLASS_2", className, t); } } } if (detailedTransformTrace && tc.isEntryEnabled()) Tr.exit(this, tc, "transform", newClassBytes); return newClassBytes; } }
public class class_name { @Override public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { if (detailedTransformTrace && tc.isEntryEnabled()) Tr.entry(this, tc, "transform", loader, className, classBeingRedefined, protectionDomain); byte[] newClassBytes = null; if (isTransformPossible(classfileBuffer)) { boolean traceEnabledForClass = injectAtTransform; if (!injectAtTransform && classBeingRedefined != null) { WeakReference<TraceComponent> tcReference = traceComponentByClass.get(classBeingRedefined); TraceComponent traceComponent = tcReference == null ? null : tcReference.get(); traceEnabledForClass |= (traceComponent != null && traceComponent.isEntryEnabled()); // depends on control dependency: [if], data = [none] } if (traceEnabledForClass) { try { newClassBytes = transform(classfileBuffer); // depends on control dependency: [try], data = [none] } catch (Throwable t) { Tr.error(tc, "INSTRUMENTATION_TRANSFORM_FAILED_FOR_CLASS_2", className, t); } // depends on control dependency: [catch], data = [none] } } if (detailedTransformTrace && tc.isEntryEnabled()) Tr.exit(this, tc, "transform", newClassBytes); return newClassBytes; } }
public class class_name { private Map<String, Object> convertToMap(Environment input) { // First use the current convertToProperties to get a flat Map from the // environment Map<String, Object> properties = convertToProperties(input); // The root map which holds all the first level properties Map<String, Object> rootMap = new LinkedHashMap<>(); for (Map.Entry<String, Object> entry : properties.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); PropertyNavigator nav = new PropertyNavigator(key); nav.setMapValue(rootMap, value); } return rootMap; } }
public class class_name { private Map<String, Object> convertToMap(Environment input) { // First use the current convertToProperties to get a flat Map from the // environment Map<String, Object> properties = convertToProperties(input); // The root map which holds all the first level properties Map<String, Object> rootMap = new LinkedHashMap<>(); for (Map.Entry<String, Object> entry : properties.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); PropertyNavigator nav = new PropertyNavigator(key); nav.setMapValue(rootMap, value); // depends on control dependency: [for], data = [none] } return rootMap; } }
public class class_name { public void checkTags(Doc doc, Tag[] tags, boolean areInlineTags) { if (tags == null) { return; } Taglet taglet; for (Tag tag : tags) { String name = tag.name(); if (name.length() > 0 && name.charAt(0) == '@') { name = name.substring(1, name.length()); } if (! (standardTags.contains(name) || customTags.containsKey(name))) { if (standardTagsLowercase.contains(StringUtils.toLowerCase(name))) { message.warning(tag.position(), "doclet.UnknownTagLowercase", tag.name()); continue; } else { message.warning(tag.position(), "doclet.UnknownTag", tag.name()); continue; } } //Check if this tag is being used in the wrong location. if ((taglet = customTags.get(name)) != null) { if (areInlineTags && ! taglet.isInlineTag()) { printTagMisuseWarn(taglet, tag, "inline"); } if ((doc instanceof RootDoc) && ! taglet.inOverview()) { printTagMisuseWarn(taglet, tag, "overview"); } else if ((doc instanceof PackageDoc) && ! taglet.inPackage()) { printTagMisuseWarn(taglet, tag, "package"); } else if ((doc instanceof ClassDoc) && ! taglet.inType()) { printTagMisuseWarn(taglet, tag, "class"); } else if ((doc instanceof ConstructorDoc) && ! taglet.inConstructor()) { printTagMisuseWarn(taglet, tag, "constructor"); } else if ((doc instanceof FieldDoc) && ! taglet.inField()) { printTagMisuseWarn(taglet, tag, "field"); } else if ((doc instanceof MethodDoc) && ! taglet.inMethod()) { printTagMisuseWarn(taglet, tag, "method"); } } } } }
public class class_name { public void checkTags(Doc doc, Tag[] tags, boolean areInlineTags) { if (tags == null) { return; // depends on control dependency: [if], data = [none] } Taglet taglet; for (Tag tag : tags) { String name = tag.name(); if (name.length() > 0 && name.charAt(0) == '@') { name = name.substring(1, name.length()); // depends on control dependency: [if], data = [none] } if (! (standardTags.contains(name) || customTags.containsKey(name))) { if (standardTagsLowercase.contains(StringUtils.toLowerCase(name))) { message.warning(tag.position(), "doclet.UnknownTagLowercase", tag.name()); // depends on control dependency: [if], data = [none] continue; } else { message.warning(tag.position(), "doclet.UnknownTag", tag.name()); // depends on control dependency: [if], data = [none] continue; } } //Check if this tag is being used in the wrong location. if ((taglet = customTags.get(name)) != null) { if (areInlineTags && ! taglet.isInlineTag()) { printTagMisuseWarn(taglet, tag, "inline"); // depends on control dependency: [if], data = [none] } if ((doc instanceof RootDoc) && ! taglet.inOverview()) { printTagMisuseWarn(taglet, tag, "overview"); // depends on control dependency: [if], data = [none] } else if ((doc instanceof PackageDoc) && ! taglet.inPackage()) { printTagMisuseWarn(taglet, tag, "package"); // depends on control dependency: [if], data = [none] } else if ((doc instanceof ClassDoc) && ! taglet.inType()) { printTagMisuseWarn(taglet, tag, "class"); // depends on control dependency: [if], data = [none] } else if ((doc instanceof ConstructorDoc) && ! taglet.inConstructor()) { printTagMisuseWarn(taglet, tag, "constructor"); // depends on control dependency: [if], data = [none] } else if ((doc instanceof FieldDoc) && ! taglet.inField()) { printTagMisuseWarn(taglet, tag, "field"); // depends on control dependency: [if], data = [none] } else if ((doc instanceof MethodDoc) && ! taglet.inMethod()) { printTagMisuseWarn(taglet, tag, "method"); // depends on control dependency: [if], data = [none] } } } } }
public class class_name { public static String getShortClassName(String className) { final List<String> packages = StrUtil.split(className, CharUtil.DOT); if (null == packages || packages.size() < 2) { return className; } final int size = packages.size(); final StringBuilder result = StrUtil.builder(); result.append(packages.get(0).charAt(0)); for (int i = 1; i < size - 1; i++) { result.append(CharUtil.DOT).append(packages.get(i).charAt(0)); } result.append(CharUtil.DOT).append(packages.get(size - 1)); return result.toString(); } }
public class class_name { public static String getShortClassName(String className) { final List<String> packages = StrUtil.split(className, CharUtil.DOT); if (null == packages || packages.size() < 2) { return className; // depends on control dependency: [if], data = [none] } final int size = packages.size(); final StringBuilder result = StrUtil.builder(); result.append(packages.get(0).charAt(0)); for (int i = 1; i < size - 1; i++) { result.append(CharUtil.DOT).append(packages.get(i).charAt(0)); // depends on control dependency: [for], data = [i] } result.append(CharUtil.DOT).append(packages.get(size - 1)); return result.toString(); } }
public class class_name { private List<Element> findQuestionAnswers(Element questionnaireResponse, String question) { List<Element> retVal = new ArrayList<>(); List<Element> items = questionnaireResponse.getChildren(ITEM_ELEMENT); for (Element next : items) { if (hasLinkId(next, question)) { List<Element> answers = extractAnswer(next); retVal.addAll(answers); } retVal.addAll(findQuestionAnswers(next, question)); } return retVal; } }
public class class_name { private List<Element> findQuestionAnswers(Element questionnaireResponse, String question) { List<Element> retVal = new ArrayList<>(); List<Element> items = questionnaireResponse.getChildren(ITEM_ELEMENT); for (Element next : items) { if (hasLinkId(next, question)) { List<Element> answers = extractAnswer(next); retVal.addAll(answers); // depends on control dependency: [if], data = [none] } retVal.addAll(findQuestionAnswers(next, question)); // depends on control dependency: [for], data = [next] } return retVal; } }
public class class_name { private void updateJenkinsExeIfNeeded() { try { File baseDir = getBaseDir(); URL exe = getClass().getResource("/windows-service/jenkins.exe"); String ourCopy = Util.getDigestOf(exe.openStream()); for (String name : new String[]{"hudson.exe","jenkins.exe"}) { try { File currentCopy = new File(baseDir,name); if(!currentCopy.exists()) continue; String curCopy = new FilePath(currentCopy).digest(); if(ourCopy.equals(curCopy)) continue; // identical File stage = new File(baseDir,name+".new"); FileUtils.copyURLToFile(exe,stage); Kernel32.INSTANCE.MoveFileExA(stage.getAbsolutePath(),currentCopy.getAbsolutePath(),MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING); LOGGER.info("Scheduled a replacement of "+name); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Failed to replace "+name,e); } catch (InterruptedException e) { } } } catch (IOException e) { LOGGER.log(Level.SEVERE, "Failed to replace jenkins.exe",e); } } }
public class class_name { private void updateJenkinsExeIfNeeded() { try { File baseDir = getBaseDir(); URL exe = getClass().getResource("/windows-service/jenkins.exe"); String ourCopy = Util.getDigestOf(exe.openStream()); for (String name : new String[]{"hudson.exe","jenkins.exe"}) { try { File currentCopy = new File(baseDir,name); if(!currentCopy.exists()) continue; String curCopy = new FilePath(currentCopy).digest(); if(ourCopy.equals(curCopy)) continue; // identical File stage = new File(baseDir,name+".new"); FileUtils.copyURLToFile(exe,stage); // depends on control dependency: [try], data = [none] Kernel32.INSTANCE.MoveFileExA(stage.getAbsolutePath(),currentCopy.getAbsolutePath(),MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING); // depends on control dependency: [try], data = [none] LOGGER.info("Scheduled a replacement of "+name); // depends on control dependency: [try], data = [none] } catch (IOException e) { LOGGER.log(Level.SEVERE, "Failed to replace "+name,e); } catch (InterruptedException e) { // depends on control dependency: [catch], data = [none] } // depends on control dependency: [catch], data = [none] } } catch (IOException e) { LOGGER.log(Level.SEVERE, "Failed to replace jenkins.exe",e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public boolean isAfter(T element) { if (element == null) { return false; } return comparator.compare(element, min) < 0; } }
public class class_name { public boolean isAfter(T element) { if (element == null) { return false; } // depends on control dependency: [if], data = [none] return comparator.compare(element, min) < 0; } }
public class class_name { @Override public PrincipalUser getUser(String username, String password) { requireNotDisposed(); requireArgument(_isUsernameValid(username), MessageFormat.format("Invalid username: {0}", username)); PrincipalUser result = null; String userDn = _findDNForUser(username); if (userDn != null && password != null) { result = _findPrincipalUser(userDn, username, password); } return result; } }
public class class_name { @Override public PrincipalUser getUser(String username, String password) { requireNotDisposed(); requireArgument(_isUsernameValid(username), MessageFormat.format("Invalid username: {0}", username)); PrincipalUser result = null; String userDn = _findDNForUser(username); if (userDn != null && password != null) { result = _findPrincipalUser(userDn, username, password); // depends on control dependency: [if], data = [(userDn] } return result; } }
public class class_name { private int findLast(CharSequence input, int beginIndex) { boolean firstInSubDomain = true; boolean canEndSubDomain = false; int firstDot = -1; int last = -1; for (int i = beginIndex; i < input.length(); i++) { char c = input.charAt(i); if (firstInSubDomain) { if (subDomainAllowed(c)) { last = i; firstInSubDomain = false; canEndSubDomain = true; } else { break; } } else { if (c == '.') { if (!canEndSubDomain) { break; } firstInSubDomain = true; if (firstDot == -1) { firstDot = i; } } else if (c == '-') { canEndSubDomain = false; } else if (subDomainAllowed(c)) { last = i; canEndSubDomain = true; } else { break; } } } if (domainMustHaveDot && (firstDot == -1 || firstDot > last)) { return -1; } else { return last; } } }
public class class_name { private int findLast(CharSequence input, int beginIndex) { boolean firstInSubDomain = true; boolean canEndSubDomain = false; int firstDot = -1; int last = -1; for (int i = beginIndex; i < input.length(); i++) { char c = input.charAt(i); if (firstInSubDomain) { if (subDomainAllowed(c)) { last = i; // depends on control dependency: [if], data = [none] firstInSubDomain = false; // depends on control dependency: [if], data = [none] canEndSubDomain = true; // depends on control dependency: [if], data = [none] } else { break; } } else { if (c == '.') { if (!canEndSubDomain) { break; } firstInSubDomain = true; // depends on control dependency: [if], data = [none] if (firstDot == -1) { firstDot = i; // depends on control dependency: [if], data = [none] } } else if (c == '-') { canEndSubDomain = false; // depends on control dependency: [if], data = [none] } else if (subDomainAllowed(c)) { last = i; // depends on control dependency: [if], data = [none] canEndSubDomain = true; // depends on control dependency: [if], data = [none] } else { break; } } } if (domainMustHaveDot && (firstDot == -1 || firstDot > last)) { return -1; // depends on control dependency: [if], data = [none] } else { return last; // depends on control dependency: [if], data = [none] } } }
public class class_name { protected static String getTargetText(Target target) { if (target != null) { if (target.getStartNode() != null) { return getNodeText(target.getStartNode()); } else if (target.getContext() != null) { return Constant.messages.getString("context.prefixName", target.getContext().getName()); } else if (target.isInScopeOnly()) { return Constant.messages.getString("context.allInScope"); } } return null; } }
public class class_name { protected static String getTargetText(Target target) { if (target != null) { if (target.getStartNode() != null) { return getNodeText(target.getStartNode()); // depends on control dependency: [if], data = [(target.getStartNode()] } else if (target.getContext() != null) { return Constant.messages.getString("context.prefixName", target.getContext().getName()); // depends on control dependency: [if], data = [none] } else if (target.isInScopeOnly()) { return Constant.messages.getString("context.allInScope"); // depends on control dependency: [if], data = [none] } } return null; } }
public class class_name { static public void registerConvention(String conventionName, Class c, ConventionNameOk match) { if (!(CoordSysBuilderIF.class.isAssignableFrom(c))) throw new IllegalArgumentException("CoordSysBuilderIF Class " + c.getName() + " must implement CoordSysBuilderIF"); // fail fast - check newInstance works try { c.newInstance(); } catch (InstantiationException e) { throw new IllegalArgumentException("CoordSysBuilderIF Class " + c.getName() + " cannot instantiate, probably need default Constructor"); } catch (IllegalAccessException e) { throw new IllegalArgumentException("CoordSysBuilderIF Class " + c.getName() + " is not accessible"); } // user stuff gets put at top if (userMode) conventionList.add(0, new Convention(conventionName, c, match)); else conventionList.add(new Convention(conventionName, c, match)); } }
public class class_name { static public void registerConvention(String conventionName, Class c, ConventionNameOk match) { if (!(CoordSysBuilderIF.class.isAssignableFrom(c))) throw new IllegalArgumentException("CoordSysBuilderIF Class " + c.getName() + " must implement CoordSysBuilderIF"); // fail fast - check newInstance works try { c.newInstance(); // depends on control dependency: [try], data = [none] } catch (InstantiationException e) { throw new IllegalArgumentException("CoordSysBuilderIF Class " + c.getName() + " cannot instantiate, probably need default Constructor"); } catch (IllegalAccessException e) { // depends on control dependency: [catch], data = [none] throw new IllegalArgumentException("CoordSysBuilderIF Class " + c.getName() + " is not accessible"); } // depends on control dependency: [catch], data = [none] // user stuff gets put at top if (userMode) conventionList.add(0, new Convention(conventionName, c, match)); else conventionList.add(new Convention(conventionName, c, match)); } }
public class class_name { public static SSLEngine createEngine(final boolean clientMode) { if (context == null) { context = createContext(); } SSLEngine engine = context.createSSLEngine(); engine.setUseClientMode(clientMode); return engine; } }
public class class_name { public static SSLEngine createEngine(final boolean clientMode) { if (context == null) { context = createContext(); // depends on control dependency: [if], data = [none] } SSLEngine engine = context.createSSLEngine(); engine.setUseClientMode(clientMode); return engine; } }
public class class_name { public static int readUnsignedVarint(ByteBuffer buffer) throws IOException { int val = 0; int bits = 0; while(true) { final int data = buffer.get(); val |= (data & 0x7F) << bits; if((data & 0x80) == 0) { return val; } bits += 7; if(bits > 35) { throw new IOException("Variable length quantity is too long for expected integer."); } } } }
public class class_name { public static int readUnsignedVarint(ByteBuffer buffer) throws IOException { int val = 0; int bits = 0; while(true) { final int data = buffer.get(); val |= (data & 0x7F) << bits; if((data & 0x80) == 0) { return val; // depends on control dependency: [if], data = [none] } bits += 7; if(bits > 35) { throw new IOException("Variable length quantity is too long for expected integer."); } } } }
public class class_name { private void fillBuffer(long amount, boolean reload) { try { if (amount > bufferSize) { amount = bufferSize; } log.debug("Buffering amount: {} buffer size: {}", amount, bufferSize); // Read all remaining bytes if the requested amount reach the end of channel if (channelSize - channel.position() < amount) { amount = channelSize - channel.position(); } if (in == null) { switch (bufferType) { case HEAP: in = IoBuffer.allocate(bufferSize, false); break; case DIRECT: in = IoBuffer.allocate(bufferSize, true); break; default: in = IoBuffer.allocate(bufferSize); } channel.read(in.buf()); in.flip(); useLoadBuf = true; } if (!useLoadBuf) { return; } if (reload || in.remaining() < amount) { if (!reload) { in.compact(); } else { in.clear(); } channel.read(in.buf()); in.flip(); } } catch (Exception e) { log.error("Error fillBuffer", e); } } }
public class class_name { private void fillBuffer(long amount, boolean reload) { try { if (amount > bufferSize) { amount = bufferSize; // depends on control dependency: [if], data = [none] } log.debug("Buffering amount: {} buffer size: {}", amount, bufferSize); // depends on control dependency: [try], data = [none] // Read all remaining bytes if the requested amount reach the end of channel if (channelSize - channel.position() < amount) { amount = channelSize - channel.position(); // depends on control dependency: [if], data = [none] } if (in == null) { switch (bufferType) { case HEAP: in = IoBuffer.allocate(bufferSize, false); break; case DIRECT: in = IoBuffer.allocate(bufferSize, true); break; default: in = IoBuffer.allocate(bufferSize); } channel.read(in.buf()); // depends on control dependency: [if], data = [(in] in.flip(); // depends on control dependency: [if], data = [none] useLoadBuf = true; // depends on control dependency: [if], data = [none] } if (!useLoadBuf) { return; // depends on control dependency: [if], data = [none] } if (reload || in.remaining() < amount) { if (!reload) { in.compact(); // depends on control dependency: [if], data = [none] } else { in.clear(); // depends on control dependency: [if], data = [none] } channel.read(in.buf()); // depends on control dependency: [if], data = [none] in.flip(); // depends on control dependency: [if], data = [none] } } catch (Exception e) { log.error("Error fillBuffer", e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { static ImmutableList<VariableElement> getFieldsToParcel( TypeElement element, OptionsDescriptor options) { Optional<AnnotationMirror> paperParcelMirror = MoreElements.getAnnotationMirror(element, PaperParcel.class); if (paperParcelMirror.isPresent()) { ImmutableList.Builder<VariableElement> fields = ImmutableList.builder(); getFieldsToParcelImpl(element, options, fields, new HashSet<Name>()); return fields.build(); } else { throw new IllegalArgumentException("element must be annotated with @PaperParcel"); } } }
public class class_name { static ImmutableList<VariableElement> getFieldsToParcel( TypeElement element, OptionsDescriptor options) { Optional<AnnotationMirror> paperParcelMirror = MoreElements.getAnnotationMirror(element, PaperParcel.class); if (paperParcelMirror.isPresent()) { ImmutableList.Builder<VariableElement> fields = ImmutableList.builder(); getFieldsToParcelImpl(element, options, fields, new HashSet<Name>()); // depends on control dependency: [if], data = [none] return fields.build(); // depends on control dependency: [if], data = [none] } else { throw new IllegalArgumentException("element must be annotated with @PaperParcel"); } } }
public class class_name { private static CharSequenceMap<Integer> createMap() { int length = STATIC_TABLE.size(); @SuppressWarnings("unchecked") CharSequenceMap<Integer> ret = new CharSequenceMap<Integer>(true, UnsupportedValueConverter.<Integer>instance(), length); // Iterate through the static table in reverse order to // save the smallest index for a given name in the map. for (int index = length; index > 0; index--) { HpackHeaderField entry = getEntry(index); CharSequence name = entry.name; ret.set(name, index); } return ret; } }
public class class_name { private static CharSequenceMap<Integer> createMap() { int length = STATIC_TABLE.size(); @SuppressWarnings("unchecked") CharSequenceMap<Integer> ret = new CharSequenceMap<Integer>(true, UnsupportedValueConverter.<Integer>instance(), length); // Iterate through the static table in reverse order to // save the smallest index for a given name in the map. for (int index = length; index > 0; index--) { HpackHeaderField entry = getEntry(index); CharSequence name = entry.name; ret.set(name, index); // depends on control dependency: [for], data = [index] } return ret; } }
public class class_name { public java.util.List<DeploymentGroupInfo> getDeploymentGroupsInfo() { if (deploymentGroupsInfo == null) { deploymentGroupsInfo = new com.amazonaws.internal.SdkInternalList<DeploymentGroupInfo>(); } return deploymentGroupsInfo; } }
public class class_name { public java.util.List<DeploymentGroupInfo> getDeploymentGroupsInfo() { if (deploymentGroupsInfo == null) { deploymentGroupsInfo = new com.amazonaws.internal.SdkInternalList<DeploymentGroupInfo>(); // depends on control dependency: [if], data = [none] } return deploymentGroupsInfo; } }
public class class_name { public Set<String> getResourceNames(String path) { Set<String> resourceNames = new HashSet<String>(); String realPath = getRealResourcePath(path); if (isFileSystemPath(path, realPath)) { // The resource has been // remapped to a file system // path try { resourceNames = FileUtils.getResourceNames(new File(realPath)); } catch (InvalidPathException e) { LOGGER.warn("The path " + path + " which has been mapped to " + realPath + " doesn't exist"); } } else { resourceNames = super.getResourceNames(realPath); } return resourceNames; } }
public class class_name { public Set<String> getResourceNames(String path) { Set<String> resourceNames = new HashSet<String>(); String realPath = getRealResourcePath(path); if (isFileSystemPath(path, realPath)) { // The resource has been // remapped to a file system // path try { resourceNames = FileUtils.getResourceNames(new File(realPath)); // depends on control dependency: [try], data = [none] } catch (InvalidPathException e) { LOGGER.warn("The path " + path + " which has been mapped to " + realPath + " doesn't exist"); } // depends on control dependency: [catch], data = [none] } else { resourceNames = super.getResourceNames(realPath); // depends on control dependency: [if], data = [none] } return resourceNames; } }
public class class_name { private static Chain isKnownChain(String chainID, List<Chain> chains){ for (int i = 0; i< chains.size();i++){ Chain testchain = chains.get(i); if (chainID.equals(testchain.getName())) { return testchain; } } return null; } }
public class class_name { private static Chain isKnownChain(String chainID, List<Chain> chains){ for (int i = 0; i< chains.size();i++){ Chain testchain = chains.get(i); if (chainID.equals(testchain.getName())) { return testchain; // depends on control dependency: [if], data = [none] } } return null; } }
public class class_name { public void marshall(ListWebhookItem listWebhookItem, ProtocolMarshaller protocolMarshaller) { if (listWebhookItem == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(listWebhookItem.getDefinition(), DEFINITION_BINDING); protocolMarshaller.marshall(listWebhookItem.getUrl(), URL_BINDING); protocolMarshaller.marshall(listWebhookItem.getErrorMessage(), ERRORMESSAGE_BINDING); protocolMarshaller.marshall(listWebhookItem.getErrorCode(), ERRORCODE_BINDING); protocolMarshaller.marshall(listWebhookItem.getLastTriggered(), LASTTRIGGERED_BINDING); protocolMarshaller.marshall(listWebhookItem.getArn(), ARN_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } } }
public class class_name { public void marshall(ListWebhookItem listWebhookItem, ProtocolMarshaller protocolMarshaller) { if (listWebhookItem == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(listWebhookItem.getDefinition(), DEFINITION_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(listWebhookItem.getUrl(), URL_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(listWebhookItem.getErrorMessage(), ERRORMESSAGE_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(listWebhookItem.getErrorCode(), ERRORCODE_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(listWebhookItem.getLastTriggered(), LASTTRIGGERED_BINDING); // depends on control dependency: [try], data = [none] protocolMarshaller.marshall(listWebhookItem.getArn(), ARN_BINDING); // depends on control dependency: [try], data = [none] } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } // depends on control dependency: [catch], data = [none] } }
public class class_name { public void genImage() { if (image == null) { ImageBuffer buffer = new ImageBuffer(128,16); for (int i=0;i<128;i++) { Color col = getColorAt(i / 128.0f); for (int j=0;j<16;j++) { buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte()); } } image = buffer.getImage(); } } }
public class class_name { public void genImage() { if (image == null) { ImageBuffer buffer = new ImageBuffer(128,16); for (int i=0;i<128;i++) { Color col = getColorAt(i / 128.0f); for (int j=0;j<16;j++) { buffer.setRGBA(i, j, col.getRedByte(), col.getGreenByte(), col.getBlueByte(), col.getAlphaByte()); // depends on control dependency: [for], data = [j] } } image = buffer.getImage(); // depends on control dependency: [if], data = [none] } } }
public class class_name { private String getProp(Map<Object, Object> props, String key) { String value = (String) props.get(key); if (null == value) { value = (String) props.get(key.toLowerCase()); } return (null != value) ? value.trim() : null; } }
public class class_name { private String getProp(Map<Object, Object> props, String key) { String value = (String) props.get(key); if (null == value) { value = (String) props.get(key.toLowerCase()); // depends on control dependency: [if], data = [none] } return (null != value) ? value.trim() : null; } }
public class class_name { public SourceFile next() { if (this.isPend()) return this.getPend(); try { ZipEntry entry = m_inZip.getNextEntry(); if (entry == null) return null; // EOF String strPath = entry.getName(); String strFilename = strPath; if (strPath.lastIndexOf(gchSeparator) != -1) if (strPath.lastIndexOf(gchSeparator) + 1 < strPath.length()) strFilename = strPath.substring(strPath.lastIndexOf(gchSeparator) + 1); long lStreamLength = entry.getSize(); if (DEBUG) System.out.println("Name: " + entry.getName() + " size: " + entry.getSize()); return new StreamSourceFile(null, m_inZip, strPath, strFilename, lStreamLength); // Return the file } catch (IOException ex) { ex.printStackTrace(); } return null; // pend(don) Don't do this! } }
public class class_name { public SourceFile next() { if (this.isPend()) return this.getPend(); try { ZipEntry entry = m_inZip.getNextEntry(); if (entry == null) return null; // EOF String strPath = entry.getName(); String strFilename = strPath; if (strPath.lastIndexOf(gchSeparator) != -1) if (strPath.lastIndexOf(gchSeparator) + 1 < strPath.length()) strFilename = strPath.substring(strPath.lastIndexOf(gchSeparator) + 1); long lStreamLength = entry.getSize(); if (DEBUG) System.out.println("Name: " + entry.getName() + " size: " + entry.getSize()); return new StreamSourceFile(null, m_inZip, strPath, strFilename, lStreamLength); // Return the file // depends on control dependency: [try], data = [none] } catch (IOException ex) { ex.printStackTrace(); } // depends on control dependency: [catch], data = [none] return null; // pend(don) Don't do this! } }
public class class_name { public void handle(SetCommand setCommand) { String key = null; try { key = URLDecoder.decode(setCommand.getKey(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new HazelcastException(e); } String mapName = DEFAULT_MAP_NAME; int index = key.indexOf(':'); if (index != -1) { mapName = MAP_NAME_PREFIX + key.substring(0, index); key = key.substring(index + 1); } Object value = new MemcacheEntry(setCommand.getKey(), setCommand.getValue(), setCommand.getFlag()); int ttl = textCommandService.getAdjustedTTLSeconds(setCommand.getExpiration()); textCommandService.incrementSetCount(); if (SET == setCommand.getType()) { textCommandService.put(mapName, key, value, ttl); setCommand.setResponse(TextCommandConstants.STORED); } else if (ADD == setCommand.getType()) { addCommandType(setCommand, mapName, key, value, ttl); } else if (REPLACE == setCommand.getType()) { replaceCommandType(setCommand, mapName, key, value, ttl); } else if (APPEND == setCommand.getType()) { appendCommandType(setCommand, mapName, key, ttl); } else if (PREPEND == setCommand.getType()) { prependCommandType(setCommand, mapName, key, ttl); } if (setCommand.shouldReply()) { textCommandService.sendResponse(setCommand); } } }
public class class_name { public void handle(SetCommand setCommand) { String key = null; try { key = URLDecoder.decode(setCommand.getKey(), "UTF-8"); // depends on control dependency: [try], data = [none] } catch (UnsupportedEncodingException e) { throw new HazelcastException(e); } // depends on control dependency: [catch], data = [none] String mapName = DEFAULT_MAP_NAME; int index = key.indexOf(':'); if (index != -1) { mapName = MAP_NAME_PREFIX + key.substring(0, index); // depends on control dependency: [if], data = [none] key = key.substring(index + 1); // depends on control dependency: [if], data = [(index] } Object value = new MemcacheEntry(setCommand.getKey(), setCommand.getValue(), setCommand.getFlag()); int ttl = textCommandService.getAdjustedTTLSeconds(setCommand.getExpiration()); textCommandService.incrementSetCount(); if (SET == setCommand.getType()) { textCommandService.put(mapName, key, value, ttl); // depends on control dependency: [if], data = [none] setCommand.setResponse(TextCommandConstants.STORED); // depends on control dependency: [if], data = [none] } else if (ADD == setCommand.getType()) { addCommandType(setCommand, mapName, key, value, ttl); // depends on control dependency: [if], data = [none] } else if (REPLACE == setCommand.getType()) { replaceCommandType(setCommand, mapName, key, value, ttl); // depends on control dependency: [if], data = [none] } else if (APPEND == setCommand.getType()) { appendCommandType(setCommand, mapName, key, ttl); // depends on control dependency: [if], data = [none] } else if (PREPEND == setCommand.getType()) { prependCommandType(setCommand, mapName, key, ttl); // depends on control dependency: [if], data = [none] } if (setCommand.shouldReply()) { textCommandService.sendResponse(setCommand); // depends on control dependency: [if], data = [none] } } }
public class class_name { java.util.regex.Pattern getPattern( @Nonnull AnnotationValue<?> annotationMetadata, boolean isOptional) { final Optional<String> regexp = annotationMetadata.get("regexp", String.class); final String pattern; if (isOptional) { pattern = regexp.orElse(".*"); } else { pattern = regexp .orElseThrow(() -> new ValidationException("No pattern specified")); } final Pattern.Flag[] flags = annotationMetadata.get("flags", Pattern.Flag[].class).orElse(ZERO_FLAGS); if (isOptional && pattern.equals(".*") && flags.length == 0) { return null; } int computedFlag = 0; for (Pattern.Flag flag : flags) { computedFlag = computedFlag | flag.getValue(); } final PatternKey key = new PatternKey(pattern, computedFlag); java.util.regex.Pattern regex = COMPUTED_PATTERNS.get(key); if (regex == null) { try { if (computedFlag != 0) { regex = java.util.regex.Pattern.compile(pattern, computedFlag); } else { regex = java.util.regex.Pattern.compile(pattern); } } catch (PatternSyntaxException e) { throw new IllegalArgumentException("Invalid regular expression", e); } COMPUTED_PATTERNS.put(key, regex); } return regex; } }
public class class_name { java.util.regex.Pattern getPattern( @Nonnull AnnotationValue<?> annotationMetadata, boolean isOptional) { final Optional<String> regexp = annotationMetadata.get("regexp", String.class); final String pattern; if (isOptional) { pattern = regexp.orElse(".*"); // depends on control dependency: [if], data = [none] } else { pattern = regexp .orElseThrow(() -> new ValidationException("No pattern specified")); // depends on control dependency: [if], data = [none] } final Pattern.Flag[] flags = annotationMetadata.get("flags", Pattern.Flag[].class).orElse(ZERO_FLAGS); if (isOptional && pattern.equals(".*") && flags.length == 0) { return null; // depends on control dependency: [if], data = [none] } int computedFlag = 0; for (Pattern.Flag flag : flags) { computedFlag = computedFlag | flag.getValue(); // depends on control dependency: [for], data = [flag] } final PatternKey key = new PatternKey(pattern, computedFlag); java.util.regex.Pattern regex = COMPUTED_PATTERNS.get(key); if (regex == null) { try { if (computedFlag != 0) { regex = java.util.regex.Pattern.compile(pattern, computedFlag); // depends on control dependency: [if], data = [none] } else { regex = java.util.regex.Pattern.compile(pattern); // depends on control dependency: [if], data = [none] } } catch (PatternSyntaxException e) { throw new IllegalArgumentException("Invalid regular expression", e); } // depends on control dependency: [catch], data = [none] COMPUTED_PATTERNS.put(key, regex); // depends on control dependency: [if], data = [none] } return regex; } }
public class class_name { public void removeListener(EnvLoaderListener listener) { super.removeListener(listener); ArrayList<EnvLoaderListener> listeners = _listeners; if (_listeners == null) return; synchronized (listeners) { for (int i = listeners.size() - 1; i >= 0; i--) { EnvLoaderListener oldListener = listeners.get(i); if (listener == oldListener) { listeners.remove(i); return; } else if (oldListener == null) { listeners.remove(i); } } } } }
public class class_name { public void removeListener(EnvLoaderListener listener) { super.removeListener(listener); ArrayList<EnvLoaderListener> listeners = _listeners; if (_listeners == null) return; synchronized (listeners) { for (int i = listeners.size() - 1; i >= 0; i--) { EnvLoaderListener oldListener = listeners.get(i); if (listener == oldListener) { listeners.remove(i); // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } else if (oldListener == null) { listeners.remove(i); // depends on control dependency: [if], data = [none] } } } } }
public class class_name { public void setReplicationRunList(java.util.Collection<ReplicationRun> replicationRunList) { if (replicationRunList == null) { this.replicationRunList = null; return; } this.replicationRunList = new java.util.ArrayList<ReplicationRun>(replicationRunList); } }
public class class_name { public void setReplicationRunList(java.util.Collection<ReplicationRun> replicationRunList) { if (replicationRunList == null) { this.replicationRunList = null; // depends on control dependency: [if], data = [none] return; // depends on control dependency: [if], data = [none] } this.replicationRunList = new java.util.ArrayList<ReplicationRun>(replicationRunList); } }
public class class_name { public void purge(int gcBefore) { topLevel = topLevel.localDeletionTime < gcBefore ? DeletionTime.LIVE : topLevel; if (ranges != null) { ranges.purge(gcBefore); if (ranges.isEmpty()) ranges = null; } } }
public class class_name { public void purge(int gcBefore) { topLevel = topLevel.localDeletionTime < gcBefore ? DeletionTime.LIVE : topLevel; if (ranges != null) { ranges.purge(gcBefore); // depends on control dependency: [if], data = [none] if (ranges.isEmpty()) ranges = null; } } }
public class class_name { private void grow(int neededSize) { if (neededSize > ARRAY_MAX - totalSize()) { throw new UnsupportedOperationException( "Cannot grow internal buffer by size " + neededSize + " because the size after growing " + "exceeds size limitation " + ARRAY_MAX); } final int length = totalSize() + neededSize; if (buffer.length < length) { int newLength = length < ARRAY_MAX / 2 ? length * 2 : ARRAY_MAX; final byte[] tmp = new byte[newLength]; Platform.copyMemory( buffer, Platform.BYTE_ARRAY_OFFSET, tmp, Platform.BYTE_ARRAY_OFFSET, totalSize()); buffer = tmp; } } }
public class class_name { private void grow(int neededSize) { if (neededSize > ARRAY_MAX - totalSize()) { throw new UnsupportedOperationException( "Cannot grow internal buffer by size " + neededSize + " because the size after growing " + "exceeds size limitation " + ARRAY_MAX); } final int length = totalSize() + neededSize; if (buffer.length < length) { int newLength = length < ARRAY_MAX / 2 ? length * 2 : ARRAY_MAX; final byte[] tmp = new byte[newLength]; Platform.copyMemory( buffer, Platform.BYTE_ARRAY_OFFSET, tmp, Platform.BYTE_ARRAY_OFFSET, totalSize()); // depends on control dependency: [if], data = [none] buffer = tmp; // depends on control dependency: [if], data = [none] } } }
public class class_name { public static void createWordNetCaches(String componentKey, Properties properties) throws SMatchException { properties = getComponentProperties(makeComponentPrefix(componentKey, InMemoryWordNetBinaryArray.class.getSimpleName()), properties); if (properties.containsKey(JWNL_PROPERTIES_PATH_KEY)) { // initialize JWNL (this must be done before JWNL library can be used) try { final String configPath = properties.getProperty(JWNL_PROPERTIES_PATH_KEY); log.info("Initializing JWNL from " + configPath); JWNL.initialize(new FileInputStream(configPath)); } catch (JWNLException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new SMatchException(errMessage, e); } catch (FileNotFoundException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new SMatchException(errMessage, e); } } else { final String errMessage = "Cannot find configuration key " + JWNL_PROPERTIES_PATH_KEY; log.error(errMessage); throw new SMatchException(errMessage); } log.info("Creating WordNet caches..."); writeNominalizations(properties); writeSynonymsAdj(properties); writeOppAdverbs(properties); writeOppAdjectives(properties); writeOppNouns(properties); writeNounMG(properties); writeVerbMG(properties); log.info("Done"); } }
public class class_name { public static void createWordNetCaches(String componentKey, Properties properties) throws SMatchException { properties = getComponentProperties(makeComponentPrefix(componentKey, InMemoryWordNetBinaryArray.class.getSimpleName()), properties); if (properties.containsKey(JWNL_PROPERTIES_PATH_KEY)) { // initialize JWNL (this must be done before JWNL library can be used) try { final String configPath = properties.getProperty(JWNL_PROPERTIES_PATH_KEY); log.info("Initializing JWNL from " + configPath); // depends on control dependency: [try], data = [none] JWNL.initialize(new FileInputStream(configPath)); // depends on control dependency: [try], data = [none] } catch (JWNLException e) { final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new SMatchException(errMessage, e); } catch (FileNotFoundException e) { // depends on control dependency: [catch], data = [none] final String errMessage = e.getClass().getSimpleName() + ": " + e.getMessage(); log.error(errMessage, e); throw new SMatchException(errMessage, e); } // depends on control dependency: [catch], data = [none] } else { final String errMessage = "Cannot find configuration key " + JWNL_PROPERTIES_PATH_KEY; log.error(errMessage); throw new SMatchException(errMessage); } log.info("Creating WordNet caches..."); writeNominalizations(properties); writeSynonymsAdj(properties); writeOppAdverbs(properties); writeOppAdjectives(properties); writeOppNouns(properties); writeNounMG(properties); writeVerbMG(properties); log.info("Done"); } }
public class class_name { @Override protected double computeCost( final DataSegment proposalSegment, final ServerHolder server, final boolean includeCurrentServer ) { double cost = super.computeCost(proposalSegment, server, includeCurrentServer); if (cost == Double.POSITIVE_INFINITY) { return cost; } int nSegments = 1; if (server.getServer().getLazyAllSegments().size() > 0) { nSegments = server.getServer().getLazyAllSegments().size(); } double normalizedCost = cost / nSegments; double usageRatio = (double) server.getSizeUsed() / (double) server.getServer().getMaxSize(); return normalizedCost * usageRatio; } }
public class class_name { @Override protected double computeCost( final DataSegment proposalSegment, final ServerHolder server, final boolean includeCurrentServer ) { double cost = super.computeCost(proposalSegment, server, includeCurrentServer); if (cost == Double.POSITIVE_INFINITY) { return cost; // depends on control dependency: [if], data = [none] } int nSegments = 1; if (server.getServer().getLazyAllSegments().size() > 0) { nSegments = server.getServer().getLazyAllSegments().size(); // depends on control dependency: [if], data = [none] } double normalizedCost = cost / nSegments; double usageRatio = (double) server.getSizeUsed() / (double) server.getServer().getMaxSize(); return normalizedCost * usageRatio; } }
public class class_name { public boolean checkChangeForGroup(final String uri, final String groupName) throws IOException { notNull(uri); notNull(groupName); LOG.debug("group={}, uri={}", groupName, uri); final ResourceChangeInfo resourceInfo = changeInfoMap.get(uri); if (resourceInfo.isCheckRequiredForGroup(groupName)) { final InputStream inputStream = locatorFactory.locate(uri); try{ final String currentHash = hashStrategy.getHash(inputStream); resourceInfo.updateHashForGroup(currentHash, groupName); }finally{ IOUtils.closeQuietly(inputStream); } } return resourceInfo.isChanged(groupName); } }
public class class_name { public boolean checkChangeForGroup(final String uri, final String groupName) throws IOException { notNull(uri); notNull(groupName); LOG.debug("group={}, uri={}", groupName, uri); final ResourceChangeInfo resourceInfo = changeInfoMap.get(uri); if (resourceInfo.isCheckRequiredForGroup(groupName)) { final InputStream inputStream = locatorFactory.locate(uri); try{ final String currentHash = hashStrategy.getHash(inputStream); resourceInfo.updateHashForGroup(currentHash, groupName); // depends on control dependency: [try], data = [none] }finally{ IOUtils.closeQuietly(inputStream); } } return resourceInfo.isChanged(groupName); } }
public class class_name { @SuppressWarnings("unchecked") public static <T> T methodToFunctionInterface(Method method, Object target, Class<T> functionInterfaceClass, Class<?>... explicitGenericTypes) { Method functionMethod = getFunctionInterfaceMethod(functionInterfaceClass); if (functionMethod == null) { return null; } if (functionMethod.getParameterCount() != method.getParameterCount()) { return null; } // Map the explicit type Map<TypeVariable<?>, Class<?>> explicitTypeMap = new HashMap<>(); TypeVariable<Class<T>>[] typeParameters = functionInterfaceClass.getTypeParameters(); if (explicitGenericTypes.length > typeParameters.length) { throw new IllegalArgumentException("The explicit generic types are too many. Expect " + typeParameters.length); } for (int i = 0; i < explicitGenericTypes.length; i++) { explicitTypeMap.put(typeParameters[i], toWrapper(explicitGenericTypes[i])); } // Map the generic reference Map<TypeVariable<?>, Type> typeVariableReference = GenericUtil.getGenericReferenceMap(functionInterfaceClass); Function<TypeVariable<?>, Class<?>> getActualTypeVariable = tv -> { Type next; while (true) { next = typeVariableReference.get(tv); if (next == null) { return explicitTypeMap.get(tv); } if (next instanceof Class<?>) { return (Class<?>) next; } tv = (TypeVariable<?>) next; } }; // Resolve return type Class<?> returnType = toWrapper(method.getReturnType()); Type functionGenericReturnType = functionMethod.getGenericReturnType(); if (functionGenericReturnType instanceof ParameterizedType) { // TODO handle and match ParameterizedType functionGenericReturnType = ((ParameterizedType) functionGenericReturnType).getRawType(); } if (returnType == void.class && functionGenericReturnType == void.class) { } else if (functionGenericReturnType instanceof Class) { if (!toWrapper((Class<?>) functionGenericReturnType).isAssignableFrom(returnType)) { return null; } } else if (functionGenericReturnType instanceof TypeVariable) { TypeVariable<?> tv = (TypeVariable<?>) functionGenericReturnType; Class<?> explicitType = getActualTypeVariable.apply(tv); if (explicitType != null) { if (!explicitType.equals(returnType)) { return null; } } else if (FunctionInterfaceUtil.matchTypeBounds(returnType, tv)) { explicitTypeMap.put(tv, returnType); } else { return null; } } else { LOG.warn().log("Can't handle GenericReturnType: {} with type {}", functionGenericReturnType, functionGenericReturnType.getClass()); return null; } // Resolve parameters Type[] functionParams = functionMethod.getGenericParameterTypes(); Class<?>[] params = method.getParameterTypes(); for (int i = 0; i < params.length; i++) { Type functionParamType = functionParams[i]; Class<?> paramType = toWrapper(params[i]); if (functionParamType instanceof ParameterizedType) { // TODO handle and match ParameterizedType functionParamType = ((ParameterizedType) functionParamType).getRawType(); } if (functionParamType instanceof Class) { if (!paramType.isAssignableFrom( toWrapper((Class<?>) functionParamType))) { return null; } } else if (functionParamType instanceof TypeVariable) { TypeVariable<?> tv = (TypeVariable<?>) functionParamType; Class<?> explicitType = getActualTypeVariable.apply(tv); if (explicitType != null) { if (!explicitType.equals(paramType)) { return null; } } else if (FunctionInterfaceUtil.matchTypeBounds(paramType, tv)) { explicitTypeMap.put(tv, paramType); } else { return null; } } else { LOG.warn().log("Can't handle GenericParameterType: {} with type {}", paramType, paramType.getClass()); return null; } } // Resolve throws List<Type> functionExceptionTypes = Arrays.asList(functionMethod.getGenericExceptionTypes()); for (Class<?> exceptionType : method.getExceptionTypes()) { if (Exception.class.isAssignableFrom(exceptionType) && !RuntimeException.class.isAssignableFrom(exceptionType) && !functionExceptionTypes.stream().anyMatch( functionThrowType -> { Class<?> functionThrowClass = null; if (functionThrowType instanceof Class) { functionThrowClass = (Class<?>) functionThrowType; } else if (functionThrowType instanceof TypeVariable) { Class<?> explicitType = explicitTypeMap.get(functionThrowType); if (explicitType == null) { return FunctionInterfaceUtil.matchTypeBounds(exceptionType, (TypeVariable<?>) functionThrowType); } else { functionThrowClass = explicitType; } } else { LOG.warn().log("Can't handle GenericException: {} with type {}", functionThrowType, functionThrowType.getClass()); return false; } return functionThrowClass.isAssignableFrom(exceptionType); })) { return null; } } return (T) Proxy.newProxyInstance( functionInterfaceClass.getClassLoader(), new Class[] { functionInterfaceClass }, (obj, m, args) -> { if (m.equals(functionMethod)) { return method.invoke(target, args); } Class<?> declaringClass = m.getDeclaringClass(); if (m.isDefault() || declaringClass.equals(Object.class)) { Object result; Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class.getDeclaredConstructor( Class.class, int.class); constructor.setAccessible(true); result = constructor .newInstance(declaringClass, MethodHandles.Lookup.PRIVATE) .unreflectSpecial(m, declaringClass) .bindTo(obj) .invokeWithArguments(args); return (result); } return m.invoke(obj, args); }); } }
public class class_name { @SuppressWarnings("unchecked") public static <T> T methodToFunctionInterface(Method method, Object target, Class<T> functionInterfaceClass, Class<?>... explicitGenericTypes) { Method functionMethod = getFunctionInterfaceMethod(functionInterfaceClass); if (functionMethod == null) { return null; // depends on control dependency: [if], data = [none] } if (functionMethod.getParameterCount() != method.getParameterCount()) { return null; // depends on control dependency: [if], data = [none] } // Map the explicit type Map<TypeVariable<?>, Class<?>> explicitTypeMap = new HashMap<>(); TypeVariable<Class<T>>[] typeParameters = functionInterfaceClass.getTypeParameters(); if (explicitGenericTypes.length > typeParameters.length) { throw new IllegalArgumentException("The explicit generic types are too many. Expect " + typeParameters.length); } for (int i = 0; i < explicitGenericTypes.length; i++) { explicitTypeMap.put(typeParameters[i], toWrapper(explicitGenericTypes[i])); // depends on control dependency: [for], data = [i] } // Map the generic reference Map<TypeVariable<?>, Type> typeVariableReference = GenericUtil.getGenericReferenceMap(functionInterfaceClass); Function<TypeVariable<?>, Class<?>> getActualTypeVariable = tv -> { Type next; while (true) { next = typeVariableReference.get(tv); // depends on control dependency: [while], data = [none] if (next == null) { return explicitTypeMap.get(tv); // depends on control dependency: [if], data = [none] } if (next instanceof Class<?>) { return (Class<?>) next; // depends on control dependency: [if], data = [)] } tv = (TypeVariable<?>) next; // depends on control dependency: [while], data = [none] } }; // Resolve return type Class<?> returnType = toWrapper(method.getReturnType()); Type functionGenericReturnType = functionMethod.getGenericReturnType(); if (functionGenericReturnType instanceof ParameterizedType) { // TODO handle and match ParameterizedType functionGenericReturnType = ((ParameterizedType) functionGenericReturnType).getRawType(); // depends on control dependency: [if], data = [none] } if (returnType == void.class && functionGenericReturnType == void.class) { } else if (functionGenericReturnType instanceof Class) { if (!toWrapper((Class<?>) functionGenericReturnType).isAssignableFrom(returnType)) { return null; // depends on control dependency: [if], data = [none] } } else if (functionGenericReturnType instanceof TypeVariable) { TypeVariable<?> tv = (TypeVariable<?>) functionGenericReturnType; Class<?> explicitType = getActualTypeVariable.apply(tv); if (explicitType != null) { if (!explicitType.equals(returnType)) { return null; // depends on control dependency: [if], data = [none] } } else if (FunctionInterfaceUtil.matchTypeBounds(returnType, tv)) { explicitTypeMap.put(tv, returnType); // depends on control dependency: [if], data = [none] } else { return null; // depends on control dependency: [if], data = [none] } } else { LOG.warn().log("Can't handle GenericReturnType: {} with type {}", functionGenericReturnType, functionGenericReturnType.getClass()); return null; } // Resolve parameters Type[] functionParams = functionMethod.getGenericParameterTypes(); Class<?>[] params = method.getParameterTypes(); for (int i = 0; i < params.length; i++) { Type functionParamType = functionParams[i]; Class<?> paramType = toWrapper(params[i]); if (functionParamType instanceof ParameterizedType) { // TODO handle and match ParameterizedType functionParamType = ((ParameterizedType) functionParamType).getRawType(); } if (functionParamType instanceof Class) { if (!paramType.isAssignableFrom( toWrapper((Class<?>) functionParamType))) { return null; } } else if (functionParamType instanceof TypeVariable) { TypeVariable<?> tv = (TypeVariable<?>) functionParamType; Class<?> explicitType = getActualTypeVariable.apply(tv); if (explicitType != null) { if (!explicitType.equals(paramType)) { return null; } } else if (FunctionInterfaceUtil.matchTypeBounds(paramType, tv)) { explicitTypeMap.put(tv, paramType); } else { return null; } } else { LOG.warn().log("Can't handle GenericParameterType: {} with type {}", paramType, paramType.getClass()); // depends on control dependency: [if], data = [none] return null; // depends on control dependency: [if], data = [none] } } // Resolve throws List<Type> functionExceptionTypes = Arrays.asList(functionMethod.getGenericExceptionTypes()); for (Class<?> exceptionType : method.getExceptionTypes()) { if (Exception.class.isAssignableFrom(exceptionType) && !RuntimeException.class.isAssignableFrom(exceptionType) && !functionExceptionTypes.stream().anyMatch( functionThrowType -> { Class<?> functionThrowClass = null; if (functionThrowType instanceof Class) { functionThrowClass = (Class<?>) functionThrowType; } else if (functionThrowType instanceof TypeVariable) { Class<?> explicitType = explicitTypeMap.get(functionThrowType); if (explicitType == null) { return FunctionInterfaceUtil.matchTypeBounds(exceptionType, (TypeVariable<?>) functionThrowType); // depends on control dependency: [if], data = [none] } else { functionThrowClass = explicitType; // depends on control dependency: [if], data = [none] } } else { LOG.warn().log("Can't handle GenericException: {} with type {}", functionThrowType, functionThrowType.getClass()); return false; } return functionThrowClass.isAssignableFrom(exceptionType); })) { return null; } } return (T) Proxy.newProxyInstance( functionInterfaceClass.getClassLoader(), new Class[] { functionInterfaceClass }, (obj, m, args) -> { if (m.equals(functionMethod)) { return method.invoke(target, args); } Class<?> declaringClass = m.getDeclaringClass(); if (m.isDefault() || declaringClass.equals(Object.class)) { Object result; Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class.getDeclaredConstructor( Class.class, int.class); constructor.setAccessible(true); result = constructor .newInstance(declaringClass, MethodHandles.Lookup.PRIVATE) .unreflectSpecial(m, declaringClass) .bindTo(obj) .invokeWithArguments(args); return (result); } return m.invoke(obj, args); }); } }
public class class_name { public long blockPoll(final BlockHandler blockHandler, final int blockLengthLimit) { long bytesConsumed = 0; for (final Image image : images) { bytesConsumed += image.blockPoll(blockHandler, blockLengthLimit); } return bytesConsumed; } }
public class class_name { public long blockPoll(final BlockHandler blockHandler, final int blockLengthLimit) { long bytesConsumed = 0; for (final Image image : images) { bytesConsumed += image.blockPoll(blockHandler, blockLengthLimit); // depends on control dependency: [for], data = [image] } return bytesConsumed; } }
public class class_name { public OutlierResult run(Relation<V> relation) { SimilarityQuery<V> snnInstance = similarityFunction.instantiate(relation); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress("Assigning Subspace Outlier Degree", relation.size(), LOG) : null; WritableDoubleDataStore sod_scores = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_STATIC); WritableDataStore<SODModel> sod_models = models ? DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_STATIC, SODModel.class) : null; DoubleMinMax minmax = new DoubleMinMax(); for(DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { DBIDs neighborhood = getNearestNeighbors(relation, snnInstance, iter); double[] center; long[] weightVector = null; double sod = 0.; if(neighborhood.size() > 0) { center = Centroid.make(relation, neighborhood).getArrayRef(); // Note: per-dimension variances; no covariances. double[] variances = computePerDimensionVariances(relation, center, neighborhood); double expectationOfVariance = Mean.of(variances); weightVector = BitsUtil.zero(variances.length); for(int d = 0; d < variances.length; d++) { if(variances[d] < alpha * expectationOfVariance) { BitsUtil.setI(weightVector, d); } } sod = subspaceOutlierDegree(relation.get(iter), center, weightVector); } else { center = relation.get(iter).toArray(); } if(sod_models != null) { sod_models.put(iter, new SODModel(center, weightVector)); } sod_scores.putDouble(iter, sod); minmax.put(sod); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); // combine results. OutlierScoreMeta meta = new BasicOutlierScoreMeta(minmax.getMin(), minmax.getMax()); OutlierResult sodResult = new OutlierResult(meta, new MaterializedDoubleRelation("Subspace Outlier Degree", "sod-outlier", sod_scores, relation.getDBIDs())); if(sod_models != null) { sodResult.addChildResult(new MaterializedRelation<>("Subspace Outlier Model", "sod-outlier", new SimpleTypeInformation<>(SODModel.class), sod_models, relation.getDBIDs())); } return sodResult; } }
public class class_name { public OutlierResult run(Relation<V> relation) { SimilarityQuery<V> snnInstance = similarityFunction.instantiate(relation); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress("Assigning Subspace Outlier Degree", relation.size(), LOG) : null; WritableDoubleDataStore sod_scores = DataStoreUtil.makeDoubleStorage(relation.getDBIDs(), DataStoreFactory.HINT_STATIC); WritableDataStore<SODModel> sod_models = models ? DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_STATIC, SODModel.class) : null; DoubleMinMax minmax = new DoubleMinMax(); for(DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { DBIDs neighborhood = getNearestNeighbors(relation, snnInstance, iter); double[] center; long[] weightVector = null; double sod = 0.; if(neighborhood.size() > 0) { center = Centroid.make(relation, neighborhood).getArrayRef(); // depends on control dependency: [if], data = [none] // Note: per-dimension variances; no covariances. double[] variances = computePerDimensionVariances(relation, center, neighborhood); double expectationOfVariance = Mean.of(variances); weightVector = BitsUtil.zero(variances.length); // depends on control dependency: [if], data = [none] for(int d = 0; d < variances.length; d++) { if(variances[d] < alpha * expectationOfVariance) { BitsUtil.setI(weightVector, d); // depends on control dependency: [if], data = [none] } } sod = subspaceOutlierDegree(relation.get(iter), center, weightVector); // depends on control dependency: [if], data = [none] } else { center = relation.get(iter).toArray(); // depends on control dependency: [if], data = [none] } if(sod_models != null) { sod_models.put(iter, new SODModel(center, weightVector)); // depends on control dependency: [if], data = [none] } sod_scores.putDouble(iter, sod); // depends on control dependency: [for], data = [iter] minmax.put(sod); // depends on control dependency: [for], data = [none] LOG.incrementProcessed(progress); // depends on control dependency: [for], data = [none] } LOG.ensureCompleted(progress); // combine results. OutlierScoreMeta meta = new BasicOutlierScoreMeta(minmax.getMin(), minmax.getMax()); OutlierResult sodResult = new OutlierResult(meta, new MaterializedDoubleRelation("Subspace Outlier Degree", "sod-outlier", sod_scores, relation.getDBIDs())); if(sod_models != null) { sodResult.addChildResult(new MaterializedRelation<>("Subspace Outlier Model", "sod-outlier", new SimpleTypeInformation<>(SODModel.class), sod_models, relation.getDBIDs())); } return sodResult; } }