Java Code Examples for java.util.Vector#addAll()

The following examples show how to use java.util.Vector#addAll() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: qaf   File: FileUtil.java    License: MIT License 6 votes vote down vote up
public static Collection<File> getFiles(File directory, String name, StringComparator c, boolean recurse) {
	// List of files / directories
	Vector<File> files = new Vector<File>();

	// Get files / directories in the directory
	File[] entries = directory.listFiles();
	FilenameFilter filter = getFileFilterFor(name, c);
	// Go over entries
	for (File entry : entries) {
		if ((filter == null) || filter.accept(directory, entry.getName())) {
			files.add(entry);
		}

		// If the file is a directory and the recurse flag
		// is set, recurse into the directory
		if (recurse && entry.isDirectory()) {
			files.addAll(listFiles(entry, filter, recurse));
		}
	}

	// Return collection of files
	return files;
}
 
Example 2
Source Project: lunzi   File: DecodeThread.java    License: Apache License 2.0 6 votes vote down vote up
DecodeThread(CaptureActivity activity,
             Vector<BarcodeFormat> decodeFormats,
             String characterSet,
             ResultPointCallback resultPointCallback) {

    this.activity = activity;
    handlerInitLatch = new CountDownLatch(1);

    hints = new Hashtable<DecodeHintType, Object>(3);

    if (decodeFormats == null || decodeFormats.isEmpty()) {
        decodeFormats = new Vector<BarcodeFormat>();
        decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
        decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
        decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
    }

    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

    if (characterSet != null) {
        hints.put(DecodeHintType.CHARACTER_SET, characterSet);
    }

    hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
}
 
Example 3
Source Project: toolbox   File: AmidstClassifier.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns an enumeration describing the available options.
 *
 * @return an enumeration of all the available options.
 */
@Override
public Enumeration<Option> listOptions() {

    Vector<Option> newVector = new Vector<Option>(2);

    newVector.addElement(new Option(
            "\tNumber of Gaussian hidden variables.\n"+
                    "\t(Default = 0)",
            "G", 1,"-G <number of Gaussian hidden>"));
    newVector.addElement(new Option(
            "\tNumber of states of the discrete hidden variable.\n"+
                    "\t(Default = 0)",
            "S", 1,"-S <number of states>"));

    newVector.addAll(Collections.list(super.listOptions()));

    return newVector.elements();
}
 
Example 4
Source Project: commcare-android   File: StorageUtils.java    License: Apache License 2.0 6 votes vote down vote up
@NonNull
public static Vector<Integer> getUnsentOrUnprocessedFormIdsForCurrentApp(
        SqlStorage<FormRecord> storage) {

    String currentAppId =
            CommCareApplication.instance().getCurrentApp().getAppRecord().getApplicationId();

    Vector<Integer> ids = storage.getIDsForValues(
            new String[]{FormRecord.META_STATUS, FormRecord.META_APP_ID},
            new Object[]{FormRecord.STATUS_UNSENT, currentAppId});
    ids.addAll(storage.getIDsForValues(
            new String[]{FormRecord.META_STATUS, FormRecord.META_APP_ID},
            new Object[]{FormRecord.STATUS_COMPLETE, currentAppId}));

    return ids;
}
 
Example 5
Source Project: tlaplus   File: PcalTranslate.java    License: MIT License 6 votes vote down vote up
private static Vector ExplodeLabeledStmtSeq (Vector seq,
                                            String next) throws PcalTranslateException {
/**********************************************************************
* seq is a sequence of LabeledStmts, and `next' is the label that     *
* follows them.  Returns the sequence of LabeledStmts obtained by     *
* iteratively calling ExplodeLabeledStmt to explode the statements    *
* in seq.                                                             *
*                                                                     *
* Added by LL on 30 Jan 2006.  I don't know why this method did not   *
* already exist, since it must have been written in-line about 5      *
* times in various other methods.                                     *
**********************************************************************/
Vector result = new Vector() ;     
for (int i = 0; i < seq.size(); i++) {
  AST.LabeledStmt stmt = (AST.LabeledStmt) seq.elementAt(i) ;
  String nxt = (i < seq.size() - 1) ?
                 ((AST.LabeledStmt) seq.elementAt(i+1)).label : next ;
  result.addAll(ExplodeLabeledStmt(stmt, nxt)) ;
 };
return result ;
}
 
Example 6
/**
 * @serialData "permissions" field (a Vector containing the SocketPermissions).
 */
/*
 * Writes the contents of the perms field out as a Vector for
 * serialization compatibility with earlier releases.
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    // Don't call out.defaultWriteObject()

    // Write out Vector
    Vector<SocketPermission> permissions = new Vector<>(perms.size());

    synchronized (this) {
        permissions.addAll(perms);
    }

    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("permissions", permissions);
    out.writeFields();
}
 
Example 7
public Vector<Report> burnDownWoods(Coords coords) {
    Vector<Report> burnReports = new Vector<>();
    int burnDamage = 5;
    try {
        burnDamage = game.getOptions().intOption(OptionsConstants.ADVANCED_WOODS_BURN_DOWN_AMOUNT);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    // Report that damage applied to terrain
    Report r = new Report(3383, Report.PUBLIC);
    r.indent(1);
    r.add(burnDamage);
    burnReports.addElement(r);

    Vector<Report> newReports =
            server.tryClearHex(coords, burnDamage, Entity.NONE);
    for (Report nr : newReports) {
        nr.indent(2);
    }
    burnReports.addAll(newReports);
    return burnReports;
}
 
Example 8
Source Project: olat   File: CPCore.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Checks how many item-elements link to the given resource element.
 * 
 * @param resource
 * @return
 */
protected int referencesCount(final CPResource resource) {

    int linkCount = 0;
    final Vector<CPItem> items = new Vector<CPItem>();
    for (final Iterator<CPOrganization> it = rootNode.getOrganizations().getOrganizationIterator(); it.hasNext();) {
        final CPOrganization org = it.next();
        items.addAll(org.getAllItems());
    }

    for (final CPItem item : items) {
        if (item.getIdentifierRef().equals(resource.getIdentifier())) {
            linkCount++;
        }
    }

    final Vector<CPDependency> dependencies = rootNode.getResources().getAllDependencies();
    for (final CPDependency dependency : dependencies) {
        if (dependency.getIdentifierRef().equals(resource.getIdentifier())) {
            linkCount++;
        }
    }

    return linkCount;
}
 
Example 9
/**
 * @serialData "permissions" field (a Vector containing the SocketPermissions).
 */
/*
 * Writes the contents of the perms field out as a Vector for
 * serialization compatibility with earlier releases.
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    // Don't call out.defaultWriteObject()

    // Write out Vector
    Vector<SocketPermission> permissions = new Vector<>(perms.size());

    synchronized (this) {
        permissions.addAll(perms);
    }

    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("permissions", permissions);
    out.writeFields();
}
 
Example 10
Source Project: toolbox   File: AmidstRegressor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns an enumeration describing the available options.
 *
 * @return an enumeration of all the available options.
 */
@Override
public Enumeration<Option> listOptions() {

    Vector<Option> newVector = new Vector<Option>(1);

    newVector.addElement(new Option(
            "\tNumber of Gaussian hidden variables.\n"+
                    "\t(Default = 0)",
            "G", 1,"-G <number of Gaussian hidden>"));

    newVector.addAll(Collections.list(super.listOptions()));

    return newVector.elements();
}
 
Example 11
Source Project: chipster   File: SwingClientApplication.java    License: MIT License 5 votes vote down vote up
public void updateFocusTraversal() {
	Vector<Component> order = new Vector<Component>();
	order.addAll(visualisationFrameManager.getFocusComponents());
	order.addAll(tree.getFocusComponents());
	order.addAll(toolPanel.getFocusComponents());

	getMainFrame().setFocusTraversalPolicy(new ClientFocusTraversalPolicy(order));

}
 
Example 12
/**
 * Very demanding task depending on how many plots in each world.
 *
 * @return all plots
 */
public List<Plot> getPlots() {
    Vector<Plot> allPlots = new Vector<>();
    for (HashMap<PlotId, Plot> plotIdPlotHashMap : plots.values()) {
        allPlots.addAll(plotIdPlotHashMap.values());
    }
    return allPlots;
}
 
Example 13
Source Project: tlaplus   File: PcalTranslate.java    License: MIT License 5 votes vote down vote up
private static Vector ExplodeLabeledStmt (AST.LabeledStmt ast,
                                          String next) throws PcalTranslateException {
     /******************************************************************
     * label SL -->                                                    *
     * label when pc = "label" ;                                       *
     *       SL                                                        *
     *       pc := next;                                               *
     *                                                                 *
     * Comment added by LL on 30 Jan 2006.                             *
     * I have no idea what the comment above is supposed to mean, but  *
     * this seems to return a sequence of labeled statements,          *
     * consisting of the exploded version of the labeled stmt ast      *
     * followed by the exploded labeled statements contained within    *
     * it.                                                             *
     ******************************************************************/
    /* Handle case of initial while separately */
    if (ast.stmts.size() > 0 && 
        ast.stmts.elementAt(0).getClass().equals(AST.WhileObj.getClass())) {
        return ExplodeWhile(ast, next);
    }
    AST.LabeledStmt newast = new AST.LabeledStmt();
    Vector pair = 
            CopyAndExplodeLastStmtWithGoto((Vector) ast.stmts.clone(), 
                                           next);
    Vector result = new Vector();
    newast.setOrigin(ast.getOrigin()) ;
    newast.col = ast.col;
    newast.line = ast.line;
    newast.label = ast.label;
    /* add the statements with last exploded */
    newast.stmts = (Vector) pair.elementAt(0);
    if (! ParseAlgorithm.omitPC) {
       /* prepend pc check */
       newast.stmts.insertElementAt(CheckPC(newast.label), 0);
       result.addElement(newast);
    }
    /* add recursively generated labeled statements */
    result.addAll((Vector) pair.elementAt(1));
    return result;
}
 
Example 14
Source Project: megamek   File: Tank.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Vector<Report> victoryReport() {
    Vector<Report> vDesc = new Vector<Report>();

    Report r = new Report(7025);
    r.type = Report.PUBLIC;
    r.addDesc(this);
    vDesc.addElement(r);

    r = new Report(7035);
    r.type = Report.PUBLIC;
    r.newlines = 0;
    vDesc.addElement(r);
    vDesc.addAll(getCrew().getDescVector(false));
    r = new Report(7070, Report.PUBLIC);
    r.add(getKillNumber());
    vDesc.addElement(r);

    if (isDestroyed()) {
        Entity killer = game.getEntity(killerId);
        if (killer == null) {
            killer = game.getOutOfGameEntity(killerId);
        }
        if (killer != null) {
            r = new Report(7072, Report.PUBLIC);
            r.addDesc(killer);
        } else {
            r = new Report(7073, Report.PUBLIC);
        }
        vDesc.addElement(r);
    } else if (getCrew().isEjected()) {
        r = new Report(7071, Report.PUBLIC);
        vDesc.addElement(r);
    }
    r.newlines = 2;

    return vDesc;
}
 
Example 15
protected Enumeration getDefinitions() {
  Vector allElements = new Vector();

  allElements.addAll(elements.values());
  allElements.addAll(labels.values());
  allElements.addAll(classes.values());

  return allElements.elements();
}
 
Example 16
@Override
protected void handleEntityDamage(Entity entityTarget,
        Vector<Report> vPhaseReport, Building bldg, int hits, int nCluster,
        int bldgAbsorbs) {
    HitData hit = entityTarget.rollHitLocation(toHit.getHitTable(),
            toHit.getSideTable(), waa.getAimedLocation(),
            waa.getAimingMode(), toHit.getCover());
    hit.setAttackerId(getAttackerId());
    // If a leg attacks hit a leg that isn't
    // there, then hit the other leg.
    if (entityTarget.getInternal(hit) <= 0) {
        if (hit.getLocation() == Mech.LOC_RLEG) {
            hit = new HitData(Mech.LOC_LLEG);
        } else {
            hit = new HitData(Mech.LOC_RLEG);
        }
    }
    hit.setGeneralDamageType(generalDamageType);

    Report r = new Report(3405);
    r.subject = subjectId;
    r.add(toHit.getTableDesc());
    r.add(entityTarget.getLocationAbbr(hit));
    vPhaseReport.addElement(r);

    int damage = 4;
    if (ae instanceof BattleArmor) {
        damage += ((BattleArmor) ae).getVibroClaws();
        if (((BattleArmor) ae).hasMyomerBooster()) {
            damage += ((BattleArmor) ae).getTroopers() * 2;
        }
    }

    // ASSUMPTION: buildings CAN'T absorb *this* damage.
    vPhaseReport.addAll(server.damageEntity(entityTarget, hit, damage,
            false, damageType, false, false, throughFront, underWater));
    Report.addNewline(vPhaseReport);
    // Do criticals.
    int critMod = 0;
    if (entityTarget.getArmorType(hit.getLocation()) == EquipmentType.T_ARMOR_HARDENED) {
        critMod -= 2;
    }
    if (ae.hasAbility(OptionsConstants.MISC_HUMAN_TRO,Crew.HUMANTRO_MECH)) {
        critMod += 1;
    }
    vPhaseReport.addAll(server.criticalEntity(entityTarget, hit.getLocation(), hit.isRear(), critMod, damage));
}
 
Example 17
Source Project: zxing   File: DecodeImgThread.java    License: MIT License 4 votes vote down vote up
@Override
public void run() {
    super.run();

    if (TextUtils.isEmpty(imgPath) || callback == null) {
        return;
    }

    Bitmap scanBitmap = getBitmap(imgPath, 400, 400);

    MultiFormatReader multiFormatReader = new MultiFormatReader();
    // 解码的参数
    Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(2);
    // 可以解析的编码类型
    Vector<BarcodeFormat> decodeFormats = new Vector<BarcodeFormat>();


    // 扫描的类型  一维码和二维码
    decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
    decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
    decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);

    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
    // 设置解析的字符编码格式为UTF8
    //  hints.put(DecodeHintType.CHARACTER_SET, "UTF8");
    // 设置解析配置参数
    multiFormatReader.setHints(hints);
    // 开始对图像资源解码
    Result rawResult = null;
    try {
        rawResult = multiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(new BitmapLuminanceSource(scanBitmap))));

        Log.i("解析结果", rawResult.getText());

    } catch (Exception e) {
        e.printStackTrace();
        //  Log.i("解析的图片结果","失败");
    }

    if (rawResult != null) {
        callback.onImageDecodeSuccess(rawResult);
    } else {
        callback.onImageDecodeFailed();
    }


}
 
Example 18
Source Project: org.openntf.domino   File: Document.java    License: Apache License 2.0 4 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Item appendItemValue(final String name, final Object value, final boolean unique) {
	checkMimeOpen(name);
	Item result = null;
	if (unique && hasItem(name)) {
		// TODO RPr This function is not yet 100% mime compatible
		// Once mime compatible, remove the reference in org.openntf.domino.ext.Document Javadoc
		result = getFirstItem(name);
		if (result.containsValue(value)) {// this does not work when it is not dominoFriendly
			return result;
		}
	}
	try {
		if (!hasItem(name)) {
			result = replaceItemValue(name, value);
		} else if (value != null) {
			List recycleThis = new ArrayList();
			try {
				Object domNode = toDominoFriendly(value, getAncestorSession(), recycleThis);
				if (getAncestorSession().isFixEnabled(Fixes.APPEND_ITEM_VALUE)) {
					Vector current = getItemValue(name);
					if (current == null) {
						result = replaceItemValue(name, value);
					} else if (domNode instanceof Collection) {
						current.addAll((Collection) domNode);
						result = replaceItemValue(name, current);
					} else {
						current.add(domNode);
						result = replaceItemValue(name, current);
					}
				} else {
					beginEdit();
					result = fromLotus(getDelegate().appendItemValue(name, domNode), Item.SCHEMA, this);
					markDirty(name, true);
				}
			} finally {
				s_recycle(recycleThis);
			}
		} else {
			result = appendItemValue(name);
		}

	} catch (NotesException e) {
		DominoUtils.handleException(e, this, "Item=" + name);
	}
	return result;
}
 
Example 19
Vector getIncludes() {
    Vector rv = new Vector();
    collectRelevantVectors(rv, "AbsoluteInclude");
    rv.addAll(getSourceIncludes());
    return rv;
}
 
Example 20
@Override
public void run() {
  synchronized (requestExistsMutex) {
    if (requestExist) {
      callback.onResponse("Another UpdateTransacionCache_taddr request exists.", null);
      return;
    } else {
      requestExist = true;
    }
  }

  Vector<ZCashTransactionDetails_taddr> transactions = cache;
  if (transactions == null) {
    synchronized (requestExistsMutex) {
      requestExist = false;
    }

    callback.onResponse("Wallet is not imported.", null);
    return;
  }


  SortedSet<ZCashTransactionDetails_taddr> uniqueTransactions = new TreeSet<>();
  long lastBlock = 0;

  if (transactions.isEmpty()) {
    rescan = true;
  } else {
    lastBlock = transactions.lastElement().blockHeight;
  }

  if (rescan) {
    synchronized (transactions) {
      transactions.clear();
    }
  }

  try {
    getAllRecv(20, 0, rescan, lastBlock, uniqueTransactions);
    getAllSent(20, 0, rescan, lastBlock, uniqueTransactions);
  } catch (ZCashException e) {
    synchronized (requestExistsMutex) {
      requestExist = false;
    }

    callback.onResponse(e.getMessage(), null);
    return;
  }

  boolean initialized = ZCashTransactionDetails_taddr.prepareAfterParsing(uniqueTransactions);
  if (initialized) {
    transactions.addAll(uniqueTransactions);
  } else {
    synchronized (requestExistsMutex) {
      requestExist = false;
    }

    return;
  }

  synchronized (requestExistsMutex) {
    requestExist = false;
  }


  callback.onResponse("ok", null);
}