Example usage for javax.swing.tree DefaultTreeModel DefaultTreeModel

List of usage examples for javax.swing.tree DefaultTreeModel DefaultTreeModel

Introduction

In this page you can find the example usage for javax.swing.tree DefaultTreeModel DefaultTreeModel.

Prototype

@ConstructorProperties({ "root" })
public DefaultTreeModel(TreeNode root) 

Source Link

Document

Creates a tree in which any node can have children.

Usage

From source file:org.zaproxy.zap.control.AddOnRunIssuesUtils.java

/**
 * Creates a scrollable tree with the given add-ons as root nodes and its issues as child nodes.
 *
 * @param availableAddOns the add-ons that are available, used to create check the running issues
 * @param addOnsNotRunnable the add-ons with running issues that will be shown in the tree
 * @return the tree wrapper in a {@code JSCrollPane}
 *//* w w  w.j  a v a 2 s. co  m*/
private static JScrollPane createScrollableTreeAddOnsNotRunnable(final AddOnCollection availableAddOns,
        AddOn... addOnsNotRunnable) {
    AddOnSearcher addOnSearcher = new AddOnSearcher() {

        @Override
        public AddOn searchAddOn(String id) {
            return availableAddOns.getAddOn(id);
        }
    };

    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("");
    for (AddOn addOn : addOnsNotRunnable) {
        DefaultMutableTreeNode addOnNode = new DefaultMutableTreeNode(addOn.getName());
        AddOn.AddOnRunRequirements requirements = addOn.calculateRunRequirements(availableAddOns.getAddOns());
        List<String> issues = getUiRunningIssues(requirements, addOnSearcher);

        if (issues.isEmpty()) {
            issues.addAll(getUiExtensionsRunningIssues(requirements, addOnSearcher));
        }

        for (String issue : issues) {
            addOnNode.add(new DefaultMutableTreeNode(issue));
        }
        rootNode.add(addOnNode);
    }

    JXTree tree = new JXTree(new DefaultTreeModel(rootNode));
    tree.setVisibleRowCount(5);
    tree.setEditable(false);
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.expandAll();

    return new JScrollPane(tree);
}

From source file:org.zaproxy.zap.extension.ascan.CustomScanDialog.java

private void setTech() {
    Context context = this.getSelectedContext();

    TechSet ts = new TechSet(Tech.builtInTech);
    Iterator<Tech> iter = ts.getIncludeTech().iterator();

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(
            Constant.messages.getString("ascan.custom.tab.tech.node"));
    Tech tech;// w  w  w .j  av  a  2 s .  c  om
    DefaultMutableTreeNode parent;
    DefaultMutableTreeNode node;
    while (iter.hasNext()) {
        tech = iter.next();
        if (tech.getParent() != null) {
            parent = techToNodeMap.get(tech.getParent());
        } else {
            parent = null;
        }
        if (parent == null) {
            parent = root;
        }
        node = new DefaultMutableTreeNode(tech.getUiName());
        parent.add(node);
        techToNodeMap.put(tech, node);
    }

    techModel = new DefaultTreeModel(root);
    techTree.setModel(techModel);
    techTree.expandAll();
    // Default to everything set
    TreePath rootTp = new TreePath(root);
    techTree.checkSubTree(rootTp, true);
    techTree.setCheckBoxEnabled(rootTp, false);

    if (context != null) {
        TechSet techSet = context.getTechSet();
        Iterator<Entry<Tech, DefaultMutableTreeNode>> iter2 = techToNodeMap.entrySet().iterator();
        while (iter.hasNext()) {
            Entry<Tech, DefaultMutableTreeNode> nodeEntry = iter2.next();
            TreePath tp = this.getTechPath(nodeEntry.getValue());
            if (techSet.includes(nodeEntry.getKey())) {
                this.getTechTree().check(tp, true);
            }
        }
    }
}

From source file:org.zaproxy.zap.extension.customFire.TechnologyTreePanel.java

public TechnologyTreePanel(String nameRootNode) {
    setLayout(new BorderLayout());

    techToNodeMap = new HashMap<>();
    techTree = new JCheckBoxScriptsTree() {

        private static final long serialVersionUID = 1L;

        @Override/*from ww  w.  j  ava  2  s. c  o m*/
        protected void setExpandedState(TreePath path, boolean state) {
            // Ignore all collapse requests; collapse events will not be fired
            if (state) {
                super.setExpandedState(path, state);
            }
        }

    };
    // Initialise the structure based on all the tech we know about
    TechSet ts = new TechSet(Tech.builtInTech);
    Iterator<Tech> iter = ts.getIncludeTech().iterator();

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(nameRootNode);
    Tech tech;
    DefaultMutableTreeNode parent;
    DefaultMutableTreeNode node;
    while (iter.hasNext()) {
        tech = iter.next();
        if (tech.getParent() != null) {
            parent = techToNodeMap.get(tech.getParent());
        } else {
            parent = null;
        }
        if (parent == null) {
            parent = root;
        }
        node = new DefaultMutableTreeNode(tech.getUiName());
        parent.add(node);
        techToNodeMap.put(tech, node);
    }

    techTree.setModel(new DefaultTreeModel(root));
    techTree.expandAll();
    techTree.setCheckBoxEnabled(new TreePath(root), false);
    reset();

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(techTree);
    scrollPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

    add(scrollPane, BorderLayout.CENTER);
}

From source file:org.zaproxy.zap.view.ContextTechnologyPanel.java

private JCheckBoxTree getTechTree() {
    if (techTree == null) {
        techTree = new JCheckBoxTree() {
            private static final long serialVersionUID = 1L;

            @Override/*from   w  w w .  java2 s .c o  m*/
            protected void setExpandedState(TreePath path, boolean state) {
                // Ignore all collapse requests; collapse events will not be fired
                if (state) {
                    super.setExpandedState(path, state);
                }
            }
        };
        // Initialise the structure based on all the tech we know about
        TechSet ts = new TechSet(Tech.builtInTech);
        Iterator<Tech> iter = ts.getIncludeTech().iterator();

        DefaultMutableTreeNode root = new DefaultMutableTreeNode(
                Constant.messages.getString("context.technology.tree.root"));
        Tech tech;
        DefaultMutableTreeNode parent;
        DefaultMutableTreeNode node;
        while (iter.hasNext()) {
            tech = iter.next();
            if (tech.getParent() != null) {
                parent = techToNodeMap.get(tech.getParent());
            } else {
                parent = null;
            }
            if (parent == null) {
                parent = root;
            }
            node = new DefaultMutableTreeNode(tech.getUiName());
            parent.add(node);
            techToNodeMap.put(tech, node);
        }

        model = new DefaultTreeModel(root);
        techTree.setModel(model);
        techTree.expandAll();
        techTree.setCheckBoxEnabled(new TreePath(root), false);

    }
    return techTree;
}

From source file:org.zaproxy.zap.view.NodeSelectDialog.java

private DefaultTreeModel emptyContextTree() {
    return new DefaultTreeModel(new SiteNode(null, -1, Constant.messages.getString("context.list")));
}

From source file:org.zaproxy.zap.view.NodeSelectDialog.java

private DefaultTreeModel emptySiteTree() {
    // Make a very sparse copy of the site tree
    SiteNode siteRoot = (SiteNode) Model.getSingleton().getSession().getSiteTree().getRoot();
    SiteNode root = new SiteNode(null, -1, Constant.messages.getString("tab.sites"));
    root.setUserObject(siteRoot);//  w ww.  j  av a  2s. co  m
    return new DefaultTreeModel(root);
}

From source file:org.zaproxy.zap.view.TechnologyTreePanel.java

public TechnologyTreePanel(String nameRootNode) {
    setLayout(new BorderLayout());

    techToNodeMap = new HashMap<>();
    techTree = new JCheckBoxTree() {

        private static final long serialVersionUID = 1L;

        @Override/*from w  w w .  j ava2s. c o m*/
        protected void setExpandedState(TreePath path, boolean state) {
            // Ignore all collapse requests; collapse events will not be fired
            if (state) {
                super.setExpandedState(path, state);
            }
        }
    };
    // Initialise the structure based on all the tech we know about
    TechSet ts = new TechSet(Tech.builtInTech);
    Iterator<Tech> iter = ts.getIncludeTech().iterator();

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(nameRootNode);
    Tech tech;
    DefaultMutableTreeNode parent;
    DefaultMutableTreeNode node;
    while (iter.hasNext()) {
        tech = iter.next();
        if (tech.getParent() != null) {
            parent = techToNodeMap.get(tech.getParent());
        } else {
            parent = null;
        }
        if (parent == null) {
            parent = root;
        }
        node = new DefaultMutableTreeNode(tech.getUiName());
        parent.add(node);
        techToNodeMap.put(tech, node);
    }

    techTree.setModel(new DefaultTreeModel(root));
    techTree.expandAll();
    techTree.setCheckBoxEnabled(new TreePath(root), false);
    reset();

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(techTree);
    scrollPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

    add(scrollPane, BorderLayout.CENTER);
}

From source file:pa_SymposiumPlanner.BRF2011GeneralChair.java

public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html; charset=UTF-8");
    //PrintWriter out = response.getWriter();
    try {//from w w  w. j  av a  2  s .c o  m
        address = PAConfiguration.getAddress();
        port = PAConfiguration.getPort(instantiation);
        poslAddress = PAConfiguration.getPOSL(instantiation, topic);
        rdfAddress = PAConfiguration.getRDFTaxonomy(instantiation);
        messageEndpoint = PAConfiguration.getEndpointName(instantiation, topic);
    } catch (BadConfigurationException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        System.exit(0);
    }
    try {
        System.out.println("General Chair Servlet");
        System.out.println(response.toString());

        BufferedReader brd = request.getReader();

        String input = "";
        String message = "";

        while (!input.equals("</RuleML>")) {
            input = brd.readLine();
            message = message + input;
        }
        String[] varOrder = getVariableOrder(message);
        System.out.println("Received Message: " + message);

        //BackwardReasoner br = new BackwardReasoner();
        //Iterator solit =null;
        //DefiniteClause dc = null;
        //SymbolTable.reset();

        POSLParser pp = new POSLParser();

        Date t1 = new GregorianCalendar().getTime();
        //System.out.println(t1.getHours() + ":" + t1.getMinutes());
        //append time to contents

        //System.out.println("day: " + t1.getDay());
        //System.out.println("day: " + t1.getYear());
        //System.out.println("day: " + t1.getMonth());

        //time
        String time = "time(" + t1.getHours() + ":integer).";
        //System.out.println(time);

        //String url = "http://www.jdrew.org/oojdrew/test.posl";
        String contents = "";

        //day of the week
        int day = t1.getDay();
        boolean weekday = true;

        if (day == 0 || day == 6) {
            weekday = false;
        }

        String dayOfWeek;

        if (weekday) {
            dayOfWeek = "day(weekday).";
        } else {
            dayOfWeek = "day(weekend).";
        }
        //full date
        Calendar cal = new GregorianCalendar();

        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH) + 1;
        int day2 = cal.get(Calendar.DAY_OF_MONTH);

        String date;

        String day3 = "" + day2;

        if (day2 == 1 || day2 == 2 || day2 == 3 || day2 == 4 || day2 == 5 || day2 == 6 || day2 == 7 || day2 == 8
                || day2 == 9) {

            day3 = "0" + day2;
        }

        if (month == 10 || month == 11 || month == 12) {
            date = "" + year + month + day3;
        } else {
            date = "" + year + "0" + month + day3;
        }

        date = "date(" + date + ":integer).";

        //System.out.println(date);

        String url = poslAddress;
        String url2 = rdfAddress;
        HttpClient client2 = new HttpClient();
        GetMethod method2 = new GetMethod(url2);
        method2.setFollowRedirects(true);
        String typestr = "";

        // Execute the GET method
        int statusCode2 = client2.executeMethod(method2);
        if (statusCode2 != -1) {
            typestr = method2.getResponseBodyAsString();
        }
        Types.reset();
        RDFSParser.parseRDFSString(typestr);

        try {
            HttpClient client = new HttpClient();
            GetMethod method = new GetMethod(url);
            method.setFollowRedirects(true);

            // Execute the GET method
            int statusCode = client.executeMethod(method);
            if (statusCode != -1) {
                contents = method.getResponseBodyAsString();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        contents = contents + "\n" + time;
        contents = contents + "\n" + dayOfWeek;
        contents = contents + "\n" + date;

        BackwardReasoner br = new BackwardReasoner();

        SymbolTable.reset();

        pp.parseDefiniteClauses(contents);
        br.loadClauses(pp.iterator());

        Iterator it = pp.iterator();
        while (it.hasNext()) {
            DefiniteClause d = (DefiniteClause) it.next();
            System.out.println("Loaded clause: " + d.toPOSLString());
        }

        br = new BackwardReasoner(br.clauses, br.oids);

        MessageParser m = new MessageParser(message);
        Element atom = null;

        try {
            atom = m.parseForContent();
        } catch (Exception e) {
            System.out.println("Invalid Message");
            //out.flush();
        }

        QueryBuilder q = new QueryBuilder(atom);
        String query = q.generateDoc();
        System.out.println("ABOUT TO INPUT THIS QUERY:" + query);
        RuleMLParser qp = new RuleMLParser();

        DefiniteClause dc = null;
        try {
            dc = qp.parseRuleMLQuery(query);
        } catch (Exception e) {
            System.out.println("Invalid Query");
            //out.flush();
        }

        int varSize = 0;

        Iterator solit = br.iterativeDepthFirstSolutionIterator(dc);
        while (solit.hasNext()) {

            Vector data = new Vector();

            BackwardReasoner.GoalList gl = (BackwardReasoner.GoalList) solit.next();

            Hashtable varbind = gl.varBindings;
            javax.swing.tree.DefaultMutableTreeNode root = br.toTree();
            root.setAllowsChildren(true);

            javax.swing.tree.DefaultTreeModel dtm = new DefaultTreeModel(root);

            int i = 0;
            Object[][] rowdata = new Object[varbind.size()][2];
            varSize = varbind.size();

            Enumeration e = varbind.keys();
            while (e.hasMoreElements()) {
                Object k = e.nextElement();
                Object val = varbind.get(k);
                String ks = (String) k;
                rowdata[i][0] = ks;
                rowdata[i][1] = val;

                i++;
            }

            data.addElement(rowdata);
            String[] messages = new String[data.size()];
            MessageGenerator g = new MessageGenerator(data, varSize, messageEndpoint, m.getId(),
                    m.getProtocol(), m.getRel(), varOrder);
            //messages = g.Messages2();
            messages = g.Messages2();
            String appender = "";

            URL sender = new URL(address + ":" + port);
            HttpMessage msg = new HttpMessage(sender);
            Properties props = new Properties();

            for (int i1 = 0; i1 < data.size(); i1++) {
                System.out.println(i1 + ")" + messages[i1].toString());
                props.put("text", messages[i1].toString());
                InputStream in = msg.sendGetMessage(props);
            }
            System.out.println("NEXT MESSAGE");
        }

        MessageGenerator g = new MessageGenerator(null, varSize, messageEndpoint, m.getId(), m.getProtocol(),
                m.getRel());

        URL sender = new URL(address + ":" + port);
        HttpMessage msg = new HttpMessage(sender);
        Properties props = new Properties();

        String finalMessage = g.finalMessage(query);

        System.out.println(finalMessage);

        props.put("text", finalMessage);
        InputStream in = msg.sendGetMessage(props);

        System.out.println("Stop_Communication");
    } catch (Exception e) {
        System.out.println("ERROR has occured : " + e.toString());
    }
    //out.close();
}

From source file:pa_SymposiumPlanner.BRF2011LiaisonChair.java

public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html; charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {/*from   w ww.  j  a v a2s  .  co m*/
        address = PAConfiguration.getAddress();
        port = PAConfiguration.getPort(instantiation);
        poslAddress = PAConfiguration.getPOSL(instantiation, topic);
        rdfAddress = PAConfiguration.getRDFTaxonomy(instantiation);
        messageEndpoint = PAConfiguration.getEndpointName(instantiation, topic);
    } catch (BadConfigurationException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        System.exit(0);
    }
    try {
        System.out.println("Liaison Chair Servlet");
        System.out.println(response.toString());

        BufferedReader brd = request.getReader();

        String input = "";
        String message = "";

        while (!input.equals("</RuleML>")) {

            input = brd.readLine();

            message = message + input;
        }
        String[] varOrder = getVariableOrder(message);
        System.out.println("Received Message: " + message);

        //   BackwardReasoner br = new BackwardReasoner();
        //   Iterator solit =null;
        //   DefiniteClause dc = null;
        //   SymbolTable.reset();

        POSLParser pp = new POSLParser();
        // String contents = "c(a).\nc(b).\nc(c).";

        Date t1 = new GregorianCalendar().getTime();
        System.out.println(t1.getHours() + ":" + t1.getMinutes());
        //append time to contents

        System.out.println("day: " + t1.getDay());
        System.out.println("day: " + t1.getYear());
        System.out.println("day: " + t1.getMonth());

        //time
        String time = "time(" + t1.getHours() + ":integer).";
        System.out.println(time);

        String url = poslAddress;

        //String url = "http://www.jdrew.org/oojdrew/test.posl";
        String contents = "";

        //day of the week
        int day = t1.getDay();
        boolean weekday = true;

        if (day == 0 || day == 6) {
            weekday = false;
        }

        String dayOfWeek;

        if (weekday) {
            dayOfWeek = "day(weekday).";
        } else {
            dayOfWeek = "day(weekend).";
        }
        //full date
        Calendar cal = new GregorianCalendar();

        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH) + 1;
        int day2 = cal.get(Calendar.DAY_OF_MONTH);

        String date;

        String day3 = "" + day2;

        if (day2 == 1 || day2 == 2 || day2 == 3 || day2 == 4 || day2 == 5 || day2 == 6 || day2 == 7 || day2 == 8
                || day2 == 9) {

            day3 = "0" + day2;
        }

        if (month == 10 || month == 11 || month == 12) {
            date = "" + year + month + day3;
        } else {
            date = "" + year + "0" + month + day3;
        }

        date = "date(" + date + ":integer).";

        System.out.println(date);

        String url2 = rdfAddress;
        HttpClient client2 = new HttpClient();
        GetMethod method2 = new GetMethod(url2);
        method2.setFollowRedirects(true);
        String typestr = "";
        // Execute the GET method
        int statusCode2 = client2.executeMethod(method2);
        if (statusCode2 != -1) {
            typestr = method2.getResponseBodyAsString();
        }
        System.out.println("Types: " + typestr);
        Types.reset();
        RDFSParser.parseRDFSString(typestr);

        try {
            HttpClient client = new HttpClient();
            GetMethod method = new GetMethod(url);
            method.setFollowRedirects(true);

            // Execute the GET method
            int statusCode = client.executeMethod(method);
            if (statusCode != -1) {
                contents = method.getResponseBodyAsString();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        contents = contents + "\n" + time;
        contents = contents + "\n" + dayOfWeek;
        contents = contents + "\n" + date;

        BackwardReasoner br = new BackwardReasoner();
        Iterator solit = null;
        DefiniteClause dc = null;
        SymbolTable.reset();

        pp.parseDefiniteClauses(contents);

        br.loadClauses(pp.iterator());

        Iterator it = pp.iterator();
        while (it.hasNext()) {
            DefiniteClause d = (DefiniteClause) it.next();
            System.out.println("Loaded clause: " + d.toPOSLString());
        }

        br = new BackwardReasoner(br.clauses, br.oids);

        MessageParser m = new MessageParser(message);
        Element atom = null;

        try {

            atom = m.parseForContent();

        } catch (Exception e) {

            System.out.println("Invalid Message");
            //out.flush();

        }

        QueryBuilder q = new QueryBuilder(atom);
        String query = q.generateDoc();
        System.out.println("ABOUT TO INPUT THIS QUERY:" + query);
        RuleMLParser qp = new RuleMLParser();

        try {

            dc = qp.parseRuleMLQuery(query);

        } catch (Exception e) {
            System.out.println("Invalid Query");
            //out.flush();
        }

        //solit = br.iterativeDepthFirstSolutionIterator(dc);

        solit = br.iterativeDepthFirstSolutionIterator(dc);

        int varSize = 0;

        while (solit.hasNext()) {

            Vector data = new Vector();

            BackwardReasoner.GoalList gl = (BackwardReasoner.GoalList) solit.next();

            Hashtable varbind = gl.varBindings;
            javax.swing.tree.DefaultMutableTreeNode root = br.toTree();
            root.setAllowsChildren(true);

            javax.swing.tree.DefaultTreeModel dtm = new DefaultTreeModel(root);

            int i = 0;
            Object[][] rowdata = new Object[varbind.size()][2];
            varSize = varbind.size();

            Enumeration e = varbind.keys();
            while (e.hasMoreElements()) {
                Object k = e.nextElement();
                Object val = varbind.get(k);
                String ks = (String) k;
                rowdata[i][0] = ks;
                rowdata[i][1] = val;

                i++;
            }

            data.addElement(rowdata);
            String[] messages = new String[data.size()];
            MessageGenerator g = new MessageGenerator(data, varSize, messageEndpoint, m.getId(),
                    m.getProtocol(), m.getRel(), varOrder);
            messages = g.Messages2();

            String appender = "";

            URL sender = new URL(address + ":" + port);
            HttpMessage msg = new HttpMessage(sender);
            Properties props = new Properties();

            for (int i1 = 0; i1 < data.size(); i1++) {
                System.out.println(i1 + ")" + messages[i1].toString());
                props.put("text", messages[i1].toString());
                InputStream in = msg.sendGetMessage(props);
            }
            System.out.println("NEXT MESSAGE");
        }

        MessageGenerator g = new MessageGenerator(null, varSize, messageEndpoint, m.getId(), m.getProtocol(),
                m.getRel());

        URL sender = new URL(address + ":" + port);
        HttpMessage msg = new HttpMessage(sender);
        Properties props = new Properties();

        String finalMessage = g.finalMessage(query);

        System.out.println(finalMessage);

        props.put("text", finalMessage);
        InputStream in = msg.sendGetMessage(props);

        System.out.println("Stop_Communication");

    } catch (Exception e) {
        System.out.println("ERROR has occured : " + e.toString());

    }
    out.close();
}

From source file:pa_SymposiumPlanner.BRF2011PanelChair.java

public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html; charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {/*from   w ww.java  2 s .  co m*/
        address = PAConfiguration.getAddress();
        port = PAConfiguration.getPort(instantiation);
        poslAddress = PAConfiguration.getPOSL(instantiation, topic);
        rdfAddress = PAConfiguration.getRDFTaxonomy(instantiation);
        messageEndpoint = PAConfiguration.getEndpointName(instantiation, topic);
    } catch (BadConfigurationException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        System.exit(0);
    }
    try {
        System.out.println("Panel Chair Servlet");
        System.out.println(response.toString());

        BufferedReader brd = request.getReader();

        String input = "";
        String message = "";

        while (!input.equals("</RuleML>")) {

            input = brd.readLine();

            message = message + input;
        }
        String[] varOrder = getVariableOrder(message);
        System.out.println("Received Message: " + message);

        //   BackwardReasoner br = new BackwardReasoner();
        //   Iterator solit =null;
        //   DefiniteClause dc = null;
        //   SymbolTable.reset();

        POSLParser pp = new POSLParser();
        // String contents = "c(a).\nc(b).\nc(c).";

        Date t1 = new GregorianCalendar().getTime();
        System.out.println(t1.getHours() + ":" + t1.getMinutes());
        //append time to contents

        System.out.println("day: " + t1.getDay());
        System.out.println("day: " + t1.getYear());
        System.out.println("day: " + t1.getMonth());

        //time
        String time = "time(" + t1.getHours() + ":integer).";
        System.out.println(time);

        String url = poslAddress;

        //String url = "http://www.jdrew.org/oojdrew/test.posl";
        String contents = "";

        //day of the week
        int day = t1.getDay();
        boolean weekday = true;

        if (day == 0 || day == 6) {
            weekday = false;
        }

        String dayOfWeek;

        if (weekday) {
            dayOfWeek = "day(weekday).";
        } else {
            dayOfWeek = "day(weekend).";
        }
        //full date
        Calendar cal = new GregorianCalendar();

        int year = cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH) + 1;
        int day2 = cal.get(Calendar.DAY_OF_MONTH);

        String date;

        String day3 = "" + day2;

        if (day2 == 1 || day2 == 2 || day2 == 3 || day2 == 4 || day2 == 5 || day2 == 6 || day2 == 7 || day2 == 8
                || day2 == 9) {

            day3 = "0" + day2;
        }

        if (month == 10 || month == 11 || month == 12) {
            date = "" + year + month + day3;
        } else {
            date = "" + year + "0" + month + day3;
        }

        date = "date(" + date + ":integer).";

        System.out.println(date);

        String url2 = rdfAddress;
        HttpClient client2 = new HttpClient();
        GetMethod method2 = new GetMethod(url2);
        method2.setFollowRedirects(true);
        String typestr = "";
        // Execute the GET method
        int statusCode2 = client2.executeMethod(method2);
        if (statusCode2 != -1) {
            typestr = method2.getResponseBodyAsString();
        }
        System.out.println("Types: " + typestr);
        Types.reset();
        RDFSParser.parseRDFSString(typestr);

        try {
            HttpClient client = new HttpClient();
            GetMethod method = new GetMethod(url);
            method.setFollowRedirects(true);

            // Execute the GET method
            int statusCode = client.executeMethod(method);
            if (statusCode != -1) {
                contents = method.getResponseBodyAsString();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        contents = contents + "\n" + time;
        contents = contents + "\n" + dayOfWeek;
        contents = contents + "\n" + date;

        BackwardReasoner br = new BackwardReasoner();
        Iterator solit = null;
        DefiniteClause dc = null;
        SymbolTable.reset();

        pp.parseDefiniteClauses(contents);

        br.loadClauses(pp.iterator());

        Iterator it = pp.iterator();
        while (it.hasNext()) {
            DefiniteClause d = (DefiniteClause) it.next();
            System.out.println("Loaded clause: " + d.toPOSLString());
        }

        br = new BackwardReasoner(br.clauses, br.oids);

        MessageParser m = new MessageParser(message);
        Element atom = null;

        try {

            atom = m.parseForContent();

        } catch (Exception e) {

            System.out.println("Invalid Message");
            //out.flush();

        }

        QueryBuilder q = new QueryBuilder(atom);
        String query = q.generateDoc();
        System.out.println("ABOUT TO INPUT THIS QUERY:" + query);
        RuleMLParser qp = new RuleMLParser();

        try {

            dc = qp.parseRuleMLQuery(query);

        } catch (Exception e) {
            System.out.println("Invalid Query");
            //out.flush();
        }

        //solit = br.iterativeDepthFirstSolutionIterator(dc);

        solit = br.iterativeDepthFirstSolutionIterator(dc);

        int varSize = 0;

        while (solit.hasNext()) {

            Vector data = new Vector();

            BackwardReasoner.GoalList gl = (BackwardReasoner.GoalList) solit.next();

            Hashtable varbind = gl.varBindings;
            javax.swing.tree.DefaultMutableTreeNode root = br.toTree();
            root.setAllowsChildren(true);

            javax.swing.tree.DefaultTreeModel dtm = new DefaultTreeModel(root);

            int i = 0;
            Object[][] rowdata = new Object[varbind.size()][2];
            varSize = varbind.size();

            Enumeration e = varbind.keys();
            while (e.hasMoreElements()) {
                Object k = e.nextElement();
                Object val = varbind.get(k);
                String ks = (String) k;
                rowdata[i][0] = ks;
                rowdata[i][1] = val;

                i++;
            }

            data.addElement(rowdata);
            String[] messages = new String[data.size()];
            MessageGenerator g = new MessageGenerator(data, varSize, messageEndpoint, m.getId(),
                    m.getProtocol(), m.getRel(), varOrder);
            messages = g.Messages2();

            String appender = "";

            URL sender = new URL(address + ":" + port);
            HttpMessage msg = new HttpMessage(sender);
            Properties props = new Properties();

            for (int i1 = 0; i1 < data.size(); i1++) {
                System.out.println(i1 + ")" + messages[i1].toString());
                props.put("text", messages[i1].toString());
                InputStream in = msg.sendGetMessage(props);
            }
            System.out.println("NEXT MESSAGE");
        }

        MessageGenerator g = new MessageGenerator(null, varSize, messageEndpoint, m.getId(), m.getProtocol(),
                m.getRel());

        URL sender = new URL(address + ":" + port);
        HttpMessage msg = new HttpMessage(sender);
        Properties props = new Properties();

        String finalMessage = g.finalMessage(query);

        System.out.println(finalMessage);

        props.put("text", finalMessage);
        InputStream in = msg.sendGetMessage(props);

        System.out.println("Stop_Communication");

    } catch (Exception e) {
        System.out.println("ERROR has occured : " + e.toString());

    }
    out.close();
}