http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-fuseki2/jena-fuseki-core/src/main/webapp/js/lib/sprintf-0.7-beta1.js ---------------------------------------------------------------------- diff --cc jena-fuseki2/jena-fuseki-core/src/main/webapp/js/lib/sprintf-0.7-beta1.js index 0e8d02c,0e8d02c..96d3131 --- a/jena-fuseki2/jena-fuseki-core/src/main/webapp/js/lib/sprintf-0.7-beta1.js +++ b/jena-fuseki2/jena-fuseki-core/src/main/webapp/js/lib/sprintf-0.7-beta1.js @@@ -1,183 -1,183 +1,183 @@@ --/** --sprintf() for JavaScript 0.7-beta1 --http://www.diveintojavascript.com/projects/javascript-sprintf -- --Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com> --All rights reserved. -- --Redistribution and use in source and binary forms, with or without --modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * Neither the name of sprintf() for JavaScript nor the -- names of its contributors may be used to endorse or promote products -- derived from this software without specific prior written permission. -- --THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND --ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED --WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --DISCLAIMED. IN NO EVENT SHALL Alexandru Marasteanu BE LIABLE FOR ANY --DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES --(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; --LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND --ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- --Changelog: --2010.09.06 - 0.7-beta1 -- - features: vsprintf, support for named placeholders -- - enhancements: format cache, reduced global namespace pollution -- --2010.05.22 - 0.6: -- - reverted to 0.4 and fixed the bug regarding the sign of the number 0 -- Note: -- Thanks to Raphael Pigulla <raph (at] n3rd [dot) org> (http://www.n3rd.org/) -- who warned me about a bug in 0.5, I discovered that the last update was -- a regress. I appologize for that. -- --2010.05.09 - 0.5: -- - bug fix: 0 is now preceeded with a + sign -- - bug fix: the sign was not at the right position on padded results (Kamal Abdali) -- - switched from GPL to BSD license -- --2007.10.21 - 0.4: -- - unit test and patch (David Baird) -- --2007.09.17 - 0.3: -- - bug fix: no longer throws exception on empty paramenters (Hans Pufal) -- --2007.09.11 - 0.2: -- - feature: added argument swapping -- --2007.04.03 - 0.1: -- - initial release --**/ -- --var sprintf = (function() { -- function get_type(variable) { -- return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); -- } -- function str_repeat(input, multiplier) { -- for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} -- return output.join(''); -- } -- -- var str_format = function() { -- if (!str_format.cache.hasOwnProperty(arguments[0])) { -- str_format.cache[arguments[0]] = str_format.parse(arguments[0]); -- } -- return str_format.format.call(null, str_format.cache[arguments[0]], arguments); -- }; -- -- str_format.format = function(parse_tree, argv) { -- var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; -- for (i = 0; i < tree_length; i++) { -- node_type = get_type(parse_tree[i]); -- if (node_type === 'string') { -- output.push(parse_tree[i]); -- } -- else if (node_type === 'array') { -- match = parse_tree[i]; // convenience purposes only -- if (match[2]) { // keyword argument -- arg = argv[cursor]; -- for (k = 0; k < match[2].length; k++) { -- if (!arg.hasOwnProperty(match[2][k])) { -- throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); -- } -- arg = arg[match[2][k]]; -- } -- } -- else if (match[1]) { // positional argument (explicit) -- arg = argv[match[1]]; -- } -- else { // positional argument (implicit) -- arg = argv[cursor++]; -- } -- -- if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { -- throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); -- } -- switch (match[8]) { -- case 'b': arg = arg.toString(2); break; -- case 'c': arg = String.fromCharCode(arg); break; -- case 'd': arg = parseInt(arg, 10); break; -- case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; -- case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; -- case 'o': arg = arg.toString(8); break; -- case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break; -- case 'u': arg = Math.abs(arg); break; -- case 'x': arg = arg.toString(16); break; -- case 'X': arg = arg.toString(16).toUpperCase(); break; -- } -- arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); -- pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; -- pad_length = match[6] - String(arg).length; -- pad = match[6] ? str_repeat(pad_character, pad_length) : ''; -- output.push(match[5] ? arg + pad : pad + arg); -- } -- } -- return output.join(''); -- }; -- -- str_format.cache = {}; -- -- str_format.parse = function(fmt) { -- var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; -- while (_fmt) { -- if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { -- parse_tree.push(match[0]); -- } -- else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { -- parse_tree.push('%'); -- } -- else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { -- if (match[2]) { -- arg_names |= 1; -- var field_list = [], replacement_field = match[2], field_match = []; -- if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { -- field_list.push(field_match[1]); -- while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { -- if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { -- field_list.push(field_match[1]); -- } -- else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { -- field_list.push(field_match[1]); -- } -- else { -- throw('[sprintf] huh?'); -- } -- } -- } -- else { -- throw('[sprintf] huh?'); -- } -- match[2] = field_list; -- } -- else { -- arg_names |= 2; -- } -- if (arg_names === 3) { -- throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); -- } -- parse_tree.push(match); -- } -- else { -- throw('[sprintf] huh?'); -- } -- _fmt = _fmt.substring(match[0].length); -- } -- return parse_tree; -- }; -- -- return str_format; --})(); -- --var vsprintf = function(fmt, argv) { -- argv.unshift(fmt); -- return sprintf.apply(null, argv); --}; ++/** ++sprintf() for JavaScript 0.7-beta1 ++http://www.diveintojavascript.com/projects/javascript-sprintf ++ ++Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com> ++All rights reserved. ++ ++Redistribution and use in source and binary forms, with or without ++modification, are permitted provided that the following conditions are met: ++ * Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ * Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in the ++ documentation and/or other materials provided with the distribution. ++ * Neither the name of sprintf() for JavaScript nor the ++ names of its contributors may be used to endorse or promote products ++ derived from this software without specific prior written permission. ++ ++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ++ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ++DISCLAIMED. IN NO EVENT SHALL Alexandru Marasteanu BE LIABLE FOR ANY ++DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ++(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ++LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ++ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++ ++Changelog: ++2010.09.06 - 0.7-beta1 ++ - features: vsprintf, support for named placeholders ++ - enhancements: format cache, reduced global namespace pollution ++ ++2010.05.22 - 0.6: ++ - reverted to 0.4 and fixed the bug regarding the sign of the number 0 ++ Note: ++ Thanks to Raphael Pigulla <raph (at] n3rd [dot) org> (http://www.n3rd.org/) ++ who warned me about a bug in 0.5, I discovered that the last update was ++ a regress. I appologize for that. ++ ++2010.05.09 - 0.5: ++ - bug fix: 0 is now preceeded with a + sign ++ - bug fix: the sign was not at the right position on padded results (Kamal Abdali) ++ - switched from GPL to BSD license ++ ++2007.10.21 - 0.4: ++ - unit test and patch (David Baird) ++ ++2007.09.17 - 0.3: ++ - bug fix: no longer throws exception on empty paramenters (Hans Pufal) ++ ++2007.09.11 - 0.2: ++ - feature: added argument swapping ++ ++2007.04.03 - 0.1: ++ - initial release ++**/ ++ ++var sprintf = (function() { ++ function get_type(variable) { ++ return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); ++ } ++ function str_repeat(input, multiplier) { ++ for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} ++ return output.join(''); ++ } ++ ++ var str_format = function() { ++ if (!str_format.cache.hasOwnProperty(arguments[0])) { ++ str_format.cache[arguments[0]] = str_format.parse(arguments[0]); ++ } ++ return str_format.format.call(null, str_format.cache[arguments[0]], arguments); ++ }; ++ ++ str_format.format = function(parse_tree, argv) { ++ var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; ++ for (i = 0; i < tree_length; i++) { ++ node_type = get_type(parse_tree[i]); ++ if (node_type === 'string') { ++ output.push(parse_tree[i]); ++ } ++ else if (node_type === 'array') { ++ match = parse_tree[i]; // convenience purposes only ++ if (match[2]) { // keyword argument ++ arg = argv[cursor]; ++ for (k = 0; k < match[2].length; k++) { ++ if (!arg.hasOwnProperty(match[2][k])) { ++ throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); ++ } ++ arg = arg[match[2][k]]; ++ } ++ } ++ else if (match[1]) { // positional argument (explicit) ++ arg = argv[match[1]]; ++ } ++ else { // positional argument (implicit) ++ arg = argv[cursor++]; ++ } ++ ++ if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { ++ throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); ++ } ++ switch (match[8]) { ++ case 'b': arg = arg.toString(2); break; ++ case 'c': arg = String.fromCharCode(arg); break; ++ case 'd': arg = parseInt(arg, 10); break; ++ case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; ++ case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; ++ case 'o': arg = arg.toString(8); break; ++ case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break; ++ case 'u': arg = Math.abs(arg); break; ++ case 'x': arg = arg.toString(16); break; ++ case 'X': arg = arg.toString(16).toUpperCase(); break; ++ } ++ arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); ++ pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; ++ pad_length = match[6] - String(arg).length; ++ pad = match[6] ? str_repeat(pad_character, pad_length) : ''; ++ output.push(match[5] ? arg + pad : pad + arg); ++ } ++ } ++ return output.join(''); ++ }; ++ ++ str_format.cache = {}; ++ ++ str_format.parse = function(fmt) { ++ var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; ++ while (_fmt) { ++ if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { ++ parse_tree.push(match[0]); ++ } ++ else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { ++ parse_tree.push('%'); ++ } ++ else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { ++ if (match[2]) { ++ arg_names |= 1; ++ var field_list = [], replacement_field = match[2], field_match = []; ++ if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { ++ field_list.push(field_match[1]); ++ while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { ++ if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { ++ field_list.push(field_match[1]); ++ } ++ else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { ++ field_list.push(field_match[1]); ++ } ++ else { ++ throw('[sprintf] huh?'); ++ } ++ } ++ } ++ else { ++ throw('[sprintf] huh?'); ++ } ++ match[2] = field_list; ++ } ++ else { ++ arg_names |= 2; ++ } ++ if (arg_names === 3) { ++ throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); ++ } ++ parse_tree.push(match); ++ } ++ else { ++ throw('[sprintf] huh?'); ++ } ++ _fmt = _fmt.substring(match[0].length); ++ } ++ return parse_tree; ++ }; ++ ++ return str_format; ++})(); ++ ++var vsprintf = function(fmt, argv) { ++ argv.unshift(fmt); ++ return sprintf.apply(null, argv); ++};
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/http/TestDatasetGraphAccessorHTTP.java ---------------------------------------------------------------------- diff --cc jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/http/TestDatasetGraphAccessorHTTP.java index 964511f,964511f..590083d --- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/http/TestDatasetGraphAccessorHTTP.java +++ b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/http/TestDatasetGraphAccessorHTTP.java @@@ -16,8 -16,8 +16,8 @@@ * limitations under the License. */ --package org.apache.jena.fuseki.http; -- ++package org.apache.jena.fuseki.http; ++ import org.apache.jena.fuseki.ServerTest ; import org.apache.jena.web.AbstractTestDatasetGraphAccessor ; import org.apache.jena.web.DatasetGraphAccessor ; @@@ -25,19 -25,19 +25,19 @@@ import org.apache.jena.web.DatasetGraph import org.junit.AfterClass ; import org.junit.Before ; import org.junit.BeforeClass ; -- --public class TestDatasetGraphAccessorHTTP extends AbstractTestDatasetGraphAccessor --{ -- @BeforeClass public static void beforeClass() { ServerTest.allocServer() ; } -- @AfterClass public static void afterClass() { ServerTest.freeServer() ; } ++ ++public class TestDatasetGraphAccessorHTTP extends AbstractTestDatasetGraphAccessor ++{ ++ @BeforeClass public static void beforeClass() { ServerTest.allocServer() ; } ++ @AfterClass public static void afterClass() { ServerTest.freeServer() ; } @Before public void before() { ServerTest.resetServer() ; -- } -- -- -- @Override -- protected DatasetGraphAccessor getDatasetUpdater() -- { -- return new DatasetGraphAccessorHTTP(ServerTest.serviceGSP) ; -- } ++ } ++ ++ ++ @Override ++ protected DatasetGraphAccessor getDatasetUpdater() ++ { ++ return new DatasetGraphAccessorHTTP(ServerTest.serviceGSP) ; ++ } } http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-maven-tools/src/test/java/org/apache/jena/tools/schemagen/SchemagenMojoTest.java ---------------------------------------------------------------------- diff --cc jena-maven-tools/src/test/java/org/apache/jena/tools/schemagen/SchemagenMojoTest.java index 132010a,132010a..8df6faf --- a/jena-maven-tools/src/test/java/org/apache/jena/tools/schemagen/SchemagenMojoTest.java +++ b/jena-maven-tools/src/test/java/org/apache/jena/tools/schemagen/SchemagenMojoTest.java @@@ -1,83 -1,83 +1,83 @@@ --/** -- * Licensed to the Apache Software Foundation (ASF) under one -- * or more contributor license agreements. See the NOTICE file -- * distributed with this work for additional information -- * regarding copyright ownership. The ASF licenses this file -- * to you under the Apache License, Version 2.0 (the -- * "License"); you may not use this file except in compliance -- * with the License. You may obtain a copy of the License at -- * -- * http://www.apache.org/licenses/LICENSE-2.0 -- * -- * Unless required by applicable law or agreed to in writing, software -- * distributed under the License is distributed on an "AS IS" BASIS, -- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- * See the License for the specific language governing permissions and -- * limitations under the License. -- */ -- --package org.apache.jena.tools.schemagen; -- --// Imports --/////////////// -- --import static org.junit.Assert.*; -- --import java.io.File; --import java.util.List; -- --import org.junit.Test; --import org.apache.jena.tools.schemagen.SchemagenMojo; -- --/** -- * <p>Unit tests for {@link SchemagenMojo}</p> -- */ --public class SchemagenMojoTest { -- -- @Test -- public void testMatchFileNames0() { -- SchemagenMojo sm = new SchemagenMojo(); -- -- List<String> s = sm.matchFileNames(); -- assertNotNull(s); -- assertTrue( s.isEmpty() ); -- } -- -- @Test -- public void testMatchFileNames1() { -- SchemagenMojo sm = new SchemagenMojo(); -- String f = "src/test/resources/test1/test1.ttl"; -- sm.addIncludes( f ); -- List<String> s = sm.matchFileNames(); -- assertNotNull(s); -- assertEquals( 1, s.size() ); -- assertEquals( new File(f), new File(s.get(0)) ); -- } -- -- @Test -- public void testMatchFileNames2() { -- SchemagenMojo sm = new SchemagenMojo(); -- String f = "src/test/resources/test1/*.ttl"; -- sm.addIncludes( f ); -- List<String> s = sm.matchFileNames(); -- assertNotNull(s); -- assertEquals( 2, s.size() ); -- assertTrue( s.get(0).endsWith( "test1.ttl" )); -- assertTrue( s.get(1).endsWith( "test2.ttl" )); -- } -- -- @Test -- public void testMatchFileNames3() { -- SchemagenMojo sm = new SchemagenMojo(); -- String f = "src/test/resources/test1/*.ttl"; -- sm.addIncludes( f ); -- sm.addExcludes( "src/test/resources/test1/test1.ttl" ); -- -- List<String> s = sm.matchFileNames(); -- assertNotNull(s); -- assertEquals( 1, s.size() ); -- assertTrue( s.get(0).endsWith( "test2.ttl" )); -- } -- -- --} ++/** ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++package org.apache.jena.tools.schemagen; ++ ++// Imports ++/////////////// ++ ++import static org.junit.Assert.*; ++ ++import java.io.File; ++import java.util.List; ++ ++import org.junit.Test; ++import org.apache.jena.tools.schemagen.SchemagenMojo; ++ ++/** ++ * <p>Unit tests for {@link SchemagenMojo}</p> ++ */ ++public class SchemagenMojoTest { ++ ++ @Test ++ public void testMatchFileNames0() { ++ SchemagenMojo sm = new SchemagenMojo(); ++ ++ List<String> s = sm.matchFileNames(); ++ assertNotNull(s); ++ assertTrue( s.isEmpty() ); ++ } ++ ++ @Test ++ public void testMatchFileNames1() { ++ SchemagenMojo sm = new SchemagenMojo(); ++ String f = "src/test/resources/test1/test1.ttl"; ++ sm.addIncludes( f ); ++ List<String> s = sm.matchFileNames(); ++ assertNotNull(s); ++ assertEquals( 1, s.size() ); ++ assertEquals( new File(f), new File(s.get(0)) ); ++ } ++ ++ @Test ++ public void testMatchFileNames2() { ++ SchemagenMojo sm = new SchemagenMojo(); ++ String f = "src/test/resources/test1/*.ttl"; ++ sm.addIncludes( f ); ++ List<String> s = sm.matchFileNames(); ++ assertNotNull(s); ++ assertEquals( 2, s.size() ); ++ assertTrue( s.get(0).endsWith( "test1.ttl" )); ++ assertTrue( s.get(1).endsWith( "test2.ttl" )); ++ } ++ ++ @Test ++ public void testMatchFileNames3() { ++ SchemagenMojo sm = new SchemagenMojo(); ++ String f = "src/test/resources/test1/*.ttl"; ++ sm.addIncludes( f ); ++ sm.addExcludes( "src/test/resources/test1/test1.ttl" ); ++ ++ List<String> s = sm.matchFileNames(); ++ assertNotNull(s); ++ assertEquals( 1, s.size() ); ++ assertTrue( s.get(0).endsWith( "test2.ttl" )); ++ } ++ ++ ++} http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-sdb/Data/data.ttl ---------------------------------------------------------------------- diff --cc jena-sdb/Data/data.ttl index 423ea6d,423ea6d..42217da --- a/jena-sdb/Data/data.ttl +++ b/jena-sdb/Data/data.ttl @@@ -1,34 -1,34 +1,34 @@@ --# Licensed to the Apache Software Foundation (ASF) under one --# or more contributor license agreements. See the NOTICE file --# distributed with this work for additional information --# regarding copyright ownership. The ASF licenses this file --# to you under the Apache License, Version 2.0 (the --# "License"); you may not use this file except in compliance --# with the License. You may obtain a copy of the License at --# --# http://www.apache.org/licenses/LICENSE-2.0 --# --# Unless required by applicable law or agreed to in writing, software --# distributed under the License is distributed on an "AS IS" BASIS, --# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --# See the License for the specific language governing permissions and --# limitations under the License. -- --@prefix : <http://example/> . -- --:x :p 1 . --:x :p 2 . --:x :p 3 . -- --:x :p :a . --:x :p :b . --:x :p :z . -- --:a :q1 :z1 . --:a :q2 :z2 . -- --:b :q1 :z1 . -- --:z :p1 "abc" . --:z :p2 "def" . --:z :p3 "g" . ++# Licensed to the Apache Software Foundation (ASF) under one ++# or more contributor license agreements. See the NOTICE file ++# distributed with this work for additional information ++# regarding copyright ownership. The ASF licenses this file ++# to you under the Apache License, Version 2.0 (the ++# "License"); you may not use this file except in compliance ++# with the License. You may obtain a copy of the License at ++# ++# http://www.apache.org/licenses/LICENSE-2.0 ++# ++# Unless required by applicable law or agreed to in writing, software ++# distributed under the License is distributed on an "AS IS" BASIS, ++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++# See the License for the specific language governing permissions and ++# limitations under the License. ++ ++@prefix : <http://example/> . ++ ++:x :p 1 . ++:x :p 2 . ++:x :p 3 . ++ ++:x :p :a . ++:x :p :b . ++:x :p :z . ++ ++:a :q1 :z1 . ++:a :q2 :z2 . ++ ++:b :q1 :z1 . ++ ++:z :p1 "abc" . ++:z :p2 "def" . ++:z :p3 "g" . http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-sdb/Data/data2.ttl ---------------------------------------------------------------------- diff --cc jena-sdb/Data/data2.ttl index b570f9d,b570f9d..08194b6 --- a/jena-sdb/Data/data2.ttl +++ b/jena-sdb/Data/data2.ttl @@@ -1,20 -1,20 +1,20 @@@ --# Licensed to the Apache Software Foundation (ASF) under one --# or more contributor license agreements. See the NOTICE file --# distributed with this work for additional information --# regarding copyright ownership. The ASF licenses this file --# to you under the Apache License, Version 2.0 (the --# "License"); you may not use this file except in compliance --# with the License. You may obtain a copy of the License at --# --# http://www.apache.org/licenses/LICENSE-2.0 --# --# Unless required by applicable law or agreed to in writing, software --# distributed under the License is distributed on an "AS IS" BASIS, --# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --# See the License for the specific language governing permissions and --# limitations under the License. -- --# Some international stuff --@prefix : <http://example/> . -- --:x :p "Unicode: 03 B1 α" . ++# Licensed to the Apache Software Foundation (ASF) under one ++# or more contributor license agreements. See the NOTICE file ++# distributed with this work for additional information ++# regarding copyright ownership. The ASF licenses this file ++# to you under the Apache License, Version 2.0 (the ++# "License"); you may not use this file except in compliance ++# with the License. You may obtain a copy of the License at ++# ++# http://www.apache.org/licenses/LICENSE-2.0 ++# ++# Unless required by applicable law or agreed to in writing, software ++# distributed under the License is distributed on an "AS IS" BASIS, ++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++# See the License for the specific language governing permissions and ++# limitations under the License. ++ ++# Some international stuff ++@prefix : <http://example/> . ++ ++:x :p "Unicode: 03 B1 α" . http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-sdb/Reports/explain.rb ---------------------------------------------------------------------- diff --cc jena-sdb/Reports/explain.rb index 49004be,49004be..1ae3b30 --- a/jena-sdb/Reports/explain.rb +++ b/jena-sdb/Reports/explain.rb @@@ -1,29 -1,29 +1,29 @@@ --#!/bin/env ruby --# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 -- --require 'format' -- --columns=nil --data=[] -- --#ARGF.each do |line| --# line.chomp! --# v = line.split("\t") --# if !columns --# columns = v --# else --# data << v --# end --#end -- --# Ruby has CSV --require 'csv.rb' --CSV::Reader.parse(ARGF) do |row| -- if !columns -- columns = row -- else -- data << row -- end --end -- --Fmt::table(columns, data) ++#!/bin/env ruby ++# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 ++ ++require 'format' ++ ++columns=nil ++data=[] ++ ++#ARGF.each do |line| ++# line.chomp! ++# v = line.split("\t") ++# if !columns ++# columns = v ++# else ++# data << v ++# end ++#end ++ ++# Ruby has CSV ++require 'csv.rb' ++CSV::Reader.parse(ARGF) do |row| ++ if !columns ++ columns = row ++ else ++ data << row ++ end ++end ++ ++Fmt::table(columns, data) http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-sdb/Reports/format.rb ---------------------------------------------------------------------- diff --cc jena-sdb/Reports/format.rb index 682710e,682710e..acc5b0c --- a/jena-sdb/Reports/format.rb +++ b/jena-sdb/Reports/format.rb @@@ -1,41 -1,41 +1,41 @@@ --# Formatting utilities --# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 -- --module Fmt -- def Fmt.table(headings, body) -- widths = calc_widths(headings, body) -- widths = calc_widths(headings, body) -- # Make lines like column names -- lines = [] -- headings.each_index { |i| lines<<"-"*(widths[i]) ; } -- lines2 = [] -- headings.each_index { |i| lines2<<"="*(widths[i]) ; } -- print_row(lines, widths, "-", "+", "-", "+") -- print_row(headings, widths, " ", "|", "|", "|") -- print_row(lines2, widths, "=", "|", "|", "|") -- body.each { |row| print_row(row, widths, " ", "|", "|", "|") } -- print_row(lines, widths, "-", "+", "-", "+") -- end -- -- private -- def Fmt.calc_widths(columns, data) -- x = [] -- columns.each { |c| x << c.length } -- data.each do |row| -- row.each_index { |i| x[i] = row[i].length if row[i].length > x[i] } -- end -- return x -- end -- -- def Fmt.print_row(items, widths, sep, left, mid, right) -- print left -- items.each_index do |i| -- print mid if i != 0 -- print sep -- printf("%-*s",widths[i],items[i]) -- print sep -- end -- print right -- print "\n" -- end --end ++# Formatting utilities ++# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 ++ ++module Fmt ++ def Fmt.table(headings, body) ++ widths = calc_widths(headings, body) ++ widths = calc_widths(headings, body) ++ # Make lines like column names ++ lines = [] ++ headings.each_index { |i| lines<<"-"*(widths[i]) ; } ++ lines2 = [] ++ headings.each_index { |i| lines2<<"="*(widths[i]) ; } ++ print_row(lines, widths, "-", "+", "-", "+") ++ print_row(headings, widths, " ", "|", "|", "|") ++ print_row(lines2, widths, "=", "|", "|", "|") ++ body.each { |row| print_row(row, widths, " ", "|", "|", "|") } ++ print_row(lines, widths, "-", "+", "-", "+") ++ end ++ ++ private ++ def Fmt.calc_widths(columns, data) ++ x = [] ++ columns.each { |c| x << c.length } ++ data.each do |row| ++ row.each_index { |i| x[i] = row[i].length if row[i].length > x[i] } ++ end ++ return x ++ end ++ ++ def Fmt.print_row(items, widths, sep, left, mid, right) ++ print left ++ items.each_index do |i| ++ print mid if i != 0 ++ print sep ++ printf("%-*s",widths[i],items[i]) ++ print sep ++ end ++ print right ++ print "\n" ++ end ++end http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-sdb/Reports/jdbc.rb ---------------------------------------------------------------------- diff --cc jena-sdb/Reports/jdbc.rb index f90a16c,f90a16c..8b84f9a --- a/jena-sdb/Reports/jdbc.rb +++ b/jena-sdb/Reports/jdbc.rb @@@ -1,139 -1,139 +1,139 @@@ --# = Module for handling JDBC Result Sets --# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 -- --require 'java' --require 'format' --include_class 'java.sql.DriverManager' -- --module JDBC -- --# == Class DB: a connection to a database / tablespace -- class DB -- attr_reader :conn -- -- def initialize(connection) -- @conn = connection ; -- end -- -- def DB.connect(url, driver, user, password) -- Java::JavaClass.for_name(driver) ; -- c = new(DriverManager.getConnection(url, user, password)) -- return c -- end -- -- def query(queryString) -- s = @conn.createStatement() -- return Results.new(s.executeQuery(queryString)) -- end -- -- def query_print(queryString) -- s = @conn.createStatement() -- rs = Results.new(s.executeQuery(queryString)) -- rs.dump -- rs.close -- return nil -- end -- -- def close -- @conn.close() -- end -- end -- -- class Results -- -- def initialize(jdbcResultSet) -- @rs = jdbcResultSet -- end -- -- def each -- while(@rs.next) -- yield Row.new(@rs) -- end -- close -- end -- -- def close -- @rs.close -- end -- -- # All the cols (via their display name) -- def cols -- if !@columns -- md = @rs.getMetaData -- @columns=[] -- 1.upto(md.getColumnCount) { |i| @columns << md.getColumnLabel(i) } -- end -- return @columns -- end -- -- # All the rows, as an array of hashes (values are strings) -- def all_rows_hash -- x = [] -- columns = cols -- each {|row| x << row.data(columns)} -- close -- return x -- end -- -- # All the rows, as an array of arrays -- def all_rows_array -- x = [] -- each {|row| x << row.as_array } -- close -- return x -- end -- -- def dump -- # Order matters - must get columns before exhausting data and closing ResultSet -- columns = cols -- data = all_rows_array -- Fmt.table(columns, data) -- end -- end -- -- class Row -- def initialize(row) -- @row = row -- end -- -- # and it works for string name or integer index -- def [](name) -- return @row.getString(name) -- end -- -- def next -- raise "Error: calling close on a Row object" -- end -- -- def each -- len = @row.getMetaData.getColumnCount -- (1..len).each { |i| yield @row.getString(i) } -- end -- -- def as_array -- len = @row.getMetaData.getColumnCount -- x = [] -- (1..len).each { |i| x << @row.getString(i) } -- return x -- end -- -- # Needs column names -- def data(cols) -- x = {} -- cols.each do |col| -- x[col] = @row.getString(col) -- if @row.wasNull -- x[col] = nil -- end -- end -- return x -- end -- -- # Direct any missing methods to the wrapped object -- def method_missing(methId, *args) -- meth = @row.method(methId) -- meth.call *args -- end -- -- end --end ++# = Module for handling JDBC Result Sets ++# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 ++ ++require 'java' ++require 'format' ++include_class 'java.sql.DriverManager' ++ ++module JDBC ++ ++# == Class DB: a connection to a database / tablespace ++ class DB ++ attr_reader :conn ++ ++ def initialize(connection) ++ @conn = connection ; ++ end ++ ++ def DB.connect(url, driver, user, password) ++ Java::JavaClass.for_name(driver) ; ++ c = new(DriverManager.getConnection(url, user, password)) ++ return c ++ end ++ ++ def query(queryString) ++ s = @conn.createStatement() ++ return Results.new(s.executeQuery(queryString)) ++ end ++ ++ def query_print(queryString) ++ s = @conn.createStatement() ++ rs = Results.new(s.executeQuery(queryString)) ++ rs.dump ++ rs.close ++ return nil ++ end ++ ++ def close ++ @conn.close() ++ end ++ end ++ ++ class Results ++ ++ def initialize(jdbcResultSet) ++ @rs = jdbcResultSet ++ end ++ ++ def each ++ while(@rs.next) ++ yield Row.new(@rs) ++ end ++ close ++ end ++ ++ def close ++ @rs.close ++ end ++ ++ # All the cols (via their display name) ++ def cols ++ if !@columns ++ md = @rs.getMetaData ++ @columns=[] ++ 1.upto(md.getColumnCount) { |i| @columns << md.getColumnLabel(i) } ++ end ++ return @columns ++ end ++ ++ # All the rows, as an array of hashes (values are strings) ++ def all_rows_hash ++ x = [] ++ columns = cols ++ each {|row| x << row.data(columns)} ++ close ++ return x ++ end ++ ++ # All the rows, as an array of arrays ++ def all_rows_array ++ x = [] ++ each {|row| x << row.as_array } ++ close ++ return x ++ end ++ ++ def dump ++ # Order matters - must get columns before exhausting data and closing ResultSet ++ columns = cols ++ data = all_rows_array ++ Fmt.table(columns, data) ++ end ++ end ++ ++ class Row ++ def initialize(row) ++ @row = row ++ end ++ ++ # and it works for string name or integer index ++ def [](name) ++ return @row.getString(name) ++ end ++ ++ def next ++ raise "Error: calling close on a Row object" ++ end ++ ++ def each ++ len = @row.getMetaData.getColumnCount ++ (1..len).each { |i| yield @row.getString(i) } ++ end ++ ++ def as_array ++ len = @row.getMetaData.getColumnCount ++ x = [] ++ (1..len).each { |i| x << @row.getString(i) } ++ return x ++ end ++ ++ # Needs column names ++ def data(cols) ++ x = {} ++ cols.each do |col| ++ x[col] = @row.getString(col) ++ if @row.wasNull ++ x[col] = nil ++ end ++ end ++ return x ++ end ++ ++ # Direct any missing methods to the wrapped object ++ def method_missing(methId, *args) ++ meth = @row.method(methId) ++ meth.call *args ++ end ++ ++ end ++end http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-sdb/bin2/sdbscript ---------------------------------------------------------------------- diff --cc jena-sdb/bin2/sdbscript index 0b20a3b,0b20a3b..82b1692 --- a/jena-sdb/bin2/sdbscript +++ b/jena-sdb/bin2/sdbscript @@@ -1,10 -1,10 +1,10 @@@ --#!/bin/bash --# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 -- --if [ "$SDBROOT" = "" ] --then -- echo "SDBROOT not set" 1>&2 -- exit 1 -- fi -- ++#!/bin/bash ++# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 ++ ++if [ "$SDBROOT" = "" ] ++then ++ echo "SDBROOT not set" 1>&2 ++ exit 1 ++ fi ++ exec "${SDBROOT}/bin/sdbscript" "$@" http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-sdb/src/main/resources/org/apache/jena/sdb/sdb-properties.xml ---------------------------------------------------------------------- diff --cc jena-sdb/src/main/resources/org/apache/jena/sdb/sdb-properties.xml index bca78a9,bca78a9..b33d25b --- a/jena-sdb/src/main/resources/org/apache/jena/sdb/sdb-properties.xml +++ b/jena-sdb/src/main/resources/org/apache/jena/sdb/sdb-properties.xml @@@ -1,9 -1,9 +1,9 @@@ --<?xml version="1.0" encoding="UTF-8"?> --<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> --<!-- Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 --> -- --<properties version="1.0"> -- <comment>SDB System Properties</comment> -- <entry key="org.apache.jena.sdb.version">${project.version}</entry> -- <entry key="org.apache.jena.sdb.build.datetime">${build.time.xsd}</entry> --</properties> ++<?xml version="1.0" encoding="UTF-8"?> ++<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> ++<!-- Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 --> ++ ++<properties version="1.0"> ++ <comment>SDB System Properties</comment> ++ <entry key="org.apache.jena.sdb.version">${project.version}</entry> ++ <entry key="org.apache.jena.sdb.build.datetime">${build.time.xsd}</entry> ++</properties> http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java ---------------------------------------------------------------------- diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java index d201f3b,d201f3b..1cd19de --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java @@@ -1,87 -1,87 +1,87 @@@ --/* -- * Licensed to the Apache Software Foundation (ASF) under one -- * or more contributor license agreements. See the NOTICE file -- * distributed with this work for additional information -- * regarding copyright ownership. The ASF licenses this file -- * to you under the Apache License, Version 2.0 (the -- * "License"); you may not use this file except in compliance -- * with the License. You may obtain a copy of the License at -- * -- * http://www.apache.org/licenses/LICENSE-2.0 -- * -- * Unless required by applicable law or agreed to in writing, software -- * distributed under the License is distributed on an "AS IS" BASIS, -- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- * See the License for the specific language governing permissions and -- * limitations under the License. -- */ -- --package org.apache.jena.query.spatial; -- --import java.util.ArrayList; --import java.util.List; -- --import com.spatial4j.core.distance.DistanceUtils; -- --public class DistanceUnitsUtils { -- -- public final static String defaultDistanceUnit = "kilometres" ; -- -- public final static List<String> SUPPORTED_UNITS; -- static { -- // International spelling "metres" -- // As used by http://en.wikipedia.org/wiki/International_Bureau_of_Weights_and_Measures -- SUPPORTED_UNITS = new ArrayList<String>(); -- SUPPORTED_UNITS.add("kilometres"); -- SUPPORTED_UNITS.add("kilometers"); // America spelling -- SUPPORTED_UNITS.add("km"); -- SUPPORTED_UNITS.add("meters"); -- SUPPORTED_UNITS.add("metres"); -- SUPPORTED_UNITS.add("m"); -- SUPPORTED_UNITS.add("centimeters"); -- SUPPORTED_UNITS.add("centimetres"); -- SUPPORTED_UNITS.add("cm"); -- SUPPORTED_UNITS.add("millimetres"); -- SUPPORTED_UNITS.add("millimeters"); -- SUPPORTED_UNITS.add("mm"); -- SUPPORTED_UNITS.add("miles"); -- SUPPORTED_UNITS.add("mi"); -- SUPPORTED_UNITS.add("degrees"); -- SUPPORTED_UNITS.add("de"); -- } -- -- public static double dist2Degrees(double dist, String units) { -- double degrees = dist; -- -- if (units.equals("kilometers") || units.equals("kilometres") || units.equals("km")) -- return DistanceUtils.dist2Degrees(dist, -- DistanceUtils.EARTH_MEAN_RADIUS_KM); -- -- else if (units.equals("meters") || units.equals("metres") || units.equals("m")) -- return DistanceUtils.dist2Degrees(dist / 1000, -- DistanceUtils.EARTH_MEAN_RADIUS_KM); -- -- else if (units.equals("centimeters") || units.equals("centimetres") || units.equals("cm")) -- return DistanceUtils.dist2Degrees(dist / (1000 * 100), -- DistanceUtils.EARTH_MEAN_RADIUS_KM) ; -- -- else if ( units.equals("millimeters") || units.equals("millimetres") || units.equals("mm") || -- units.equals("milimeters") || units.equals("milimetres") ) // Common spelling mistake. -- return DistanceUtils.dist2Degrees(dist / (1000 * 1000), -- DistanceUtils.EARTH_MEAN_RADIUS_KM) ; -- -- else if (units.equals("miles") || units.equals("mi")) -- return DistanceUtils.dist2Degrees(dist, -- DistanceUtils.EARTH_MEAN_RADIUS_MI); -- -- else if (units.equals("degrees") || units.equals("de")) -- return degrees; -- -- throw new IllegalArgumentException("unknow distance units: "+ units); -- } -- -- public static boolean isSupportedUnits(String units){ -- return SUPPORTED_UNITS.contains(units); -- } -- --} ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++package org.apache.jena.query.spatial; ++ ++import java.util.ArrayList; ++import java.util.List; ++ ++import com.spatial4j.core.distance.DistanceUtils; ++ ++public class DistanceUnitsUtils { ++ ++ public final static String defaultDistanceUnit = "kilometres" ; ++ ++ public final static List<String> SUPPORTED_UNITS; ++ static { ++ // International spelling "metres" ++ // As used by http://en.wikipedia.org/wiki/International_Bureau_of_Weights_and_Measures ++ SUPPORTED_UNITS = new ArrayList<String>(); ++ SUPPORTED_UNITS.add("kilometres"); ++ SUPPORTED_UNITS.add("kilometers"); // America spelling ++ SUPPORTED_UNITS.add("km"); ++ SUPPORTED_UNITS.add("meters"); ++ SUPPORTED_UNITS.add("metres"); ++ SUPPORTED_UNITS.add("m"); ++ SUPPORTED_UNITS.add("centimeters"); ++ SUPPORTED_UNITS.add("centimetres"); ++ SUPPORTED_UNITS.add("cm"); ++ SUPPORTED_UNITS.add("millimetres"); ++ SUPPORTED_UNITS.add("millimeters"); ++ SUPPORTED_UNITS.add("mm"); ++ SUPPORTED_UNITS.add("miles"); ++ SUPPORTED_UNITS.add("mi"); ++ SUPPORTED_UNITS.add("degrees"); ++ SUPPORTED_UNITS.add("de"); ++ } ++ ++ public static double dist2Degrees(double dist, String units) { ++ double degrees = dist; ++ ++ if (units.equals("kilometers") || units.equals("kilometres") || units.equals("km")) ++ return DistanceUtils.dist2Degrees(dist, ++ DistanceUtils.EARTH_MEAN_RADIUS_KM); ++ ++ else if (units.equals("meters") || units.equals("metres") || units.equals("m")) ++ return DistanceUtils.dist2Degrees(dist / 1000, ++ DistanceUtils.EARTH_MEAN_RADIUS_KM); ++ ++ else if (units.equals("centimeters") || units.equals("centimetres") || units.equals("cm")) ++ return DistanceUtils.dist2Degrees(dist / (1000 * 100), ++ DistanceUtils.EARTH_MEAN_RADIUS_KM) ; ++ ++ else if ( units.equals("millimeters") || units.equals("millimetres") || units.equals("mm") || ++ units.equals("milimeters") || units.equals("milimetres") ) // Common spelling mistake. ++ return DistanceUtils.dist2Degrees(dist / (1000 * 1000), ++ DistanceUtils.EARTH_MEAN_RADIUS_KM) ; ++ ++ else if (units.equals("miles") || units.equals("mi")) ++ return DistanceUtils.dist2Degrees(dist, ++ DistanceUtils.EARTH_MEAN_RADIUS_MI); ++ ++ else if (units.equals("degrees") || units.equals("de")) ++ return degrees; ++ ++ throw new IllegalArgumentException("unknow distance units: "+ units); ++ } ++ ++ public static boolean isSupportedUnits(String units){ ++ return SUPPORTED_UNITS.contains(units); ++ } ++ ++} http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialDatasetFactory.java ---------------------------------------------------------------------- diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialDatasetFactory.java index 9d0c8d5,9d0c8d5..1c919f6 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialDatasetFactory.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialDatasetFactory.java @@@ -1,105 -1,105 +1,105 @@@ --/* -- * Licensed to the Apache Software Foundation (ASF) under one -- * or more contributor license agreements. See the NOTICE file -- * distributed with this work for additional information -- * regarding copyright ownership. The ASF licenses this file -- * to you under the Apache License, Version 2.0 (the -- * "License"); you may not use this file except in compliance -- * with the License. You may obtain a copy of the License at -- * -- * http://www.apache.org/licenses/LICENSE-2.0 -- * -- * Unless required by applicable law or agreed to in writing, software -- * distributed under the License is distributed on an "AS IS" BASIS, -- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- * See the License for the specific language governing permissions and -- * limitations under the License. -- */ -- --package org.apache.jena.query.spatial; -- --import org.apache.jena.query.Dataset ; --import org.apache.jena.query.DatasetFactory ; --import org.apache.jena.query.spatial.assembler.SpatialVocab; --import org.apache.jena.sparql.core.DatasetGraph ; --import org.apache.jena.sparql.core.assembler.AssemblerUtils ; --import org.apache.jena.sparql.util.Context ; --import org.apache.jena.system.JenaSystem ; --import org.apache.lucene.store.Directory; --import org.apache.solr.client.solrj.SolrServer; -- --public class SpatialDatasetFactory --{ -- static { JenaSystem.init(); } -- -- /** Use an assembler file to build a dataset with spatial search capabilities */ -- public static Dataset create(String assemblerFile) -- { -- return (Dataset)AssemblerUtils.build(assemblerFile, SpatialVocab.spatialDataset) ; -- } -- -- /** Create a text-indexed dataset */ -- public static Dataset create(Dataset base, SpatialIndex textIndex) -- { -- DatasetGraph dsg = base.asDatasetGraph() ; -- dsg = create(dsg, textIndex) ; -- return DatasetFactory.wrap(dsg) ; -- } -- -- -- /** Create a text-indexed dataset */ -- public static DatasetGraph create(DatasetGraph dsg, SpatialIndex spatialIndex) -- { -- SpatialDocProducer producer = new SpatialDocProducerTriples(spatialIndex) ; -- DatasetGraph dsgt = new DatasetGraphSpatial(dsg, spatialIndex, producer) ; -- // Also set on dsg -- Context c = dsgt.getContext() ; -- -- dsgt.getContext().set(SpatialQuery.spatialIndex, spatialIndex) ; -- return dsgt ; -- -- } -- -- /** Create a Lucene TextIndex */ -- public static SpatialIndex createLuceneIndex(Directory directory, EntityDefinition entMap) -- { -- SpatialIndex index = new SpatialIndexLucene(directory, entMap) ; -- return index ; -- } -- -- /** Create a text-indexed dataset, using Lucene */ -- public static Dataset createLucene(Dataset base, Directory directory, EntityDefinition entMap) -- { -- SpatialIndex index = createLuceneIndex(directory, entMap) ; -- return create(base, index) ; -- } -- -- /** Create a text-indexed dataset, using Lucene */ -- public static DatasetGraph createLucene(DatasetGraph base, Directory directory, EntityDefinition entMap) -- { -- SpatialIndex index = createLuceneIndex(directory, entMap) ; -- return create(base, index) ; -- } -- -- /** Create a Solr TextIndex */ -- public static SpatialIndex createSolrIndex(SolrServer server, EntityDefinition entMap) -- { -- SpatialIndex index = new SpatialIndexSolr(server, entMap) ; -- return index ; -- } -- -- /** Create a text-indexed dataset, using Solr */ -- public static Dataset createSolrIndex(Dataset base, SolrServer server, EntityDefinition entMap) -- { -- SpatialIndex index = createSolrIndex(server, entMap) ; -- return create(base, index) ; -- } -- -- /** Create a text-indexed dataset, using Solr */ -- public static DatasetGraph createSolrIndex(DatasetGraph base, SolrServer server, EntityDefinition entMap) -- { -- SpatialIndex index = createSolrIndex(server, entMap) ; -- return create(base, index) ; -- } --} -- ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++package org.apache.jena.query.spatial; ++ ++import org.apache.jena.query.Dataset ; ++import org.apache.jena.query.DatasetFactory ; ++import org.apache.jena.query.spatial.assembler.SpatialVocab; ++import org.apache.jena.sparql.core.DatasetGraph ; ++import org.apache.jena.sparql.core.assembler.AssemblerUtils ; ++import org.apache.jena.sparql.util.Context ; ++import org.apache.jena.system.JenaSystem ; ++import org.apache.lucene.store.Directory; ++import org.apache.solr.client.solrj.SolrServer; ++ ++public class SpatialDatasetFactory ++{ ++ static { JenaSystem.init(); } ++ ++ /** Use an assembler file to build a dataset with spatial search capabilities */ ++ public static Dataset create(String assemblerFile) ++ { ++ return (Dataset)AssemblerUtils.build(assemblerFile, SpatialVocab.spatialDataset) ; ++ } ++ ++ /** Create a text-indexed dataset */ ++ public static Dataset create(Dataset base, SpatialIndex textIndex) ++ { ++ DatasetGraph dsg = base.asDatasetGraph() ; ++ dsg = create(dsg, textIndex) ; ++ return DatasetFactory.wrap(dsg) ; ++ } ++ ++ ++ /** Create a text-indexed dataset */ ++ public static DatasetGraph create(DatasetGraph dsg, SpatialIndex spatialIndex) ++ { ++ SpatialDocProducer producer = new SpatialDocProducerTriples(spatialIndex) ; ++ DatasetGraph dsgt = new DatasetGraphSpatial(dsg, spatialIndex, producer) ; ++ // Also set on dsg ++ Context c = dsgt.getContext() ; ++ ++ dsgt.getContext().set(SpatialQuery.spatialIndex, spatialIndex) ; ++ return dsgt ; ++ ++ } ++ ++ /** Create a Lucene TextIndex */ ++ public static SpatialIndex createLuceneIndex(Directory directory, EntityDefinition entMap) ++ { ++ SpatialIndex index = new SpatialIndexLucene(directory, entMap) ; ++ return index ; ++ } ++ ++ /** Create a text-indexed dataset, using Lucene */ ++ public static Dataset createLucene(Dataset base, Directory directory, EntityDefinition entMap) ++ { ++ SpatialIndex index = createLuceneIndex(directory, entMap) ; ++ return create(base, index) ; ++ } ++ ++ /** Create a text-indexed dataset, using Lucene */ ++ public static DatasetGraph createLucene(DatasetGraph base, Directory directory, EntityDefinition entMap) ++ { ++ SpatialIndex index = createLuceneIndex(directory, entMap) ; ++ return create(base, index) ; ++ } ++ ++ /** Create a Solr TextIndex */ ++ public static SpatialIndex createSolrIndex(SolrServer server, EntityDefinition entMap) ++ { ++ SpatialIndex index = new SpatialIndexSolr(server, entMap) ; ++ return index ; ++ } ++ ++ /** Create a text-indexed dataset, using Solr */ ++ public static Dataset createSolrIndex(Dataset base, SolrServer server, EntityDefinition entMap) ++ { ++ SpatialIndex index = createSolrIndex(server, entMap) ; ++ return create(base, index) ; ++ } ++ ++ /** Create a text-indexed dataset, using Solr */ ++ public static DatasetGraph createSolrIndex(DatasetGraph base, SolrServer server, EntityDefinition entMap) ++ { ++ SpatialIndex index = createSolrIndex(server, entMap) ; ++ return create(base, index) ; ++ } ++} ++ http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexContext.java ---------------------------------------------------------------------- diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexContext.java index 5d25d19,5d25d19..36a6801 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexContext.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexContext.java @@@ -1,103 -1,103 +1,103 @@@ --/* -- * Licensed to the Apache Software Foundation (ASF) under one -- * or more contributor license agreements. See the NOTICE file -- * distributed with this work for additional information -- * regarding copyright ownership. The ASF licenses this file -- * to you under the Apache License, Version 2.0 (the -- * "License"); you may not use this file except in compliance -- * with the License. You may obtain a copy of the License at -- * -- * http://www.apache.org/licenses/LICENSE-2.0 -- * -- * Unless required by applicable law or agreed to in writing, software -- * distributed under the License is distributed on an "AS IS" BASIS, -- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- * See the License for the specific language governing permissions and -- * limitations under the License. -- */ -- --package org.apache.jena.query.spatial; -- --import java.util.HashMap; --import java.util.HashSet; --import java.util.Iterator; --import java.util.Map; --import java.util.Set; -- --import org.apache.jena.atlas.logging.Log ; --import org.apache.jena.graph.Node ; -- --import com.spatial4j.core.shape.Shape; -- --public class SpatialIndexContext { -- -- private final EntityDefinition defn; -- private final SpatialIndex indexer; -- private final Map<String, Set<SpatialPredicatePairValue>> spatialPredicatePairValues; -- -- public SpatialIndexContext(SpatialIndex indexer) { -- super(); -- this.defn = indexer.getDocDef(); -- this.indexer = indexer; -- this.spatialPredicatePairValues = new HashMap<String, Set<SpatialPredicatePairValue>>(); -- } -- -- public void index(Node g, Node s, Node p, Node o) { -- -- if (!o.isLiteral()) { -- return; -- } -- -- String x = SpatialQueryFuncs.subjectToString(s) ; -- Log.info(getClass(), "Subject: "+x) ; -- -- if (defn.isSpatialPredicate(p) && SpatialValueUtil.isDecimal(o)) { -- -- boolean isLat = defn.isLatitudePredicate(p); -- -- SpatialPredicatePair pair = defn.getSpatialPredicatePair(p); -- Set<SpatialPredicatePairValue> pairValues = spatialPredicatePairValues -- .get(x); -- if (pairValues == null) { -- pairValues = new HashSet<SpatialPredicatePairValue>(); -- spatialPredicatePairValues.put(x, pairValues); -- } -- -- Iterator<SpatialPredicatePairValue> it = pairValues.iterator(); -- SpatialPredicatePairValue toRemove = null; -- -- while (it.hasNext()) { -- SpatialPredicatePairValue pairValue = it.next(); -- if (pairValue.getPair().equals(pair)) { -- Double theOtherValue = pairValue.getTheOtherValue(p); -- if (theOtherValue != null) { -- if (isLat) { -- indexer.add(x, SpatialQuery.ctx.makePoint( -- theOtherValue, -- Double.parseDouble(o.getLiteralLexicalForm()))); -- } else { -- indexer.add(x, SpatialQuery.ctx.makePoint(Double.parseDouble(o.getLiteralLexicalForm()), -- theOtherValue)); -- } -- toRemove = pairValue; -- } -- break; -- } -- } -- if (toRemove != null) { -- pairValues.remove(toRemove); -- return; -- } -- -- SpatialPredicatePairValue toAdd = new SpatialPredicatePairValue( -- pair); -- toAdd.setValue(p, Double.parseDouble(o.getLiteralLexicalForm())); -- pairValues.add(toAdd); -- -- } else if (defn.isWKTPredicate(p) && SpatialValueUtil.isWKTLiteral(o.getLiteral())) { -- @SuppressWarnings("deprecation") -- Shape shape = SpatialQuery.ctx.readShape(o.getLiteralLexicalForm()); -- indexer.add(x, shape); -- } -- } --} ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++package org.apache.jena.query.spatial; ++ ++import java.util.HashMap; ++import java.util.HashSet; ++import java.util.Iterator; ++import java.util.Map; ++import java.util.Set; ++ ++import org.apache.jena.atlas.logging.Log ; ++import org.apache.jena.graph.Node ; ++ ++import com.spatial4j.core.shape.Shape; ++ ++public class SpatialIndexContext { ++ ++ private final EntityDefinition defn; ++ private final SpatialIndex indexer; ++ private final Map<String, Set<SpatialPredicatePairValue>> spatialPredicatePairValues; ++ ++ public SpatialIndexContext(SpatialIndex indexer) { ++ super(); ++ this.defn = indexer.getDocDef(); ++ this.indexer = indexer; ++ this.spatialPredicatePairValues = new HashMap<String, Set<SpatialPredicatePairValue>>(); ++ } ++ ++ public void index(Node g, Node s, Node p, Node o) { ++ ++ if (!o.isLiteral()) { ++ return; ++ } ++ ++ String x = SpatialQueryFuncs.subjectToString(s) ; ++ Log.info(getClass(), "Subject: "+x) ; ++ ++ if (defn.isSpatialPredicate(p) && SpatialValueUtil.isDecimal(o)) { ++ ++ boolean isLat = defn.isLatitudePredicate(p); ++ ++ SpatialPredicatePair pair = defn.getSpatialPredicatePair(p); ++ Set<SpatialPredicatePairValue> pairValues = spatialPredicatePairValues ++ .get(x); ++ if (pairValues == null) { ++ pairValues = new HashSet<SpatialPredicatePairValue>(); ++ spatialPredicatePairValues.put(x, pairValues); ++ } ++ ++ Iterator<SpatialPredicatePairValue> it = pairValues.iterator(); ++ SpatialPredicatePairValue toRemove = null; ++ ++ while (it.hasNext()) { ++ SpatialPredicatePairValue pairValue = it.next(); ++ if (pairValue.getPair().equals(pair)) { ++ Double theOtherValue = pairValue.getTheOtherValue(p); ++ if (theOtherValue != null) { ++ if (isLat) { ++ indexer.add(x, SpatialQuery.ctx.makePoint( ++ theOtherValue, ++ Double.parseDouble(o.getLiteralLexicalForm()))); ++ } else { ++ indexer.add(x, SpatialQuery.ctx.makePoint(Double.parseDouble(o.getLiteralLexicalForm()), ++ theOtherValue)); ++ } ++ toRemove = pairValue; ++ } ++ break; ++ } ++ } ++ if (toRemove != null) { ++ pairValues.remove(toRemove); ++ return; ++ } ++ ++ SpatialPredicatePairValue toAdd = new SpatialPredicatePairValue( ++ pair); ++ toAdd.setValue(p, Double.parseDouble(o.getLiteralLexicalForm())); ++ pairValues.add(toAdd); ++ ++ } else if (defn.isWKTPredicate(p) && SpatialValueUtil.isWKTLiteral(o.getLiteral())) { ++ @SuppressWarnings("deprecation") ++ Shape shape = SpatialQuery.ctx.readShape(o.getLiteralLexicalForm()); ++ indexer.add(x, shape); ++ } ++ } ++} http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialPredicatePair.java ---------------------------------------------------------------------- diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialPredicatePair.java index 2f88e1c,2f88e1c..eedc212 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialPredicatePair.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialPredicatePair.java @@@ -1,74 -1,74 +1,74 @@@ --/* -- * Licensed to the Apache Software Foundation (ASF) under one -- * or more contributor license agreements. See the NOTICE file -- * distributed with this work for additional information -- * regarding copyright ownership. The ASF licenses this file -- * to you under the Apache License, Version 2.0 (the -- * "License"); you may not use this file except in compliance -- * with the License. You may obtain a copy of the License at -- * -- * http://www.apache.org/licenses/LICENSE-2.0 -- * -- * Unless required by applicable law or agreed to in writing, software -- * distributed under the License is distributed on an "AS IS" BASIS, -- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- * See the License for the specific language governing permissions and -- * limitations under the License. -- */ -- --package org.apache.jena.query.spatial; -- --import org.apache.jena.graph.Node ; -- --public class SpatialPredicatePair { -- -- private Node latitudePredicate; -- private Node longitudePredicate; -- -- public SpatialPredicatePair(Node latitudePredicate, Node longitudePredicate) { -- super(); -- this.latitudePredicate = latitudePredicate; -- this.longitudePredicate = longitudePredicate; -- } -- -- public Node getLatitudePredicate() { -- return latitudePredicate; -- } -- -- public Node getLongitudePredicate() { -- return longitudePredicate; -- } -- -- @Override -- public int hashCode() { -- return latitudePredicate.hashCode() * 7 + longitudePredicate.hashCode() -- * 13; -- } -- -- @Override -- public boolean equals(Object otherObject) { -- // a quick test to see if the objects are identical -- if (this == otherObject) -- return true; -- -- // must return false if the explicit parameter is null -- if (otherObject == null) -- return false; -- -- // if the classes don't match, they can't be equal -- if (getClass() != otherObject.getClass()) -- return false; -- -- // now we know otherObject is a non-null Employee -- SpatialPredicatePair other = (SpatialPredicatePair) otherObject; -- -- // test whether the fields have identical values -- return latitudePredicate.equals(other.latitudePredicate) -- && longitudePredicate == other.longitudePredicate; -- } -- -- @Override -- public String toString(){ -- return "[ " + latitudePredicate.toString() + ", " + longitudePredicate.toString() + " ]"; -- } --} ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++package org.apache.jena.query.spatial; ++ ++import org.apache.jena.graph.Node ; ++ ++public class SpatialPredicatePair { ++ ++ private Node latitudePredicate; ++ private Node longitudePredicate; ++ ++ public SpatialPredicatePair(Node latitudePredicate, Node longitudePredicate) { ++ super(); ++ this.latitudePredicate = latitudePredicate; ++ this.longitudePredicate = longitudePredicate; ++ } ++ ++ public Node getLatitudePredicate() { ++ return latitudePredicate; ++ } ++ ++ public Node getLongitudePredicate() { ++ return longitudePredicate; ++ } ++ ++ @Override ++ public int hashCode() { ++ return latitudePredicate.hashCode() * 7 + longitudePredicate.hashCode() ++ * 13; ++ } ++ ++ @Override ++ public boolean equals(Object otherObject) { ++ // a quick test to see if the objects are identical ++ if (this == otherObject) ++ return true; ++ ++ // must return false if the explicit parameter is null ++ if (otherObject == null) ++ return false; ++ ++ // if the classes don't match, they can't be equal ++ if (getClass() != otherObject.getClass()) ++ return false; ++ ++ // now we know otherObject is a non-null Employee ++ SpatialPredicatePair other = (SpatialPredicatePair) otherObject; ++ ++ // test whether the fields have identical values ++ return latitudePredicate.equals(other.latitudePredicate) ++ && longitudePredicate == other.longitudePredicate; ++ } ++ ++ @Override ++ public String toString(){ ++ return "[ " + latitudePredicate.toString() + ", " + longitudePredicate.toString() + " ]"; ++ } ++} http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialPredicatePairValue.java ---------------------------------------------------------------------- diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialPredicatePairValue.java index b8e1285,b8e1285..9288757 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialPredicatePairValue.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialPredicatePairValue.java @@@ -1,109 -1,109 +1,109 @@@ --/* -- * Licensed to the Apache Software Foundation (ASF) under one -- * or more contributor license agreements. See the NOTICE file -- * distributed with this work for additional information -- * regarding copyright ownership. The ASF licenses this file -- * to you under the Apache License, Version 2.0 (the -- * "License"); you may not use this file except in compliance -- * with the License. You may obtain a copy of the License at -- * -- * http://www.apache.org/licenses/LICENSE-2.0 -- * -- * Unless required by applicable law or agreed to in writing, software -- * distributed under the License is distributed on an "AS IS" BASIS, -- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- * See the License for the specific language governing permissions and -- * limitations under the License. -- */ -- --package org.apache.jena.query.spatial; -- --import org.apache.jena.graph.Node ; --import org.slf4j.Logger; --import org.slf4j.LoggerFactory; -- --public class SpatialPredicatePairValue { -- -- private static Logger log = LoggerFactory -- .getLogger(SpatialPredicatePairValue.class); -- -- public SpatialPredicatePairValue(SpatialPredicatePair pair) { -- this.pair = pair; -- } -- -- private SpatialPredicatePair pair; -- private Double latitudeValue; -- private Double longitudeValue; -- -- public Double getLatitudeValue() { -- return latitudeValue; -- } -- -- public Double getLongitudeValue() { -- return longitudeValue; -- } -- -- public SpatialPredicatePair getPair() { -- return pair; -- } -- -- public void setValue(Node predicate, Double value) { -- if (predicate.equals(pair.getLatitudePredicate())) { -- this.latitudeValue = value; -- } else if (predicate.equals(pair.getLongitudePredicate())) { -- this.longitudeValue = value; -- } else { -- log.warn("Try to set value to a SpatialPredicatePairValue with no such predicate: " -- + predicate + " :: " + value); -- } -- -- } -- -- public Double getTheOtherValue(Node predicate) { -- if (pair.getLatitudePredicate().equals(predicate)) { -- return this.getLongitudeValue(); -- } else if (predicate.equals(pair.getLongitudePredicate())) { -- return this.getLatitudeValue(); -- } else { -- log.warn("Try to get value to a SpatialPredicatePairValue with no such predicate: " -- + predicate); -- return null; -- } -- } -- -- @Override -- public int hashCode() { -- int latitudeHashCode = latitudeValue == null ? 0 : latitudeValue -- .hashCode() * 17; -- int longitudeHashCode = longitudeValue == null ? 0 : longitudeValue -- .hashCode() * 19; -- return pair.hashCode() * 11 + latitudeHashCode + longitudeHashCode; -- } -- -- @Override -- public boolean equals(Object otherObject) { -- // a quick test to see if the objects are identical -- if (this == otherObject) -- return true; -- -- // must return false if the explicit parameter is null -- if (otherObject == null) -- return false; -- -- // if the classes don't match, they can't be equal -- if (getClass() != otherObject.getClass()) -- return false; -- -- // now we know otherObject is a non-null Employee -- SpatialPredicatePairValue other = (SpatialPredicatePairValue) otherObject; -- -- boolean latitudeValueEquals = this.latitudeValue == null ? other.latitudeValue == null -- : this.latitudeValue.equals(other.latitudeValue); -- boolean longitudeValueEquals = this.longitudeValue == null ? other.longitudeValue == null -- : this.longitudeValue.equals(other.longitudeValue); -- -- // test whether the fields have identical values -- return pair.equals(other.pair) && latitudeValueEquals -- && longitudeValueEquals; -- } --} ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++package org.apache.jena.query.spatial; ++ ++import org.apache.jena.graph.Node ; ++import org.slf4j.Logger; ++import org.slf4j.LoggerFactory; ++ ++public class SpatialPredicatePairValue { ++ ++ private static Logger log = LoggerFactory ++ .getLogger(SpatialPredicatePairValue.class); ++ ++ public SpatialPredicatePairValue(SpatialPredicatePair pair) { ++ this.pair = pair; ++ } ++ ++ private SpatialPredicatePair pair; ++ private Double latitudeValue; ++ private Double longitudeValue; ++ ++ public Double getLatitudeValue() { ++ return latitudeValue; ++ } ++ ++ public Double getLongitudeValue() { ++ return longitudeValue; ++ } ++ ++ public SpatialPredicatePair getPair() { ++ return pair; ++ } ++ ++ public void setValue(Node predicate, Double value) { ++ if (predicate.equals(pair.getLatitudePredicate())) { ++ this.latitudeValue = value; ++ } else if (predicate.equals(pair.getLongitudePredicate())) { ++ this.longitudeValue = value; ++ } else { ++ log.warn("Try to set value to a SpatialPredicatePairValue with no such predicate: " ++ + predicate + " :: " + value); ++ } ++ ++ } ++ ++ public Double getTheOtherValue(Node predicate) { ++ if (pair.getLatitudePredicate().equals(predicate)) { ++ return this.getLongitudeValue(); ++ } else if (predicate.equals(pair.getLongitudePredicate())) { ++ return this.getLatitudeValue(); ++ } else { ++ log.warn("Try to get value to a SpatialPredicatePairValue with no such predicate: " ++ + predicate); ++ return null; ++ } ++ } ++ ++ @Override ++ public int hashCode() { ++ int latitudeHashCode = latitudeValue == null ? 0 : latitudeValue ++ .hashCode() * 17; ++ int longitudeHashCode = longitudeValue == null ? 0 : longitudeValue ++ .hashCode() * 19; ++ return pair.hashCode() * 11 + latitudeHashCode + longitudeHashCode; ++ } ++ ++ @Override ++ public boolean equals(Object otherObject) { ++ // a quick test to see if the objects are identical ++ if (this == otherObject) ++ return true; ++ ++ // must return false if the explicit parameter is null ++ if (otherObject == null) ++ return false; ++ ++ // if the classes don't match, they can't be equal ++ if (getClass() != otherObject.getClass()) ++ return false; ++ ++ // now we know otherObject is a non-null Employee ++ SpatialPredicatePairValue other = (SpatialPredicatePairValue) otherObject; ++ ++ boolean latitudeValueEquals = this.latitudeValue == null ? other.latitudeValue == null ++ : this.latitudeValue.equals(other.latitudeValue); ++ boolean longitudeValueEquals = this.longitudeValue == null ? other.longitudeValue == null ++ : this.longitudeValue.equals(other.longitudeValue); ++ ++ // test whether the fields have identical values ++ return pair.equals(other.pair) && latitudeValueEquals ++ && longitudeValueEquals; ++ } ++} http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialValueUtil.java ---------------------------------------------------------------------- diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialValueUtil.java index 3996f36,3996f36..e30d8ee --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialValueUtil.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialValueUtil.java @@@ -1,60 -1,60 +1,60 @@@ --/* -- * Licensed to the Apache Software Foundation (ASF) under one -- * or more contributor license agreements. See the NOTICE file -- * distributed with this work for additional information -- * regarding copyright ownership. The ASF licenses this file -- * to you under the Apache License, Version 2.0 (the -- * "License"); you may not use this file except in compliance -- * with the License. You may obtain a copy of the License at -- * -- * http://www.apache.org/licenses/LICENSE-2.0 -- * -- * Unless required by applicable law or agreed to in writing, software -- * distributed under the License is distributed on an "AS IS" BASIS, -- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- * See the License for the specific language governing permissions and -- * limitations under the License. -- */ -- --package org.apache.jena.query.spatial; -- --import org.apache.jena.datatypes.RDFDatatype ; --import org.apache.jena.datatypes.xsd.XSDDatatype ; --import org.apache.jena.graph.Node ; --import org.apache.jena.graph.impl.LiteralLabel ; --import org.apache.jena.sparql.util.NodeUtils ; -- --public class SpatialValueUtil { -- -- /** Does the LiteralLabel look like a decimal? -- * (Maybe a string - if so, OK if it parses as a decimal) -- */ -- public static boolean isDecimal(Node n) { -- if ( NodeUtils.isSimpleString(n) || NodeUtils.isLangString(n) ) { -- try { -- Double.parseDouble(n.getLiteralLexicalForm()) ; -- return true; -- } catch (NumberFormatException e) { -- return false; -- } -- } -- -- RDFDatatype dtype = n.getLiteralDatatype(); -- if ((dtype.equals(XSDDatatype.XSDfloat)) -- || (dtype.equals(XSDDatatype.XSDdecimal)) -- || (dtype.equals(XSDDatatype.XSDdouble) || (dtype -- .equals(XSDDatatype.XSDinteger)))) -- return true; -- return false; -- } -- -- public static boolean isWKTLiteral(LiteralLabel literal) { -- RDFDatatype dtype = literal.getDatatype(); -- if (dtype == null) -- return false; -- if (dtype.getURI().equals( -- EntityDefinition.geosparql_wktLiteral.getURI())) -- return true; -- return false; -- } --} ++/* ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++package org.apache.jena.query.spatial; ++ ++import org.apache.jena.datatypes.RDFDatatype ; ++import org.apache.jena.datatypes.xsd.XSDDatatype ; ++import org.apache.jena.graph.Node ; ++import org.apache.jena.graph.impl.LiteralLabel ; ++import org.apache.jena.sparql.util.NodeUtils ; ++ ++public class SpatialValueUtil { ++ ++ /** Does the LiteralLabel look like a decimal? ++ * (Maybe a string - if so, OK if it parses as a decimal) ++ */ ++ public static boolean isDecimal(Node n) { ++ if ( NodeUtils.isSimpleString(n) || NodeUtils.isLangString(n) ) { ++ try { ++ Double.parseDouble(n.getLiteralLexicalForm()) ; ++ return true; ++ } catch (NumberFormatException e) { ++ return false; ++ } ++ } ++ ++ RDFDatatype dtype = n.getLiteralDatatype(); ++ if ((dtype.equals(XSDDatatype.XSDfloat)) ++ || (dtype.equals(XSDDatatype.XSDdecimal)) ++ || (dtype.equals(XSDDatatype.XSDdouble) || (dtype ++ .equals(XSDDatatype.XSDinteger)))) ++ return true; ++ return false; ++ } ++ ++ public static boolean isWKTLiteral(LiteralLabel literal) { ++ RDFDatatype dtype = literal.getDatatype(); ++ if (dtype == null) ++ return false; ++ if (dtype.getURI().equals( ++ EntityDefinition.geosparql_wktLiteral.getURI())) ++ return true; ++ return false; ++ } ++}
