test_class.declarator: FAST_SERVER_PORT = 8024
test_class.modifier: private static final
test_class.original_string: private static final int FAST_SERVER_PORT = 8024;
test_class.type: int
test_class.var_name: FAST_SERVER_PORT
test_class.declarator: service
test_class.modifier: private final
test_class.original_string: private final String service;
test_class.type: String
test_class.var_name: service
test_class.declarator: fastServerContainer
test_class.modifier: private static
test_class.original_string: private static ServerMock fastServerContainer;
test_class.type: ServerMock
test_class.var_name: fastServerContainer
test_class.declarator: fastServer
test_class.modifier: private static
test_class.original_string: private static ContainerServer fastServer;
test_class.type: ContainerServer
test_class.var_name: fastServer
test_class.declarator: fastConnection
test_class.modifier: private static
test_class.original_string: private static SocketConnection fastConnection;
test_class.type: SocketConnection
test_class.var_name: fastConnection
test_class.declarator: queryStr
test_class.modifier: private final
test_class.original_string: private final String queryStr;
test_class.type: String
test_class.var_name: queryStr
test_class.declarator: expectedConversionQuery
test_class.modifier: private final
test_class.original_string: private final Query expectedConversionQuery;
test_class.type: Query
test_class.var_name: expectedConversionQuery
test_class.declarator: vars
test_class.modifier: private final
test_class.original_string: private final String[] vars;
test_class.type: String[]
test_class.var_name: vars
test_class.declarator: expectedReplacedQuery
test_class.modifier: private final
test_class.original_string: private final String expectedReplacedQuery;
test_class.type: String
test_class.var_name: expectedReplacedQuery
test_class.declarator: expectedInstances
test_class.modifier: private final
test_class.original_string: private final List<String> expectedInstances;
test_class.type: List<String>
test_class.var_name: expectedInstances
test_class.declarator: dir = UUID.randomUUID().toString()
test_class.modifier: private
test_class.original_string: private String dir = UUID.randomUUID().toString();
test_class.type: String
test_class.var_name: dir
test_class.file: iguana.corecontroller/src/test/java/org/aksw/iguana/cc/query/impl/PatternQueryHandlerTest.java
test_class.identifier: PatternQueryHandlerTest
test_case.body: @Test
      public void testPatternExchange(){
          List<String> instances = getHandler().getInstances(queryStr);
          assertEquals(expectedInstances, instances);
          
      }
test_case.class_method_signature: PatternQueryHandlerTest.testPatternExchange()
test_case.full_signature: @Test public void testPatternExchange()
test_case.identifier: testPatternExchange
test_case.invocations: getInstances getHandler assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPatternExchange()
focal_class.declarator: LOGGER = LoggerFactory
  			.getLogger(PatternQueryHandler.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory
  			.getLogger(PatternQueryHandler.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: service
focal_class.modifier: private
focal_class.original_string: private String service;
focal_class.type: String
focal_class.var_name: service
focal_class.declarator: limit = 2000l
focal_class.modifier: private
focal_class.original_string: private Long limit = 2000l;
focal_class.type: Long
focal_class.var_name: limit
focal_class.file: iguana.corecontroller/src/main/java/org/aksw/iguana/cc/query/impl/PatternQueryHandler.java
focal_class.identifier: PatternQueryHandler
focal_class.class_method_signature: PatternQueryHandler.PatternQueryHandler(List<Worker> workers, String endpoint)
focal_class.full_signature: public  PatternQueryHandler(List<Worker> workers, String endpoint)
focal_class.identifier: PatternQueryHandler
focal_class.modifiers: public
focal_class.parameters: (List<Worker> workers, String endpoint)
focal_class.signature:  PatternQueryHandler(List<Worker> workers, String endpoint)
focal_class.class_method_signature: PatternQueryHandler.PatternQueryHandler(LinkedList<Worker> workers, String endpoint, String limit)
focal_class.full_signature: public  PatternQueryHandler(LinkedList<Worker> workers, String endpoint, String limit)
focal_class.identifier: PatternQueryHandler
focal_class.modifiers: public
focal_class.parameters: (LinkedList<Worker> workers, String endpoint, String limit)
focal_class.signature:  PatternQueryHandler(LinkedList<Worker> workers, String endpoint, String limit)
focal_class.class_method_signature: PatternQueryHandler.PatternQueryHandler(LinkedList<Worker> workers, String endpoint, Long limit)
focal_class.full_signature: public  PatternQueryHandler(LinkedList<Worker> workers, String endpoint, Long limit)
focal_class.identifier: PatternQueryHandler
focal_class.modifiers: public
focal_class.parameters: (LinkedList<Worker> workers, String endpoint, Long limit)
focal_class.signature:  PatternQueryHandler(LinkedList<Worker> workers, String endpoint, Long limit)
focal_class.class_method_signature: PatternQueryHandler.replaceVars(String queryStr, Set<String> varNames)
focal_class.full_signature: protected String replaceVars(String queryStr, Set<String> varNames)
focal_class.identifier: replaceVars
focal_class.modifiers: protected
focal_class.parameters: (String queryStr, Set<String> varNames)
focal_class.return: String
focal_class.signature: String replaceVars(String queryStr, Set<String> varNames)
focal_class.class_method_signature: PatternQueryHandler.getInstances(String queryStr)
focal_class.full_signature: @Override protected List<String> getInstances(String queryStr)
focal_class.identifier: getInstances
focal_class.modifiers: @Override protected
focal_class.parameters: (String queryStr)
focal_class.return: List<String>
focal_class.signature: List<String> getInstances(String queryStr)
focal_class.class_method_signature: PatternQueryHandler.getInstanceVars(ParameterizedSparqlString pss, Set<String> varNames)
focal_class.full_signature: protected ResultSet getInstanceVars(ParameterizedSparqlString pss, Set<String> varNames)
focal_class.identifier: getInstanceVars
focal_class.modifiers: protected
focal_class.parameters: (ParameterizedSparqlString pss, Set<String> varNames)
focal_class.return: ResultSet
focal_class.signature: ResultSet getInstanceVars(ParameterizedSparqlString pss, Set<String> varNames)
focal_class.class_method_signature: PatternQueryHandler.convertToSelect(ParameterizedSparqlString pss, Set<String> varNames)
focal_class.full_signature: protected Query convertToSelect(ParameterizedSparqlString pss, Set<String> varNames)
focal_class.identifier: convertToSelect
focal_class.modifiers: protected
focal_class.parameters: (ParameterizedSparqlString pss, Set<String> varNames)
focal_class.return: Query
focal_class.signature: Query convertToSelect(ParameterizedSparqlString pss, Set<String> varNames)
focal_class.superclass: extends InstancesQueryHandler
focal_method.body: @Override
  	protected List<String> getInstances(String queryStr) {
  		List<String> instances = new ArrayList<>();
  
  		//check if query is already an instance
  		try{
  			QueryFactory.create(queryStr);
  			//query is instance
  			LOGGER.debug("[QueryHandler: {{}}] Query is already an instance: {{}}", this.getClass().getName(), queryStr);
  			instances.add(queryStr);
  			return instances;
  		}catch(Exception e) {
  			//query is pattern, nothing to do
  		}
  		
  		//get vars from queryStr
  		Set<String> varNames = new HashSet<String>();
  		String command = replaceVars(queryStr, varNames);
  		
  		//generate parameterized sparql query
  		ParameterizedSparqlString pss = new ParameterizedSparqlString();
  		pss.setCommandText(command);
  		ResultSet exchange = getInstanceVars(pss, varNames);		
  		// exchange vars in PSS
  		if(!exchange.hasNext()) {
  			//no solution
  			LOGGER.warn("[QueryHandler: {{}}] Query has no solution, will use variables instead of var instances: {{}}", this.getClass().getName(), queryStr);
  			instances.add(command);
  		}
  		while(exchange.hasNext()) {
  			QuerySolution solution = exchange.next();
  			for(String var : exchange.getResultVars()) {
  				//exchange variable with 
  				pss.clearParam(var);
  				pss.setParam(var, solution.get(var));
  			}
  			instances.add(pss.toString());
  		}
  		LOGGER.debug("Found instances {}", instances);
  
  		return instances;
  	}
focal_method.class_method_signature: PatternQueryHandler.getInstances(String queryStr)
focal_method.full_signature: @Override protected List<String> getInstances(String queryStr)
focal_method.identifier: getInstances
focal_method.invocations: create debug getName getClass add replaceVars setCommandText getInstanceVars hasNext warn getName getClass add hasNext next getResultVars clearParam setParam get add toString debug
focal_method.modifiers: @Override protected
focal_method.parameters: (String queryStr)
focal_method.return: List<String>
focal_method.signature: List<String> getInstances(String queryStr)