List of usage examples for java.util Collection toArray
Object[] toArray();
From source file:org.seamless_ip.services.dao.test.EnumDaoTest.java
@SuppressWarnings("unchecked") @Test/*from w ww . java 2s.c om*/ public void domainEnumTest() { Collection<EnumTO> enums = enumerations.findAll(Domain.class.getName()); assertEquals(2, enums.size()); assertEquals("Effect of agriculture on itself", ((EnumTO) enums.toArray()[0]).getLabel()); assertEquals("Effect of agriculture on the rest of the world", ((EnumTO) enums.toArray()[1]).getLabel()); }
From source file:deployer.publishers.artifact.PythonAppsArtifactContentsPublisherTest.java
@Test public void testGenerateEntries() throws IOException, DeploymentException { PythonAppsArtifactContentsPublisher publisher = new PythonAppsArtifactContentsPublisher(); Collection<ArtifactDataEntry> entries = publisher .generateEntries(TestUtils.createSampleOpenShiftDeploymentArtifact()); Assert.assertEquals(entries.size(), 1); ArtifactDataEntry entry = (ArtifactDataEntry) entries.toArray()[0]; Assert.assertEquals("./wsgi.py", entry.getEntry().getName()); }
From source file:com.scooter1556.sms.server.io.StreamProcess.java
@Override public void start() throws IOException { // Set response headers response.reset();/*w w w . j a v a 2s . c o m*/ response.setContentType(contentType); response.setHeader("Accept-Ranges", "bytes"); response.setHeader("ETag", id.toString()); // Enable CORS response.setHeader(("Access-Control-Allow-Origin"), "*"); response.setHeader("Access-Control-Allow-Methods", "GET"); response.setIntHeader("Access-Control-Max-Age", 3600); // Set status code response.setStatus(SC_PARTIAL_CONTENT); /*********************** DEBUG: Response Headers *********************************/ String requestHeader = "\n***************\nResponse Header:\n***************\n"; Collection<String> responseHeaderNames = response.getHeaderNames(); for (int i = 0; i < responseHeaderNames.size(); i++) { String header = (String) responseHeaderNames.toArray()[i]; String value = response.getHeader(header); requestHeader += header + ": " + value + "\n"; } // Print Headers LogService.getInstance().addLogEntry(LogService.Level.INSANE, CLASS_NAME, requestHeader, null); /********************************************************************************/ // Try available commands for (String[] command : commands) { // Start transcode process run(command); // Check for error if (bytesTransferred == 0) { LogService.getInstance().addLogEntry(LogService.Level.WARN, CLASS_NAME, "Transcode command failed for job " + id + ". Attempting alternatives if available...", null); } else { break; } } }
From source file:com.doculibre.constellio.wicket.panels.results.PopupSearchResultPanel.java
/** * Will never return null/*from w ww . j a v a2s . c om*/ * * @param doc * @param fieldName * @return */ private String getFieldValue(SolrDocument doc, String fieldName) { Collection<Object> values = doc.getFieldValues(fieldName); if (values == null) { return ""; } return StringUtils.join(values.toArray(), ", "); }
From source file:com.github.haixing_hu.criteria.CollectionCriterion.java
/** * Constructs a {@link CollectionCriterion}. * * @param property/* ww w . j a va 2 s . c o m*/ * the name of a property. * @param operator * a collection operator. * @param values * a collection of values acts as the other operand of the operator. * @throws NullPointerException * if {@code property} or {@code operator} or {@code values} is * {@code null}. * @throws IllegalArgumentException * if {@code values} is empty. */ public CollectionCriterion(final String property, final CollectionOperator operator, final Collection<?> values) { super(CriterionType.COLLECTION); this.property = requireNonEmpty("property", property); this.operator = requireNonNull("operator", operator); this.values = values.toArray(); }
From source file:eu.learnpad.simulator.mon.rules.DroolsRulesManager.java
@Override public void deleteRule(final String ruleName) throws UnknownRuleException { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "Listing rules loaded into the knowledgeBases"); Collection<KnowledgePackage> ass = kbase.getKnowledgePackages(); Object esd[] = ass.toArray(); for (int i = 0; i < esd.length; i++) { KnowledgePackage kp = (KnowledgePackage) esd[i]; Collection<Rule> rls = kp.getRules(); Object r[] = rls.toArray(); DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getSimpleName(), "KnowledgeBase name: " + kp.getName()); if (r.length > 0) { for (int j = 0; j < r.length; j++) { Rule gg = (Rule) r[j];//w w w . ja v a 2 s .c om if (gg.getName().compareTo(ruleName) == 0) { kp.getRules().remove(gg); } } } } }
From source file:it.cnr.isti.labsedc.glimpse.rules.DroolsRulesManager.java
@Override public void deleteRule(final String ruleName) throws UnknownRuleException { DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getCanonicalName(), "Listing rules loaded into the knowledgeBases"); Collection<KnowledgePackage> ass = kbase.getKnowledgePackages(); Object esd[] = ass.toArray(); for (int i = 0; i < esd.length; i++) { KnowledgePackage kp = (KnowledgePackage) esd[i]; Collection<Rule> rls = kp.getRules(); Object r[] = rls.toArray(); DebugMessages.println(TimeStamp.getCurrentTime(), this.getClass().getCanonicalName(), "KnowledgeBase name: " + kp.getName()); if (r.length > 0) { for (int j = 0; j < r.length; j++) { Rule gg = (Rule) r[j];/*w ww.j a v a 2s . co m*/ if (gg.getName().compareTo(ruleName) == 0) { kp.getRules().remove(gg); } } } } /* * DebugMessages.println(TimeStamp.getCurrentTime(),this.getClass().getCanonicalName(), "Listing rules loaded into the knowledgeBases"); Collection<KnowledgePackage> ass = kbase.getKnowledgePackages(); Object esd[] = ass.toArray(); for (int i = 0; i<esd.length; i++) { KnowledgePackage kp = (KnowledgePackage)esd[i]; Collection<Rule> rls = kp.getRules(); Object r[] = rls.toArray(); DebugMessages.println(TimeStamp.getCurrentTime(),this.getClass().getCanonicalName(), "KnowledgeBase name: " + kp.getName()); if (r.length == 0) { DebugMessages.println(TimeStamp.getCurrentTime(),this.getClass().getCanonicalName(), "--! No rules loaded into: " + kp.getName() + " knowledgeBase"); } else { for (int j = 0; j<r.length;j++) { Rule gg = (Rule) r[j]; DebugMessages.println(TimeStamp.getCurrentTime(),this.getClass().getCanonicalName(), "RuleName: " + gg.getName()); } } DebugMessages.line(); */ }
From source file:de.document.controller.UmlsController.java
@RequestMapping(value = "/queryId", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Collection<Umls>> getDef() { Map<BigInteger, Umls> greetingMap = null; RetrieveCui RC = new RetrieveCui(Cui); Umls u = new Umls(); u = RC.RetCui(Cui);//from w w w .j a va2 s .c om if (greetingMap == null) { greetingMap = new HashMap<BigInteger, Umls>(); nextId = BigInteger.ONE; } nextId = nextId.add(BigInteger.ONE); greetingMap.put(nextId, u); Collection<Umls> greetings = null; greetings = greetingMap.values(); System.out.println("55555555555555555555555555555555"); System.out.println(Cui); System.out.println(greetings.toArray()[0]); System.out.println(u); return new ResponseEntity<Collection<Umls>>(greetings, HttpStatus.OK); }
From source file:com.expressui.core.view.tomanyrelationship.AggregationRelationship.java
/** * Invoked when user selects entities to be added to the relationship. */// ww w. j av a 2 s .c om public void itemsSelected() { getEntitySelect().close(); Collection<T> selectedValues = getEntitySelect().getResults().getSelectedValues(); setReferencesToParentAndPersist((T[]) selectedValues.toArray()); showAddSuccessful(); }
From source file:com.fiveamsolutions.nci.commons.web.struts2.validator.HibernateValidator.java
/** * {@inheritDoc}/*from www. java2 s .c o m*/ */ public void validate(Object object) throws ValidationException { ValueStack stack = ActionContext.getContext().getValueStack(); if (StringUtils.isNotBlank(getConditionalExpression()) && !(Boolean) stack.findValue(getConditionalExpression())) { return; } Object value = getFieldValue(getFieldName(), object); stack.push(object); if (value instanceof Collection<?>) { Collection<?> coll = (Collection<?>) value; Object[] array = coll.toArray(); validateArrayElements(array, getFieldName()); } else if (value instanceof Object[]) { Object[] array = (Object[]) value; validateArrayElements(array, getFieldName()); } else { validateObject(getFieldName(), value); } stack.pop(); }