コード例 #1
1
  public static IdeaPluginDescriptorImpl[] loadDescriptors(@Nullable StartupProgress progress) {
    if (ClassUtilCore.isLoadingOfExternalPluginsDisabled()) {
      return IdeaPluginDescriptorImpl.EMPTY_ARRAY;
    }

    final List<IdeaPluginDescriptorImpl> result = new ArrayList<IdeaPluginDescriptorImpl>();

    int pluginsCount =
        countPlugins(PathManager.getPluginsPath())
            + countPlugins(PathManager.getPreinstalledPluginsPath());
    loadDescriptors(PathManager.getPluginsPath(), result, progress, pluginsCount);
    Application application = ApplicationManager.getApplication();
    boolean fromSources = false;
    if (application == null || !application.isUnitTestMode()) {
      int size = result.size();
      loadDescriptors(PathManager.getPreinstalledPluginsPath(), result, progress, pluginsCount);
      fromSources = size == result.size();
    }

    loadDescriptorsFromProperty(result);

    loadDescriptorsFromClassPath(result, fromSources ? progress : null);

    IdeaPluginDescriptorImpl[] pluginDescriptors =
        result.toArray(new IdeaPluginDescriptorImpl[result.size()]);
    try {
      Arrays.sort(pluginDescriptors, new PluginDescriptorComparator(pluginDescriptors));
    } catch (Exception e) {
      prepareLoadingPluginsErrorMessage(
          IdeBundle.message("error.plugins.were.not.loaded", e.getMessage()));
      getLogger().info(e);
      return findCorePlugin(pluginDescriptors);
    }
    return pluginDescriptors;
  }
コード例 #2
1
ファイル: Util.java プロジェクト: subxiang/jdk-source-code
 /** Return the list of ProgramElementDoc objects as Array. */
 public static ProgramElementDoc[] toProgramElementDocArray(List list) {
   ProgramElementDoc[] pgmarr = new ProgramElementDoc[list.size()];
   for (int i = 0; i < list.size(); i++) {
     pgmarr[i] = (ProgramElementDoc) (list.get(i));
   }
   return pgmarr;
 }
コード例 #3
1
ファイル: Shell.java プロジェクト: dbremner/fortress
  /** Compile a file. If you want a dump then give -out somefile. */
  public static int compilerPhases(List<String> args, Option<String> out, String phase)
      throws UserError, InterruptedException, IOException, RepositoryError {
    int return_code = 0;
    if (args.size() == 0) {
      throw new UserError("The " + phase + " command must be given a file.");
    }
    String s = args.get(0);
    List<String> rest = args.subList(1, args.size());

    if (s.startsWith("-")) {
      if (s.equals("-debug")) {
        rest = Debug.parseOptions(rest);
      } else if (s.equals("-out") && !rest.isEmpty()) {
        out = Option.<String>some(rest.get(0));
        rest = rest.subList(1, rest.size());
      } else if (s.equals("-compiler-lib")) {
        WellKnownNames.useCompilerLibraries();
        Types.useCompilerLibraries();
      } else if (s.equals("-typecheck-java")) {
        setScala(false);
      } else if (s.equals("-coercion")) {
        setTestCoercion(true);
      } else invalidFlag(s, phase);
      return_code = compilerPhases(rest, out, phase);
    } else {
      return_code = compileWithErrorHandling(s, out, false);
    }
    return return_code;
  }
コード例 #4
1
ファイル: Shell.java プロジェクト: dbremner/fortress
  /** UnParse a file. If you want a dump then give -out somefile. */
  private static void unparse(
      List<String> args, Option<String> out, boolean _unqualified, boolean _unmangle)
      throws UserError, InterruptedException, IOException {
    if (args.size() == 0) {
      throw new UserError("The unparse command needs a file to unparse.");
    }
    String s = args.get(0);
    List<String> rest = args.subList(1, args.size());
    boolean unqualified = _unqualified;
    boolean unmangle = _unmangle;

    if (s.startsWith("-")) {
      if (s.equals("-unqualified")) {
        unqualified = true;
      } else if (s.equals("-unmangle")) {
        unmangle = true;
      } else if (s.equals("-debug")) {
        rest = Debug.parseOptions(rest);
      } else if (s.equals("-out") && !rest.isEmpty()) {
        out = Option.<String>some(rest.get(0));
        rest = rest.subList(1, rest.size());
      } else invalidFlag(s, "unparse");

      unparse(rest, out, unqualified, unmangle);
    } else {
      unparse(s, out, unqualified, unmangle);
    }
  }
コード例 #5
0
ファイル: ColdMigration.java プロジェクト: mikelopez/jvm
  private static DatastoreInfo getDataStoreInfo(ManagedObjectReference dataStore) throws Exception {
    DatastoreInfo dataStoreInfo = new DatastoreInfo();
    PropertySpec propertySpec = new PropertySpec();
    propertySpec.setAll(Boolean.FALSE);
    propertySpec.getPathSet().add("info");
    propertySpec.setType("Datastore");

    // Now create Object Spec
    ObjectSpec objectSpec = new ObjectSpec();
    objectSpec.setObj(dataStore);
    objectSpec.setSkip(Boolean.FALSE);
    objectSpec.getSelectSet().addAll(buildFullTraversal());
    // Create PropertyFilterSpec using the PropertySpec and ObjectPec
    // created above.
    PropertyFilterSpec propertyFilterSpec = new PropertyFilterSpec();
    propertyFilterSpec.getPropSet().add(propertySpec);
    propertyFilterSpec.getObjectSet().add(objectSpec);
    List<PropertyFilterSpec> listpfs = new ArrayList<PropertyFilterSpec>(1);
    listpfs.add(propertyFilterSpec);
    List<ObjectContent> listobjcont = retrievePropertiesAllObjects(listpfs);
    for (int j = 0; j < listobjcont.size(); j++) {
      List<DynamicProperty> propSetList = listobjcont.get(j).getPropSet();
      for (int k = 0; k < propSetList.size(); k++) {
        dataStoreInfo = (DatastoreInfo) propSetList.get(k).getVal();
      }
    }
    return dataStoreInfo;
  }
コード例 #6
0
  @Override
  public boolean equalsImpl(Object obj) {
    boolean ivarsEqual = true;

    if (!(obj instanceof MinefieldDataPdu)) return false;

    final MinefieldDataPdu rhs = (MinefieldDataPdu) obj;

    if (!(minefieldID.equals(rhs.minefieldID))) ivarsEqual = false;
    if (!(requestingEntityID.equals(rhs.requestingEntityID))) ivarsEqual = false;
    if (!(minefieldSequenceNumbeer == rhs.minefieldSequenceNumbeer)) ivarsEqual = false;
    if (!(requestID == rhs.requestID)) ivarsEqual = false;
    if (!(pduSequenceNumber == rhs.pduSequenceNumber)) ivarsEqual = false;
    if (!(numberOfPdus == rhs.numberOfPdus)) ivarsEqual = false;
    if (!(numberOfMinesInThisPdu == rhs.numberOfMinesInThisPdu)) ivarsEqual = false;
    if (!(numberOfSensorTypes == rhs.numberOfSensorTypes)) ivarsEqual = false;
    if (!(pad2 == rhs.pad2)) ivarsEqual = false;
    if (!(dataFilter == rhs.dataFilter)) ivarsEqual = false;
    if (!(mineType.equals(rhs.mineType))) ivarsEqual = false;

    for (int idx = 0; idx < sensorTypes.size(); idx++) {
      if (!(sensorTypes.get(idx).equals(rhs.sensorTypes.get(idx)))) ivarsEqual = false;
    }

    if (!(pad3 == rhs.pad3)) ivarsEqual = false;

    for (int idx = 0; idx < mineLocation.size(); idx++) {
      if (!(mineLocation.get(idx).equals(rhs.mineLocation.get(idx)))) ivarsEqual = false;
    }

    return ivarsEqual && super.equalsImpl(rhs);
  }
コード例 #7
0
  public void marshal(DataOutputStream dos) {
    super.marshal(dos);
    try {
      minefieldID.marshal(dos);
      requestingEntityID.marshal(dos);
      dos.writeShort((short) minefieldSequenceNumbeer);
      dos.writeByte((byte) requestID);
      dos.writeByte((byte) pduSequenceNumber);
      dos.writeByte((byte) numberOfPdus);
      dos.writeByte((byte) mineLocation.size());
      dos.writeByte((byte) sensorTypes.size());
      dos.writeByte((byte) pad2);
      dos.writeInt((int) dataFilter);
      mineType.marshal(dos);

      for (int idx = 0; idx < sensorTypes.size(); idx++) {
        TwoByteChunk aTwoByteChunk = sensorTypes.get(idx);
        aTwoByteChunk.marshal(dos);
      } // end of list marshalling

      dos.writeByte((byte) pad3);

      for (int idx = 0; idx < mineLocation.size(); idx++) {
        Vector3Float aVector3Float = mineLocation.get(idx);
        aVector3Float.marshal(dos);
      } // end of list marshalling

    } // end try
    catch (Exception e) {
      System.out.println(e);
    }
  } // end of marshal method
コード例 #8
0
ファイル: Env.java プロジェクト: NathanEEvans/api
  static synchronized String sourceLine(Location location, int lineNumber) throws IOException {
    if (lineNumber == -1) {
      throw new IllegalArgumentException();
    }

    try {
      String fileName = location.sourceName();

      Iterator<SourceCode> iter = sourceCache.iterator();
      SourceCode code = null;
      while (iter.hasNext()) {
        SourceCode candidate = iter.next();
        if (candidate.fileName().equals(fileName)) {
          code = candidate;
          iter.remove();
          break;
        }
      }
      if (code == null) {
        BufferedReader reader = sourceReader(location);
        if (reader == null) {
          throw new FileNotFoundException(fileName);
        }
        code = new SourceCode(fileName, reader);
        if (sourceCache.size() == SOURCE_CACHE_SIZE) {
          sourceCache.remove(sourceCache.size() - 1);
        }
      }
      sourceCache.add(0, code);
      return code.sourceLine(lineNumber);
    } catch (AbsentInformationException e) {
      throw new IllegalArgumentException();
    }
  }
コード例 #9
0
  // 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");
    }
  }
コード例 #10
0
ファイル: SelectTests.java プロジェクト: nile/beankeeper
 public void testMapSelection() throws Exception {
   // Drop
   removeAll(MapHolder.class);
   // Create
   MapHolder mapHolder = new MapHolder();
   Book book = new Book("Book of Bokonon", "9");
   HashMap meta = new HashMap();
   meta.put("meta1", new Author("Geordi", "LaForge"));
   meta.put("meta2", new Author("Data", ""));
   meta.put("meta3", new Author("Scott", "Montgomery"));
   meta.put("book", book);
   mapHolder.setMeta(meta);
   // Save
   getStore().save(mapHolder);
   // Select
   List result =
       getStore()
           .find(
               "find mapholder where mapholder.meta['book'](book)=book and book.title like 'Book%'");
   Assert.assertEquals(result.size(), 1);
   result =
       getStore()
           .find("find mapholder where mapholder.meta['book'](book)=book and book.title like '9'");
   Assert.assertEquals(result.size(), 0);
 }
コード例 #11
0
ファイル: SelectTests.java プロジェクト: nile/beankeeper
 public void testContainsString() throws Exception {
   // Create test setup
   removeAll(Task.class);
   // Create tasks
   Project bk = new Project("BeanKeeper");
   getStore().save(bk);
   getStore().save(new Task(bk, "Test", new String[] {"bk", "test"}));
   getStore().save(new Task(bk, "Implement", new String[] {"bk", "implement"}));
   getStore().save(new Task(bk, "Refactor", new String[] {"bk", "refactor"}));
   Project ex = new Project("Exorcist");
   getStore().save(ex);
   getStore().save(new Task(ex, "Test", new String[] {"ex", "test"}));
   // Select in project
   List result =
       getStore()
           .find(
               "find task where project = ? and (tags contains ? or tags contains ?)",
               new Object[] {bk, "test", "develop"});
   Assert.assertEquals(result.size(), 1);
   // Cross select
   List result2 =
       getStore()
           .find(
               "find task where tags contains ? and (project.name = ? or project.name = ?)",
               new Object[] {"test", "BeanKeeper", "Exorcist"});
   Assert.assertEquals(result2.size(), 2);
 }
コード例 #12
0
ファイル: SelectTests.java プロジェクト: nile/beankeeper
 public void testResultListSerializableComplex() throws Exception {
   // Create mutliple objects
   removeAll(Object.class);
   for (int i = 0; i < 20; i++) getStore().save(new Book("Learning Java 1." + i, "" + i));
   for (int i = 0; i < 20; i++) getStore().save(new Referrer(i));
   for (int i = 0; i < 20; i++) getStore().save(new User());
   for (int i = 0; i < 20; i++) getStore().save(new MapHolder());
   // Get the result list for all objects
   List result = getStore().find("find object");
   Assert.assertEquals(result.size(), 80);
   // Now serialize
   ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
   ObjectOutputStream objectOut = new ObjectOutputStream(byteOut);
   objectOut.writeObject(result);
   objectOut.close();
   // Close the store, let's pretend we're outside it
   tearDownStore();
   try {
     // Deserialize
     ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
     ObjectInputStream objectIn = new ObjectInputStream(byteIn);
     List deList = (List) objectIn.readObject();
     // Test object
     Assert.assertEquals(deList.size(), 80);
     Assert.assertEquals(getCount(deList, Book.class), 20);
     Assert.assertEquals(getCount(deList, Referrer.class), 20);
     Assert.assertEquals(getCount(deList, User.class), 20);
     Assert.assertEquals(getCount(deList, MapHolder.class), 20);
   } finally {
     // Setup store for next tests
     setUpStore();
   }
 }
コード例 #13
0
  /**
   * Tests identification of source bundles in a 3.0.2 install.
   *
   * @throws Exception
   */
  public void testClassicSourcePlugins() throws Exception {
    // extract the 3.0.2 skeleton
    IPath location = extractClassicPlugins();

    // the new way
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString());
    definition.setTargetLocations(new ITargetLocation[] {container});

    definition.resolve(null);
    TargetBundle[] bundles = definition.getBundles();
    List source = new ArrayList();
    for (int i = 0; i < bundles.length; i++) {
      TargetBundle sb = bundles[i];
      if (sb.isSourceBundle()) {
        source.add(sb);
      }
    }

    assertEquals("Wrong number of source bundles", 4, source.size());
    Set names = new HashSet();
    for (int i = 0; i < source.size(); i++) {
      names.add(((TargetBundle) source.get(i)).getBundleInfo().getSymbolicName());
    }
    String[] expected =
        new String[] {
          "org.eclipse.platform.source",
          "org.eclipse.jdt.source",
          "org.eclipse.pde.source",
          "org.eclipse.platform.source.win32.win32.x86"
        };
    for (int i = 0; i < expected.length; i++) {
      assertTrue("Missing source for " + expected[i], names.contains(expected[i]));
    }
  }
コード例 #14
0
ファイル: JChannel.java プロジェクト: schaebo/JGroups
  protected Address generateAddress() {
    if (address_generators == null || address_generators.isEmpty()) return UUID.randomUUID();
    if (address_generators.size() == 1) return address_generators.get(0).generateAddress();

    // at this point we have multiple AddressGenerators installed
    Address[] addrs = new Address[address_generators.size()];
    for (int i = 0; i < addrs.length; i++) addrs[i] = address_generators.get(i).generateAddress();

    for (int i = 0; i < addrs.length; i++) {
      if (!(addrs[i] instanceof ExtendedUUID)) {
        log.error(
            "address generator %s does not subclass %s which is required if multiple address generators "
                + "are installed, removing it",
            addrs[i].getClass().getSimpleName(), ExtendedUUID.class.getSimpleName());
        addrs[i] = null;
      }
    }
    ExtendedUUID uuid = null;
    for (int i = 0; i < addrs.length; i++) { // we only have ExtendedUUIDs in addrs
      if (addrs[i] != null) {
        if (uuid == null) uuid = (ExtendedUUID) addrs[i];
        else uuid.addContents((ExtendedUUID) addrs[i]);
      }
    }
    return uuid != null ? uuid : UUID.randomUUID();
  }
コード例 #15
0
ファイル: Directory.java プロジェクト: duncan-brown/pegasus
  /**
   * Deletes a very specific mapping from the replica catalog. The LFN must be matches, the PFN, and
   * all PFN attributes specified in the replica catalog entry. More than one entry could
   * theoretically be removed. Upon removal of an entry, all attributes associated with the PFN also
   * evaporate (cascading deletion).
   *
   * @param lfn is the logical directory in the tuple.
   * @param tuple is a description of the PFN and its attributes.
   * @return the number of removed entries, either 0 or 1.
   */
  public int delete(String lfn, ReplicaCatalogEntry tuple) {
    int result = 0;
    if (lfn == null || tuple == null) {
      return result;
    }

    Collection c = (Collection) mLFNMap.get(lfn);
    if (c == null) {
      return result;
    }

    List l = new ArrayList();
    for (Iterator i = c.iterator(); i.hasNext(); ) {
      ReplicaCatalogEntry rce = (ReplicaCatalogEntry) i.next();
      if (!matchMe(rce, tuple)) {
        l.add(rce);
      }
    }

    // anything removed?
    if (l.size() != c.size()) {
      result = c.size() - l.size();
      mLFNMap.put(lfn, l);
    }

    // done
    return result;
  }
コード例 #16
0
  // write output, each sentence on a line
  // <word1>/<postag1> <word2>/<postag2> ...
  public void writeData(Map lbInt2Str, String outputFile) {
    if (data == null) {
      return;
    }

    PrintWriter fout = null;

    try {
      fout = new PrintWriter(new FileWriter(outputFile));

      // main loop for writing
      for (int i = 0; i < data.size(); i++) {
        List seq = (List) data.get(i);
        for (int j = 0; j < seq.size(); j++) {
          Observation obsr = (Observation) seq.get(j);
          fout.print(obsr.toString(lbInt2Str) + " ");
        }
        fout.println();
      }

      fout.close();

    } catch (IOException e) {
      System.out.println("Couldn't create file: " + outputFile);
      return;
    }
  }
コード例 #17
0
  // Deze method checkt rooster conflicten (Dubbele roosteringen van studenten)
  public int computeStudentConflicts() {
    ArrayList<Student> checkedStudentsList = new ArrayList<Student>();
    int studentConflictCounter = 0;
    boolean conflictFound = false;

    for (int i = 0; i < timeslots; i++) {
      for (int j = 0; j < rooms.size() - 1; j++) {
        Activity activity = rooms.get(j).timetable.get(i);
        if (activity != null) {
          for (Student student : activity.studentGroup) {
            if (!checkedStudentsList.contains(student)) {
              for (int k = j + 1; k < rooms.size(); k++) {
                Room otherRoom = rooms.get(k);
                Activity otherActivity = otherRoom.timetable.get(i);
                if (otherActivity != null) {
                  if (otherActivity.studentGroup.contains(student)) {
                    studentConflictCounter++;
                    conflictFound = true;
                  }
                }
              }
            }
            if (conflictFound) {
              checkedStudentsList.add(student);
              conflictFound = false;
            }
          }
        }
      }
      checkedStudentsList.clear();
    }
    return studentConflictCounter;
  }
コード例 #18
0
ファイル: MemoryStudy.java プロジェクト: ePADD/muse
  // add the new user to the encrypted users file which has the detailed stats for all users
  // synchronize to make sure that only one thread can be inside this block at a time.
  public static synchronized String addUserAndIssueCode(UserStats stats)
      throws IOException, GeneralSecurityException, ClassNotFoundException, NoMoreCodesException {

    // ok, now we have a list of stats objects, representing all users.
    // add this user to the list.
    // the code assigned to this user will simply be codes.get(users.size())
    // but do an error check first to be sure we're not out of codes
    List<UserStats> users = readUsersFile();

    if (users.size() >= MemoryStudy.codes.size()) {
      log.warn("NOC WARNING: codes file exhausted!!!!");
      throw new NoMoreCodesException();
    }

    // ok, we have enough codes, just give out one
    String passkey = MemoryStudy.codes.get(users.size());
    int USERID_BASE =
        100; // userid numbering starts from USERID_BASE, new id is base + # existing codes
    stats.userid = Integer.toString(USERID_BASE + users.size());
    stats.code = passkey;
    users.add(stats);

    // encrypt and write the users file back
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(users);
    oos.close();
    CryptoUtils.writeEncryptedBytes(baos.toByteArray(), USERS_FILE);

    return passkey;
  }
コード例 #19
0
  static <T> List<List<T>> combinations(List<T> list, int n) {

    List<List<T>> result;

    if (list.size() <= n) {

      result = new ArrayList<List<T>>();
      result.add(new ArrayList<T>(list));

    } else if (n <= 0) {

      result = new ArrayList<List<T>>();
      result.add(new ArrayList<T>());

    } else {

      List<T> sublist = list.subList(1, list.size());

      result = combinations(sublist, n);

      for (List<T> alist : combinations(sublist, n - 1)) {
        List<T> thelist = new ArrayList<T>(alist);
        thelist.add(list.get(0));
        result.add(thelist);
      }
    }

    return result;
  }
コード例 #20
0
ファイル: Lexicon.java プロジェクト: kevinkissi/openccg
 // look up and apply coarts for given rels to each sign in result
 private void applyCoarts(List<String> coartRels, Collection<Sign> result) {
   List<Sign> inputSigns = new ArrayList<Sign>(result);
   result.clear();
   List<Sign> outputSigns = new ArrayList<Sign>(inputSigns.size());
   // for each rel, lookup coarts and apply to input signs, storing results in output signs
   for (Iterator<String> it = coartRels.iterator(); it.hasNext(); ) {
     String rel = it.next();
     Collection<String> preds = (Collection<String>) _coartRelsToPreds.get(rel);
     if (preds == null) continue; // not expected
     Collection<Sign> coartResult = getSignsFromRelAndPreds(rel, preds);
     if (coartResult == null) continue;
     for (Iterator<Sign> it2 = coartResult.iterator(); it2.hasNext(); ) {
       Sign coartSign = it2.next();
       // apply to each input
       for (int j = 0; j < inputSigns.size(); j++) {
         Sign sign = inputSigns.get(j);
         grammar.rules.applyCoart(sign, coartSign, outputSigns);
       }
     }
     // switch output to input for next iteration
     inputSigns.clear();
     inputSigns.addAll(outputSigns);
     outputSigns.clear();
   }
   // add results back
   result.addAll(inputSigns);
 }
コード例 #21
0
    @Override
    public void map(LongWritable key, Text value, Context context)
        throws IOException, InterruptedException {
      String line = ((Text) value).toString();

      List<String> tokens = new ArrayList<String>();
      StringTokenizer itr = new StringTokenizer(line);
      int numWords = 0;
      while (itr.hasMoreTokens() && numWords < 100) {
        String w = itr.nextToken().toLowerCase().replaceAll("(^[^a-z]+|[^a-z]+$)", "");
        if (w.length() == 0) continue;
        if (!tokens.contains(w)) {
          tokens.add(w);
        }
        numWords++;
      }

      for (int i = 0; i < tokens.size(); i++) {
        MAP.clear();
        for (int j = 0; j < tokens.size(); j++) {
          if (i == j) continue;

          MAP.increment(tokens.get(j));
        }
        KEY.set(tokens.get(i));
        context.write(KEY, MAP);
      }
    }
コード例 #22
0
ファイル: Lexicon.java プロジェクト: kevinkissi/openccg
 // look up and apply coarts for w to each sign in result
 @SuppressWarnings("unchecked")
 private void applyCoarts(Word w, SignHash result) throws LexException {
   List<Sign> inputSigns = new ArrayList<Sign>(result.asSignSet());
   result.clear();
   List<Sign> outputSigns = new ArrayList<Sign>(inputSigns.size());
   // for each surface attr, lookup coarts and apply to input signs, storing results in output
   // signs
   for (Iterator<Pair<String, String>> it = w.getSurfaceAttrValPairs(); it.hasNext(); ) {
     Pair<String, String> p = it.next();
     String attr = (String) p.a;
     if (!_indexedCoartAttrs.contains(attr)) continue;
     String val = (String) p.b;
     Word coartWord = Word.createWord(attr, val);
     SignHash coartResult = getSignsFromWord(coartWord, null, null, null);
     for (Iterator<Sign> it2 = coartResult.iterator(); it2.hasNext(); ) {
       Sign coartSign = it2.next();
       // apply to each input
       for (int j = 0; j < inputSigns.size(); j++) {
         Sign sign = inputSigns.get(j);
         grammar.rules.applyCoart(sign, coartSign, outputSigns);
       }
     }
     // switch output to input for next iteration
     inputSigns.clear();
     inputSigns.addAll(outputSigns);
     outputSigns.clear();
   }
   // add results back
   result.addAll(inputSigns);
 }
コード例 #23
0
  /**
   * Packs a Pdu into the ByteBuffer.
   *
   * @throws java.nio.BufferOverflowException if buff is too small
   * @throws java.nio.ReadOnlyBufferException if buff is read only
   * @see java.nio.ByteBuffer
   * @param buff The ByteBuffer at the position to begin writing
   * @since ??
   */
  public void marshal(java.nio.ByteBuffer buff) {
    super.marshal(buff);
    minefieldID.marshal(buff);
    requestingEntityID.marshal(buff);
    buff.putShort((short) minefieldSequenceNumbeer);
    buff.put((byte) requestID);
    buff.put((byte) pduSequenceNumber);
    buff.put((byte) numberOfPdus);
    buff.put((byte) mineLocation.size());
    buff.put((byte) sensorTypes.size());
    buff.put((byte) pad2);
    buff.putInt((int) dataFilter);
    mineType.marshal(buff);

    for (int idx = 0; idx < sensorTypes.size(); idx++) {
      TwoByteChunk aTwoByteChunk = (TwoByteChunk) sensorTypes.get(idx);
      aTwoByteChunk.marshal(buff);
    } // end of list marshalling

    buff.put((byte) pad3);

    for (int idx = 0; idx < mineLocation.size(); idx++) {
      Vector3Float aVector3Float = (Vector3Float) mineLocation.get(idx);
      aVector3Float.marshal(buff);
    } // end of list marshalling
  } // end of marshal method
コード例 #24
0
  public AllSubstitution FOL_BC_AND(List<Predicate> goal, AllSubstitution theta) {
    //
    if (theta.status == false) return theta;
    else if (goal.size() == 0) return theta;
    else {
      Predicate first = goal.get(0); // n

      first = substFromTheata(theta, first);

      int index = 0;

      int tSize =
          (KBObj.KB.get(first.fnName) == null)
              ? 0
              : (KBObj.KB.get(first.fnName).sentences.size() - 1);
      while (index <= tSize) {
        AllSubstitution thetaPrime = FOL_BC_OR(first, theta, index++);

        if (thetaPrime.status && goal.size() > 1) {
          List<Predicate> rest =
              new ArrayList<Predicate>(((ArrayList<Predicate>) goal).subList(1, goal.size()));

          AllSubstitution thetaDoublePrime = FOL_BC_AND(rest, sumUpTheta(theta, thetaPrime));

          if (thetaDoublePrime.status) return thetaDoublePrime;
        } else return thetaPrime;
      }
      AllSubstitution t = new AllSubstitution();
      t.status = false;
      return t;
    }
  }
コード例 #25
0
  public int getMarshalledSize() {
    int marshalSize = 0;

    marshalSize = super.getMarshalledSize();
    marshalSize = marshalSize + minefieldID.getMarshalledSize(); // minefieldID
    marshalSize = marshalSize + requestingEntityID.getMarshalledSize(); // requestingEntityID
    marshalSize = marshalSize + 2; // minefieldSequenceNumbeer
    marshalSize = marshalSize + 1; // requestID
    marshalSize = marshalSize + 1; // pduSequenceNumber
    marshalSize = marshalSize + 1; // numberOfPdus
    marshalSize = marshalSize + 1; // numberOfMinesInThisPdu
    marshalSize = marshalSize + 1; // numberOfSensorTypes
    marshalSize = marshalSize + 1; // pad2
    marshalSize = marshalSize + 4; // dataFilter
    marshalSize = marshalSize + mineType.getMarshalledSize(); // mineType
    for (int idx = 0; idx < sensorTypes.size(); idx++) {
      TwoByteChunk listElement = sensorTypes.get(idx);
      marshalSize = marshalSize + listElement.getMarshalledSize();
    }
    marshalSize = marshalSize + 1; // pad3
    for (int idx = 0; idx < mineLocation.size(); idx++) {
      Vector3Float listElement = mineLocation.get(idx);
      marshalSize = marshalSize + listElement.getMarshalledSize();
    }

    return marshalSize;
  }
コード例 #26
0
ファイル: FileUtil.java プロジェクト: zh69183787/wd-stptm
  public static ArrayList getFjList(String sid) {
    ArrayList result = new ArrayList();
    String strSql =
        "select SID,File_Name,Ext_Name,File_Size from  t_docs_fj where state='1' and parent_sid="
            + sid;
    CommonDao dao = CommonDao.GetOldDatabaseDao();
    List lst = dao.fetchAll(strSql);
    if (lst != null && lst.size() > 0) {
      for (int i = 0; i < lst.size(); i++) {
        Object[] arr = (Object[]) lst.get(i);
        result.add(arr[1]);
        result.add(arr[2]);
        if (arr[3] != null) {
          Float fileSize = Float.parseFloat(arr[3].toString()) * 1000;
          result.add(fileSize);
        } else {
          result.add(0);
        }
        result.add(arr[0]);
      }
    }
    dao.getSessionFactory().close();
    return result;
    /*Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    ArrayList result = new ArrayList();
    String strSql = "select * from  t_docs_fj where state='1' and parent_sid="
    		+ sid;
    try {
    	conn = DataManager.getConnection();
    	stmt = conn.createStatement();
    	rs = stmt.executeQuery(strSql);
    	while (rs.next()) {
    		result.add(rs.getString("File_Name"));
    		result.add(rs.getString("Ext_Name"));
    		result.add(""
    				+ Float.valueOf(rs.getString("File_Size")).floatValue()
    				* 1000.0);
    		result.add(rs.getString("SID"));
    		result.add(FileUtil.getDocumentPath());
    	}
    } catch (Exception ex) {
    	ex.printStackTrace();
    }

    finally {
    	try {
    		if (rs != null)
    			rs.close();
    		if (stmt != null)
    			stmt.close();
    		if (conn != null)
    			conn.close();
    	} catch (Exception ex) {
    		ex.printStackTrace();
    	}
    }*/

  }
コード例 #27
0
ファイル: NodeRunnerDcom.java プロジェクト: winsx/Payara
  /* hack TODO do not know how to get int status back from Windows
   * Stick in code that handles particular commands that we can figure out
   * the status.
   */
  private int determineStatus(List<String> args) {
    if (args == null) throw new NullPointerException();

    if (args.size() < 2) return 0;

    String instanceName = args.get(args.size() - 1);

    if (isCommand(args, "_delete-instance-filesystem")) {
      try {
        String dir = Paths.getInstanceDirPath(node, instanceName);
        WindowsRemoteFile instanceDir = new WindowsRemoteFile(dcomInfo.getCredentials(), dir);
        return instanceDir.exists() ? 1 : 0;
      } catch (WindowsException ex) {
        return 0;
      }
    } else if (isCommand(args, "_create-instance-filesystem")) {
      try {
        String dir = Paths.getDasPropsPath(node);
        WindowsRemoteFile dasProps = new WindowsRemoteFile(dcomInfo.getCredentials(), dir);

        if (dasProps.exists()) return 0;

        // uh-oh.  Wipe out the instance directory that was created
        dir = Paths.getInstanceDirPath(node, instanceName);
        WindowsRemoteFile instanceDir = new WindowsRemoteFile(dcomInfo.getCredentials(), dir);
        instanceDir.delete();
        return 1;
      } catch (WindowsException ex) {
        return 1;
      }
    }
    return 0;
  }
コード例 #28
0
ファイル: Message.java プロジェクト: lemmy/dnsjava
 /**
  * Returns an array containing all records in the given section grouped into RRsets.
  *
  * @see RRset
  * @see Section
  */
 public RRset[] getSectionRRsets(int section) {
   if (sections[section] == null) return emptyRRsetArray;
   List sets = new LinkedList();
   Record[] recs = getSectionArray(section);
   Set hash = new HashSet();
   for (int i = 0; i < recs.length; i++) {
     Name name = recs[i].getName();
     boolean newset = true;
     if (hash.contains(name)) {
       for (int j = sets.size() - 1; j >= 0; j--) {
         RRset set = (RRset) sets.get(j);
         if (set.getType() == recs[i].getRRsetType()
             && set.getDClass() == recs[i].getDClass()
             && set.getName().equals(name)) {
           set.addRR(recs[i]);
           newset = false;
           break;
         }
       }
     }
     if (newset) {
       RRset set = new RRset(recs[i]);
       sets.add(set);
       hash.add(name);
     }
   }
   return (RRset[]) sets.toArray(new RRset[sets.size()]);
 }
コード例 #29
0
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    String line;
    StringBuilder sb = new StringBuilder();
    while ((line = in.readLine()) != null) {
      int k = Integer.parseInt(line);
      List<Integer> xd = new ArrayList<Integer>();
      List<Integer> yd = new ArrayList<Integer>();

      for (int y = k + 1; y <= 2 * k; ++y) {
        if (k * y % (y - k) == 0) {
          int x = k * y / (y - k);
          xd.add(x);
          yd.add(y);
        }
      }

      sb.append(xd.size() + "\n");
      for (int i = 0; i < xd.size(); ++i)
        sb.append(String.format("1/%d = 1/%d + 1/%d\n", k, xd.get(i), yd.get(i)));
    }

    System.out.print(sb);

    in.close();
    System.exit(0);
  }
コード例 #30
0
  public boolean perform(
      String[] strings,
      List clients,
      List rejectList,
      Map groups,
      ChatClientHandler_345387 myHandler)
      throws IOException {
    // ユーザの名前を入れてソートするためのListを宣言(ローカル変数)
    List names = new ArrayList();

    // 全クライアントのListに加える
    for (int i = 0; i < clients.size(); i++) {
      ChatClientHandler_345387 handler = (ChatClientHandler_345387) clients.get(i);
      names.add(handler.getClientName());
    }

    // ソートする
    Collections.sort(names);

    // 接続中のクライアント名をコンマで区切って昇順に一行で表示
    String returnMessage = "";
    for (int i = 0; i < names.size(); i++) {
      returnMessage += names.get(i) + ",";
    }
    myHandler.send(returnMessage);

    System.out.println(myHandler.getClientName() + ": users: " + returnMessage);

    return true;
  }