Skip to content

Commit

Permalink
Aggiornato repository
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzokyne committed Apr 25, 2018
1 parent 11dbaee commit 9a14d87
Show file tree
Hide file tree
Showing 24 changed files with 170 additions and 60 deletions.
Binary file added bin/testJSon/BufferReader.class
Binary file not shown.
Binary file added bin/testJSon/Channels$1.class
Binary file not shown.
Binary file modified bin/testJSon/Channels.class
Binary file not shown.
Binary file added bin/testJSon/Members$1.class
Binary file not shown.
Binary file modified bin/testJSon/Members.class
Binary file not shown.
Binary file modified bin/testJSon/Persona.class
Binary file not shown.
Binary file added bin/testJSon/ciao2.jar
Binary file not shown.
Binary file added bin/testJSon/ciao3.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions bin/testJSon/exe.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -jar ciao3.jar
pause
Binary file added bin/testJSon/funzioni.class
Binary file not shown.
Binary file added bin/testJSon/staticmain.class
Binary file not shown.
Binary file modified bin/testJSon/testJson.class
Binary file not shown.
7 changes: 7 additions & 0 deletions files/titolo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

.d8888. d8b db .d8b. j88D .d8888. db .d8b. .o88b. db dD
88' YP 888o 88 d8' `8b j8~88 88' YP 88 d8' `8b d8P Y8 88 ,8P'
`8bo. 88V8o 88 88ooo88 j8' 88 `8bo. 88 88ooo88 8P 88,8P
`Y8b. 88 V8o88 88~~~88 V88888D `Y8b. 88 88~~~88 8b 88`8b
db 8D 88 V888 88 88 88 db 8D 88booo. 88 88 Y8b d8 88 `88.
`8888Y' VP V8P YP YP VP `8888Y' Y88888P YP YP `Y88P' YP YD
2 changes: 1 addition & 1 deletion src/testJSon/BufferReader.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package graficaint;
package testJSon;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
Expand Down
61 changes: 57 additions & 4 deletions src/testJSon/Channels.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,72 @@
package testJSon;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

import org.json.simple.JSONArray;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class Channels {
private ArrayList<Channel> canali;

public Channels(ArrayList<Channel> a) {
canali=a;
}

public void listaCanali() {
for(int i=0;i<canali.size();i++) {
System.out.println(canali.get(i).getName());
}
}

public String trovaNome(String codice,Members utenti) {
return utenti.getRealName(codice);
}

public void stampaMembri(String membri[],String path) {
Members utenti=new Members();
utenti.acquisisci(path);
for(int i=0;i<membri.length;i++) {
System.out.println(" "+trovaNome(membri[i],utenti)+",");
}
}

public void membriPerChannel(String path) {
for(int i=0;i<canali.size();i++) {
System.out.println(canali.get(i).getName()+":[\n");
stampaMembri(canali.get(i).getMembers(),path);
System.out.println("],");
}

}

public void membridiunchannel(String nomeChannel,String path) {
for(int i=0;i<canali.size();i++) {
if(canali.get(i).getName().equals(nomeChannel)) {
stampaMembri(canali.get(i).getMembers(),path);
}
}
}

public void acquisisci(String path) {
JSONParser parser = new JSONParser();
try {
Gson a=new Gson();
Object obj = parser.parse(new FileReader("channels.json"));
JSONArray jsonArray = (JSONArray) obj;
String temp=jsonArray.toString();
java.lang.reflect.Type listType = new TypeToken<ArrayList<Channel>>() {}.getType();
canali=a.fromJson(temp,listType);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}

public String toString() {
String temp="";
for(int i=0;i<canali.size();i++) {
Expand Down
49 changes: 45 additions & 4 deletions src/testJSon/Members.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,64 @@
package testJSon;
import com.google.gson.Gson;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.json.simple.JSONArray;

import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;

public class Members {
private ArrayList<Persona> membri;

public Members(ArrayList<Persona> persone) {
membri=persone;
}

public void listaMembri() {
for(int i=0;i<membri.size();i++) {
System.out.println(membri.get(i).getReal_name());
}
}

public void acquisisci(String path) {
JSONParser parser = new JSONParser();
try {
Gson a=new Gson();
Object obj = parser.parse(new FileReader("users.json"));//TO DO utilizzare la variabile path
JSONArray jsonArray = (JSONArray) obj;
String temp=jsonArray.toString();
java.lang.reflect.Type listType = new TypeToken<ArrayList<Persona>>() {}.getType();
membri=a.fromJson(temp,listType);
// System.out.println(utenti.toString());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}

public String toString() {
String temp="";
for(int i=0;i<membri.size();i++) {
temp=temp+membri.get(i).toString();
}
return temp;
}

public String getId(int index) {
return membri.get(index).getId();
}

public String getRealName(String codice) {
for(int i=0;i<membri.size();i++) {
if(membri.get(i).getId().equals(codice))
return membri.get(i).getReal_name();
}
return null;
}

public String getRealName(int index) {
return membri.get(index).getReal_name();
}
}
6 changes: 3 additions & 3 deletions src/testJSon/Persona.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package testJSon;

public class Persona{
String id;
String team_id;
String name;
private String id;
private String team_id;
private String name;
private boolean deleted;
private String color;
private String real_name;
Expand Down
Binary file added src/testJSon/ciao3.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/testJSon/exe.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
java -jar ciao2.jar
java -jar ciao3.jar
pause
6 changes: 1 addition & 5 deletions src/testJSon/funzioni.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package graficaint;


package testJSon;

public class funzioni {


public void help() {
System.out.println("usage [--quit] [--listmember] [--listchannel] [--help] ");
System.out.println("--listmember visualizza la lista dei membri specificando successivamente il workspace");
Expand Down
69 changes: 44 additions & 25 deletions src/testJSon/staticmain.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package graficaint;
package testJSon;

import java.io.FileNotFoundException;
import java.io.IOException;
Expand All @@ -18,29 +18,48 @@ public static void main(String[] args) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Scanner tastiera=new Scanner(System.in);
do {
Scanner tastiera=new Scanner(System.in);
b=tastiera.nextLine();
System.out.println(b);
if(b.equals("--help")){
m.help();
}
else if(b.equals("--listmember")) { //funzione
System.out.println("\n"+"Inserisci workspace"+" "+"\n");
//String nomeW=tastiera.nextLine();
//se troviamo il workspace parte il comando --listmember
}
else if(b.equals("--listchannel")) {
System.out.println("\n"+"Inserisci workspace"+" "+"\n");
//String nomeW1=tastiera.nextLine();
//se troviamo il workspace parte il comando --listchannel
}
else if(!b.equals("--quit") && !b.equals("--listmember") && !b.equals("--listchannel") && !b.equals("--help")) {
m.help();
}
//tastiera.close();
}while(!b.equals("--quit"));
}

b=tastiera.nextLine();
if(b.equals("--help")){
m.help();
}
else if(b.equals("--memberlist")) { //funzione
System.out.println("\n"+"Inserisci workspace"+" "+"\n");
String path=tastiera.nextLine();
//se troviamo il workspace parte il comando --listmember
Members temp=new Members();
temp.acquisisci(path);
temp.listaMembri();
}
else if(b.equals("--channellist")) {
System.out.println("\n"+"Inserisci workspace"+" "+"\n");
String path=tastiera.nextLine();
//se troviamo il workspace parte il comando --listchannel
Channels temp=new Channels();
temp.acquisisci(path);
temp.listaCanali();
}
else if(b.equals("memberforchannel")){
System.out.println("\n"+"Inserisci workspace"+" "+"\n");
String path=tastiera.nextLine();
Channels temp=new Channels();
temp.acquisisci(path);
temp.membriPerChannel(path);
}
else if(b.equals("channelmembers")) {
System.out.println("\n"+"Inserisci workspace"+" "+"\n");
String path=tastiera.nextLine();
System.out.println("\n"+"Inserisci Nome canale"+" "+"\n");
String nome=tastiera.nextLine();
Channels temp=new Channels();
temp.acquisisci(path);
temp.membridiunchannel(nome, path);
}
else if(!b.equals("quit")) {
m.help();
}
}while(!b.equals("quit"));
tastiera.close();
}
}
17 changes: 1 addition & 16 deletions src/testJSon/testJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@ public static void main(String[]args) {
} catch (ParseException e) {
e.printStackTrace();
}*/
JSONParser parser = new JSONParser();
try {
Gson a=new Gson();
Object obj = parser.parse(new FileReader("channels.json"));
JSONArray jsonArray = (JSONArray) obj;
String temp=jsonArray.toString();
java.lang.reflect.Type listType = new TypeToken<ArrayList<Channel>>() {}.getType();
Channels canali=new Channels(a.fromJson(temp,listType));
canali.listaCanali();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}

}
}
7 changes: 7 additions & 0 deletions titolo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

.d8888. d8b db .d8b. j88D .d8888. db .d8b. .o88b. db dD
88' YP 888o 88 d8' `8b j8~88 88' YP 88 d8' `8b d8P Y8 88 ,8P'
`8bo. 88V8o 88 88ooo88 j8' 88 `8bo. 88 88ooo88 8P 88,8P
`Y8b. 88 V8o88 88~~~88 V88888D `Y8b. 88 88~~~88 8b 88`8b
db 8D 88 V888 88 88 88 db 8D 88booo. 88 88 Y8b d8 88 `88.
`8888Y' VP V8P YP YP VP `8888Y' Y88888P YP YP `Y88P' YP YD
2 changes: 1 addition & 1 deletion users.json
Original file line number Diff line number Diff line change
Expand Up @@ -6915,4 +6915,4 @@
"updated": 1522055989,
"is_app_user": false
}
]
]

0 comments on commit 9a14d87

Please sign in to comment.