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 2011/09/22 16:12:43 UTC
svn commit: r1174152 - in /incubator/jena/Scratch/AFS/trunk:
src-dev/dev/Table.java src-dev/dev/TableArray.java src-test/riot/
Author: andy
Date: Thu Sep 22 14:12:43 2011
New Revision: 1174152
URL: http://svn.apache.org/viewvc?rev=1174152&view=rev
Log: (empty)
Added:
incubator/jena/Scratch/AFS/trunk/src-dev/dev/Table.java (with props)
incubator/jena/Scratch/AFS/trunk/src-dev/dev/TableArray.java (with props)
Removed:
incubator/jena/Scratch/AFS/trunk/src-test/riot/
Added: incubator/jena/Scratch/AFS/trunk/src-dev/dev/Table.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/trunk/src-dev/dev/Table.java?rev=1174152&view=auto
==============================================================================
--- incubator/jena/Scratch/AFS/trunk/src-dev/dev/Table.java (added)
+++ incubator/jena/Scratch/AFS/trunk/src-dev/dev/Table.java Thu Sep 22 14:12:43 2011
@@ -0,0 +1,44 @@
+/**
+ * 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 dev;
+
+import java.util.Iterator ;
+import java.util.List ;
+
+import com.hp.hpl.jena.sparql.core.Var ;
+import com.hp.hpl.jena.sparql.engine.binding.Binding ;
+
+/** A SPARQL table : each row is a set of variable-value pairs.
+ * A table is ragged - not every row has a binding for every column.
+ */
+public interface Table
+{
+ /** The columns on the table.
+ * Any given row will only bindings for a variable in the columns list but
+ * a particular row may not have a binding for a particular variable.
+ */
+
+ public List<Var> columns() ;
+
+ /**
+ * The rows of the table as an iterator.
+ */
+ public Iterator<Binding> rows() ;
+}
+
Propchange: incubator/jena/Scratch/AFS/trunk/src-dev/dev/Table.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/jena/Scratch/AFS/trunk/src-dev/dev/TableArray.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/trunk/src-dev/dev/TableArray.java?rev=1174152&view=auto
==============================================================================
--- incubator/jena/Scratch/AFS/trunk/src-dev/dev/TableArray.java (added)
+++ incubator/jena/Scratch/AFS/trunk/src-dev/dev/TableArray.java Thu Sep 22 14:12:43 2011
@@ -0,0 +1,99 @@
+/**
+ * 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 dev;
+
+import java.util.ArrayList ;
+import java.util.Collections ;
+import java.util.Iterator ;
+import java.util.List ;
+
+import com.hp.hpl.jena.sparql.core.Var ;
+import com.hp.hpl.jena.sparql.engine.binding.Binding ;
+
+/** Implementation of a Table using an array. */
+
+public class TableArray implements Table
+{
+ private List<Binding> rows = new ArrayList<Binding>() ;
+ private List<Var> columns = new ArrayList<Var>() ;
+
+ public TableArray() {}
+
+ public void add(Binding binding)
+ {
+ Iterator<Var> vars = binding.vars() ;
+
+ for ( ; vars.hasNext() ; )
+ {
+ Var v = vars.next() ;
+ accVar(v) ;
+ rows.add(binding) ;
+ }
+ }
+
+ public void add(Iterator<Binding> bindings)
+ {
+ for ( ; bindings.hasNext() ; )
+ add(bindings.next()) ;
+ }
+
+ public void add(Table other)
+ {
+ if ( other instanceof TableArray )
+ {
+ add((TableArray)other) ;
+ return ;
+ }
+ // General
+ for ( Var v : other.columns() )
+ accVar(v) ;
+ add(other.rows()) ;
+ }
+
+ public void add(TableArray other)
+ {
+ for ( Var v : other.columns() )
+ accVar(v) ;
+ rows.addAll(other.rows) ;
+ }
+
+
+ public void var(Var var)
+ {}
+
+ private void accVar(Var var)
+ {
+ if ( ! columns.contains(var) )
+ columns.add(var) ;
+ }
+
+ @Override
+ public List<Var> columns()
+ {
+ return Collections.unmodifiableList(columns) ;
+ }
+
+ @Override
+ public Iterator<Binding> rows()
+ {
+ return rows.iterator() ;
+ }
+
+}
+
Propchange: incubator/jena/Scratch/AFS/trunk/src-dev/dev/TableArray.java
------------------------------------------------------------------------------
svn:mime-type = text/plain