@Override protected void fillVoiceXmlDocument( Document document, Element formElement, VoiceXmlDialogueContext dialogueContext) throws VoiceXmlDocumentRenderingException { List<String> submitNameList = new ArrayList<String>(); VariableList submitVariableList = mSubmitParameters; if (submitVariableList != null) { addVariables(formElement, submitVariableList); for (Entry<String, String> entry : mSubmitParameters) { submitNameList.add(entry.getKey()); } } Element subdialogueElement = DomUtils.appendNewElement(formElement, SUBDIALOG_ELEMENT); subdialogueElement.setAttribute(NAME_ATTRIBUTE, SUBDIALOGUE_FORM_ITEM_NAME); subdialogueElement.setAttribute(SRC_ATTRIBUTE, mUri); if (!submitNameList.isEmpty()) { subdialogueElement.setAttribute(NAME_LIST_ATTRIBUTE, StringUtils.join(submitNameList, " ")); } for (Parameter parameter : mParameters) { Element paramElement = DomUtils.appendNewElement(subdialogueElement, PARAM_ELEMENT); paramElement.setAttribute(NAME_ATTRIBUTE, parameter.getName()); setAttribute(paramElement, VALUE_ATTRIBUTE, parameter.getValue()); setAttribute(paramElement, EXPR_ATTRIBUTE, parameter.getExpression()); } SubmitMethod submitMethod = mMethod; if (submitMethod != null) { subdialogueElement.setAttribute(METHOD_ATTRIBUTE, submitMethod.name()); } DocumentFetchConfiguration fetchConfiguration = mFetchConfiguration; if (fetchConfiguration != null) { applyFetchAudio(subdialogueElement, fetchConfiguration.getFetchAudio()); applyRessourceFetchConfiguration(subdialogueElement, fetchConfiguration); } Element filledElement = DomUtils.appendNewElement(subdialogueElement, FILLED_ELEMENT); createVarElement( filledElement, SUBDIALOGUE_RESULT_VARIABLE_NAME, "dialog." + SUBDIALOGUE_FORM_ITEM_NAME); if (mPostDialogueScript != null) { createScript(filledElement, mPostDialogueScript); } createScript( filledElement, RIVR_SCOPE_OBJECT + ".addValueResult(" + SUBDIALOGUE_RESULT_VARIABLE_NAME + ");"); createGotoSubmit(filledElement); }
/** * Create a method conveniently. The method is added to the class "TestClass". Parameters can be * given as an (positional) array of local variables (the "identity statements", required by Soot * to map parameters to local variables, are inserted automatically) */ public SootMethod makeMethod( int modifier, String name, List<Local> params, soot.Type retType, List<Unit> bodyStmts) { SootMethod m = new SootMethod( name, params.stream().map(Local::getType).collect(toList()), retType, modifier); this.testClass.addMethod(m); Body body = Jimple.v().newBody(m); m.setActiveBody(body); // set the statements for the body.. first the identity statements, then the bodyStmts if (!m.isStatic()) { body.getLocals().add(localThis); body.getUnits() .add(Jimple.v().newIdentityStmt(localThis, Jimple.v().newThisRef(testClass.getType()))); } IntStream.range(0, params.size()) .forEach( pos -> { Local l = params.get(pos); ParameterRef pr = Jimple.v().newParameterRef(l.getType(), pos); body.getUnits().add(Jimple.v().newIdentityStmt(l, pr)); }); body.getUnits().addAll(bodyStmts); // set the locals for the body Set<Local> locals = Stream.concat( params.stream(), body.getUseAndDefBoxes() .stream() .filter(b -> b.getValue() instanceof Local) .map(b -> (Local) b.getValue())) .collect(toSet()); locals.removeAll(body.getLocals()); body.getLocals().addAll(locals); return m; }
/** * @param nodeId Primary node ID. * @param req Request. * @return Remote transaction. * @throws GridException If failed. * @throws GridDistributedLockCancelledException If lock has been cancelled. */ @SuppressWarnings({"RedundantTypeArguments"}) @Nullable public GridNearTxRemote<K, V> startRemoteTx(UUID nodeId, GridDhtLockRequest<K, V> req) throws GridException, GridDistributedLockCancelledException { List<byte[]> nearKeyBytes = req.nearKeyBytes(); GridNearTxRemote<K, V> tx = null; ClassLoader ldr = ctx.deploy().globalLoader(); if (ldr != null) { for (int i = 0; i < nearKeyBytes.size(); i++) { byte[] bytes = nearKeyBytes.get(i); if (bytes == null) continue; K key = req.nearKeys().get(i); Collection<GridCacheMvccCandidate<K>> cands = req.candidatesByIndex(i); if (log.isDebugEnabled()) log.debug("Unmarshalled key: " + key); GridNearCacheEntry<K, V> entry = null; while (true) { try { entry = peekExx(key); if (entry != null) { entry.keyBytes(bytes); // Handle implicit locks for pessimistic transactions. if (req.inTx()) { tx = ctx.tm().tx(req.version()); if (tx != null) tx.addWrite(key, bytes, null /*Value.*/, null /*Value bytes.*/); else { tx = new GridNearTxRemote<K, V>( nodeId, req.nearNodeId(), req.threadId(), req.version(), null, PESSIMISTIC, req.isolation(), req.isInvalidate(), req.timeout(), key, bytes, null, // Value. null, // Value bytes. ctx); if (tx.empty()) return tx; tx = ctx.tm().onCreated(tx); if (tx == null || !ctx.tm().onStarted(tx)) throw new GridCacheTxRollbackException( "Failed to acquire lock " + "(transaction has been completed): " + req.version()); } } // Add remote candidate before reordering. entry.addRemote( req.nodeId(), nodeId, req.threadId(), req.version(), req.timeout(), tx != null && tx.ec(), tx != null, tx != null && tx.implicitSingle()); // Remote candidates for ordered lock queuing. entry.addRemoteCandidates( cands, req.version(), req.committedVersions(), req.rolledbackVersions()); entry.orderOwned(req.version(), req.owned(entry.key())); } // Double-check in case if sender node left the grid. if (ctx.discovery().node(req.nodeId()) == null) { if (log.isDebugEnabled()) log.debug("Node requesting lock left grid (lock request will be ignored): " + req); if (tx != null) tx.rollback(); return null; } // Entry is legit. break; } catch (GridCacheEntryRemovedException ignored) { assert entry.obsoleteVersion() != null : "Obsolete flag not set on removed entry: " + entry; if (log.isDebugEnabled()) log.debug("Received entry removed exception (will retry on renewed entry): " + entry); if (tx != null) { tx.clearEntry(entry.key()); if (log.isDebugEnabled()) log.debug( "Cleared removed entry from remote transaction (will retry) [entry=" + entry + ", tx=" + tx + ']'); } } } } } else { String err = "Failed to acquire deployment class loader for message: " + req; U.warn(log, err); throw new GridException(err); } return tx; }
public String[] process() throws Exception { String[] ret = new String[20]; String s[][] = new String[30][200]; String st = ""; File filepath = new File(inputFileName); FileInputStream fin = new FileInputStream(filepath); // FileInputStream fin1=new FileInputStream(filepath); int i, j = 0, k = 0, count = 1; String st1 = "", st2 = ""; List l = new ArrayList(); while ((i = fin.read()) != -1) { st = st + (char) i; char c = (char) i; if (c == '\n') { StringTokenizer str = new StringTokenizer(st, delimiters); while (str.hasMoreTokens()) { StringBuilder sb = new StringBuilder(str.nextToken().toLowerCase().trim()); // if(Character.isWhitespace(sb.charAt(0))) // System.out.print("hello"); String stt = sb.toString(); l.add(stt); count++; } st = ""; } } HashSet m = new HashSet(); Collections.sort(l); System.out.println(l); j = 1; for (int f = 0; f < count - 1; f++) { String st5 = l.get(f).toString(); for (int ft = 0; ft < count - 1; ft++) { String st6 = l.get(ft).toString(); if (st5.equalsIgnoreCase(st6)) { ++k; } } // System.out.println(l.get(f).toString()+k); m.add((st5 + k)); k = 0; // j++; } // System.out.println(t.toString()+count);ject // Collection stmap = m.values() Iterator itr = m.iterator(); while (itr.hasNext()) System.out.println(itr.next()); System.out.println("finished"); // TODO return ret; }
public Builder addVoiceXmlParameter(Parameter parameter) { Assert.notNull(parameter, "parameter"); mParameters.add(parameter); return this; }
/** * Creates a list containing the given elements. * * @param <T> the type of elements of the list to create. * @param elements the elements to store in the list. * @return the created list. */ public static <T> List<T> list(T... elements) { if (elements == null) return null; List<T> list = new ArrayList<T>(); for (T e : elements) list.add(e); return list; }