List of usage examples for java.util Set toArray
Object[] toArray();
From source file:com.amalto.workbench.actions.XSDNewParticleFromParticleAction.java
public void addAnnotion(XSDAnnotationsStructure struc, XSDAnnotation xsdannotationparent) { Map<String, List<String>> infor = new HashMap<String, List<String>>(); infor = cloneXSDAnnotation(xsdannotationparent); Set<String> keys = infor.keySet(); for (int i = 0; i < infor.size(); i++) { List<String> lists = (List<String>) infor.get(keys.toArray()[i]); try {// ww w. j a v a 2 s . com struc.setAccessRole(lists, false, (IStructuredContentProvider) page.getTreeViewer().getContentProvider(), (String) keys.toArray()[i]); } catch (Exception e) { log.error(e.getMessage(), e); } } }
From source file:org.n2.chess.beans.BoardService.java
private void highlightLastMove(Game game, Board board, String colorPlayer) { Set<Move> moveSet = game.getMoveSet(); if (moveSet != null && !moveSet.isEmpty()) { Move lastMove = (Move) moveSet.toArray()[moveSet.size() - 1]; hightlightMove(board, colorPlayer, lastMove); }//from w w w . ja v a2 s . com }
From source file:com.amalto.workbench.actions.XSDNewParticleFromTypeAction.java
public void addAnnotion(XSDAnnotationsStructure struc, XSDAnnotation xsdannotationparent) { Map<String, List<String>> infor = new HashMap<String, List<String>>(); infor = cloneXSDAnnotation(xsdannotationparent); Set<String> keys = infor.keySet(); for (int i = 0; i < infor.size(); i++) { ArrayList<String> lists = (ArrayList<String>) infor.get(keys.toArray()[i]); try {// ww w . ja v a 2 s . com struc.setAccessRole(lists, false, (IStructuredContentProvider) page.getTreeViewer().getContentProvider(), (String) keys.toArray()[i]); } catch (Exception e) { log.error(e.getMessage(), e); } } }
From source file:com.ciphertool.genetics.algorithms.mutation.cipherkey.RandomValueMutationAlgorithm.java
/** * Performs a genetic mutation of a random Gene of the supplied Chromosome * // w ww .jav a 2 s . c om * @param chromosome * the Chromosome to mutate * @param availableIndices * the Set of available indices to mutate */ protected void mutateRandomGene(KeyedChromosome<Object> chromosome, Set<Object> availableIndices) { if (availableIndices == null || availableIndices.isEmpty()) { log.warn( "List of available indices is null or empty. Unable to find a Gene to mutate. Returning null."); return; } Random generator = new Random(); Object[] keys = availableIndices.toArray(); // Get a random map key Object randomKey = keys[generator.nextInt(keys.length)]; // Replace that map value with a randomly generated Gene chromosome.getGenes().put((Object) randomKey, geneDao.findRandomGene(chromosome)); // Remove the key so that it is not used for mutation again availableIndices.remove(randomKey); }
From source file:backtype.storm.security.auth.kerberos.KerberosSaslTransportPlugin.java
private String getPrincipal(Subject subject) { Set<Principal> principals = (Set<Principal>) subject.getPrincipals(); if (principals == null || principals.size() < 1) { LOG.info("No principal found in login subject"); return null; }//from w w w.j a va 2 s. c om return ((Principal) (principals.toArray()[0])).getName(); }
From source file:edu.cornell.mannlib.vitro.webapp.freemarker.config.FreemarkerConfigurationImpl.java
private String[] joinNames(Set<String> nameSet, String[] nameArray) { Set<String> allNames = new HashSet<>(nameSet); for (String n : nameArray) { allNames.add(n);/*ww w . j a v a2s . c o m*/ } return (String[]) allNames.toArray(); }
From source file:com.aurel.track.persist.TDashboardFieldPeer.java
/** * Loads TDashboardFields by IDs//from w w w .ja v a2 s .c o m * @return */ @Override public List<TDashboardFieldBean> loadByKeys(Set<Integer> objectIDs) { Connection con = null; List beanList = null; Criteria crit = new Criteria(); crit.addIn(OBJECTID, objectIDs.toArray()); try { con = Transaction.begin(DATABASE_NAME); beanList = convertTorqueListToBeanList(doSelect(crit, con)); for (int i = 0; i < beanList.size(); i++) { TDashboardFieldBean o = (TDashboardFieldBean) beanList.get(i); setParamaters(o, con); } Transaction.commit(con); } catch (TorqueException e) { Transaction.safeRollback(con); LOGGER.error("Loading all DashboardFields failed with " + e.getMessage()); } return beanList; }
From source file:at.ac.univie.isc.asio.Web.java
@Bean public ResourceConfig baseJerseyConfiguration(final ObjectMapper mapper, final Set<ContainerRequestFilter> filters) { final ResourceConfig config = new Application(); config.register(VndErrorMapper.class); config.register(JenaModelWriter.class); log.info(Scope.SYSTEM.marker(), "registering jersey filters {}", filters); config.registerInstances(filters.toArray()); log.info(Scope.SYSTEM.marker(), "registering jackson mapper {}", mapper); config.registerInstances(new ObjectMapperProvider(mapper)); if (debug) {//from ww w.j a va 2s . co m config.registerInstances(new LoggingFilter()); } return config; }
From source file:com.ny.apps.dao.BaseDaoImpl.java
public <T> void RemoveAll(Class<T> entityType, Set<Serializable> ids) { if (ids.isEmpty()) { return;/*from w w w. j a va2s . c o m*/ } String whereClause = buildOrIdWhereClause(ids.size(), "e.id"); update(concatenateString("delete from ", entityType.getSimpleName(), "e where ", whereClause), ids.toArray()); }
From source file:files.populate.java
private void populate_checkin(Connection connection, String string) { String fileName = "/Users/yash/Documents/workspace/HW 3/data/yelp_checkin.json"; Path path = Paths.get(fileName); Scanner scanner = null;// ww w . j av a2 s . c om try { scanner = new Scanner(path); } catch (IOException e) { e.printStackTrace(); } //read file line by line scanner.useDelimiter("\n"); int i = 0; while (scanner.hasNext()) { if (i < 20) { JSONParser parser = new JSONParser(); String s = (String) scanner.next(); s = s.replace("'", "''"); JSONObject obj; try { obj = (JSONObject) parser.parse(s); Map checkin_info = (Map) obj.get("checkin_info"); Set keys = checkin_info.keySet(); Object[] days = keys.toArray(); Statement statement = connection.createStatement(); for (int j = 0; j < days.length; ++j) { // String thiskey = days[j].toString(); String q3 = "insert into yelp_checkin values ('" + obj.get("business_id") + "','" + obj.get("type") + "','" + thiskey + "','" + checkin_info.get(thiskey) + "')"; // statement.executeUpdate(q3); } statement.close(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } ++i; } else { break; } } }