List of usage examples for java.util Set toString
public String toString()
From source file:org.apache.camel.maven.DocumentGeneratorMojo.java
public static List<EndpointInfo> getEndpoints(Class<? extends ApiMethod> apiMethod, ApiMethodHelper<?> helper, Class<?> endpointConfig) { // get list of valid options final Set<String> validOptions = new HashSet<String>(); for (Field field : endpointConfig.getDeclaredFields()) { validOptions.add(field.getName()); }//w w w . ja va 2s . c om // create method name map final Map<String, List<ApiMethod>> methodMap = new TreeMap<String, List<ApiMethod>>(); for (ApiMethod method : apiMethod.getEnumConstants()) { String methodName = method.getName(); List<ApiMethod> apiMethods = methodMap.get(methodName); if (apiMethods == null) { apiMethods = new ArrayList<ApiMethod>(); methodMap.put(methodName, apiMethods); } apiMethods.add(method); } // create method name to alias name map final Map<String, Set<String>> aliasMap = new TreeMap<String, Set<String>>(); final Map<String, Set<String>> aliasToMethodMap = helper.getAliases(); for (Map.Entry<String, Set<String>> entry : aliasToMethodMap.entrySet()) { final String alias = entry.getKey(); for (String method : entry.getValue()) { Set<String> aliases = aliasMap.get(method); if (aliases == null) { aliases = new TreeSet<String>(); aliasMap.put(method, aliases); } aliases.add(alias); } } // create options map and return type map final Map<String, Set<String>> optionMap = new TreeMap<String, Set<String>>(); final Map<String, Set<String>> returnType = new TreeMap<String, Set<String>>(); for (Map.Entry<String, List<ApiMethod>> entry : methodMap.entrySet()) { final String name = entry.getKey(); final List<ApiMethod> apiMethods = entry.getValue(); // count the number of times, every valid option shows up across methods // and also collect return types final Map<String, Integer> optionCount = new TreeMap<String, Integer>(); final TreeSet<String> resultTypes = new TreeSet<String>(); returnType.put(name, resultTypes); for (ApiMethod method : apiMethods) { for (String arg : method.getArgNames()) { if (validOptions.contains(arg)) { Integer count = optionCount.get(arg); if (count == null) { count = 1; } else { count += 1; } optionCount.put(arg, count); } } // wrap primitive result types Class<?> resultType = method.getResultType(); if (resultType.isPrimitive()) { resultType = ClassUtils.primitiveToWrapper(resultType); } resultTypes.add(getCanonicalName(resultType)); } // collect method options final TreeSet<String> options = new TreeSet<String>(); optionMap.put(name, options); final Set<String> mandatory = new TreeSet<String>(); // generate optional and mandatory lists for overloaded methods int nMethods = apiMethods.size(); for (ApiMethod method : apiMethods) { final Set<String> optional = new TreeSet<String>(); for (String arg : method.getArgNames()) { if (validOptions.contains(arg)) { final Integer count = optionCount.get(arg); if (count == nMethods) { mandatory.add(arg); } else { optional.add(arg); } } } if (!optional.isEmpty()) { options.add(optional.toString()); } } if (!mandatory.isEmpty()) { // strip [] from mandatory options final String mandatoryOptions = mandatory.toString(); options.add(mandatoryOptions.substring(1, mandatoryOptions.length() - 1)); } } // create endpoint data final List<EndpointInfo> infos = new ArrayList<EndpointInfo>(); for (Map.Entry<String, List<ApiMethod>> methodEntry : methodMap.entrySet()) { final String endpoint = methodEntry.getKey(); // set endpoint name EndpointInfo info = new EndpointInfo(); info.endpoint = endpoint; info.aliases = convertSetToString(aliasMap.get(endpoint)); info.options = convertSetToString(optionMap.get(endpoint)); final Set<String> resultTypes = returnType.get(endpoint); // get rid of void results resultTypes.remove("void"); info.resultTypes = convertSetToString(resultTypes); infos.add(info); } return infos; }
From source file:org.openmrs.web.controller.report.ReportDataListController.java
/** * This is called prior to displaying a form for the first time. It tells Spring the * form/command object to load into the request * /*from w ww . j a va 2 s.c om*/ * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ protected Object formBackingObject(HttpServletRequest request) throws ServletException { String key = ServletRequestUtils.getStringParameter(request, "indicator", "empty"); // If there is no parameter named 'indicator' then return an empty Person stub. if (null == key || "empty".equals(key)) { Person p = new Person(); p.setPersonId(-1); return p; } // Get the ReportData that is in the current Session. ReportData report = (ReportData) request.getSession() .getAttribute(ReportingCompatibilityConstants.OPENMRS_REPORT_DATA); // Extract the Collection<DataSet> from the ReportData and put it into an ArrayList so it is usable. ArrayList<DataSet> cohortDataSets = new ArrayList<DataSet>(); Map<String, DataSet> dataSetMap = report.getDataSets(); cohortDataSets.addAll(dataSetMap.values()); // For each CohortDataSet.cohortData in the DataSet row... Iterator<Map<String, Cohort>> iterator = cohortDataSets.get(0).iterator(); Cohort cohort = null; while (iterator.hasNext()) { Map<String, Cohort> cohortData = iterator.next(); // ... if the cohortData contains the indicator key... if (cohortData.containsKey(key)) { // ... then use that Cohort. cohort = cohortData.get(key); } } // Set the 'patientIds' attribute of the request to the Cohort.personIds Set<Integer> ids = cohort.getMemberIds(); String personIds = ids.toString(); personIds = personIds.replaceAll("\\[", ""); personIds = personIds.replaceAll("\\]", ""); personIds = personIds.replaceAll(", ", ","); personIds = personIds.trim(); request.setAttribute("patientIds", personIds); // return the ReportData return report; }
From source file:org.jajuk.ui.views.TestParameterView.java
/** * Test method for.//from w w w . j av a 2 s. co m * * {@link org.jajuk.ui.views.ParameterView#getRegistrationKeys()}. */ public void testGetRegistrationKeys() { ParameterView view = new ParameterView(); Set<JajukEvents> set = view.getRegistrationKeys(); assertTrue(set.toString(), set.contains(JajukEvents.PARAMETERS_CHANGE)); }
From source file:com.ace.commons.mybatis.type.StringToSetTypeHander.java
@Override public void setNonNullParameter(PreparedStatement ps, int i, Set<Long> parameter, JdbcType jdbcType) throws SQLException { if (parameter != null) { String ids = parameter.toString(); ps.setString(i, ids.substring(1, ids.length() - 1)); } else {/*from w w w. j ava 2s . co m*/ ps.setString(i, null); } }
From source file:org.apache.oodt.cas.catalog.cli.action.LoadCatalogRepositoryCliAction.java
@Override public void execute(ActionMessagePrinter printer) throws CmdLineActionException { try {//from w w w. ja va 2s .com Validate.notNull(catalogRepositoryId, "Must specify catalogRepositoryId"); Validate.notNull(beanRepo, "Must specify beanRepo"); FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext( new String[] { this.beanRepo }, false); appContext.setClassLoader(new Serializer().getClassLoader()); appContext.refresh(); CatalogRepositoryFactory factory = (CatalogRepositoryFactory) appContext .getBean(this.catalogRepositoryId, CatalogRepositoryFactory.class); CatalogRepository catalogRepository = factory.createRepository(); Set<Catalog> catalogs = catalogRepository.deserializeAllCatalogs(); printer.println("Deserialized Catalogs: " + catalogs.toString()); for (Catalog catalog : catalogs) { printer.println("Adding Catalog: " + catalog); getClient().addCatalog(catalog); } } catch (Exception e) { throw new CmdLineActionException("Failed to load catalogs from bean repo : " + e.getMessage(), e); } }
From source file:com.frank.search.solr.repository.cdi.SolrRepositoryExtension.java
private <T> Bean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers, BeanManager beanManager) {//from www . j a v a 2 s . c o m Bean<SolrOperations> solrOperationBeans = this.solrOperationsMap.get(qualifiers.toString()); if (solrOperationBeans == null) { throw new UnsatisfiedResolutionException( String.format("Unable to resolve a bean for '%s' with qualifiers %s.", SolrOperations.class.getName(), qualifiers)); } return new SolrRepositoryBean<T>(solrOperationBeans, qualifiers, repositoryType, beanManager, getCustomImplementationDetector()); }
From source file:org.apache.sentry.policy.indexer.AbstractTestIndexerPolicyEngine.java
@Test public void testAdmin() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(ADMIN_INDEXER_ALL)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getPrivileges(set("admin"), ActiveRoleSet.ALL)).toString()); }
From source file:org.apache.sentry.policy.search.AbstractTestSearchPolicyEngine.java
@Test public void testAdmin() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(ADMIN_COLLECTION_ALL)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getPrivileges(set("admin"), ActiveRoleSet.ALL)).toString()); }
From source file:org.apache.sentry.policy.sqoop.AbstractTestSqoopPolicyEngine.java
@Test public void testAdmin() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(ADMIN)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getPrivileges(set("admin"), ActiveRoleSet.ALL)).toString()); }
From source file:org.apache.sentry.provider.file.AbstractTestSimplePolicyEngine.java
@Test public void testAdmin() throws Exception { Set<String> expected = Sets.newTreeSet(Sets.newHashSet(PERM_SERVER1_ADMIN)); Assert.assertEquals(expected.toString(), new TreeSet<String>(policy.getPermissions(authorizables, list("admin")).values()).toString()); }