private static Long latestVersion(Hashtable<String, String> config, dbutil db_util) throws Exception { if (!config.get("timestamp_stop").equals(Integer.toString(Integer.MAX_VALUE))) { return new Long(config.get("timestamp_stop")); } String rowName = config.get("file_id") + config.get("run_id") + "_"; if (config.get("task_id") != "") { try { rowName = rowName + String.format("%04d", new Integer(config.get("task_id"))); } catch (NumberFormatException E) { rowName = rowName + config.get("task_id"); } } Get timestampGet = new Get(rowName.getBytes()); timestampGet.addColumn("d".getBytes(), "update".getBytes()); Result timestampResult = db_util.doGet(config.get("db_name_updates"), timestampGet); KeyValue tsKv = timestampResult.getColumnLatest("d".getBytes(), "update".getBytes()); if (tsKv == null) { rowName = config.get("file_id") + "_"; timestampGet = new Get(rowName.getBytes()); timestampGet.addColumn("d".getBytes(), "update".getBytes()); timestampResult = db_util.doGet(config.get("db_name_updates"), timestampGet); tsKv = timestampResult.getColumnLatest("d".getBytes(), "update".getBytes()); } if (tsKv == null) { return new Long(Integer.MAX_VALUE); } Long latestVersion = new Long(tsKv.getTimestamp()); return latestVersion; }
/** * Filters a PMData's measurements by the modifier of each measurement... the format for the data * should be such for each modifier, there is parameter name/value pairs for each parameter name * supplied. the resulting list is a list of String arrays with the parameters * * @param data PMData: the PM data object * @param params String[]: the PM parameters * @return Hashtable: a table of string arrays, with the modifier as the key (or "?" if no * modifier) */ public static Hashtable process(PMData data, String[] params) { if (data != null) { // table for temporary storage of param lists... Hashtable ht = new Hashtable(); // for each param... for (int i = 0; i < params.length; i++) { PmMeasurement[] m = data.getMeasurementList(); for (int j = 0; j < m.length; j++) { if (m[j].getParameterName().equals(params[i])) { String mod = m[j].getModifier(); if (mod == null) { mod = "?"; } String[] datum = (String[]) ht.get(mod); if (datum == null) { datum = new String[params.length]; for (int k = 0; k < params.length; k++) { datum[k] = ""; } } datum[i] = m[j].getParameterValue(); ht.put(mod, datum); } } } return ht; } return null; }
public synchronized void messageReceived(int to, Message m) { DrainMsg mhMsg = (DrainMsg) m; log.debug( "incoming: localDest: " + to + " type:" + mhMsg.get_type() + " hops:" + (16 - mhMsg.get_ttl()) + " seqNo:" + mhMsg.get_seqNo() + " source:" + mhMsg.get_source() + " finalDest:" + mhMsg.get_dest()); // lets assume that the network cannot buffer more than 25 drain msgs from a single source at a // time (should be more than reasonable) if (seqNos.containsKey(new Integer(mhMsg.get_source()))) { int oldSeqNo = ((Integer) seqNos.get(new Integer(mhMsg.get_source()))).intValue(); int upperBound = mhMsg.get_seqNo() + 25; int wrappedUpperBound = 25 - (255 - mhMsg.get_seqNo()); if ((oldSeqNo >= mhMsg.get_seqNo() && oldSeqNo < upperBound) || (oldSeqNo >= 0 && oldSeqNo < wrappedUpperBound)) { log.debug( "Dropping message from " + mhMsg.get_source() + " with duplicate seqNo: " + mhMsg.get_seqNo()); return; } } seqNos.put(new Integer(mhMsg.get_source()), new Integer(mhMsg.get_seqNo())); if (to != spAddr && to != MoteIF.TOS_BCAST_ADDR && to != TOS_UART_ADDR) { log.debug("Dropping message not for me."); return; } HashSet promiscuousSet = (HashSet) idTable.get(new Integer(BCAST_ID)); HashSet listenerSet = (HashSet) idTable.get(new Integer(mhMsg.get_type())); if (listenerSet != null && promiscuousSet != null) { listenerSet.addAll(promiscuousSet); } else if (listenerSet == null && promiscuousSet != null) { listenerSet = promiscuousSet; } if (listenerSet == null) { log.debug("No Listener for type: " + mhMsg.get_type()); return; } for (Iterator it = listenerSet.iterator(); it.hasNext(); ) { MessageListener ml = (MessageListener) it.next(); ml.messageReceived(to, mhMsg); } }
/** * Filters a PMData's measurements by the modifier of each measurement... the format for the data * should be such for each modifier, there is parameter name/value pairs for each parameter name * supplied. the resulting list is a list of String arrays with the parameters * * @param data PMData: the PM data object * @param params String[]: the PM parameters * @return Hashtable: a table of string arrays, with the modifier as the key (or "?" if no * modifier) */ public static Hashtable processInclude(PMData data, String[] params) { if (data != null) { Hashtable ht = new Hashtable(); // for each measurement... PmMeasurement[] m = data.getMeasurementList(); for (int i = 0; i < m.length; i++) { if (m[i] == null) { continue; } String mod = m[i].getModifier(); if (mod == null) { mod = "?"; } String[] datum = (String[]) ht.get(mod); if (datum == null) { datum = new String[params.length]; for (int j = 0; j < params.length; j++) { datum[j] = ""; } } for (int j = 0; j < params.length; j++) { if (m[i].getParameterName().equals(params[j])) { datum[j] = m[i].getParameterValue(); } } ht.put(mod, datum); } return ht; } return null; }
// ------------------------------------------- public static String[] mergeArrays(String[] sa1, String[] sa2) { if (sa1 == null) { sa1 = new String[0]; } if (sa2 == null) { sa2 = new String[0]; } int sa1Len = sa1.length; int sa2Len = sa2.length; Hashtable tab = new Hashtable(sa1Len + sa2Len); for (int i = 0; i < sa1Len; i++) { tab.put(sa1[i], sa1[i]); } for (int i = 0; i < sa2Len; i++) { tab.put(sa2[i], sa2[i]); } int len = tab.size(); String[] res = new String[len]; int i = 0; for (Enumeration e = tab.keys(); e.hasMoreElements(); ) { String s = (String) e.nextElement(); res[i++] = s; } return res; }
/** * Filters a PMData's measurements by the modifier of each measurement... the format for the data * should be such for each modifier, there is parameter name/value pairs for each parameter name * supplied. the resulting list is a list of String arrays with the parameters * * @param data PMData: the PM data object * @param params String[]: the PM parameters * @param includeMod boolean: include modifier as first value if true * @return ArrayList: a list of string arrays */ public static ArrayList processByMod(PMData data, String[] params, boolean includeMod) { if (data != null) { // table for temporary storage of param lists... Hashtable ht = new Hashtable(); // for each param... for (int i = 0; i < params.length; i++) { PmMeasurement[] m = data.getMeasurementList(); for (int j = 0; j < m.length; j++) { if (m[j].getParameterName().equals(params[i])) { String mod = m[j].getModifier(); if (mod == null) { mod = "?"; } String[] datum = (String[]) ht.get(mod); int offset = (includeMod ? 1 : 0); if (datum == null) { if (includeMod) { datum = new String[params.length + 1]; datum[0] = mod; } else { datum = new String[params.length]; } for (int k = 0; k < params.length; k++) { datum[k + offset] = ""; } } datum[i + offset] = m[j].getParameterValue(); ht.put(mod, datum); } } } return new ArrayList(ht.values()); } return null; }
// Look up an older packet for responses // Return true if the packet is unique; false if we have seen it before private boolean rememberPacket(GnutellaPacket pkt) { GnutellaConnection gc = (GnutellaConnection) packetTable.get(pkt.getGUID()); if (gc != null) return false; if (DEBUG) System.err.println("**** REMEMBERING: " + pkt + " from " + pkt.getConnection()); packetTable.put(pkt.getGUID(), pkt.getConnection()); return true; }
private static toFrom checkArgs(Hashtable config) { if (config.get("type").equals("l2r")) { return toFrom.LOCAL2REMOTE; } else if (config.get("type").equals("r2l")) { return toFrom.REMOTE2LOCAL; } else { return toFrom.ERROR; } }
/** * This Method returns the 2D Array which is the list of the Items for the selected WorkOrder of * the Customer. * * @param workorderId - WorkOrder Id Foreign Key of WRK_ORDR_DETS table * @return Object[][] - 2D Array which is List of the Items for the WorkOrder */ public Object[][] getWorkOrderItems(long workorderId) throws RemoteException { WrkOrdrDets wrkordrdts_obj = new WrkOrdrDets(conn); RHCCBlgKeys blgkeys_obj = new RHCCBlgKeys(conn); Vector workorderdetList = wrkordrdts_obj.getProductList(workorderId); // Hashtable BSysList = (Hashtable) USFEnv.getBillSystems(); BlgSys blgsys = new BlgSys(); Hashtable BSysList = (Hashtable) blgsys.searchBlgSys(); Enumeration BSys = BSysList.keys(); // The 2-Dimensional array to hold the Items Billing System wise. Object[][] prodList = new Object[BSysList.size()][workorderdetList.size() + 1]; // The Number of Billing Systems are assumed to be equal to the // Static Load Billing Systems Hashtable size. The Billing Systems will // be in order starting from 1 and incrementing by one. for (int i = 0; i < BSysList.size(); i++) { // Set the 2D array to store the Billing System as the first element // of each row. prodList[i][0] = String.valueOf(i + 1); } // Loop throught the WorkOrder Items List and place them in the appropriate // positions in the 2D array. for (int j = 0; j < workorderdetList.size(); j++) { // Determine the Billing System of the Product Vector tmpVector = new Vector(); WrkOrdrDets workorderObj = (WrkOrdrDets) workorderdetList.elementAt(j); RHCCBlgKeys bkObj = blgkeys_obj.searchRHCCBlgKeys(((WrkOrdrDets) workorderdetList.elementAt(j)).getRBKID()); int bsid = (new Long(bkObj.getBsId())).intValue(); tmpVector.addElement(bkObj); tmpVector.addElement(workorderObj); // Based on the Billing System Id retreived place the Product Object // in the 2D array. int k = 1; while (prodList[bsid - 1][k] != null) { k = k + 1; } prodList[bsid - 1][k] = tmpVector; } // Return the 2D array return prodList; }
/** * Constructs a timezone adjustment record. * * @param d the Date at which the adjustment is going to take place. * @param offset the adjustment in number of seconds relative to the start time of the * SessionDescription with which this object is associated. * @return TimeZoneAdjustment */ public TimeZoneAdjustment createTimeZoneAdjustment(Date d, int offset) { ZoneField timeZoneAdjustmentImpl = new ZoneField(); try { Hashtable map = new Hashtable(); map.put(d, new Integer(offset)); timeZoneAdjustmentImpl.setZoneAdjustments(map); } catch (SdpException s) { s.printStackTrace(); } return timeZoneAdjustmentImpl; }
/** * Implements CallListener.callEnded. Stops sounds that are playing at the moment if there're any. * Removes the call panel and disables the hangup button. */ public void callEnded(CallEvent event) { Call sourceCall = event.getSourceCall(); NotificationManager.stopSound(NotificationManager.BUSY_CALL); NotificationManager.stopSound(NotificationManager.INCOMING_CALL); NotificationManager.stopSound(NotificationManager.OUTGOING_CALL); if (activeCalls.get(sourceCall) != null) { CallPanel callPanel = (CallPanel) activeCalls.get(sourceCall); this.removeCallPanelWait(callPanel); } }
public void setParameters(Hashtable params) { setName("TiniBogusLocationResource"); setScalingFactor((long) Constants.Geophysical.DEGTOBILLIONTHS); attrtable = params; if (params != null) { if (params.get("Latitude") != null) { String pstr = (String) params.get("Latitude"); Double temp = new Double(pstr); latitude = temp.doubleValue(); } if (params.get("Longitude") != null) { String pstr = (String) params.get("Longitude"); Double temp = new Double(pstr); longitude = temp.doubleValue(); } if (params.get("Heading") != null) { String pstr = (String) params.get("Heading"); Double temp = new Double(pstr); heading = temp.doubleValue(); } if (params.get("Altitude") != null) { String pstr = (String) params.get("Altitude"); Double temp = new Double(pstr); altitude = temp.doubleValue(); } } }
public String getLegend(String[] cityMap, int[] POIs) { char[] ans = new char[POIs.length]; Hashtable hash = new Hashtable(); for (int i = 0; i < cityMap.length; i++) { for (int j = 0; j < cityMap[i].length(); j++) { char cur = cityMap[i].charAt(j); int k = 1; if (!hash.containsKey(cur)) { hash.put(cur, k); } else { int prev = (int) hash.get(cur); hash.remove(cur); hash.put(cur, prev + 1); } } } Enumeration vals = hash.keys(); while (vals.hasMoreElements()) { char c = (char) vals.nextElement(); for (int i = 0; i < POIs.length; i++) { if (hash.get(c) == POIs[i]) { ans[i] = c; } } } String str = new String(ans); return str; }
/** * Implements CallListener.incomingCallReceived. When a call is received creates a call panel and * adds it to the main tabbed pane and plays the ring phone sound to the user. */ public void incomingCallReceived(CallEvent event) { Call sourceCall = event.getSourceCall(); CallPanel callPanel = new CallPanel(this, sourceCall, GuiCallParticipantRecord.INCOMING_CALL); mainFrame.addCallPanel(callPanel); if (mainFrame.getState() == JFrame.ICONIFIED) mainFrame.setState(JFrame.NORMAL); if (!mainFrame.isVisible()) mainFrame.setVisible(true); mainFrame.toFront(); this.callButton.setEnabled(true); this.hangupButton.setEnabled(true); NotificationManager.fireNotification( NotificationManager.INCOMING_CALL, null, "Incoming call recived from: " + sourceCall.getCallParticipants().next()); activeCalls.put(sourceCall, callPanel); this.setCallPanelVisible(true); }
// add new Chef public void add(Chef chef) { _entries.addElement(chef); int index = _entries.size() - 1; _chefsByName.put(chef.getName(), new Integer(index)); // tell TableView to update fireTableRowsInserted(index, index); fireTableRowsUpdated(index, index); }
/** * Removes the given call panel tab. * * @param callPanel the CallPanel to remove */ private void removeCallPanel(CallPanel callPanel) { if (callPanel.getCall() != null && activeCalls.contains(callPanel.getCall())) { this.activeCalls.remove(callPanel.getCall()); } mainFrame.removeCallPanel(callPanel); updateButtonsStateAccordingToSelectedPanel(); }
/** replaces the font (PS name) if necessary and returns the new name */ private static String replacePSFont(String font) { String result; result = font; // do we have to replace it? -> same style, size if (m_PSFontReplacement.containsKey(font)) { result = m_PSFontReplacement.get(font).toString(); if (DEBUG) System.out.println( Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_First") + font + Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_Second") + result + Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_Third")); } return result; }
public static String format(String message, Object[] args) { MessageFormat mf; String msg; try { mf = (MessageFormat) _formats.get(message); if (mf == null) { try { msg = _messages.getString(message); } catch (MissingResourceException except) { return message; } mf = new MessageFormat(msg); _formats.put(message, mf); } return mf.format(args); } catch (Exception except) { return "An internal error occured while processing message " + message; } }
/** * Reads the children of an XML element and matches them to properties of a bean. * * @param ob The bean to receive the values * @param element The element the corresponds to the bean * @throws IOException If there is an error reading the document */ public void readObject(Object ob, Element element) throws IOException { // If the object is null, skip the element if (ob == null) { return; } try { BeanInfo info = (BeanInfo) beanCache.get(ob.getClass()); if (info == null) { // Get the bean info for the object info = Introspector.getBeanInfo(ob.getClass(), Object.class); beanCache.put(ob.getClass(), info); } // Get the object's properties PropertyDescriptor[] props = info.getPropertyDescriptors(); // Get the attributes of the node NamedNodeMap attrs = element.getAttributes(); // Get the children of the XML element NodeList nodes = element.getChildNodes(); int numNodes = nodes.getLength(); for (int i = 0; i < props.length; i++) { // Treat indexed properties a little differently if (props[i] instanceof IndexedPropertyDescriptor) { readIndexedProperty(ob, (IndexedPropertyDescriptor) props[i], nodes, attrs); } else { readProperty(ob, props[i], nodes, attrs); } } } catch (IntrospectionException exc) { throw new IOException( "Error getting bean info for " + ob.getClass().getName() + ": " + exc.toString()); } }
/** output if we're in debug mode */ static { if (DEBUG) System.err.println( PostscriptGraphics.class.getName() + Messages.getInstance().getString("PostscriptGraphics_Error_Text")); // get font replacements m_PSFontReplacement = new Hashtable(); m_PSFontReplacement.put( "SansSerif.plain", "Helvetica.plain"); // SansSerif.plain is displayed as Courier in GV??? m_PSFontReplacement.put( "Dialog.plain", "Helvetica.plain"); // dialog is a Sans Serif font, but GV displays it as Courier??? m_PSFontReplacement.put( "Microsoft Sans Serif", "Helvetica.plain"); // MS Sans Serif is a Sans Serif font (hence the name!), but GV displays // it as Courier??? m_PSFontReplacement.put( "MicrosoftSansSerif", "Helvetica.plain"); // MS Sans Serif is a Sans Serif font (hence the name!), but GV displays // it as Courier??? }
{ //create out of bounds exception emailList.get(-1) if (emailList.get(i) == emailList.get(i-1)) { dupEmailCount++; } else { //insert domain email, dupEmailCount into hashtable domainCount.put(emailList.get(i), dupEmailCount); dupEmailCount = 0; } }
static void writeUsersToFile() { userWriter = createCSVFile("Users.dat"); // write the list of users to file System.out.println("Users that are both seller and buyer BUT different ratings: "); Enumeration<String> keys = userList.keys(); while (keys.hasMoreElements()) { String curUserID = keys.nextElement(); String curUser[] = userList.get(curUserID); String userRow = wrapQuotations(curUser[0]) + "," + curUser[1] + "," + curUser[2] + "," + wrapQuotations(curUser[3]) + "," + wrapQuotations(curUser[4]); writeLine(userWriter, userRow); // if(curUser[1] != null && curUser[2] != null && !curUser[1].equals(curUser[2])) // System.out.println(curUser[0]); } System.out.println("----end different ratings----"); // System.out.println("The users that are both seller and buyer: "); // Enumeration<String> both = bothSellerAndBuyer.elements(); // while(both.hasMoreElements()) { // System.out.println(both.nextElement()); // } // System.out.println("----end both----"); try { userWriter.flush(); userWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
/** * Implements ChangeListener.stateChanged. Enables the hangup button if ones selects a tab in the * main tabbed pane that contains a call panel. */ public void stateChanged(ChangeEvent e) { this.updateButtonsStateAccordingToSelectedPanel(); Component selectedPanel = mainFrame.getSelectedTab(); if (selectedPanel == null || !(selectedPanel instanceof CallPanel)) { Iterator callPanels = activeCalls.values().iterator(); while (callPanels.hasNext()) { CallPanel callPanel = (CallPanel) callPanels.next(); callPanel.removeDialogs(); } } }
// Forward an incoming packet to the corresponding source private void forwardPacket(GnutellaPacket pkt) { GnutellaConnection gc; gc = (GnutellaConnection) packetTable.get(pkt.getGUID()); if (gc == null) { if (VERBOSE) System.err.println("-- Received reply with no request: " + pkt); return; } if (DEBUG) System.err.println("**** REPLYING: " + pkt + " to " + gc); if ((pkt.ttl == 0) || (--pkt.ttl == 0)) { if (VERBOSE) System.err.println("-- Dropping packet, TTL expired: " + pkt); } pkt.hops++; gc.enqueue_lossy(pkt); }
private void doClean(timerEvent ev) { // Cleaner event if (VERBOSE) System.err.println("-- Cleaning up packetTable"); // Might cause some recent packets to be dropped packetTable.clear(); if (VERBOSE) { Runtime r = Runtime.getRuntime(); System.err.println( "TOTAL: " + r.totalMemory() / 1024 + "KB FREE: " + r.freeMemory() / 1024 + "KB"); } // Reregister timer event timer.registerEvent(CLEAN_TIMER_FREQUENCY, ev, mySink); }
public Hashtable processData( ServletInputStream is, String boundary, String saveInDir, int clength) throws IllegalArgumentException, IOException { if (is == null) throw new IllegalArgumentException("InputStream"); if (boundary == null || boundary.trim().length() < 1) throw new IllegalArgumentException("\"" + boundary + "\" is an illegal boundary indicator"); boundary = "--" + boundary; StringTokenizer stLine = null, stFields = null; FileInfo fileInfo = null; Hashtable dataTable = new Hashtable(5); String line = null, field = null, paramName = null; boolean saveFiles = (saveInDir != null && saveInDir.trim().length() > 0); boolean isFile = false; if (saveFiles) { // Create the required directory (including parent dirs) File f = new File(saveInDir); f.mkdirs(); } line = getLine(is); if (line == null || !line.startsWith(boundary)) throw new IOException("Boundary not found; boundary = " + boundary + ", line = " + line); while (line != null) { if (line == null || !line.startsWith(boundary)) return dataTable; line = getLine(is); if (line == null) return dataTable; stLine = new StringTokenizer(line, ";\r\n"); if (stLine.countTokens() < 2) throw new IllegalArgumentException("Bad data in second line"); line = stLine.nextToken().toLowerCase(); if (line.indexOf("form-data") < 0) throw new IllegalArgumentException("Bad data in second line"); stFields = new StringTokenizer(stLine.nextToken(), "=\""); if (stFields.countTokens() < 2) throw new IllegalArgumentException("Bad data in second line"); fileInfo = new FileInfo(); stFields.nextToken(); paramName = stFields.nextToken(); isFile = false; if (stLine.hasMoreTokens()) { field = stLine.nextToken(); stFields = new StringTokenizer(field, "=\""); if (stFields.countTokens() > 1) { if (stFields.nextToken().trim().equalsIgnoreCase("filename")) { fileInfo.name = paramName; String value = stFields.nextToken(); if (value != null && value.trim().length() > 0) { fileInfo.clientFileName = value; isFile = true; } else { line = getLine(is); // Skip "Content-Type:" line line = getLine(is); // Skip blank line line = getLine(is); // Skip blank line line = getLine(is); // Position to boundary line continue; } } } else if (field.toLowerCase().indexOf("filename") >= 0) { line = getLine(is); // Skip "Content-Type:" line line = getLine(is); // Skip blank line line = getLine(is); // Skip blank line line = getLine(is); // Position to boundary line continue; } } boolean skipBlankLine = true; if (isFile) { line = getLine(is); if (line == null) return dataTable; if (line.trim().length() < 1) skipBlankLine = false; else { stLine = new StringTokenizer(line, ": "); if (stLine.countTokens() < 2) throw new IllegalArgumentException("Bad data in third line"); stLine.nextToken(); // Content-Type fileInfo.fileContentType = stLine.nextToken(); } } if (skipBlankLine) { line = getLine(is); if (line == null) return dataTable; } if (!isFile) { line = getLine(is); if (line == null) return dataTable; dataTable.put(paramName, line); // If parameter is dir, change saveInDir to dir if (paramName.equals("dir")) saveInDir = line; line = getLine(is); continue; } try { UplInfo uplInfo = new UplInfo(clength); UploadMonitor.set(fileInfo.clientFileName, uplInfo); OutputStream os = null; String path = null; if (saveFiles) os = new FileOutputStream(path = getFileName(saveInDir, fileInfo.clientFileName)); else os = new ByteArrayOutputStream(ONE_MB); boolean readingContent = true; byte previousLine[] = new byte[2 * ONE_MB]; byte temp[] = null; byte currentLine[] = new byte[2 * ONE_MB]; int read, read3; if ((read = is.readLine(previousLine, 0, previousLine.length)) == -1) { line = null; break; } while (readingContent) { if ((read3 = is.readLine(currentLine, 0, currentLine.length)) == -1) { line = null; uplInfo.aborted = true; break; } if (compareBoundary(boundary, currentLine)) { os.write(previousLine, 0, read - 2); line = new String(currentLine, 0, read3); break; } else { os.write(previousLine, 0, read); uplInfo.currSize += read; temp = currentLine; currentLine = previousLine; previousLine = temp; read = read3; } // end else } // end while os.flush(); os.close(); if (!saveFiles) { ByteArrayOutputStream baos = (ByteArrayOutputStream) os; fileInfo.setFileContents(baos.toByteArray()); } else fileInfo.file = new File(path); dataTable.put(paramName, fileInfo); uplInfo.currSize = uplInfo.totalSize; } // end try catch (IOException e) { throw e; } } return dataTable; }
static UplInfo getInfo(String fName) { UplInfo info = (UplInfo) uploadTable.get(fName); return info; }
static void set(String fName, UplInfo info) { uploadTable.put(fName, info); }
static void remove(String fName) { uploadTable.remove(fName); }
/** * Handles the <tt>ActionEvent</tt> generated when user presses one of the buttons in this panel. */ public void actionPerformed(ActionEvent evt) { JButton button = (JButton) evt.getSource(); String buttonName = button.getName(); if (buttonName.equals("call")) { Component selectedPanel = mainFrame.getSelectedTab(); // call button is pressed over an already open call panel if (selectedPanel != null && selectedPanel instanceof CallPanel && ((CallPanel) selectedPanel).getCall().getCallState() == CallState.CALL_INITIALIZATION) { NotificationManager.stopSound(NotificationManager.BUSY_CALL); NotificationManager.stopSound(NotificationManager.INCOMING_CALL); CallPanel callPanel = (CallPanel) selectedPanel; Iterator participantPanels = callPanel.getParticipantsPanels(); while (participantPanels.hasNext()) { CallParticipantPanel panel = (CallParticipantPanel) participantPanels.next(); panel.setState("Connecting"); } Call call = callPanel.getCall(); answerCall(call); } // call button is pressed over the call list else if (selectedPanel != null && selectedPanel instanceof CallListPanel && ((CallListPanel) selectedPanel).getCallList().getSelectedIndex() != -1) { CallListPanel callListPanel = (CallListPanel) selectedPanel; GuiCallParticipantRecord callRecord = (GuiCallParticipantRecord) callListPanel.getCallList().getSelectedValue(); String stringContact = callRecord.getParticipantName(); createCall(stringContact); } // call button is pressed over the contact list else if (selectedPanel != null && selectedPanel instanceof ContactListPanel) { // call button is pressed when a meta contact is selected if (isCallMetaContact) { Object[] selectedContacts = mainFrame.getContactListPanel().getContactList().getSelectedValues(); Vector telephonyContacts = new Vector(); for (int i = 0; i < selectedContacts.length; i++) { Object o = selectedContacts[i]; if (o instanceof MetaContact) { Contact contact = ((MetaContact) o).getDefaultContact(OperationSetBasicTelephony.class); if (contact != null) telephonyContacts.add(contact); else { new ErrorDialog( this.mainFrame, Messages.getI18NString("warning").getText(), Messages.getI18NString( "contactNotSupportingTelephony", new String[] {((MetaContact) o).getDisplayName()}) .getText()) .showDialog(); } } } if (telephonyContacts.size() > 0) createCall(telephonyContacts); } else if (!phoneNumberCombo.isComboFieldEmpty()) { // if no contact is selected checks if the user has chosen // or has // writen something in the phone combo box String stringContact = phoneNumberCombo.getEditor().getItem().toString(); createCall(stringContact); } } else if (selectedPanel != null && selectedPanel instanceof DialPanel) { String stringContact = phoneNumberCombo.getEditor().getItem().toString(); createCall(stringContact); } } else if (buttonName.equalsIgnoreCase("hangup")) { Component selectedPanel = this.mainFrame.getSelectedTab(); if (selectedPanel != null && selectedPanel instanceof CallPanel) { NotificationManager.stopSound(NotificationManager.BUSY_CALL); NotificationManager.stopSound(NotificationManager.INCOMING_CALL); NotificationManager.stopSound(NotificationManager.OUTGOING_CALL); CallPanel callPanel = (CallPanel) selectedPanel; Call call = callPanel.getCall(); if (removeCallTimers.containsKey(callPanel)) { ((Timer) removeCallTimers.get(callPanel)).stop(); removeCallTimers.remove(callPanel); } removeCallPanel(callPanel); if (call != null) { ProtocolProviderService pps = call.getProtocolProvider(); OperationSetBasicTelephony telephony = mainFrame.getTelephonyOpSet(pps); Iterator participants = call.getCallParticipants(); while (participants.hasNext()) { try { // now we hang up the first call participant in the // call telephony.hangupCallParticipant((CallParticipant) participants.next()); } catch (OperationFailedException e) { logger.error("Hang up was not successful: " + e); } } } } } else if (buttonName.equalsIgnoreCase("minimize")) { JCheckBoxMenuItem hideCallPanelItem = mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem(); if (!hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(true); this.setCallPanelVisible(false); } else if (buttonName.equalsIgnoreCase("restore")) { JCheckBoxMenuItem hideCallPanelItem = mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem(); if (hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(false); this.setCallPanelVisible(true); } }