\r
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;\r
\r
+/**\r
+ * UI utilities \r
+ * \r
+ * @author Niels Erik\r
+ *\r
+ */\r
@Named("pzui")\r
@ApplicationScoped\r
public class UiUtils {\r
* @param string\r
* @return\r
*/\r
- public static String quotes(String string) {\r
+ public static String quote(String string) {\r
return "\"" + string + "\"";\r
}\r
\r
+ /**\r
+ * Gets at most maxElements elements of the given elementName\r
+ * @param container The parent element containing the elements to retrieve\r
+ * @param elementName The name of the element(s) to retrieve\r
+ * @param maxElements Maximum number of elements to retrieve\r
+ * @return At most maxElements data objects of the given type\r
+ */\r
public static List<ResponseDataObject> getMaxNumElements(ResponseDataObject container, String elementName, int maxElements) {\r
if (container.getElements(elementName)!=null) {\r
int elementCount = container.getElements(elementName).size();\r
return container.getElements(elementName);\r
}\r
\r
+ /**\r
+ * Gets at most maxElements data objects, up to a total string length of maxTotalValueLength\r
+ * @param container The parent element containing the elements to retrieve\r
+ * @param elementName The name of the element(s) to retrieve\r
+ * @param maxElements Maximum number of elements to retrieve\r
+ * @param maxTotalValueLength The maximum total string length of the values of the elements retrieved\r
+ * @param hardLimit If set to true, the list will be cut of at or below the total string length, if false, the list\r
+ * will contain the first element that exceeds the length limit - for instance thus guaranteeing \r
+ * that at least one of the elements will be returned, no matter it's length. \r
+ * @return Delimited list of elements\r
+ */\r
public List<ResponseDataObject> getMaxElements(ResponseDataObject container, String elementName, int maxElements, int maxTotalValueLength, boolean hardLimit) {\r
List<ResponseDataObject> maxNumList = getMaxNumElements(container,elementName,maxElements);\r
if (maxNumList!=null) {\r