Java Code Examples for java.util.Set

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project activejdbc, under directory /javalite-common/src/main/java/org/javalite/http/.

Source file: Http.java

  18 
vote

/** 
 * Converts a map to URL- encoded content. This is a convenience method which can be used in combination with  {@link #post(String,byte[])},  {@link #put(String,String)} and others. It makes it easyto convert parameters to submit a string: <pre> key=value&key1=value1 </pre>
 * @param params map with keys and values to be posted. This map is used to buildcontent to be posted, such that keys are names of parameters, and values are values of those posted parameters. This method will also URL-encode keys and content using UTF-8 encoding. <p> String representations of both keys and values are used. </p>
 * @return {@link Post} object.
 */
public static String map2Content(Map params){
  StringBuilder stringBuilder=new StringBuilder();
  try {
    Set keySet=params.keySet();
    Object[] keys=keySet.toArray();
    for (int i=0; i < keys.length; i++) {
      stringBuilder.append(encode(keys[i].toString(),"UTF-8")).append("=").append(encode(params.get(keys[i]).toString(),"UTF-8"));
      if (i < (keys.length - 1)) {
        stringBuilder.append("&");
      }
    }
  }
 catch (  Exception e) {
    throw new HttpException("failed to generate content from map",e);
  }
  return stringBuilder.toString();
}
 

Example 2

From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/ui/custom/.

Source file: SelectUsersPopupWindow.java

  16 
vote

protected void initSelectUserButton(){
  selectUserButton=new Button(">");
  selectUserButton.addListener(new ClickListener(){
    public void buttonClick(    ClickEvent event){
      for (      String selectedItemId : (Set<String>)matchingUsersTable.getValue()) {
        Item originalItem=matchingUsersTable.getItem(selectedItemId);
        selectUser(selectedItemId,(String)originalItem.getItemProperty("userName").getValue());
        matchingUsersTable.removeItem(selectedItemId);
      }
    }
  }
);
  userSelectionLayout.addComponent(selectUserButton);
  userSelectionLayout.setComponentAlignment(selectUserButton,Alignment.MIDDLE_CENTER);
}
 

Example 3

From project 16Blocks, under directory /src/main/java/de/minestar/sixteenblocks/Core/.

Source file: Core.java

  15 
vote

private void saveUsers(Set<String> set,String fileName){
  File f=new File(getDataFolder(),fileName);
  if (f.exists()) {
    f.delete();
  }
  try {
    f.createNewFile();
    BufferedWriter bWriter=new BufferedWriter(new FileWriter(f));
    int count=0;
    for (    String name : set) {
      bWriter.write(name + System.getProperty("line.separator"));
      count++;
    }
    ConsoleUtils.printInfo(NAME,"Saved " + count + " users in '"+ fileName+ "'!");
    bWriter.flush();
    bWriter.close();
  }
 catch (  Exception e) {
    ConsoleUtils.printException(e,NAME,"Error while saving file '" + fileName + "'!");
  }
}
 

Example 4

From project accesointeligente, under directory /src/org/accesointeligente/client/views/.

Source file: RegisterView.java

  15 
vote

@Override public Set<Activity> getInstitutionActivities(){
  Set<Activity> activities=new HashSet<Activity>();
  for (int i=0; i < institutionActivities.getWidgetCount(); i++) {
    Widget widget=institutionActivities.getWidget(i);
    if (widget instanceof CheckBox) {
      CheckBox cb=(CheckBox)widget;
      if (cb.getValue()) {
        Activity activity=new Activity();
        activity.setId(Integer.parseInt(cb.getFormValue()));
        activity.setName(cb.getText());
        activities.add(activity);
      }
    }
  }
  return activities;
}
 

Example 5

From project AceWiki, under directory /src/ch/uzh/ifi/attempto/acewiki/aceowl/.

Source file: ACESentence.java

  15 
vote

public Set<OWLAxiom> getOWLAxioms(){
  if (parserResult == null) {
    update();
  }
  if (owlAxioms == null) {
    owlAxioms=new HashSet<OWLAxiom>();
  }
  return owlAxioms;
}
 

Example 6

From project ACLS-protocol-library, under directory /aclslib/src/main/java/au/edu/uq/cmm/aclslib/config/.

Source file: StaticConfiguration.java

  15 
vote

public void setTrustedAddresses(Set<String> trustedAddresses) throws UnknownHostException {
  this.trustedAddresses=trustedAddresses;
  this.trustedInetAddresses=new HashSet<InetAddress>(trustedAddresses.size());
  for (  String address : trustedAddresses) {
    trustedInetAddresses.add(InetAddress.getByName(address));
  }
}
 

Example 7

From project activemq-apollo, under directory /apollo-util/src/main/scala/org/apache/activemq/apollo/util/.

Source file: Combinator.java

  15 
vote

private Set<Map<String,Object>> _combinations(){
  LinkedHashSet<Map<String,Object>> rc=new LinkedHashSet<Map<String,Object>>();
  List<Map<String,Object>> expandedOptions=new ArrayList<Map<String,Object>>();
  expandCombinations(new ArrayList<ComboOption>(comboOptions.values()),expandedOptions);
  rc.addAll(expandedOptions);
  for (  Combinator c : children) {
    rc.addAll(c._combinations());
  }
  return rc;
}
 

Example 8

From project activiti, under directory /src/activiti-examples/org/activiti/examples/identity/.

Source file: IdentityTest.java

  15 
vote

private Object createStringSet(String... strings){
  Set<String> stringSet=new HashSet<String>();
  for (  String string : strings) {
    stringSet.add(string);
  }
  return stringSet;
}
 

Example 9

From project activiti-webapp-rest-generic, under directory /activiti-webapp-rest/src/main/java/org/activiti/rest/api/cycle/session/.

Source file: HttpSessionContext.java

  15 
vote

public Set<String> getKeySet(){
  HashSet<String> result=new HashSet<String>();
  for (@SuppressWarnings("unchecked") Enumeration<String> e=session.getAttributeNames(); e.hasMoreElements(); ) {
    result.add(e.nextElement());
  }
  return result;
}
 

Example 10

From project adbcj, under directory /api/src/main/java/org/adbcj/support/.

Source file: DefaultRow.java

  15 
vote

@Override public Set<java.util.Map.Entry<Object,Value>> entrySet(){
  if (entrySet == null) {
    Set<java.util.Map.Entry<Object,Value>> set=new HashSet<Entry<Object,Value>>();
    for (    Value value : values) {
      set.add(new AbstractMap.SimpleEntry<Object,Value>(value.getField(),value));
    }
    entrySet=Collections.unmodifiableSet(set);
  }
  return entrySet;
}
 

Example 11

From project addis, under directory /application/src/main/java/org/drugis/addis/entities/analysis/.

Source file: AbstractMetaAnalysis.java

  15 
vote

@Override public Set<Entity> getDependencies(){
  HashSet<Entity> deps=new HashSet<Entity>();
  Collection<Category> categories=EntityUtil.flatten(getAlternatives());
  for (  Category category : categories) {
    deps.addAll(category.getDependencies());
  }
  deps.add(getIndication());
  deps.add(getOutcomeMeasure());
  deps.addAll(getIncludedStudies());
  return deps;
}
 

Example 12

From project addressbook-sample-mongodb, under directory /web-ui/src/main/java/nl/enovation/addressbook/cqrs/webui/init/.

Source file: DBInit.java

  15 
vote

public String obtainInfo(){
  Set<String> collectionNames=systemAxonMongo.database().getCollectionNames();
  StringBuilder sb=new StringBuilder();
  for (  String name : collectionNames) {
    sb.append(name);
    sb.append("  ");
  }
  return sb.toString();
}
 

Example 13

From project ades, under directory /src/main/java/com/cloudera/science/pig/.

Source file: Combinatorial.java

  15 
vote

@Override public DataBag exec(Tuple input) throws IOException {
  try {
    DataBag output=bagFactory.newDefaultBag();
    Object o=input.get(0);
    if (!(o instanceof DataBag)) {
      throw new IOException("Expected input to be a bag, but got: " + o.getClass().getName());
    }
    DataBag inputBag=(DataBag)o;
    Set<Comparable> uniqs=Sets.newTreeSet();
    for (    Tuple t : inputBag) {
      if (t != null && t.get(0) != null) {
        uniqs.add((Comparable)t.get(0));
      }
    }
    if (uniqs.size() < arity) {
      return output;
    }
    List<Comparable> values=Lists.newArrayList(uniqs);
    Comparable[] subset=new Comparable[arity];
    process(values,subset,0,0,output);
    return output;
  }
 catch (  ExecException e) {
    throw new IOException(e);
  }
}
 

Example 14

From project AdminCmd, under directory /src/main/java/be/Balor/Importer/.

Source file: ImportTools.java

  15 
vote

public static boolean importESHomes(final ExtendedConfiguration userFile,final String playerName){
  Set<String> nodeList;
  ConfigurationSection home=null, homes=null;
  Location homeLoc=null;
  if (userFile == null) {
    ACLogger.info("[ERROR] Could not import data of user: " + playerName);
    return false;
  }
  homes=userFile.getConfigurationSection("homes");
  if (homes != null) {
    nodeList=homes.getKeys(false);
    for (    final String name : nodeList) {
      home=homes.getConfigurationSection(name);
      final ACWorld w=ACWorld.getWorld(home.getString("world"));
      try {
        homeLoc=buildLocation(home,w);
      }
 catch (      final Exception e) {
        ACLogger.info("[ERROR] Could not import homes of user: " + playerName);
        DebugLog.INSTANCE.log(Level.WARNING,"[ERROR] Could not import homes of user: " + playerName,e);
        return false;
      }
      ACPlayer.getPlayer(playerName).setHome(name,homeLoc);
    }
  }
 else {
    if (ConfigEnum.VERBOSE.getBoolean()) {
      ACLogger.info("User " + playerName + " did not have any homes.");
    }
    return false;
  }
  return false;
}
 

Example 15

From project AdminStuff, under directory /src/main/java/de/minestar/AdminStuff/commands/.

Source file: cmdChat.java

  15 
vote

private void createRecipientList(String[] args,Player player){
  StringBuilder output=new StringBuilder(256);
  Set<String> recipientSet=new HashSet<String>();
  Player temp=null;
  for (  String arg : args) {
    temp=PlayerUtils.getOnlinePlayer(arg);
    if (temp != null) {
      recipientSet.add(temp.getName().toLowerCase());
      output.append(temp.getName());
      output.append(", ");
    }
  }
  if (recipientSet.isEmpty()) {
    PlayerUtils.sendError(player,pluginName,"Kein Empfaenger gefunden!");
    return;
  }
  output.delete(output.length() - 2,output.length());
  pManager.setRecipients(player.getName().toLowerCase(),recipientSet);
  PlayerUtils.sendSuccess(player,pluginName,"Folgende Spieler erhalten jetzt deine Nachrichten:");
  PlayerUtils.sendInfo(player,output.toString());
}
 

Example 16

From project AdServing, under directory /modules/server/adserver/src/main/java/net/mad/ads/server/utils/http/.

Source file: KeywordUtils.java

  15 
vote

public static String getSearchEngineQueryString(HttpServletRequest request,String referrer){
  String queryString=null;
  String hostName=null;
  if (referrer != null) {
    URL refererURL;
    try {
      refererURL=new URL(referrer);
    }
 catch (    MalformedURLException e) {
      return null;
    }
    hostName=refererURL.getHost();
    queryString=refererURL.getQuery();
    if (Strings.isEmpty(queryString)) {
      return null;
    }
    Set<String> keys=seParams.keySet();
    for (    String se : keys) {
      if (hostName.toLowerCase().contains(se)) {
        queryString=getQueryStringParameter(queryString,seParams.get(se));
      }
    }
    return queryString;
  }
  return null;
}
 

Example 17

From project adt-maven-plugin, under directory /src/test/java/com/yelbota/plugins/adt/.

Source file: PackageAdtMojoTest.java

  15 
vote

@Test public void prepareAneDirTest() throws MojoFailureException {
  Set<Artifact> artifactList=new HashSet<Artifact>();
  ArtifactStub stub=new ArtifactStub();
  stub.setGroupId("com.example");
  stub.setArtifactId("myExt1");
  stub.setVersion("1.0");
  stub.setType("ane");
  stub.setFile(FileUtils.resolveFile(wd,"src/test/resources/unit/myExt1-1.0.ane"));
  artifactList.add(stub);
  stub=new ArtifactStub();
  stub.setGroupId("com.example");
  stub.setArtifactId("myLib");
  stub.setVersion("1.0");
  stub.setType("swc");
  artifactList.add(stub);
  stub=new ArtifactStub();
  stub.setGroupId("com.example");
  stub.setArtifactId("myExt2");
  stub.setVersion("1.1");
  stub.setType("ane");
  stub.setFile(FileUtils.resolveFile(wd,"src/test/resources/unit/myExt2-1.1.ane"));
  artifactList.add(stub);
  PackageAdtMojo mojo=new PackageAdtMojo();
  mojo.outputDirectory=FileUtils.resolveFile(wd,"target/unit/extDirTest");
  mojo.outputDirectory.mkdirs();
  mojo.project=new MavenProjectStub();
  mojo.project.setDependencyArtifacts(artifactList);
  File dir=mojo.prepareAneDir();
  String[] dirList=dir.list();
  String[] pattern=new String[]{"myExt1-1.0.ane","myExt2-1.1.ane"};
  Assert.assertTrue(dir.exists());
  Assert.assertEquals(dirList.length,pattern.length);
  for (int i=0; i < pattern.length; i++) {
    Assert.assertEquals(dirList[i],pattern[i]);
  }
}
 

Example 18

From project advanced, under directory /management/src/main/java/org/neo4j/management/impl/jconsole/.

Source file: ManagementAccess.java

  15 
vote

static ManagementAccess[] getAll(MBeanServerConnection server){
  final Set<ObjectName> names;
  try {
    names=server.queryNames(createObjectName("*",KERNEL_BEAN_NAME),null);
  }
 catch (  IOException e) {
    return new ManagementAccess[0];
  }
  ManagementAccess[] proxies=new ManagementAccess[names.size()];
  Iterator<ObjectName> iter=names.iterator();
  for (int i=0; i < proxies.length || iter.hasNext(); i++) {
    proxies[i]=new ManagementAccess(server,iter.next());
  }
  return proxies;
}
 

Example 19

From project AeminiumRuntime, under directory /src/aeminium/runtime/implementations/implicitworkstealing/task/.

Source file: ImplicitAtomicTask.java

  15 
vote

public Set<DataGroup> getDataGroupDependencies(){
  if (requiredGroups == null) {
    return Collections.emptySet();
  }
 else {
    return Collections.unmodifiableSet(requiredGroups);
  }
}
 

Example 20

From project aerogear-controller, under directory /src/main/java/org/jboss/aerogear/controller/router/.

Source file: DefaultRoute.java

  15 
vote

/** 
 * Constructs a Route with the specified roles and exceptions accociated with it.
 * @param path the path for this Route. Can be {@code null}.
 * @param methods the {@link RequestMethod}s that this Route should handle. Can be  {@code null}.
 * @param targetClass the target {@link Class} that is the target for this Route. Must not be {@code null}
 * @param targetMethod the target method in the {@link #targetClass}. Must not be  {@code null}
 * @param roles the roles to associate with this Route. Can be {@code null}.
 * @param throwables the exceptions that this Route can handle. Can be {@code null}.
 */
public DefaultRoute(String path,RequestMethod[] methods,Class<?> targetClass,Method targetMethod,String[] roles,Set<Class<? extends Throwable>> throwables){
  checkNotNull(targetClass,"'targetClass' must not be null");
  checkNotNull(targetMethod,"'targetMethod' must not be null");
  this.path=path;
  this.methods=asSet(methods);
  this.targetClass=targetClass;
  this.targetMethod=targetMethod;
  this.roles=asSet(roles);
  this.throwables=firstNonNull(throwables,emptyThrowableSet());
}
 

Example 21

From project aether-core, under directory /aether-api/src/main/java/org/eclipse/aether/graph/.

Source file: Dependency.java

  15 
vote

private Dependency(Artifact artifact,String scope,Set<Exclusion> exclusions,boolean optional){
  if (artifact == null) {
    throw new IllegalArgumentException("no artifact specified for dependency");
  }
  this.artifact=artifact;
  this.scope=(scope != null) ? scope : "";
  this.optional=optional;
  this.exclusions=exclusions;
}
 

Example 22

From project agile, under directory /agile-apps/agile-app-admin/src/main/java/org/headsupdev/agile/app/admin/.

Source file: AddAccount.java

  15 
vote

public void onSubmit(){
  User exists=getSecurityManager().getUserByUsername(username);
  if (exists != null) {
    info("An account with username " + username + " already exists");
    return;
  }
  StoredUser created=new StoredUser(username);
  created.setPassword(password);
  created.setEmail(email);
  created.setFirstname(firstname);
  created.setLastname(lastname);
  created.addRole(getSecurityManager().getRoleById((new MemberRole()).getId()));
  HashSet<Project> allProjects=new HashSet<Project>(getStorage().getProjects());
  allProjects.add(StoredProject.getDefault());
  created.setProjects(allProjects);
  for (  Project project : allProjects) {
    project.getUsers().add(created);
  }
  Set<User> defaultProjectMembers=StoredProject.getDefault().getUsers();
  defaultProjectMembers.add(created);
  StoredProject.setDefaultProjectMembers(defaultProjectMembers);
  ((AdminApplication)getHeadsUpApplication()).addUser(created);
  PageParameters params=new PageParameters();
  params.add("username",created.getUsername());
  setResponsePage(getPageClass("account"),params);
}
 

Example 23

From project agileBase, under directory /gtpb_server/src/com/gtwm/pb/auth/.

Source file: AppUser.java

  15 
vote

public void sendPasswordReset(String appUrl) throws CantDoThatException, CodingErrorException, MessagingException {
  if (this.getEmail() == null) {
    throw new CantDoThatException("The user has no email address");
  }
  if (!this.getEmail().contains("@")) {
    throw new CantDoThatException("The user's email isn't valid");
  }
  try {
    String password=RandomString.generate();
    this.hashAndSetPassword(password);
    String passwordResetLink=appUrl + "?return=gui/set_password/email_reset&u=" + this.getUserName()+ "&x="+ password;
    if (this.getAllowPasswordReset()) {
      throw new CantDoThatException("The previous password reset request hasn't timed out yet, please use that: " + passwordResetLink);
    }
    Set<String> recipients=new HashSet<String>();
    recipients.add(this.getEmail());
    String subject="Set your password";
    String body="Please choose a password for your account by following this link:\n\n";
    body+=passwordResetLink + "\n";
    Helpers.sendEmail(recipients,body,subject);
  }
 catch (  MissingParametersException mpex) {
    throw new CodingErrorException("Error generating a password: " + mpex);
  }
  this.passwordResetSent=System.currentTimeMillis();
}