Example usage for java.util Vector elements

List of usage examples for java.util Vector elements

Introduction

In this page you can find the example usage for java.util Vector elements.

Prototype

public Enumeration<E> elements() 

Source Link

Document

Returns an enumeration of the components of this vector.

Usage

From source file:org.accada.reader.rprm.core.Source.java

/**
 * Programs a tag with the given ID and the optionally specified passwords.
 * @param newID/*from  www .  jav  a 2 s .  c  o  m*/
 *           The new id
 * @param passwords
 *           An optional list of one or more passwords (or lock code). The
 *          use of passwords is dependent upon the tag's RF protocol
 * @param tagSelectorList
 *           Not in use // TODO: Remove this parameter.
 * @throws ReaderProtocolException
 *            "ERROR_MULTIPLE_TAGS"
 */
public void writeID(final String newID, final String[] passwords, final TagSelector[] tagSelectorList)
        throws ReaderProtocolException {

    // get all relevant readers with their readpoints
    Vector closure = getReaderAndReadPoints();

    // closure
    Enumeration closureIterator = closure.elements();
    ReaderAndReadPoints curClosure;
    while (closureIterator.hasMoreElements()) {
        curClosure = (ReaderAndReadPoints) closureIterator.nextElement();

        try {
            HardwareAbstraction reader = curClosure.getReader();

            // write ID
            String[] readPoints = curClosure.getAllReadPointsAsArray();
            HardwareException ex;
            int failcount = 0;
            for (int i = 0; i < readPoints.length; i++) {
                try {
                    reader.writeId(readPoints[i], newID, passwords);
                } catch (HardwareException he) {
                    failcount++;
                    ex = he;
                }
            }
            if (failcount == readPoints.length) {
                throw new ReaderProtocolException("ERROR_UNKNOWN", MessagingConstants.ERROR_UNKNOWN);
            }

            // Where is the tag?
            Observation[] observations = reader.identify(curClosure.getAllReadPointsAsArray());
            String readPointName = null;
            for (int i = 0; i < observations.length; i++) {
                if (observations[i].containsId(newID))
                    readPointName = observations[i].getReadPointName();
                break;
            }

            // Increase the counter
            if (readPointName != null) {
                increaseAntennaReadPointWriteCount(readPointName);
            }
        } catch (HardwareException he) {
            ReadPoint readPoint = (ReadPoint) readPoints.get(he.getMessage());
            if ((readPoint != null) && (readPoint instanceof AntennaReadPoint)) {
                ((AntennaReadPoint) readPoint).writeFailureOccurred();
            }
            /*
            ReadPoint readPoint = (ReadPoint) readPoints.get(he.getReadPointName());
            if (readPoint instanceof AntennaReadPoint) {
               ((AntennaReadPoint) readPoint).writeFailureOccurred();
            }
            int errorCode = he.getReaderProtocolErrorCode();
            switch(errorCode) {
               case MessagingConstants.ERROR_MULTIPLE_TAGS:
                  throw new ReaderProtocolException("ERROR_MULTIPLE_TAGS", errorCode);
               case MessagingConstants.ERROR_NO_TAG:
                  throw new ReaderProtocolException("ERROR_NO_TAG", errorCode);
            }
            */
            throw new ReaderProtocolException("ERROR_UNKNOWN", MessagingConstants.ERROR_UNKNOWN);
        }
    }
}

From source file:org.accada.reader.rprm.core.Source.java

/**
 * Reads a tag field.//  w w w.  ja va 2s  .  c om
 * @param tagId
 *           The id of the tag
 * @param closure
 *           The readers an its readpoint instances
 * @param tagField
 *           The tag field
 * @return The read value. If no value is found this method returns 'null'
 */
private String readTagField(final String tagId, final Vector closure, final TagField tagField) {

    // closure
    Enumeration closureIterator = closure.elements();
    ReaderAndReadPoints curClosure;
    while (closureIterator.hasMoreElements()) {

        curClosure = (ReaderAndReadPoints) closureIterator.nextElement();

        HardwareAbstraction reader = curClosure.getReader();
        String[] readPointNames = curClosure.getAllReadPointsAsArray();
        for (int i = 0; i < readPointNames.length; i++) {
            try {
                byte[] memory;
                // calculate byte borders
                int offset = tagField.getOffset();
                int length = tagField.getLength();
                int byteoffset = offset / 8;
                int bytelength = ((offset % 8) + length + 7) / 8;
                // read
                memory = reader.readBytes(readPointNames[i], tagId, tagField.getMemoryBank(), byteoffset,
                        bytelength, new String[] {}).toByteArray();
                increaseAntennaReadPointMemReadCount(readPointNames[i]);
                // extract requested bits
                int shift = (offset + length) % 8;
                byte[] cutmemory;
                if (shift != 0) {
                    int shiftlength = bytelength * 8 - (offset % 8);
                    byte[] shiftedmemory = HexUtil.bitarrayShiftAndFill(memory, shiftlength, shift, (byte) 0x00,
                            (byte) 0x00);
                    cutmemory = new byte[shiftedmemory.length - 1];
                    System.arraycopy(shiftedmemory, 0, cutmemory, 0, cutmemory.length);
                } else {
                    cutmemory = memory;
                    int leftmask = 0xFF >> ((8 - (length % 8)) % 8);
                    cutmemory[0] &= leftmask;
                }
                // create string representation
                return HexUtil.byteArrayToHexString(cutmemory);
            } catch (HardwareException he) {
                ReadPoint readPoint = (ReadPoint) readPoints.get(readPointNames[i]);
                if (readPoint instanceof AntennaReadPoint) {
                    ((AntennaReadPoint) readPoint).memReadFailureOccurred();
                }
            }
        }
    }

    /* This is code from the 0.2 branch that Remo edited
    // I was not 100% convinced that we might not need, but it does not take the changes
    // in the HAL interface into account
            
       curClosure = (ReaderAndReadPoints) closureIterator.nextElement();
            
       // services
       try {
    String[] services = curClosure.getReader().getServices();
    for (int j = 0; j < services.length; j++) {
       if (services[j].equals("readBytes")) {
          byte[] temp;
          temp = curClosure.getReader().readBytes( tagId,
                tagField.getOffset(), tagField.getLength());
          return HexUtil.byteArrayToHexString(temp);
       }
    }
       } catch (Exception e) {
    // tag not in range of this reader
    System.out.println(e.getMessage());
       }
            
    }
            
    */
    return "not found";
}

From source file:com.github.maven_nar.cpptasks.compiler.CommandLineCompiler.java

@Override
protected CompilerConfiguration createConfiguration(final CCTask task, final LinkType linkType,
        final ProcessorDef[] baseDefs, final CompilerDef specificDef, final TargetDef targetPlatform,
        final VersionInfo versionInfo) {

    this.prefix = specificDef.getCompilerPrefix();
    this.objDir = task.getObjdir();
    final Vector<String> args = new Vector<>();
    final CompilerDef[] defaultProviders = new CompilerDef[baseDefs.length + 1];
    for (int i = 0; i < baseDefs.length; i++) {
        defaultProviders[i + 1] = (CompilerDef) baseDefs[i];
    }/*from   w  w w.j a  va  2  s. c o  m*/
    defaultProviders[0] = specificDef;
    final Vector<CommandLineArgument> cmdArgs = new Vector<>();

    //
    // add command line arguments inherited from <cc> element
    // any "extends" and finally the specific CompilerDef
    CommandLineArgument[] commandArgs;
    for (int i = defaultProviders.length - 1; i >= 0; i--) {
        commandArgs = defaultProviders[i].getActiveProcessorArgs();
        for (final CommandLineArgument commandArg : commandArgs) {
            if (commandArg.getLocation() == 0) {
                String arg = commandArg.getValue();
                if (isWindows() && arg.matches(".*[ \"].*")) {
                    // Work around inconsistent quoting by Ant
                    arg = "\"" + arg.replaceAll("[\\\\\"]", "\\\\$0") + "\"";
                }
                args.addElement(arg);
            } else {
                cmdArgs.addElement(commandArg);
            }
        }
    }
    final Vector<ProcessorParam> params = new Vector<>();
    //
    // add command line arguments inherited from <cc> element
    // any "extends" and finally the specific CompilerDef
    ProcessorParam[] paramArray;
    for (int i = defaultProviders.length - 1; i >= 0; i--) {
        paramArray = defaultProviders[i].getActiveProcessorParams();
        Collections.addAll(params, paramArray);
    }
    paramArray = params.toArray(new ProcessorParam[params.size()]);

    if (specificDef.isClearDefaultOptions() == false) {
        final boolean multithreaded = specificDef.getMultithreaded(defaultProviders, 1);
        final boolean debug = specificDef.getDebug(baseDefs, 0);
        final boolean exceptions = specificDef.getExceptions(defaultProviders, 1);
        final Boolean rtti = specificDef.getRtti(defaultProviders, 1);
        final OptimizationEnum optimization = specificDef.getOptimization(defaultProviders, 1);
        this.addImpliedArgs(args, debug, multithreaded, exceptions, linkType, rtti, optimization);
    }

    //
    // add all appropriate defines and undefines
    //
    buildDefineArguments(defaultProviders, args);
    final int warnings = specificDef.getWarnings(defaultProviders, 0);
    addWarningSwitch(args, warnings);
    Enumeration<CommandLineArgument> argEnum = cmdArgs.elements();
    int endCount = 0;
    while (argEnum.hasMoreElements()) {
        final CommandLineArgument arg = argEnum.nextElement();
        switch (arg.getLocation()) {
        case 1:
            args.addElement(arg.getValue());
            break;
        case 2:
            endCount++;
            break;
        }
    }
    final String[] endArgs = new String[endCount];
    argEnum = cmdArgs.elements();
    int index = 0;
    while (argEnum.hasMoreElements()) {
        final CommandLineArgument arg = argEnum.nextElement();
        if (arg.getLocation() == 2) {
            endArgs[index++] = arg.getValue();
        }
    }
    //
    // Want to have distinct set of arguments with relative
    // path names for includes that are used to build
    // the configuration identifier
    //
    final Vector<String> relativeArgs = (Vector) args.clone();
    //
    // add all active include and sysincludes
    //
    final StringBuffer includePathIdentifier = new StringBuffer();
    final File baseDir = specificDef.getProject().getBaseDir();
    String baseDirPath;
    try {
        baseDirPath = baseDir.getCanonicalPath();
    } catch (final IOException ex) {
        baseDirPath = baseDir.toString();
    }
    final Vector<String> includePath = new Vector<>();
    final Vector<String> sysIncludePath = new Vector<>();
    for (int i = defaultProviders.length - 1; i >= 0; i--) {
        String[] incPath = defaultProviders[i].getActiveIncludePaths();
        for (final String element : incPath) {
            includePath.addElement(element);
        }
        incPath = defaultProviders[i].getActiveSysIncludePaths();
        for (final String element : incPath) {
            sysIncludePath.addElement(element);
        }
    }
    final File[] incPath = new File[includePath.size()];
    for (int i = 0; i < includePath.size(); i++) {
        incPath[i] = new File(includePath.elementAt(i));
    }
    final File[] sysIncPath = new File[sysIncludePath.size()];
    for (int i = 0; i < sysIncludePath.size(); i++) {
        sysIncPath[i] = new File(sysIncludePath.elementAt(i));
    }
    addIncludes(baseDirPath, incPath, args, relativeArgs, includePathIdentifier, false);
    addIncludes(baseDirPath, sysIncPath, args, null, null, true);
    final StringBuffer buf = new StringBuffer(getIdentifier());
    for (int i = 0; i < relativeArgs.size(); i++) {
        buf.append(' ');
        buf.append(relativeArgs.elementAt(i));
    }
    for (final String endArg : endArgs) {
        buf.append(' ');
        buf.append(endArg);
    }
    final String configId = buf.toString();
    final String[] argArray = new String[args.size()];
    args.copyInto(argArray);
    final boolean rebuild = specificDef.getRebuild(baseDefs, 0);
    final File[] envIncludePath = getEnvironmentIncludePath();
    final String path = specificDef.getToolPath();

    CommandLineCompiler compiler = this;
    Environment environment = specificDef.getEnv();
    if (environment == null) {
        for (final ProcessorDef baseDef : baseDefs) {
            environment = baseDef.getEnv();
            if (environment != null) {
                compiler = (CommandLineCompiler) compiler.changeEnvironment(baseDef.isNewEnvironment(),
                        environment);
            }
        }
    } else {
        compiler = (CommandLineCompiler) compiler.changeEnvironment(specificDef.isNewEnvironment(),
                environment);
    }
    return new CommandLineCompilerConfiguration(compiler, configId, incPath, sysIncPath, envIncludePath,
            includePathIdentifier.toString(), argArray, paramArray, rebuild, endArgs, path,
            specificDef.getCcache());
}

From source file:org.accada.reader.rprm.core.Source.java

/**
 * Performs a single read cycle without using the corresponding Source
 * objects list of TagSelectors. The resulting ReadReport shall be formatted
 * according to the given DataSelector./*  ww w  . j a  va2  s  . co m*/
 * @param dataselector
 *           The data selector to use
 * @return The read report
 */
public ReadReport rawReadIDs(final DataSelector dataselector) {

    // if dataSelector is null, use the default dataSselector
    DataSelector dataSelector;
    if (dataselector == null) {
        dataSelector = readerDevice.getCurrentDataSelector();
    } else {
        dataSelector = dataselector;
    }

    SourceReport sourceReport = new SourceReport();

    // get all relevant readers with their readpoints
    Vector closure = getReaderAndReadPoints();

    // collection of all observations
    Observation[] tempObservations;
    Vector allObservations = new Vector();

    // closure
    Enumeration closureIterator = closure.elements();
    ReaderAndReadPoints curClosure;
    while (closureIterator.hasMoreElements()) {
        curClosure = (ReaderAndReadPoints) closureIterator.nextElement();

        try {
            tempObservations = curClosure.getReader().identify(curClosure.getAllReadPointsAsArray());
            for (int i = 0; i < tempObservations.length; i++) {
                Observation observation = tempObservations[i];
                if (observation.successful) {
                    allObservations.add(tempObservations[i]);
                } else {
                    ReadPoint readPoint = (ReadPoint) readPoints.get(observation.getReadPointName());
                    if (readPoint instanceof AntennaReadPoint) {
                        ((AntennaReadPoint) readPoint).increaseFailedIdentificationCount();
                    }
                }
            }
        } catch (HardwareException he) {
            log.error(he.getMessage());
        }

    }

    // add tags to read report
    Enumeration observationIterator = allObservations.elements();
    Observation curObservation;
    while (observationIterator.hasMoreElements()) {
        curObservation = (Observation) observationIterator.nextElement();

        for (int i = 0; i < curObservation.getIds().length; i++) {
            try {
                if (!sourceReport.containsTag(curObservation.getIds()[i])) {
                    addTagToReport(curObservation.getIds()[i], sourceReport, dataSelector, closure, null);
                }
            } catch (Exception e) {
                // TODO: catch the concrete exception and not Exception
                System.out.println(e.getMessage());
            }
        }

    }

    ReadReport readReport = new ReadReport();

    // Complete the report
    addReaderInfo(readReport, dataSelector);
    addSourceInfo(sourceReport, dataSelector);

    readReport.addSourceReport(sourceReport);

    // update read point counter
    updateAntennaReadPointIdentificationCount(allObservations);

    return readReport;

}

From source file:org.accada.reader.rprm.core.Source.java

/**
 * Add a list of tag selectors.//w w w  .  j av a 2 s  . c  o m
 * @param selectorList
 *           The list of tag selectors
 * @throws ReaderProtocolException
 *            "ERROR_TOO_MANY_TAGSELECTORS"
 */
public void addTagSelectors(final TagSelector[] selectorList) throws ReaderProtocolException {

    Vector selectors = readerDevice.getVector(selectorList);

    if (readerDevice.getMaxTagSelectorNumber() <= tagSelectors.size()) {
        throw new ReaderProtocolException("ERROR_TOO_MANY_TAGSELECTORS",
                MessagingConstants.ERROR_TOO_MANY_TAGSELECTORS);
    }

    Enumeration iterator = selectors.elements();
    TagSelector cur;

    while (iterator.hasMoreElements()) {
        cur = (TagSelector) iterator.nextElement();
        if (!this.tagSelectors.containsKey(cur.getName())) {
            this.tagSelectors.put(cur.getName(), cur);
        }
    }

}

From source file:org.accada.reader.rprm.core.Source.java

/**
 * Performs a single read cycle (with event generation).
 * @param dataSelector/*from  w ww . ja  v a 2  s. c  om*/
 *           The dataselector for report generation
 * @param trigger
 *           The trigger that caused the call of this method
 */
public void readWithEventGeneration(final DataSelector dataSelector, final Trigger trigger) {

    // get TagFields !

    Hashtable tagFieldNames = new Hashtable();

    // get all associated NotificationChannels
    Enumeration notificationChannelIterator = getAllNotificationChannels().elements();
    NotificationChannel curNotificationChannel;
    while (notificationChannelIterator.hasMoreElements()) {
        curNotificationChannel = (NotificationChannel) notificationChannelIterator.nextElement();

        Enumeration tagFieldNameIterator;
        try {
            tagFieldNameIterator = curNotificationChannel.getDataSelector().getTagFieldNames().elements();
        } catch (ReaderProtocolException e) {
            // no dataSelector associated to curNotificationChannel
            break;
        }
        String curTagFieldName;
        while (tagFieldNameIterator.hasMoreElements()) {
            curTagFieldName = (String) tagFieldNameIterator.nextElement();
            tagFieldNames.put(curTagFieldName, curTagFieldName);
        }

    }
    dataSelector.addTagFieldNames((String[]) readerDevice.stringsToArray(tagFieldNames));

    // actual time
    Date now = new Date();

    // read part !

    // get all relevant readers with their readpoints
    Vector closure = getReaderAndReadPoints();

    // collection of all observations
    Observation[] tempObservations;
    Vector allObservations = new Vector();

    // closure
    Enumeration closureIterator = closure.elements();
    ReaderAndReadPoints curClosure;
    // TODO: anders strukturieren: erst checken welcher service
    // vorhanden dann fuer alle HALs die Abfragen machen
    while (closureIterator.hasMoreElements()) {
        curClosure = (ReaderAndReadPoints) closureIterator.nextElement();

        try {
            String[] arpaa = curClosure.getAllReadPointsAsArray();
            HardwareAbstraction rd = curClosure.getReader();
            tempObservations = rd.identify(arpaa);
            for (int i = 0; i < tempObservations.length; i++) {
                Observation observation = tempObservations[i];
                if (observation.successful) {
                    allObservations.add(tempObservations[i]);
                } else {
                    ReadPoint readPoint = (ReadPoint) readPoints.get(observation.getReadPointName());
                    if (readPoint instanceof AntennaReadPoint) {
                        ((AntennaReadPoint) readPoint).increaseFailedIdentificationCount();
                    }
                }
            }
        } catch (HardwareException he) {
            log.error(he.getMessage());
        }

    }

    // event part !

    // observed tags
    Enumeration observationIterator = allObservations.elements();
    Observation curObservation;
    while (observationIterator.hasMoreElements()) {
        curObservation = (Observation) observationIterator.nextElement();

        // tags
        for (int i = 0; i < curObservation.getIds().length; i++) {
            // update last read timestamp
            tagsEverDetected.add(curObservation.getIds()[i]);
            updateLastReadTimestamp(curObservation.getIds()[i], (new Date()).getTime());

        }

    }
    log.info("[Source: " + this.getName() + "] Tags ever detected: " + tagsEverDetected);

    // generate new report (events)
    setSourceReport(updateCurrentState(now, dataSelector, closure, trigger));

    /*
    if (getSourceReport().getAllTags().size() > 0) {
       // Complete the report
       addSourceInfo(getSourceReport(), dataSelector);
            
    }
    */

    //    Complete the report
    addSourceInfo(getSourceReport(), dataSelector);

    log.debug("[Source: " + this.getName() + "] Tags reported: " + getSourceReport().getAllTags().keySet());

    /* commented out by CF on 20/9/2006
    if (log.isDebugEnabled()) {
    if (getSourceReport().getSourceInfo().getSourceName() == null) {
       log.debug("Source name is not set in source report");
    }
    else {
       log.debug("Source name is set to " + getSourceReport().getSourceInfo().getSourceName() + " in source report");
    }
       }
    */

    // send reports to notification channels
    Enumeration ncIterator = getAllNotificationChannels().elements();
    NotificationChannel curNc;
    log.debug("Distributing source report to appropriate notification channels...");
    log.debug("Registered notification channels " + getAllNotificationChannels().keySet().toString());
    while (ncIterator.hasMoreElements()) {
        curNc = (NotificationChannel) ncIterator.nextElement();
        curNc.addSourceReport(getSourceReport());
        log.debug("SourceReport featuring tags " + getSourceReport().getAllTags().keySet()
                + " detected at source " + getSourceReport().getSourceInfo().getSourceName()
                + " added to notification channel " + curNc.getName());
    }

    // update read point counter
    updateAntennaReadPointIdentificationCount(allObservations);

    if (log.isDebugEnabled()) {
        Collection tags = getSourceReport().getAllTags().values();
        Iterator it = tags.iterator();
        while (it.hasNext()) {
            TagType tag = (TagType) it.next();
            log.debug("Tag: " + tag.getId() + " Event contained: " + tag.containsEventInfo());
        }

        //log.debug("Tag events are at least partially included: " + (TagType)(.));
    }
}

From source file:org.accada.reader.rprm.core.Source.java

/**
 * Add a list of read triggers to this source.
 * @param triggerList/*from   w ww.j a va 2s .co  m*/
 *           The list of read triggers
 * @throws ReaderProtocolException
 *            "ERROR_TOO_MANY_TRIGGERS"
 */
public void addReadTriggers(final Trigger[] triggerList) throws ReaderProtocolException {

    Vector triggers = readerDevice.getVector(triggerList);

    if (readerDevice.getMaxTriggerNumber() <= triggers.size()) {
        throw new ReaderProtocolException("ERROR_TOO_MANY_TRIGGERS",
                MessagingConstants.ERROR_TOO_MANY_TRIGGERS);
    }

    Enumeration iterator = triggers.elements();
    Trigger cur;

    while (iterator.hasMoreElements()) {
        cur = (Trigger) iterator.nextElement();
        if (!this.readTriggers.containsKey(cur.getName())) {
            this.readTriggers.put(cur.getName(), cur);
            if (cur.getType().equals(TriggerType.CONTINUOUS)) {
                // conitnuous trigger
                if (continuousThread == null && timerThreads.size() == 0) {
                    continuousThread = new ContinuousReadThread(this, cur);
                    continuousThread.start();
                }
            } else if (cur.getType().equals(TriggerType.TIMER)) {
                // timer trigger
                if (continuousThread == null) {
                    Timer timerThread = new Timer();
                    timerThreads.put(cur.getName(), timerThread);
                    final int num = 3;
                    timerThread.schedule(new TimerReadThread(this, cur), 0,
                            Integer.parseInt(cur.getValue().substring(num)));
                }
            } else if (cur.getType().equals(TriggerType.IO_EDGE)) {
                // io edge trigger
                if (continuousThread == null) {
                    // get port
                    final int num = 6;
                    String port = cur.getValue().substring(cur.getValue().indexOf(';') + num,
                            cur.getValue().lastIndexOf(';'));
                    if (readerDevice.getEdgeTriggers().containsKey(port)) {
                        IOEdgeTriggerPortManager manager = (IOEdgeTriggerPortManager) readerDevice
                                .getEdgeTriggers().get(port);
                        manager.addListener(cur, this.getName());
                        if (manager.getNumberOfTriggers() == 1) {
                            manager.start();
                        }
                    } else {
                        throw new ReaderProtocolException("no trigger manager available",
                                MessagingConstants.ERROR_UNKNOWN);
                    }
                }
            } else if (cur.getType().equals(TriggerType.IO_VALUE)) {
                // io value trigger
                if (continuousThread == null) {
                    // get port
                    final int num = 5;
                    String port = cur.getValue().substring(num, cur.getValue().indexOf(';'));
                    if (readerDevice.getValueTriggers().containsKey(port)) {
                        IOValueTriggerPortManager manager = (IOValueTriggerPortManager) readerDevice
                                .getValueTriggers().get(port);
                        manager.addListener(cur, this.getName());
                        if (manager.getNumberOfTriggers() == 1) {
                            manager.start();
                        }
                    } else {
                        throw new ReaderProtocolException("no trigger manager available",
                                MessagingConstants.ERROR_UNKNOWN);
                    }
                }
            }

        }
    }

}

From source file:com.github.maven_nar.cpptasks.CCTask.java

private BuildException runTargetPool(final CCTaskProgressMonitor monitor, BuildException compileException,
        final ArrayList<Vector<TargetInfo>> targetVectors) {
    int index;// w w w .  j a va  2  s  .c om
    for (final Vector<TargetInfo> targetsForConfig : targetVectors) {
        //
        // get the configuration from the first entry
        //
        final CompilerConfiguration config = (CompilerConfiguration) targetsForConfig.elementAt(0)
                .getConfiguration();
        //
        // prepare the list of source files
        //

        // BEGINFREEHEP
        int noOfCores = Runtime.getRuntime().availableProcessors();
        log("Found " + noOfCores + " processors available");
        if (this.maxCores > 0) {
            noOfCores = Math.min(this.maxCores, noOfCores);
            log("Limited processors to " + noOfCores);
        }
        final int noOfFiles = targetsForConfig.size();
        if (noOfFiles < noOfCores) {
            noOfCores = noOfFiles;
            log("Limited used processors to " + noOfCores);
        }
        if (this.ordered) {
            noOfCores = 1;
            log("Limited processors to 1 due to ordering of source files");
        }

        final List<String>[] sourceFiles = new List[noOfCores];
        for (int j = 0; j < sourceFiles.length; j++) {
            sourceFiles[j] = new ArrayList<>(noOfFiles / sourceFiles.length);
        }
        final Enumeration<TargetInfo> targetsEnum = targetsForConfig.elements();
        index = 0;
        while (targetsEnum.hasMoreElements()) {
            final TargetInfo targetInfo = targetsEnum.nextElement();
            sourceFiles[index++].add(targetInfo.getSources()[0].toString());
            index %= sourceFiles.length;
        }

        // setup cores/cpus
        final Core[] cores = new Core[noOfCores];
        for (int j = 0; j < cores.length; j++) {
            cores[j] = new Core(this, j, config, this._objDir, sourceFiles[j], this.relentless, monitor);
            log("\nStarting Core " + j + " with " + sourceFiles[j].size() + " source files...");
        }

        // starting cores
        for (final Core core : cores) {
            core.start();
        }

        // checking cores
        boolean alive = false;
        try {
            do {
                alive = false;
                for (int j = 0; j < cores.length; j++) {
                    if (cores[j] != null) {
                        if (cores[j].isAlive()) {
                            alive = true;
                        } else {
                            final Exception exception = cores[j].getException();
                            if (exception != null) {
                                if (compileException == null && exception instanceof BuildException) {
                                    compileException = (BuildException) exception;
                                } else {
                                    log(cores[j].getName() + " " + exception
                                            + "                                  ", Project.MSG_ERR);
                                }
                                if (!this.relentless) {
                                    cores[j] = null;
                                    alive = false;
                                    break;
                                }
                            }
                            cores[j] = null;
                        }
                    }
                }
                if (alive) {
                    // wait for a maximum of 5 seconds or #files*2 seconds.
                    Thread.sleep(Math.min(5000, sourceFiles[0].size() * 2000));
                }
            } while (alive);
        } catch (final InterruptedException e) {
            break;
        }

        // killing leftovers
        for (final Core core : cores) {
            if (core != null) {
                core.interrupt();
                log(core.getName() + " interrupted                                          ");
            }
        }

        if (!this.relentless && compileException != null) {
            break;
        }
        // ENDFREEHEP

        /*
         * OLD CODE
         * String[] sourceFiles = new String[targetsForConfig.size()];
         * Enumeration targetsEnum = targetsForConfig.elements();
         * index = 0;
         * while (targetsEnum.hasMoreElements()) {
         * TargetInfo targetInfo = ((TargetInfo) targetsEnum
         * .nextElement());
         * sourceFiles[index++] = targetInfo.getSources()[0]
         * .toString();
         * }
         * try {
         * config.compile(this, _objDir, sourceFiles, relentless,
         * monitor);
         * } catch (BuildException ex) {
         * if (compileException == null) {
         * compileException = ex;
         * }
         * if (!relentless)
         * break;
         * }
         */
    }
    return compileException;
}

From source file:org.accada.reader.rprm.core.Source.java

/**
 * Computes the ReaderAndReadPoint elements of this source. A
 * ReaderAndReadPoints element contains one reader instance
 * (HardwareAbstraction) and all of ist read points associated with this
 * source./* ww  w .  j a  v  a  2  s  .  c om*/
 * @return Vector of ReaderAndReadPoints elements
 */
protected Vector getReaderAndReadPoints() {

    // contains elements of type ReaderAndReadPoints
    Vector closure = new Vector();

    // read points
    Enumeration readPointIterator = readPoints.elements();
    ReadPoint curReadPoint;
    while (readPointIterator.hasMoreElements()) {
        curReadPoint = (ReadPoint) readPointIterator.nextElement();

        // flag if curReadPoint.getReader() is in closure
        boolean exists = false;

        // closure
        Enumeration closureIterator = closure.elements();
        ReaderAndReadPoints curClosure;
        while (closureIterator.hasMoreElements()) {
            curClosure = (ReaderAndReadPoints) closureIterator.nextElement();

            if (curClosure.getReader().equals(curReadPoint.getReader())) {
                exists = true;
                curClosure.addReadPoint(curReadPoint.getName());
                break;
            }

        }

        // add new ReaderAndReadPoint
        if (!exists) {
            ReaderAndReadPoints rarp = new ReaderAndReadPoints();
            rarp.setReader(curReadPoint.getReader());
            rarp.addReadPoint(curReadPoint.getName());
            closure.add(rarp);
        }

    }

    return closure;

}

From source file:focusedCrawler.util.parser.PaginaURL.java

/**
 * Declara\uFFFD\uFFFDo do M\uFFFDtodo//from w  ww.  j av  a 2s. c om
 *
 *
 * @param palavra
 *
 * @return
 *
 * @see
 */
public Enumeration posicoes(String palavra) {
    Vector v = (Vector) palavra_posicoes.get(palavra);

    if (v != null) {
        return v.elements();
    } else {
        return null;
    }
}