@Test public void testDeserialize() { Assignment a = new Assignment(ad, "input1", Variable.VariableType.INPUT, "String", null, null, null); deserialize(ad, a, "-_.!~*'( )", "-_.!~*'(+)", "-_.%21%7E*%27%28+%29"); deserialize(ad, a, ";/?:&=+$,#", "%3B%2F%3F%3A%26%3D%2B%24%2C%23", "%3B%2F%3F%3A%26%3D%2B%24%2C%23"); deserialize(ad, a, "http: "http%3A%2F%2Fwww.test.com%2Fgetit%3Fa%3D1%26b%3D2", "http%3A%2F%2Fwww.test.com%2Fgetit%3Fa%3D1%26b%3D2"); deserialize(ad, a, "a,b=c:aa,,bb==cc", "a%2Cb%3Dc%3Aaa%2C%2Cbb%3D%3Dcc", "a%2Cb%3Dc%3Aaa%2C%2Cbb%3D%3Dcc"); deserialize(ad, a, "a|=b=|c:a[=b=[c:a]=b=]c", "a%7C%3Db%3D%7Cc%3Aa%5B%3Db%3D%5Bc%3Aa%5D%3Db%3D%5Dc", "a%7C%3Db%3D%7Cc%3Aa%5B%3Db%3D%5Bc%3Aa%5D%3Db%3D%5Dc"); deserialize(ad, a, "C:\\home\\joe bloggs\\test\\stuff.txt", "C%3A%5Chome%5Cjoe+bloggs%5Ctest%5Cstuff.txt", "C%3A%5Chome%5Cjoe+bloggs%5Ctest%5Cstuff.txt"); deserialize(ad, a, "a bb ", "a+bb++", "a%20bb%20%20"); deserialize(ad, a, "a+bb++", "a%2Bbb%2B%2B", "a%2Bbb%2B%2B"); deserialize(ad, a, "a+ a +bb++ bb ++", "a%2B%20a%20%2Bbb%2B%2B%20%20bb%20%20%2B%2B", "a%2B%20a%20%2Bbb%2B%2B%20%20bb%20%20%2B%2B"); }
public static Assignment deserialize(final AssignmentData assignmentData, String sAssignment) { if (sAssignment == null || sAssignment.isEmpty()) { return null; } Variable.VariableType assignmentType = null; if (sAssignment.startsWith(INPUT_ASSIGNMENT_PREFIX)) { assignmentType = Variable.VariableType.INPUT; sAssignment = sAssignment.substring(INPUT_ASSIGNMENT_PREFIX.length()); } else if (sAssignment.startsWith(OUTPUT_ASSIGNMENT_PREFIX)) { assignmentType = Variable.VariableType.OUTPUT; sAssignment = sAssignment.substring(OUTPUT_ASSIGNMENT_PREFIX.length()); } String variableName = null; String processVariableName = null; String constant = null; if (sAssignment.contains(ASSIGNMENT_OPERATOR_TOVARIABLE)) { int i = sAssignment.indexOf(ASSIGNMENT_OPERATOR_TOVARIABLE); if (assignmentType == Variable.VariableType.INPUT) { processVariableName = sAssignment.substring(0, i); variableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOVARIABLE.length()); } else { variableName = sAssignment.substring(0, i); processVariableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOVARIABLE.length()); } } else if (sAssignment.contains(ASSIGNMENT_OPERATOR_TOCONSTANT)) { int i = sAssignment.indexOf(ASSIGNMENT_OPERATOR_TOCONSTANT); if (assignmentType == Variable.VariableType.INPUT) { variableName = sAssignment.substring(0, i); constant = StringUtils.urlDecode(sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOCONSTANT.length())); } else { variableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOCONSTANT.length()); String value = StringUtils.urlDecode(sAssignment.substring(0, i)); constant = value.equals("null") ? null : value; } } return new Assignment(assignmentData, variableName, assignmentType, processVariableName, constant); }
Assignment { public static Assignment deserialize(final AssignmentData assignmentData, String sAssignment) { if (sAssignment == null || sAssignment.isEmpty()) { return null; } Variable.VariableType assignmentType = null; if (sAssignment.startsWith(INPUT_ASSIGNMENT_PREFIX)) { assignmentType = Variable.VariableType.INPUT; sAssignment = sAssignment.substring(INPUT_ASSIGNMENT_PREFIX.length()); } else if (sAssignment.startsWith(OUTPUT_ASSIGNMENT_PREFIX)) { assignmentType = Variable.VariableType.OUTPUT; sAssignment = sAssignment.substring(OUTPUT_ASSIGNMENT_PREFIX.length()); } String variableName = null; String processVariableName = null; String constant = null; if (sAssignment.contains(ASSIGNMENT_OPERATOR_TOVARIABLE)) { int i = sAssignment.indexOf(ASSIGNMENT_OPERATOR_TOVARIABLE); if (assignmentType == Variable.VariableType.INPUT) { processVariableName = sAssignment.substring(0, i); variableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOVARIABLE.length()); } else { variableName = sAssignment.substring(0, i); processVariableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOVARIABLE.length()); } } else if (sAssignment.contains(ASSIGNMENT_OPERATOR_TOCONSTANT)) { int i = sAssignment.indexOf(ASSIGNMENT_OPERATOR_TOCONSTANT); if (assignmentType == Variable.VariableType.INPUT) { variableName = sAssignment.substring(0, i); constant = StringUtils.urlDecode(sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOCONSTANT.length())); } else { variableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOCONSTANT.length()); String value = StringUtils.urlDecode(sAssignment.substring(0, i)); constant = value.equals("null") ? null : value; } } return new Assignment(assignmentData, variableName, assignmentType, processVariableName, constant); } }
Assignment { public static Assignment deserialize(final AssignmentData assignmentData, String sAssignment) { if (sAssignment == null || sAssignment.isEmpty()) { return null; } Variable.VariableType assignmentType = null; if (sAssignment.startsWith(INPUT_ASSIGNMENT_PREFIX)) { assignmentType = Variable.VariableType.INPUT; sAssignment = sAssignment.substring(INPUT_ASSIGNMENT_PREFIX.length()); } else if (sAssignment.startsWith(OUTPUT_ASSIGNMENT_PREFIX)) { assignmentType = Variable.VariableType.OUTPUT; sAssignment = sAssignment.substring(OUTPUT_ASSIGNMENT_PREFIX.length()); } String variableName = null; String processVariableName = null; String constant = null; if (sAssignment.contains(ASSIGNMENT_OPERATOR_TOVARIABLE)) { int i = sAssignment.indexOf(ASSIGNMENT_OPERATOR_TOVARIABLE); if (assignmentType == Variable.VariableType.INPUT) { processVariableName = sAssignment.substring(0, i); variableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOVARIABLE.length()); } else { variableName = sAssignment.substring(0, i); processVariableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOVARIABLE.length()); } } else if (sAssignment.contains(ASSIGNMENT_OPERATOR_TOCONSTANT)) { int i = sAssignment.indexOf(ASSIGNMENT_OPERATOR_TOCONSTANT); if (assignmentType == Variable.VariableType.INPUT) { variableName = sAssignment.substring(0, i); constant = StringUtils.urlDecode(sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOCONSTANT.length())); } else { variableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOCONSTANT.length()); String value = StringUtils.urlDecode(sAssignment.substring(0, i)); constant = value.equals("null") ? null : value; } } return new Assignment(assignmentData, variableName, assignmentType, processVariableName, constant); } Assignment();  Assignment(final AssignmentData assignmentData,
                      final String variableName,
                      final Variable.VariableType variableType,
                      final String dataType,
                      final String customDataType,
                      final String processVarName,
                      final String expression);  Assignment(final AssignmentData assignmentData,
                      final String variableName,
                      final Variable.VariableType variableType,
                      final String processVarName,
                      final String expression); }
Assignment { public static Assignment deserialize(final AssignmentData assignmentData, String sAssignment) { if (sAssignment == null || sAssignment.isEmpty()) { return null; } Variable.VariableType assignmentType = null; if (sAssignment.startsWith(INPUT_ASSIGNMENT_PREFIX)) { assignmentType = Variable.VariableType.INPUT; sAssignment = sAssignment.substring(INPUT_ASSIGNMENT_PREFIX.length()); } else if (sAssignment.startsWith(OUTPUT_ASSIGNMENT_PREFIX)) { assignmentType = Variable.VariableType.OUTPUT; sAssignment = sAssignment.substring(OUTPUT_ASSIGNMENT_PREFIX.length()); } String variableName = null; String processVariableName = null; String constant = null; if (sAssignment.contains(ASSIGNMENT_OPERATOR_TOVARIABLE)) { int i = sAssignment.indexOf(ASSIGNMENT_OPERATOR_TOVARIABLE); if (assignmentType == Variable.VariableType.INPUT) { processVariableName = sAssignment.substring(0, i); variableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOVARIABLE.length()); } else { variableName = sAssignment.substring(0, i); processVariableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOVARIABLE.length()); } } else if (sAssignment.contains(ASSIGNMENT_OPERATOR_TOCONSTANT)) { int i = sAssignment.indexOf(ASSIGNMENT_OPERATOR_TOCONSTANT); if (assignmentType == Variable.VariableType.INPUT) { variableName = sAssignment.substring(0, i); constant = StringUtils.urlDecode(sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOCONSTANT.length())); } else { variableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOCONSTANT.length()); String value = StringUtils.urlDecode(sAssignment.substring(0, i)); constant = value.equals("null") ? null : value; } } return new Assignment(assignmentData, variableName, assignmentType, processVariableName, constant); } Assignment();  Assignment(final AssignmentData assignmentData,
                      final String variableName,
                      final Variable.VariableType variableType,
                      final String dataType,
                      final String customDataType,
                      final String processVarName,
                      final String expression);  Assignment(final AssignmentData assignmentData,
                      final String variableName,
                      final Variable.VariableType variableType,
                      final String processVarName,
                      final String expression); String getName(); void setName(final String name); Variable.VariableType getVariableType(); void setVariableType(final Variable.VariableType variableType); Variable getVariable(); String getDataType(); void setDataType(final String dataType); String getCustomDataType(); void setCustomDataType(final String customDataType); String getProcessVarName(); void setProcessVarName(final String processVarName); String getExpression(); void setExpression(final String expression); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static Assignment deserialize(final AssignmentData assignmentData,
                                         String sAssignment); }
Assignment { public static Assignment deserialize(final AssignmentData assignmentData, String sAssignment) { if (sAssignment == null || sAssignment.isEmpty()) { return null; } Variable.VariableType assignmentType = null; if (sAssignment.startsWith(INPUT_ASSIGNMENT_PREFIX)) { assignmentType = Variable.VariableType.INPUT; sAssignment = sAssignment.substring(INPUT_ASSIGNMENT_PREFIX.length()); } else if (sAssignment.startsWith(OUTPUT_ASSIGNMENT_PREFIX)) { assignmentType = Variable.VariableType.OUTPUT; sAssignment = sAssignment.substring(OUTPUT_ASSIGNMENT_PREFIX.length()); } String variableName = null; String processVariableName = null; String constant = null; if (sAssignment.contains(ASSIGNMENT_OPERATOR_TOVARIABLE)) { int i = sAssignment.indexOf(ASSIGNMENT_OPERATOR_TOVARIABLE); if (assignmentType == Variable.VariableType.INPUT) { processVariableName = sAssignment.substring(0, i); variableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOVARIABLE.length()); } else { variableName = sAssignment.substring(0, i); processVariableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOVARIABLE.length()); } } else if (sAssignment.contains(ASSIGNMENT_OPERATOR_TOCONSTANT)) { int i = sAssignment.indexOf(ASSIGNMENT_OPERATOR_TOCONSTANT); if (assignmentType == Variable.VariableType.INPUT) { variableName = sAssignment.substring(0, i); constant = StringUtils.urlDecode(sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOCONSTANT.length())); } else { variableName = sAssignment.substring(i + ASSIGNMENT_OPERATOR_TOCONSTANT.length()); String value = StringUtils.urlDecode(sAssignment.substring(0, i)); constant = value.equals("null") ? null : value; } } return new Assignment(assignmentData, variableName, assignmentType, processVariableName, constant); } Assignment();  Assignment(final AssignmentData assignmentData,
                      final String variableName,
                      final Variable.VariableType variableType,
                      final String dataType,
                      final String customDataType,
                      final String processVarName,
                      final String expression);  Assignment(final AssignmentData assignmentData,
                      final String variableName,
                      final Variable.VariableType variableType,
                      final String processVarName,
                      final String expression); String getName(); void setName(final String name); Variable.VariableType getVariableType(); void setVariableType(final Variable.VariableType variableType); Variable getVariable(); String getDataType(); void setDataType(final String dataType); String getCustomDataType(); void setCustomDataType(final String customDataType); String getProcessVarName(); void setProcessVarName(final String processVarName); String getExpression(); void setExpression(final String expression); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static Assignment deserialize(final AssignmentData assignmentData,
                                         String sAssignment);  }