6
6
import java .rmi .UnmarshalException ;
7
7
import java .util .ArrayList ;
8
8
import java .util .HashMap ;
9
+ import java .util .HashSet ;
9
10
import java .util .List ;
10
11
import java .util .Map ;
11
12
import java .util .Map .Entry ;
@@ -600,7 +601,7 @@ public static String getKeyString(Query query, Result result, Entry<String, Obje
600
601
601
602
sb .append ("." );
602
603
603
- String typeName = cleanupStr (getConcatedTypeNameValues (typeNames , result .getTypeName ()));
604
+ String typeName = cleanupStr (getConcatedTypeNameValues (query , typeNames , result .getTypeName ()));
604
605
if (typeName != null ) {
605
606
sb .append (typeName );
606
607
sb .append ("." );
@@ -629,7 +630,7 @@ public static String getKeyString2(Query query, Result result, Entry<String, Obj
629
630
630
631
sb .append ("." );
631
632
632
- String typeName = cleanupStr (getConcatedTypeNameValues (typeNames , result .getTypeName ()));
633
+ String typeName = cleanupStr (getConcatedTypeNameValues (query , typeNames , result .getTypeName ()));
633
634
if (typeName != null ) {
634
635
sb .append (typeName );
635
636
sb .append ("." );
@@ -639,7 +640,8 @@ public static String getKeyString2(Query query, Result result, Entry<String, Obj
639
640
return sb .toString ();
640
641
}
641
642
642
- /**
643
+
644
+ /**
643
645
* Replaces all . with _ and removes all spaces and double/single quotes.
644
646
*/
645
647
public static String cleanupStr (String name ) {
@@ -677,6 +679,29 @@ public static String getConcatedTypeNameValues(List<String> typeNames, String ty
677
679
return StringUtils .chomp (sb .toString (), "_" );
678
680
}
679
681
682
+
683
+ /**
684
+ * Given a typeName string, get the first match from the typeNames setting.
685
+ * In other words, suppose you have:
686
+ *
687
+ * typeName=name=PS Eden Space,type=MemoryPool
688
+ *
689
+ * If you addTypeName("name"), then it'll retrieve 'PS Eden Space' from the string
690
+ */
691
+ public static String getConcatedTypeNameValues (Query query , List <String > typeNames , String typeName ) {
692
+ Set <String > queryTypeNames = query .getTypeNames ();
693
+ if (queryTypeNames != null && queryTypeNames .size () > 0 ) {
694
+ List <String > allNames = new ArrayList <String >(queryTypeNames );
695
+ for (String name : typeNames ) {
696
+ if (!allNames .contains (name )) {
697
+ allNames .add (name );
698
+ }
699
+ }
700
+ return getConcatedTypeNameValues (allNames , typeName );
701
+ } else {
702
+ return getConcatedTypeNameValues (typeNames , typeName );
703
+ }
704
+ }
680
705
/** */
681
706
private static String getTypeNameValue (String typeName , String [] tokens ) {
682
707
boolean foundIt = false ;
0 commit comments