public fUML.Semantics.Activities.IntermediateActivities.TokenList takeOfferedTokens( int maxCount) { // Take all the offered tokens, up to the given maximum count of // non-null object tokens, and return them. TokenList tokens = new TokenList(); int remainingCount = maxCount; while (this.offers.size() > 0 & remainingCount > 0) { Offer offer = this.offers.getValue(0); TokenList offeredTokens = offer.getOfferedTokens(); int count = offer.countOfferedValues(); if (count <= remainingCount) { for (int i = 0; i < offeredTokens.size(); i++) { tokens.addValue(offeredTokens.getValue(i)); } remainingCount = remainingCount - count; this.offers.removeValue(0); } else { for (int i = 0; i < remainingCount; i++) { Token token = offeredTokens.getValue(i); if (token.getValue() != null) { tokens.addValue(token); } } offer.removeOfferedValues(remainingCount); remainingCount = 0; } } return tokens; } // takeOfferedTokens
public void fire(fUML.Semantics.Activities.IntermediateActivities.TokenList incomingTokens) { // Create forked tokens for all incoming tokens and offer them on all // outgoing edges. if (this.node == null) { Debug.println("[fire] Anonymous fork node."); } else { Debug.println("[fire] Fork node " + this.node.name + "..."); } ActivityEdgeInstanceList outgoingEdges = this.outgoingEdges; int outgoingEdgeCount = outgoingEdges.size(); TokenList forkedTokens = new TokenList(); for (int i = 0; i < incomingTokens.size(); i++) { Token token = incomingTokens.getValue(i); ForkedToken forkedToken = new ForkedToken(); forkedToken.baseToken = token; forkedToken.remainingOffersCount = outgoingEdgeCount; forkedToken.baseTokenIsWithdrawn = false; forkedTokens.addValue(forkedToken); } this.addTokens(forkedTokens); this.sendOffers(forkedTokens); } // fire
public fUML.Semantics.Activities.IntermediateActivities.TokenList takeOfferedTokens() { // Take all the offered tokens and return them. TokenList tokens = new TokenList(); while (this.offers.size() > 0) { TokenList offeredTokens = this.offers.getValue(0).getOfferedTokens(); for (int i = 0; i < offeredTokens.size(); i++) { tokens.addValue(offeredTokens.getValue(i)); } this.offers.removeValue(0); } return tokens; } // takeOfferedTokens
public fUML.Semantics.Activities.IntermediateActivities.TokenList getOfferedTokens() { // Get the offered tokens (after which the tokens will still be // offered). TokenList tokens = new TokenList(); OfferList offers = this.offers; for (int i = 0; i < offers.size(); i++) { TokenList offeredTokens = offers.getValue(i).getOfferedTokens(); for (int j = 0; j < offeredTokens.size(); j++) { tokens.addValue(offeredTokens.getValue(j)); } } return tokens; } // getOfferedTokens