List of usage examples for java.util Vector setElementAt
public synchronized void setElementAt(E obj, int index)
From source file:vitro.vspEngine.service.persistence.DBCommons.java
/** * * @param ssUNinfoGWHM//from w w w . j a va2 s .co m * @param ssUNCapHM * @param in_advCapsToSensModelsToMerge * @param in_advSmDevs * @param in_advGatewayIDStr * @param in_regGatewayDescStr * @param in_advGatewayIPv4 * @param in_advGatewayLocStr */ synchronized public void mergeAdvDataToGateway(HashMap<String, GatewayWithSmartNodes> ssUNinfoGWHM, HashMap<String, Vector<SensorModel>> ssUNCapHM, HashMap<String, Vector<SensorModel>> in_advCapsToSensModelsToMerge, Vector<SmartNode> in_advSmDevs, String in_advGatewayIDStr, String in_regGatewayDescStr, String in_advGatewayIPv4, String in_advGatewayLocStr) { // // For each generic capability found in the GatewayDescriptionAdvertisement (even when went per smart device separately) // Check if the UserPeer's capHMap contains it // (if not add it, with its full vector of sensormodels). // (if it does, then add only those sensormodels that don't exist in the existing vector of sensormodels (of the UserPeer's capHMap) // TODO: support String for id for sensorModels ...(?) Set<String> advCapsSet = in_advCapsToSensModelsToMerge.keySet(); Iterator<String> advCapsIt = advCapsSet.iterator(); // from the received GW ADV String currentAdvCap; // place one check-box for each Generic Capability Description while (advCapsIt.hasNext()) { currentAdvCap = advCapsIt.next(); Vector<SensorModel> listOfSensToAdd = in_advCapsToSensModelsToMerge.get(currentAdvCap); if (ssUNCapHM.containsKey(currentAdvCap)) { Vector<SensorModel> previousListOfSensModel = ssUNCapHM.get(currentAdvCap); // concatenate with previous List (skip if the results are from an existing gateway) // so this does not PRECLUDE the same sensor model being added for the generic capability. (TODO: this can only be fixed in the gateways retroactively make a shared hastable for unique ids for specifi sensormodels) // but each model is uniquely indexed within its gateway (and maintains the gateway id info in its class type). This is good and similar to the SensorML specs // SensorML additionally allows for multiple output formats for a "sensor model" (component) and unlimited nesting in components though.... for (int k1 = 0; k1 < previousListOfSensModel.size(); k1++) { for (int m1 = 0; m1 < listOfSensToAdd.size(); m1++) { if ((previousListOfSensModel.get(k1).getGatewayId() .equals(listOfSensToAdd.get(m1).getGatewayId())) && (previousListOfSensModel.get(k1).getSmID() .equals(listOfSensToAdd.get(m1).getSmID()))) { // we should add only the newly added models...if any listOfSensToAdd.removeElementAt(m1); m1 -= 1; } } } previousListOfSensModel.addAll(listOfSensToAdd); } else if (listOfSensToAdd.size() > 0) { ssUNCapHM.put(currentAdvCap, listOfSensToAdd); } } // Find an existing entry for the gateway if (ssUNinfoGWHM.containsKey(in_advGatewayIDStr)) { // update existing mapped gateway with new possible values for each field GatewayWithSmartNodes tmpToUpd = ssUNinfoGWHM.get(in_advGatewayIDStr); Vector<SmartNode> existingSmDevs = tmpToUpd.getSmartNodesVec(); tmpToUpd.setName(in_regGatewayDescStr); //renew description tmpToUpd.setDescription("GwDesc"); //???? boolean foundDev = false; for (int j = 0; j < in_advSmDevs.size(); j++) { foundDev = false; for (int o = 0; o < existingSmDevs.size(); o++) { if (in_advSmDevs.elementAt(j).getId().equalsIgnoreCase(existingSmDevs.elementAt(o).getId())) { foundDev = true; existingSmDevs.setElementAt(in_advSmDevs.elementAt(j), o); //replace (update) } } if (foundDev == false) { existingSmDevs.add(in_advSmDevs.elementAt(j)); } } } else { GatewayWithSmartNodes tmpToInsert = null; if (in_regGatewayDescStr != null && !(in_regGatewayDescStr.trim().isEmpty())) { tmpToInsert = new GatewayWithSmartNodes(new Gateway(in_advGatewayIDStr, in_regGatewayDescStr, "GwDesc", null, null, in_advGatewayIPv4, in_advGatewayLocStr)); tmpToInsert.setSmartNodesVec(in_advSmDevs); } else { GeoPoint gwGP = null; if (in_advGatewayLocStr != null) { String[] locTokensLatLong = in_advGatewayLocStr.split(","); if (locTokensLatLong != null && locTokensLatLong.length == 2) { gwGP = new GeoPoint(locTokensLatLong[0].trim(), locTokensLatLong[1].trim(), "0"); } } tmpToInsert = new GatewayWithSmartNodes( new Gateway(in_advGatewayIDStr, "GwName", "GwDesc", null, gwGP, in_advGatewayIPv4, null)); tmpToInsert.setSmartNodesVec(in_advSmDevs); } ssUNinfoGWHM.put(in_advGatewayIDStr, tmpToInsert); } }
From source file:com.github.maven_nar.cpptasks.compiler.AbstractCompiler.java
/** * Returns dependency info for the specified source file * * @param task//from w ww. j ava2 s . co m * task for any diagnostic output * @param source * file to be parsed * @param includePath * include path to be used to resolve included files * * @param sysIncludePath * sysinclude path from build file, files resolved using * sysInclude path will not participate in dependency analysis * * @param envIncludePath * include path from environment variable, files resolved with * envIncludePath will not participate in dependency analysis * * @param baseDir * used to produce relative paths in DependencyInfo * @param includePathIdentifier * used to distinguish DependencyInfo's from different include * path settings * */ public final DependencyInfo parseIncludes(final CCTask task, final File source, final File[] includePath, final File[] sysIncludePath, final File[] envIncludePath, final File baseDir, final String includePathIdentifier) { // // if any of the include files can not be identified // change the sourceLastModified to Long.MAX_VALUE to // force recompilation of anything that depends on it long sourceLastModified = source.lastModified(); final File[] sourcePath = new File[1]; sourcePath[0] = new File(source.getParent()); final Vector onIncludePath = new Vector(); final Vector onSysIncludePath = new Vector(); String baseDirPath; try { baseDirPath = baseDir.getCanonicalPath(); } catch (final IOException ex) { baseDirPath = baseDir.toString(); } final String relativeSource = CUtil.getRelativePath(baseDirPath, source); String[] includes = emptyIncludeArray; if (canParse(source)) { final Parser parser = createParser(source); try { final Reader reader = new BufferedReader(new FileReader(source)); parser.parse(reader); includes = parser.getIncludes(); } catch (final IOException ex) { task.log("Error parsing " + source.toString() + ":" + ex.toString()); includes = new String[0]; } } for (final String include : includes) { if (!resolveInclude(include, sourcePath, onIncludePath)) { if (!resolveInclude(include, includePath, onIncludePath)) { if (!resolveInclude(include, sysIncludePath, onSysIncludePath)) { if (!resolveInclude(include, envIncludePath, onSysIncludePath)) { // // this should be enough to require us to reparse // the file with the missing include for dependency // information without forcing a rebuild sourceLastModified += 2 * CUtil.FILETIME_EPSILON; } } } } } for (int i = 0; i < onIncludePath.size(); i++) { final String relativeInclude = CUtil.getRelativePath(baseDirPath, (File) onIncludePath.elementAt(i)); onIncludePath.setElementAt(relativeInclude, i); } for (int i = 0; i < onSysIncludePath.size(); i++) { final String relativeInclude = CUtil.getRelativePath(baseDirPath, (File) onSysIncludePath.elementAt(i)); onSysIncludePath.setElementAt(relativeInclude, i); } return new DependencyInfo(includePathIdentifier, relativeSource, sourceLastModified, onIncludePath, onSysIncludePath); }