code
stringlengths
73
34.1k
label
stringclasses
1 value
private void updateRegion() { actMessage.setVisible(false); String state = (String) stateSelector.getSelected(); if (STATE_ACT.equals(state)) { actMessage.setVisible(true); regionSelector.setOptions(new String[]{null, "Belconnen", "City", "Woden"}); } else if (STATE_NSW.equals(state)) { regionSelecto...
java
public static InterceptorComponent replaceInterceptor(final Class match, final InterceptorComponent replacement, final InterceptorComponent chain) { if (chain == null) { return null; } InterceptorComponent current = chain; InterceptorComponent previous = null; InterceptorComponent updatedChain = null; ...
java
protected static String render(final WebComponent component) { StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); component.paint(new WebXmlRenderContext(printWriter)); printWriter.flush(); String content = stringWriter.toString(); return content; }
java
public void attachUI(final WComponent ui) { if (backing == null || backing instanceof WComponent) { backing = ui; } else if (backing instanceof InterceptorComponent) { ((InterceptorComponent) backing).attachUI(ui); } else { throw new IllegalStateException( "Unable to attachUI. Unknown type of WebCom...
java
public void setAlignment(final int col, final Alignment alignment) { columnAlignments[col] = alignment == null ? Alignment.LEFT : alignment; }
java
public static void copy(final InputStream in, final OutputStream out) throws IOException { copy(in, out, DEFAULT_BUFFER_SIZE); }
java
public static void copy(final InputStream in, final OutputStream out, final int bufferSize) throws IOException { final byte[] buf = new byte[bufferSize]; int bytesRead = in.read(buf); while (bytesRead != -1) { out.write(buf, 0, bytesRead); bytesRead = in.read(buf); } out.flush(); }
java
public static void safeClose(final Closeable stream) { if (stream != null) { try { stream.close(); } catch (IOException e) { LOG.error("Failed to close resource stream", e); } } }
java
public void applySettings() { messageList.clear(); messageList.add(""); for (int i = 1; messageBox.getMessages().size() >= i; i++) { messageList.add(String.valueOf(i)); } selRemove.setOptions(messageList); selRemove.resetData(); btnRemove.setDisabled(messageList.isEmpty()); btnRemoveAll.setDisable...
java
@Override public void escape() throws IOException { LOG.debug("...ContentEscape escape()"); if (contentAccess == null) { LOG.warn("No content to output"); } else { String mimeType = contentAccess.getMimeType(); Response response = getResponse(); response.setContentType(mimeType); if (isCacheabl...
java
public Embed createEmbed(String url) { return getResourceFactory().getApiResource("/embed/") .entity(new EmbedCreate(url), MediaType.APPLICATION_JSON_TYPE) .post(Embed.class); }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WField field = (WField) component; XmlStringBuilder xml = renderContext.getWriter(); int inputWidth = field.getInputWidth(); xml.appendTagOpen("ui:field"); xml.appendAttribute("id", component.getId()); xm...
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("hr"); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendEnd(); }
java
private void addMenuItem(final WComponent parent, final String text, final WText selectedMenuText) { WMenuItem menuItem = new WMenuItem(text, new ExampleMenuAction(selectedMenuText)); menuItem.setActionObject(text); if (parent instanceof WSubMenu) { ((WSubMenu) parent).add(menuItem); } else { ((WMenuIt...
java
private WMenuItem createImageMenuItem(final String resource, final String desc, final String cacheKey, final WText selectedMenuText) { WImage image = new WImage(resource, desc); image.setCacheKey(cacheKey); WDecoratedLabel label = new WDecoratedLabel(image, new WText(desc), null); WMenuItem menuItem = new...
java
@Deprecated public void setPaddingChar(final char paddingChar) { if (Character.isDigit(paddingChar)) { throw new IllegalArgumentException("Padding character should not be a digit."); } getOrCreateComponentModel().paddingChar = paddingChar; }
java
@Override protected void validateComponent(final List<Diagnostic> diags) { if (isValidDate()) { super.validateComponent(diags); } else { diags.add(createErrorDiagnostic(getComponentModel().errorMessage, this)); } }
java
public void setDate(final Date date) { if (date == null) { setPartialDate(null, null, null); } else { Calendar cal = Calendar.getInstance(); cal.setTime(date); Integer year = cal.get(Calendar.YEAR); Integer month = cal.get(Calendar.MONTH) + 1; Integer day = cal.get(Calendar.DAY_OF_MONTH); setPa...
java
public Integer getDay() { String dateValue = getValue(); if (dateValue != null && dateValue.length() == DAY_END) { return parseDateComponent(dateValue.substring(DAY_START, DAY_END), getPaddingChar()); } else { return null; } }
java
public Integer getMonth() { String dateValue = getValue(); if (dateValue != null && dateValue.length() >= MONTH_END) { return parseDateComponent(dateValue.substring(MONTH_START, MONTH_END), getPaddingChar()); } else { return null; } }
java
public Integer getYear() { String dateValue = getValue(); if (dateValue != null && dateValue.length() >= YEAR_END) { return parseDateComponent(dateValue.substring(YEAR_START, YEAR_END), getPaddingChar()); } else { return null; } }
java
public Date getDate() { if (getYear() != null && getMonth() != null && getDay() != null) { return DateUtilities.createDate(getDay(), getMonth(), getYear()); } return null; }
java
private boolean isValidCharacters(final String component, final char padding) { // Check the component is either all padding chars or all digit chars boolean paddingChars = false; boolean digitChars = false; for (int i = 0; i < component.length(); i++) { char chr = component.charAt(i); // Padding if (c...
java
public static String getPathToRoot(final WComponent component) { StringBuffer buf = new StringBuffer(); for (WComponent node = component; node != null; node = node.getParent()) { if (buf.length() != 0) { buf.insert(0, '\n'); } buf.insert(0, node.getClass().getName()); } return buf.toString(); }
java
public static <T> T getAncestorOfClass(final Class<T> clazz, final WComponent comp) { if (comp == null || clazz == null) { return null; } WComponent parent = comp.getParent(); while (parent != null) { if (clazz.isInstance(parent)) { return (T) parent; } parent = parent.getParent(); } retur...
java
public static WComponent getTop(final WComponent comp) { WComponent top = comp; for (WComponent parent = top.getParent(); parent != null; parent = parent.getParent()) { top = parent; } return top; }
java
public static String encodeUrl(final String urlStr) { if (Util.empty(urlStr)) { return urlStr; } // Percent Encode String percentEncode = percentEncodeUrl(urlStr); // XML Enocde return encode(percentEncode); }
java
public static String percentEncodeUrl(final String urlStr) { if (Util.empty(urlStr)) { return urlStr; } try { // Avoid double encoding String decode = URIUtil.decode(urlStr); URI uri = new URI(decode, false); return uri.getEscapedURIReference(); } catch (Exception e) { return urlStr; } }
java
public static String escapeForUrl(final String input) { if (input == null || input.length() == 0) { return input; } final StringBuilder buffer = new StringBuilder(input.length() * 2); // worst-case char[] characters = input.toCharArray(); for (int i = 0, len = input.length(); i < len; ++i) { final cha...
java
public static String encode(final String input) { if (input == null || input.length() == 0) { return input; } return ENCODE.translate(input); }
java
public static String decode(final String encoded) { if (encoded == null || encoded.length() == 0 || encoded.indexOf('&') == -1) { return encoded; } return DECODE.translate(encoded); }
java
public static String encodeBrackets(final String input) { if (input == null || input.length() == 0) { // For performance reasons don't use Util.empty return input; } return ENCODE_BRACKETS.translate(input); }
java
public static String decodeBrackets(final String input) { if (input == null || input.length() == 0) { // For performance reasons don't use Util.empty return input; } return DECODE_BRACKETS.translate(input); }
java
public static String doubleEncodeBrackets(final String input) { if (input == null || input.length() == 0) { // For performance reasons don't use Util.empty return input; } return DOUBLE_ENCODE_BRACKETS.translate(input); }
java
public static String doubleDecodeBrackets(final String input) { if (input == null || input.length() == 0) { // For performance reasons don't use Util.empty return input; } return DOUBLE_DECODE_BRACKETS.translate(input); }
java
public static void appendGetParamForJavascript(final String key, final String value, final StringBuffer vars, final boolean existingVars) { vars.append(existingVars ? '&' : '?'); vars.append(key).append('=').append(WebUtilities.escapeForUrl(value)); }
java
public static String generateRandom() { long next = ATOMIC_COUNT.incrementAndGet(); StringBuffer random = new StringBuffer(); random.append(new Date().getTime()).append('-').append(next); return random.toString(); }
java
public static boolean isAncestor(final WComponent component1, final WComponent component2) { for (WComponent parent = component2.getParent(); parent != null; parent = parent.getParent()) { if (parent == component1) { return true; } } return false; }
java
public static UIContext getContextForComponent(final WComponent component) { // Start with the current Context UIContext result = UIContextHolder.getCurrent(); // Go through the contexts until we find the component while (result instanceof SubUIContext && !((SubUIContext) result).isInContext(component)) { re...
java
public static ComponentWithContext getComponentById(final String id, final boolean visibleOnly) { UIContext uic = UIContextHolder.getCurrent(); WComponent root = uic.getUI(); ComponentWithContext comp = TreeUtil.getComponentWithContextForId(root, id, visibleOnly); return comp; }
java
public static UIContext findClosestContext(final String id) { UIContext uic = UIContextHolder.getCurrent(); WComponent root = uic.getUI(); UIContext closest = TreeUtil.getClosestContextForId(root, id); return closest; }
java
public static void updateBeanValue(final WComponent component, final boolean visibleOnly) { // Do not process if component is invisble and ignore visible is true. Will ignore entire branch from this point. if (!component.isVisible() && visibleOnly) { return; } if (component instanceof WBeanComponent) { (...
java
public static String render(final Request request, final WComponent component) { boolean needsContext = UIContextHolder.getCurrent() == null; if (needsContext) { UIContextHolder.pushContext(new UIContextImpl()); } try { StringWriter buffer = new StringWriter(); component.preparePaint(request); tr...
java
public static String renderWithTransformToHTML(final Request request, final WComponent component, final boolean includePageShell) { // Setup a context (if needed) boolean needsContext = UIContextHolder.getCurrent() == null; if (needsContext) { UIContextHolder.pushContext(new UIContextImpl()); } try { ...
java
public static String getContentType(final String fileName) { if (Util.empty(fileName)) { return ConfigurationProperties.getDefaultMimeType(); } String mimeType = null; if (fileName.lastIndexOf('.') > -1) { String suffix = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase(); mimeType = Co...
java
public static NamingContextable getParentNamingContext(final WComponent component) { if (component == null) { return null; } WComponent child = component; NamingContextable parent = null; while (true) { NamingContextable naming = WebUtilities.getAncestorOfClass(NamingContextable.class, child); ...
java
private void updateBeanValueForColumnInRow(final WTableRowRenderer rowRenderer, final UIContext rowContext, final List<Integer> rowIndex, final int col, final TableModel model) { // The actual component is wrapped in a renderer wrapper, so we have to fetch it from that WComponent renderer = ((Container) rowRe...
java
private void updateBeanValueForRowRenderer(final WTableRowRenderer rowRenderer, final UIContext rowContext, final Class<? extends WComponent> expandRenderer) { Container expandWrapper = (Container) rowRenderer. getExpandedTreeNodeRenderer(expandRenderer); if (expandWrapper == null) { return; } //...
java
public void setSeparatorType(final SeparatorType separatorType) { getOrCreateComponentModel().separatorType = separatorType == null ? SeparatorType.NONE : separatorType; }
java
public void setStripingType(final StripingType stripingType) { getOrCreateComponentModel().stripingType = stripingType == null ? StripingType.NONE : stripingType; }
java
public void setPaginationMode(final PaginationMode paginationMode) { getOrCreateComponentModel().paginationMode = paginationMode == null ? PaginationMode.NONE : paginationMode; }
java
public void setPaginationLocation(final PaginationLocation location) { getOrCreateComponentModel().paginationLocation = location == null ? PaginationLocation.AUTO : location; }
java
public void setType(final Type type) { getOrCreateComponentModel().type = type == null ? Type.TABLE : type; }
java
public void setSelectAllMode(final SelectAllType selectAllMode) { getOrCreateComponentModel().selectAllMode = selectAllMode == null ? SelectAllType.TEXT : selectAllMode; }
java
public List<WButton> getActions() { final int numActions = actions.getChildCount(); List<WButton> buttons = new ArrayList<>(numActions); for (int i = 0; i < numActions; i++) { WButton button = (WButton) actions.getChildAt(i); buttons.add(button); } return Collections.unmodifiableList(buttons); }
java
public void addActionConstraint(final WButton button, final ActionConstraint constraint) { if (button.getParent() != actions) { throw new IllegalArgumentException( "Can only add a constraint to a button which is in this table's actions"); } getOrCreateComponentModel().addActionConstraint(button, constrai...
java
public List<ActionConstraint> getActionConstraints(final WButton button) { List<ActionConstraint> constraints = getComponentModel().actionConstraints.get(button); return constraints == null ? null : Collections.unmodifiableList(constraints); }
java
private void handleSortRequest(final Request request) { String sortColStr = request.getParameter(getId() + ".sort"); String sortDescStr = request.getParameter(getId() + ".sortDesc"); if (sortColStr != null) { if ("".equals(sortColStr)) { // Reset sort setSort(-1, false); getOrCreateComponentModel(...
java
public void sort(final int sortCol, final boolean sortAsc) { int[] rowIndexMappings = getTableModel().sort(sortCol, sortAsc); getOrCreateComponentModel().rowIndexMapping = rowIndexMappings; setSort(sortCol, sortAsc); if (rowIndexMappings == null) { // There's no way to correlate the previously selected row...
java
@SuppressWarnings("checkstyle:parameternumber") private void calcChildrenRowIds(final List<RowIdWrapper> rows, final RowIdWrapper row, final TableModel model, final RowIdWrapper parent, final Set<?> expanded, final ExpandMode mode, final boolean forUpdate, final boolean editable) { // Add row rows.add(row...
java
@Override public void paint(final RenderContext renderContext) { super.paint(renderContext); UIContext uic = UIContextHolder.getCurrent(); if (LOG.isDebugEnabled()) { UIContextDebugWrapper debugWrapper = new UIContextDebugWrapper(uic); LOG.debug("Session usage after paint:\n" + debugWrapper); } LOG.d...
java
public void setButtonColumns(final int numColumns) { if (numColumns < 1) { throw new IllegalArgumentException("Must have one or more columns"); } CheckBoxSelectModel model = getOrCreateComponentModel(); model.numColumns = numColumns; model.layout = numColumns == 1 ? LAYOUT_STACKED : LAYOUT_COLUMNS; }
java
protected void doHandleAjaxRefresh() { final Action action = getRefreshAction(); if (action == null) { return; } final ActionEvent event = new ActionEvent(this, AJAX_REFRESH_ACTION_COMMAND, getAjaxFilter()); Runnable later = new Runnable() { @Override public void run() { action.execute(event); ...
java
public List<String> getSuggestions() { // Lookup table Object table = getLookupTable(); if (table == null) { SuggestionsModel model = getComponentModel(); List<String> suggestions = model.getSuggestions(); return suggestions == null ? Collections.EMPTY_LIST : suggestions; } else { List<?> lookupSug...
java
public void setSuggestions(final List<String> suggestions) { SuggestionsModel model = getOrCreateComponentModel(); model.setSuggestions(suggestions); }
java
public static String validateXMLAgainstSchema(final String xml) { // Validate XML against schema if (xml != null && !xml.equals("")) { // Wrap XML with a root element (if required) String testXML = wrapXMLInRootElement(xml); try { // Create SAX Parser Factory SAXParserFactory spf = SAXParserFactory...
java
public static String wrapXMLInRootElement(final String xml) { // The XML may not need to be wrapped. if (xml.startsWith("<?xml") || xml.startsWith("<!DOCTYPE")) { return xml; } else { // ENTITY definition required for NBSP. // ui namepsace required for xml theme. return XMLUtil.XML_DECLARATION + "<ui:...
java
public static void registerResource(final InternalResource resource) { String resourceName = resource.getResourceName(); if (!RESOURCES.containsKey(resourceName)) { RESOURCES.put(resourceName, resource); RESOURCE_CACHE_KEYS.put(resourceName, computeHash(resource)); } }
java
public static String computeHash(final InternalResource resource) { final int bufferSize = 1024; try (InputStream stream = resource.getStream()) { if (stream == null) { return null; } // Compute CRC-32 checksum // TODO: Is a 1 in 2^32 chance of a cache bust fail good enough? // Checksum checksu...
java
@Override protected void doReplace(final String search, final Writer backing) { WComponent component = componentsByKey.get(search); UIContextHolder.pushContext(uic); try { component.paint(new WebXmlRenderContext((PrintWriter) backing)); } finally { UIContextHolder.popContext(); } }
java
protected Object getTopRowBean(final List<Integer> row) { // Get root level List<?> lvl = getBeanList(); if (lvl == null || lvl.isEmpty()) { return null; } // Get root row bean (ie top level) int rowIdx = row.get(0); Object rowData = lvl.get(rowIdx); return rowData; }
java
protected Object getBeanPropertyValue(final String property, final Object bean) { if (bean == null) { return null; } if (".".equals(property)) { return bean; } try { Object data = PropertyUtils.getProperty(bean, property); return data; } catch (Exception e) { LOG.error("Failed to get bean p...
java
protected void setBeanPropertyValue(final String property, final Object bean, final Serializable value) { if (bean == null) { return; } if (".".equals(property)) { LOG.error("Set of entire bean is not supported by this model"); return; } try { PropertyUtils.setProperty(bean, property, value); ...
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WDataTable table = (WDataTable) component; XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("ui:table"); xml.appendAttribute("id", component.getId()); xml.appendOptionalAttribute("track",...
java
private void paintPaginationElement(final WDataTable table, final XmlStringBuilder xml) { TableDataModel model = table.getDataModel(); xml.appendTagOpen("ui:pagination"); if (model instanceof TreeTableDataModel) { // For tree tables, we only include top-level nodes for pagination. TreeNode firstNode = (...
java
public void setAction(final Action action) { MenuItemModel model = getOrCreateComponentModel(); model.action = action; model.url = null; }
java
public void setUrl(final String url) { MenuItemModel model = getOrCreateComponentModel(); model.url = url; model.action = null; }
java
public void setMessage(final String message, final Serializable... args) { getOrCreateComponentModel().message = I18nUtilities.asMessage(message, args); }
java
@Override public void handleRequest(final Request request) { if (isDisabled()) { // Protect against client-side tampering of disabled/read-only fields. return; } if (isMenuPresent(request)) { String requestValue = request.getParameter(getId()); if (requestValue != null) { // Only process on a P...
java
protected boolean isMenuPresent(final Request request) { WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, this); if (menu != null) { return menu.isPresent(request); } return false; }
java
@Deprecated @Override public void setEditable(final boolean editable) { setType(editable ? DropdownType.COMBO : DropdownType.NATIVE); }
java
private void buildUI() { add(new WSkipLinks()); // the application header add(headerPanel); headerPanel.add(new UtilityBar()); headerPanel.add(new WHeading(HeadingLevel.H1, "WComponents")); // mainPanel holds the menu and the actual example. add(mainPanel); mainPanel.add(menuPanel); mainPanel.add(ex...
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WPopup popup = (WPopup) component; XmlStringBuilder xml = renderContext.getWriter(); int width = popup.getWidth(); int height = popup.getHeight(); String targetWindow = popup.getTargetWindow(); xml.append...
java
public static ObjectGraphNode dump(final Object obj) { ObjectGraphDump dump = new ObjectGraphDump(false, true); ObjectGraphNode root = new ObjectGraphNode(++dump.nodeCount, null, obj.getClass().getName(), obj); dump.visit(root); return root; }
java
private void visit(final ObjectGraphNode currentNode) { Object currentValue = currentNode.getValue(); if (currentValue == null || (currentValue instanceof java.lang.ref.SoftReference) || currentNode.isPrimitive() || currentNode.isSimpleType()) { return; } if (isObjectVisited(currentNode)) { Obje...
java
private void visitComplexType(final ObjectGraphNode node) { Field[] fields = getAllInstanceFields(node.getValue()); for (int i = 0; i < fields.length; i++) { Object fieldValue = readField(fields[i], node.getValue()); String fieldType = fields[i].getType().getName(); ObjectGraphNode childNode = new Object...
java
private void visitComplexTypeWithDiff(final ObjectGraphNode node, final Object otherInstance) { if (otherInstance == null) { // Nothing to compare against, just use the default visit visitComplexType(node); } else { Field[] fields = getAllInstanceFields(node.getValue()); for (int i = 0; i < fields.leng...
java
private void visitComponentModel(final ObjectGraphNode node) { ComponentModel model = (ComponentModel) node.getValue(); ComponentModel sharedModel = null; List<Field> fieldList = ReflectionUtil.getAllFields(node.getValue(), true, false); Field[] fields = fieldList.toArray(new Field[fieldList.size()]); for (...
java
private Object readField(final Field field, final Object obj) { try { return field.get(obj); } catch (IllegalAccessException e) { // Should not happen as we've called Field.setAccessible(true). LOG.error("Failed to read " + field.getName() + " of " + obj.getClass().getName(), e); } return null; }
java
private void visitArray(final ObjectGraphNode node) { if (node.getValue() instanceof Object[]) { Object[] array = (Object[]) node.getValue(); for (int i = 0; i < array.length; i++) { String entryType = array[i] == null ? Object.class.getName() : array[i].getClass(). getName(); ObjectGraphNode ch...
java
private void visitList(final ObjectGraphNode node) { int index = 0; for (Iterator i = ((List) node.getValue()).iterator(); i.hasNext();) { Object entry = i.next(); String entryType = entry == null ? Object.class.getName() : entry.getClass().getName(); ObjectGraphNode childNode = new ObjectGraphNode(++nod...
java
private void summariseNode(final ObjectGraphNode node) { int size = node.getSize(); node.removeAll(); node.setSize(size); }
java
private void visitMap(final ObjectGraphNode node) { Map map = (Map) node.getValue(); for (Iterator i = map.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); Object key = entry.getKey(); if (key != null) { ObjectGraphNode keyNode = new ObjectGraphNode(++nodeCount, "key", k...
java
private Field[] getAllInstanceFields(final Object obj) { Field[] fields = instanceFieldsByClass.get(obj.getClass()); if (fields == null) { List<Field> fieldList = ReflectionUtil. getAllFields(obj, excludeStatic, excludeTransient); fields = fieldList.toArray(new Field[fieldList.size()]); instanceFiel...
java
private static void renderHelper(final WebXmlRenderContext renderContext, final Diagnosable component, final List<Diagnostic> diags, final int severity) { if (diags.isEmpty()) { return; } XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen(TAG_NAME); xml.appendAttribute("id", "_w...
java
public static void renderDiagnostics(final Diagnosable component, final WebXmlRenderContext renderContext) { List<Diagnostic> diags = component.getDiagnostics(Diagnostic.ERROR); if (diags != null) { renderHelper(renderContext, component, diags, Diagnostic.ERROR); } diags = component.getDiagnostics(Diagnostic...
java
private void handleWarpToTheFuture(final UIContext uic) { // Increment the step counter StepCountUtil.incrementSessionStep(uic); // Get component at end of chain WComponent application = getUI(); // Call handle step error on WApplication if (application instanceof WApplication) { LOG.warn("The handleS...
java
private void handleRenderRedirect(final PrintWriter writer) { UIContext uic = UIContextHolder.getCurrent(); // Redirect user to error page LOG.warn("User will be redirected to " + redirectUrl); // Setup response with redirect getResponse().setContentType(WebUtilities.CONTENT_TYPE_XML); writer.write(XMLUtil...
java
private String buildApplicationUrl(final UIContext uic) { Environment env = uic.getEnvironment(); return env.getPostPath(); }
java
public static Serializable asMessage(final String text, final Serializable... args) { if (text == null) { return null; } else if (args == null || args.length == 0) { return text; } else { return new Message(text, args); } }
java