@Nonnull @Override public String getDataType() { return getData().getDataType().getTypeString(); }
@Nonnull @Override public String getExportedType() { final FragmentData value = getData(); // Mimetype for text-based datatypes String type = value.getContentType(); // Datatype for non text-based datatypes if (type == null) { type = value.getDataType().getTypeString(); } return type; }
@Override public boolean isMultiLine() { String contentType = getContentType(); // a text element is defined as a single-valued element with a certain content type (e.g. "text/plain", // "text/html", "text/x-markdown", potentially others) return contentType != null && contentType.startsWith("text/") && !getData().getDataType().isMultiValue(); }
@Nonnull @Override protected List<ContentElement> getItems(@Nonnull ContentFragment fragment, @Nonnull SlingHttpServletRequest request) { Config config = getConfig(request); ValueMap map = getComponentValueMap(config, request); String textOnlyParam = request.getParameter(PARAM_AND_PN_DISPLAY_MODE); boolean textOnly = map != null && map.containsKey(PARAM_AND_PN_DISPLAY_MODE) && map.get(PARAM_AND_PN_DISPLAY_MODE, "multi").equals(SINGLE_TEXT); if (textOnlyParam != null) { textOnly = textOnlyParam.equals(SINGLE_TEXT); } if (textOnly) { Iterator<ContentElement> elementIterator = fragment.getElements(); List<ContentElement> elementList = new ArrayList<ContentElement>(); while (elementIterator.hasNext()) { ContentElement element = elementIterator.next(); String contentType = element.getValue().getContentType(); if (contentType != null && contentType.startsWith("text/") && !element.getValue().getDataType().isMultiValue()) { elementList.add(element); } } return elementList; } return IteratorUtils.toList(fragment.getElements()); }