/** Shut down all connections and clean up. */ public void shutDown() { // inform all associated streams synchronized (connectionTable) { // return if multiplexer already officially dead if (!alive) return; alive = false; Enumeration<MultiplexConnectionInfo> enum_ = connectionTable.elements(); while (enum_.hasMoreElements()) { MultiplexConnectionInfo info = enum_.nextElement(); info.in.disconnect(); info.out.disconnect(); } connectionTable.clear(); numConnections = 0; } // close underlying connection, if possible (and not already done) try { in.close(); } catch (IOException e) { } try { out.close(); } catch (IOException e) { } }
/** * Loads the keystore from the Keychain. * * @param stream Ignored - here for API compatibility. * @param password Ignored - if user needs to unlock keychain Security framework will post any * dialogs. * @exception IOException if there is an I/O or format problem with the keystore data * @exception NoSuchAlgorithmException if the algorithm used to check the integrity of the * keystore cannot be found * @exception CertificateException if any of the certificates in the keystore could not be loaded */ public void engineLoad(InputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException { permissionCheck(); // Release any stray keychain references before clearing out the entries. synchronized (entries) { for (Enumeration<String> e = entries.keys(); e.hasMoreElements(); ) { String alias = e.nextElement(); Object entry = entries.get(alias); if (entry instanceof TrustedCertEntry) { if (((TrustedCertEntry) entry).certRef != 0) { _releaseKeychainItemRef(((TrustedCertEntry) entry).certRef); } } else { KeyEntry keyEntry = (KeyEntry) entry; if (keyEntry.chain != null) { for (int i = 0; i < keyEntry.chain.length; i++) { if (keyEntry.chainRefs[i] != 0) { _releaseKeychainItemRef(keyEntry.chainRefs[i]); } } if (keyEntry.keyRef != 0) { _releaseKeychainItemRef(keyEntry.keyRef); } } } } entries.clear(); _scanKeychain(); } }
/** Removes all elements from the iterator-list. */ public void removeAll() { if (!readonly) { synchronized (this) { data.removeAllElements(); hash.clear(); } } }
public void stop() { timer_running = false; if (refresher_task != null) refresher_task.cancel(); timer.cancel(); groups.clear(); // provide another refresh tools in case the channel gets reconnected // timer=new Timer(); // refresher_task=new Refresher(); }
public void run() { // each file is processed into a local hash table and then merged with the global results // this will cause much less contention on the global table, but still avoids a sequential // update Hashtable<String, Integer> local_results = new Hashtable<String, Integer>(WordCountJ.HASH_SIZE, WordCountJ.LF); // grab a file to work on String cf; while ((cf = files.poll()) != null) { try { BufferedReader input = new BufferedReader(new FileReader(cf)); String text; // well go line-by-line... maybe this is not the fastest while ((text = input.readLine()) != null) { // parse words Matcher matcher = pattern.matcher(text); while (matcher.find()) { String word = matcher.group(1); if (local_results.containsKey(word)) { local_results.put(word, 1 + local_results.get(word)); } else { local_results.put(word, 1); } } } input.close(); } catch (Exception e) { System.out.println(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); return; } // merge local hashmap with shared one,could have a // seperate thread do this but that might be cheating Iterator<Map.Entry<String, Integer>> updates = local_results.entrySet().iterator(); while (updates.hasNext()) { Map.Entry<String, Integer> kv = updates.next(); String k = kv.getKey(); Integer v = kv.getValue(); synchronized (results) { if (results.containsKey(k)) { results.put(k, v + results.get(k)); } else { results.put(k, v); } } } local_results.clear(); } }
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); }
/** * does the same as the constructor * * @param language relative path. would be "help/en" currently */ public void reInit(String language) { System.out.println("HelpLoader reloading..."); if (this.language == null) { System.out.println( "language == null! Do you have an empty ~/.jasmin? Delete it!" + " And please tell us about this at [email protected]"); } else if (this.language.equals(language)) { System.out.println("but the same language all over again? nope!"); return; } helpcache.clear(); this.language = language; this.helpcache = new Hashtable<>(); init(); System.out.println("... done\n"); }
/** Supprime tous les éléments de l'ensemble. */ public void vider() { table.clear(); }
/** * Stores this keystore to the given output stream, and protects its integrity with the given * password. * * @param stream Ignored. the output stream to which this keystore is written. * @param password the password to generate the keystore integrity check * @exception IOException if there was an I/O problem with data * @exception NoSuchAlgorithmException if the appropriate data integrity algorithm could not be * found * @exception CertificateException if any of the certificates included in the keystore data could * not be stored */ public void engineStore(OutputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException { permissionCheck(); // Delete items that do have a keychain item ref. for (Enumeration<String> e = deletedEntries.keys(); e.hasMoreElements(); ) { String alias = e.nextElement(); Object entry = deletedEntries.get(alias); if (entry instanceof TrustedCertEntry) { if (((TrustedCertEntry) entry).certRef != 0) { _removeItemFromKeychain(((TrustedCertEntry) entry).certRef); _releaseKeychainItemRef(((TrustedCertEntry) entry).certRef); } } else { Certificate certElem; KeyEntry keyEntry = (KeyEntry) entry; if (keyEntry.chain != null) { for (int i = 0; i < keyEntry.chain.length; i++) { if (keyEntry.chainRefs[i] != 0) { _removeItemFromKeychain(keyEntry.chainRefs[i]); _releaseKeychainItemRef(keyEntry.chainRefs[i]); } } if (keyEntry.keyRef != 0) { _removeItemFromKeychain(keyEntry.keyRef); _releaseKeychainItemRef(keyEntry.keyRef); } } } } // Add all of the certs or keys in the added entries. // No need to check for 0 refs, as they are in the added list. for (Enumeration<String> e = addedEntries.keys(); e.hasMoreElements(); ) { String alias = e.nextElement(); Object entry = addedEntries.get(alias); if (entry instanceof TrustedCertEntry) { TrustedCertEntry tce = (TrustedCertEntry) entry; Certificate certElem; certElem = tce.cert; tce.certRef = addCertificateToKeychain(alias, certElem); } else { KeyEntry keyEntry = (KeyEntry) entry; if (keyEntry.chain != null) { for (int i = 0; i < keyEntry.chain.length; i++) { keyEntry.chainRefs[i] = addCertificateToKeychain(alias, keyEntry.chain[i]); } keyEntry.keyRef = _addItemToKeychain(alias, false, keyEntry.protectedPrivKey, keyEntry.password); } } } // Clear the added and deletedEntries hashtables here, now that we're done with the updates. // For the deleted entries, we freed up the native references above. deletedEntries.clear(); addedEntries.clear(); }
public void clear() { uiList.clear(); uiElementsList.clear(); elementsAndPanels.clear(); numberOfRequiredFields = 0; }
public void destroy() { timer_running = false; timer.cancel(); groups.clear(); }
/** * Creates a vm program. If the given file is a dir, creates a program composed of the vm files in * the dir. The vm files are scanned twice: in the first scan a symbol table (that maps function & * label names into addresses) is built. In the second scan, the instructions array is built. * Throws ProgramException if an error occurs while loading the program. */ public void loadProgram(String fileName) throws ProgramException { File file = new File(fileName); if (!file.exists()) throw new ProgramException("cannot find " + fileName); File[] files; if (file.isDirectory()) { files = file.listFiles(new HackFileFilter(".vm")); if (files == null || files.length == 0) throw new ProgramException("No vm files found in " + fileName); } else files = new File[] {file}; if (displayChanges) gui.showMessage("Loading..."); // First scan staticRange.clear(); functions.clear(); builtInAccessStatus = BUILTIN_ACCESS_UNDECIDED; Hashtable symbols = new Hashtable(); nextPC = 0; for (int i = 0; i < files.length; i++) { String name = files[i].getName(); String className = name.substring(0, name.indexOf(".")); // put some dummy into static range - just to tell the function // getAddress in the second pass which classes exist staticRange.put(className, new Boolean(true)); try { updateSymbolTable(files[i], symbols, functions); } catch (ProgramException pe) { if (displayChanges) gui.hideMessage(); throw new ProgramException(name + ": " + pe.getMessage()); } } boolean addCallBuiltInSysInit = false; if ((file.isDirectory() || symbols.get("Main.main") != null) && symbols.get("Sys.init") == null) { // If the program is in multiple files or there's a Main.main // function it is assumed that it should be run by calling Sys.init. // If no Sys.init is found, add an invisible line with a call // to Sys.init to start on - the builtin version will be called. addCallBuiltInSysInit = true; getAddress("Sys.init"); // confirm calling the built-in Sys.init ++nextPC; // A "call Sys.init 0" line will be added } instructions = new VMEmulatorInstruction[nextPC + 4]; // Second scan nextPC = 0; currentStaticIndex = Definitions.VAR_START_ADDRESS; for (int i = 0; i < files.length; i++) { String name = files[i].getName(); String className = name.substring(0, name.indexOf(".")); largestStaticIndex = -1; int[] range = new int[2]; range[0] = currentStaticIndex; try { // functions is not passed as an argument since it is accessed // through getAddress() buildProgram(files[i], symbols); } catch (ProgramException pe) { if (displayChanges) gui.hideMessage(); throw new ProgramException(name + ": " + pe.getMessage()); } currentStaticIndex += largestStaticIndex + 1; range[1] = currentStaticIndex - 1; staticRange.put(className, range); } instructionsLength = visibleInstructionsLength = nextPC; if (builtInAccessStatus == BUILTIN_ACCESS_AUTHORIZED) { // Add some "invisible" code in the end to make everything work instructionsLength += 4; if (addCallBuiltInSysInit) { instructionsLength += 1; } short indexInInvisibleCode = 0; // Add a jump to the end (noone should get here since // both calls to built-in functions indicate that // that this is a function-based program and not a script // a-la proj7, but just to be on the safe side...). instructions[nextPC] = new VMEmulatorInstruction( HVMInstructionSet.GOTO_CODE, (short) instructionsLength, indexInInvisibleCode); instructions[nextPC].setStringArg("afterInvisibleCode"); nextPC++; // Add a small infinite loop for built-in // methods to call (for example when Sys.halt is // called it must call a non-built-in infinite loop // because otherwise the current script would not // finish running - a problem for the OS tests. instructions[nextPC] = new VMEmulatorInstruction(HVMInstructionSet.LABEL_CODE, (short) -1); instructions[nextPC].setStringArg("infiniteLoopForBuiltIns"); nextPC++; infiniteLoopForBuiltInsAddress = nextPC; instructions[nextPC] = new VMEmulatorInstruction(HVMInstructionSet.GOTO_CODE, nextPC, ++indexInInvisibleCode); instructions[nextPC].setStringArg("infiniteLoopForBuiltIns"); nextPC++; if (addCallBuiltInSysInit) { // Add a call to the built-in Sys.init instructions[nextPC] = new VMEmulatorInstruction( HVMInstructionSet.CALL_CODE, getAddress("Sys.init"), (short) 0, ++indexInInvisibleCode); instructions[nextPC].setStringArg("Sys.init"); startAddress = nextPC; nextPC++; } // Add the label that the first invisible code line jumps to instructions[nextPC] = new VMEmulatorInstruction(HVMInstructionSet.LABEL_CODE, (short) -1); instructions[nextPC].setStringArg("afterInvisibleCode"); nextPC++; } if (!addCallBuiltInSysInit) { Short sysInitAddress = (Short) symbols.get("Sys.init"); if (sysInitAddress == null) // Single file, no Sys.init - start at 0 startAddress = 0; else // Implemented Sys.init - start there startAddress = sysInitAddress.shortValue(); } if (displayChanges) gui.hideMessage(); nextPC = startAddress; setGUIContents(); notifyProgramListeners(ProgramEvent.LOAD, fileName); }