This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.0.4-incubator in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git
commit 5c546cbaeba521c3eb8d69a782c8bcae5db7f78f Author: Carsten Ziegeler <[email protected]> AuthorDate: Fri Aug 1 11:21:11 2008 +0000 Add toStringArray method with additional default value. git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/osgi@681655 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/sling/commons/osgi/OsgiUtil.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/sling/commons/osgi/OsgiUtil.java b/src/main/java/org/apache/sling/commons/osgi/OsgiUtil.java index 0635570..e5e6b86 100644 --- a/src/main/java/org/apache/sling/commons/osgi/OsgiUtil.java +++ b/src/main/java/org/apache/sling/commons/osgi/OsgiUtil.java @@ -158,9 +158,23 @@ public class OsgiUtil { * returned. */ public static String[] toStringArray(Object propValue) { + return toStringArray(propValue, null); + } + + /** + * Returns the named service reference property as an array of Strings. If + * the property is a scalar value its string value is returned as a single + * element array. If the property is an array, the elements are converted to + * String objects and returned as an array. If the property is a vector, the + * vector elements are converted to String objects and returned as an array. + * Otherwise (if the property does not exist) a provided default value is + * returned. + * @since 2.0.4 + */ + public static String[] toStringArray(Object propValue, String[] defaultArray) { if (propValue == null) { // no value at all - return null; + return defaultArray; } else if (propValue instanceof String) { // single string @@ -193,7 +207,7 @@ public class OsgiUtil { return values.toArray(new String[values.size()]); } - return null; + return defaultArray; } public static Event createEvent(Bundle sourceBundle, -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
