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 EFA40200BAA for ; Thu, 27 Oct 2016 11:07:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EE317160AE4; Thu, 27 Oct 2016 09:07:00 +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 E6406160B04 for ; Thu, 27 Oct 2016 11:06:59 +0200 (CEST) Received: (qmail 51391 invoked by uid 500); 27 Oct 2016 09:06:59 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 51382 invoked by uid 99); 27 Oct 2016 09:06:59 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Oct 2016 09:06:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 985561A0423 for ; Thu, 27 Oct 2016 09:06:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id iesFss1-yF6r for ; Thu, 27 Oct 2016 09:06:56 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id E067A5FB35 for ; Thu, 27 Oct 2016 09:06:55 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 37B64E0318 for ; Thu, 27 Oct 2016 09:06:54 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 576B93A0233 for ; Thu, 27 Oct 2016 09:06:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1766791 - in /felix/trunk/converter: converter/src/main/java/org/apache/felix/converter/impl/ schematizer/src/main/java/org/apache/felix/serializer/impl/json/ serializer/src/main/java/org/apache/felix/serializer/impl/ serializer/src/main/j... Date: Thu, 27 Oct 2016 09:06:52 -0000 To: commits@felix.apache.org From: davidb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20161027090653.576B93A0233@svn01-us-west.apache.org> archived-at: Thu, 27 Oct 2016 09:07:01 -0000 Author: davidb Date: Thu Oct 27 09:06:52 2016 New Revision: 1766791 URL: http://svn.apache.org/viewvc?rev=1766791&view=rev Log: Refactor util class and make private Added: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/Util.java felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/Util.java Modified: felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/Util.java felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlDeserializingImpl.java Modified: felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/Util.java URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/Util.java?rev=1766791&r1=1766790&r2=1766791&view=diff ============================================================================== --- felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/Util.java (original) +++ felix/trunk/converter/converter/src/main/java/org/apache/felix/converter/impl/Util.java Thu Oct 27 09:06:52 2016 @@ -16,15 +16,12 @@ */ package org.apache.felix.converter.impl; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; import java.lang.reflect.Type; import java.util.Collections; import java.util.HashMap; import java.util.Map; -public class Util { +class Util { private static final Map, Class> boxedClasses; static { Map, Class> m = new HashMap<>(); @@ -40,6 +37,8 @@ public class Util { boxedClasses = Collections.unmodifiableMap(m); } + private Util() {} // prevent instantiation + static Type primitiveToBoxed(Type type) { if (type instanceof Class) return primitiveToBoxed((Class) type); @@ -54,29 +53,4 @@ public class Util { else return cls; } - - public static byte [] readStream(InputStream is) throws IOException { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] bytes = new byte[8192]; - - int length = 0; - int offset = 0; - - while ((length = is.read(bytes, offset, bytes.length - offset)) != -1) { - offset += length; - - if (offset == bytes.length) { - baos.write(bytes, 0, bytes.length); - offset = 0; - } - } - if (offset != 0) { - baos.write(bytes, 0, offset); - } - return baos.toByteArray(); - } finally { - is.close(); - } - } } Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java?rev=1766791&r1=1766790&r2=1766791&view=diff ============================================================================== --- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java (original) +++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java Thu Oct 27 09:06:52 2016 @@ -26,7 +26,7 @@ import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.felix.converter.impl.Util; +import org.apache.felix.serializer.impl.Util; /** * A very small JSON parser. Added: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/Util.java URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/Util.java?rev=1766791&view=auto ============================================================================== --- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/Util.java (added) +++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/Util.java Thu Oct 27 09:06:52 2016 @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.felix.serializer.impl.json; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +public class Util { + private Util() {} // prevent instantiation + + public static byte [] readStream(InputStream is) throws IOException { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] bytes = new byte[8192]; + + int length = 0; + int offset = 0; + + while ((length = is.read(bytes, offset, bytes.length - offset)) != -1) { + offset += length; + + if (offset == bytes.length) { + baos.write(bytes, 0, bytes.length); + offset = 0; + } + } + if (offset != 0) { + baos.write(bytes, 0, offset); + } + return baos.toByteArray(); + } finally { + is.close(); + } + } +} Added: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/Util.java URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/Util.java?rev=1766791&view=auto ============================================================================== --- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/Util.java (added) +++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/Util.java Thu Oct 27 09:06:52 2016 @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.felix.serializer.impl; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +public class Util { + private Util() {} // prevent instantiation + + public static byte [] readStream(InputStream is) throws IOException { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] bytes = new byte[8192]; + + int length = 0; + int offset = 0; + + while ((length = is.read(bytes, offset, bytes.length - offset)) != -1) { + offset += length; + + if (offset == bytes.length) { + baos.write(bytes, 0, bytes.length); + offset = 0; + } + } + if (offset != 0) { + baos.write(bytes, 0, offset); + } + return baos.toByteArray(); + } finally { + is.close(); + } + } +} Modified: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java?rev=1766791&r1=1766790&r2=1766791&view=diff ============================================================================== --- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java (original) +++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java Thu Oct 27 09:06:52 2016 @@ -24,7 +24,7 @@ import java.nio.charset.StandardCharsets import java.util.Map; import java.util.Scanner; -import org.apache.felix.converter.impl.Util; +import org.apache.felix.serializer.impl.Util; import org.osgi.service.serializer.Deserializing; import org.osgi.util.converter.ConversionException; import org.osgi.util.converter.Converter; Modified: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java?rev=1766791&r1=1766790&r2=1766791&view=diff ============================================================================== --- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java (original) +++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java Thu Oct 27 09:06:52 2016 @@ -26,7 +26,7 @@ import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.felix.converter.impl.Util; +import org.apache.felix.serializer.impl.Util; /** * A very small JSON parser. Modified: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlDeserializingImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlDeserializingImpl.java?rev=1766791&r1=1766790&r2=1766791&view=diff ============================================================================== --- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlDeserializingImpl.java (original) +++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/yaml/YamlDeserializingImpl.java Thu Oct 27 09:06:52 2016 @@ -23,7 +23,7 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Scanner; -import org.apache.felix.converter.impl.Util; +import org.apache.felix.serializer.impl.Util; import org.osgi.service.serializer.Deserializing; import org.osgi.util.converter.ConversionException; import org.osgi.util.converter.Converter;