You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/11/15 17:21:57 UTC
[1/6] jena git commit: Process UNDERSCORE.
Repository: jena
Updated Branches:
refs/heads/master b237c76ae -> 9f5bce9d8
Process UNDERSCORE.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/2c351ee3
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/2c351ee3
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/2c351ee3
Branch: refs/heads/master
Commit: 2c351ee3eeb336694688978bb0a7cef5f0eea535
Parents: b237c76
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Nov 14 14:26:12 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Nov 14 14:26:12 2016 +0000
----------------------------------------------------------------------
.../apache/jena/riot/tokens/TokenizerText.java | 28 +++++++++++++-------
1 file changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/2c351ee3/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java b/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java
index 94fa9b2..267907b 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/tokens/TokenizerText.java
@@ -36,7 +36,7 @@ import org.apache.jena.sparql.ARQInternalErrorException ;
public final class TokenizerText implements Tokenizer
{
- // TODO Remove CNTL and make SYMBOLS
+ // TODO Remove CNTRL and make SYMBOLS
// Drop through to final general symbol/keyword reader, including <=, !=
// Care with <=
// STRING, not STRING1/2, LONG_STRING1/2
@@ -294,11 +294,18 @@ public final class TokenizerText implements Tokenizer
}
if ( ch == CH_UNDERSCORE ) {
- // Blank node :label must be at least one char
- expect("_:") ;
- token.setImage(readBlankNodeLabel()) ;
- token.setType(TokenType.BNODE) ;
- if ( Checking ) checkBlankNode(token.getImage()) ;
+ reader.readChar();
+ int ch2 = reader.peekChar();
+ if ( ch2 == CH_COLON ) {
+ reader.readChar();
+ // Blank node :label must be at least one char
+ token.setImage(readBlankNodeLabel()) ;
+ token.setType(TokenType.BNODE) ;
+ if ( Checking ) checkBlankNode(token.getImage()) ;
+ return token ;
+ }
+ token.setType(TokenType.UNDERSCORE) ;
+ /*token.setImage(CH_UNDERSCORE) ;*/
return token ;
}
@@ -370,9 +377,12 @@ public final class TokenizerText implements Tokenizer
// Specials (if blank node processing off)
//case CH_COLON: reader.readChar() ; token.setType(TokenType.COLON) ; return token ;
- case CH_UNDERSCORE: reader.readChar() ; token.setType(TokenType.UNDERSCORE) ; /*token.setImage(CH_UNDERSCORE) ;*/ return token ;
+
+ // Done above with blank nodes.
+ //case CH_UNDERSCORE: reader.readChar() ; token.setType(TokenType.UNDERSCORE) ; /*token.setImage(CH_UNDERSCORE) ;*/ return token ;
case CH_LT: reader.readChar() ; token.setType(TokenType.LT) ; /*token.setImage(CH_LT) ;*/ return token ;
case CH_GT: reader.readChar() ; token.setType(TokenType.GT) ; /*token.setImage(CH_GT) ;*/ return token ;
+ // Above: CNTRL
case CH_STAR: reader.readChar() ; token.setType(TokenType.STAR) ; /*token.setImage(CH_STAR) ;*/ return token ;
// Multi character symbols
@@ -668,13 +678,13 @@ public final class TokenizerText implements Tokenizer
ch = reader.peekChar() ;
if ( ! isHexChar(ch) )
- error("Not a hex charcater: '%c'",ch) ;
+ error("Not a hex character: '%c'",ch) ;
stringBuilder.append((char)ch) ;
reader.readChar() ;
ch = reader.peekChar() ;
if ( ! isHexChar(ch) )
- error("Not a hex charcater: '%c'",ch) ;
+ error("Not a hex character: '%c'",ch) ;
stringBuilder.append((char)ch) ;
reader.readChar() ;
}
[4/6] jena git commit: JENA-1261: add triples,
don't underwrite graphs.
Posted by an...@apache.org.
JENA-1261: add triples, don't underwrite graphs.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/968e24bb
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/968e24bb
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/968e24bb
Branch: refs/heads/master
Commit: 968e24bb212c7a7edca68d2ad17b8747f8dee6ac
Parents: 6110847
Author: Andy Seaborne <an...@apache.org>
Authored: Tue Nov 15 16:19:03 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Nov 15 16:19:03 2016 +0000
----------------------------------------------------------------------
.../apache/jena/sparql/util/DatasetUtils.java | 47 +++++++++++---------
1 file changed, 25 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/968e24bb/jena-arq/src/main/java/org/apache/jena/sparql/util/DatasetUtils.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/DatasetUtils.java b/jena-arq/src/main/java/org/apache/jena/sparql/util/DatasetUtils.java
index 851732b..4cc5f79 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/util/DatasetUtils.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/DatasetUtils.java
@@ -23,11 +23,12 @@ import java.util.Arrays ;
import java.util.Iterator ;
import java.util.List ;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.GraphUtil;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.NodeFactory ;
import org.apache.jena.query.Dataset ;
import org.apache.jena.query.DatasetFactory ;
-import org.apache.jena.rdf.model.Model ;
import org.apache.jena.riot.RDFDataMgr ;
import org.apache.jena.riot.system.IRIResolver ;
import org.apache.jena.sparql.core.DatasetDescription ;
@@ -39,6 +40,8 @@ import org.apache.jena.system.Txn ;
/** Internal Dataset factory + graph equivalents. */
public class DatasetUtils
{
+ private DatasetUtils() {}
+
/** Create a general purpose, in-memory dataset, and load data into the default graph and
* also some named graphs.
* @param uri Default graph
@@ -178,37 +181,37 @@ public class DatasetUtils
Txn.executeWrite(dsg, ()->addInGraphsWorker(dsg, uriList, namedSourceList, baseURI)) ;
}
+ // For the transactional case, could read straight in, not via buffering graphs that catch syntax errors.
+
private static void addInGraphsWorker(DatasetGraph dsg, List<String> uriList, List<String> namedSourceList, String baseURI) {
+ String absBaseURI = null;
+ // Sort out base URI, if any.
+ if ( baseURI != null )
+ absBaseURI = IRIResolver.resolveString(baseURI);
+
// Merge into background graph
- if ( uriList != null ) {
- Model m = GraphFactory.makeDefaultModel();
+ if ( uriList != null && ! uriList.isEmpty() ) {
+ // Isolate from syntax errors
+ Graph gTmp = GraphFactory.createJenaDefaultGraph();
for ( Iterator<String> iter = uriList.iterator() ; iter.hasNext() ; ) {
String sourceURI = iter.next();
- String absURI = null;
- if ( baseURI != null )
- absURI = IRIResolver.resolveString(sourceURI, baseURI);
- else
- absURI = IRIResolver.resolveString(sourceURI);
- // FileManager.readGraph?
- RDFDataMgr.read(m, sourceURI, absURI, null);
+ String absURI = IRIResolver.resolveString(sourceURI, baseURI);
+ RDFDataMgr.read(gTmp, sourceURI, absURI, null);
}
- dsg.setDefaultGraph(m.getGraph());
- } else {
- dsg.setDefaultGraph(GraphFactory.createDefaultGraph());
+ GraphUtil.addInto(dsg.getDefaultGraph(), gTmp);
}
- if ( namedSourceList != null ) {
+ if ( namedSourceList != null && ! namedSourceList.isEmpty() ) {
for ( Iterator<String> iter = namedSourceList.iterator() ; iter.hasNext() ; ) {
String sourceURI = iter.next();
- String absURI = null;
- if ( baseURI != null )
- absURI = IRIResolver.resolveString(baseURI, sourceURI);
- else
- absURI = IRIResolver.resolveString(sourceURI);
- Model m = GraphFactory.makeDefaultModel();
- RDFDataMgr.read(m, sourceURI, absURI, null);
+ if ( absBaseURI == null )
+ sourceURI = IRIResolver.resolveString(sourceURI);
+ else
+ sourceURI = IRIResolver.resolveString(sourceURI, absBaseURI);
+ Graph gTmp = GraphFactory.createJenaDefaultGraph();
+ RDFDataMgr.read(gTmp, sourceURI, absBaseURI, null);
Node gn = NodeFactory.createURI(sourceURI);
- dsg.addGraph(gn, m.getGraph());
+ dsg.addGraph(gn, gTmp);
}
}
}
[3/6] jena git commit: Minor clean.
Posted by an...@apache.org.
Minor clean.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/6110847f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/6110847f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/6110847f
Branch: refs/heads/master
Commit: 6110847f6d5de8a7ac115a32910b9f5d37c2baf9
Parents: 0af13c1
Author: Andy Seaborne <an...@apache.org>
Authored: Tue Nov 15 16:18:02 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Nov 15 16:18:02 2016 +0000
----------------------------------------------------------------------
jena-cmds/src/main/java/arq/sparql.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/6110847f/jena-cmds/src/main/java/arq/sparql.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/arq/sparql.java b/jena-cmds/src/main/java/arq/sparql.java
index d42ba7f..8bb0863 100644
--- a/jena-cmds/src/main/java/arq/sparql.java
+++ b/jena-cmds/src/main/java/arq/sparql.java
@@ -24,7 +24,7 @@ import org.apache.jena.query.Syntax ;
public class sparql extends query
{
- public static void main (String... argv) {
+ public static void main(String... argv) {
new sparql(argv).mainRun() ;
}
[5/6] jena git commit: Use full IRI resolution for "file:" URIs.
Posted by an...@apache.org.
Use full IRI resolution for "file:" URIs.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/974f5629
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/974f5629
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/974f5629
Branch: refs/heads/master
Commit: 974f5629928c5e255fb0097e9f1098892e460242
Parents: 968e24b
Author: Andy Seaborne <an...@apache.org>
Authored: Tue Nov 15 16:25:45 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Nov 15 16:25:45 2016 +0000
----------------------------------------------------------------------
.../main/java/org/apache/jena/riot/system/IRIResolver.java | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/974f5629/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java b/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
index 7a199e1..bb5da0e 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/system/IRIResolver.java
@@ -220,9 +220,9 @@ public abstract class IRIResolver
}
/**
- * Resolve a URI against a base. If baseStr is a relative file IRI
- * then it is first resolved against the current working directory.
- * If it is an absolute URI, it is normalized.
+ * Resolve a URI against the base for this process. If baseStr is a
+ * relative file IRI then it is first resolved against the current
+ * working directory. If it is an absolute URI, it is normalized.
*
* @param uriStr
* @return String An absolute URI
@@ -264,9 +264,6 @@ public abstract class IRIResolver
return globalResolver.getBaseIRI().create(i) ;
IRI base = iriFactory.create(baseStr) ;
-
- if ("file".equalsIgnoreCase(base.getScheme()))
- return globalResolver.getBaseIRI().create(i) ;
return base.create(i) ;
}
[2/6] jena git commit: Fix formatting. Use Txn.
Posted by an...@apache.org.
Fix formatting. Use Txn.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/0af13c1f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/0af13c1f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/0af13c1f
Branch: refs/heads/master
Commit: 0af13c1f3fa7bf5c7da9426617191bdde0f419d6
Parents: 2c351ee
Author: Andy Seaborne <an...@apache.org>
Authored: Mon Nov 14 14:27:42 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Nov 14 14:27:42 2016 +0000
----------------------------------------------------------------------
.../java/arq/cmdline/ModDatasetAssembler.java | 15 ++---
.../java/arq/cmdline/ModDatasetGeneral.java | 67 ++++++++------------
2 files changed, 33 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/0af13c1f/jena-cmds/src/main/java/arq/cmdline/ModDatasetAssembler.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/arq/cmdline/ModDatasetAssembler.java b/jena-cmds/src/main/java/arq/cmdline/ModDatasetAssembler.java
index 840136c..9c1ffa0 100644
--- a/jena-cmds/src/main/java/arq/cmdline/ModDatasetAssembler.java
+++ b/jena-cmds/src/main/java/arq/cmdline/ModDatasetAssembler.java
@@ -34,8 +34,7 @@ public class ModDatasetAssembler extends ModDataset
private ModAssembler modAssembler = new ModAssembler() ;
@Override
- public Dataset createDataset()
- {
+ public Dataset createDataset() {
if ( modAssembler.getAssemblerFile() == null )
return null ;
@@ -52,19 +51,15 @@ public class ModDatasetAssembler extends ModDataset
catch (Exception ex)
{ throw new CmdException("Error creating dataset", ex) ; }
return dataset ;
-
}
@Override
- public void registerWith(CmdGeneral cmdLine)
- {
- modAssembler.registerWith(cmdLine) ;
+ public void registerWith(CmdGeneral cmdLine) {
+ modAssembler.registerWith(cmdLine);
}
@Override
- public void processArgs(CmdArgModule cmdLine)
- {
- modAssembler.processArgs(cmdLine) ;
+ public void processArgs(CmdArgModule cmdLine) {
+ modAssembler.processArgs(cmdLine);
}
-
}
http://git-wip-us.apache.org/repos/asf/jena/blob/0af13c1f/jena-cmds/src/main/java/arq/cmdline/ModDatasetGeneral.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/arq/cmdline/ModDatasetGeneral.java b/jena-cmds/src/main/java/arq/cmdline/ModDatasetGeneral.java
index 0f9d665..57f0b19 100644
--- a/jena-cmds/src/main/java/arq/cmdline/ModDatasetGeneral.java
+++ b/jena-cmds/src/main/java/arq/cmdline/ModDatasetGeneral.java
@@ -27,10 +27,10 @@ import jena.cmd.CmdGeneral;
import org.apache.jena.query.Dataset ;
import org.apache.jena.query.DatasetFactory ;
import org.apache.jena.query.LabelExistsException ;
-import org.apache.jena.query.ReadWrite ;
import org.apache.jena.riot.RDFDataMgr ;
import org.apache.jena.shared.JenaException ;
import org.apache.jena.sparql.util.DatasetUtils ;
+import org.apache.jena.system.Txn;
/** ModDataset: arguments to build a dataset -
* see also ModDatasetAssembler which extends ModDataset
@@ -40,10 +40,8 @@ public class ModDatasetGeneral extends ModDataset
{
// See also ModDatasetAssembler
protected final ArgDecl graphDecl = new ArgDecl(ArgDecl.HasValue, "graph") ;
- protected final ArgDecl dataDecl = new ArgDecl(ArgDecl.HasValue, "data") ;
+ protected final ArgDecl dataDecl = new ArgDecl(ArgDecl.HasValue, "data") ;
protected final ArgDecl namedGraphDecl = new ArgDecl(ArgDecl.HasValue, "named", "namedgraph", "namedGraph", "namedData", "nameddata") ;
- //protected final ArgDecl dataFmtDecl = new ArgDecl(ArgDecl.HasValue, "fmt", "format") ;
- //protected final ArgDecl dirDecl = new ArgDecl(ArgDecl.HasValue, "dir") ;
private List<String> dataURLs = null ;
private List<String> graphURLs = null ;
@@ -51,8 +49,7 @@ public class ModDatasetGeneral extends ModDataset
protected ModDatasetGeneral() {}
@Override
- public void registerWith(CmdGeneral cl)
- {
+ public void registerWith(CmdGeneral cl) {
cl.getUsage().startCategory("Dataset") ;
cl.add(dataDecl,
"--data=FILE",
@@ -62,24 +59,22 @@ public class ModDatasetGeneral extends ModDataset
"Graph for default graph of the datset") ;
cl.add(namedGraphDecl,
"--namedGraph=FILE",
- "Add a graph into the dataset as a named graph") ;
+ "Add a graph into the dataset as a named graph");
}
-
+
@Override
- public void processArgs(CmdArgModule cmdLine)
- {
- dataURLs = cmdLine.getValues(dataDecl) ;
- graphURLs = cmdLine.getValues(graphDecl) ;
- namedGraphURLs = cmdLine.getValues(namedGraphDecl) ;
+ public void processArgs(CmdArgModule cmdLine) {
+ dataURLs = cmdLine.getValues(dataDecl);
+ graphURLs = cmdLine.getValues(graphDecl);
+ namedGraphURLs = cmdLine.getValues(namedGraphDecl);
}
@Override
- public Dataset createDataset()
- {
- // If nothing specified to the module. Leave alone and hope the query has FROM/FROM NAMED
- if ( ( dataURLs == null || dataURLs.size() == 0) &&
- (graphURLs == null || graphURLs.size() == 0) &&
- (namedGraphURLs == null || namedGraphURLs.size() == 0 ) )
+ public Dataset createDataset() {
+ // If nothing specified for this module, Leave alone and hope the query has FROM/FROM NAMED
+ if ( (dataURLs == null || dataURLs.size() == 0) &&
+ (graphURLs == null || graphURLs.size() == 0) &&
+ (namedGraphURLs == null || namedGraphURLs.size() == 0) )
return null ;
Dataset ds = DatasetFactory.createTxnMem() ;
@@ -94,25 +89,21 @@ public class ModDatasetGeneral extends ModDataset
return ! list.isEmpty() ;
}
- protected void addGraphs(Dataset ds)
- {
+ protected void addGraphs(Dataset ds) {
try {
- if ( hasEntries(dataURLs) )
- {
- if ( ds.supportsTransactions() )
- ds.begin(ReadWrite.WRITE) ;
-
- for ( String url : dataURLs )
- RDFDataMgr.read(ds, url) ;
-
+ if ( hasEntries(dataURLs) ) {
if ( ds.supportsTransactions() ) {
- ds.commit() ;
- ds.end() ;
+ Txn.executeWrite(ds, () -> {
+ for ( String url : dataURLs )
+ RDFDataMgr.read(ds, url);
+ });
+ } else {
+ for ( String url : dataURLs )
+ RDFDataMgr.read(ds, url);
}
}
-
if ( hasEntries(graphURLs) || hasEntries(namedGraphURLs) )
- ds = DatasetUtils.addInGraphs(ds, graphURLs, namedGraphURLs, null) ;
+ DatasetUtils.addInGraphs(ds, graphURLs, namedGraphURLs, null) ;
}
catch (LabelExistsException ex)
{ throw new CmdException(ex.getMessage()) ; }
@@ -122,13 +113,11 @@ public class ModDatasetGeneral extends ModDataset
{ throw new CmdException("Error creating dataset", ex) ; }
}
- public List<String> getGraphURLs()
- {
- return graphURLs ;
+ public List<String> getGraphURLs() {
+ return graphURLs;
}
- public List<String> getNamedGraphURLs()
- {
- return namedGraphURLs ;
+ public List<String> getNamedGraphURLs() {
+ return namedGraphURLs;
}
}
[6/6] jena git commit: Tidy up.
Posted by an...@apache.org.
Tidy up.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/9f5bce9d
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/9f5bce9d
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/9f5bce9d
Branch: refs/heads/master
Commit: 9f5bce9d8935a76e5c98f4a317387a492dde5bdb
Parents: 974f562
Author: Andy Seaborne <an...@apache.org>
Authored: Tue Nov 15 16:25:52 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Nov 15 16:25:52 2016 +0000
----------------------------------------------------------------------
.../java/org/apache/jena/tdb/store/NodeId.java | 148 ++++++++-----------
1 file changed, 63 insertions(+), 85 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/9f5bce9d/jena-tdb/src/main/java/org/apache/jena/tdb/store/NodeId.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/NodeId.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/NodeId.java
index f4173f7..5774f0d 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/store/NodeId.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/NodeId.java
@@ -46,8 +46,7 @@ public class NodeId
public static final int SIZE = SystemTDB.SizeOfLong ;
final long value ;
- public static NodeId create(long value)
- {
+ public static NodeId create(long value) {
// All creation of NodeIds must go through this.
if ( value == NodeDoesNotExist.value )
return NodeDoesNotExist ;
@@ -60,14 +59,12 @@ public class NodeId
public static NodeId create(ByteBuffer b) { return create(b, 0) ; }
// Chance for a cache? (Small Java objects are really not that expensive these days.)
- public static NodeId create(byte[] b, int idx)
- {
+ public static NodeId create(byte[] b, int idx) {
long value = Bytes.getLong(b, idx) ;
return create(value) ;
}
- public static NodeId create(ByteBuffer b, int idx)
- {
+ public static NodeId create(ByteBuffer b, int idx) {
long value = b.getLong(idx) ;
return create(value) ;
}
@@ -79,42 +76,38 @@ public class NodeId
public boolean isDirect() { return type() != NONE && type() != SPECIAL ; }
- public int type()
- {
- return (int)BitsLong.unpack(value, 56, 64) ;
+ public int type() {
+ return (int)BitsLong.unpack(value, 56, 64);
}
- static long setType(long value, int type)
- {
- return BitsLong.pack(value, type, 56, 64) ;
+ static long setType(long value, int type) {
+ return BitsLong.pack(value, type, 56, 64);
}
-
// Masked?
public long getId() { return value ; }
@Override
- public int hashCode()
- {
+ public int hashCode() {
// Ensure the type byte has an effect on the bottom 32 bits.
- return ((int)value) ^ ((int)(value >> 32)) ;
+ return ((int)value) ^ ((int)(value >> 32));
}
@Override
- public boolean equals(Object other)
- {
+ public boolean equals(Object other) {
if ( this == other ) return true ;
if ( !(other instanceof NodeId ) ) return false ;
return value == ((NodeId)other).value ;
}
@Override
- public String toString()
- {
- if ( this == NodeDoesNotExist ) return "[DoesNotExist]" ;
- if ( this == NodeIdAny ) return "[Any]" ;
-
- return String.format("[%016X]", value) ;
+ public String toString() {
+ if ( this == NodeDoesNotExist )
+ return "[DoesNotExist]";
+ if ( this == NodeIdAny )
+ return "[Any]";
+
+ return String.format("[%016X]", value);
}
// ---- Encoding special - inlines.
@@ -154,23 +147,18 @@ public class NodeId
public static final int SPECIAL = 0xFF ;
/** Encode a node as an inline literal. Return null if it can't be done */
- public static NodeId inline(Node node)
- {
- if ( node == null )
- {
- Log.warn(NodeId.class, "Null node: "+node) ;
- return null ;
+ public static NodeId inline(Node node) {
+ if ( node == null ) {
+ Log.warn(NodeId.class, "Null node: " + node);
+ return null;
}
-
- if ( ! enableInlineLiterals )
- return null ;
- if ( ! node.isLiteral() )
- return null ;
-
+ if ( !enableInlineLiterals )
+ return null;
+ if ( !node.isLiteral() )
+ return null;
if ( NodeUtils.isSimpleString(node) || NodeUtils.isLangString(node) )
- return null ;
-
+ return null;
try { return inline$(node) ; }
catch (Throwable th) {
Log.warn(NodeId.class, "Failed to process "+node) ;
@@ -209,13 +197,11 @@ public class NodeId
return false ;
}
- private static NodeId inline$(Node node)
- {
- LiteralLabel lit = node.getLiteral() ;
+ private static NodeId inline$(Node node) {
+ LiteralLabel lit = node.getLiteral();
// Decimal is a valid supertype of integer but we handle integers and decimals differently.
- if ( node.getLiteralDatatype().equals(XSDDatatype.XSDdecimal) )
- {
+ if ( node.getLiteralDatatype().equals(XSDDatatype.XSDdecimal) ) {
// Check lexical form.
if ( ! XSDDatatype.XSDdecimal.isValidLiteral(lit) )
return null ;
@@ -233,11 +219,9 @@ public class NodeId
return new NodeId(dn.pack()) ;
else
return null ;
- }
- else // Not decimal.
- {
- if ( XSDDatatype.XSDinteger.isValidLiteral(lit) )
- {
+ } else {
+ // Not decimal.
+ if ( XSDDatatype.XSDinteger.isValidLiteral(lit) ) {
// Check length of lexical form to see if it's in range of a long.
// Long.MAX_VALUE = 9223372036854775807
// Long.MIN_VALUE = -9223372036854775808
@@ -260,50 +244,46 @@ public class NodeId
}
}
- if ( XSDDatatype.XSDdateTime.isValidLiteral(lit) )
- {
- // Could use the Jena/XSDDateTime object here rather than reparse the lexical form.
- // But this works and it's close to a release ...
- long v = DateTimeNode.packDateTime(lit.getLexicalForm()) ;
+ if ( XSDDatatype.XSDdateTime.isValidLiteral(lit) ) {
+ // Could use the Jena/XSDDateTime object here rather than reparse the lexical
+ // form.
+ // But this works and it's close to a release ...
+ long v = DateTimeNode.packDateTime(lit.getLexicalForm());
if ( v == -1 )
- return null ;
- v = setType(v, DATETIME) ;
- return new NodeId(v) ;
+ return null;
+ v = setType(v, DATETIME);
+ return new NodeId(v);
}
-
- if ( XSDDatatype.XSDdate.isValidLiteral(lit) )
- {
- long v = DateTimeNode.packDate(lit.getLexicalForm()) ;
+
+ if ( XSDDatatype.XSDdate.isValidLiteral(lit) ) {
+ long v = DateTimeNode.packDate(lit.getLexicalForm());
if ( v == -1 )
- return null ;
- v = setType(v, DATE) ;
- return new NodeId(v) ;
+ return null;
+ v = setType(v, DATE);
+ return new NodeId(v);
}
-
- if ( XSDDatatype.XSDboolean.isValidLiteral(lit) )
- {
- long v = 0 ;
- boolean b = (Boolean) lit.getValue();
- //return new NodeValueBoolean(b, node) ;
- v = setType(v, BOOLEAN) ;
+
+ if ( XSDDatatype.XSDboolean.isValidLiteral(lit) ) {
+ long v = 0;
+ boolean b = (Boolean)lit.getValue();
+ // return new NodeValueBoolean(b, node) ;
+ v = setType(v, BOOLEAN);
if ( b )
- v = v | 0x01 ;
- return new NodeId(v) ;
+ v = v | 0x01;
+ return new NodeId(v);
}
return null ;
}
- public static boolean isInline(NodeId nodeId)
- {
+ public static boolean isInline(NodeId nodeId) {
if ( nodeId == NodeId.NodeDoesNotExist )
- return false ;
-
- long v = nodeId.value ;
- int type = nodeId.type() ;
-
- switch (type)
- {
+ return false;
+
+ long v = nodeId.value;
+ int type = nodeId.type();
+
+ switch (type) {
case NONE: return false ;
case SPECIAL: return false ;
@@ -319,8 +299,7 @@ public class NodeId
}
/** Decode an inline nodeID, return null if not an inline node */
- public static Node extract(NodeId nodeId)
- {
+ public static Node extract(NodeId nodeId) {
if ( nodeId == NodeId.NodeDoesNotExist )
return null ;
@@ -366,8 +345,7 @@ public class NodeId
public final boolean isConcrete() { return !isAny(this) && !isDoesNotExist(this) ; }
- public static final boolean isConcrete(NodeId nodeId)
- {
+ public static final boolean isConcrete(NodeId nodeId) {
if ( nodeId == null ) return false ;
if ( nodeId == NodeIdAny ) return false ;
if ( nodeId == NodeDoesNotExist ) return false ;