public static Map<String,Map<String,Map<String,Object>>> prepareField(Map<String,?> inputFields,Map<String,Object> queryStringMap,Map<String,List<Object[]>> origValueMap){
  Map<String,Map<String,Map<String,Object>>> normalizedFields=new LinkedHashMap<String,Map<String,Map<String,Object>>>();
  for (  String fieldNameRaw : inputFields.keySet()) {
    String fieldNameRoot=null;
    String fieldPair=null;
    Object fieldValue=null;
    int iPos=-1;
    int iPos2=-1;
    Map<String,Map<String,Object>> subMap=null;
    Map<String,Object> subMap2=null;
    String fieldMode=null;
    fieldValue=inputFields.get(fieldNameRaw);
    if (ObjectType.isEmpty(fieldValue)) {
      continue;
    }
    queryStringMap.put(fieldNameRaw,fieldValue);
    iPos=fieldNameRaw.indexOf("_");
    if (iPos >= 0) {
      String suffix=fieldNameRaw.substring(iPos + 1);
      iPos2=suffix.indexOf("_");
      if (iPos2 == 1) {
        continue;
      }
    }
    if (iPos < 0) {
      fieldNameRoot=fieldNameRaw;
      fieldPair="fld0";
      fieldMode="value";
    }
 else {
      fieldNameRoot=fieldNameRaw.substring(0,iPos);
      String suffix=fieldNameRaw.substring(iPos + 1);
      iPos2=suffix.indexOf("_");
      if (iPos2 < 0) {
        if (suffix.startsWith("fld")) {
          fieldPair=suffix;
          fieldMode="value";
        }
 else {
          fieldPair="fld0";
          fieldMode=suffix;
        }
      }
 else {
        String tkn0=suffix.substring(0,iPos2);
        String tkn1=suffix.substring(iPos2 + 1);
        if (tkn0.startsWith("fld")) {
          fieldPair=tkn0;
          fieldMode=tkn1;
        }
 else {
          fieldPair=tkn1;
          fieldMode=tkn0;
        }
      }
    }
    subMap=normalizedFields.get(fieldNameRoot);
    if (subMap == null) {
      subMap=new LinkedHashMap<String,Map<String,Object>>();
      normalizedFields.put(fieldNameRoot,subMap);
    }
    subMap2=subMap.get(fieldPair);
    if (subMap2 == null) {
      subMap2=new LinkedHashMap<String,Object>();
      subMap.put(fieldPair,subMap2);
    }
    subMap2.put(fieldMode,fieldValue);
    List<Object[]> origList=origValueMap.get(fieldNameRoot);
    if (origList == null) {
      origList=new LinkedList<Object[]>();
      origValueMap.put(fieldNameRoot,origList);
    }
    Object[] origValues={fieldNameRaw,fieldValue};
    origList.add(origValues);
  }
  return normalizedFields;
}

public static Map < String , Map < String , Map < String , Object > > > prepareField ( Map < String , ? > inputFields , Map < String , Object > queryStringMap , Map < String , List < Object [ ] > > origValueMap ) { Map < String , Map < String , Map < String , Object > > > normalizedFields = new LinkedHashMap < String , Map < String , Map < String , Object > > > ( ) ; for ( String fieldNameRaw : inputFields . keySet ( ) ) { String fieldNameRoot = null ; String fieldPair = null ; Object fieldValue = null ; int iPos = - 1 ; int iPos2 = - 1 ; Map < String , Map < String , Object > > subMap = null ; Map < String , Object > subMap2 = null ; String fieldMode = null ; fieldValue = inputFields . get ( fieldNameRaw ) ; if ( ObjectType . isEmpty ( fieldValue ) ) { continue ; } queryStringMap . put ( fieldNameRaw , fieldValue ) ; iPos = fieldNameRaw . indexOf ( "_" ) ; if ( iPos >= 0 ) { String suffix = fieldNameRaw . substring ( iPos + 1 ) ; iPos2 = suffix . indexOf ( "_" ) ; if ( iPos2 == 1 ) { continue ; } } if ( iPos < 0 ) { fieldNameRoot = fieldNameRaw ; fieldPair = "fld0" ; fieldMode = "value" ; } else { fieldNameRoot = fieldNameRaw . substring ( 0 , iPos ) ; String suffix = fieldNameRaw . substring ( iPos + 1 ) ; iPos2 = suffix . indexOf ( "_" ) ; if ( iPos2 < 0 ) { if ( suffix . startsWith ( "fld" ) ) { fieldPair = suffix ; fieldMode = "value" ; } else { fieldPair = "fld0" ; fieldMode = suffix ; } } else { String tkn0 = suffix . substring ( 0 , iPos2 ) ; String tkn1 = suffix . substring ( iPos2 + 1 ) ; if ( tkn0 . startsWith ( "fld" ) ) { fieldPair = tkn0 ; fieldMode = tkn1 ; } else { fieldPair = tkn1 ; fieldMode = tkn0 ; } } } subMap = normalizedFields . get ( fieldNameRoot ) ; if ( subMap == null ) { subMap = new LinkedHashMap < String , Map < String , Object > > ( ) ; normalizedFields . put ( fieldNameRoot , subMap ) ; } subMap2 = subMap . get ( fieldPair ) ; if ( subMap2 == null ) { subMap2 = new LinkedHashMap < String , Object > ( ) ; subMap . put ( fieldPair , subMap2 ) ; } subMap2 . put ( fieldMode , fieldValue ) ; List < Object [ ] > origList = origValueMap . get ( fieldNameRoot ) ; if ( origList == null ) { origList = new LinkedList < Object [ ] > ( ) ; origValueMap . put ( fieldNameRoot , origList ) ; } Object [ ] origValues = { fieldNameRaw , fieldValue } ; origList . add ( origValues ) ; } return normalizedFields ; }
preparefield , analyse inputfields to created normalizedfields a map with field name and operator . this is use to the generic method that expects entity data affixed with special suffixes to indicate their purpose in formulating an sql query statement .
