/** * decode * * @param eventparms an event parm string * @return a list of parameters */ public static List<Parm> decode(final String eventparms) { if (eventparms == null) return null; final List<Parm> parms = new ArrayList<Parm>(); String[] paramslistString = eventparms.split(Character.toString(Constants.MULTIPLE_VAL_DELIM)); if (paramslistString != null) { for (int i = 0; i < paramslistString.length; i++) { String[] paramEncoded = paramslistString[i].split(Character.toString(Constants.NAME_VAL_DELIM)); if (paramEncoded != null && paramEncoded.length == 2) { Parm parm = new Parm(); parm.setParmName(paramEncoded[0]); Value value = new Value(); int startParamType = paramEncoded[1].lastIndexOf('('); if (startParamType == -1) { value.setContent(paramEncoded[1]); value.setType("string"); value.setEncoding("text"); } else { value.setContent(paramEncoded[1].substring(0, startParamType)); String paramType = paramEncoded[1].substring(startParamType + 1); String[] typeAndEncode = paramType.split(Character.toString(Constants.DB_ATTRIB_DELIM)); if (typeAndEncode != null && typeAndEncode.length == 2) { value.setType(typeAndEncode[0]); value.setEncoding(typeAndEncode[1].split("\\)")[0]); } else { value.setType("string"); value.setEncoding("text"); } } parm.setValue(value); parms.add(parm); } } } return parms; }
public EventBuilder addParam( final String parmName, final String val, final String type, final String encoding) { if (parmName != null) { Value value = new Value(); value.setContent(val); if (type != null) { value.setType(type); } if (encoding != null) { value.setEncoding(encoding); } Parm parm = new Parm(); parm.setParmName(parmName); parm.setValue(value); addParam(parm); } return this; }