Example usage for java.util Set toArray

List of usage examples for java.util Set toArray

Introduction

In this page you can find the example usage for java.util Set toArray.

Prototype

<T> T[] toArray(T[] a);

Source Link

Document

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.

Usage

From source file:ch.entwine.weblounge.contentrepository.index.SearchIndexTest.java

/**
 * Sets up the solr search index. Since solr sometimes has a hard time
 * shutting down cleanly, it's done only once for all the tests.
 * //from   w ww  . jav  a2 s .c  o m
 * @throws Exception
 */
@BeforeClass
public static void setupClass() throws Exception {
    // Template
    template = EasyMock.createNiceMock(PageTemplate.class);
    EasyMock.expect(template.getIdentifier()).andReturn("templateid").anyTimes();
    EasyMock.expect(template.getStage()).andReturn("non-existing").anyTimes();
    EasyMock.replay(template);

    Set<Language> languages = new HashSet<Language>();
    languages.add(LanguageUtils.getLanguage("en"));
    languages.add(LanguageUtils.getLanguage("de"));

    // Site
    site = EasyMock.createNiceMock(Site.class);
    EasyMock.expect(site.getIdentifier()).andReturn("test").anyTimes();
    EasyMock.expect(site.getTemplate((String) EasyMock.anyObject())).andReturn(template).anyTimes();
    EasyMock.expect(site.getDefaultTemplate()).andReturn(template).anyTimes();
    EasyMock.expect(site.getLanguages()).andReturn(languages.toArray(new Language[languages.size()]))
            .anyTimes();
    EasyMock.expect(site.getAdministrator()).andReturn(new SiteAdminImpl("testsite")).anyTimes();
    EasyMock.replay(site);

    // Resource serializer
    serializer = new ResourceSerializerServiceImpl();
    serializer.addSerializer(new PageSerializer());
    serializer.addSerializer(new FileResourceSerializer());
    serializer.addSerializer(new ImageResourceSerializer());
    serializer.addSerializer(new MovieResourceSerializer());

    // Index
    String rootPath = PathUtils.concat(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    System.setProperty("weblounge.home", rootPath);
    idxRoot = new File(rootPath);
    ElasticSearchUtils.createIndexConfigurationAt(idxRoot);
    idx = new SearchIndex(site, serializer, isReadOnly);
}

From source file:com.blocks.framework.utils.date.StringUtil.java

/**
  * ???Integer[]//from www. j a  v a  2  s .  c  o  m
  * 
  * @param Integer[]
  * 
  * @return String ??
  */

 public static Integer[] delRepeatData(Integer[] intArr) {
     ArrayList<Integer> al = new ArrayList<Integer>();

     if (intArr != null) {
         for (int i = 0; i < intArr.length; i++) {
             al.add(intArr[i]);
         }
     }
     Set<Integer> set = new HashSet<Integer>(al);
     Object objs[] = set.toArray(new Integer[0]);
     return (Integer[]) objs;
 }

From source file:fi.smaa.libror.PerformanceMatrix.java

private void initializeLevels(RealMatrix perfMatrix) {
    levels = new RealVector[perfMatrix.getColumnDimension()];
    for (int i = 0; i < levels.length; i++) {
        Set<Double> levelsSet = new TreeSet<Double>();
        for (double d : perfMatrix.getColumn(i)) {
            levelsSet.add(d);/*  ww  w .  j a  v  a2s. c om*/
        }
        RealVector lvl = new ArrayRealVector(levelsSet.toArray(new Double[0]));
        levels[i] = lvl;
    }
}

From source file:com.impetus.kundera.persistence.AbstractEntityReader.java

/**
 * On association using lucene.//from   w  w w  . j  a v  a2  s  . co  m
 * 
 * @param m
 *            the m
 * @param client
 *            the client
 * @param ls
 *            the ls
 * @return the list
 */
protected List<EnhanceEntity> onAssociationUsingLucene(EntityMetadata m, Client client,
        List<EnhanceEntity> ls) {
    Set<String> rSet = fetchDataFromLucene(client);
    List resultList = client.findAll(m.getEntityClazz(), rSet.toArray(new String[] {}));
    return m.getRelationNames() != null && !m.getRelationNames().isEmpty() ? resultList
            : transform(m, ls, resultList);
}

From source file:net.geoprism.ontology.Classifier.java

public static String getClassifierTree(String classifierId) {
    Classifier root = Classifier.getRoot();

    Classifier classifier = Classifier.get(classifierId);

    OIterator<Term> anscestorIt = classifier.getAllAncestors(ClassifierIsARelationship.CLASS);
    Set<String> ids = new HashSet<String>();

    try {/* ww  w . java2 s.c om*/
        while (anscestorIt.hasNext()) {
            Classifier ancestor = (Classifier) anscestorIt.next();

            if (!ancestor.getId().equals(root.getId())) {
                ids.add(ancestor.getId());
            }
        }
    } finally {
        anscestorIt.close();
    }

    JSONArray array = new JSONArray();

    QueryFactory factory = new QueryFactory();

    ClassifierIsARelationshipQuery isAQuery = new ClassifierIsARelationshipQuery(factory);
    isAQuery.WHERE(isAQuery.getParent().EQ(root));
    isAQuery.AND(isAQuery.childId().IN(ids.toArray(new String[ids.size()])));

    ClassifierQuery query = new ClassifierQuery(factory);
    query.WHERE(query.isAParent(isAQuery));
    query.ORDER_BY_ASC(query.getDisplayLabel().localize());

    OIterator<? extends Classifier> classifierIt = query.getIterator();

    try {
        while (classifierIt.hasNext()) {
            Classifier parent = classifierIt.next();

            array.put(Classifier.getJSONObject(parent, ids, true));
        }
    } finally {
        classifierIt.close();
    }

    return array.toString();
}

From source file:com.intuit.wasabi.email.impl.EmailServiceImpl.java

/**
 * {@inheritDoc}//from   w w  w. j a v a2s .c  o m
 */
@Override
public void sendEmailForUserPermission(Application.Name appName, UserInfo.Username user, EmailLinksList links) {
    LOGGER.debug("Sending an email to the administrators of " + appName + " for user " + user + "with links"
            + links.toString());
    String subject = emailTextProcessor.getSubject(appName);
    String msg = emailTextProcessor.getMessage(appName, user, links);
    Set<String> addressees = emailTextProcessor.getAddressees(appName);

    doSend(subject, msg, addressees.toArray(new String[addressees.size()]));
}

From source file:org.tsm.concharto.web.changehistory.ChangeHistoryControllerHelper.java

/**
 * Update the model with a set of user page titles.  This allows the view to give hints to 
 * the user about which user pages have been created and which haven't (e.g. red links indicate
 * the page hasn't been created yet)/*w ww .ja va2s  . c o  m*/
 * @param model
 * @param titles
 */
@SuppressWarnings("unchecked")
private void updateModelUserPages(Map model, Set<String> titles) {
    Map<String, Long> pages;
    if (titles.size() != 0) {
        pages = wikiTextDao.exists((String[]) (titles.toArray(new String[titles.size()])));
    } else {
        pages = new HashMap<String, Long>();
    }
    model.put(MODEL_USER_PAGES, pages);
}

From source file:org.elasticsoftware.elasticactors.base.serialization.ObjectMapperBuilder.java

private void registerSubtypes(Reflections reflections, ObjectMapper objectMapper) {
    Set<Class<?>> subTypes = reflections.getTypesAnnotatedWith(JsonTypeName.class);
    objectMapper.registerSubtypes(subTypes.toArray(new Class<?>[subTypes.size()]));
}

From source file:at.gv.egiz.bku.spring.PKITrustManager.java

@Override
public X509Certificate[] getAcceptedIssuers() {

    if (pkiProfile == null) {
        log.warn("No PKI profile set. Configuration error.");
        return new X509Certificate[] {};
    }/*from w  w w . ja  v a  2 s . c  o  m*/

    TransactionId tid = new MDCTransactionId();

    try {

        TrustStore trustStore = TrustStoreFactory.getInstance(pkiProfile.getTrustStoreProfile(), tid);
        @SuppressWarnings("unchecked")
        Set<X509Certificate> certs = trustStore.getTrustedCertificates(tid);
        return certs.toArray(new X509Certificate[certs.size()]);
    } catch (TrustStoreException e) {
        log.warn("Failed to get list of accepted issuers.", e);
        return new X509Certificate[] {};
    } catch (ClassCastException e) {
        log.error("Failed to cast list of accepted issuers.", e);
        return new X509Certificate[] {};
    }
}

From source file:hr.fer.zemris.vhdllab.platform.preference.DatabasePreferences.java

@Override
protected String[] keysSpi() throws BackingStoreException {
    Set<Object> keySet = getProperties().keySet();
    String[] keys = new String[keySet.size()];
    return keySet.toArray(keys);
}