@Test public void testAsArray1() { String[] strings = new String[] { "a", "b" }; String[] array = RenderKitUtils.asArray(strings); assertSame(strings, array); }
public static String[] asArray(Object object) { if (object == null) { return null; } Class<?> componentType = object.getClass().getComponentType(); if (String.class.equals(componentType)) { return (String[]) object; } else if (componentType != null) { Object[] objects = (Object[]) object; String[] result = new String[objects.length]; for (int i = 0; i < objects.length; i++) { Object o = objects[i]; if (o == null) { continue; } result[i] = o.toString(); } return result; } else if (object instanceof Collection) { Collection<?> collection = (Collection<?>) object; String[] result = new String[collection.size()]; Iterator<?> iterator = collection.iterator(); for (int i = 0; i < result.length; i++) { Object next = iterator.next(); if (next == null) { continue; } result[i] = next.toString(); } return result; } else { String string = object.toString().trim(); String[] split = string.split("\\s*,\\s*"); return split; } }
RenderKitUtils { public static String[] asArray(Object object) { if (object == null) { return null; } Class<?> componentType = object.getClass().getComponentType(); if (String.class.equals(componentType)) { return (String[]) object; } else if (componentType != null) { Object[] objects = (Object[]) object; String[] result = new String[objects.length]; for (int i = 0; i < objects.length; i++) { Object o = objects[i]; if (o == null) { continue; } result[i] = o.toString(); } return result; } else if (object instanceof Collection) { Collection<?> collection = (Collection<?>) object; String[] result = new String[collection.size()]; Iterator<?> iterator = collection.iterator(); for (int i = 0; i < result.length; i++) { Object next = iterator.next(); if (next == null) { continue; } result[i] = next.toString(); } return result; } else { String string = object.toString().trim(); String[] split = string.split("\\s*,\\s*"); return split; } } }
RenderKitUtils { public static String[] asArray(Object object) { if (object == null) { return null; } Class<?> componentType = object.getClass().getComponentType(); if (String.class.equals(componentType)) { return (String[]) object; } else if (componentType != null) { Object[] objects = (Object[]) object; String[] result = new String[objects.length]; for (int i = 0; i < objects.length; i++) { Object o = objects[i]; if (o == null) { continue; } result[i] = o.toString(); } return result; } else if (object instanceof Collection) { Collection<?> collection = (Collection<?>) object; String[] result = new String[collection.size()]; Iterator<?> iterator = collection.iterator(); for (int i = 0; i < result.length; i++) { Object next = iterator.next(); if (next == null) { continue; } result[i] = next.toString(); } return result; } else { String string = object.toString().trim(); String[] split = string.split("\\s*,\\s*"); return split; } } private  RenderKitUtils(); }
RenderKitUtils { public static String[] asArray(Object object) { if (object == null) { return null; } Class<?> componentType = object.getClass().getComponentType(); if (String.class.equals(componentType)) { return (String[]) object; } else if (componentType != null) { Object[] objects = (Object[]) object; String[] result = new String[objects.length]; for (int i = 0; i < objects.length; i++) { Object o = objects[i]; if (o == null) { continue; } result[i] = o.toString(); } return result; } else if (object instanceof Collection) { Collection<?> collection = (Collection<?>) object; String[] result = new String[collection.size()]; Iterator<?> iterator = collection.iterator(); for (int i = 0; i < result.length; i++) { Object next = iterator.next(); if (next == null) { continue; } result[i] = next.toString(); } return result; } else { String string = object.toString().trim(); String[] split = string.split("\\s*,\\s*"); return split; } } private  RenderKitUtils(); static String[] asArray(Object object); static boolean shouldRenderAttribute(Object attributeValue); static String prefixAttributeName(String attributeName, boolean isXhtmlMode); static String prefixAttributeName(String attributeName, ResponseWriter responseWriter); static void renderAttribute(FacesContext facesContext, String attributeName, Object attributeValue); static Object getAttributeAndBehaviorsValue(FacesContext facesContext, UIComponent component,
            ComponentAttribute componentAttribute); static void renderAttributeAndBehaviors(FacesContext facesContext, UIComponent component,
            ComponentAttribute componentAttribute); static void renderPassThroughAttributesOptimized(FacesContext context, UIComponent component,
            Map<String, ComponentAttribute> knownAttributesMap); static void renderPassThroughAttributes(FacesContext context, UIComponent component,
            Map<String, ComponentAttribute> knownAttributesMap); static void renderPassThroughAttributes(FacesContext context, UIComponent component,
            Collection<ComponentAttribute> attributes); static String decodeBehaviors(FacesContext context, UIComponent component); static Attributes attributes(); static Attributes attributes(Enum<?>... attrs); static Attributes attributes(String... attrs); static void addToScriptHash(Map<String, Object> hash, String name, Object value); static void addToScriptHash(Map<String, Object> hash, String name, Object value, Object defaultValue); static void addToScriptHash(Map<String, Object> hash, String name, Object value, Object defaultValue,
            ScriptHashVariableWrapper wrapper); static void addToScriptHash(Map<String, Object> hash, FacesContext facesContext, UIComponent component,
            Attributes attributes, ScriptHashVariableWrapper wrapper); static String toScriptArgs(Object... objects); static String getResourcePath(FacesContext context, String library, String resourceName); static String getResourceURL(String url, FacesContext context); static Object getFirstNonEmptyAttribute(String attributeName, UIComponent component); static Object getFirstNonEmptyAttribute(String attributeName, UIComponent componentA, UIComponent componentB); static Object getFirstNonEmptyAttribute(String attributeName, UIComponent... components); static String getBehaviorSourceId(FacesContext facesContext); static boolean hasFacet(UIComponent component, String facetName); @SuppressWarnings("unchecked") static T evaluateAttribute(String attribute, UIComponent component, FacesContext context); }
RenderKitUtils { public static String[] asArray(Object object) { if (object == null) { return null; } Class<?> componentType = object.getClass().getComponentType(); if (String.class.equals(componentType)) { return (String[]) object; } else if (componentType != null) { Object[] objects = (Object[]) object; String[] result = new String[objects.length]; for (int i = 0; i < objects.length; i++) { Object o = objects[i]; if (o == null) { continue; } result[i] = o.toString(); } return result; } else if (object instanceof Collection) { Collection<?> collection = (Collection<?>) object; String[] result = new String[collection.size()]; Iterator<?> iterator = collection.iterator(); for (int i = 0; i < result.length; i++) { Object next = iterator.next(); if (next == null) { continue; } result[i] = next.toString(); } return result; } else { String string = object.toString().trim(); String[] split = string.split("\\s*,\\s*"); return split; } } private  RenderKitUtils(); static String[] asArray(Object object); static boolean shouldRenderAttribute(Object attributeValue); static String prefixAttributeName(String attributeName, boolean isXhtmlMode); static String prefixAttributeName(String attributeName, ResponseWriter responseWriter); static void renderAttribute(FacesContext facesContext, String attributeName, Object attributeValue); static Object getAttributeAndBehaviorsValue(FacesContext facesContext, UIComponent component,
            ComponentAttribute componentAttribute); static void renderAttributeAndBehaviors(FacesContext facesContext, UIComponent component,
            ComponentAttribute componentAttribute); static void renderPassThroughAttributesOptimized(FacesContext context, UIComponent component,
            Map<String, ComponentAttribute> knownAttributesMap); static void renderPassThroughAttributes(FacesContext context, UIComponent component,
            Map<String, ComponentAttribute> knownAttributesMap); static void renderPassThroughAttributes(FacesContext context, UIComponent component,
            Collection<ComponentAttribute> attributes); static String decodeBehaviors(FacesContext context, UIComponent component); static Attributes attributes(); static Attributes attributes(Enum<?>... attrs); static Attributes attributes(String... attrs); static void addToScriptHash(Map<String, Object> hash, String name, Object value); static void addToScriptHash(Map<String, Object> hash, String name, Object value, Object defaultValue); static void addToScriptHash(Map<String, Object> hash, String name, Object value, Object defaultValue,
            ScriptHashVariableWrapper wrapper); static void addToScriptHash(Map<String, Object> hash, FacesContext facesContext, UIComponent component,
            Attributes attributes, ScriptHashVariableWrapper wrapper); static String toScriptArgs(Object... objects); static String getResourcePath(FacesContext context, String library, String resourceName); static String getResourceURL(String url, FacesContext context); static Object getFirstNonEmptyAttribute(String attributeName, UIComponent component); static Object getFirstNonEmptyAttribute(String attributeName, UIComponent componentA, UIComponent componentB); static Object getFirstNonEmptyAttribute(String attributeName, UIComponent... components); static String getBehaviorSourceId(FacesContext facesContext); static boolean hasFacet(UIComponent component, String facetName); @SuppressWarnings("unchecked") static T evaluateAttribute(String attribute, UIComponent component, FacesContext context);  }