コード例 #1
0
ファイル: ActionMessage.java プロジェクト: hszander/TomP2P
 /**
  * Set the value of an input parameter before a message service call
  *
  * @param parameterName the parameter name
  * @param parameterValue the date parameter value, will be automatically translated to the correct
  *     ISO 8601 date format for the given action input param related state variable
  * @return the current ActionMessage object instance
  * @throws IllegalArgumentException if the provided parameterName is not valid for this message or
  *     if no input parameters are required for this message
  */
 public ActionMessage setInputParameter(String parameterName, Date parameterValue)
     throws IllegalArgumentException {
   if (serviceAction.getInputActionArguments() == null) {
     throw new IllegalArgumentException("No input parameters required for this message");
   }
   Argument arg = serviceAction.getInputActionArgument(parameterName);
   if (arg == null) {
     throw new IllegalArgumentException(
         "Wrong input argument name for this action:"
             + parameterName
             + " available parameters are : "
             + serviceAction.getInputActionArguments());
   }
   StateVariable linkedVar = arg.getRelatedStateVariable();
   if (linkedVar.dataType.equals(StateVariableTypes.TIME)) {
     return setInputParameter(parameterName, ISO8601Date.getIsoTime(parameterValue));
   } else if (linkedVar.dataType.equals(StateVariableTypes.TIME_TZ)) {
     return setInputParameter(parameterName, ISO8601Date.getIsoTimeZone(parameterValue));
   } else if (linkedVar.dataType.equals(StateVariableTypes.DATE)) {
     return setInputParameter(parameterName, ISO8601Date.getIsoDate(parameterValue));
   } else if (linkedVar.dataType.equals(StateVariableTypes.DATETIME)) {
     return setInputParameter(parameterName, ISO8601Date.getIsoDateTime(parameterValue));
   } else if (linkedVar.dataType.equals(StateVariableTypes.DATETIME_TZ)) {
     return setInputParameter(parameterName, ISO8601Date.getIsoDateTimeZone(parameterValue));
   } else {
     throw new IllegalArgumentException(
         "Related input state variable " + linkedVar.name + " is not of an date type");
   }
 }
コード例 #2
0
ファイル: ActionMessage.java プロジェクト: hszander/TomP2P
 /**
  * Set the value of an input parameter before a message service call. If the param name already
  * exists, the param value will be overwritten with the new value provided
  *
  * @param parameterName the parameter name
  * @param parameterValue the string parameter value
  * @return the current ActionMessage object instance
  * @throws IllegalArgumentException if the provided parameterName is not valid for this message or
  *     if no input parameters are required for this message
  */
 public ActionMessage setInputParameter(String parameterName, String parameterValue)
     throws IllegalArgumentException {
   if (serviceAction.getInputActionArguments() == null) {
     throw new IllegalArgumentException("No input parameters required for this message");
   }
   Argument arg = serviceAction.getInputActionArgument(parameterName);
   if (arg == null) {
     throw new IllegalArgumentException(
         "Wrong input argument name for this action:"
             + parameterName
             + " available parameters are : "
             + serviceAction.getInputActionArguments());
   }
   for (Iterator<InputParamContainer> i = inputParameters.iterator(); i.hasNext(); ) {
     InputParamContainer container = i.next();
     if (container.name.equals(parameterName)) {
       container.value = parameterValue;
       return this;
     }
   }
   // nothing found add the new value
   InputParamContainer container = new InputParamContainer();
   container.name = parameterName;
   container.value = parameterValue;
   inputParameters.add(container);
   return this;
 }