Updated code-style / format.
Change-Id: I4c0480b1637e0bf75b5aae98015b588bafc6d543
diff --git a/src/main/java/de/ids_mannheim/korap/KrillQuery.java b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
index 5a0ccd7..f7fbdbd 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
@@ -88,7 +88,7 @@
// Variables used for relation queries
private String direction;
private byte[] classNumbers;
-
+
// Private class for koral:boundary objects
private class Boundary {
public int min, max;
@@ -185,6 +185,7 @@
return this.fromJson(jsonN);
};
+
/**
* <p>Deserialize JSON-LD query as a {@link JsonNode} object
* to a {@link SpanQueryWrapper} object.</p>
@@ -198,7 +199,7 @@
// TODO: Use the shortcuts implemented in the builder
// instead of the wrapper constructors
// TODO: Rename this span context!
- public SpanQueryWrapper fromJson(JsonNode json) throws QueryException {
+ public SpanQueryWrapper fromJson (JsonNode json) throws QueryException {
int number = 0;
// Only accept @typed objects for the moment
@@ -413,7 +414,7 @@
if (!json.has("relation")) {
throw new QueryException(717, "Missing relation node");
}
-
+
return _operationRelationFromJson(operands,
json.get("relation"));
/*throw new QueryException(765,
@@ -431,9 +432,9 @@
throw new QueryException(711, "Unknown group operation");
};
- private SpanQueryWrapper _operationRelationFromJson(JsonNode operands,
- JsonNode relation)
- throws QueryException {
+
+ private SpanQueryWrapper _operationRelationFromJson (JsonNode operands,
+ JsonNode relation) throws QueryException {
if (operands.size() < 2) {
throw new QueryException(705,
@@ -454,6 +455,7 @@
}
+
// Deserialize operation:junction
private SpanQueryWrapper _operationJunctionFromJson (JsonNode operands)
throws QueryException {
@@ -916,13 +918,15 @@
throw new QueryException(745, "Token type is not supported");
};
+
private SpanQueryWrapper _termFromJson (JsonNode json)
throws QueryException {
return _termFromJson(json, null);
}
+
// Deserialize koral:term
- private SpanQueryWrapper _termFromJson(JsonNode json, String direction)
+ private SpanQueryWrapper _termFromJson (JsonNode json, String direction)
throws QueryException {
if (!json.has("key") || json.get("key").asText().length() < 1) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRelationWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRelationWrapper.java
index c4dd49b..634ade8 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRelationWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRelationWrapper.java
@@ -15,9 +15,10 @@
private SpanQueryWrapper subQuery2;
private byte[] classNumbers;
+
public SpanRelationWrapper (SpanQueryWrapper relationWrapper,
- SpanQueryWrapper operand1, SpanQueryWrapper operand2,
- byte[] classNumbers) {
+ SpanQueryWrapper operand1,
+ SpanQueryWrapper operand2, byte[] classNumbers) {
this.relationQuery = relationWrapper;
if (relationQuery != null) {
@@ -36,15 +37,17 @@
this.classNumbers = classNumbers;
}
+
@Override
- public SpanQuery toQuery() throws QueryException {
+ public SpanQuery toQuery () throws QueryException {
if (this.isNull() || this.isEmpty()) {
return null;
}
SpanQuery sq = relationQuery.retrieveNode(this.retrieveNode).toQuery();
- if (sq == null) return null;
+ if (sq == null)
+ return null;
ArrayList<Byte> classNumbers = new ArrayList<Byte>();
for (byte c : this.classNumbers) {
@@ -59,8 +62,8 @@
// match subquery2
subq2 = subQuery2.retrieveNode(this.retrieveNode).toQuery();
if (subq2 != null) {
- return new SpanFocusQuery(
- new SpanSegmentQuery(sq, subq2, true), classNumbers);
+ return new SpanFocusQuery(new SpanSegmentQuery(sq, subq2,
+ true), classNumbers);
}
}
}
@@ -69,29 +72,28 @@
// match subquery1
subq1 = subQuery1.retrieveNode(this.retrieveNode).toQuery();
if (subq1 != null) {
- return new SpanFocusQuery(
- new SpanSegmentQuery(sq, subq1, true),
- classNumbers);
+ return new SpanFocusQuery(new SpanSegmentQuery(sq, subq1,
+ true), classNumbers);
}
- }
+ }
}
- else{
+ else {
// match both
subq1 = subQuery1.retrieveNode(this.retrieveNode).toQuery();
if (subq1 != null) {
- SpanFocusQuery fq = new SpanFocusQuery(new SpanSegmentQuery(sq, subq1,
- true), (byte) 2);
+ SpanFocusQuery fq = new SpanFocusQuery(new SpanSegmentQuery(sq,
+ subq1, true), (byte) 2);
fq.setSorted(false);
sq = fq;
}
-
+
subq2 = subQuery2.retrieveNode(this.retrieveNode).toQuery();
- if (subq2 != null){
- return new SpanFocusQuery(new SpanSegmentQuery(sq, subq2, true),
- classNumbers);
+ if (subq2 != null) {
+ return new SpanFocusQuery(
+ new SpanSegmentQuery(sq, subq2, true), classNumbers);
}
}
-
+
return new SpanFocusQuery(sq, classNumbers);
}
}
diff --git a/src/main/java/de/ids_mannheim/korap/server/Node.java b/src/main/java/de/ids_mannheim/korap/server/Node.java
index b4d0068..3e406f5 100644
--- a/src/main/java/de/ids_mannheim/korap/server/Node.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Node.java
@@ -70,23 +70,25 @@
// create a resource config that scans for JAX-RS resources and providers
// in de.ids_mannheim.korap.server package
final ResourceConfig rc = new ResourceConfig()
- .packages("de.ids_mannheim.korap.server");
+ .packages("de.ids_mannheim.korap.server");
// create and start a new instance of grizzly http server
// exposing the Jersey application at BASE_URI
- return GrizzlyHttpServerFactory.createHttpServer(
- URI.create(BASE_URI), rc
- );
+ return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI),
+ rc);
};
+
/**
* Starts Grizzly HTTP server exposing JAX-RS
* resources defined in this application.
* Mainly used for testing.
*
- * @param nodeName The name of the node.
- * @param indexPath The path of the Lucene index.
- *
+ * @param nodeName
+ * The name of the node.
+ * @param indexPath
+ * The path of the Lucene index.
+ *
* @return Grizzly {@link HttpServer} server.
*/
public static HttpServer startServer (String nodeName, String indexPath) {
@@ -111,7 +113,8 @@
/**
* Runner method for Krill node.
*
- * @param args No special arguments required.
+ * @param args
+ * No special arguments required.
* @throws IOException
*/
public static void main (String[] args) throws IOException {
@@ -121,20 +124,17 @@
final HttpServer server = startServer();
// Establish shutdown hook
- Runtime.getRuntime().addShutdownHook(
- new Thread(
- new Runnable() {
+ Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- @Override
- public void run () {
- log.info("Stop Server");
- server.stop();
- if (cpds != null)
- cpds.close();
- };
+ @Override
+ public void run () {
+ log.info("Stop Server");
+ server.stop();
+ if (cpds != null)
+ cpds.close();
+ };
- }, "shutdownHook")
- );
+ }, "shutdownHook"));
// Start server
try {
@@ -151,7 +151,7 @@
/**
* Get the name of the node.
* The name is unique in the cluster and should be persistent.
- *
+ *
* @return The unique name of the node.
*/
public static String getName () {
@@ -161,8 +161,8 @@
/**
* Get the URI (incl. port) the node is listening on.
- *
- * @return The URI the node is listening on.
+ *
+ * @return The URI the node is listening on.
*/
public static String getListener () {
return BASE_URI;
@@ -181,7 +181,7 @@
/**
* Get the associated database pool
* for match collection.
- *
+ *
* @return The CPDS {@link ComboPooledDataSource} object.
*/
public static ComboPooledDataSource getDBPool () {
@@ -213,7 +213,7 @@
/**
* Get the associuated {@link KrillIndex}.
- *
+ *
* @return The associated {@link KrillIndex}.
*/
public static KrillIndex getIndex () {
@@ -285,8 +285,9 @@
// Load configuration
URL resUrl = Node.class.getClassLoader().getResource(propFile);
if (resUrl == null) {
- log.error("Cannot find {}. Please create it using \"{}.info\" as template.",
- propFile, propFile);
+ log.error(
+ "Cannot find {}. Please create it using \"{}.info\" as template.",
+ propFile, propFile);
return null;
};
diff --git a/src/main/java/de/ids_mannheim/korap/server/Resource.java b/src/main/java/de/ids_mannheim/korap/server/Resource.java
index be13ee7..7f9e99b 100644
--- a/src/main/java/de/ids_mannheim/korap/server/Resource.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Resource.java
@@ -66,9 +66,8 @@
public static final boolean DEBUG = false;
// Slightly based on String::BooleanSimple
- static Pattern p = Pattern
- .compile("\\s*(?i:false|no|inactive|disabled|" +
- "off|n|neg(?:ative)?|not|null|undef)\\s*");
+ static Pattern p = Pattern.compile("\\s*(?i:false|no|inactive|disabled|"
+ + "off|n|neg(?:ative)?|not|null|undef)\\s*");
/**
@@ -464,7 +463,7 @@
Matcher m = p.matcher(value);
if (m.matches())
return true;
-
+
return false;
};
};
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
index 7e28e1e..f151843 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
@@ -116,7 +116,7 @@
}
- public static FieldDocument createFieldDoc2() {
+ public static FieldDocument createFieldDoc2 () {
FieldDocument fd = new FieldDocument();
fd.addString("ID", "doc-2");
fd.addTV(
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanRelationQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanRelationQueryJSON.java
index 7de20c6..be2eb5f 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanRelationQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanRelationQueryJSON.java
@@ -12,7 +12,7 @@
public class TestSpanRelationQueryJSON {
@Test
- public void testMatchRelationSource() throws QueryException {
+ public void testMatchRelationSource () throws QueryException {
//
String filepath = getClass().getResource(
"/queries/relation/match-source.json").getFile();
@@ -23,8 +23,9 @@
sq.toString());
}
+
@Test
- public void testMatchRelationTarget() throws QueryException {
+ public void testMatchRelationTarget () throws QueryException {
//
String filepath = getClass().getResource(
"/queries/relation/match-target.json").getFile();
@@ -35,8 +36,9 @@
sq.toString());
}
+
@Test
- public void testMatchRelationSourceAndTarget() throws QueryException {
+ public void testMatchRelationSourceAndTarget () throws QueryException {
//
String filepath = getClass().getResource(
"/queries/relation/match-source-and-target.json").getFile();
@@ -47,8 +49,9 @@
sq.toString());
}
+
@Test
- public void testMatchOperandWithProperty() throws QueryException {
+ public void testMatchOperandWithProperty () throws QueryException {
//
String filepath = getClass().getResource(
"/queries/relation/operand-with-property.json").getFile();
@@ -60,8 +63,9 @@
sq.toString());
}
+
@Test
- public void testMatchOperandWithAttribute() throws QueryException {
+ public void testMatchOperandWithAttribute () throws QueryException {
//
String filepath = getClass().getResource(
"/queries/relation/operand-with-attribute.json").getFile();
@@ -73,8 +77,9 @@
sq.toString());
}
+
@Test
- public void testMatchRelationOnly() throws QueryException {
+ public void testMatchRelationOnly () throws QueryException {
//
String filepath = getClass().getResource(
"/queries/relation/relation-only.json").getFile();
@@ -83,7 +88,8 @@
assertEquals("focus([1,2]tokens:<:mate/d:HEAD)", sq.toString());
}
- public void testFocusSource() throws QueryException {
+
+ public void testFocusSource () throws QueryException {
//
String filepath = getClass().getResource(
"/queries/relation/focus-source.json").getFile();
@@ -94,7 +100,8 @@
sq.toString());
}
- public void testFocusTarget() throws QueryException {
+
+ public void testFocusTarget () throws QueryException {
String filepath = getClass().getResource(
"/queries/relation/match-source.json").getFile();
SpanQueryWrapper sqwi = getJSONQuery(filepath);
diff --git a/src/test/java/de/ids_mannheim/korap/server/TestResource.java b/src/test/java/de/ids_mannheim/korap/server/TestResource.java
index 4593320..ce44a19 100644
--- a/src/test/java/de/ids_mannheim/korap/server/TestResource.java
+++ b/src/test/java/de/ids_mannheim/korap/server/TestResource.java
@@ -37,6 +37,7 @@
ObjectMapper mapper = new ObjectMapper();
+
@Before
public void setUp () throws Exception {
// start the server
@@ -80,6 +81,7 @@
assertEquals("Gimme 5 minutes, please!", responseMsg);
};
+
@Test
public void testInfo () throws IOException {
String responseMsg = target.path("/").request().get(String.class);
@@ -105,7 +107,7 @@
try {
// Put new documents to the index
resp = target.path("/index/" + i).request("application/json")
- .put(jsonE, String.class);
+ .put(jsonE, String.class);
res = mapper.readTree(resp);
assertEquals("milena", res.at("/node").asText());
@@ -129,13 +131,12 @@
public void testCollection () throws IOException {
String json = getString(getClass().getResource(
- "/queries/bsp-uid-example.jsonld").getFile()
- );
+ "/queries/bsp-uid-example.jsonld").getFile());
try {
String resp = target.path("/").queryParam("uid", "1")
- .queryParam("uid", "4").request("application/json")
- .post(Entity.json(json), String.class);
+ .queryParam("uid", "4").request("application/json")
+ .post(Entity.json(json), String.class);
JsonNode res = mapper.readTree(resp);
assertEquals(2, res.at("/totalResults").asInt());
}