blob: 72fe7dc5db6eaa8e0696dc43ec291cf01268c2d9 [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2010, 2017 Stephan Wahlbrink and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.r.core.rhelp;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.statet.jcommons.collections.ImCollections;
import org.eclipse.statet.jcommons.collections.ImList;
import org.eclipse.statet.internal.r.core.rhelp.index.IREnvIndex;
import org.eclipse.statet.internal.r.core.rhelp.index.SearchQuery;
import org.eclipse.statet.r.core.renv.IREnv;
public class RHelpSearchQuery {
public static final int TOPIC_SEARCH= 1;
public static final int FIELD_SEARCH= 2;
public static final int DOC_SEARCH= 3;
public static final String TOPICS_FIELD= IREnvIndex.ALIAS_TXT_FIELD_NAME;
public static final String TITLE_FIELD= IREnvIndex.TITLE_TXT_FIELD_NAME;
public static final String CONCEPTS_FIELD= IREnvIndex.CONCEPT_TXT_FIELD_NAME;
public static class Compiled extends RHelpSearchQuery {
private final Object compiled;
public Compiled(final RHelpSearchQuery org, final Object compiled) {
super(org.getSearchType(),
org.getSearchString(),
org.getEnabledFields(),
org.getKeywords(),
org.getPackages(),
org.getREnv().resolve() );
this.compiled= compiled;
}
@Override
public Compiled compile() {
return this;
}
public Object compiled() {
return this.compiled;
}
}
private final int searchType;
private final String searchText;
private final ImList<String> fields;
private final ImList<String> keywords;
private final ImList<String> packages;
private final IREnv rEnv;
/**
* @param type
* @param text
* @param fields
* @param keywords
* @param packages
*/
public RHelpSearchQuery(final int type, final String text, final List<String> fields,
final List<String> keywords, final List<String> packages, final IREnv rEnv) {
this.searchType= type;
this.searchText= text;
this.fields= ImCollections.toList(fields);
this.keywords= ImCollections.toList(keywords);
this.packages= ImCollections.toList(packages);
this.rEnv= rEnv;
}
public IREnv getREnv() {
return this.rEnv;
}
public int getSearchType() {
return this.searchType;
}
public String getSearchString() {
return this.searchText;
}
public ImList<String> getEnabledFields() {
return this.fields;
}
public ImList<String> getKeywords() {
return this.keywords;
}
public ImList<String> getPackages() {
return this.packages;
}
public RHelpSearchQuery.Compiled compile() throws CoreException {
final Object compiled= SearchQuery.compile(this);
return new RHelpSearchQuery.Compiled(this, compiled);
}
@Override
public String toString() {
return this.searchText;
}
}