/**
   * Processes the messages from the server
   *
   * @param message
   */
  private synchronized void processServerMessage(String message) {
    SAXBuilder builder = new SAXBuilder();
    String what = new String();
    Document doc = null;

    try {
      doc = builder.build(new StringReader(message));
      Element root = doc.getRootElement();
      List childs = root.getChildren();
      Iterator i = childs.iterator();
      what = ((Element) i.next()).getName();
    } catch (Exception e) {
    }

    if (what.equalsIgnoreCase("LOGIN") == true) _login(doc);
    else if (what.equalsIgnoreCase("LOGOUT") == true) _logout(doc);
    else if (what.equalsIgnoreCase("MESSAGE") == true) _message(doc);
    else if (what.equalsIgnoreCase("WALL") == true) _wall(doc);
    else if (what.equalsIgnoreCase("CREATEGROUP") == true) _creategroup(doc);
    else if (what.equalsIgnoreCase("JOINGROUP") == true) _joingroup(doc);
    else if (what.equalsIgnoreCase("PARTGROUP") == true) _partgroup(doc);
    else if (what.equalsIgnoreCase("GROUPMESSAGE") == true) _groupmessage(doc);
    else if (what.equalsIgnoreCase("KICK") == true) _kick(doc);
    else if (what.equalsIgnoreCase("LISTUSER") == true) _listuser(doc);
    else if (what.equalsIgnoreCase("LISTGROUP") == true) _listgroup(doc);
  }
Beispiel #2
0
 public static Document getXmlDocument(String fileName, boolean isWord) {
   File file = new File(fileName);
   SAXBuilder builder = new SAXBuilder();
   if (false) {
     builder.setValidation(true);
     builder.setProperty(
         "http://java.sun.com/xml/jaxp/properties/schemaSource",
         "http://localhost/Wiki/xsd/wikiXmlSchema.xsd");
   }
   try {
     return builder.build(file);
   } catch (Exception e) {
     return null;
   }
 }
Beispiel #3
0
  public static Document getDocumentFromHttpGetRequest(String service, String xmlSchema)
      throws JDOMException {
    try {
      // Open connection to service
      HttpURLConnection connection = (HttpURLConnection) (new URL(service)).openConnection();

      connection.setRequestMethod("GET");
      connection.setConnectTimeout(150);
      connection.setReadTimeout(150);

      // Build document from inputstream
      InputStream in = connection.getInputStream();
      SAXBuilder builder = new SAXBuilder();
      if (false) {
        builder.setValidation(true);
        builder.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", xmlSchema);
      }
      return builder.build(in);
    } catch (IOException e) {
      return null;
    }
  }