DataInterfaceParamUtil.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package jnpf.base.util;
  2. import jnpf.base.model.datainterface.DataInterfaceMarkModel;
  3. import jnpf.constant.DataInterfaceVarConst;
  4. import jnpf.util.RandomUtil;
  5. import java.util.Map;
  6. public class DataInterfaceParamUtil {
  7. /**
  8. * 获取指定字符串所在的位置及应该赋予的值
  9. *
  10. * @param map 位置、值
  11. * @param str 字符串
  12. * @param specifyString 指定字符串
  13. * @param value 值
  14. * @return
  15. */
  16. public static Map<Double, DataInterfaceMarkModel> getParamModel(Map<Double, DataInterfaceMarkModel> map, String str, String specifyString, Object value) {
  17. int frontLength = 0;
  18. while (str.contains(specifyString)) {
  19. int index = str.indexOf(specifyString);
  20. boolean flag = false;
  21. double aDouble = index + frontLength + 1;
  22. while (!flag) {
  23. if (map.containsKey(aDouble)) {
  24. aDouble += 0.0001;
  25. } else {
  26. if (specifyString.equals(DataInterfaceVarConst.ID_LOT)) {
  27. value = RandomUtil.uuId();
  28. }
  29. map.put(aDouble, new DataInterfaceMarkModel(specifyString, value));
  30. flag = true;
  31. }
  32. }
  33. frontLength += (index + specifyString.length());
  34. str = str.substring(index + specifyString.length());
  35. }
  36. return map;
  37. }
  38. }