mirror of https://github.com/apache/lucene.git
SOLR-2288: more small tweaks to eliminate compiler warnings .. inlcudes a small code de-dup refactoring in FieldAnalysisResponse
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1056594 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
abfa458e2a
commit
98b448aa8c
|
@ -62,12 +62,12 @@ public class AnalysisResponseBase extends SolrResponseBase {
|
|||
*
|
||||
* @return The built analysis phases list.
|
||||
*/
|
||||
protected List<AnalysisPhase> buildPhases(NamedList<Object> phaseNL) {
|
||||
protected List<AnalysisPhase> buildPhases(NamedList<List<NamedList<Object>>> phaseNL) {
|
||||
List<AnalysisPhase> phases = new ArrayList<AnalysisPhase>(phaseNL.size());
|
||||
for (Map.Entry<String, Object> phaseEntry : phaseNL) {
|
||||
for (Map.Entry<String, List<NamedList<Object>>> phaseEntry : phaseNL) {
|
||||
AnalysisPhase phase = new AnalysisPhase(phaseEntry.getKey());
|
||||
List<NamedList> tokens = (List<NamedList>) phaseEntry.getValue();
|
||||
for (NamedList token : tokens) {
|
||||
List<NamedList<Object>> tokens = phaseEntry.getValue();
|
||||
for (NamedList<Object> token : tokens) {
|
||||
TokenInfo tokenInfo = buildTokenInfo(token);
|
||||
phase.addTokenInfo(tokenInfo);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class AnalysisResponseBase extends SolrResponseBase {
|
|||
*
|
||||
* @return The built token info.
|
||||
*/
|
||||
protected TokenInfo buildTokenInfo(NamedList tokenNL) {
|
||||
protected TokenInfo buildTokenInfo(NamedList<Object> tokenNL) {
|
||||
String text = (String) tokenNL.get("text");
|
||||
String rawText = (String) tokenNL.get("rawText");
|
||||
String type = (String) tokenNL.get("type");
|
||||
|
|
|
@ -42,24 +42,30 @@ public class DocumentAnalysisResponse extends AnalysisResponseBase implements It
|
|||
public void setResponse(NamedList<Object> response) {
|
||||
super.setResponse(response);
|
||||
|
||||
NamedList<Object> analysis = (NamedList<Object>) response.get("analysis");
|
||||
for (Map.Entry<String, Object> documentEntry : analysis) {
|
||||
DocumentAnalysis documentAnalysis = new DocumentAnalysis(documentEntry.getKey());
|
||||
NamedList<Object> document = (NamedList<Object>) documentEntry.getValue();
|
||||
for (Map.Entry<String, Object> fieldEntry : document) {
|
||||
@SuppressWarnings("unchecked")
|
||||
NamedList<NamedList<NamedList<Object>>> analysis
|
||||
= (NamedList<NamedList<NamedList<Object>>>) response.get("analysis");
|
||||
for (Map.Entry<String, NamedList<NamedList<Object>>> document : analysis) {
|
||||
DocumentAnalysis documentAnalysis = new DocumentAnalysis(document.getKey());
|
||||
for (Map.Entry<String, NamedList<Object>> fieldEntry : document.getValue()) {
|
||||
FieldAnalysis fieldAnalysis = new FieldAnalysis(fieldEntry.getKey());
|
||||
NamedList field = (NamedList) fieldEntry.getValue();
|
||||
|
||||
NamedList<Object> query = (NamedList<Object>) field.get("query");
|
||||
NamedList<Object> field = fieldEntry.getValue();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
NamedList<List<NamedList<Object>>> query
|
||||
= (NamedList<List<NamedList<Object>>>) field.get("query");
|
||||
if (query != null) {
|
||||
List<AnalysisPhase> phases = buildPhases(query);
|
||||
fieldAnalysis.setQueryPhases(phases);
|
||||
}
|
||||
|
||||
NamedList<Object> index = (NamedList<Object>) field.get("index");
|
||||
for (Map.Entry<String, Object> valueEntry : index) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
NamedList<NamedList<List<NamedList<Object>>>> index
|
||||
= (NamedList<NamedList<List<NamedList<Object>>>>) field.get("index");
|
||||
for (Map.Entry<String, NamedList<List<NamedList<Object>>>> valueEntry : index) {
|
||||
String fieldValue = valueEntry.getKey();
|
||||
NamedList<Object> valueNL = (NamedList<Object>) valueEntry.getValue();
|
||||
NamedList<List<NamedList<Object>>> valueNL = valueEntry.getValue();
|
||||
List<AnalysisPhase> phases = buildPhases(valueNL);
|
||||
fieldAnalysis.setIndexPhases(fieldValue, phases);
|
||||
}
|
||||
|
|
|
@ -42,35 +42,35 @@ public class FieldAnalysisResponse extends AnalysisResponseBase {
|
|||
public void setResponse(NamedList<Object> response) {
|
||||
super.setResponse(response);
|
||||
|
||||
NamedList analysisNL = (NamedList) response.get("analysis");
|
||||
@SuppressWarnings("unchecked")
|
||||
NamedList<NamedList<NamedList<NamedList<List<NamedList<Object>>>>>> analysisNL
|
||||
= (NamedList<NamedList<NamedList<NamedList<List<NamedList<Object>>>>>>) response.get("analysis");
|
||||
|
||||
NamedList<Object> fieldTypesNL = (NamedList<Object>) analysisNL.get("field_types");
|
||||
for (Map.Entry<String, Object> entry : fieldTypesNL) {
|
||||
Analysis analysis = new Analysis();
|
||||
NamedList fieldTypeNL = (NamedList) entry.getValue();
|
||||
NamedList<Object> queryNL = (NamedList<Object>) fieldTypeNL.get("query");
|
||||
List<AnalysisPhase> phases = (queryNL == null) ? null : buildPhases(queryNL);
|
||||
analysis.setQueryPhases(phases);
|
||||
NamedList<Object> indexNL = (NamedList<Object>) fieldTypeNL.get("index");
|
||||
phases = buildPhases(indexNL);
|
||||
analysis.setIndexPhases(phases);
|
||||
String fieldTypeName = entry.getKey();
|
||||
analysisByFieldTypeName.put(fieldTypeName, analysis);
|
||||
for (Map.Entry<String, NamedList<NamedList<List<NamedList<Object>>>>> entry
|
||||
: analysisNL.get("field_types")) {
|
||||
|
||||
analysisByFieldTypeName.put(entry.getKey(), buildAnalysis(entry.getValue()));
|
||||
}
|
||||
|
||||
NamedList<Object> fieldNamesNL = (NamedList<Object>) analysisNL.get("field_names");
|
||||
for (Map.Entry<String, Object> entry : fieldNamesNL) {
|
||||
for (Map.Entry<String, NamedList<NamedList<List<NamedList<Object>>>>> entry
|
||||
: analysisNL.get("field_names")) {
|
||||
|
||||
analysisByFieldName.put(entry.getKey(), buildAnalysis(entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
private Analysis buildAnalysis(NamedList<NamedList<List<NamedList<Object>>>> value) {
|
||||
Analysis analysis = new Analysis();
|
||||
NamedList fieldNameNL = (NamedList) entry.getValue();
|
||||
NamedList<Object> queryNL = (NamedList<Object>) fieldNameNL.get("query");
|
||||
|
||||
NamedList<List<NamedList<Object>>> queryNL = value.get("query");
|
||||
List<AnalysisPhase> phases = (queryNL == null) ? null : buildPhases(queryNL);
|
||||
analysis.setQueryPhases(phases);
|
||||
NamedList<Object> indexNL = (NamedList<Object>) fieldNameNL.get("index");
|
||||
|
||||
NamedList<List<NamedList<Object>>> indexNL = value.get("index");
|
||||
phases = buildPhases(indexNL);
|
||||
analysis.setIndexPhases(phases);
|
||||
String fieldName = entry.getKey();
|
||||
analysisByFieldName.put(fieldName, analysis);
|
||||
}
|
||||
|
||||
return analysis;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue