@NotNull
  @Override
  public SuggestedNameInfo suggestUniqueVariableName(
      @NotNull final SuggestedNameInfo baseNameInfo,
      PsiElement place,
      boolean ignorePlaceName,
      boolean lookForward) {
    final String[] names = baseNameInfo.names;
    final LinkedHashSet<String> uniqueNames = new LinkedHashSet<String>(names.length);
    for (String name : names) {
      if (ignorePlaceName && place instanceof PsiNamedElement) {
        final String placeName = ((PsiNamedElement) place).getName();
        if (Comparing.strEqual(placeName, name)) {
          uniqueNames.add(name);
          continue;
        }
      }
      uniqueNames.add(suggestUniqueVariableName(name, place, lookForward));
    }

    return new SuggestedNameInfo(ArrayUtil.toStringArray(uniqueNames)) {
      @Override
      public void nameChosen(String name) {
        baseNameInfo.nameChosen(name);
      }
    };
  }
 public static void determineDependencies(AbstractMetadataRecord p, Command command) {
   Collection<GroupSymbol> groups =
       GroupCollectorVisitor.getGroupsIgnoreInlineViewsAndEvaluatableSubqueries(command, true);
   LinkedHashSet<AbstractMetadataRecord> values = new LinkedHashSet<AbstractMetadataRecord>();
   for (GroupSymbol group : groups) {
     Object mid = group.getMetadataID();
     if (mid instanceof TempMetadataAdapter) {
       mid = ((TempMetadataID) mid).getOriginalMetadataID();
     }
     if (mid instanceof AbstractMetadataRecord) {
       values.add((AbstractMetadataRecord) mid);
     }
   }
   Collection<ElementSymbol> elems = ElementCollectorVisitor.getElements(command, true, true);
   for (ElementSymbol elem : elems) {
     Object mid = elem.getMetadataID();
     if (mid instanceof TempMetadataAdapter) {
       mid = ((TempMetadataID) mid).getOriginalMetadataID();
     }
     if (mid instanceof AbstractMetadataRecord) {
       values.add((AbstractMetadataRecord) mid);
     }
   }
   p.setIncomingObjects(new ArrayList<AbstractMetadataRecord>(values));
 }
示例#3
0
  public static LinkedHashSet<String> disintegrate(
      String text,
      String origText,
      LinkedHashSet<String> set,
      int inputLength,
      int origLength,
      int subStrLength,
      int pos) {
    if (text.length() < subStrLength) {
      set.add(
          (subStrLength < inputLength)
              ? origText.substring(0, subStrLength + 1)
              : origText.substring(0, subStrLength));
      return set;
    }
    if (subStrLength <= text.length()) set.add(text.substring(0, subStrLength));

    disintegrate(
        text.substring(pos),
        origText,
        set,
        inputLength,
        text.substring(1).length(),
        subStrLength,
        pos);
    disintegrate(
        origText.substring(pos),
        origText,
        set,
        inputLength,
        origText.length(),
        ++subStrLength,
        pos);
    return set;
  }
示例#4
0
 @SuppressWarnings("unchecked")
 @Override
 public String toString() {
   LinkedHashSet<Field> fields = new LinkedHashSet<Field>();
   for (FieldSpec<KeyAnn> spec : getJsonKeySpecs(getClass())) {
     fields.add(spec.field);
   }
   if (this instanceof Entity) {
     for (FieldSpec<ColumnAnn> spec : getTableColumnSpecs((Class<? extends Entity>) getClass())) {
       fields.add(spec.field);
     }
   }
   StringBuilder sb = new StringBuilder();
   ArrayList<String> fieldVals = new ArrayList<String>();
   for (Field field : fields) {
     sb.append(field.getName()).append(": ");
     try {
       sb.append(getFieldVal(this, field));
     } catch (Exception e) {
       sb.append("n/a");
     }
     fieldVals.add(sb.toString());
     sb.setLength(0);
   }
   sb.append(getClass().getSimpleName());
   sb.append(" [");
   sb.append(join(fieldVals, ", "));
   sb.append("]");
   return sb.toString();
 }
  public void test_toArray$Ljava_lang_Object() {
    LinkedHashSet<Integer> lhs = new LinkedHashSet<Integer>();
    lhs.add(new Integer(1));
    lhs.add(new Integer(6));
    lhs.add(new Integer(7));
    lhs.add(new Integer(8));
    lhs.add(new Integer(9));
    lhs.add(new Integer(10));
    lhs.add(new Integer(11));
    lhs.add(new Integer(12));
    lhs.add(new Integer(13));

    Object[] o1 = new Object[lhs.size()];
    Object[] o2 = new Double[lhs.size()];
    lhs.toArray(o1);
    for (int i = 0; i < o1.length; i++) {
      assertTrue(lhs.contains(o1[i]));
    }

    try {
      lhs.toArray(null);
      fail("NullPointerException expected");
    } catch (NullPointerException e) {
      // expected
    }

    try {
      lhs.toArray(o2);
      fail("ArrayStoreException expected");
    } catch (ArrayStoreException e) {
      // expected
    }
  }
 protected Set<ToutElement> listeAny(final String namespace, final String targetNamespace) {
   final LinkedHashSet<ToutElement> liste = new LinkedHashSet<ToutElement>();
   if (namespace == null || "".equals(namespace) || "##any".equals(namespace)) {
     for (final WXSElement el : lTousElements)
       if (el.getName() != null && el.getRef() == null && !el.getAbstract()) liste.add(el);
   } else if ("##local".equals(namespace)) {
     for (final WXSElement el : lTousElements) {
       if (el.getName() != null && el.getRef() == null && !el.getAbstract()) {
         final String tns = el.getNamespace();
         if (tns == null || tns.equals(targetNamespace)) liste.add(el);
       }
     }
   } else if ("##other".equals(namespace)) {
     final ArrayList<Element> references = cfg.listeElementsHorsEspace(targetNamespace);
     for (Element ref : references) liste.add(new ElementExterne(ref, cfg));
   } else {
     // liste d'espaces de noms s?par?s par des espaces
     final HashSet<String> espaces = new HashSet<String>(Arrays.asList(namespace.split("\\s")));
     if (espaces.contains("##targetNamespace")) {
       espaces.remove("##targetNamespace");
       espaces.add(targetNamespace);
     }
     if (espaces.contains("##local")) {
       espaces.remove("##local");
       espaces.add("");
     }
     final ArrayList<Element> references = cfg.listeElementsDansEspaces(espaces);
     for (Element ref : references) liste.add(new ElementExterne(ref, cfg));
   }
   return (liste);
 }
  /**
   * Creates a map which provides project ids for each working set. If the working set is an
   * AggregateWorkingSet then these are the ids of (simple) working sets. Otherwise these are ids of
   * the contained projects.
   *
   * @return
   */
  private Map<String, Set<String>> getWorkingSetTable() {
    LinkedHashMap<String, Set<String>> table = new LinkedHashMap<String, Set<String>>();

    Map<String, IWorkingSet> workingSetMap = getWorkingSetMap();
    for (String wsId : workingSetMap.keySet()) {
      if (wsId == null) {
        System.err.println("Illegal AggregateWorkingSet: key is null");
        continue;
      }
      IWorkingSet ws = workingSetMap.get(wsId);
      LinkedHashSet<String> ids = new LinkedHashSet<String>();
      if (ws instanceof IAggregateWorkingSet) {
        IWorkingSet[] components = ((IAggregateWorkingSet) ws).getComponents();
        for (IWorkingSet _ws : components) {

          if (_ws == null) {
            System.err.println("Illegal AggregateWorkingSet: null component in " + wsId);
            continue;
          }

          String _wsId = _ws.getName();
          ids.add(_wsId);
        }
      } else {
        IAdaptable[] elements = ws.getElements();
        for (IAdaptable e : elements) {
          String pId = ((IProject) e).getName();
          ids.add(pId);
        }
      }
      table.put(wsId, ids);
    }

    return table;
  }
  /**
   * Test importing of Clinical Data File.
   *
   * @throws DaoException Database Access Error.
   * @throws IOException IO Error.
   */
  @Test
  @Ignore("To be fixed")
  public void testImportClinicalDataSurvival() throws Exception {

    // TBD: change this to use getResourceAsStream()
    File clinicalFile = new File("target/test-classes/clinical_data.txt");
    ImportClinicalData importClinicalData = new ImportClinicalData(study, clinicalFile);
    importClinicalData.importData();

    LinkedHashSet<String> caseSet = new LinkedHashSet<String>();
    caseSet.add("TCGA-A1-A0SB");
    caseSet.add("TCGA-A1-A0SI");
    caseSet.add("TCGA-A1-A0SE");

    List<Patient> clinicalCaseList =
        DaoClinicalData.getSurvivalData(study.getInternalId(), caseSet);
    assertEquals(3, clinicalCaseList.size());

    Patient clinical0 = clinicalCaseList.get(0);
    assertEquals(new Double(79.04), clinical0.getAgeAtDiagnosis());
    assertEquals("DECEASED", clinical0.getOverallSurvivalStatus());
    assertEquals("Recurred/Progressed", clinical0.getDiseaseFreeSurvivalStatus());
    assertEquals(new Double(43.8), clinical0.getOverallSurvivalMonths());
    assertEquals(new Double(15.05), clinical0.getDiseaseFreeSurvivalMonths());

    Patient clinical1 = clinicalCaseList.get(1);
    assertEquals(new Double(55.53), clinical1.getAgeAtDiagnosis());
    assertEquals("LIVING", clinical1.getOverallSurvivalStatus());
    assertEquals("DiseaseFree", clinical1.getDiseaseFreeSurvivalStatus());
    assertEquals(new Double(49.02), clinical1.getOverallSurvivalMonths());
    assertEquals(new Double(49.02), clinical1.getDiseaseFreeSurvivalMonths());

    Patient clinical2 = clinicalCaseList.get(2);
    assertEquals(null, clinical2.getDiseaseFreeSurvivalMonths());
  }
  @SuppressWarnings("rawtypes")
  private boolean addOrderedElement(Ordered adding) {
    boolean added = false;
    E[] tempUnorderedElements = (E[]) this.toArray();
    if (super.contains(adding)) {
      return false;
    }
    super.clear();

    if (tempUnorderedElements.length == 0) {
      added = super.add((E) adding);
    } else {
      Set tempSet = new LinkedHashSet();
      for (E current : tempUnorderedElements) {
        if (current instanceof Ordered) {
          if (this.comparator.compare(adding, current) < 0) {
            added = super.add((E) adding);
            super.add(current);
          } else {
            super.add(current);
          }
        } else {
          tempSet.add(current);
        }
      }
      if (!added) {
        added = super.add((E) adding);
      }
      for (Object object : tempSet) {
        super.add((E) object);
      }
    }
    return added;
  }
 @Test
 public void testCalculaFreteLocalDiferente() {
   LinkedHashSet<Livro> cestaLivro = new LinkedHashSet<Livro>();
   cestaLivro.add(new Livro(0, "Guia do exame SCJP", 1));
   cestaLivro.add(new Livro(1, "Dominando Hibernate", 2));
   assertEquals("Entrega em 15 dias", new Livro().checkout(cestaLivro, "BA", "SP"));
 }
示例#11
0
  /**
   * Sets up the fixture, for example, open a network connection. This method is called before a
   * test is executed.
   */
  protected void setUp() {
    objArray = new Object[1000];
    for (int i = 0; i < objArray.length; i++) objArray[i] = new Integer(i);

    hs = new LinkedHashSet();
    for (int i = 0; i < objArray.length; i++) hs.add(objArray[i]);
    hs.add(null);
  }
  /** Format deadlock displaying to a user. */
  public static String prettyFormat(Collection<Dependency> deadlock) {
    StringBuilder text = new StringBuilder();
    LinkedHashSet<LocalThread> threads = new LinkedHashSet<LocalThread>();

    Set<Object> seenDependers = new HashSet<>();
    Object lastDependsOn = text;
    Object lastDepender = text;

    for (Dependency dep : deadlock) {
      Object depender = dep.getDepender();
      Object dependsOn = dep.getDependsOn();

      String dependerString;
      if (lastDependsOn.equals(depender)) {
        dependerString = "which";
      } else if (lastDepender.equals(depender)) {
        dependerString = "and";
      } else {
        dependerString = String.valueOf(depender);
      }
      lastDepender = depender;
      lastDependsOn = dependsOn;

      String also = seenDependers.contains(depender) ? " also" : "";
      seenDependers.add(depender);

      if (depender instanceof LocalThread) {
        text.append(dependerString)
            .append(" is")
            .append(also)
            .append(" waiting on ")
            .append(dependsOn)
            .append("\n");
        threads.add((LocalThread) depender);
      } else if (dependsOn instanceof LocalThread) {
        text.append(dependerString).append(" is held by thread ").append(dependsOn).append("\n");
        threads.add((LocalThread) dependsOn);
      } else {
        text.append(dependerString)
            .append(" is")
            .append(also)
            .append(" waiting for ")
            .append(dependsOn)
            .append("\n");
      }
      text.append("\n");
    }

    text.append("\nStack traces for involved threads\n");
    for (LocalThread threadInfo : threads) {
      text.append(threadInfo.getLocatility())
          .append(":")
          .append(threadInfo.getThreadStack())
          .append("\n\n");
    }

    return text.toString();
  }
示例#13
0
 /** java.util.LinkedHashSet#add(java.lang.Object) */
 public void test_addLjava_lang_Object() {
   // Test for method boolean java.util.LinkedHashSet.add(java.lang.Object)
   int size = hs.size();
   hs.add(new Integer(8));
   assertTrue("Added element already contained by set", hs.size() == size);
   hs.add(new Integer(-9));
   assertTrue("Failed to increment set size after add", hs.size() == size + 1);
   assertTrue("Failed to add element to set", hs.contains(new Integer(-9)));
 }
示例#14
0
  /**
   * Insert the method's description here. Creation date: (21.12.2000 22:24:23)
   *
   * @return boolean
   * @param object com.cosylab.vdct.graphics.objects.VisibleObject
   * @param zoomOnHilited sets the option whether the hilited object should be zoomed in
   */
  public boolean setAsHilited(VisibleObject object, boolean zoomOnHilited) {
    this.zoomOnHilited = zoomOnHilited;

    if (zoomOnHilited) {
      DrawingSurface.getInstance().repaint();
      hilitedObjects.clear();
      if (hilitedObject != null) {
        hilitedObjects.add(hilitedObject);
      }
    }

    if (object == null) {
      hilitedObjects.clear();
      hilitedObject = null;
      return false;
    }

    if (object != hilitedObject || hilitedObjects.size() == 1) {

      hilitedObject = object;

      // initialization
      hilitedObjects.clear();
      hilitedObjects.add(hilitedObject);
      Object obj = hilitedObject;

      // inlinks
      Vector outlinks = null;
      if (obj instanceof MultiInLink) {
        outlinks = ((MultiInLink) obj).getOutlinks();
      } else if (obj instanceof InLink) {
        outlinks = new Vector();
        outlinks.add(((InLink) obj).getOutput());
      }

      if (!zoomOnHilited) {
        if (outlinks != null)
          for (int i = 0; i < outlinks.size(); i++) {
            obj = outlinks.elementAt(i);
            hilitedObjects.add(obj);
            while (obj instanceof InLink) {
              obj = ((InLink) obj).getOutput();
              hilitedObjects.add(obj);
            }
          }

        // outLinks
        obj = hilitedObject;
        while (obj instanceof OutLink) {
          obj = ((OutLink) obj).getInput();
          hilitedObjects.add(obj);
        }
      }
      return true;
    } else return false;
  }
 @Override
 public Set<Object> getSingletons() {
   LinkedHashSet<Object> instances = new LinkedHashSet<Object>();
   instances.add(StreamingOutputProvider); // provider
   instances.add(new BadResource()); // simulate resource exception
   instances.add("bla-bla"); // should be ignored
   instances.add(new BadProvider()); // simulate provider exception
   instances.add(rootResource); // resource
   return instances;
 }
 @Test
 public void testCalculaMaisUmKg() {
   LinkedHashSet<Livro> cestaLivro = new LinkedHashSet<Livro>();
   cestaLivro.add(new Livro(0, "Guia do exame SCJP", 1));
   cestaLivro.add(new Livro(1, "Dominando Hibernate", 2));
   cestaLivro.add(new Livro(3, "TomCat Administrador", 1));
   cestaLivro.add(new Livro(4, "Core JSF 2.0", 1));
   cestaLivro.add(new Livro(5, "Certificação LPI", 1));
   assertEquals("Entrega em 5 dias", new Livro().checkout(cestaLivro, "RJ", "rj"));
 }
  /**
   * Builds a list of components (Component) for a form that are ordered in the default focus order.
   */
  public static LinkedHashSet buildDefaultFocusPolicy(FormComponent fc) {
    System.out.println("buildDefaultFocusPolicy  form: " + fc.getId());

    final FormComponent theform = fc;
    LinkedHashSet default_policy = new LinkedHashSet();
    LayoutFocusTraversalPolicy policy =
        new LayoutFocusTraversalPolicy() {
          protected boolean accept(Component aComponent) {
            if (aComponent instanceof StandardComponent) {
              if (((StandardComponent) aComponent).getBeanDelegate() == null) return false;
            }

            if (aComponent == theform) return super.accept(aComponent);

            if (aComponent instanceof FormComponent) {
              if (((FormComponent) aComponent).isTopLevelForm()) return false;
            }

            if (aComponent instanceof JTabbedPane) return true;

            if (aComponent != null) {
              /** handle the case for embedded focus cycle roots such as JTabbedPane forms */
              Container cc = aComponent.getParent();
              while (cc != null && cc != theform) {
                if (cc instanceof FormContainerComponent) {
                  return false;
                }

                cc = cc.getParent();
              }
            }
            return super.accept(aComponent);
          }
        };
    Component comp = policy.getFirstComponent(fc);
    Component last_comp = policy.getLastComponent(fc);
    while (true) {

      /** Don't add scroll pane in design mode since the scroll bars might not be visible */
      if (FormUtils.isDesignMode()) {
        if (!(comp instanceof JScrollPane) && !(comp instanceof JScrollBar)) {
          default_policy.add(comp);
        }
      } else {
        default_policy.add(comp);
      }

      if (comp == last_comp) break;

      System.out.println("FormFocusManager.getComponentAfter: " + comp.getClass());
      comp = policy.getComponentAfter(fc, comp);
    }

    return default_policy;
  }
示例#18
0
    /*
     * @see java.util.HashSet#add(java.lang.Object)
     */
    @Override
    public boolean add(E o) {
      if (remove(o)) {
        super.add(o);
        return false;
      }

      if (size() >= fMaxSize) remove(this.iterator().next());

      super.add(o);
      return true;
    }
  public ClassLoaderServiceImpl(
      ClassLoader applicationClassLoader,
      ClassLoader resourcesClassLoader,
      ClassLoader hibernateClassLoader,
      ClassLoader environmentClassLoader) {
    this.classLoadingClassLoaders = new LinkedHashSet<ClassLoader>();
    classLoadingClassLoaders.add(applicationClassLoader);
    classLoadingClassLoaders.add(hibernateClassLoader);
    classLoadingClassLoaders.add(environmentClassLoader);

    this.resourcesClassLoader = resourcesClassLoader;
  }
示例#20
0
  @Override
  public Set<String> keySet() {
    LinkedHashSet<String> set = new LinkedHashSet<>();

    set.add("database");
    set.add("table");
    for (String key : this.pkKeys) {
      set.add(key);
    }

    return set;
  }
示例#21
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;
  }
示例#22
0
    public void addFile(File file, boolean warn) {
      if (contains(file)) {
        // discard duplicates
        return;
      }

      if (!fsInfo.exists(file)) {
        /* No such file or directory exists */
        if (warn) {
          log.warning(Lint.LintCategory.PATH, "path.element.not.found", file);
        }
        super.add(file);
        return;
      }

      File canonFile = fsInfo.getCanonicalFile(file);
      if (canonicalValues.contains(canonFile)) {
        /* Discard duplicates and avoid infinite recursion */
        return;
      }

      if (fsInfo.isFile(file)) {
        /* File is an ordinary file. */
        if (!isArchive(file)) {
          /* Not a recognized extension; open it to see if
          it looks like a valid zip file. */
          try {
            ZipFile z = new ZipFile(file);
            z.close();
            if (warn) {
              log.warning(Lint.LintCategory.PATH, "unexpected.archive.file", file);
            }
          } catch (IOException e) {
            // FIXME: include e.getLocalizedMessage in warning
            if (warn) {
              log.warning(Lint.LintCategory.PATH, "invalid.archive.file", file);
            }
            return;
          }
        }
      }

      /* Now what we have left is either a directory or a file name
      conforming to archive naming convention */
      super.add(file);
      canonicalValues.add(canonFile);

      if (expandJarClassPaths && fsInfo.isFile(file)) addJarClassPath(file, warn);
    }
  public static void main(String a[]) {

    LinkedHashSet<String> lhs = new LinkedHashSet<String>();

    // add elements to HashSet
    lhs.add("first");
    lhs.add("second");
    lhs.add("third");
    System.out.println("My LinkedHashSet content:");
    System.out.println(lhs);
    System.out.println("Clearing LinkedHashSet:");
    lhs.clear();
    System.out.println("Content After clear:");
    System.out.println(lhs);
  }
 public static <I, S extends AbstractNode<I, S>> LinkedHashSet<S> findAllowedRootsByAffectedNodes(
     TreeAndParentMap<I, S> tree, Set<S> affectedNodes) {
   final S treeRoot = tree.getTree();
   final Map<S, S> parentMap = tree.getParentMap();
   LinkedHashSet<S> ret = new LinkedHashSet<>();
   for (S affectedNode : affectedNodes) {
     S node = affectedNode;
     while (node != treeRoot) {
       ret.add(node);
       node = parentMap.get(node);
     }
     ret.add(node);
   }
   return ret;
 }
示例#25
0
  public static LinkedHashSet<String> findJars(LogicalPlan dag, Class<?>[] defaultClasses) {
    List<Class<?>> jarClasses = new ArrayList<Class<?>>();

    for (String className : dag.getClassNames()) {
      try {
        Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
        jarClasses.add(clazz);
      } catch (ClassNotFoundException e) {
        throw new IllegalArgumentException("Failed to load class " + className, e);
      }
    }

    for (Class<?> clazz : Lists.newArrayList(jarClasses)) {
      // process class and super classes (super does not require deploy annotation)
      for (Class<?> c = clazz; c != Object.class && c != null; c = c.getSuperclass()) {
        // LOG.debug("checking " + c);
        jarClasses.add(c);
        jarClasses.addAll(Arrays.asList(c.getInterfaces()));
      }
    }

    jarClasses.addAll(Arrays.asList(defaultClasses));

    if (dag.isDebug()) {
      LOG.debug("Deploy dependencies: {}", jarClasses);
    }

    LinkedHashSet<String> localJarFiles = new LinkedHashSet<String>(); // avoid duplicates
    HashMap<String, String> sourceToJar = new HashMap<String, String>();

    for (Class<?> jarClass : jarClasses) {
      if (jarClass.getProtectionDomain().getCodeSource() == null) {
        // system class
        continue;
      }
      String sourceLocation =
          jarClass.getProtectionDomain().getCodeSource().getLocation().toString();
      String jar = sourceToJar.get(sourceLocation);
      if (jar == null) {
        // don't create jar file from folders multiple times
        jar = JarFinder.getJar(jarClass);
        sourceToJar.put(sourceLocation, jar);
        LOG.debug("added sourceLocation {} as {}", sourceLocation, jar);
      }
      if (jar == null) {
        throw new AssertionError("Cannot resolve jar file for " + jarClass);
      }
      localJarFiles.add(jar);
    }

    String libJarsPath = dag.getValue(LogicalPlan.LIBRARY_JARS);
    if (!StringUtils.isEmpty(libJarsPath)) {
      String[] libJars = StringUtils.splitByWholeSeparator(libJarsPath, LIB_JARS_SEP);
      localJarFiles.addAll(Arrays.asList(libJars));
    }

    LOG.info("Local jar file dependencies: " + localJarFiles);

    return localJarFiles;
  }
    public LinkedHashSet<Path> scan(FileSystem fs, Path filePath, Set<String> consumedFiles) {
      LinkedHashSet<Path> pathSet = Sets.newLinkedHashSet();
      try {
        LOG.debug("Scanning {} with pattern {}", filePath, this.filePatternRegexp);
        FileStatus[] files = fs.listStatus(filePath);
        for (FileStatus status : files) {
          Path path = status.getPath();
          String filePathStr = path.toString();

          if (consumedFiles.contains(filePathStr)) {
            continue;
          }

          if (ignoredFiles.contains(filePathStr)) {
            continue;
          }

          if (acceptFile(filePathStr)) {
            LOG.debug("Found {}", filePathStr);
            pathSet.add(path);
          } else {
            // don't look at it again
            ignoredFiles.add(filePathStr);
          }
        }
      } catch (FileNotFoundException e) {
        LOG.warn("Failed to list directory {}", filePath, e);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return pathSet;
    }
示例#27
0
  /** {@inheritDoc} */
  @Override()
  public DynamicGroup newInstance(Entry groupEntry) throws DirectoryException {
    ensureNotNull(groupEntry);

    // Get the memberURL attribute from the entry, if there is one, and parse
    // out the LDAP URLs that it contains.
    LinkedHashSet<LDAPURL> memberURLs = new LinkedHashSet<LDAPURL>();
    AttributeType memberURLType = DirectoryConfig.getAttributeType(ATTR_MEMBER_URL_LC, true);
    List<Attribute> attrList = groupEntry.getAttribute(memberURLType);
    if (attrList != null) {
      for (Attribute a : attrList) {
        for (AttributeValue v : a) {
          try {
            memberURLs.add(LDAPURL.decode(v.getValue().toString(), true));
          } catch (DirectoryException de) {
            if (debugEnabled()) {
              TRACER.debugCaught(DebugLogLevel.ERROR, de);
            }

            Message message =
                ERR_DYNAMICGROUP_CANNOT_DECODE_MEMBERURL.get(
                    v.getValue().toString(),
                    String.valueOf(groupEntry.getDN()),
                    de.getMessageObject());
            ErrorLogger.logError(message);
          }
        }
      }
    }

    return new DynamicGroup(groupEntry.getDN(), memberURLs);
  }
 /**
  * The place where feature sets get added to the classification run. If you're building a new
  * feature set, put the symbol here and the add code that instantiates the class after the
  * appropriate case statement and add a break
  *
  * @param featureSetName
  */
 public void addFeatureSet(FeatureSetName featureSetName) {
   switch (featureSetName) {
     case ColorRingScores:
       feature_sets.add(new ColorRingScores());
       break;
     case ColorDiameterScores:
       feature_sets.add(new ColorDiameterScores());
       break;
     case MaxLineScores:
       feature_sets.add(new MaxLineScores());
       break;
     case EdgeRingScores:
       feature_sets.add(new EdgeRingScores());
       break;
   }
 }
示例#29
0
 @Override
 public void run() {
   timer.scheduleAtFixedRate(
       new TimerTask() {
         @Override
         public void run() {
           for (String ip : ips) {
             int idx = Math.abs(ip.hashCode() % ip_cnts.length);
             if (ip_cnts[idx] > DISC_THRESHOLD) {
               log.warning("Many disconnects for IP: " + ip + " - " + ip_cnts[idx]);
             }
             ip_cnts[idx] = 0;
           }
         }
       },
       CLEANUP_RATE,
       CLEANUP_RATE);
   while (!stopped) {
     try {
       String ip = queue.poll(10, TimeUnit.SECONDS);
       if (ip != null) {
         int idx = Math.abs(ip.hashCode()) % ip_cnts.length;
         ++ip_cnts[idx];
         if (ips.size() < MAX_SIZE) {
           ips.add(ip);
         }
       }
     } catch (Exception e) {
       log.warning("Error processing queue: " + e);
     }
   }
   timer.cancel();
 }
 public void bePatternConfiguration(List<PsiClass> classes, PsiMethod method) {
   data.TEST_OBJECT = TestType.PATTERN.getType();
   final String suffix;
   if (method != null) {
     data.METHOD_NAME = method.getName();
     suffix = "," + data.METHOD_NAME;
   } else {
     suffix = "";
   }
   LinkedHashSet<String> patterns = new LinkedHashSet<String>();
   for (PsiClass pattern : classes) {
     patterns.add(JavaExecutionUtil.getRuntimeQualifiedName(pattern) + suffix);
   }
   data.setPatterns(patterns);
   final Module module =
       RunConfigurationProducer.getInstance(TestNGPatternConfigurationProducer.class)
           .findModule(this, getConfigurationModule().getModule(), patterns);
   if (module == null) {
     data.setScope(TestSearchScope.WHOLE_PROJECT);
     setModule(null);
   } else {
     setModule(module);
   }
   setGeneratedName();
 }