コード例 #1
1
ファイル: NCCPConnection.java プロジェクト: WU-ARL/RLI
 public void fireEvent(NCCPConnection.ConnectionEvent e) {
   ConnectionListener l;
   int max = listeners.size();
   for (int i = 0; i < max; ++i) {
     ExpCoordinator.print(
         new String(
             "NCCPConnection.fireEvent ("
                 + toString()
                 + ") event: "
                 + e.getType()
                 + " max:"
                 + max
                 + " i:"
                 + i),
         2);
     l = (ConnectionListener) (listeners.elementAt(i));
     switch (e.getType()) {
       case ConnectionEvent.CONNECTION_FAILED:
         l.connectionFailed(e);
         break;
       case ConnectionEvent.CONNECTION_CLOSED:
         l.connectionClosed(e);
         break;
       case ConnectionEvent.CONNECTION_OPENED:
         ExpCoordinator.printer.print(
             new String("Opened control connection (" + toString() + ")"));
         l.connectionOpened(e);
     }
   }
 }
コード例 #2
1
ファイル: ExtendedResolver.java プロジェクト: lemmy/dnsjava
  public Message send(Message query) {
    int q, r;
    Message best = null;
    byte rcode;

    for (q = 0; q < 20; q++) {
      boolean ok = false;
      for (r = 0; r < resolvers.length; r++) ok |= sendTo(query, r, q);
      if (!ok) break;
      Message m = null;
      synchronized (queue) {
        try {
          queue.wait((quantum + 1) * 1000);
        } catch (InterruptedException e) {
          System.out.println("interrupted");
        }
        if (queue.size() == 0) continue;
        m = (Message) queue.firstElement();
        queue.removeElementAt(0);
        Integer I = (Integer) queue.firstElement();
        queue.removeElementAt(0);
        r = I.intValue();
      }
      if (m == null) invalid[r] = true;
      else {
        rcode = m.getHeader().getRcode();
        if (rcode == Rcode.NOERROR) return m;
        else {
          if (best == null) best = m;
          invalid[r] = true;
        }
      }
    }
    return best;
  }
コード例 #3
0
 public boolean checkEvents(BundleEvent[] expevents) {
   boolean res = true;
   for (int i = 0; i < 20; i++) {
     try {
       Thread.sleep(100);
     } catch (InterruptedException ignore) {
     }
     if (events.size() == expevents.length) {
       break;
     }
   }
   if (events.size() == expevents.length) {
     for (int i = 0; i < events.size(); i++) {
       BundleEvent be = (BundleEvent) events.elementAt(i);
       if (!(be.getBundle().equals(expevents[i].getBundle())
           && be.getType() == expevents[i].getType())) {
         res = false;
       }
     }
   } else {
     res = false;
   }
   if (!res) {
     out.println("Real events");
     for (int i = 0; i < events.size(); i++) {
       BundleEvent be = (BundleEvent) events.elementAt(i);
       out.println("Event " + be.getBundle() + ", Type " + be.getType());
     }
     out.println("Expected events");
     for (int i = 0; i < expevents.length; i++) {
       out.println("Event " + expevents[i].getBundle() + ", Type " + expevents[i].getType());
     }
   }
   return res;
 }
コード例 #4
0
 /** Get row count (part of table model interface) */
 public int getRowCount() {
   int count = data.size();
   if (filter_data != null) {
     count = filter_data.size();
   }
   return count;
 }
コード例 #5
0
ファイル: Configuration.java プロジェクト: colombbus/tangara
 /**
  * Gets the urlClassLoader that enables to access to the objects jar files.
  *
  * @return an URLClassLoader
  */
 public URLClassLoader getObjectsClassLoader() {
   if (objectsClassLoader == null) {
     try {
       if (isExecutionMode()) {
         URL[] listUrl = new URL[1];
         listUrl[0] = instance.getTangaraPath().toURI().toURL();
         objectsClassLoader = new URLClassLoader(listUrl);
       } else {
         File f = new File(instance.getTangaraPath().getParentFile(), "objects");
         File[] list = f.listFiles();
         Vector<URL> vector = new Vector<URL>();
         for (int i = 0; i < list.length; i++) {
           if (list[i].getName().endsWith(".jar")) vector.add(list[i].toURI().toURL());
         }
         File flib =
             new File(
                 instance.getTangaraPath().getParentFile().getAbsolutePath().replace("\\", "/")
                     + "/objects/lib");
         File[] listflib = flib.listFiles();
         for (int j = 0; j < listflib.length; j++) {
           if (listflib[j].getName().endsWith(".jar")) vector.add(listflib[j].toURI().toURL());
         }
         URL[] listUrl = new URL[vector.size()];
         for (int j = 0; j < vector.size(); j++) listUrl[j] = vector.get(j);
         objectsClassLoader = new URLClassLoader(listUrl);
       }
     } catch (Exception e1) {
       displayError("URL MAL FORMED " + e1);
       return null;
     }
   }
   return objectsClassLoader;
 }
コード例 #6
0
ファイル: server.java プロジェクト: michi-goetz/java-chat
  public Vector<String> getUserNames() {
    int i;
    Vector<String> names = new Vector<String>(connections.size());

    for (i = 0; i < connections.size(); i++) {
      names.addElement((String) connections.elementAt(i).nickname);
    }

    return names;
  }
コード例 #7
0
 /** Add data to the table as a new row */
 public void addData(SOAPMonitorData soap) {
   int row = data.size();
   data.addElement(soap);
   if (filter_data != null) {
     if (filterMatch(soap)) {
       row = filter_data.size();
       filter_data.addElement(soap);
       fireTableRowsInserted(row, row);
     }
   } else {
     fireTableRowsInserted(row, row);
   }
 }
コード例 #8
0
ファイル: WebServer.java プロジェクト: badaljain/cmpe281
 private boolean checkSocket(Socket s) {
   int l = deny.size();
   byte address[] = s.getInetAddress().getAddress();
   for (int i = 0; i < l; i++) {
     AddressMatcher match = (AddressMatcher) deny.elementAt(i);
     if (match.matches(address)) return false;
   }
   l = accept.size();
   for (int i = 0; i < l; i++) {
     AddressMatcher match = (AddressMatcher) accept.elementAt(i);
     if (match.matches(address)) return true;
   }
   return false;
 }
コード例 #9
0
 public boolean action(Event e, Object arg) {
   System.out.println(e + " " + arg);
   if (e.target == bf.tf) {
     System.out.println("new page");
     String url = bf.tf.getText();
     pages.addElement(url);
     String page = split(url);
     System.out.println("Server = " + server);
     System.out.println("Port = " + port);
     System.out.println("Page = " + page);
     connect(page);
     position++;
     bf.back.enable();
     return true;
   } else if (e.target == bf.back) {
     System.out.println("pos " + position + " " + pages.size());
     if (position > 0) {
       position--;
       String page = split((String) pages.elementAt(position));
       bf.tf.setText((String) pages.elementAt(position));
       connect(page);
       if (position == 0) {
         bf.back.disable();
       }
       bf.forward.enable();
     }
     return true;
   } else if (e.target == bf.forward) {
     if (position != pages.size() - 1) {
       position++;
       bf.tf.setText((String) pages.elementAt(position));
       String page = split((String) pages.elementAt(position));
       if (position == pages.size() - 1) {
         bf.forward.disable();
       }
       bf.back.enable();
       connect(page);
     }
     return true;
   } else if (e.target == bf.b) {
     System.out.println("Disposing of browser frame");
     bf.hide();
     bf.dispose();
     bf = null;
     return true;
   } else {
     return false;
   }
 }
コード例 #10
0
  private String[] getNoAuthCiperSuites(String ciperSuites[]) {
    // Count the number of ciper suites.
    Vector<Integer> v = new Vector<Integer>();
    for (int i = 0; i < ciperSuites.length; i++) {
      if (ciperSuites[i].indexOf("anon") != -1) v.add(new Integer(i));
    }

    String ret[] = new String[v.size()];
    for (int i = 0; i < v.size(); i++) {
      int tmp = v.get(i).intValue();
      ret[i] = ciperSuites[tmp];
    }

    return ret;
  }
コード例 #11
0
  public void nick_name(String msg) {
    try {
      String name = msg.substring(13);
      this.setName(name);
      Vector v = father.onlineList;
      boolean isRepeatedName = false;
      int size = v.size();
      for (int i = 0; i < size; i++) {
        ServerAgentThread tempSat = (ServerAgentThread) v.get(i);
        if (tempSat.getName().equals(name)) {
          isRepeatedName = true;
          break;
        }
      }
      if (isRepeatedName == true) {
        dout.writeUTF("<#NAME_REPEATED#>");
        din.close();
        dout.close();
        sc.close();
        flag = false;
      } else {
        v.add(this);
        father.refreshList();
        String nickListMsg = "";
        StringBuilder nickListMsgSb = new StringBuilder();
        size = v.size();
        for (int i = 0; i < size; i++) {
          ServerAgentThread tempSat = (ServerAgentThread) v.get(i);
          nickListMsgSb.append("!");
          nickListMsgSb.append(tempSat.getName());
        }
        nickListMsgSb.append("<#NICK_LIST#>");
        nickListMsg = nickListMsgSb.toString();
        Vector tempv = father.onlineList;
        size = tempv.size();
        for (int i = 0; i < size; i++) {
          ServerAgentThread tempSat = (ServerAgentThread) tempv.get(i);
          tempSat.dout.writeUTF(nickListMsg);
          if (tempSat != this) {
            tempSat.dout.writeUTF("<#MSG#>" + this.getName() + "is now online....");
          }
        }
      }

    } catch (IOException e) {
      e.printStackTrace();
    }
  }
コード例 #12
0
  private void updateTabBar(Vector vtThread) {
    pnlThread.removeAll();
    for (int iThreadIndex = 0; iThreadIndex < vtThread.size(); iThreadIndex++) {
      try {
        Vector vtThreadInfo = (Vector) vtThread.elementAt(iThreadIndex);
        PanelThreadMonitor mntTemp = new PanelThreadMonitor(channel);

        String strThreadID = (String) vtThreadInfo.elementAt(0);
        String strThreadName = (String) vtThreadInfo.elementAt(1);
        int iThreadStatus = Integer.parseInt((String) vtThreadInfo.elementAt(2));
        mntTemp.setThreadID(strThreadID);
        mntTemp.setThreadName(strThreadName);
        mntTemp.setThreadStatus(iThreadStatus);
        showResult(mntTemp.txtMonitor, (String) vtThreadInfo.elementAt(3));
        mntTemp.addPropertyChangeListener(this);

        pnlThread.add(strThreadName, mntTemp);
        mntTemp.updateStatus();
      } catch (Exception e) {
        e.printStackTrace();
        MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
      }
    }
    Skin.applySkin(this);
  }
コード例 #13
0
ファイル: NCCPConnection.java プロジェクト: WU-ARL/RLI
 public void setConnected(boolean b, boolean process_pending) {
   if (b && state != ConnectionEvent.CONNECTION_OPENED) {
     if (host.length() > 0)
       ExpCoordinator.print(
           "NCCPConnection open connection to ipaddress " + host + " port " + port);
     state = ConnectionEvent.CONNECTION_OPENED;
     // connected = true;
     fireEvent(new ConnectionEvent(this, state));
     ExpCoordinator.printer.print("NCCPConnection.setConnected " + b + " event fired", 8);
     if (process_pending) {
       int max = pendingMessages.size();
       ExpCoordinator.printer.print(new String("   pendingMessages " + max + " elements"), 8);
       for (int i = 0; i < max; ++i) {
         sendMessage((NCCP.Message) pendingMessages.elementAt(i));
       }
       pendingMessages.removeAllElements();
     }
   } else {
     if (!b
         && (state != ConnectionEvent.CONNECTION_CLOSED
             || state != ConnectionEvent.CONNECTION_FAILED)) {
       if (host.length() > 0)
         ExpCoordinator.print(
             new String(
                 "NCCPConnection.setConnected -- Closed control socket for " + host + "." + port));
       state = ConnectionEvent.CONNECTION_CLOSED;
       fireEvent(new ConnectionEvent(this, state));
     }
   }
 }
コード例 #14
0
ファイル: SdpFactory.java プロジェクト: jiafu1115/jain-sip-1
  public static void main(String[] args) throws SdpParseException, SdpException {
    String sdpFields =
        "v=0\r\n"
            + "o=4855 13760799956958020 13760799956958020 IN IP4 166.35.224.216\r\n"
            + "s=nortelnetworks\r\n"
            + "p=+1 972 684 1000\r\n"
            + "c=IN IP4 166.35.224.216\r\n"
            + "t=0 0\r\n"
            + "m=audio 50006 RTP/AVP 0 8 4 18\r\n"
            + "a=rtpmap:0 PCMU/8000\r\n"
            + "a=rtpmap:8 PCMA/8000\r\n"
            + "a=rtpmap:4 G723/8000\r\n"
            + "a=rtpmap:18 G729A/8000\r\n"
            + "a=ptime:30\r\n";
    SdpFactory sdpFactory = new SdpFactory();
    SessionDescription sessionDescription = sdpFactory.createSessionDescription(sdpFields);

    System.out.println("sessionDescription = " + sessionDescription);
    Vector mediaDescriptions = sessionDescription.getMediaDescriptions(true);
    for (int i = 0; i < mediaDescriptions.size(); i++) {
      MediaDescription m = (MediaDescription) mediaDescriptions.elementAt(i);
      System.out.println("m = " + m.toString());
      Media media = m.getMedia();
      Vector formats = media.getMediaFormats(false);
      System.out.println("formats = " + formats);
    }
  }
コード例 #15
0
 public void removeUser(String strChannel) {
   Vector vtData = tblUser.getFilteredData();
   for (int iIndex = 0; iIndex < vtData.size(); iIndex++) {
     Vector vtRow = (Vector) vtData.elementAt(iIndex);
     if (vtRow.elementAt(0).equals(strChannel)) tblUser.deleteRow(iIndex);
   }
 }
コード例 #16
0
ファイル: server.java プロジェクト: michi-goetz/java-chat
  public void sendGlobalServerMsg(String msg) {
    int i;
    connection you;

    for (i = 0; i < connections.size(); i++) {
      you = (connection) connections.elementAt(i);
      you.sendServerMsg(msg);
    }
  }
コード例 #17
0
ファイル: Util.java プロジェクト: rhusar/smartfrog
 // ------------------------------------------------------------
 // test whether "s1" and "s2" share substring, each substring
 // is deliminated by "delim"
 // ------------------------------------------------------------
 public static boolean shareString(String s1, String s2, String delim) {
   Vector v1 = str2vec(s1, delim);
   Vector v2 = str2vec(s2, delim);
   for (int i = 0; i < v1.size(); i++) {
     String s = (String) v1.elementAt(i);
     if (v2.contains(s)) return true;
   }
   return false;
 }
コード例 #18
0
ファイル: PDBfile.java プロジェクト: genome-vendor/apollo
 public PDBChain findChain(String id) {
   for (int i = 0; i < chains.size(); i++) {
     // System.out.println("ID = " + id + " " +((PDBChain)chains.elementAt(i)).id);
     if (((PDBChain) chains.elementAt(i)).id.equals(id)) {
       return (PDBChain) chains.elementAt(i);
     }
   }
   return null;
 }
コード例 #19
0
 /** Update a message */
 public void updateData(SOAPMonitorData soap) {
   int row;
   if (filter_data == null) {
     // No filter, so just fire table updated
     row = data.indexOf(soap);
     if (row != -1) {
       fireTableRowsUpdated(row, row);
     }
   } else {
     // Check if the row was being displayed
     row = filter_data.indexOf(soap);
     if (row == -1) {
       // Row was not displayed, so check for if it
       // now needs to be displayed
       if (filterMatch(soap)) {
         int index = -1;
         row = data.indexOf(soap) + 1;
         while ((row < data.size()) && (index == -1)) {
           index = filter_data.indexOf(data.elementAt(row));
           if (index != -1) {
             // Insert at this location
             filter_data.add(index, soap);
           }
           row++;
         }
         if (index == -1) {
           // Insert at end
           index = filter_data.size();
           filter_data.addElement(soap);
         }
         fireTableRowsInserted(index, index);
       }
     } else {
       // Row was displayed, so check if it needs to
       // be updated or removed
       if (filterMatch(soap)) {
         fireTableRowsUpdated(row, row);
       } else {
         filter_data.remove(soap);
         fireTableRowsDeleted(row, row);
       }
     }
   }
 }
コード例 #20
0
ファイル: Server.java プロジェクト: G10DRAS/speech
 public Session findSessionTo(String to) {
   int n = clients.size();
   Log.fine(Name + ": looking for client to " + to);
   for (int i = 0; i < n; i++) {
     Session ias = clients.elementAt(i);
     Log.fine(Name + ": client " + i + " id is " + ias.sid);
     if (ias.sid.startsWith(to)) return ias;
   }
   return null;
 }
コード例 #21
0
ファイル: Server.java プロジェクト: G10DRAS/speech
 public Session findSession(String id) {
   int n = clients.size();
   Log.fine(Name + ": looking for client with id " + id);
   for (int i = 0; i < n; i++) {
     Session ias = clients.elementAt(i);
     Log.fine(Name + ": client " + i + " id is " + ias.sid);
     if (ias.sid.equals(id)) return ias;
   }
   return null;
 }
コード例 #22
0
 /** Find the data for a given id */
 public SOAPMonitorData findData(Long id) {
   SOAPMonitorData soap = null;
   for (int row = data.size(); (row > 0) && (soap == null); row--) {
     soap = (SOAPMonitorData) data.elementAt(row - 1);
     if (soap.getId().longValue() != id.longValue()) {
       soap = null;
     }
   }
   return soap;
 }
コード例 #23
0
ファイル: Broadcast.java プロジェクト: lojo57/auguste
 public boolean existLogin(String login) {
   boolean res = false;
   for (int i = 0; i < mClients.size(); i++) {
     ClientInfo clientInfo = (ClientInfo) mClients.get(i);
     if (login.equals(clientInfo.login)) {
       res = true;
     }
   }
   return res;
 }
コード例 #24
0
ファイル: IUmenu.java プロジェクト: jhonderson/NavelBattle
 /*
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 */
 public boolean yaEsta(String nombre) {
   boolean siOno = false;
   for (int a = 0; a < vectorJugadores.size(); a++) {
     if (nombre.equals(vectorJugadores.get(a))) {
       siOno = true;
       break;
     }
   }
   return siOno;
 }
コード例 #25
0
ファイル: server.java プロジェクト: michi-goetz/java-chat
  /** @param msg Sende msg an alle Teilnehmer */
  public void broadcast(String msg) {
    int i;
    connection you;

    for (i = 0; i < connections.size(); i++) {
      // System.out.println("Nachricht verschicken!");
      you = (connection) connections.elementAt(i);
      you.out.println(msg);
    }
  }
コード例 #26
0
  public void createPopupMenu() {
    menu = new JPopupMenu();
    for (int i = filenames.size() - 2, j = 0; i >= 0; i--, j++) {
      menu.add((String) filenames.elementAt(i));
      JMenuItem mi = (JMenuItem) menu.getComponent(j);
      mi.setFont(new Font("Arial", Font.PLAIN, 11));
      mi.addActionListener(this);
    }

    menu.pack();
    // setPopupLocation(200, 200);
  }
コード例 #27
0
ファイル: server.java プロジェクト: michi-goetz/java-chat
  public boolean userExists(String name) {
    int i;
    connection you;

    for (i = 0; i < connections.size(); i++) {
      you = (connection) connections.elementAt(i);
      if (you.getNickname().equals(name)) {
        return true;
      }
    }
    return false;
  }
コード例 #28
0
 /** Remove all messages from the table (but leave "most recent") */
 public void clearAll() {
   int last_row = data.size() - 1;
   if (last_row > 0) {
     data.removeAllElements();
     SOAPMonitorData soap = new SOAPMonitorData(null, null, null);
     data.addElement(soap);
     if (filter_data != null) {
       filter_data.removeAllElements();
       filter_data.addElement(soap);
     }
     fireTableDataChanged();
   }
 }
コード例 #29
0
ファイル: Util.java プロジェクト: rhusar/smartfrog
 public static String commonString(String s1, String s2, String delim) {
   Vector v1 = str2vec(s1, delim);
   Vector v2 = str2vec(s2, delim);
   StringBuffer buf = new StringBuffer();
   for (int i = 0; i < v1.size(); i++) {
     String s = (String) v1.elementAt(i);
     if (v2.contains(s)) {
       if (buf.length() > 0) buf.append(delim);
       buf.append(s);
     }
   }
   return buf.toString();
 }
コード例 #30
0
ファイル: UDP.java プロジェクト: NZDIS/jgroups
  void sendMultipleUdpMessages(Message msg, Vector dests) {
    Address dest;

    for (int i = 0; i < dests.size(); i++) {
      dest = (Address) dests.elementAt(i);
      msg.setDest(dest);

      try {
        sendUdpMessage(msg);
      } catch (Exception e) {
        Trace.debug("UDP.sendMultipleUdpMessages()", "exception=" + e);
      }
    }
  }