Author: cziegeler
Date: Fri Aug 1 04:21:11 2008
New Revision: 681655
URL: http://svn.apache.org/viewvc?rev=681655&view=rev
Log:
Add toStringArray method with additional default value.
Modified:
incubator/sling/trunk/commons/osgi/src/main/java/org/apache/sling/commons/osgi/OsgiUtil.java
Modified:
incubator/sling/trunk/commons/osgi/src/main/java/org/apache/sling/commons/osgi/OsgiUtil.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/commons/osgi/src/main/java/org/apache/sling/commons/osgi/OsgiUtil.java?rev=681655&r1=681654&r2=681655&view=diff
==============================================================================
---
incubator/sling/trunk/commons/osgi/src/main/java/org/apache/sling/commons/osgi/OsgiUtil.java
(original)
+++
incubator/sling/trunk/commons/osgi/src/main/java/org/apache/sling/commons/osgi/OsgiUtil.java
Fri Aug 1 04:21:11 2008
@@ -158,9 +158,23 @@
* 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 @@
return values.toArray(new String[values.size()]);
}
- return null;
+ return defaultArray;
}
public static Event createEvent(Bundle sourceBundle,