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/11/07 14:36:34 UTC

svn commit: r1198733 [12/13] - in /incubator/jena/Scratch/AFS/Dev/trunk: src-archive/riot/comms/ src-archive/riot/comms/client/ src-archive/riot/comms/server0/ src-archive/riot/comms/server1/nio/ src-archive/riot/comms/server1/socket/ src-archive/riot/...

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/riot/io/TokenOutputStreamWriter.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/riot/io/TokenOutputStreamWriter.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/riot/io/TokenOutputStreamWriter.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/riot/io/TokenOutputStreamWriter.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,305 +16,305 @@
  * limitations under the License.
  */
 
-package riot.io;
-
-import java.io.IOException ;
-import java.util.ArrayList ;
-import java.util.List ;
-
-import org.openjena.atlas.io.BufferingWriter ;
-import org.openjena.riot.RiotException ;
-import org.openjena.riot.system.PrefixMap ;
-import org.openjena.riot.tokens.Token ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-import riot.comms.CommsException ;
-import riot.comms.TokenComms ;
-
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.sparql.util.FmtUtils ;
-import com.hp.hpl.jena.tdb.lib.NodeFmtLib ;
-
-public class TokenOutputStreamWriter implements TokenOutputStream
-{
-    // Both token output stream and tuple abbreviation rules.
-    // Separate out abbreviation/LastTuple support?
-    
-    // Will need rework to improve performance.
-    // XXX TokenWriter. See tokenToString
-    
-    private static Logger log = LoggerFactory.getLogger(TokenOutputStreamWriter.class) ;
-    
-    // Whether to space out the tuples a bit for readability.
-    private static final boolean GAPS = true ;
-    
-    private final BufferingWriter out ;
-    private List<Object> lastTuple = null ;
-    private boolean inTuple = false ;
-    private boolean inSection = false ;
-    private List<Object> thisTuple = new ArrayList<Object> () ;
-    
-    private PrefixMap pmap = new PrefixMap() ;
-
-    private String label ;
-    
-    public TokenOutputStreamWriter(String label, BufferingWriter out)
-    {
-        this.out = out ;
-        this.label = label ;
-    }
-    
-    @Override
-    public BufferingWriter getWriter()
-    {
-        return out ;
-    }
-
-    // Really want to directly insert in to the output byte buffer.
-    // Optimization for later - get somethign working for now
-    // (and it may well be fast enough anyway).
-    
-    public void setPrefixMapping(String prefix, String uri)
-    {
-        String pf = prefix ;
-        if ( pf.endsWith(":") )
-            pf = pf.substring(0, pf.length()-1) ;
-        else
-            prefix = prefix + ":" ;
-        pmap.add(pf, uri) ;
-        startTuple() ;
-        lastTuple = null ;
-        accumulate("@prefix") ;
-        gap(true) ;
-        accumulate(prefix) ;
-        gap(true) ;
-        accumulate("<") ;
-        accumulate(uri) ;
-        accumulate(">") ;
-        gap(false) ;
-        endTuple() ;
-    }
-    
-    @Override
-    public void sendToken(Token token)
-    {
-        remember(token) ;
-        String string = tokenToString(token) ;
-        accumulate(string) ;
-        gap(true) ;
-    }
-    
-    @Override
-    public void sendNode(Node node)
-    {
-        remember(node) ;
-        String x = NodeFmtLib.serialize(node, null, pmap) ;
-        accumulate(x) ;
-        gap(false) ;
-    }
-
-    @Override
-    public void sendString(String string)
-    {
-        remember(string) ;
-        accumulate("\"") ;
-        accumulate(string) ; // escapes 
-        accumulate("\"") ;
-        gap(false) ;
-    }
-    
-    @Override
-    public void sendWord(String string)
-    {
-        remember(string) ;
-        accumulate(string) ; // no escapes 
-        gap(true) ;
-    }
-    
-    @Override
-    public void sendControl(char controlChar)
-    {
-        String x = TokenComms.cntrlAsString(controlChar) ;
-        remember(x) ;
-        accumulate(x) ; 
-        gap(false) ;
-    }
-
-    @Override
-    public void sendNumber(long number)
-    {
-        remember(number) ;
-        accumulate(Long.toString(number)) ;
-        gap(true) ;
-    }
-    
-    @Override
-    public void startTuple()
-    {
-        // Ensure endTuple.
-        if ( log.isDebugEnabled() ) log.debug("Start tuple") ;
-    }
-
-    @Override
-    public void endTuple()
-    {
-        if ( ! inTuple ) return ;
-        accumulate(".") ;
-        accumulate("\n") ;
-        if ( log.isDebugEnabled() )
-        {
-            log.debug("End tuple") ;
-            if ( label != null )
-                log.debug(">> "+label+": "+thisTuple) ;
-            else
-                log.debug(">> "+thisTuple.toString()) ;
-        }
-        
-        // Compression.
-        lastTuple = thisTuple ;
-        thisTuple = new ArrayList<Object>(lastTuple.size()) ;
-        inTuple = false ; 
-    }
-    
-    @Override
-    public void startSection()
-    {
-        if ( log.isDebugEnabled() )
-            log.debug("Start section") ;
-        if ( inSection )
-            log.warn("Already in a section") ;
-        inSection = true ;
-    }
-
-    @Override
-    public void endSection()
-    {
-        if ( log.isDebugEnabled() )
-            log.debug("End section") ;
-        if ( ! inSection )
-            log.warn("Not in a section") ;
-        startTuple() ;
-        sendControl(TokenComms.endSectionMarker) ;
-        endTuple() ;
-        inSection = false ;
-    }
-
-    @Override
-    public void close()
-    {
-        startTuple() ;
-        sendControl(TokenComms.endSectionMarker) ;
-        endTuple() ;
-        out.close();
-    }
-    
-    @Override
-    public void sync()
-    { flush() ; }
-    
-    @Override
-    public void flush() { 
-        //System.out.println("Send: flush") ;
-        out.flush(); 
-    }
-    
-    // --------
-    
-    private String tokenToString(Token token)
-    {
-        switch ( token.getType() )
-        {
-            // superclass case NODE:
-            case IRI:
-                return "<"+token.getImage()+">" ;
-            case PREFIXED_NAME: 
-                notImplemented(token) ;
-                return null ;
-            case BNODE:
-                return "_:"+token.getImage() ;
-            //BOOLEAN,
-            // One kind of string?
-            case STRING:
-            case STRING1:
-            case STRING2:
-            case LONG_STRING1:
-            case LONG_STRING2:
-                // XXX
-                //return "'"+NodeFmtLib.esc(token.getImage())+"'" ;
-                return "\""+FmtUtils.stringEsc(token.getImage())+"\"" ;
-            case LITERAL_LANG:
-                return "\""+FmtUtils.stringEsc(token.getImage())+"\"@"+token.getImage2() ;
-            case LITERAL_DT:
-                return "\""+FmtUtils.stringEsc(token.getImage())+"\"^^"+tokenToString(token.getSubToken()) ;
-            case INTEGER:
-            case DECIMAL:
-            case DOUBLE:
-                return token.getImage() ;
-                
-            // Not RDF
-            case KEYWORD:
-                return token.getImage() ;
+package riot.io;
+
+import java.io.IOException ;
+import java.util.ArrayList ;
+import java.util.List ;
+
+import org.openjena.atlas.io.BufferingWriter ;
+import org.openjena.riot.RiotException ;
+import org.openjena.riot.system.PrefixMap ;
+import org.openjena.riot.tokens.Token ;
+import org.slf4j.Logger ;
+import org.slf4j.LoggerFactory ;
+import riot.comms.CommsException ;
+import riot.comms.TokenComms ;
+
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.sparql.util.FmtUtils ;
+import com.hp.hpl.jena.tdb.lib.NodeFmtLib ;
+
+public class TokenOutputStreamWriter implements TokenOutputStream
+{
+    // Both token output stream and tuple abbreviation rules.
+    // Separate out abbreviation/LastTuple support?
+    
+    // Will need rework to improve performance.
+    // XXX TokenWriter. See tokenToString
+    
+    private static Logger log = LoggerFactory.getLogger(TokenOutputStreamWriter.class) ;
+    
+    // Whether to space out the tuples a bit for readability.
+    private static final boolean GAPS = true ;
+    
+    private final BufferingWriter out ;
+    private List<Object> lastTuple = null ;
+    private boolean inTuple = false ;
+    private boolean inSection = false ;
+    private List<Object> thisTuple = new ArrayList<Object> () ;
+    
+    private PrefixMap pmap = new PrefixMap() ;
+
+    private String label ;
+    
+    public TokenOutputStreamWriter(String label, BufferingWriter out)
+    {
+        this.out = out ;
+        this.label = label ;
+    }
+    
+    @Override
+    public BufferingWriter getWriter()
+    {
+        return out ;
+    }
+
+    // Really want to directly insert in to the output byte buffer.
+    // Optimization for later - get somethign working for now
+    // (and it may well be fast enough anyway).
+    
+    public void setPrefixMapping(String prefix, String uri)
+    {
+        String pf = prefix ;
+        if ( pf.endsWith(":") )
+            pf = pf.substring(0, pf.length()-1) ;
+        else
+            prefix = prefix + ":" ;
+        pmap.add(pf, uri) ;
+        startTuple() ;
+        lastTuple = null ;
+        accumulate("@prefix") ;
+        gap(true) ;
+        accumulate(prefix) ;
+        gap(true) ;
+        accumulate("<") ;
+        accumulate(uri) ;
+        accumulate(">") ;
+        gap(false) ;
+        endTuple() ;
+    }
+    
+    @Override
+    public void sendToken(Token token)
+    {
+        remember(token) ;
+        String string = tokenToString(token) ;
+        accumulate(string) ;
+        gap(true) ;
+    }
+    
+    @Override
+    public void sendNode(Node node)
+    {
+        remember(node) ;
+        String x = NodeFmtLib.serialize(node, null, pmap) ;
+        accumulate(x) ;
+        gap(false) ;
+    }
+
+    @Override
+    public void sendString(String string)
+    {
+        remember(string) ;
+        accumulate("\"") ;
+        accumulate(string) ; // escapes 
+        accumulate("\"") ;
+        gap(false) ;
+    }
+    
+    @Override
+    public void sendWord(String string)
+    {
+        remember(string) ;
+        accumulate(string) ; // no escapes 
+        gap(true) ;
+    }
+    
+    @Override
+    public void sendControl(char controlChar)
+    {
+        String x = TokenComms.cntrlAsString(controlChar) ;
+        remember(x) ;
+        accumulate(x) ; 
+        gap(false) ;
+    }
+
+    @Override
+    public void sendNumber(long number)
+    {
+        remember(number) ;
+        accumulate(Long.toString(number)) ;
+        gap(true) ;
+    }
+    
+    @Override
+    public void startTuple()
+    {
+        // Ensure endTuple.
+        if ( log.isDebugEnabled() ) log.debug("Start tuple") ;
+    }
+
+    @Override
+    public void endTuple()
+    {
+        if ( ! inTuple ) return ;
+        accumulate(".") ;
+        accumulate("\n") ;
+        if ( log.isDebugEnabled() )
+        {
+            log.debug("End tuple") ;
+            if ( label != null )
+                log.debug(">> "+label+": "+thisTuple) ;
+            else
+                log.debug(">> "+thisTuple.toString()) ;
+        }
+        
+        // Compression.
+        lastTuple = thisTuple ;
+        thisTuple = new ArrayList<Object>(lastTuple.size()) ;
+        inTuple = false ; 
+    }
+    
+    @Override
+    public void startSection()
+    {
+        if ( log.isDebugEnabled() )
+            log.debug("Start section") ;
+        if ( inSection )
+            log.warn("Already in a section") ;
+        inSection = true ;
+    }
+
+    @Override
+    public void endSection()
+    {
+        if ( log.isDebugEnabled() )
+            log.debug("End section") ;
+        if ( ! inSection )
+            log.warn("Not in a section") ;
+        startTuple() ;
+        sendControl(TokenComms.endSectionMarker) ;
+        endTuple() ;
+        inSection = false ;
+    }
+
+    @Override
+    public void close()
+    {
+        startTuple() ;
+        sendControl(TokenComms.endSectionMarker) ;
+        endTuple() ;
+        out.close();
+    }
+    
+    @Override
+    public void sync()
+    { flush() ; }
+    
+    @Override
+    public void flush() { 
+        //System.out.println("Send: flush") ;
+        out.flush(); 
+    }
+    
+    // --------
+    
+    private String tokenToString(Token token)
+    {
+        switch ( token.getType() )
+        {
+            // superclass case NODE:
+            case IRI:
+                return "<"+token.getImage()+">" ;
+            case PREFIXED_NAME: 
+                notImplemented(token) ;
+                return null ;
+            case BNODE:
+                return "_:"+token.getImage() ;
+            //BOOLEAN,
+            // One kind of string?
+            case STRING:
+            case STRING1:
+            case STRING2:
+            case LONG_STRING1:
+            case LONG_STRING2:
+                // XXX
+                //return "'"+NodeFmtLib.esc(token.getImage())+"'" ;
+                return "\""+FmtUtils.stringEsc(token.getImage())+"\"" ;
+            case LITERAL_LANG:
+                return "\""+FmtUtils.stringEsc(token.getImage())+"\"@"+token.getImage2() ;
+            case LITERAL_DT:
+                return "\""+FmtUtils.stringEsc(token.getImage())+"\"^^"+tokenToString(token.getSubToken()) ;
+            case INTEGER:
+            case DECIMAL:
+            case DOUBLE:
+                return token.getImage() ;
+                
+            // Not RDF
+            case KEYWORD:
+                return token.getImage() ;
             case CNTRL:
                 if ( token.getCntrlCode() == -1 )
                     return "*" ; 
-                return "*"+Character.toString((char)token.getCntrlCode()) ;
-            case VAR:
-            case HEX:
-                
-            // Syntax
-            // COLON is only visible if prefix names are not being processed.
-            case DOT:
-            case COMMA:
-            case SEMICOLON:
-            case COLON: 
-            case DIRECTIVE:
-            // LT, GT, LE, GE are only visible if IRI processing is not enabled.
-            case LT:
-            case GT:
-            case LE:
-            case GE:
-            // In RDF, UNDERSCORE is only visible if BNode processing is not enabled.
-            case UNDERSCORE: 
-            case LBRACE:    case RBRACE:    // {} 
-            case LPAREN:    case RPAREN:    // ()
-            case LBRACKET:  case RBRACKET:  // []
-                
-            case PLUS:
-            case MINUS:
-            case STAR:
-            case SLASH:
+                return "*"+Character.toString((char)token.getCntrlCode()) ;
+            case VAR:
+            case HEX:
+                
+            // Syntax
+            // COLON is only visible if prefix names are not being processed.
+            case DOT:
+            case COMMA:
+            case SEMICOLON:
+            case COLON: 
+            case DIRECTIVE:
+            // LT, GT, LE, GE are only visible if IRI processing is not enabled.
+            case LT:
+            case GT:
+            case LE:
+            case GE:
+            // In RDF, UNDERSCORE is only visible if BNode processing is not enabled.
+            case UNDERSCORE: 
+            case LBRACE:    case RBRACE:    // {} 
+            case LPAREN:    case RPAREN:    // ()
+            case LBRACKET:  case RBRACKET:  // []
+                
+            case PLUS:
+            case MINUS:
+            case STAR:
+            case SLASH:
             case RSLASH:
-            default:
-                notImplemented(token) ;
-                return null ;
-            //case EOF:
-        }
-    }
-
-    private void remember(Object obj)
-    { thisTuple.add(obj) ; }
-    
-    // A gap is always necessary for items that are not endLog-limited.
-    // For example, numbers adjacent to numbers must have a gap but
-    // quoted string then quoted string does not require a gap.  
-    private void gap(boolean required)
-    {
-        if ( required || GAPS ) accumulate(" ") ;
-    }
-
-    // Beware of multiple stringing.
-    private void accumulate(String string)
-    { 
-        //System.out.println("Send: "+string) ;
-        inTuple = true ; 
-        out.output(string) ;
-    }
-    
-    private static void exception(IOException ex)
-    { throw new CommsException(ex) ; }
-
-    private void notImplemented(Token token)
-    {
-        throw new RiotException("Unencodable token: "+token) ;
-    }
+            default:
+                notImplemented(token) ;
+                return null ;
+            //case EOF:
+        }
+    }
+
+    private void remember(Object obj)
+    { thisTuple.add(obj) ; }
+    
+    // A gap is always necessary for items that are not endLog-limited.
+    // For example, numbers adjacent to numbers must have a gap but
+    // quoted string then quoted string does not require a gap.  
+    private void gap(boolean required)
+    {
+        if ( required || GAPS ) accumulate(" ") ;
+    }
+
+    // Beware of multiple stringing.
+    private void accumulate(String string)
+    { 
+        //System.out.println("Send: "+string) ;
+        inTuple = true ; 
+        out.output(string) ;
+    }
+    
+    private static void exception(IOException ex)
+    { throw new CommsException(ex) ; }
+
+    private void notImplemented(Token token)
+    {
+        throw new RiotException("Unencodable token: "+token) ;
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/riot/lang/LangSSE.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/riot/lang/LangSSE.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/riot/lang/LangSSE.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/riot/lang/LangSSE.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,223 +16,223 @@
  * limitations under the License.
  */
 
-package riot.lang;
-
-import org.openjena.atlas.lib.SinkNull ;
-import org.openjena.riot.Lang ;
-import org.openjena.riot.lang.LangBase ;
-import org.openjena.riot.system.ParserProfile ;
-import org.openjena.riot.tokens.Token ;
-import org.openjena.riot.tokens.TokenType ;
-import org.openjena.riot.tokens.Tokenizer ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-
-import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.sparql.sse.lang.ParseHandler ;
-
-/** Parse the SSE (SPARQL/Lisp) syntax */
-
-public class LangSSE extends LangBase<Object>
-{
-    // Tokenizer needs tuning to yield + - * < and > as tokens. 
-    
-    private static Logger log = LoggerFactory.getLogger(LangSSE.class) ;
-
-    private ParseHandler handler ;
-    
-    public LangSSE(Tokenizer tokens,
-                   ParserProfile profile,
-                   ParseHandler handler)
-    {
-        super(tokens, profile, new SinkNull<Object>()) ;
-        this.handler = handler ;
-    }
-    
-    @Override
-    public Lang getLang()
-    {
-        return null ;
-    }
-
-    @Override
-    protected void runParser()
-    {
-        parseOne() ;
-        if ( ! eof() )
-            exception(peekToken(), "Excess characters") ;
-    }
-    
-    private void parseList(TokenType opener, TokenType terminator)
-    { 
-        // On entry, looking at opening character.
-        Token t = nextToken() ;
-        handler.listStart((int)t.getLine(), (int)t.getColumn()) ;
-        
-        while(moreTokens())
-        {
-            // Do one
-            if ( lookingAt(terminator) )
-                break ;
-            if ( lookingAt(TokenType.RPAREN) || lookingAt(TokenType.RBRACKET) || lookingAt(TokenType.RBRACE) )
-            {
-                Token t2 = nextToken() ;
-                exception(t2, "Mismatched delimiters: %s %s ('%s')", opener, t2.getType(), t2.getImage()) ;
-            }
-            
-            parseOne() ;
-        }
-
-        if ( eof() )
-            exception(peekToken(), "EOF: Expected ')'") ;
-        Token t2 = nextToken() ;
-        
-        handler.listFinish((int)t2.getLine(), (int)t2.getColumn()) ;
-    }
-    
-    private void parseOne()
-    {
-        if ( lookingAt(TokenType.LPAREN) )
-        {
-            parseList(TokenType.LPAREN, TokenType.RPAREN) ;
-            return ;
-        }
-        
-        if ( lookingAt(TokenType.LBRACKET) )
-        {
-            parseList(TokenType.LBRACKET, TokenType.RBRACKET) ;
-            return ;
-        }
-        
-        if ( lookingAt(TokenType.LBRACE) )
-        {
-            parseList(TokenType.LBRACE, TokenType.RBRACE) ;
-            return ;
-        }
-
-        if ( lookingAt(TokenType.STRING) || 
-             lookingAt(TokenType.STRING1) || lookingAt(TokenType.STRING2) ||
-             lookingAt(TokenType.LONG_STRING1) || lookingAt(TokenType.LONG_STRING2) )
-        {
-            Token t = nextToken() ;
-            handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), 
-                                t.getImage(), null, null, null) ;
-            return ;
-        }
-
-        if ( lookingAt(TokenType.LITERAL_DT) )
-        {
-            Token t = nextToken() ;
-            Token t2 = t.getSubToken() ;
-            if ( t2.hasType(TokenType.PREFIXED_NAME) )
-            {
-                handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), t.getImage(),
-                                    null, null, t2.getImage()+":"+t2.getImage2()) ;
-                return ;
-
-            }
-            if ( t2.hasType(TokenType.IRI) )
-            {
-                handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), t.getImage(),
-                                    null, t2.getImage(), null) ;
-                return ;
-            }
-            else
-               exception(t, "Unexpected token after '^^': %s", t) ; 
-        }
-        
-        if ( lookingAt(TokenType.LITERAL_LANG) )
-        {
-            Token t = nextToken() ;
-            handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), 
-                                t.getImage(), t.getImage2(), null, null) ;
-            return ;
-        }
-        
-        if ( lookingAt(TokenType.IRI) )
-        {
-            Token t = nextToken() ;
-            handler.emitIRI((int)t.getLine(), (int)t.getColumn(), t.getImage()) ;
-            return ;
-        }
-
-        if ( lookingAt(TokenType.BNODE) )
-        {
-            Token t = nextToken() ;
-            handler.emitBNode((int)t.getLine(), (int)t.getColumn(), t.getImage()) ;
-            return ;
-        }
-        
-        if ( lookingAt(TokenType.KEYWORD) )
-        {
-            Token t = nextToken() ;
-            handler.emitSymbol((int)t.getLine(), (int)t.getColumn(), t.getImage()) ;
-            return ;
-        }
-        
-        if ( lookingAt(TokenType.PLUS) )
-        {
-            Token t = nextToken() ;
-            handler.emitSymbol((int)t.getLine(), (int)t.getColumn(), "+") ;
-            return ;
-        }
-
-        if ( lookingAt(TokenType.MINUS) )
-        {
-            Token t = nextToken() ;
-            handler.emitSymbol((int)t.getLine(), (int)t.getColumn(), "-") ;
-            return ;
-        }
-
-        if ( lookingAt(TokenType.PREFIXED_NAME) )
-        {
-            Token t = nextToken() ;
-            // FIXME - use tokenAsNode through out
-            String x = t.getImage()+":"+t.getImage2() ;
-            handler.emitPName((int)t.getLine(), (int)t.getColumn(), x) ;
-            return ;
-        }
-        
-        if ( lookingAt(TokenType.VAR) )
-        {
-            Token t = nextToken() ;
-            handler.emitVar((int)t.getLine(), (int)t.getColumn(), t.getImage()) ;
-            return ;
-        }
-        
-        if ( lookingAt(TokenType.INTEGER) )
-        {
-            Token t = nextToken() ;
-            handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), 
-                                t.getImage(), null, XSDDatatype.XSDinteger.getURI(), null) ;
-            return ;
-        }
-
-        if ( lookingAt(TokenType.DECIMAL) )
-        {
-            Token t = nextToken() ;
-            handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), 
-                                t.getImage(), null, XSDDatatype.XSDdecimal.getURI(), null) ;
-            return ;
-        }
-
-        if ( lookingAt(TokenType.DOUBLE) )
-        {
-            Token t = nextToken() ;
-            handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), 
-                                t.getImage(), null, XSDDatatype.XSDdouble.getURI(), null) ;
-            return ;
-        }
-        
-        Token token  = nextToken() ;
-        
-        exception(token, "Unexpected: %s", token) ;
-    }
-
-    //@Override
-    protected Node tokenAsNode(Token token)
-    {
-        return profile.create(null, token) ;
-    }
+package riot.lang;
+
+import org.openjena.atlas.lib.SinkNull ;
+import org.openjena.riot.Lang ;
+import org.openjena.riot.lang.LangBase ;
+import org.openjena.riot.system.ParserProfile ;
+import org.openjena.riot.tokens.Token ;
+import org.openjena.riot.tokens.TokenType ;
+import org.openjena.riot.tokens.Tokenizer ;
+import org.slf4j.Logger ;
+import org.slf4j.LoggerFactory ;
+
+import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.sparql.sse.lang.ParseHandler ;
+
+/** Parse the SSE (SPARQL/Lisp) syntax */
+
+public class LangSSE extends LangBase<Object>
+{
+    // Tokenizer needs tuning to yield + - * < and > as tokens. 
+    
+    private static Logger log = LoggerFactory.getLogger(LangSSE.class) ;
+
+    private ParseHandler handler ;
+    
+    public LangSSE(Tokenizer tokens,
+                   ParserProfile profile,
+                   ParseHandler handler)
+    {
+        super(tokens, profile, new SinkNull<Object>()) ;
+        this.handler = handler ;
+    }
+    
+    @Override
+    public Lang getLang()
+    {
+        return null ;
+    }
+
+    @Override
+    protected void runParser()
+    {
+        parseOne() ;
+        if ( ! eof() )
+            exception(peekToken(), "Excess characters") ;
+    }
+    
+    private void parseList(TokenType opener, TokenType terminator)
+    { 
+        // On entry, looking at opening character.
+        Token t = nextToken() ;
+        handler.listStart((int)t.getLine(), (int)t.getColumn()) ;
+        
+        while(moreTokens())
+        {
+            // Do one
+            if ( lookingAt(terminator) )
+                break ;
+            if ( lookingAt(TokenType.RPAREN) || lookingAt(TokenType.RBRACKET) || lookingAt(TokenType.RBRACE) )
+            {
+                Token t2 = nextToken() ;
+                exception(t2, "Mismatched delimiters: %s %s ('%s')", opener, t2.getType(), t2.getImage()) ;
+            }
+            
+            parseOne() ;
+        }
+
+        if ( eof() )
+            exception(peekToken(), "EOF: Expected ')'") ;
+        Token t2 = nextToken() ;
+        
+        handler.listFinish((int)t2.getLine(), (int)t2.getColumn()) ;
+    }
+    
+    private void parseOne()
+    {
+        if ( lookingAt(TokenType.LPAREN) )
+        {
+            parseList(TokenType.LPAREN, TokenType.RPAREN) ;
+            return ;
+        }
+        
+        if ( lookingAt(TokenType.LBRACKET) )
+        {
+            parseList(TokenType.LBRACKET, TokenType.RBRACKET) ;
+            return ;
+        }
+        
+        if ( lookingAt(TokenType.LBRACE) )
+        {
+            parseList(TokenType.LBRACE, TokenType.RBRACE) ;
+            return ;
+        }
+
+        if ( lookingAt(TokenType.STRING) || 
+             lookingAt(TokenType.STRING1) || lookingAt(TokenType.STRING2) ||
+             lookingAt(TokenType.LONG_STRING1) || lookingAt(TokenType.LONG_STRING2) )
+        {
+            Token t = nextToken() ;
+            handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), 
+                                t.getImage(), null, null, null) ;
+            return ;
+        }
+
+        if ( lookingAt(TokenType.LITERAL_DT) )
+        {
+            Token t = nextToken() ;
+            Token t2 = t.getSubToken() ;
+            if ( t2.hasType(TokenType.PREFIXED_NAME) )
+            {
+                handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), t.getImage(),
+                                    null, null, t2.getImage()+":"+t2.getImage2()) ;
+                return ;
+
+            }
+            if ( t2.hasType(TokenType.IRI) )
+            {
+                handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), t.getImage(),
+                                    null, t2.getImage(), null) ;
+                return ;
+            }
+            else
+               exception(t, "Unexpected token after '^^': %s", t) ; 
+        }
+        
+        if ( lookingAt(TokenType.LITERAL_LANG) )
+        {
+            Token t = nextToken() ;
+            handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), 
+                                t.getImage(), t.getImage2(), null, null) ;
+            return ;
+        }
+        
+        if ( lookingAt(TokenType.IRI) )
+        {
+            Token t = nextToken() ;
+            handler.emitIRI((int)t.getLine(), (int)t.getColumn(), t.getImage()) ;
+            return ;
+        }
+
+        if ( lookingAt(TokenType.BNODE) )
+        {
+            Token t = nextToken() ;
+            handler.emitBNode((int)t.getLine(), (int)t.getColumn(), t.getImage()) ;
+            return ;
+        }
+        
+        if ( lookingAt(TokenType.KEYWORD) )
+        {
+            Token t = nextToken() ;
+            handler.emitSymbol((int)t.getLine(), (int)t.getColumn(), t.getImage()) ;
+            return ;
+        }
+        
+        if ( lookingAt(TokenType.PLUS) )
+        {
+            Token t = nextToken() ;
+            handler.emitSymbol((int)t.getLine(), (int)t.getColumn(), "+") ;
+            return ;
+        }
+
+        if ( lookingAt(TokenType.MINUS) )
+        {
+            Token t = nextToken() ;
+            handler.emitSymbol((int)t.getLine(), (int)t.getColumn(), "-") ;
+            return ;
+        }
+
+        if ( lookingAt(TokenType.PREFIXED_NAME) )
+        {
+            Token t = nextToken() ;
+            // FIXME - use tokenAsNode through out
+            String x = t.getImage()+":"+t.getImage2() ;
+            handler.emitPName((int)t.getLine(), (int)t.getColumn(), x) ;
+            return ;
+        }
+        
+        if ( lookingAt(TokenType.VAR) )
+        {
+            Token t = nextToken() ;
+            handler.emitVar((int)t.getLine(), (int)t.getColumn(), t.getImage()) ;
+            return ;
+        }
+        
+        if ( lookingAt(TokenType.INTEGER) )
+        {
+            Token t = nextToken() ;
+            handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), 
+                                t.getImage(), null, XSDDatatype.XSDinteger.getURI(), null) ;
+            return ;
+        }
+
+        if ( lookingAt(TokenType.DECIMAL) )
+        {
+            Token t = nextToken() ;
+            handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), 
+                                t.getImage(), null, XSDDatatype.XSDdecimal.getURI(), null) ;
+            return ;
+        }
+
+        if ( lookingAt(TokenType.DOUBLE) )
+        {
+            Token t = nextToken() ;
+            handler.emitLiteral((int)t.getLine(), (int)t.getColumn(), 
+                                t.getImage(), null, XSDDatatype.XSDdouble.getURI(), null) ;
+            return ;
+        }
+        
+        Token token  = nextToken() ;
+        
+        exception(token, "Unexpected: %s", token) ;
+    }
+
+    //@Override
+    protected Node tokenAsNode(Token token)
+    {
+        return profile.create(null, token) ;
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/BaseSearchPF.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/BaseSearchPF.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/BaseSearchPF.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/BaseSearchPF.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,61 +16,61 @@
  * limitations under the License.
  */
 
-package search;
-
-import java.util.Iterator ;
-
-import org.openjena.atlas.iterator.Iter ;
-import org.openjena.atlas.iterator.Transform ;
-
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.query.QueryExecException ;
-import com.hp.hpl.jena.sparql.core.Var ;
-import com.hp.hpl.jena.sparql.engine.ExecutionContext ;
-import com.hp.hpl.jena.sparql.engine.QueryIterator ;
-import com.hp.hpl.jena.sparql.engine.binding.Binding ;
-import com.hp.hpl.jena.sparql.engine.binding.BindingFactory ;
-import com.hp.hpl.jena.sparql.engine.iterator.QueryIterPlainWrapper ;
-import com.hp.hpl.jena.sparql.pfunction.PropFuncArg ;
-import com.hp.hpl.jena.sparql.pfunction.PropFuncArgType ;
-import com.hp.hpl.jena.sparql.pfunction.PropertyFunctionEval ;
-
-public abstract class BaseSearchPF extends PropertyFunctionEval
-{
-    public BaseSearchPF()
-    {
-        super(PropFuncArgType.PF_ARG_SINGLE, PropFuncArgType.PF_ARG_SINGLE) ;
-    }
-
-    protected abstract Search searchEngine() ;
-    
-    @Override
-    public QueryIterator execEvaluated(final Binding binding, PropFuncArg argSubject, Node predicate, PropFuncArg argObject,
-                                       ExecutionContext execCxt)
-    {
-        // check subject is a variable.
-        if ( ! argSubject.getArg().isVariable() )
-            throw new QueryExecException("Subject not a variable") ;
-        
-        final Var var = Var.alloc(argSubject.getArg()) ;
-        
-        if ( ! argObject.getArg().isLiteral() )
-            throw new QueryExecException("Subject not a literal") ;
-
-        String searchTerm = argObject.getArg().getLiteralLexicalForm() ;
-        Search search = searchEngine() ;
-        Iterator<String> x = search.search(searchTerm) ;
-        Iter<String> iter = Iter.iter(x) ;
-        
-        Transform<String , Binding> converter = new Transform<String , Binding>(){
-
-            @Override
-            public Binding convert(String item)
-            {
-                return BindingFactory.binding(binding, var, Node.createURI(item)) ;
-            }} ;
-        QueryIterator qIter = new QueryIterPlainWrapper(iter.map(converter)) ;
-        return qIter ;
-    }
-
+package search;
+
+import java.util.Iterator ;
+
+import org.openjena.atlas.iterator.Iter ;
+import org.openjena.atlas.iterator.Transform ;
+
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.query.QueryExecException ;
+import com.hp.hpl.jena.sparql.core.Var ;
+import com.hp.hpl.jena.sparql.engine.ExecutionContext ;
+import com.hp.hpl.jena.sparql.engine.QueryIterator ;
+import com.hp.hpl.jena.sparql.engine.binding.Binding ;
+import com.hp.hpl.jena.sparql.engine.binding.BindingFactory ;
+import com.hp.hpl.jena.sparql.engine.iterator.QueryIterPlainWrapper ;
+import com.hp.hpl.jena.sparql.pfunction.PropFuncArg ;
+import com.hp.hpl.jena.sparql.pfunction.PropFuncArgType ;
+import com.hp.hpl.jena.sparql.pfunction.PropertyFunctionEval ;
+
+public abstract class BaseSearchPF extends PropertyFunctionEval
+{
+    public BaseSearchPF()
+    {
+        super(PropFuncArgType.PF_ARG_SINGLE, PropFuncArgType.PF_ARG_SINGLE) ;
+    }
+
+    protected abstract Search searchEngine() ;
+    
+    @Override
+    public QueryIterator execEvaluated(final Binding binding, PropFuncArg argSubject, Node predicate, PropFuncArg argObject,
+                                       ExecutionContext execCxt)
+    {
+        // check subject is a variable.
+        if ( ! argSubject.getArg().isVariable() )
+            throw new QueryExecException("Subject not a variable") ;
+        
+        final Var var = Var.alloc(argSubject.getArg()) ;
+        
+        if ( ! argObject.getArg().isLiteral() )
+            throw new QueryExecException("Subject not a literal") ;
+
+        String searchTerm = argObject.getArg().getLiteralLexicalForm() ;
+        Search search = searchEngine() ;
+        Iterator<String> x = search.search(searchTerm) ;
+        Iter<String> iter = Iter.iter(x) ;
+        
+        Transform<String , Binding> converter = new Transform<String , Binding>(){
+
+            @Override
+            public Binding convert(String item)
+            {
+                return BindingFactory.binding(binding, var, Node.createURI(item)) ;
+            }} ;
+        QueryIterator qIter = new QueryIterPlainWrapper(iter.map(converter)) ;
+        return qIter ;
+    }
+
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/DevSearch.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/DevSearch.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/DevSearch.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/DevSearch.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,68 +16,68 @@
  * limitations under the License.
  */
 
-package search;
-
-import java.util.Iterator;
-
-import com.hp.hpl.jena.util.FileUtils;
-
-
-public class DevSearch
-{
-    public static void search()
-    {
-        //socksProxyHost=socks-server
-        // This happens to work on the public net as well because the socks-server DNS does not exist. 
-        if ( System.getProperty("socksProxyHost") == null &&
-             System.getProperty("http.socksProxyHost") == null &&
-             System.getProperty("httpProxyHost") == null && 
-             System.getProperty("http.httpProxyHost") == null )
-        {
-            System.setProperty("socksProxyHost", "socks-server") ;
-        }
-        
-        String term = "sodium citrate" ;
-
-        String[] a1 = { "--data=D.ttl", "PREFIX s: <java:search.> SELECT * { ?url s:WikipediaPF '"+term+"'}" } ;  
-        String[] a2 = { "--data=D.ttl", "PREFIX s: <java:search.> SELECT * { ?url s:GooglePF '"+term+"'}" } ;
-        System.out.println("Wikpedia") ;
-        arq.sparql.main(a1) ;
-        System.out.println("Google") ;
-        arq.sparql.main(a2) ;
-        System.exit(0) ;
-    }
-
-    // Call directly for debugging
-    public static void search(String ... words)
-    {
-        SearchGoogle s = new SearchGoogle() ;
-        Iterator<String> links = s.search(words) ;
-        while ( links.hasNext() )
-        {
-            String x = links.next();
-            System.out.println("Link: "+x) ;
-        }
-        System.out.println("--") ;
-    }
-    
-    public static void scrapePage()
-    {
-        try {
-            String x = FileUtils.readWholeFileAsUTF8("sodium search.htm") ;
-            Iterator<String> iter = SearchWikipedia.parse(x) ;
-
-            for ( ; iter.hasNext(); )
-            {
-                String z = iter.next() ;
-                System.out.println(z) ;
-            }
-
-            System.out.println("------------") ;
-        } catch (Exception ex)
-        {
-            ex.printStackTrace() ;
-        }
-        System.exit(0) ;
-    }
+package search;
+
+import java.util.Iterator;
+
+import com.hp.hpl.jena.util.FileUtils;
+
+
+public class DevSearch
+{
+    public static void search()
+    {
+        //socksProxyHost=socks-server
+        // This happens to work on the public net as well because the socks-server DNS does not exist. 
+        if ( System.getProperty("socksProxyHost") == null &&
+             System.getProperty("http.socksProxyHost") == null &&
+             System.getProperty("httpProxyHost") == null && 
+             System.getProperty("http.httpProxyHost") == null )
+        {
+            System.setProperty("socksProxyHost", "socks-server") ;
+        }
+        
+        String term = "sodium citrate" ;
+
+        String[] a1 = { "--data=D.ttl", "PREFIX s: <java:search.> SELECT * { ?url s:WikipediaPF '"+term+"'}" } ;  
+        String[] a2 = { "--data=D.ttl", "PREFIX s: <java:search.> SELECT * { ?url s:GooglePF '"+term+"'}" } ;
+        System.out.println("Wikpedia") ;
+        arq.sparql.main(a1) ;
+        System.out.println("Google") ;
+        arq.sparql.main(a2) ;
+        System.exit(0) ;
+    }
+
+    // Call directly for debugging
+    public static void search(String ... words)
+    {
+        SearchGoogle s = new SearchGoogle() ;
+        Iterator<String> links = s.search(words) ;
+        while ( links.hasNext() )
+        {
+            String x = links.next();
+            System.out.println("Link: "+x) ;
+        }
+        System.out.println("--") ;
+    }
+    
+    public static void scrapePage()
+    {
+        try {
+            String x = FileUtils.readWholeFileAsUTF8("sodium search.htm") ;
+            Iterator<String> iter = SearchWikipedia.parse(x) ;
+
+            for ( ; iter.hasNext(); )
+            {
+                String z = iter.next() ;
+                System.out.println(z) ;
+            }
+
+            System.out.println("------------") ;
+        } catch (Exception ex)
+        {
+            ex.printStackTrace() ;
+        }
+        System.exit(0) ;
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/GooglePF.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/GooglePF.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/GooglePF.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/GooglePF.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,15 +16,15 @@
  * limitations under the License.
  */
 
-package search;
-
-public class GooglePF extends BaseSearchPF
-{
-    private Search search = new SearchGoogle() ;
-    
-    @Override
-    protected Search searchEngine()
-    {
-        return search ;
-    }
+package search;
+
+public class GooglePF extends BaseSearchPF
+{
+    private Search search = new SearchGoogle() ;
+    
+    @Override
+    protected Search searchEngine()
+    {
+        return search ;
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/Search.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/Search.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/Search.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/Search.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,12 +16,12 @@
  * limitations under the License.
  */
 
-package search;
-
-import java.util.Iterator;
-
-public interface Search
-{
-    public Iterator<String> search(String... words) ;
-    //public Iterator<String> search(String str)
+package search;
+
+import java.util.Iterator;
+
+public interface Search
+{
+    public Iterator<String> search(String... words) ;
+    //public Iterator<String> search(String str)
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchBase.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchBase.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchBase.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchBase.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,94 +16,94 @@
  * limitations under the License.
  */
 
-package search;
-
-import java.io.IOException ;
-import java.io.InputStream ;
-import java.io.InputStreamReader ;
-import java.io.Reader ;
-import java.net.HttpURLConnection ;
-import java.util.Iterator ;
-
-import org.openjena.atlas.iterator.NullIterator ;
-import org.openjena.atlas.lib.StrUtils ;
-
-import com.hp.hpl.jena.sparql.util.Convert ;
-
-public abstract class SearchBase implements Search 
-{
-    @Override
-    public final Iterator<String> search(String... words)
-    {
-        String str = StrUtils.strjoin(" ", words) ;
-        str = Convert.encWWWForm(str) ;
-        InputStream in = execGet(str) ;
-        if ( in == null )
-            return new NullIterator<String>() ;
-        
-        return parse(in) ;
-    }
-    
-    protected abstract InputStream execGet(String searchString) ;
-    protected abstract Iterator<String> parse(InputStream in) ;
-    
-    // Put somewhere!
-    public static String readAll(InputStream in, String charset)
-    {
-        try {
-            Reader r = new InputStreamReader(in, charset) ;//FileUtils.asUTF8(in) ;
-            StringBuilder sw = new StringBuilder(64*1024);
-            char buff[] = new char[8*1024];
-            while (true)
-            {
-                int len = r.read(buff);
-                if (len < 0)
-                    break;
-                sw.append(buff, 0, len);
-            }
-            r.close();
-
-            return sw.toString();
-        } catch (IOException ex)
-        {
-            throw new SearchException(ex) ;
-        }
-    }
-
-    
-    protected InputStream execCommon(HttpURLConnection httpConnection)
-    {
-        try {        
-            int responseCode = httpConnection.getResponseCode() ;
-            String responseMessage = Convert.decWWWForm(httpConnection.getResponseMessage()) ;
-            
-            // 1xx: Informational 
-            // 2xx: Success 
-            // 3xx: Redirection 
-            // 4xx: Client Error 
-            // 5xx: Server Error 
-            
-            if ( 300 <= responseCode && responseCode < 400 )
-                throw new SearchException(responseCode+" "+responseMessage) ;
-            
-            // Other 400 and 500 - errors 
-            if ( responseCode >= 400 )
-                throw new SearchException(responseCode+" "+responseMessage) ;
-  
-            // Request suceeded
-            InputStream in = httpConnection.getInputStream() ;
-            
-//            Map<String, List<String>> x = httpConnection.getHeaderFields() ;
-//            for ( String f : x.keySet() )
-//                System.out.println(f+" = "+x.get(f)) ;
-            
-            return in ;
-        }
-        catch (IOException ioEx)
-        {
-            throw new SearchException(ioEx) ;
-        } 
-    }
- 
-    
+package search;
+
+import java.io.IOException ;
+import java.io.InputStream ;
+import java.io.InputStreamReader ;
+import java.io.Reader ;
+import java.net.HttpURLConnection ;
+import java.util.Iterator ;
+
+import org.openjena.atlas.iterator.NullIterator ;
+import org.openjena.atlas.lib.StrUtils ;
+
+import com.hp.hpl.jena.sparql.util.Convert ;
+
+public abstract class SearchBase implements Search 
+{
+    @Override
+    public final Iterator<String> search(String... words)
+    {
+        String str = StrUtils.strjoin(" ", words) ;
+        str = Convert.encWWWForm(str) ;
+        InputStream in = execGet(str) ;
+        if ( in == null )
+            return new NullIterator<String>() ;
+        
+        return parse(in) ;
+    }
+    
+    protected abstract InputStream execGet(String searchString) ;
+    protected abstract Iterator<String> parse(InputStream in) ;
+    
+    // Put somewhere!
+    public static String readAll(InputStream in, String charset)
+    {
+        try {
+            Reader r = new InputStreamReader(in, charset) ;//FileUtils.asUTF8(in) ;
+            StringBuilder sw = new StringBuilder(64*1024);
+            char buff[] = new char[8*1024];
+            while (true)
+            {
+                int len = r.read(buff);
+                if (len < 0)
+                    break;
+                sw.append(buff, 0, len);
+            }
+            r.close();
+
+            return sw.toString();
+        } catch (IOException ex)
+        {
+            throw new SearchException(ex) ;
+        }
+    }
+
+    
+    protected InputStream execCommon(HttpURLConnection httpConnection)
+    {
+        try {        
+            int responseCode = httpConnection.getResponseCode() ;
+            String responseMessage = Convert.decWWWForm(httpConnection.getResponseMessage()) ;
+            
+            // 1xx: Informational 
+            // 2xx: Success 
+            // 3xx: Redirection 
+            // 4xx: Client Error 
+            // 5xx: Server Error 
+            
+            if ( 300 <= responseCode && responseCode < 400 )
+                throw new SearchException(responseCode+" "+responseMessage) ;
+            
+            // Other 400 and 500 - errors 
+            if ( responseCode >= 400 )
+                throw new SearchException(responseCode+" "+responseMessage) ;
+  
+            // Request suceeded
+            InputStream in = httpConnection.getInputStream() ;
+            
+//            Map<String, List<String>> x = httpConnection.getHeaderFields() ;
+//            for ( String f : x.keySet() )
+//                System.out.println(f+" = "+x.get(f)) ;
+            
+            return in ;
+        }
+        catch (IOException ioEx)
+        {
+            throw new SearchException(ioEx) ;
+        } 
+    }
+ 
+    
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchException.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchException.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchException.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchException.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,27 +16,27 @@
  * limitations under the License.
  */
 
-package search;
-
-public class SearchException extends RuntimeException
-{
-    public SearchException()
-    {
-        super() ;
-    }
-
-    public SearchException(String message)
-    {
-        super(message) ;
-    }
-
-    public SearchException(String message, Throwable cause)
-    {
-        super(message, cause) ;
-    }
-
-    public SearchException(Throwable cause)
-    {
-        super(cause) ;
-    }
+package search;
+
+public class SearchException extends RuntimeException
+{
+    public SearchException()
+    {
+        super() ;
+    }
+
+    public SearchException(String message)
+    {
+        super(message) ;
+    }
+
+    public SearchException(String message, Throwable cause)
+    {
+        super(message, cause) ;
+    }
+
+    public SearchException(Throwable cause)
+    {
+        super(cause) ;
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchGoogle.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchGoogle.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchGoogle.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchGoogle.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,91 +16,91 @@
  * limitations under the License.
  */
 
-package search;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/** A crude page scraper-based google search API.
- *  Portable.
- */ 
-
-public class SearchGoogle extends SearchBase
-{
-    String serviceURL = "http://www.google.com/search?q=" ;
-  
-    //  http://www.google.com/search?num=100&start=0&q=
-    //  num= removes results from same site
-    //  100 is the maximum value for num that you can use.
-    
-    // Non-greedy .*
-    private static Pattern pattern = Pattern.compile(".*?<h2 class=r><a href=\"([^\"]*)\"") ;
-
-    
-    @Override
-    protected Iterator<String> parse(InputStream in)
-    {
-        // Get bored - read it all in.
-        String content = readAll(in, "ISO-8859-1") ;
-        return parse(content) ;
-    }
-     
-    private Iterator<String> parse(String content)
-    {    
-        if ( ! content.contains("<h2 class=r>") )
-            System.err.println("NOTHING") ;
-        
-        Matcher matcher = pattern.matcher(content); 
-        ArrayList<String> links = new ArrayList<String>(20) ;
-        while(matcher.find())
-        {
-            String link = matcher.group(1) ;
-            links.add(link) ;
-            if ( links.size() > 9 )
-                break ;
-        }
-        return links.iterator() ;
-    }
-
-    protected String url(String searchExpr)
-    {
-        return  serviceURL+searchExpr ;
-    }
-    
-    @Override
-    protected InputStream execGet(String str)
-    {
-        URL target = null ;
-        try {
-                String qs = url(str) ;
-                target = new URL(qs) ;
-        }
-        catch (MalformedURLException malEx)
-        { throw new SearchException("Malformed URL: "+malEx) ; }
-        
-        try
-        {
-            HttpURLConnection httpConnection = (HttpURLConnection) target.openConnection();
-            // By default, following 3xx redirects is true
-            //conn.setFollowRedirects(true) ;
-            httpConnection.setRequestProperty("Accept", "text/html") ;
-            httpConnection.setRequestProperty("Accept-Charset", "utf-8") ;
-            httpConnection.setRequestProperty("User-Agent", "Mozilla 9 // ARQ SPARQL Query Engine") ;
-            httpConnection.setDoInput(true);
-            httpConnection.connect();
-            return execCommon(httpConnection);
-        }
-        catch (java.net.ConnectException connEx)
-        { throw new SearchException("Failed to connect to remote server"); }
-        catch (IOException ioEx)
-        { throw new SearchException(ioEx); }
-    }
-   
+package search;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** A crude page scraper-based google search API.
+ *  Portable.
+ */ 
+
+public class SearchGoogle extends SearchBase
+{
+    String serviceURL = "http://www.google.com/search?q=" ;
+  
+    //  http://www.google.com/search?num=100&start=0&q=
+    //  num= removes results from same site
+    //  100 is the maximum value for num that you can use.
+    
+    // Non-greedy .*
+    private static Pattern pattern = Pattern.compile(".*?<h2 class=r><a href=\"([^\"]*)\"") ;
+
+    
+    @Override
+    protected Iterator<String> parse(InputStream in)
+    {
+        // Get bored - read it all in.
+        String content = readAll(in, "ISO-8859-1") ;
+        return parse(content) ;
+    }
+     
+    private Iterator<String> parse(String content)
+    {    
+        if ( ! content.contains("<h2 class=r>") )
+            System.err.println("NOTHING") ;
+        
+        Matcher matcher = pattern.matcher(content); 
+        ArrayList<String> links = new ArrayList<String>(20) ;
+        while(matcher.find())
+        {
+            String link = matcher.group(1) ;
+            links.add(link) ;
+            if ( links.size() > 9 )
+                break ;
+        }
+        return links.iterator() ;
+    }
+
+    protected String url(String searchExpr)
+    {
+        return  serviceURL+searchExpr ;
+    }
+    
+    @Override
+    protected InputStream execGet(String str)
+    {
+        URL target = null ;
+        try {
+                String qs = url(str) ;
+                target = new URL(qs) ;
+        }
+        catch (MalformedURLException malEx)
+        { throw new SearchException("Malformed URL: "+malEx) ; }
+        
+        try
+        {
+            HttpURLConnection httpConnection = (HttpURLConnection) target.openConnection();
+            // By default, following 3xx redirects is true
+            //conn.setFollowRedirects(true) ;
+            httpConnection.setRequestProperty("Accept", "text/html") ;
+            httpConnection.setRequestProperty("Accept-Charset", "utf-8") ;
+            httpConnection.setRequestProperty("User-Agent", "Mozilla 9 // ARQ SPARQL Query Engine") ;
+            httpConnection.setDoInput(true);
+            httpConnection.connect();
+            return execCommon(httpConnection);
+        }
+        catch (java.net.ConnectException connEx)
+        { throw new SearchException("Failed to connect to remote server"); }
+        catch (IOException ioEx)
+        { throw new SearchException(ioEx); }
+    }
+   
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchSite.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchSite.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchSite.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchSite.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,22 +16,22 @@
  * limitations under the License.
  */
 
-package search;
-
-/** Use Google's search site feature. */
-public class SearchSite extends SearchGoogle 
-{
-    String siteName ="http;//jena.sf.net/" ;
-    
-    public SearchSite(String site)
-    {
-        this.siteName  = site ; 
-    }
-
-    //"site:SITE"
-    @Override
-    protected String url(String searchExpr)
-    {
-        return  serviceURL+searchExpr+"%20site:"+siteName  ;
-    }
+package search;
+
+/** Use Google's search site feature. */
+public class SearchSite extends SearchGoogle 
+{
+    String siteName ="http;//jena.sf.net/" ;
+    
+    public SearchSite(String site)
+    {
+        this.siteName  = site ; 
+    }
+
+    //"site:SITE"
+    @Override
+    protected String url(String searchExpr)
+    {
+        return  serviceURL+searchExpr+"%20site:"+siteName  ;
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchWikipedia.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchWikipedia.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchWikipedia.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/SearchWikipedia.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,89 +16,89 @@
  * limitations under the License.
  */
 
-package search;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class SearchWikipedia extends SearchBase
-{
-    // Unfinished.
-    static String site = "en.wikipedia.org" ;
-    
-    // http://en.wikipedia.org/wiki/API
-    static String serviceURL = "http://%s/wiki/Special:Search?search=%s&fulltext=Search" ;
-    
-    // Non-greedy .*
-
-    // FIXME (this is Google) for the search results page.
-    private static Pattern pattern1 = Pattern.compile(".*?<li><a href=\"([^\"]*)\" title=\"([^\"]*)\">") ; 
-
-    
-    @Override
-    protected Iterator<String> parse(InputStream in)
-    {
-        // Get bored - read it all in.
-        String content = readAll(in, "UTF-8") ;
-        return parse(content) ;
-    }
-     
-    public static Iterator<String> parse(String content)
-    {
-        Matcher matcher = pattern1.matcher(content) ; 
-        ArrayList<String> links = new ArrayList<String>(20) ;
-        while(matcher.find())
-        {
-            String link = matcher.group(1) ;
-            link = "http://"+site+link ;
-            String title = matcher.group(2) ;
-            
-            if ( ! links.contains(link) )
-                links.add(link) ;
-            if ( links.size() > 9 )
-                break ;
-        }
-        return links.iterator() ;
-    }
-    
-    private String url(String searchExpr)
-    {
-        return String.format(serviceURL, site, searchExpr) ;
-    }
-    
-    @Override
-    protected InputStream execGet(String str)
-    {
-        URL target = null ;
-        try {
-                String qs = url(str) ;
-                target = new URL(qs) ;
-        }
-        catch (MalformedURLException malEx)
-        { throw new SearchException("Malformed URL: "+malEx) ; }
-        
-        try
-        {
-            HttpURLConnection httpConnection = (HttpURLConnection) target.openConnection();
-            // By default, following 3xx redirects is true
-            //conn.setFollowRedirects(true) ;
-            httpConnection.setRequestProperty("Accept", "text/html") ;
-            httpConnection.setRequestProperty("Accept-Charset", "utf-8") ;
-            httpConnection.setRequestProperty("User-Agent", "Mozilla 9 // ARQ SPARQL Query Engine") ;
-            httpConnection.setDoInput(true);
-            httpConnection.connect();
-            return execCommon(httpConnection);
-        }
-        catch (java.net.ConnectException connEx)
-        { throw new SearchException("Failed to connect to remote server"); }
-        catch (IOException ioEx)
-        { throw new SearchException(ioEx); }
-    }
+package search;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class SearchWikipedia extends SearchBase
+{
+    // Unfinished.
+    static String site = "en.wikipedia.org" ;
+    
+    // http://en.wikipedia.org/wiki/API
+    static String serviceURL = "http://%s/wiki/Special:Search?search=%s&fulltext=Search" ;
+    
+    // Non-greedy .*
+
+    // FIXME (this is Google) for the search results page.
+    private static Pattern pattern1 = Pattern.compile(".*?<li><a href=\"([^\"]*)\" title=\"([^\"]*)\">") ; 
+
+    
+    @Override
+    protected Iterator<String> parse(InputStream in)
+    {
+        // Get bored - read it all in.
+        String content = readAll(in, "UTF-8") ;
+        return parse(content) ;
+    }
+     
+    public static Iterator<String> parse(String content)
+    {
+        Matcher matcher = pattern1.matcher(content) ; 
+        ArrayList<String> links = new ArrayList<String>(20) ;
+        while(matcher.find())
+        {
+            String link = matcher.group(1) ;
+            link = "http://"+site+link ;
+            String title = matcher.group(2) ;
+            
+            if ( ! links.contains(link) )
+                links.add(link) ;
+            if ( links.size() > 9 )
+                break ;
+        }
+        return links.iterator() ;
+    }
+    
+    private String url(String searchExpr)
+    {
+        return String.format(serviceURL, site, searchExpr) ;
+    }
+    
+    @Override
+    protected InputStream execGet(String str)
+    {
+        URL target = null ;
+        try {
+                String qs = url(str) ;
+                target = new URL(qs) ;
+        }
+        catch (MalformedURLException malEx)
+        { throw new SearchException("Malformed URL: "+malEx) ; }
+        
+        try
+        {
+            HttpURLConnection httpConnection = (HttpURLConnection) target.openConnection();
+            // By default, following 3xx redirects is true
+            //conn.setFollowRedirects(true) ;
+            httpConnection.setRequestProperty("Accept", "text/html") ;
+            httpConnection.setRequestProperty("Accept-Charset", "utf-8") ;
+            httpConnection.setRequestProperty("User-Agent", "Mozilla 9 // ARQ SPARQL Query Engine") ;
+            httpConnection.setDoInput(true);
+            httpConnection.connect();
+            return execCommon(httpConnection);
+        }
+        catch (java.net.ConnectException connEx)
+        { throw new SearchException("Failed to connect to remote server"); }
+        catch (IOException ioEx)
+        { throw new SearchException(ioEx); }
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/WikipediaPF.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/WikipediaPF.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/WikipediaPF.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/search/WikipediaPF.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,16 +16,16 @@
  * limitations under the License.
  */
 
-package search;
-
-public class WikipediaPF extends BaseSearchPF
-{
-    // Site search wikipedia.
-    private Search search = new SearchWikipedia() ;
-    
-    @Override
-    protected Search searchEngine()
-    {
-        return search ;
-    }
+package search;
+
+public class WikipediaPF extends BaseSearchPF
+{
+    // Site search wikipedia.
+    private Search search = new SearchWikipedia() ;
+    
+    @Override
+    protected Search searchEngine()
+    {
+        return search ;
+    }
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/Indirection.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/Indirection.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/Indirection.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/Indirection.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/Sequence.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/Sequence.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/Sequence.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/Sequence.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/varblock/Design.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/varblock/Design.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/varblock/Design.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/varblock/Design.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,11 +16,11 @@
  * limitations under the License.
  */
 
-package storage.varblock;
-
-public class Design
-{
-    // "disk-malloc"
-    //http://gee.cs.oswego.edu/dl/html/malloc.html
-    
+package storage.varblock;
+
+public class Design
+{
+    // "disk-malloc"
+    //http://gee.cs.oswego.edu/dl/html/malloc.html
+    
 }

Modified: incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/varrecord/TestVarRecordBlock.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/varrecord/TestVarRecordBlock.java?rev=1198733&r1=1198732&r2=1198733&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/varrecord/TestVarRecordBlock.java (original)
+++ incubator/jena/Scratch/AFS/Dev/trunk/src/main/java/storage/varrecord/TestVarRecordBlock.java Mon Nov  7 13:36:30 2011
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -16,199 +16,199 @@
  * limitations under the License.
  */
 
-package storage.varrecord;
-
-import java.nio.ByteBuffer;
-
-import com.hp.hpl.jena.tdb.base.record.Record;
-
-import org.junit.Test;
-import org.openjena.atlas.junit.BaseTest ;
-
-public class TestVarRecordBlock extends BaseTest
-{
-    // Some data items.
-    static byte[] d1 = make(1,2,3,4) ;
-    static byte[] d2 = make(0xFF, 0xFE) ;
-
-    static byte[] d3 = make(5,4,5,4,3,2,3,2,1,1) ;
-    static byte[] d4 = make(0xFF, 0xFE, 0xFD, 0xFC, 0xFB) ;
-
-    
-    //Record r1 = new Record() ;
-    
-    @Test public void vrb_new_1()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(100) ;
-        assertEquals(100, vrb.getByteBuffer().capacity()) ;
-        assertEquals(100, vrb.getByteBuffer().limit()) ;
-        assertEquals(0, vrb.size()) ;
-        assertEquals(4, vrb.bytesInUse()) ;
-    }
-    
-    @Test public void vrb_2()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
-        vrb.put(d1,d2) ;
-        assertEquals(1, vrb.size()) ;
-        int len = d1.length+d2.length+1+1 +2+2+4 ; // varInt of length 1,twice, the index slots, twice and the count slot 
-        assertEquals(len, vrb.bytesInUse()) ;
-    }
-    
-    @Test public void vrb_3()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(50) ;
-        vrb.put(d1,d2) ;
-        vrb.put(d1,d2) ;
-        assertEquals(2, vrb.size()) ;
-    }
-    
-    @Test public void vrb_3a()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(50) ;
-        vrb.put(d1,d2) ;
-        vrb.put(d3,d4) ;
-        int len = d1.length + d2.length + d3.length + d4.length + 4/*VarInts*/ + 4*2 + 4 ;
-        assertEquals(2, vrb.size()) ;
-        assertEquals(len, vrb.bytesInUse()) ;
-    }
-    
-
-    @Test public void vrb_4()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
-        vrb.put(0, d1,d2) ;
-        Record r = vrb.get(0) ;
-        assertArrayEquals(d1, r.getKey()) ;
-        assertArrayEquals(d2, r.getValue()) ;
-    }
-
-    @Test public void vrb_4a()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(100) ;
-        vrb.put(d1,d2) ;
-        vrb.put(d3,d4) ;
-        Record r = vrb.get(0) ;
-        assertArrayEquals(d1, r.getKey()) ;
-        assertArrayEquals(d2, r.getValue()) ;
-        
-        r = vrb.get(1) ;
-        assertArrayEquals(d3, r.getKey()) ;
-        assertArrayEquals(d4, r.getValue()) ;
-    }
-    
-    @Test public void vrb_5()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
-        vrb.put(0, d1, d2) ;
-        byte[] v = vrb.find(d1) ;
-        assertArrayEquals(d2, v) ;
-        assertNull(vrb.find(d2)) ;
-        assertNull(vrb.find(d3)) ;
-    }
-
-    @Test public void vrb_6()
-    {
-        // Insert at specific place.
-        VarRecordBuffer vrb = new VarRecordBuffer(50) ;
-        vrb.put(0, d1,d2) ;
-        vrb.put(0, d1,d2) ;
-        assertEquals(2, vrb.size()) ;
-    }
-    
-    @Test public void vrb_7()
-    {
-        // Too small.
-        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
-        vrb.put(d1,d2) ;
-        try { vrb.put(d1,d2) ; } catch (Exception ex) {} 
-        assertEquals(1, vrb.size()) ;
-        Record r = vrb.get(0) ;
-        assertArrayEquals(d1, r.getKey()) ;
-        assertArrayEquals(d2, r.getValue()) ;
-    }
-    
-    
-    // Delete
-    @Test public void vrb_10()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
-        vrb.put(0, d1,d2) ;
-        vrb.delete(0) ;
-        assertEquals(0, vrb.size()) ;
-    }
-    
-    @Test public void vrb_11()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
-        vrb.put(0, d1,d2) ;
-        vrb.delete() ;
-        assertEquals(0, vrb.size()) ;
-    }
-
-    @Test public void vrb_12()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(100) ;
-        vrb.put(0, d1,d2) ;
-        vrb.put(1, d3,d4) ;
-        vrb.delete() ;
-        assertEquals(1, vrb.size()) ;
-        Record r = vrb.get(0) ;
-        assertArrayEquals(d1, r.getKey()) ;
-        assertArrayEquals(d2, r.getValue()) ;
-        
-    }
-    
-    @Test public void vrb_13()
-    {
-        VarRecordBuffer vrb = new VarRecordBuffer(100) ;
-        vrb.put(0, d1,d2) ;
-        vrb.put(1, d3,d4) ;
-        vrb.delete(0) ;
-        assertEquals(1, vrb.size()) ;
-        Record r = vrb.get(0) ;
-        assertArrayEquals(d3, r.getKey()) ;
-        assertArrayEquals(d4, r.getValue()) ;
-        
-    }
-
-    @Test public void vrb_reattach_1()
-    {
-        int capacity = 100 ;
-        VarRecordBuffer vrb = new VarRecordBuffer(capacity) ;
-        vrb.put(0, d1,d2) ;
-        
-        ByteBuffer bb = ByteBuffer.allocate(capacity) ;
-        bb.put(vrb.getByteBuffer()) ;
-        VarRecordBuffer vrb2 = VarRecordBuffer.wrap(bb) ;
-        vrb2.put(1, d3,d4) ;
-        
-        assertEquals(2, vrb2.size()) ;
-        assertEquals(1, vrb.size()) ;
-        
-        Record r = vrb2.get(0) ;
-        assertArrayEquals(d1, r.getKey()) ;
-        assertArrayEquals(d2, r.getValue()) ;
-        r = vrb2.get(1) ;
-        assertArrayEquals(d3, r.getKey()) ;
-        assertArrayEquals(d4, r.getValue()) ;
-    }
-
-    
-    // A neater way to write byte[] x = {(byte)0xFF...} because no casts needed for > 128.
-    private static byte[] make(int ... values)
-    {
-        byte[] array = new byte[values.length] ;
-        for ( int i = 0 ; i < values.length ; i++ )
-        {
-            int v = values[i] ;
-            if ( v > 255 )
-                throw new IllegalArgumentException("Bad value for byte: "+v) ;
-            byte b = (byte)(v&0xFF) ;
-            array[i] = b ;
-        }
-        return array ;
-    }
-    
-    
+package storage.varrecord;
+
+import java.nio.ByteBuffer;
+
+import com.hp.hpl.jena.tdb.base.record.Record;
+
+import org.junit.Test;
+import org.openjena.atlas.junit.BaseTest ;
+
+public class TestVarRecordBlock extends BaseTest
+{
+    // Some data items.
+    static byte[] d1 = make(1,2,3,4) ;
+    static byte[] d2 = make(0xFF, 0xFE) ;
+
+    static byte[] d3 = make(5,4,5,4,3,2,3,2,1,1) ;
+    static byte[] d4 = make(0xFF, 0xFE, 0xFD, 0xFC, 0xFB) ;
+
+    
+    //Record r1 = new Record() ;
+    
+    @Test public void vrb_new_1()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(100) ;
+        assertEquals(100, vrb.getByteBuffer().capacity()) ;
+        assertEquals(100, vrb.getByteBuffer().limit()) ;
+        assertEquals(0, vrb.size()) ;
+        assertEquals(4, vrb.bytesInUse()) ;
+    }
+    
+    @Test public void vrb_2()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
+        vrb.put(d1,d2) ;
+        assertEquals(1, vrb.size()) ;
+        int len = d1.length+d2.length+1+1 +2+2+4 ; // varInt of length 1,twice, the index slots, twice and the count slot 
+        assertEquals(len, vrb.bytesInUse()) ;
+    }
+    
+    @Test public void vrb_3()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(50) ;
+        vrb.put(d1,d2) ;
+        vrb.put(d1,d2) ;
+        assertEquals(2, vrb.size()) ;
+    }
+    
+    @Test public void vrb_3a()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(50) ;
+        vrb.put(d1,d2) ;
+        vrb.put(d3,d4) ;
+        int len = d1.length + d2.length + d3.length + d4.length + 4/*VarInts*/ + 4*2 + 4 ;
+        assertEquals(2, vrb.size()) ;
+        assertEquals(len, vrb.bytesInUse()) ;
+    }
+    
+
+    @Test public void vrb_4()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
+        vrb.put(0, d1,d2) ;
+        Record r = vrb.get(0) ;
+        assertArrayEquals(d1, r.getKey()) ;
+        assertArrayEquals(d2, r.getValue()) ;
+    }
+
+    @Test public void vrb_4a()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(100) ;
+        vrb.put(d1,d2) ;
+        vrb.put(d3,d4) ;
+        Record r = vrb.get(0) ;
+        assertArrayEquals(d1, r.getKey()) ;
+        assertArrayEquals(d2, r.getValue()) ;
+        
+        r = vrb.get(1) ;
+        assertArrayEquals(d3, r.getKey()) ;
+        assertArrayEquals(d4, r.getValue()) ;
+    }
+    
+    @Test public void vrb_5()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
+        vrb.put(0, d1, d2) ;
+        byte[] v = vrb.find(d1) ;
+        assertArrayEquals(d2, v) ;
+        assertNull(vrb.find(d2)) ;
+        assertNull(vrb.find(d3)) ;
+    }
+
+    @Test public void vrb_6()
+    {
+        // Insert at specific place.
+        VarRecordBuffer vrb = new VarRecordBuffer(50) ;
+        vrb.put(0, d1,d2) ;
+        vrb.put(0, d1,d2) ;
+        assertEquals(2, vrb.size()) ;
+    }
+    
+    @Test public void vrb_7()
+    {
+        // Too small.
+        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
+        vrb.put(d1,d2) ;
+        try { vrb.put(d1,d2) ; } catch (Exception ex) {} 
+        assertEquals(1, vrb.size()) ;
+        Record r = vrb.get(0) ;
+        assertArrayEquals(d1, r.getKey()) ;
+        assertArrayEquals(d2, r.getValue()) ;
+    }
+    
+    
+    // Delete
+    @Test public void vrb_10()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
+        vrb.put(0, d1,d2) ;
+        vrb.delete(0) ;
+        assertEquals(0, vrb.size()) ;
+    }
+    
+    @Test public void vrb_11()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(20) ;
+        vrb.put(0, d1,d2) ;
+        vrb.delete() ;
+        assertEquals(0, vrb.size()) ;
+    }
+
+    @Test public void vrb_12()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(100) ;
+        vrb.put(0, d1,d2) ;
+        vrb.put(1, d3,d4) ;
+        vrb.delete() ;
+        assertEquals(1, vrb.size()) ;
+        Record r = vrb.get(0) ;
+        assertArrayEquals(d1, r.getKey()) ;
+        assertArrayEquals(d2, r.getValue()) ;
+        
+    }
+    
+    @Test public void vrb_13()
+    {
+        VarRecordBuffer vrb = new VarRecordBuffer(100) ;
+        vrb.put(0, d1,d2) ;
+        vrb.put(1, d3,d4) ;
+        vrb.delete(0) ;
+        assertEquals(1, vrb.size()) ;
+        Record r = vrb.get(0) ;
+        assertArrayEquals(d3, r.getKey()) ;
+        assertArrayEquals(d4, r.getValue()) ;
+        
+    }
+
+    @Test public void vrb_reattach_1()
+    {
+        int capacity = 100 ;
+        VarRecordBuffer vrb = new VarRecordBuffer(capacity) ;
+        vrb.put(0, d1,d2) ;
+        
+        ByteBuffer bb = ByteBuffer.allocate(capacity) ;
+        bb.put(vrb.getByteBuffer()) ;
+        VarRecordBuffer vrb2 = VarRecordBuffer.wrap(bb) ;
+        vrb2.put(1, d3,d4) ;
+        
+        assertEquals(2, vrb2.size()) ;
+        assertEquals(1, vrb.size()) ;
+        
+        Record r = vrb2.get(0) ;
+        assertArrayEquals(d1, r.getKey()) ;
+        assertArrayEquals(d2, r.getValue()) ;
+        r = vrb2.get(1) ;
+        assertArrayEquals(d3, r.getKey()) ;
+        assertArrayEquals(d4, r.getValue()) ;
+    }
+
+    
+    // A neater way to write byte[] x = {(byte)0xFF...} because no casts needed for > 128.
+    private static byte[] make(int ... values)
+    {
+        byte[] array = new byte[values.length] ;
+        for ( int i = 0 ; i < values.length ; i++ )
+        {
+            int v = values[i] ;
+            if ( v > 255 )
+                throw new IllegalArgumentException("Bad value for byte: "+v) ;
+            byte b = (byte)(v&0xFF) ;
+            array[i] = b ;
+        }
+        return array ;
+    }
+    
+    
 }