'Added simply MailClient mockup;'
This commit is contained in:
parent
09153fccde
commit
324989f8ae
11
02_MailClient/MailClient.iml
Normal file
11
02_MailClient/MailClient.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
02_MailClient/src/Main.java
Normal file
6
02_MailClient/src/Main.java
Normal file
@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
8
02_MailClient/src/net/hypki/mailclient/db/Db.java
Normal file
8
02_MailClient/src/net/hypki/mailclient/db/Db.java
Normal file
@ -0,0 +1,8 @@
|
||||
package net.hypki.mailclient.db;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface Db {
|
||||
public void save(String key, Object value) throws IOException;
|
||||
public Object get(String key);
|
||||
}
|
22
02_MailClient/src/net/hypki/mailclient/db/sql/MySQLDB.java
Normal file
22
02_MailClient/src/net/hypki/mailclient/db/sql/MySQLDB.java
Normal file
@ -0,0 +1,22 @@
|
||||
package net.hypki.mailclient.db.sql;
|
||||
|
||||
import net.hypki.mailclient.db.Db;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MySQLDB implements Db {
|
||||
@Override
|
||||
public void save(String key, Object value) throws IOException {
|
||||
// 1. opening a client to a real databse
|
||||
// 2. put object to real database
|
||||
// 3. check for errors
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String key) {
|
||||
// 1. open a client to a database
|
||||
// 2. return data from DB
|
||||
// 3. convert to Object and return it
|
||||
return null;
|
||||
}
|
||||
}
|
57
02_MailClient/src/net/hypki/mailclient/model/Mail.java
Normal file
57
02_MailClient/src/net/hypki/mailclient/model/Mail.java
Normal file
@ -0,0 +1,57 @@
|
||||
package net.hypki.mailclient.model;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Mail extends ModelObject {
|
||||
private String id = null;
|
||||
private String title = null;
|
||||
private String from = null;
|
||||
private String to = null;
|
||||
|
||||
public Mail() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws IOException, IllegalArgumentException {
|
||||
// if `to` mail is incorrect then throw exception
|
||||
if (!to.contains("@"))
|
||||
throw new IOException("bbbbbb");
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
// additions
|
||||
// someFunction()
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String newTitle) {
|
||||
|
||||
this.title = newTitle;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setTo(String to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package net.hypki.mailclient.model;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class ModelObject {
|
||||
public abstract void validate() throws IOException, IllegalArgumentException;
|
||||
}
|
36
02_MailClient/src/net/hypki/mailclient/model/User.java
Normal file
36
02_MailClient/src/net/hypki/mailclient/model/User.java
Normal file
@ -0,0 +1,36 @@
|
||||
package net.hypki.mailclient.model;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class User extends ModelObject {
|
||||
private String email = null;
|
||||
|
||||
private String name = null;
|
||||
|
||||
public User() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws IOException, IllegalArgumentException {
|
||||
// if `to` mail is incorrect then throw exception
|
||||
if (!email.contains("@"))
|
||||
throw new IOException("bbbbbb");
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
27
02_MailClient/src/net/hypki/mailclient/view/MainUI.java
Normal file
27
02_MailClient/src/net/hypki/mailclient/view/MainUI.java
Normal file
@ -0,0 +1,27 @@
|
||||
package net.hypki.mailclient.view;
|
||||
|
||||
import net.hypki.mailclient.db.Db;
|
||||
import net.hypki.mailclient.db.sql.MySQLDB;
|
||||
import net.hypki.mailclient.model.Mail;
|
||||
|
||||
import javax.activation.MailcapCommandMap;
|
||||
|
||||
public class MainUI {
|
||||
|
||||
private Db database = null;
|
||||
|
||||
public MainUI() {
|
||||
database = new MySQLDB();
|
||||
}
|
||||
|
||||
public void showMainDialog() {
|
||||
// show UI
|
||||
|
||||
while (true) {
|
||||
// check evey 5 mins for new mails
|
||||
|
||||
Mail newMail = new Mail();
|
||||
database.save(newMail.getId(), newMail);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user