Esempio n. 1
0
 // check inclusion between states in the input FTA
 public boolean inclusionCheck(LinkedHashSet<String> q1, LinkedHashSet<String> q2) {
   Iterator iter, qiter1, qiter2;
   String x;
   LinkedHashSet<String> q;
   boolean includes = true;
   boolean b;
   iter = qd.iterator();
   while (iter.hasNext() && includes) {
     q = (LinkedHashSet<String>) iter.next();
     qiter1 = q1.iterator();
     while (qiter1.hasNext()) {
       x = (String) qiter1.next();
       if (q.contains(x)) {
         b = false;
         qiter2 = q2.iterator();
         while (qiter2.hasNext() && !b) {
           if (q.contains((String) qiter2.next())) {
             b = true;
           }
         }
         includes = includes && b;
       }
     }
   }
   return includes;
 }
 public static boolean isValid(LinkedHashSet<?> expected, LinkedHashSet<?> map) {
   if (isValid((HashSet<?>) expected, (HashSet<?>) map)) {
     Iterator<?> expectedEntries = expected.iterator();
     Iterator<?> actualEntries = map.iterator();
     return equals(expectedEntries, actualEntries);
   }
   return false;
 }
Esempio n. 3
0
  public ArrayList<String> IPTrack(
      String ipaddr, boolean IPdisp, boolean recursive, boolean override) {
    ArrayList<String> output = new ArrayList<String>();

    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
      ps =
          conn.prepareStatement(
              "SELECT `accountname` "
                  + "FROM `"
                  + table
                  + "` "
                  + "WHERE `ip` = ? "
                  + "ORDER BY `time` DESC");
      ps.setString(1, ipaddr);
      rs = ps.executeQuery();

      LinkedHashSet<String> names = new LinkedHashSet<String>();
      while (rs.next()) {
        if ((!plugin.untraceable.contains(rs.getString("accountname"))) || (override))
          names.add(rs.getString("accountname") + ((IPdisp) ? " (" + ipaddr + ")" : ""));
      }
      if (recursive) { // OH GOD OH GOD OH GOD
        LinkedHashSet<String> names_spent = new LinkedHashSet<String>();
        java.util.Iterator<String> names_itr = names.iterator();
        while (names_itr.hasNext()) {

          String thisName = names_itr.next();
          if (names_spent.contains(thisName)) continue;

          names_spent.add(thisName);
          if (names.addAll(
              PlayerTrack(
                  ((thisName.indexOf(" ") != -1)
                      ? thisName.substring(0, thisName.indexOf(" "))
                      : thisName),
                  IPdisp,
                  false,
                  override,
                  false,
                  false))) names_itr = names.iterator();
        }
      }
      output.addAll(names);
    } catch (SQLException ex) {
      PlayerTracker.log.log(Level.SEVERE, "[P-Tracker] Couldn't execute MySQL statement: ", ex);
    }

    return output;
  }
  @Override
  public RVFormula expandToRVFormula(
      LinkedHashSet<FoLtlConstant> domain, FoLtlAssignment assignment) {
    RVFormula res = null;
    FoLtlFormula nested = this.getNestedFormula();
    FoLtlVariable v = this.getQuantifiedVariable();

    Iterator<FoLtlConstant> i;

    if (!v.getSort().isEmpty()) {
      i = v.getSort().iterator();
    } else {
      i = domain.iterator();
    }

    while (i.hasNext()) {
      FoLtlConstant c = i.next();
      assignment.put(v, c);

      RVFormula temp = nested.expandToRVFormula(domain, assignment);

      if (res == null) {
        res = temp;
      } else {
        res = new RVAndFormula(temp, res);
      }

      assignment.remove(v);
    }

    return res;
  }
Esempio n. 5
0
  @SuppressWarnings(
      "null") /* eclipse bug; it falsely thinks stuffAc will always be null or some such hogwash. */
  private static void compareMessages(
      String name,
      LombokImmutableList<CompilerMessageMatcher> expected,
      LinkedHashSet<CompilerMessage> actual) {
    Iterator<CompilerMessageMatcher> expectedIterator = expected.iterator();
    Iterator<CompilerMessage> actualIterator = actual.iterator();

    CompilerMessage stuffAc = null;
    while (true) {
      boolean exHasNext = expectedIterator.hasNext();
      boolean acHasNext = stuffAc != null || actualIterator.hasNext();
      if (!exHasNext && !acHasNext) break;
      if (exHasNext && acHasNext) {
        CompilerMessageMatcher cmm = expectedIterator.next();
        CompilerMessage cm = stuffAc == null ? actualIterator.next() : stuffAc;
        if (cmm.matches(cm)) continue;
        if (cmm.isOptional()) stuffAc = cm;
        fail(String.format("[%s] Expected message '%s' but got message '%s'", name, cmm, cm));
        throw new AssertionError("fail should have aborted already.");
      }

      while (expectedIterator.hasNext()) {
        CompilerMessageMatcher next = expectedIterator.next();
        if (next.isOptional()) continue;
        fail(
            String.format("[%s] Expected message '%s' but ran out of actual messages", name, next));
      }
      if (acHasNext)
        fail(String.format("[%s] Unexpected message: %s", name, actualIterator.next()));
      break;
    }
  }
Esempio n. 6
0
 public void fireSimEvent() {
   SimEvent se = new SimEvent(this, entity.getTimeNow());
   for (Iterator<?> i = listeners.iterator(); i.hasNext(); ) {
     ((SimEventListener) i.next()).simEventOccurred(se);
   }
   entity.schedule("fireSimEvent", period);
 }
Esempio n. 7
0
  // ## operation writeChemkinReactions(ReactionModel)
  // 10/26/07 gmagoon: changed to take temperature as parameter (it doesn't seem like this method is
  // currently used anywhere)
  public static String writeChemkinReactions(
      ReactionModel p_reactionModel, Temperature p_temperature) {
    // #[ operation writeChemkinReactions(ReactionModel)
    StringBuilder result = new StringBuilder();
    result.append("REACTIONS	KCAL/MOLE\n");
    CoreEdgeReactionModel cerm = (CoreEdgeReactionModel) p_reactionModel;

    LinkedHashSet all = cerm.getReactedReactionSet();

    HashSet hs = new HashSet();
    int numfor = 0;
    int numrev = 0;
    int numdup = 0;
    int numnorev = 0;
    for (Iterator iter = all.iterator(); iter.hasNext(); ) {
      Reaction rxn = (Reaction) iter.next();
      if (rxn.isForward()) {
        result.append(
            " "
                + rxn.toChemkinString(p_temperature)
                + "\n"); // 10/26/07 gmagoon: changed to avoid use of Global.temperature
        //	result.append(" " + rxn.toChemkinString(Global.temperature) + "\n");

      }
    }

    result.append("END\n");

    return result.toString();

    // #]
  }
Esempio n. 8
0
    private synchronized TaskAttemptId getAndRemove(int volumeId) {
      TaskAttemptId taskAttemptId = null;
      if (!unassignedTaskForEachVolume.containsKey(volumeId)) {
        if (volumeId > REMOTE) {
          diskVolumeLoads.remove(volumeId);
        }
        return taskAttemptId;
      }

      LinkedHashSet<TaskAttempt> list = unassignedTaskForEachVolume.get(volumeId);
      if (list != null && !list.isEmpty()) {
        TaskAttempt taskAttempt;
        synchronized (unassignedTaskForEachVolume) {
          Iterator<TaskAttempt> iterator = list.iterator();
          taskAttempt = iterator.next();
          iterator.remove();
        }

        taskAttemptId = taskAttempt.getId();
        for (DataLocation location : taskAttempt.getTask().getDataLocations()) {
          HostVolumeMapping volumeMapping =
              scheduledRequests.leafTaskHostMapping.get(location.getHost());
          if (volumeMapping != null) {
            volumeMapping.removeTaskAttempt(location.getVolumeId(), taskAttempt);
          }
        }

        increaseConcurrency(volumeId);
      }

      return taskAttemptId;
    }
Esempio n. 9
0
 public static ArrayList<Integer> roll(LinkedHashSet<Dice> dice) {
   ArrayList<Integer> ret = new ArrayList<Integer>();
   Iterator<Dice> it = dice.iterator();
   while (it.hasNext()) {
     ret.add(it.next().roll());
   }
   return ret;
 }
Esempio n. 10
0
 public String[] LinkedSetToArray(LinkedHashSet<String> datas) {
   String[] array = new String[datas.size()];
   int index = 0;
   for (Iterator<String> iter = datas.iterator(); iter.hasNext(); ) {
     array[index] = (String) iter.next();
     index++;
   }
   return array;
 }
Esempio n. 11
0
 @Override
 public String toString() {
   Iterator<Hop> i = path.iterator();
   String s = null;
   while (i.hasNext()) {
     s += i.next().toString();
   }
   return s;
 }
Esempio n. 12
0
 LinkedHashSet<String> rhsSet(LinkedHashSet<FTATransition> tSet) {
   Iterator i = tSet.iterator();
   FTATransition t;
   LinkedHashSet<String> result = new LinkedHashSet<String>();
   while (i.hasNext()) {
     t = (FTATransition) i.next();
     result.add(t.q0);
   }
   return result;
 }
  public static void send_to_group(LinkedList Clients, ArrayList<String> Decrypted_Chat_Buffer) {

    LinkedHashSet client_set = new LinkedHashSet();
    Iterator j = Clients.iterator();
    while (j.hasNext()) {
      boolean isthere = false;
      Object g = j.next();
      Iterator k = client_set.iterator();
      while (k.hasNext()) {
        System.out.println("Comparing two elements");
        if (k.next().toString().equals(g.toString())) {
          isthere = true;
          System.out.println("Elements can not be added");
        }
      }
      if (!isthere) {
        System.out.println("Adding element");
        client_set.add(g);
      }
    }

    System.out.println(client_set.size());
    System.out.println(Clients.size());
    Iterator i = client_set.iterator();

    System.out.println("Writing Data to all the clients");
    while (i.hasNext()) {
      System.out.println("Writing Data to all the client" + i.toString());
      SocketChannel channel = (SocketChannel) i.next();
      Iterator chat = Decrypted_Chat_Buffer.iterator();
      while (chat.hasNext()) {
        String mesg = chat.next().toString();
        System.out.println("message" + mesg);
        prepareBuffer("message" + mesg);
        channelWrite(channel);
        System.out.println("Writen Data to client" + i.toString());
      }
    }
    setPhase_4_over(true);
    setPhase_2_over(false);
    setDecrypted(false);
    Decrypted_Chat_Buffer.clear();
  }
 private void restoreSet(LinkedHashSet<?> set, int restoreSize) {
   for (Iterator<?> it = set.iterator(); it.hasNext(); ) {
     it.next();
     if (restoreSize == 0) {
       it.remove();
     } else {
       restoreSize--;
     }
   }
 }
Esempio n. 15
0
  /**
   * Returns an array containing all installed providers that satisfy the specified* selection
   * criteria, or null if no such providers have been installed. The returned providers are ordered
   * according to their <a href= "#insertProviderAt(java.security.Provider, int)">preference
   * order</a>.
   *
   * <p>The selection criteria are represented by a map. Each map entry represents a selection
   * criterion. A provider is selected iff it satisfies all selection criteria. The key for any
   * entry in such a map must be in one of the following two formats:
   *
   * <ul>
   *   <li><i>&lt;crypto_service>.&lt;algorithm_or_type></i>
   *       <p>The cryptographic service name must not contain any dots.
   *       <p>The value associated with the key must be an empty string.
   *       <p>A provider satisfies this selection criterion iff the provider implements the
   *       specified algorithm or type for the specified cryptographic service.
   *   <li><i>&lt;crypto_service>.&lt;algorithm_or_type> &lt;attribute_name></i>
   *       <p>The cryptographic service name must not contain any dots. There must be one or more
   *       space charaters between the <i>&lt;algorithm_or_type></i> and the
   *       <i>&lt;attribute_name></i>.
   *       <p>The value associated with the key must be a non-empty string. A provider satisfies
   *       this selection criterion iff the provider implements the specified algorithm or type for
   *       the specified cryptographic service and its implementation meets the constraint expressed
   *       by the specified attribute name/value pair.
   * </ul>
   *
   * <p>See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java
   * Cryptogaphy Architecture API Specification &amp; Reference </a> for information about standard
   * cryptographic service names, standard algorithm names and standard attribute names.
   *
   * @param filter the criteria for selecting providers. The filter is case-insensitive.
   * @return all the installed providers that satisfy the selection criteria, or null if no such
   *     providers have been installed.
   * @throws InvalidParameterException if the filter is not in the required format
   * @throws NullPointerException if filter is null
   * @see #getProviders(java.lang.String)
   */
  public static Provider[] getProviders(Map<String, String> filter) {
    // Get all installed providers first.
    // Then only return those providers who satisfy the selection criteria.
    Provider[] allProviders = Security.getProviders();
    Set keySet = filter.keySet();
    LinkedHashSet candidates = new LinkedHashSet(5);

    // Returns all installed providers
    // if the selection criteria is null.
    if ((keySet == null) || (allProviders == null)) {
      return allProviders;
    }

    boolean firstSearch = true;

    // For each selection criterion, remove providers
    // which don't satisfy the criterion from the candidate set.
    for (Iterator ite = keySet.iterator(); ite.hasNext(); ) {
      String key = (String) ite.next();
      String value = (String) filter.get(key);

      LinkedHashSet newCandidates = getAllQualifyingCandidates(key, value, allProviders);
      if (firstSearch) {
        candidates = newCandidates;
        firstSearch = false;
      }

      if ((newCandidates != null) && !newCandidates.isEmpty()) {
        // For each provider in the candidates set, if it
        // isn't in the newCandidate set, we should remove
        // it from the candidate set.
        for (Iterator cansIte = candidates.iterator(); cansIte.hasNext(); ) {
          Provider prov = (Provider) cansIte.next();
          if (!newCandidates.contains(prov)) {
            cansIte.remove();
          }
        }
      } else {
        candidates = null;
        break;
      }
    }

    if ((candidates == null) || (candidates.isEmpty())) return null;

    Object[] candidatesArray = candidates.toArray();
    Provider[] result = new Provider[candidatesArray.length];

    for (int i = 0; i < result.length; i++) {
      result[i] = (Provider) candidatesArray[i];
    }

    return result;
  }
 @Override
 public void calcData(final DataKey key, final DataSink sink) {
   if (key.equals(LangDataKeys.PSI_ELEMENT)) {
     if (mySelectedElements != null && !mySelectedElements.isEmpty()) {
       T selectedElement = mySelectedElements.iterator().next();
       if (selectedElement instanceof ClassMemberWithElement) {
         sink.put(
             LangDataKeys.PSI_ELEMENT, ((ClassMemberWithElement) selectedElement).getElement());
       }
     }
   }
 }
Esempio n. 17
0
 public void unregister(final Class<?> eventType, final Object target) {
   if (listeners != null) {
     Iterators.removeIf(
         listeners.iterator(),
         new Predicate<ListenerMethod>() {
           @Override
           public boolean apply(ListenerMethod m) {
             return m.matches(eventType, target);
           }
         });
   }
 }
Esempio n. 18
0
  /** java.util.LinkedHashSet#iterator() */
  public void test_iterator() {
    // Test for method java.util.Iterator java.util.LinkedHashSet.iterator()
    Iterator i = hs.iterator();
    int x = 0;
    int j;
    for (j = 0; i.hasNext(); j++) {
      Object oo = i.next();
      if (oo != null) {
        Integer ii = (Integer) oo;
        assertTrue("Incorrect element found", ii.intValue() == j);
      } else {
        assertTrue("Cannot find null", hs.contains(oo));
      }
      ++x;
    }
    assertTrue("Returned iteration of incorrect size", hs.size() == x);

    LinkedHashSet s = new LinkedHashSet();
    s.add(null);
    assertNull("Cannot handle null", s.iterator().next());
  }
Esempio n. 19
0
  // This may not catch 100% of packets, but should get most of them, a small number may end up
  // being compressed by main thread
  @SuppressWarnings("unchecked")
  public void manageChunkQueue(boolean flag1) {
    List<ChunkCoordIntPair> playerChunkQueue = player.chunkCoordIntPairQueue;

    try {
      if (!playerChunkQueue.isEmpty()) {
        chunkUpdateQueue.addAll(playerChunkQueue);
        playerChunkQueue.clear();
      }
    } catch (ConcurrentModificationException e) {
      // seems to be called from a separate thread during teleports (rogue plugins?)
    }

    int chunkCompressionThreadSize = ChunkCompressionThread.getPlayerQueueSize(this.player);
    if (!chunkUpdateQueue.isEmpty()
        && (lowPriorityCount()
                + chunkCompressionThreadSize
                + MapChunkThread.getQueueLength(this.player))
            < 4) {
      ChunkCoordIntPair playerChunk = getPlayerChunk();
      Iterator<ChunkCoordIntPair> i = chunkUpdateQueue.iterator();
      ChunkCoordIntPair first = i.next();
      while (first != null && !activeChunks.contains(first)) {
        i.remove();
        if (i.hasNext()) {
          first = i.next();
        } else {
          first = null;
        }
      }
      if (first != null) {
        if (updateCounter.get() > 0) {
          int cx = playerChunk.x;
          int cz = playerChunk.z;
          boolean chunkFound = false;
          for (int c = 0; c < spiralx.length; c++) {
            ChunkCoordIntPair testChunk = new ChunkCoordIntPair(spiralx[c] + cx, spiralz[c] + cz);
            if (chunkUpdateQueue.contains(testChunk)) {
              first = testChunk;
              chunkFound = true;
              break;
            }
          }
          if (!chunkFound) {
            updateCounter.decrementAndGet();
          }
        }
        chunkUpdateQueue.remove(first);
        MapChunkThread.sendPacketMapChunk(first, this.player, this.player.world);
        sendChunkTiles(first.x, first.z, player);
      }
    }
  }
Esempio n. 20
0
 // ## operation setReactantTree(LinkedHashSet)
 public void setReactantTree(LinkedHashSet p_treeSet) {
   // #[ operation setReactantTree(LinkedHashSet)
   if (p_treeSet == null) throw new InvalidReactantTreeException();
   int size = p_treeSet.size();
   if (size == 0) throw new InvalidReactantTreeException();
   Iterator iter = p_treeSet.iterator();
   while (iter.hasNext()) {
     HierarchyTree tree = (HierarchyTree) iter.next();
     addReactantTree(tree);
   }
   return;
   // #]
 }
Esempio n. 21
0
  /**
   * Elevates the status of the designated isomer from nonincluded to included, and generates
   * pathways for this isomer. Generally a large number of pathways are generated.
   *
   * @param isomer The isomer to make included.
   */
  public void makeIsomerIncluded(PDepIsomer isomer) {

    if (!isomer.isUnimolecular() || isomer.getIncluded()) return;

    isomer.setIncluded(true);

    LinkedHashSet reactionSet = isomer.generatePaths(reactionSystem);

    for (Iterator iter = reactionSet.iterator(); iter.hasNext(); ) {
      Reaction rxn = (Reaction) iter.next();
      if (!contains(rxn)) addReactionToNetworks(rxn);
    }
  }
Esempio n. 22
0
  public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable {
    if (!Pigeons.isOpenableMethod(method)) {
      // 如果是 Object 的方法 那么可以直接调用不会通过网络进行远程调用
      if (method.getDeclaringClass() == Object.class) {
        return method.invoke(this, arguments);
      }
      throw new NonopenMethodException(interfase, method, arguments);
    }
    try {
      String x = Pigeons.getOpenPath(implementation);
      String y = Pigeons.getOpenPath(interfase);
      String z = Pigeons.getOpenPath(method);

      String path = Pigeons.getOpenPath(x + y + z);

      Header header = new Header();
      header.setContentType(format);
      header.setCharset(client.getCharset());
      header.setConnection("closed");
      header.setHost(host + (port == 80 ? "" : ":" + port));
      header.setPragma("no-cache");
      header.setCacheControl("no-cache");
      header.setUserAgent(
          Version.getCurrent().getName()
              + "/"
              + Version.getCurrent().getCode()
              + "["
              + System.getProperty("user.language")
              + "]"
              + "("
              + System.getProperty("os.name")
              + " "
              + System.getProperty("os.version")
              + ")");

      Invocation invocation = new Invocation();
      invocation.setClientHeader(header);
      invocation.setHost(host);
      invocation.setPort(port);
      invocation.setPath(path);
      invocation.setInterfase(interfase);
      invocation.setMethod(method);
      invocation.setImplementation(this);
      invocation.setArguments(arguments);
      invocation.setInterceptors(interceptors.iterator());

      return invocation.invoke();
    } catch (Throwable e) {
      throw e instanceof IOException ? (IOException) e : new IOException(e);
    }
  }
Esempio n. 23
0
  /** Method to clear the LinkedHashSet */
  public void clear() {
    if (ownerOP != null && ownerOP.getExecutionContext().getManageRelations()) {
      // Relationship management
      Iterator iter = delegate.iterator();
      RelationshipManager relMgr = ownerOP.getExecutionContext().getRelationshipManager(ownerOP);
      while (iter.hasNext()) {
        relMgr.relationRemove(ownerMmd.getAbsoluteFieldNumber(), iter.next());
      }
    }

    if (ownerOP != null && !delegate.isEmpty()) {
      // Cascade delete
      if (SCOUtils.useQueuedUpdate(ownerOP)) {
        // Queue the cascade delete
        Iterator iter = delegate.iterator();
        while (iter.hasNext()) {
          ownerOP
              .getExecutionContext()
              .addOperationToQueue(
                  new CollectionRemoveOperation(
                      ownerOP, ownerMmd.getAbsoluteFieldNumber(), iter.next(), true));
        }
      } else if (SCOUtils.hasDependentElement(ownerMmd)) {
        // Perform the cascade delete
        Iterator iter = delegate.iterator();
        while (iter.hasNext()) {
          ownerOP.getExecutionContext().deleteObjectInternal(iter.next());
        }
      }
    }

    delegate.clear();

    makeDirty();
    if (ownerOP != null && !ownerOP.getExecutionContext().getTransaction().isActive()) {
      ownerOP.getExecutionContext().processNontransactionalUpdate();
    }
  }
Esempio n. 24
0
 protected String formatErrorMessages() {
   StringBuilder sb = new StringBuilder();
   sb.append("<html>");
   if (errorMessages.size() == 1) {
     sb.append(errorMessages.iterator().next());
   } else {
     sb.append("<ul>");
     for (String msg : errorMessages) {
       sb.append("<li>").append(msg).append("</li>");
     }
     sb.append("/ul>");
   }
   sb.append("</html>");
   return sb.toString();
 }
Esempio n. 25
0
 public void unregister(final Class<?> eventType, final Object target, final Method method) {
   if (listeners != null) {
     ListenerMethod toBeRemove =
         Iterators.find(
             listeners.iterator(),
             new Predicate<ListenerMethod>() {
               @Override
               public boolean apply(ListenerMethod m) {
                 return m.matches(eventType, target, method);
               }
             });
     if (toBeRemove != null) {
       listeners.remove(toBeRemove);
     }
   }
 }
Esempio n. 26
0
 @Override
 public Formula apply(final Formula formula, boolean cache) {
   if (!this.proceed) return null;
   if (formula.type().precedence() >= LITERAL.precedence()) return formula;
   Formula cached = formula.transformationCacheEntry(FACTORIZED_CNF);
   if (cached != null) return cached;
   switch (formula.type()) {
     case NOT:
     case IMPL:
     case EQUIV:
       cached = this.apply(formula.nnf(), cache);
       break;
     case OR:
       LinkedHashSet<Formula> nops = new LinkedHashSet<>();
       for (final Formula op : formula) {
         if (!this.proceed) return null;
         nops.add(this.apply(op, cache));
       }
       final Iterator<Formula> it = nops.iterator();
       cached = it.next();
       while (it.hasNext()) {
         if (!this.proceed) return null;
         cached = this.distribute(cached, it.next());
       }
       break;
     case AND:
       nops = new LinkedHashSet<>();
       for (final Formula op : formula) {
         final Formula apply = this.apply(op, cache);
         if (!this.proceed) return null;
         nops.add(apply);
       }
       cached = formula.factory().and(nops);
       break;
     case PBC:
       cached = formula.nnf();
       break;
     default:
       throw new IllegalArgumentException("Could not process the formula type " + formula.type());
   }
   if (this.proceed) {
     if (cache) formula.setTransformationCacheEntry(FACTORIZED_CNF, cached);
     return cached;
   }
   return null;
 }
  @Test
  @SuppressWarnings("unchecked")
  public void testPackagesWithDots() throws Exception {

    Constructor<PackageNamesLoader> constructor = PackageNamesLoader.class.getDeclaredConstructor();
    constructor.setAccessible(true);
    PackageNamesLoader loader = constructor.newInstance();

    Attributes attributes = mock(Attributes.class);
    when(attributes.getValue("name")).thenReturn("coding.");
    loader.startElement("", "", "package", attributes);
    loader.endElement("", "", "package");

    Field field = PackageNamesLoader.class.getDeclaredField("packageNames");
    field.setAccessible(true);
    LinkedHashSet<String> list = (LinkedHashSet<String>) field.get(loader);
    assertEquals("coding.", list.iterator().next());
  }
 private static LookupElement[] initLookupItems(
     LinkedHashSet<String> names, PsiNamedElement elementToRename, final boolean shouldSelectAll) {
   if (names == null) {
     names = new LinkedHashSet<String>();
     for (NameSuggestionProvider provider :
         Extensions.getExtensions(NameSuggestionProvider.EP_NAME)) {
       final SuggestedNameInfo suggestedNameInfo =
           provider.getSuggestedNames(elementToRename, elementToRename, names);
       if (suggestedNameInfo != null
           && provider instanceof PreferrableNameSuggestionProvider
           && !((PreferrableNameSuggestionProvider) provider).shouldCheckOthers()) {
         break;
       }
     }
   }
   final LookupElement[] lookupElements = new LookupElement[names.size()];
   final Iterator<String> iterator = names.iterator();
   for (int i = 0; i < lookupElements.length; i++) {
     final String suggestion = iterator.next();
     lookupElements[i] =
         LookupElementBuilder.create(suggestion)
             .withInsertHandler(
                 new InsertHandler<LookupElement>() {
                   @Override
                   public void handleInsert(InsertionContext context, LookupElement item) {
                     if (shouldSelectAll) return;
                     final Editor topLevelEditor =
                         InjectedLanguageUtil.getTopLevelEditor(context.getEditor());
                     final TemplateState templateState =
                         TemplateManagerImpl.getTemplateState(topLevelEditor);
                     if (templateState != null) {
                       final TextRange range = templateState.getCurrentVariableRange();
                       if (range != null) {
                         topLevelEditor
                             .getDocument()
                             .replaceString(
                                 range.getStartOffset(), range.getEndOffset(), suggestion);
                       }
                     }
                   }
                 });
   }
   return lookupElements;
 }
Esempio n. 29
0
  // constructor
  public SeqGraphXcons(
      SeqGraph graph,
      LinkedHashSet<SeqNode> startNodes,
      LinkedHashSet<SeqNode> stopNodes,
      boolean stopAtFFTs)
      throws Xcept {
    this.graph = graph;
    this.startNodes = startNodes;
    this.stopNodes = stopNodes;
    this.stopAtFFTs = stopAtFFTs;

    System.err.println("SeqGraphXCons stopAtFFTs=" + stopAtFFTs);
    nodeDests = new Hashtable<SeqNode, LinkedHashSet<SeqNode>>();
    Iterator<SeqNode> ns = startNodes.iterator();
    while (ns.hasNext()) {
      SeqNode n = ns.next();
      SeqPhase p = graph.getPhase(n);
      initNodeDests(p, n);
    }
    System.err.println("  nodeDests=" + nodeDests);
  }
Esempio n. 30
0
  /** {@inheritDoc} */
  @Override()
  public void toString(StringBuilder buffer) {
    buffer.append("DynamicGroup(dn=");
    buffer.append(groupEntryDN);
    buffer.append(",urls={");

    if (!memberURLs.isEmpty()) {
      Iterator<LDAPURL> iterator = memberURLs.iterator();
      buffer.append("\"");
      iterator.next().toString(buffer, false);

      while (iterator.hasNext()) {
        buffer.append("\", ");
        iterator.next().toString(buffer, false);
      }

      buffer.append("\"");
    }

    buffer.append("})");
  }