Thanks, it's very clear. About the close method, is it up to the user to maintain a reference to the stream which has been passed to the binding stream to close it?
On Tue, Sep 6, 2011 at 3:44 PM, Andy Seaborne <[email protected]> wrote: > Laurent, > > Thanks for the concrete example. > > A binding is a row in a table. Whether it's done by extending an existing > binding to add extra variables, using the parent for the common part, or > whether it's done by a self-contained binding, is an implementation issue. > > What's important is that > > binding.equals(unserializedBinding) > > which is true. All the operations in the Binding API should have the same > effect. GetParent(), which is an internal detail of one implementation that > leaks out. > > I've just checked the code base, and getParent() isn't used any more so it > can be removed from the Binding interface. Does that make things clearer? > Is there a specific requirement you have for access to any parent? > > Andy > > On 06/09/11 12:00, Laurent Pellegrino wrote: >> >> Hi Andy, >> >> Hereunder a test case: >> >> Node defaultNode = Node.createURI("http://www.openjena.org"); >> >> Binding parentBinding = BindingFactory.create(); >> parentBinding.add(Var.alloc("parent"), defaultNode); >> >> Binding binding = BindingFactory.create(parentBinding); >> binding.add(Var.alloc("var1"), defaultNode); >> binding.add(Var.alloc("var2"), defaultNode); >> >> ByteArrayOutputStream baos = new ByteArrayOutputStream(); >> BindingOutputStream bos = new BindingOutputStream(baos); >> bos.send(binding); >> >> bos.close(); >> >> ByteArrayInputStream bais = >> new ByteArrayInputStream(baos.toByteArray()); >> >> BindingInputStream bis = new BindingInputStream(bais); >> >> Binding unserializedBinding = bis.next(); >> Binding unserializedParentBinding = >> unserializedBinding.getParent(); >> >> try { >> bais.close(); >> } catch (IOException e) { >> e.printStackTrace(); >> } >> >> System.out.println("parent value=" + unserializedParentBinding); >> >> >> The deserialized parent value is null whereas the initial binding >> contain a parent value with a variable. >> >> Also, why is there no close method in BindingInputStream? and why >> BindingInputStream and BindingOutputStream are not implementing the >> Java InputStream and OutputStream interfaces? >> >> I ask for that because when I decorate an InputStream >> (ByteArrayInputStream, FileInputStream, GZipInputStream, etc.) with a >> BindingInputStream, I expect to have a close method that close >> BindingInputStream and the underlying InputStreams. >> >> Laurent >> >> On Tue, Sep 6, 2011 at 11:27 AM, Andy Seaborne >> <[email protected]> wrote: >>> >>> Laurent, >>> >>> Do you have a test case? >>> >>> Parent values should be flattened out and lost on reading back. Parents >>> for >>> bindings is just a space saving optimization. The API to bindings does >>> not >>> expose them and the read-back bindings should have the same variables and >>> same values. >>> >>> Andy >>> >>> On 06/09/11 09:14, Laurent Pellegrino wrote: >>>> >>>> Hello, >>>> >>>> It seems that BindingOutputStream and BindingInputStream are not >>>> taking into account the parent value associated to a binding (i.e. the >>>> parent value is not serialized). Is it a desired behavior? >>>> >>>> Kind Regards, >>>> >>>> Laurent >>> >
