diff --git a/bin/config.xml b/bin/config.xml index d7974345f7cfd5a487e8942f578c8a4710662ab2..66b674926fe721dface4f20021498540b29a138a 100755 --- a/bin/config.xml +++ b/bin/config.xml @@ -65,7 +65,7 @@ <ExternalServer data="localhost:12345"/> -<LastWindowAttributes x="547" y="86" width="792" height="597" max="false" /> +<LastWindowAttributes x="468" y="59" width="788" height="597" max="false" /> </TURTLECONFIGURATION> diff --git a/crawler/bin/client.jar b/crawler/bin/client.jar index 4285912653b34b89c8d0dd27d690eb3532307ee3..a757d749e3595c6efe45608fdcc32b24c7e34bdb 100644 Binary files a/crawler/bin/client.jar and b/crawler/bin/client.jar differ diff --git a/crawler/bin/crawler.jar b/crawler/bin/crawler.jar index ba7b380b2f4df3393a3e6b79f711224685c4d804..d18b857d1739146b7e24ffc9418cb229da1dafa4 100755 Binary files a/crawler/bin/crawler.jar and b/crawler/bin/crawler.jar differ diff --git a/crawler/bin/derby.log b/crawler/bin/derby.log index 4b7bc14fb34ecfb1f5ca4d773ece31a8ad2ac711..ebb67fadcb19e6b185db342afd5ee1b7d7e70ffa 100755 --- a/crawler/bin/derby.log +++ b/crawler/bin/derby.log @@ -1,4 +1,4 @@ -Mon Jun 08 12:05:31 CEST 2015 : Could not listen on port 1527 on host 127.0.0.1: +Fri Jun 12 11:32:26 CEST 2015 : Could not listen on port 1527 on host 127.0.0.1: java.net.BindException: Address already in use An exception was thrown during network server startup. DRDA_ListenPort.S:Could not listen on port 1527 on host 127.0.0.1: java.net.BindException: Address already in use diff --git a/crawler/src/myutil/externalSearch/Message.java b/crawler/src/myutil/externalSearch/Message.java index 7cd104b974fdf42266e410062b2c7a0cc4fbf1e5..5da8716d2538e4c0de00ea40363008f29d98fe13 100644 --- a/crawler/src/myutil/externalSearch/Message.java +++ b/crawler/src/myutil/externalSearch/Message.java @@ -1,3 +1,48 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + + ludovic.apvrille AT enst.fr + + This software is a computer program whose purpose is to allow the + edition of TURTLE analysis, design and deployment diagrams, to + allow the generation of RT-LOTOS or Java code from this diagram, + and at last to allow the analysis of formal validation traces + obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + from INRIA Rhone-Alpes. + + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can use, + modify and/ or redistribute the software under the terms of the CeCILL + license as circulated by CEA, CNRS and INRIA at the following URL + "http://www.cecill.info". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited + liability. + + In this respect, the user's attention is drawn to the risks associated + with loading, using, modifying and/or developing or reproducing the + software by the user in light of its specific status of free software, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + requirements in conditions enabling the security of their systems and/or + data to be ensured and, more generally, to use and operate it in the + same conditions as regards security. + + The fact that you are presently reading this means that you have had + knowledge of the CeCILL license and that you accept its terms. + + /** + * JDialogSearchBox + * unity message for client and server. + * Creation: 22/03/2015 + * @version 1.0 11/03/2015 + * @author Dan VO + * @see + */ package myutil.externalSearch; import java.awt.image.BufferedImage; @@ -10,9 +55,6 @@ import java.util.ArrayList; import java.io.Serializable; import javax.imageio.ImageIO; -/** - * Created by Dan on 3/22/15. - */ //Message format @@ -48,17 +90,19 @@ public class Message implements Serializable { public static String OPTION_SCORE = "score"; public static String OPTION_NUMBER = "number"; public static String OPTION_SYSTEM = "system"; - public static String OPTION_FILE_BIN = "filebin"; - public static String OPTION_FILE_XML = "filexml"; + //public static String OPTION_FILE_BIN = "filebin"; + //public static String OPTION_FILE_XML = "filexml"; public static String CMD_SEARCH = "search"; public static String CMD_STATISTIC = "stat"; public static String CMD_DETAIL = "detail"; + public static String CMD_HISTOGRAM = "histo"; public static String RESULT_SEARCH = "resultSearch"; public static String RESULT_STATISTIC = "resultStat"; public static String RESULT_DETAIL = "resultDetail"; + public static String RESULT_HISTOGRAM = "resultHistogram"; private String cmd; @@ -158,7 +202,6 @@ public class Message implements Serializable { public ArrayList<Object> parseMessage(Message msg) { - //TODO Parse the message return msg.content; } @@ -176,7 +219,6 @@ public class Message implements Serializable { } } catch (IOException e) { - // TODO Auto-generated catch block System.out.println("Image can't not be found!"); } @@ -195,12 +237,11 @@ public class Message implements Serializable { BufferedImage img = ImageIO.read(inStream); ImageIO.write(img, "png", new File(PIC_DES)); - System.out.println("Image has been created successfully!"); + //System.out.println("Image has been created successfully!"); } catch (IOException e) { - // TODO Auto-generated catch block - System.out.println("Image can't not be created!"); + // System.out.println("Image can't not be created!"); } } diff --git a/src/myutil/externalSearch/Client.java b/src/myutil/externalSearch/Client.java index a0705b88b356d4e3d8f0266993a07702e3eb67e5..e94970a3af01808a02d647867ac6ea040ccc58ee 100644 --- a/src/myutil/externalSearch/Client.java +++ b/src/myutil/externalSearch/Client.java @@ -1,251 +1,198 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + + ludovic.apvrille AT enst.fr + + This software is a computer program whose purpose is to allow the + edition of TURTLE analysis, design and deployment diagrams, to + allow the generation of RT-LOTOS or Java code from this diagram, + and at last to allow the analysis of formal validation traces + obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + from INRIA Rhone-Alpes. + + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can use, + modify and/ or redistribute the software under the terms of the CeCILL + license as circulated by CEA, CNRS and INRIA at the following URL + "http://www.cecill.info". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited + liability. + + In this respect, the user's attention is drawn to the risks associated + with loading, using, modifying and/or developing or reproducing the + software by the user in light of its specific status of free software, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + requirements in conditions enabling the security of their systems and/or + data to be ensured and, more generally, to use and operate it in the + same conditions as regards security. + + The fact that you are presently reading this means that you have had + knowledge of the CeCILL license and that you accept its terms. + + /** + * JDialogSearchBox + * dialog for external search with key words + * Creation: 11/03/2015 + * @version 1.0 11/03/2015 + * @author Dan VO & Huy TRUONG + * @see + */ package myutil.externalSearch; import java.io.IOException; -import java.io.PrintStream; -import java.lang.reflect.Array; -import java.net.Socket; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Scanner; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; - - - +import myutil.TraceManager; import org.jsoup.Jsoup; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import org.jsoup.parser.Parser; - import org.jsoup.nodes.Document; public class Client { - //public static String dbaddr="localhost"; - //public static int dpport=9999; public Object parserAnswerMessage(Message answerMsg) { //Analyse the message from the server, //Depends on the cmd, we can determine the values String cmd = answerMsg.getCmd(); - // System.out.println(cmd); + if (cmd == null) { - System.out.println(Message.ERR_CMD); + TraceManager.addDev("Wrong message format - no cmd"); return null; } else if (cmd.equals(Message.RESULT_SEARCH)) { ArrayList<Record> lrecord = new ArrayList<>(); - - // try { - //byte[] encoded = Files.readAllBytes(Paths.get("/home/trhuy/Downloads/02-51-34.xml")); - - //ArrayList<Object> res = new ArrayList(); - //res = answerMsg.getContent(); - //System.out.println("\n"+res); - - - //byte[] encoded = (byte[])answerMsg.getContent().get(0); - - String resultxml = (String)answerMsg.getContent().get(0); - - //System.out.print(resultxml); - - Document doc = Jsoup.parse(resultxml); - for (Element e : doc.select("Row")) { - Record r = new Record(); - Document eachRow = Jsoup.parse(e.toString()); - Element e_id = eachRow.select("cve_id").first(); - Element e_title = eachRow.select("name").first(); - Element e_des = eachRow.select("summary").first(); - r.setCve_id(e_id.text()); - r.setName(e_title.text()); - r.setSummary(e_des.text()); - lrecord.add(r); - } - // } catch (IOException e) { - // e.printStackTrace(); - // } - //System.out.println(lrecord.toArray()); - return (Object)lrecord; + //get content of return result + String resultxml = (String)answerMsg.getContent().get(0); + Document doc = Jsoup.parse(resultxml); + //parser content to get value by tag name. + for (Element e : doc.select("Row")) { + Record r = new Record(); + Document eachRow = Jsoup.parse(e.toString()); + Element e_id = eachRow.select("cve_id").first(); + Element e_title = eachRow.select("name").first(); + Element e_des = eachRow.select("summary").first(); + r.setCve_id(e_id.text()); + r.setName(e_title.text()); + r.setSummary(e_des.text()); + lrecord.add(r); + } + return lrecord; } else if (cmd.equals(Message.RESULT_DETAIL)) { Record r = new Record(); - // try { - //byte[] encoded = Files.readAllBytes(Paths.get("/home/trhuy/Downloads/02-40-06.xml")); -// /byte[] encoded = (byte[])answerMsg.getContent().get(0); - String resultxml = (String)answerMsg.getContent().get(0); - //String resultxml = new String(encoded, "UTF-8"); - - Document doc = Jsoup.parse(resultxml); - for (Element e : doc.select("Row")) { - - Document eachRow = Jsoup.parse(e.toString()); - Element cve_id = eachRow.select("cve_id").first(); - Element pub_date = eachRow.select("pub_date").first(); - Element mod_date = eachRow.select("mod_date").first(); - Element score = eachRow.select("score").first(); - Element access_vector = eachRow.select("access_vector").first(); - Element access_complexity = eachRow.select("access_complexity").first(); - Element authentication = eachRow.select("authentication").first(); - Element confidentiality_impact = eachRow.select("confidentiality_impact").first(); - Element integrity_impact = eachRow.select("integrity_impact").first(); - Element availability_impact = eachRow.select("availability_impact").first(); - Element gen_date = eachRow.select("gen_date").first(); - Element cwe_id = eachRow.select("cwe_id").first(); - Element summary = eachRow.select("summary").first(); - Element ref_type = eachRow.select("ref_type").first(); - Element source = eachRow.select("source").first(); - Element link = eachRow.select("link").first(); - Element name = eachRow.select("name").first(); - - r.setCve_id(cve_id.text()); - r.setPub_date(pub_date.text()); - r.setMod_date(mod_date.text()); - r.setScore(score.text()); - r.setAccess_vector(access_vector.text()); - r.setAccess_complexity(access_complexity.text()); - r.setAuthentication(authentication.text()); - r.setConfidentiality_impact(confidentiality_impact.text()); - r.setIntegrity_impact(integrity_impact.text()); - r.setAvailability_impact(availability_impact.text()); - r.setGen_date(gen_date.text()); - r.setCwe_id(cwe_id.text()); - r.setSummary(summary.text()); - r.setRef_type(ref_type.text()); - r.setSource(source.text()); - r.setLink(link.text()); - - - System.out.print(r.toString()); - - } - // } catch (IOException e) { - // e.printStackTrace(); - //} - - return (Object)r; + //get content of return result + String resultxml = (String)answerMsg.getContent().get(0); + + //parser content to get value by tag name. + Document doc = Jsoup.parse(resultxml); + for (Element e : doc.select("Row")) { + + Document eachRow = Jsoup.parse(e.toString()); + Element cve_id = eachRow.select("cve_id").first(); + Element pub_date = eachRow.select("pub_date").first(); + Element mod_date = eachRow.select("mod_date").first(); + Element score = eachRow.select("score").first(); + Element access_vector = eachRow.select("access_vector").first(); + Element access_complexity = eachRow.select("access_complexity").first(); + Element authentication = eachRow.select("authentication").first(); + Element confidentiality_impact = eachRow.select("confidentiality_impact").first(); + Element integrity_impact = eachRow.select("integrity_impact").first(); + Element availability_impact = eachRow.select("availability_impact").first(); + Element gen_date = eachRow.select("gen_date").first(); + Element cwe_id = eachRow.select("cwe_id").first(); + Element summary = eachRow.select("summary").first(); + Element ref_type = eachRow.select("ref_type").first(); + Element source = eachRow.select("source").first(); + Element link = eachRow.select("link").first(); + Element name = eachRow.select("name").first(); + + r.setCve_id(cve_id.text()); + r.setPub_date(pub_date.text()); + r.setMod_date(mod_date.text()); + r.setScore(score.text()); + r.setAccess_vector(access_vector.text()); + r.setAccess_complexity(access_complexity.text()); + r.setAuthentication(authentication.text()); + r.setConfidentiality_impact(confidentiality_impact.text()); + r.setIntegrity_impact(integrity_impact.text()); + r.setAvailability_impact(availability_impact.text()); + r.setGen_date(gen_date.text()); + r.setCwe_id(cwe_id.text()); + r.setSummary(summary.text()); + r.setRef_type(ref_type.text()); + r.setSource(source.text()); + r.setLink(link.text()); + r.setName(name.text()); + + //System.out.print(r.toString()); + + } + + return r; } else if (cmd.equals(Message.RESULT_STATISTIC)) { - //show picture - //Use a function to convert binary to image + // the content are image. byte[] encoded = (byte[]) answerMsg.getContent().get(0); + return encoded; - return (Object)encoded; - - //Call Huy's function to load Image - } else System.out.print(Message.ERR_CMD2); + } else + TraceManager.addDev("The command is not supported\n"); return null; } - - + /** + * + * @param cmd strings in Message class. + * @param options list of options corresponds to list of values. + * @param values + * @return Message. + */ public Message createRequestMessage(String cmd, ArrayList<String> options, ArrayList<String> values) { Message requestMsg = new Message(cmd,options,values); - System.out.println(Message.SUC_CREATE_REQ_MESSAGE); + //System.out.println(Message.SUC_CREATE_REQ_MESSAGE); return requestMsg; } - public Message send(Message msg, String server, int port){ + /** + * + * @param msg Message + * @param server server address + * @param port port of service + * @return Message from Server. + * @throws IOException + * @throws ClassNotFoundException + */ + public Message send(Message msg, String server, int port) throws IOException, ClassNotFoundException { SSLSocket sslClient = null; - try { - //Socket client = new Socket(dbaddr,dpport); - SSLSocketFactory sslSocketFactory = (SSLSocketFactory)SSLSocketFactory.getDefault(); - sslClient = (SSLSocket)sslSocketFactory.createSocket(server,port); - - sslClient.setEnabledCipherSuites(sslClient.getSupportedCipherSuites()); - System.out.println("Client has been created successfully!"); - - ObjectOutputStream outputStream = new ObjectOutputStream(sslClient.getOutputStream()); - ObjectInputStream inputStream = new ObjectInputStream(sslClient.getInputStream()); - - outputStream.writeObject(msg); - - //Get back the message from server - Message answerMsg = new Message(); - try { - answerMsg = (Message) inputStream.readObject(); - } catch (ClassNotFoundException ex) { - // Logger.getLogger(MultiThreadServer.class.getName()).log(Level.SEVERE, null, ex); - } - - - outputStream.close(); - inputStream.close(); - sslClient.close(); - return answerMsg; - - } catch (UnknownHostException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return null; - } - - - } - - public void main(String[] args){ - try { - Socket client = new Socket("LocalHost",1234); - System.out.println("Client has been created successfully!"); - - ObjectOutputStream outputStream = new ObjectOutputStream(client.getOutputStream()); - ObjectInputStream inputStream = new ObjectInputStream(client.getInputStream()); - - //Create a temporary data to tests - String cmd ="stat"; - ArrayList<String> options = new ArrayList(); - ArrayList<String> values = new ArrayList(); - - options.add("keyword"); - options.add("year"); - options.add("system"); - - values.add("Stuxnet"); - values.add("2014"); - values.add("windows"); - - //Create a msg with constructors - Message msg = createRequestMessage(cmd, options, values); - - //Push the message to server - outputStream.writeObject(msg); - - //Get back the message from server - Message answerMsg = new Message(); - try { - answerMsg = (Message) inputStream.readObject(); - } catch (ClassNotFoundException ex) { - // Logger.getLogger(MultiThreadServer.class.getName()).log(Level.SEVERE, null, ex); - } + //crate a ssl socket. + SSLSocketFactory sslSocketFactory = (SSLSocketFactory)SSLSocketFactory.getDefault(); + sslClient = (SSLSocket)sslSocketFactory.createSocket(server,port); - //Print out the content from the server - // System.out.println(answerMsg.getContent()); + sslClient.setEnabledCipherSuites(sslClient.getSupportedCipherSuites()); + TraceManager.addDev("Client has been created successfully!"); - parserAnswerMessage(answerMsg); - // Message.convertByteToImage(answerMsg.getImageByte()); + ObjectOutputStream outputStream = new ObjectOutputStream(sslClient.getOutputStream()); + ObjectInputStream inputStream = new ObjectInputStream(sslClient.getInputStream()); - outputStream.close(); - inputStream.close(); - client.close(); + outputStream.writeObject(msg); - } catch (UnknownHostException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + //Get back the message from server + Message answerMsg = (Message) inputStream.readObject(); + outputStream.close(); + inputStream.close(); + sslClient.close(); + return answerMsg; } } diff --git a/src/myutil/externalSearch/Message.java b/src/myutil/externalSearch/Message.java index 7cd104b974fdf42266e410062b2c7a0cc4fbf1e5..a6dfda20682a0d14b3ff8533987180f75c2e739a 100644 --- a/src/myutil/externalSearch/Message.java +++ b/src/myutil/externalSearch/Message.java @@ -1,3 +1,48 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + + ludovic.apvrille AT enst.fr + + This software is a computer program whose purpose is to allow the + edition of TURTLE analysis, design and deployment diagrams, to + allow the generation of RT-LOTOS or Java code from this diagram, + and at last to allow the analysis of formal validation traces + obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + from INRIA Rhone-Alpes. + + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can use, + modify and/ or redistribute the software under the terms of the CeCILL + license as circulated by CEA, CNRS and INRIA at the following URL + "http://www.cecill.info". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited + liability. + + In this respect, the user's attention is drawn to the risks associated + with loading, using, modifying and/or developing or reproducing the + software by the user in light of its specific status of free software, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + requirements in conditions enabling the security of their systems and/or + data to be ensured and, more generally, to use and operate it in the + same conditions as regards security. + + The fact that you are presently reading this means that you have had + knowledge of the CeCILL license and that you accept its terms. + + /** + * JDialogSearchBox + * unity message for client and server. + * Creation: 22/03/2015 + * @version 1.0 11/03/2015 + * @author Dan VO + * @see + */ package myutil.externalSearch; import java.awt.image.BufferedImage; @@ -10,9 +55,6 @@ import java.util.ArrayList; import java.io.Serializable; import javax.imageio.ImageIO; -/** - * Created by Dan on 3/22/15. - */ //Message format @@ -48,17 +90,19 @@ public class Message implements Serializable { public static String OPTION_SCORE = "score"; public static String OPTION_NUMBER = "number"; public static String OPTION_SYSTEM = "system"; - public static String OPTION_FILE_BIN = "filebin"; - public static String OPTION_FILE_XML = "filexml"; + //public static String OPTION_FILE_BIN = "filebin"; + //public static String OPTION_FILE_XML = "filexml"; public static String CMD_SEARCH = "search"; public static String CMD_STATISTIC = "stat"; public static String CMD_DETAIL = "detail"; + public static String CMD_HISTOGRAM = "histo"; public static String RESULT_SEARCH = "resultSearch"; public static String RESULT_STATISTIC = "resultStat"; public static String RESULT_DETAIL = "resultDetail"; + public static String RESULT_HISTOGRAM = "resultHistogram"; private String cmd; @@ -158,7 +202,6 @@ public class Message implements Serializable { public ArrayList<Object> parseMessage(Message msg) { - //TODO Parse the message return msg.content; } @@ -176,7 +219,6 @@ public class Message implements Serializable { } } catch (IOException e) { - // TODO Auto-generated catch block System.out.println("Image can't not be found!"); } @@ -195,12 +237,11 @@ public class Message implements Serializable { BufferedImage img = ImageIO.read(inStream); ImageIO.write(img, "png", new File(PIC_DES)); - System.out.println("Image has been created successfully!"); + //System.out.println("Image has been created successfully!"); } catch (IOException e) { - // TODO Auto-generated catch block - System.out.println("Image can't not be created!"); + // System.out.println("Image can't not be created!"); } } diff --git a/src/myutil/externalSearch/Record.java b/src/myutil/externalSearch/Record.java index 756d6b3e449324ce3030e03b117e9654d065ce69..35ecae7f1e2efabc407e62fe5eae553761ec2ade 100644 --- a/src/myutil/externalSearch/Record.java +++ b/src/myutil/externalSearch/Record.java @@ -1,11 +1,51 @@ package myutil.externalSearch; -/** - * Created by trhuy on 5/12/15. +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + + ludovic.apvrille AT enst.fr + + This software is a computer program whose purpose is to allow the + edition of TURTLE analysis, design and deployment diagrams, to + allow the generation of RT-LOTOS or Java code from this diagram, + and at last to allow the analysis of formal validation traces + obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + from INRIA Rhone-Alpes. + + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can use, + modify and/ or redistribute the software under the terms of the CeCILL + license as circulated by CEA, CNRS and INRIA at the following URL + "http://www.cecill.info". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited + liability. + + In this respect, the user's attention is drawn to the risks associated + with loading, using, modifying and/or developing or reproducing the + software by the user in light of its specific status of free software, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + requirements in conditions enabling the security of their systems and/or + data to be ensured and, more generally, to use and operate it in the + same conditions as regards security. + + The fact that you are presently reading this means that you have had + knowledge of the CeCILL license and that you accept its terms. + + /** + * JDialogSearchBox + * format of return message from CVE database + * Creation: 12/03/2015 + * @version 1.0 11/03/2015 + * @author Huy TRUONG + * @see */ public class Record { - //private String id; - //private String n; private String summary; private String cve_id ; private String pub_date ; diff --git a/src/ui/TDiagramMouseManager.java b/src/ui/TDiagramMouseManager.java index 6db772510be13d4a3787fadba3f6f73a7b35409c..1d869443fe41db4bd68400e77d753cbedfb048c6 100755 --- a/src/ui/TDiagramMouseManager.java +++ b/src/ui/TDiagramMouseManager.java @@ -347,7 +347,6 @@ public class TDiagramMouseManager implements MouseListener, MouseMotionListener //open a Search Dialog with seleted component's value if ( (e.getButton() == MouseEvent.BUTTON1) && e.isAltDown()) { byte info = tdp.hoveredComponent(e.getX(), e.getY()); - System.out.print (info); if (info > 1) { tgc = tdp.componentHovered(); String search = tgc.getValue(); diff --git a/src/ui/window/JDialogSearchBox.java b/src/ui/window/JDialogSearchBox.java index be00814ddd724ab4218ee9010b91f8ac00c2627f..3affd3e8273bfbce3d74a1becb35135356016778 100644 --- a/src/ui/window/JDialogSearchBox.java +++ b/src/ui/window/JDialogSearchBox.java @@ -53,7 +53,6 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import javax.imageio.ImageIO; -import java.io.File; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; @@ -94,6 +93,7 @@ public class JDialogSearchBox extends javax.swing.JFrame { private javax.swing.JComboBox combobox_Score; private javax.swing.JComboBox combobox_System; private javax.swing.JComboBox combobox_Year; + private javax.swing.JComboBox combobox_Diagram; private javax.swing.JCheckBox databaseCb; private javax.swing.JTextPane detailText_db; private javax.swing.JTextPane detailText_google; @@ -125,6 +125,7 @@ public class JDialogSearchBox extends javax.swing.JFrame { //private TableSorter resultTable_google; private javax.swing.JTextField searchBox; private javax.swing.JButton searchBt; + private javax.swing.JButton drawBt; private javax.swing.JLabel jLabel_Keyword; private javax.swing.JLabel jLabel_Result; @@ -142,11 +143,11 @@ public class JDialogSearchBox extends javax.swing.JFrame { private DefaultListModel listModel; - ArrayList<GoogleSearch> resultGoogle; + //ArrayList<GoogleSearch> resultGoogle; int searchGoogle; - ArrayList<GoogleSearch> resultGoogleScholar; + //ArrayList<GoogleSearch> resultGoogleScholar; int searchGoogleScholar; - ArrayList<GoogleSearch> resultDatabase; + //ArrayList<GoogleSearch> resultDatabase; int searchDatabase; TDiagramMouseManager tdmm ; @@ -161,7 +162,7 @@ public class JDialogSearchBox extends javax.swing.JFrame { this.tdmm = tdmm; this.setTitle("External Search"); GraphicLib.centerOnParent(this); - String s=""; + //String s=""; for (int i =0; i< l.size(); i++){ addValueListKeyword(l.get(i)); } @@ -216,9 +217,12 @@ public class JDialogSearchBox extends javax.swing.JFrame { jScrollPane8= new JScrollPane(); jScrollPane9= new JScrollPane(); jTextaddressDB = new JTextField(); + combobox_Diagram = new javax.swing.JComboBox(); + drawBt = new JButton(); + String DIAGRAM_LIST[] = {"None","Statistic","Histogram","pie"}; String SYSTEM_LIST[] = {"all", "linux", "windows", "others"}; - String TIME_LIST[]= {"all", "last year", "last 5 years", "last 10 years"}; + String TIME_LIST[]= {"all", "last year", "last 3 years"}; String SCORE_LIST[] = {"all", "5-7", "7-8", "8-9"}; String COLUMNTITLE_G[] ={"No", "Title", "Link"} ; String COLUMNTITLE_GS[]= {"No", "Title", "Author", "Link"}; @@ -252,8 +256,10 @@ public class JDialogSearchBox extends javax.swing.JFrame { removeBt.setText("Remove"); removeBt.setActionCommand("Remove"); removeBt.setEnabled(false); - + drawBt.setText("Draw"); + drawBt.setEnabled(false); searchBt.setText("Search"); + combobox_Diagram.setEnabled(false); searchBox.setText("Key words"); @@ -370,7 +376,7 @@ public class JDialogSearchBox extends javax.swing.JFrame { jTabbedPane2.addTab(GOOGLE_SCHOLAR, jPanel_GoogleScholarTab); - ///// + ///// resultTable_db.setModel(new javax.swing.table.DefaultTableModel(new Object[][]{}, COLUMNTITLE_DB) { @Override @@ -404,12 +410,14 @@ public class JDialogSearchBox extends javax.swing.JFrame { jTabbedPane2.addTab(DB, jPanel_DBTab); + combobox_System.setModel(new javax.swing.DefaultComboBoxModel(SYSTEM_LIST)); combobox_Year.setModel(new javax.swing.DefaultComboBoxModel(TIME_LIST)); combobox_Score.setModel(new javax.swing.DefaultComboBoxModel(SCORE_LIST)); + combobox_Diagram.setModel(new javax.swing.DefaultComboBoxModel(DIAGRAM_LIST)); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); @@ -434,8 +442,9 @@ public class JDialogSearchBox extends javax.swing.JFrame { .addComponent(removeBt)) .addGap(100, 100, 100))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jButton_Setting, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jButton_Statistic, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE)) + .addComponent(jButton_Setting, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(combobox_Diagram, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel_Score) @@ -443,16 +452,20 @@ public class JDialogSearchBox extends javax.swing.JFrame { .addComponent(jLabel_System)) .addGap(37, 37, 37) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(combobox_Score, 0, 142, Short.MAX_VALUE) - .addComponent(combobox_Year, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(combobox_System, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addComponent(combobox_Score, 0, 142, Short.MAX_VALUE) + .addComponent(combobox_Year, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(combobox_System, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + )) .addGroup(layout.createSequentialGroup() .addComponent(jLabel_Status) .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() .addComponent(searchBox) - .addGap(18, 18, 18) - .addComponent(searchBt, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(10, 10, 10) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(searchBt, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(drawBt, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap()) ); layout.setVerticalGroup( @@ -471,8 +484,9 @@ public class JDialogSearchBox extends javax.swing.JFrame { .addComponent(combobox_System, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(googleScholarCb) - .addComponent(jButton_Statistic)) + .addComponent(googleScholarCb) + .addComponent(combobox_Diagram, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + ) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(removeBt)) .addGroup(layout.createSequentialGroup() @@ -485,9 +499,11 @@ public class JDialogSearchBox extends javax.swing.JFrame { .addComponent(combobox_Year, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel_Year)))) .addGap(24, 24, 24) + .addComponent(drawBt) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(searchBox, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(searchBt)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jTabbedPane2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) @@ -521,19 +537,22 @@ public class JDialogSearchBox extends javax.swing.JFrame { public void checkandsetSearchBt() { - if (searchBox.getText().length() <= 0 || searchBox.getText().length() > MAXLENGTH_INPUT) { if (searchBox.getText().length() > MAXLENGTH_INPUT) JOptionPane.showMessageDialog(null, ERROR_INPUT_TOO_LONG, "Warning", JOptionPane.WARNING_MESSAGE); searchBt.setEnabled(false); + drawBt.setEnabled(false); } else + if (combobox_Diagram.getSelectedItem() != "None") + drawBt.setEnabled(true); searchBt.setEnabled(true); - if ( ! isPrintableString(searchBox.getText())) { + if (!isPrintableString(searchBox.getText())) { JOptionPane.showMessageDialog(null, "Not printable character", "Warning", JOptionPane.WARNING_MESSAGE); searchBt.setEnabled(false); + drawBt.setEnabled(false); } } }); @@ -547,7 +566,7 @@ public class JDialogSearchBox extends javax.swing.JFrame { googleCb.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - if (googleCb.isSelected() && ListKeywords.getModel().getSize()>0) + if (googleCb.isSelected() && ListKeywords.getModel().getSize() > 0) searchBt.setEnabled(true); googleCbActionPerformed(evt); } @@ -555,16 +574,32 @@ public class JDialogSearchBox extends javax.swing.JFrame { databaseCb.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - if (databaseCb.isSelected() && ListKeywords.getModel().getSize()>0) + if (databaseCb.isSelected()){ + combobox_Diagram.setEnabled(true); + if (combobox_Diagram.getSelectedItem()!="None") + drawBt.setEnabled(true); + else drawBt.setEnabled(false); + }else { + combobox_Diagram.setEnabled(false); + drawBt.setEnabled(false); + } + if (databaseCb.isSelected() && ListKeywords.getModel().getSize() > 0){ searchBt.setEnabled(true); + } databaseCbActionPerformed(evt); } }); googleScholarCb.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - if (googleScholarCb.isSelected() && ListKeywords.getModel().getSize()>0) + if (googleScholarCb.isSelected() && ListKeywords.getModel().getSize() > 0) { searchBt.setEnabled(true); + drawBt.setEnabled(true); + }else + { + //searchBt.setEnabled(false); + drawBt.setEnabled(false); + } googleScholarCbActionPerformed(evt); } }); @@ -642,13 +677,15 @@ public class JDialogSearchBox extends javax.swing.JFrame { Message msg = new Message(Message.CMD_DETAIL); msg.addKeywordMessage(st); - //Client cl = new Client(); + //Client cl = new Client();) Message returnMsg = sendMessage(msg); //Message returnMsg = new Message(Message.RESULT_DETAIL); //Record r = (Record)cl.parserAnswerMessage(returnMsg); - Record r = (Record) parserMessage(returnMsg); - printDetailRecord(r); + if (returnMsg != null) { + Record r = (Record) parserMessage(returnMsg); + printDetailRecord(r); + } } } @@ -719,12 +756,14 @@ public class JDialogSearchBox extends javax.swing.JFrame { ); - jButton_Statistic.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent actionEvent) { + drawBt.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + //System.out.print(combobox_Diagram.getSelectedItem()); + if (combobox_Diagram.getSelectedItem() == "statistic") doStatistic(); - } - }); + } + }); jTextaddressDB.getDocument().addDocumentListener(new DocumentListener() { @Override @@ -744,11 +783,14 @@ public class JDialogSearchBox extends javax.swing.JFrame { }); - jTabbedPane2.addChangeListener(new ChangeListener() { + + combobox_Diagram.addActionListener(new ActionListener() { @Override - public void stateChanged(ChangeEvent changeEvent) { - //detailText_db.setDocument(new HTMLDocument()); - //detailText_google.setDocument(new HTMLDocument()); + public void actionPerformed(ActionEvent actionEvent) { + if (combobox_Diagram.getSelectedItem() == "None" || searchBox.getText().length() <=0) + drawBt.setEnabled(false); + else if ((combobox_Diagram.getSelectedItem() != "None" && searchBox.getText().length() >0)) + drawBt.setEnabled(true); } }); @@ -760,11 +802,33 @@ public class JDialogSearchBox extends javax.swing.JFrame { this.dispose(); } - public Message sendMessage(Message msg){ + /** + * + * @param msg + * @return + */ + public Message sendMessage(Message msg) { Client cl = new Client(); - return cl.send(msg,dbaddress,dbport); + try{ + return cl.send(msg,dbaddress,dbport); + }catch (IOException e){ + JOptionPane.showMessageDialog(null, "Cannot connect to server !!!", "Warning", + JOptionPane.WARNING_MESSAGE); + return null; + } catch (ClassNotFoundException e) { + JOptionPane.showMessageDialog(null, "Cannot parse message!!!", "Warning", + JOptionPane.WARNING_MESSAGE); + return null; + } + } + + /** + * + * @param msg + * @return Object + */ public Object parserMessage(Message msg){ Client cl = new Client(); return cl.parserAnswerMessage(msg); @@ -817,6 +881,11 @@ public class JDialogSearchBox extends javax.swing.JFrame { } + + /** + * + * @param evt + */ private void searchBtActionPerformed(java.awt.event.ActionEvent evt) { //reset Tab title @@ -824,14 +893,11 @@ public class JDialogSearchBox extends javax.swing.JFrame { jTabbedPane2.setTitleAt(1, GOOGLE_SCHOLAR); jTabbedPane2.setTitleAt(2, DB); - - if (searchGoogle == 0 && searchGoogleScholar == 0 && searchDatabase == 0) { JOptionPane.showMessageDialog(null, "Please select the resource to search","Warning", JOptionPane.WARNING_MESSAGE); } - Thread t = new Thread(new Runnable() { @Override public void run() { @@ -975,20 +1041,27 @@ public class JDialogSearchBox extends javax.swing.JFrame { t.start(); } - - public void showtable(ArrayList<Object[]> list, DefaultTableModel model,int index){ + /** + * Display content in table. + * @param list + * @param model + * @param objectType 0: google + * 1: google scholar + * 2: database + */ + public void showtable(ArrayList<Object[]> list, DefaultTableModel model,int objectType){ int id=0; - if (index ==1 || index ==0) { + if (objectType ==1 || objectType ==0) { for (Object[] o : list) { id = (Integer) (o[0]); GoogleSearch gs = (GoogleSearch) (o[1]); - if (index == 0) + if (objectType == 0) model.addRow(new Object[]{id, gs.getTitle(), gs.getUrl()}); - else if (index == 1) + else if (objectType == 1) model.addRow(new Object[]{id, gs.getTitle(), gs.getAuthors(), gs.getUrl()}); } - } else if (index == 2){ + } else if (objectType == 2){ for (Object[] o : list) { id = (Integer) (o[0]); Record r = (Record) (o[1]); @@ -997,20 +1070,29 @@ public class JDialogSearchBox extends javax.swing.JFrame { } - if (index ==0 ){ - jTabbedPane2.setTitleAt(index, GOOGLE + " [" + model.getRowCount() + "]"); + if (objectType ==0 ){ + jTabbedPane2.setTitleAt(objectType, GOOGLE + " [" + model.getRowCount() + "]"); } - else if (index ==1 ){ - jTabbedPane2.setTitleAt(index, GOOGLE_SCHOLAR + " [" + model.getRowCount() + "]"); + else if (objectType ==1 ){ + jTabbedPane2.setTitleAt(objectType, GOOGLE_SCHOLAR + " [" + model.getRowCount() + "]"); } - else if (index ==2 ){ - jTabbedPane2.setTitleAt(index, DB + " [" + model.getRowCount() + "]"); + else if (objectType ==2 ){ + jTabbedPane2.setTitleAt(objectType, DB + " [" + model.getRowCount() + "]"); } searchBt.setEnabled(true); jLabel_Status.setText("Finished"); - //jTabbedPane2.updateUI(); } + /** + * + * @param evt + * @param rows + * @param resultTable + * @param textpane + * @param typeObject 0: google + * 1: google scholar + * 2: database + */ private void selectrow(ListSelectionEvent evt,ArrayList<Object[]> rows,JTable resultTable,JTextPane textpane,int typeObject) { int rowindex = resultTable.getSelectedRow(); int id =0; @@ -1076,15 +1158,20 @@ public class JDialogSearchBox extends javax.swing.JFrame { this.combobox_Score.setEnabled(false); this.combobox_Year.setEnabled(false); } - } - + } + + + /** + * add new value into Keyword list. + * @param st + */ public void addValueListKeyword(String st){ if (! this.listModel.contains(st)){ this.listModel.addElement(st); String query = ""; - if (this.listModel.getSize()>0) + //split the string query = splitAndConcat((String) this.listModel.elementAt(0)); for (int i=1; i< this.listModel.getSize(); i++ ){ if (query != "") @@ -1119,7 +1206,8 @@ public class JDialogSearchBox extends javax.swing.JFrame { i=i+1; } } - + + public void putGoogleScholarToTable(ArrayList<GoogleSearch> a) { int i = this.rowsGoogleScholar.size()+1; @@ -1129,12 +1217,20 @@ public class JDialogSearchBox extends javax.swing.JFrame { } } + private void printDetailRecord(Record r){ if (r!=null) this.detailText_db.setText(formatOutput_DB_DETAIL(r)); } - + /** + * + * @param obj + * @param typeObject 0: obj from google. + * 1: obj from googleScholar + * 2: obj from database + * @param textPane + */ public void presentDataInDetail(Object obj, int typeObject, JTextPane textPane){ textPane.setContentType("text/html"); @@ -1156,89 +1252,6 @@ public class JDialogSearchBox extends javax.swing.JFrame { } } - public void presentDataInDetail1(Object obj, int typeObject, JTextPane textPane){ - StyledDocument doc = textPane.getStyledDocument(); - textPane.setText(""); - - SimpleAttributeSet bold = new SimpleAttributeSet(); - StyleConstants.setBold(bold, true); - StyleConstants.setFontSize(bold, 15); - SimpleAttributeSet underline = new SimpleAttributeSet(); - StyleConstants.setUnderline(underline, true); - SimpleAttributeSet normal = new SimpleAttributeSet(); - StyleConstants.setBold(normal, false); - StyleConstants.setFontSize(normal, 13); - - if (typeObject ==1 || typeObject ==0 ){ - int offset = 0; - GoogleSearch gs = (GoogleSearch)obj; - if (gs != null) - { - String detail = ""; - if (gs.getTitle()!=null) { - //detail = detail + gs.getTitle() + "\n"; - try { - doc.insertString(offset, gs.getTitle() + "\n", bold); - offset = offset+ gs.getTitle().length()+1; - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - - - - if (gs.getAuthors()!=null) { - //detail = detail + gs.getAuthors() + "\n"; - try { - doc.insertString(offset, gs.getAuthors() + "\n", normal); - offset = offset+gs.getAuthors().length()+1; - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - if (gs.getUrl()!=null){ - try { - detail = detail + gs.getUrl()+"\n"; - doc.insertString(offset, gs.getUrl() + "\n", underline); - offset = offset+gs.getUrl().length()+1; - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - - if (gs.getCitedNumber()!=null){ - try { - //detail = detail + gs.getCitedNumber()+"\n"; - doc.insertString(offset, gs.getCitedNumber() + "\n", normal); - offset = offset+gs.getCitedNumber().length()+1; - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - - if (gs.getDesc()!=null){ - try { - //detail = detail + gs.getCitedNumber()+"\n"; - //detail = detail + gs.getDesc()+"\n"; - doc.insertString(offset, gs.getDesc() + "\n", normal); - offset = offset+gs.getDesc().length()+1; - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - - - //textPane.setText(detail); - } - }else{ - Record r = (Record)obj; - if (r!=null) { - String detail = r.getSummary(); - textPane.setText(detail); - } - } - - } //========================================== //database functions @@ -1265,22 +1278,24 @@ public class JDialogSearchBox extends javax.swing.JFrame { Message ret = sendMessage(msg); + if (ret !=null) + { byte[] b = (byte[])parserMessage(ret); - if(b != null){ + if(b != null) { ByteArrayInputStream in = new ByteArrayInputStream(b); - img = ImageIO.read(in); - ImageIcon icon=new ImageIcon(img); - JFrame frame=new JFrame(); - frame.setLayout(new FlowLayout()); - frame.setSize(200,300); - JLabel lbl=new JLabel(); - lbl.setIcon(icon); - frame.add(lbl); - frame.setVisible(true); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + img = ImageIO.read(in); + ImageIcon icon = new ImageIcon(img); + Image scaleImage = icon.getImage().getScaledInstance(750, 200, Image.SCALE_DEFAULT); + icon = new ImageIcon(scaleImage); + JLabel imageLabel = new JLabel(icon); + JScrollPane scrollPane = new JScrollPane(imageLabel); + jTabbedPane2.addTab("HUY", scrollPane); + + } } } catch (IOException e) { - e.printStackTrace(); + JOptionPane.showMessageDialog(null, "Cannot display diagram !!!", "Warning", + JOptionPane.WARNING_MESSAGE); } } @@ -1303,7 +1318,11 @@ public class JDialogSearchBox extends javax.swing.JFrame { return value; } - + /** + * Check a string if it contains only number. + * @param str + * @return + */ public boolean isNum(String str){ try{ Integer.parseInt(str); @@ -1313,6 +1332,11 @@ public class JDialogSearchBox extends javax.swing.JFrame { } } + /** + * create html format for content from Google Scholar + * @param gs + * @return String + */ public String formatOutput_GoogleScholar (GoogleSearch gs){ String html = "<html>" + "<title>"+gs.getTitle()+"</title>" + @@ -1326,6 +1350,12 @@ public class JDialogSearchBox extends javax.swing.JFrame { "</html>"; return html; } + + /** + * create html format for content from Google + * @param gs + * @return String + */ public String formatOutput_Google (GoogleSearch gs){ String html = "<html>" + "<title>"+gs.getTitle()+"</title>" + @@ -1338,6 +1368,11 @@ public class JDialogSearchBox extends javax.swing.JFrame { return html; } + /** + * create html format for content from Database (not detail) + * @param r + * @return String + */ public String formatOutput_DB_SHORT (Record r){ String html = "<html>" + "<body style=\"font-size: 14pt\">" + @@ -1349,6 +1384,11 @@ public class JDialogSearchBox extends javax.swing.JFrame { return html; } + /** + * create html format for content from Database (detail) + * @param r + * @return String + */ public String formatOutput_DB_DETAIL (Record r){ String html = "<html>" + "<body style=\"font-size: 14pt\">" + @@ -1370,6 +1410,11 @@ public class JDialogSearchBox extends javax.swing.JFrame { return html; } + /** + * Check the printable character. + * @param c + * @return + */ public boolean isPrintableChar( char c ) { Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); return (!Character.isISOControl(c)) && @@ -1378,6 +1423,11 @@ public class JDialogSearchBox extends javax.swing.JFrame { block != Character.UnicodeBlock.SPECIALS; } + /** + * Check the printable string + * @param s + * @return + */ public boolean isPrintableString(String s){ if (s==null) return false;