code
stringlengths
73
34.1k
label
stringclasses
1 value
private void addToArray(JsonNode j) { if (j instanceof ArrayNode) { for (Iterator<JsonNode> itr = ((ArrayNode) j).elements(); itr.hasNext();) { addToArray(itr.next()); } } else { ((ArrayNode) node).add(j); } }
java
public int getFeaturePosition(AbstractFeature feature) { AbstractFeature result = feature; if (!featurePositions.containsKey(feature)) { if (feature instanceof FeatureGroup) { FeatureGroup featureGroup = (FeatureGroup) feature; List<Feature> features = feature...
java
public List<Product> getSortedProducts() { ArrayList<Product> result = new ArrayList<>(pcm.getProducts()); Collections.sort(result, new Comparator<Product>() { @Override public int compare(Product o1, Product o2) { Integer op1 = getProductPosition(o1); ...
java
public List<Feature> getSortedFeatures() { ArrayList<Feature> result = new ArrayList<>(pcm.getConcreteFeatures()); Collections.sort(result, new Comparator<Feature>() { @Override public int compare(Feature f1, Feature f2) { Integer fp1 = getFeaturePosition(f1); ...
java
public FacetBuilder setItemsList(Map<String, String> items) { ArrayList<FacetWidgetItem> facetWidgetItems = new ArrayList<FacetWidgetItem>(); for (String key : items.keySet()){ String label = items.get(key); FacetWidgetItem facetWidgetItem = new FacetWidgetItem(key, label); ...
java
public void updateRuleBasicInfo(ValidationRule rule) { this.orderIdx = rule.orderIdx; this.parentDependency = rule.parentDependency; this.standardValueType = rule.standardValueType; this.validationCheck = rule.validationCheck; this.overlapBanRuleName = rule.overlapBanRuleName; ...
java
public boolean isUse() { if (!this.use) { return this.use; } return !(this.standardValueType != null && !this.standardValueType.equals(StandardValueType.NONE) && this.standardValue == null); }
java
public boolean isUsedMyRule(ValidationData item) { List<ValidationRule> usedRules = item.getValidationRules(); if (usedRules == null || usedRules.isEmpty()) { return false; } return usedRules.stream().filter(ur -> ur.getRuleName().equals(this.ruleName) && ur.isUse()).findAny(...
java
public List<ValidationData> filter(List<ValidationData> allList) { return allList.stream().filter(vd -> this.isUsedMyRule(vd)).collect(Collectors.toList()); }
java
public void updateMethodKey() { Arrays.stream(ParamType.values()).forEach(paramType -> this.syncMethodKey(paramType)); this.validationDataRepository.flush(); this.validationStore.refresh(); log.info("[METHOD_KEY_SYNC] Complete"); }
java
public void setSelected(String s) { for (int i = 0; i < listBox.getItemCount(); i++) { if (listBox.getItemText(i).equals(s)) listBox.setSelectedIndex(i); } }
java
public Panel draw(TemplateViewNodesConfig config, RecordList recordList){ // setup basic layout // has a reference to builders from plot to do rest of the plots final TemplateViewNodesConfig.TemplateNode rootTemplateNode = config.getRootTemplateNode(); if(rootTemplateNode == null){ ...
java
private VerticalPanel fixedWidthAndHeightPanel() { final VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.setHeight("300px"); verticalPanel.setWidth("500px"); return verticalPanel; }
java
protected void initNewThread(Path monitoredFile, CountDownLatch start, CountDownLatch stop) throws IOException { final Runnable watcher = initializeWatcherWithDirectory(monitoredFile, start, stop); final Thread thread = new Thread(watcher); thread.setDaemon(false); thread.start(); }
java
public void initSynchronous(Path monitoredFile) throws IOException { final Runnable watcher = initializeWatcherWithDirectory(monitoredFile, new CountDownLatch(1), new CountDownLatch(1)); watcher.run(); }
java
protected static void registerGraphiteMetricObserver(List<MetricObserver> observers, String prefix, String host, String port) { // verify at least hostname is set, else cannot configure this observer if (null == host || host.trim().isEmpty()) { LOGGER.info("GraphiteMetricObserver not configu...
java
protected static void registerStatsdMetricObserver(List<MetricObserver> observers, String prefix, String host, String port) { // verify at least hostname is set, else cannot configure this observer if (null == host || host.trim().isEmpty()) { LOGGER.info("StatdsMetricObserver not configured,...
java
private static String findVariable(String key) { String value = System.getProperty(key); if (value == null) { return System.getenv(key); } return value; }
java
public void addOverrideMap(Map<String, String> overrideMap) { if (sealed) { throw new IllegalStateException("Instance is sealed."); } for (Map.Entry<String, String> entry : overrideMap.entrySet()) { try { ParameterOverrideInfo info = new ParameterOverrideInfo(entry.getKey()); if ...
java
public void seal() { lockedParameterNamesSet = ImmutableSet.copyOf(lockedParameterNamesSet); lockedParameterNamesScopeMap = ImmutableMap.copyOf(Maps.transformValues(lockedParameterNamesScopeMap, new Function<Set<String>, Set<String>>() { @Override public Set<String> apply(Set<String> input) { ...
java
public String getOverrideForce(String configurationId, String parameterName) { Map<String, String> overrideForceScopeMapEntry = overrideForceScopeMap.get(configurationId); if (overrideForceScopeMapEntry != null) { return overrideForceScopeMapEntry.get(parameterName); } return null; }
java
public Set<String> getLockedParameterNames(String configurationId) { Set<String> lockedParameterNamesScopeMapEntry = lockedParameterNamesScopeMap.get(configurationId); if (lockedParameterNamesScopeMapEntry != null) { return lockedParameterNamesScopeMapEntry; } else { return ImmutableSet.of()...
java
@GetMapping("/setting/download/api/json/all") public void downloadApiJsonAll(HttpServletRequest req, HttpServletResponse res) { this.validationSessionComponent.sessionCheck(req); List<ValidationData> list = this.msgSettingService.getAllValidationData(); ValidationFileUtil.sendFileToHttpServi...
java
@GetMapping("/setting/download/api/json") public void downloadApiJson(HttpServletRequest req, @RequestParam("method") String method, @RequestParam("url") String url, HttpServletResponse res) { this.validationSessionComponent.sessionCheck(req); url = new String(Base64.getDecoder().decode(url)); ...
java
@GetMapping("/setting/download/api/excel/all") public void downloadApiAll(HttpServletRequest req, HttpServletResponse res) { this.validationSessionComponent.sessionCheck(req); PoiWorkBook workBook = this.msgExcelService.getAllExcels(); workBook.writeFile("ValidationApis_" + System.currentTim...
java
@GetMapping("/setting/download/api/excel") public void downloadApi(HttpServletRequest req, @RequestParam("method") String method, @RequestParam("url") String url, HttpServletResponse res) { this.validationSessionComponent.sessionCheck(req); url = new String(Base64.getDecoder().decode(url)); ...
java
@PostMapping("/setting/upload/json") public void uploadSetting(HttpServletRequest req) { this.validationSessionComponent.sessionCheck(req); this.msgSettingService.updateValidationData((MultipartHttpServletRequest) req); }
java
@GetMapping("/setting/url/list/all") public List<ReqUrl> reqUrlAllList(HttpServletRequest req) { this.validationSessionComponent.sessionCheck(req); return this.msgSettingService.getAllUrlList(); }
java
@GetMapping("/setting/param/from/url") public List<ValidationData> getValidationDataLists(HttpServletRequest req) { this.validationSessionComponent.sessionCheck(req); ValidationData data = ParameterMapper.requestParamaterToObject(req, ValidationData.class, "UTF-8"); return this.msgSettingSer...
java
private int transactionToIndex(T t) { Integer r = allTransactions.absoluteIndexOf(t); return r == null ? -1 : r.intValue(); }
java
private int itemToIndex(I i) { Integer r = allItems.absoluteIndexOf(i); return r == null ? -1 : r.intValue(); }
java
public boolean add(T transaction, I item) { return matrix.add(transactionToIndex(transaction), itemToIndex(item)); }
java
public boolean contains(T transaction, I item) { int t = transactionToIndex(transaction); if (t < 0) return false; int i = itemToIndex(item); if (i < 0) return false; return matrix.contains(t, i); }
java
public boolean remove(T transaction, I item) { return matrix.remove(transactionToIndex(transaction), itemToIndex(item)); }
java
public boolean removeAll(Collection<T> trans, Collection<I> items) { if (trans == null || trans.isEmpty() || items == null || items.isEmpty()) return false; return matrix.removeAll(allTransactions.convert(trans).indices(), allItems.convert(items).indices()); }
java
public boolean retainAll(Collection<T> trans, I item) { if (isEmpty()) return false; if (trans == null || trans.isEmpty() || item == null) { clear(); return true; } return matrix.retainAll(allTransactions.convert(trans).indices(), itemToIndex(item)); }
java
public IndexedSet<I> itemsOf(T transaction) { IndexedSet<I> res = allItems.empty(); res.indices().addAll(matrix.getRow(transactionToIndex(transaction))); return res; }
java
public IndexedSet<T> transactionsOf(I item) { IndexedSet<T> res = allTransactions.empty(); res.indices().addAll(matrix.getCol(itemToIndex(item))); return res; }
java
private List<File> unTar(final File inputFile, final File outputDir) throws FileNotFoundException, IOException, ArchiveException { _log.info(String.format("Untaring %s to dir %s.", inputFile.getAbsolutePath(), outputDir.getAbsolutePath())); final List<File> untaredFiles = new LinkedList<File>(); final ...
java
private void updateLoockup() { synchronized (parameterOverrideProviders) { ParameterOverrideInfoLookup newLookup = new ParameterOverrideInfoLookup(); for (ParameterOverrideProvider provider : parameterOverrideProviders) { newLookup.addOverrideMap(provider.getOverrideMap()); } newLook...
java
public static void load() { if (!isLoaded()) { ScriptInjector.fromString(LocalForageResources.INSTANCE.js().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); } }
java
public static void resetCounters() { unionCount = intersectionCount = differenceCount = symmetricDifferenceCount = complementCount = unionSizeCount = intersectionSizeCount = differenceSizeCount = symmetricDifferenceSizeCount = complementSizeCount = equalsCount = hashCodeCount = containsAllCount = contains...
java
public void setMarkers(List<GenericMarker> m){ this.markers = m; for (GenericMarker marker : m) { marker.setMap(this); } //setup any clustering options clusterMarkers(); }
java
public static void load() { if (!isLoaded()) { // ScriptInjector.fromString(OpenLayersV3Resources.INSTANCE.proj4js().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); // ScriptInjector.fromString(OpenLayersV3Resources.INSTANCE.supercluster().getText()).setWindow(ScriptInjector.TOP_...
java
protected void display() { new FilterPresenter(new FilterViewUI()).go(layout); resultPresenter = new ResultPresenter(getResultView()); loadStatusListener.registerObserver(resultPresenter); resultPresenter.go(layout); }
java
public BaseValidationCheck getValidationChecker(ValidationRule rule) { ValidationRule existRule = this.rules.stream().filter(r -> r.getRuleName().equals(rule.getRuleName())).findFirst().orElse(null); if (existRule == null) { throw new ValidationLibException("rulename : " + rule.getRuleName()...
java
public synchronized ValidationRuleStore addRule(ValidationRule rule) { rule.setOrderIdx(this.rules.size()); this.rules.add(rule); this.checkHashMap.put(rule.getRuleName(), rule.getValidationCheck()); return this; }
java
private static PCM clear_ligne(PCM pcm, PCM pcm_return){ List<Product> pdts = pcm.getProducts(); List<Cell> cells = new ArrayList<Cell>() ; for (Product pr : pdts) { float nbCellsEmpty = 0 ; // On ajoute les cellules du product dans une liste cells = pr.getCells(); // On traite les infos des ce...
java
private static PCM clear_colonne(PCM pcm, PCM pcm_return){ List<Feature> pdts = pcm.getConcreteFeatures(); List<Cell> cells = new ArrayList<Cell>() ; for (Feature pr : pdts) { float nbCellsEmpty = 0 ; // On ajoute les cellules du product dans une liste cells = pr.getCells(); // On traite les infos des...
java
public boolean sameFeature(JFeature f){ return this.name.equals(f.name) && this.type.equals(f.type); }
java
public static void nodeWalker(NodeList childNodes, NodeElementParser parser) throws ParseException { for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); String node = item.getNodeName(); if(item.getNodeType() == Node.ELEMENT_NODE){ ...
java
protected boolean isObject(String text) { final String trim = text.trim(); return trim.startsWith("{") && trim.endsWith("}"); }
java
@SuppressWarnings("unchecked") protected <D> void evalResponse(Request request, Deferred<D> deferred, Class<D> resolveType, Class<?> parametrizedType, RawResponse response) { if (parametrizedType != null) { processor.process(request, response, parametrizedType...
java
private void assertNotNull(Object value, String message) throws IllegalArgumentException { if (value == null) { throw new IllegalArgumentException(message); } }
java
public List<ReqUrl> getUrlList() { List<ReqUrl> reqUrls = new ArrayList<>(); for (String key : this.methodAndUrlIndex.getMap().keySet()) { List<ValidationData> datas = this.methodAndUrlIndex.getMap().get(key); if (!datas.isEmpty()) { reqUrls.add(new ReqUrl(datas.g...
java
public ValidationData findById(Long id) { List<ValidationData> datas = this.idIndex.get(ValidationIndexUtil.makeKey(String.valueOf(id))); if (datas.isEmpty()) { return null; } return datas.get(0); }
java
public void addIndex(ValidationData data) { for (ValidationDataIndex idx : this.idxs) { ValidationIndexUtil.addIndexData(data, idx); } }
java
public void removeIndex(ValidationData data) { for (ValidationDataIndex idx : this.idxs) { ValidationIndexUtil.removeIndexData(data, idx); } }
java
public void updateFromFile(MultipartFile file) { ObjectMapper objectMapper = ValidationObjUtil.getDefaultObjectMapper(); try { String jsonStr = new String(file.getBytes(), "UTF-8"); List<ValidationData> list = objectMapper.readValue(jsonStr, objectMapper.getTypeFactory().constru...
java
public static boolean isNotScanClass(String className) { String block = BASIC_PACKAGE_PREFIX_LIST.stream().filter(prefix -> className.startsWith(prefix)).findAny().orElse(null); return block != null; }
java
public static boolean isObjClass(Class<?> type) { if (type.isPrimitive() || type.isEnum() || type.isArray()) { return false; } String block = BASIC_PACKAGE_PREFIX_LIST.stream().filter(prefix -> type.getName().startsWith(prefix)).findAny().orElse(null); if (block != null) { ...
java
public static boolean isListClass(Class<?> type) { if (type.isPrimitive() || type.isEnum()) { return false; } return type.equals(List.class); }
java
public void initBeans(Object[] beans) { this.controllers = Arrays.stream(beans).filter(bean -> this.getController(bean) != null).map(bean -> this.getController(bean)).collect(Collectors.toList()); }
java
public List<DetailParam> getParameterFromMethodWithAnnotation(Class<?> parentClass, Method method, Class<?> annotationClass) { List<DetailParam> params = new ArrayList<>(); if (method.getParameterCount() < 1) { return params; } for (Parameter param : method.getParameters()) ...
java
public List<DetailParam> getParameterFromClassWithAnnotation(Class<?> baseClass, Class<?> annotationClass) { List<DetailParam> params = new ArrayList<>(); Arrays.stream(baseClass.getDeclaredMethods()).forEach(method -> params.addAll(this.getParameterFromMethodWithAnnotation(baseClass, method, annotation...
java
public List<DetailParam> getParameterWithAnnotation(Class<?> annotation) { List<DetailParam> params = new ArrayList<>(); this.controllers.stream().forEach(cla -> params.addAll(this.getParameterFromClassWithAnnotation(cla, annotation))); return params; }
java
public Row nextRow(int cnt) { Row lastrow = null; for (int i = 0; i < cnt; i++) { lastrow = this.nextRow(); } return lastrow; }
java
public List<Cell> createTitleCells(String... strs) { List<Cell> cells = new ArrayList<>(); for (String s : strs) { Cell cell = this.createTitleCell(s, DEFAULT_WIDTH); cells.add(cell); } return cells; }
java
public void createTitleCells(double width, String... strs) { for (String s : strs) { this.createTitleCell(s, width); } }
java
public Cell createTitleCell(String str, double width) { int cellCnt = this.getCellCnt(); Cell cell = this.getLastRow().createCell(cellCnt); cell.setCellValue(str); cell.setCellType(CellType.STRING); cell.setCellStyle(this.style.getStringCs()); sheet.setColumnWidth(cell...
java
public void createValueCells(Object... values) { for (Object value : values) { if (value == null) { this.createCell(""); continue; } if (value instanceof String) { this.createCell((String) value); } else if (value i...
java
private String printStackTrace(Object[] stackTrace) { StringBuilder output = new StringBuilder(); for (Object line : stackTrace) { output.append(line); output.append(newline); } return output.toString(); }
java
public IndexedSet<T> universe() { IntSet allItems = indices.empty(); allItems.fill(0, indexToItem.length - 1); return createFromIndices(allItems); }
java
boolean expiringSoon(TokenInfo info) { // TODO(jasonhall): Consider varying the definition of "soon" based on the // original expires_in value (e.g., "soon" = 1/10th of the total time before // it's expired). return Double.valueOf(info.getExpires()) < (clock.now() + TEN_MINUTES); }
java
public DataBulkRequest insertBefore(CRUDRequest request, CRUDRequest before) { this.requests.add(requests.indexOf(before), request); return this; }
java
public DataBulkRequest insertAfter(CRUDRequest request, CRUDRequest after) { this.requests.add(requests.indexOf(after) + 1, request); return this; }
java
public static String readFileToString(File file, final Charset charset) throws IOException { String line = null; BufferedReader reader = getBufferReader(file, charset); StringBuffer strBuffer = new StringBuffer(); while ((line = reader.readLine()) != null) { strBuffer.append...
java
public static void writeStringToFile(File file, String content) throws IOException { OutputStream outputStream = getOutputStream(file); outputStream.write(content.getBytes()); }
java
public static String getEncodingFileName(String fn) { try { return URLEncoder.encode(fn, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new ValidationLibException("unSupported fiel encoding : " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } }
java
public static void initFileSendHeader(HttpServletResponse res, String filename, String contentType) { filename = getEncodingFileName(filename); if (contentType != null) { res.setContentType(contentType); } else { res.setContentType("applicaiton/download;charset=utf-8"); ...
java
public static DataError fromJson(ObjectNode node) { DataError error = new DataError(); JsonNode x = node.get("data"); if (x != null) { error.entityData = x; } x = node.get("errors"); if (x instanceof ArrayNode) { error.errors = new ArrayList<>(); ...
java
public static DataError findErrorForDoc(List<DataError> list, JsonNode node) { for (DataError x : list) { if (x.entityData == node) { return x; } } return null; }
java
public void setMarkers(QueryResult queryResult){ mapWidget.clearMarkers(); RecordList recordList = queryResult.getRecordList(); List<RecordList.Record> records = recordList.getRecords(); List<GenericMarker> markers = new ArrayList<GenericMarker>(); final MarkerCoordinateSource ma...
java
public Uri getUri() { if (uri == null) { try { uri = uriBuilder.build(); } catch (Exception e) { throw new IllegalStateException("Could not build the URI.", e); } } return uri; }
java
private <T> void setupMarkerFixedNoRepeatHack(GoogleV3Marker<T> genericMarker) { final Marker marker1 = genericMarker.getMarker(); final LatLng[] initialPosition = new LatLng[1]; marker1.addDragStartHandler(new DragStartMapHandler() { @Override public void onEvent(DragSta...
java
public void setComparator(Column<T, ?> column, Comparator<T> comparator) { columnSortHandler.setComparator(column, comparator); }
java
String toUrl(Auth.UrlCodex urlCodex) { return new StringBuilder(authUrl) .append(authUrl.contains("?") ? "&" : "?") .append("client_id").append("=").append(urlCodex.encode(clientId)) .append("&").append("response_type").append("=").append("token") ...
java
public synchronized static <T> T get(Class<T> cType) { if( map.get(cType) != null){ return cType.cast(map.get(cType)); } try { Object obj = cType.newInstance(); log.debug("[CREATE INSTANCE] : " + cType.getSimpleName()); map.put(cType, obj); ...
java
public WriteStreamOld openWrite() { if (_cb != null) _cb.clear(); else _cb = CharBuffer.allocate(); if (_ws == null) _ws = new WriteStreamOld(this); else _ws.init(this); try { _ws.setEncoding("utf-8"); } catch (UnsupportedEncodingException e) { } return...
java
@Override public void write(byte []buf, int offset, int length, boolean isEnd) throws IOException { int end = offset + length; while (offset < end) { int ch1 = buf[offset++] & 0xff; if (ch1 < 0x80) _cb.append((char) ch1); else if ((ch1 & 0xe0) == 0xc0) { if (offset >= ...
java
public List<String> extractMetricNames() { List<String> result = new ArrayList<>(); for (MonitoringRule rule : monitoringRules.getMonitoringRules()) { for (Action action : rule.getActions().getActions()) { if (action.getName().equalsIgnoreCase("OutputMetric")) { ...
java
public static String escapeHtml(String s) { if (s == null) return null; StringBuilder cb = new StringBuilder(); int lineCharacter = 0; boolean startsWithSpace = false; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); lineCharacter++; if (ch == '<'...
java
public static void inc(byte[] nonce, byte value) { int i = nonce.length - 1; nonce[i] += value; if (value > 0 && (nonce[i] < 0 || nonce[i] >= value)) return; if (value < 0 && (nonce[i] < 0 && nonce[i] >= value)) return; for (i = i - 1; i >= 0; i--) { ...
java
@Override public <T> T run(long timeout, TimeUnit unit, Consumer<Result<T>> task) { try (OutboxAmp outbox = OutboxAmp.currentOrCreate(this)) { ResultFuture<T> future = new ResultFuture<>(); task.accept(future); return future.get(timeout, unit); } }
java
@Override public String address(Class<?> api, String address) { Objects.requireNonNull(address); if (address.isEmpty()) { address = addressDefault(api); } int slash = address.indexOf("/"); //int colon = address.indexOf(":"); if (address.endsWith(":") && slash < 0) { addres...
java
@Override public ServiceRefAmp bind(ServiceRefAmp service, String address) { if (log.isLoggable(Level.FINEST)) { log.finest(L.l("bind {0} for {1} in {2}", address, service.api().getType(), this)); } address = toCanonical(address); registry().bind(address, service); ...
java
private boolean isSeedHeartbeatValid() { boolean isSeed = false; for (ServerHeartbeat server : _serverSelf.getCluster().getSeedServers()) { if (server.port() > 0) { isSeed = true; if (server.isUp()) { return true; } } } return ! isSeed; }
java
public UpdateRackHeartbeat join(String extAddress, int extPort, String clusterId, String address, int port, int portBartender, String displayName, String serverHash, ...
java
private void joinSelf(ServerHeartbeat server, String extAddress, int extPort, String address, int port, String serverHash) { if (server != _serverSelf) { throw new IllegalStateException(L.l("Invalid self: {0} vs {1}", ...
java
public void hubHeartbeat(UpdateServerHeartbeat updateServer, UpdateRackHeartbeat updateRack, UpdatePodSystem updatePod, long sourceTime) { RackHeartbeat rack = getCluster().findRack(updateRack.getId()); if (rack == nul...
java