private static boolean allSuperMethodsSelectedToDelete(
     List<PsiMethod> unselectedMethods, PsiMethod method) {
   final ArrayList<PsiMethod> superMethods =
       new ArrayList<>(Arrays.asList(method.findSuperMethods()));
   superMethods.retainAll(unselectedMethods);
   return superMethods.isEmpty();
 }
Example #2
0
  // Dont use this method just jet. We need to fix the columnscoring first.
  // TODO: What this method needs is the end of the table!!! For this it also needs to know the end
  // of the row!!!
  private void checkMapForX2Columns() {
    ArrayList<String> col = new ArrayList<String>();
    ArrayList<Integer> X2Col = new ArrayList<Integer>();
    ArrayList<Integer> X1Col = new ArrayList<Integer>();

    for (int x = 0; x < tableMap.size(); x++) {

      boolean startOfTable = false;

      ArrayList<String> currentPixel = tableMap.get(x);

      if (!currentPixel.isEmpty() && !startOfTable && col.isEmpty()) {
        startOfTable = true;
        X1Col.add(x);

        System.out.println("Begin of Column: " + X1Col);
      }
      if (!currentPixel.isEmpty() && startOfTable) {
        col.add(tableMap.get(x).toString());
        startOfTable = false;
      }
      if (currentPixel.isEmpty() && !col.isEmpty()) {
        col = new ArrayList<String>();
        X2Col.add(x);
        System.out.println("End of Column: " + X2Col);
        startOfTable = false;
      }
    }
    this.X2ColumnBoundaries = X2Col;
    this.X1ColumnBoundaries = X1Col;
  }
Example #3
0
  /**
   * Returns all summary path nodes for the specified location step or {@code null} if nodes cannot
   * be retrieved or are found on different levels.
   *
   * @param data data reference
   * @param last last step to be checked
   * @return path nodes
   */
  private ArrayList<PathNode> pathNodes(final Data data, final int last) {
    // skip request if no path index exists or might be out-of-date
    if (!data.meta.uptodate) return null;

    ArrayList<PathNode> nodes = data.paths.root();
    for (int s = 0; s <= last; s++) {
      // only follow axis steps
      final Step curr = axisStep(s);
      if (curr == null) return null;

      final boolean desc = curr.axis == DESC;
      if (!desc && curr.axis != CHILD || curr.test.kind != Kind.NAME) return null;

      final int name = data.elemNames.id(curr.test.name.local());

      final ArrayList<PathNode> tmp = new ArrayList<>();
      for (final PathNode node : PathSummary.desc(nodes, desc)) {
        if (node.kind == Data.ELEM && name == node.name) {
          // skip test if an element name occurs on different levels
          if (!tmp.isEmpty() && tmp.get(0).level() != node.level()) return null;
          tmp.add(node);
        }
      }
      if (tmp.isEmpty()) return null;
      nodes = tmp;
    }
    return nodes;
  }
Example #4
0
  /**
   * Returns all summary path nodes for the specified location step or {@code null} if nodes cannot
   * be retrieved or are found on different levels.
   *
   * @param data data reference
   * @param l last step to be checked
   * @return path nodes
   */
  ArrayList<PathNode> pathNodes(final Data data, final int l) {
    // skip request if no path index exists or might be out-of-date
    if (!data.meta.uptodate) return null;

    ArrayList<PathNode> in = data.paths.root();
    for (int s = 0; s <= l; ++s) {
      final Step curr = axisStep(s);
      if (curr == null) return null;
      final boolean desc = curr.axis == DESC;
      if (!desc && curr.axis != CHILD || curr.test.mode != Mode.LN) return null;

      final int name = data.tagindex.id(curr.test.name.local());

      final ArrayList<PathNode> al = new ArrayList<>();
      for (final PathNode pn : PathSummary.desc(in, desc)) {
        if (pn.kind == Data.ELEM && name == pn.name) {
          // skip test if a tag is found on different levels
          if (!al.isEmpty() && al.get(0).level() != pn.level()) return null;
          al.add(pn);
        }
      }
      if (al.isEmpty()) return null;
      in = al;
    }
    return in;
  }
    @Override
    public void initPhase() throws PipelineException {
      /* initialize builder parameters from source images node information */
      setParamValue(new ParamMapping(DeliverNamer.aDeliverable), pSourcePrefix);
      setParamValue(new ParamMapping(aNotes), pSourceVersion.getMessage());
      setParamValue(new ParamMapping(aClientVersion), pSourceVersion.getVersionID().toString());
      setParamValue(new ParamMapping(aClientShotName), pSourcePrefix);

      /* replace placeholder parameters with the names of the available
      slate script, format script and codec settings nodes */
      {
        Path path = pProjectNamer.getSlateNukeScriptsParentPath();
        ArrayList<String> pnames = findChildNodeNames(path);
        if ((pnames == null) || pnames.isEmpty())
          throw new PipelineException(
              "Unable to find any slate creation Nuke script nodes in (" + path + ")!");

        UtilityParam param =
            new EnumUtilityParam(
                aSlateScript,
                "Select the master slate creation Nuke script to use.",
                pnames.get(0),
                pnames);
        replaceParam(param);
      }

      {
        Path path = pProjectNamer.getFormatNukeScriptsParentPath();
        ArrayList<String> pnames = findChildNodeNames(path);
        if ((pnames == null) || pnames.isEmpty())
          throw new PipelineException(
              "Unable to find any image formatting Nuke script nodes in (" + path + ")!");

        UtilityParam param =
            new EnumUtilityParam(
                aFormatScript,
                "Select final image formatting Nuke script to use.",
                pnames.get(0),
                pnames);
        replaceParam(param);
      }

      {
        Path path = pProjectNamer.getQtCodecSettingsParentPath();
        ArrayList<String> pnames = findChildNodeNames(path);
        if ((pnames == null) || pnames.isEmpty())
          throw new PipelineException(
              "Unable to find any QuickTime codec settings nodes in (" + path + ")!");

        UtilityParam param =
            new EnumUtilityParam(
                aCodecSettings,
                "Select the QuickTime codec settings to encode the final movie.",
                pnames.get(0),
                pnames);
        replaceParam(param);
      }
    }
Example #6
0
  public void setModels(ArrayList /*<ZLTextModel>*/ models, String fileName) {
    myFileName = fileName;

    myPositionStack.clear();

    final int stackSize =
        new ZLIntegerRangeOption(
                ZLOption.STATE_CATEGORY, fileName, BUFFER_SIZE, 0, MAX_UNDO_STACK_SIZE, 0)
            .getValue();
    myCurrentPointInStack =
        new ZLIntegerRangeOption(
                ZLOption.STATE_CATEGORY,
                fileName,
                POSITION_IN_BUFFER,
                0,
                (stackSize == 0) ? 0 : (stackSize - 1),
                0)
            .getValue();

    if (models != null) {
      final ZLIntegerOption option = new ZLIntegerOption(ZLOption.STATE_CATEGORY, fileName, "", 0);
      final int size = models.size();
      for (int i = 0; i < stackSize; ++i) {
        //		option.changeName(MODEL_PREFIX + i);
        //		final int modelIndex = option.getValue();
        option.changeName(PARAGRAPH_PREFIX + i);
        int paragraphIndex = option.getValue();
        int modelIndex = -1;
        int paragraphsNumber = 0;
        while (paragraphIndex >= 0 && paragraphsNumber != 1) {
          modelIndex++;
          paragraphsNumber =
              modelIndex >= 0 && modelIndex < size
                  ? ((ZLTextModel) models.get(modelIndex)).getParagraphsNumber() + 1
                  : 1;
          paragraphIndex -= paragraphsNumber;
        }
        paragraphIndex += paragraphsNumber;
        option.changeName(WORD_PREFIX + i);
        final int wordIndex = option.getValue();
        option.changeName(CHAR_PREFIX + i);
        final int charIndex = option.getValue();
        myPositionStack.add(new Position(modelIndex, paragraphIndex, wordIndex, charIndex));
      }
    }
    if (!myPositionStack.isEmpty()) {
      super.setModels(models, ((Position) myPositionStack.get(myCurrentPointInStack)).ModelIndex);
    } else {
      super.setModels(models, 0);
    }
    if ((getModel() != null) && (!myPositionStack.isEmpty())) {
      gotoPosition((Position) myPositionStack.get(myCurrentPointInStack));
    }
  }
Example #7
0
 private boolean arraysIntersect(
     final ArrayList<String> dataStoreArray, final ArrayList<String> thisAssertingArray) {
   if (dataStoreArray.isEmpty()) {
     return true;
   } else if (!thisAssertingArray.isEmpty()) {
     for (final String entry : thisAssertingArray) {
       if (dataStoreArray.contains(entry)) {
         return true;
       }
     }
   }
   return false;
 }
  public StructureVillageStart(World par1World, Random par2Random, int par3, int par4, int par5) {
    hasMoreThanTwoComponents = false;
    ArrayList arraylist =
        StructureVillagePieces.getStructureVillageWeightedPieceList(par2Random, par5);
    ComponentVillageStartPiece componentvillagestartpiece =
        new ComponentVillageStartPiece(
            par1World.getWorldChunkManager(),
            0,
            par2Random,
            (par3 << 4) + 2,
            (par4 << 4) + 2,
            arraylist,
            par5);
    components.add(componentvillagestartpiece);
    componentvillagestartpiece.buildComponent(componentvillagestartpiece, components, par2Random);
    ArrayList arraylist1 = componentvillagestartpiece.field_74930_j;

    for (ArrayList arraylist2 = componentvillagestartpiece.field_74932_i;
        !arraylist1.isEmpty() || !arraylist2.isEmpty(); ) {
      if (arraylist1.isEmpty()) {
        int i = par2Random.nextInt(arraylist2.size());
        StructureComponent structurecomponent = (StructureComponent) arraylist2.remove(i);
        structurecomponent.buildComponent(componentvillagestartpiece, components, par2Random);
      } else {
        int j = par2Random.nextInt(arraylist1.size());
        StructureComponent structurecomponent1 = (StructureComponent) arraylist1.remove(j);
        structurecomponent1.buildComponent(componentvillagestartpiece, components, par2Random);
      }
    }

    updateBoundingBox();
    int k = 0;
    Iterator iterator = components.iterator();

    do {
      if (!iterator.hasNext()) {
        break;
      }

      StructureComponent structurecomponent2 = (StructureComponent) iterator.next();

      if (!(structurecomponent2 instanceof ComponentVillageRoadPiece)) {
        k++;
      }
    } while (true);

    hasMoreThanTwoComponents = k > 2;
  }
  private synchronized void assertAllPointersDisposed() {
    for (Map.Entry<VirtualFilePointerListener, FilePointerPartNode> entry : myPointers.entrySet()) {
      FilePointerPartNode root = entry.getValue();
      ArrayList<FilePointerPartNode> left = new ArrayList<FilePointerPartNode>();
      root.getPointersUnder(null, false, "", left);
      if (!left.isEmpty()) {
        VirtualFilePointerImpl p = left.get(0).leaf;
        try {
          p.throwDisposalError("Not disposed pointer: " + p);
        } finally {
          for (FilePointerPartNode pair : left) {
            VirtualFilePointerImpl pointer = pair.leaf;
            pointer.dispose();
          }
        }
      }
    }

    synchronized (myContainers) {
      if (!myContainers.isEmpty()) {
        VirtualFilePointerContainerImpl container = myContainers.iterator().next();
        container.throwDisposalError("Not disposed container");
      }
    }
  }
Example #10
0
 @Override
 public boolean endElementHandler(String tag) {
   tag = tag.toLowerCase().intern();
   switch (myReadState) {
     case READ_NONE:
       break;
     case READ_MAP:
       if (TAG_NAVMAP == tag) {
         myReadState = READ_NONE;
       }
       break;
     case READ_POINT:
       if (TAG_NAVPOINT == tag) {
         NavPoint last = myPointStack.get(myPointStack.size() - 1);
         if (last.Text.length() == 0) {
           last.Text = "...";
         }
         myNavigationMap.put(last.Order, last);
         myPointStack.remove(myPointStack.size() - 1);
         myReadState = (myPointStack.isEmpty()) ? READ_MAP : READ_POINT;
       }
     case READ_LABEL:
       if (TAG_NAVLABEL == tag) {
         myReadState = READ_POINT;
       }
       break;
     case READ_TEXT:
       if (TAG_TEXT == tag) {
         myReadState = READ_LABEL;
       }
       break;
   }
   return false;
 }
Example #11
0
 protected List<MappingWithDirection> findApplicable(MappingKey key) {
   ArrayList<MappingWithDirection> result = new ArrayList<MappingWithDirection>();
   for (ParsedMapping pm : mappings) {
     if ((pm.mappingCase == null && key.mappingCase == null)
         ^ (pm.mappingCase != null && pm.mappingCase.equals(key.mappingCase))) {
       if (pm.sideA.isAssignableFrom(key.source) && pm.sideB.isAssignableFrom(key.target))
         result.add(new MappingWithDirection(pm, true));
       else if (pm.sideB.isAssignableFrom(key.source) && pm.sideA.isAssignableFrom(key.target))
         result.add(new MappingWithDirection(pm, false));
     }
   }
   if (!result.isEmpty()) {
     Collections.sort(result, new MappingComparator(key.target));
   } else if (automappingEnabled) {
     logger.info(
         "Could not find applicable mappings between {} and {}. A mapping will be created using automapping facility",
         key.source.getName(),
         key.target.getName());
     ParsedMapping pm = new Mapping(key.source, key.target, this).automap().parse();
     logger.debug("Automatically created {}", pm);
     mappings.add(pm);
     result.add(new MappingWithDirection(pm, true));
   } else
     logger.warn(
         "Could not find applicable mappings between {} and {}!",
         key.source.getName(),
         key.target.getName());
   return result;
 }
  /**
   * iterator over the Tokens in the given ring, starting with the token for the node owning start
   * (which does not have to be a Token in the ring)
   *
   * @param includeMin True if the minimum token should be returned in the ring even if it has no
   *     owner.
   */
  public static Iterator<Token> ringIterator(
      final ArrayList<Token> ring, Token start, boolean includeMin) {
    if (ring.isEmpty())
      return includeMin
          ? Iterators.singletonIterator(StorageService.getPartitioner().getMinimumToken())
          : Iterators.<Token>emptyIterator();

    final boolean insertMin = includeMin && !ring.get(0).isMinimum();
    final int startIndex = firstTokenIndex(ring, start, insertMin);
    return new AbstractIterator<Token>() {
      int j = startIndex;

      protected Token computeNext() {
        if (j < -1) return endOfData();
        try {
          // return minimum for index == -1
          if (j == -1) return StorageService.getPartitioner().getMinimumToken();
          // return ring token for other indexes
          return ring.get(j);
        } finally {
          j++;
          if (j == ring.size()) j = insertMin ? -1 : 0;
          if (j == startIndex)
            // end iteration
            j = -2;
        }
      }
    };
  }
Example #13
0
 /**
  * distribute datanodes in multi hosts,means ,dn1 (host1),dn100
  * (host2),dn300(host3),dn2(host1),dn101(host2),dn301(host3)...etc
  *
  * @param dataNodes
  */
 private void distributeDataNodes(ArrayList<String> theDataNodes) {
   Map<String, ArrayList<String>> newDataNodeMap =
       new HashMap<String, ArrayList<String>>(dataHosts.size());
   for (String dn : theDataNodes) {
     DataNodeConfig dnConf = dataNodes.get(dn);
     String host = dnConf.getDataHost();
     ArrayList<String> hostDns = newDataNodeMap.get(host);
     hostDns = (hostDns == null) ? new ArrayList<String>() : hostDns;
     hostDns.add(dn);
     newDataNodeMap.put(host, hostDns);
   }
   ArrayList<String> result = new ArrayList<String>(theDataNodes.size());
   boolean hasData = true;
   while (hasData) {
     hasData = false;
     for (ArrayList<String> dns : newDataNodeMap.values()) {
       if (!dns.isEmpty()) {
         result.add(dns.remove(0));
         hasData = true;
       }
     }
   }
   theDataNodes.clear();
   theDataNodes.addAll(result);
 }
  public Connection getConnection() throws SQLException {
    synchronized (pool) {
      if (!pool.isEmpty()) {
        int last = pool.size() - 1;
        Connection pooled = (Connection) pool.remove(last);

        boolean conn_ok = true;
        String test_table = prop.getProperty("test_table");
        if (test_table != null) {
          Statement stmt = null;
          try {
            stmt = pooled.createStatement();
            stmt.executeQuery("select * from " + prop.getProperty("test_table"));
          } catch (SQLException ex) {
            conn_ok = false; // 连接不可用
          } finally {
            if (stmt != null) {
              stmt.close();
            }
          }
        }
        if (conn_ok == true) {
          return pooled;
        } else {
          pooled.close();
        }
      }
    }
    Connection conn =
        DriverManager.getConnection(
            prop.getProperty("url"), prop.getProperty("username"), prop.getProperty("password"));
    return conn;
  }
 public void removeOwnership(String group) {
   if (!ownership.isEmpty()) {
     if (ownership.contains(group)) {
       ownership.remove(ownership.indexOf(group));
     }
   }
 }
 @Override
 public void ignoreProblem(RefEntity refEntity, CommonProblemDescriptor problem, int idx) {
   if (refEntity == null) return;
   final Set<QuickFix> localQuickFixes = getQuickFixActions().get(refEntity);
   final QuickFix[] fixes = problem.getFixes();
   if (isIgnoreProblem(fixes, localQuickFixes, idx)) {
     getProblemToElements().remove(problem);
     Map<RefEntity, CommonProblemDescriptor[]> problemElements = getProblemElements();
     synchronized (lock) {
       CommonProblemDescriptor[] descriptors = problemElements.get(refEntity);
       if (descriptors != null) {
         ArrayList<CommonProblemDescriptor> newDescriptors =
             new ArrayList<CommonProblemDescriptor>(Arrays.asList(descriptors));
         newDescriptors.remove(problem);
         getQuickFixActions().put(refEntity, null);
         if (!newDescriptors.isEmpty()) {
           problemElements.put(
               refEntity,
               newDescriptors.toArray(new CommonProblemDescriptor[newDescriptors.size()]));
           for (CommonProblemDescriptor descriptor : newDescriptors) {
             collectQuickFixes(descriptor.getFixes(), refEntity);
           }
         } else {
           ignoreProblemElement(refEntity);
         }
       }
     }
   }
 }
  @Nullable
  private ProblemDescriptor[] checkMember(
      final PsiDocCommentOwner docCommentOwner,
      final InspectionManager manager,
      final boolean isOnTheFly) {
    final ArrayList<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>();
    final PsiDocComment docComment = docCommentOwner.getDocComment();
    if (docComment == null) return null;

    final Set<PsiJavaCodeReferenceElement> references = new HashSet<PsiJavaCodeReferenceElement>();
    docComment.accept(getVisitor(references, docCommentOwner, problems, manager, isOnTheFly));
    for (PsiJavaCodeReferenceElement reference : references) {
      final List<PsiClass> classesToImport = new ImportClassFix(reference).getClassesToImport();
      final PsiElement referenceNameElement = reference.getReferenceNameElement();
      problems.add(
          manager.createProblemDescriptor(
              referenceNameElement != null ? referenceNameElement : reference,
              cannotResolveSymbolMessage("<code>" + reference.getText() + "</code>"),
              !isOnTheFly || classesToImport.isEmpty() ? null : new AddImportFix(classesToImport),
              ProblemHighlightType.LIKE_UNKNOWN_SYMBOL,
              isOnTheFly));
    }

    return problems.isEmpty() ? null : problems.toArray(new ProblemDescriptor[problems.size()]);
  }
 /**
  * Return certificates for signed bundle, otherwise null.
  *
  * @return An array of certificates or null.
  */
 public ArrayList getCertificateChains(boolean onlyTrusted) {
   if (checkCerts) {
     Certificate[] c = archive.getCertificates();
     checkCerts = false;
     if (c != null) {
       ArrayList failed = new ArrayList();
       untrustedCerts = Util.getCertificateChains(c, failed);
       if (!failed.isEmpty()) {
         // NYI, log Bundle archive has invalid certificates
         untrustedCerts = null;
       }
     }
   }
   ArrayList res = trustedCerts;
   if (!onlyTrusted && untrustedCerts != null) {
     if (res == null) {
       res = untrustedCerts;
     } else {
       res = new ArrayList(trustedCerts.size() + untrustedCerts.size());
       res.addAll(trustedCerts);
       res.addAll(untrustedCerts);
     }
   }
   return res;
 }
  private void updateTables7() {
    final ArrayList<Long> seriesIDs = new ArrayList<Long>();
    Cursor cursor = myDatabase.rawQuery("SELECT series_id,name FROM Series", null);
    while (cursor.moveToNext()) {
      if (cursor.getString(1).length() > 200) {
        seriesIDs.add(cursor.getLong(0));
      }
    }
    cursor.close();
    if (seriesIDs.isEmpty()) {
      return;
    }

    final ArrayList<Long> bookIDs = new ArrayList<Long>();
    for (Long id : seriesIDs) {
      cursor = myDatabase.rawQuery("SELECT book_id FROM BookSeries WHERE series_id=" + id, null);
      while (cursor.moveToNext()) {
        bookIDs.add(cursor.getLong(0));
      }
      cursor.close();
      myDatabase.execSQL("DELETE FROM BookSeries WHERE series_id=" + id);
      myDatabase.execSQL("DELETE FROM Series WHERE series_id=" + id);
    }

    for (Long id : bookIDs) {
      myDatabase.execSQL("DELETE FROM Books WHERE book_id=" + id);
      myDatabase.execSQL("DELETE FROM BookAuthor WHERE book_id=" + id);
      myDatabase.execSQL("DELETE FROM BookTag WHERE book_id=" + id);
    }
  }
  /**
   * formatCardType.
   *
   * @param card a {@link forge.Card} object.
   * @return a {@link java.lang.String} object.
   */
  public static String formatCardType(Card card) {
    ArrayList<String> list = card.getType();
    StringBuilder sb = new StringBuilder();

    ArrayList<String> superTypes = new ArrayList<String>();
    ArrayList<String> cardTypes = new ArrayList<String>();
    ArrayList<String> subTypes = new ArrayList<String>();
    for (String t : list) {
      if (CardUtil.isASuperType(t)) superTypes.add(t);
      if (CardUtil.isACardType(t)) cardTypes.add(t);
      if (CardUtil.isASubType(t)) subTypes.add(t);
    }

    for (String type : superTypes) {
      sb.append(type).append(" ");
    }
    for (String type : cardTypes) {
      sb.append(type).append(" ");
    }
    if (!subTypes.isEmpty()) sb.append("- ");
    for (String type : subTypes) {
      sb.append(type).append(" ");
    }

    return sb.toString();
  }
Example #21
0
  public void draw(node leaf, Graphics2D g, int px, int py) {
    int lvl = leaf.getLevel();
    double l = lvl;
    counts[lvl]++;

    double xfraq = counts[lvl] / (spacing[lvl] + 1);
    double yfraq = l / depth;
    int x = new Double(1600 * xfraq).intValue();
    int y = new Double(1200 * yfraq).intValue() + 10;

    if (leaf.getAttr() != null) {
      g.drawString(leaf.getAttr(), x - 20, y);
    }
    if (leaf.getCrit() != null) {
      g.drawString(leaf.getCrit(), x - 20, y + 10);
    }
    if (leaf.getResult() != null) {
      g.drawString(leaf.getResult(), x - 20, y + 10);
    }
    g.drawLine(x, y, px, py);
    // g.fillRect(x,y,20,20);
    ArrayList children = leaf.getChildren();
    while (!children.isEmpty()) {
      draw((node) children.remove(0), g, x, y);
    }
  }
 /**
  * Creates parent nodes, grandparent nodes, and so forth up to the root node, for the data that
  * has been inserted into the tree. Can only be called once, and thus can be called only after all
  * of the data has been inserted into the tree.
  */
 public synchronized void build() {
   if (built) return;
   root = itemBoundables.isEmpty() ? createNode(0) : createHigherLevels(itemBoundables, -1);
   // the item list is no longer needed
   itemBoundables = null;
   built = true;
 }
  protected boolean processConcludeQuest(QuestClient.ConcludeMessage msg) {
    Long mobOid = msg.getMobOid();
    if (!questOid.equals(msg.getQuestOid())) return true;
    if (Log.loggingDebug)
      log.debug("processConcludeQuest: player=" + getPlayerOid() + ", mob=" + mobOid);
    ArrayList<String> templateList = new ArrayList<String>();
    for (CollectionGoalStatus goalStatus : goalsStatus) {
      for (int i = 0; i < goalStatus.getTargetCount(); i++) {
        templateList.add(goalStatus.getTemplateName());
      }
    }

    boolean conclude = false;
    if (templateList.isEmpty()) {
      conclude = true;
    } else {
      List<Long> removeResult = InventoryClient.removeItems(getPlayerOid(), templateList);
      if (removeResult != null) {
        conclude = true;
        for (Long itemOid : removeResult) {
          ObjectManagerClient.deleteObject(itemOid);
        }
      }
    }
    if (conclude) {
      setConcluded(true);
      deactivate();
      updateQuestLog();
      sendStateStatusChange();
    }
    return true;
  }
  /**
   * This method will read the bill info from the database and return the whole set in a properly
   * formatted arraylist in order to be displayed in the report jtable of the program
   */
  protected void readDBReport() {

    super.runQuery(sql1);
    ArrayList results = this.getIds();
    if (results.isEmpty()) {
      System.out.println("result set is empty. Dump database operation aborted");
      results = new ArrayList();
      // System.exit(1);

    } else {

      for (int i = 0; i < results.size(); i += 8) {
        // with ids
        String[] row = {
          (String) results.get(i),
          (String) results.get(i + 1),
          (String) results.get(i + 2),
          (String) results.get(i + 3),
          (String) results.get(i + 4),
          (String) results.get(i + 5),
          (String) results.get(i + 6),
          (String) results.get(i + 7)
        };

        rows.add(row);
      }
    }
  }
 @Override
 protected void executeOverride(final RunningEffect linkedRE, final boolean trigger) {
   final ArrayList<RunningEffect> effectToRemove = new ArrayList<RunningEffect>();
   if (this.m_target == null) {
     StateDecurse.m_logger.warn(
         (Object) "[Effect] Impossible d'appliquer un desenvoutement car la cible est null");
     this.setNotified(true);
     return;
   }
   final RunningEffectManager effectManager = this.m_target.getRunningEffectManager();
   if (effectManager == null) {
     return;
   }
   int newStateLevel = 0;
   newStateLevel = this.computeEffectsToRemove(effectToRemove, effectManager, newStateLevel);
   if (effectToRemove.isEmpty()) {
     this.setNotified();
     return;
   }
   for (final RunningEffect anEffectToRemove : effectToRemove) {
     ((TimedRunningEffectManager) effectManager).removeEffect(anEffectToRemove, true);
   }
   this.notifyExecution(linkedRE, trigger);
   if (this.isValueComputationEnabled() && this.m_decreaseLevel && newStateLevel > 0) {
     this.applyNewState(newStateLevel, linkedRE);
   }
 }
 private BxBounds parseElementContainingVertexes(Element el) {
   ArrayList<Element> vs = getChildren("Vertex", el);
   if (vs.isEmpty()) {
     return null;
   }
   ArrayList<ComparablePair<Integer, Integer>> list =
       new ArrayList<ComparablePair<Integer, Integer>>();
   int minx = Integer.MAX_VALUE;
   int maxx = Integer.MIN_VALUE;
   int miny = Integer.MAX_VALUE;
   int maxy = Integer.MIN_VALUE;
   for (Element v : vs) {
     int x = Integer.parseInt(v.getAttribute("x"));
     if (x < minx) minx = x;
     if (x > maxx) maxx = x;
     int y = Integer.parseInt(v.getAttribute("y"));
     if (y < miny) miny = y;
     if (y > maxy) maxy = y;
     list.add(new ComparablePair<Integer, Integer>(x, y));
   }
   Collections.sort(list);
   ComparablePair<Integer, Integer> mine = list.get(0);
   ComparablePair<Integer, Integer> maxe = list.get(list.size() - 1);
   BxBounds ret = new BxBounds(minx, miny, maxx - minx, maxy - miny);
   if (ret.getHeight() == 0 || ret.getWidth() == 0) {
     log.warn("problems with height or width points are:");
     for (ComparablePair<Integer, Integer> pa : list) {
       log.warn("\t" + pa.o1 + " , " + pa.o2);
     }
   }
   return ret;
 }
Example #27
0
  public static void golf(String file_name) {
    Random rand = new Random();
    ArrayList<Person> players = new ArrayList();
    try {
      Scanner in = new Scanner(new FileReader(file_name));
      while (in.hasNextLine()) {
        String name = in.nextLine();
        Person person = new Person(name);
        players.add(person);
      }
    } catch (Exception e) {
      System.out.println("Could not find file");
    }

    while (!players.isEmpty()) {
      int first, second;
      do {
        first = rand.nextInt(players.size());
        second = rand.nextInt(players.size());
      } while (first == second);
      System.out.println("Team:");
      System.out.println(players.get(first).name);
      System.out.println(players.get(second).name);
      System.out.print("\n");
      players.remove(second);
      if (second < first) {
        players.remove(first - 1);
      } else {
        players.remove(first);
      }
    }
  }
 public GetFightersLevelSum(final ArrayList<ParserObject> args) {
   super();
   if (args.isEmpty()) {
     return;
   }
   this.m_monsters = "monster".equalsIgnoreCase(args.get(0).getValue());
 }
    @Override
    public Object findElement(String s) {
      List<ObjectWithWeight> elements = new ArrayList<ObjectWithWeight>();
      s = s.trim();
      final ListIterator<Object> it = getElementIterator(0);
      while (it.hasNext()) {
        final ObjectWithWeight o = new ObjectWithWeight(it.next(), s, getComparator());
        if (!o.weights.isEmpty()) {
          elements.add(o);
        }
      }
      ObjectWithWeight cur = null;
      ArrayList<ObjectWithWeight> current = new ArrayList<ObjectWithWeight>();
      for (ObjectWithWeight element : elements) {
        if (cur == null) {
          cur = element;
          current.add(cur);
          continue;
        }

        final int i = element.compareWith(cur);
        if (i == 0) {
          current.add(element);
        } else if (i < 0) {
          cur = element;
          current.clear();
          current.add(cur);
        }
      }

      return current.isEmpty() ? null : findClosestTo(myInitialPsiElement, current);
    }
Example #30
-1
  /**
   * Generates a synthetic network for provided vertices in the given graphh such that the provided
   * expected number of communities are generated with the specified expected number of edges.
   *
   * @param graph
   * @param vertices
   * @param expectedNumCommunities
   * @param expectedNumEdges
   * @return The actual number of edges generated. May be different from the expected number.
   */
  public int generate(
      Graph graph, Iterable<Vertex> vertices, int expectedNumCommunities, int expectedNumEdges) {
    if (communitySize == null)
      throw new IllegalStateException("Need to initialize community size distribution");
    if (edgeDegree == null)
      throw new IllegalStateException("Need to initialize degree distribution");
    int numVertices = SizableIterable.sizeOf(vertices);
    Iterator<Vertex> iter = vertices.iterator();
    ArrayList<ArrayList<Vertex>> communities =
        new ArrayList<ArrayList<Vertex>>(expectedNumCommunities);
    Distribution communityDist = communitySize.initialize(expectedNumCommunities, numVertices);
    while (iter.hasNext()) {
      int nextSize = communityDist.nextValue(random);
      ArrayList<Vertex> community = new ArrayList<Vertex>(nextSize);
      for (int i = 0; i < nextSize && iter.hasNext(); i++) {
        community.add(iter.next());
      }
      if (!community.isEmpty()) communities.add(community);
    }

    double inCommunityPercentage = 1.0 - crossCommunityPercentage;
    Distribution degreeDist = edgeDegree.initialize(numVertices, expectedNumEdges);
    if (crossCommunityPercentage > 0 && communities.size() < 2)
      throw new IllegalArgumentException("Cannot have cross links with only one community");
    int addedEdges = 0;

    // System.out.println("Generating links on communities: "+communities.size());

    for (ArrayList<Vertex> community : communities) {
      for (Vertex v : community) {
        int degree = degreeDist.nextValue(random);
        degree =
            Math.min(degree, (int) Math.ceil((community.size() - 1) / inCommunityPercentage) - 1);
        Set<Vertex> inlinks = new HashSet<Vertex>();
        for (int i = 0; i < degree; i++) {
          Vertex selected = null;
          if (random.nextDouble() < crossCommunityPercentage
              || (community.size() - 1 <= inlinks.size())) {
            // Cross community
            ArrayList<Vertex> othercomm = null;
            while (othercomm == null) {
              othercomm = communities.get(random.nextInt(communities.size()));
              if (othercomm.equals(community)) othercomm = null;
            }
            selected = othercomm.get(random.nextInt(othercomm.size()));
          } else {
            // In community
            while (selected == null) {
              selected = community.get(random.nextInt(community.size()));
              if (v.equals(selected) || inlinks.contains(selected)) selected = null;
            }
            inlinks.add(selected);
          }
          addEdge(graph, v, selected);
          addedEdges++;
        }
      }
    }
    return addedEdges;
  }