Exemplo n.º 1
0
 @Override
 public Value value(final QueryContext qc) throws QueryException {
   final ArrayList<User> users = qc.context.users.users(null, qc.context);
   final TokenList tl = new TokenList(users.size());
   for (final User user : users) tl.add(user.name());
   return StrSeq.get(tl);
 }
Exemplo n.º 2
0
  private User refUser(String name) {

    for (User user : users) {
      if (name.equals(user.name())) return user;
    }

    return null;
  }
Exemplo n.º 3
0
 public static User convert(ChatUser cu) {
   if (cu == null) {
     return null;
   }
   User u = new User();
   u.id = cu.getId();
   u.name = cu.getName();
   u.style = cu.getStyle();
   return u;
 }
Exemplo n.º 4
0
 @Override
 public User build() {
   try {
     User record = new User();
     record.name =
         fieldSetFlags()[0] ? this.name : (java.lang.CharSequence) defaultValue(fields()[0]);
     record.favorite_number =
         fieldSetFlags()[1]
             ? this.favorite_number
             : (java.lang.Integer) defaultValue(fields()[1]);
     record.favorite_color =
         fieldSetFlags()[2]
             ? this.favorite_color
             : (java.lang.CharSequence) defaultValue(fields()[2]);
     record.type_long_test =
         fieldSetFlags()[3] ? this.type_long_test : (java.lang.Long) defaultValue(fields()[3]);
     record.type_double_test =
         fieldSetFlags()[4]
             ? this.type_double_test
             : (java.lang.Object) defaultValue(fields()[4]);
     record.type_null_test =
         fieldSetFlags()[5] ? this.type_null_test : (java.lang.Object) defaultValue(fields()[5]);
     record.type_bool_test =
         fieldSetFlags()[6] ? this.type_bool_test : (java.lang.Object) defaultValue(fields()[6]);
     record.type_array_string =
         fieldSetFlags()[7]
             ? this.type_array_string
             : (java.util.List<java.lang.CharSequence>) defaultValue(fields()[7]);
     record.type_array_boolean =
         fieldSetFlags()[8]
             ? this.type_array_boolean
             : (java.util.List<java.lang.Boolean>) defaultValue(fields()[8]);
     record.type_nullable_array =
         fieldSetFlags()[9]
             ? this.type_nullable_array
             : (java.util.List<java.lang.CharSequence>) defaultValue(fields()[9]);
     record.type_enum =
         fieldSetFlags()[10]
             ? this.type_enum
             : (eu.stratosphere.api.java.record.io.avro.generated.Colors)
                 defaultValue(fields()[10]);
     record.type_map =
         fieldSetFlags()[11]
             ? this.type_map
             : (java.util.Map<java.lang.CharSequence, java.lang.Long>)
                 defaultValue(fields()[11]);
     return record;
   } catch (Exception e) {
     throw new org.apache.avro.AvroRuntimeException(e);
   }
 }
Exemplo n.º 5
0
  public static void main(String[] args) {
    // writes your code here
    HashMap<String, User> users = new HashMap(); // creating list to hold users
    Spark.init();
    Spark.post(
        "/create-account",
        ((request, response) -> {
          String name = request.queryParams("username");
          String password = request.queryParams("password");

          Session session = request.session();
          session.attribute("username", name);

          if (users.get(name) == null) {
            User user = new User(); // creating new user
            user.name = name;
            user.password = password;
            users.put(name, user);
          }
          response.redirect("/");
          return "";
        }));
    Spark.get(
        "/",
        ((request, response) -> {
          Session session = request.session();
          String name = session.attribute("username");
          if (name != null) {
            HashMap m = new HashMap();
            m.put("count", users.size());
            m.put("accounts", users.values());
            return new ModelAndView(m, "logged-in.html");
          }
          HashMap m = new HashMap();
          return new ModelAndView(m, "not-logged-in.html");
        }),
        new MustacheTemplateEngine());
    Spark.post(
        "/logout",
        ((request, response) -> {
          Session session = request.session();
          session.invalidate();
          response.redirect("/");
          return "";
        }));
  }
Exemplo n.º 6
0
  private void button3_updateActionPerformed(ActionEvent e) {
    String message = null;
    User temp = (User) list1.getSelectedValue();
    try {
      temp.name = textField1_name.getText();
      temp.emeil = textField2_emeil.getText();
      temp.telefon = Integer.valueOf(textField3_telefon.getText());
      message = "Успешно преобразован";
      textField1_name.setText("");
      textField2_emeil.setText("");
      textField3_telefon.setText("");

    } catch (NumberFormatException ex) {
      message = "Разберитесь с телефоном";
    } finally {
      JOptionPane.showMessageDialog(this, message);
    }
  }