示例#1
0
 @Override
 public List<Unit> getPredsOf(Unit unit) {
   if (unit.equals(nIf)) {
     return Collections.emptyList();
   } else if (unit.equals(n1)) {
     return Collections.singletonList(nIf);
   } else if (unit.equals(n2)) {
     return Collections.singletonList(nIf);
   } else {
     throw new RuntimeException("UNEXPECTED CASE");
   }
 }
示例#2
0
 @Override
 public final List<Unit> getSuccsOf(Unit s) {
   if (this.forwardEdges.containsKey(s)) {
     return new ArrayList<>(this.forwardEdges.get(s));
   } else {
     return Collections.emptyList();
   }
 }
  /** {@inheritDoc} */
  @Override
  public GridFuture<Map<K, V>> getAllAsync(
      @Nullable Collection<? extends K> keys,
      @Nullable GridPredicate<? super GridCacheEntry<K, V>>[] filter) {
    ctx.denyOnFlag(LOCAL);

    if (F.isEmpty(keys))
      return new GridFinishedFuture<Map<K, V>>(ctx.kernalContext(), Collections.<K, V>emptyMap());

    GridCacheTxLocalAdapter<K, V> tx = ctx.tm().threadLocalTx();

    if (tx != null && !tx.implicit()) return ctx.wrapCloneMap(tx.getAllAsync(keys, filter));

    return loadAsync(keys, false, filter);
  }
  /**
   * @param keys Keys to load.
   * @param reload Reload flag.
   * @param filter Filter.
   * @return Loaded values.
   */
  public GridFuture<Map<K, V>> loadAsync(
      @Nullable Collection<? extends K> keys,
      boolean reload,
      @Nullable GridPredicate<? super GridCacheEntry<K, V>>[] filter) {
    if (F.isEmpty(keys))
      return new GridFinishedFuture<Map<K, V>>(ctx.kernalContext(), Collections.<K, V>emptyMap());

    GridNearGetFuture<K, V> fut = new GridNearGetFuture<K, V>(ctx, keys, reload, null, filter);

    // Register future for responses.
    ctx.mvcc().addFuture(fut);

    fut.init();

    return ctx.wrapCloneMap(fut);
  }
  @Test
  public void shouldAlsoLookForClassesInClassDirectories() throws Exception {
    newDir = new File("tempClassDir");
    List<File> buildPaths = asList(newDir);
    ClasspathProvider classpath =
        new StandaloneClasspath(
            Collections.<File>emptyList(),
            buildPaths,
            FakeEnvironments.systemClasspath() + pathSeparator + newDir.getAbsolutePath());

    String classname = "org.fakeco.Foobar2";
    createClass(classname);

    builder = new JavaClassBuilder(classpath);
    JavaClass javaClass = builder.createClass(classname);
    assertEquals(classname, javaClass.getName());
    assertFalse(javaClass.isATest());
  }
  /**
   * @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> startRemoteTxForFinish(
      UUID nodeId, GridDhtTxFinishRequest<K, V> req)
      throws GridException, GridDistributedLockCancelledException {
    GridNearTxRemote<K, V> tx = null;

    ClassLoader ldr = ctx.deploy().globalLoader();

    if (ldr != null) {
      for (GridCacheTxEntry<K, V> txEntry : req.nearWrites()) {
        GridDistributedCacheEntry<K, V> entry = null;

        while (true) {
          try {
            entry = peekExx(txEntry.key());

            if (entry != null) {
              entry.keyBytes(txEntry.keyBytes());

              // Handle implicit locks for pessimistic transactions.
              tx = ctx.tm().tx(req.version());

              if (tx != null) {
                if (tx.local()) return null;

                if (tx.markFinalizing()) tx.addWrite(txEntry.key(), txEntry.keyBytes());
                else return null;
              } else {
                tx =
                    new GridNearTxRemote<K, V>(
                        nodeId,
                        req.nearNodeId(),
                        req.threadId(),
                        req.version(),
                        null,
                        PESSIMISTIC,
                        req.isolation(),
                        req.isInvalidate(),
                        0,
                        txEntry.key(),
                        txEntry.keyBytes(),
                        txEntry.value(),
                        txEntry.valueBytes(),
                        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());

                if (!tx.markFinalizing()) return null;
              }

              // Add remote candidate before reordering.
              if (txEntry.explicitVersion() == null)
                entry.addRemote(
                    req.nearNodeId(),
                    nodeId,
                    req.threadId(),
                    req.version(),
                    0,
                    tx.ec(),
                    /*tx*/ true,
                    tx.implicitSingle());

              // Remote candidates for ordered lock queuing.
              entry.addRemoteCandidates(
                  Collections.<GridCacheMvccCandidate<K>>emptyList(),
                  req.version(),
                  req.committedVersions(),
                  req.rolledbackVersions());
            }

            // Double-check in case if sender node left the grid.
            if (ctx.discovery().node(req.nearNodeId()) == 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;
  }
示例#7
0
  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;
  }
示例#8
0
  public Code(TypeVars tvars) {

    this.j = Jimple.v();

    this.localX = j.newLocal("x", IntType.v());
    this.localY = j.newLocal("y", IntType.v());
    this.localZ = j.newLocal("z", IntType.v());
    this.localO = j.newLocal("o", RefType.v("java.lang.Object"));
    this.localT = j.newLocal("t", RefType.v("TestClass"));
    this.localThis = j.newLocal("this", RefType.v("TestClass"));
    this.varX = Var.fromLocal(localX);
    this.varY = Var.fromLocal(localY);
    this.varZ = Var.fromLocal(localZ);
    this.varO = Var.fromLocal(localO);
    this.varT = Var.fromLocal(localT);
    this.varThis = Var.fromLocal(localThis);
    this.tvarX = tvars.testParam(varX, "");
    this.tvarY = tvars.testParam(varY, "");
    this.tvarZ = tvars.testParam(varZ, "");
    this.tvarO = tvars.testParam(varO, "");
    this.tvarT = tvars.testParam(varT, "");
    this.tvarThis = tvars.testParam(varThis, "");

    this.init =
        Environments.makeEmpty()
            .add(varX, tvarX)
            .add(varY, tvarY)
            .add(varZ, tvarZ)
            .add(varO, tvarO)
            .add(varT, tvarT)
            .add(varThis, tvarThis);

    this.testClass = makeFreshClass("TestClass");

    Map<SootField, TypeDomain.Type<Level>> fieldMap = new HashMap<>();

    this.testLowField_int = new SootField("testLowField", IntType.v(), 0);
    testClass.addField(this.testLowField_int);
    fieldMap.put(testLowField_int, TLOW);
    this.testHighField_int = new SootField("testHighField", IntType.v(), 0);
    testClass.addField(this.testHighField_int);
    fieldMap.put(testHighField_int, THIGH);
    this.testStaticDynField_int = new SootField("testStaticDynField", IntType.v(), Modifier.STATIC);
    testClass.addField(this.testStaticDynField_int);
    fieldMap.put(testStaticDynField_int, DYN);

    // freeze field map
    this.fields = new FieldTable<>(fieldMap);

    Map<SootMethod, Signature<Level>> sigMap = new HashMap<>();
    Symbol.Param<LowHigh.Level> param_x = param(0);
    Symbol.Param<LowHigh.Level> param_y = param(1);

    // Method:
    // int testCallee()
    //    with {} effect {}
    this.testCallee__int =
        new SootMethod("testCallee", Collections.emptyList(), IntType.v(), Modifier.ABSTRACT);
    this.testClass.addMethod(testCallee__int);
    sigMap.put(
        this.testCallee__int,
        makeSignature(
            this.testCallee__int.getParameterCount(),
            Stream.of(leS(Symbol.literal(PUB), ret())).collect(toList()),
            Effects.emptyEffect()));

    // Method:
    // int testCallee_int_int__int (int, int)
    //   with {@param1 <= @ret, @param2 <= @ret} effect {}
    this.testCallee_int_int__int =
        new SootMethod(
            "testCallee", asList(IntType.v(), IntType.v()), IntType.v(), Modifier.ABSTRACT);
    this.testClass.addMethod(testCallee_int_int__int);
    Stream<SigConstraint<Level>> sigCstrs = Stream.of(leS(param_x, ret()), leS(param_y, ret()));
    sigMap.put(
        this.testCallee_int_int__int,
        makeSignature(
            this.testCallee_int_int__int.getParameterCount(),
            sigCstrs.collect(toList()),
            Effects.emptyEffect()));

    // Method:
    // int ignoreSnd(int, int)
    //   with { @param1 <= @ret } effect {}
    this.ignoreSnd_int_int__int =
        new SootMethod(
            "ignoreSnd", asList(IntType.v(), IntType.v()), IntType.v(), Modifier.ABSTRACT);
    this.testClass.addMethod(ignoreSnd_int_int__int);
    sigCstrs = Stream.of(leS(param_x, ret()), leS(param_y, param_y));
    sigMap.put(
        this.ignoreSnd_int_int__int,
        makeSignature(
            this.ignoreSnd_int_int__int.getParameterCount(),
            sigCstrs.collect(toList()),
            Effects.emptyEffect()));

    // Method:
    // int writeToLowReturn0(int)
    //   with { @param0 <= LOW } effect { LOW }
    this.writeToLowReturn0_int__int =
        new SootMethod("writeToLow", singletonList(IntType.v()), IntType.v(), Modifier.ABSTRACT);
    this.testClass.addMethod(this.writeToLowReturn0_int__int);
    sigCstrs = Stream.of((leS(param_x, literal(TLOW))), leS(ret(), ret()));
    sigMap.put(
        this.writeToLowReturn0_int__int,
        makeSignature(
            this.writeToLowReturn0_int__int.getParameterCount(),
            sigCstrs.collect(toList()),
            Effects.makeEffects(TLOW)));

    // Method:
    // int ignore0Low1ReturnHigh(int, int)
    //   with { @param1 <= LOW, HIGH <= ret } effect {}
    this.ignore0Low1ReturnHigh =
        new SootMethod(
            "ignore0Low1ReturnHigh",
            asList(IntType.v(), IntType.v()),
            IntType.v(),
            Modifier.ABSTRACT);
    this.testClass.addMethod(this.ignore0Low1ReturnHigh);
    sigCstrs = Stream.of(leS(param(1), literal(TLOW)), leS(literal(THIGH), ret()));
    sigMap.put(
        this.ignore0Low1ReturnHigh,
        makeSignature(
            this.ignore0Low1ReturnHigh.getParameterCount(),
            sigCstrs.collect(toList()),
            Effects.emptyEffect()));

    // freeze signatures
    this.signatures = makeTable(sigMap);
  }
示例#9
0
 @Override
 public List<Unit> getTails() {
   return Collections.singletonList(nIf);
 }
示例#10
0
/**
 * A {@link SubdialogueCall} is a {@link VoiceXmlOutputTurn} that invokes another external dialogue.
 *
 * <p>Parameters may be passed to the subdialogue and return values may be retrieved if the invoked
 * subdialogue ends with a <code>&lt;return&gt;</code> instruction.
 *
 * @author Nu Echo Inc.
 * @see Parameter
 * @see <a
 *     href="http://www.w3.org/TR/voicexml20/#dml2.3.4">http://www.w3.org/TR/voicexml20/#dml2.3.4</a>
 */
public class SubdialogueCall extends VoiceXmlOutputTurn {
  public static final String SUBDIALOGUE_RESULT_VARIABLE_NAME = "subdialogue";

  private static final String SUBDIALOGUE_INVOCATION_TURN_TYPE = "subdialogue";

  private static final String POST_DIALOGUE_SCRIPT_PROPERTY = "postDialogueScript";
  private static final String SUBDIALOGUE_PARAMETERS_PROPERTY = "subdialogueParameters";
  private static final String SUBMIT_URI_PROPERTY = "uri";
  private static final String SUBMIT_PARAMETERS_PROPERTY = "submitParameters";
  private static final String SUBMIT_METHOD_PROPERTY = "submitMethod";
  private static final String FETCH_CONFIGURATION_PROPERTY = "fetchConfiguration";

  private final String mUri;
  private Collection<Parameter> mParameters = Collections.emptyList();
  private VariableList mSubmitParameters = new VariableList();
  private SubmitMethod mMethod = SubmitMethod.get;
  private DocumentFetchConfiguration mFetchConfiguration;
  private String mPostDialogueScript;

  /**
   * @param name The name of this turn. Not empty.
   * @param uri The URI of the subdialogue. Not empty.
   */
  public SubdialogueCall(String name, String uri) {
    super(name);
    Assert.notEmpty(uri, "uri");
    mUri = uri;
  }

  /**
   * @param parameters A list of {@link Parameter} that will be passed to the subdialogue. Not null.
   */
  public final void setSubdialogueParameters(Collection<Parameter> parameters) {
    Assert.noNullValues(parameters, "parameters");
    mParameters = new ArrayList<Parameter>(parameters);
  }

  /**
   * @param subdialogueParameters A list of {@link Parameter} that will be passed to the
   *     subdialogue. Not null.
   */
  public final void setSubdialogueParameters(Parameter... subdialogueParameters) {
    setSubdialogueParameters(asListChecked(subdialogueParameters));
  }

  /** @param submitParameters A list of variable to submit when invoking the URI. Not null. */
  public final void setSubmitParameters(VariableList submitParameters) {
    Assert.notNull(submitParameters, "submitParameters");
    mSubmitParameters = submitParameters;
  }

  /**
   * @param method The HTTP method used to invoke the subdialogue (GET or POST). <code>null</code>
   *     to use the VoiceXML platform default
   * @see SubmitMethod
   */
  public final void setMethod(SubmitMethod method) {
    mMethod = method;
  }

  /**
   * @param fetchConfiguration The {@link DocumentFetchConfiguration}. <code>null</code> to use the
   *     VoiceXML platform default.
   */
  public final void setFetchConfiguration(DocumentFetchConfiguration fetchConfiguration) {
    mFetchConfiguration = fetchConfiguration;
  }

  /** @param postDialogueScript The ECMAScript script to execute after subdialogue invocation. */
  public final void setPostDialogueScript(String postDialogueScript) {
    mPostDialogueScript = postDialogueScript;
  }

  public final String getUri() {
    return mUri;
  }

  public final Collection<Parameter> getVoiceXmlParameters() {
    return unmodifiableCollection(mParameters);
  }

  public final VariableList getSubmitParameters() {
    return mSubmitParameters;
  }

  public final SubmitMethod getMethod() {
    return mMethod;
  }

  public final String getPostDialogueScript() {
    return mPostDialogueScript;
  }

  public final DocumentFetchConfiguration getFetchConfiguration() {
    return mFetchConfiguration;
  }

  @Override
  protected final String getOuputTurnType() {
    return SUBDIALOGUE_INVOCATION_TURN_TYPE;
  }

  @Override
  protected void addTurnProperties(JsonObjectBuilder builder) {
    JsonUtils.add(builder, SUBMIT_URI_PROPERTY, mUri);
    JsonUtils.add(builder, SUBMIT_METHOD_PROPERTY, mMethod.name());
    JsonUtils.add(builder, SUBMIT_PARAMETERS_PROPERTY, mSubmitParameters);
    JsonUtils.add(builder, SUBDIALOGUE_PARAMETERS_PROPERTY, JsonUtils.toJson(mParameters));
    JsonUtils.add(builder, FETCH_CONFIGURATION_PROPERTY, mFetchConfiguration);
    JsonUtils.add(builder, POST_DIALOGUE_SCRIPT_PROPERTY, getPostDialogueScript());
  }

  @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);
  }

  /**
   * {@link SubdialogueCall} parameter, can be created with a string value, a {@link JsonValue} or
   * an expression.
   */
  public static final class Parameter implements JsonSerializable {
    private static final String NAME_PROPERTY = "name";
    private static final String VALUE_PROPERTY = "value";
    private static final String EXPRESSION_PROPERTY = "expression";

    private final String mName;
    private String mExpression;
    private String mValue;

    /**
     * @param name The name of the parameter. Not empty.
     * @param value The string value of the parameter. Not null.
     * @return The newly created subdialogue parameter
     */
    public static Parameter createWithValue(String name, String value) {
      Assert.notNull(value, "value");

      Parameter parameter = new Parameter(name);
      parameter.mValue = value;
      return parameter;
    }

    /**
     * @param name The name of the parameter. Not empty.
     * @param json The JSON value of the parameter. Not null.
     * @return The newly created subdialogue parameter
     */
    public static Parameter createWithJson(String name, JsonValue json) {
      Assert.notNull(json, "json");
      return createWithExpression(name, json.toString());
    }

    /**
     * @param name The name of the parameter. Not empty.
     * @param expression The ECMAScript expression of the parameter. Not null.
     * @return The newly created subdialogue parameter
     */
    public static Parameter createWithExpression(String name, String expression) {
      Assert.notNull(expression, "expression");

      Parameter parameter = new Parameter(name);
      parameter.mExpression = expression;
      return parameter;
    }

    private Parameter(String name) {
      Assert.notEmpty(name, "name");
      mName = name;
    }

    public String getName() {
      return mName;
    }

    public String getExpression() {
      return mExpression;
    }

    public String getValue() {
      return mValue;
    }

    @Override
    public JsonValue asJson() {
      JsonObjectBuilder builder = JsonUtils.createObjectBuilder();
      JsonUtils.add(builder, NAME_PROPERTY, mName);
      JsonUtils.add(builder, EXPRESSION_PROPERTY, mExpression);
      JsonUtils.add(builder, VALUE_PROPERTY, mValue);
      return builder.build();
    }
  }

  /** Builder used to ease the creation of instances of {@link SubdialogueCall} . */
  public static class Builder {

    private final String mName;
    private String mUri;
    private final List<Parameter> mParameters = Collections.emptyList();
    private final VariableList mSubmitParameters = new VariableList();
    private SubmitMethod mMethod = SubmitMethod.get;
    private DocumentFetchConfiguration mFetchConfiguration;
    private String mPostDialogueScript;

    public Builder(String name) {
      mName = name;
    }

    public Builder uri(String uri) {
      Assert.notEmpty(uri, "uri");
      mUri = uri;
      return this;
    }

    public Builder addVoiceXmlParameter(Parameter parameter) {
      Assert.notNull(parameter, "parameter");
      mParameters.add(parameter);
      return this;
    }

    public Builder addSubmitParameterExpression(String name, String expression) {
      Assert.notEmpty(name, "name");
      mSubmitParameters.addWithExpression(name, expression);
      return this;
    }

    public Builder addSubmitParameterString(String name, String string) {
      Assert.notEmpty(name, "name");
      mSubmitParameters.addWithString(name, string);
      return this;
    }

    public Builder setMethod(SubmitMethod method) {
      Assert.notNull(method, "method");
      mMethod = method;
      return this;
    }

    public Builder setFetchConfiguration(DocumentFetchConfiguration fetchConfiguration) {
      mFetchConfiguration = fetchConfiguration;
      return this;
    }

    public Builder setPostDialogueScript(String postDialogueScript) {
      mPostDialogueScript = postDialogueScript;
      return this;
    }

    public SubdialogueCall build() {
      SubdialogueCall subdialogueCall = new SubdialogueCall(mName, mUri);
      subdialogueCall.setMethod(mMethod);
      subdialogueCall.setPostDialogueScript(mPostDialogueScript);
      subdialogueCall.setFetchConfiguration(mFetchConfiguration);
      subdialogueCall.setSubdialogueParameters(mParameters);
      subdialogueCall.setSubmitParameters(mSubmitParameters);
      return subdialogueCall;
    }
  }
}
示例#11
0
  /** Builder used to ease the creation of instances of {@link SubdialogueCall} . */
  public static class Builder {

    private final String mName;
    private String mUri;
    private final List<Parameter> mParameters = Collections.emptyList();
    private final VariableList mSubmitParameters = new VariableList();
    private SubmitMethod mMethod = SubmitMethod.get;
    private DocumentFetchConfiguration mFetchConfiguration;
    private String mPostDialogueScript;

    public Builder(String name) {
      mName = name;
    }

    public Builder uri(String uri) {
      Assert.notEmpty(uri, "uri");
      mUri = uri;
      return this;
    }

    public Builder addVoiceXmlParameter(Parameter parameter) {
      Assert.notNull(parameter, "parameter");
      mParameters.add(parameter);
      return this;
    }

    public Builder addSubmitParameterExpression(String name, String expression) {
      Assert.notEmpty(name, "name");
      mSubmitParameters.addWithExpression(name, expression);
      return this;
    }

    public Builder addSubmitParameterString(String name, String string) {
      Assert.notEmpty(name, "name");
      mSubmitParameters.addWithString(name, string);
      return this;
    }

    public Builder setMethod(SubmitMethod method) {
      Assert.notNull(method, "method");
      mMethod = method;
      return this;
    }

    public Builder setFetchConfiguration(DocumentFetchConfiguration fetchConfiguration) {
      mFetchConfiguration = fetchConfiguration;
      return this;
    }

    public Builder setPostDialogueScript(String postDialogueScript) {
      mPostDialogueScript = postDialogueScript;
      return this;
    }

    public SubdialogueCall build() {
      SubdialogueCall subdialogueCall = new SubdialogueCall(mName, mUri);
      subdialogueCall.setMethod(mMethod);
      subdialogueCall.setPostDialogueScript(mPostDialogueScript);
      subdialogueCall.setFetchConfiguration(mFetchConfiguration);
      subdialogueCall.setSubdialogueParameters(mParameters);
      subdialogueCall.setSubmitParameters(mSubmitParameters);
      return subdialogueCall;
    }
  }