id
int32
0
12.9k
code
sequencelengths
2
264k
8,800
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "DefaultTableAccessStrategy", "extends", "TableAccessStrategy", "{", "public", "DefaultTableAccessStrategy", "(", ")", "{", "super", "(", ")", ";", "}", "public", "DefaultTableAccessStrategy", "(", "QueryNode", "node", ")", "{", "super", "(", "node", ")", ";", "}", "}", "</s>" ]
8,801
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "public", "class", "AnnotateQueryData", "{", "private", "int", "left", ";", "private", "int", "right", ";", "private", "String", "segmentationLayer", ";", "public", "AnnotateQueryData", "(", "int", "left", ",", "int", "right", ")", "{", "this", "(", "left", ",", "right", ",", "null", ")", ";", "}", "public", "AnnotateQueryData", "(", "int", "left", ",", "int", "right", ",", "String", "segmentationLayer", ")", "{", "super", "(", ")", ";", "this", ".", "left", "=", "left", ";", "this", ".", "right", "=", "right", ";", "this", ".", "segmentationLayer", "=", "segmentationLayer", ";", "}", "public", "int", "getLeft", "(", ")", "{", "return", "left", ";", "}", "public", "int", "getRight", "(", ")", "{", "return", "right", ";", "}", "public", "String", "getSegmentationLayer", "(", ")", "{", "return", "segmentationLayer", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "List", "<", "String", ">", "fields", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "if", "(", "left", ">", "0", ")", "{", "fields", ".", "add", "(", "\"left", "=", "\"", "+", "left", ")", ";", "}", "if", "(", "right", ">", "0", ")", "{", "fields", ".", "add", "(", "\"right", "=", "\"", "+", "right", ")", ";", "}", "if", "(", "segmentationLayer", "!=", "null", ")", "{", "fields", ".", "add", "(", "\"segLayer", "=", "\"", "+", "segmentationLayer", ")", ";", "}", "return", "StringUtils", ".", "join", "(", "fields", ",", "\",", "\"", ")", ";", "}", "}", "</s>" ]
8,802
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "model", ".", "AnnisConstants", ".", "*", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "COMPONENT_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "EDGE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "RANK_TABLE", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "TreeMap", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "common", ".", "util", ".", "EList", ";", "import", "org", ".", "eclipse", ".", "emf", ".", "common", ".", "util", ".", "URI", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "SaltFactory", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "graph", ".", "Edge", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltProject", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "exceptions", ".", "SaltException", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SCorpus", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SCorpusGraph", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sCorpusStructure", ".", "SDocument", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "sDocumentStructure", ".", "*", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SAnnotation", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SFeature", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SGraph", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SLayer", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SMetaAnnotation", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SNode", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SProcessingAnnotation", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCore", ".", "SRelation", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "SaltAnnotateExtractor", "implements", "AnnotateExtractor", "<", "SaltProject", ">", "{", "private", "static", "final", "org", ".", "slf4j", ".", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "SaltAnnotateExtractor", ".", "class", ")", ";", "private", "TableAccessStrategy", "outerQueryTableAccessStrategy", ";", "private", "CorpusPathExtractor", "corpusPathExtractor", ";", "public", "SaltAnnotateExtractor", "(", ")", "{", "}", "@", "Override", "public", "SaltProject", "extractData", "(", "ResultSet", "resultSet", ")", "throws", "SQLException", ",", "DataAccessException", "{", "SaltProject", "project", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSaltProject", "(", ")", ";", "try", "{", "SCorpusGraph", "corpusGraph", "=", "null", ";", "SDocumentGraph", "graph", "=", "null", ";", "Map", "<", "RankID", ",", "SNode", ">", "nodeByPre", "=", "new", "HashMap", "<", "RankID", ",", "SNode", ">", "(", ")", ";", "TreeMap", "<", "Long", ",", "String", ">", "tokenTexts", "=", "new", "TreeMap", "<", "Long", ",", "String", ">", "(", ")", ";", "TreeMap", "<", "Long", ",", "SToken", ">", "tokenByIndex", "=", "new", "TreeMap", "<", "Long", ",", "SToken", ">", "(", ")", ";", "TreeMap", "<", "String", ",", "TreeMap", "<", "Long", ",", "String", ">", ">", "nodeBySegmentationPath", "=", "new", "TreeMap", "<", "String", ",", "TreeMap", "<", "Long", ",", "String", ">", ">", "(", ")", ";", "nodeByPre", ".", "clear", "(", ")", ";", "SDocument", "document", "=", "null", ";", "String", "[", "]", "keyNameList", "=", "new", "String", "[", "0", "]", ";", "int", "match_index", "=", "0", ";", "SolutionKey", "<", "?", ">", "key", "=", "createSolutionKey", "(", ")", ";", "while", "(", "resultSet", ".", "next", "(", ")", ")", "{", "key", ".", "retrieveKey", "(", "resultSet", ")", ";", "if", "(", "key", ".", "isNewKey", "(", ")", ")", "{", "if", "(", "graph", "!=", "null", "&&", "document", "!=", "null", ")", "{", "createPrimaryText", "(", "graph", ",", "tokenTexts", ",", "tokenByIndex", ")", ";", "setMatchedIDs", "(", "document", ",", "keyNameList", ")", ";", "addOrderingRelations", "(", "graph", ",", "nodeBySegmentationPath", ")", ";", "}", "nodeByPre", ".", "clear", "(", ")", ";", "tokenTexts", ".", "clear", "(", ")", ";", "tokenByIndex", ".", "clear", "(", ")", ";", "keyNameList", "=", "new", "String", "[", "key", ".", "getKeySize", "(", ")", "]", ";", "Integer", "matchstart", "=", "resultSet", ".", "getInt", "(", "\"matchstart\"", ")", ";", "corpusGraph", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSCorpusGraph", "(", ")", ";", "corpusGraph", ".", "setSName", "(", "\"match_\"", "+", "(", "match_index", "+", "matchstart", ")", ")", ";", "project", ".", "getSCorpusGraphs", "(", ")", ".", "add", "(", "corpusGraph", ")", ";", "graph", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSDocumentGraph", "(", ")", ";", "document", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSDocument", "(", ")", ";", "List", "<", "String", ">", "path", "=", "corpusPathExtractor", ".", "extractCorpusPath", "(", "resultSet", ",", "\"path\"", ")", ";", "SCorpus", "toplevelCorpus", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSCorpus", "(", ")", ";", "toplevelCorpus", ".", "setSName", "(", "path", ".", "get", "(", "0", ")", ")", ";", "corpusGraph", ".", "addSNode", "(", "toplevelCorpus", ")", ";", "Validate", ".", "isTrue", "(", "path", ".", "size", "(", ")", ">=", "2", ",", "\"\"", ")", ";", "SCorpus", "corpus", "=", "toplevelCorpus", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "path", ".", "size", "(", ")", "-", "1", ";", "i", "++", ")", "{", "SCorpus", "subcorpus", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSCorpus", "(", ")", ";", "subcorpus", ".", "setSName", "(", "path", ".", "get", "(", "i", ")", ")", ";", "corpusGraph", ".", "addSSubCorpus", "(", "corpus", ",", "subcorpus", ")", ";", "corpus", "=", "subcorpus", ";", "}", "document", ".", "setSName", "(", "path", ".", "get", "(", "path", ".", "size", "(", ")", "-", "1", ")", ")", ";", "corpusGraph", ".", "addSDocument", "(", "corpus", ",", "document", ")", ";", "document", ".", "setSDocumentGraph", "(", "graph", ")", ";", "match_index", "++", ";", "}", "SNode", "node", "=", "createOrFindNewNode", "(", "resultSet", ",", "graph", ",", "tokenTexts", ",", "tokenByIndex", ",", "nodeBySegmentationPath", ",", "key", ",", "keyNameList", ")", ";", "long", "pre", "=", "longValue", "(", "resultSet", ",", "RANK_TABLE", ",", "\"pre\"", ")", ";", "long", "componentID", "=", "longValue", "(", "resultSet", ",", "RANK_TABLE", ",", "\"component_id\"", ")", ";", "if", "(", "!", "resultSet", ".", "wasNull", "(", ")", ")", "{", "nodeByPre", ".", "put", "(", "new", "RankID", "(", "componentID", ",", "pre", ")", ",", "node", ")", ";", "createRelation", "(", "resultSet", ",", "graph", ",", "nodeByPre", ",", "node", ")", ";", "}", "}", "if", "(", "graph", "!=", "null", ")", "{", "createPrimaryText", "(", "graph", ",", "tokenTexts", ",", "tokenByIndex", ")", ";", "setMatchedIDs", "(", "document", ",", "keyNameList", ")", ";", "addOrderingRelations", "(", "graph", ",", "nodeBySegmentationPath", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "return", "project", ";", "}", "private", "void", "addOrderingRelations", "(", "SDocumentGraph", "graph", ",", "TreeMap", "<", "String", ",", "TreeMap", "<", "Long", ",", "String", ">", ">", "nodeBySegmentationPath", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "TreeMap", "<", "Long", ",", "String", ">", ">", "e", ":", "nodeBySegmentationPath", ".", "entrySet", "(", ")", ")", "{", "TreeMap", "<", "Long", ",", "String", ">", "nodeBySegIndex", "=", "e", ".", "getValue", "(", ")", ";", "SNode", "lastNode", "=", "null", ";", "for", "(", "String", "nodeID", ":", "nodeBySegIndex", ".", "values", "(", ")", ")", "{", "SNode", "n", "=", "graph", ".", "getSNode", "(", "nodeID", ")", ";", "if", "(", "lastNode", "!=", "null", "&&", "n", "!=", "null", ")", "{", "SOrderRelation", "orderRel", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSOrderRelation", "(", ")", ";", "orderRel", ".", "setSSource", "(", "lastNode", ")", ";", "orderRel", ".", "setSTarget", "(", "n", ")", ";", "orderRel", ".", "addSType", "(", "e", ".", "getKey", "(", ")", ")", ";", "graph", ".", "addSRelation", "(", "orderRel", ")", ";", "}", "lastNode", "=", "n", ";", "}", "}", "}", "private", "void", "setMatchedIDs", "(", "SDocument", "document", ",", "String", "[", "]", "keyNameList", ")", "{", "SFeature", "feature", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSFeature", "(", ")", ";", "feature", ".", "setSNS", "(", "ANNIS_NS", ")", ";", "feature", ".", "setSName", "(", "FEAT_MATCHEDIDS", ")", ";", "String", "val", "=", "StringUtils", ".", "join", "(", "keyNameList", ",", "\",\"", ")", ";", "feature", ".", "setSValue", "(", "val", ")", ";", "document", ".", "addSFeature", "(", "feature", ")", ";", "}", "private", "void", "createPrimaryText", "(", "SDocumentGraph", "graph", ",", "TreeMap", "<", "Long", ",", "String", ">", "tokenTexts", ",", "TreeMap", "<", "Long", ",", "SToken", ">", "tokenByIndex", ")", "{", "STextualDS", "textDataSource", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSTextualDS", "(", ")", ";", "graph", ".", "addSNode", "(", "textDataSource", ")", ";", "StringBuilder", "sbText", "=", "new", "StringBuilder", "(", ")", ";", "Iterator", "<", "Map", ".", "Entry", "<", "Long", ",", "String", ">", ">", "itToken", "=", "tokenTexts", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "itToken", ".", "hasNext", "(", ")", ")", "{", "Map", ".", "Entry", "<", "Long", ",", "String", ">", "e", "=", "itToken", ".", "next", "(", ")", ";", "SToken", "tok", "=", "tokenByIndex", ".", "get", "(", "e", ".", "getKey", "(", ")", ")", ";", "STextualRelation", "textRel", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSTextualRelation", "(", ")", ";", "textRel", ".", "setSSource", "(", "tok", ")", ";", "textRel", ".", "setSTarget", "(", "textDataSource", ")", ";", "textRel", ".", "setSStart", "(", "sbText", ".", "length", "(", ")", ")", ";", "textRel", ".", "setSEnd", "(", "sbText", ".", "length", "(", ")", "+", "e", ".", "getValue", "(", ")", ".", "length", "(", ")", ")", ";", "textRel", ".", "setSTextualDS", "(", "textDataSource", ")", ";", "graph", ".", "addSRelation", "(", "textRel", ")", ";", "sbText", ".", "append", "(", "e", ".", "getValue", "(", ")", ")", ";", "if", "(", "itToken", ".", "hasNext", "(", ")", ")", "{", "sbText", ".", "append", "(", "\"", "\"", ")", ";", "}", "}", "textDataSource", ".", "setSText", "(", "sbText", ".", "toString", "(", ")", ")", ";", "}", "private", "SNode", "createOrFindNewNode", "(", "ResultSet", "resultSet", ",", "SDocumentGraph", "graph", ",", "TreeMap", "<", "Long", ",", "String", ">", "tokenTexts", ",", "TreeMap", "<", "Long", ",", "SToken", ">", "tokenByIndex", ",", "TreeMap", "<", "String", ",", "TreeMap", "<", "Long", ",", "String", ">", ">", "nodeBySegmentationPath", ",", "SolutionKey", "<", "?", ">", "key", ",", "String", "[", "]", "keyNameList", ")", "throws", "SQLException", "{", "String", "name", "=", "stringValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"node_name\"", ")", ";", "long", "internalID", "=", "longValue", "(", "resultSet", ",", "\"node\"", ",", "\"id\"", ")", ";", "long", "tokenIndex", "=", "longValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"token_index\"", ")", ";", "boolean", "isToken", "=", "!", "resultSet", ".", "wasNull", "(", ")", ";", "URI", "nodeURI", "=", "graph", ".", "getSElementPath", "(", ")", ";", "nodeURI", "=", "nodeURI", ".", "appendFragment", "(", "name", ")", ";", "SStructuredNode", "node", "=", "(", "SStructuredNode", ")", "graph", ".", "getSNode", "(", "nodeURI", ".", "toString", "(", ")", ")", ";", "if", "(", "node", "==", "null", ")", "{", "if", "(", "isToken", ")", "{", "SToken", "tok", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSToken", "(", ")", ";", "node", "=", "tok", ";", "tokenTexts", ".", "put", "(", "tokenIndex", ",", "stringValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"span\"", ")", ")", ";", "tokenByIndex", ".", "put", "(", "tokenIndex", ",", "tok", ")", ";", "}", "else", "{", "SStructure", "struct", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSStructure", "(", ")", ";", "node", "=", "struct", ";", "}", "node", ".", "setSName", "(", "name", ")", ";", "graph", ".", "addNode", "(", "node", ")", ";", "addLongSFeature", "(", "node", ",", "FEAT_INTERNALID", ",", "internalID", ")", ";", "addLongSFeature", "(", "node", ",", "resultSet", ",", "FEAT_CORPUSREF", ",", "\"node\"", ",", "\"corpus_ref\"", ")", ";", "addLongSFeature", "(", "node", ",", "resultSet", ",", "FEAT_TEXTREF", ",", "\"node\"", ",", "\"text_ref\"", ")", ";", "addLongSFeature", "(", "node", ",", "resultSet", ",", "FEAT_LEFT", ",", "\"node\"", ",", "\"left\"", ")", ";", "addLongSFeature", "(", "node", ",", "resultSet", ",", "FEAT_LEFTTOKEN", ",", "\"node\"", ",", "\"left_token\"", ")", ";", "addLongSFeature", "(", "node", ",", "resultSet", ",", "FEAT_RIGHT", ",", "\"node\"", ",", "\"right\"", ")", ";", "addLongSFeature", "(", "node", ",", "resultSet", ",", "FEAT_RIGHTTOKEN", ",", "\"node\"", ",", "\"right_token\"", ")", ";", "addLongSFeature", "(", "node", ",", "resultSet", ",", "FEAT_TOKENINDEX", ",", "\"node\"", ",", "\"token_index\"", ")", ";", "addLongSFeature", "(", "node", ",", "resultSet", ",", "FEAT_SEGLEFT", ",", "\"node\"", ",", "\"seg_left\"", ")", ";", "addLongSFeature", "(", "node", ",", "resultSet", ",", "FEAT_SEGRIGHT", ",", "\"node\"", ",", "\"seg_right\"", ")", ";", "addStringSFeature", "(", "node", ",", "resultSet", ",", "FEAT_SEGNAME", ",", "\"node\"", ",", "\"seg_name\"", ")", ";", "Object", "nodeId", "=", "key", ".", "getNodeId", "(", "resultSet", ",", "outerQueryTableAccessStrategy", ")", ";", "Integer", "matchedNode", "=", "key", ".", "getMatchedNodeIndex", "(", "nodeId", ")", ";", "if", "(", "matchedNode", "!=", "null", ")", "{", "addLongSFeature", "(", "node", ",", "FEAT_MATCHEDNODE", ",", "matchedNode", ")", ";", "keyNameList", "[", "matchedNode", "-", "1", "]", "=", "node", ".", "getSName", "(", ")", ";", "}", "String", "namespace", "=", "stringValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"namespace\"", ")", ";", "EList", "<", "SLayer", ">", "layerList", "=", "graph", ".", "getSLayerByName", "(", "namespace", ")", ";", "SLayer", "layer", "=", "(", "layerList", "!=", "null", "&&", "layerList", ".", "size", "(", ")", ">", "0", ")", "?", "layerList", ".", "get", "(", "0", ")", ":", "null", ";", "if", "(", "layer", "==", "null", ")", "{", "layer", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSLayer", "(", ")", ";", "layer", ".", "setSName", "(", "namespace", ")", ";", "graph", ".", "addSLayer", "(", "layer", ")", ";", "}", "node", ".", "getSLayers", "(", ")", ".", "add", "(", "layer", ")", ";", "}", "String", "nodeAnnoValue", "=", "stringValue", "(", "resultSet", ",", "NODE_ANNOTATION_TABLE", ",", "\"value\"", ")", ";", "String", "nodeAnnoNameSpace", "=", "stringValue", "(", "resultSet", ",", "NODE_ANNOTATION_TABLE", ",", "\"namespace\"", ")", ";", "String", "nodeAnnoName", "=", "stringValue", "(", "resultSet", ",", "NODE_ANNOTATION_TABLE", ",", "\"name\"", ")", ";", "if", "(", "!", "resultSet", ".", "wasNull", "(", ")", ")", "{", "String", "fullName", "=", "(", "nodeAnnoNameSpace", "==", "null", "?", "\"\"", ":", "(", "nodeAnnoNameSpace", "+", "\"::\"", ")", ")", "+", "nodeAnnoName", ";", "SAnnotation", "anno", "=", "node", ".", "getSAnnotation", "(", "fullName", ")", ";", "if", "(", "anno", "==", "null", ")", "{", "anno", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSAnnotation", "(", ")", ";", "anno", ".", "setSNS", "(", "nodeAnnoNameSpace", ")", ";", "anno", ".", "setSName", "(", "nodeAnnoName", ")", ";", "anno", ".", "setSValue", "(", "nodeAnnoValue", ")", ";", "node", ".", "addSAnnotation", "(", "anno", ")", ";", "}", "}", "String", "segName", "=", "stringValue", "(", "resultSet", ",", "\"node\"", ",", "\"seg_name\"", ")", ";", "if", "(", "segName", "!=", "null", ")", "{", "long", "left", "=", "longValue", "(", "resultSet", ",", "\"node\"", ",", "\"seg_left\"", ")", ";", "long", "right", "=", "longValue", "(", "resultSet", ",", "\"node\"", ",", "\"seg_right\"", ")", ";", "if", "(", "left", "==", "right", ")", "{", "if", "(", "!", "nodeBySegmentationPath", ".", "containsKey", "(", "segName", ")", ")", "{", "nodeBySegmentationPath", ".", "put", "(", "segName", ",", "new", "TreeMap", "<", "Long", ",", "String", ">", "(", ")", ")", ";", "}", "nodeBySegmentationPath", ".", "get", "(", "segName", ")", ".", "put", "(", "left", ",", "node", ".", "getSId", "(", ")", ")", ";", "}", "}", "return", "node", ";", "}", "private", "void", "addLongSFeature", "(", "SNode", "node", ",", "String", "name", ",", "long", "value", ")", "throws", "SQLException", "{", "SFeature", "feat", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSFeature", "(", ")", ";", "feat", ".", "setSNS", "(", "ANNIS_NS", ")", ";", "feat", ".", "setSName", "(", "name", ")", ";", "feat", ".", "setSValue", "(", "value", ")", ";", "node", ".", "addSFeature", "(", "feat", ")", ";", "}", "private", "void", "addStringSFeature", "(", "SNode", "node", ",", "String", "name", ",", "String", "value", ")", "throws", "SQLException", "{", "SFeature", "feat", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSFeature", "(", ")", ";", "feat", ".", "setSNS", "(", "ANNIS_NS", ")", ";", "feat", ".", "setSName", "(", "name", ")", ";", "feat", ".", "setSValue", "(", "value", ")", ";", "node", ".", "addSFeature", "(", "feat", ")", ";", "}", "private", "void", "addLongSFeature", "(", "SNode", "node", ",", "ResultSet", "resultSet", ",", "String", "name", ",", "String", "table", ",", "String", "tupleName", ")", "throws", "SQLException", "{", "addLongSFeature", "(", "node", ",", "name", ",", "longValue", "(", "resultSet", ",", "table", ",", "tupleName", ")", ")", ";", "}", "private", "void", "addStringSFeature", "(", "SNode", "node", ",", "ResultSet", "resultSet", ",", "String", "name", ",", "String", "table", ",", "String", "tupleName", ")", "throws", "SQLException", "{", "addStringSFeature", "(", "node", ",", "name", ",", "stringValue", "(", "resultSet", ",", "table", ",", "tupleName", ")", ")", ";", "}", "private", "SStructuredNode", "recreateNode", "(", "Class", "<", "?", "extends", "SStructuredNode", ">", "clazz", ",", "SStructuredNode", "oldNode", ")", "{", "if", "(", "oldNode", ".", "getClass", "(", ")", "==", "clazz", ")", "{", "return", "oldNode", ";", "}", "SStructuredNode", "node", "=", "oldNode", ";", "if", "(", "clazz", "==", "SSpan", ".", "class", ")", "{", "node", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSSpan", "(", ")", ";", "}", "else", "if", "(", "clazz", "==", "SStructure", ".", "class", ")", "{", "node", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSStructure", "(", ")", ";", "}", "else", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", "+", "clazz", ".", "getName", "(", ")", ")", ";", "}", "moveNodeProperties", "(", "oldNode", ",", "node", ",", "oldNode", ".", "getSGraph", "(", ")", ")", ";", "return", "node", ";", "}", "private", "void", "moveNodeProperties", "(", "SStructuredNode", "from", ",", "SStructuredNode", "to", ",", "SGraph", "graph", ")", "{", "Validate", ".", "notNull", "(", "from", ")", ";", "Validate", ".", "notNull", "(", "to", ")", ";", "to", ".", "setSName", "(", "from", ".", "getSName", "(", ")", ")", ";", "for", "(", "SLayer", "l", ":", "from", ".", "getSLayers", "(", ")", ")", "{", "to", ".", "getSLayers", "(", ")", ".", "add", "(", "l", ")", ";", "}", "from", ".", "getSLayers", "(", ")", ".", "clear", "(", ")", ";", "Validate", ".", "isTrue", "(", "graph", ".", "removeNode", "(", "from", ")", ")", ";", "graph", ".", "addNode", "(", "to", ")", ";", "for", "(", "SAnnotation", "anno", ":", "from", ".", "getSAnnotations", "(", ")", ")", "{", "to", ".", "addSAnnotation", "(", "anno", ")", ";", "}", "for", "(", "SFeature", "feat", ":", "from", ".", "getSFeatures", "(", ")", ")", "{", "if", "(", "!", "(", "SaltFactory", ".", "SALT_CORE_NAMESPACE", ".", "equals", "(", "feat", ".", "getSNS", "(", ")", ")", "&&", "SaltFactory", ".", "SALT_CORE_SFEATURES", ".", "SNAME", ".", "toString", "(", ")", ".", "equals", "(", "feat", ".", "getSName", "(", ")", ")", ")", ")", "{", "to", ".", "addSFeature", "(", "feat", ")", ";", "}", "}", "for", "(", "SProcessingAnnotation", "proc", ":", "from", ".", "getSProcessingAnnotations", "(", ")", ")", "{", "to", ".", "addSProcessingAnnotation", "(", "proc", ")", ";", "}", "for", "(", "SMetaAnnotation", "meta", ":", "from", ".", "getSMetaAnnotations", "(", ")", ")", "{", "to", ".", "addSMetaAnnotation", "(", "meta", ")", ";", "}", "}", "private", "SRelation", "findExistingRelation", "(", "SDocumentGraph", "graph", ",", "SNode", "sourceNode", ",", "SNode", "targetNode", ",", "String", "edgeName", ",", "SLayer", "layer", ")", "{", "SRelation", "rel", "=", "null", ";", "EList", "<", "Edge", ">", "existingEdges", "=", "graph", ".", "getEdges", "(", "sourceNode", ".", "getSId", "(", ")", ",", "targetNode", ".", "getSId", "(", ")", ")", ";", "if", "(", "existingEdges", "!=", "null", ")", "{", "for", "(", "Edge", "e", ":", "existingEdges", ")", "{", "if", "(", "e", "instanceof", "SRelation", ")", "{", "SRelation", "existingRel", "=", "(", "SRelation", ")", "e", ";", "boolean", "noType", "=", "existingRel", ".", "getSTypes", "(", ")", "==", "null", "||", "existingRel", ".", "getSTypes", "(", ")", ".", "size", "(", ")", "==", "0", ";", "if", "(", "(", "(", "noType", "&&", "edgeName", "==", "null", ")", "||", "(", "!", "noType", "&&", "existingRel", ".", "getSTypes", "(", ")", ".", "contains", "(", "edgeName", ")", ")", ")", "&&", "existingRel", ".", "getSLayers", "(", ")", ".", "contains", "(", "layer", ")", ")", "{", "rel", "=", "existingRel", ";", "break", ";", "}", "}", "}", "}", "return", "rel", ";", "}", "private", "SRelation", "createNewRelation", "(", "SDocumentGraph", "graph", ",", "SStructuredNode", "sourceNode", ",", "SNode", "targetNode", ",", "String", "edgeName", ",", "String", "type", ",", "long", "componentID", ",", "SLayer", "layer", ",", "long", "parent", ",", "long", "pre", ",", "Map", "<", "RankID", ",", "SNode", ">", "nodeByPre", ")", "{", "SRelation", "rel", "=", "null", ";", "if", "(", "\"d\"", ".", "equals", "(", "type", ")", ")", "{", "SDominanceRelation", "domrel", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSDominanceRelation", "(", ")", ";", "rel", "=", "domrel", ";", "if", "(", "sourceNode", "!=", "null", "&&", "!", "(", "sourceNode", "instanceof", "SStructure", ")", ")", "{", "sourceNode", "=", "recreateNode", "(", "SStructure", ".", "class", ",", "sourceNode", ")", ";", "nodeByPre", ".", "put", "(", "new", "RankID", "(", "componentID", ",", "parent", ")", ",", "sourceNode", ")", ";", "}", "}", "else", "if", "(", "\"c\"", ".", "equals", "(", "type", ")", ")", "{", "SSpanningRelation", "spanrel", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSSpanningRelation", "(", ")", ";", "rel", "=", "spanrel", ";", "if", "(", "sourceNode", "!=", "null", "&&", "!", "(", "sourceNode", "instanceof", "SSpan", ")", ")", "{", "sourceNode", "=", "recreateNode", "(", "SSpan", ".", "class", ",", "sourceNode", ")", ";", "nodeByPre", ".", "put", "(", "new", "RankID", "(", "componentID", ",", "parent", ")", ",", "sourceNode", ")", ";", "}", "}", "else", "if", "(", "\"p\"", ".", "equals", "(", "type", ")", ")", "{", "SPointingRelation", "pointingrel", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSPointingRelation", "(", ")", ";", "rel", "=", "pointingrel", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"\"", "+", "type", "+", "\"\"", ")", ";", "}", "try", "{", "rel", ".", "getSLayers", "(", ")", ".", "add", "(", "layer", ")", ";", "rel", ".", "addSType", "(", "edgeName", ")", ";", "SFeature", "featInternalID", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSFeature", "(", ")", ";", "featInternalID", ".", "setSNS", "(", "ANNIS_NS", ")", ";", "featInternalID", ".", "setSName", "(", "FEAT_INTERNALID", ")", ";", "featInternalID", ".", "setSValue", "(", "Long", ".", "valueOf", "(", "pre", ")", ")", ";", "rel", ".", "addSFeature", "(", "featInternalID", ")", ";", "SFeature", "featComponentID", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSFeature", "(", ")", ";", "featComponentID", ".", "setSNS", "(", "ANNIS_NS", ")", ";", "featComponentID", ".", "setSName", "(", "FEAT_COMPONENTID", ")", ";", "featComponentID", ".", "setSValue", "(", "Long", ".", "valueOf", "(", "componentID", ")", ")", ";", "rel", ".", "addSFeature", "(", "featComponentID", ")", ";", "rel", ".", "setSSource", "(", "nodeByPre", ".", "get", "(", "new", "RankID", "(", "componentID", ",", "parent", ")", ")", ")", ";", "if", "(", "\"c\"", ".", "equals", "(", "type", ")", "&&", "!", "(", "targetNode", "instanceof", "SToken", ")", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "\"\"", ",", "new", "Object", "[", "]", "{", "targetNode", ".", "getSName", "(", ")", ",", "sourceNode", ".", "getSName", "(", ")", ",", "\"\"", "+", "pre", "}", ")", ";", "}", "else", "{", "rel", ".", "setSTarget", "(", "targetNode", ")", ";", "graph", ".", "addSRelation", "(", "rel", ")", ";", "}", "}", "catch", "(", "SaltException", "ex", ")", "{", "log", ".", "warn", "(", "\"\"", ",", "ex", ")", ";", "}", "return", "rel", ";", "}", "private", "void", "addEdgeAnnotations", "(", "ResultSet", "resultSet", ",", "SRelation", "rel", ")", "throws", "SQLException", "{", "String", "edgeAnnoValue", "=", "stringValue", "(", "resultSet", ",", "EDGE_ANNOTATION_TABLE", ",", "\"value\"", ")", ";", "String", "edgeAnnoNameSpace", "=", "stringValue", "(", "resultSet", ",", "EDGE_ANNOTATION_TABLE", ",", "\"namespace\"", ")", ";", "String", "edgeAnnoName", "=", "stringValue", "(", "resultSet", ",", "EDGE_ANNOTATION_TABLE", ",", "\"name\"", ")", ";", "if", "(", "!", "resultSet", ".", "wasNull", "(", ")", ")", "{", "String", "fullName", "=", "edgeAnnoNameSpace", "==", "null", "?", "\"\"", ":", "edgeAnnoNameSpace", "+", "\"::\"", "+", "edgeAnnoName", ";", "SAnnotation", "anno", "=", "rel", ".", "getSAnnotation", "(", "fullName", ")", ";", "if", "(", "anno", "==", "null", ")", "{", "anno", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSAnnotation", "(", ")", ";", "anno", ".", "setSNS", "(", "edgeAnnoNameSpace", "==", "null", "?", "\"\"", ":", "edgeAnnoNameSpace", ")", ";", "anno", ".", "setSName", "(", "edgeAnnoName", ")", ";", "anno", ".", "setSValue", "(", "edgeAnnoValue", ")", ";", "rel", ".", "addSAnnotation", "(", "anno", ")", ";", "}", "}", "}", "private", "SRelation", "createRelation", "(", "ResultSet", "resultSet", ",", "SDocumentGraph", "graph", ",", "Map", "<", "RankID", ",", "SNode", ">", "nodeByPre", ",", "SNode", "targetNode", ")", "throws", "SQLException", "{", "long", "parent", "=", "longValue", "(", "resultSet", ",", "RANK_TABLE", ",", "\"parent\"", ")", ";", "if", "(", "resultSet", ".", "wasNull", "(", ")", ")", "{", "return", "null", ";", "}", "long", "pre", "=", "longValue", "(", "resultSet", ",", "RANK_TABLE", ",", "\"pre\"", ")", ";", "long", "componentID", "=", "longValue", "(", "resultSet", ",", "RANK_TABLE", ",", "\"component_id\"", ")", ";", "String", "edgeNamespace", "=", "stringValue", "(", "resultSet", ",", "COMPONENT_TABLE", ",", "\"namespace\"", ")", ";", "String", "edgeName", "=", "stringValue", "(", "resultSet", ",", "COMPONENT_TABLE", ",", "\"name\"", ")", ";", "String", "type", "=", "stringValue", "(", "resultSet", ",", "COMPONENT_TABLE", ",", "\"type\"", ")", ";", "SStructuredNode", "sourceNode", "=", "(", "SStructuredNode", ")", "nodeByPre", ".", "get", "(", "new", "RankID", "(", "componentID", ",", "parent", ")", ")", ";", "if", "(", "sourceNode", "==", "null", ")", "{", "return", "null", ";", "}", "EList", "<", "SLayer", ">", "layerList", "=", "graph", ".", "getSLayerByName", "(", "edgeNamespace", ")", ";", "SLayer", "layer", "=", "(", "layerList", "!=", "null", "&&", "layerList", ".", "size", "(", ")", ">", "0", ")", "?", "layerList", ".", "get", "(", "0", ")", ":", "null", ";", "if", "(", "layer", "==", "null", ")", "{", "layer", "=", "SaltFactory", ".", "eINSTANCE", ".", "createSLayer", "(", ")", ";", "layer", ".", "setSName", "(", "edgeNamespace", ")", ";", "graph", ".", "addSLayer", "(", "layer", ")", ";", "}", "SRelation", "rel", "=", "null", ";", "if", "(", "!", "resultSet", ".", "wasNull", "(", ")", ")", "{", "rel", "=", "findExistingRelation", "(", "graph", ",", "sourceNode", ",", "targetNode", ",", "edgeName", ",", "layer", ")", ";", "if", "(", "rel", "==", "null", ")", "{", "rel", "=", "createNewRelation", "(", "graph", ",", "sourceNode", ",", "targetNode", ",", "edgeName", ",", "type", ",", "componentID", ",", "layer", ",", "parent", ",", "pre", ",", "nodeByPre", ")", ";", "}", "addEdgeAnnotations", "(", "resultSet", ",", "rel", ")", ";", "}", "return", "rel", ";", "}", "protected", "SolutionKey", "<", "?", ">", "createSolutionKey", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "protected", "void", "newline", "(", "StringBuilder", "sb", ",", "int", "indentBy", ")", "{", "sb", ".", "append", "(", "\"n\"", ")", ";", "indent", "(", "sb", ",", "indentBy", ")", ";", "}", "protected", "void", "indent", "(", "StringBuilder", "sb", ",", "int", "indentBy", ")", "{", "sb", ".", "append", "(", "StringUtils", ".", "repeat", "(", "AbstractSqlGenerator", ".", "TABSTOP", ",", "indentBy", ")", ")", ";", "}", "protected", "long", "longValue", "(", "ResultSet", "resultSet", ",", "String", "table", ",", "String", "column", ")", "throws", "SQLException", "{", "return", "resultSet", ".", "getLong", "(", "outerQueryTableAccessStrategy", ".", "columnName", "(", "table", ",", "column", ")", ")", ";", "}", "protected", "String", "stringValue", "(", "ResultSet", "resultSet", ",", "String", "table", ",", "String", "column", ")", "throws", "SQLException", "{", "return", "resultSet", ".", "getString", "(", "outerQueryTableAccessStrategy", ".", "columnName", "(", "table", ",", "column", ")", ")", ";", "}", "public", "CorpusPathExtractor", "getCorpusPathExtractor", "(", ")", "{", "return", "corpusPathExtractor", ";", "}", "public", "void", "setCorpusPathExtractor", "(", "CorpusPathExtractor", "corpusPathExtractor", ")", "{", "this", ".", "corpusPathExtractor", "=", "corpusPathExtractor", ";", "}", "public", "TableAccessStrategy", "getOuterQueryTableAccessStrategy", "(", ")", "{", "return", "outerQueryTableAccessStrategy", ";", "}", "@", "Override", "public", "void", "setOuterQueryTableAccessStrategy", "(", "TableAccessStrategy", "outerQueryTableAccessStrategy", ")", "{", "this", ".", "outerQueryTableAccessStrategy", "=", "outerQueryTableAccessStrategy", ";", "}", "public", "static", "class", "RankID", "{", "private", "long", "componentID", ";", "private", "long", "pre", ";", "public", "RankID", "(", "long", "componentID", ",", "long", "pre", ")", "{", "this", ".", "componentID", "=", "componentID", ";", "this", ".", "pre", "=", "pre", ";", "}", "public", "long", "getComponentID", "(", ")", "{", "return", "componentID", ";", "}", "public", "long", "getPre", "(", ")", "{", "return", "pre", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "getClass", "(", ")", "!=", "obj", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "final", "RankID", "other", "=", "(", "RankID", ")", "obj", ";", "if", "(", "this", ".", "componentID", "!=", "other", ".", "componentID", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "pre", "!=", "other", ".", "pre", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "hash", "=", "5", ";", "hash", "=", "29", "*", "hash", "+", "(", "int", ")", "(", "this", ".", "componentID", "^", "(", "this", ".", "componentID", ">>>", "32", ")", ")", ";", "hash", "=", "29", "*", "hash", "+", "(", "int", ")", "(", "this", ".", "pre", "^", "(", "this", ".", "pre", ">>>", "32", ")", ")", ";", "return", "hash", ";", "}", "}", "}", "</s>" ]
8,803
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "EDGE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_ANNOTATION_TABLE", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "CommonAncestor", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Dominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Identical", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Inclusion", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Join", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftAlignment", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftDominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftOverlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Overlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "PointingRelation", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Precedence", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightAlignment", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightDominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightOverlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "SameSpan", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Sibling", ";", "public", "abstract", "class", "AbstractWhereClauseGenerator", "extends", "TableAccessStrategyFactory", "implements", "WhereClauseSqlGenerator", "<", "QueryData", ">", "{", "@", "Override", "public", "Set", "<", "String", ">", "whereConditions", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "List", "<", "String", ">", "conditions", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "QueryNode", "node", ":", "alternative", ")", "{", "if", "(", "node", ".", "getSpannedText", "(", ")", "!=", "null", ")", "{", "addSpanConditions", "(", "conditions", ",", "queryData", ",", "node", ")", ";", "}", "if", "(", "node", ".", "isToken", "(", ")", ")", "{", "addIsTokenConditions", "(", "conditions", ",", "queryData", ",", "node", ")", ";", "}", "if", "(", "node", ".", "isRoot", "(", ")", ")", "{", "addIsRootConditions", "(", "conditions", ",", "queryData", ",", "node", ")", ";", "}", "if", "(", "node", ".", "getNamespace", "(", ")", "!=", "null", ")", "{", "addNodeNamespaceConditions", "(", "conditions", ",", "queryData", ",", "node", ")", ";", "}", "if", "(", "node", ".", "getName", "(", ")", "!=", "null", ")", "{", "addNodeNameCondition", "(", "conditions", ",", "queryData", ",", "node", ")", ";", "}", "if", "(", "node", ".", "getArity", "(", ")", "!=", "null", ")", "{", "addNodeArityConditions", "(", "conditions", ",", "queryData", ",", "node", ")", ";", "}", "if", "(", "node", ".", "getTokenArity", "(", ")", "!=", "null", ")", "{", "addTokenArityConditions", "(", "conditions", ",", "queryData", ",", "node", ")", ";", "}", "for", "(", "Join", "join", ":", "node", ".", "getJoins", "(", ")", ")", "{", "QueryNode", "target", "=", "join", ".", "getTarget", "(", ")", ";", "if", "(", "join", "instanceof", "SameSpan", ")", "{", "addSameSpanConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "SameSpan", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "Identical", ")", "{", "addIdenticalConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "Identical", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "LeftAlignment", ")", "{", "addLeftAlignmentConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "LeftAlignment", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "RightAlignment", ")", "{", "addRightAlignmentConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "RightAlignment", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "Inclusion", ")", "{", "addInclusionConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "Inclusion", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "Overlap", ")", "{", "addOverlapConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "Overlap", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "LeftOverlap", ")", "{", "addLeftOverlapConditions", "(", "conditions", ",", "target", ",", "node", ",", "(", "LeftOverlap", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "RightOverlap", ")", "{", "addRightOverlapConditions", "(", "conditions", ",", "target", ",", "node", ",", "(", "RightOverlap", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "Precedence", ")", "{", "addPrecedenceConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "Precedence", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "Sibling", ")", "{", "addSiblingConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "Sibling", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "CommonAncestor", ")", "{", "addCommonAncestorConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "CommonAncestor", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "LeftDominance", ")", "{", "addLeftDominanceConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "LeftDominance", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "RightDominance", ")", "{", "addRightDominanceConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "RightDominance", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "Dominance", ")", "{", "addDominanceConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "Dominance", ")", "join", ",", "queryData", ")", ";", "}", "else", "if", "(", "join", "instanceof", "PointingRelation", ")", "{", "addPointingRelationConditions", "(", "conditions", ",", "node", ",", "target", ",", "(", "PointingRelation", ")", "join", ",", "queryData", ")", ";", "}", "}", "int", "i", "=", "0", ";", "for", "(", "QueryAnnotation", "annotation", ":", "node", ".", "getNodeAnnotations", "(", ")", ")", "{", "++", "i", ";", "addAnnotationConditions", "(", "conditions", ",", "node", ",", "i", ",", "annotation", ",", "NODE_ANNOTATION_TABLE", ",", "queryData", ")", ";", "}", "int", "j", "=", "0", ";", "for", "(", "QueryAnnotation", "annotation", ":", "node", ".", "getEdgeAnnotations", "(", ")", ")", "{", "++", "j", ";", "addAnnotationConditions", "(", "conditions", ",", "node", ",", "j", ",", "annotation", ",", "EDGE_ANNOTATION_TABLE", ",", "queryData", ")", ";", "}", "}", "return", "new", "HashSet", "<", "String", ">", "(", "conditions", ")", ";", "}", "protected", "abstract", "void", "addSpanConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", ";", "protected", "abstract", "void", "addIsTokenConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", ";", "protected", "abstract", "void", "addIsRootConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", ";", "protected", "abstract", "void", "addNodeNamespaceConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", ";", "protected", "abstract", "void", "addNodeNameCondition", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", ";", "protected", "abstract", "void", "addNodeArityConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", ";", "protected", "abstract", "void", "addTokenArityConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", ";", "protected", "abstract", "void", "addSingleEdgeCondition", "(", "QueryNode", "node", ",", "QueryNode", "target", ",", "List", "<", "String", ">", "conditions", ",", "Join", "join", ",", "final", "String", "edgeType", ")", ";", "protected", "abstract", "void", "addSiblingConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Sibling", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addCommonAncestorConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "CommonAncestor", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addSameSpanConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "SameSpan", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addIdenticalConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Identical", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addLeftAlignmentConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "LeftAlignment", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addRightAlignmentConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "RightAlignment", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addInclusionConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Inclusion", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addOverlapConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Overlap", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addLeftOverlapConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "target", ",", "QueryNode", "node", ",", "LeftOverlap", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addRightOverlapConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "target", ",", "QueryNode", "node", ",", "RightOverlap", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addPrecedenceConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Precedence", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addAnnotationConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "int", "index", ",", "QueryAnnotation", "annotation", ",", "String", "table", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addLeftDominanceConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "LeftDominance", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addRightDominanceConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "RightDominance", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addDominanceConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Dominance", "join", ",", "QueryData", "queryData", ")", ";", "protected", "abstract", "void", "addPointingRelationConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "PointingRelation", "join", ",", "QueryData", "queryData", ")", ";", "}", "</s>" ]
8,804
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "List", ";", "public", "interface", "NodeSqlAdapter", "{", "String", "selectClause", "(", ")", ";", "String", "selectClauseNullValues", "(", ")", ";", "String", "fromClause", "(", ")", ";", "List", "<", "String", ">", "whereClause", "(", ")", ";", "}", "</s>" ]
8,805
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "between", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "in", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "isNotNull", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "isNull", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "isTrue", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "join", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "numberJoin", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "sqlString", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "COMPONENT_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "FACTS_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "RANK_TABLE", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "model", ".", "QueryNode", ".", "TextMatching", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "CommonAncestor", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Dominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Identical", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Inclusion", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Join", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftAlignment", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftDominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftOverlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Overlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "PointingRelation", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Precedence", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RangedJoin", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RankTableJoin", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightAlignment", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightDominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightOverlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "SameSpan", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Sibling", ";", "public", "class", "DefaultWhereClauseGenerator", "extends", "AbstractWhereClauseGenerator", "{", "private", "boolean", "optimizeIndirectPrecedence", ";", "private", "boolean", "allowIdenticalSibling", ";", "private", "boolean", "optimizeInclusion", ";", "private", "String", "componentPredicates", ";", "private", "boolean", "useIsTokenColumn", ";", "private", "boolean", "useToplevelCorpusPredicateInCommonAncestorSubquery", ";", "private", "boolean", "useComponentRefPredicateInCommonAncestorSubquery", ";", "private", "AnnotationConditionProvider", "annoCondition", ";", "private", "void", "addComponentPredicates", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "final", "String", "edgeType", ",", "String", "componentName", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "COMPONENT_TABLE", ",", "\"type\"", ")", ",", "sqlString", "(", "edgeType", ")", ")", ")", ";", "if", "(", "componentName", "==", "null", ")", "{", "conditions", ".", "add", "(", "isNull", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "COMPONENT_TABLE", ",", "\"name\"", ")", ")", ")", ";", "}", "else", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "COMPONENT_TABLE", ",", "\"name\"", ")", ",", "sqlString", "(", "componentName", ")", ")", ")", ";", "}", "}", "private", "void", "addComponentPredicates", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "String", "componentName", ",", "String", "edgeType", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "COMPONENT_TABLE", ",", "\"id\"", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "COMPONENT_TABLE", ",", "\"id\"", ")", ")", ")", ";", "if", "(", "\"lhs\"", ".", "equals", "(", "componentPredicates", ")", "||", "\"both\"", ".", "equals", "(", "componentPredicates", ")", ")", "{", "addComponentPredicates", "(", "conditions", ",", "node", ",", "edgeType", ",", "componentName", ")", ";", "}", "if", "(", "\"rhs\"", ".", "equals", "(", "componentPredicates", ")", "||", "\"both\"", ".", "equals", "(", "componentPredicates", ")", ")", "{", "addComponentPredicates", "(", "conditions", ",", "target", ",", "edgeType", ",", "componentName", ")", ";", "}", "}", "@", "Override", "protected", "void", "addPointingRelationConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "PointingRelation", "join", ",", "QueryData", "queryData", ")", "{", "addSingleEdgeCondition", "(", "node", ",", "target", ",", "conditions", ",", "join", ",", "\"p\"", ")", ";", "}", "@", "Override", "protected", "void", "addDominanceConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Dominance", "join", ",", "QueryData", "queryData", ")", "{", "addSingleEdgeCondition", "(", "node", ",", "target", ",", "conditions", ",", "join", ",", "\"d\"", ")", ";", "}", "@", "Override", "protected", "void", "addRightDominanceConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "RightDominance", "join", ",", "QueryData", "queryData", ")", "{", "addLeftOrRightDominance", "(", "conditions", ",", "node", ",", "target", ",", "queryData", ",", "join", ",", "\"max\"", ",", "\"right_token\"", ")", ";", "}", "@", "Override", "protected", "void", "addLeftDominanceConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "LeftDominance", "join", ",", "QueryData", "queryData", ")", "{", "addLeftOrRightDominance", "(", "conditions", ",", "node", ",", "target", ",", "queryData", ",", "join", ",", "\"min\"", ",", "\"left_token\"", ")", ";", "}", "protected", "void", "addLeftOrRightDominance", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "QueryData", "queryData", ",", "RankTableJoin", "join", ",", "String", "aggregationFunction", ",", "String", "tokenBoarder", ")", "{", "RankTableJoin", "rankTableJoin", "=", "(", "RankTableJoin", ")", "join", ";", "String", "componentName", "=", "rankTableJoin", ".", "getName", "(", ")", ";", "addComponentPredicates", "(", "conditions", ",", "node", ",", "target", ",", "componentName", ",", "\"d\"", ")", ";", "TableAccessStrategy", "tas", "=", "tables", "(", "null", ")", ";", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"parent\"", ")", ")", ")", ";", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "boolean", "doJoin", "=", "!", "tas", ".", "isMaterialized", "(", "NODE_TABLE", ",", "RANK_TABLE", ")", ";", "String", "innerSelect", "=", "\"SELECT", "\"", "+", "aggregationFunction", "+", "\"(lrsub.\"", "+", "tokenBoarder", "+", "\")", "FROM", "\"", ";", "if", "(", "doJoin", ")", "{", "innerSelect", "+=", "tas", ".", "tableName", "(", "NODE_TABLE", ")", "+", "\"", "AS", "lrsub,", "\"", "+", "tas", ".", "tableName", "(", "RANK_TABLE", ")", "+", "\"\"", ";", "}", "else", "{", "innerSelect", "+=", "tas", ".", "tableName", "(", "RANK_TABLE", ")", "+", "\"", "as", "lrsub", "\"", ";", "}", "innerSelect", "+=", "\"\"", "+", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", "+", "\"\"", "+", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"component_id\"", ")", "+", "\"\"", "+", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", "+", "\"\"", "+", "(", "corpusList", "==", "null", "||", "corpusList", ".", "isEmpty", "(", ")", "?", "\"NULL\"", ":", "StringUtils", ".", "join", "(", "corpusList", ",", "\",\"", ")", ")", "+", "\")\"", ";", "if", "(", "doJoin", ")", "{", "innerSelect", "+=", "\"\"", "+", "(", "corpusList", "==", "null", "||", "corpusList", ".", "isEmpty", "(", ")", "?", "\"NULL\"", ":", "StringUtils", ".", "join", "(", "corpusList", ",", "\",\"", ")", ")", "+", "\")\"", "+", "\"\"", ";", "}", "conditions", ".", "add", "(", "in", "(", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "tokenBoarder", ")", ",", "innerSelect", ")", ")", ";", "}", "void", "joinOnNode", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "String", "operator", ",", "String", "leftColumn", ",", "String", "rightColumn", ")", "{", "conditions", ".", "add", "(", "join", "(", "operator", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "leftColumn", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "rightColumn", ")", ")", ")", ";", "}", "void", "betweenJoinOnNode", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "String", "leftColumn", ",", "String", "rightColumn", ",", "int", "min", ",", "int", "max", ")", "{", "conditions", ".", "add", "(", "between", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "leftColumn", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "rightColumn", ")", ",", "min", ",", "max", ")", ")", ";", "}", "void", "numberJoinOnNode", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "String", "operator", ",", "String", "leftColumn", ",", "String", "rightColumn", ",", "int", "offset", ")", "{", "conditions", ".", "add", "(", "numberJoin", "(", "operator", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "leftColumn", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "rightColumn", ")", ",", "offset", ")", ")", ";", "}", "@", "Override", "protected", "void", "addAnnotationConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "int", "index", ",", "QueryAnnotation", "annotation", ",", "String", "table", ",", "QueryData", "queryData", ")", "{", "annoCondition", ".", "addAnnotationConditions", "(", "conditions", ",", "node", ",", "index", ",", "annotation", ",", "table", ",", "queryData", ",", "tables", "(", "node", ")", ")", ";", "}", "@", "Override", "protected", "void", "addPrecedenceConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Precedence", "join", ",", "QueryData", "queryData", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"text_ref\"", ",", "\"text_ref\"", ")", ";", "int", "min", "=", "join", ".", "getMinDistance", "(", ")", ";", "int", "max", "=", "join", ".", "getMaxDistance", "(", ")", ";", "String", "left", "=", "join", ".", "getSegmentationName", "(", ")", "==", "null", "?", "\"left_token\"", ":", "\"seg_left\"", ";", "String", "right", "=", "join", ".", "getSegmentationName", "(", ")", "==", "null", "?", "\"right_token\"", ":", "\"seg_right\"", ";", "if", "(", "join", ".", "getSegmentationName", "(", ")", "!=", "null", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"seg_name\"", ")", ",", "sqlString", "(", "join", ".", "getSegmentationName", "(", ")", ")", ")", ")", ";", "}", "if", "(", "min", "==", "0", "&&", "max", "==", "0", ")", "{", "if", "(", "optimizeIndirectPrecedence", ")", "{", "numberJoinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"<=\"", ",", "right", ",", "left", ",", "-", "1", ")", ";", "}", "else", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"<\"", ",", "right", ",", "left", ")", ";", "}", "}", "else", "if", "(", "min", "==", "max", ")", "{", "numberJoinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "right", ",", "left", ",", "-", "min", ")", ";", "}", "else", "{", "betweenJoinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "right", ",", "left", ",", "-", "min", ",", "-", "max", ")", ";", "}", "}", "@", "Override", "protected", "void", "addRightOverlapConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "target", ",", "QueryNode", "node", ",", "RightOverlap", "join", ",", "QueryData", "queryData", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"text_ref\"", ",", "\"text_ref\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\">=\"", ",", "\"right\"", ",", "\"right\"", ")", ";", "joinOnNode", "(", "conditions", ",", "target", ",", "node", ",", "\">=\"", ",", "\"right\"", ",", "\"left\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\">=\"", ",", "\"left\"", ",", "\"left\"", ")", ";", "}", "@", "Override", "protected", "void", "addLeftOverlapConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "target", ",", "QueryNode", "node", ",", "LeftOverlap", "join", ",", "QueryData", "queryData", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"text_ref\"", ",", "\"text_ref\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"<=\"", ",", "\"left\"", ",", "\"left\"", ")", ";", "joinOnNode", "(", "conditions", ",", "target", ",", "node", ",", "\"<=\"", ",", "\"left\"", ",", "\"right\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"<=\"", ",", "\"right\"", ",", "\"right\"", ")", ";", "}", "@", "Override", "protected", "void", "addOverlapConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Overlap", "join", ",", "QueryData", "queryData", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"text_ref\"", ",", "\"text_ref\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"<=\"", ",", "\"left\"", ",", "\"right\"", ")", ";", "joinOnNode", "(", "conditions", ",", "target", ",", "node", ",", "\"<=\"", ",", "\"left\"", ",", "\"right\"", ")", ";", "}", "@", "Override", "protected", "void", "addInclusionConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Inclusion", "join", ",", "QueryData", "queryData", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"text_ref\"", ",", "\"text_ref\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"<=\"", ",", "\"left\"", ",", "\"left\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\">=\"", ",", "\"right\"", ",", "\"right\"", ")", ";", "if", "(", "optimizeInclusion", ")", "{", "joinOnNode", "(", "conditions", ",", "target", ",", "node", ",", "\"<=\"", ",", "\"left\"", ",", "\"right\"", ")", ";", "joinOnNode", "(", "conditions", ",", "target", ",", "node", ",", "\">=\"", ",", "\"right\"", ",", "\"left\"", ")", ";", "}", "}", "@", "Override", "protected", "void", "addRightAlignmentConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "RightAlignment", "join", ",", "QueryData", "queryData", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"text_ref\"", ",", "\"text_ref\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"right\"", ",", "\"right\"", ")", ";", "}", "@", "Override", "protected", "void", "addLeftAlignmentConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "LeftAlignment", "join", ",", "QueryData", "queryData", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"text_ref\"", ",", "\"text_ref\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"left\"", ",", "\"left\"", ")", ";", "}", "@", "Override", "protected", "void", "addIdenticalConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Identical", "join", ",", "QueryData", "queryData", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"id\"", ",", "\"id\"", ")", ";", "}", "@", "Override", "protected", "void", "addSameSpanConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "SameSpan", "join", ",", "QueryData", "queryData", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"text_ref\"", ",", "\"text_ref\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"left\"", ",", "\"left\"", ")", ";", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"=\"", ",", "\"right\"", ",", "\"right\"", ")", ";", "}", "@", "Override", "protected", "void", "addCommonAncestorConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "CommonAncestor", "join", ",", "QueryData", "queryData", ")", "{", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "String", "componentName", "=", "join", ".", "getName", "(", ")", ";", "addComponentPredicates", "(", "conditions", ",", "node", ",", "target", ",", "componentName", ",", "\"d\"", ")", ";", "if", "(", "!", "allowIdenticalSibling", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"<>\"", ",", "\"id\"", ",", "\"id\"", ")", ";", "}", "if", "(", "useComponentRefPredicateInCommonAncestorSubquery", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", ")", ")", ";", "}", "TableAccessStrategy", "tas", "=", "tables", "(", "null", ")", ";", "String", "pre1", "=", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ";", "String", "pre2", "=", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ";", "String", "pre", "=", "tas", ".", "column", "(", "\"ancestor\"", ",", "tas", ".", "columnName", "(", "RANK_TABLE", ",", "\"pre\"", ")", ")", ";", "String", "post", "=", "tas", ".", "column", "(", "\"ancestor\"", ",", "tas", ".", "columnName", "(", "RANK_TABLE", ",", "\"post\"", ")", ")", ";", "String", "component", "=", "tas", ".", "column", "(", "\"ancestor\"", ",", "tas", ".", "columnName", "(", "RANK_TABLE", ",", "\"\"", ")", ")", ";", "String", "component1", "=", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "\"\"", "+", "tas", ".", "tableName", "(", "RANK_TABLE", ")", "+", "\"\"", ")", ";", "if", "(", "useComponentRefPredicateInCommonAncestorSubquery", ")", "{", "sb", ".", "append", "(", "\"t\"", "+", "component", "+", "\"", "=", "\"", "+", "component1", "+", "\"", "ANDn\"", ")", ";", "}", "sb", ".", "append", "(", "\"t\"", "+", "pre", "+", "\"", "<", "\"", "+", "pre1", "+", "\"", "AND", "\"", "+", "pre1", "+", "\"", "<", "\"", "+", "post", "+", "\"", "ANDn\"", ")", ";", "sb", ".", "append", "(", "\"t\"", "+", "pre", "+", "\"", "<", "\"", "+", "pre2", "+", "\"", "AND", "\"", "+", "pre2", "+", "\"", "<", "\"", "+", "post", ")", ";", "if", "(", "useToplevelCorpusPredicateInCommonAncestorSubquery", "&&", "!", "(", "corpusList", "==", "null", "||", "corpusList", ".", "isEmpty", "(", ")", ")", ")", "{", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "corpusList", ",", "\",\"", ")", ")", ";", "sb", ".", "append", "(", "\")\"", ")", ";", "}", "sb", ".", "append", "(", "\")\"", ")", ";", "conditions", ".", "add", "(", "sb", ".", "toString", "(", ")", ")", ";", "}", "@", "Override", "protected", "void", "addSiblingConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "QueryNode", "target", ",", "Sibling", "join", ",", "QueryData", "queryData", ")", "{", "Sibling", "sibling", "=", "(", "Sibling", ")", "join", ";", "String", "componentName", "=", "sibling", ".", "getName", "(", ")", ";", "addComponentPredicates", "(", "conditions", ",", "node", ",", "target", ",", "componentName", ",", "\"d\"", ")", ";", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"parent\"", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"parent\"", ")", ")", ")", ";", "if", "(", "!", "allowIdenticalSibling", ")", "{", "joinOnNode", "(", "conditions", ",", "node", ",", "target", ",", "\"<>\"", ",", "\"id\"", ",", "\"id\"", ")", ";", "}", "}", "@", "Override", "protected", "void", "addSingleEdgeCondition", "(", "QueryNode", "node", ",", "QueryNode", "target", ",", "List", "<", "String", ">", "conditions", ",", "Join", "join", ",", "final", "String", "edgeType", ")", "{", "RankTableJoin", "rankTableJoin", "=", "(", "RankTableJoin", ")", "join", ";", "String", "componentName", "=", "rankTableJoin", ".", "getName", "(", ")", ";", "addComponentPredicates", "(", "conditions", ",", "node", ",", "target", ",", "componentName", ",", "edgeType", ")", ";", "int", "min", "=", "rankTableJoin", ".", "getMinDistance", "(", ")", ";", "int", "max", "=", "rankTableJoin", ".", "getMaxDistance", "(", ")", ";", "if", "(", "min", "==", "1", "&&", "max", "==", "1", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"parent\"", ")", ")", ")", ";", "}", "else", "{", "conditions", ".", "add", "(", "join", "(", "\"<\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ")", ")", ";", "conditions", ".", "add", "(", "join", "(", "\"<\"", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"post\"", ")", ")", ")", ";", "if", "(", "min", ">", "0", "&&", "min", "==", "max", ")", "{", "conditions", ".", "add", "(", "numberJoin", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"level\"", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"level\"", ")", ",", "-", "min", ")", ")", ";", "}", "else", "if", "(", "min", ">", "0", "&&", "min", "<", "max", ")", "{", "conditions", ".", "add", "(", "between", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"level\"", ")", ",", "tables", "(", "target", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"level\"", ")", ",", "-", "min", ",", "-", "max", ")", ")", ";", "}", "}", "}", "@", "Override", "protected", "void", "addTokenArityConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", "{", "QueryNode", ".", "Range", "tokenArity", "=", "node", ".", "getTokenArity", "(", ")", ";", "if", "(", "tokenArity", ".", "getMin", "(", ")", "==", "tokenArity", ".", "getMax", "(", ")", ")", "{", "conditions", ".", "add", "(", "numberJoin", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"left_token\"", ")", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"right_token\"", ")", ",", "-", "(", "tokenArity", ".", "getMin", "(", ")", ")", "+", "1", ")", ")", ";", "}", "else", "{", "conditions", ".", "add", "(", "between", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"left_token\"", ")", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"right_token\"", ")", ",", "-", "(", "tokenArity", ".", "getMin", "(", ")", ")", "+", "1", ",", "-", "(", "tokenArity", ".", "getMax", "(", ")", ")", "+", "1", ")", ")", ";", "}", "}", "@", "Override", "protected", "void", "addNodeArityConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", "{", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "TableAccessStrategy", "tas", "=", "tables", "(", "null", ")", ";", "String", "pre1", "=", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ";", "String", "parent", "=", "tas", ".", "column", "(", "\"children\"", ",", "tas", ".", "columnName", "(", "RANK_TABLE", ",", "\"parent\"", ")", ")", ";", "String", "pre", "=", "tas", ".", "column", "(", "\"children\"", ",", "tas", ".", "columnName", "(", "RANK_TABLE", ",", "\"pre\"", ")", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "\"\"", "+", "pre", "+", "\")n\"", ")", ";", "sb", ".", "append", "(", "\"tFROM", "\"", "+", "tas", ".", "tableName", "(", "RANK_TABLE", ")", "+", "\"\"", ")", ";", "sb", ".", "append", "(", "\"tWHERE", "\"", "+", "parent", "+", "\"", "=", "\"", "+", "pre1", "+", "\"\"", "+", "(", "corpusList", ".", "isEmpty", "(", ")", "?", "\"NULL\"", ":", "StringUtils", ".", "join", "(", "corpusList", ",", "\",\"", ")", ")", "+", "\")\"", "+", "\")\"", ")", ";", "QueryNode", ".", "Range", "arity", "=", "node", ".", "getArity", "(", ")", ";", "if", "(", "arity", ".", "getMin", "(", ")", "==", "arity", ".", "getMax", "(", ")", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "sb", ".", "toString", "(", ")", ",", "String", ".", "valueOf", "(", "arity", ".", "getMin", "(", ")", ")", ")", ")", ";", "}", "else", "{", "conditions", ".", "add", "(", "between", "(", "sb", ".", "toString", "(", ")", ",", "arity", ".", "getMin", "(", ")", ",", "arity", ".", "getMax", "(", ")", ")", ")", ";", "}", "}", "@", "Override", "protected", "void", "addNodeNameCondition", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"name\"", ")", ",", "sqlString", "(", "node", ".", "getName", "(", ")", ")", ")", ")", ";", "}", "@", "Override", "protected", "void", "addNodeNamespaceConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"namespace\"", ")", ",", "sqlString", "(", "node", ".", "getNamespace", "(", ")", ")", ")", ")", ";", "}", "@", "Override", "protected", "void", "addIsRootConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", "{", "conditions", ".", "add", "(", "isTrue", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"root\"", ")", ")", ")", ";", "}", "@", "Override", "protected", "void", "addIsTokenConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", "{", "if", "(", "useIsTokenColumn", ")", "{", "conditions", ".", "add", "(", "isTrue", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"is_token\"", ")", ")", ")", ";", "}", "else", "{", "conditions", ".", "add", "(", "isNotNull", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"span\"", ")", ")", ")", ";", "}", "}", "@", "Override", "protected", "void", "addSpanConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryData", "queryData", ",", "QueryNode", "node", ")", "{", "TextMatching", "textMatching", "=", "node", ".", "getSpanTextMatching", "(", ")", ";", "conditions", ".", "add", "(", "join", "(", "textMatching", ".", "sqlOperator", "(", ")", ",", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"span\"", ")", ",", "sqlString", "(", "node", ".", "getSpannedText", "(", ")", ",", "textMatching", ")", ")", ")", ";", "}", "public", "boolean", "isOptimizeIndirectPrecedence", "(", ")", "{", "return", "optimizeIndirectPrecedence", ";", "}", "public", "void", "setOptimizeIndirectPrecedence", "(", "boolean", "optimizeIndirectPrecedence", ")", "{", "this", ".", "optimizeIndirectPrecedence", "=", "optimizeIndirectPrecedence", ";", "}", "public", "boolean", "isAllowIdenticalSibling", "(", ")", "{", "return", "allowIdenticalSibling", ";", "}", "public", "void", "setAllowIdenticalSibling", "(", "boolean", "allowIdenticalSibling", ")", "{", "this", ".", "allowIdenticalSibling", "=", "allowIdenticalSibling", ";", "}", "public", "boolean", "isOptimizeInclusion", "(", ")", "{", "return", "optimizeInclusion", ";", "}", "public", "void", "setOptimizeInclusion", "(", "boolean", "optimizeInclusion", ")", "{", "this", ".", "optimizeInclusion", "=", "optimizeInclusion", ";", "}", "public", "String", "getComponentPredicates", "(", ")", "{", "return", "componentPredicates", ";", "}", "public", "void", "setComponentPredicates", "(", "String", "componentPredicates", ")", "{", "this", ".", "componentPredicates", "=", "componentPredicates", ";", "}", "public", "boolean", "isUseIsTokenColumn", "(", ")", "{", "return", "useIsTokenColumn", ";", "}", "public", "void", "setUseIsTokenColumn", "(", "boolean", "useIsTokenColumn", ")", "{", "this", ".", "useIsTokenColumn", "=", "useIsTokenColumn", ";", "}", "public", "boolean", "isUseToplevelCorpusPredicateInCommonAncestorSubquery", "(", ")", "{", "return", "useToplevelCorpusPredicateInCommonAncestorSubquery", ";", "}", "public", "void", "setUseToplevelCorpusPredicateInCommonAncestorSubquery", "(", "boolean", "useToplevelCorpusPredicateInCommonAncestorSubquery", ")", "{", "this", ".", "useToplevelCorpusPredicateInCommonAncestorSubquery", "=", "useToplevelCorpusPredicateInCommonAncestorSubquery", ";", "}", "public", "boolean", "isUseComponentRefPredicateInCommonAncestorSubquery", "(", ")", "{", "return", "useComponentRefPredicateInCommonAncestorSubquery", ";", "}", "public", "void", "setUseComponentRefPredicateInCommonAncestorSubquery", "(", "boolean", "useComponentRefPredicateInCommonAncestorSubquery", ")", "{", "this", ".", "useComponentRefPredicateInCommonAncestorSubquery", "=", "useComponentRefPredicateInCommonAncestorSubquery", ";", "}", "public", "AnnotationConditionProvider", "getAnnoCondition", "(", ")", "{", "return", "annoCondition", ";", "}", "public", "void", "setAnnoCondition", "(", "AnnotationConditionProvider", "annoCondition", ")", "{", "this", ".", "annoCondition", "=", "annoCondition", ";", "}", "}", "</s>" ]
8,806
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "java", ".", "util", ".", "List", ";", "public", "interface", "WithClauseSqlGenerator", "<", "T", ">", "{", "public", "List", "<", "String", ">", "withClauses", "(", "T", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", ";", "}", "</s>" ]
8,807
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "COMPONENT_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "RANK_TABLE", ";", "import", "java", ".", "sql", ".", "Array", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "sql", ".", "Types", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "ListIterator", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "annis", ".", "dao", ".", "DocumentNameMapRow", ";", "import", "annis", ".", "model", ".", "AnnisNode", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "model", ".", "AnnotationGraph", ";", "import", "annis", ".", "model", ".", "Edge", ";", "import", "annis", ".", "model", ".", "Edge", ".", "EdgeType", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "import", "annis", ".", "sqlgen", ".", "SaltAnnotateExtractor", ".", "RankID", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "AomAnnotateExtractor", "implements", "ResultSetExtractor", "<", "List", "<", "AnnotationGraph", ">", ">", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AomAnnotateExtractor", ".", "class", ")", ";", "private", "TableAccessStrategy", "outerQueryTableAccessStrategy", ";", "public", "AnnisNode", "mapNode", "(", "ResultSet", "resultSet", ",", "TableAccessStrategy", "tableAccessStrategy", ")", "throws", "SQLException", "{", "AnnisNode", "annisNode", "=", "new", "AnnisNode", "(", "longValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"id\"", ",", "tableAccessStrategy", ")", ")", ";", "annisNode", ".", "setCorpus", "(", "longValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"corpus_ref\"", ",", "tableAccessStrategy", ")", ")", ";", "annisNode", ".", "setTextId", "(", "longValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"text_ref\"", ",", "tableAccessStrategy", ")", ")", ";", "annisNode", ".", "setLeft", "(", "longValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"left\"", ",", "tableAccessStrategy", ")", ")", ";", "annisNode", ".", "setRight", "(", "longValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"right\"", ",", "tableAccessStrategy", ")", ")", ";", "annisNode", ".", "setNamespace", "(", "stringValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"namespace\"", ",", "tableAccessStrategy", ")", ")", ";", "annisNode", ".", "setName", "(", "stringValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"name\"", ",", "tableAccessStrategy", ")", ")", ";", "annisNode", ".", "setTokenIndex", "(", "longValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"token_index\"", ",", "tableAccessStrategy", ")", ")", ";", "if", "(", "resultSet", ".", "wasNull", "(", ")", ")", "annisNode", ".", "setTokenIndex", "(", "null", ")", ";", "annisNode", ".", "setSpannedText", "(", "stringValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"span\"", ",", "tableAccessStrategy", ")", ")", ";", "annisNode", ".", "setLeftToken", "(", "longValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"left_token\"", ",", "tableAccessStrategy", ")", ")", ";", "annisNode", ".", "setRightToken", "(", "longValue", "(", "resultSet", ",", "NODE_TABLE", ",", "\"right_token\"", ",", "tableAccessStrategy", ")", ")", ";", "return", "annisNode", ";", "}", "public", "Edge", "mapEdge", "(", "ResultSet", "resultSet", ",", "TableAccessStrategy", "tableAccessStrategy", ")", "throws", "SQLException", "{", "Edge", "edge", "=", "new", "Edge", "(", ")", ";", "edge", ".", "setPre", "(", "longValue", "(", "resultSet", ",", "RANK_TABLE", ",", "\"pre\"", ",", "tableAccessStrategy", ")", ")", ";", "edge", ".", "setComponentID", "(", "longValue", "(", "resultSet", ",", "RANK_TABLE", ",", "\"component_id\"", ",", "tableAccessStrategy", ")", ")", ";", "edge", ".", "setEdgeType", "(", "EdgeType", ".", "parseEdgeType", "(", "stringValue", "(", "resultSet", ",", "RANK_TABLE", ",", "\"edge_type\"", ",", "tableAccessStrategy", ")", ")", ")", ";", "edge", ".", "setNamespace", "(", "stringValue", "(", "resultSet", ",", "COMPONENT_TABLE", ",", "\"namespace\"", ",", "tableAccessStrategy", ")", ")", ";", "edge", ".", "setName", "(", "stringValue", "(", "resultSet", ",", "COMPONENT_TABLE", ",", "\"name\"", ",", "tableAccessStrategy", ")", ")", ";", "edge", ".", "setDestination", "(", "new", "AnnisNode", "(", "longValue", "(", "resultSet", ",", "RANK_TABLE", ",", "\"node_ref\"", ",", "tableAccessStrategy", ")", ")", ")", ";", "long", "parent", "=", "longValue", "(", "resultSet", ",", "RANK_TABLE", ",", "\"parent\"", ",", "tableAccessStrategy", ")", ";", "if", "(", "!", "resultSet", ".", "wasNull", "(", ")", ")", "edge", ".", "setSource", "(", "new", "AnnisNode", "(", "parent", ")", ")", ";", "return", "edge", ";", "}", "public", "Annotation", "mapAnnotation", "(", "ResultSet", "resultSet", ",", "TableAccessStrategy", "tableAccessStrategy", ",", "String", "table", ")", "throws", "SQLException", "{", "String", "name", "=", "stringValue", "(", "resultSet", ",", "table", ",", "\"name\"", ",", "tableAccessStrategy", ")", ";", "if", "(", "resultSet", ".", "wasNull", "(", ")", ")", "return", "null", ";", "String", "namespace", "=", "stringValue", "(", "resultSet", ",", "table", ",", "\"namespace\"", ",", "tableAccessStrategy", ")", ";", "String", "value", "=", "stringValue", "(", "resultSet", ",", "table", ",", "\"value\"", ",", "tableAccessStrategy", ")", ";", "return", "new", "Annotation", "(", "namespace", ",", "name", ",", "value", ")", ";", "}", "private", "long", "longValue", "(", "ResultSet", "resultSet", ",", "String", "table", ",", "String", "column", ",", "TableAccessStrategy", "tableAccessStrategy", ")", "throws", "SQLException", "{", "return", "resultSet", ".", "getLong", "(", "tableAccessStrategy", ".", "columnName", "(", "table", ",", "column", ")", ")", ";", "}", "private", "String", "stringValue", "(", "ResultSet", "resultSet", ",", "String", "table", ",", "String", "column", ",", "TableAccessStrategy", "tableAccessStrategy", ")", "throws", "SQLException", "{", "return", "resultSet", ".", "getString", "(", "tableAccessStrategy", ".", "columnName", "(", "table", ",", "column", ")", ")", ";", "}", "@", "Override", "public", "List", "<", "AnnotationGraph", ">", "extractData", "(", "ResultSet", "resultSet", ")", "throws", "SQLException", ",", "DataAccessException", "{", "TableAccessStrategy", "tableAccessStrategy", "=", "outerQueryTableAccessStrategy", ";", "List", "<", "AnnotationGraph", ">", "graphs", "=", "new", "LinkedList", "<", "AnnotationGraph", ">", "(", ")", ";", "Map", "<", "List", "<", "Long", ">", ",", "AnnotationGraph", ">", "graphByMatchGroup", "=", "new", "HashMap", "<", "List", "<", "Long", ">", ",", "AnnotationGraph", ">", "(", ")", ";", "Map", "<", "Long", ",", "AnnisNode", ">", "nodeById", "=", "new", "HashMap", "<", "Long", ",", "AnnisNode", ">", "(", ")", ";", "Map", "<", "RankID", ",", "Edge", ">", "edgeByPre", "=", "new", "HashMap", "<", "RankID", ",", "Edge", ">", "(", ")", ";", "int", "rowNum", "=", "0", ";", "while", "(", "resultSet", ".", "next", "(", ")", ")", "{", "Array", "sqlKey", "=", "resultSet", ".", "getArray", "(", "\"key\"", ")", ";", "Validate", ".", "isTrue", "(", "!", "resultSet", ".", "wasNull", "(", ")", ",", "\"\"", ")", ";", "Validate", ".", "isTrue", "(", "sqlKey", ".", "getBaseType", "(", ")", "==", "Types", ".", "BIGINT", ",", "\"\"", "+", "sqlKey", ".", "getBaseTypeName", "(", ")", "+", "\"\\\"\"", ")", ";", "Long", "[", "]", "keyArray", "=", "(", "Long", "[", "]", ")", "sqlKey", ".", "getArray", "(", ")", ";", "List", "<", "Long", ">", "key", "=", "Arrays", ".", "asList", "(", "keyArray", ")", ";", "if", "(", "!", "graphByMatchGroup", ".", "containsKey", "(", "key", ")", ")", "{", "log", ".", "debug", "(", "\"\"", "+", "key", ")", ";", "AnnotationGraph", "graph", "=", "new", "AnnotationGraph", "(", ")", ";", "graphs", ".", "add", "(", "graph", ")", ";", "graphByMatchGroup", ".", "put", "(", "key", ",", "graph", ")", ";", "nodeById", ".", "clear", "(", ")", ";", "edgeByPre", ".", "clear", "(", ")", ";", "for", "(", "Long", "l", ":", "key", ")", "{", "if", "(", "l", "!=", "null", ")", "{", "graph", ".", "addMatchedNodeId", "(", "l", ")", ";", "}", "}", "}", "AnnotationGraph", "graph", "=", "graphByMatchGroup", ".", "get", "(", "key", ")", ";", "graph", ".", "setDocumentName", "(", "new", "DocumentNameMapRow", "(", ")", ".", "mapRow", "(", "resultSet", ",", "rowNum", ")", ")", ";", "Array", "path", "=", "resultSet", ".", "getArray", "(", "\"path\"", ")", ";", "graph", ".", "setPath", "(", "(", "String", "[", "]", ")", "path", ".", "getArray", "(", ")", ")", ";", "AnnisNode", "node", "=", "mapNode", "(", "resultSet", ",", "tableAccessStrategy", ")", ";", "long", "id", "=", "node", ".", "getId", "(", ")", ";", "if", "(", "!", "nodeById", ".", "containsKey", "(", "id", ")", ")", "{", "log", ".", "debug", "(", "\"new", "node:", "\"", "+", "id", ")", ";", "nodeById", ".", "put", "(", "id", ",", "node", ")", ";", "graph", ".", "addNode", "(", "node", ")", ";", "}", "else", "{", "node", "=", "nodeById", ".", "get", "(", "id", ")", ";", "}", "long", "matchIndex", "=", "1", ";", "for", "(", "Long", "l", ":", "key", ")", "{", "if", "(", "l", "!=", "null", ")", "{", "if", "(", "id", "==", "l", ")", "{", "node", ".", "setMatchedNodeInQuery", "(", "matchIndex", ")", ";", "break", ";", "}", "matchIndex", "++", ";", "}", "}", "Edge", "edge", "=", "mapEdge", "(", "resultSet", ",", "tableAccessStrategy", ")", ";", "long", "pre", "=", "edge", ".", "getPre", "(", ")", ";", "long", "componentID", "=", "edge", ".", "getComponentID", "(", ")", ";", "if", "(", "!", "edgeByPre", ".", "containsKey", "(", "new", "RankID", "(", "componentID", ",", "pre", ")", ")", ")", "{", "edge", ".", "setDestination", "(", "node", ")", ";", "fixNodes", "(", "edge", ",", "edgeByPre", ",", "nodeById", ")", ";", "node", ".", "addIncomingEdge", "(", "edge", ")", ";", "AnnisNode", "source", "=", "edge", ".", "getSource", "(", ")", ";", "if", "(", "source", "!=", "null", ")", "{", "source", ".", "addOutgoingEdge", "(", "edge", ")", ";", "}", "log", ".", "debug", "(", "\"new", "edge:", "\"", "+", "edge", ")", ";", "edgeByPre", ".", "put", "(", "new", "RankID", "(", "componentID", ",", "pre", ")", ",", "edge", ")", ";", "graph", ".", "addEdge", "(", "edge", ")", ";", "}", "else", "{", "edge", "=", "edgeByPre", ".", "get", "(", "new", "RankID", "(", "componentID", ",", "pre", ")", ")", ";", "}", "Annotation", "nodeAnnotation", "=", "mapAnnotation", "(", "resultSet", ",", "tableAccessStrategy", ",", "TableAccessStrategy", ".", "NODE_ANNOTATION_TABLE", ")", ";", "if", "(", "nodeAnnotation", "!=", "null", ")", "{", "node", ".", "addNodeAnnotation", "(", "nodeAnnotation", ")", ";", "}", "Annotation", "edgeAnnotation", "=", "mapAnnotation", "(", "resultSet", ",", "tableAccessStrategy", ",", "TableAccessStrategy", ".", "EDGE_ANNOTATION_TABLE", ")", ";", "if", "(", "edgeAnnotation", "!=", "null", ")", "{", "edge", ".", "addAnnotation", "(", "edgeAnnotation", ")", ";", "}", "rowNum", "++", ";", "}", "for", "(", "AnnotationGraph", "graph", ":", "graphByMatchGroup", ".", "values", "(", ")", ")", "{", "ListIterator", "<", "Edge", ">", "itEdge", "=", "graph", ".", "getEdges", "(", ")", ".", "listIterator", "(", ")", ";", "while", "(", "itEdge", ".", "hasNext", "(", ")", ")", "{", "Edge", "edge", "=", "itEdge", ".", "next", "(", ")", ";", "if", "(", "edge", ".", "getSource", "(", ")", "==", "null", ")", "{", "edge", ".", "getDestination", "(", ")", ".", "getIncomingEdges", "(", ")", ".", "remove", "(", "edge", ")", ";", "itEdge", ".", "remove", "(", ")", ";", "}", "}", "}", "return", "graphs", ";", "}", "protected", "void", "fixNodes", "(", "Edge", "edge", ",", "Map", "<", "RankID", ",", "Edge", ">", "edgeByPre", ",", "Map", "<", "Long", ",", "AnnisNode", ">", "nodeById", ")", "{", "AnnisNode", "source", "=", "edge", ".", "getSource", "(", ")", ";", "if", "(", "source", "==", "null", ")", "{", "return", ";", "}", "long", "pre", "=", "source", ".", "getId", "(", ")", ";", "Edge", "parentEdge", "=", "edgeByPre", ".", "get", "(", "new", "RankID", "(", "edge", ".", "getComponentID", "(", ")", ",", "pre", ")", ")", ";", "AnnisNode", "parent", "=", "parentEdge", "!=", "null", "?", "parentEdge", ".", "getDestination", "(", ")", ":", "null", ";", "edge", ".", "setSource", "(", "parent", ")", ";", "long", "destinationId", "=", "edge", ".", "getDestination", "(", ")", ".", "getId", "(", ")", ";", "edge", ".", "setDestination", "(", "nodeById", ".", "get", "(", "destinationId", ")", ")", ";", "}", "public", "TableAccessStrategy", "getOuterQueryTableAccessStrategy", "(", ")", "{", "return", "outerQueryTableAccessStrategy", ";", "}", "public", "void", "setOuterQueryTableAccessStrategy", "(", "TableAccessStrategy", "outerQueryTableAccessStrategy", ")", "{", "this", ".", "outerQueryTableAccessStrategy", "=", "outerQueryTableAccessStrategy", ";", "}", "}", "</s>" ]
8,808
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "annis", ".", "CommonHelper", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "java", ".", "net", ".", "URI", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "static", "annis", ".", "sqlgen", ".", "AbstractSqlGenerator", ".", "TABSTOP", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "CORPUS_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "sqlString", ";", "import", "java", ".", "util", ".", "Collections", ";", "public", "class", "GraphWithClauseGenerator", "extends", "CommonAnnotateWithClauseGenerator", "{", "@", "Override", "protected", "String", "getMatchesWithClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "TableAccessStrategy", "tas", "=", "createTableAccessStrategy", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "String", "indent2", "=", "indent", "+", "TABSTOP", ";", "String", "indent3", "=", "indent2", "+", "TABSTOP", ";", "List", "<", "AnnotateQueryData", ">", "extensions", "=", "queryData", ".", "getExtensions", "(", "AnnotateQueryData", ".", "class", ")", ";", "AnnotateQueryData", "annotateQueryData", "=", "extensions", ".", "isEmpty", "(", ")", "?", "new", "AnnotateQueryData", "(", "5", ",", "5", ")", ":", "extensions", ".", "get", "(", "0", ")", ";", "List", "<", "SaltURIs", ">", "listOfSaltURIs", "=", "queryData", ".", "getExtensions", "(", "SaltURIs", ".", "class", ")", ";", "Validate", ".", "isTrue", "(", "!", "listOfSaltURIs", ".", "isEmpty", "(", ")", ")", ";", "SaltURIs", "saltURIs", "=", "listOfSaltURIs", ".", "get", "(", "0", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"matches", "ASn\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"(n\"", ")", ";", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"SELECTn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "\"1", "AS", "n,", "n\"", ")", ".", "append", "(", "indent3", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "alternative", ".", "size", "(", ")", ";", "i", "++", ")", "{", "sb", ".", "append", "(", "tas", ".", "tableName", "(", "NODE_TABLE", ")", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\".\"", ")", ".", "append", "(", "tas", ".", "columnName", "(", "NODE_TABLE", ",", "\"id\"", ")", ")", ".", "append", "(", "\"", "AS", "\"", ")", ".", "append", "(", "\"id\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "tas", ".", "tableName", "(", "NODE_TABLE", ")", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\".\"", ")", ".", "append", "(", "tas", ".", "columnName", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ".", "append", "(", "\"", "AS", "\"", ")", ".", "append", "(", "\"text\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "tas", ".", "tableName", "(", "NODE_TABLE", ")", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\".\"", ")", ".", "append", "(", "tas", ".", "columnName", "(", "NODE_TABLE", ",", "\"left_token\"", ")", ")", ";", "if", "(", "annotateQueryData", ".", "getSegmentationLayer", "(", ")", "==", "null", ")", "{", "sb", ".", "append", "(", "\"", "-", "\"", ")", ".", "append", "(", "annotateQueryData", ".", "getLeft", "(", ")", ")", ";", "}", "sb", ".", "append", "(", "\"", "AS", "\"", ")", ".", "append", "(", "\"min\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "tas", ".", "tableName", "(", "NODE_TABLE", ")", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\".\"", ")", ".", "append", "(", "tas", ".", "columnName", "(", "NODE_TABLE", ",", "\"right_token\"", ")", ")", ";", "if", "(", "annotateQueryData", ".", "getSegmentationLayer", "(", ")", "==", "null", ")", "{", "sb", ".", "append", "(", "\"", "+", "\"", ")", ".", "append", "(", "annotateQueryData", ".", "getRight", "(", ")", ")", ";", "}", "sb", ".", "append", "(", "\"", "AS", "\"", ")", ".", "append", "(", "\"max\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "tas", ".", "tableName", "(", "NODE_TABLE", ")", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\".\"", ")", ".", "append", "(", "tas", ".", "columnName", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ")", ".", "append", "(", "\"", "AS", "\"", ")", ".", "append", "(", "\"corpus\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "tas", ".", "tableName", "(", "NODE_TABLE", ")", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\".\"", ")", ".", "append", "(", "tas", ".", "columnName", "(", "NODE_TABLE", ",", "\"node_name\"", ")", ")", ".", "append", "(", "\"", "AS", "\"", ")", ".", "append", "(", "\"name\"", ")", ".", "append", "(", "i", ")", ";", "if", "(", "i", "==", "alternative", ".", "size", "(", ")", ")", "{", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "\",", "n\"", ")", ".", "append", "(", "indent3", ")", ";", "}", "}", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"FROMn\"", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "alternative", ".", "size", "(", ")", ";", "i", "++", ")", "{", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "tas", ".", "tableName", "(", "NODE_TABLE", ")", ")", ".", "append", "(", "\"", "AS", "\"", ")", ".", "append", "(", "\"facts\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\",", "\"", ")", ".", "append", "(", "tas", ".", "tableName", "(", "CORPUS_TABLE", ")", ")", ".", "append", "(", "\"", "AS", "\"", ")", ".", "append", "(", "\"corpus\"", ")", ".", "append", "(", "i", ")", ";", "if", "(", "i", "==", "alternative", ".", "size", "(", ")", ")", "{", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "\",n\"", ")", ".", "append", "(", "indent3", ")", ";", "}", "}", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"WHEREn\"", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "alternative", ".", "size", "(", ")", ";", "i", "++", ")", "{", "URI", "uri", "=", "saltURIs", ".", "get", "(", "i", "-", "1", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "\"corpus\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "generatePathName", "(", "uri", ")", ")", ".", "append", "(", "\"", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "\"facts\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"corpus\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\".id", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "\"facts\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "\"'\"", ")", ".", "append", "(", "uri", ".", "getFragment", "(", ")", ")", ".", "append", "(", "\"'\"", ")", ".", "append", "(", "\"", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent3", ")", ".", "append", "(", "\"facts\"", ")", ".", "append", "(", "i", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "StringUtils", ".", "join", "(", "queryData", ".", "getCorpusList", "(", ")", ",", "\",\"", ")", ")", ".", "append", "(", "\")", "\"", ")", ";", "if", "(", "i", "<", "alternative", ".", "size", "(", ")", ")", "{", "sb", ".", "append", "(", "\"ANDn\"", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "}", "sb", ".", "append", "(", "indent2", ")", ".", "append", "(", "\"LIMIT", "1n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "private", "String", "generatePathName", "(", "URI", "uri", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "List", "<", "String", ">", "path", "=", "CommonHelper", ".", "getCorpusPath", "(", "uri", ")", ";", "Collections", ".", "reverse", "(", "path", ")", ";", "sb", ".", "append", "(", "\"{\"", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "path", ",", "\",", "\"", ")", ")", ";", "sb", ".", "append", "(", "\"}\"", ")", ";", "return", "sqlString", "(", "sb", ".", "toString", "(", ")", ")", ";", "}", "}", "</s>" ]
8,809
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "sql", ".", "Types", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "AbstractSolutionKey", "<", "BaseType", ">", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AbstractSolutionKey", ".", "class", ")", ";", "private", "String", "idColumnName", ";", "private", "List", "<", "BaseType", ">", "lastKey", ";", "private", "List", "<", "BaseType", ">", "currentKey", ";", "public", "List", "<", "String", ">", "generateInnerQueryColumns", "(", "TableAccessStrategy", "tableAccessStrategy", ",", "int", "index", ")", "{", "List", "<", "String", ">", "columns", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "columns", ".", "add", "(", "tableAccessStrategy", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "idColumnName", ")", "+", "\"", "AS", "\"", "+", "idColumnName", "+", "index", ")", ";", "return", "columns", ";", "}", "public", "boolean", "isNewKey", "(", ")", "{", "return", "currentKey", "==", "null", "||", "!", "currentKey", ".", "equals", "(", "lastKey", ")", ";", "}", "public", "Integer", "getMatchedNodeIndex", "(", "Object", "id", ")", "{", "int", "index", "=", "getCurrentKey", "(", ")", ".", "indexOf", "(", "id", ")", ";", "return", "index", "==", "-", "1", "?", "null", ":", "index", "+", "1", ";", "}", "public", "String", "getCurrentKeyAsString", "(", ")", "{", "return", "StringUtils", ".", "join", "(", "getCurrentKey", "(", ")", ",", "\",\"", ")", ";", "}", "public", "Object", "getNodeId", "(", "ResultSet", "resultSet", ",", "TableAccessStrategy", "tableAccessStrategy", ")", "{", "try", "{", "String", "idAlias", "=", "tableAccessStrategy", ".", "columnName", "(", "NODE_TABLE", ",", "getIdColumnName", "(", ")", ")", ";", "int", "idAliasIdx", "=", "resultSet", ".", "findColumn", "(", "idAlias", ")", ";", "if", "(", "resultSet", ".", "getMetaData", "(", ")", "!=", "null", ")", "{", "switch", "(", "resultSet", ".", "getMetaData", "(", ")", ".", "getColumnType", "(", "idAliasIdx", ")", ")", "{", "case", "Types", ".", "VARCHAR", ":", "return", "resultSet", ".", "getString", "(", "idAliasIdx", ")", ";", "case", "Types", ".", "BIGINT", ":", "return", "resultSet", ".", "getLong", "(", "idAliasIdx", ")", ";", "case", "Types", ".", "INTEGER", ":", "return", "resultSet", ".", "getInt", "(", "idAliasIdx", ")", ";", "}", "}", "return", "resultSet", ".", "getObject", "(", "idAliasIdx", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ",", "e", ")", ";", "throw", "new", "IllegalStateException", "(", "\"\"", ",", "e", ")", ";", "}", "}", "public", "String", "getIdColumnName", "(", ")", "{", "return", "idColumnName", ";", "}", "public", "void", "setIdColumnName", "(", "String", "idColumnName", ")", "{", "this", ".", "idColumnName", "=", "idColumnName", ";", "}", "protected", "List", "<", "BaseType", ">", "getLastKey", "(", ")", "{", "return", "lastKey", ";", "}", "protected", "void", "setLastKey", "(", "List", "<", "BaseType", ">", "lastKey", ")", "{", "this", ".", "lastKey", "=", "lastKey", ";", "}", "protected", "List", "<", "BaseType", ">", "getCurrentKey", "(", ")", "{", "return", "currentKey", ";", "}", "protected", "void", "setCurrentKey", "(", "List", "<", "BaseType", ">", "currentKey", ")", "{", "this", ".", "currentKey", "=", "currentKey", ";", "}", "public", "int", "getKeySize", "(", ")", "{", "return", "currentKey", ".", "size", "(", ")", ";", "}", "}", "</s>" ]
8,810
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "NodeNameAndIdPostgreSqlArraySolutionKey", "extends", "PostgreSqlArraySolutionKey", "<", "String", ">", "{", "public", "NodeNameAndIdPostgreSqlArraySolutionKey", "(", ")", "{", "super", "(", ")", ";", "setIdColumnName", "(", "\"name\"", ")", ";", "setKeyColumnName", "(", "\"key_names\"", ")", ";", "}", "@", "Override", "public", "List", "<", "String", ">", "generateInnerQueryColumns", "(", "TableAccessStrategy", "tableAccessStrategy", ",", "int", "index", ")", "{", "List", "<", "String", ">", "columns", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "columns", ".", "add", "(", "tableAccessStrategy", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"id\"", ")", "+", "\"", "AS", "\"", "+", "\"id\"", "+", "index", ")", ";", "columns", ".", "add", "(", "tableAccessStrategy", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"name\"", ")", "+", "\"", "AS", "\"", "+", "\"name\"", "+", "index", ")", ";", "return", "columns", ";", "}", "@", "Override", "public", "List", "<", "String", ">", "generateOuterQueryColumns", "(", "TableAccessStrategy", "tableAccessStrategy", ",", "int", "size", ")", "{", "String", "idAlias", "=", "tableAccessStrategy", ".", "aliasedColumn", "(", "\"solutions\"", ",", "\"id\"", ")", ";", "String", "nameAlias", "=", "tableAccessStrategy", ".", "aliasedColumn", "(", "\"solutions\"", ",", "\"name\"", ")", ";", "List", "<", "String", ">", "columns", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "columns", ".", "add", "(", "createKeyArray", "(", "idAlias", ",", "\"key\"", ",", "size", ")", ")", ";", "columns", ".", "add", "(", "createKeyArray", "(", "nameAlias", ",", "\"key_names\"", ",", "size", ")", ")", ";", "return", "columns", ";", "}", "}", "</s>" ]
8,811
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "AbstractSqlGenerator", ".", "TABSTOP", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "COMPONENT_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "EDGE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "RANK_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "TEXT_TABLE", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "public", "class", "TableJoinsInFromClauseSqlGenerator", "extends", "AbstractFromClauseGenerator", "{", "@", "Override", "public", "String", "fromClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "List", "<", "String", ">", "tables", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "QueryNode", "node", ":", "alternative", ")", "tables", ".", "add", "(", "fromClauseForNode", "(", "node", ",", "false", ")", ")", ";", "return", "StringUtils", ".", "join", "(", "tables", ",", "\",n\"", "+", "indent", "+", "TABSTOP", ")", ";", "}", "public", "String", "fromClauseForNode", "(", "QueryNode", "node", ",", "boolean", "leftJoin", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "tableAliasDefinition", "(", "node", ",", "NODE_TABLE", ",", "1", ")", ")", ";", "if", "(", "tables", "(", "node", ")", ".", "usesRankTable", "(", ")", "&&", "!", "tables", "(", "node", ")", ".", "isMaterialized", "(", "RANK_TABLE", ",", "NODE_TABLE", ")", ")", "{", "sb", ".", "append", "(", "\"", "\"", ")", ";", "sb", ".", "append", "(", "joinDefinition", "(", "node", ",", "RANK_TABLE", ",", "\"node_ref\"", ",", "NODE_TABLE", ",", "\"id\"", ",", "false", ")", ")", ";", "}", "if", "(", "tables", "(", "node", ")", ".", "usesComponentTable", "(", ")", "&&", "!", "tables", "(", "node", ")", ".", "isMaterialized", "(", "COMPONENT_TABLE", ",", "RANK_TABLE", ")", ")", "{", "sb", ".", "append", "(", "\"", "\"", ")", ";", "sb", ".", "append", "(", "joinDefinition", "(", "node", ",", "COMPONENT_TABLE", ",", "\"id\"", ",", "RANK_TABLE", ",", "\"\"", ",", "false", ")", ")", ";", "}", "if", "(", "tables", "(", "node", ")", ".", "usesNodeAnnotationTable", "(", ")", ")", "{", "int", "start", "=", "tables", "(", "node", ")", ".", "isMaterialized", "(", "NODE_ANNOTATION_TABLE", ",", "NODE_TABLE", ")", "?", "2", ":", "1", ";", "int", "size", "=", "node", "!=", "null", "?", "node", ".", "getNodeAnnotations", "(", ")", ".", "size", "(", ")", ":", "1", ";", "for", "(", "int", "i", "=", "start", ";", "i", "<=", "size", ";", "++", "i", ")", "{", "sb", ".", "append", "(", "\"", "\"", ")", ";", "sb", ".", "append", "(", "joinDefinition", "(", "node", ",", "NODE_ANNOTATION_TABLE", ",", "\"node_ref\"", ",", "NODE_TABLE", ",", "\"id\"", ",", "i", ",", "leftJoin", ")", ")", ";", "}", "}", "if", "(", "!", "tables", "(", "node", ")", ".", "usesNodeAnnotationTable", "(", ")", "&&", "node", ".", "getNodeAnnotations", "(", ")", ".", "size", "(", ")", ">", "0", "&&", "!", "tables", "(", "node", ")", ".", "isMaterialized", "(", "NODE_ANNOTATION_TABLE", ",", "NODE_TABLE", ")", ")", "{", "sb", ".", "append", "(", "\"", "\"", ")", ";", "sb", ".", "append", "(", "joinDefinition", "(", "node", ",", "NODE_ANNOTATION_TABLE", ",", "\"node_ref\"", ",", "NODE_TABLE", ",", "\"id\"", ",", "leftJoin", ")", ")", ";", "}", "if", "(", "tables", "(", "node", ")", ".", "usesEdgeAnnotationTable", "(", ")", ")", "{", "int", "start", "=", "tables", "(", "node", ")", ".", "isMaterialized", "(", "EDGE_ANNOTATION_TABLE", ",", "RANK_TABLE", ")", "?", "2", ":", "1", ";", "int", "size", "=", "node", "!=", "null", "?", "node", ".", "getEdgeAnnotations", "(", ")", ".", "size", "(", ")", ":", "1", ";", "for", "(", "int", "i", "=", "start", ";", "i", "<=", "size", ";", "++", "i", ")", "{", "sb", ".", "append", "(", "\"", "\"", ")", ";", "sb", ".", "append", "(", "joinDefinition", "(", "node", ",", "EDGE_ANNOTATION_TABLE", ",", "\"rank_ref\"", ",", "RANK_TABLE", ",", "\"pre\"", ",", "i", ",", "leftJoin", ")", ")", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "protected", "String", "joinDefinition", "(", "QueryNode", "node", ",", "String", "table", ",", "String", "column", ",", "String", "joinedTable", ",", "String", "joinedColumn", ")", "{", "return", "joinDefinition", "(", "node", ",", "table", ",", "column", ",", "joinedTable", ",", "joinedColumn", ",", "false", ")", ";", "}", "protected", "String", "joinDefinition", "(", "QueryNode", "node", ",", "String", "table", ",", "String", "column", ",", "String", "joinedTable", ",", "String", "joinedColumn", ",", "boolean", "leftJoin", ")", "{", "return", "joinDefinition", "(", "node", ",", "table", ",", "column", ",", "joinedTable", ",", "joinedColumn", ",", "1", ",", "leftJoin", ")", ";", "}", "protected", "String", "joinDefinition", "(", "QueryNode", "node", ",", "String", "table", ",", "String", "column", ",", "String", "joinedTable", ",", "String", "joinedColumn", ",", "int", "count", ")", "{", "return", "joinDefinition", "(", "node", ",", "table", ",", "column", ",", "joinedTable", ",", "joinedColumn", ",", "count", ",", "false", ")", ";", "}", "protected", "String", "joinDefinition", "(", "QueryNode", "node", ",", "String", "table", ",", "String", "column", ",", "String", "joinedTable", ",", "String", "joinedColumn", ",", "int", "count", ",", "boolean", "leftJoin", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "if", "(", "leftJoin", ")", "{", "sb", ".", "append", "(", "\"LEFT", "OUTER", "\"", ")", ";", "}", "sb", ".", "append", "(", "\"JOIN", "\"", ")", ";", "sb", ".", "append", "(", "tableAliasDefinition", "(", "node", ",", "table", ",", "count", ")", ")", ";", "sb", ".", "append", "(", "\"", "ON", "(\"", ")", ";", "sb", ".", "append", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "table", ",", "column", ",", "count", ")", ")", ";", "sb", ".", "append", "(", "\"", "=", "\"", ")", ";", "sb", ".", "append", "(", "tables", "(", "node", ")", ".", "aliasedColumn", "(", "joinedTable", ",", "joinedColumn", ")", ")", ";", "sb", ".", "append", "(", "\")\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,812
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "java", ".", "net", ".", "URI", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "public", "class", "SaltURIs", "extends", "ArrayList", "<", "URI", ">", "{", "}", "</s>" ]
8,813
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "CommonLimitOffsetGenerator", "implements", "LimitOffsetClauseSqlGenerator", "<", "QueryData", ">", "{", "@", "Override", "public", "String", "limitOffsetClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "LimitOffsetQueryData", "LimitOffsetQueryData", "=", "getLimitOffsetQueryData", "(", "queryData", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "Integer", "limit", "=", "null", ";", "Integer", "offset", "=", "null", ";", "if", "(", "LimitOffsetQueryData", "!=", "null", ")", "{", "limit", "=", "LimitOffsetQueryData", ".", "getLimit", "(", ")", ";", "offset", "=", "LimitOffsetQueryData", ".", "getOffset", "(", ")", ";", "}", "if", "(", "limit", "!=", "null", ")", "{", "sb", ".", "append", "(", "\"LIMIT", "\"", ")", ".", "append", "(", "limit", ")", ".", "append", "(", "\"n\"", ")", ";", "}", "if", "(", "offset", "!=", "null", ")", "{", "sb", ".", "append", "(", "\"OFFSET", "\"", ")", ".", "append", "(", "offset", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "private", "LimitOffsetQueryData", "getLimitOffsetQueryData", "(", "QueryData", "queryData", ")", "{", "for", "(", "Object", "o", ":", "queryData", ".", "getExtensions", "(", ")", ")", "{", "if", "(", "o", "instanceof", "LimitOffsetQueryData", ")", "{", "return", "(", "LimitOffsetQueryData", ")", "o", ";", "}", "}", "return", "null", ";", "}", "}", "</s>" ]
8,814
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "interface", "SelectClauseSqlGenerator", "<", "T", ">", "{", "String", "selectClause", "(", "T", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", ";", "}", "</s>" ]
8,815
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "public", "class", "CountSqlGenerator", "extends", "AbstractSqlGenerator", "<", "Integer", ">", "implements", "SelectClauseSqlGenerator", "<", "QueryData", ">", ",", "FromClauseSqlGenerator", "<", "QueryData", ">", "{", "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "private", "SqlGenerator", "findSqlGenerator", ";", "@", "Override", "public", "String", "selectClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "return", "\"n\"", "+", "indent", "+", "TABSTOP", "+", "\"count(*)\"", ";", "}", "@", "Override", "public", "Integer", "extractData", "(", "ResultSet", "rs", ")", "throws", "SQLException", ",", "DataAccessException", "{", "int", "sum", "=", "0", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "sum", "+=", "rs", ".", "getInt", "(", "1", ")", ";", "return", "sum", ";", "}", "@", "Override", "public", "String", "fromClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"(n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "findSqlGenerator", ".", "toSql", "(", "queryData", ",", "indent", "+", "TABSTOP", ")", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ".", "append", "(", "\"\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "SqlGenerator", "getFindSqlGenerator", "(", ")", "{", "return", "findSqlGenerator", ";", "}", "public", "void", "setFindSqlGenerator", "(", "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "SqlGenerator", "findSqlGenerator", ")", "{", "this", ".", "findSqlGenerator", "=", "findSqlGenerator", ";", "}", "}", "</s>" ]
8,816
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "CORPUS_TABLE", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "ResultSetMetaData", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "annis", ".", "service", ".", "objects", ".", "Match", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "service", ".", "internal", ".", "AnnisWebService", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "net", ".", "URLEncoder", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "FindSqlGenerator", "extends", "AbstractUnionSqlGenerator", "<", "List", "<", "Match", ">", ">", "implements", "SelectClauseSqlGenerator", "<", "QueryData", ">", ",", "OrderByClauseSqlGenerator", "<", "QueryData", ">", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "FindSqlGenerator", ".", "class", ")", ";", "private", "boolean", "optimizeDistinct", ";", "private", "boolean", "sortSolutions", ";", "private", "CorpusPathExtractor", "corpusPathExtractor", ";", "@", "Override", "public", "String", "selectClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "int", "maxWidth", "=", "queryData", ".", "getMaxWidth", "(", ")", ";", "Validate", ".", "isTrue", "(", "alternative", ".", "size", "(", ")", "<=", "maxWidth", ",", "\"\"", ")", ";", "boolean", "isDistinct", "=", "false", "||", "!", "optimizeDistinct", ";", "List", "<", "String", ">", "ids", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "int", "i", "=", "0", ";", "for", "(", "QueryNode", "node", ":", "alternative", ")", "{", "++", "i", ";", "TableAccessStrategy", "tblAccessStr", "=", "tables", "(", "node", ")", ";", "ids", ".", "add", "(", "tblAccessStr", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"id\"", ")", "+", "\"", "AS", "id\"", "+", "i", ")", ";", "ids", ".", "add", "(", "tblAccessStr", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"node_name\"", ")", "+", "\"\"", "+", "i", ")", ";", "ids", ".", "add", "(", "tblAccessStr", ".", "aliasedColumn", "(", "CORPUS_TABLE", ",", "\"path_name\"", ")", "+", "\"\"", "+", "i", ")", ";", "if", "(", "tblAccessStr", ".", "usesRankTable", "(", ")", ")", "{", "isDistinct", "=", "true", ";", "}", "}", "for", "(", "i", "=", "alternative", ".", "size", "(", ")", ";", "i", "<", "maxWidth", ";", "++", "i", ")", "{", "ids", ".", "add", "(", "\"NULL\"", ")", ";", "}", "ids", ".", "add", "(", "tables", "(", "alternative", ".", "get", "(", "0", ")", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", ")", ";", "return", "(", "isDistinct", "?", "\"DISTINCT\"", ":", "\"\"", ")", "+", "\"n\"", "+", "indent", "+", "TABSTOP", "+", "StringUtils", ".", "join", "(", "ids", ",", "\",", "\"", ")", ";", "}", "@", "Override", "protected", "void", "appendOrderByClause", "(", "StringBuffer", "sb", ",", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "if", "(", "!", "sortSolutions", ")", "{", "return", ";", "}", "List", "<", "LimitOffsetQueryData", ">", "extensions", "=", "queryData", ".", "getExtensions", "(", "LimitOffsetQueryData", ".", "class", ")", ";", "if", "(", "extensions", ".", "size", "(", ")", ">", "0", ")", "{", "super", ".", "appendOrderByClause", "(", "sb", ",", "queryData", ",", "alternative", ",", "indent", ")", ";", "}", "}", "@", "Override", "public", "String", "orderByClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "List", "<", "String", ">", "ids", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "queryData", ".", "getMaxWidth", "(", ")", ";", "++", "i", ")", "{", "ids", ".", "add", "(", "\"id\"", "+", "i", ")", ";", "}", "return", "StringUtils", ".", "join", "(", "ids", ",", "\",", "\"", ")", ";", "}", "@", "Override", "public", "List", "<", "Match", ">", "extractData", "(", "ResultSet", "rs", ")", "throws", "SQLException", ",", "DataAccessException", "{", "List", "<", "Match", ">", "matches", "=", "new", "ArrayList", "<", "Match", ">", "(", ")", ";", "int", "rowNum", "=", "0", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "matches", ".", "add", "(", "mapRow", "(", "rs", ",", "++", "rowNum", ")", ")", ";", "}", "return", "matches", ";", "}", "public", "Match", "mapRow", "(", "ResultSet", "rs", ",", "int", "rowNum", ")", "throws", "SQLException", "{", "Match", "match", "=", "new", "Match", "(", ")", ";", "ResultSetMetaData", "metaData", "=", "rs", ".", "getMetaData", "(", ")", ";", "int", "columnCount", "=", "metaData", ".", "getColumnCount", "(", ")", ";", "String", "node_name", "=", "null", ";", "List", "<", "String", ">", "corpus_path", "=", "null", ";", "for", "(", "int", "column", "=", "1", ";", "column", "<=", "columnCount", ";", "++", "column", ")", "{", "if", "(", "metaData", ".", "getColumnName", "(", "column", ")", ".", "startsWith", "(", "\"path_name\"", ")", ")", "{", "corpus_path", "=", "corpusPathExtractor", ".", "extractCorpusPath", "(", "rs", ",", "metaData", ".", "getColumnName", "(", "column", ")", ")", ";", "}", "}", "for", "(", "int", "column", "=", "1", ";", "column", "<=", "columnCount", ";", "++", "column", ")", "{", "if", "(", "metaData", ".", "getColumnName", "(", "column", ")", ".", "startsWith", "(", "\"node_name\"", ")", ")", "{", "node_name", "=", "rs", ".", "getString", "(", "column", ")", ";", "}", "else", "if", "(", "rs", ".", "wasNull", "(", ")", ")", "{", "break", ";", "}", "if", "(", "node_name", "!=", "null", ")", "{", "match", ".", "setSaltId", "(", "buildSaltId", "(", "corpus_path", ",", "node_name", ")", ")", ";", "node_name", "=", "null", ";", "}", "}", "return", "match", ";", "}", "public", "boolean", "isOptimizeDistinct", "(", ")", "{", "return", "optimizeDistinct", ";", "}", "public", "void", "setOptimizeDistinct", "(", "boolean", "optimizeDistinct", ")", "{", "this", ".", "optimizeDistinct", "=", "optimizeDistinct", ";", "}", "private", "String", "buildSaltId", "(", "List", "<", "String", ">", "path", ",", "String", "node_name", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"salt:/\"", ")", ";", "for", "(", "String", "dir", ":", "path", ")", "{", "try", "{", "sb", ".", "append", "(", "URLEncoder", ".", "encode", "(", "dir", ",", "\"UTF-8\"", ")", ")", ".", "append", "(", "\"/\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "sb", ".", "append", "(", "dir", ")", ".", "append", "(", "\"/\"", ")", ";", "}", "}", "return", "sb", ".", "append", "(", "\"#\"", ")", ".", "append", "(", "node_name", ")", ".", "toString", "(", ")", ";", "}", "public", "CorpusPathExtractor", "getCorpusPathExtractor", "(", ")", "{", "return", "corpusPathExtractor", ";", "}", "public", "void", "setCorpusPathExtractor", "(", "CorpusPathExtractor", "corpusPathExtractor", ")", "{", "this", ".", "corpusPathExtractor", "=", "corpusPathExtractor", ";", "}", "public", "boolean", "isSortSolutions", "(", ")", "{", "return", "sortSolutions", ";", "}", "public", "void", "setSortSolutions", "(", "boolean", "sortSolutions", ")", "{", "this", ".", "sortSolutions", "=", "sortSolutions", ";", "}", "}", "</s>" ]
8,817
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "apache", ".", "commons", ".", "collections", ".", "Bag", ";", "import", "org", ".", "apache", ".", "commons", ".", "collections", ".", "bag", ".", "HashBag", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "TableAccessStrategy", "{", "public", "final", "static", "String", "NODE_TABLE", "=", "\"node\"", ";", "public", "final", "static", "String", "RANK_TABLE", "=", "\"rank\"", ";", "public", "final", "static", "String", "COMPONENT_TABLE", "=", "\"component\"", ";", "public", "final", "static", "String", "NODE_ANNOTATION_TABLE", "=", "\"\"", ";", "public", "final", "static", "String", "EDGE_ANNOTATION_TABLE", "=", "\"\"", ";", "public", "final", "static", "String", "ANNOTATION_POOL_TABLE", "=", "\"\"", ";", "public", "final", "static", "String", "FACTS_TABLE", "=", "\"facts\"", ";", "public", "final", "static", "String", "CORPUS_TABLE", "=", "\"corpus\"", ";", "public", "final", "static", "String", "CORPUS_ANNOTATION_TABLE", "=", "\"\"", ";", "public", "final", "static", "String", "TEXT_TABLE", "=", "\"text\"", ";", "private", "QueryNode", "node", ";", "private", "Map", "<", "String", ",", "String", ">", "tableAliases", ";", "private", "Map", "<", "String", ",", "Map", "<", "String", ",", "String", ">", ">", "columnAliases", ";", "public", "TableAccessStrategy", "(", ")", "{", "this", ".", "tableAliases", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "this", ".", "columnAliases", "=", "new", "HashMap", "<", "String", ",", "Map", "<", "String", ",", "String", ">", ">", "(", ")", ";", "}", "public", "TableAccessStrategy", "(", "QueryNode", "node", ")", "{", "this", "(", ")", ";", "this", ".", "node", "=", "node", ";", "}", "public", "TableAccessStrategy", "(", "TableAccessStrategy", "tas", ")", "{", "this", ".", "tableAliases", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", "tas", ".", "getTableAliases", "(", ")", ")", ";", "this", ".", "columnAliases", "=", "new", "HashMap", "<", "String", ",", "Map", "<", "String", ",", "String", ">", ">", "(", "tas", ".", "getColumnAliases", "(", ")", ")", ";", "this", ".", "node", "=", "tas", ".", "getNode", "(", ")", ";", "}", "public", "String", "tableName", "(", "String", "table", ")", "{", "return", "tableAliases", ".", "containsKey", "(", "table", ")", "?", "tableAliases", ".", "get", "(", "table", ")", ":", "table", ";", "}", "public", "String", "columnName", "(", "String", "table", ",", "String", "column", ")", "{", "if", "(", "columnAliases", ".", "containsKey", "(", "table", ")", ")", "{", "Map", "<", "String", ",", "String", ">", "columns", "=", "columnAliases", ".", "get", "(", "table", ")", ";", "if", "(", "columns", ".", "containsKey", "(", "column", ")", ")", "{", "return", "columns", ".", "get", "(", "column", ")", ";", "}", "}", "return", "column", ";", "}", "public", "String", "aliasedTable", "(", "String", "table", ",", "int", "count", ")", "{", "if", "(", "node", "!=", "null", ")", "{", "if", "(", "table", ".", "equals", "(", "NODE_ANNOTATION_TABLE", ")", "&&", "count", ">", "node", ".", "getNodeAnnotations", "(", ")", ".", "size", "(", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", "+", "count", ")", ";", "if", "(", "table", ".", "equals", "(", "EDGE_ANNOTATION_TABLE", ")", "&&", "count", ">", "node", ".", "getEdgeAnnotations", "(", ")", ".", "size", "(", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", "+", "count", ")", ";", "if", "(", "table", ".", "equals", "(", "NODE_TABLE", ")", "&&", "count", ">", "1", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", "+", "count", ")", ";", "if", "(", "table", ".", "equals", "(", "RANK_TABLE", ")", "&&", "count", ">", "1", ")", "throw", "new", "IllegalArgumentException", "(", "\"\"", "+", "count", ")", ";", "if", "(", "table", ".", "equals", "(", "EDGE_ANNOTATION_TABLE", ")", "&&", "isMaterialized", "(", "EDGE_ANNOTATION_TABLE", ",", "NODE_ANNOTATION_TABLE", ")", ")", "count", "=", "count", "+", "node", ".", "getNodeAnnotations", "(", ")", ".", "size", "(", ")", "-", "1", ";", "}", "if", "(", "count", "==", "0", ")", "{", "count", "=", "1", ";", "}", "Bag", "tables", "=", "computeSourceTables", "(", ")", ";", "String", "aliasedName", "=", "tableName", "(", "table", ")", ";", "String", "aliasCount", "=", "node", "!=", "null", "?", "String", ".", "valueOf", "(", "node", ".", "getId", "(", ")", ")", ":", "\"\"", ";", "String", "countSuffix", "=", "tables", ".", "getCount", "(", "aliasedName", ")", ">", "1", "?", "\"_\"", "+", "count", ":", "\"\"", ";", "return", "aliasedName", "+", "aliasCount", "+", "countSuffix", ";", "}", "public", "String", "aliasedColumn", "(", "String", "table", ",", "String", "column", ")", "{", "return", "aliasedColumn", "(", "table", ",", "column", ",", "1", ")", ";", "}", "public", "String", "aliasedColumn", "(", "String", "table", ",", "String", "column", ",", "int", "count", ")", "{", "return", "column", "(", "aliasedTable", "(", "table", ",", "count", ")", ",", "columnName", "(", "table", ",", "column", ")", ")", ";", "}", "protected", "String", "column", "(", "String", "table", ",", "String", "column", ")", "{", "return", "table", "+", "\".\"", "+", "column", ";", "}", "protected", "Bag", "computeSourceTables", "(", ")", "{", "Bag", "tables", "=", "new", "HashBag", "(", ")", ";", "if", "(", "node", "==", "null", ")", "{", "String", "[", "]", "tableNames", "=", "{", "NODE_TABLE", ",", "RANK_TABLE", ",", "COMPONENT_TABLE", ",", "NODE_ANNOTATION_TABLE", ",", "EDGE_ANNOTATION_TABLE", "}", ";", "for", "(", "String", "table", ":", "tableNames", ")", "tables", ".", "add", "(", "table", ")", ";", "return", "tables", ";", "}", "tables", ".", "add", "(", "tableName", "(", "NODE_ANNOTATION_TABLE", ")", ",", "node", ".", "getNodeAnnotations", "(", ")", ".", "size", "(", ")", ")", ";", "if", "(", "node", ".", "getNodeAnnotations", "(", ")", ".", "isEmpty", "(", ")", "&&", "node", ".", "getNodeAnnotations", "(", ")", ".", "size", "(", ")", ">", "0", ")", "tables", ".", "add", "(", "tableName", "(", "NODE_ANNOTATION_TABLE", ")", ")", ";", "tables", ".", "add", "(", "tableName", "(", "EDGE_ANNOTATION_TABLE", ")", ",", "node", ".", "getEdgeAnnotations", "(", ")", ".", "size", "(", ")", ")", ";", "if", "(", "tables", ".", "getCount", "(", "tableName", "(", "RANK_TABLE", ")", ")", "==", "0", "&&", "usesRankTable", "(", ")", ")", "tables", ".", "add", "(", "tableName", "(", "RANK_TABLE", ")", ")", ";", "if", "(", "tables", ".", "getCount", "(", "tableName", "(", "COMPONENT_TABLE", ")", ")", "==", "0", "&&", "usesRankTable", "(", ")", ")", "tables", ".", "add", "(", "tableName", "(", "COMPONENT_TABLE", ")", ")", ";", "if", "(", "tables", ".", "getCount", "(", "tableName", "(", "NODE_TABLE", ")", ")", "==", "0", ")", "tables", ".", "add", "(", "tableName", "(", "NODE_TABLE", ")", ")", ";", "return", "tables", ";", "}", "public", "boolean", "usesNodeAnnotationTable", "(", ")", "{", "return", "node", "==", "null", "||", "!", "node", ".", "getNodeAnnotations", "(", ")", ".", "isEmpty", "(", ")", ";", "}", "public", "boolean", "usesRankTable", "(", ")", "{", "return", "node", "==", "null", "||", "usesComponentTable", "(", ")", "||", "node", ".", "isRoot", "(", ")", "||", "node", ".", "getArity", "(", ")", "!=", "null", ";", "}", "public", "boolean", "usesComponentTable", "(", ")", "{", "return", "node", "==", "null", "||", "node", ".", "isPartOfEdge", "(", ")", "||", "usesEdgeAnnotationTable", "(", ")", ";", "}", "public", "boolean", "usesEdgeAnnotationTable", "(", ")", "{", "return", "node", "==", "null", "||", "!", "node", ".", "getEdgeAnnotations", "(", ")", ".", "isEmpty", "(", ")", ";", "}", "public", "boolean", "isMaterialized", "(", "String", "table", ",", "String", "otherTable", ")", "{", "return", "tableName", "(", "table", ")", ".", "equals", "(", "tableName", "(", "otherTable", ")", ")", ";", "}", "public", "void", "addTableAlias", "(", "String", "table", ",", "String", "alias", ")", "{", "tableAliases", ".", "put", "(", "table", ",", "alias", ")", ";", "}", "public", "void", "addColumnAlias", "(", "String", "table", ",", "String", "column", ",", "String", "alias", ")", "{", "if", "(", "!", "columnAliases", ".", "containsKey", "(", "table", ")", ")", "columnAliases", ".", "put", "(", "table", ",", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ")", ";", "Map", "<", "String", ",", "String", ">", "aliases", "=", "columnAliases", ".", "get", "(", "table", ")", ";", "aliases", ".", "put", "(", "column", ",", "alias", ")", ";", "}", "public", "QueryNode", "getNode", "(", ")", "{", "return", "node", ";", "}", "public", "void", "setNode", "(", "QueryNode", "node", ")", "{", "this", ".", "node", "=", "node", ";", "}", "public", "Map", "<", "String", ",", "String", ">", "getTableAliases", "(", ")", "{", "return", "tableAliases", ";", "}", "public", "void", "setTableAliases", "(", "Map", "<", "String", ",", "String", ">", "tableAliases", ")", "{", "this", ".", "tableAliases", "=", "tableAliases", ";", "}", "public", "Map", "<", "String", ",", "Map", "<", "String", ",", "String", ">", ">", "getColumnAliases", "(", ")", "{", "return", "columnAliases", ";", "}", "public", "void", "setColumnAliases", "(", "Map", "<", "String", ",", "Map", "<", "String", ",", "String", ">", ">", "columnAliases", ")", "{", "this", ".", "columnAliases", "=", "columnAliases", ";", "}", "}", "</s>" ]
8,818
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "interface", "WhereClauseSqlGenerator", "<", "T", ">", "{", "Set", "<", "String", ">", "whereConditions", "(", "T", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", ";", "}", "</s>" ]
8,819
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "interface", "OrderByClauseSqlGenerator", "<", "T", ">", "{", "String", "orderByClause", "(", "T", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", ";", "}", "</s>" ]
8,820
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "import", "annis", ".", "model", ".", "AnnisNode", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisAttribute", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "public", "class", "ListAnnotationsSqlHelper", "implements", "ResultSetExtractor", "{", "public", "String", "createSqlQuery", "(", "List", "<", "Long", ">", "corpusList", ",", "boolean", "listValues", ",", "boolean", "onlyMostFrequentValue", ")", "{", "String", "sql", "=", "\"\"", "+", "\"(n\"", "+", "\"\"", "+", "\"", "FROMn\"", "+", "\"", "(n\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"", "WHEREn\"", "+", "\"\"", "+", "(", "corpusList", ".", "isEmpty", "(", ")", "?", "\"n\"", ":", "\"\"", ")", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", "if", "(", "(", "listValues", "&&", "onlyMostFrequentValue", ")", "||", "!", "listValues", ")", "{", "sql", "+=", "\"\"", ";", "}", "sql", "=", "sql", ".", "replaceAll", "(", "\":corpora\"", ",", "StringUtils", ".", "join", "(", "corpusList", ",", "\",", "\"", ")", ")", ";", "sql", "=", "sql", ".", "replaceAll", "(", "\":value\"", ",", "listValues", "?", "\"value\"", ":", "\"\"", ")", ";", "return", "sql", ";", "}", "@", "Override", "public", "Object", "extractData", "(", "ResultSet", "resultSet", ")", "throws", "SQLException", ",", "DataAccessException", "{", "Map", "<", "String", ",", "AnnisAttribute", ">", "attributesByName", "=", "new", "HashMap", "<", "String", ",", "AnnisAttribute", ">", "(", ")", ";", "while", "(", "resultSet", ".", "next", "(", ")", ")", "{", "String", "namespace", "=", "resultSet", ".", "getString", "(", "\"namespace\"", ")", ";", "String", "name", "=", "resultSet", ".", "getString", "(", "\"name\"", ")", ";", "String", "qName", "=", "AnnisNode", ".", "qName", "(", "namespace", ",", "name", ")", ";", "String", "edgeNamespace", "=", "resultSet", ".", "getString", "(", "\"\"", ")", ";", "String", "edgeName", "=", "resultSet", ".", "getString", "(", "\"edge_name\"", ")", ";", "String", "qEdgeName", "=", "AnnisNode", ".", "qName", "(", "edgeNamespace", ",", "edgeName", ")", ";", "String", "key", "=", "qName", ";", "if", "(", "qEdgeName", "!=", "null", ")", "{", "key", "+=", "\"_\"", "+", "qEdgeName", ";", "}", "if", "(", "!", "attributesByName", ".", "containsKey", "(", "key", ")", ")", "{", "attributesByName", ".", "put", "(", "key", ",", "new", "AnnisAttribute", "(", ")", ")", ";", "}", "AnnisAttribute", "attribute", "=", "attributesByName", ".", "get", "(", "key", ")", ";", "attribute", ".", "setName", "(", "qName", ")", ";", "attribute", ".", "setEdgeName", "(", "qEdgeName", ")", ";", "AnnisAttribute", ".", "Type", "t", "=", "AnnisAttribute", ".", "Type", ".", "unknown", ";", "try", "{", "t", "=", "AnnisAttribute", ".", "Type", ".", "valueOf", "(", "resultSet", ".", "getString", "(", "\"type\"", ")", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "}", "attribute", ".", "setType", "(", "t", ")", ";", "AnnisAttribute", ".", "SubType", "st", "=", "AnnisAttribute", ".", "SubType", ".", "unknown", ";", "try", "{", "st", "=", "AnnisAttribute", ".", "SubType", ".", "valueOf", "(", "resultSet", ".", "getString", "(", "\"subtype\"", ")", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "}", "attribute", ".", "setSubtype", "(", "st", ")", ";", "String", "value", "=", "resultSet", ".", "getString", "(", "\"value\"", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "attribute", ".", "addValue", "(", "value", ")", ";", "}", "}", "return", "new", "ArrayList", "<", "AnnisAttribute", ">", "(", "attributesByName", ".", "values", "(", ")", ")", ";", "}", "}", "</s>" ]
8,821
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "ParameterizedRowMapper", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "sqlString", ";", "public", "class", "ListCorpusAnnotationsSqlHelper", "implements", "ParameterizedRowMapper", "<", "Annotation", ">", "{", "public", "String", "createSqlQuery", "(", "String", "toplevelCorpusName", ",", "String", "corpusName", ")", "{", "String", "template", "=", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", "String", "sql", "=", "template", ".", "replaceAll", "(", "\":docname\"", ",", "sqlString", "(", "corpusName", ")", ")", ".", "replaceAll", "(", "\"\"", ",", "sqlString", "(", "toplevelCorpusName", ")", ")", ";", "return", "sql", ";", "}", "@", "Override", "public", "Annotation", "mapRow", "(", "ResultSet", "rs", ",", "int", "rowNum", ")", "throws", "SQLException", "{", "String", "namespace", "=", "rs", ".", "getString", "(", "\"namespace\"", ")", ";", "String", "name", "=", "rs", ".", "getString", "(", "\"name\"", ")", ";", "String", "value", "=", "rs", ".", "getString", "(", "\"value\"", ")", ";", "String", "type", "=", "rs", ".", "getString", "(", "\"type\"", ")", ";", "String", "corpusName", "=", "rs", ".", "getString", "(", "\"parent_name\"", ")", ";", "int", "pre", "=", "rs", ".", "getInt", "(", "\"parent_pre\"", ")", ";", "return", "new", "Annotation", "(", "namespace", ",", "name", ",", "value", ",", "type", ",", "corpusName", ",", "pre", ")", ";", "}", "}", "</s>" ]
8,822
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "java", ".", "util", ".", "Arrays", ".", "asList", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "List", ";", "public", "class", "CsvCorpusPathExtractor", "implements", "CorpusPathExtractor", "{", "@", "Override", "public", "List", "<", "String", ">", "extractCorpusPath", "(", "ResultSet", "resultSet", ",", "String", "columnName", ")", "throws", "SQLException", "{", "String", "csv", "=", "resultSet", ".", "getString", "(", "columnName", ")", ";", "String", "[", "]", "pathArray", "=", "csv", ".", "split", "(", "\",\"", ")", ";", "List", "<", "String", ">", "path", "=", "asList", "(", "pathArray", ")", ";", "Collections", ".", "reverse", "(", "path", ")", ";", "return", "path", ";", "}", "}", "</s>" ]
8,823
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "public", "interface", "AnnotateExtractor", "<", "T", ">", "extends", "ResultSetExtractor", "<", "T", ">", "{", "public", "void", "setOuterQueryTableAccessStrategy", "(", "TableAccessStrategy", "outerQueryTableAccessStrategy", ")", ";", "}", "</s>" ]
8,824
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "join", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Inclusion", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Join", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftAlignment", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftOverlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Overlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Precedence", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightAlignment", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightOverlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "SameSpan", ";", "public", "class", "SubcorpusConstraintWhereClause", "extends", "TableAccessStrategyFactory", "implements", "WhereClauseSqlGenerator", "<", "QueryData", ">", "{", "public", "Set", "<", "String", ">", "whereConditions", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "Set", "<", "String", ">", "conditions", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "List", "<", "Long", ">", "documents", "=", "queryData", ".", "getDocuments", "(", ")", ";", "conditions", ".", "addAll", "(", "commonWhereConditions", "(", "alternative", ",", "corpusList", ",", "documents", ")", ")", ";", "return", "conditions", ";", "}", "@", "Deprecated", "public", "List", "<", "String", ">", "commonWhereConditions", "(", "List", "<", "QueryNode", ">", "nodes", ",", "List", "<", "Long", ">", "corpusList", ",", "List", "<", "Long", ">", "documents", ")", "{", "LinkedList", "<", "String", ">", "conditions", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "conditions", ".", "add", "(", "\"\"", ")", ";", "QueryNode", "[", "]", "copyNodes", "=", "nodes", ".", "toArray", "(", "new", "QueryNode", "[", "0", "]", ")", ";", "HashSet", "<", "IdPair", ">", "hasAlreadyTextref", "=", "calculateTextRefRelations", "(", "copyNodes", ")", ";", "for", "(", "int", "left", "=", "0", ";", "left", "<", "copyNodes", ".", "length", ";", "left", "++", ")", "{", "for", "(", "int", "right", "=", "left", "+", "1", ";", "right", "<", "copyNodes", ".", "length", ";", "right", "++", ")", "{", "if", "(", "!", "hasAlreadyTextref", ".", "contains", "(", "new", "IdPair", "(", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ",", "copyNodes", "[", "right", "]", ".", "getId", "(", ")", ")", ")", ")", "{", "conditions", ".", "add", "(", "join", "(", "\"=\"", ",", "tables", "(", "copyNodes", "[", "left", "]", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ",", "tables", "(", "copyNodes", "[", "right", "]", ")", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ")", ")", ";", "}", "}", "}", "return", "conditions", ";", "}", "private", "HashSet", "<", "IdPair", ">", "calculateTextRefRelations", "(", "QueryNode", "[", "]", "copyNodes", ")", "{", "HashSet", "<", "IdPair", ">", "hasAlreadyTextref", "=", "new", "HashSet", "<", "IdPair", ">", "(", ")", ";", "for", "(", "int", "left", "=", "0", ";", "left", "<", "copyNodes", ".", "length", ";", "left", "++", ")", "{", "for", "(", "int", "right", "=", "0", ";", "right", "<", "copyNodes", ".", "length", ";", "right", "++", ")", "{", "for", "(", "Join", "j", ":", "copyNodes", "[", "left", "]", ".", "getJoins", "(", ")", ")", "{", "if", "(", "j", "instanceof", "SameSpan", ")", "{", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ",", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ")", ")", ";", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ",", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "if", "(", "j", "instanceof", "LeftAlignment", ")", "{", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ",", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ")", ")", ";", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ",", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "if", "(", "j", "instanceof", "RightAlignment", ")", "{", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ",", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ")", ")", ";", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ",", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "if", "(", "j", "instanceof", "Inclusion", ")", "{", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ",", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ")", ")", ";", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ",", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "if", "(", "j", "instanceof", "Overlap", ")", "{", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ",", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ")", ")", ";", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ",", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "if", "(", "j", "instanceof", "LeftOverlap", ")", "{", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ",", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ")", ")", ";", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ",", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "if", "(", "j", "instanceof", "RightOverlap", ")", "{", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ",", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ")", ")", ";", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ",", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ")", ")", ";", "}", "else", "if", "(", "j", "instanceof", "Precedence", ")", "{", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ",", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ")", ")", ";", "hasAlreadyTextref", ".", "add", "(", "new", "IdPair", "(", "j", ".", "getTarget", "(", ")", ".", "getId", "(", ")", ",", "copyNodes", "[", "left", "]", ".", "getId", "(", ")", ")", ")", ";", "}", "}", "}", "}", "return", "hasAlreadyTextref", ";", "}", "public", "static", "class", "IdPair", "{", "public", "long", "id1", ";", "public", "long", "id2", ";", "public", "IdPair", "(", "long", "id1", ",", "long", "id2", ")", "{", "this", ".", "id1", "=", "id1", ";", "this", ".", "id2", "=", "id2", ";", "}", "@", "Override", "public", "boolean", "equals", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "getClass", "(", ")", "!=", "obj", ".", "getClass", "(", ")", ")", "{", "return", "false", ";", "}", "final", "IdPair", "other", "=", "(", "IdPair", ")", "obj", ";", "if", "(", "this", ".", "id1", "!=", "other", ".", "id1", ")", "{", "return", "false", ";", "}", "if", "(", "this", ".", "id2", "!=", "other", ".", "id2", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "@", "Override", "public", "int", "hashCode", "(", ")", "{", "int", "hash", "=", "5", ";", "hash", "=", "97", "*", "hash", "+", "(", "int", ")", "(", "this", ".", "id1", "^", "(", "this", ".", "id1", ">>>", "32", ")", ")", ";", "hash", "=", "97", "*", "hash", "+", "(", "int", ")", "(", "this", ".", "id2", "^", "(", "this", ".", "id2", ">>>", "32", ")", ")", ";", "return", "hash", ";", "}", "}", "}", "</s>" ]
8,825
[ "<s>", "package", "annis", ".", "sqlgen", ".", "annopool", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "COMPONENT_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "RANK_TABLE", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "sqlgen", ".", "AnnotateSqlGenerator", ";", "import", "annis", ".", "sqlgen", ".", "LimitOffsetQueryData", ";", "import", "annis", ".", "sqlgen", ".", "SolutionKey", ";", "import", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "sqlString", ";", "public", "class", "ApAnnotateSqlGenerator", "<", "T", ">", "extends", "AnnotateSqlGenerator", "<", "T", ">", "{", "@", "Override", "public", "String", "fromClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "TableAccessStrategy", "tas", "=", "createTableAccessStrategy", "(", ")", ";", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"solutions,n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "getTableJoinsInFromClauseSqlGenerator", "(", ")", ".", "fromClauseForNode", "(", "null", ",", "true", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "StringUtils", ".", "join", "(", "corpusList", ",", "\",", "\"", ")", ")", ".", "append", "(", "\"))\"", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", ")", ".", "append", "(", "\"\"", "+", "\"\"", ")", ".", "append", "(", "StringUtils", ".", "join", "(", "corpusList", ",", "\",", "\"", ")", ")", ".", "append", "(", "\"))\"", ")", ";", "sb", ".", "append", "(", "\",n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "TableAccessStrategy", ".", "CORPUS_TABLE", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "String", "selectClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "String", "innerIndent", "=", "indent", "+", "TABSTOP", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"DISTINCTn\"", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ";", "int", "matchStart", "=", "0", ";", "List", "<", "LimitOffsetQueryData", ">", "extension", "=", "queryData", ".", "getExtensions", "(", "LimitOffsetQueryData", ".", "class", ")", ";", "if", "(", "extension", ".", "size", "(", ")", ">", "0", ")", "{", "matchStart", "=", "extension", ".", "get", "(", "0", ")", ".", "getOffset", "(", ")", ";", "}", "sb", ".", "append", "(", "matchStart", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "\"\"", ")", ";", "List", "<", "String", ">", "fields", "=", "getSelectFields", "(", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "StringUtils", ".", "join", "(", "fields", ",", "\",n\"", "+", "innerIndent", ")", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "\",n\"", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "\"\"", ")", ";", "if", "(", "isIncludeDocumentNameInAnnotateQuery", "(", ")", ")", "{", "sb", ".", "append", "(", "\",n\"", ")", ";", "sb", ".", "append", "(", "innerIndent", ")", ".", "append", "(", "\"\"", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "protected", "List", "<", "String", ">", "getSelectFields", "(", ")", "{", "List", "<", "String", ">", "fields", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"id\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"text_ref\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"namespace\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"name\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"left\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"right\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"token_index\"", ")", ";", "if", "(", "isIncludeIsTokenColumn", "(", ")", ")", "{", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"is_token\"", ")", ";", "}", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"continuous\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"span\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"left_token\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"right_token\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"seg_name\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"seg_left\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "NODE_TABLE", ",", "\"seg_right\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "RANK_TABLE", ",", "\"pre\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "RANK_TABLE", ",", "\"post\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "RANK_TABLE", ",", "\"parent\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "RANK_TABLE", ",", "\"root\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "RANK_TABLE", ",", "\"level\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "COMPONENT_TABLE", ",", "\"id\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "COMPONENT_TABLE", ",", "\"type\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "COMPONENT_TABLE", ",", "\"name\"", ")", ";", "addSelectClauseAttribute", "(", "fields", ",", "COMPONENT_TABLE", ",", "\"namespace\"", ")", ";", "fields", ".", "add", "(", "\"\"", ")", ";", "fields", ".", "add", "(", "\"\"", ")", ";", "fields", ".", "add", "(", "\"\"", ")", ";", "fields", ".", "add", "(", "\"\"", ")", ";", "fields", ".", "add", "(", "\"\"", ")", ";", "fields", ".", "add", "(", "\"\"", ")", ";", "return", "fields", ";", "}", "@", "Override", "public", "String", "getTextQuery", "(", "long", "textID", ")", "{", "TableAccessStrategy", "tas", "=", "createTableAccessStrategy", "(", ")", ";", "List", "<", "String", ">", "fields", "=", "getSelectFields", "(", ")", ";", "String", "template", "=", "\"\"", "+", "\"\"", "+", "StringUtils", ".", "join", "(", "fields", ",", "\",", "\"", ")", "+", "\",", "\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"FROMn\"", "+", "\"t\"", "+", "getTableJoinsInFromClauseSqlGenerator", "(", ")", ".", "fromClauseForNode", "(", "null", ",", "true", ")", "+", "\"n\"", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", "+", "\"\"", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", "+", "\"\"", "+", "\"\"", "+", "\"WHEREn\"", "+", "\"t\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", "+", "\"", "=", "c.idn\"", "+", "\"ORDER", "BY", "\"", "+", "tas", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ";", "String", "sql", "=", "template", ".", "replace", "(", "\":text_id\"", ",", "String", ".", "valueOf", "(", "textID", ")", ")", ";", "return", "sql", ";", "}", "@", "Override", "public", "String", "getDocumentQuery", "(", "String", "toplevelCorpusName", ",", "String", "documentName", ")", "{", "TableAccessStrategy", "tas", "=", "createTableAccessStrategy", "(", ")", ";", "List", "<", "String", ">", "fields", "=", "getSelectFields", "(", ")", ";", "String", "template", "=", "\"\"", "+", "\"\"", "+", "StringUtils", ".", "join", "(", "fields", ",", "\",", "\"", ")", "+", "\",", "\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"FROMn\"", "+", "\"t\"", "+", "getTableJoinsInFromClauseSqlGenerator", "(", ")", ".", "fromClauseForNode", "(", "null", ",", "true", ")", "+", "\"n\"", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", "+", "\"\"", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", "+", "\"\"", "+", "\"\"", "+", "\"WHEREn\"", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", "+", "\"", "=", "c.idn\"", "+", "\"\"", "+", "\"\"", "+", "\"ORDER", "BY", "\"", "+", "tas", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ";", "String", "sql", "=", "template", ".", "replace", "(", "\"\"", ",", "sqlString", "(", "toplevelCorpusName", ")", ")", ".", "replace", "(", "\"\"", ",", "sqlString", "(", "documentName", ")", ")", ";", "return", "sql", ";", "}", "}", "</s>" ]
8,826
[ "<s>", "package", "annis", ".", "sqlgen", ".", "annopool", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "model", ".", "QueryNode", ".", "TextMatching", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "sqlgen", ".", "AnnotationConditionProvider", ";", "import", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "public", "class", "ApAnnotationConditionProvider", "implements", "AnnotationConditionProvider", "{", "@", "Override", "public", "void", "addAnnotationConditions", "(", "List", "<", "String", ">", "conditions", ",", "QueryNode", "node", ",", "int", "index", ",", "QueryAnnotation", "annotation", ",", "String", "table", ",", "QueryData", "queryData", ",", "TableAccessStrategy", "tas", ")", "{", "TextMatching", "tm", "=", "annotation", ".", "getTextMatching", "(", ")", ";", "StringBuilder", "sbFunc", "=", "new", "StringBuilder", "(", "\"getAnno\"", ")", ";", "if", "(", "tm", "==", "TextMatching", ".", "EXACT_NOT_EQUAL", "||", "tm", "==", "TextMatching", ".", "REGEXP_NOT_EQUAL", ")", "{", "sbFunc", ".", "append", "(", "\"Not\"", ")", ";", "}", "List", "<", "String", ">", "params", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "if", "(", "annotation", ".", "getNamespace", "(", ")", "!=", "null", ")", "{", "params", ".", "add", "(", "\"'\"", "+", "annotation", ".", "getNamespace", "(", ")", "+", "\"'\"", ")", ";", "}", "else", "{", "params", ".", "add", "(", "\"NULL\"", ")", ";", "}", "if", "(", "annotation", ".", "getName", "(", ")", "!=", "null", ")", "{", "params", ".", "add", "(", "\"'\"", "+", "annotation", ".", "getName", "(", ")", "+", "\"'\"", ")", ";", "}", "else", "{", "params", ".", "add", "(", "\"NULL\"", ")", ";", "}", "if", "(", "annotation", ".", "getValue", "(", ")", "!=", "null", ")", "{", "if", "(", "tm", "==", "TextMatching", ".", "REGEXP_EQUAL", "||", "tm", "==", "TextMatching", ".", "REGEXP_NOT_EQUAL", ")", "{", "params", ".", "add", "(", "\"NULL\"", ")", ";", "params", ".", "add", "(", "\"'^(\"", "+", "annotation", ".", "getValue", "(", ")", "+", "\")$'\"", ")", ";", "}", "else", "{", "params", ".", "add", "(", "\"'\"", "+", "annotation", ".", "getValue", "(", ")", "+", "\"'\"", ")", ";", "params", ".", "add", "(", "\"NULL\"", ")", ";", "}", "}", "else", "{", "params", ".", "add", "(", "\"NULL\"", ")", ";", "params", ".", "add", "(", "\"NULL\"", ")", ";", "}", "params", ".", "add", "(", "\"ARRAY[\"", "+", "StringUtils", ".", "join", "(", "queryData", ".", "getCorpusList", "(", ")", ",", "\",", "\"", ")", "+", "\"]\"", ")", ";", "params", ".", "add", "(", "\"'\"", "+", "StringUtils", ".", "removeEnd", "(", "table", ",", "\"_annotation\"", ")", ".", "toLowerCase", "(", ")", "+", "\"'\"", ")", ";", "sbFunc", ".", "append", "(", "\"(\"", ")", ";", "sbFunc", ".", "append", "(", "StringUtils", ".", "join", "(", "params", ",", "\",", "\"", ")", ")", ";", "sbFunc", ".", "append", "(", "\")\"", ")", ";", "String", "cond", "=", "tas", ".", "aliasedColumn", "(", "table", ",", "\"anno_ref\"", ",", "index", ")", "+", "\"=", "ANY(\"", "+", "sbFunc", ".", "toString", "(", ")", "+", "\")\"", ";", "conditions", ".", "add", "(", "cond", ")", ";", "}", "}", "</s>" ]
8,827
[ "<s>", "package", "annis", ".", "sqlgen", ".", "annopool", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "*", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "sqlgen", ".", "MatrixSqlGenerator", ";", "import", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "public", "class", "ApMatrixSqlGenerator", "extends", "MatrixSqlGenerator", "{", "@", "Override", "protected", "void", "addFromOuterJoins", "(", "StringBuilder", "sb", ",", "QueryData", "queryData", ",", "TableAccessStrategy", "tas", ",", "String", "indent", ")", "{", "super", ".", "addFromOuterJoins", "(", "sb", ",", "queryData", ",", "tas", ",", "indent", ")", ";", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "StringUtils", ".", "join", "(", "corpusList", ",", "\",", "\"", ")", ")", ".", "append", "(", "\"))\"", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", ")", ".", "append", "(", "\"\"", ")", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", ")", ".", "append", "(", "\"\"", "+", "\"\"", ")", ".", "append", "(", "StringUtils", ".", "join", "(", "corpusList", ",", "\",", "\"", ")", ")", ".", "append", "(", "\"))\"", ")", ";", "}", "@", "Override", "protected", "String", "selectAnnotationsString", "(", "TableAccessStrategy", "tas", ")", "{", "return", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", ";", "}", "}", "</s>" ]
8,828
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Comparator", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "org", ".", "springframework", ".", "util", ".", "Assert", ";", "public", "abstract", "class", "AbstractSqlGenerator", "<", "T", ">", "extends", "TableAccessStrategyFactory", "implements", "SqlGenerator", "<", "QueryData", ",", "T", ">", "{", "private", "WithClauseSqlGenerator", "<", "QueryData", ">", "withClauseSqlGenerator", ";", "private", "SelectClauseSqlGenerator", "<", "QueryData", ">", "selectClauseSqlGenerator", ";", "private", "List", "<", "FromClauseSqlGenerator", "<", "QueryData", ">", ">", "fromClauseSqlGenerators", ";", "private", "List", "<", "WhereClauseSqlGenerator", "<", "QueryData", ">", ">", "whereClauseSqlGenerators", ";", "private", "GroupByClauseSqlGenerator", "<", "QueryData", ">", "groupByClauseSqlGenerator", ";", "private", "OrderByClauseSqlGenerator", "<", "QueryData", ">", "orderByClauseSqlGenerator", ";", "private", "LimitOffsetClauseSqlGenerator", "<", "QueryData", ">", "limitOffsetClauseSqlGenerator", ";", "public", "final", "static", "String", "TABSTOP", "=", "\"", "\"", ";", "@", "Override", "public", "String", "toSql", "(", "QueryData", "queryData", ")", "{", "return", "toSql", "(", "queryData", ",", "\"\"", ")", ";", "}", "@", "Override", "public", "String", "toSql", "(", "QueryData", "queryData", ",", "String", "indent", ")", "{", "Assert", ".", "notEmpty", "(", "queryData", ".", "getAlternatives", "(", ")", ",", "\"\"", ")", ";", "List", "<", "QueryNode", ">", "alternative", "=", "queryData", ".", "getAlternatives", "(", ")", ".", "get", "(", "0", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ";", "sb", ".", "append", "(", "createSqlForAlternative", "(", "queryData", ",", "alternative", ",", "indent", ")", ")", ";", "appendOrderByClause", "(", "sb", ",", "queryData", ",", "alternative", ",", "indent", ")", ";", "appendLimitOffsetClause", "(", "sb", ",", "queryData", ",", "alternative", ",", "indent", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "protected", "String", "createSqlForAlternative", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "appendWithClause", "(", "sb", ",", "queryData", ",", "alternative", ",", "indent", ")", ";", "appendSelectClause", "(", "sb", ",", "queryData", ",", "alternative", ",", "indent", ")", ";", "appendFromClause", "(", "sb", ",", "queryData", ",", "alternative", ",", "indent", ")", ";", "appendWhereClause", "(", "sb", ",", "queryData", ",", "alternative", ",", "indent", ")", ";", "appendGroupByClause", "(", "sb", ",", "queryData", ",", "alternative", ",", "indent", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "protected", "String", "computeIndent", "(", "int", "indentBy", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "indentBy", ";", "++", "i", ")", "{", "sb", ".", "append", "(", "TABSTOP", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "private", "void", "appendWithClause", "(", "StringBuffer", "sb", ",", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "if", "(", "withClauseSqlGenerator", "!=", "null", ")", "{", "List", "<", "String", ">", "clauses", "=", "withClauseSqlGenerator", ".", "withClauses", "(", "queryData", ",", "alternative", ",", "indent", "+", "TABSTOP", ")", ";", "if", "(", "!", "clauses", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"WITHn\"", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "clauses", ",", "\",n\"", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "}", "}", "private", "void", "appendSelectClause", "(", "StringBuffer", "sb", ",", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "sb", ".", "append", "(", "\"SELECT", "\"", ")", ";", "sb", ".", "append", "(", "selectClauseSqlGenerator", ".", "selectClause", "(", "queryData", ",", "alternative", ",", "indent", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "private", "void", "appendFromClause", "(", "StringBuffer", "sb", ",", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "sb", ".", "append", "(", "indent", ")", ";", "sb", ".", "append", "(", "\"FROM\"", ")", ";", "List", "<", "String", ">", "fromTables", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "FromClauseSqlGenerator", "<", "QueryData", ">", "generator", ":", "fromClauseSqlGenerators", ")", "{", "fromTables", ".", "add", "(", "generator", ".", "fromClause", "(", "queryData", ",", "alternative", ",", "indent", ")", ")", ";", "}", "sb", ".", "append", "(", "\"n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "fromTables", ",", "\",n\"", "+", "indent", "+", "TABSTOP", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "private", "void", "appendWhereClause", "(", "StringBuffer", "sb", ",", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "if", "(", "whereClauseSqlGenerators", "==", "null", "||", "whereClauseSqlGenerators", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "List", "<", "StringBuffer", ">", "conditions", "=", "new", "ArrayList", "<", "StringBuffer", ">", "(", ")", ";", "for", "(", "WhereClauseSqlGenerator", "<", "QueryData", ">", "generator", ":", "whereClauseSqlGenerators", ")", "{", "Set", "<", "String", ">", "whereConditions", "=", "generator", ".", "whereConditions", "(", "queryData", ",", "alternative", ",", "indent", ")", ";", "for", "(", "String", "constraint", ":", "whereConditions", ")", "{", "conditions", ".", "add", "(", "new", "StringBuffer", "(", "constraint", ")", ")", ";", "}", "}", "Collections", ".", "sort", "(", "conditions", ",", "new", "Comparator", "<", "StringBuffer", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "StringBuffer", "o1", ",", "StringBuffer", "o2", ")", "{", "if", "(", "o1", "==", "null", "&&", "o2", "==", "null", ")", "{", "return", "0", ";", "}", "else", "if", "(", "o1", "==", "null", "&&", "o2", "!=", "null", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "o1", "!=", "null", "&&", "o2", "==", "null", ")", "{", "return", "1", ";", "}", "else", "if", "(", "o1", "!=", "null", "&&", "o2", "!=", "null", ")", "{", "return", "o1", ".", "toString", "(", ")", ".", "compareTo", "(", "o2", ".", "toString", "(", ")", ")", ";", "}", "throw", "new", "IllegalArgumentException", "(", "\"\"", "+", "o1", "+", "\"", "with", "\"", "+", "o2", ")", ";", "}", "}", ")", ";", "if", "(", "conditions", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "sb", ".", "append", "(", "indent", ")", ";", "sb", ".", "append", "(", "\"WHERE\"", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "conditions", ",", "\"", "ANDn\"", "+", "indent", "+", "TABSTOP", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "private", "void", "appendGroupByClause", "(", "StringBuffer", "sb", ",", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "if", "(", "groupByClauseSqlGenerator", "!=", "null", ")", "{", "sb", ".", "append", "(", "indent", ")", ";", "sb", ".", "append", "(", "\"GROUP", "BY", "\"", ")", ";", "sb", ".", "append", "(", "groupByClauseSqlGenerator", ".", "groupByAttributes", "(", "queryData", ",", "alternative", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "}", "protected", "void", "appendOrderByClause", "(", "StringBuffer", "sb", ",", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "if", "(", "orderByClauseSqlGenerator", "!=", "null", ")", "{", "sb", ".", "append", "(", "indent", ")", ";", "sb", ".", "append", "(", "\"ORDER", "BY", "\"", ")", ";", "sb", ".", "append", "(", "orderByClauseSqlGenerator", ".", "orderByClause", "(", "queryData", ",", "alternative", ",", "indent", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "}", "protected", "void", "appendLimitOffsetClause", "(", "StringBuffer", "sb", ",", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "if", "(", "limitOffsetClauseSqlGenerator", "!=", "null", ")", "{", "sb", ".", "append", "(", "indent", ")", ";", "sb", ".", "append", "(", "limitOffsetClauseSqlGenerator", ".", "limitOffsetClause", "(", "queryData", ",", "alternative", ",", "indent", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "}", "public", "List", "<", "FromClauseSqlGenerator", "<", "QueryData", ">", ">", "getFromClauseSqlGenerators", "(", ")", "{", "return", "fromClauseSqlGenerators", ";", "}", "public", "void", "setFromClauseSqlGenerators", "(", "List", "<", "FromClauseSqlGenerator", "<", "QueryData", ">", ">", "fromClauseSqlGenerators", ")", "{", "this", ".", "fromClauseSqlGenerators", "=", "fromClauseSqlGenerators", ";", "}", "public", "List", "<", "WhereClauseSqlGenerator", "<", "QueryData", ">", ">", "getWhereClauseSqlGenerators", "(", ")", "{", "return", "whereClauseSqlGenerators", ";", "}", "public", "void", "setWhereClauseSqlGenerators", "(", "List", "<", "WhereClauseSqlGenerator", "<", "QueryData", ">", ">", "whereClauseSqlGenerators", ")", "{", "this", ".", "whereClauseSqlGenerators", "=", "whereClauseSqlGenerators", ";", "}", "public", "GroupByClauseSqlGenerator", "<", "QueryData", ">", "getGroupByClauseSqlGenerator", "(", ")", "{", "return", "groupByClauseSqlGenerator", ";", "}", "public", "void", "setGroupByClauseSqlGenerator", "(", "GroupByClauseSqlGenerator", "<", "QueryData", ">", "groupByClauseSqlGenerator", ")", "{", "this", ".", "groupByClauseSqlGenerator", "=", "groupByClauseSqlGenerator", ";", "}", "public", "WithClauseSqlGenerator", "getWithClauseSqlGenerator", "(", ")", "{", "return", "withClauseSqlGenerator", ";", "}", "public", "void", "setWithClauseSqlGenerator", "(", "WithClauseSqlGenerator", "withClauseSqlGenerator", ")", "{", "this", ".", "withClauseSqlGenerator", "=", "withClauseSqlGenerator", ";", "}", "public", "SelectClauseSqlGenerator", "<", "QueryData", ">", "getSelectClauseSqlGenerator", "(", ")", "{", "return", "selectClauseSqlGenerator", ";", "}", "public", "void", "setSelectClauseSqlGenerator", "(", "SelectClauseSqlGenerator", "<", "QueryData", ">", "selectClauseSqlGenerator", ")", "{", "this", ".", "selectClauseSqlGenerator", "=", "selectClauseSqlGenerator", ";", "}", "public", "OrderByClauseSqlGenerator", "<", "QueryData", ">", "getOrderByClauseSqlGenerator", "(", ")", "{", "return", "orderByClauseSqlGenerator", ";", "}", "public", "void", "setOrderByClauseSqlGenerator", "(", "OrderByClauseSqlGenerator", "<", "QueryData", ">", "orderByClauseSqlGenerator", ")", "{", "this", ".", "orderByClauseSqlGenerator", "=", "orderByClauseSqlGenerator", ";", "}", "public", "LimitOffsetClauseSqlGenerator", "<", "QueryData", ">", "getLimitOffsetClauseSqlGenerator", "(", ")", "{", "return", "limitOffsetClauseSqlGenerator", ";", "}", "public", "void", "setLimitOffsetClauseSqlGenerator", "(", "LimitOffsetClauseSqlGenerator", "<", "QueryData", ">", "limitOffsetClauseSqlGenerator", ")", "{", "this", ".", "limitOffsetClauseSqlGenerator", "=", "limitOffsetClauseSqlGenerator", ";", "}", "}", "</s>" ]
8,829
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "CORPUS_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "TEXT_TABLE", ";", "import", "java", ".", "sql", ".", "Array", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "sql", ".", "Types", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "commons", ".", "codec", ".", "binary", ".", "Base64", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "annis", ".", "dao", ".", "AnnotatedMatch", ";", "import", "annis", ".", "dao", ".", "AnnotatedSpan", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "MatrixSqlGenerator", "extends", "AbstractSqlGenerator", "<", "List", "<", "AnnotatedMatch", ">", ">", "implements", "SelectClauseSqlGenerator", "<", "QueryData", ">", ",", "FromClauseSqlGenerator", "<", "QueryData", ">", ",", "WhereClauseSqlGenerator", "<", "QueryData", ">", ",", "GroupByClauseSqlGenerator", "<", "QueryData", ">", ",", "OrderByClauseSqlGenerator", "<", "QueryData", ">", "{", "private", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "MatrixSqlGenerator", ".", "class", ")", ";", "@", "Deprecated", "private", "String", "matchedNodesViewName", ";", "private", "SqlGenerator", "<", "QueryData", ",", "?", ">", "innerQuerySqlGenerator", ";", "private", "TableJoinsInFromClauseSqlGenerator", "tableJoinsInFromClauseGenerator", ";", "protected", "SolutionKey", "<", "?", ">", "createSolutionKey", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "List", "<", "AnnotatedMatch", ">", "extractData", "(", "ResultSet", "resultSet", ")", "throws", "SQLException", ",", "DataAccessException", "{", "List", "<", "AnnotatedMatch", ">", "matches", "=", "new", "ArrayList", "<", "AnnotatedMatch", ">", "(", ")", ";", "Map", "<", "List", "<", "Long", ">", ",", "AnnotatedSpan", "[", "]", ">", "matchesByGroup", "=", "new", "HashMap", "<", "List", "<", "Long", ">", ",", "AnnotatedSpan", "[", "]", ">", "(", ")", ";", "while", "(", "resultSet", ".", "next", "(", ")", ")", "{", "long", "id", "=", "resultSet", ".", "getLong", "(", "\"id\"", ")", ";", "String", "coveredText", "=", "resultSet", ".", "getString", "(", "\"span\"", ")", ";", "Array", "arrayAnnotation", "=", "resultSet", ".", "getArray", "(", "\"annotations\"", ")", ";", "Array", "arrayMeta", "=", "resultSet", ".", "getArray", "(", "\"metadata\"", ")", ";", "List", "<", "Annotation", ">", "annotations", "=", "extractAnnotations", "(", "arrayAnnotation", ")", ";", "List", "<", "Annotation", ">", "metaData", "=", "extractAnnotations", "(", "arrayMeta", ")", ";", "Array", "sqlKey", "=", "resultSet", ".", "getArray", "(", "\"key\"", ")", ";", "Validate", ".", "isTrue", "(", "!", "resultSet", ".", "wasNull", "(", ")", ",", "\"\"", ")", ";", "Validate", ".", "isTrue", "(", "sqlKey", ".", "getBaseType", "(", ")", "==", "Types", ".", "BIGINT", ",", "\"\"", "+", "sqlKey", ".", "getBaseTypeName", "(", ")", "+", "\"\\\"\"", ")", ";", "Long", "[", "]", "keyArray", "=", "(", "Long", "[", "]", ")", "sqlKey", ".", "getArray", "(", ")", ";", "int", "matchWidth", "=", "keyArray", ".", "length", ";", "List", "<", "Long", ">", "key", "=", "Arrays", ".", "asList", "(", "keyArray", ")", ";", "if", "(", "!", "matchesByGroup", ".", "containsKey", "(", "key", ")", ")", "{", "matchesByGroup", ".", "put", "(", "key", ",", "new", "AnnotatedSpan", "[", "matchWidth", "]", ")", ";", "}", "for", "(", "int", "posInMatch", "=", "0", ";", "posInMatch", "<", "key", ".", "size", "(", ")", ";", "posInMatch", "++", ")", "{", "if", "(", "key", ".", "get", "(", "posInMatch", ")", "==", "id", ")", "{", "matchesByGroup", ".", "get", "(", "key", ")", "[", "posInMatch", "]", "=", "new", "AnnotatedSpan", "(", "id", ",", "coveredText", ",", "annotations", ",", "metaData", ")", ";", "}", "}", "}", "for", "(", "AnnotatedSpan", "[", "]", "match", ":", "matchesByGroup", ".", "values", "(", ")", ")", "{", "matches", ".", "add", "(", "new", "AnnotatedMatch", "(", "Arrays", ".", "asList", "(", "match", ")", ")", ")", ";", "}", "return", "matches", ";", "}", "@", "Override", "public", "String", "selectClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "TableAccessStrategy", "tables", "=", "tables", "(", "null", ")", ";", "SolutionKey", "<", "?", ">", "key", "=", "createSolutionKey", "(", ")", ";", "List", "<", "String", ">", "keyColumns", "=", "key", ".", "generateOuterQueryColumns", "(", "tables", ",", "alternative", ".", "size", "(", ")", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "keyColumns", ",", "\",", "\"", ")", ")", ";", "sb", ".", "append", "(", "\",n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "getSelectFields", "(", "tables", ")", ",", "\",n\"", "+", "indent", "+", "TABSTOP", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "protected", "List", "<", "String", ">", "getSelectFields", "(", "TableAccessStrategy", "tas", ")", "{", "List", "<", "String", ">", "result", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "result", ".", "add", "(", "selectIdString", "(", "tas", ")", ")", ";", "result", ".", "add", "(", "selectSpanString", "(", "tas", ")", ")", ";", "result", ".", "add", "(", "selectAnnotationsString", "(", "tas", ")", ")", ";", "result", ".", "add", "(", "selectMetadataString", "(", "tas", ")", ")", ";", "return", "result", ";", "}", "protected", "String", "selectIdString", "(", "TableAccessStrategy", "tas", ")", "{", "return", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"id\"", ")", "+", "\"", "AS", "id\"", ";", "}", "protected", "String", "selectSpanString", "(", "TableAccessStrategy", "tas", ")", "{", "return", "\"min(substr(\"", "+", "tas", ".", "aliasedColumn", "(", "TEXT_TABLE", ",", "\"text\"", ")", "+", "\",", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"left\"", ")", "+", "\"", "+", "1,", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"right\"", ")", "+", "\"", "-", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"left\"", ")", "+", "\"))", "AS", "span\"", ";", "}", "protected", "String", "selectAnnotationsString", "(", "TableAccessStrategy", "tas", ")", "{", "return", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_ANNOTATION_TABLE", ",", "\"namespace\"", ")", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_ANNOTATION_TABLE", ",", "\"name\"", ")", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_ANNOTATION_TABLE", ",", "\"value\"", ")", "+", "\"\"", ";", "}", "protected", "String", "selectMetadataString", "(", "TableAccessStrategy", "tas", ")", "{", "return", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "CORPUS_ANNOTATION_TABLE", ",", "\"namespace\"", ")", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "CORPUS_ANNOTATION_TABLE", ",", "\"name\"", ")", "+", "\"\"", "+", "tas", ".", "aliasedColumn", "(", "CORPUS_ANNOTATION_TABLE", ",", "\"value\"", ")", "+", "\"\"", ";", "}", "@", "Override", "public", "String", "fromClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"(n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ";", "sb", ".", "append", "(", "innerQuerySqlGenerator", ".", "toSql", "(", "queryData", ",", "indent", "+", "TABSTOP", ")", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "tableJoinsInFromClauseGenerator", ".", "fromClauseForNode", "(", "null", ",", "true", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "TableAccessStrategy", "tables", "=", "tables", "(", "null", ")", ";", "addFromOuterJoins", "(", "sb", ",", "queryData", ",", "tables", ",", "indent", ")", ";", "sb", ".", "append", "(", "\",n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "TEXT_TABLE", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "protected", "void", "addFromOuterJoins", "(", "StringBuilder", "sb", ",", "QueryData", "queryData", ",", "TableAccessStrategy", "tas", ",", "String", "indent", ")", "{", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "CORPUS_ANNOTATION_TABLE", ")", ";", "sb", ".", "append", "(", "\"", "ON", "(\"", ")", ";", "sb", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "CORPUS_ANNOTATION_TABLE", ",", "\"corpus_ref\"", ")", ")", ";", "sb", ".", "append", "(", "\"", "=", "\"", ")", ";", "sb", ".", "append", "(", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ")", ";", "sb", ".", "append", "(", "\")\"", ")", ";", "}", "@", "Override", "public", "Set", "<", "String", ">", "whereConditions", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "Set", "<", "String", ">", "conditions", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "TableAccessStrategy", "tables", "=", "tables", "(", "null", ")", ";", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "if", "(", "corpusList", "!=", "null", "&&", "!", "corpusList", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", ")", ";", "sb", ".", "append", "(", "\"", "IN", "(\"", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "corpusList", ",", "\",", "\"", ")", ")", ";", "sb", ".", "append", "(", "\")\"", ")", ";", "conditions", ".", "add", "(", "sb", ".", "toString", "(", ")", ")", ";", "}", "sb", ".", "setLength", "(", "0", ")", ";", "sb", ".", "append", "(", "tables", ".", "aliasedColumn", "(", "TEXT_TABLE", ",", "\"id\"", ")", ")", ";", "sb", ".", "append", "(", "\"", "=", "\"", ")", ";", "sb", ".", "append", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", ")", ";", "conditions", ".", "add", "(", "sb", ".", "toString", "(", ")", ")", ";", "sb", ".", "setLength", "(", "0", ")", ";", "sb", ".", "append", "(", "\"(n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ".", "append", "(", "TABSTOP", ")", ";", "List", "<", "String", ">", "ors", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "queryData", ".", "getMaxWidth", "(", ")", ";", "++", "i", ")", "{", "ors", ".", "add", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"id\"", ")", "+", "\"\"", "+", "String", ".", "valueOf", "(", "i", ")", ")", ";", "}", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "ors", ",", "\"", "ORn\"", "+", "indent", "+", "TABSTOP", "+", "TABSTOP", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "\")\"", ")", ";", "conditions", ".", "add", "(", "sb", ".", "toString", "(", ")", ")", ";", "return", "conditions", ";", "}", "@", "Override", "public", "String", "groupByAttributes", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ")", "{", "TableAccessStrategy", "tas", "=", "tables", "(", "null", ")", ";", "return", "\"key,", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", "+", "\",", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", "+", "\",", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"token_index\"", ")", "+", "\",", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"id\"", ")", ";", "}", "@", "Override", "public", "String", "orderByClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "TableAccessStrategy", "tas", "=", "tables", "(", "null", ")", ";", "return", "\"key,", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", "+", "\",", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", "+", "\",", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"token_index\"", ")", "+", "\",", "\"", "+", "tas", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"id\"", ")", ";", "}", "private", "List", "<", "Annotation", ">", "extractAnnotations", "(", "Array", "array", ")", "throws", "SQLException", "{", "List", "<", "Annotation", ">", "result", "=", "new", "ArrayList", "<", "Annotation", ">", "(", ")", ";", "if", "(", "array", "!=", "null", ")", "{", "String", "[", "]", "arrayLines", "=", "(", "String", "[", "]", ")", "array", ".", "getArray", "(", ")", ";", "for", "(", "String", "line", ":", "arrayLines", ")", "{", "if", "(", "line", "!=", "null", ")", "{", "String", "namespace", "=", "null", ";", "String", "name", "=", "null", ";", "String", "value", "=", "null", ";", "String", "[", "]", "split", "=", "line", ".", "split", "(", "\":\"", ")", ";", "if", "(", "split", ".", "length", ">", "2", ")", "{", "namespace", "=", "split", "[", "0", "]", ";", "name", "=", "split", "[", "1", "]", ";", "value", "=", "split", "[", "2", "]", ";", "}", "else", "if", "(", "split", ".", "length", ">", "1", ")", "{", "name", "=", "split", "[", "0", "]", ";", "value", "=", "split", "[", "1", "]", ";", "}", "else", "{", "name", "=", "split", "[", "0", "]", ";", "}", "if", "(", "value", "!=", "null", ")", "{", "try", "{", "value", "=", "new", "String", "(", "Base64", ".", "decodeBase64", "(", "value", ")", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "}", "result", ".", "add", "(", "new", "annis", ".", "model", ".", "Annotation", "(", "namespace", ",", "name", ",", "value", ")", ")", ";", "}", "}", "}", "return", "result", ";", "}", "public", "String", "getMatchedNodesViewName", "(", ")", "{", "return", "matchedNodesViewName", ";", "}", "public", "void", "setMatchedNodesViewName", "(", "String", "matchedNodesViewName", ")", "{", "this", ".", "matchedNodesViewName", "=", "matchedNodesViewName", ";", "}", "public", "SqlGenerator", "<", "QueryData", ",", "?", ">", "getInnerQuerySqlGenerator", "(", ")", "{", "return", "innerQuerySqlGenerator", ";", "}", "public", "void", "setInnerQuerySqlGenerator", "(", "SqlGenerator", "<", "QueryData", ",", "?", ">", "innerQuerySqlGenerator", ")", "{", "this", ".", "innerQuerySqlGenerator", "=", "innerQuerySqlGenerator", ";", "}", "public", "TableJoinsInFromClauseSqlGenerator", "getTableJoinsInFromClauseGenerator", "(", ")", "{", "return", "tableJoinsInFromClauseGenerator", ";", "}", "public", "void", "setTableJoinsInFromClauseGenerator", "(", "TableJoinsInFromClauseSqlGenerator", "tableJoinsInFromClauseGenerator", ")", "{", "this", ".", "tableJoinsInFromClauseGenerator", "=", "tableJoinsInFromClauseGenerator", ";", "}", "}", "</s>" ]
8,830
[ "<s>", "package", "annis", ".", "sqlgen", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "UnknownExpressionException", "extends", "RuntimeException", "{", "public", "UnknownExpressionException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "UnknownExpressionException", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "public", "UnknownExpressionException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "UnknownExpressionException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "}", "</s>" ]
8,831
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "interface", "GroupByClauseSqlGenerator", "<", "T", ">", "{", "String", "groupByAttributes", "(", "T", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ")", ";", "}", "</s>" ]
8,832
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "interface", "LimitOffsetClauseSqlGenerator", "<", "T", ">", "{", "String", "limitOffsetClause", "(", "T", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", ";", "}", "</s>" ]
8,833
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "public", "class", "AnnotateInnerQuerySqlGenerator", "extends", "AbstractUnionSqlGenerator", "<", "Object", ">", "implements", "SelectClauseSqlGenerator", "<", "QueryData", ">", ",", "OrderByClauseSqlGenerator", "<", "QueryData", ">", "{", "private", "boolean", "sortSolutions", ";", "private", "SolutionKey", "<", "?", ">", "solutionKey", ";", "@", "Override", "public", "Object", "extractData", "(", "ResultSet", "rs", ")", "throws", "SQLException", ",", "DataAccessException", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "String", "toSql", "(", "QueryData", "queryData", ",", "String", "indent", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\"FROM", "(n\"", ")", ";", "sb", ".", "append", "(", "super", ".", "toSql", "(", "queryData", ",", "indent", "+", "TABSTOP", ")", ")", ".", "append", "(", "\"n\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "\")", "AS", "innn\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "@", "Override", "public", "String", "selectClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "List", "<", "AnnotateQueryData", ">", "extensions", "=", "queryData", ".", "getExtensions", "(", "AnnotateQueryData", ".", "class", ")", ";", "AnnotateQueryData", "annotateQueryData", "=", "null", ";", "if", "(", "extensions", ".", "isEmpty", "(", ")", ")", "{", "annotateQueryData", "=", "new", "AnnotateQueryData", "(", "5", ",", "5", ")", ";", "}", "else", "{", "annotateQueryData", "=", "extensions", ".", "get", "(", "0", ")", ";", "}", "List", "<", "String", ">", "selectClauseForNode", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "alternative", ".", "size", "(", ")", ";", "++", "i", ")", "{", "QueryNode", "node", "=", "alternative", ".", "get", "(", "i", "-", "1", ")", ";", "TableAccessStrategy", "tables", "=", "tables", "(", "node", ")", ";", "List", "<", "String", ">", "fields", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "fields", ".", "addAll", "(", "solutionKey", ".", "generateInnerQueryColumns", "(", "tables", ",", "i", ")", ")", ";", "fields", ".", "add", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"text_ref\"", ")", "+", "\"", "AS", "text\"", "+", "i", ")", ";", "if", "(", "annotateQueryData", ".", "getSegmentationLayer", "(", ")", "==", "null", ")", "{", "fields", ".", "add", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"left_token\"", ")", "+", "\"", "-", "\"", "+", "annotateQueryData", ".", "getLeft", "(", ")", "+", "\"", "AS", "min\"", "+", "i", ")", ";", "fields", ".", "add", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"right_token\"", ")", "+", "\"", "+", "\"", "+", "annotateQueryData", ".", "getRight", "(", ")", "+", "\"", "AS", "max\"", "+", "i", ")", ";", "}", "else", "{", "fields", ".", "add", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"left_token\"", ")", "+", "\"", "AS", "min\"", "+", "i", ")", ";", "fields", ".", "add", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"right_token\"", ")", "+", "\"", "AS", "max\"", "+", "i", ")", ";", "}", "fields", ".", "add", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", "+", "\"", "AS", "corpus\"", "+", "i", ")", ";", "fields", ".", "add", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"name\"", ")", "+", "\"", "AS", "name\"", "+", "i", ")", ";", "selectClauseForNode", ".", "add", "(", "\"n\"", "+", "indent", "+", "TABSTOP", "+", "StringUtils", ".", "join", "(", "fields", ",", "\",", "\"", ")", ")", ";", "}", "return", "\"DISTINCT\"", "+", "StringUtils", ".", "join", "(", "selectClauseForNode", ",", "\",", "\"", ")", ";", "}", "@", "Override", "protected", "void", "appendOrderByClause", "(", "StringBuffer", "sb", ",", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "if", "(", "!", "sortSolutions", ")", "{", "return", ";", "}", "super", ".", "appendOrderByClause", "(", "sb", ",", "queryData", ",", "alternative", ",", "indent", ")", ";", "}", "@", "Override", "public", "String", "orderByClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "List", "<", "String", ">", "ids", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "queryData", ".", "getMaxWidth", "(", ")", ";", "++", "i", ")", "{", "ids", ".", "add", "(", "\"id\"", "+", "i", ")", ";", "}", "return", "StringUtils", ".", "join", "(", "ids", ",", "\",", "\"", ")", ";", "}", "public", "boolean", "isSortSolutions", "(", ")", "{", "return", "sortSolutions", ";", "}", "public", "void", "setSortSolutions", "(", "boolean", "sortSolutions", ")", "{", "this", ".", "sortSolutions", "=", "sortSolutions", ";", "}", "public", "SolutionKey", "<", "?", ">", "getSolutionKey", "(", ")", "{", "return", "solutionKey", ";", "}", "public", "void", "setSolutionKey", "(", "SolutionKey", "<", "?", ">", "solutionKey", ")", "{", "this", ".", "solutionKey", "=", "solutionKey", ";", "}", "}", "</s>" ]
8,834
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Properties", ";", "public", "class", "IslandsPolicy", "{", "private", "String", "defaultIslandsPolicy", ";", "public", "enum", "IslandPolicies", "{", "context", ",", "none", "}", "public", "IslandPolicies", "getMostRestrictivePolicy", "(", "List", "<", "Long", ">", "corpora", ",", "Map", "<", "Long", ",", "Properties", ">", "props", ")", "{", "if", "(", "corpora", ".", "isEmpty", "(", ")", ")", "{", "return", "IslandPolicies", ".", "valueOf", "(", "defaultIslandsPolicy", ")", ";", "}", "IslandPolicies", "[", "]", "all", "=", "IslandPolicies", ".", "values", "(", ")", ";", "IslandPolicies", "result", "=", "all", "[", "all", ".", "length", "-", "1", "]", ";", "for", "(", "Long", "l", ":", "corpora", ")", "{", "IslandPolicies", "newPolicy", "=", "IslandPolicies", ".", "valueOf", "(", "defaultIslandsPolicy", ")", ";", "if", "(", "props", ".", "get", "(", "l", ")", "!=", "null", ")", "{", "newPolicy", "=", "IslandPolicies", ".", "valueOf", "(", "props", ".", "get", "(", "l", ")", ".", "getProperty", "(", "\"\"", ",", "defaultIslandsPolicy", ")", ")", ";", "}", "if", "(", "newPolicy", ".", "ordinal", "(", ")", "<", "result", ".", "ordinal", "(", ")", ")", "{", "result", "=", "newPolicy", ";", "}", "}", "return", "result", ";", "}", "public", "String", "getDefaultIslandsPolicy", "(", ")", "{", "return", "defaultIslandsPolicy", ";", "}", "public", "void", "setDefaultIslandsPolicy", "(", "String", "defaultIslandsPolicy", ")", "{", "this", ".", "defaultIslandsPolicy", "=", "defaultIslandsPolicy", ";", "}", "}", "</s>" ]
8,835
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "java", ".", "util", ".", "Arrays", ".", "asList", ";", "import", "java", ".", "sql", ".", "Array", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "PostgreSqlArraySolutionKey", "<", "BaseType", ">", "extends", "AbstractSolutionKey", "<", "BaseType", ">", "implements", "SolutionKey", "<", "List", "<", "BaseType", ">", ">", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "PostgreSqlArraySolutionKey", ".", "class", ")", ";", "private", "String", "keyColumnName", ";", "@", "Override", "public", "List", "<", "String", ">", "generateOuterQueryColumns", "(", "TableAccessStrategy", "tableAccessStrategy", ",", "int", "size", ")", "{", "List", "<", "String", ">", "columns", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "nameAlias", "=", "tableAccessStrategy", ".", "aliasedColumn", "(", "\"solutions\"", ",", "getIdColumnName", "(", ")", ")", ";", "columns", ".", "add", "(", "createKeyArray", "(", "nameAlias", ",", "keyColumnName", ",", "size", ")", ")", ";", "return", "columns", ";", "}", "protected", "String", "createKeyArray", "(", "String", "column", ",", "String", "alias", ",", "int", "size", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"ARRAY[\"", ")", ";", "sb", ".", "append", "(", "column", ")", ";", "sb", ".", "append", "(", "1", ")", ";", "for", "(", "int", "i", "=", "2", ";", "i", "<=", "size", ";", "++", "i", ")", "{", "sb", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "column", ")", ";", "sb", ".", "append", "(", "i", ")", ";", "}", "sb", ".", "append", "(", "\"]\"", ")", ";", "sb", ".", "append", "(", "\"", "AS", "\"", ")", ";", "sb", ".", "append", "(", "alias", ")", ";", "String", "s", "=", "sb", ".", "toString", "(", ")", ";", "return", "s", ";", "}", "@", "Override", "public", "List", "<", "BaseType", ">", "retrieveKey", "(", "ResultSet", "resultSet", ")", "{", "try", "{", "Array", "sqlArray", "=", "resultSet", ".", "getArray", "(", "keyColumnName", ")", ";", "if", "(", "resultSet", ".", "wasNull", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"\"", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "BaseType", "[", "]", "keyArray", "=", "(", "BaseType", "[", "]", ")", "sqlArray", ".", "getArray", "(", ")", ";", "setLastKey", "(", "getCurrentKey", "(", ")", ")", ";", "setCurrentKey", "(", "asList", "(", "keyArray", ")", ")", ";", "return", "getCurrentKey", "(", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ",", "e", ")", ";", "throw", "new", "IllegalStateException", "(", "\"\"", ",", "e", ")", ";", "}", "}", "@", "Override", "public", "List", "<", "String", ">", "getKeyColumns", "(", "int", "size", ")", "{", "return", "asList", "(", "keyColumnName", ")", ";", "}", "public", "String", "getKeyColumnName", "(", ")", "{", "return", "keyColumnName", ";", "}", "public", "void", "setKeyColumnName", "(", "String", "keyColumnName", ")", "{", "this", ".", "keyColumnName", "=", "keyColumnName", ";", "}", "}", "</s>" ]
8,836
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "class", "TableAccessStrategyFactory", "{", "public", "TableAccessStrategy", "tables", "(", "QueryNode", "node", ")", "{", "TableAccessStrategy", "tableAccessStrategy", "=", "createTableAccessStrategy", "(", ")", ";", "tableAccessStrategy", ".", "setNode", "(", "node", ")", ";", "return", "tableAccessStrategy", ";", "}", "protected", "TableAccessStrategy", "createTableAccessStrategy", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
8,837
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "*", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "JdbcTemplate", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "public", "abstract", "class", "AnnotateSqlGenerator", "<", "T", ">", "extends", "AbstractSqlGenerator", "<", "T", ">", "implements", "SelectClauseSqlGenerator", "<", "QueryData", ">", ",", "FromClauseSqlGenerator", "<", "QueryData", ">", ",", "WhereClauseSqlGenerator", "<", "QueryData", ">", ",", "OrderByClauseSqlGenerator", "<", "QueryData", ">", ",", "AnnotateExtractor", "<", "T", ">", "{", "private", "boolean", "includeDocumentNameInAnnotateQuery", ";", "private", "boolean", "includeIsTokenColumn", ";", "private", "TableJoinsInFromClauseSqlGenerator", "tableJoinsInFromClauseSqlGenerator", ";", "private", "TableAccessStrategy", "outerQueryTableAccessStrategy", ";", "private", "ResultSetExtractor", "<", "T", ">", "resultExtractor", ";", "private", "CorpusPathExtractor", "corpusPathExtractor", ";", "private", "String", "matchedNodesViewName", ";", "public", "AnnotateSqlGenerator", "(", ")", "{", "}", "protected", "SolutionKey", "<", "?", ">", "createSolutionKey", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Deprecated", "public", "T", "queryAnnotationGraph", "(", "JdbcTemplate", "jdbcTemplate", ",", "long", "textID", ")", "{", "return", "(", "T", ")", "jdbcTemplate", ".", "query", "(", "getTextQuery", "(", "textID", ")", ",", "this", ")", ";", "}", "public", "T", "queryAnnotationGraph", "(", "JdbcTemplate", "jdbcTemplate", ",", "String", "toplevelCorpusName", ",", "String", "documentName", ")", "{", "return", "(", "T", ")", "jdbcTemplate", ".", "query", "(", "getDocumentQuery", "(", "toplevelCorpusName", ",", "documentName", ")", ",", "this", ")", ";", "}", "@", "Deprecated", "public", "abstract", "String", "getTextQuery", "(", "long", "textID", ")", ";", "public", "abstract", "String", "getDocumentQuery", "(", "String", "toplevelCorpusName", ",", "String", "documentName", ")", ";", "public", "String", "getMatchedNodesViewName", "(", ")", "{", "return", "matchedNodesViewName", ";", "}", "public", "void", "setMatchedNodesViewName", "(", "String", "matchedNodesViewName", ")", "{", "this", ".", "matchedNodesViewName", "=", "matchedNodesViewName", ";", "}", "@", "Override", "public", "abstract", "String", "selectClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", ";", "protected", "void", "addSelectClauseAttribute", "(", "List", "<", "String", ">", "fields", ",", "String", "table", ",", "String", "column", ")", "{", "TableAccessStrategy", "tas", "=", "tables", "(", "null", ")", ";", "fields", ".", "add", "(", "tas", ".", "aliasedColumn", "(", "table", ",", "column", ")", "+", "\"", "AS", "\\\"\"", "+", "outerQueryTableAccessStrategy", ".", "columnName", "(", "table", ",", "column", ")", "+", "\"\\\"\"", ")", ";", "}", "@", "Override", "public", "Set", "<", "String", ">", "whereConditions", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "TableAccessStrategy", "tables", "=", "tables", "(", "null", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "List", "<", "Long", ">", "corpusList", "=", "queryData", ".", "getCorpusList", "(", ")", ";", "if", "(", "corpusList", "!=", "null", "&&", "!", "corpusList", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "indent", ")", ";", "sb", ".", "append", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"\"", ")", ")", ";", "sb", ".", "append", "(", "\"", "IN", "(\"", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "corpusList", ",", "\",", "\"", ")", ")", ";", "sb", ".", "append", "(", "\")", "ANDn\"", ")", ";", "if", "(", "!", "tables", ".", "isMaterialized", "(", "RANK_TABLE", ",", "NODE_TABLE", ")", ")", "{", "sb", ".", "append", "(", "indent", ")", ";", "sb", ".", "append", "(", "tables", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"\"", ")", ")", ";", "sb", ".", "append", "(", "\"", "IN", "(\"", ")", ";", "sb", ".", "append", "(", "StringUtils", ".", "join", "(", "corpusList", ",", "\",", "\"", ")", ")", ";", "sb", ".", "append", "(", "\")", "ANDn\"", ")", ";", "}", "}", "String", "overlap", "=", "CommonAnnotateWithClauseGenerator", ".", "overlapForOneRange", "(", "indent", "+", "TABSTOP", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "tables", ")", ";", "sb", ".", "append", "(", "overlap", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "sb", ".", "append", "(", "\"", "ANDn\"", ")", ";", "sb", ".", "append", "(", "indent", ")", ".", "append", "(", "TABSTOP", ")", ";", "sb", ".", "append", "(", "tables", ".", "aliasedColumn", "(", "CORPUS_TABLE", ",", "\"id\"", ")", ")", ";", "sb", ".", "append", "(", "\"", "=", "\"", ")", ";", "sb", ".", "append", "(", "tables", ".", "aliasedColumn", "(", "NODE_TABLE", ",", "\"corpus_ref\"", ")", ")", ";", "HashSet", "<", "String", ">", "result", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "result", ".", "add", "(", "sb", ".", "toString", "(", ")", ")", ";", "return", "result", ";", "}", "@", "Override", "public", "String", "orderByClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"\"", ")", ";", "sb", ".", "append", "(", "tables", "(", "null", ")", ".", "aliasedColumn", "(", "COMPONENT_TABLE", ",", "\"id\"", ")", ")", ".", "append", "(", "\",", "\"", ")", ";", "String", "preColumn", "=", "tables", "(", "null", ")", ".", "aliasedColumn", "(", "RANK_TABLE", ",", "\"pre\"", ")", ";", "sb", ".", "append", "(", "preColumn", ")", ";", "String", "orderByClause", "=", "sb", ".", "toString", "(", ")", ";", "return", "orderByClause", ";", "}", "@", "Override", "public", "abstract", "String", "fromClause", "(", "QueryData", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", ";", "@", "Override", "public", "T", "extractData", "(", "ResultSet", "resultSet", ")", "throws", "SQLException", ",", "DataAccessException", "{", "return", "resultExtractor", ".", "extractData", "(", "resultSet", ")", ";", "}", "public", "TableJoinsInFromClauseSqlGenerator", "getTableJoinsInFromClauseSqlGenerator", "(", ")", "{", "return", "tableJoinsInFromClauseSqlGenerator", ";", "}", "public", "void", "setTableJoinsInFromClauseSqlGenerator", "(", "TableJoinsInFromClauseSqlGenerator", "tableJoinsInFromClauseSqlGenerator", ")", "{", "this", ".", "tableJoinsInFromClauseSqlGenerator", "=", "tableJoinsInFromClauseSqlGenerator", ";", "}", "public", "TableAccessStrategy", "getOuterQueryTableAccessStrategy", "(", ")", "{", "return", "outerQueryTableAccessStrategy", ";", "}", "public", "boolean", "isIncludeDocumentNameInAnnotateQuery", "(", ")", "{", "return", "includeDocumentNameInAnnotateQuery", ";", "}", "public", "void", "setIncludeDocumentNameInAnnotateQuery", "(", "boolean", "includeDocumentNameInAnnotateQuery", ")", "{", "this", ".", "includeDocumentNameInAnnotateQuery", "=", "includeDocumentNameInAnnotateQuery", ";", "}", "public", "boolean", "isIncludeIsTokenColumn", "(", ")", "{", "return", "includeIsTokenColumn", ";", "}", "public", "void", "setIncludeIsTokenColumn", "(", "boolean", "includeIsTokenColumn", ")", "{", "this", ".", "includeIsTokenColumn", "=", "includeIsTokenColumn", ";", "}", "public", "CorpusPathExtractor", "getCorpusPathExtractor", "(", ")", "{", "return", "corpusPathExtractor", ";", "}", "public", "void", "setCorpusPathExtractor", "(", "CorpusPathExtractor", "corpusPathExtractor", ")", "{", "this", ".", "corpusPathExtractor", "=", "corpusPathExtractor", ";", "}", "@", "Override", "public", "void", "setOuterQueryTableAccessStrategy", "(", "TableAccessStrategy", "outerQueryTableAccessStrategy", ")", "{", "this", ".", "outerQueryTableAccessStrategy", "=", "outerQueryTableAccessStrategy", ";", "}", "public", "ResultSetExtractor", "<", "T", ">", "getResultExtractor", "(", ")", "{", "return", "resultExtractor", ";", "}", "public", "void", "setResultExtractor", "(", "ResultSetExtractor", "<", "T", ">", "resultExtractor", ")", "{", "this", ".", "resultExtractor", "=", "resultExtractor", ";", "}", "}", "</s>" ]
8,838
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "public", "abstract", "class", "AbstractFromClauseGenerator", "extends", "TableAccessStrategyFactory", "implements", "FromClauseSqlGenerator", "<", "QueryData", ">", "{", "protected", "String", "tableAliasDefinition", "(", "QueryNode", "node", ",", "String", "table", ",", "int", "count", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "tables", "(", "node", ")", ".", "tableName", "(", "table", ")", ")", ";", "sb", ".", "append", "(", "\"", "AS", "\"", ")", ";", "sb", ".", "append", "(", "tables", "(", "node", ")", ".", "aliasedTable", "(", "table", ",", "count", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,839
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "public", "interface", "FromClauseSqlGenerator", "<", "T", ">", "{", "String", "fromClause", "(", "T", "queryData", ",", "List", "<", "QueryNode", ">", "alternative", ",", "String", "indent", ")", ";", "}", "</s>" ]
8,840
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "MultipleColumnsSolutionKey", "<", "BaseType", ">", "extends", "AbstractSolutionKey", "<", "BaseType", ">", "implements", "SolutionKey", "<", "List", "<", "BaseType", ">", ">", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "MultipleColumnsSolutionKey", ".", "class", ")", ";", "private", "String", "keyColumnName", ";", "@", "Override", "public", "List", "<", "String", ">", "generateOuterQueryColumns", "(", "TableAccessStrategy", "tableAccessStrategy", ",", "int", "size", ")", "{", "List", "<", "String", ">", "columns", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "nameAlias", "=", "tableAccessStrategy", ".", "aliasedColumn", "(", "\"solutions\"", ",", "getIdColumnName", "(", ")", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "size", ";", "++", "i", ")", "{", "columns", ".", "add", "(", "nameAlias", "+", "i", "+", "\"", "AS", "\"", "+", "keyColumnName", "+", "i", ")", ";", "}", "return", "columns", ";", "}", "@", "Override", "public", "List", "<", "BaseType", ">", "retrieveKey", "(", "ResultSet", "resultSet", ")", "{", "setLastKey", "(", "getCurrentKey", "(", ")", ")", ";", "List", "<", "BaseType", ">", "currentKey", "=", "new", "ArrayList", "<", "BaseType", ">", "(", ")", ";", "setCurrentKey", "(", "currentKey", ")", ";", "SQLException", "sqlException", "=", "null", ";", "int", "index", "=", "1", ";", "boolean", "hasMoreKeyColumns", "=", "true", ";", "do", "{", "try", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "BaseType", "keyPart", "=", "(", "BaseType", ")", "resultSet", ".", "getObject", "(", "keyColumnName", "+", "index", ")", ";", "currentKey", ".", "add", "(", "keyPart", ")", ";", "++", "index", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "sqlException", "=", "e", ";", "hasMoreKeyColumns", "=", "false", ";", "}", "}", "while", "(", "hasMoreKeyColumns", ")", ";", "if", "(", "index", "==", "1", ")", "{", "log", ".", "error", "(", "\"\"", ",", "sqlException", ")", ";", "throw", "new", "IllegalStateException", "(", "\"\"", ",", "sqlException", ")", ";", "}", "return", "currentKey", ";", "}", "@", "Override", "public", "List", "<", "String", ">", "getKeyColumns", "(", "int", "size", ")", "{", "List", "<", "String", ">", "keyColumns", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "size", ";", "++", "i", ")", "{", "keyColumns", ".", "add", "(", "keyColumnName", "+", "i", ")", ";", "}", "return", "keyColumns", ";", "}", "public", "String", "getKeyColumnName", "(", ")", "{", "return", "keyColumnName", ";", "}", "public", "void", "setKeyColumnName", "(", "String", "keyColumnName", ")", "{", "this", ".", "keyColumnName", "=", "keyColumnName", ";", "}", "}", "</s>" ]
8,841
[ "<s>", "package", "annis", ".", "service", ".", "internal", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "annis", ".", "AnnisBaseRunner", ";", "import", "annis", ".", "utils", ".", "Utils", ";", "import", "com", ".", "sun", ".", "jersey", ".", "api", ".", "core", ".", "PackagesResourceConfig", ";", "import", "com", ".", "sun", ".", "jersey", ".", "api", ".", "core", ".", "ResourceConfig", ";", "import", "com", ".", "sun", ".", "jersey", ".", "core", ".", "spi", ".", "component", ".", "ioc", ".", "IoCComponentProviderFactory", ";", "import", "com", ".", "sun", ".", "jersey", ".", "spi", ".", "container", ".", "WebApplication", ";", "import", "com", ".", "sun", ".", "jersey", ".", "spi", ".", "container", ".", "servlet", ".", "ServletContainer", ";", "import", "com", ".", "sun", ".", "jersey", ".", "spi", ".", "spring", ".", "container", ".", "SpringComponentProviderFactory", ";", "import", "java", ".", "io", ".", "File", ";", "import", "org", ".", "eclipse", ".", "jetty", ".", "server", ".", "Server", ";", "import", "org", ".", "eclipse", ".", "jetty", ".", "servlet", ".", "ServletContextHandler", ";", "import", "org", ".", "eclipse", ".", "jetty", ".", "servlet", ".", "ServletHolder", ";", "import", "org", ".", "eclipse", ".", "jetty", ".", "util", ".", "thread", ".", "ExecutorThreadPool", ";", "import", "org", ".", "eclipse", ".", "jetty", ".", "util", ".", "thread", ".", "QueuedThreadPool", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "import", "org", ".", "springframework", ".", "context", ".", "support", ".", "GenericXmlApplicationContext", ";", "import", "org", ".", "springframework", ".", "core", ".", "env", ".", "MutablePropertySources", ";", "import", "org", ".", "springframework", ".", "core", ".", "io", ".", "support", ".", "ResourcePropertySource", ";", "public", "class", "AnnisServiceRunner", "extends", "AnnisBaseRunner", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AnnisServiceRunner", ".", "class", ")", ";", "private", "static", "AnnisServiceRunner", "annisServiceRunner", ";", "private", "boolean", "isShutdownRequested", "=", "false", ";", "private", "static", "Thread", "mainThread", ";", "private", "Server", "server", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "IOException", "{", "boolean", "daemonMode", "=", "false", ";", "if", "(", "args", ".", "length", "==", "1", "&&", "(", "\"-d\"", ".", "equals", "(", "args", "[", "0", "]", ")", ")", ")", "{", "daemonMode", "=", "true", ";", "}", "AnnisBaseRunner", ".", "setupLogging", "(", "!", "daemonMode", ")", ";", "mainThread", "=", "Thread", ".", "currentThread", "(", ")", ";", "annisServiceRunner", "=", "new", "AnnisServiceRunner", "(", ")", ";", "if", "(", "daemonMode", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "File", "pidFile", "=", "new", "File", "(", "System", ".", "getProperty", "(", "\"\"", ")", ")", ";", "pidFile", ".", "deleteOnExit", "(", ")", ";", "annisServiceRunner", ".", "start", "(", ")", ";", "if", "(", "!", "annisServiceRunner", ".", "isShutdownRequested", ")", "{", "closeSystemStreams", "(", ")", ";", "}", "}", "else", "{", "log", ".", "info", "(", "\"\"", ")", ";", "annisServiceRunner", ".", "start", "(", ")", ";", "}", "if", "(", "!", "annisServiceRunner", ".", "isShutdownRequested", ")", "{", "addShutdownHook", "(", ")", ";", "}", "try", "{", "while", "(", "!", "annisServiceRunner", ".", "isShutdownRequested", ")", "{", "Thread", ".", "sleep", "(", "1000", ")", ";", "}", "}", "catch", "(", "InterruptedException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "public", "void", "shutdown", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "isShutdownRequested", "=", "true", ";", "try", "{", "mainThread", ".", "join", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "log", ".", "error", "(", "\"\"", ")", ";", "}", "}", "private", "static", "void", "closeSystemStreams", "(", ")", "{", "System", ".", "err", ".", "close", "(", ")", ";", "System", ".", "out", ".", "close", "(", ")", ";", "}", "static", "private", "void", "addShutdownHook", "(", ")", "{", "Runtime", ".", "getRuntime", "(", ")", ".", "addShutdownHook", "(", "new", "Thread", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "annisServiceRunner", ".", "shutdown", "(", ")", ";", "}", "}", ")", ";", "}", "public", "void", "createWebServer", "(", ")", "{", "GenericXmlApplicationContext", "ctx", "=", "new", "GenericXmlApplicationContext", "(", ")", ";", "MutablePropertySources", "sources", "=", "ctx", ".", "getEnvironment", "(", ")", ".", "getPropertySources", "(", ")", ";", "try", "{", "sources", ".", "addFirst", "(", "new", "ResourcePropertySource", "(", "\"file:\"", "+", "Utils", ".", "getAnnisFile", "(", "\"\"", ")", ".", "getAbsolutePath", "(", ")", ")", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "ctx", ".", "load", "(", "\"file:\"", "+", "Utils", ".", "getAnnisFile", "(", "\"\"", ")", ".", "getAbsolutePath", "(", ")", ")", ";", "ctx", ".", "refresh", "(", ")", ";", "ResourceConfig", "rc", "=", "new", "PackagesResourceConfig", "(", "\"\"", ",", "\"\"", ",", "\"\"", ")", ";", "final", "IoCComponentProviderFactory", "factory", "=", "new", "SpringComponentProviderFactory", "(", "rc", ",", "ctx", ")", ";", "int", "port", "=", "ctx", ".", "getBean", "(", "AnnisWebService", ".", "class", ")", ".", "getPort", "(", ")", ";", "try", "{", "server", "=", "new", "Server", "(", "port", ")", ";", "ServletContextHandler", "context", "=", "new", "ServletContextHandler", "(", "ServletContextHandler", ".", "NO_SESSIONS", ")", ";", "context", ".", "setContextPath", "(", "\"/\"", ")", ";", "server", ".", "setHandler", "(", "context", ")", ";", "server", ".", "setThreadPool", "(", "new", "ExecutorThreadPool", "(", ")", ")", ";", "ServletContainer", "jerseyContainer", "=", "new", "ServletContainer", "(", "rc", ")", "{", "@", "Override", "protected", "void", "initiate", "(", "ResourceConfig", "rc", ",", "WebApplication", "wa", ")", "{", "wa", ".", "initiate", "(", "rc", ",", "factory", ")", ";", "}", "}", ";", "ServletHolder", "holder", "=", "new", "ServletHolder", "(", "jerseyContainer", ")", ";", "context", ".", "addServlet", "(", "holder", ",", "\"/*\"", ")", ";", "}", "catch", "(", "IllegalArgumentException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "isShutdownRequested", "=", "true", ";", ";", "}", "catch", "(", "NullPointerException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "isShutdownRequested", "=", "true", ";", "}", "}", "private", "void", "start", "(", ")", "{", "log", ".", "info", "(", "\"\"", ")", ";", "try", "{", "createWebServer", "(", ")", ";", "if", "(", "server", "==", "null", ")", "{", "isShutdownRequested", "=", "true", ";", "}", "else", "{", "server", ".", "start", "(", ")", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "isShutdownRequested", "=", "true", ";", "}", "}", "}", "</s>" ]
8,842
[ "<s>", "package", "annis", ".", "service", ".", "internal", ";", "import", "annis", ".", "CommonHelper", ";", "import", "java", ".", "net", ".", "URISyntaxException", ";", "import", "static", "java", ".", "util", ".", "Arrays", ".", "asList", ";", "import", "annis", ".", "WekaHelper", ";", "import", "annis", ".", "dao", ".", "AnnisDao", ";", "import", "annis", ".", "dao", ".", "AnnotatedMatch", ";", "import", "annis", ".", "service", ".", "objects", ".", "Match", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "resolver", ".", "ResolverEntry", ";", "import", "annis", ".", "resolver", ".", "SingleResolverRequest", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisAttribute", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisBinary", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisCorpus", ";", "import", "annis", ".", "service", ".", "objects", ".", "CorpusConfig", ";", "import", "annis", ".", "sqlgen", ".", "AnnotateQueryData", ";", "import", "annis", ".", "sqlgen", ".", "LimitOffsetQueryData", ";", "import", "annis", ".", "sqlgen", ".", "SaltURIs", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltProject", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "net", ".", "URI", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "TreeSet", ";", "import", "java", ".", "util", ".", "concurrent", ".", "locks", ".", "Lock", ";", "import", "java", ".", "util", ".", "concurrent", ".", "locks", ".", "ReentrantLock", ";", "import", "javax", ".", "ws", ".", "rs", ".", "DefaultValue", ";", "import", "javax", ".", "ws", ".", "rs", ".", "GET", ";", "import", "javax", ".", "ws", ".", "rs", ".", "Path", ";", "import", "javax", ".", "ws", ".", "rs", ".", "PathParam", ";", "import", "javax", ".", "ws", ".", "rs", ".", "Produces", ";", "import", "javax", ".", "ws", ".", "rs", ".", "QueryParam", ";", "import", "javax", ".", "ws", ".", "rs", ".", "WebApplicationException", ";", "import", "javax", ".", "ws", ".", "rs", ".", "core", ".", "MediaType", ";", "import", "javax", ".", "ws", ".", "rs", ".", "core", ".", "Response", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "import", "org", ".", "springframework", ".", "stereotype", ".", "Component", ";", "@", "Component", "@", "Path", "(", "\"/annis\"", ")", "public", "class", "AnnisWebService", "{", "private", "final", "static", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AnnisWebService", ".", "class", ")", ";", "private", "final", "static", "Logger", "queryLog", "=", "LoggerFactory", ".", "getLogger", "(", "\"QueryLog\"", ")", ";", "private", "AnnisDao", "annisDao", ";", "private", "WekaHelper", "wekaHelper", ";", "private", "int", "maxContext", "=", "10", ";", "private", "int", "port", "=", "5711", ";", "public", "void", "init", "(", ")", "{", "annisDao", ".", "checkDatabaseVersion", "(", ")", ";", "log", ".", "info", "(", "\"\"", ")", ";", "}", "@", "GET", "@", "Path", "(", "\"search/count\"", ")", "@", "Produces", "(", "\"plain/text\"", ")", "public", "Response", "count", "(", "@", "QueryParam", "(", "\"q\"", ")", "String", "query", ",", "@", "QueryParam", "(", "\"corpora\"", ")", "String", "rawCorpusNames", ")", "{", "requiredParameter", "(", "query", ",", "\"q\"", ",", "\"\"", ")", ";", "requiredParameter", "(", "rawCorpusNames", ",", "\"corpora\"", ",", "\"\"", ")", ";", "QueryData", "data", "=", "queryDataFromParameters", "(", "query", ",", "rawCorpusNames", ")", ";", "long", "start", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "int", "count", "=", "annisDao", ".", "count", "(", "data", ")", ";", "long", "end", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "logQuery", "(", "\"COUNT\"", ",", "query", ",", "splitCorpusNamesFromRaw", "(", "rawCorpusNames", ")", ",", "end", "-", "start", ")", ";", "return", "Response", ".", "ok", "(", "\"\"", "+", "count", ")", ".", "type", "(", "MediaType", ".", "TEXT_PLAIN", ")", ".", "build", "(", ")", ";", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "SaltProject", "annotate", "(", "@", "QueryParam", "(", "\"q\"", ")", "String", "query", ",", "@", "QueryParam", "(", "\"corpora\"", ")", "String", "rawCorpusNames", ",", "@", "DefaultValue", "(", "\"0\"", ")", "@", "QueryParam", "(", "\"offset\"", ")", "String", "offsetRaw", ",", "@", "DefaultValue", "(", "\"10\"", ")", "@", "QueryParam", "(", "\"limit\"", ")", "String", "limitRaw", ",", "@", "DefaultValue", "(", "\"5\"", ")", "@", "QueryParam", "(", "\"left\"", ")", "String", "leftRaw", ",", "@", "DefaultValue", "(", "\"5\"", ")", "@", "QueryParam", "(", "\"right\"", ")", "String", "rightRaw", ",", "@", "QueryParam", "(", "\"seglayer\"", ")", "String", "segmentationLayer", ")", "throws", "IOException", "{", "requiredParameter", "(", "query", ",", "\"q\"", ",", "\"\"", ")", ";", "requiredParameter", "(", "rawCorpusNames", ",", "\"corpora\"", ",", "\"\"", ")", ";", "int", "offset", "=", "Integer", ".", "parseInt", "(", "offsetRaw", ")", ";", "int", "limit", "=", "Integer", ".", "parseInt", "(", "limitRaw", ")", ";", "int", "left", "=", "Math", ".", "min", "(", "maxContext", ",", "Integer", ".", "parseInt", "(", "leftRaw", ")", ")", ";", "int", "right", "=", "Math", ".", "min", "(", "maxContext", ",", "Integer", ".", "parseInt", "(", "rightRaw", ")", ")", ";", "QueryData", "data", "=", "queryDataFromParameters", "(", "query", ",", "rawCorpusNames", ")", ";", "String", "logParameters", "=", "createAnnotateLogParameters", "(", "left", ",", "right", ",", "offset", ",", "limit", ")", ";", "data", ".", "addExtension", "(", "new", "LimitOffsetQueryData", "(", "offset", ",", "limit", ")", ")", ";", "data", ".", "addExtension", "(", "new", "AnnotateQueryData", "(", "left", ",", "right", ",", "segmentationLayer", ")", ")", ";", "long", "start", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "SaltProject", "p", "=", "annisDao", ".", "annotate", "(", "data", ")", ";", "long", "end", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "logQuery", "(", "\"ANNOTATE\"", ",", "query", ",", "splitCorpusNamesFromRaw", "(", "rawCorpusNames", ")", ",", "end", "-", "start", ",", "logParameters", ")", ";", "return", "p", ";", "}", "@", "GET", "@", "Path", "(", "\"search/find\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "List", "<", "Match", ">", "find", "(", "@", "QueryParam", "(", "\"q\"", ")", "String", "query", ",", "@", "QueryParam", "(", "\"corpora\"", ")", "String", "rawCorpusNames", ",", "@", "DefaultValue", "(", "\"0\"", ")", "@", "QueryParam", "(", "\"offset\"", ")", "String", "offsetRaw", ",", "@", "DefaultValue", "(", "\"10\"", ")", "@", "QueryParam", "(", "\"limit\"", ")", "String", "limitRaw", ")", "throws", "IOException", "{", "requiredParameter", "(", "query", ",", "\"q\"", ",", "\"\"", ")", ";", "requiredParameter", "(", "rawCorpusNames", ",", "\"corpora\"", ",", "\"\"", ")", ";", "int", "offset", "=", "Integer", ".", "parseInt", "(", "offsetRaw", ")", ";", "int", "limit", "=", "Integer", ".", "parseInt", "(", "limitRaw", ")", ";", "QueryData", "data", "=", "queryDataFromParameters", "(", "query", ",", "rawCorpusNames", ")", ";", "data", ".", "setCorpusConfiguration", "(", "annisDao", ".", "getCorpusConfiguration", "(", ")", ")", ";", "data", ".", "addExtension", "(", "new", "LimitOffsetQueryData", "(", "offset", ",", "limit", ")", ")", ";", "return", "annisDao", ".", "find", "(", "data", ")", ";", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"text/plain\"", ")", "public", "String", "matrix", "(", "@", "QueryParam", "(", "\"q\"", ")", "String", "query", ",", "@", "QueryParam", "(", "\"corpora\"", ")", "String", "rawCorpusNames", ")", "{", "requiredParameter", "(", "query", ",", "\"q\"", ",", "\"\"", ")", ";", "requiredParameter", "(", "rawCorpusNames", ",", "\"corpora\"", ",", "\"\"", ")", ";", "QueryData", "data", "=", "queryDataFromParameters", "(", "query", ",", "rawCorpusNames", ")", ";", "long", "start", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "List", "<", "AnnotatedMatch", ">", "matches", "=", "annisDao", ".", "matrix", "(", "data", ")", ";", "long", "end", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "logQuery", "(", "\"MATRIX\"", ",", "query", ",", "splitCorpusNamesFromRaw", "(", "rawCorpusNames", ")", ",", "end", "-", "start", ")", ";", "if", "(", "matches", ".", "isEmpty", "(", ")", ")", "{", "return", "\"(empty)\"", ";", "}", "else", "{", "return", "WekaHelper", ".", "exportAsArff", "(", "matches", ")", ";", "}", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "SaltProject", "subgraph", "(", "@", "QueryParam", "(", "\"q\"", ")", "String", "saltIDs", ",", "@", "DefaultValue", "(", "\"5\"", ")", "@", "QueryParam", "(", "\"left\"", ")", "String", "leftRaw", ",", "@", "DefaultValue", "(", "\"5\"", ")", "@", "QueryParam", "(", "\"right\"", ")", "String", "rightRaw", ",", "@", "QueryParam", "(", "\"seglayer\"", ")", "String", "segmentationLayer", ")", "{", "String", "[", "]", "ids", ";", "List", "<", "URI", ">", "saltURI", "=", "new", "SaltURIs", "(", ")", ";", "QueryData", "data", "=", "new", "QueryData", "(", ")", ";", "int", "left", "=", "Integer", ".", "parseInt", "(", "leftRaw", ")", ";", "int", "right", "=", "Integer", ".", "parseInt", "(", "rightRaw", ")", ";", "data", ".", "addExtension", "(", "new", "AnnotateQueryData", "(", "left", ",", "right", ",", "segmentationLayer", ")", ")", ";", "if", "(", "saltIDs", "==", "null", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "type", "(", "MediaType", ".", "TEXT_PLAIN", ")", ".", "entity", "(", "\"\"", ")", ".", "build", "(", ")", ")", ";", "}", "ids", "=", "saltIDs", ".", "split", "(", "\"\\\\s*,\\\\s*\"", ")", ";", "for", "(", "String", "id", ":", "ids", ")", "{", "try", "{", "URI", "saltID", "=", "new", "URI", "(", "id", ")", ";", "saltURI", ".", "add", "(", "saltID", ")", ";", "if", "(", "saltID", ".", "getScheme", "(", ")", "==", "null", "||", "!", "saltID", ".", "getScheme", "(", ")", ".", "equals", "(", "\"salt\"", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "type", "(", "MediaType", ".", "TEXT_PLAIN", ")", ".", "entity", "(", "\"\"", ")", ".", "build", "(", ")", ")", ";", "}", "}", "catch", "(", "URISyntaxException", "ex", ")", "{", "String", "msg", "=", "id", "+", "\"\"", ";", "log", ".", "error", "(", "msg", ",", "ex", ")", ";", "}", "}", "Set", "<", "String", ">", "corpusNames", "=", "new", "TreeSet", "<", "String", ">", "(", ")", ";", "List", "<", "QueryNode", ">", "pseudoNodes", "=", "new", "ArrayList", "<", "QueryNode", ">", "(", "saltURI", ".", "size", "(", ")", ")", ";", "for", "(", "java", ".", "net", ".", "URI", "u", ":", "saltURI", ")", "{", "pseudoNodes", ".", "add", "(", "new", "QueryNode", "(", ")", ")", ";", "corpusNames", ".", "add", "(", "CommonHelper", ".", "getCorpusPath", "(", "u", ")", ".", "get", "(", "0", ")", ")", ";", "}", "List", "<", "Long", ">", "corpusIDs", "=", "annisDao", ".", "mapCorpusNamesToIds", "(", "new", "LinkedList", "<", "String", ">", "(", "corpusNames", ")", ")", ";", "data", ".", "setCorpusList", "(", "corpusIDs", ")", ";", "data", ".", "addAlternative", "(", "pseudoNodes", ")", ";", "data", ".", "addExtension", "(", "saltURI", ")", ";", "return", "annisDao", ".", "graph", "(", "data", ")", ";", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "SaltProject", "graph", "(", "@", "PathParam", "(", "\"top\"", ")", "String", "toplevelCorpusName", ",", "@", "PathParam", "(", "\"doc\"", ")", "String", "documentName", ")", "{", "try", "{", "long", "start", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "SaltProject", "p", "=", "annisDao", ".", "retrieveAnnotationGraph", "(", "toplevelCorpusName", ",", "documentName", ")", ";", "long", "end", "=", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "logQuery", "(", "\"GRAPH\"", ",", "toplevelCorpusName", ",", "documentName", ",", "end", "-", "start", ")", ";", "return", "p", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "\"\"", "+", "toplevelCorpusName", "+", "\"/\"", "+", "documentName", ",", "ex", ")", ";", "throw", "new", "WebApplicationException", "(", "ex", ")", ";", "}", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "List", "<", "ResolverEntry", ">", "resolver", "(", "@", "PathParam", "(", "\"corpusName\"", ")", "String", "corpusName", ",", "@", "PathParam", "(", "\"namespace\"", ")", "String", "namespace", ",", "@", "PathParam", "(", "\"type\"", ")", "String", "type", ")", "{", "ResolverEntry", ".", "ElementType", "enumType", "=", "ResolverEntry", ".", "ElementType", ".", "valueOf", "(", "type", ")", ";", "SingleResolverRequest", "r", "=", "new", "SingleResolverRequest", "(", "corpusName", ",", "namespace", ",", "enumType", ")", ";", "return", "annisDao", ".", "getResolverEntries", "(", "r", ")", ";", "}", "@", "GET", "@", "Path", "(", "\"corpora\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "List", "<", "AnnisCorpus", ">", "corpora", "(", ")", "{", "return", "annisDao", ".", "listCorpora", "(", ")", ";", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "CorpusConfig", "corpusconfig", "(", "@", "PathParam", "(", "\"top\"", ")", "String", "toplevelName", ")", "{", "Map", "<", "String", ",", "String", ">", "tmp", "=", "annisDao", ".", "getCorpusConfiguration", "(", "toplevelName", ")", ";", "CorpusConfig", "result", "=", "new", "CorpusConfig", "(", ")", ";", "result", ".", "setConfig", "(", "tmp", ")", ";", "return", "result", ";", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "List", "<", "AnnisAttribute", ">", "annotations", "(", "@", "PathParam", "(", "\"top\"", ")", "String", "toplevelCorpus", ",", "@", "DefaultValue", "(", "\"false\"", ")", "@", "QueryParam", "(", "\"fetchvalues\"", ")", "String", "fetchValues", ",", "@", "DefaultValue", "(", "\"false\"", ")", "@", "QueryParam", "(", "\"\"", ")", "String", "onlyMostFrequentValues", ")", "{", "List", "<", "String", ">", "list", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "list", ".", "add", "(", "toplevelCorpus", ")", ";", "List", "<", "Long", ">", "corpusList", "=", "annisDao", ".", "mapCorpusNamesToIds", "(", "list", ")", ";", "return", "annisDao", ".", "listAnnotations", "(", "corpusList", ",", "Boolean", ".", "parseBoolean", "(", "fetchValues", ")", ",", "Boolean", ".", "parseBoolean", "(", "onlyMostFrequentValues", ")", ")", ";", "}", "@", "GET", "@", "Path", "(", "\"check\"", ")", "public", "String", "check", "(", "@", "QueryParam", "(", "\"q\"", ")", "String", "query", ")", "{", "annisDao", ".", "parseAQL", "(", "query", ",", "new", "LinkedList", "<", "Long", ">", "(", ")", ")", ";", "return", "\"ok\"", ";", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "List", "<", "Annotation", ">", "getMetadata", "(", "@", "PathParam", "(", "\"top\"", ")", "String", "toplevelCorpusName", ")", "{", "return", "annisDao", ".", "listCorpusAnnotations", "(", "toplevelCorpusName", ")", ";", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "List", "<", "Annotation", ">", "getMetadata", "(", "@", "PathParam", "(", "\"top\"", ")", "String", "toplevelCorpusName", ",", "@", "PathParam", "(", "\"document\"", ")", "String", "documentName", ")", "{", "if", "(", "documentName", "==", "null", ")", "{", "documentName", "=", "toplevelCorpusName", ";", "}", "return", "annisDao", ".", "listCorpusAnnotations", "(", "toplevelCorpusName", ",", "documentName", ")", ";", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "AnnisBinary", "binary", "(", "@", "PathParam", "(", "\"top\"", ")", "String", "toplevelCorpusName", ",", "@", "PathParam", "(", "\"document\"", ")", "String", "corpusName", ",", "@", "PathParam", "(", "\"offset\"", ")", "String", "rawOffset", ",", "@", "PathParam", "(", "\"length\"", ")", "String", "rawLength", ")", "{", "int", "offset", "=", "Integer", ".", "parseInt", "(", "rawOffset", ")", ";", "int", "length", "=", "Integer", ".", "parseInt", "(", "rawLength", ")", ";", "AnnisBinary", "bin", "=", "null", ";", "log", ".", "debug", "(", "\"fetching", "\"", "+", "(", "length", "/", "1024", ")", "+", "\"kb", "(\"", "+", "offset", "+", "\"-\"", "+", "(", "offset", "+", "length", ")", "+", "\"\"", "+", "toplevelCorpusName", "+", "\"/\"", "+", "corpusName", ")", ";", "bin", "=", "annisDao", ".", "getBinary", "(", "toplevelCorpusName", ",", "corpusName", ",", "offset", "+", "1", ",", "length", ")", ";", "log", ".", "debug", "(", "\"\"", ")", ";", "return", "bin", ";", "}", "@", "GET", "@", "Path", "(", "\"\"", ")", "@", "Produces", "(", "\"\"", ")", "public", "AnnisBinary", "binaryMeta", "(", "@", "PathParam", "(", "\"top\"", ")", "String", "toplevelCorpusName", ",", "@", "PathParam", "(", "\"document\"", ")", "String", "documentName", ")", "{", "AnnisBinary", "bin", "=", "null", ";", "bin", "=", "annisDao", ".", "getBinary", "(", "toplevelCorpusName", ",", "documentName", ",", "1", ",", "1", ")", ";", "return", "bin", ";", "}", "private", "String", "createAnnotateLogParameters", "(", "int", "left", ",", "int", "right", ",", "int", "offset", ",", "int", "limit", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"left:", "\"", ")", ";", "sb", ".", "append", "(", "left", ")", ";", "sb", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "\"right:", "\"", ")", ";", "sb", ".", "append", "(", "right", ")", ";", "sb", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "\"offset:", "\"", ")", ";", "sb", ".", "append", "(", "offset", ")", ";", "sb", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "\"limit:", "\"", ")", ";", "sb", ".", "append", "(", "limit", ")", ";", "String", "logParameters", "=", "sb", ".", "toString", "(", ")", ";", "return", "logParameters", ";", "}", "private", "void", "logQuery", "(", "String", "queryFunction", ",", "String", "toplevelCorpus", ",", "String", "documentName", ",", "long", "runtime", ")", "{", "logQuery", "(", "queryFunction", ",", "null", ",", "asList", "(", "toplevelCorpus", ")", ",", "runtime", ",", "\"document:", "\"", "+", "documentName", ")", ";", "}", "private", "void", "logQuery", "(", "String", "queryFunction", ",", "String", "annisQuery", ",", "List", "<", "String", ">", "corpusNames", ",", "long", "runtime", ")", "{", "logQuery", "(", "queryFunction", ",", "annisQuery", ",", "corpusNames", ",", "runtime", ",", "null", ")", ";", "}", "private", "void", "logQuery", "(", "String", "queryFunction", ",", "String", "annisQuery", ",", "List", "<", "String", ">", "corpusNames", ",", "long", "runtime", ",", "String", "options", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"function:", "\"", ")", ";", "sb", ".", "append", "(", "queryFunction", ")", ";", "sb", ".", "append", "(", "\",", "\"", ")", ";", "if", "(", "annisQuery", "!=", "null", "&&", "!", "annisQuery", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "\"query:", "\"", ")", ";", "sb", ".", "append", "(", "annisQuery", ")", ";", "sb", ".", "append", "(", "\",", "\"", ")", ";", "}", "sb", ".", "append", "(", "\"corpus:", "\"", ")", ";", "sb", ".", "append", "(", "corpusNames", ")", ";", "sb", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "\"runtime:", "\"", ")", ";", "sb", ".", "append", "(", "runtime", ")", ";", "sb", ".", "append", "(", "\"", "ms\"", ")", ";", "if", "(", "options", "!=", "null", "&&", "!", "options", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "\",", "\"", ")", ";", "sb", ".", "append", "(", "options", ")", ";", "}", "String", "message", "=", "sb", ".", "toString", "(", ")", ";", "queryLog", ".", "info", "(", "message", ")", ";", "}", "private", "void", "requiredParameter", "(", "String", "value", ",", "String", "name", ",", "String", "description", ")", "throws", "WebApplicationException", "{", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "BAD_REQUEST", ")", ".", "type", "(", "MediaType", ".", "TEXT_PLAIN", ")", ".", "entity", "(", "\"\"", "+", "name", "+", "\"'", "(\"", "+", "description", "+", "\")\"", ")", ".", "build", "(", ")", ")", ";", "}", "}", "private", "QueryData", "queryDataFromParameters", "(", "String", "query", ",", "String", "rawCorpusNames", ")", "throws", "WebApplicationException", "{", "List", "<", "String", ">", "corpusNames", "=", "splitCorpusNamesFromRaw", "(", "rawCorpusNames", ")", ";", "List", "<", "Long", ">", "corpusIDs", "=", "annisDao", ".", "mapCorpusNamesToIds", "(", "corpusNames", ")", ";", "if", "(", "corpusIDs", ".", "size", "(", ")", "!=", "corpusNames", ".", "size", "(", ")", ")", "{", "throw", "new", "WebApplicationException", "(", "Response", ".", "status", "(", "Response", ".", "Status", ".", "NOT_FOUND", ")", ".", "type", "(", "\"text/plain\"", ")", ".", "entity", "(", "\"\"", ")", ".", "build", "(", ")", ")", ";", "}", "return", "annisDao", ".", "parseAQL", "(", "query", ",", "corpusIDs", ")", ";", "}", "private", "List", "<", "String", ">", "splitCorpusNamesFromRaw", "(", "String", "rawCorpusNames", ")", "{", "return", "Arrays", ".", "asList", "(", "rawCorpusNames", ".", "split", "(", "\",\"", ")", ")", ";", "}", "public", "AnnisDao", "getAnnisDao", "(", ")", "{", "return", "annisDao", ";", "}", "public", "void", "setAnnisDao", "(", "AnnisDao", "annisDao", ")", "{", "this", ".", "annisDao", "=", "annisDao", ";", "}", "public", "int", "getMaxContext", "(", ")", "{", "return", "maxContext", ";", "}", "public", "void", "setMaxContext", "(", "int", "maxContext", ")", "{", "this", ".", "maxContext", "=", "maxContext", ";", "}", "public", "WekaHelper", "getWekaHelper", "(", ")", "{", "return", "wekaHelper", ";", "}", "public", "void", "setWekaHelper", "(", "WekaHelper", "wekaHelper", ")", "{", "this", ".", "wekaHelper", "=", "wekaHelper", ";", "}", "public", "int", "getPort", "(", ")", "{", "return", "port", ";", "}", "public", "void", "setPort", "(", "int", "port", ")", "{", "this", ".", "port", "=", "port", ";", "}", "}", "</s>" ]
8,843
[ "<s>", "package", "annis", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "UsageException", "extends", "AnnisRunnerException", "{", "public", "UsageException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "UsageException", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "public", "UsageException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "UsageException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "}", "</s>" ]
8,844
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "annis", ".", "exceptions", ".", "AnnisQLSemanticsException", ";", "import", "annis", ".", "exceptions", ".", "AnnisQLSyntaxException", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAndExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnnotationSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnyNodeSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AArityLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ADirectDominanceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ADirectPointingRelationSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ADirectPrecedenceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ADirectSiblingSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ADocumentConstraintExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AEdgeAnnotation", ";", "import", "annis", ".", "ql", ".", "node", ".", "AEdgeSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "AEqualAnnoValue", ";", "import", "annis", ".", "ql", ".", "node", ".", "AExactOverlapLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "AGroupedExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AIdentityLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "AImplicitAndExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AInclusionLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "AIndirectDominanceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "AIndirectPointingRelationSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "AIndirectPrecedenceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "AIndirectSiblingSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALeftAlignLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALeftLeftOrRight", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALeftOverlapLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALinguisticConstraintExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AMetaConstraintExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AOrExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AOverlapLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARangeDominanceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARangePointingRelationSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARangePrecedenceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARangeSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARegexpTextSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARightAlignLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARightLeftOrRight", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARightOverlapLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARootLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ASameAnnotationGroupLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchNotEqualExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATokenArityLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "AUnequalAnnoValue", ";", "import", "annis", ".", "ql", ".", "node", ".", "AWildTextSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "PAnnoValue", ";", "import", "annis", ".", "ql", ".", "node", ".", "PEdgeAnnotation", ";", "import", "annis", ".", "ql", ".", "node", ".", "PExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "PLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "Token", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "CommonAncestor", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Dominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Identical", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Inclusion", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Join", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftAlignment", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftDominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftOverlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Overlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "PointingRelation", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Precedence", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightAlignment", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightDominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightOverlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "SameSpan", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Sibling", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Constructor", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "LinkedHashMap", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "ClauseAnalysis", "extends", "DepthFirstAdapter", "{", "private", "static", "final", "org", ".", "slf4j", ".", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "ClauseAnalysis", ".", "class", ")", ";", "private", "Map", "<", "String", ",", "QueryNode", ">", "nodes", ";", "private", "int", "aliasCount", ";", "private", "List", "<", "QueryAnnotation", ">", "metaAnnotations", ";", "private", "int", "precedenceBound", ";", "public", "ClauseAnalysis", "(", ")", "{", "this", "(", "0", ",", "new", "ArrayList", "<", "QueryAnnotation", ">", "(", ")", ",", "new", "LinkedHashMap", "<", "String", ",", "QueryNode", ">", "(", ")", ",", "0", ")", ";", "}", "public", "ClauseAnalysis", "(", "int", "aliasCount", ",", "List", "<", "QueryAnnotation", ">", "metaAnnotations", ",", "Map", "<", "String", ",", "QueryNode", ">", "nodes", ",", "int", "precedenceBound", ")", "{", "this", ".", "aliasCount", "=", "aliasCount", ";", "this", ".", "metaAnnotations", "=", "metaAnnotations", ";", "this", ".", "nodes", "=", "nodes", ";", "this", ".", "precedenceBound", "=", "precedenceBound", ";", "}", "public", "int", "nodesCount", "(", ")", "{", "return", "nodes", ".", "size", "(", ")", ";", "}", "@", "Override", "public", "void", "caseAOrExpr", "(", "AOrExpr", "node", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "caseAImplicitAndExpr", "(", "AImplicitAndExpr", "node", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "caseAGroupedExpr", "(", "AGroupedExpr", "node", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "caseASameAnnotationGroupLingOp", "(", "ASameAnnotationGroupLingOp", "node", ")", "{", "throw", "new", "AnnisQLSyntaxException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "caseADocumentConstraintExpr", "(", "ADocumentConstraintExpr", "node", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "caseARootLingOp", "(", "ARootLingOp", "node", ")", "{", "QueryNode", "nleft", "=", "lhs", "(", "node", ")", ";", "Validate", ".", "notNull", "(", "nleft", ",", "errorLHS", "(", "\"root\"", ")", ")", ";", "nleft", ".", "setRoot", "(", "true", ")", ";", "}", "@", "Override", "public", "void", "caseAArityLingOp", "(", "AArityLingOp", "node", ")", "{", "QueryNode", "nleft", "=", "lhs", "(", "node", ")", ";", "Validate", ".", "notNull", "(", "nleft", ",", "errorLHS", "(", "\"arity\"", ")", ")", ";", "nleft", ".", "setArity", "(", "annisRangeFromARangeSpec", "(", "(", "ARangeSpec", ")", "node", ".", "getRangeSpec", "(", ")", ")", ")", ";", "}", "@", "Override", "public", "void", "caseATokenArityLingOp", "(", "ATokenArityLingOp", "node", ")", "{", "QueryNode", "nleft", "=", "lhs", "(", "node", ")", ";", "Validate", ".", "notNull", "(", "nleft", ",", "errorLHS", "(", "\"token-arity\"", ")", ")", ";", "nleft", ".", "setTokenArity", "(", "annisRangeFromARangeSpec", "(", "(", "ARangeSpec", ")", "node", ".", "getRangeSpec", "(", ")", ")", ")", ";", "}", "@", "Override", "public", "void", "caseAIdentityLingOp", "(", "AIdentityLingOp", "node", ")", "{", "join", "(", "node", ",", "Identical", ".", "class", ")", ";", "}", "@", "Override", "public", "void", "caseAExactOverlapLingOp", "(", "AExactOverlapLingOp", "node", ")", "{", "join", "(", "node", ",", "SameSpan", ".", "class", ")", ";", "}", "@", "Override", "public", "void", "caseALeftAlignLingOp", "(", "ALeftAlignLingOp", "node", ")", "{", "join", "(", "node", ",", "LeftAlignment", ".", "class", ")", ";", "}", "@", "Override", "public", "void", "caseARightAlignLingOp", "(", "ARightAlignLingOp", "node", ")", "{", "join", "(", "node", ",", "RightAlignment", ".", "class", ")", ";", "}", "@", "Override", "public", "void", "caseAInclusionLingOp", "(", "AInclusionLingOp", "node", ")", "{", "join", "(", "node", ",", "Inclusion", ".", "class", ")", ";", "}", "@", "Override", "public", "void", "caseAOverlapLingOp", "(", "AOverlapLingOp", "node", ")", "{", "join", "(", "node", ",", "Overlap", ".", "class", ")", ";", "}", "@", "Override", "public", "void", "caseALeftOverlapLingOp", "(", "ALeftOverlapLingOp", "node", ")", "{", "join", "(", "node", ",", "LeftOverlap", ".", "class", ")", ";", "}", "@", "Override", "public", "void", "caseARightOverlapLingOp", "(", "ARightOverlapLingOp", "node", ")", "{", "join", "(", "node", ",", "RightOverlap", ".", "class", ")", ";", "}", "@", "Override", "public", "void", "caseADirectPrecedenceSpec", "(", "ADirectPrecedenceSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "Precedence", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "Precedence", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "String", "name", "=", "token", "(", "node", ".", "getName", "(", ")", ")", ";", "if", "(", "name", "==", "null", ")", "{", "left", ".", "addJoin", "(", "new", "Precedence", "(", "right", ",", "1", ")", ")", ";", "}", "else", "{", "left", ".", "addJoin", "(", "new", "Precedence", "(", "right", ",", "1", ",", "1", ",", "name", ")", ")", ";", "}", "}", "@", "Override", "public", "void", "caseAIndirectPrecedenceSpec", "(", "AIndirectPrecedenceSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "Precedence", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "Precedence", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "String", "name", "=", "token", "(", "node", ".", "getName", "(", ")", ")", ";", "if", "(", "precedenceBound", ">", "0", ")", "{", "left", ".", "addJoin", "(", "new", "Precedence", "(", "right", ",", "1", ",", "precedenceBound", ",", "name", ")", ")", ";", "}", "else", "{", "left", ".", "addJoin", "(", "new", "Precedence", "(", "right", ",", "name", ")", ")", ";", "}", "}", "@", "Override", "public", "void", "caseARangePrecedenceSpec", "(", "ARangePrecedenceSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "Precedence", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "Precedence", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "String", "name", "=", "token", "(", "node", ".", "getName", "(", ")", ")", ";", "ARangeSpec", "spec", "=", "(", "ARangeSpec", ")", "node", ".", "getRangeSpec", "(", ")", ";", "int", "min", "=", "number", "(", "spec", ".", "getMin", "(", ")", ")", ";", "if", "(", "min", "==", "0", ")", "{", "throw", "new", "AnnisQLSyntaxException", "(", "\"\"", ")", ";", "}", "if", "(", "spec", ".", "getMax", "(", ")", "==", "null", ")", "{", "left", ".", "addJoin", "(", "new", "Precedence", "(", "right", ",", "min", ",", "name", ")", ")", ";", "}", "else", "{", "int", "max", "=", "number", "(", "spec", ".", "getMax", "(", ")", ")", ";", "if", "(", "max", "==", "0", ")", "{", "throw", "new", "AnnisQLSyntaxException", "(", "\"\"", ")", ";", "}", "left", ".", "addJoin", "(", "new", "Precedence", "(", "right", ",", "min", ",", "max", ",", "name", ")", ")", ";", "}", "}", "@", "Override", "public", "void", "caseADirectDominanceSpec", "(", "ADirectDominanceSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "Dominance", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "Dominance", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "String", "name", "=", "token", "(", "node", ".", "getName", "(", ")", ")", ";", "if", "(", "node", ".", "getLeftOrRight", "(", ")", "!=", "null", ")", "{", "if", "(", "node", ".", "getLeftOrRight", "(", ")", "instanceof", "ALeftLeftOrRight", ")", "{", "left", ".", "addJoin", "(", "new", "LeftDominance", "(", "right", ",", "name", ")", ")", ";", "}", "else", "if", "(", "node", ".", "getLeftOrRight", "(", ")", "instanceof", "ARightLeftOrRight", ")", "{", "left", ".", "addJoin", "(", "new", "RightDominance", "(", "right", ",", "name", ")", ")", ";", "}", "else", "{", "throw", "new", "AnnisQLSemanticsException", "(", "\"\"", ")", ";", "}", "}", "else", "{", "left", ".", "addJoin", "(", "new", "Dominance", "(", "right", ",", "name", ",", "1", ")", ")", ";", "}", "if", "(", "node", ".", "getEdgeSpec", "(", ")", "!=", "null", ")", "{", "LinkedList", "<", "QueryAnnotation", ">", "annotations", "=", "fromEdgeAnnotation", "(", "(", "AEdgeSpec", ")", "node", ".", "getEdgeSpec", "(", ")", ")", ";", "for", "(", "QueryAnnotation", "a", ":", "annotations", ")", "{", "right", ".", "addEdgeAnnotation", "(", "a", ")", ";", "}", "}", "}", "@", "Override", "public", "void", "caseAIndirectDominanceSpec", "(", "AIndirectDominanceSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "Dominance", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "Dominance", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "left", ".", "addJoin", "(", "new", "Dominance", "(", "right", ",", "token", "(", "node", ".", "getName", "(", ")", ")", ")", ")", ";", "}", "@", "Override", "public", "void", "caseARangeDominanceSpec", "(", "ARangeDominanceSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "Dominance", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "Dominance", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "ARangeSpec", "rangeSpec", "=", "(", "ARangeSpec", ")", "node", ".", "getRangeSpec", "(", ")", ";", "if", "(", "rangeSpec", ".", "getMax", "(", ")", "==", "null", ")", "{", "int", "distance", "=", "number", "(", "rangeSpec", ".", "getMin", "(", ")", ")", ";", "if", "(", "distance", "==", "0", ")", "{", "throw", "new", "AnnisQLSyntaxException", "(", "\"\"", ")", ";", "}", "left", ".", "addJoin", "(", "new", "Dominance", "(", "right", ",", "token", "(", "node", ".", "getName", "(", ")", ")", ",", "distance", ")", ")", ";", "}", "else", "{", "int", "min", "=", "number", "(", "rangeSpec", ".", "getMin", "(", ")", ")", ";", "int", "max", "=", "number", "(", "rangeSpec", ".", "getMax", "(", ")", ")", ";", "if", "(", "min", "==", "0", "||", "max", "==", "0", ")", "{", "throw", "new", "AnnisQLSyntaxException", "(", "\"\"", ")", ";", "}", "left", ".", "addJoin", "(", "new", "Dominance", "(", "right", ",", "token", "(", "node", ".", "getName", "(", ")", ")", ",", "min", ",", "max", ")", ")", ";", "}", "}", "@", "Override", "public", "void", "caseADirectSiblingSpec", "(", "ADirectSiblingSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "Sibling", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "Sibling", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "left", ".", "addJoin", "(", "new", "Sibling", "(", "right", ",", "token", "(", "node", ".", "getName", "(", ")", ")", ")", ")", ";", "if", "(", "node", ".", "getEdgeSpec", "(", ")", "!=", "null", ")", "{", "LinkedList", "<", "QueryAnnotation", ">", "annotations", "=", "fromEdgeAnnotation", "(", "(", "AEdgeSpec", ")", "node", ".", "getEdgeSpec", "(", ")", ")", ";", "for", "(", "QueryAnnotation", "a", ":", "annotations", ")", "{", "left", ".", "addEdgeAnnotation", "(", "a", ")", ";", "right", ".", "addEdgeAnnotation", "(", "a", ")", ";", "}", "}", "}", "@", "Override", "public", "void", "caseAIndirectSiblingSpec", "(", "AIndirectSiblingSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "CommonAncestor", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "CommonAncestor", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "left", ".", "addJoin", "(", "new", "CommonAncestor", "(", "right", ",", "token", "(", "node", ".", "getName", "(", ")", ")", ")", ")", ";", "}", "@", "Override", "public", "void", "caseADirectPointingRelationSpec", "(", "ADirectPointingRelationSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "PointingRelation", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "PointingRelation", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "String", "name", "=", "token", "(", "node", ".", "getName", "(", ")", ")", ";", "left", ".", "addJoin", "(", "new", "PointingRelation", "(", "right", ",", "name", ",", "1", ")", ")", ";", "if", "(", "node", ".", "getEdgeSpec", "(", ")", "!=", "null", ")", "{", "LinkedList", "<", "QueryAnnotation", ">", "annotations", "=", "fromEdgeAnnotation", "(", "(", "AEdgeSpec", ")", "node", ".", "getEdgeSpec", "(", ")", ")", ";", "for", "(", "QueryAnnotation", "a", ":", "annotations", ")", "{", "right", ".", "addEdgeAnnotation", "(", "a", ")", ";", "}", "}", "}", "@", "Override", "public", "void", "caseARangePointingRelationSpec", "(", "ARangePointingRelationSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "PointingRelation", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "PointingRelation", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "ARangeSpec", "rangeSpec", "=", "(", "ARangeSpec", ")", "node", ".", "getRangeSpec", "(", ")", ";", "if", "(", "rangeSpec", ".", "getMax", "(", ")", "==", "null", ")", "{", "int", "distance", "=", "number", "(", "rangeSpec", ".", "getMin", "(", ")", ")", ";", "if", "(", "distance", "==", "0", ")", "{", "throw", "new", "AnnisQLSyntaxException", "(", "\"\"", ")", ";", "}", "left", ".", "addJoin", "(", "new", "PointingRelation", "(", "right", ",", "token", "(", "node", ".", "getName", "(", ")", ")", ",", "distance", ")", ")", ";", "}", "else", "{", "int", "min", "=", "number", "(", "rangeSpec", ".", "getMin", "(", ")", ")", ";", "int", "max", "=", "number", "(", "rangeSpec", ".", "getMax", "(", ")", ")", ";", "if", "(", "min", "==", "0", "||", "max", "==", "0", ")", "{", "throw", "new", "AnnisQLSyntaxException", "(", "\"\"", ")", ";", "}", "left", ".", "addJoin", "(", "new", "PointingRelation", "(", "right", ",", "token", "(", "node", ".", "getName", "(", ")", ")", ",", "min", ",", "max", ")", ")", ";", "}", "}", "@", "Override", "public", "void", "caseAIndirectPointingRelationSpec", "(", "AIndirectPointingRelationSpec", "node", ")", "{", "PLingOp", "parent", "=", "(", "PLingOp", ")", "node", ".", "parent", "(", ")", ";", "QueryNode", "left", "=", "lhs", "(", "parent", ")", ";", "QueryNode", "right", "=", "rhs", "(", "parent", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "PointingRelation", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "PointingRelation", ".", "class", ".", "getSimpleName", "(", ")", ")", ")", ";", "left", ".", "addJoin", "(", "new", "PointingRelation", "(", "right", ",", "token", "(", "node", ".", "getName", "(", ")", ")", ")", ")", ";", "}", "@", "Override", "public", "void", "caseAMetaConstraintExpr", "(", "AMetaConstraintExpr", "node", ")", "{", "String", "annoText", "=", "textFromAnnoValue", "(", "node", ".", "getValue", "(", ")", ")", ";", "QueryNode", ".", "TextMatching", "annoTextMatching", "=", "textMatchingFromAnnoValue", "(", "node", ".", "getValue", "(", ")", ")", ";", "token", "(", "node", ".", "getName", "(", ")", ")", ";", "QueryAnnotation", "annotation", "=", "new", "QueryAnnotation", "(", "token", "(", "node", ".", "getNamespace", "(", ")", ")", ",", "token", "(", "node", ".", "getName", "(", ")", ")", ",", "annoText", ",", "annoTextMatching", ")", ";", "metaAnnotations", ".", "add", "(", "annotation", ")", ";", "}", "@", "Override", "public", "void", "caseAAndExpr", "(", "AAndExpr", "node", ")", "{", "for", "(", "PExpr", "expr", ":", "node", ".", "getExpr", "(", ")", ")", "{", "analyzeNestedPath", "(", "expr", ")", ";", "}", "}", "@", "Override", "public", "void", "caseAAnnotationSearchExpr", "(", "AAnnotationSearchExpr", "node", ")", "{", "QueryNode", "target", "=", "newNode", "(", ")", ";", "QueryAnnotation", "anno", "=", "new", "QueryAnnotation", "(", "token", "(", "node", ".", "getAnnoNamespace", "(", ")", ")", ",", "token", "(", "node", ".", "getAnnoType", "(", ")", ")", ")", ";", "if", "(", "node", ".", "getAnnoValue", "(", ")", "!=", "null", ")", "{", "QueryNode", ".", "TextMatching", "textMatching", "=", "textMatchingFromAnnoValue", "(", "node", ".", "getAnnoValue", "(", ")", ")", ";", "String", "text", "=", "textFromAnnoValue", "(", "node", ".", "getAnnoValue", "(", ")", ")", ";", "anno", ".", "setValue", "(", "text", ")", ";", "anno", ".", "setTextMatching", "(", "textMatching", ")", ";", "}", "target", ".", "addNodeAnnotation", "(", "anno", ")", ";", "}", "@", "Override", "public", "void", "caseATextSearchExpr", "(", "ATextSearchExpr", "node", ")", "{", "QueryNode", "context", "=", "newNode", "(", ")", ";", "if", "(", "node", ".", "getTextSpec", "(", ")", "==", "null", ")", "{", "context", ".", "setToken", "(", "true", ")", ";", "}", "else", "if", "(", "node", ".", "getTextSpec", "(", ")", "instanceof", "AWildTextSpec", ")", "{", "context", ".", "setSpannedText", "(", "(", "(", "AWildTextSpec", ")", "node", ".", "getTextSpec", "(", ")", ")", ".", "getText", "(", ")", ".", "getText", "(", ")", ",", "QueryNode", ".", "TextMatching", ".", "EXACT_EQUAL", ")", ";", "}", "else", "if", "(", "node", ".", "getTextSpec", "(", ")", "instanceof", "ARegexpTextSpec", ")", "{", "context", ".", "setSpannedText", "(", "(", "(", "ARegexpTextSpec", ")", "node", ".", "getTextSpec", "(", ")", ")", ".", "getRegexp", "(", ")", ".", "getText", "(", ")", ",", "QueryNode", ".", "TextMatching", ".", "REGEXP_EQUAL", ")", ";", "}", "}", "@", "Override", "public", "void", "caseATextSearchNotEqualExpr", "(", "ATextSearchNotEqualExpr", "node", ")", "{", "QueryNode", "target", "=", "newNode", "(", ")", ";", "if", "(", "node", ".", "getTextSpec", "(", ")", "instanceof", "AWildTextSpec", ")", "{", "target", ".", "setSpannedText", "(", "(", "(", "AWildTextSpec", ")", "node", ".", "getTextSpec", "(", ")", ")", ".", "getText", "(", ")", ".", "getText", "(", ")", ",", "QueryNode", ".", "TextMatching", ".", "EXACT_NOT_EQUAL", ")", ";", "}", "else", "if", "(", "node", ".", "getTextSpec", "(", ")", "instanceof", "ARegexpTextSpec", ")", "{", "target", ".", "setSpannedText", "(", "(", "(", "ARegexpTextSpec", ")", "node", ".", "getTextSpec", "(", ")", ")", ".", "getRegexp", "(", ")", ".", "getText", "(", ")", ",", "QueryNode", ".", "TextMatching", ".", "REGEXP_NOT_EQUAL", ")", ";", "}", "}", "@", "Override", "public", "void", "caseAAnyNodeSearchExpr", "(", "AAnyNodeSearchExpr", "node", ")", "{", "newNode", "(", ")", ";", "}", "private", "QueryNode", "newNode", "(", ")", "{", "QueryNode", "n", "=", "new", "QueryNode", "(", "++", "aliasCount", ")", ";", "n", ".", "setVariable", "(", "\"n\"", "+", "n", ".", "getId", "(", ")", ")", ";", "n", ".", "setMarker", "(", "n", ".", "getVariable", "(", ")", ")", ";", "nodes", ".", "put", "(", "n", ".", "getVariable", "(", ")", ",", "n", ")", ";", "return", "n", ";", "}", "private", "ClauseAnalysis", "analyzeNestedPath", "(", "PExpr", "expr", ")", "{", "ClauseAnalysis", "nested", "=", "new", "ClauseAnalysis", "(", "aliasCount", ",", "metaAnnotations", ",", "nodes", ",", "precedenceBound", ")", ";", "expr", ".", "apply", "(", "nested", ")", ";", "aliasCount", "=", "nested", ".", "aliasCount", ";", "return", "nested", ";", "}", "private", "QueryNode", ".", "Range", "annisRangeFromARangeSpec", "(", "ARangeSpec", "spec", ")", "{", "String", "min", "=", "spec", ".", "getMin", "(", ")", ".", "getText", "(", ")", ";", "String", "max", "=", "spec", ".", "getMax", "(", ")", "!=", "null", "?", "spec", ".", "getMax", "(", ")", ".", "getText", "(", ")", ":", "null", ";", "if", "(", "max", "==", "null", ")", "{", "return", "new", "QueryNode", ".", "Range", "(", "Integer", ".", "parseInt", "(", "min", ")", ",", "Integer", ".", "parseInt", "(", "min", ")", ")", ";", "}", "else", "{", "return", "new", "QueryNode", ".", "Range", "(", "Integer", ".", "parseInt", "(", "min", ")", ",", "Integer", ".", "parseInt", "(", "max", ")", ")", ";", "}", "}", "private", "void", "join", "(", "PLingOp", "node", ",", "Class", "<", "?", "extends", "Join", ">", "type", ")", "{", "QueryNode", "left", "=", "lhs", "(", "node", ")", ";", "QueryNode", "right", "=", "rhs", "(", "node", ")", ";", "Validate", ".", "notNull", "(", "left", ",", "errorLHS", "(", "type", ".", "getSimpleName", "(", ")", ")", ")", ";", "Validate", ".", "notNull", "(", "right", ",", "errorRHS", "(", "type", ".", "getSimpleName", "(", ")", ")", ")", ";", "try", "{", "Constructor", "<", "?", "extends", "Join", ">", "c", "=", "type", ".", "getConstructor", "(", "QueryNode", ".", "class", ")", ";", "Join", "newJoin", "=", "c", ".", "newInstance", "(", "right", ")", ";", "left", ".", "addJoin", "(", "newJoin", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "}", "private", "LinkedList", "<", "QueryAnnotation", ">", "fromEdgeAnnotation", "(", "AEdgeSpec", "spec", ")", "{", "LinkedList", "<", "QueryAnnotation", ">", "result", "=", "new", "LinkedList", "<", "QueryAnnotation", ">", "(", ")", ";", "for", "(", "PEdgeAnnotation", "pAnno", ":", "spec", ".", "getEdgeAnnotation", "(", ")", ")", "{", "AEdgeAnnotation", "anno", "=", "(", "AEdgeAnnotation", ")", "pAnno", ";", "if", "(", "anno", ".", "getValue", "(", ")", "!=", "null", ")", "{", "String", "text", "=", "textFromAnnoValue", "(", "anno", ".", "getValue", "(", ")", ")", ";", "QueryNode", ".", "TextMatching", "textMatching", "=", "textMatchingFromAnnoValue", "(", "anno", ".", "getValue", "(", ")", ")", ";", "result", ".", "add", "(", "new", "QueryAnnotation", "(", "token", "(", "anno", ".", "getNamespace", "(", ")", ")", ",", "token", "(", "anno", ".", "getType", "(", ")", ")", ",", "text", ",", "textMatching", ")", ")", ";", "}", "else", "{", "result", ".", "add", "(", "new", "QueryAnnotation", "(", "token", "(", "anno", ".", "getNamespace", "(", ")", ")", ",", "token", "(", "anno", ".", "getType", "(", ")", ")", ")", ")", ";", "}", "}", "return", "result", ";", "}", "private", "String", "textFromAnnoValue", "(", "PAnnoValue", "value", ")", "{", "Token", "text", "=", "null", ";", "if", "(", "value", "instanceof", "AUnequalAnnoValue", ")", "{", "AUnequalAnnoValue", "val", "=", "(", "AUnequalAnnoValue", ")", "value", ";", "if", "(", "val", ".", "getTextSpec", "(", ")", "instanceof", "AWildTextSpec", ")", "{", "text", "=", "(", "(", "AWildTextSpec", ")", "val", ".", "getTextSpec", "(", ")", ")", ".", "getText", "(", ")", ";", "}", "else", "if", "(", "val", ".", "getTextSpec", "(", ")", "instanceof", "ARegexpTextSpec", ")", "{", "text", "=", "(", "(", "ARegexpTextSpec", ")", "val", ".", "getTextSpec", "(", ")", ")", ".", "getRegexp", "(", ")", ";", "}", "}", "else", "if", "(", "value", "instanceof", "AEqualAnnoValue", ")", "{", "AEqualAnnoValue", "val", "=", "(", "AEqualAnnoValue", ")", "value", ";", "if", "(", "val", ".", "getTextSpec", "(", ")", "instanceof", "AWildTextSpec", ")", "{", "text", "=", "(", "(", "AWildTextSpec", ")", "val", ".", "getTextSpec", "(", ")", ")", ".", "getText", "(", ")", ";", "}", "else", "if", "(", "val", ".", "getTextSpec", "(", ")", "instanceof", "ARegexpTextSpec", ")", "{", "text", "=", "(", "(", "ARegexpTextSpec", ")", "val", ".", "getTextSpec", "(", ")", ")", ".", "getRegexp", "(", ")", ";", "}", "}", "Validate", ".", "notNull", "(", "text", ",", "\"\"", ")", ";", "return", "token", "(", "text", ")", ";", "}", "private", "QueryNode", ".", "TextMatching", "textMatchingFromAnnoValue", "(", "PAnnoValue", "value", ")", "{", "QueryNode", ".", "TextMatching", "textMatching", "=", "null", ";", "if", "(", "value", "instanceof", "AUnequalAnnoValue", ")", "{", "AUnequalAnnoValue", "val", "=", "(", "AUnequalAnnoValue", ")", "value", ";", "if", "(", "val", ".", "getTextSpec", "(", ")", "instanceof", "AWildTextSpec", ")", "{", "textMatching", "=", "QueryNode", ".", "TextMatching", ".", "EXACT_NOT_EQUAL", ";", "}", "else", "if", "(", "val", ".", "getTextSpec", "(", ")", "instanceof", "ARegexpTextSpec", ")", "{", "textMatching", "=", "QueryNode", ".", "TextMatching", ".", "REGEXP_NOT_EQUAL", ";", "}", "}", "else", "if", "(", "value", "instanceof", "AEqualAnnoValue", ")", "{", "AEqualAnnoValue", "val", "=", "(", "AEqualAnnoValue", ")", "value", ";", "if", "(", "val", ".", "getTextSpec", "(", ")", "instanceof", "AWildTextSpec", ")", "{", "textMatching", "=", "QueryNode", ".", "TextMatching", ".", "EXACT_EQUAL", ";", "}", "else", "if", "(", "val", ".", "getTextSpec", "(", ")", "instanceof", "ARegexpTextSpec", ")", "{", "textMatching", "=", "QueryNode", ".", "TextMatching", ".", "REGEXP_EQUAL", ";", "}", "}", "Validate", ".", "notNull", "(", "textMatching", ",", "\"\"", ")", ";", "return", "textMatching", ";", "}", "private", "int", "number", "(", "Token", "token", ")", "{", "return", "Integer", ".", "parseInt", "(", "token", "(", "token", ")", ")", ";", "}", "private", "String", "token", "(", "Token", "token", ")", "{", "return", "token", "!=", "null", "?", "token", ".", "getText", "(", ")", ":", "null", ";", "}", "private", "QueryNode", "lhs", "(", "PLingOp", "node", ")", "{", "String", "tok", "=", "lhsStr", "(", "node", ")", ";", "if", "(", "tok", "==", "null", ")", "{", "return", "null", ";", "}", "return", "nodes", ".", "get", "(", "\"n\"", "+", "tok", ")", ";", "}", "private", "QueryNode", "rhs", "(", "PLingOp", "node", ")", "{", "String", "tok", "=", "rhsStr", "(", "node", ")", ";", "if", "(", "tok", "==", "null", ")", "{", "return", "null", ";", "}", "return", "nodes", ".", "get", "(", "\"n\"", "+", "tok", ")", ";", "}", "private", "String", "lhsStr", "(", "PLingOp", "node", ")", "{", "return", "token", "(", "(", "(", "ALinguisticConstraintExpr", ")", "node", ".", "parent", "(", ")", ")", ".", "getLhs", "(", ")", ")", ";", "}", "private", "String", "rhsStr", "(", "PLingOp", "node", ")", "{", "return", "token", "(", "(", "(", "ALinguisticConstraintExpr", ")", "node", ".", "parent", "(", ")", ")", ".", "getRhs", "(", ")", ")", ";", "}", "private", "String", "errorLHS", "(", "String", "function", ")", "{", "return", "function", "+", "\"\"", ";", "}", "private", "String", "errorRHS", "(", "String", "function", ")", "{", "return", "function", "+", "\"\"", ";", "}", "public", "List", "<", "QueryAnnotation", ">", "getMetaAnnotations", "(", ")", "{", "return", "metaAnnotations", ";", "}", "public", "Collection", "<", "QueryNode", ">", "getNodes", "(", ")", "{", "return", "nodes", ".", "values", "(", ")", ";", "}", "public", "int", "getPrecedenceBound", "(", ")", "{", "return", "precedenceBound", ";", "}", "public", "void", "setPrecedenceBound", "(", "int", "precedenceBound", ")", "{", "this", ".", "precedenceBound", "=", "precedenceBound", ";", "}", "}", "</s>" ]
8,845
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "annis", ".", "sqlgen", ".", "*", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "UnknownExpressionException", "extends", "RuntimeException", "{", "public", "UnknownExpressionException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "UnknownExpressionException", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "public", "UnknownExpressionException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "UnknownExpressionException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "}", "</s>" ]
8,846
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAndExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnnotationSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnyNodeSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALinguisticConstraintExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AMetaConstraintExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AOrExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchNotEqualExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "PExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "DnfTransformer", "extends", "DepthFirstAdapter", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "DnfTransformer", ".", "class", ")", ";", "private", "SearchExpressionCounter", "counter", ";", "private", "DnfNodeRelNumberUpdater", "relNumberUpdater", ";", "@", "Override", "public", "void", "caseStart", "(", "Start", "node", ")", "{", "counter", "=", "new", "SearchExpressionCounter", "(", ")", ";", "node", ".", "apply", "(", "counter", ")", ";", "PExpr", "inDnf", "=", "normalize", "(", "node", ".", "getPExpr", "(", ")", ")", ";", "node", ".", "setPExpr", "(", "inDnf", ")", ";", "relNumberUpdater", "=", "new", "DnfNodeRelNumberUpdater", "(", "counter", ")", ";", "node", ".", "apply", "(", "relNumberUpdater", ")", ";", "log", ".", "debug", "(", "\"dnf", "is:", "\"", "+", "AnnisParser", ".", "dumpTree", "(", "node", ")", ")", ";", "}", "public", "PExpr", "normalize", "(", "PExpr", "expr", ")", "{", "if", "(", "expr", "instanceof", "AAnnotationSearchExpr", "||", "expr", "instanceof", "ATextSearchExpr", "||", "expr", "instanceof", "ATextSearchNotEqualExpr", "||", "expr", "instanceof", "AAnyNodeSearchExpr", "||", "expr", "instanceof", "AMetaConstraintExpr", ")", "{", "return", "clone", "(", "expr", ")", ";", "}", "else", "if", "(", "expr", "instanceof", "ALinguisticConstraintExpr", ")", "{", "return", "(", "PExpr", ")", "expr", ".", "clone", "(", ")", ";", "}", "else", "if", "(", "expr", "instanceof", "AOrExpr", ")", "{", "return", "normalize", "(", "(", "AOrExpr", ")", "expr", ")", ";", "}", "else", "if", "(", "expr", "instanceof", "AAndExpr", ")", "{", "return", "normalize", "(", "(", "AAndExpr", ")", "expr", ")", ";", "}", "throw", "new", "RuntimeException", "(", "\"\"", "+", "expr", ".", "getClass", "(", ")", ")", ";", "}", "public", "PExpr", "clone", "(", "PExpr", "node", ")", "{", "PExpr", "clone", "=", "(", "PExpr", ")", "node", ".", "clone", "(", ")", ";", "counter", ".", "mapSearchExpressionClone", "(", "clone", ",", "node", ")", ";", "return", "clone", ";", "}", "public", "PExpr", "normalize", "(", "AOrExpr", "node", ")", "{", "List", "<", "PExpr", ">", "normalizedChildren", "=", "new", "ArrayList", "<", "PExpr", ">", "(", ")", ";", "for", "(", "PExpr", "expr", ":", "node", ".", "getExpr", "(", ")", ")", "{", "normalizedChildren", ".", "add", "(", "normalize", "(", "expr", ")", ")", ";", "}", "List", "<", "PExpr", ">", "children", "=", "new", "ArrayList", "<", "PExpr", ">", "(", ")", ";", "for", "(", "PExpr", "expr", ":", "normalizedChildren", ")", "{", "if", "(", "expr", "instanceof", "AOrExpr", ")", "{", "log", ".", "debug", "(", "\"\"", ")", ";", "AOrExpr", "or", "=", "(", "AOrExpr", ")", "expr", ";", "for", "(", "PExpr", "expr2", ":", "or", ".", "getExpr", "(", ")", ")", "{", "children", ".", "add", "(", "expr2", ")", ";", "}", "}", "else", "{", "children", ".", "add", "(", "expr", ")", ";", "}", "}", "AOrExpr", "result", "=", "new", "AOrExpr", "(", ")", ";", "result", ".", "setExpr", "(", "children", ")", ";", "return", "result", ";", "}", "public", "PExpr", "normalize", "(", "AAndExpr", "node", ")", "{", "List", "<", "PExpr", ">", "normalizedChildren", "=", "new", "ArrayList", "<", "PExpr", ">", "(", ")", ";", "for", "(", "PExpr", "expr", ":", "node", ".", "getExpr", "(", ")", ")", "{", "normalizedChildren", ".", "add", "(", "normalize", "(", "expr", ")", ")", ";", "}", "List", "<", "AOrExpr", ">", "ors", "=", "new", "ArrayList", "<", "AOrExpr", ">", "(", ")", ";", "List", "<", "PExpr", ">", "children", "=", "new", "ArrayList", "<", "PExpr", ">", "(", ")", ";", "for", "(", "PExpr", "expr", ":", "normalizedChildren", ")", "{", "if", "(", "expr", "instanceof", "AAndExpr", ")", "{", "log", ".", "debug", "(", "\"\"", ")", ";", "AAndExpr", "and", "=", "(", "AAndExpr", ")", "expr", ";", "for", "(", "PExpr", "expr2", ":", "and", ".", "getExpr", "(", ")", ")", "{", "children", ".", "add", "(", "expr2", ")", ";", "}", "}", "else", "if", "(", "expr", "instanceof", "AOrExpr", ")", "{", "ors", ".", "add", "(", "(", "AOrExpr", ")", "expr", ")", ";", "}", "else", "{", "children", ".", "add", "(", "expr", ")", ";", "}", "}", "AAndExpr", "result", "=", "new", "AAndExpr", "(", ")", ";", "result", ".", "setExpr", "(", "children", ")", ";", "if", "(", "ors", ".", "isEmpty", "(", ")", ")", "{", "return", "result", ";", "}", "List", "<", "AAndExpr", ">", "ands", "=", "new", "ArrayList", "<", "AAndExpr", ">", "(", ")", ";", "ands", ".", "add", "(", "result", ")", ";", "List", "<", "AAndExpr", ">", "distributed", "=", "distribute", "(", "ors", ",", "ands", ")", ";", "List", "<", "PExpr", ">", "alternatives", "=", "new", "ArrayList", "<", "PExpr", ">", "(", ")", ";", "alternatives", ".", "addAll", "(", "distributed", ")", ";", "AOrExpr", "or", "=", "new", "AOrExpr", "(", ")", ";", "or", ".", "setExpr", "(", "alternatives", ")", ";", "return", "or", ";", "}", "public", "List", "<", "AAndExpr", ">", "distribute", "(", "List", "<", "AOrExpr", ">", "ors", ",", "List", "<", "AAndExpr", ">", "ands", ")", "{", "List", "<", "AAndExpr", ">", "res", "=", "new", "ArrayList", "<", "AAndExpr", ">", "(", ")", ";", "AOrExpr", "or", "=", "ors", ".", "get", "(", "ors", ".", "size", "(", ")", "-", "1", ")", ";", "ors", ".", "remove", "(", "or", ")", ";", "log", ".", "debug", "(", "\"\"", ")", ";", "for", "(", "PExpr", "expr", ":", "or", ".", "getExpr", "(", ")", ")", "{", "for", "(", "AAndExpr", "and", ":", "ands", ")", "{", "List", "<", "PExpr", ">", "alternative", "=", "new", "ArrayList", "<", "PExpr", ">", "(", ")", ";", "for", "(", "PExpr", "factor", ":", "and", ".", "getExpr", "(", ")", ")", "{", "alternative", ".", "add", "(", "clone", "(", "factor", ")", ")", ";", "}", "PExpr", "clone", "=", "(", "PExpr", ")", "expr", ".", "clone", "(", ")", ";", "if", "(", "clone", "instanceof", "AAndExpr", ")", "{", "AAndExpr", "clonedAnd", "=", "(", "AAndExpr", ")", "clone", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "clonedAnd", ".", "getExpr", "(", ")", ".", "size", "(", ")", ";", "++", "i", ")", "{", "PExpr", "original", "=", "(", "(", "AAndExpr", ")", "expr", ")", ".", "getExpr", "(", ")", ".", "get", "(", "i", ")", ";", "counter", ".", "mapSearchExpressionClone", "(", "clonedAnd", ".", "getExpr", "(", ")", ".", "get", "(", "i", ")", ",", "original", ")", ";", "}", "}", "counter", ".", "mapSearchExpressionClone", "(", "clone", ",", "expr", ")", ";", "alternative", ".", "add", "(", "clone", ")", ";", "AAndExpr", "newAnd", "=", "new", "AAndExpr", "(", ")", ";", "newAnd", ".", "setExpr", "(", "alternative", ")", ";", "res", ".", "add", "(", "(", "AAndExpr", ")", "normalize", "(", "newAnd", ")", ")", ";", "}", "}", "if", "(", "ors", ".", "isEmpty", "(", ")", ")", "{", "return", "res", ";", "}", "else", "{", "return", "distribute", "(", "ors", ",", "res", ")", ";", "}", "}", "public", "List", "<", "PExpr", ">", "listClauses", "(", "Start", "statement", ")", "throws", "UnknownExpressionException", "{", "List", "<", "PExpr", ">", "clauses", "=", "new", "ArrayList", "<", "PExpr", ">", "(", ")", ";", "PExpr", "expr", "=", "statement", ".", "getPExpr", "(", ")", ";", "if", "(", "expr", "instanceof", "AOrExpr", ")", "{", "List", "<", "PExpr", ">", "children", "=", "(", "(", "AOrExpr", ")", "expr", ")", ".", "getExpr", "(", ")", ";", "for", "(", "PExpr", "child", ":", "children", ")", "{", "clauses", ".", "add", "(", "child", ")", ";", "}", "}", "else", "{", "clauses", ".", "add", "(", "expr", ")", ";", "}", "return", "clauses", ";", "}", "public", "int", "getPosition", "(", "PExpr", "expr", ")", "{", "return", "counter", ".", "getPosition", "(", "expr", ")", ";", "}", "public", "SearchExpressionCounter", "getCounter", "(", ")", "{", "return", "counter", ";", "}", "public", "void", "setCounter", "(", "SearchExpressionCounter", "counter", ")", "{", "this", ".", "counter", "=", "counter", ";", "}", "}", "</s>" ]
8,847
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "annis", ".", "exceptions", ".", "AnnisQLSemanticsException", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAndExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnnotationSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnyNodeSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALinguisticConstraintExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchNotEqualExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "PExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "import", "annis", ".", "ql", ".", "node", ".", "TDigits", ";", "public", "class", "QueryValidator", "extends", "DepthFirstAdapter", "{", "private", "DnfTransformer", "dnfTransformer", ";", "public", "QueryValidator", "(", ")", "{", "dnfTransformer", "=", "new", "DnfTransformer", "(", ")", ";", "}", "@", "Override", "public", "void", "caseStart", "(", "Start", "node", ")", "{", "Start", "normalized", "=", "(", "Start", ")", "node", ".", "clone", "(", ")", ";", "normalized", ".", "apply", "(", "dnfTransformer", ")", ";", "normalized", ".", "getPExpr", "(", ")", ".", "apply", "(", "this", ")", ";", "}", "@", "Override", "public", "void", "caseALinguisticConstraintExpr", "(", "ALinguisticConstraintExpr", "node", ")", "{", "throw", "new", "AnnisQLSemanticsException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "caseAAndExpr", "(", "AAndExpr", "node", ")", "{", "Set", "<", "Integer", ">", "expected", "=", "new", "HashSet", "<", "Integer", ">", "(", ")", ";", "List", "<", "Set", "<", "Integer", ">", ">", "connectedNodeClasses", "=", "new", "ArrayList", "<", "Set", "<", "Integer", ">", ">", "(", ")", ";", "for", "(", "PExpr", "expr", ":", "node", ".", "getExpr", "(", ")", ")", "{", "if", "(", "expr", "instanceof", "ATextSearchExpr", "||", "expr", "instanceof", "ATextSearchNotEqualExpr", "||", "expr", "instanceof", "AAnnotationSearchExpr", "||", "expr", "instanceof", "AAnyNodeSearchExpr", ")", "{", "expected", ".", "add", "(", "dnfTransformer", ".", "getPosition", "(", "expr", ")", ")", ";", "}", "if", "(", "expr", "instanceof", "ALinguisticConstraintExpr", ")", "{", "ALinguisticConstraintExpr", "lingOp", "=", "(", "ALinguisticConstraintExpr", ")", "expr", ";", "if", "(", "lingOp", ".", "getRhs", "(", ")", "==", "null", ")", "{", "continue", ";", "}", "int", "lhs", "=", "digits", "(", "lingOp", ".", "getLhs", "(", ")", ")", ";", "int", "rhs", "=", "digits", "(", "lingOp", ".", "getRhs", "(", ")", ")", ";", "Set", "<", "Integer", ">", "connectedNodeClass", "=", "new", "HashSet", "<", "Integer", ">", "(", ")", ";", "connectedNodeClass", ".", "add", "(", "lhs", ")", ";", "connectedNodeClass", ".", "add", "(", "rhs", ")", ";", "connectedNodeClasses", ".", "add", "(", "connectedNodeClass", ")", ";", "}", "}", "if", "(", "expected", ".", "size", "(", ")", "==", "1", ")", "{", "if", "(", "connectedNodeClasses", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "else", "{", "throw", "new", "AnnisQLSemanticsException", "(", "\"\"", ")", ";", "}", "}", "if", "(", "connectedNodeClasses", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "AnnisQLSemanticsException", "(", "\"\"", ")", ";", "}", "connectedNodeClasses", "=", "collapse", "(", "connectedNodeClasses", ")", ";", "if", "(", "connectedNodeClasses", ".", "size", "(", ")", ">", "1", ")", "{", "HashSet", "<", "Integer", ">", "actual", "=", "new", "HashSet", "<", "Integer", ">", "(", ")", ";", "for", "(", "Set", "<", "Integer", ">", "group", ":", "connectedNodeClasses", ")", "{", "actual", ".", "addAll", "(", "group", ")", ";", "}", "if", "(", "!", "actual", ".", "containsAll", "(", "expected", ")", ")", "{", "throw", "new", "AnnisQLSemanticsException", "(", "\"\"", ")", ";", "}", "else", "if", "(", "!", "expected", ".", "containsAll", "(", "actual", ")", ")", "{", "throw", "new", "AnnisQLSemanticsException", "(", "\"\"", ")", ";", "}", "else", "{", "throw", "new", "AnnisQLSemanticsException", "(", "\"\"", ")", ";", "}", "}", "Set", "<", "Integer", ">", "actual", "=", "connectedNodeClasses", ".", "get", "(", "0", ")", ";", "boolean", "connected", "=", "expected", ".", "size", "(", ")", "==", "actual", ".", "size", "(", ")", "&&", "actual", ".", "containsAll", "(", "expected", ")", ";", "if", "(", "!", "connected", ")", "{", "if", "(", "!", "actual", ".", "containsAll", "(", "expected", ")", ")", "{", "throw", "new", "AnnisQLSemanticsException", "(", "\"\"", ")", ";", "}", "else", "{", "throw", "new", "AnnisQLSemanticsException", "(", "\"\"", ")", ";", "}", "}", "}", "private", "List", "<", "Set", "<", "Integer", ">", ">", "collapse", "(", "List", "<", "Set", "<", "Integer", ">", ">", "classes", ")", "{", "int", "size", "=", "classes", ".", "size", "(", ")", ";", "if", "(", "size", "==", "1", ")", "{", "return", "classes", ";", "}", "Set", "<", "Integer", ">", "first", "=", "classes", ".", "get", "(", "0", ")", ";", "List", "<", "Integer", ">", "remove", "=", "new", "ArrayList", "<", "Integer", ">", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "size", ";", "++", "i", ")", "{", "Set", "<", "Integer", ">", "next", "=", "classes", ".", "get", "(", "i", ")", ";", "for", "(", "int", "ref", ":", "next", ")", "{", "if", "(", "first", ".", "contains", "(", "ref", ")", ")", "{", "remove", ".", "add", "(", "i", ")", ";", "first", ".", "addAll", "(", "next", ")", ";", "break", ";", "}", "}", "}", "for", "(", "int", "i", "=", "remove", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "Integer", "index", "=", "remove", ".", "get", "(", "i", ")", ";", "classes", ".", "remove", "(", "classes", ".", "get", "(", "index", ")", ")", ";", "}", "if", "(", "classes", ".", "size", "(", ")", "==", "size", ")", "{", "return", "classes", ";", "}", "return", "collapse", "(", "classes", ")", ";", "}", "private", "int", "digits", "(", "TDigits", "lhs", ")", "{", "return", "Integer", ".", "parseInt", "(", "lhs", ".", "getText", "(", ")", ")", ";", "}", "}", "</s>" ]
8,848
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnnotationSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnyNodeSearchExpr", ";", "public", "class", "NodeSearchNormalizer", "extends", "DepthFirstAdapter", "{", "@", "Override", "public", "void", "caseAAnnotationSearchExpr", "(", "AAnnotationSearchExpr", "node", ")", "{", "String", "type", "=", "node", ".", "getAnnoType", "(", ")", ".", "getText", "(", ")", ";", "if", "(", "type", ".", "equals", "(", "\"node\"", ")", ")", "{", "AAnyNodeSearchExpr", "anyNodeSearchExpr", "=", "new", "AAnyNodeSearchExpr", "(", ")", ";", "node", ".", "replaceBy", "(", "anyNodeSearchExpr", ")", ";", "}", "}", "}", "</s>" ]
8,849
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Properties", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "QueryData", "implements", "Cloneable", "{", "private", "static", "final", "org", ".", "slf4j", ".", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "QueryData", ".", "class", ")", ";", "private", "List", "<", "List", "<", "QueryNode", ">", ">", "alternatives", ";", "private", "List", "<", "Long", ">", "corpusList", ";", "private", "List", "<", "Long", ">", "documents", ";", "private", "List", "<", "QueryAnnotation", ">", "metaData", ";", "private", "int", "maxWidth", ";", "private", "Set", "<", "Object", ">", "extensions", ";", "private", "HashMap", "<", "Long", ",", "Properties", ">", "corpusConfiguration", ";", "public", "QueryData", "(", ")", "{", "alternatives", "=", "new", "ArrayList", "<", "List", "<", "QueryNode", ">", ">", "(", ")", ";", "corpusList", "=", "new", "ArrayList", "<", "Long", ">", "(", ")", ";", "documents", "=", "new", "ArrayList", "<", "Long", ">", "(", ")", ";", "metaData", "=", "new", "ArrayList", "<", "QueryAnnotation", ">", "(", ")", ";", "extensions", "=", "new", "HashSet", "<", "Object", ">", "(", ")", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "Iterator", "<", "List", "<", "QueryNode", ">", ">", "itOr", "=", "getAlternatives", "(", ")", ".", "iterator", "(", ")", ";", "while", "(", "itOr", ".", "hasNext", "(", ")", ")", "{", "List", "<", "QueryNode", ">", "nextNodes", "=", "itOr", ".", "next", "(", ")", ";", "Iterator", "<", "QueryNode", ">", "itAnd", "=", "nextNodes", ".", "iterator", "(", ")", ";", "while", "(", "itAnd", ".", "hasNext", "(", ")", ")", "{", "sb", ".", "append", "(", "\"t\"", ")", ".", "append", "(", "itAnd", ".", "next", "(", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "if", "(", "itAnd", ".", "hasNext", "(", ")", ")", "{", "sb", ".", "append", "(", "\"tAND\"", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "}", "if", "(", "itOr", ".", "hasNext", "(", ")", ")", "{", "sb", ".", "append", "(", "\"OR\"", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "}", "Iterator", "<", "QueryAnnotation", ">", "itMeta", "=", "getMetaData", "(", ")", ".", "iterator", "(", ")", ";", "if", "(", "itMeta", ".", "hasNext", "(", ")", ")", "{", "sb", ".", "append", "(", "\"META\"", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "while", "(", "itMeta", ".", "hasNext", "(", ")", ")", "{", "sb", ".", "append", "(", "\"t\"", ")", ".", "append", "(", "itMeta", ".", "next", "(", ")", ".", "toString", "(", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "if", "(", "!", "extensions", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "\"EXTENSIONSn\"", ")", ";", "}", "for", "(", "Object", "extension", ":", "extensions", ")", "{", "String", "toString", "=", "extension", ".", "toString", "(", ")", ";", "if", "(", "!", "\"\"", ".", "equals", "(", "toString", ")", ")", "sb", ".", "append", "(", "\"t\"", "+", "toString", "+", "\"n\"", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "List", "<", "List", "<", "QueryNode", ">", ">", "getAlternatives", "(", ")", "{", "return", "alternatives", ";", "}", "public", "void", "setAlternatives", "(", "List", "<", "List", "<", "QueryNode", ">", ">", "alternatives", ")", "{", "this", ".", "alternatives", "=", "alternatives", ";", "}", "public", "List", "<", "Long", ">", "getCorpusList", "(", ")", "{", "return", "corpusList", ";", "}", "public", "void", "setCorpusList", "(", "List", "<", "Long", ">", "corpusList", ")", "{", "this", ".", "corpusList", "=", "corpusList", ";", "}", "public", "List", "<", "QueryAnnotation", ">", "getMetaData", "(", ")", "{", "return", "metaData", ";", "}", "public", "void", "setMetaData", "(", "List", "<", "QueryAnnotation", ">", "metaData", ")", "{", "this", ".", "metaData", "=", "metaData", ";", "}", "public", "int", "getMaxWidth", "(", ")", "{", "return", "maxWidth", ";", "}", "public", "void", "setMaxWidth", "(", "int", "maxWidth", ")", "{", "this", ".", "maxWidth", "=", "maxWidth", ";", "}", "public", "boolean", "addAlternative", "(", "List", "<", "QueryNode", ">", "nodes", ")", "{", "return", "alternatives", ".", "add", "(", "nodes", ")", ";", "}", "public", "boolean", "addMetaAnnotations", "(", "List", "<", "QueryAnnotation", ">", "annotations", ")", "{", "return", "metaData", ".", "addAll", "(", "annotations", ")", ";", "}", "@", "Override", "public", "QueryData", "clone", "(", ")", "{", "try", "{", "return", "(", "QueryData", ")", "super", ".", "clone", "(", ")", ";", "}", "catch", "(", "CloneNotSupportedException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "throw", "new", "InternalError", "(", "\"\"", ")", ";", "}", "}", "public", "List", "<", "Long", ">", "getDocuments", "(", ")", "{", "return", "documents", ";", "}", "public", "void", "setDocuments", "(", "List", "<", "Long", ">", "documents", ")", "{", "this", ".", "documents", "=", "documents", ";", "}", "public", "Set", "<", "Object", ">", "getExtensions", "(", ")", "{", "return", "extensions", ";", "}", "public", "<", "T", ">", "List", "<", "T", ">", "getExtensions", "(", "Class", "<", "T", ">", "clazz", ")", "{", "List", "<", "T", ">", "result", "=", "new", "LinkedList", "<", "T", ">", "(", ")", ";", "for", "(", "Object", "o", ":", "extensions", ")", "{", "if", "(", "clazz", ".", "isInstance", "(", "o", ")", ")", "{", "result", ".", "add", "(", "(", "T", ")", "o", ")", ";", "}", "}", "return", "result", ";", "}", "public", "boolean", "addExtension", "(", "Object", "extension", ")", "{", "return", "extensions", ".", "add", "(", "extension", ")", ";", "}", "public", "HashMap", "<", "Long", ",", "Properties", ">", "getCorpusConfiguration", "(", ")", "{", "return", "corpusConfiguration", ";", "}", "public", "void", "setCorpusConfiguration", "(", "HashMap", "<", "Long", ",", "Properties", ">", "corpusConfiguration", ")", "{", "this", ".", "corpusConfiguration", "=", "corpusConfiguration", ";", "}", "}", "</s>" ]
8,850
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnnotationSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AEqualAnnoValue", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchNotEqualExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AUnequalAnnoValue", ";", "import", "annis", ".", "ql", ".", "node", ".", "PAnnoValue", ";", "public", "class", "TokenSearchNormalizer", "extends", "DepthFirstAdapter", "{", "@", "Override", "public", "void", "caseAAnnotationSearchExpr", "(", "AAnnotationSearchExpr", "node", ")", "{", "String", "type", "=", "node", ".", "getAnnoType", "(", ")", ".", "getText", "(", ")", ";", "if", "(", "type", ".", "equals", "(", "\"tok\"", ")", ")", "{", "PAnnoValue", "annoValue", "=", "node", ".", "getAnnoValue", "(", ")", ";", "if", "(", "annoValue", "!=", "null", "&&", "annoValue", "instanceof", "AEqualAnnoValue", ")", "{", "ATextSearchExpr", "textSearchExpr", "=", "new", "ATextSearchExpr", "(", ")", ";", "textSearchExpr", ".", "setTextSpec", "(", "(", "(", "AEqualAnnoValue", ")", "annoValue", ")", ".", "getTextSpec", "(", ")", ")", ";", "node", ".", "replaceBy", "(", "textSearchExpr", ")", ";", "}", "else", "if", "(", "annoValue", "!=", "null", "&&", "annoValue", "instanceof", "AUnequalAnnoValue", ")", "{", "ATextSearchNotEqualExpr", "textSearchExpr", "=", "new", "ATextSearchNotEqualExpr", "(", ")", ";", "textSearchExpr", ".", "setTextSpec", "(", "(", "(", "AUnequalAnnoValue", ")", "annoValue", ")", ".", "getTextSpec", "(", ")", ")", ";", "node", ".", "replaceBy", "(", "textSearchExpr", ")", ";", "}", "else", "{", "ATextSearchExpr", "textSearchExpr", "=", "new", "ATextSearchExpr", "(", ")", ";", "textSearchExpr", ".", "setTextSpec", "(", "null", ")", ";", "node", ".", "replaceBy", "(", "textSearchExpr", ")", ";", "}", "}", "}", "}", "</s>" ]
8,851
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "annis", ".", "exceptions", ".", "AnnisQLSyntaxException", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "io", ".", "PushbackReader", ";", "import", "java", ".", "io", ".", "StringReader", ";", "import", "java", ".", "io", ".", "StringWriter", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "lexer", ".", "Lexer", ";", "import", "annis", ".", "ql", ".", "lexer", ".", "LexerException", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "AnnisParser", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AnnisParser", ".", "class", ")", ";", "public", "static", "class", "InternalParser", "{", "public", "Start", "parse", "(", "String", "input", ")", "throws", "ParserException", ",", "LexerException", ",", "IOException", "{", "return", "new", "Parser", "(", "new", "Lexer", "(", "new", "PushbackReader", "(", "new", "StringReader", "(", "input", ")", ",", "3000", ")", ")", ")", ".", "parse", "(", ")", ";", "}", "}", "private", "InternalParser", "internalParser", ";", "private", "List", "<", "DepthFirstAdapter", ">", "postProcessors", ";", "public", "AnnisParser", "(", ")", "{", "postProcessors", "=", "new", "ArrayList", "<", "DepthFirstAdapter", ">", "(", ")", ";", "postProcessors", ".", "add", "(", "new", "NodeSearchNormalizer", "(", ")", ")", ";", "postProcessors", ".", "add", "(", "new", "TokenSearchNormalizer", "(", ")", ")", ";", "postProcessors", ".", "add", "(", "new", "QueryValidator", "(", ")", ")", ";", "internalParser", "=", "new", "InternalParser", "(", ")", ";", "}", "public", "Start", "parse", "(", "String", "annisQuery", ")", "{", "try", "{", "log", ".", "debug", "(", "\"\"", "+", "annisQuery", ")", ";", "Start", "start", "=", "getInternalParser", "(", ")", ".", "parse", "(", "annisQuery", ")", ";", "for", "(", "DepthFirstAdapter", "postProcessor", ":", "getPostProcessors", "(", ")", ")", "{", "log", ".", "debug", "(", "\"\"", "+", "postProcessor", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "start", ".", "apply", "(", "postProcessor", ")", ";", "}", "log", ".", "debug", "(", "\"\"", "+", "dumpTree", "(", "start", ")", ")", ";", "return", "start", ";", "}", "catch", "(", "ParserException", "e", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "annisQuery", ",", "e", ")", ";", "throw", "new", "AnnisQLSyntaxException", "(", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "}", "catch", "(", "LexerException", "e", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "annisQuery", ",", "e", ")", ";", "throw", "new", "AnnisQLSyntaxException", "(", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "annisQuery", ",", "e", ")", ";", "throw", "new", "AnnisQLSyntaxException", "(", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "}", "}", "public", "String", "dumpTree", "(", "String", "annisQuery", ")", "{", "return", "dumpTree", "(", "parse", "(", "annisQuery", ")", ")", ";", "}", "public", "static", "String", "dumpTree", "(", "Start", "start", ")", "{", "try", "{", "StringWriter", "result", "=", "new", "StringWriter", "(", ")", ";", "start", ".", "apply", "(", "new", "TreeDumper", "(", "new", "PrintWriter", "(", "result", ")", ")", ")", ";", "return", "result", ".", "toString", "(", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "String", "errorMessage", "=", "\"\"", ";", "log", ".", "warn", "(", "errorMessage", ",", "e", ")", ";", "return", "errorMessage", ";", "}", "}", "public", "List", "<", "DepthFirstAdapter", ">", "getPostProcessors", "(", ")", "{", "return", "postProcessors", ";", "}", "public", "void", "setPostProcessors", "(", "List", "<", "DepthFirstAdapter", ">", "postProcessors", ")", "{", "this", ".", "postProcessors", "=", "postProcessors", ";", "}", "protected", "void", "setInternalParser", "(", "InternalParser", "parser", ")", "{", "this", ".", "internalParser", "=", "parser", ";", "}", "protected", "InternalParser", "getInternalParser", "(", ")", "{", "return", "internalParser", ";", "}", "}", "</s>" ]
8,852
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAndExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ADominanceLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "AIdentityLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALinguisticConstraintExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "APointingRelationLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ASiblingLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "Node", ";", "import", "annis", ".", "ql", ".", "node", ".", "PExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "PLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "TDigits", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "LinkedHashMap", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Map", ".", "Entry", ";", "import", "org", ".", "springframework", ".", "util", ".", "Assert", ";", "public", "class", "NodeRelationNormalizer", "extends", "DepthFirstAdapter", "{", "@", "Override", "public", "void", "caseAAndExpr", "(", "AAndExpr", "node", ")", "{", "boolean", "check", "=", "true", ";", "while", "(", "check", ")", "{", "check", "=", "false", ";", "SearchExpressionCounter", "counter", "=", "new", "SearchExpressionCounter", "(", ")", ";", "node", ".", "apply", "(", "counter", ")", ";", "RelationCollector", "relcheck", "=", "new", "RelationCollector", "(", ")", ";", "node", ".", "apply", "(", "relcheck", ")", ";", "for", "(", "Entry", "<", "String", ",", "List", "<", "ALinguisticConstraintExpr", ">", ">", "e", ":", "relcheck", ".", "getIsIn", "(", ")", ".", "entrySet", "(", ")", ")", "{", "if", "(", "e", ".", "getValue", "(", ")", ".", "size", "(", ")", ">", "1", ")", "{", "ALinguisticConstraintExpr", "relation", "=", "e", ".", "getValue", "(", ")", ".", "get", "(", "0", ")", ";", "Assert", ".", "notNull", "(", "relation", ".", "getRhs", "(", ")", ",", "\"\"", ")", ";", "boolean", "leftSide", "=", "true", ";", "if", "(", "relation", ".", "getRhs", "(", ")", ".", "getText", "(", ")", ".", "equals", "(", "e", ".", "getKey", "(", ")", ")", ")", "{", "leftSide", "=", "false", ";", "}", "split", "(", "node", ",", "relation", ",", "counter", ",", "leftSide", ")", ";", "check", "=", "true", ";", "break", ";", "}", "}", "}", "}", "public", "void", "split", "(", "AAndExpr", "expr", ",", "ALinguisticConstraintExpr", "relation", ",", "SearchExpressionCounter", "counter", ",", "boolean", "replaceLeft", ")", "{", "if", "(", "relation", ".", "getRhs", "(", ")", "==", "null", ")", "{", "return", ";", "}", "int", "oldId", "=", "-", "1", ";", "int", "newId", "=", "counter", ".", "getCount", "(", ")", "+", "1", ";", "ALinguisticConstraintExpr", "updatedRelation", "=", "(", "ALinguisticConstraintExpr", ")", "relation", ".", "clone", "(", ")", ";", "if", "(", "replaceLeft", ")", "{", "oldId", "=", "Integer", ".", "parseInt", "(", "relation", ".", "getLhs", "(", ")", ".", "getText", "(", ")", ")", ";", "updatedRelation", ".", "getLhs", "(", ")", ".", "setText", "(", "\"\"", "+", "newId", ")", ";", "}", "else", "{", "oldId", "=", "Integer", ".", "parseInt", "(", "relation", ".", "getRhs", "(", ")", ".", "getText", "(", ")", ")", ";", "updatedRelation", ".", "getRhs", "(", ")", ".", "setText", "(", "\"\"", "+", "newId", ")", ";", "}", "LinkedList", "<", "PExpr", ">", "result", "=", "expr", ".", "getExpr", "(", ")", ";", "Node", "nodeToDuplicate", "=", "counter", ".", "getSearchExpression", "(", "oldId", ")", ";", "Node", "duplicatedNode", "=", "(", "Node", ")", "nodeToDuplicate", ".", "clone", "(", ")", ";", "result", ".", "add", "(", "(", "PExpr", ")", "duplicatedNode", ")", ";", "result", ".", "remove", "(", "relation", ")", ";", "result", ".", "add", "(", "updatedRelation", ")", ";", "ALinguisticConstraintExpr", "newIdentityRelation", "=", "new", "ALinguisticConstraintExpr", "(", ")", ";", "newIdentityRelation", ".", "setLhs", "(", "new", "TDigits", "(", "\"\"", "+", "oldId", ")", ")", ";", "newIdentityRelation", ".", "setLingOp", "(", "new", "AIdentityLingOp", "(", ")", ")", ";", "newIdentityRelation", ".", "setRhs", "(", "new", "TDigits", "(", "\"\"", "+", "newId", ")", ")", ";", "result", ".", "add", "(", "newIdentityRelation", ")", ";", "}", "public", "static", "class", "RelationCollector", "extends", "DepthFirstAdapter", "{", "private", "Map", "<", "String", ",", "List", "<", "ALinguisticConstraintExpr", ">", ">", "isIn", "=", "new", "LinkedHashMap", "<", "String", ",", "List", "<", "ALinguisticConstraintExpr", ">", ">", "(", ")", ";", "@", "Override", "public", "void", "caseALinguisticConstraintExpr", "(", "ALinguisticConstraintExpr", "node", ")", "{", "PLingOp", "op", "=", "node", ".", "getLingOp", "(", ")", ";", "String", "left", "=", "node", ".", "getLhs", "(", ")", ".", "getText", "(", ")", ";", "String", "right", "=", "null", ";", "if", "(", "node", ".", "getRhs", "(", ")", "!=", "null", ")", "{", "right", "=", "node", ".", "getRhs", "(", ")", ".", "getText", "(", ")", ";", "}", "if", "(", "op", "instanceof", "ADominanceLingOp", "||", "op", "instanceof", "APointingRelationLingOp", "||", "op", "instanceof", "ASiblingLingOp", ")", "{", "if", "(", "isIn", ".", "get", "(", "left", ")", "==", "null", ")", "{", "isIn", ".", "put", "(", "left", ",", "new", "ArrayList", "<", "ALinguisticConstraintExpr", ">", "(", ")", ")", ";", "}", "isIn", ".", "get", "(", "left", ")", ".", "add", "(", "node", ")", ";", "if", "(", "right", "!=", "null", ")", "{", "if", "(", "isIn", ".", "get", "(", "right", ")", "==", "null", ")", "{", "isIn", ".", "put", "(", "right", ",", "new", "ArrayList", "<", "ALinguisticConstraintExpr", ">", "(", ")", ")", ";", "}", "isIn", ".", "get", "(", "right", ")", ".", "add", "(", "node", ")", ";", "}", "}", "}", "public", "Map", "<", "String", ",", "List", "<", "ALinguisticConstraintExpr", ">", ">", "getIsIn", "(", ")", "{", "return", "isIn", ";", "}", "}", "}", "</s>" ]
8,853
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchNotEqualExpr", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnnotationSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnyNodeSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "Node", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "public", "class", "SearchExpressionCounter", "extends", "DepthFirstAdapter", "{", "private", "Map", "<", "Node", ",", "Integer", ">", "exprToPos", ";", "private", "Map", "<", "Integer", ",", "Node", ">", "posToExpr", ";", "private", "int", "count", ";", "public", "SearchExpressionCounter", "(", ")", "{", "this", ".", "count", "=", "0", ";", "this", ".", "exprToPos", "=", "new", "HashMap", "<", "Node", ",", "Integer", ">", "(", ")", ";", "this", ".", "posToExpr", "=", "new", "HashMap", "<", "Integer", ",", "Node", ">", "(", ")", ";", "}", "public", "int", "getCount", "(", ")", "{", "return", "count", ";", "}", "public", "Node", "getSearchExpression", "(", "int", "i", ")", "{", "return", "posToExpr", ".", "get", "(", "i", ")", ";", "}", "public", "int", "getPosition", "(", "Node", "expr", ")", "{", "if", "(", "exprToPos", ".", "containsKey", "(", "expr", ")", ")", "{", "return", "exprToPos", ".", "get", "(", "expr", ")", ";", "}", "else", "{", "return", "-", "1", ";", "}", "}", "public", "void", "mapSearchExpressionClone", "(", "Node", "clone", ",", "Node", "original", ")", "{", "if", "(", "!", "(", "original", "instanceof", "ATextSearchExpr", "||", "original", "instanceof", "ATextSearchNotEqualExpr", "||", "original", "instanceof", "AAnnotationSearchExpr", "||", "original", "instanceof", "AAnyNodeSearchExpr", ")", ")", "{", "return", ";", "}", "int", "pos", "=", "getPosition", "(", "original", ")", ";", "if", "(", "pos", "==", "-", "1", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "exprToPos", ".", "put", "(", "clone", ",", "pos", ")", ";", "posToExpr", ".", "put", "(", "pos", ",", "clone", ")", ";", "}", "public", "void", "setSearchPosition", "(", "Node", "node", ",", "int", "pos", ")", "{", "exprToPos", ".", "put", "(", "node", ",", "pos", ")", ";", "posToExpr", ".", "put", "(", "pos", ",", "node", ")", ";", "}", "@", "Override", "public", "void", "caseAAnnotationSearchExpr", "(", "AAnnotationSearchExpr", "node", ")", "{", "addSearchExpr", "(", "node", ")", ";", "}", "@", "Override", "public", "void", "caseATextSearchExpr", "(", "ATextSearchExpr", "node", ")", "{", "addSearchExpr", "(", "node", ")", ";", "}", "@", "Override", "public", "void", "caseATextSearchNotEqualExpr", "(", "ATextSearchNotEqualExpr", "node", ")", "{", "addSearchExpr", "(", "node", ")", ";", "}", "@", "Override", "public", "void", "caseAAnyNodeSearchExpr", "(", "AAnyNodeSearchExpr", "node", ")", "{", "addSearchExpr", "(", "node", ")", ";", "}", "private", "void", "addSearchExpr", "(", "Node", "node", ")", "{", "++", "count", ";", "exprToPos", ".", "put", "(", "node", ",", "count", ")", ";", "posToExpr", ".", "put", "(", "count", ",", "node", ")", ";", "}", "}", "</s>" ]
8,854
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "node", ".", "Node", ";", "import", "annis", ".", "ql", ".", "node", ".", "Token", ";", "public", "class", "TreeDumper", "extends", "DepthFirstAdapter", "{", "private", "int", "depth", "=", "0", ";", "private", "PrintWriter", "out", ";", "public", "TreeDumper", "(", "PrintWriter", "out", ")", "{", "this", ".", "out", "=", "out", ";", "}", "public", "void", "defaultCase", "(", "Node", "node", ")", "{", "indent", "(", ")", ";", "out", ".", "println", "(", "(", "(", "Token", ")", "node", ")", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "defaultIn", "(", "Node", "node", ")", "{", "indent", "(", ")", ";", "printNodeName", "(", "node", ")", ";", "out", ".", "println", "(", ")", ";", "depth", "=", "depth", "+", "1", ";", "}", "public", "void", "defaultOut", "(", "Node", "node", ")", "{", "depth", "=", "depth", "-", "1", ";", "out", ".", "flush", "(", ")", ";", "}", "private", "void", "printNodeName", "(", "Node", "node", ")", "{", "String", "fullName", "=", "node", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "String", "name", "=", "fullName", ".", "substring", "(", "fullName", ".", "lastIndexOf", "(", "'.'", ")", "+", "1", ")", ";", "out", ".", "print", "(", "name", ")", ";", "}", "private", "void", "indent", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "depth", ";", "i", "++", ")", "out", ".", "write", "(", "\"", "\"", ")", ";", "}", "}", "</s>" ]
8,855
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "node", ".", "PExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "QueryAnalysis", "{", "private", "final", "static", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "QueryAnalysis", ".", "class", ")", ";", "private", "boolean", "normalizeNodesInEdgeRelations", ";", "private", "DnfTransformer", "dummyDnfTransformer", ";", "private", "ClauseAnalysis", "dummyClauseAnalysis", ";", "private", "NodeRelationNormalizer", "nodeRelationNormalizer", ";", "public", "QueryData", "analyzeQuery", "(", "Start", "statement", ",", "List", "<", "Long", ">", "corpusList", ")", "{", "QueryData", "queryData", "=", "new", "QueryData", "(", ")", ";", "queryData", ".", "setCorpusList", "(", "new", "ArrayList", "<", "Long", ">", "(", "corpusList", ")", ")", ";", "DnfTransformer", "dnfTransformer", "=", "getDnfTransformer", "(", ")", ";", "statement", ".", "apply", "(", "dnfTransformer", ")", ";", "List", "<", "PExpr", ">", "clauses", "=", "dnfTransformer", ".", "listClauses", "(", "statement", ")", ";", "log", ".", "debug", "(", "clauses", ".", "size", "(", ")", "+", "\"\"", ")", ";", "for", "(", "PExpr", "clause", ":", "clauses", ")", "{", "if", "(", "normalizeNodesInEdgeRelations", ")", "{", "NodeRelationNormalizer", "nodeRelationNormalizer", "=", "getNodeRelationNormalizer", "(", ")", ";", "clause", ".", "apply", "(", "nodeRelationNormalizer", ")", ";", "}", "ClauseAnalysis", "clauseAnalysis", "=", "getClauseAnalysis", "(", ")", ";", "clause", ".", "apply", "(", "clauseAnalysis", ")", ";", "queryData", ".", "addAlternative", "(", "new", "LinkedList", "<", "QueryNode", ">", "(", "clauseAnalysis", ".", "getNodes", "(", ")", ")", ")", ";", "queryData", ".", "setMaxWidth", "(", "Math", ".", "max", "(", "queryData", ".", "getMaxWidth", "(", ")", ",", "clauseAnalysis", ".", "nodesCount", "(", ")", ")", ")", ";", "queryData", ".", "addMetaAnnotations", "(", "clauseAnalysis", ".", "getMetaAnnotations", "(", ")", ")", ";", "}", "log", ".", "debug", "(", "\"\"", "+", "queryData", ".", "getMaxWidth", "(", ")", ")", ";", "return", "queryData", ";", "}", "public", "DnfTransformer", "getDnfTransformer", "(", ")", "{", "return", "dummyDnfTransformer", ";", "}", "public", "void", "setDnfTransformer", "(", "DnfTransformer", "dnfTransformer", ")", "{", "this", ".", "dummyDnfTransformer", "=", "dnfTransformer", ";", "}", "public", "ClauseAnalysis", "getClauseAnalysis", "(", ")", "{", "return", "dummyClauseAnalysis", ";", "}", "public", "void", "setClauseAnalysis", "(", "ClauseAnalysis", "clauseAnalysis", ")", "{", "this", ".", "dummyClauseAnalysis", "=", "clauseAnalysis", ";", "}", "public", "NodeRelationNormalizer", "getNodeRelationNormalizer", "(", ")", "{", "return", "nodeRelationNormalizer", ";", "}", "public", "void", "setNodeRelationNormalizer", "(", "NodeRelationNormalizer", "nodeRelationNormalizer", ")", "{", "this", ".", "nodeRelationNormalizer", "=", "nodeRelationNormalizer", ";", "}", "public", "boolean", "isNormalizeNodesInEdgeRelations", "(", ")", "{", "return", "normalizeNodesInEdgeRelations", ";", "}", "public", "void", "setNormalizeNodesInEdgeRelations", "(", "boolean", "normalizeNodesInEdgeRelations", ")", "{", "this", ".", "normalizeNodesInEdgeRelations", "=", "normalizeNodesInEdgeRelations", ";", "}", "}", "</s>" ]
8,856
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "node", ".", "*", ";", "import", "java", ".", "util", ".", "LinkedHashMap", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "class", "DnfNodeRelNumberUpdater", "extends", "DepthFirstAdapter", "{", "private", "SearchExpressionCounter", "origCounter", ";", "private", "Map", "<", "Node", ",", "Integer", ">", "newNodeNumbers", ";", "private", "int", "newCounter", ";", "public", "DnfNodeRelNumberUpdater", "(", "SearchExpressionCounter", "origCounter", ")", "{", "this", ".", "origCounter", "=", "origCounter", ";", "this", ".", "newNodeNumbers", "=", "new", "LinkedHashMap", "<", "Node", ",", "Integer", ">", "(", ")", ";", "this", ".", "newCounter", "=", "0", ";", "}", "@", "Override", "public", "void", "caseAAnyNodeSearchExpr", "(", "AAnyNodeSearchExpr", "node", ")", "{", "addNewNode", "(", "node", ")", ";", "}", "@", "Override", "public", "void", "caseAAnnotationSearchExpr", "(", "AAnnotationSearchExpr", "node", ")", "{", "addNewNode", "(", "node", ")", ";", "}", "@", "Override", "public", "void", "caseATextSearchExpr", "(", "ATextSearchExpr", "node", ")", "{", "addNewNode", "(", "node", ")", ";", "}", "@", "Override", "public", "void", "caseATextSearchNotEqualExpr", "(", "ATextSearchNotEqualExpr", "node", ")", "{", "addNewNode", "(", "node", ")", ";", "}", "@", "Override", "public", "void", "caseALinguisticConstraintExpr", "(", "ALinguisticConstraintExpr", "node", ")", "{", "node", ".", "setLhs", "(", "updateOperand", "(", "node", ".", "getLhs", "(", ")", ")", ")", ";", "node", ".", "setRhs", "(", "updateOperand", "(", "node", ".", "getRhs", "(", ")", ")", ")", ";", "}", "@", "Override", "public", "void", "caseAAndExpr", "(", "AAndExpr", "node", ")", "{", "newCounter", "=", "0", ";", "super", ".", "caseAAndExpr", "(", "node", ")", ";", "}", "private", "void", "addNewNode", "(", "PExpr", "expr", ")", "{", "newNodeNumbers", ".", "put", "(", "expr", ",", "++", "newCounter", ")", ";", "}", "private", "TDigits", "updateOperand", "(", "TDigits", "d", ")", "{", "if", "(", "d", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "int", "oldNumber", "=", "Integer", ".", "parseInt", "(", "d", ".", "getText", "(", ")", ")", ";", "Node", "referencedExpr", "=", "origCounter", ".", "getSearchExpression", "(", "oldNumber", ")", ";", "if", "(", "newNodeNumbers", ".", "containsKey", "(", "referencedExpr", ")", ")", "{", "int", "newNumber", "=", "newNodeNumbers", ".", "get", "(", "referencedExpr", ")", ";", "TDigits", "r", "=", "(", "TDigits", ")", "d", ".", "clone", "(", ")", ";", "r", ".", "setText", "(", "\"\"", "+", "newNumber", ")", ";", "origCounter", ".", "setSearchPosition", "(", "referencedExpr", ",", "newNumber", ")", ";", "return", "r", ";", "}", "else", "{", "return", "d", ";", "}", "}", "}", "}", "</s>" ]
8,857
[ "<s>", "package", "annis", ".", "rest", ".", "provider", ";", "import", "javax", ".", "ws", ".", "rs", ".", "core", ".", "Response", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "ExceptionMapper", ";", "import", "javax", ".", "ws", ".", "rs", ".", "ext", ".", "Provider", ";", "import", "org", ".", "springframework", ".", "transaction", ".", "CannotCreateTransactionException", ";", "@", "Provider", "public", "class", "CannotCreateTransactionMapper", "implements", "ExceptionMapper", "<", "CannotCreateTransactionException", ">", "{", "@", "Override", "public", "Response", "toResponse", "(", "CannotCreateTransactionException", "exception", ")", "{", "return", "Response", ".", "status", "(", "Response", ".", "Status", ".", "SERVICE_UNAVAILABLE", ")", ".", "entity", "(", "\"\"", "+", "exception", ".", "getMessage", "(", ")", ")", ".", "type", "(", "\"text/plain\"", ")", ".", "build", "(", ")", ";", "}", "}", "</s>" ]
8,858
[ "<s>", "package", "annis", ";", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "class", "AnnisRunnerException", "extends", "RuntimeException", "{", "public", "AnnisRunnerException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "AnnisRunnerException", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "public", "AnnisRunnerException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "AnnisRunnerException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "}", "</s>" ]
8,859
[ "<s>", "package", "annis", ".", "corpuspathsearch", ";", "import", "au", ".", "com", ".", "bytecode", ".", "opencsv", ".", "CSVReader", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "FileReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "TreeMap", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "Search", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "Search", ".", "class", ")", ";", "private", "List", "<", "File", ">", "rootPaths", ";", "private", "Map", "<", "String", ",", "File", ">", "corpusPaths", ";", "private", "boolean", "wasSearched", ";", "public", "Search", "(", "List", "<", "File", ">", "rootPaths", ")", "{", "this", ".", "rootPaths", "=", "rootPaths", ";", "this", ".", "corpusPaths", "=", "new", "TreeMap", "<", "String", ",", "File", ">", "(", ")", ";", "this", ".", "wasSearched", "=", "false", ";", "}", "public", "void", "startSearch", "(", ")", "{", "corpusPaths", ".", "clear", "(", ")", ";", "for", "(", "File", "f", ":", "rootPaths", ")", "{", "searchPath", "(", "f", ")", ";", "}", "wasSearched", "=", "true", ";", "}", "private", "void", "searchPath", "(", "File", "path", ")", "{", "if", "(", "path", "!=", "null", "&&", "path", ".", "canRead", "(", ")", ")", "{", "if", "(", "path", ".", "isDirectory", "(", ")", ")", "{", "File", "[", "]", "children", "=", "path", ".", "listFiles", "(", ")", ";", "for", "(", "File", "f", ":", "children", ")", "{", "log", ".", "debug", "(", "\"seaching", "in", "\"", "+", "f", ".", "getPath", "(", ")", "+", "\"", "for", "corpora\"", ")", ";", "searchPath", "(", "f", ")", ";", "}", "}", "else", "if", "(", "path", ".", "isFile", "(", ")", "&&", "\"corpus.tab\"", ".", "equals", "(", "path", ".", "getName", "(", ")", ")", ")", "{", "try", "{", "CSVReader", "csv", "=", "new", "CSVReader", "(", "new", "InputStreamReader", "(", "new", "FileInputStream", "(", "path", ")", ",", "\"UTF-8\"", ")", ",", "'\\t'", ")", ";", "String", "[", "]", "line", ";", "int", "maxPost", "=", "Integer", ".", "MIN_VALUE", ";", "int", "minPre", "=", "Integer", ".", "MAX_VALUE", ";", "while", "(", "(", "line", "=", "csv", ".", "readNext", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "line", ".", "length", ">=", "6", "&&", "\"CORPUS\"", ".", "equalsIgnoreCase", "(", "line", "[", "2", "]", ")", ")", "{", "int", "pre", "=", "Integer", ".", "parseInt", "(", "line", "[", "4", "]", ")", ";", "int", "post", "=", "Integer", ".", "parseInt", "(", "line", "[", "5", "]", ")", ";", "if", "(", "pre", "<=", "minPre", "&&", "post", ">=", "maxPost", ")", "{", "minPre", "=", "pre", ";", "maxPost", "=", "post", ";", "corpusPaths", ".", "put", "(", "line", "[", "1", "]", ",", "path", ")", ";", "}", "}", "}", "}", "catch", "(", "FileNotFoundException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "}", "}", "}", "public", "Map", "<", "String", ",", "File", ">", "getCorpusPaths", "(", ")", "{", "return", "corpusPaths", ";", "}", "public", "boolean", "isWasSearched", "(", ")", "{", "return", "wasSearched", ";", "}", "public", "void", "setWasSearched", "(", "boolean", "wasSearched", ")", "{", "this", ".", "wasSearched", "=", "wasSearched", ";", "}", "@", "Override", "public", "String", "toString", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "File", ">", "e", ":", "corpusPaths", ".", "entrySet", "(", ")", ")", "{", "sb", ".", "append", "(", "e", ".", "getKey", "(", ")", ")", ";", "sb", ".", "append", "(", "\"t\"", ")", ";", "sb", ".", "append", "(", "e", ".", "getValue", "(", ")", ".", "getParentFile", "(", ")", ".", "getAbsolutePath", "(", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,860
[ "<s>", "package", "annis", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Field", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "TableFormatter", "{", "private", "final", "static", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "TableFormatter", ".", "class", ")", ";", "public", "String", "formatAsTable", "(", "List", "<", "?", ">", "list", ",", "String", "...", "fields", ")", "{", "if", "(", "list", ".", "isEmpty", "(", ")", ")", "return", "\"(empty)\"", ";", "boolean", "isList", "=", "list", ".", "get", "(", "0", ")", "instanceof", "List", "<", "?", ">", ";", "if", "(", "isList", ")", "fields", "=", "fieldNamesForListItems", "(", "list", ")", ";", "if", "(", "fields", ".", "length", "==", "0", ")", "return", "\"\"", ";", "List", "<", "String", ">", "columns", "=", "new", "ArrayList", "<", "String", ">", "(", "Arrays", ".", "asList", "(", "fields", ")", ")", ";", "Map", "<", "String", ",", "Integer", ">", "columnSizes", "=", "new", "HashMap", "<", "String", ",", "Integer", ">", "(", ")", ";", "for", "(", "String", "column", ":", "columns", ")", "updateColumnSize", "(", "columnSizes", ",", "column", ",", "column", ")", ";", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "rows", "=", "new", "ArrayList", "<", "Map", "<", "String", ",", "String", ">", ">", "(", ")", ";", "for", "(", "Object", "item", ":", "list", ")", "{", "Map", "<", "String", ",", "String", ">", "row", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "if", "(", "isList", ")", "{", "List", "<", "?", ">", "listItem", "=", "(", "List", "<", "?", ">", ")", "item", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listItem", ".", "size", "(", ")", ";", "++", "i", ")", "{", "String", "column", "=", "String", ".", "valueOf", "(", "i", ")", ";", "String", "value", "=", "listItem", ".", "get", "(", "i", ")", ".", "toString", "(", ")", ";", "row", ".", "put", "(", "\"#\"", "+", "column", ",", "value", ")", ";", "updateColumnSize", "(", "columnSizes", ",", "column", ",", "value", ")", ";", "}", "}", "else", "{", "for", "(", "String", "column", ":", "new", "ArrayList", "<", "String", ">", "(", "columns", ")", ")", "{", "String", "value", "=", "fieldValue", "(", "item", ",", "column", ",", "columns", ")", ";", "if", "(", "value", "==", "null", ")", "continue", ";", "row", ".", "put", "(", "column", ",", "value", ")", ";", "updateColumnSize", "(", "columnSizes", ",", "column", ",", "value", ")", ";", "}", "}", "rows", ".", "add", "(", "row", ")", ";", "}", "if", "(", "columns", ".", "isEmpty", "(", ")", ")", "return", "\"\"", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "printHeader", "(", "sb", ",", "columns", ",", "columnSizes", ")", ";", "printValues", "(", "sb", ",", "rows", ",", "columns", ",", "columnSizes", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "String", "[", "]", "fieldNamesForListItems", "(", "List", "<", "?", ">", "list", ")", "{", "int", "size", "=", "0", ";", "for", "(", "List", "<", "?", ">", "item", ":", "(", "List", "<", "List", "<", "?", ">", ">", ")", "list", ")", "{", "size", "=", "Math", ".", "max", "(", "size", ",", "item", ".", "size", "(", ")", ")", ";", "}", "String", "[", "]", "fields", "=", "new", "String", "[", "size", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "++", "i", ")", "fields", "[", "i", "]", "=", "\"#\"", "+", "String", ".", "valueOf", "(", "i", ")", ";", "return", "fields", ";", "}", "private", "void", "updateColumnSize", "(", "Map", "<", "String", ",", "Integer", ">", "columnSizes", ",", "String", "column", ",", "String", "value", ")", "{", "int", "length", "=", "value", ".", "length", "(", ")", ";", "if", "(", "!", "columnSizes", ".", "containsKey", "(", "column", ")", "||", "columnSizes", ".", "get", "(", "column", ")", "<", "length", ")", "columnSizes", ".", "put", "(", "column", ",", "length", ")", ";", "}", "private", "String", "fieldValue", "(", "Object", "item", ",", "String", "fieldName", ",", "List", "<", "String", ">", "columns", ")", "{", "Class", "<", "?", ">", "clazz", "=", "item", ".", "getClass", "(", ")", ";", "String", "value", "=", "null", ";", "try", "{", "Field", "field", "=", "clazz", ".", "getDeclaredField", "(", "fieldName", ")", ";", "field", ".", "setAccessible", "(", "true", ")", ";", "Object", "object", "=", "field", ".", "get", "(", "item", ")", ";", "value", "=", "object", "!=", "null", "?", "object", ".", "toString", "(", ")", ":", "\"\"", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "clazz", ".", "getName", "(", ")", "+", "\".\"", "+", "fieldName", ",", "e", ")", ";", "}", "catch", "(", "NoSuchFieldException", "e", ")", "{", "log", ".", "warn", "(", "\"Can't", "print", "\"", "+", "clazz", ".", "getName", "(", ")", "+", "\".\"", "+", "fieldName", "+", "\"\"", ",", "e", ")", ";", "columns", ".", "remove", "(", "fieldName", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "clazz", ".", "getName", "(", ")", "+", "\".\"", "+", "fieldName", ",", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "log", ".", "warn", "(", "\"\"", "+", "clazz", ".", "getName", "(", ")", "+", "\".\"", "+", "fieldName", ",", "e", ")", ";", "}", "return", "value", ";", "}", "private", "void", "printHeader", "(", "StringBuffer", "sb", ",", "List", "<", "String", ">", "columns", ",", "Map", "<", "String", ",", "Integer", ">", "columnSizes", ")", "{", "for", "(", "String", "column", ":", "columns", ")", "{", "sb", ".", "append", "(", "pad", "(", "column", ",", "columnSizes", ".", "get", "(", "column", ")", ")", ")", ";", "sb", ".", "append", "(", "\"", "|", "\"", ")", ";", "}", "sb", ".", "setLength", "(", "sb", ".", "length", "(", ")", "-", "\"", "|", "\"", ".", "length", "(", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "for", "(", "String", "column", ":", "columns", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "columnSizes", ".", "get", "(", "column", ")", ";", "++", "i", ")", "sb", ".", "append", "(", "\"-\"", ")", ";", "sb", ".", "append", "(", "\"-+-\"", ")", ";", "}", "sb", ".", "setLength", "(", "sb", ".", "length", "(", ")", "-", "\"-+-\"", ".", "length", "(", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "private", "void", "printValues", "(", "StringBuffer", "sb", ",", "List", "<", "Map", "<", "String", ",", "String", ">", ">", "rows", ",", "List", "<", "String", ">", "columns", ",", "Map", "<", "String", ",", "Integer", ">", "columnSizes", ")", "{", "for", "(", "Map", "<", "String", ",", "String", ">", "row", ":", "rows", ")", "{", "for", "(", "String", "column", ":", "columns", ")", "{", "sb", ".", "append", "(", "pad", "(", "row", ".", "get", "(", "column", ")", ",", "columnSizes", ".", "get", "(", "column", ")", ")", ")", ";", "sb", ".", "append", "(", "\"", "|", "\"", ")", ";", "}", "sb", ".", "setLength", "(", "sb", ".", "length", "(", ")", "-", "\"", "|", "\"", ".", "length", "(", ")", ")", ";", "sb", ".", "append", "(", "\"n\"", ")", ";", "}", "}", "private", "String", "pad", "(", "Object", "o", ",", "int", "length", ")", "{", "String", "s", "=", "o", "!=", "null", "?", "o", ".", "toString", "(", ")", ":", "\"\"", ";", "if", "(", "s", ".", "length", "(", ")", ">=", "length", ")", "return", "s", ";", "StringBuffer", "padded", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", "-", "s", ".", "length", "(", ")", ";", "++", "i", ")", "padded", ".", "append", "(", "\"", "\"", ")", ";", "padded", ".", "append", "(", "s", ")", ";", "return", "padded", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,861
[ "<s>", "package", "annis", ".", "utils", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "UnsupportedEncodingException", ";", "import", "java", ".", "security", ".", "MessageDigest", ";", "import", "java", ".", "security", ".", "NoSuchAlgorithmException", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "Utils", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "Utils", ".", "class", ")", ";", "public", "static", "File", "getAnnisHomeLocation", "(", ")", "{", "String", "annisHome", "=", "System", ".", "getProperty", "(", "\"annis.home\"", ")", ";", "Validate", ".", "notNull", "(", "annisHome", ")", ";", "File", "fAnnisHome", "=", "new", "File", "(", "annisHome", ")", ";", "return", "fAnnisHome", ";", "}", "public", "static", "File", "getAnnisFile", "(", "String", "subpath", ")", "{", "File", "annisConfig", "=", "getAnnisHomeLocation", "(", ")", ";", "return", "new", "File", "(", "annisConfig", ",", "subpath", ")", ";", "}", "public", "static", "String", "min", "(", "List", "<", "Long", ">", "runtimeList", ")", "{", "long", "min", "=", "Long", ".", "MAX_VALUE", ";", "for", "(", "long", "value", ":", "runtimeList", ")", "{", "min", "=", "Math", ".", "min", "(", "min", ",", "value", ")", ";", "}", "return", "String", ".", "valueOf", "(", "min", ")", ";", "}", "public", "static", "String", "max", "(", "List", "<", "Long", ">", "runtimeList", ")", "{", "long", "max", "=", "Long", ".", "MIN_VALUE", ";", "for", "(", "long", "value", ":", "runtimeList", ")", "{", "max", "=", "Math", ".", "max", "(", "max", ",", "value", ")", ";", "}", "return", "String", ".", "valueOf", "(", "max", ")", ";", "}", "public", "static", "String", "avg", "(", "List", "<", "Long", ">", "runtimeList", ")", "{", "if", "(", "runtimeList", ".", "isEmpty", "(", ")", ")", "{", "return", "\"\"", ";", "}", "long", "sum", "=", "0", ";", "for", "(", "long", "value", ":", "runtimeList", ")", "{", "sum", "+=", "value", ";", "}", "return", "String", ".", "valueOf", "(", "sum", "/", "runtimeList", ".", "size", "(", ")", ")", ";", "}", "public", "static", "Long", "[", "]", "split2Long", "(", "String", "text", ",", "char", "seperator", ")", "{", "String", "[", "]", "str", "=", "StringUtils", ".", "split", "(", "text", ",", "seperator", ")", ";", "Long", "[", "]", "lng", "=", "new", "Long", "[", "str", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "lng", ".", "length", ";", "i", "++", ")", "{", "try", "{", "lng", "[", "i", "]", "=", "Long", ".", "parseLong", "(", "str", "[", "i", "]", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "return", "lng", ";", "}", "public", "static", "String", "calculateSHAHash", "(", "String", "s", ")", "throws", "NoSuchAlgorithmException", ",", "UnsupportedEncodingException", "{", "MessageDigest", "md", "=", "MessageDigest", ".", "getInstance", "(", "\"SHA-256\"", ")", ";", "md", ".", "update", "(", "s", ".", "getBytes", "(", "\"UTF-8\"", ")", ")", ";", "byte", "[", "]", "digest", "=", "md", ".", "digest", "(", ")", ";", "StringBuilder", "hashVal", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "byte", "b", ":", "digest", ")", "{", "hashVal", ".", "append", "(", "String", ".", "format", "(", "\"%02x\"", ",", "b", ")", ")", ";", "}", "return", "hashVal", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,862
[ "<s>", "package", "annis", ";", "import", "annis", ".", "dao", ".", "AnnisDao", ";", "import", "annis", ".", "dao", ".", "SpringAnnisDao", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "test", ".", "TestHelper", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "javax", ".", "annotation", ".", "Resource", ";", "import", "org", ".", "junit", ".", "Assume", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "springframework", ".", "beans", ".", "factory", ".", "annotation", ".", "Autowired", ";", "import", "org", ".", "springframework", ".", "test", ".", "context", ".", "ContextConfiguration", ";", "import", "org", ".", "springframework", ".", "test", ".", "context", ".", "junit4", ".", "SpringJUnit4ClassRunner", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "*", ";", "import", "static", "org", ".", "junit", ".", "Assume", ".", "assumeNotNull", ";", "import", "static", "org", ".", "junit", ".", "Assume", ".", "assumeNoException", ";", "import", "static", "org", ".", "junit", ".", "Assume", ".", "assumeTrue", ";", ";", "import", "org", ".", "springframework", ".", "dao", ".", "DataAccessException", ";", "@", "RunWith", "(", "SpringJUnit4ClassRunner", ".", "class", ")", "@", "ContextConfiguration", "(", "locations", "=", "{", "\"\"", "}", ",", "loader", "=", "AnnisXmlContextLoader", ".", "class", ")", "public", "class", "CountTest", "{", "@", "Resource", "(", "name", "=", "\"annisDao\"", ")", "AnnisDao", "annisDao", ";", "private", "List", "<", "Long", ">", "pcc2CorpusID", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "SpringAnnisDao", "springAnnisDao", "=", "(", "SpringAnnisDao", ")", "TestHelper", ".", "proxyTarget", "(", "annisDao", ")", ";", "try", "{", "assumeNotNull", "(", "springAnnisDao", ".", "getSimpleJdbcTemplate", "(", ")", ")", ";", "springAnnisDao", ".", "getSimpleJdbcTemplate", "(", ")", ".", "queryForInt", "(", "\"SELECT", "1\"", ")", ";", "}", "catch", "(", "DataAccessException", "ex", ")", "{", "assumeNoException", "(", "ex", ")", ";", "}", "List", "<", "String", ">", "corpusNames", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "corpusNames", ".", "add", "(", "\"pcc2\"", ")", ";", "List", "<", "Long", ">", "corpusIDs", "=", "annisDao", ".", "mapCorpusNamesToIds", "(", "corpusNames", ")", ";", "pcc2CorpusID", "=", "corpusIDs", ";", "}", "@", "Test", "public", "void", "testAQLTestSuitePcc2", "(", ")", "{", "assumeTrue", "(", "pcc2CorpusID", ".", "size", "(", ")", ">", "0", ")", ";", "assertEquals", "(", "5", ",", "countPcc2", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "5", ",", "countPcc2", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "13", ",", "countPcc2", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "2", ",", "countPcc2", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "3", ",", "countPcc2", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "1", ",", "countPcc2", "(", "\"\"", ")", ")", ";", "}", "private", "int", "countPcc2", "(", "String", "aql", ")", "{", "QueryData", "qd", "=", "annisDao", ".", "parseAQL", "(", "aql", ",", "pcc2CorpusID", ")", ";", "return", "annisDao", ".", "count", "(", "qd", ")", ";", "}", "}", "</s>" ]
8,863
[ "<s>", "package", "annis", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "instanceOf", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Dominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftDominance", ";", "public", "class", "TestLeftDominance", "{", "@", "Test", "public", "void", "instanceOfDominance", "(", ")", "{", "assertThat", "(", "new", "LeftDominance", "(", "new", "QueryNode", "(", "1", ")", ")", ",", "instanceOf", "(", "Dominance", ".", "class", ")", ")", ";", "}", "}", "</s>" ]
8,864
[ "<s>", "package", "annis", ".", "model", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "not", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "nullValue", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verify", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RankTableJoin", ";", "public", "class", "TestQueryNode", "{", "private", "QueryNode", "node", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "node", "=", "new", "QueryNode", "(", "0", ")", ";", "}", "@", "Test", "public", "void", "qNameFullyQualified", "(", ")", "{", "assertThat", "(", "QueryNode", ".", "qName", "(", "\"namespace\"", ",", "\"name\"", ")", ",", "is", "(", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "qNameNoNamespace", "(", ")", "{", "assertThat", "(", "QueryNode", ".", "qName", "(", "null", ",", "\"name\"", ")", ",", "is", "(", "\"name\"", ")", ")", ";", "}", "@", "Test", "public", "void", "setSpannedText", "(", ")", "{", "assertThat", "(", "node", ".", "getSpannedText", "(", ")", ",", "is", "(", "nullValue", "(", ")", ")", ")", ";", "String", "spannedText", "=", "\"span\"", ";", "node", ".", "setSpannedText", "(", "spannedText", ")", ";", "assertThat", "(", "node", ".", "getSpannedText", "(", ")", ",", "is", "(", "spannedText", ")", ")", ";", "}", "@", "Test", "public", "void", "clearSpannedText", "(", ")", "{", "node", ".", "setSpannedText", "(", "\"span\"", ")", ";", "assertThat", "(", "node", ".", "getSpannedText", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "node", ".", "clearSpannedText", "(", ")", ";", "assertThat", "(", "node", ".", "getSpannedText", "(", ")", ",", "is", "(", "nullValue", "(", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "addRelationRankTable", "(", ")", "{", "assertThat", "(", "node", ".", "isPartOfEdge", "(", ")", ",", "is", "(", "false", ")", ")", ";", "QueryNode", "target", "=", "mock", "(", "QueryNode", ".", "class", ")", ";", "RankTableJoin", "rankTableJoin", "=", "new", "RankTableJoin", "(", "target", ",", "\"foo\"", ",", "0", ",", "0", ")", "{", "}", ";", "node", ".", "addJoin", "(", "rankTableJoin", ")", ";", "assertThat", "(", "node", ".", "isPartOfEdge", "(", ")", ",", "is", "(", "true", ")", ")", ";", "verify", "(", "target", ")", ".", "setPartOfEdge", "(", "true", ")", ";", "}", "@", "Test", "public", "void", "setTokenIndexToken", "(", ")", "{", "QueryNode", "node", "=", "new", "QueryNode", "(", "1", ")", ";", "node", ".", "setTokenIndex", "(", "1L", ")", ";", "assertThat", "(", "node", ".", "isToken", "(", ")", ",", "is", "(", "true", ")", ")", ";", "}", "@", "Test", "public", "void", "setTokenIndexNull", "(", ")", "{", "QueryNode", "node", "=", "new", "QueryNode", "(", "1", ")", ";", "node", ".", "setTokenIndex", "(", "null", ")", ";", "assertThat", "(", "node", ".", "isToken", "(", ")", ",", "is", "(", "false", ")", ")", ";", "}", "}", "</s>" ]
8,865
[ "<s>", "package", "annis", ".", "model", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TestAnnotationGraph", "{", "private", "AnnotationGraph", "graph", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "graph", "=", "new", "AnnotationGraph", "(", ")", ";", "}", "@", "Test", "public", "void", "addNodeToken", "(", ")", "{", "AnnisNode", "token1", "=", "newMockedToken", "(", "1", ")", ";", "AnnisNode", "token2", "=", "newMockedToken", "(", "2", ")", ";", "AnnisNode", "token3", "=", "newMockedToken", "(", "3", ")", ";", "AnnisNode", "node1", "=", "new", "AnnisNode", "(", "1", ")", ";", "AnnisNode", "node2", "=", "new", "AnnisNode", "(", "2", ")", ";", "graph", ".", "addNode", "(", "token2", ")", ";", "graph", ".", "addNode", "(", "token1", ")", ";", "graph", ".", "addNode", "(", "node2", ")", ";", "graph", ".", "addNode", "(", "node1", ")", ";", "graph", ".", "addNode", "(", "token3", ")", ";", "List", "<", "AnnisNode", ">", "expected", "=", "Arrays", ".", "asList", "(", "token1", ",", "token2", ",", "token3", ")", ";", "assertThat", "(", "graph", ".", "getTokens", "(", ")", ",", "is", "(", "expected", ")", ")", ";", "}", "@", "Test", "public", "void", "addNodeStoresGraphInNode", "(", ")", "{", "AnnisNode", "node", "=", "new", "AnnisNode", "(", "1", ")", ";", "graph", ".", "addNode", "(", "node", ")", ";", "assertThat", "(", "node", ".", "getGraph", "(", ")", ",", "is", "(", "graph", ")", ")", ";", "}", "@", "Test", "public", "void", "addNodeStoresTokenByIndex", "(", ")", "{", "final", "long", "TOKEN_INDEX", "=", "23L", ";", "AnnisNode", "token", "=", "newMockedToken", "(", "TOKEN_INDEX", ")", ";", "graph", ".", "addNode", "(", "token", ")", ";", "assertThat", "(", "graph", ".", "getToken", "(", "TOKEN_INDEX", ")", ",", "is", "(", "token", ")", ")", ";", "}", "private", "AnnisNode", "newMockedToken", "(", "long", "tokenIndex", ")", "{", "AnnisNode", "node", "=", "mock", "(", "AnnisNode", ".", "class", ")", ";", "when", "(", "node", ".", "getTokenIndex", "(", ")", ")", ".", "thenReturn", "(", "tokenIndex", ")", ";", "when", "(", "node", ".", "isToken", "(", ")", ")", ".", "thenReturn", "(", "true", ")", ";", "return", "node", ";", "}", "}", "</s>" ]
8,866
[ "<s>", "package", "annis", ".", "model", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "not", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "nullValue", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TestAnnisNode", "{", "private", "AnnisNode", "node", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "node", "=", "new", "AnnisNode", "(", "0", ")", ";", "}", "@", "Test", "public", "void", "qNameFullyQualified", "(", ")", "{", "assertThat", "(", "AnnisNode", ".", "qName", "(", "\"namespace\"", ",", "\"name\"", ")", ",", "is", "(", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "qNameNoNamespace", "(", ")", "{", "assertThat", "(", "AnnisNode", ".", "qName", "(", "null", ",", "\"name\"", ")", ",", "is", "(", "\"name\"", ")", ")", ";", "}", "@", "Test", "public", "void", "setSpannedText", "(", ")", "{", "assertThat", "(", "node", ".", "getSpannedText", "(", ")", ",", "is", "(", "nullValue", "(", ")", ")", ")", ";", "String", "spannedText", "=", "\"span\"", ";", "node", ".", "setSpannedText", "(", "spannedText", ")", ";", "assertThat", "(", "node", ".", "getSpannedText", "(", ")", ",", "is", "(", "spannedText", ")", ")", ";", "}", "@", "Test", "public", "void", "clearSpannedText", "(", ")", "{", "node", ".", "setSpannedText", "(", "\"span\"", ")", ";", "assertThat", "(", "node", ".", "getSpannedText", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "node", ".", "clearSpannedText", "(", ")", ";", "assertThat", "(", "node", ".", "getSpannedText", "(", ")", ",", "is", "(", "nullValue", "(", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "setTokenIndexToken", "(", ")", "{", "AnnisNode", "node", "=", "new", "AnnisNode", "(", "1", ")", ";", "node", ".", "setTokenIndex", "(", "1L", ")", ";", "assertThat", "(", "node", ".", "isToken", "(", ")", ",", "is", "(", "true", ")", ")", ";", "}", "@", "Test", "public", "void", "setTokenIndexNull", "(", ")", "{", "AnnisNode", "node", "=", "new", "AnnisNode", "(", "1", ")", ";", "node", ".", "setTokenIndex", "(", "null", ")", ";", "assertThat", "(", "node", ".", "isToken", "(", ")", ",", "is", "(", "false", ")", ")", ";", "}", "}", "</s>" ]
8,867
[ "<s>", "package", "annis", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "instanceOf", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Dominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightDominance", ";", "public", "class", "TestRightDominance", "{", "@", "Test", "public", "void", "instanceOfDominance", "(", ")", "{", "assertThat", "(", "new", "RightDominance", "(", "new", "QueryNode", "(", "1", ")", ")", ",", "instanceOf", "(", "Dominance", ".", "class", ")", ")", ";", "}", "}", "</s>" ]
8,868
[ "<s>", "package", "annis", ".", "model", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "instanceOf", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Dominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Sibling", ";", "public", "class", "TestSibling", "{", "@", "Test", "public", "void", "instanceOfDominance", "(", ")", "{", "assertThat", "(", "new", "Sibling", "(", "new", "QueryNode", "(", "1", ")", ")", ",", "instanceOf", "(", "Dominance", ".", "class", ")", ")", ";", "}", "}", "</s>" ]
8,869
[ "<s>", "package", "annis", ".", "model", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "not", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertFalse", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "builder", ".", "HashCodeBuilder", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "@", "SuppressWarnings", "(", "{", "\"unused\"", ",", "\"serial\"", "}", ")", "public", "class", "TestDataObject", "{", "static", "class", "A", "extends", "DataObject", "{", "private", "String", "s", ";", "public", "A", "(", "String", "s", ")", "{", "this", ".", "s", "=", "s", ";", "}", "}", "static", "class", "B", "extends", "DataObject", "{", "private", "String", "s", ";", "private", "Collection", "<", "String", ">", "c", ";", "public", "B", "(", "String", "s", ",", "Collection", "<", "String", ">", "c", ")", "{", "this", ".", "s", "=", "s", ";", "this", ".", "c", "=", "c", ";", "}", "}", "static", "class", "C", "extends", "DataObject", "{", "private", "A", "a", ";", "public", "C", "(", "A", "a", ")", "{", "super", "(", ")", ";", "this", ".", "a", "=", "a", ";", "}", "}", "private", "static", "final", "String", "S1", "=", "\"S1\"", ";", "private", "static", "final", "String", "S2", "=", "\"S2\"", ";", "private", "static", "final", "Collection", "<", "String", ">", "C1", "=", "Arrays", ".", "asList", "(", "S1", ")", ";", "private", "static", "final", "Collection", "<", "String", ">", "C2", "=", "Arrays", ".", "asList", "(", "S2", ")", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "assertThat", "(", "\"\"", ",", "S1", ",", "is", "(", "not", "(", "S2", ")", ")", ")", ";", "assertThat", "(", "\"\"", ",", "C1", ",", "is", "(", "not", "(", "C2", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "equalsTrueA", "(", ")", "{", "A", "a1", "=", "new", "A", "(", "S1", ")", ";", "A", "a2", "=", "new", "A", "(", "S1", ")", ";", "assertThat", "(", "a1", ",", "is", "(", "a2", ")", ")", ";", "}", "@", "Test", "public", "void", "equalsFalseA", "(", ")", "{", "A", "a1", "=", "new", "A", "(", "S1", ")", ";", "A", "a2", "=", "new", "A", "(", "S2", ")", ";", "assertThat", "(", "a1", ",", "is", "(", "not", "(", "a2", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "equalsTrueB", "(", ")", "{", "B", "b1", "=", "new", "B", "(", "S1", ",", "C1", ")", ";", "B", "b2", "=", "new", "B", "(", "S1", ",", "C1", ")", ";", "assertThat", "(", "b1", ",", "is", "(", "b2", ")", ")", ";", "}", "@", "Test", "public", "void", "equalsFalseBWrongString", "(", ")", "{", "B", "b1", "=", "new", "B", "(", "S1", ",", "C1", ")", ";", "B", "b2", "=", "new", "B", "(", "S2", ",", "C1", ")", ";", "assertThat", "(", "b1", ",", "is", "(", "not", "(", "b2", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "equalsFalseBWrongCollection", "(", ")", "{", "B", "b1", "=", "new", "B", "(", "S1", ",", "C1", ")", ";", "B", "b2", "=", "new", "B", "(", "S1", ",", "C2", ")", ";", "assertThat", "(", "b1", ",", "is", "(", "not", "(", "b2", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "equalsFalseWrongType", "(", ")", "{", "A", "a", "=", "new", "A", "(", "S1", ")", ";", "B", "b", "=", "new", "B", "(", "S1", ",", "C1", ")", ";", "assertFalse", "(", "a", ".", "equals", "(", "b", ")", ")", ";", "}", "@", "Test", "public", "void", "equalsFalseThisNull", "(", ")", "{", "A", "a", "=", "new", "A", "(", "S1", ")", ";", "C", "c1", "=", "new", "C", "(", "null", ")", ";", "C", "c2", "=", "new", "C", "(", "a", ")", ";", "assertFalse", "(", "c1", ".", "equals", "(", "c2", ")", ")", ";", "}", "@", "Test", "public", "void", "equalsFalseOtherNull", "(", ")", "{", "A", "a", "=", "new", "A", "(", "S1", ")", ";", "C", "c1", "=", "new", "C", "(", "a", ")", ";", "C", "c2", "=", "new", "C", "(", "null", ")", ";", "assertFalse", "(", "c1", ".", "equals", "(", "c2", ")", ")", ";", "}", "@", "Test", "public", "void", "hashCodeA", "(", ")", "{", "A", "a", "=", "new", "A", "(", "S1", ")", ";", "int", "expected", "=", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "S1", ")", ".", "toHashCode", "(", ")", ";", "assertThat", "(", "a", ".", "hashCode", "(", ")", ",", "is", "(", "expected", ")", ")", ";", "}", "@", "Test", "public", "void", "hashCodeB", "(", ")", "{", "B", "b", "=", "new", "B", "(", "S1", ",", "C1", ")", ";", "int", "expected", "=", "new", "HashCodeBuilder", "(", ")", ".", "append", "(", "C1", ")", ".", "append", "(", "S1", ")", ".", "toHashCode", "(", ")", ";", "assertThat", "(", "b", ".", "hashCode", "(", ")", ",", "is", "(", "expected", ")", ")", ";", "}", "}", "</s>" ]
8,870
[ "<s>", "package", "annis", ".", "administration", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verify", ";", "import", "static", "org", ".", "mockito", ".", "MockitoAnnotations", ".", "initMocks", ";", "public", "class", "TestAnnisAdminRunner", "{", "@", "Mock", "private", "CorpusAdministration", "administration", ";", "private", "AnnisAdminRunner", "main", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "initMocks", "(", "this", ")", ";", "main", "=", "new", "AnnisAdminRunner", "(", ")", ";", "main", ".", "setCorpusAdministration", "(", "null", ")", ";", "main", ".", "setCorpusAdministration", "(", "administration", ")", ";", "}", "@", "Test", "public", "void", "importManyCorpora", "(", ")", "{", "run", "(", "\"\"", ")", ";", "List", "<", "String", ">", "expected", "=", "Arrays", ".", "asList", "(", "\"\"", ".", "split", "(", "\"", "\"", ")", ")", ";", "verify", "(", "administration", ")", ".", "importCorpora", "(", "expected", ")", ";", "}", "@", "Test", "public", "void", "initializeDatabase", "(", ")", "{", "run", "(", "\"\"", ")", ";", "verify", "(", "administration", ")", ".", "initializeDatabase", "(", "\"host\"", ",", "\"5432\"", ",", "\"database\"", ",", "\"user\"", ",", "\"password\"", ",", "\"postgres\"", ",", "\"postgres\"", ",", "null", ")", ";", "}", "@", "Test", "public", "void", "indexes", "(", ")", "{", "run", "(", "\"indexes\"", ")", ";", "verify", "(", "administration", ")", ".", "listUsedIndexes", "(", ")", ";", "verify", "(", "administration", ")", ".", "listUnusedIndexes", "(", ")", ";", "}", "private", "void", "run", "(", "String", "cmdline", ")", "{", "main", ".", "run", "(", "cmdline", ".", "split", "(", "\"", "\"", ")", ")", ";", "}", "}", "</s>" ]
8,871
[ "<s>", "package", "annis", ".", "administration", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "inOrder", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verifyNoMoreInteractions", ";", "import", "static", "org", ".", "mockito", ".", "MockitoAnnotations", ".", "initMocks", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "mockito", ".", "InOrder", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "public", "class", "TestCorpusAdministration", "{", "@", "Mock", "private", "DefaultAdministrationDao", "administrationDao", ";", "private", "CorpusAdministration", "administration", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "initMocks", "(", "this", ")", ";", "administration", "=", "new", "CorpusAdministration", "(", ")", ";", "administration", ".", "setAdministrationDao", "(", "administrationDao", ")", ";", "}", "@", "Test", "public", "void", "importCorporaOne", "(", ")", "{", "String", "path", "=", "\"somePath\"", ";", "administration", ".", "importCorpora", "(", "path", ")", ";", "InOrder", "inOrder", "=", "inOrder", "(", "administrationDao", ")", ";", "verifyPreImport", "(", "inOrder", ")", ";", "verifyImport", "(", "inOrder", ",", "path", ")", ";", "verifyPostImport", "(", "inOrder", ")", ";", "verifyNoMoreInteractions", "(", "administrationDao", ")", ";", "}", "@", "Test", "public", "void", "importCorporaMany", "(", ")", "{", "String", "path1", "=", "\"somePath\"", ";", "String", "path2", "=", "\"anotherPath\"", ";", "String", "path3", "=", "\"\"", ";", "administration", ".", "importCorpora", "(", "path1", ",", "path2", ",", "path3", ")", ";", "InOrder", "inOrder", "=", "inOrder", "(", "administrationDao", ")", ";", "verifyPreImport", "(", "inOrder", ")", ";", "verifyImport", "(", "inOrder", ",", "path1", ")", ";", "verifyImport", "(", "inOrder", ",", "path2", ")", ";", "verifyImport", "(", "inOrder", ",", "path3", ")", ";", "verifyNoMoreInteractions", "(", "administrationDao", ")", ";", "}", "private", "void", "verifyPreImport", "(", "InOrder", "inOrder", ")", "{", "}", "private", "void", "verifyPostImport", "(", "InOrder", "inOrder", ")", "{", "}", "private", "void", "verifyImport", "(", "InOrder", "inOrder", ",", "String", "path", ")", "{", "inOrder", ".", "verify", "(", "administrationDao", ")", ".", "importCorpus", "(", "path", ")", ";", "}", "}", "</s>" ]
8,872
[ "<s>", "package", "annis", ".", "dao", ";", "import", "annis", ".", "AnnisXmlContextLoader", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "not", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "nullValue", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "any", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "anyBoolean", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "anyList", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "anyLong", ";", "import", "static", "org", ".", "mockito", ".", "Matchers", ".", "anyString", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "spy", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verify", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verifyNoMoreInteractions", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "static", "org", ".", "mockito", ".", "MockitoAnnotations", ".", "initMocks", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Ignore", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "JdbcTemplate", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "ResultSetExtractor", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "RowMapper", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "ParameterizedSingleColumnRowMapper", ";", "import", "org", ".", "springframework", ".", "jdbc", ".", "core", ".", "simple", ".", "SimpleJdbcTemplate", ";", "import", "org", ".", "springframework", ".", "test", ".", "context", ".", "ContextConfiguration", ";", "import", "org", ".", "springframework", ".", "test", ".", "context", ".", "junit4", ".", "SpringJUnit4ClassRunner", ";", "import", "annis", ".", "test", ".", "TestHelper", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "model", ".", "AnnotationGraph", ";", "import", "annis", ".", "ql", ".", "parser", ".", "AnnisParser", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryAnalysis", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisCorpus", ";", "import", "annis", ".", "sqlgen", ".", "AnnotateSqlGenerator", ";", "import", "annis", ".", "sqlgen", ".", "ListCorpusAnnotationsSqlHelper", ";", "import", "annis", ".", "sqlgen", ".", "ListCorpusSqlHelper", ";", "import", "annis", ".", "sqlgen", ".", "ListAnnotationsSqlHelper", ";", "import", "annis", ".", "sqlgen", ".", "SqlGenerator", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "import", "annis", ".", "service", ".", "objects", ".", "AnnisAttribute", ";", "import", "annis", ".", "sqlgen", ".", "SaltAnnotateExtractor", ";", "import", "de", ".", "hu_berlin", ".", "german", ".", "korpling", ".", "saltnpepper", ".", "salt", ".", "saltCommon", ".", "SaltProject", ";", "import", "java", ".", "util", ".", "LinkedList", ";", "import", "javax", ".", "annotation", ".", "Resource", ";", "import", "org", ".", "springframework", ".", "context", ".", "annotation", ".", "PropertySource", ";", "@", "RunWith", "(", "SpringJUnit4ClassRunner", ".", "class", ")", "@", "ContextConfiguration", "(", "locations", "=", "{", "\"\"", "}", ",", "loader", "=", "AnnisXmlContextLoader", ".", "class", ")", "public", "class", "TestSpringAnnisDao", "{", "@", "Resource", "(", "name", "=", "\"annisDao\"", ")", "private", "AnnisDao", "annisDao", ";", "private", "SpringAnnisDao", "simpleAnnisDao", ";", "@", "Mock", "private", "AnnisParser", "annisParser", ";", "@", "Mock", "private", "MetaDataFilter", "metaDataFilter", ";", "@", "Mock", "private", "SqlGenerator", "sqlGenerator", ";", "@", "Mock", "private", "AnnotateSqlGenerator", "annotateSqlGenerator", ";", "@", "Mock", "private", "SaltAnnotateExtractor", "saltAnnotateExtractor", ";", "@", "Mock", "private", "ParameterizedSingleColumnRowMapper", "<", "String", ">", "planRowMapper", ";", "@", "Mock", "private", "JdbcTemplate", "jdbcTemplate", ";", "private", "SimpleJdbcTemplate", "simpleJdbcTemplate", ";", "@", "Mock", "private", "ListCorpusSqlHelper", "listCorpusHelper", ";", "@", "Mock", "private", "ListAnnotationsSqlHelper", "listNodeAnnotationsSqlHelper", ";", "@", "Mock", "private", "ListCorpusAnnotationsSqlHelper", "listCorpusAnnotationsHelper", ";", "@", "Mock", "private", "QueryAnalysis", "queryAnalysis", ";", "private", "static", "final", "String", "DDDQUERY", "=", "\"DDDQUERY\"", ";", "private", "static", "final", "Start", "STATEMENT", "=", "new", "Start", "(", ")", ";", "private", "static", "final", "String", "SQL", "=", "\"SQL\"", ";", "private", "static", "final", "List", "<", "Long", ">", "CORPUS_LIST", "=", "new", "ArrayList", "<", "Long", ">", "(", ")", ";", "private", "static", "final", "List", "<", "Long", ">", "DOCUMENT_LIST", "=", "new", "LinkedList", "<", "Long", ">", "(", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Before", "public", "void", "setup", "(", ")", "{", "initMocks", "(", "this", ")", ";", "simpleAnnisDao", "=", "new", "SpringAnnisDao", "(", ")", ";", "simpleAnnisDao", ".", "setAqlParser", "(", "annisParser", ")", ";", "simpleAnnisDao", ".", "setSqlGenerator", "(", "sqlGenerator", ")", ";", "simpleAnnisDao", ".", "setAnnotateSqlGenerator", "(", "annotateSqlGenerator", ")", ";", "simpleAnnisDao", ".", "setSaltAnnotateExtractor", "(", "saltAnnotateExtractor", ")", ";", "simpleAnnisDao", ".", "setPlanRowMapper", "(", "planRowMapper", ")", ";", "simpleAnnisDao", ".", "setJdbcTemplate", "(", "jdbcTemplate", ")", ";", "simpleAnnisDao", ".", "setListCorpusSqlHelper", "(", "listCorpusHelper", ")", ";", "simpleAnnisDao", ".", "setListAnnotationsSqlHelper", "(", "listNodeAnnotationsSqlHelper", ")", ";", "simpleAnnisDao", ".", "setListCorpusAnnotationsSqlHelper", "(", "listCorpusAnnotationsHelper", ")", ";", "simpleAnnisDao", ".", "setQueryAnalysis", "(", "queryAnalysis", ")", ";", "simpleAnnisDao", ".", "setMetaDataFilter", "(", "metaDataFilter", ")", ";", "when", "(", "annisParser", ".", "parse", "(", "anyString", "(", ")", ")", ")", ".", "thenReturn", "(", "STATEMENT", ")", ";", "when", "(", "sqlGenerator", ".", "toSql", "(", "any", "(", "QueryData", ".", "class", ")", ")", ")", ".", "thenReturn", "(", "SQL", ")", ";", "simpleJdbcTemplate", "=", "spy", "(", "simpleAnnisDao", ".", "getSimpleJdbcTemplate", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "springManagedInstanceHasAllDependencies", "(", ")", "{", "SpringAnnisDao", "springManagedDao", "=", "(", "SpringAnnisDao", ")", "TestHelper", ".", "proxyTarget", "(", "annisDao", ")", ";", "assertThat", "(", "springManagedDao", ".", "getSimpleJdbcTemplate", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getAqlParser", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getSqlGenerator", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getPlanRowMapper", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getListCorpusSqlHelper", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getListCorpusAnnotationsSqlHelper", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getListAnnotationsSqlHelper", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getCountExtractor", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getQueryAnalysis", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getFindSqlGenerator", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getSqlSessionModifiers", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getListCorpusByNameDaoHelper", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedDao", ".", "getMetaDataFilter", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "retrieveAnnotationGraphText", "(", ")", "{", "final", "long", "TEXT_ID", "=", "23", ";", "final", "SaltProject", "GRAPH", "=", "mock", "(", "SaltProject", ".", "class", ")", ";", "when", "(", "annotateSqlGenerator", ".", "queryAnnotationGraph", "(", "any", "(", "JdbcTemplate", ".", "class", ")", ",", "anyLong", "(", ")", ")", ")", ".", "thenReturn", "(", "GRAPH", ")", ";", "assertThat", "(", "simpleAnnisDao", ".", "retrieveAnnotationGraph", "(", "TEXT_ID", ")", ",", "is", "(", "GRAPH", ")", ")", ";", "}", "@", "Test", "public", "void", "retrieveAnnotationGraphNoText", "(", ")", "{", "when", "(", "jdbcTemplate", ".", "query", "(", "anyString", "(", ")", ",", "any", "(", "AnnotateSqlGenerator", ".", "class", ")", ")", ")", ".", "thenReturn", "(", "new", "ArrayList", "<", "AnnotationGraph", ">", "(", ")", ")", ";", "assertThat", "(", "simpleAnnisDao", ".", "retrieveAnnotationGraph", "(", "0", ")", ",", "is", "(", "nullValue", "(", ")", ")", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Test", "public", "void", "listCorpora", "(", ")", "{", "final", "List", "<", "AnnisCorpus", ">", "CORPORA", "=", "mock", "(", "List", ".", "class", ")", ";", "when", "(", "jdbcTemplate", ".", "query", "(", "anyString", "(", ")", ",", "any", "(", "RowMapper", ".", "class", ")", ")", ")", ".", "thenReturn", "(", "CORPORA", ")", ";", "when", "(", "listCorpusHelper", ".", "createSqlQuery", "(", ")", ")", ".", "thenReturn", "(", "SQL", ")", ";", "assertThat", "(", "simpleAnnisDao", ".", "listCorpora", "(", ")", ",", "is", "(", "CORPORA", ")", ")", ";", "verify", "(", "jdbcTemplate", ")", ".", "query", "(", "SQL", ",", "listCorpusHelper", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Test", "public", "void", "listCorpusAnnotations", "(", ")", "{", "final", "List", "<", "Annotation", ">", "ANNOTATIONS", "=", "mock", "(", "List", ".", "class", ")", ";", "when", "(", "jdbcTemplate", ".", "query", "(", "anyString", "(", ")", ",", "any", "(", "RowMapper", ".", "class", ")", ")", ")", ".", "thenReturn", "(", "ANNOTATIONS", ")", ";", "final", "String", "ID", "=", "\"\"", ";", "when", "(", "listCorpusAnnotationsHelper", ".", "createSqlQuery", "(", "anyString", "(", ")", ",", "anyString", "(", ")", ")", ")", ".", "thenReturn", "(", "SQL", ")", ";", "assertThat", "(", "simpleAnnisDao", ".", "listCorpusAnnotations", "(", "ID", ")", ",", "is", "(", "ANNOTATIONS", ")", ")", ";", "verify", "(", "listCorpusAnnotationsHelper", ")", ".", "createSqlQuery", "(", "ID", ",", "ID", ")", ";", "verify", "(", "jdbcTemplate", ")", ".", "query", "(", "SQL", ",", "listCorpusAnnotationsHelper", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Test", "public", "void", "listNodeAnnotations", "(", ")", "{", "final", "List", "<", "AnnisAttribute", ">", "NODE_ANNOTATIONS", "=", "mock", "(", "List", ".", "class", ")", ";", "when", "(", "jdbcTemplate", ".", "query", "(", "anyString", "(", ")", ",", "any", "(", "ResultSetExtractor", ".", "class", ")", ")", ")", ".", "thenReturn", "(", "NODE_ANNOTATIONS", ")", ";", "when", "(", "listNodeAnnotationsSqlHelper", ".", "createSqlQuery", "(", "anyList", "(", ")", ",", "anyBoolean", "(", ")", ",", "anyBoolean", "(", ")", ")", ")", ".", "thenReturn", "(", "SQL", ")", ";", "assertThat", "(", "simpleAnnisDao", ".", "listAnnotations", "(", "CORPUS_LIST", ",", "false", ",", "false", ")", ",", "is", "(", "NODE_ANNOTATIONS", ")", ")", ";", "verify", "(", "jdbcTemplate", ")", ".", "query", "(", "SQL", ",", "listNodeAnnotationsSqlHelper", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Ignore", "public", "void", "listCorpusByName", "(", ")", "{", "final", "List", "<", "String", ">", "CORPUS_NAMES", "=", "mock", "(", "List", ".", "class", ")", ";", "ListCorpusByNameDaoHelper", "listCorpusByNameDaoHelper", "=", "mock", "(", "ListCorpusByNameDaoHelper", ".", "class", ")", ";", "simpleAnnisDao", ".", "setListCorpusByNameDaoHelper", "(", "listCorpusByNameDaoHelper", ")", ";", "when", "(", "listCorpusByNameDaoHelper", ".", "createSql", "(", "anyList", "(", ")", ")", ")", ".", "thenReturn", "(", "SQL", ")", ";", "List", "<", "Long", ">", "wtf", "=", "simpleJdbcTemplate", ".", "query", "(", "anyString", "(", ")", ",", "any", "(", "ListCorpusByNameDaoHelper", ".", "class", ")", ")", ";", "when", "(", "wtf", ")", ".", "thenReturn", "(", "CORPUS_LIST", ")", ";", "assertThat", "(", "simpleAnnisDao", ".", "mapCorpusNamesToIds", "(", "CORPUS_NAMES", ")", ",", "is", "(", "CORPUS_LIST", ")", ")", ";", "verify", "(", "listCorpusByNameDaoHelper", ")", ".", "createSql", "(", "CORPUS_NAMES", ")", ";", "verify", "(", "simpleJdbcTemplate", ")", ".", "query", "(", "SQL", ",", "listCorpusByNameDaoHelper", ")", ";", "}", "@", "Test", "public", "void", "sessionTimeout", "(", ")", "{", "int", "timeout", "=", "100", ";", "simpleAnnisDao", ".", "setTimeout", "(", "timeout", ")", ";", "simpleAnnisDao", ".", "modifySqlSession", "(", "jdbcTemplate", ",", "null", ")", ";", "verify", "(", "jdbcTemplate", ")", ".", "update", "(", "\"\"", "+", "timeout", ")", ";", "}", "@", "Test", "public", "void", "noTimeout", "(", ")", "{", "simpleAnnisDao", ".", "setTimeout", "(", "0", ")", ";", "simpleAnnisDao", ".", "modifySqlSession", "(", "jdbcTemplate", ",", "null", ")", ";", "verifyNoMoreInteractions", "(", "simpleJdbcTemplate", ")", ";", "}", "}", "</s>" ]
8,873
[ "<s>", "package", "annis", ".", "dao", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TestListCorpusByNameDaoHelper", "{", "@", "Test", "public", "void", "createSql", "(", ")", "{", "final", "ListCorpusByNameDaoHelper", "listCorpusByNameDaoHelper", "=", "new", "ListCorpusByNameDaoHelper", "(", ")", ";", "List", "<", "String", ">", "corpusNames", "=", "Arrays", ".", "asList", "(", "\"a\"", ",", "\"b\"", ",", "\"c\"", ")", ";", "String", "expected", "=", "\"\"", ";", "assertEquals", "(", "expected", ",", "listCorpusByNameDaoHelper", ".", "createSql", "(", "corpusNames", ")", ")", ";", "}", "}", "</s>" ]
8,874
[ "<s>", "package", "annis", ";", "import", "annis", ".", "utils", ".", "Utils", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "org", ".", "slf4j", ".", "Logger", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "import", "org", ".", "springframework", ".", "context", ".", "support", ".", "GenericApplicationContext", ";", "import", "org", ".", "springframework", ".", "core", ".", "env", ".", "MutablePropertySources", ";", "import", "org", ".", "springframework", ".", "core", ".", "io", ".", "support", ".", "ResourcePropertySource", ";", "import", "org", ".", "springframework", ".", "test", ".", "context", ".", "support", ".", "GenericXmlContextLoader", ";", "public", "class", "AnnisXmlContextLoader", "extends", "GenericXmlContextLoader", "{", "private", "static", "final", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "AnnisXmlContextLoader", ".", "class", ")", ";", "@", "Override", "protected", "void", "prepareContext", "(", "GenericApplicationContext", "ctx", ")", "{", "super", ".", "customizeContext", "(", "ctx", ")", ";", "MutablePropertySources", "sources", "=", "ctx", ".", "getEnvironment", "(", ")", ".", "getPropertySources", "(", ")", ";", "try", "{", "sources", ".", "addFirst", "(", "new", "ResourcePropertySource", "(", "\"file:\"", "+", "Utils", ".", "getAnnisFile", "(", "\"\"", ")", ".", "getAbsolutePath", "(", ")", ")", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "\"\"", ",", "ex", ")", ";", "}", "}", "}", "</s>" ]
8,875
[ "<s>", "package", "annis", ".", "test", ";", "import", "static", "org", ".", "mockito", ".", "BDDMockito", ".", "given", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "java", ".", "sql", ".", "Array", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "RandomStringUtils", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "org", ".", "hamcrest", ".", "Description", ";", "import", "org", ".", "hamcrest", ".", "Factory", ";", "import", "org", ".", "hamcrest", ".", "Matcher", ";", "import", "org", ".", "hamcrest", ".", "TypeSafeMatcher", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TestUtils", "{", "@", "Test", "public", "void", "dummyTest", "(", ")", "{", "}", "public", "static", "<", "T", ">", "Array", "createJdbcArray", "(", "T", "...", "keys", ")", "throws", "SQLException", "{", "Array", "array", "=", "mock", "(", "Array", ".", "class", ")", ";", "given", "(", "array", ".", "getArray", "(", ")", ")", ".", "willReturn", "(", "keys", ")", ";", "return", "array", ";", "}", "public", "static", "<", "T", ">", "Set", "<", "T", ">", "newSet", "(", "T", "...", "items", ")", "{", "Set", "<", "T", ">", "set", "=", "new", "HashSet", "<", "T", ">", "(", ")", ";", "for", "(", "T", "item", ":", "items", ")", "{", "set", ".", "add", "(", "item", ")", ";", "}", "return", "set", ";", "}", "public", "static", "<", "T", ">", "Set", "<", "T", ">", "emptySetOf", "(", "Class", "<", "T", ">", "clazz", ")", "{", "Set", "<", "T", ">", "set", "=", "new", "HashSet", "<", "T", ">", "(", ")", ";", "return", "set", ";", "}", "public", "static", "String", "uniqueString", "(", ")", "{", "return", "uniqueString", "(", "10", ")", ";", "}", "public", "static", "String", "uniqueString", "(", "int", "length", ")", "{", "return", "RandomStringUtils", ".", "randomAlphanumeric", "(", "length", ")", ";", "}", "public", "static", "String", "uniqueString", "(", "String", "prefix", ")", "{", "return", "uniqueString", "(", "prefix", ",", "10", ")", ";", "}", "public", "static", "String", "uniqueString", "(", "String", "prefix", ",", "int", "length", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "prefix", ")", ";", "sb", ".", "append", "(", "uniqueString", "(", "length", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "static", "String", "uniqueAlphaString", "(", ")", "{", "return", "RandomStringUtils", ".", "randomAlphabetic", "(", "10", ")", ";", "}", "public", "static", "int", "uniqueInt", "(", ")", "{", "return", "uniqueInt", "(", "Integer", ".", "MAX_VALUE", ")", ";", "}", "public", "static", "int", "uniqueInt", "(", "int", "maxValue", ")", "{", "return", "uniqueInt", "(", "0", ",", "maxValue", ")", ";", "}", "public", "static", "int", "uniqueInt", "(", "int", "minValue", ",", "int", "maxValue", ")", "{", "Validate", ".", "isTrue", "(", "maxValue", ">", "minValue", ",", "\"maxValue", "(\"", "+", "maxValue", "+", "\"\"", "+", "minValue", "+", "\")\"", ")", ";", "return", "minValue", "+", "(", "int", ")", "(", "Math", ".", "random", "(", ")", "*", "(", "maxValue", "-", "minValue", ")", ")", ";", "}", "public", "static", "long", "uniqueLong", "(", ")", "{", "return", "(", "long", ")", "(", "Math", ".", "random", "(", ")", "*", "Long", ".", "MAX_VALUE", ")", ";", "}", "@", "Factory", "public", "static", "Matcher", "<", "Collection", "<", "?", "extends", "Object", ">", ">", "empty", "(", ")", "{", "return", "new", "TypeSafeMatcher", "<", "Collection", "<", "?", "extends", "Object", ">", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matchesSafely", "(", "Collection", "<", "?", "extends", "Object", ">", "item", ")", "{", "return", "item", "!=", "null", "&&", "item", ".", "isEmpty", "(", ")", ";", "}", "@", "Override", "public", "void", "describeTo", "(", "Description", "description", ")", "{", "description", ".", "appendText", "(", "\"\"", ")", ";", "}", "}", ";", "}", "@", "Factory", "public", "static", "Matcher", "<", "Collection", "<", "?", "extends", "Object", ">", ">", "size", "(", "final", "int", "size", ")", "{", "return", "new", "TypeSafeMatcher", "<", "Collection", "<", "?", "extends", "Object", ">", ">", "(", ")", "{", "private", "int", "actual", ";", "@", "Override", "public", "boolean", "matchesSafely", "(", "Collection", "<", "?", "extends", "Object", ">", "collection", ")", "{", "actual", "=", "collection", ".", "size", "(", ")", ";", "return", "collection", ".", "size", "(", ")", "==", "size", ";", "}", "public", "void", "describeTo", "(", "Description", "description", ")", "{", "description", ".", "appendText", "(", "\"\"", "+", "size", "+", "\"", "element\"", "+", "(", "size", "==", "1", "?", "\"\"", ":", "\"s\"", ")", "+", "\";", "got:", "\"", "+", "actual", ")", ";", "}", "}", ";", "}", "}", "</s>" ]
8,876
[ "<s>", "package", "annis", ".", "test", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "ParametersSuppliedBy", ";", "@", "Retention", "(", "RetentionPolicy", ".", "RUNTIME", ")", "@", "ParametersSuppliedBy", "(", "SpringSyntaxTreeExamplesSupplier", ".", "class", ")", "public", "@", "interface", "SpringSyntaxTreeExamples", "{", "String", "contextLocation", "(", ")", ";", "String", "exampleMap", "(", ")", ";", "}", "</s>" ]
8,877
[ "<s>", "package", "annis", ".", "test", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "PotentialAssignment", ";", "public", "class", "SyntaxTreeExample", "extends", "PotentialAssignment", "{", "private", "String", "query", ";", "private", "String", "syntaxTree", ";", "@", "Override", "public", "Object", "getValue", "(", ")", "throws", "CouldNotGenerateValueException", "{", "return", "this", ";", "}", "public", "String", "getQuery", "(", ")", "{", "return", "query", ";", "}", "public", "void", "setQuery", "(", "String", "query", ")", "{", "this", ".", "query", "=", "query", ";", "}", "public", "String", "getSyntaxTree", "(", ")", "{", "return", "syntaxTree", ";", "}", "public", "void", "setSyntaxTree", "(", "String", "syntaxTree", ")", "{", "this", ".", "syntaxTree", "=", "syntaxTree", ";", "}", "@", "Override", "public", "String", "getDescription", "(", ")", "throws", "CouldNotGenerateValueException", "{", "return", "\"query", "=", "\"", "+", "query", ";", "}", "}", "</s>" ]
8,878
[ "<s>", "package", "annis", ".", "test", ";", "import", "java", ".", "lang", ".", "annotation", ".", "Retention", ";", "import", "java", ".", "lang", ".", "annotation", ".", "RetentionPolicy", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "ParametersSuppliedBy", ";", "@", "Retention", "(", "RetentionPolicy", ".", "RUNTIME", ")", "@", "ParametersSuppliedBy", "(", "SpringQueryExamplesSupplier", ".", "class", ")", "public", "@", "interface", "SpringQueryExamples", "{", "String", "contextLocation", "(", ")", ";", "String", "exampleList", "(", ")", ";", "}", "</s>" ]
8,879
[ "<s>", "package", "annis", ".", "test", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "ParameterSignature", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "ParameterSupplier", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "PotentialAssignment", ";", "import", "org", ".", "springframework", ".", "context", ".", "ApplicationContext", ";", "import", "org", ".", "springframework", ".", "context", ".", "support", ".", "ClassPathXmlApplicationContext", ";", "public", "class", "SpringQueryExamplesSupplier", "extends", "ParameterSupplier", "{", "@", "Override", "public", "List", "<", "PotentialAssignment", ">", "getValueSources", "(", "ParameterSignature", "signature", ")", "{", "SpringQueryExamples", "annotation", "=", "signature", ".", "getAnnotation", "(", "SpringQueryExamples", ".", "class", ")", ";", "ApplicationContext", "ctx", "=", "new", "ClassPathXmlApplicationContext", "(", "annotation", ".", "contextLocation", "(", ")", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "List", "<", "String", ">", "exampleList", "=", "(", "List", "<", "String", ">", ")", "ctx", ".", "getBean", "(", "annotation", ".", "exampleList", "(", ")", ")", ";", "List", "<", "PotentialAssignment", ">", "examples", "=", "new", "ArrayList", "<", "PotentialAssignment", ">", "(", ")", ";", "for", "(", "final", "String", "example", ":", "exampleList", ")", "examples", ".", "add", "(", "new", "PotentialAssignment", "(", ")", "{", "@", "Override", "public", "Object", "getValue", "(", ")", "throws", "CouldNotGenerateValueException", "{", "return", "example", ";", "}", "@", "Override", "public", "String", "getDescription", "(", ")", "throws", "CouldNotGenerateValueException", "{", "return", "\"query", "=", "\"", "+", "example", ";", "}", "}", ")", ";", "return", "examples", ";", "}", "}", "</s>" ]
8,880
[ "<s>", "package", "annis", ".", "test", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Map", ".", "Entry", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "ParameterSignature", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "ParameterSupplier", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "PotentialAssignment", ";", "import", "org", ".", "springframework", ".", "context", ".", "ApplicationContext", ";", "import", "org", ".", "springframework", ".", "context", ".", "support", ".", "ClassPathXmlApplicationContext", ";", "public", "class", "SpringSyntaxTreeExamplesSupplier", "extends", "ParameterSupplier", "{", "@", "Override", "public", "List", "<", "PotentialAssignment", ">", "getValueSources", "(", "ParameterSignature", "signature", ")", "{", "SpringSyntaxTreeExamples", "annotation", "=", "signature", ".", "getAnnotation", "(", "SpringSyntaxTreeExamples", ".", "class", ")", ";", "ApplicationContext", "ctx", "=", "new", "ClassPathXmlApplicationContext", "(", "annotation", ".", "contextLocation", "(", ")", ")", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Map", "<", "String", ",", "String", ">", "exampleMap", "=", "(", "Map", "<", "String", ",", "String", ">", ")", "ctx", ".", "getBean", "(", "annotation", ".", "exampleMap", "(", ")", ")", ";", "List", "<", "PotentialAssignment", ">", "examples", "=", "new", "ArrayList", "<", "PotentialAssignment", ">", "(", ")", ";", "for", "(", "Entry", "<", "String", ",", "String", ">", "exampleEntry", ":", "exampleMap", ".", "entrySet", "(", ")", ")", "{", "SyntaxTreeExample", "example", "=", "new", "SyntaxTreeExample", "(", ")", ";", "example", ".", "setQuery", "(", "exampleEntry", ".", "getKey", "(", ")", ")", ";", "example", ".", "setSyntaxTree", "(", "exampleEntry", ".", "getValue", "(", ")", ".", "trim", "(", ")", ")", ";", "examples", ".", "add", "(", "example", ")", ";", "}", "return", "examples", ";", "}", "}", "</s>" ]
8,881
[ "<s>", "package", "annis", ".", "test", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "org", ".", "hamcrest", ".", "Description", ";", "import", "org", ".", "hamcrest", ".", "TypeSafeMatcher", ";", "public", "class", "IsCollection", "extends", "TypeSafeMatcher", "<", "Collection", "<", "?", "extends", "Object", ">", ">", "{", "Object", "[", "]", "expected", ";", "public", "IsCollection", "(", "Object", "...", "expected", ")", "{", "this", ".", "expected", "=", "expected", ";", "}", "@", "Override", "public", "boolean", "matchesSafely", "(", "Collection", "<", "?", "extends", "Object", ">", "actual", ")", "{", "if", "(", "expected", ".", "length", "!=", "actual", ".", "size", "(", ")", ")", "return", "false", ";", "for", "(", "Object", "object", ":", "expected", ")", "if", "(", "!", "actual", ".", "contains", "(", "object", ")", ")", "return", "false", ";", "return", "true", ";", "}", "public", "void", "describeTo", "(", "Description", "description", ")", "{", "description", ".", "appendValue", "(", "expected", ")", ";", "}", "public", "static", "IsCollection", "isCollection", "(", "Object", "...", "items", ")", "{", "return", "new", "IsCollection", "(", "items", ")", ";", "}", "}", "</s>" ]
8,882
[ "<s>", "package", "annis", ".", "test", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "fail", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Proxy", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "Validate", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "springframework", ".", "aop", ".", "target", ".", "SingletonTargetSource", ";", "public", "class", "TestHelper", "{", "private", "static", "String", "packagePath", "(", "Class", "<", "?", ">", "clazz", ")", "{", "String", "packageDeclaration", "=", "clazz", ".", "getPackage", "(", ")", ".", "toString", "(", ")", ";", "String", "path", "=", "packageDeclaration", ".", "replaceFirst", "(", "\"package", "\"", ",", "\"\"", ")", ".", "replaceAll", "(", "\"\\\\.\"", ",", "\"/\"", ")", "+", "\"/\"", ";", "return", "path", ";", "}", "private", "static", "String", "packagePath", "(", "Object", "instance", ")", "{", "return", "packagePath", "(", "instance", ".", "getClass", "(", ")", ")", ";", "}", "private", "static", "String", "springFile", "(", "Class", "<", "?", ">", "clazz", ",", "String", "contextFile", ")", "{", "return", "packagePath", "(", "clazz", ")", "+", "contextFile", ";", "}", "private", "static", "String", "springFile", "(", "Object", "instance", ",", "String", "contextFile", ")", "{", "return", "springFile", "(", "instance", ".", "getClass", "(", ")", ",", "contextFile", ")", ";", "}", "public", "static", "String", "[", "]", "springFiles", "(", "Class", "<", "?", ">", "clazz", ",", "String", "...", "contextFiles", ")", "{", "Validate", ".", "notEmpty", "(", "contextFiles", ",", "\"\"", ")", ";", "String", "[", "]", "springFiles", "=", "new", "String", "[", "contextFiles", ".", "length", "]", ";", "String", "packagePath", "=", "packagePath", "(", "clazz", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "contextFiles", ".", "length", ";", "++", "i", ")", "springFiles", "[", "i", "]", "=", "packagePath", "+", "contextFiles", "[", "i", "]", ";", "return", "springFiles", ";", "}", "public", "static", "String", "[", "]", "springFiles", "(", "Object", "instance", ",", "String", "...", "contextFiles", ")", "{", "return", "springFiles", "(", "instance", ".", "getClass", "(", ")", ",", "contextFiles", ")", ";", "}", "@", "Test", "public", "void", "testPackagePath", "(", ")", "{", "assertThat", "(", "packagePath", "(", "this", ")", ",", "is", "(", "\"annis/test/\"", ")", ")", ";", "}", "@", "Test", "public", "void", "testSpringFile", "(", ")", "{", "assertThat", "(", "springFile", "(", "this", ",", "\"context.xml\"", ")", ",", "is", "(", "\"\"", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "IllegalArgumentException", ".", "class", ")", "public", "void", "testSpringFilesEmpty", "(", ")", "{", "springFiles", "(", "this", ")", ";", "}", "@", "Test", "public", "void", "testSpringFiles", "(", ")", "{", "String", "[", "]", "expected", "=", "{", "\"\"", ",", "\"\"", "}", ";", "assertThat", "(", "springFiles", "(", "this", ",", "\"context1.xml\"", ",", "\"context2.xml\"", ")", ",", "is", "(", "expected", ")", ")", ";", "}", "public", "static", "Object", "proxyTarget", "(", "Object", "proxy", ")", "{", "if", "(", "!", "(", "proxy", "instanceof", "Proxy", ")", ")", "fail", "(", "\"\"", "+", "proxy", ")", ";", "SingletonTargetSource", "targetSource", "=", "null", ";", "try", "{", "targetSource", "=", "(", "SingletonTargetSource", ")", "proxy", ".", "getClass", "(", ")", ".", "getMethod", "(", "\"\"", ")", ".", "invoke", "(", "proxy", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "fail", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "if", "(", "targetSource", "==", "null", ")", "fail", "(", "\"\"", ")", ";", "return", "targetSource", ".", "getTarget", "(", ")", ";", "}", "}", "</s>" ]
8,883
[ "<s>", "package", "annis", ".", "test", ";", "import", "static", "org", ".", "hamcrest", ".", "core", ".", "AllOf", ".", "allOf", ";", "import", "static", "org", ".", "hamcrest", ".", "core", ".", "IsEqual", ".", "equalTo", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "org", ".", "hamcrest", ".", "Description", ";", "import", "org", ".", "hamcrest", ".", "Factory", ";", "import", "org", ".", "hamcrest", ".", "Matcher", ";", "import", "org", ".", "hamcrest", ".", "TypeSafeMatcher", ";", "public", "class", "IsCollectionContainingSubTypes", "<", "T", ">", "extends", "TypeSafeMatcher", "<", "Iterable", "<", "?", "super", "T", ">", ">", "{", "private", "final", "Matcher", "<", "?", "extends", "T", ">", "elementMatcher", ";", "public", "IsCollectionContainingSubTypes", "(", "final", "Matcher", "<", "?", "extends", "T", ">", "elementMatcher", ")", "{", "this", ".", "elementMatcher", "=", "elementMatcher", ";", "}", "@", "Override", "public", "boolean", "matchesSafely", "(", "final", "Iterable", "<", "?", "super", "T", ">", "collection", ")", "{", "for", "(", "final", "Object", "item", ":", "collection", ")", "{", "if", "(", "elementMatcher", ".", "matches", "(", "item", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "public", "void", "describeTo", "(", "final", "Description", "description", ")", "{", "description", ".", "appendText", "(", "\"\"", ")", ".", "appendDescriptionOf", "(", "elementMatcher", ")", ";", "}", "@", "Factory", "public", "static", "<", "T", ">", "Matcher", "<", "Iterable", "<", "?", "super", "T", ">", ">", "containsItem", "(", "final", "Matcher", "<", "?", "extends", "T", ">", "elementMatcher", ")", "{", "return", "new", "IsCollectionContainingSubTypes", "<", "T", ">", "(", "elementMatcher", ")", ";", "}", "@", "Factory", "public", "static", "<", "T", ">", "Matcher", "<", "Iterable", "<", "?", "super", "T", ">", ">", "containsItem", "(", "final", "T", "element", ")", "{", "return", "containsItem", "(", "equalTo", "(", "element", ")", ")", ";", "}", "@", "Factory", "public", "static", "<", "T", ">", "Matcher", "<", "Iterable", "<", "?", "super", "T", ">", ">", "containsItems", "(", "final", "Matcher", "<", "?", "extends", "T", ">", "...", "elementMatchers", ")", "{", "final", "Collection", "<", "Matcher", "<", "?", "extends", "Iterable", "<", "?", "super", "T", ">", ">", ">", "all", "=", "new", "ArrayList", "<", "Matcher", "<", "?", "extends", "Iterable", "<", "?", "super", "T", ">", ">", ">", "(", "elementMatchers", ".", "length", ")", ";", "for", "(", "final", "Matcher", "<", "?", "extends", "T", ">", "elementMatcher", ":", "elementMatchers", ")", "{", "all", ".", "add", "(", "containsItem", "(", "elementMatcher", ")", ")", ";", "}", "return", "allOf", "(", "all", ")", ";", "}", "@", "Factory", "public", "static", "<", "T", ">", "Matcher", "<", "Iterable", "<", "?", "super", "T", ">", ">", "containsItems", "(", "final", "T", "...", "elements", ")", "{", "final", "Collection", "<", "Matcher", "<", "?", "extends", "Iterable", "<", "?", "super", "T", ">", ">", ">", "all", "=", "new", "ArrayList", "<", "Matcher", "<", "?", "extends", "Iterable", "<", "?", "super", "T", ">", ">", ">", "(", "elements", ".", "length", ")", ";", "for", "(", "final", "T", "element", ":", "elements", ")", "{", "all", ".", "add", "(", "containsItem", "(", "element", ")", ")", ";", "}", "return", "allOf", "(", "all", ")", ";", "}", "@", "Factory", "public", "static", "<", "T", ">", "Matcher", "<", "Iterable", "<", "?", "super", "T", ">", ">", "containsItems", "(", "final", "Collection", "<", "?", "extends", "T", ">", "elements", ")", "{", "final", "Collection", "<", "Matcher", "<", "?", "extends", "Iterable", "<", "?", "super", "T", ">", ">", ">", "all", "=", "new", "ArrayList", "<", "Matcher", "<", "?", "extends", "Iterable", "<", "?", "super", "T", ">", ">", ">", "(", "elements", ".", "size", "(", ")", ")", ";", "for", "(", "final", "T", "element", ":", "elements", ")", "{", "all", ".", "add", "(", "containsItem", "(", "element", ")", ")", ";", "}", "return", "allOf", "(", "all", ")", ";", "}", "}", "</s>" ]
8,884
[ "<s>", "package", "annis", ".", "test", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "au", ".", "com", ".", "bytecode", ".", "opencsv", ".", "CSVReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "sql", ".", "Array", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "sql", ".", "Types", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "logging", ".", "Level", ";", "import", "java", ".", "util", ".", "logging", ".", "Logger", ";", "import", "org", ".", "apache", ".", "commons", ".", "lang3", ".", "StringUtils", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "org", ".", "mockito", ".", "MockitoAnnotations", ";", "import", "org", ".", "mockito", ".", "invocation", ".", "InvocationOnMock", ";", "import", "org", ".", "mockito", ".", "stubbing", ".", "Answer", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "*", ";", "import", "org", ".", "slf4j", ".", "LoggerFactory", ";", "public", "class", "CsvResultSetProvider", "{", "private", "static", "final", "org", ".", "slf4j", ".", "Logger", "log", "=", "LoggerFactory", ".", "getLogger", "(", "CsvResultSetProvider", ".", "class", ")", ";", "@", "Mock", "protected", "ResultSet", "rs", ";", "private", "CSVReader", "reader", ";", "private", "String", "[", "]", "current", ";", "private", "Map", "<", "String", ",", "Integer", ">", "header", ";", "boolean", "wasNull", ";", "public", "CsvResultSetProvider", "(", "InputStream", "csvStream", ")", "throws", "SQLException", "{", "MockitoAnnotations", ".", "initMocks", "(", "(", "CsvResultSetProvider", ")", "this", ")", ";", "header", "=", "new", "HashMap", "<", "String", ",", "Integer", ">", "(", ")", ";", "reader", "=", "new", "CSVReader", "(", "new", "InputStreamReader", "(", "csvStream", ")", ",", "';'", ",", "'\"'", ")", ";", "try", "{", "String", "[", "]", "firstLine", "=", "reader", ".", "readNext", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "firstLine", "!=", "null", "&&", "i", "<", "firstLine", ".", "length", ";", "i", "++", ")", "{", "header", ".", "put", "(", "firstLine", "[", "i", "]", ",", "i", ")", ";", "}", "}", "catch", "(", "IOException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "wasNull", "=", "false", ";", "when", "(", "rs", ".", "next", "(", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Boolean", ">", "(", ")", "{", "@", "Override", "public", "Boolean", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "try", "{", "current", "=", "reader", ".", "readNext", "(", ")", ";", "return", "current", "!=", "null", "&&", "current", ".", "length", ">", "0", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "return", "false", ";", "}", "}", "}", ")", ";", "when", "(", "rs", ".", "wasNull", "(", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Boolean", ">", "(", ")", "{", "@", "Override", "public", "Boolean", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "return", "wasNull", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "findColumn", "(", "anyString", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Integer", ">", "(", ")", "{", "@", "Override", "public", "Integer", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "String", "arg", "=", "(", "String", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ";", "return", "getColumnByName", "(", "arg", ")", "+", "1", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getString", "(", "anyInt", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "String", ">", "(", ")", "{", "@", "Override", "public", "String", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "int", "idx", "=", "(", "Integer", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ";", "return", "getStringValue", "(", "idx", "-", "1", ")", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getLong", "(", "anyInt", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Long", ">", "(", ")", "{", "@", "Override", "public", "Long", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "int", "idx", "=", "(", "Integer", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ";", "return", "getLongValue", "(", "idx", "-", "1", ")", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getInt", "(", "anyInt", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Integer", ">", "(", ")", "{", "@", "Override", "public", "Integer", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "int", "idx", "=", "(", "Integer", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ";", "return", "getIntValue", "(", "idx", "-", "1", ")", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getBoolean", "(", "anyInt", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Boolean", ">", "(", ")", "{", "@", "Override", "public", "Boolean", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "int", "idx", "=", "(", "Integer", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ";", "return", "getBooleanValue", "(", "idx", "-", "1", ")", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getArray", "(", "anyInt", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Array", ">", "(", ")", "{", "@", "Override", "public", "Array", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "int", "idx", "=", "(", "Integer", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ";", "return", "new", "DummySQLArray", "(", "getArrayValue", "(", "idx", "-", "1", ",", "Types", ".", "VARCHAR", ")", ",", "Types", ".", "VARCHAR", ",", "\"VARCHAR\"", ")", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getObject", "(", "anyInt", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Object", ">", "(", ")", "{", "@", "Override", "public", "Object", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "int", "idx", "=", "(", "Integer", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ";", "return", "getObjectValue", "(", "idx", "-", "1", ")", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getString", "(", "anyString", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "String", ">", "(", ")", "{", "@", "Override", "public", "String", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "return", "getStringValue", "(", "getColumnByName", "(", "(", "String", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ")", ")", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getLong", "(", "anyString", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Long", ">", "(", ")", "{", "@", "Override", "public", "Long", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "return", "getLongValue", "(", "getColumnByName", "(", "(", "String", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ")", ")", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getInt", "(", "anyString", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Integer", ">", "(", ")", "{", "@", "Override", "public", "Integer", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "return", "getIntValue", "(", "getColumnByName", "(", "(", "String", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ")", ")", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getBoolean", "(", "anyString", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Boolean", ">", "(", ")", "{", "@", "Override", "public", "Boolean", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "return", "getBooleanValue", "(", "getColumnByName", "(", "(", "String", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ")", ")", ";", "}", "}", ")", ";", "when", "(", "rs", ".", "getArray", "(", "anyString", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Array", ">", "(", ")", "{", "@", "Override", "public", "Array", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "if", "(", "\"key\"", ".", "equalsIgnoreCase", "(", "(", "String", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ")", ")", "{", "return", "new", "DummySQLArray", "(", "getArrayValue", "(", "getColumnByName", "(", "(", "String", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ")", ",", "Types", ".", "BIGINT", ")", ",", "Types", ".", "BIGINT", ",", "\"BIGINT\"", ")", ";", "}", "else", "{", "return", "new", "DummySQLArray", "(", "getArrayValue", "(", "getColumnByName", "(", "(", "String", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ")", ",", "Types", ".", "VARCHAR", ")", ",", "Types", ".", "VARCHAR", ",", "\"VARCHAR\"", ")", ";", "}", "}", "}", ")", ";", "when", "(", "rs", ".", "getObject", "(", "anyString", "(", ")", ")", ")", ".", "thenAnswer", "(", "new", "Answer", "<", "Object", ">", "(", ")", "{", "@", "Override", "public", "Object", "answer", "(", "InvocationOnMock", "invocation", ")", "throws", "Throwable", "{", "return", "getObjectValue", "(", "getColumnByName", "(", "(", "String", ")", "invocation", ".", "getArguments", "(", ")", "[", "0", "]", ")", ")", ";", "}", "}", ")", ";", "}", "public", "int", "getColumnByName", "(", "String", "name", ")", "{", "if", "(", "header", ".", "containsKey", "(", "name", ")", ")", "{", "return", "header", ".", "get", "(", "name", ")", ";", "}", "return", "-", "1", ";", "}", "public", "Object", "getObjectValue", "(", "int", "column", ")", "{", "String", "rawString", "=", "getStringValue", "(", "column", ")", ";", "try", "{", "return", "Long", ".", "parseLong", "(", "rawString", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "}", "return", "rawString", ";", "}", "public", "String", "getStringValue", "(", "int", "column", ")", "{", "if", "(", "current", "!=", "null", "&&", "column", ">=", "0", ")", "{", "String", "val", "=", "current", "[", "column", "]", ";", "if", "(", "!", "\"\"", ".", "equals", "(", "val", ")", ")", "{", "wasNull", "=", "false", ";", "return", "val", ";", "}", "}", "wasNull", "=", "true", ";", "return", "null", ";", "}", "public", "long", "getLongValue", "(", "int", "column", ")", "{", "String", "str", "=", "getStringValue", "(", "column", ")", ";", "if", "(", "str", "!=", "null", ")", "{", "try", "{", "Long", "l", "=", "Long", ".", "parseLong", "(", "str", ")", ";", "return", "l", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "}", "}", "return", "0l", ";", "}", "public", "int", "getIntValue", "(", "int", "column", ")", "{", "String", "str", "=", "getStringValue", "(", "column", ")", ";", "if", "(", "str", "!=", "null", ")", "{", "try", "{", "Integer", "l", "=", "Integer", ".", "parseInt", "(", "str", ")", ";", "return", "l", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "}", "}", "return", "0", ";", "}", "public", "boolean", "getBooleanValue", "(", "int", "column", ")", "{", "String", "str", "=", "getStringValue", "(", "column", ")", ";", "if", "(", "str", "!=", "null", ")", "{", "try", "{", "if", "(", "\"t\"", ".", "equalsIgnoreCase", "(", "str", ")", "||", "\"true\"", ".", "equalsIgnoreCase", "(", "str", ")", ")", "{", "return", "true", ";", "}", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "}", "}", "return", "false", ";", "}", "public", "Object", "[", "]", "getArrayValue", "(", "int", "column", ",", "int", "sqlType", ")", "{", "String", "str", "=", "getStringValue", "(", "column", ")", ";", "if", "(", "StringUtils", ".", "startsWith", "(", "str", ",", "\"{\"", ")", "&&", "StringUtils", ".", "endsWith", "(", "str", ",", "\"}\"", ")", ")", "{", "String", "stripped", "=", "str", ".", "substring", "(", "1", ",", "str", ".", "length", "(", ")", "-", "1", ")", ";", "String", "[", "]", "split", "=", "stripped", ".", "split", "(", "\",\"", ")", ";", "if", "(", "sqlType", "==", "Types", ".", "BIGINT", ")", "{", "Long", "[", "]", "result", "=", "new", "Long", "[", "split", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "length", ";", "i", "++", ")", "{", "try", "{", "result", "[", "i", "]", "=", "Long", ".", "parseLong", "(", "split", "[", "i", "]", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "log", ".", "error", "(", "null", ",", "ex", ")", ";", "}", "}", "return", "result", ";", "}", "else", "{", "return", "split", ";", "}", "}", "return", "null", ";", "}", "public", "ResultSet", "getResultSet", "(", ")", "{", "return", "rs", ";", "}", "public", "static", "class", "DummySQLArray", "implements", "Array", "{", "private", "Object", "[", "]", "base", ";", "private", "int", "sqlType", ";", "private", "String", "sqlTypeName", ";", "public", "DummySQLArray", "(", "Object", "[", "]", "base", ",", "int", "sqlType", ",", "String", "sqlTypeName", ")", "{", "this", ".", "base", "=", "base", ";", "this", ".", "sqlType", "=", "sqlType", ";", "this", ".", "sqlTypeName", "=", "sqlTypeName", ";", "}", "@", "Override", "public", "String", "getBaseTypeName", "(", ")", "throws", "SQLException", "{", "return", "sqlTypeName", ";", "}", "@", "Override", "public", "int", "getBaseType", "(", ")", "throws", "SQLException", "{", "return", "sqlType", ";", "}", "@", "Override", "public", "Object", "getArray", "(", ")", "throws", "SQLException", "{", "return", "base", ";", "}", "@", "Override", "public", "Object", "getArray", "(", "Map", "<", "String", ",", "Class", "<", "?", ">", ">", "arg0", ")", "throws", "SQLException", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "Object", "getArray", "(", "long", "arg0", ",", "int", "arg1", ")", "throws", "SQLException", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "Object", "getArray", "(", "long", "arg0", ",", "int", "arg1", ",", "Map", "<", "String", ",", "Class", "<", "?", ">", ">", "arg2", ")", "throws", "SQLException", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "ResultSet", "getResultSet", "(", ")", "throws", "SQLException", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "ResultSet", "getResultSet", "(", "Map", "<", "String", ",", "Class", "<", "?", ">", ">", "arg0", ")", "throws", "SQLException", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "ResultSet", "getResultSet", "(", "long", "arg0", ",", "int", "arg1", ")", "throws", "SQLException", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "ResultSet", "getResultSet", "(", "long", "arg0", ",", "int", "arg1", ",", "Map", "<", "String", ",", "Class", "<", "?", ">", ">", "arg2", ")", "throws", "SQLException", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "@", "Override", "public", "void", "free", "(", ")", "throws", "SQLException", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "}", "}", "</s>" ]
8,885
[ "<s>", "package", "test", ";", "import", "org", ".", "junit", ".", "Ignore", ";", "@", "Ignore", "public", "class", "TestConsole", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "}", "}", "</s>" ]
8,886
[ "<s>", "package", "annis", ".", "test", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "org", ".", "hamcrest", ".", "Description", ";", "import", "org", ".", "hamcrest", ".", "Matcher", ";", "import", "org", ".", "hamcrest", ".", "TypeSafeMatcher", ";", "public", "class", "CustomMatcher", "{", "public", "static", "Matcher", "<", "Collection", "<", "?", ">", ">", "hasInstance", "(", "final", "Class", "<", "?", ">", "clazz", ")", "{", "return", "new", "TypeSafeMatcher", "<", "Collection", "<", "?", ">", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matchesSafely", "(", "Collection", "<", "?", ">", "collection", ")", "{", "for", "(", "Object", "item", ":", "collection", ")", "{", "if", "(", "clazz", ".", "isInstance", "(", "item", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}", "public", "void", "describeTo", "(", "Description", "description", ")", "{", "description", ".", "appendText", "(", "\"\"", "+", "clazz", ")", ";", "}", "}", ";", "}", "}", "</s>" ]
8,887
[ "<s>", "package", "annis", ".", "service", ".", "objects", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "not", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "nullValue", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "static", "org", ".", "junit", ".", "matchers", ".", "JUnitMatchers", ".", "hasItems", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "static", "org", ".", "mockito", ".", "MockitoAnnotations", ".", "initMocks", ";", "import", "static", "annis", ".", "test", ".", "TestUtils", ".", "size", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "annis", ".", "model", ".", "AnnisNode", ";", "import", "annis", ".", "model", ".", "Annotation", ";", "import", "annis", ".", "model", ".", "AnnotationGraph", ";", "import", "annis", ".", "service", ".", "ifaces", ".", "AnnisResult", ";", "import", "annis", ".", "service", ".", "ifaces", ".", "AnnisToken", ";", "public", "class", "TestAnnisResultImpl", "{", "@", "Mock", "private", "AnnotationGraph", "graph", ";", "private", "static", "final", "long", "LEFT", "=", "201", ";", "private", "static", "final", "long", "RIGHT", "=", "301", ";", "private", "static", "final", "long", "ID1", "=", "646", ";", "private", "static", "final", "String", "TEXT1", "=", "\"Hello\"", ";", "private", "static", "final", "long", "TOKEN_INDEX1", "=", "1", ";", "private", "static", "final", "long", "ID2", "=", "254", ";", "private", "static", "final", "String", "TEXT2", "=", "\"world\"", ";", "private", "static", "final", "long", "TOKEN_INDEX2", "=", "2", ";", "private", "static", "final", "long", "ID3", "=", "103", ";", "private", "static", "final", "String", "TEXT3", "=", "\"!\"", ";", "private", "static", "final", "long", "TOKEN_INDEX3", "=", "3", ";", "private", "AnnisNode", "token1", ";", "private", "AnnisNode", "token2", ";", "private", "AnnisNode", "token3", ";", "private", "static", "final", "long", "ID4", "=", "104", ";", "private", "static", "final", "long", "ID5", "=", "105", ";", "private", "AnnisNode", "node4", ";", "private", "AnnisNode", "node5", ";", "private", "static", "final", "String", "NAMESPACE", "=", "\"NAMESPACE\"", ";", "private", "static", "final", "String", "NAME1", "=", "\"NAME1\"", ";", "private", "static", "final", "String", "NAME2", "=", "\"NAME2\"", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "initMocks", "(", "this", ")", ";", "assertThat", "(", "ID1", ",", "is", "(", "not", "(", "ID2", ")", ")", ")", ";", "assertThat", "(", "ID2", ",", "is", "(", "not", "(", "ID3", ")", ")", ")", ";", "assertThat", "(", "ID3", ",", "is", "(", "not", "(", "ID1", ")", ")", ")", ";", "token1", "=", "newToken", "(", "ID1", ",", "TEXT1", ",", "TOKEN_INDEX1", ")", ";", "token2", "=", "newToken", "(", "ID2", ",", "TEXT2", ",", "TOKEN_INDEX2", ")", ";", "token3", "=", "newToken", "(", "ID3", ",", "TEXT3", ",", "TOKEN_INDEX3", ")", ";", "node4", "=", "new", "AnnisNode", "(", "ID4", ")", ";", "node5", "=", "new", "AnnisNode", "(", "ID5", ")", ";", "when", "(", "graph", ".", "getNodes", "(", ")", ")", ".", "thenReturn", "(", "Arrays", ".", "asList", "(", "token1", ",", "token2", ",", "token3", ",", "node4", ",", "node5", ")", ")", ";", "when", "(", "graph", ".", "getTokens", "(", ")", ")", ".", "thenReturn", "(", "Arrays", ".", "asList", "(", "token1", ",", "token2", ",", "token3", ")", ")", ";", "}", "@", "Test", "public", "void", "getTokenList", "(", ")", "{", "List", "<", "AnnisToken", ">", "expected", "=", "new", "ArrayList", "<", "AnnisToken", ">", "(", ")", ";", "expected", ".", "add", "(", "new", "AnnisTokenImpl", "(", "ID1", ",", "TEXT1", ",", "LEFT", ",", "RIGHT", ",", "TOKEN_INDEX1", ",", "1L", ")", ")", ";", "expected", ".", "add", "(", "new", "AnnisTokenImpl", "(", "ID2", ",", "TEXT2", ",", "LEFT", ",", "RIGHT", ",", "TOKEN_INDEX2", ",", "1L", ")", ")", ";", "expected", ".", "add", "(", "new", "AnnisTokenImpl", "(", "ID3", ",", "TEXT3", ",", "LEFT", ",", "RIGHT", ",", "TOKEN_INDEX3", ",", "1L", ")", ")", ";", "AnnisResult", "annisResult", "=", "new", "AnnisResultImpl", "(", "graph", ")", ";", "assertThat", "(", "annisResult", ".", "getTokenList", "(", ")", ",", "is", "(", "expected", ")", ")", ";", "}", "@", "Test", "public", "void", "getStartEndNodeId", "(", ")", "{", "AnnisResult", "annisResult", "=", "new", "AnnisResultImpl", "(", "graph", ")", ";", "assertThat", "(", "annisResult", ".", "getEndNodeId", "(", ")", ",", "is", "(", "ID3", ")", ")", ";", "}", "@", "Test", "public", "void", "getAnnotationLevelSet", "(", ")", "{", "token3", ".", "addNodeAnnotation", "(", "new", "Annotation", "(", "NAMESPACE", ",", "NAME1", ")", ")", ";", "node5", ".", "addNodeAnnotation", "(", "new", "Annotation", "(", "NAMESPACE", ",", "NAME2", ")", ")", ";", "AnnisResult", "annisResult", "=", "new", "AnnisResultImpl", "(", "graph", ")", ";", "Set", "<", "String", ">", "annotations", "=", "annisResult", ".", "getAnnotationLevelSet", "(", ")", ";", "assertThat", "(", "annotations", ",", "size", "(", "1", ")", ")", ";", "assertThat", "(", "annotations", ",", "hasItems", "(", "AnnisNode", ".", "qName", "(", "NAMESPACE", ",", "NAME2", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "getTokenAnnotationLevelSet", "(", ")", "{", "token3", ".", "addNodeAnnotation", "(", "new", "Annotation", "(", "NAMESPACE", ",", "NAME1", ")", ")", ";", "node5", ".", "addNodeAnnotation", "(", "new", "Annotation", "(", "NAMESPACE", ",", "NAME2", ")", ")", ";", "AnnisResult", "annisResult", "=", "new", "AnnisResultImpl", "(", "graph", ")", ";", "Set", "<", "String", ">", "tokenAnnotations", "=", "annisResult", ".", "getTokenAnnotationLevelSet", "(", ")", ";", "assertThat", "(", "tokenAnnotations", ",", "size", "(", "1", ")", ")", ";", "assertThat", "(", "tokenAnnotations", ",", "hasItems", "(", "AnnisNode", ".", "qName", "(", "NAMESPACE", ",", "NAME1", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "getMarkerIdMatchedNode", "(", ")", "{", "when", "(", "graph", ".", "getMatchedNodeIds", "(", ")", ")", ".", "thenReturn", "(", "new", "HashSet", "<", "Long", ">", "(", "Arrays", ".", "asList", "(", "ID1", ")", ")", ")", ";", "AnnisResult", "annisResult", "=", "new", "AnnisResultImpl", "(", "graph", ")", ";", "assertThat", "(", "annisResult", ".", "getMarkerId", "(", "ID1", ")", ",", "is", "(", "String", ".", "valueOf", "(", "ID1", ")", ")", ")", ";", "assertThat", "(", "annisResult", ".", "getMarkerId", "(", "ID2", ")", ",", "is", "(", "nullValue", "(", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "hasMarkerId", "(", ")", "{", "when", "(", "graph", ".", "getMatchedNodeIds", "(", ")", ")", ".", "thenReturn", "(", "new", "HashSet", "<", "Long", ">", "(", "Arrays", ".", "asList", "(", "ID1", ")", ")", ")", ";", "AnnisResult", "annisResult", "=", "new", "AnnisResultImpl", "(", "graph", ")", ";", "assertThat", "(", "annisResult", ".", "hasMarker", "(", "String", ".", "valueOf", "(", "ID1", ")", ")", ",", "is", "(", "true", ")", ")", ";", "assertThat", "(", "annisResult", ".", "hasMarker", "(", "String", ".", "valueOf", "(", "ID2", ")", ")", ",", "is", "(", "false", ")", ")", ";", "}", "private", "AnnisNode", "newToken", "(", "long", "id", ",", "String", "text", ",", "long", "tokenIndex", ")", "{", "AnnisNode", "n", "=", "new", "AnnisNode", "(", "id", ")", ";", "n", ".", "setSpannedText", "(", "text", ")", ";", "n", ".", "setTokenIndex", "(", "tokenIndex", ")", ";", "n", ".", "setLeft", "(", "LEFT", ")", ";", "n", ".", "setRight", "(", "RIGHT", ")", ";", "return", "n", ";", "}", "}", "</s>" ]
8,888
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "java", ".", "io", ".", "PrintWriter", ";", "import", "java", ".", "io", ".", "PushbackReader", ";", "import", "java", ".", "io", ".", "StringReader", ";", "import", "java", ".", "io", ".", "StringWriter", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "annis", ".", "ql", ".", "lexer", ".", "Lexer", ";", "import", "annis", ".", "ql", ".", "node", ".", "Node", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "public", "class", "TestSearchExpressionCounter", "{", "String", "input", "=", "\"\"", ";", "public", "void", "foo", "(", ")", "{", "Start", "start", "=", "parse", "(", "input", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "dumpTree", "(", "start", ")", ";", "start", ".", "apply", "(", "new", "SearchExpressionCounter", "(", ")", ")", ";", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "dumpTree", "(", "start", ")", ";", "}", "private", "Start", "parse", "(", "String", "input", ")", "{", "try", "{", "Parser", "parser", "=", "new", "Parser", "(", "new", "Lexer", "(", "new", "PushbackReader", "(", "new", "StringReader", "(", "input", ")", ")", ")", ")", ";", "Start", "start", "=", "parser", ".", "parse", "(", ")", ";", "return", "start", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "void", "dumpTree", "(", "Node", "node", ")", "{", "StringWriter", "writer", "=", "new", "StringWriter", "(", ")", ";", "TreeDumper", "dumper", "=", "new", "TreeDumper", "(", "new", "PrintWriter", "(", "writer", ")", ")", ";", "node", ".", "apply", "(", "dumper", ")", ";", "System", ".", "out", ".", "println", "(", "writer", ".", "toString", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "countSearchExpressions", "(", ")", "{", "Start", "start", "=", "parse", "(", "input", ")", ";", "SearchExpressionCounter", "analysis", "=", "new", "SearchExpressionCounter", "(", ")", ";", "start", ".", "apply", "(", "analysis", ")", ";", "int", "count", "=", "analysis", ".", "getCount", "(", ")", ";", "assertThat", "(", "count", ",", "is", "(", "3", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "++", "i", ")", "{", "int", "pos", "=", "i", "+", "1", ";", "Node", "node", "=", "analysis", ".", "getSearchExpression", "(", "pos", ")", ";", "assertThat", "(", "analysis", ".", "getPosition", "(", "node", ")", ",", "is", "(", "pos", ")", ")", ";", "}", "}", "}", "</s>" ]
8,889
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "not", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "sameInstance", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "inOrder", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "static", "annis", ".", "test", ".", "CustomMatcher", ".", "hasInstance", ";", "import", "static", "annis", ".", "test", ".", "TestUtils", ".", "empty", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Ignore", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "mockito", ".", "InOrder", ";", "import", "org", ".", "springframework", ".", "beans", ".", "BeansException", ";", "import", "org", ".", "springframework", ".", "beans", ".", "factory", ".", "annotation", ".", "Autowired", ";", "import", "org", ".", "springframework", ".", "context", ".", "ApplicationContext", ";", "import", "org", ".", "springframework", ".", "context", ".", "ApplicationContextAware", ";", "import", "org", ".", "springframework", ".", "test", ".", "context", ".", "ContextConfiguration", ";", "import", "org", ".", "springframework", ".", "test", ".", "context", ".", "junit4", ".", "SpringJUnit4ClassRunner", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "lexer", ".", "LexerException", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "import", "annis", ".", "ql", ".", "parser", ".", "AnnisParser", ".", "InternalParser", ";", "@", "RunWith", "(", "SpringJUnit4ClassRunner", ".", "class", ")", "@", "ContextConfiguration", "(", "locations", "=", "{", "\"\"", "}", ")", "public", "class", "TestAnnisParser", "implements", "ApplicationContextAware", "{", "private", "ApplicationContext", "ctx", ";", "private", "AnnisParser", "parser", ";", "@", "Autowired", "private", "AnnisParser", "springManagedParser", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "parser", "=", "new", "AnnisParser", "(", ")", ";", "}", "@", "Test", "public", "void", "postProcessors", "(", ")", "{", "assertCorrectPostProcessorList", "(", "parser", ")", ";", "}", "@", "Test", "public", "void", "springManagedPostProcessors", "(", ")", "{", "assertCorrectPostProcessorList", "(", "springManagedParser", ")", ";", "}", "private", "void", "assertCorrectPostProcessorList", "(", "AnnisParser", "parser", ")", "{", "List", "<", "DepthFirstAdapter", ">", "postProcessors", "=", "parser", ".", "getPostProcessors", "(", ")", ";", "assertThat", "(", "postProcessors", ",", "hasInstance", "(", "NodeSearchNormalizer", ".", "class", ")", ")", ";", "assertThat", "(", "postProcessors", ",", "hasInstance", "(", "TokenSearchNormalizer", ".", "class", ")", ")", ";", "assertThat", "(", "postProcessors", ",", "hasInstance", "(", "QueryValidator", ".", "class", ")", ")", ";", "}", "@", "Test", "public", "void", "parseAppliesPostProcessors", "(", ")", "throws", "ParserException", ",", "LexerException", ",", "IOException", "{", "final", "String", "ANNIS_QUERY", "=", "\"\"", ";", "final", "Start", "SYNTAX_TREE", "=", "new", "Start", "(", ")", ";", "InternalParser", "internalParser", "=", "mock", "(", "InternalParser", ".", "class", ")", ";", "when", "(", "internalParser", ".", "parse", "(", "ANNIS_QUERY", ")", ")", ".", "thenReturn", "(", "SYNTAX_TREE", ")", ";", "parser", ".", "setInternalParser", "(", "internalParser", ")", ";", "DepthFirstAdapter", "postProcessor1", "=", "mock", "(", "DepthFirstAdapter", ".", "class", ")", ";", "DepthFirstAdapter", "postProcessor2", "=", "mock", "(", "DepthFirstAdapter", ".", "class", ")", ";", "parser", ".", "setPostProcessors", "(", "Arrays", ".", "asList", "(", "postProcessor1", ",", "postProcessor2", ")", ")", ";", "parser", ".", "parse", "(", "ANNIS_QUERY", ")", ";", "InOrder", "inOrder", "=", "inOrder", "(", "postProcessor1", ",", "postProcessor2", ")", ";", "inOrder", ".", "verify", "(", "postProcessor1", ")", ".", "caseStart", "(", "SYNTAX_TREE", ")", ";", "inOrder", ".", "verify", "(", "postProcessor2", ")", ".", "caseStart", "(", "SYNTAX_TREE", ")", ";", "}", "@", "Test", "public", "void", "springManagedIsThreadSafe", "(", ")", "{", "assertThat", "(", "\"\"", ",", "springManagedParser", ".", "getPostProcessors", "(", ")", ",", "is", "(", "not", "(", "empty", "(", ")", ")", ")", ")", ";", "DepthFirstAdapter", "processor1", "=", "springManagedParser", ".", "getPostProcessors", "(", ")", ".", "get", "(", "0", ")", ";", "DepthFirstAdapter", "processor2", "=", "springManagedParser", ".", "getPostProcessors", "(", ")", ".", "get", "(", "0", ")", ";", "assertThat", "(", "processor1", ",", "is", "(", "not", "(", "sameInstance", "(", "processor2", ")", ")", ")", ")", ";", "InternalParser", "internalParser1", "=", "springManagedParser", ".", "getInternalParser", "(", ")", ";", "InternalParser", "internalParser2", "=", "springManagedParser", ".", "getInternalParser", "(", ")", ";", "assertThat", "(", "internalParser1", ",", "is", "(", "not", "(", "sameInstance", "(", "internalParser2", ")", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "springManagedIsSingleton", "(", ")", "{", "AnnisParser", "parser1", "=", "(", "AnnisParser", ")", "ctx", ".", "getBean", "(", "\"annisParser\"", ")", ";", "AnnisParser", "parser2", "=", "(", "AnnisParser", ")", "ctx", ".", "getBean", "(", "\"annisParser\"", ")", ";", "assertThat", "(", "parser1", ",", "is", "(", "sameInstance", "(", "parser2", ")", ")", ")", ";", "}", "@", "Ignore", "public", "void", "dump", "(", ")", "{", "System", ".", "out", ".", "println", "(", "springManagedParser", ".", "dumpTree", "(", "\"\"", ")", ")", ";", "}", "public", "void", "setApplicationContext", "(", "ApplicationContext", "applicationContext", ")", "throws", "BeansException", "{", "ctx", "=", "applicationContext", ";", "}", "}", "</s>" ]
8,890
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newAnnotationSearchExpr", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newStart", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newWildTextSpec", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newEqualAnnoValue", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "instanceOf", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "sameInstance", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnnotationSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AEqualAnnoValue", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AWildTextSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "public", "class", "TestTokenSearchNormalizer", "{", "@", "Test", "public", "void", "caseAnnotationSearchExprNormalSearch", "(", ")", "{", "AWildTextSpec", "textSpec", "=", "newWildTextSpec", "(", "\"hello\"", ")", ";", "AEqualAnnoValue", "annoValue", "=", "newEqualAnnoValue", "(", "textSpec", ")", ";", "AAnnotationSearchExpr", "expr", "=", "newAnnotationSearchExpr", "(", "\"pos\"", ",", "annoValue", ")", ";", "Start", "start", "=", "newStart", "(", "expr", ")", ";", "TokenSearchNormalizer", "normalizer", "=", "new", "TokenSearchNormalizer", "(", ")", ";", "start", ".", "apply", "(", "normalizer", ")", ";", "assertThat", "(", "start", ".", "getPExpr", "(", ")", ",", "is", "(", "instanceOf", "(", "AAnnotationSearchExpr", ".", "class", ")", ")", ")", ";", "assertThat", "(", "(", "AAnnotationSearchExpr", ")", "start", ".", "getPExpr", "(", ")", ",", "is", "(", "sameInstance", "(", "expr", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "caseAnnotationSearchExprTokenSearch", "(", ")", "{", "AWildTextSpec", "textSpec", "=", "newWildTextSpec", "(", "\"hello\"", ")", ";", "AEqualAnnoValue", "annoValue", "=", "newEqualAnnoValue", "(", "textSpec", ")", ";", "AAnnotationSearchExpr", "expr", "=", "newAnnotationSearchExpr", "(", "\"tok\"", ",", "annoValue", ")", ";", "Start", "start", "=", "newStart", "(", "expr", ")", ";", "TokenSearchNormalizer", "normalizer", "=", "new", "TokenSearchNormalizer", "(", ")", ";", "start", ".", "apply", "(", "normalizer", ")", ";", "assertThat", "(", "start", ".", "getPExpr", "(", ")", ",", "is", "(", "instanceOf", "(", "ATextSearchExpr", ".", "class", ")", ")", ")", ";", "ATextSearchExpr", "textSearchExpr", "=", "(", "ATextSearchExpr", ")", "start", ".", "getPExpr", "(", ")", ";", "assertThat", "(", "textSearchExpr", ".", "getTextSpec", "(", ")", ",", "is", "(", "instanceOf", "(", "AWildTextSpec", ".", "class", ")", ")", ")", ";", "assertThat", "(", "(", "AWildTextSpec", ")", "textSearchExpr", ".", "getTextSpec", "(", ")", ",", "is", "(", "sameInstance", "(", "textSpec", ")", ")", ")", ";", "}", "}", "</s>" ]
8,891
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAndExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnnotationSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnyNodeSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AArityLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ADirectDominanceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ADirectPrecedenceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ADominanceLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "AEdgeAnnotation", ";", "import", "annis", ".", "ql", ".", "node", ".", "AEdgeSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "AEqualAnnoValue", ";", "import", "annis", ".", "ql", ".", "node", ".", "AExactOverlapLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "AImplicitAndExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AInclusionLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "AIndirectDominanceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "AIndirectPrecedenceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALeftAlignLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALeftOverlapLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALinguisticConstraintExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AMetaConstraintExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AOrExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "APrecedenceLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARangeDominanceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARangePrecedenceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARangeSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARegexpTextSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARightAlignLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARootLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ASameAnnotationGroupLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ASiblingLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATextSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ATokenArityLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "AUnequalAnnoValue", ";", "import", "annis", ".", "ql", ".", "node", ".", "AWildTextSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "EOF", ";", "import", "annis", ".", "ql", ".", "node", ".", "PAnnoValue", ";", "import", "annis", ".", "ql", ".", "node", ".", "PDominanceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "PEdgeAnnotation", ";", "import", "annis", ".", "ql", ".", "node", ".", "PExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "PLingOp", ";", "import", "annis", ".", "ql", ".", "node", ".", "PPrecedenceSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "PRangeSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "PTextSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "import", "annis", ".", "ql", ".", "node", ".", "TDigits", ";", "import", "annis", ".", "ql", ".", "node", ".", "TId", ";", "import", "annis", ".", "ql", ".", "node", ".", "TRegexp", ";", "import", "annis", ".", "ql", ".", "node", ".", "TText", ";", "public", "class", "AstBuilder", "{", "public", "static", "Start", "newStart", "(", "PExpr", "expr", ")", "{", "Start", "n", "=", "new", "Start", "(", ")", ";", "n", ".", "setPExpr", "(", "expr", ")", ";", "n", ".", "setEOF", "(", "new", "EOF", "(", ")", ")", ";", "return", "n", ";", "}", "public", "static", "AMetaConstraintExpr", "newMetaConstraintExpr", "(", "String", "namespace", ",", "String", "name", ",", "String", "value", ")", "{", "AMetaConstraintExpr", "n", "=", "new", "AMetaConstraintExpr", "(", ")", ";", "n", ".", "setNamespace", "(", "newTId", "(", "namespace", ")", ")", ";", "n", ".", "setName", "(", "newTId", "(", "name", ")", ")", ";", "n", ".", "setValue", "(", "newEqualAnnoValue", "(", "newWildTextSpec", "(", "value", ")", ")", ")", ";", "return", "n", ";", "}", "public", "static", "AAnyNodeSearchExpr", "newAnyNodeSearchExpr", "(", ")", "{", "return", "new", "AAnyNodeSearchExpr", "(", ")", ";", "}", "public", "static", "AAnnotationSearchExpr", "newAnnotationSearchExpr", "(", "String", "type", ",", "PAnnoValue", "value", ")", "{", "AAnnotationSearchExpr", "n", "=", "new", "AAnnotationSearchExpr", "(", ")", ";", "n", ".", "setAnnoType", "(", "newTId", "(", "type", ")", ")", ";", "if", "(", "value", "!=", "null", ")", "n", ".", "setAnnoValue", "(", "value", ")", ";", "return", "n", ";", "}", "public", "static", "AAnnotationSearchExpr", "newAnnotationSearchExpr", "(", "String", "type", ")", "{", "return", "newAnnotationSearchExpr", "(", "type", ",", "null", ")", ";", "}", "public", "static", "ATextSearchExpr", "newTextSearchExpr", "(", "PTextSpec", "textSpec", ")", "{", "ATextSearchExpr", "n", "=", "new", "ATextSearchExpr", "(", ")", ";", "n", ".", "setTextSpec", "(", "textSpec", ")", ";", "return", "n", ";", "}", "public", "static", "ALinguisticConstraintExpr", "newLinguisticConstraintExpr", "(", ")", "{", "return", "newLinguisticConstraintExpr", "(", "null", ",", "null", ",", "null", ")", ";", "}", "public", "static", "ALinguisticConstraintExpr", "newLinguisticConstraintExpr", "(", "PLingOp", "operator", ",", "String", "lhs", ")", "{", "return", "newLinguisticConstraintExpr", "(", "operator", ",", "lhs", ",", "null", ")", ";", "}", "public", "static", "ALinguisticConstraintExpr", "newLinguisticConstraintExpr", "(", "PLingOp", "operator", ",", "String", "lhs", ",", "String", "rhs", ")", "{", "ALinguisticConstraintExpr", "n", "=", "new", "ALinguisticConstraintExpr", "(", ")", ";", "n", ".", "setLingOp", "(", "operator", ")", ";", "n", ".", "setLhs", "(", "newTDigits", "(", "lhs", ")", ")", ";", "n", ".", "setRhs", "(", "newTDigits", "(", "rhs", ")", ")", ";", "return", "n", ";", "}", "public", "static", "AAndExpr", "newAndExpr", "(", "PExpr", "...", "exprs", ")", "{", "AAndExpr", "n", "=", "new", "AAndExpr", "(", ")", ";", "n", ".", "setExpr", "(", "Arrays", ".", "asList", "(", "exprs", ")", ")", ";", "return", "n", ";", "}", "public", "static", "AOrExpr", "newOrExpr", "(", "PExpr", "...", "exprs", ")", "{", "AOrExpr", "n", "=", "new", "AOrExpr", "(", ")", ";", "n", ".", "setExpr", "(", "Arrays", ".", "asList", "(", "exprs", ")", ")", ";", "return", "n", ";", "}", "public", "static", "AImplicitAndExpr", "newImplicitAndExpr", "(", "List", "<", "PExpr", ">", "factors", ")", "{", "AImplicitAndExpr", "n", "=", "new", "AImplicitAndExpr", "(", ")", ";", "n", ".", "setExpr", "(", "factors", ")", ";", "return", "n", ";", "}", "public", "static", "AWildTextSpec", "newWildTextSpec", "(", "String", "text", ")", "{", "AWildTextSpec", "n", "=", "new", "AWildTextSpec", "(", ")", ";", "n", ".", "setText", "(", "new", "TText", "(", "text", ")", ")", ";", "return", "n", ";", "}", "public", "static", "ARegexpTextSpec", "newRegexpTextSpec", "(", "String", "regexp", ")", "{", "ARegexpTextSpec", "n", "=", "new", "ARegexpTextSpec", "(", ")", ";", "n", ".", "setRegexp", "(", "new", "TRegexp", "(", "regexp", ")", ")", ";", "return", "n", ";", "}", "public", "static", "AEqualAnnoValue", "newEqualAnnoValue", "(", "PTextSpec", "text", ")", "{", "AEqualAnnoValue", "n", "=", "new", "AEqualAnnoValue", "(", ")", ";", "n", ".", "setTextSpec", "(", "text", ")", ";", "return", "n", ";", "}", "public", "static", "AUnequalAnnoValue", "newUnequalAnnoValue", "(", "PTextSpec", "text", ")", "{", "AUnequalAnnoValue", "n", "=", "new", "AUnequalAnnoValue", "(", ")", ";", "n", ".", "setTextSpec", "(", "text", ")", ";", "return", "n", ";", "}", "public", "static", "ARootLingOp", "newRootLingOp", "(", ")", "{", "return", "new", "ARootLingOp", "(", ")", ";", "}", "public", "static", "AArityLingOp", "newArityLingOp", "(", "PRangeSpec", "rangeSpec", ")", "{", "AArityLingOp", "n", "=", "new", "AArityLingOp", "(", ")", ";", "n", ".", "setRangeSpec", "(", "rangeSpec", ")", ";", "return", "n", ";", "}", "public", "static", "ATokenArityLingOp", "newTokenArityLingOp", "(", "PRangeSpec", "rangeSpec", ")", "{", "ATokenArityLingOp", "n", "=", "new", "ATokenArityLingOp", "(", ")", ";", "n", ".", "setRangeSpec", "(", "rangeSpec", ")", ";", "return", "n", ";", "}", "public", "static", "AExactOverlapLingOp", "newExactOverlapLingOp", "(", ")", "{", "return", "new", "AExactOverlapLingOp", "(", ")", ";", "}", "public", "static", "ALeftAlignLingOp", "newLeftAlignLingOp", "(", ")", "{", "return", "new", "ALeftAlignLingOp", "(", ")", ";", "}", "public", "static", "ARightAlignLingOp", "newRightAlignLingOp", "(", ")", "{", "return", "new", "ARightAlignLingOp", "(", ")", ";", "}", "public", "static", "AInclusionLingOp", "newInclusionLingOp", "(", ")", "{", "return", "new", "AInclusionLingOp", "(", ")", ";", "}", "public", "static", "ALeftOverlapLingOp", "newLeftOverlapLingOp", "(", ")", "{", "return", "new", "ALeftOverlapLingOp", "(", ")", ";", "}", "public", "static", "APrecedenceLingOp", "newPrecedenceLingOp", "(", "PPrecedenceSpec", "precedenceSpec", ")", "{", "APrecedenceLingOp", "n", "=", "new", "APrecedenceLingOp", "(", ")", ";", "n", ".", "setPrecedenceSpec", "(", "precedenceSpec", ")", ";", "return", "n", ";", "}", "public", "static", "ADominanceLingOp", "newDominanceLingOp", "(", "PDominanceSpec", "dominanceSpec", ")", "{", "ADominanceLingOp", "n", "=", "new", "ADominanceLingOp", "(", ")", ";", "n", ".", "setDominanceSpec", "(", "dominanceSpec", ")", ";", "return", "n", ";", "}", "public", "static", "AEdgeSpec", "newEdgeSpec", "(", "PEdgeAnnotation", "...", "edgeAnnotations", ")", "{", "AEdgeSpec", "n", "=", "new", "AEdgeSpec", "(", ")", ";", "n", ".", "setEdgeAnnotation", "(", "Arrays", ".", "asList", "(", "edgeAnnotations", ")", ")", ";", "return", "n", ";", "}", "public", "static", "AEdgeAnnotation", "newEdgeAnnotation", "(", "String", "namespace", ",", "String", "name", ",", "PAnnoValue", "value", ")", "{", "AEdgeAnnotation", "n", "=", "new", "AEdgeAnnotation", "(", ")", ";", "n", ".", "setNamespace", "(", "newTId", "(", "namespace", ")", ")", ";", "n", ".", "setType", "(", "newTId", "(", "name", ")", ")", ";", "n", ".", "setValue", "(", "value", ")", ";", "return", "n", ";", "}", "public", "static", "AEdgeAnnotation", "newEdgeAnnotation", "(", "String", "name", ",", "PAnnoValue", "value", ")", "{", "return", "newEdgeAnnotation", "(", "null", ",", "name", ",", "value", ")", ";", "}", "public", "static", "AEdgeAnnotation", "newEdgeAnnotation", "(", "String", "namespace", ",", "String", "name", ")", "{", "return", "newEdgeAnnotation", "(", "namespace", ",", "name", ",", "null", ")", ";", "}", "public", "static", "AEdgeAnnotation", "newEdgeAnnotation", "(", "String", "name", ")", "{", "return", "newEdgeAnnotation", "(", "null", ",", "name", ")", ";", "}", "public", "static", "ASiblingLingOp", "newSiblingLingOp", "(", ")", "{", "return", "new", "ASiblingLingOp", "(", ")", ";", "}", "public", "static", "ASameAnnotationGroupLingOp", "newSameAnnotationGroupLingOp", "(", ")", "{", "return", "new", "ASameAnnotationGroupLingOp", "(", ")", ";", "}", "public", "static", "ARangeSpec", "newRangeSpec", "(", "String", "min", ",", "String", "max", ")", "{", "ARangeSpec", "n", "=", "new", "ARangeSpec", "(", ")", ";", "n", ".", "setMin", "(", "newTDigits", "(", "min", ")", ")", ";", "n", ".", "setMax", "(", "newTDigits", "(", "max", ")", ")", ";", "return", "n", ";", "}", "public", "static", "ARangeSpec", "newRangeSpec", "(", "String", "num", ")", "{", "return", "newRangeSpec", "(", "num", ",", "null", ")", ";", "}", "public", "static", "TId", "newTId", "(", "String", "id", ")", "{", "return", "(", "id", "==", "null", ")", "?", "(", "TId", ")", "null", ":", "new", "TId", "(", "id", ")", ";", "}", "public", "static", "TDigits", "newTDigits", "(", "String", "digits", ")", "{", "return", "(", "digits", "==", "null", ")", "?", "(", "TDigits", ")", "null", ":", "new", "TDigits", "(", "digits", ")", ";", "}", "public", "static", "ADirectPrecedenceSpec", "newDirectPrecedenceSpec", "(", ")", "{", "return", "new", "ADirectPrecedenceSpec", "(", ")", ";", "}", "public", "static", "AIndirectPrecedenceSpec", "newIndirectPrecedenceSpec", "(", ")", "{", "return", "new", "AIndirectPrecedenceSpec", "(", ")", ";", "}", "public", "static", "ARangePrecedenceSpec", "newRangePrecedenceSpec", "(", "PRangeSpec", "rangeSpec", ")", "{", "ARangePrecedenceSpec", "n", "=", "new", "ARangePrecedenceSpec", "(", ")", ";", "n", ".", "setRangeSpec", "(", "rangeSpec", ")", ";", "return", "n", ";", "}", "public", "static", "ADirectDominanceSpec", "newDirectDominanceSpec", "(", ")", "{", "return", "new", "ADirectDominanceSpec", "(", ")", ";", "}", "public", "static", "AIndirectDominanceSpec", "newIndirectDominanceSpec", "(", ")", "{", "return", "new", "AIndirectDominanceSpec", "(", ")", ";", "}", "public", "static", "ARangeDominanceSpec", "newRangeDominanceSpec", "(", "PRangeSpec", "rangeSpec", ")", "{", "ARangeDominanceSpec", "n", "=", "new", "ARangeDominanceSpec", "(", ")", ";", "n", ".", "setRangeSpec", "(", "rangeSpec", ")", ";", "return", "n", ";", "}", "}", "</s>" ]
8,892
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newAndExpr", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newAnnotationSearchExpr", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newAnyNodeSearchExpr", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newLinguisticConstraintExpr", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newMetaConstraintExpr", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newOrExpr", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newStart", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newTextSearchExpr", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newWildTextSpec", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "org", ".", "hamcrest", ".", "Description", ";", "import", "org", ".", "hamcrest", ".", "Matcher", ";", "import", "org", ".", "hamcrest", ".", "TypeSafeMatcher", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "annis", ".", "ql", ".", "node", ".", "PExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "import", "annis", ".", "ql", ".", "parser", ".", "AstComparator", ".", "DifferentTreeException", ";", "public", "class", "TestDnfTransformer", "{", "private", "DnfTransformer", "dnfTransformer", ";", "private", "PExpr", "leaf1", ";", "private", "PExpr", "leaf2", ";", "private", "PExpr", "leaf3", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "dnfTransformer", "=", "new", "DnfTransformer", "(", ")", ";", "leaf1", "=", "newAnnotationSearchExpr", "(", "\"leaf1\"", ")", ";", "leaf2", "=", "newAnnotationSearchExpr", "(", "\"leaf2\"", ")", ";", "leaf3", "=", "newAnnotationSearchExpr", "(", "\"leaf3\"", ")", ";", "}", "@", "Test", "public", "void", "metaConstraintIsNormalized", "(", ")", "{", "assertLeafExpressionIsNormalized", "(", "newMetaConstraintExpr", "(", "\"namespace\"", ",", "\"name\"", ",", "\"value\"", ")", ",", "false", ")", ";", "}", "@", "Test", "public", "void", "textSearchIsNormalized", "(", ")", "{", "assertLeafExpressionIsNormalized", "(", "newTextSearchExpr", "(", "newWildTextSpec", "(", "\"text\"", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "annotationSearchIsNormalized", "(", ")", "{", "assertLeafExpressionIsNormalized", "(", "newAnnotationSearchExpr", "(", "\"annotation\"", ")", ")", ";", "}", "@", "Test", "public", "void", "nodeSearchIsNormalized", "(", ")", "{", "assertLeafExpressionIsNormalized", "(", "newAnyNodeSearchExpr", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "linguisticOperationIsNormalized", "(", ")", "{", "PExpr", "expr", "=", "newLinguisticConstraintExpr", "(", ")", ";", "Start", "actual", "=", "newStart", "(", "expr", ")", ";", "actual", ".", "apply", "(", "dnfTransformer", ")", ";", "Start", "expected", "=", "newStart", "(", "expr", ")", ";", "assertThat", "(", "actual", ",", "sameTree", "(", "expected", ")", ")", ";", "}", "@", "Test", "public", "void", "nestedAnd", "(", ")", "{", "Start", "actual", "=", "newStart", "(", "newAndExpr", "(", "leaf1", ",", "newAndExpr", "(", "leaf2", ",", "leaf3", ")", ")", ")", ";", "Start", "expected", "=", "newStart", "(", "newAndExpr", "(", "clone", "(", "leaf1", ",", "leaf2", ",", "leaf3", ")", ")", ")", ";", "assertTreeAndLeafPosition", "(", "actual", ",", "expected", ")", ";", "}", "@", "Test", "public", "void", "nestedOr", "(", ")", "{", "Start", "actual", "=", "newStart", "(", "newOrExpr", "(", "leaf1", ",", "newOrExpr", "(", "leaf2", ",", "leaf3", ")", ")", ")", ";", "Start", "expected", "=", "newStart", "(", "newOrExpr", "(", "clone", "(", "leaf1", ",", "leaf2", ",", "leaf3", ")", ")", ")", ";", "assertTreeAndLeafPosition", "(", "actual", ",", "expected", ")", ";", "}", "@", "Test", "public", "void", "nestedOrInAnd", "(", ")", "{", "Start", "actual", "=", "newStart", "(", "newAndExpr", "(", "leaf1", ",", "newOrExpr", "(", "leaf2", ",", "leaf3", ")", ")", ")", ";", "Start", "expected", "=", "newStart", "(", "newOrExpr", "(", "newAndExpr", "(", "clone", "(", "leaf1", ",", "leaf2", ")", ")", ",", "newAndExpr", "(", "clone", "(", "leaf1", ",", "leaf3", ")", ")", ")", ")", ";", "assertTreeAndLeafPosition", "(", "actual", ",", "expected", ")", ";", "}", "@", "Test", "public", "void", "nestedAndInOr", "(", ")", "{", "Start", "actual", "=", "newStart", "(", "newOrExpr", "(", "leaf1", ",", "newAndExpr", "(", "leaf2", ",", "leaf3", ")", ")", ")", ";", "Start", "expected", "=", "newStart", "(", "newOrExpr", "(", "clone", "(", "leaf1", ")", ",", "newAndExpr", "(", "clone", "(", "leaf2", ",", "leaf3", ")", ")", ")", ")", ";", "assertTreeAndLeafPosition", "(", "actual", ",", "expected", ")", ";", "}", "private", "Matcher", "<", "Start", ">", "sameTree", "(", "final", "Start", "expected", ")", "{", "return", "new", "TypeSafeMatcher", "<", "Start", ">", "(", ")", "{", "@", "Override", "public", "boolean", "matchesSafely", "(", "Start", "item", ")", "{", "try", "{", "item", ".", "apply", "(", "new", "AstComparator", "(", "expected", ")", ")", ";", "}", "catch", "(", "DifferentTreeException", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "public", "void", "describeTo", "(", "Description", "description", ")", "{", "description", ".", "appendText", "(", "\"\"", "+", "AnnisParser", ".", "dumpTree", "(", "expected", ")", ")", ";", "}", "}", ";", "}", "private", "void", "assertLeafExpressionIsNormalized", "(", "PExpr", "expr", ")", "{", "assertLeafExpressionIsNormalized", "(", "expr", ",", "true", ")", ";", "}", "private", "void", "assertLeafExpressionIsNormalized", "(", "PExpr", "expr", ",", "boolean", "rememberPosition", ")", "{", "Start", "actual", "=", "newStart", "(", "expr", ")", ";", "actual", ".", "apply", "(", "dnfTransformer", ")", ";", "Start", "expected", "=", "newStart", "(", "expr", ")", ";", "assertThat", "(", "actual", ",", "sameTree", "(", "expected", ")", ")", ";", "if", "(", "rememberPosition", ")", "assertThat", "(", "dnfTransformer", ".", "getPosition", "(", "expr", ")", ",", "is", "(", "1", ")", ")", ";", "else", "assertThat", "(", "dnfTransformer", ".", "getPosition", "(", "expr", ")", ",", "is", "(", "-", "1", ")", ")", ";", "}", "private", "void", "assertTreeAndLeafPosition", "(", "Start", "actual", ",", "Start", "expected", ")", "{", "actual", ".", "apply", "(", "dnfTransformer", ")", ";", "assertThat", "(", "actual", ",", "sameTree", "(", "expected", ")", ")", ";", "assertThat", "(", "dnfTransformer", ".", "getPosition", "(", "leaf1", ")", ",", "is", "(", "1", ")", ")", ";", "assertThat", "(", "dnfTransformer", ".", "getPosition", "(", "leaf2", ")", ",", "is", "(", "2", ")", ")", ";", "assertThat", "(", "dnfTransformer", ".", "getPosition", "(", "leaf3", ")", ",", "is", "(", "3", ")", ")", ";", "}", "private", "PExpr", "clone", "(", "PExpr", "expr", ")", "{", "return", "(", "PExpr", ")", "expr", ".", "clone", "(", ")", ";", "}", "private", "PExpr", "[", "]", "clone", "(", "PExpr", "...", "exprs", ")", "{", "PExpr", "[", "]", "result", "=", "new", "PExpr", "[", "exprs", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "exprs", ".", "length", ";", "++", "i", ")", "result", "[", "i", "]", "=", "(", "PExpr", ")", "exprs", "[", "i", "]", ".", "clone", "(", ")", ";", "return", "result", ";", "}", "}", "</s>" ]
8,893
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "java", ".", "lang", ".", "reflect", ".", "InvocationTargetException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "annis", ".", "ql", ".", "analysis", ".", "DepthFirstAdapter", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnnotationSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ALinguisticConstraintExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARangeSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "ARegexpTextSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "AWildTextSpec", ";", "import", "annis", ".", "ql", ".", "node", ".", "Node", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "import", "annis", ".", "ql", ".", "node", ".", "Token", ";", "public", "class", "AstComparator", "extends", "DepthFirstAdapter", "{", "@", "SuppressWarnings", "(", "\"serial\"", ")", "public", "static", "class", "DifferentTreeException", "extends", "RuntimeException", "{", "public", "DifferentTreeException", "(", "String", "msg", ")", "{", "super", "(", "msg", ")", ";", "}", "public", "DifferentTreeException", "(", "String", "msg", ",", "String", "expected", ",", "String", "actual", ")", "{", "super", "(", "msg", "+", "\"\"", "+", "expected", "+", "\">;", "was:", "<\"", "+", "actual", "+", "\">\"", ")", ";", "}", "}", ";", "private", "final", "List", "<", "Node", ">", "nodes", ";", "public", "AstComparator", "(", "Node", "expectedTree", ")", "{", "this", ".", "nodes", "=", "pushNodesToStack", "(", "expectedTree", ")", ";", "}", "@", "Override", "public", "void", "defaultIn", "(", "Node", "node", ")", "{", "popNode", "(", "node", ".", "getClass", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "outStart", "(", "Start", "node", ")", "{", "if", "(", "nodes", ".", "isEmpty", "(", ")", ")", "return", ";", "throw", "new", "DifferentTreeException", "(", "\"\"", "+", "nodes", ".", "get", "(", "0", ")", ".", "getClass", "(", ")", ")", ";", "}", "@", "Override", "public", "void", "inAAnnotationSearchExpr", "(", "AAnnotationSearchExpr", "node", ")", "{", "String", "[", "]", "terminals", "=", "{", "\"anno_type\"", "}", ";", "checkTerminals", "(", "node", ",", "terminals", ")", ";", "}", "@", "Override", "public", "void", "inAWildTextSpec", "(", "AWildTextSpec", "node", ")", "{", "checkTerminal", "(", "node", ",", "\"text\"", ")", ";", "}", "@", "Override", "public", "void", "inARegexpTextSpec", "(", "ARegexpTextSpec", "node", ")", "{", "checkTerminal", "(", "node", ",", "\"regexp\"", ")", ";", "}", "@", "Override", "public", "void", "inALinguisticConstraintExpr", "(", "ALinguisticConstraintExpr", "node", ")", "{", "String", "[", "]", "terminals", "=", "{", "\"lhs\"", ",", "\"rhs\"", "}", ";", "checkTerminals", "(", "node", ",", "terminals", ")", ";", "}", "@", "Override", "public", "void", "inARangeSpec", "(", "ARangeSpec", "node", ")", "{", "String", "[", "]", "terminals", "=", "{", "\"min\"", ",", "\"max\"", "}", ";", "checkTerminals", "(", "node", ",", "terminals", ")", ";", "}", "private", "List", "<", "Node", ">", "pushNodesToStack", "(", "Node", "root", ")", "{", "final", "List", "<", "Node", ">", "nodes", "=", "new", "ArrayList", "<", "Node", ">", "(", ")", ";", "root", ".", "apply", "(", "new", "DepthFirstAdapter", "(", ")", "{", "@", "Override", "public", "void", "defaultIn", "(", "Node", "node", ")", "{", "nodes", ".", "add", "(", "node", ")", ";", "}", "}", ")", ";", "return", "nodes", ";", "}", "private", "Node", "popNode", "(", "Class", "<", "?", ">", "nodeClass", ")", "{", "if", "(", "nodes", ".", "isEmpty", "(", ")", ")", "throw", "new", "DifferentTreeException", "(", "\"\"", ")", ";", "Node", "node", "=", "nodes", ".", "remove", "(", "0", ")", ";", "if", "(", "nodeClass", ".", "isInstance", "(", "node", ")", ")", "return", "node", ";", "throw", "new", "DifferentTreeException", "(", "\"\"", ",", "node", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "nodeClass", ".", "getName", "(", ")", ")", ";", "}", "private", "void", "checkTerminals", "(", "Node", "node", ",", "String", "[", "]", "terminals", ")", "{", "Node", "other", "=", "popNode", "(", "node", ".", "getClass", "(", ")", ")", ";", "for", "(", "String", "terminal", ":", "terminals", ")", "{", "try", "{", "String", "methodName", "=", "terminalAccessorMethodName", "(", "terminal", ")", ";", "Method", "actualTerminalAccessor", "=", "node", ".", "getClass", "(", ")", ".", "getMethod", "(", "methodName", ",", "new", "Class", "[", "]", "{", "}", ")", ";", "Method", "expectedTerminalAccessor", "=", "other", ".", "getClass", "(", ")", ".", "getMethod", "(", "methodName", ",", "new", "Class", "[", "]", "{", "}", ")", ";", "Token", "actualToken", "=", "(", "Token", ")", "actualTerminalAccessor", ".", "invoke", "(", "node", ",", "new", "Object", "[", "]", "{", "}", ")", ";", "Token", "expectedToken", "=", "(", "Token", ")", "expectedTerminalAccessor", ".", "invoke", "(", "other", ",", "new", "Object", "[", "]", "{", "}", ")", ";", "if", "(", "actualToken", "==", "null", "&&", "expectedToken", "==", "null", ")", "continue", ";", "if", "(", "actualToken", "==", "null", ")", "throw", "new", "DifferentTreeException", "(", "\"\"", "+", "terminal", ",", "expectedToken", ".", "getText", "(", ")", ",", "null", ")", ";", "if", "(", "expectedToken", "==", "null", ")", "throw", "new", "DifferentTreeException", "(", "\"\"", "+", "terminal", ",", "null", ",", "actualToken", ".", "getText", "(", ")", ")", ";", "String", "actual", "=", "actualToken", ".", "getText", "(", ")", ";", "String", "expected", "=", "expectedToken", ".", "getText", "(", ")", ";", "if", "(", "!", "expected", ".", "equals", "(", "actual", ")", ")", "throw", "new", "DifferentTreeException", "(", "\"\"", "+", "terminal", ",", "expected", ",", "actual", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "DifferentTreeException", "(", "\"\"", "+", "terminal", ")", ";", "}", "catch", "(", "SecurityException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "RuntimeException", "(", "\"BUG!\"", ",", "e", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "RuntimeException", "(", "\"BUG!\"", ",", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "RuntimeException", "(", "\"BUG!\"", ",", "e", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "RuntimeException", "(", "\"BUG!\"", ",", "e", ")", ";", "}", "}", "}", "private", "void", "checkTerminal", "(", "Node", "node", ",", "String", "terminal", ")", "{", "checkTerminals", "(", "node", ",", "new", "String", "[", "]", "{", "terminal", "}", ")", ";", "}", "public", "String", "terminalAccessorMethodName", "(", "String", "terminal", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"get\"", ")", ";", "int", "i", "=", "0", ";", "int", "last", "=", "0", ";", "while", "(", "true", ")", "{", "i", "=", "terminal", ".", "indexOf", "(", "\"_\"", ",", "last", ")", ";", "if", "(", "i", "==", "-", "1", ")", "break", ";", "sb", ".", "append", "(", "terminal", ".", "substring", "(", "last", ",", "last", "+", "1", ")", ".", "toUpperCase", "(", ")", ")", ";", "sb", ".", "append", "(", "terminal", ".", "substring", "(", "last", "+", "1", ",", "i", ")", ")", ";", "last", "=", "i", "+", "1", ";", "}", "if", "(", "last", "<", "terminal", ".", "length", "(", ")", ")", "{", "sb", ".", "append", "(", "terminal", ".", "substring", "(", "last", ",", "last", "+", "1", ")", ".", "toUpperCase", "(", ")", ")", ";", "sb", ".", "append", "(", "terminal", ".", "substring", "(", "last", "+", "1", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
8,894
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "not", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "nullValue", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "sameInstance", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "static", "org", ".", "mockito", ".", "BDDMockito", ".", "given", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "inOrder", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verify", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "verifyZeroInteractions", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "static", "org", ".", "mockito", ".", "MockitoAnnotations", ".", "initMocks", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "mockito", ".", "InOrder", ";", "import", "org", ".", "mockito", ".", "InjectMocks", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "org", ".", "springframework", ".", "beans", ".", "factory", ".", "annotation", ".", "Autowired", ";", "import", "org", ".", "springframework", ".", "test", ".", "context", ".", "ContextConfiguration", ";", "import", "org", ".", "springframework", ".", "test", ".", "context", ".", "junit4", ".", "SpringJUnit4ClassRunner", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAndExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "PExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "@", "RunWith", "(", "SpringJUnit4ClassRunner", ".", "class", ")", "@", "ContextConfiguration", "(", "locations", "=", "{", "\"\"", "}", ")", "public", "class", "TestQueryAnalysis", "{", "@", "InjectMocks", "private", "QueryAnalysis", "queryAnalysis", "=", "new", "QueryAnalysis", "(", ")", ";", "@", "Mock", "private", "DnfTransformer", "dnfTransformer", ";", "@", "Mock", "private", "ClauseAnalysis", "clauseAnalysis", ";", "@", "Mock", "private", "NodeRelationNormalizer", "nodeRelationNormalizer", ";", "@", "Autowired", "private", "QueryAnalysis", "springManagedQueryAnalysis", ";", "private", "Start", "statement", "=", "new", "Start", "(", ")", ";", "private", "ArrayList", "<", "Long", ">", "corpusList", "=", "new", "ArrayList", "<", "Long", ">", "(", ")", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "initMocks", "(", "this", ")", ";", "}", "@", "Test", "public", "void", "shouldDuplicateNodesInEdgeRelations", "(", ")", "{", "queryAnalysis", ".", "setNormalizeNodesInEdgeRelations", "(", "true", ")", ";", "AAndExpr", "clause1", "=", "new", "AAndExpr", "(", ")", ";", "AAndExpr", "clause2", "=", "new", "AAndExpr", "(", ")", ";", "setupStatement", "(", "statement", ",", "clause1", ",", "clause2", ")", ";", "queryAnalysis", ".", "analyzeQuery", "(", "statement", ",", "corpusList", ")", ";", "verify", "(", "nodeRelationNormalizer", ")", ".", "caseAAndExpr", "(", "clause1", ")", ";", "verify", "(", "nodeRelationNormalizer", ")", ".", "caseAAndExpr", "(", "clause2", ")", ";", "}", "@", "Test", "public", "void", "shouldNotDuplicateNodesInEdgeRelations", "(", ")", "{", "queryAnalysis", ".", "setNormalizeNodesInEdgeRelations", "(", "false", ")", ";", "AAndExpr", "clause1", "=", "new", "AAndExpr", "(", ")", ";", "AAndExpr", "clause2", "=", "new", "AAndExpr", "(", ")", ";", "setupStatement", "(", "statement", ",", "clause1", ",", "clause2", ")", ";", "queryAnalysis", ".", "analyzeQuery", "(", "statement", ",", "corpusList", ")", ";", "verifyZeroInteractions", "(", "nodeRelationNormalizer", ")", ";", "}", "private", "void", "setupStatement", "(", "Start", "statement", ",", "PExpr", "...", "exprs", ")", "{", "ArrayList", "<", "PExpr", ">", "clauses", "=", "new", "ArrayList", "<", "PExpr", ">", "(", ")", ";", "for", "(", "PExpr", "expr", ":", "exprs", ")", "{", "clauses", ".", "add", "(", "expr", ")", ";", "}", "given", "(", "dnfTransformer", ".", "listClauses", "(", "statement", ")", ")", ".", "willReturn", "(", "clauses", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Test", "public", "void", "analyzeQuery", "(", ")", "{", "final", "Start", "statement", "=", "new", "Start", "(", ")", ";", "final", "ArrayList", "<", "PExpr", ">", "clauses", "=", "new", "ArrayList", "<", "PExpr", ">", "(", ")", ";", "AAndExpr", "clause1", "=", "new", "AAndExpr", "(", ")", ";", "clauses", ".", "add", "(", "clause1", ")", ";", "AAndExpr", "clause2", "=", "new", "AAndExpr", "(", ")", ";", "clauses", ".", "add", "(", "clause2", ")", ";", "when", "(", "dnfTransformer", ".", "listClauses", "(", "statement", ")", ")", ".", "thenReturn", "(", "clauses", ")", ";", "final", "Integer", "columnWidth", "=", "new", "Integer", "(", "5", ")", ";", "when", "(", "clauseAnalysis", ".", "nodesCount", "(", ")", ")", ".", "thenReturn", "(", "columnWidth", ")", ";", "QueryNode", "node1", "=", "mock", "(", "QueryNode", ".", "class", ")", ";", "QueryNode", "node2", "=", "mock", "(", "QueryNode", ".", "class", ")", ";", "List", "<", "QueryNode", ">", "nodes1", "=", "Arrays", ".", "asList", "(", "node1", ")", ";", "List", "<", "QueryNode", ">", "nodes2", "=", "Arrays", ".", "asList", "(", "node2", ")", ";", "when", "(", "clauseAnalysis", ".", "getNodes", "(", ")", ")", ".", "thenReturn", "(", "nodes1", ",", "nodes2", ")", ";", "QueryAnnotation", "annotation1", "=", "mock", "(", "QueryAnnotation", ".", "class", ")", ";", "QueryAnnotation", "annotation2", "=", "mock", "(", "QueryAnnotation", ".", "class", ")", ";", "List", "<", "QueryAnnotation", ">", "annotations1", "=", "Arrays", ".", "asList", "(", "annotation1", ")", ";", "List", "<", "QueryAnnotation", ">", "annotations2", "=", "Arrays", ".", "asList", "(", "annotation2", ")", ";", "when", "(", "clauseAnalysis", ".", "getMetaAnnotations", "(", ")", ")", ".", "thenReturn", "(", "annotations1", ",", "annotations2", ")", ";", "List", "<", "Long", ">", "corpusList", "=", "new", "ArrayList", "<", "Long", ">", "(", ")", ";", "QueryData", "queryData", "=", "queryAnalysis", ".", "analyzeQuery", "(", "statement", ",", "corpusList", ")", ";", "assertThat", "(", "queryData", ".", "getCorpusList", "(", ")", ",", "is", "(", "corpusList", ")", ")", ";", "assertThat", "(", "queryData", ".", "getAlternatives", "(", ")", ",", "is", "(", "Arrays", ".", "asList", "(", "nodes1", ",", "nodes2", ")", ")", ")", ";", "assertThat", "(", "queryData", ".", "getMaxWidth", "(", ")", ",", "is", "(", "columnWidth", ")", ")", ";", "assertThat", "(", "queryData", ".", "getMetaData", "(", ")", ",", "is", "(", "Arrays", ".", "asList", "(", "annotation1", ",", "annotation2", ")", ")", ")", ";", "InOrder", "inOrder", "=", "inOrder", "(", "dnfTransformer", ",", "clauseAnalysis", ")", ";", "inOrder", ".", "verify", "(", "dnfTransformer", ")", ".", "caseStart", "(", "statement", ")", ";", "inOrder", ".", "verify", "(", "dnfTransformer", ")", ".", "listClauses", "(", "statement", ")", ";", "inOrder", ".", "verify", "(", "clauseAnalysis", ")", ".", "caseAAndExpr", "(", "clause1", ")", ";", "inOrder", ".", "verify", "(", "clauseAnalysis", ")", ".", "nodesCount", "(", ")", ";", "inOrder", ".", "verify", "(", "clauseAnalysis", ")", ".", "caseAAndExpr", "(", "clause2", ")", ";", "inOrder", ".", "verify", "(", "clauseAnalysis", ")", ".", "nodesCount", "(", ")", ";", "}", "@", "Test", "public", "void", "springManagedInstanceHasAllDependencies", "(", ")", "{", "assertThat", "(", "springManagedQueryAnalysis", ".", "getClauseAnalysis", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedQueryAnalysis", ".", "getDnfTransformer", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "assertThat", "(", "springManagedQueryAnalysis", ".", "getNodeRelationNormalizer", "(", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "springManagedInstanceIsThreadSafe", "(", ")", "{", "ClauseAnalysis", "clauseAnalysis1", "=", "springManagedQueryAnalysis", ".", "getClauseAnalysis", "(", ")", ";", "ClauseAnalysis", "clauseAnalysis2", "=", "springManagedQueryAnalysis", ".", "getClauseAnalysis", "(", ")", ";", "assertThat", "(", "clauseAnalysis1", ",", "is", "(", "not", "(", "sameInstance", "(", "clauseAnalysis2", ")", ")", ")", ")", ";", "DnfTransformer", "dnfTransformer1", "=", "springManagedQueryAnalysis", ".", "getDnfTransformer", "(", ")", ";", "DnfTransformer", "dnfTransformer2", "=", "springManagedQueryAnalysis", ".", "getDnfTransformer", "(", ")", ";", "assertThat", "(", "dnfTransformer1", ",", "is", "(", "not", "(", "sameInstance", "(", "dnfTransformer2", ")", ")", ")", ")", ";", "NodeRelationNormalizer", "nodeRelationNormalizer1", "=", "springManagedQueryAnalysis", ".", "getNodeRelationNormalizer", "(", ")", ";", "NodeRelationNormalizer", "nodeRelationNormalizer2", "=", "springManagedQueryAnalysis", ".", "getNodeRelationNormalizer", "(", ")", ";", "assertThat", "(", "nodeRelationNormalizer1", ",", "is", "(", "not", "(", "sameInstance", "(", "nodeRelationNormalizer2", ")", ")", ")", ")", ";", "}", "}", "</s>" ]
8,895
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "not", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "nullValue", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "fail", ";", "import", "static", "annis", ".", "test", ".", "TestHelper", ".", "springFiles", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "BeforeClass", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "Theories", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "Theory", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "springframework", ".", "context", ".", "ApplicationContext", ";", "import", "org", ".", "springframework", ".", "context", ".", "support", ".", "ClassPathXmlApplicationContext", ";", "import", "annis", ".", "test", ".", "SpringQueryExamples", ";", "import", "annis", ".", "test", ".", "SpringSyntaxTreeExamples", ";", "import", "annis", ".", "test", ".", "SyntaxTreeExample", ";", "import", "annis", ".", "exceptions", ".", "AnnisException", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "@", "RunWith", "(", "Theories", ".", "class", ")", "public", "class", "TestAnnisParserExamples", "{", "private", "static", "final", "String", "EXAMPLES", "=", "\"\"", ";", "static", "ApplicationContext", "ctx", ";", "private", "AnnisParser", "parser", ";", "@", "BeforeClass", "public", "static", "void", "loadApplicationContext", "(", ")", "{", "final", "String", "[", "]", "ctxFiles", "=", "springFiles", "(", "TestAnnisParserExamples", ".", "class", ",", "\"\"", ")", ";", "ctx", "=", "new", "ClassPathXmlApplicationContext", "(", "ctxFiles", ")", ";", "}", "@", "Before", "public", "void", "setup", "(", ")", "{", "parser", "=", "(", "AnnisParser", ")", "ctx", ".", "getBean", "(", "\"annisParser\"", ")", ";", "}", "@", "Theory", "public", "void", "testSyntaxTrees", "(", "@", "SpringSyntaxTreeExamples", "(", "exampleMap", "=", "\"\"", ",", "contextLocation", "=", "EXAMPLES", ")", "SyntaxTreeExample", "example", ")", "{", "Start", "syntaxTree", "=", "parser", ".", "parse", "(", "example", ".", "getQuery", "(", ")", ")", ";", "assertThat", "(", "syntaxTree", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "String", "actual", "=", "parser", ".", "dumpTree", "(", "syntaxTree", ")", ".", "trim", "(", ")", ";", "String", "provided", "=", "example", ".", "getSyntaxTree", "(", ")", ".", "replaceAll", "(", "\"n\"", ",", "System", ".", "getProperty", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "\"\"", "+", "example", ".", "getQuery", "(", ")", ",", "provided", ",", "actual", ")", ";", "}", "@", "Theory", "public", "void", "testGoodQueries", "(", "@", "SpringQueryExamples", "(", "exampleList", "=", "\"good\"", ",", "contextLocation", "=", "EXAMPLES", ")", "String", "annisQuery", ")", "{", "assertThat", "(", "parser", ".", "parse", "(", "annisQuery", ")", ",", "is", "(", "not", "(", "nullValue", "(", ")", ")", ")", ")", ";", "}", "@", "Theory", "public", "void", "testBadQueries", "(", "@", "SpringQueryExamples", "(", "exampleList", "=", "\"bad\"", ",", "contextLocation", "=", "EXAMPLES", ")", "String", "annisQuery", ")", "{", "try", "{", "parser", ".", "parse", "(", "annisQuery", ")", ";", "fail", "(", "\"\"", "+", "annisQuery", ")", ";", "}", "catch", "(", "AnnisException", "e", ")", "{", "}", "}", "}", "</s>" ]
8,896
[ "<s>", "package", "annis", ".", "ql", ".", "parser", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newAnnotationSearchExpr", ";", "import", "static", "annis", ".", "ql", ".", "parser", ".", "AstBuilder", ".", "newStart", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "allOf", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "instanceOf", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "sameInstance", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnnotationSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "AAnyNodeSearchExpr", ";", "import", "annis", ".", "ql", ".", "node", ".", "Start", ";", "public", "class", "TestNodeSearchNormalizer", "{", "private", "NodeSearchNormalizer", "nodeSearchNormalizer", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "nodeSearchNormalizer", "=", "new", "NodeSearchNormalizer", "(", ")", ";", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Test", "public", "void", "caseAAnnotationSearchNormal", "(", ")", "{", "AAnnotationSearchExpr", "anno", "=", "newAnnotationSearchExpr", "(", "\"foo\"", ")", ";", "Start", "start", "=", "newStart", "(", "anno", ")", ";", "start", ".", "apply", "(", "nodeSearchNormalizer", ")", ";", "assertThat", "(", "start", ".", "getPExpr", "(", ")", ",", "allOf", "(", "instanceOf", "(", "AAnnotationSearchExpr", ".", "class", ")", ",", "sameInstance", "(", "anno", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "caseAAnnotationSearchNodeSearch", "(", ")", "{", "Start", "start", "=", "newStart", "(", "newAnnotationSearchExpr", "(", "\"node\"", ")", ")", ";", "start", ".", "apply", "(", "nodeSearchNormalizer", ")", ";", "assertThat", "(", "start", ".", "getPExpr", "(", ")", ",", "is", "(", "instanceOf", "(", "AAnyNodeSearchExpr", ".", "class", ")", ")", ")", ";", "}", "}", "</s>" ]
8,897
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "between", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "isNotNull", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "isNull", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "join", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "numberJoin", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "sqlString", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "COMPONENT_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "EDGE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_ANNOTATION_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "NODE_TABLE", ";", "import", "static", "annis", ".", "sqlgen", ".", "TableAccessStrategy", ".", "RANK_TABLE", ";", "import", "static", "annis", ".", "test", ".", "TestUtils", ".", "size", ";", "import", "static", "annis", ".", "test", ".", "TestUtils", ".", "uniqueInt", ";", "import", "static", "annis", ".", "test", ".", "TestUtils", ".", "uniqueLong", ";", "import", "static", "annis", ".", "test", ".", "TestUtils", ".", "uniqueString", ";", "import", "static", "java", ".", "util", ".", "Arrays", ".", "asList", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "static", "org", ".", "junit", ".", "matchers", ".", "JUnitMatchers", ".", "hasItem", ";", "import", "static", "org", ".", "mockito", ".", "BDDMockito", ".", "given", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "static", "org", ".", "mockito", ".", "MockitoAnnotations", ".", "initMocks", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "DataPoints", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "Theories", ";", "import", "org", ".", "junit", ".", "experimental", ".", "theories", ".", "Theory", ";", "import", "org", ".", "junit", ".", "runner", ".", "RunWith", ";", "import", "org", ".", "mockito", ".", "Mock", ";", "import", "annis", ".", "model", ".", "QueryAnnotation", ";", "import", "annis", ".", "model", ".", "QueryNode", ";", "import", "annis", ".", "model", ".", "QueryNode", ".", "TextMatching", ";", "import", "annis", ".", "ql", ".", "parser", ".", "QueryData", ";", "import", "annis", ".", "sqlgen", ".", "annopool", ".", "ApAnnotationConditionProvider", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "CommonAncestor", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Dominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Identical", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Inclusion", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftAlignment", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftDominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "LeftOverlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Overlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "PointingRelation", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Precedence", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightAlignment", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightDominance", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "RightOverlap", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "SameSpan", ";", "import", "annis", ".", "sqlgen", ".", "model", ".", "Sibling", ";", "@", "RunWith", "(", "Theories", ".", "class", ")", "public", "class", "TestDefaultWhereClauseGenerator", "{", "private", "QueryNode", "node23", ";", "private", "QueryNode", "node42", ";", "private", "DefaultWhereClauseGenerator", "generator", ";", "@", "Mock", "private", "Set", "<", "QueryAnnotation", ">", "annotations", ";", "@", "DataPoints", "public", "final", "static", "String", "[", "]", "componentPredicates", "=", "{", "\"lhs\"", ",", "\"rhs\"", ",", "\"both\"", "}", ";", "@", "Mock", "private", "QueryData", "queryData", ";", "@", "Before", "public", "void", "setup", "(", ")", "{", "initMocks", "(", "this", ")", ";", "node23", "=", "new", "QueryNode", "(", "23", ")", ";", "node42", "=", "new", "QueryNode", "(", "42", ")", ";", "final", "TableAccessStrategy", "tableAccessStrategy", "=", "new", "TableAccessStrategy", "(", ")", ";", "tableAccessStrategy", ".", "addTableAlias", "(", "NODE_TABLE", ",", "\"_node\"", ")", ";", "tableAccessStrategy", ".", "addTableAlias", "(", "COMPONENT_TABLE", ",", "\"_component\"", ")", ";", "tableAccessStrategy", ".", "addTableAlias", "(", "RANK_TABLE", ",", "\"_rank\"", ")", ";", "tableAccessStrategy", ".", "addTableAlias", "(", "NODE_ANNOTATION_TABLE", ",", "\"_annotation\"", ")", ";", "tableAccessStrategy", ".", "addTableAlias", "(", "EDGE_ANNOTATION_TABLE", ",", "\"\"", ")", ";", "tableAccessStrategy", ".", "addColumnAlias", "(", "NODE_ANNOTATION_TABLE", ",", "\"namespace\"", ",", "\"\"", ")", ";", "tableAccessStrategy", ".", "addColumnAlias", "(", "NODE_ANNOTATION_TABLE", ",", "\"name\"", ",", "\"\"", ")", ";", "tableAccessStrategy", ".", "addColumnAlias", "(", "NODE_ANNOTATION_TABLE", ",", "\"value\"", ",", "\"\"", ")", ";", "tableAccessStrategy", ".", "addColumnAlias", "(", "EDGE_ANNOTATION_TABLE", ",", "\"namespace\"", ",", "\"\"", ")", ";", "tableAccessStrategy", ".", "addColumnAlias", "(", "EDGE_ANNOTATION_TABLE", ",", "\"name\"", ",", "\"\"", ")", ";", "tableAccessStrategy", ".", "addColumnAlias", "(", "EDGE_ANNOTATION_TABLE", ",", "\"value\"", ",", "\"\"", ")", ";", "generator", "=", "new", "DefaultWhereClauseGenerator", "(", ")", "{", "@", "Override", "protected", "TableAccessStrategy", "createTableAccessStrategy", "(", ")", "{", "return", "tableAccessStrategy", ";", "}", "}", ";", "generator", ".", "setAnnoCondition", "(", "new", "ApAnnotationConditionProvider", "(", ")", ")", ";", "when", "(", "annotations", ".", "size", "(", ")", ")", ".", "thenReturn", "(", "3", ")", ";", "}", "private", "void", "checkEdgeConditions", "(", "String", "componentPredicate", ",", "String", "edgeType", ",", "String", "componentName", ",", "String", "...", "expected", ")", "{", "List", "<", "String", ">", "expectedConditions", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "expectedConditions", ".", "add", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ")", ";", "if", "(", "\"lhs\"", ".", "equals", "(", "componentPredicate", ")", "||", "\"both\"", ".", "equals", "(", "componentPredicate", ")", ")", "{", "expectedConditions", ".", "add", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "sqlString", "(", "edgeType", ")", ")", ")", ";", "if", "(", "componentName", "==", "null", ")", "{", "expectedConditions", ".", "add", "(", "isNull", "(", "\"\"", ")", ")", ";", "}", "else", "{", "expectedConditions", ".", "add", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "sqlString", "(", "componentName", ")", ")", ")", ";", "}", "}", "if", "(", "\"rhs\"", ".", "equals", "(", "componentPredicate", ")", "||", "\"both\"", ".", "equals", "(", "componentPredicate", ")", ")", "{", "expectedConditions", ".", "add", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "sqlString", "(", "edgeType", ")", ")", ")", ";", "if", "(", "componentName", "==", "null", ")", "{", "expectedConditions", ".", "add", "(", "isNull", "(", "\"\"", ")", ")", ";", "}", "else", "{", "expectedConditions", ".", "add", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "sqlString", "(", "componentName", ")", ")", ")", ";", "}", "}", "expectedConditions", ".", "addAll", "(", "asList", "(", "expected", ")", ")", ";", "generator", ".", "setComponentPredicates", "(", "componentPredicate", ")", ";", "checkWhereConditions", "(", "node23", ",", "expectedConditions", ".", "toArray", "(", "new", "String", "[", "]", "{", "}", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForNodeDirectDominance", "(", "String", "componentPredicate", ")", "{", "node23", ".", "addJoin", "(", "new", "Dominance", "(", "node42", ",", "1", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "join", "(", "\"=\"", ",", "\"_rank23.pre\"", ",", "\"\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForNodeNamedDirectDominance", "(", "String", "componentPredicate", ")", "{", "String", "componentName", "=", "uniqueString", "(", ")", ";", "node23", ".", "addJoin", "(", "new", "Dominance", "(", "node42", ",", "componentName", ",", "1", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "componentName", ",", "join", "(", "\"=\"", ",", "\"_rank23.pre\"", ",", "\"\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForNamedAndAnnotatedDirectDominance", "(", "String", "componentPredicate", ")", "{", "String", "componentName", "=", "uniqueString", "(", ")", ";", "node23", ".", "addJoin", "(", "new", "Dominance", "(", "node42", ",", "componentName", ",", "1", ")", ")", ";", "node42", ".", "addEdgeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace3\"", ",", "\"name3\"", ",", "\"value3\"", ",", "TextMatching", ".", "REGEXP_EQUAL", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "componentName", ",", "join", "(", "\"=\"", ",", "\"_rank23.pre\"", ",", "\"\"", ")", ")", ";", "checkWhereConditions", "(", "node42", ",", "\"\"", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForIndirectDominance", "(", "String", "componentPredicate", ")", "{", "node23", ".", "addJoin", "(", "new", "Dominance", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "join", "(", "\"<\"", ",", "\"_rank23.pre\"", ",", "\"_rank42.pre\"", ")", ",", "join", "(", "\"<\"", ",", "\"_rank42.pre\"", ",", "\"_rank23.post\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForExactDominance", "(", "String", "componentPredicate", ")", "{", "int", "distance", "=", "uniqueInt", "(", ")", ";", "node23", ".", "addJoin", "(", "new", "Dominance", "(", "node42", ",", "distance", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "join", "(", "\"<\"", ",", "\"_rank23.pre\"", ",", "\"_rank42.pre\"", ")", ",", "join", "(", "\"<\"", ",", "\"_rank42.pre\"", ",", "\"_rank23.post\"", ")", ",", "numberJoin", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ",", "-", "distance", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForRangedDominance", "(", "String", "componentPredicate", ")", "{", "int", "min", "=", "uniqueInt", "(", "1", ",", "10", ")", ";", "int", "max", "=", "min", "+", "uniqueInt", "(", "1", ",", "10", ")", ";", "node23", ".", "addJoin", "(", "new", "Dominance", "(", "node42", ",", "min", ",", "max", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "join", "(", "\"<\"", ",", "\"_rank23.pre\"", ",", "\"_rank42.pre\"", ")", ",", "join", "(", "\"<\"", ",", "\"_rank42.pre\"", ",", "\"_rank23.post\"", ")", ",", "between", "(", "\"\"", ",", "\"\"", ",", "-", "min", ",", "-", "max", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForLeftDominance", "(", "String", "componentPredicate", ")", "{", "node23", ".", "addJoin", "(", "new", "LeftDominance", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "join", "(", "\"=\"", ",", "\"_rank23.pre\"", ",", "\"\"", ")", ",", "\"\"", "+", "\"\"", "+", "\"\"", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForRightDominance", "(", "String", "componentPredicate", ")", "{", "node23", ".", "addJoin", "(", "new", "RightDominance", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "join", "(", "\"=\"", ",", "\"_rank23.pre\"", ",", "\"\"", ")", ",", "\"\"", "+", "\"\"", "+", "\"\"", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForDirectPointingRelation", "(", "String", "componentPredicate", ")", "{", "String", "componentName", "=", "uniqueString", "(", ")", ";", "node23", ".", "addJoin", "(", "new", "PointingRelation", "(", "node42", ",", "componentName", ",", "1", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"p\"", ",", "componentName", ",", "join", "(", "\"=\"", ",", "\"_rank23.pre\"", ",", "\"\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForIndirectPointingRelation", "(", "String", "componentPredicate", ")", "{", "String", "componentName", "=", "uniqueString", "(", ")", ";", "node23", ".", "addJoin", "(", "new", "PointingRelation", "(", "node42", ",", "componentName", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"p\"", ",", "componentName", ",", "join", "(", "\"<\"", ",", "\"_rank23.pre\"", ",", "\"_rank42.pre\"", ")", ",", "join", "(", "\"<\"", ",", "\"_rank42.pre\"", ",", "\"_rank23.post\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForSibling", "(", "String", "componentPredicate", ")", "{", "node23", ".", "addJoin", "(", "new", "Sibling", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\"<>\"", ",", "\"_node23.id\"", ",", "\"_node42.id\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldAllowIdenticalNodeForSiblingTarget", "(", "String", "componentPredicate", ")", "{", "generator", ".", "setAllowIdenticalSibling", "(", "true", ")", ";", "node23", ".", "addJoin", "(", "new", "Sibling", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldGenerateWhereConditionsForCommonAncestor", "(", "String", "componentPredicate", ")", "{", "node23", ".", "addJoin", "(", "new", "CommonAncestor", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "\"\"", "+", "\"nt\"", "+", "\"\"", "+", "\"nt\"", "+", "\"\"", ",", "join", "(", "\"<>\"", ",", "\"_node23.id\"", ",", "\"_node42.id\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldAllowIdenticalNodeForCommonAncestorTarget", "(", "String", "componentPredicate", ")", "{", "generator", ".", "setAllowIdenticalSibling", "(", "true", ")", ";", "node23", ".", "addJoin", "(", "new", "CommonAncestor", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "\"\"", "+", "\"nt\"", "+", "\"\"", "+", "\"nt\"", "+", "\"\"", ")", ";", "}", "@", "Theory", "public", "void", "shouldUseToplevelCorpusPredicateForCommonAncestor", "(", "String", "componentPredicate", ")", "{", "generator", ".", "setUseToplevelCorpusPredicateInCommonAncestorSubquery", "(", "true", ")", ";", "long", "corpusId", "=", "uniqueLong", "(", ")", ";", "given", "(", "queryData", ".", "getCorpusList", "(", ")", ")", ".", "willReturn", "(", "asList", "(", "corpusId", ")", ")", ";", "node23", ".", "addJoin", "(", "new", "CommonAncestor", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "\"\"", "+", "\"nt\"", "+", "\"\"", "+", "\"nt\"", "+", "\"\"", "+", "corpusId", "+", "\"))\"", ",", "join", "(", "\"<>\"", ",", "\"_node23.id\"", ",", "\"_node42.id\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldSkipToplevelCorpusPredicateForCommonAncestorIfCorpusListIsEmpty", "(", "String", "componentPredicate", ")", "{", "generator", ".", "setUseToplevelCorpusPredicateInCommonAncestorSubquery", "(", "true", ")", ";", "given", "(", "queryData", ".", "getCorpusList", "(", ")", ")", ".", "willReturn", "(", "new", "ArrayList", "<", "Long", ">", "(", ")", ")", ";", "node23", ".", "addJoin", "(", "new", "CommonAncestor", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "\"\"", "+", "\"nt\"", "+", "\"\"", "+", "\"nt\"", "+", "\"\"", ",", "join", "(", "\"<>\"", ",", "\"_node23.id\"", ",", "\"_node42.id\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldSkipToplevelCorpusPredicateForCommonAncestorIfCorpusListIsNull", "(", "String", "componentPredicate", ")", "{", "generator", ".", "setUseToplevelCorpusPredicateInCommonAncestorSubquery", "(", "true", ")", ";", "given", "(", "queryData", ".", "getCorpusList", "(", ")", ")", ".", "willReturn", "(", "null", ")", ";", "node23", ".", "addJoin", "(", "new", "CommonAncestor", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "\"\"", "+", "\"nt\"", "+", "\"\"", "+", "\"nt\"", "+", "\"\"", ",", "join", "(", "\"<>\"", ",", "\"_node23.id\"", ",", "\"_node42.id\"", ")", ")", ";", "}", "@", "Theory", "public", "void", "shouldUseComponentRefPredicateForCommonAncestor", "(", "String", "componentPredicate", ")", "{", "generator", ".", "setUseComponentRefPredicateInCommonAncestorSubquery", "(", "true", ")", ";", "long", "corpusId", "=", "uniqueLong", "(", ")", ";", "given", "(", "queryData", ".", "getCorpusList", "(", ")", ")", ".", "willReturn", "(", "asList", "(", "corpusId", ")", ")", ";", "node23", ".", "addJoin", "(", "new", "CommonAncestor", "(", "node42", ")", ")", ";", "checkEdgeConditions", "(", "componentPredicate", ",", "\"d\"", ",", "null", ",", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "\"\"", "+", "\"nt\"", "+", "\"\"", "+", "\"nt\"", "+", "\"\"", "+", "\"nt\"", "+", "\"\"", ",", "join", "(", "\"<>\"", ",", "\"_node23.id\"", ",", "\"_node42.id\"", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldOptimizeIndirectPrecedenceForIndexOnLeftTokenMinus1", "(", ")", "{", "generator", ".", "setOptimizeIndirectPrecedence", "(", "true", ")", ";", "node23", ".", "addJoin", "(", "new", "Precedence", "(", "node42", ")", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "numberJoin", "(", "\"<=\"", ",", "\"\"", ",", "\"\"", ",", "-", "1", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldGenerateWhereConditionsForInclusion", "(", ")", "{", "node23", ".", "addJoin", "(", "new", "Inclusion", "(", "node42", ")", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\"<=\"", ",", "\"_node23.left\"", ",", "\"_node42.left\"", ")", ",", "join", "(", "\">=\"", ",", "\"\"", ",", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldOptimizeInclusion", "(", ")", "{", "generator", ".", "setOptimizeInclusion", "(", "true", ")", ";", "node23", ".", "addJoin", "(", "new", "Inclusion", "(", "node42", ")", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\"<=\"", ",", "\"_node23.left\"", ",", "\"_node42.left\"", ")", ",", "join", "(", "\"<=\"", ",", "\"_node42.left\"", ",", "\"\"", ")", ",", "join", "(", "\">=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\">=\"", ",", "\"\"", ",", "\"_node23.left\"", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldGenerateWhereConditionsForIsToken", "(", ")", "{", "generator", ".", "setUseIsTokenColumn", "(", "true", ")", ";", "node23", ".", "setToken", "(", "true", ")", ";", "checkWhereConditions", "(", "\"\"", ")", ";", "}", "@", "Test", "public", "void", "shouldGenerateWhereConditionsForIsTokenSpanAlternative", "(", ")", "{", "generator", ".", "setUseIsTokenColumn", "(", "false", ")", ";", "node23", ".", "setToken", "(", "true", ")", ";", "checkWhereConditions", "(", "isNotNull", "(", "\"_node23.span\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeRoot", "(", ")", "{", "node23", ".", "setRoot", "(", "true", ")", ";", "checkWhereConditions", "(", "\"\"", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeNamespace", "(", ")", "{", "node23", ".", "setNamespace", "(", "\"namespace\"", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"'namespace'\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeName", "(", ")", "{", "node23", ".", "setName", "(", "\"name\"", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"_node23.name\"", ",", "\"'name'\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeSpanString", "(", ")", "{", "node23", ".", "setSpannedText", "(", "\"string\"", ",", "TextMatching", ".", "EXACT_EQUAL", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"_node23.span\"", ",", "\"'string'\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeSpanRegexp", "(", ")", "{", "node23", ".", "setSpannedText", "(", "\"regexp\"", ",", "TextMatching", ".", "REGEXP_EQUAL", ")", ";", "checkWhereConditions", "(", "join", "(", "\"~\"", ",", "\"_node23.span\"", ",", "\"'^(regexp)$'\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeAnnotation", "(", ")", "{", "node23", ".", "addNodeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace1\"", ",", "\"name1\"", ")", ")", ";", "node23", ".", "addNodeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace2\"", ",", "\"name2\"", ",", "\"value2\"", ",", "TextMatching", ".", "EXACT_EQUAL", ")", ")", ";", "node23", ".", "addNodeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace3\"", ",", "\"name3\"", ",", "\"value3\"", ",", "TextMatching", ".", "REGEXP_EQUAL", ")", ")", ";", "checkWhereConditions", "(", "\"\"", ",", "\"\"", ",", "\"\"", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeAnnotationNot", "(", ")", "{", "node23", ".", "addNodeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace2\"", ",", "\"name2\"", ",", "\"value2\"", ",", "TextMatching", ".", "EXACT_NOT_EQUAL", ")", ")", ";", "node23", ".", "addNodeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace3\"", ",", "\"name3\"", ",", "\"value3\"", ",", "TextMatching", ".", "REGEXP_NOT_EQUAL", ")", ")", ";", "checkWhereConditions", "(", "\"\"", ",", "\"\"", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeEdgeAnnotation", "(", ")", "{", "node23", ".", "addEdgeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace1\"", ",", "\"name1\"", ")", ")", ";", "node23", ".", "addEdgeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace2\"", ",", "\"name2\"", ",", "\"value2\"", ",", "TextMatching", ".", "EXACT_EQUAL", ")", ")", ";", "node23", ".", "addEdgeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace3\"", ",", "\"name3\"", ",", "\"value3\"", ",", "TextMatching", ".", "REGEXP_EQUAL", ")", ")", ";", "checkWhereConditions", "(", "\"\"", ",", "\"\"", ",", "\"\"", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeEdgeAnnotationNot", "(", ")", "{", "node23", ".", "addEdgeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace2\"", ",", "\"name2\"", ",", "\"value2\"", ",", "TextMatching", ".", "EXACT_NOT_EQUAL", ")", ")", ";", "node23", ".", "addEdgeAnnotation", "(", "new", "QueryAnnotation", "(", "\"namespace3\"", ",", "\"name3\"", ",", "\"value3\"", ",", "TextMatching", ".", "REGEXP_NOT_EQUAL", ")", ")", ";", "checkWhereConditions", "(", "\"\"", ",", "\"\"", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeSameSpan", "(", ")", "{", "node23", ".", "addJoin", "(", "new", "SameSpan", "(", "node42", ")", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\"=\"", ",", "\"_node23.left\"", ",", "\"_node42.left\"", ")", ",", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeLeftAlignment", "(", ")", "{", "node23", ".", "addJoin", "(", "new", "LeftAlignment", "(", "node42", ")", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\"=\"", ",", "\"_node23.left\"", ",", "\"_node42.left\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeRightAlignment", "(", ")", "{", "node23", ".", "addJoin", "(", "new", "RightAlignment", "(", "node42", ")", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeLeftOverlap", "(", ")", "{", "node23", ".", "addJoin", "(", "new", "LeftOverlap", "(", "node42", ")", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\"<=\"", ",", "\"_node23.left\"", ",", "\"_node42.left\"", ")", ",", "join", "(", "\"<=\"", ",", "\"_node42.left\"", ",", "\"\"", ")", ",", "join", "(", "\"<=\"", ",", "\"\"", ",", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeRightOverlap", "(", ")", "{", "node23", ".", "addJoin", "(", "new", "RightOverlap", "(", "node42", ")", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\">=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\">=\"", ",", "\"\"", ",", "\"_node23.left\"", ")", ",", "join", "(", "\">=\"", ",", "\"_node23.left\"", ",", "\"_node42.left\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForNodeOverlap", "(", ")", "{", "node23", ".", "addJoin", "(", "new", "Overlap", "(", "node42", ")", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"\"", ",", "\"\"", ")", ",", "join", "(", "\"<=\"", ",", "\"_node23.left\"", ",", "\"\"", ")", ",", "join", "(", "\"<=\"", ",", "\"_node42.left\"", ",", "\"\"", ")", ")", ";", "}", "@", "Test", "public", "void", "whereClauseForIdentity", "(", ")", "{", "node23", ".", "addJoin", "(", "new", "Identical", "(", "node42", ")", ")", ";", "checkWhereConditions", "(", "join", "(", "\"=\"", ",", "\"_node23.id\"", ",", "\"_node42.id\"", ")", ")", ";", "}", "private", "void", "checkWhereConditions", "(", "String", "...", "expected", ")", "{", "checkWhereConditions", "(", "node23", ",", "expected", ")", ";", "}", "private", "void", "checkWhereConditions", "(", "QueryNode", "node", ",", "String", "...", "expected", ")", "{", "List", "<", "QueryNode", ">", "alternative", "=", "new", "ArrayList", "<", "QueryNode", ">", "(", ")", ";", "alternative", ".", "add", "(", "node", ")", ";", "Set", "<", "String", ">", "actual", "=", "generator", ".", "whereConditions", "(", "queryData", ",", "alternative", ",", "\"\"", ")", ";", "for", "(", "String", "item", ":", "expected", ")", "assertThat", "(", "actual", ",", "hasItem", "(", "item", ")", ")", ";", "assertThat", "(", "actual", ",", "is", "(", "size", "(", "expected", ".", "length", ")", ")", ")", ";", "}", "}", "</s>" ]
8,898
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "between", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "isNull", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "isTrue", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "isFalse", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "isNotNull", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "join", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "numberJoin", ";", "import", "static", "annis", ".", "sqlgen", ".", "SqlConstraints", ".", "sqlString", ";", "import", "static", "annis", ".", "test", ".", "TestUtils", ".", "uniqueInt", ";", "import", "static", "annis", ".", "test", ".", "TestUtils", ".", "uniqueString", ";", "import", "static", "org", ".", "hamcrest", ".", "Matchers", ".", "is", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "TestSqlConstraints", "{", "@", "Before", "public", "void", "setup", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenPredicate", "(", "false", ")", ";", "SqlConstraints", ".", "setDisableBetweenSymmetricPredicate", "(", "false", ")", ";", "}", "@", "Test", "public", "void", "shouldGenerateIsTruePredicate", "(", ")", "{", "String", "lhs", "=", "uniqueString", "(", ")", ";", "String", "actual", "=", "isTrue", "(", "lhs", ")", ";", "String", "expected", "=", "lhs", "+", "\"", "IS", "TRUE\"", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldGenerateIsFalsePredicate", "(", ")", "{", "String", "lhs", "=", "uniqueString", "(", ")", ";", "String", "actual", "=", "isFalse", "(", "lhs", ")", ";", "String", "expected", "=", "lhs", "+", "\"", "IS", "NOT", "TRUE\"", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldGenerateIsNullPredicate", "(", ")", "{", "String", "lhs", "=", "uniqueString", "(", ")", ";", "String", "actual", "=", "isNull", "(", "lhs", ")", ";", "String", "expected", "=", "lhs", "+", "\"", "IS", "NULL\"", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldGenerateIsNotNullPredicate", "(", ")", "{", "String", "lhs", "=", "uniqueString", "(", ")", ";", "String", "actual", "=", "isNotNull", "(", "lhs", ")", ";", "String", "expected", "=", "lhs", "+", "\"", "IS", "NOT", "NULL\"", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldUseBetweenSymmetric", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenSymmetricPredicate", "(", "false", ")", ";", "int", "min", "=", "uniqueInt", "(", ")", ";", "int", "max", "=", "uniqueInt", "(", ")", ";", "String", "actual", "=", "between", "(", "\"lhs\"", ",", "min", ",", "max", ")", ";", "String", "expected", "=", "\"\"", "+", "min", "+", "\"", "AND", "\"", "+", "max", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldNotUseBetweenSymmetric", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenSymmetricPredicate", "(", "true", ")", ";", "int", "min", "=", "uniqueInt", "(", "10", ")", ";", "int", "max", "=", "min", "+", "uniqueInt", "(", "10", ")", ";", "String", "actual", "=", "between", "(", "\"lhs\"", ",", "min", ",", "max", ")", ";", "String", "expected", "=", "\"lhs", "BETWEEN", "\"", "+", "min", "+", "\"", "AND", "\"", "+", "max", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldNotUseBetweenSymmetricMinMaxReversed", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenSymmetricPredicate", "(", "true", ")", ";", "int", "max", "=", "uniqueInt", "(", "10", ")", ";", "int", "min", "=", "max", "+", "uniqueInt", "(", "10", ")", ";", "String", "actual", "=", "between", "(", "\"lhs\"", ",", "min", ",", "max", ")", ";", "String", "expected", "=", "\"lhs", "BETWEEN", "\"", "+", "max", "+", "\"", "AND", "\"", "+", "min", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldNotUseBetweenPredicate", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenPredicate", "(", "true", ")", ";", "int", "min", "=", "uniqueInt", "(", "10", ")", ";", "int", "max", "=", "min", "+", "uniqueInt", "(", "10", ")", ";", "String", "actual", "=", "between", "(", "\"lhs\"", ",", "min", ",", "max", ")", ";", "String", "expected", "=", "\"lhs", ">=", "\"", "+", "min", "+", "\"", "AND", "lhs", "<=", "\"", "+", "max", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldNotUseBetweenPredicateMinMaxReversed", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenPredicate", "(", "true", ")", ";", "int", "max", "=", "uniqueInt", "(", "10", ")", ";", "int", "min", "=", "max", "+", "uniqueInt", "(", "10", ")", ";", "String", "actual", "=", "between", "(", "\"lhs\"", ",", "min", ",", "max", ")", ";", "String", "expected", "=", "\"lhs", ">=", "\"", "+", "max", "+", "\"", "AND", "lhs", "<=", "\"", "+", "min", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldUseBetweenSymmetricRhs", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenSymmetricPredicate", "(", "false", ")", ";", "int", "min", "=", "uniqueInt", "(", ")", ";", "int", "max", "=", "uniqueInt", "(", ")", ";", "String", "actual", "=", "between", "(", "\"lhs\"", ",", "\"rhs\"", ",", "min", ",", "max", ")", ";", "String", "expected", "=", "\"\"", "+", "min", "+", "\"", "AND", "rhs", "+", "\"", "+", "max", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldNotUseBetweenSymmetricRhs", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenSymmetricPredicate", "(", "true", ")", ";", "int", "min", "=", "uniqueInt", "(", "10", ")", ";", "int", "max", "=", "min", "+", "uniqueInt", "(", "10", ")", ";", "String", "actual", "=", "between", "(", "\"lhs\"", ",", "\"rhs\"", ",", "min", ",", "max", ")", ";", "String", "expected", "=", "\"\"", "+", "min", "+", "\"", "AND", "rhs", "+", "\"", "+", "max", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldNotUseBetweenSymmetricRhsMinMaxReversed", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenSymmetricPredicate", "(", "true", ")", ";", "int", "max", "=", "uniqueInt", "(", "10", ")", ";", "int", "min", "=", "max", "+", "uniqueInt", "(", "10", ")", ";", "String", "actual", "=", "between", "(", "\"lhs\"", ",", "\"rhs\"", ",", "min", ",", "max", ")", ";", "String", "expected", "=", "\"\"", "+", "max", "+", "\"", "AND", "rhs", "+", "\"", "+", "min", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldNotUseBetweenPredicateRhs", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenPredicate", "(", "true", ")", ";", "int", "min", "=", "uniqueInt", "(", "10", ")", ";", "int", "max", "=", "min", "+", "uniqueInt", "(", "10", ")", ";", "String", "actual", "=", "between", "(", "\"lhs\"", ",", "\"rhs\"", ",", "min", ",", "max", ")", ";", "String", "expected", "=", "\"\"", "+", "min", "+", "\"\"", "+", "max", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldNotUseBetweenPredicateRhsMinMaxReversed", "(", ")", "{", "SqlConstraints", ".", "setDisableBetweenPredicate", "(", "true", ")", ";", "int", "max", "=", "uniqueInt", "(", "10", ")", ";", "int", "min", "=", "max", "+", "uniqueInt", "(", "10", ")", ";", "String", "actual", "=", "between", "(", "\"lhs\"", ",", "\"rhs\"", ",", "min", ",", "max", ")", ";", "String", "expected", "=", "\"\"", "+", "max", "+", "\"\"", "+", "min", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldAddPositiveOffsetToNumberJoinRhs", "(", ")", "{", "String", "expected", "=", "\"\"", ";", "String", "actual", "=", "numberJoin", "(", "\"<op>\"", ",", "\"lhs\"", ",", "\"rhs\"", ",", "0", ")", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldSubstractNegativeOffsetFromNumberJoinRhs", "(", ")", "{", "String", "expected", "=", "\"\"", ";", "String", "actual", "=", "numberJoin", "(", "\"<op>\"", ",", "\"lhs\"", ",", "\"rhs\"", ",", "-", "1", ")", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "@", "Test", "public", "void", "shouldUseSingleQuotesForSqlString", "(", ")", "{", "String", "string", "=", "\"string\"", ";", "assertThat", "(", "sqlString", "(", "string", ")", ",", "is", "(", "\"'\"", "+", "string", "+", "\"'\"", ")", ")", ";", "}", "@", "Test", "public", "void", "shouldJoinLhsAndRhsWithOp", "(", ")", "{", "String", "expected", "=", "\"lhs", "<op>", "rhs\"", ";", "String", "actual", "=", "join", "(", "\"<op>\"", ",", "\"lhs\"", ",", "\"rhs\"", ")", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "}", "</s>" ]
8,899
[ "<s>", "package", "annis", ".", "sqlgen", ";", "import", "static", "annis", ".", "test", ".", "TestUtils", ".", "createJdbcArray", ";", "import", "static", "annis", ".", "test", ".", "TestUtils", ".", "uniqueString", ";", "import", "static", "java", ".", "util", ".", "Arrays", ".", "asList", ";", "import", "static", "org", ".", "hamcrest", ".", "CoreMatchers", ".", "is", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "import", "static", "org", ".", "mockito", ".", "BDDMockito", ".", "given", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "java", ".", "sql", ".", "Array", ";", "import", "java", ".", "sql", ".", "ResultSet", ";", "import", "java", ".", "sql", ".", "SQLException", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "ArrayCorpusPathExtractorTest", "{", "CorpusPathExtractor", "extractor", "=", "new", "ArrayCorpusPathExtractor", "(", ")", ";", "@", "Test", "public", "void", "shouldExtractCorpusPath", "(", ")", "throws", "SQLException", "{", "String", "pathAlias", "=", "uniqueString", "(", "5", ")", ";", "String", "path1", "=", "uniqueString", "(", "3", ")", ";", "String", "path2", "=", "uniqueString", "(", "3", ")", ";", "String", "path3", "=", "uniqueString", "(", "3", ")", ";", "ResultSet", "resultSet", "=", "mock", "(", "ResultSet", ".", "class", ")", ";", "Array", "array", "=", "createJdbcArray", "(", "path1", ",", "path2", ",", "path3", ")", ";", "given", "(", "resultSet", ".", "getArray", "(", "pathAlias", ")", ")", ".", "willReturn", "(", "array", ")", ";", "List", "<", "String", ">", "path", "=", "extractor", ".", "extractCorpusPath", "(", "resultSet", ",", "pathAlias", ")", ";", "assertThat", "(", "path", ",", "is", "(", "asList", "(", "path3", ",", "path2", ",", "path1", ")", ")", ")", ";", "}", "}", "</s>" ]