/** * checks if a particular chained task is ready for processing * * @param chain_id the id this process is part off order * @param process_id the process_id * @return * @throws java.sql.SQLException */ public boolean canExecute(int chain_id, int process_id) throws SQLException { boolean isReady = false; try (AutoCloseableDBConnection c = new AutoCloseableDBConnection(); PreparedStatement getChain = c.prepareStatement( "SELECT process_id,busy FROM chain_activities WHERE (chain_id=?) ORDER BY process_id")) { getChain.setInt(1, chain_id); LinkedHashMap<Integer, Boolean> clearedToRunMap = new LinkedHashMap<>(); try (ResultSet executeQuery = getChain.executeQuery()) { while (executeQuery.next()) { clearedToRunMap.put(executeQuery.getInt("process_id"), executeQuery.getBoolean("busy")); } } int predecessingProcess = -1; for (Entry<Integer, Boolean> aProcess : clearedToRunMap.entrySet()) { if (aProcess.getKey() == process_id) { break; } else { predecessingProcess = aProcess.getKey(); // check if this process is already busy } } if (predecessingProcess == -1) { // then there's no predecessing process, meaning it can be run for sure isReady = true; } else if (clearedToRunMap.get(predecessingProcess)) { try ( // then it's busy, but it can be that it's not yet done ! ProcessDAO pdao = ProcessDAO.getInstance()) { isReady = pdao.isCompletedProcess(process_id); } } } return isReady; }
public void stopSingleSongs() { for (Entry<Song, PlayerController> entry : singleSongPlayers.entrySet()) { PlayerController controller = entry.getValue(); controller.close(true); } singleSongPlayers.clear(); }
public void setStaticUserProperties(final Map<String, String> staticUserPropertiesMap) { // trim map staticUserProperties = new HashMap<String, String>(); for (final Entry<String, String> entry : staticUserPropertiesMap.entrySet()) { staticUserProperties.put(entry.getKey().trim(), entry.getValue().trim()); } }
/** * Test with a subtitle with multiple format to read. * * @throws IOException if there was an I/O error. */ @Test public void testMultipleFormatSubtitle() throws IOException { final SubtitleFormat subtitleFormat = mock(SubtitleFormat.class); final SubtitleReader subtitleReader = mock(SubtitleReader.class); final SubtitleFile subtitleFile = mock(SubtitleFile.class); final Path file = subtitleFolder.newFile("single.srt").toPath(); when(subtitleFormatManager.getFormatByPath(file)) .thenReturn(new HashSet<>(Arrays.asList(subtitleFormat, mock(SubtitleFormat.class)))); when(userPrompt.askChoice( anyCollectionOf(SubtitleFormat.class), eq(TRANSLATION_KEY.chooseSubtitleFormat()), eq(file))) .thenReturn(subtitleFormat); when(subtitleFormat.getReader()).thenReturn(subtitleReader); when(subtitleReader.readFile(file)).thenReturn(subtitleFile); final Map<SubtitleFile, SubtitleFormat> subtitles = subtitleProvider.loadSubtitles(file); assertEquals(1, subtitles.size()); final Entry<SubtitleFile, SubtitleFormat> loaded = subtitles.entrySet().iterator().next(); assertEquals(subtitleFile, loaded.getKey()); assertEquals(subtitleFormat, loaded.getValue()); verify(userPrompt) .askChoice( anyCollectionOf(SubtitleFormat.class), eq(TRANSLATION_KEY.chooseSubtitleFormat()), eq(file)); }
/** Saves the defaults and missing values. */ public void save() { if (!this.folder.exists()) { this.folder.mkdirs(); } if (!this.file.exists()) { try { this.file.createNewFile(); } catch (Exception e) { e.printStackTrace(); } } this.config = YamlConfiguration.loadConfiguration(this.file); for (Entry<String, Object> en : this.defaults.entrySet()) { if (!this.config.contains(en.getKey())) { ConfigUtils.setObject(this.config, en.getKey(), en.getValue()); } } try { this.config.save(this.file); } catch (Exception e) { e.printStackTrace(); } }
@Override @SuppressWarnings("unchecked") public <T> T promptChoice(final String message, final Map<String, T> options) { println(message); List<Entry<String, T>> entries = new ArrayList<Map.Entry<String, T>>(); entries.addAll(options.entrySet()); Object result = InvalidInput.INSTANCE; while (result instanceof InvalidInput) { int count = 1; println(); for (Entry<String, T> entry : entries) { println(" " + count + " - [" + entry.getKey() + "]"); count++; } println(); String input = prompt("Choose an option by typing the name or number of the selection: "); if (options.containsKey(input)) { result = options.get(input); } else if (input.matches("[0-9]+")) { int choice = Integer.parseInt(input); if ((choice > 0) && (choice <= options.size())) { result = entries.get(choice - 1).getValue(); } } } return (T) result; }
/** {@inheritDoc} */ @Override public void setup(OAuth2Settings settings) throws OAuth2SettingsException { /* validate supplied settings */ if (settings == null) { throw new OAuth2SettingsException("Missing settings."); } if (Utils.isNullOrEmpty(settings.getTokenUri())) { throw new OAuth2SettingsException("Token server URI missing."); } else { tokenServer = settings.getTokenUri(); } if (Utils.isNullOrEmpty(settings.getRefreshToken())) { throw new OAuth2SettingsException("Refresh token cannot be null or empty."); } if (Utils.isNullOrEmpty(settings.getClientId())) { throw new OAuth2SettingsException("Client ID cannot be null or empty."); } if (settings.getClientSecret() != null) { tokenParams.put("client_secret", settings.getClientSecret()); } if (!Utils.isNullOrEmpty(settings.getScope())) { tokenParams.put("scope", settings.getScope()); } /* populate token request params */ tokenParams.put("client_id", settings.getClientId()); tokenParams.put("grant_type", "refresh_token"); tokenParams.put("refresh_token", settings.getRefreshToken()); for (Entry<String, String> entry : settings.getExtraTokenParams().entrySet()) { if (!tokenParams.containsKey(entry.getKey())) { tokenParams.put(entry.getKey(), entry.getValue()); } } }
private static Map<String, Double> sortByComparator( Map<String, Double> map, final boolean order) { List<Entry<String, Double>> list = new LinkedList<Entry<String, Double>>(map.entrySet()); // Sorting the list based on values Collections.sort( list, new Comparator<Entry<String, Double>>() { public int compare(Entry<String, Double> o1, Entry<String, Double> o2) { if (order) { return o1.getValue().compareTo(o2.getValue()); } else { return o2.getValue().compareTo(o1.getValue()); } } }); // Maintaining insertion order with the help of LinkedList Map<String, Double> sortedMap = new LinkedHashMap<String, Double>(); for (Entry<String, Double> entry : list) { sortedMap.put(entry.getKey(), entry.getValue()); } return sortedMap; }
public void loadProperties(InputStream in) throws IOException { Properties props = new Properties(); props.load(in); for (Entry<Object, Object> prop : props.entrySet()) { properties.put(prop.getKey().toString(), prop.getValue().toString()); } }
/** * Computes the m matrix with one setup (you should execute it with the other setup too). * * @param root The ancestor of {@code w}, {@code x} nodes. ({@code v}). * @param d Distance matrix. * @param w The left node of {@code root}. * @param x The right node of {@code root}. * @param rightM The subtable for the right m. * @param ret The result table. * @param leftKeys The leaves of {@code w} tree. * @param rightKeys The leaves of {@code x} tree. */ private void computeM( final DendrogramNode root, final Map<RowKey, DistanceVectorDataValue> d, final DendrogramNode w, final DendrogramNode x, final Map<Triple<DendrogramNode, RowKey, RowKey>, Number> rightM, final Map<Triple<DendrogramNode, RowKey, RowKey>, Number> ret, final Set<RowKey> leftKeys, final Set<RowKey> rightKeys) { final Map<RowKey, Map<RowKey, Number>> t = computeT(w, ret, d, leftKeys, rightKeys); for (final Entry<RowKey, Map<RowKey, Number>> entry : t.entrySet()) { for (final Entry<RowKey, Number> innerEntry : entry.getValue().entrySet()) { double max = Double.NEGATIVE_INFINITY; for (final RowKey l : rightKeys) { final Triple<DendrogramNode, RowKey, RowKey> key = Triple.apply(x, l, innerEntry.getKey()); if (!rightM.containsKey(key)) { continue; } final double alternative = entry.getValue().get(l).doubleValue() + rightM.get(key).doubleValue(); if (alternative > max) { max = alternative; } } ret.put(Triple.apply(root, entry.getKey(), innerEntry.getKey()), Double.valueOf(max)); } } }
private static void buildTextQueryPart( Query query, Map<IQueryField, ComboViewer> operators, Map<IQueryField, Text> values) { for (Entry<IQueryField, Text> entry : values.entrySet()) { IQueryField queryField = entry.getKey(); Text text = entry.getValue(); ComboViewer opCombo = operators.get(queryField); IStructuredSelection selection = (IStructuredSelection) opCombo.getSelection(); if (selection.getFirstElement() instanceof CompareOperator) { CompareOperator operator = (CompareOperator) selection.getFirstElement(); if (queryField instanceof CustomField) { CustomField customField = (CustomField) queryField; if (customField.getFieldFormat() == CustomField.Format.BOOL) { query.addFilter( customField, QueryField.BOOLEAN_TYPE, operator, IRedmineConstants.BOOLEAN_TRUE_SUBMIT_VALUE); } else { QueryField definition = customField.getQueryField(); query.addFilter(customField, definition, operator, text.getText().trim()); } } else { query.addFilter((QueryField) queryField, operator, text.getText().trim()); } } } }
public static void restoreTextQueryPart( Query query, Configuration configuration, Map<IQueryField, ComboViewer> operators, Map<IQueryField, Text> values) { for (Entry<IQueryField, Text> entry : values.entrySet()) { IQueryField queryField = entry.getKey(); QueryFilter queryFilter = query.getQueryFilter(queryField); if (queryFilter == null) { continue; } Text control = entry.getValue(); ComboViewer operatorCombo = operators.get(queryField); operatorCombo.setSelection(new StructuredSelection(queryFilter.getOperator())); if (queryFilter.getOperator().isValueBased()) { control.setEnabled(true); List<String> filterValues = queryFilter.getValues(); if (filterValues.size() > 0) { control.setText(filterValues.get(0)); } } } }
void save() throws FatalStorageException { if (!loaded) { return; } CommittableOutputStream cos = null; ATRWriter w = null; try { cos = l.getOutputStream(); w = new ATRWriter(cos.stream()); for (Entry<String, String> kv : __kv.entrySet()) { w.startRecord(); w.write(kv.getKey()); w.write(kv.getValue()); w.endRecord(); } w.flush(); } catch (Exception e) { cos.abort(); throw new FatalStorageException("Unable to save data to " + l.getName() + ".", e); } finally { try { w.close(); } catch (Exception e) { } try { cos.commitIfNotAborted(); } catch (Exception e) { throw new FatalStorageException("Unable to save data to " + l.getName() + ".", e); } } }
/** * 将当前页面解析到的字段传递给新的request * * @param page * @param nextRequest */ private void transmitResultItem(Page page, Request nextRequest) { // 将当前page解析下来的字段转交到nextRequest中 Map<String, Object> fields = page.getResultItems().getAll(); for (Entry<String, Object> entry : fields.entrySet()) { nextRequest.addInheritField(entry.getKey(), entry.getValue()); } }
@MapFeature.Require(SUPPORTS_REMOVE) @CollectionSize.Require(absent = ZERO) public void testRemovePropagatesToAsMapEntrySet() { List<Entry<K, V>> entries = Helpers.copyToList(multimap().entries()); for (Entry<K, V> entry : entries) { resetContainer(); K key = entry.getKey(); V value = entry.getValue(); Iterator<Entry<K, Collection<V>>> asMapItr = multimap().asMap().entrySet().iterator(); Collection<V> collection = null; while (asMapItr.hasNext()) { Entry<K, Collection<V>> asMapEntry = asMapItr.next(); if (key.equals(asMapEntry.getKey())) { collection = asMapEntry.getValue(); break; } } assertNotNull(collection); Collection<V> expectedCollection = Helpers.copyToList(collection); multimap().remove(key, value); expectedCollection.remove(value); ASSERT.that(collection).hasContentsAnyOrder(expectedCollection.toArray()); assertEquals(!expectedCollection.isEmpty(), multimap().containsKey(key)); } }
@SuppressWarnings("unchecked") private void processNextNode() { if (stateStack.isEmpty()) { nextEvent = null; return; } currentItr = stateStack.peek(); if (currentItr.hasNext()) { Object o = currentItr.next(); if (inMap()) { Entry<String, HValue> entry = (Entry<String, HValue>) o; key = entry.getKey(); value = entry.getValue(); } else { key = null; value = HValue.initFromObject(o); } nextEvent = Types.getEventTypeForType(value.getType()); if (!value.getType().isScalar()) { stateStack.push(new IteratorWithType(value)); } } else { IteratorWithType iter = stateStack.pop(); key = null; value = iter.getValue(); nextEvent = (iter.getType() == Type.MAP) ? EventType.END_MAP : EventType.END_ARRAY; currentItr = stateStack.isEmpty() ? null : stateStack.peek(); } }
private void doMatches(Map<String, Object> ret, BagQueryResult bqr) { for (Entry<Integer, List> pair : bqr.getMatches().entrySet()) { Map<String, Object> resultItem; InterMineObject imo; try { imo = im.getObjectStore().getObjectById(pair.getKey()); } catch (ObjectStoreException e) { throw new IllegalStateException("Could not retrieve object reported as match", e); } String idKey = String.valueOf(imo.getId()); if (ret.containsKey(idKey)) { resultItem = (Map<String, Object>) ret.get(idKey); } else { resultItem = new HashMap<String, Object>(); resultItem.put("identifiers", new HashMap<String, Object>()); } if (!resultItem.containsKey("summary")) { resultItem.put("summary", getObjectDetails(imo)); } Map<String, Object> identifiers = (Map<String, Object>) resultItem.get("identifiers"); for (Object o : pair.getValue()) { String ident = (String) o; if (!identifiers.containsKey(ident)) { identifiers.put(ident, new HashSet<String>()); } Set<String> categories = (Set<String>) identifiers.get(ident); categories.add("MATCH"); } String className = DynamicUtil.getSimpleClassName(imo.getClass()); resultItem.put("type", className.replaceAll("^.*\\.", "")); ret.put(idKey, resultItem); } }
/** * Check the logged out players for if any data can be removed.<br> * Currently only "dumb" full removal is performed. Later it is thinkable to remove "as much as * reasonable". */ public void checkExpiration() { if (durExpireData <= 0) return; final long now = System.currentTimeMillis(); final Set<CheckDataFactory> factories = new LinkedHashSet<CheckDataFactory>(); final Set<Entry<String, Long>> entries = lastLogout.entrySet(); final Iterator<Entry<String, Long>> iterator = entries.iterator(); while (iterator.hasNext()) { final Entry<String, Long> entry = iterator.next(); final long ts = entry.getValue(); if (now - ts <= durExpireData) break; final String playerName = entry.getKey(); if (deleteData) { factories.clear(); for (final CheckType type : CheckType.values()) { final CheckDataFactory factory = type.getDataFactory(); if (factory != null) factories.add(factory); } for (final CheckDataFactory factory : factories) { factory.removeData(playerName); } clearComponentData(CheckType.ALL, playerName); } if (deleteData || deleteHistory) removeExecutionHistory(CheckType.ALL, playerName); if (deleteHistory) ViolationHistory.removeHistory(playerName); iterator.remove(); } }
/** * {@link PersistentSnapshotDeletionPolicy} wraps another {@link IndexDeletionPolicy} to enable * flexible snapshotting. * * @param primary the {@link IndexDeletionPolicy} that is used on non-snapshotted commits. * Snapshotted commits, by definition, are not deleted until explicitly released via {@link * #release(String)}. * @param dir the {@link Directory} which will be used to persist the snapshots information. * @param mode specifies whether a new index should be created, deleting all existing snapshots * information (immediately), or open an existing index, initializing the class with the * snapshots information. * @param matchVersion specifies the {@link Version} that should be used when opening the * IndexWriter. */ public PersistentSnapshotDeletionPolicy( IndexDeletionPolicy primary, Directory dir, OpenMode mode, Version matchVersion) throws CorruptIndexException, LockObtainFailedException, IOException { super(primary, null); // Initialize the index writer over the snapshot directory. writer = new IndexWriter(dir, new IndexWriterConfig(matchVersion, null).setOpenMode(mode)); if (mode != OpenMode.APPEND) { // IndexWriter no longer creates a first commit on an empty Directory. So // if we were asked to CREATE*, call commit() just to be sure. If the // index contains information and mode is CREATE_OR_APPEND, it's a no-op. writer.commit(); } try { // Initializes the snapshots information. This code should basically run // only if mode != CREATE, but if it is, it's no harm as we only open the // reader once and immediately close it. for (Entry<String, String> e : readSnapshotsInfo(dir).entrySet()) { registerSnapshotInfo(e.getKey(), e.getValue(), null); } } catch (RuntimeException e) { writer.close(); // don't leave any open file handles throw e; } catch (IOException e) { writer.close(); // don't leave any open file handles throw e; } }
@Override public String analyze(Iterable<Mutation> mutations, HtmlReport report) { List<String> lines = new ArrayList<String>(); for (Mutation mutation : mutations) { if (mutation.isKilled()) { MutationTestResult result = mutation.getMutationResult(); Set<TestMessage> detecting = new HashSet<TestMessage>(); Collection<TestMessage> failures = result.getFailures(); detecting.addAll(failures); Collection<TestMessage> errors = result.getErrors(); detecting.addAll(errors); String tests = getIds(detecting); String line = mutation.getId() + "," + tests; lines.add(line); } } Set<Entry<String, Integer>> entrySet = testsIds.entrySet(); lines.add("Ids"); for (Entry<String, Integer> entry : entrySet) { lines.add(entry.getKey() + "," + entry.getValue()); } try { FileUtils.writeLines(new File("detectedByTest.csv"), lines); } catch (IOException e) { e.printStackTrace(); } return Joiner.on("\n").join(lines); }
@Override public LocalDateDoubleTimeSeries evaluate(final LocalDateDoubleTimeSeries... x) { testInputData(x); if (x.length > 2) { s_logger.info("Have more than two time series in array; only using first two"); } final FastIntDoubleTimeSeries ts1 = (FastIntDoubleTimeSeries) x[0].getFastSeries(); final FastIntDoubleTimeSeries ts2 = (FastIntDoubleTimeSeries) x[1].getFastSeries(); final int n = ts1.size(); final int[] times = new int[n]; final double[] returns = new double[n]; final Iterator<Entry<Integer, Double>> iter1 = ts1.iterator(); Entry<Integer, Double> entry1; Double value2; Integer t; int i = 0; while (iter1.hasNext()) { entry1 = iter1.next(); t = entry1.getKey(); value2 = ts2.getValue(t); if (value2 == null || Math.abs(value2) < ZERO) { if (getMode().equals(CalculationMode.STRICT)) { throw new TimeSeriesException("No data in second series for time " + t); } } else { times[i] = entry1.getKey(); returns[i++] = Math.log(entry1.getValue() / value2); } } return getSeries(x[0], times, returns, i); }
/** * POSTs the variables and returns the body * * @param url - fully qualified and encoded URL to post to * @param params * @return */ public String doPost(String url, Map<String, String> params) throws com.ettrema.httpclient.HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException { notifyStartRequest(); HttpPost m = new HttpPost(url); List<NameValuePair> formparams = new ArrayList<NameValuePair>(); for (Entry<String, String> entry : params.entrySet()) { formparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } UrlEncodedFormEntity entity; try { entity = new UrlEncodedFormEntity(formparams); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); } m.setEntity(entity); try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); int res = Utils.executeHttpWithStatus(client, m, bout); Utils.processResultCode(res, url); return bout.toString(); } catch (HttpException ex) { throw new RuntimeException(ex); } catch (IOException ex) { throw new RuntimeException(ex); } finally { notifyFinishRequest(); } }
public void loadSemanticModule(Properties properties) { String uri = properties.getProperty("uri", null); if (uri == null || uri.trim().equals("")) { throw new RuntimeException("Semantic Module URI property must not be empty"); } DefaultSemanticModule module = new DefaultSemanticModule(uri); for (Entry<Object, Object> entry : properties.entrySet()) { String elementName = (String) entry.getKey(); // uri is processed above, so skip if ("uri".equals(elementName)) { continue; } if (elementName == null || elementName.trim().equals("")) { throw new RuntimeException("Element name must be specified for Semantic Module handler"); } String handlerName = (String) entry.getValue(); if (handlerName == null || handlerName.trim().equals("")) { throw new RuntimeException("Handler name must be specified for Semantic Module"); } Handler handler = (Handler) ClassUtils.instantiateObject(handlerName, this.classLoader); if (handler == null) { throw new RuntimeException( "Unable to load Semantic Module handler '" + elementName + ":" + handlerName + "'"); } else { module.addHandler(elementName, handler); } } this.semanticModules.addSemanticModule(module); }
private Instance getConnectorConfiguration(Model model, StringToExpressionConverter converter) { final Instance configuration = model.newInstance("connectorconfiguration.ConnectorConfiguration"); configuration.set("definitionId", getDefinitionId()); configuration.set("version", getDefinitionVersion()); final Map<String, Object> additionalInputs = definitionMapper.getAdditionalInputs(inputs); final Map<String, Object> allInput = new HashMap<String, Object>(inputs); allInput.putAll(additionalInputs); for (Entry<String, Object> input : allInput.entrySet()) { final String parameterKeyFor = getParameterKeyFor(input.getKey()); if (parameterKeyFor != null) { final Instance parameter = model.newInstance("connectorconfiguration.ConnectorParameter"); parameter.set("key", parameterKeyFor); parameter.set( "expression", getParameterExpressionFor( model, parameterKeyFor, converter, definitionMapper.transformParameterValue(parameterKeyFor, input.getValue(), inputs), getReturnType(parameterKeyFor))); configuration.add("parameters", parameter); } else { if (BonitaStudioLog.isLoggable(IStatus.OK)) { BonitaStudioLog.debug( input.getKey() + " not mapped for " + getDefinitionId(), BarImporterPlugin.PLUGIN_ID); } } } return configuration; }
/** * Method to determine a comple argument based on the dependency declared by an argument. The * method calls a recursive method that searches in each line of the processed sentence for the * dependency declared and dependencies of each depency * * @param arg - The original argument * @param sentenceLines - all lines of the SRL file that compse the processed sentence */ private static void preDetermineFullArg(SemanticRelationArgument arg, String[] sentenceLines) { TreeMap<Integer, ArgumentTerm> parts = new TreeMap<Integer, ArgumentTerm>(); parts.put( arg.getArgLine(), new ArgumentTerm(arg.getShortArg(), arg.getShortArgLemma(), arg.getShortArgPosTag())); // call to recursive method parts.putAll(retrieveDependentArgs(parts, sentenceLines)); // build a string based on all dependencies found and populate the array of ArgumentTerms // The TreeMap guarantees that the words are read in order, since // the nodes are ordered by the line ID String fullArg = ""; int firstWordLine = arg.getArgLine(); for (Entry<Integer, ArgumentTerm> part : parts.entrySet()) { // Add ArgumentTerm to array of ArgumentTerm objects arg.getArgumentTerms().add(part.getValue()); fullArg += part.getValue().getWord() + " "; // check if the argument actually begins prior the argument lead if (part.getKey() < firstWordLine) { firstWordLine = part.getKey(); } } arg.setArgLine(firstWordLine); arg.setFullArg(fullArg); }
public String getURL() { String url = this.baseURL + "?source=" + this.superid; for (Entry<String, String> temp : params.entrySet()) { url += "&" + temp.getKey() + "=" + temp.getValue(); } return url; }
public void setReqAttrs(final Map<String, String> reqAttrs) { // trim map reqAttr = new HashMap<String, String>(); for (final Entry<String, String> entry : reqAttrs.entrySet()) { reqAttr.put(entry.getKey().trim(), entry.getValue().trim()); } }
public void cleanup(Context context) throws IOException, InterruptedException { // close for (Entry<String, Integer> entry : wordMap.entrySet()) { word.set(entry.getKey()); counter.set(entry.getValue()); context.write(word, counter); } }
/** * @param format * @param bindings * @return formatted commit name */ public static String formatName(final String format, Map<String, String> bindings) { String result = format; for (Entry<String, String> e : bindings.entrySet()) { result = result.replace(e.getKey(), e.getValue()); } return result; }
public static void writePropagationContexts(MarshallerWriteContext context) throws IOException { ObjectOutputStream stream = context.stream; if (context.terminalTupleMap != null && context.terminalTupleMap.size() > 0) { Entry<LeftTuple, Integer>[] entries = context.terminalTupleMap.entrySet().toArray(new Entry[context.terminalTupleMap.size()]); Arrays.sort(entries, TupleSorter.instance); // Map<LeftTuple, Integer> tuples = context.terminalTupleMap; if (entries.length != 0) { Map<Long, PropagationContext> pcMap = new HashMap<Long, PropagationContext>(); for (Entry<LeftTuple, Integer> entry : entries) { LeftTuple leftTuple = entry.getKey(); if (leftTuple.getObject() != null) { PropagationContext pc = ((Activation) leftTuple.getObject()).getPropagationContext(); if (!pcMap.containsKey(pc.getPropagationNumber())) { stream.writeShort(PersisterEnums.PROPAGATION_CONTEXT); writePropagationContext(context, pc); pcMap.put(pc.getPropagationNumber(), pc); } } } } } stream.writeShort(PersisterEnums.END); }