Esempio n. 1
0
  public static void testAllEqual() {
    Address[] mbrs = Util.createRandomAddresses(5);
    View[] views = {
      View.create(mbrs[0], 1, mbrs), View.create(mbrs[0], 1, mbrs), View.create(mbrs[0], 1, mbrs)
    };

    boolean same = Util.allEqual(Arrays.asList(views));
    System.out.println("views=" + Arrays.toString(views) + ", same = " + same);
    assert same;

    views =
        new View[] {
          View.create(mbrs[0], 1, mbrs),
          View.create(mbrs[0], 2, mbrs),
          View.create(mbrs[0], 1, mbrs)
        };
    same = Util.allEqual(Arrays.asList(views));
    System.out.println("views=" + Arrays.toString(views) + ", same = " + same);
    assert !same;

    views =
        new View[] {
          View.create(mbrs[1], 1, mbrs),
          View.create(mbrs[0], 1, mbrs),
          View.create(mbrs[0], 1, mbrs)
        };
    same = Util.allEqual(Arrays.asList(views));
    System.out.println("views=" + Arrays.toString(views) + ", same = " + same);
    assert !same;
  }
Esempio n. 2
0
  /**
   * Creates a java process that executes the given main class and waits for the process to
   * terminate.
   *
   * @return a {@link ProcessOutputReader} that can be used to get the exit code and stdout+stderr
   *     of the terminated process.
   */
  public static ProcessOutputReader fg(Class main, String[] vmArgs, String[] mainArgs)
      throws IOException {
    File javabindir = new File(System.getProperty("java.home"), "bin");
    File javaexe = new File(javabindir, "java");

    int bits = Integer.getInteger("sun.arch.data.model", 0).intValue();
    String vmKindArg = (bits == 64) ? "-d64" : null;

    ArrayList argList = new ArrayList();
    argList.add(javaexe.getPath());
    if (vmKindArg != null) {
      argList.add(vmKindArg);
    }
    // argList.add("-Dgemfire.systemDirectory=" +
    // GemFireConnectionFactory.getDefaultSystemDirectory());
    argList.add("-Djava.class.path=" + System.getProperty("java.class.path"));
    argList.add("-Djava.library.path=" + System.getProperty("java.library.path"));
    if (vmArgs != null) {
      argList.addAll(Arrays.asList(vmArgs));
    }
    argList.add(main.getName());
    if (mainArgs != null) {
      argList.addAll(Arrays.asList(mainArgs));
    }
    String[] cmd = (String[]) argList.toArray(new String[argList.size()]);
    return new ProcessOutputReader(Runtime.getRuntime().exec(cmd));
  }
  public List<String> find() throws IOException {
    //		Set<String> g1 = new HashSet<String>(Arrays.asList("HRAS", "NRAS", "KRAS"));
    //		Set<String> g2 = new HashSet<String>(Arrays.asList("BRAF"));

    Set<String> g1 = new HashSet<String>(Arrays.asList("HRAS"));
    Set<String> g2 = new HashSet<String>(Arrays.asList("NRAS", "KRAS"));

    Map<String, Double> pvals = calcDifferencePvals(g1, g2);

    System.out.println("pvals.size() = " + pvals.size());

    List<String> list = FDR.select(pvals, null, fdrThr);
    System.out.println("result size = " + list.size());

    Map<String, Boolean> dirs = getChangeDirections(list, g1, g2);

    int up = 0;
    int dw = 0;

    for (String gene : dirs.keySet()) {
      Boolean d = dirs.get(gene);
      if (d) up++;
      else dw++;
    }

    System.out.println("up = " + up);
    System.out.println("dw = " + dw);

    return list;
  }
Esempio n. 4
0
 /**
  * get parameter names of given {@code constructor}
  *
  * <p>depends on MethodParameterNamesScanner configured
  */
 public List<String> getConstructorParamNames(Constructor constructor) {
   Iterable<String> names =
       store.get(index(MethodParameterNamesScanner.class), Utils.name(constructor));
   return !Iterables.isEmpty(names)
       ? Arrays.asList(Iterables.getOnlyElement(names).split(", "))
       : Arrays.<String>asList();
 }
 public static void main(String[] args) {
   LetterToSound text = LetterToSound.getInstance();
   System.out.println(Arrays.asList(text.getPhones("laggin", "n")));
   System.out.println(Arrays.asList(text.getPhones("dragon", "n")));
   System.out.println(Arrays.asList(text.getPhones("hello", "n")));
   // System.out.println(Arrays.asList(text.getPhones("antelope", "n")));
 }
Esempio n. 6
0
  void test(String[] opts, String className) throws Exception {
    count++;
    System.err.println("Test " + count + " " + Arrays.asList(opts) + " " + className);
    Path testSrcDir = Paths.get(System.getProperty("test.src"));
    Path testClassesDir = Paths.get(System.getProperty("test.classes"));
    Path classes = Paths.get("classes." + count);
    classes.createDirectory();

    Context ctx = new Context();
    PathFileManager fm = new JavacPathFileManager(ctx, true, null);
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    List<String> options = new ArrayList<String>();
    options.addAll(Arrays.asList(opts));
    options.addAll(Arrays.asList("-verbose", "-XDverboseCompilePolicy", "-d", classes.toString()));
    Iterable<? extends JavaFileObject> compilationUnits =
        fm.getJavaFileObjects(testSrcDir.resolve(className + ".java"));
    StringWriter sw = new StringWriter();
    PrintWriter out = new PrintWriter(sw);
    JavaCompiler.CompilationTask t =
        compiler.getTask(out, fm, null, options, null, compilationUnits);
    boolean ok = t.call();
    System.err.println(sw.toString());
    if (!ok) {
      throw new Exception("compilation failed");
    }

    File expect = new File("classes." + count + "/" + className + ".class");
    if (!expect.exists()) throw new Exception("expected file not found: " + expect);
    long expectedSize = new File(testClassesDir.toString(), className + ".class").length();
    long actualSize = expect.length();
    if (expectedSize != actualSize)
      throw new Exception("wrong size found: " + actualSize + "; expected: " + expectedSize);
  }
Esempio n. 7
0
  public static void main(String... args) throws Throwable {
    String testSrcDir = System.getProperty("test.src");
    String testClassDir = System.getProperty("test.classes");
    String self = T6361619.class.getName();

    JavacTool tool = JavacTool.create();

    final PrintWriter out = new PrintWriter(System.err, true);

    Iterable<String> flags =
        Arrays.asList(
            "-processorpath", testClassDir,
            "-processor", self,
            "-d", ".");
    DiagnosticListener<JavaFileObject> dl =
        new DiagnosticListener<JavaFileObject>() {
          public void report(Diagnostic<? extends JavaFileObject> m) {
            out.println(m);
          }
        };

    StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
    Iterable<? extends JavaFileObject> f =
        fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));

    JavacTask task = tool.getTask(out, fm, dl, flags, null, f);
    MyTaskListener tl = new MyTaskListener(task);
    task.setTaskListener(tl);

    // should complete, without exceptions
    task.call();
  }
Esempio n. 8
0
 private void updateJsonJob(ApplicationInfo appInfo, CIJob job) throws PhrescoException {
   try {
     deleteJsonJobs(appInfo, Arrays.asList(job));
     writeJsonJobs(appInfo, Arrays.asList(job), CI_APPEND_JOBS);
   } catch (Exception e) {
     throw new PhrescoException(e);
   }
 }
Esempio n. 9
0
  ///////////
  // Methods//
  ///////////
  public void createServerFile(
      HashMap<String, DataObj> dataObjsMap, HashMap<String, PageObj> pageObjsMap) {
    // Copy files over
    try {
      FileUtils.copyFile(sourceConfig, new File("Output/config.js"));
    } catch (IOException e) {
      System.out.println("Error copying over config file for");
      System.out.println(e);
    }
    out.write(genDbConnection());
    // For each data object, get object by ID
    Iterator it = dataObjsMap.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry one = (Map.Entry) it.next();
      DataObj curDataObj = (DataObj) one.getValue();
      String name = curDataObj.getName();
      out.write("\n /* " + name + ": CRUD GET, DELETE, UPDATE, POST BY ID*/\n");
      out.write(genGetById(curDataObj));
      out.write(genDelById(curDataObj));
      out.write(genUpdateById(curDataObj));
      out.write(genAdd(curDataObj));
    }
    // Hack to get a necessary API call for OAuth stuff
    out.write(
        genGetByPageParam(
            null,
            new Section(
                "View",
                new ArrayList<String>(Arrays.asList(new String[] {"OAuthID"})),
                new ArrayList<String>(Arrays.asList(new String[] {"User"}))),
            dataObjsMap));

    // For each page, generate the calls necessery to make
    // the view/create params work
    it = pageObjsMap.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry one = (Map.Entry) it.next();
      PageObj curPageObj = (PageObj) one.getValue();
      String name = curPageObj.getName();
      out.write("\n /* " + name + ": CRUD GET,DELETE,UPDATE,POST *NOT* BY ID */\n");
      List<Section> sections = curPageObj.getSections();
      for (Section section : sections) {
        switch ((Section.Type) section.getType()) {
          case VIEW:
            out.write(genGetByPageParam(curPageObj, section, dataObjsMap));
            break;
          case CREATE:
            // out.write(genPostByPageParam(curPageObj, section));
            break;
          case MODIFY:
            break;
          case DELETE:
            break;
        }
      }
    }
    out.write(genServerListen());
  }
Esempio n. 10
0
  /**
   * setupPlayZone.
   *
   * @param p a {@link arcane.ui.PlayArea} object.
   * @param c an array of {@link forge.Card} objects.
   */
  public static void setupPlayZone(PlayArea p, Card c[]) {
    List<Card> tmp, diff;
    tmp = new ArrayList<Card>();
    for (arcane.ui.CardPanel cpa : p.cardPanels) tmp.add(cpa.gameCard);
    diff = new ArrayList<Card>(tmp);
    diff.removeAll(Arrays.asList(c));
    if (diff.size() == p.cardPanels.size()) p.clear();
    else {
      for (Card card : diff) {
        p.removeCardPanel(p.getCardPanel(card.getUniqueNumber()));
      }
    }
    diff = new ArrayList<Card>(Arrays.asList(c));
    diff.removeAll(tmp);

    arcane.ui.CardPanel toPanel = null;
    for (Card card : diff) {
      toPanel = p.addCard(card);
      Animation.moveCard(toPanel);
    }

    for (Card card : c) {
      toPanel = p.getCardPanel(card.getUniqueNumber());
      if (card.isTapped()) {
        toPanel.tapped = true;
        toPanel.tappedAngle = arcane.ui.CardPanel.TAPPED_ANGLE;
      } else {
        toPanel.tapped = false;
        toPanel.tappedAngle = 0;
      }
      toPanel.attachedPanels.clear();
      if (card.isEnchanted()) {
        ArrayList<Card> enchants = card.getEnchantedBy();
        for (Card e : enchants) {
          arcane.ui.CardPanel cardE = p.getCardPanel(e.getUniqueNumber());
          if (cardE != null) toPanel.attachedPanels.add(cardE);
        }
      }

      if (card.isEquipped()) {
        ArrayList<Card> enchants = card.getEquippedBy();
        for (Card e : enchants) {
          arcane.ui.CardPanel cardE = p.getCardPanel(e.getUniqueNumber());
          if (cardE != null) toPanel.attachedPanels.add(cardE);
        }
      }

      if (card.isEnchanting()) {
        toPanel.attachedToPanel = p.getCardPanel(card.getEnchanting().get(0).getUniqueNumber());
      } else if (card.isEquipping()) {
        toPanel.attachedToPanel = p.getCardPanel(card.getEquipping().get(0).getUniqueNumber());
      } else toPanel.attachedToPanel = null;

      toPanel.setCard(toPanel.gameCard);
    }
    p.invalidate();
    p.repaint();
  }
 /** descendingkeySet.toArray returns contains all keys */
 public void testDescendingDescendingKeySetToArray() {
   ConcurrentNavigableMap map = dmap5();
   Set s = map.descendingKeySet();
   Object[] ar = s.toArray();
   assertEquals(5, ar.length);
   assertTrue(s.containsAll(Arrays.asList(ar)));
   ar[0] = m10;
   assertFalse(s.containsAll(Arrays.asList(ar)));
 }
Esempio n. 12
0
  public Collection<String> getArguments() {
    Collection<String> args = new ArrayList<>();
    Optional.ofNullable(username).ifPresent(s -> args.addAll(Arrays.asList("-u", s)));
    Optional.ofNullable(password).ifPresent(s -> args.addAll(Arrays.asList("-p", s)));
    Optional.ofNullable(from)
        .ifPresent(d -> args.addAll(Arrays.asList("-f", d.format(DateTimeFormatter.ISO_DATE))));

    return args;
  }
Esempio n. 13
0
    public static String _c1(c1options x) {

      assertEquals(true, x.flag());
      assertEquals(33, x.a());
      assertEquals("bb", x.bb(), "bb");
      assertEquals(Arrays.asList(new File("f1.txt"), new File("f2.txt")), x.input());
      assertEquals(false, x.notset());
      assertEquals(Arrays.asList("-a", "--a", "a"), x._arguments());

      return "a";
    }
Esempio n. 14
0
  public void readFile(String active, String passive) throws IOException {
    if (fileName == null) {
      throw new IOException();
    }

    this.activeCriteria = new ArrayList<>(Arrays.asList(active.split(",")));
    this.passiveCriteria = new ArrayList<>(Arrays.asList(passive.split(",")));

    InputStream is = new FileInputStream(new File(this.fileName));
    workbook = new XSSFWorkbook(is);
    processSheetRows(workbook.getSheetAt(0));
    is.close();
  }
 /**
  * Parses the quantization table from the GATK Report and turns it into a map of original =>
  * quantized quality scores
  *
  * @param table the GATKReportTable containing the quantization mappings
  * @return an ArrayList with the quantization mappings from 0 to MAX_SAM_QUAL_SCORE
  */
 private QuantizationInfo initializeQuantizationTable(GATKReportTable table) {
   final Byte[] quals = new Byte[QualityUtils.MAX_SAM_QUAL_SCORE + 1];
   final Long[] counts = new Long[QualityUtils.MAX_SAM_QUAL_SCORE + 1];
   for (int i = 0; i < table.getNumRows(); i++) {
     final byte originalQual = (byte) i;
     final Object quantizedObject = table.get(i, RecalUtils.QUANTIZED_VALUE_COLUMN_NAME);
     final Object countObject = table.get(i, RecalUtils.QUANTIZED_COUNT_COLUMN_NAME);
     final byte quantizedQual = Byte.parseByte(quantizedObject.toString());
     final long quantizedCount = Long.parseLong(countObject.toString());
     quals[originalQual] = quantizedQual;
     counts[originalQual] = quantizedCount;
   }
   return new QuantizationInfo(Arrays.asList(quals), Arrays.asList(counts));
 }
Esempio n. 16
0
  /**
   * Remove files if needed to make cache have less than maxBytes bytes file sizes. This will remove
   * files in sort order defined by fileComparator. The first files in the sort order are kept,
   * until the max bytes is exceeded, then they are deleted.
   *
   * @param maxBytes max number of bytes in cache.
   * @param fileComparator sort files first with this
   * @param sbuff write results here, null is ok.
   */
  public static void cleanCache(
      long maxBytes, Comparator<File> fileComparator, StringBuilder sbuff) {
    if (sbuff != null)
      sbuff.append("DiskCache clean maxBytes= " + maxBytes + "on dir " + root + "\n");

    File dir = new File(root);
    File[] files = dir.listFiles();
    List<File> fileList = Arrays.asList(files);
    Collections.sort(fileList, fileComparator);

    long total = 0, total_delete = 0;
    for (File file : fileList) {
      if (file.length() + total > maxBytes) {
        total_delete += file.length();
        if (sbuff != null) sbuff.append(" delete " + file + " (" + file.length() + ")\n");
        file.delete();
      } else {
        total += file.length();
      }
    }
    if (sbuff != null) {
      sbuff.append("Total bytes deleted= " + total_delete + "\n");
      sbuff.append("Total bytes left in cache= " + total + "\n");
    }
  }
Esempio n. 17
0
  /**
   * @param fname String filename to read matrix from
   * @return Map of lists, 1 indexed representing the adjacency matrix
   */
  public Map<Integer, List<Integer>> readAdjacencyMatrix(String fname) {
    Map<Integer, List<Integer>> adjMatrix = new HashMap<>();
    int i = 1;

    try {
      BufferedReader br = new BufferedReader(new FileReader(fname));
      String line;
      while ((line = br.readLine()) != null) {
        List<String> words = Arrays.asList(line.split("\\s*"));
        List<Integer> wordVals = new ArrayList<>();
        for (String w : words) {
          if (w.equals("1") || w.equals("0")) {
            wordVals.add(Integer.parseInt(w));
          }
        }
        adjMatrix.put(i, wordVals);
        i += 1;
      }
      br.close();
      return adjMatrix;
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      return null;
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }
Esempio n. 18
0
 void setFormData(WObject.FormData formData) {
   if (!(formData.values.length == 0)) {
     List<String> attributes = new ArrayList<String>();
     attributes = new ArrayList<String>(Arrays.asList(formData.values[0].split(";")));
     if (attributes.size() == 6) {
       try {
         this.volume_ = Double.parseDouble(attributes.get(0));
       } catch (RuntimeException e) {
         this.volume_ = -1;
       }
       try {
         this.current_ = Double.parseDouble(attributes.get(1));
       } catch (RuntimeException e) {
         this.current_ = -1;
       }
       try {
         this.duration_ = Double.parseDouble(attributes.get(2));
       } catch (RuntimeException e) {
         this.duration_ = -1;
       }
       this.playing_ = attributes.get(3).equals("0");
       this.ended_ = attributes.get(4).equals("1");
       try {
         this.readyState_ = intToReadyState(Integer.parseInt(attributes.get(5)));
       } catch (RuntimeException e) {
         throw new WException(
             "WAbstractMedia: error parsing: " + formData.values[0] + ": " + e.toString());
       }
     } else {
       throw new WException("WAbstractMedia: error parsing: " + formData.values[0]);
     }
   }
 }
Esempio n. 19
0
 /**
  * Invoke a script from the command line.
  *
  * @param scriptResource the script resource of path
  * @param scriptArgs an array of command line arguments
  * @return the return value
  * @throws IOException an I/O related error occurred
  * @throws JavaScriptException the script threw an error during compilation or execution
  */
 public Object runScript(Object scriptResource, String... scriptArgs)
     throws IOException, JavaScriptException {
   Resource resource;
   if (scriptResource instanceof Resource) {
     resource = (Resource) scriptResource;
   } else if (scriptResource instanceof String) {
     resource = findResource((String) scriptResource, null, null);
   } else {
     throw new IOException("Unsupported script resource: " + scriptResource);
   }
   if (!resource.exists()) {
     throw new FileNotFoundException(scriptResource.toString());
   }
   Context cx = contextFactory.enterContext();
   try {
     Object retval;
     Map<Trackable, ReloadableScript> scripts = getScriptCache(cx);
     commandLineArgs = Arrays.asList(scriptArgs);
     ReloadableScript script = new ReloadableScript(resource, this);
     scripts.put(resource, script);
     mainScope = new ModuleScope(resource.getModuleName(), resource, globalScope, mainWorker);
     retval = mainWorker.evaluateScript(cx, script, mainScope);
     mainScope.updateExports();
     return retval instanceof Wrapper ? ((Wrapper) retval).unwrap() : retval;
   } finally {
     Context.exit();
   }
 }
Esempio n. 20
0
 /*
  * Parses the data in the given input stream as a sequence of DER encoded
  * X.509 CRLs (in binary or base 64 encoded format) OR as a single PKCS#7
  * encoded blob (in binary or base 64 encoded format).
  */
 private Collection<? extends java.security.cert.CRL> parseX509orPKCS7CRL(InputStream is)
     throws CRLException, IOException {
   Collection<X509CRLImpl> coll = new ArrayList<>();
   byte[] data = readOneBlock(is);
   if (data == null) {
     return new ArrayList<>(0);
   }
   try {
     PKCS7 pkcs7 = new PKCS7(data);
     X509CRL[] crls = pkcs7.getCRLs();
     // CRLs are optional in PKCS #7
     if (crls != null) {
       return Arrays.asList(crls);
     } else {
       // no crls provided
       return new ArrayList<>(0);
     }
   } catch (ParsingException e) {
     while (data != null) {
       coll.add(new X509CRLImpl(data));
       data = readOneBlock(is);
     }
   }
   return coll;
 }
  @Override
  protected void onStart() {
    final GameBoard boardView = (GameBoard) this.findViewById(R.id.gameBoard);
    SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE);

    this.level = prefs.getInt("level", 0);
    String mapJson = prefs.getString("map", null);

    if (mapJson == null) {
      waitForNext = true;
    } else {
      this.game.initGame(mapJson);
      String howdyPosition = prefs.getString("howdy", null);

      if (howdyPosition != null) {
        this.game.setHowdyPosition(howdyPosition);
      }

      Toast.makeText(this, this.level + "", Toast.LENGTH_SHORT).show();
    }

    String allDoneLevelsString = prefs.getString("doneLevels", null);

    if (allDoneLevelsString != null) {
      allDoneLevels = new ArrayList<String>(Arrays.asList(allDoneLevelsString.split(",")));
    }

    super.onStart();
  }
  // Deze method leest alle zalen in en bepaald hun capaciteit
  public void getRooms() {
    try {
      BufferedReader csvZaalGegevens =
          new BufferedReader(new FileReader("resources/zalen_roostering.csv"));
      String room;
      csvZaalGegevens.readLine();

      while ((room = csvZaalGegevens.readLine()) != null) {
        List<String> gegevensZaal = Arrays.asList(room.split(";"));
        String roomName = gegevensZaal.get(0);
        int capacity = Integer.parseInt(gegevensZaal.get(1));
        if (capacity > 100) {
          List<Activity> list = new ArrayList<>(25);
          for (int i = 0; i < 25; i++) {
            list.add(null);
          }
          Room newRoom = new Room(roomName, capacity, true, list);
          rooms.add(newRoom);
        } else {
          List<Activity> list = new ArrayList<>(2);
          for (int i = 0; i < 20; i++) {
            list.add(null);
          }
          Room newRoom = new Room(roomName, capacity, false, list);
          rooms.add(newRoom);
        }
      }
      csvZaalGegevens.close();
    } catch (IOException e) {
      System.out.println("File Read Error Rooms");
    }
  }
  private int[] getSelectedRows(int[] selectedRowsNumber, Map[] selectedRowsKeys, Tab tab) {
    if (selectedRowsKeys == null || selectedRowsKeys.length == 0) return new int[0];
    // selectedRowsNumber is the most performant so we use it when possible
    else if (selectedRowsNumber.length == selectedRowsKeys.length) return selectedRowsNumber;
    else {
      // find the rows from the selectedKeys

      // This has a poor performance, but it covers the case when the selected
      // rows are not loaded for the tab, something that can occurs if the user
      // select rows and afterwards reorder the list.
      try {
        int[] s = new int[selectedRowsKeys.length];
        List selectedKeys = Arrays.asList(selectedRowsKeys);
        int end = tab.getTableModel().getTotalSize();
        int x = 0;
        for (int i = 0; i < end; i++) {
          Map key = (Map) tab.getTableModel().getObjectAt(i);
          if (selectedKeys.contains(key)) {
            s[x] = i;
            x++;
          }
        }
        return s;
      } catch (Exception ex) {
        log.warn(XavaResources.getString("fails_selected"), ex);
        throw new XavaException("fails_selected");
      }
    }
  }
  private int getNumNonSerialVersionUIDFields(Class clazz) {
    Field[] declaredFields = clazz.getDeclaredFields();
    int numFields = declaredFields.length;
    List<Field> fieldList = Arrays.asList(declaredFields);

    //        System.out.println(clazz);
    //
    //        for (Field field : fieldList) {
    //            System.out.println(field.getNode());
    //        }

    for (Field field : fieldList) {
      if (field.getName().equals("serialVersionUID")) {
        numFields--;
      }

      if (field.getName().equals("this$0")) {
        numFields--;
      }
    }

    //        System.out.println(numFields);

    return numFields;
  }
  // Deze method maakt alle studenten aan
  public void getStudents() {
    try {
      BufferedReader csvStudentGegevens =
          new BufferedReader(new FileReader("resources/studenten_roostering.csv"));
      String student;
      csvStudentGegevens.readLine();

      while ((student = csvStudentGegevens.readLine()) != null) {
        List<String> gegevens = Arrays.asList(student.split(";"));
        String lastName = gegevens.get(0);
        String firstName = gegevens.get(1);
        int studentNumber = Integer.parseInt(gegevens.get(2));
        List<String> studentCourses = gegevens.subList(3, gegevens.size());
        List<Activity> studentActivities = new ArrayList<>();
        Student newStudent = new Student(lastName, firstName, studentNumber, studentCourses);
        students.add(newStudent);

        // Voeg student toe aan course
        for (int i = 0; i < courses.size(); i++) {
          Course course = courses.get(i);
          if (studentCourses.contains(course.name)) {
            course.courseStudents.add(newStudent);
          }
        }
      }
      csvStudentGegevens.close();
    } catch (IOException e) {
      System.out.println("File Read Error Students");
    }
  }
Esempio n. 26
0
  static private List getCommandCompilerCPP(String avrBasePath,
    List includePaths, String sourceName, String objectName,
    Map<String, String> boardPreferences) {
    
    List baseCommandCompilerCPP = new ArrayList(Arrays.asList(new String[] {
      avrBasePath + "avr-g++",
      "-c", // compile, don't link
      "-g", // include debugging info (so errors include line numbers)
      "-Os", // optimize for size
      Preferences.getBoolean("build.verbose") ? "-Wall" : "-w", // show warnings if verbose
      "-fno-exceptions",
      "-ffunction-sections", // place each function in its own section
      "-fdata-sections",
      "-mmcu=" + boardPreferences.get("build.mcu"),
      "-DF_CPU=" + boardPreferences.get("build.f_cpu"),
      "-MMD", // output dependancy info
      "-DUSB_VID=" + boardPreferences.get("build.vid"),
      "-DUSB_PID=" + boardPreferences.get("build.pid"),      
      "-DARDUINO=" + Base.REVISION,
    }));

    for (int i = 0; i < includePaths.size(); i++) {
      baseCommandCompilerCPP.add("-I" + (String) includePaths.get(i));
    }

    baseCommandCompilerCPP.add(sourceName);
    baseCommandCompilerCPP.add("-o");
    baseCommandCompilerCPP.add(objectName);

    return baseCommandCompilerCPP;
  }
  // Deze method leest alle vakken in
  public void getCourses() {
    try {
      BufferedReader csvVakkenGegevens =
          new BufferedReader(new FileReader("resources/vakken_roostering.csv"));
      String course;
      csvVakkenGegevens.readLine();

      while ((course = csvVakkenGegevens.readLine()) != null) {
        List<String> gegevensVak = Arrays.asList(course.split(";"));
        String name = gegevensVak.get(0);
        int numberLectures = Integer.parseInt(gegevensVak.get(1));
        int numberWorkgroups = Integer.parseInt(gegevensVak.get(2));
        int maxStudentsGroups = Integer.parseInt(gegevensVak.get(3));
        int numberPracticum = Integer.parseInt(gegevensVak.get(4));
        int maxStudentsPracticum = Integer.parseInt(gegevensVak.get(5));

        List<Student> courseStudents = new ArrayList<Student>();

        Course newCourse =
            new Course(
                name,
                numberLectures,
                numberWorkgroups,
                maxStudentsGroups,
                numberPracticum,
                maxStudentsPracticum,
                courseStudents,
                1);
        courses.add(newCourse);
      }
      csvVakkenGegevens.close();
    } catch (IOException e) {
      System.out.println("File Read Error Course ");
    }
  }
Esempio n. 28
0
  public static LiveRef read(ObjectInput in, boolean useNewFormat)
      throws IOException, ClassNotFoundException {
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
      ep = TCPEndpoint.read(in);
    } else {
      ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
      ConnectionInputStream stream = (ConnectionInputStream) in;
      // save ref to send "dirty" call after all args/returns
      // have been unmarshaled.
      stream.saveRef(ref);
      if (isResultStream) {
        // set flag in stream indicating that remote objects were
        // unmarshaled.  A DGC ack should be sent by the transport.
        stream.setAckNeeded();
      }
    } else {
      DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] {ref}));
    }

    return ref;
  }
  private static boolean checkDependants(
      final IdeaPluginDescriptor pluginDescriptor,
      final Function<PluginId, IdeaPluginDescriptor> pluginId2Descriptor,
      final Condition<PluginId> check,
      final Set<PluginId> processed) {
    processed.add(pluginDescriptor.getPluginId());
    final PluginId[] dependentPluginIds = pluginDescriptor.getDependentPluginIds();
    final Set<PluginId> optionalDependencies =
        new HashSet<PluginId>(Arrays.asList(pluginDescriptor.getOptionalDependentPluginIds()));
    for (final PluginId dependentPluginId : dependentPluginIds) {
      if (processed.contains(dependentPluginId)) continue;

      // TODO[yole] should this condition be a parameter?
      if (isModuleDependency(dependentPluginId)
          && (ourAvailableModules.isEmpty()
              || ourAvailableModules.contains(dependentPluginId.getIdString()))) {
        continue;
      }
      if (!optionalDependencies.contains(dependentPluginId)) {
        if (!check.value(dependentPluginId)) {
          return false;
        }
        final IdeaPluginDescriptor dependantPluginDescriptor =
            pluginId2Descriptor.fun(dependentPluginId);
        if (dependantPluginDescriptor != null
            && !checkDependants(dependantPluginDescriptor, pluginId2Descriptor, check, processed)) {
          return false;
        }
      }
    }
    return true;
  }
Esempio n. 30
0
  private LinkedHashMap[] obtenerMapeos(CliGol cliGol, NodeList variables, String[] excluye) {

    LinkedHashMap<String, Object> mapa = new LinkedHashMap<String, Object>();

    LinkedHashMap<String, String> puntos = new LinkedHashMap<String, String>();

    List<String> ex = Arrays.asList(excluye);

    for (int i = 0; i < variables.getLength(); i++) {

      String nom = variables.item(i).getNodeName();

      if (!ex.contains(nom)) {

        String golMapdijo = GolMap.xmlGol(nom);

        String val = null;
        if (golMapdijo != null) {
          val = buscaValEnCli(golMapdijo, cliGol);
          mapa.put(nom, val);

          puntos.put(nom, variables.item(i).getTextContent());
        }
      }
    }

    return new LinkedHashMap[] {mapa, puntos};
  }