List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java
/** * Transforms the Vector of the Repository parameters into a Repository Object.<br> * Structure of the parameters:<br> * Vector[name, Vector[project parameters], type, content type, uri] * </p>//w w w . j av a2 s . c om * * @param xmlRpcParameters Vector[name, Vector[project parameters], type, content type, uri] * @return the Repository. */ @SuppressWarnings("unchecked") public static Repository toRepository(Vector<Object> xmlRpcParameters) { Repository repository = null; if (!xmlRpcParameters.isEmpty()) { repository = Repository.newInstance((String) xmlRpcParameters.get(REPOSITORY_UID_IDX)); repository.setName((String) xmlRpcParameters.get(REPOSITORY_NAME_IDX)); repository.setProject(toProject((Vector) xmlRpcParameters.get(REPOSITORY_PROJECT_IDX))); repository.setType(toRepositoryType((Vector) xmlRpcParameters.get(REPOSITORY_TYPE_IDX))); repository.setContentType( ContentType.getInstance((String) xmlRpcParameters.get(REPOSITORY_CONTENTTYPE_IDX))); repository.setBaseUrl((String) xmlRpcParameters.get(REPOSITORY_BASE_URL_IDX)); repository.setBaseRepositoryUrl((String) xmlRpcParameters.get(REPOSITORY_BASEREPO_URL_IDX)); repository.setBaseTestUrl((String) xmlRpcParameters.get(REPOSITORY_BASETEST_URL_IDX)); repository.setUsername(toNullIfEmpty((String) xmlRpcParameters.get(REPOSITORY_USERNAME_IDX))); repository.setPassword(toNullIfEmpty((String) xmlRpcParameters.get(REPOSITORY_PASSWORD_IDX))); repository.setMaxUsers((Integer) xmlRpcParameters.get(REPOSITORY_MAX_USERS_IDX)); } return repository; }
From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java
/** * Transforms the Vector of the Specification parameters into a Specification Object.<br> * Structure of the parameters:<br> * Vector[name, Vector[repository parameters], Vector[SUT parameters]] * </p>/*w ww . jav a2 s . c o m*/ * * @param xmlRpcParameters a {@link java.util.Vector} object. * @return the Specification. */ @SuppressWarnings("unchecked") public static Specification toSpecification(Vector<Object> xmlRpcParameters) { Specification specification = null; if (!xmlRpcParameters.isEmpty()) { specification = Specification.newInstance((String) xmlRpcParameters.get(DOCUMENT_NAME_IDX)); specification .setRepository(toRepository((Vector<Object>) xmlRpcParameters.get(DOCUMENT_REPOSITORY_IDX))); specification.setTargetedSystemUnderTests( toSystemUnderTestList((Vector<Object>) xmlRpcParameters.get(SPECIFICATION_SUTS_IDX))); if (xmlRpcParameters.size() >= 4) { specification.setDialectClass((String) xmlRpcParameters.get(SPECIFICATION_DIALECT_IDX)); } } return specification; }
From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java
/** * Transforms the Vector of the SystemUnderTest parameters into a SystemUnderTest Object.<br> * Structure of the parameters:<br> * Vector[name, Vector[project parameters], Vector[seeds classPaths], Vector[fixture classPaths], fixturefactory, fixturefactoryargs, isdefault, Runner['name','cmd',['envtypename'],'servername','serverport','mainclass',['cp1','cp2'],'secured'], projectdependencydescriptor] * </p>/*from www .j a v a 2s . c o m*/ * * @param xmlRpcParameters a {@link java.util.Vector} object. * @return the SystemUnderTest. */ @SuppressWarnings("unchecked") public static SystemUnderTest toSystemUnderTest(Vector<Object> xmlRpcParameters) { SystemUnderTest sut = null; if (!xmlRpcParameters.isEmpty()) { ClasspathSet sutClasspaths = new ClasspathSet((Vector) xmlRpcParameters.get(SUT_CLASSPATH_IDX)); ClasspathSet fixtureClasspaths = new ClasspathSet( (Vector) xmlRpcParameters.get(SUT_FIXTURE_CLASSPATH_IDX)); sut = SystemUnderTest.newInstance((String) xmlRpcParameters.get(SUT_NAME_IDX)); sut.setProject(toProject((Vector<Object>) xmlRpcParameters.get(SUT_PROJECT_IDX))); sut.setSutClasspaths(sutClasspaths); sut.setFixtureClasspaths(fixtureClasspaths); sut.setFixtureFactory(toNullIfEmpty((String) xmlRpcParameters.get(SUT_FIXTURE_FACTORY_IDX))); sut.setFixtureFactoryArgs(toNullIfEmpty((String) xmlRpcParameters.get(SUT_FIXTURE_FACTORY_ARGS_IDX))); sut.setIsDefault((Boolean) xmlRpcParameters.get(SUT_IS_DEFAULT_IDX)); sut.setRunner(toRunner((Vector<Object>) xmlRpcParameters.get(SUT_RUNNER_IDX))); sut.setProjectDependencyDescriptor( toNullIfEmpty((String) xmlRpcParameters.get(SUT_PROJECT_DEPENDENCY_DESCRIPTOR_IDX))); } return sut; }
From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java
/** * Transforms the Vector of the RepositoryType parameters into a RepositoryType Object.<br> * Structure of the parameters:<br> * Vector[name, uriFormat]// w w w. ja va 2 s .c o m * </p> * * @param xmlRpcParameters a {@link java.util.Vector} object. * @return the RepositoryType. */ public static RepositoryType toRepositoryType(Vector<Object> xmlRpcParameters) { RepositoryType repositoryType = null; if (!xmlRpcParameters.isEmpty()) { repositoryType = RepositoryType.newInstance((String) xmlRpcParameters.get(REPOSITORY_TYPE_NAME_IDX)); @SuppressWarnings("unchecked") Hashtable<String, String> params = (Hashtable<String, String>) xmlRpcParameters .get(REPOSITORY_TYPE_REPOCLASSES_IDX); for (String env : params.keySet()) repositoryType.registerClassForEnvironment(params.get(env), EnvironmentType.newInstance(env)); repositoryType.setDocumentUrlFormat( toNullIfEmpty((String) xmlRpcParameters.get(REPOSITORY_TYPE_NAME_FORMAT_IDX))); repositoryType .setTestUrlFormat(toNullIfEmpty((String) xmlRpcParameters.get(REPOSITORY_TYPE_URI_FORMAT_IDX))); } return repositoryType; }
From source file:com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.java
/** * Transforms the Vector of the Reference parameters into a Reference Object.<br> * * @param xmlRpcParameters a {@link java.util.Vector} object. * @return the Reference.//from w w w. ja va 2 s . c o m */ @SuppressWarnings("unchecked") public static Reference toReference(Vector<Object> xmlRpcParameters) { Reference reference = null; if (!xmlRpcParameters.isEmpty()) { Requirement requirement = toRequirement( (Vector<Object>) xmlRpcParameters.get(REFERENCE_REQUIREMENT_IDX)); Specification specification = toSpecification( (Vector<Object>) xmlRpcParameters.get(REFERENCE_SPECIFICATION_IDX)); SystemUnderTest sut = toSystemUnderTest((Vector<Object>) xmlRpcParameters.get(REFERENCE_SUT_IDX)); String sections = toNullIfEmpty((String) xmlRpcParameters.get(REFERENCE_SECTIONS_IDX)); reference = Reference.newInstance(requirement, specification, sut, sections); Execution exe = toExecution((Vector<Object>) xmlRpcParameters.get(REFERENCE_LAST_EXECUTION_IDX)); reference.setLastExecution(exe); } return reference; }
From source file:de.mpg.escidoc.services.common.util.Util.java
/** * Converts a Format Vector into a Format Array. * @param formatsV as Vector//from w w w . j a va 2 s. c om * @return Format[] */ public static Format[] formatVectorToFormatArray(Vector<Format> formatsV) { Format[] formatsA = new Format[formatsV.size()]; for (int i = 0; i < formatsV.size(); i++) { formatsA[i] = (Format) formatsV.get(i); } return formatsA; }
From source file:Main.java
public static void vectorToXML222(String xmlFile, String xpath, String parentNodeName, Vector<HashMap> vector) { File file = new File(xmlFile); try {/*from ww w . j a v a2 s . co m*/ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document; Element rootNode; if (file.exists()) { document = documentBuilder.parse(new File(xmlFile)); rootNode = document.getDocumentElement(); } else { document = documentBuilder.newDocument(); rootNode = document.createElement(xpath); document.appendChild(rootNode); } for (int x = 0; x < vector.size(); x++) { Element parentNode = document.createElement(parentNodeName); rootNode.appendChild(parentNode); HashMap hashmap = vector.get(x); Set set = hashmap.entrySet(); Iterator i = set.iterator(); while (i.hasNext()) { Map.Entry me = (Map.Entry) i.next(); // System.out.println("key=" + // me.getKey().toString()); Element em = document.createElement(me.getKey().toString()); em.appendChild(document.createTextNode(me.getValue().toString())); parentNode.appendChild(em); // System.out.println("write " + // me.getKey().toString() + // "=" // + me.getValue().toString()); } } TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(document); FileOutputStream fo = new FileOutputStream(xmlFile); StreamResult result = new StreamResult(fo); transformer.transform(source, result); } catch (Exception ex) { file.delete(); ex.printStackTrace(); } }
From source file:de.mpg.escidoc.services.common.util.Util.java
/** * Merges a Vector of Format[] into Format[]. * @param allFormatsV as Format[] Vector * @return Format[]/*from w ww . j a v a 2 s . c om*/ */ public static Format[] mergeFormats(Vector<Format[]> allFormatsV) { Vector<Format> tmpV = new Vector<Format>(); Format[] tmpA; for (int i = 0; i < allFormatsV.size(); i++) { tmpA = allFormatsV.get(i); if (tmpA != null) { for (int x = 0; x < tmpA.length; x++) { tmpV.add(tmpA[x]); //System.out.println(tmpA[x].getName()); } } } tmpV = getRidOfDuplicatesInVector(tmpV); return formatVectorToFormatArray(tmpV); }
From source file:com.mmone.gpdati.allotment.reader.AvailCrud.java
private static int modifyAllotment(XmlRpcClient client, java.util.Date dateStart, java.util.Date dateEnd, String action, int availability, int reservation, Integer invCode, Integer hotelCode) { Vector parameters = new Vector(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); parameters.add(new Integer(hotelCode)); //1 parameters.add(new Integer(invCode)); //2 //todo gestire con inventario unico -1 int rate = 1; ///fisso nr da verificare per iu parameters.add(new Integer(rate)); //3 offerta parameters.add(new Integer(availability)); //4 disponibilit parameters.add(new Integer(reservation)); //5 prenotazione parameters.add(action); //6 Azione : set,increase,decrease parameters.add(df.format(dateStart).toString()); //7 parameters.add(df.format(dateEnd).toString()); //8 Vector result = new Vector(); int ret = XRPC_SET_ALLOTMENT_RESULT_ERROR; String logData = "hotelCode=" + hotelCode + " - invCode=" + invCode + " - offerta=" + rate + " - availability=" + availability + " - reservation=" + reservation + " - action=" + action + " - dateStart=" + df.format(dateStart).toString() + " - dateEnd=" + df.format(dateEnd).toString() ;// w ww . j av a 2 s . c o m Logger.getLogger("AvailCrud").log(Level.INFO, logData); try { result = (Vector) client.execute("backend.modifyAllotment", parameters); } catch (Exception e) { Logger.getLogger("AvailCrud").log(Level.SEVERE, "", e); // addError(ResponseBuilder.EWT_UNKNOWN, ResponseBuilder.ERR_SYSTEM_ERROR, "Error on updating allotment (modifyAllotment)"); return ret; } try { Map hret = (Map) result.get(0); ret = new Integer((String) hret.get("unique_allotment_service_response")); } catch (Exception e) { } Map hret = (Map) result.get(0); ret = new Integer((String) hret.get("unique_allotment_service_response")); Logger.getLogger("AvailCrud").log(Level.INFO, "Xrpc done "); return ret; }
From source file:edu.umn.cs.spatialHadoop.nasa.SpatioTemporalAggregateQuery.java
/** * Performs a spatio-temporal aggregate query on an indexed directory * @param inFile/*from w w w .j ava 2s . c o m*/ * @param params * @throws ParseException * @throws IOException */ public static AggregateQuadTree.Node aggregateQuery(Path inFile, OperationsParams params) throws ParseException, IOException { // 1- Run a temporal filter step to find all matching temporal partitions Vector<Path> matchingPartitions = new Vector<Path>(); // List of time ranges to check. Initially it contains one range as // specified by the user. Eventually, it can be split into at most two // partitions if partially matched by a partition. Vector<TimeRange> temporalRanges = new Vector<TimeRange>(); temporalRanges.add(new TimeRange(params.get("time"))); Path[] temporalIndexes = new Path[] { new Path(inFile, "yearly"), new Path(inFile, "monthly"), new Path(inFile, "daily") }; int index = 0; final FileSystem fs = inFile.getFileSystem(params); while (index < temporalIndexes.length && !temporalRanges.isEmpty()) { Path indexDir = temporalIndexes[index]; LOG.info("Checking index dir " + indexDir); TemporalIndex temporalIndex = new TemporalIndex(fs, indexDir); for (int iRange = 0; iRange < temporalRanges.size(); iRange++) { TimeRange range = temporalRanges.get(iRange); TemporalPartition[] matches = temporalIndex.selectContained(range.start, range.end); if (matches != null) { LOG.info("Matched " + matches.length + " partitions in " + indexDir); for (TemporalPartition match : matches) { LOG.info("Matched temporal partition: " + match.dirName); matchingPartitions.add(new Path(indexDir, match.dirName)); } // Update range to remove matching part TemporalPartition firstMatch = matches[0]; TemporalPartition lastMatch = matches[matches.length - 1]; if (range.start < firstMatch.start && range.end > lastMatch.end) { // Need to split the range into two temporalRanges.setElementAt(new TimeRange(range.start, firstMatch.start), iRange); temporalRanges.insertElementAt(new TimeRange(lastMatch.end, range.end), iRange); } else if (range.start < firstMatch.start) { // Update range in-place range.end = firstMatch.start; } else if (range.end > lastMatch.end) { // Update range in-place range.start = lastMatch.end; } else { // Current range was completely covered. Remove it temporalRanges.remove(iRange); } } } index++; } numOfTemporalPartitionsInLastQuery = matchingPartitions.size(); // 2- Find all matching files (AggregateQuadTrees) in matching partitions final Rectangle spatialRange = params.getShape("rect", new Rectangle()).getMBR(); // Convert spatialRange from lat/lng space to Sinusoidal space double cosPhiRad = Math.cos(spatialRange.y1 * Math.PI / 180); double southWest = spatialRange.x1 * cosPhiRad; double southEast = spatialRange.x2 * cosPhiRad; cosPhiRad = Math.cos(spatialRange.y2 * Math.PI / 180); double northWest = spatialRange.x1 * cosPhiRad; double northEast = spatialRange.x2 * cosPhiRad; spatialRange.x1 = Math.min(northWest, southWest); spatialRange.x2 = Math.max(northEast, southEast); // Convert to the h v space used by MODIS spatialRange.x1 = (spatialRange.x1 + 180.0) / 10.0; spatialRange.x2 = (spatialRange.x2 + 180.0) / 10.0; spatialRange.y2 = (90.0 - spatialRange.y2) / 10.0; spatialRange.y1 = (90.0 - spatialRange.y1) / 10.0; // Vertically flip because the Sinusoidal space increases to the south double tmp = spatialRange.y2; spatialRange.y2 = spatialRange.y1; spatialRange.y1 = tmp; // Find the range of cells in MODIS Sinusoidal grid overlapping the range final int h1 = (int) Math.floor(spatialRange.x1); final int h2 = (int) Math.ceil(spatialRange.x2); final int v1 = (int) Math.floor(spatialRange.y1); final int v2 = (int) Math.ceil(spatialRange.y2); PathFilter rangeFilter = new PathFilter() { @Override public boolean accept(Path p) { Matcher matcher = MODISTileID.matcher(p.getName()); if (!matcher.matches()) return false; int h = Integer.parseInt(matcher.group(1)); int v = Integer.parseInt(matcher.group(2)); return h >= h1 && h < h2 && v >= v1 && v < v2; } }; final Vector<Path> allMatchingFiles = new Vector<Path>(); for (Path matchingPartition : matchingPartitions) { // Select all matching files FileStatus[] matchingFiles = fs.listStatus(matchingPartition, rangeFilter); for (FileStatus matchingFile : matchingFiles) { allMatchingFiles.add(matchingFile.getPath()); } } // 3- Query all matching files in parallel Vector<Node> threadsResults = Parallel.forEach(allMatchingFiles.size(), new RunnableRange<AggregateQuadTree.Node>() { @Override public Node run(int i1, int i2) { Node threadResult = new AggregateQuadTree.Node(); for (int i_file = i1; i_file < i2; i_file++) { try { Path matchingFile = allMatchingFiles.get(i_file); Matcher matcher = MODISTileID.matcher(matchingFile.getName()); matcher.matches(); // It has to match int h = Integer.parseInt(matcher.group(1)); int v = Integer.parseInt(matcher.group(2)); // Clip the query region and normalize in this tile Rectangle translated = spatialRange.translate(-h, -v); int x1 = (int) (Math.max(translated.x1, 0) * 1200); int y1 = (int) (Math.max(translated.y1, 0) * 1200); int x2 = (int) (Math.min(translated.x2, 1.0) * 1200); int y2 = (int) (Math.min(translated.y2, 1.0) * 1200); AggregateQuadTree.Node fileResult = AggregateQuadTree.aggregateQuery(fs, matchingFile, new java.awt.Rectangle(x1, y1, (x2 - x1), (y2 - y1))); threadResult.accumulate(fileResult); } catch (IOException e) { e.printStackTrace(); } } return threadResult; } }); AggregateQuadTree.Node finalResult = new AggregateQuadTree.Node(); for (Node threadResult : threadsResults) finalResult.accumulate(threadResult); numOfTreesTouchesInLastRequest = allMatchingFiles.size(); return finalResult; }