Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BA37B200C6E for ; Sun, 2 Apr 2017 19:47:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B8F23160B9E; Sun, 2 Apr 2017 17:47:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 763F5160BC8 for ; Sun, 2 Apr 2017 19:47:46 +0200 (CEST) Received: (qmail 19593 invoked by uid 500); 2 Apr 2017 17:47:45 -0000 Mailing-List: contact commits-help@polygene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@polygene.apache.org Delivered-To: mailing list commits@polygene.apache.org Received: (qmail 18485 invoked by uid 99); 2 Apr 2017 17:47:44 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Apr 2017 17:47:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EFB1EE117B; Sun, 2 Apr 2017 17:47:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: paulmerlin@apache.org To: commits@polygene.apache.org Date: Sun, 02 Apr 2017 17:48:27 -0000 Message-Id: <43abd88144ee4d48ab8ca2d28ca6d089@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [45/52] [abbrv] polygene-java git commit: Do not constrain XmlDeserializer input to Document, use Node instead archived-at: Sun, 02 Apr 2017 17:47:48 -0000 Do not constrain XmlDeserializer input to Document, use Node instead This gives users of the XmlDeserializer service more freedom as to where they get the XML state from. Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/82f1dbc8 Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/82f1dbc8 Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/82f1dbc8 Branch: refs/heads/develop Commit: 82f1dbc8b9932257753d32abba489f2f728b9142 Parents: 14fe39c Author: Paul Merlin Authored: Sun Apr 2 15:26:34 2017 +0200 Committer: Paul Merlin Committed: Sun Apr 2 19:16:24 2017 +0200 ---------------------------------------------------------------------- .../spi/serialization/XmlDeserializer.java | 21 ++++++++++---------- .../spi/serialization/XmlSerializer.java | 2 +- .../javaxxml/JavaxXmlDeserializer.java | 3 +-- 3 files changed, 13 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/polygene-java/blob/82f1dbc8/core/spi/src/main/java/org/apache/polygene/spi/serialization/XmlDeserializer.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/polygene/spi/serialization/XmlDeserializer.java b/core/spi/src/main/java/org/apache/polygene/spi/serialization/XmlDeserializer.java index f61e533..3d42828 100644 --- a/core/spi/src/main/java/org/apache/polygene/spi/serialization/XmlDeserializer.java +++ b/core/spi/src/main/java/org/apache/polygene/spi/serialization/XmlDeserializer.java @@ -33,57 +33,58 @@ import org.apache.polygene.spi.module.ModuleSpi; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import org.w3c.dom.Node; /** * {@literal javax.xml} deserializer. */ public interface XmlDeserializer extends Deserializer { - T fromXml( ModuleDescriptor module, ValueType valueType, Document state ); + T fromXml( ModuleDescriptor module, ValueType valueType, Node state ); - default Function fromXmlFunction( ModuleDescriptor module, ValueType valueType ) + default Function fromXmlFunction( ModuleDescriptor module, ValueType valueType ) { return state -> fromXml( module, valueType, state ); } - default Stream fromXmlEach( ModuleDescriptor module, ValueType valueType, Stream states ) + default Stream fromXmlEach( ModuleDescriptor module, ValueType valueType, Stream states ) { return states.map( fromXmlFunction( module, valueType ) ); } - default Stream fromXmlEach( ModuleDescriptor module, ValueType valueType, Iterable states ) + default Stream fromXmlEach( ModuleDescriptor module, ValueType valueType, Iterable states ) { return fromXmlEach( module, valueType, StreamSupport.stream( states.spliterator(), false ) ); } - default Stream fromXmlEach( ModuleDescriptor module, ValueType valueType, Document... states ) + default Stream fromXmlEach( ModuleDescriptor module, ValueType valueType, Node... states ) { return fromXmlEach( module, valueType, Stream.of( states ) ); } - default T fromXml( ModuleDescriptor module, Class type, Document state ) + default T fromXml( ModuleDescriptor module, Class type, Node state ) { // TODO Remove (ModuleSpi) cast ValueType valueType = ( (ModuleSpi) module.instance() ).valueTypeFactory().valueTypeOf( module, type ); return fromXml( module, valueType, state ); } - default Function fromXml( ModuleDescriptor module, Class type ) + default Function fromXml( ModuleDescriptor module, Class type ) { return state -> fromXml( module, type, state ); } - default Stream fromXmlEach( ModuleDescriptor module, Class valueType, Stream states ) + default Stream fromXmlEach( ModuleDescriptor module, Class valueType, Stream states ) { return states.map( fromXml( module, valueType ) ); } - default Stream fromXmlEach( ModuleDescriptor module, Class valueType, Iterable states ) + default Stream fromXmlEach( ModuleDescriptor module, Class valueType, Iterable states ) { return fromXmlEach( module, valueType, StreamSupport.stream( states.spliterator(), false ) ); } - default Stream fromXmlEach( ModuleDescriptor module, Class valueType, Document... states ) + default Stream fromXmlEach( ModuleDescriptor module, Class valueType, Node... states ) { return fromXmlEach( module, valueType, Stream.of( states ) ); } http://git-wip-us.apache.org/repos/asf/polygene-java/blob/82f1dbc8/core/spi/src/main/java/org/apache/polygene/spi/serialization/XmlSerializer.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/polygene/spi/serialization/XmlSerializer.java b/core/spi/src/main/java/org/apache/polygene/spi/serialization/XmlSerializer.java index afffe5f..6e1b7dc 100644 --- a/core/spi/src/main/java/org/apache/polygene/spi/serialization/XmlSerializer.java +++ b/core/spi/src/main/java/org/apache/polygene/spi/serialization/XmlSerializer.java @@ -96,7 +96,7 @@ public interface XmlSerializer extends Serializer } try { - // We want plain Strings to be serialized without quotes + // We want plain text nodes to be serialized without surrounding elements if( xmlDocument.getNodeType() == Node.TEXT_NODE ) { writer.write( xmlDocument.getNodeValue() ); http://git-wip-us.apache.org/repos/asf/polygene-java/blob/82f1dbc8/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlDeserializer.java ---------------------------------------------------------------------- diff --git a/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlDeserializer.java b/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlDeserializer.java index 8c6bc7b..5caed72 100644 --- a/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlDeserializer.java +++ b/extensions/serialization-javaxxml/src/main/java/org/apache/polygene/serialization/javaxxml/JavaxXmlDeserializer.java @@ -53,7 +53,6 @@ import org.apache.polygene.api.value.ValueBuilder; import org.apache.polygene.api.value.ValueDescriptor; import org.apache.polygene.spi.serialization.AbstractTextDeserializer; import org.apache.polygene.spi.serialization.XmlDeserializer; -import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -77,7 +76,7 @@ public class JavaxXmlDeserializer extends AbstractTextDeserializer implements Xm private ServiceDescriptor descriptor; @Override - public T fromXml( ModuleDescriptor module, ValueType valueType, Document state ) + public T fromXml( ModuleDescriptor module, ValueType valueType, Node state ) { Optional stateElement = JavaxXml.firstChildElementNamed( state, getSettings().getRootTagName() ); if( stateElement.isPresent() )