private SSLContext createSSLContext(LDAPConnectionHandlerCfg config) throws DirectoryException { try { DN keyMgrDN = config.getKeyManagerProviderDN(); KeyManagerProvider<?> keyManagerProvider = DirectoryServer.getKeyManagerProvider(keyMgrDN); if (keyManagerProvider == null) { logger.error(ERR_NULL_KEY_PROVIDER_MANAGER, keyMgrDN, friendlyName); disableAndWarnIfUseSSL(config); keyManagerProvider = new NullKeyManagerProvider(); // The SSL connection is unusable without a key manager provider } else if (!keyManagerProvider.containsAtLeastOneKey()) { logger.error(ERR_INVALID_KEYSTORE, friendlyName); disableAndWarnIfUseSSL(config); } final SortedSet<String> aliases = new TreeSet<>(config.getSSLCertNickname()); final KeyManager[] keyManagers; if (aliases.isEmpty()) { keyManagers = keyManagerProvider.getKeyManagers(); } else { final Iterator<String> it = aliases.iterator(); while (it.hasNext()) { if (!keyManagerProvider.containsKeyWithAlias(it.next())) { logger.error(ERR_KEYSTORE_DOES_NOT_CONTAIN_ALIAS, aliases, friendlyName); it.remove(); } } if (aliases.isEmpty()) { disableAndWarnIfUseSSL(config); } keyManagers = SelectableCertificateKeyManager.wrap( keyManagerProvider.getKeyManagers(), aliases, friendlyName); } DN trustMgrDN = config.getTrustManagerProviderDN(); TrustManagerProvider<?> trustManagerProvider = DirectoryServer.getTrustManagerProvider(trustMgrDN); if (trustManagerProvider == null) { trustManagerProvider = new NullTrustManagerProvider(); } SSLContext sslContext = SSLContext.getInstance(SSL_CONTEXT_INSTANCE_NAME); sslContext.init(keyManagers, trustManagerProvider.getTrustManagers(), null); return sslContext; } catch (Exception e) { logger.traceException(e); ResultCode resCode = DirectoryServer.getServerErrorResultCode(); LocalizableMessage message = ERR_CONNHANDLER_SSL_CANNOT_INITIALIZE.get(getExceptionMessage(e)); throw new DirectoryException(resCode, message, e); } }
private void bes(Graph graph) { TetradLogger.getInstance().log("info", "** BACKWARD EQUIVALENCE SEARCH"); initializeArrowsBackward(graph); while (!sortedArrows.isEmpty()) { Arrow arrow = sortedArrows.first(); sortedArrows.remove(arrow); Node x = arrow.getX(); Node y = arrow.getY(); clearArrow(x, y); if (!validDelete(arrow.getHOrT(), arrow.getNaYX(), graph)) { continue; } List<Node> h = arrow.getHOrT(); double bump = arrow.getBump(); delete(x, y, h, graph, bump); score += bump; rebuildPattern(graph); storeGraph(graph); initializeArrowsBackward( graph); // Rebuilds Arrows from scratch each time. Fast enough for backwards. } }
@Override public int previousTab(int position) { int tabStop = 0; // Search for the first tab stop before the given position... SortedSet<Integer> headSet = myTabStops.headSet(Integer.valueOf(position)); if (!headSet.isEmpty()) { tabStop = headSet.last(); } // Don't go beyond the start of the line... return Math.max(0, tabStop); }
@Override public int nextTab(int position) { int tabStop = Integer.MAX_VALUE; // Search for the first tab stop after the given position... SortedSet<Integer> tailSet = myTabStops.tailSet(position + 1); if (!tailSet.isEmpty()) { tabStop = tailSet.first(); } // Don't go beyond the end of the line... return Math.min(tabStop, (myWidth - 1)); }
private void storeGraph(Graph graph) { if (numPatternsToStore < 1) return; if (topGraphs.isEmpty() || score > topGraphs.first().getScore()) { Graph graphCopy = new EdgeListGraphSingleConnections(graph); topGraphs.add(new ScoredGraph(graphCopy, score)); if (topGraphs.size() > getNumPatternsToStore()) { topGraphs.remove(topGraphs.first()); } } }
/** @tests java.util.TreeSet#TreeSet(java.util.Comparator) */ public void test_ConstructorLjava_util_Comparator() { // Test for method java.util.TreeSet(java.util.Comparator) SortedSet myTreeSet = db.createTreeSet("test", new ReversedIntegerComparator(), null); assertTrue("Did not construct correct TreeSet", myTreeSet.isEmpty()); myTreeSet.add(new Integer(1)); myTreeSet.add(new Integer(2)); assertTrue( "Answered incorrect first element--did not use custom comparator ", myTreeSet.first().equals(new Integer(2))); assertTrue( "Answered incorrect last element--did not use custom comparator ", myTreeSet.last().equals(new Integer(1))); }
/** * Forward equivalence search. * * @param graph The graph in the state prior to the forward equivalence search. */ private void fes(Graph graph, List<Node> nodes) { TetradLogger.getInstance().log("info", "** FORWARD EQUIVALENCE SEARCH"); lookupArrows = new HashMap<OrderedPair, Set<Arrow>>(); initializeArrowsForward(nodes); while (!sortedArrows.isEmpty()) { Arrow arrow = sortedArrows.first(); sortedArrows.remove(arrow); Node x = arrow.getX(); Node y = arrow.getY(); clearArrow(x, y); if (graph.isAdjacentTo(x, y)) { continue; } if (!validInsert(x, y, arrow.getHOrT(), arrow.getNaYX(), graph)) { continue; } List<Node> t = arrow.getHOrT(); double bump = arrow.getBump(); Set<Edge> edges = graph.getEdges(); insert(x, y, t, graph, bump); score += bump; rebuildPattern(graph); // Try to avoid duplicating scoring calls. First clear out all of the edges that need to be // changed, // then change them, checking to see if they're already been changed. I know, roundabout, but // there's // a performance boost. for (Edge edge : graph.getEdges()) { if (!edges.contains(edge)) { reevaluateForward(graph, nodes, edge.getNode1(), edge.getNode2()); } } storeGraph(graph); } }
public boolean work(int[] nums, int k, int t) { if (k < 1 || t < 0 || nums == null || nums.length < 2) return false; SortedSet<Long> kSet = new TreeSet<Long>(); for (int i = 0; i < nums.length; i++) { SortedSet<Long> tempSet = kSet.subSet((long) nums[i] - t, (long) nums[i] + t + 1); if (!tempSet.isEmpty()) return true; if (i >= k) { kSet.remove((long) nums[i - k]); } kSet.add((long) nums[i]); } return false; }
/** * Does this match? * * @param token The current token * @param no The token number * @param stack The fork stack... may be used if there are partial matches * @param lookBackStack The reverse stack (ignored) */ public TypeExpr matches(Token token, int no, Stack<MatchFork> stack, List<Token> lookBackStack) { if (matches == null) { if (set) { matches = new TreeSet<WordListEntry>(); WordListSet wls = WordListSet.getWordListSetByName(wordListName); if (wls == null) { throw new IllegalArgumentException("Cannot find word list set %" + wordListName); } for (Map.Entry<String, WordList> entry : wls.getWordListSets()) { matches.addAll(WordListSet.getMatchSet(entry.getKey(), token.termText().toLowerCase())); } // currentMatch = wls.getEntry(token.termText().toLowerCase()); currentMatch = new WordListEntry(new LinkedList<String>()); currentMatch.addWord(token.term().toLowerCase()); } else { matches = new TreeSet<WordListEntry>( WordListSet.getMatchSet(wordListName, token.termText().toLowerCase())); // currentMatch = // WordListSet.getWordListSetByList(wordListName).getEntry(token.termText().toLowerCase()); currentMatch = new WordListEntry(new LinkedList<String>()); currentMatch.addWord(token.term().toLowerCase()); } } else { currentMatch.addWord(token.termText().toLowerCase()); } MatchFork mf = MatchFork.find(stack, no, this); if (mf != null && (mf.used == true || stack.peek() == mf)) { stack.peek().split(no, this); return this; } Iterator<WordListEntry> wleIter = matches.iterator(); while (wleIter.hasNext()) { WordListEntry wle = wleIter.next(); if (wle.equals(currentMatch)) { if (matches.size() > 1 && (stack.empty() || stack.peek().tokenNo < no)) stack.push(new MatchFork(no, this)); return next; } if (!wle.matchable(currentMatch)) wleIter.remove(); } if (matches.isEmpty()) return null; else return this; }
/** * Build the method documentation. * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added */ public void buildMethodDoc(XMLNode node, Content memberDetailsTree) { if (writer == null) { return; } if (!methods.isEmpty()) { Content methodDetailsTree = writer.getMethodDetailsTreeHeader(typeElement, memberDetailsTree); Set<Element> methodDetailSet = ((ConfigurationImpl) configuration).sortedMethodDetails ? methods : visibleMemberMap.getLeafClassMembersSourceOrder(); for (Element e : methodDetailSet) { currentMethod = (ExecutableElement) e; Content methodDocTree = writer.getMethodDocTreeHeader(currentMethod, methodDetailsTree); buildChildren(node, methodDocTree); methodDetailsTree.addContent( writer.getMethodDoc(methodDocTree, currentMethod == methods.last())); } memberDetailsTree.addContent(writer.getMethodDetails(methodDetailsTree)); } }
long getStartTime() { if (output_set.isEmpty()) return 0; return output_set.first().getStartTime(); }
/** {@inheritDoc} */ @Override public boolean hasMembersToDocument() { return !methods.isEmpty(); }
/** * Check if this token contains one ore more gaps. * * @return {@code true} if this token contains gaps, {@code false} otherwise */ public boolean hasGaps() { return !gaps.isEmpty(); }
/** @tests java.util.TreeSet#isEmpty() */ public void test_isEmpty() { // Test for method boolean java.util.TreeSet.isEmpty() assertTrue("Empty set returned false", db.createTreeSet("test").isEmpty()); assertTrue("Non-Empty returned true", !ts.isEmpty()); }