id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
139,200
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WHiddenCommentRenderer.java
WHiddenCommentRenderer.doRender
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WHiddenComment hiddenComponent = (WHiddenComment) component; XmlStringBuilder xml = renderContext.getWriter(); String hiddenText = hiddenComponent.getText(); if (!Util.empty(hiddenText)) { xml.appendTag("ui:comment"); xml.appendEscaped(hiddenText); xml.appendEndTag("ui:comment"); } }
java
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { WHiddenComment hiddenComponent = (WHiddenComment) component; XmlStringBuilder xml = renderContext.getWriter(); String hiddenText = hiddenComponent.getText(); if (!Util.empty(hiddenText)) { xml.appendTag("ui:comment"); xml.appendEscaped(hiddenText); xml.appendEndTag("ui:comment"); } }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "WHiddenComment", "hiddenComponent", "=", "(", "WHiddenComment", ")", "component", ";", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "String", "hiddenText", "=", "hiddenComponent", ".", "getText", "(", ")", ";", "if", "(", "!", "Util", ".", "empty", "(", "hiddenText", ")", ")", "{", "xml", ".", "appendTag", "(", "\"ui:comment\"", ")", ";", "xml", ".", "appendEscaped", "(", "hiddenText", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:comment\"", ")", ";", "}", "}" ]
Paints the given WHiddenComment. @param component the WHiddenComment to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WHiddenComment", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WHiddenCommentRenderer.java#L24-L36
139,201
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleTableModel.java
SimpleTableModel.setComparator
public void setComparator(final int col, final Comparator comparator) { synchronized (this) { if (comparators == null) { comparators = new HashMap<>(); } } if (comparator == null) { comparators.remove(col); } else { comparators.put(col, comparator); } }
java
public void setComparator(final int col, final Comparator comparator) { synchronized (this) { if (comparators == null) { comparators = new HashMap<>(); } } if (comparator == null) { comparators.remove(col); } else { comparators.put(col, comparator); } }
[ "public", "void", "setComparator", "(", "final", "int", "col", ",", "final", "Comparator", "comparator", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "comparators", "==", "null", ")", "{", "comparators", "=", "new", "HashMap", "<>", "(", ")", ";", "}", "}", "if", "(", "comparator", "==", "null", ")", "{", "comparators", ".", "remove", "(", "col", ")", ";", "}", "else", "{", "comparators", ".", "put", "(", "col", ",", "comparator", ")", ";", "}", "}" ]
Sets the comparator for the given column, to enable sorting. @param col the column to set the comparator on. @param comparator the comparator to set.
[ "Sets", "the", "comparator", "for", "the", "given", "column", "to", "enable", "sorting", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleTableModel.java#L86-L98
139,202
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDropdownSubmitOnChangeExample.java
WDropdownSubmitOnChangeExample.updateRegion
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)) { regionSelector.setOptions( new String[]{null, "Hunter", "Riverina", "Southern Tablelands"}); } else if (STATE_VIC.equals(state)) { regionSelector.setOptions( new String[]{null, "Gippsland", "Melbourne", "Mornington Peninsula"}); } else { regionSelector.setOptions(new Object[]{null}); } }
java
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)) { regionSelector.setOptions( new String[]{null, "Hunter", "Riverina", "Southern Tablelands"}); } else if (STATE_VIC.equals(state)) { regionSelector.setOptions( new String[]{null, "Gippsland", "Melbourne", "Mornington Peninsula"}); } else { regionSelector.setOptions(new Object[]{null}); } }
[ "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", ")", ")", "{", "regionSelector", ".", "setOptions", "(", "new", "String", "[", "]", "{", "null", ",", "\"Hunter\"", ",", "\"Riverina\"", ",", "\"Southern Tablelands\"", "}", ")", ";", "}", "else", "if", "(", "STATE_VIC", ".", "equals", "(", "state", ")", ")", "{", "regionSelector", ".", "setOptions", "(", "new", "String", "[", "]", "{", "null", ",", "\"Gippsland\"", ",", "\"Melbourne\"", ",", "\"Mornington Peninsula\"", "}", ")", ";", "}", "else", "{", "regionSelector", ".", "setOptions", "(", "new", "Object", "[", "]", "{", "null", "}", ")", ";", "}", "}" ]
Updates the options present in the region selector, depending on the state selector's value.
[ "Updates", "the", "options", "present", "in", "the", "region", "selector", "depending", "on", "the", "state", "selector", "s", "value", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WDropdownSubmitOnChangeExample.java#L90-L107
139,203
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/InterceptorComponent.java
InterceptorComponent.replaceInterceptor
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; while (updatedChain == null) { if (match.isInstance(current)) { // Found the interceptor that needs to be replaced. replacement.setBackingComponent(current.getBackingComponent()); if (previous == null) { updatedChain = replacement; } else { previous.setBackingComponent(replacement); updatedChain = chain; } } else { previous = current; WebComponent next = current.getBackingComponent(); if (next instanceof InterceptorComponent) { current = (InterceptorComponent) next; } else { // Reached the end of the chain. No replacement done. updatedChain = chain; } } } return updatedChain; }
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; while (updatedChain == null) { if (match.isInstance(current)) { // Found the interceptor that needs to be replaced. replacement.setBackingComponent(current.getBackingComponent()); if (previous == null) { updatedChain = replacement; } else { previous.setBackingComponent(replacement); updatedChain = chain; } } else { previous = current; WebComponent next = current.getBackingComponent(); if (next instanceof InterceptorComponent) { current = (InterceptorComponent) next; } else { // Reached the end of the chain. No replacement done. updatedChain = chain; } } } return updatedChain; }
[ "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", ";", "while", "(", "updatedChain", "==", "null", ")", "{", "if", "(", "match", ".", "isInstance", "(", "current", ")", ")", "{", "// Found the interceptor that needs to be replaced.", "replacement", ".", "setBackingComponent", "(", "current", ".", "getBackingComponent", "(", ")", ")", ";", "if", "(", "previous", "==", "null", ")", "{", "updatedChain", "=", "replacement", ";", "}", "else", "{", "previous", ".", "setBackingComponent", "(", "replacement", ")", ";", "updatedChain", "=", "chain", ";", "}", "}", "else", "{", "previous", "=", "current", ";", "WebComponent", "next", "=", "current", ".", "getBackingComponent", "(", ")", ";", "if", "(", "next", "instanceof", "InterceptorComponent", ")", "{", "current", "=", "(", "InterceptorComponent", ")", "next", ";", "}", "else", "{", "// Reached the end of the chain. No replacement done.", "updatedChain", "=", "chain", ";", "}", "}", "}", "return", "updatedChain", ";", "}" ]
Utility method for replacing an individual interceptor within an existing chain. @param match the type of the interceptor to be replaced. @param replacement the new interceptor to be used as a replacement. @param chain the existing interceptor chain in which the replacement will take place. @return the modified interceptor chain. If no match was found, the existing interceptor chain is returned unchanged.
[ "Utility", "method", "for", "replacing", "an", "individual", "interceptor", "within", "an", "existing", "chain", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/InterceptorComponent.java#L95-L129
139,204
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/InterceptorComponent.java
InterceptorComponent.render
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
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; }
[ "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", ";", "}" ]
Renders the given component to a web-XML String and returns it. This occurs outside the context of a Servlet. @param component the component to render. @return the rendered output as a String.
[ "Renders", "the", "given", "component", "to", "a", "web", "-", "XML", "String", "and", "returns", "it", ".", "This", "occurs", "outside", "the", "context", "of", "a", "Servlet", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/InterceptorComponent.java#L198-L205
139,205
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/InterceptorComponent.java
InterceptorComponent.attachUI
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 WebComponent encountered. " + backing. getClass().getName()); } }
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 WebComponent encountered. " + backing. getClass().getName()); } }
[ "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 WebComponent encountered. \"", "+", "backing", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "}" ]
Add the WComponent to the end of the interceptor chain. @param ui the WComponent to add.
[ "Add", "the", "WComponent", "to", "the", "end", "of", "the", "interceptor", "chain", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/InterceptorComponent.java#L227-L237
139,206
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/ColumnLayout.java
ColumnLayout.setAlignment
public void setAlignment(final int col, final Alignment alignment) { columnAlignments[col] = alignment == null ? Alignment.LEFT : alignment; }
java
public void setAlignment(final int col, final Alignment alignment) { columnAlignments[col] = alignment == null ? Alignment.LEFT : alignment; }
[ "public", "void", "setAlignment", "(", "final", "int", "col", ",", "final", "Alignment", "alignment", ")", "{", "columnAlignments", "[", "col", "]", "=", "alignment", "==", "null", "?", "Alignment", ".", "LEFT", ":", "alignment", ";", "}" ]
Sets the alignment of the given column. An IndexOutOfBoundsException will be thrown if col is out of bounds. @param col the index of the column to set the alignment of. @param alignment the alignment to set.
[ "Sets", "the", "alignment", "of", "the", "given", "column", ".", "An", "IndexOutOfBoundsException", "will", "be", "thrown", "if", "col", "is", "out", "of", "bounds", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/layout/ColumnLayout.java#L188-L190
139,207
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/StreamUtil.java
StreamUtil.copy
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) throws IOException { copy(in, out, DEFAULT_BUFFER_SIZE); }
[ "public", "static", "void", "copy", "(", "final", "InputStream", "in", ",", "final", "OutputStream", "out", ")", "throws", "IOException", "{", "copy", "(", "in", ",", "out", ",", "DEFAULT_BUFFER_SIZE", ")", ";", "}" ]
Copies information from the input stream to the output stream, using the default copy buffer size. @param in the source stream. @param out the destination stream. @throws IOException if there is an error reading or writing to the streams.
[ "Copies", "information", "from", "the", "input", "stream", "to", "the", "output", "stream", "using", "the", "default", "copy", "buffer", "size", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/StreamUtil.java#L41-L44
139,208
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/StreamUtil.java
StreamUtil.copy
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 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(); }
[ "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", "(", ")", ";", "}" ]
Copies information from the input stream to the output stream using a specified buffer size. @param in the source stream. @param out the destination stream. @param bufferSize the buffer size. @throws IOException if there is an error reading or writing to the streams.
[ "Copies", "information", "from", "the", "input", "stream", "to", "the", "output", "stream", "using", "a", "specified", "buffer", "size", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/StreamUtil.java#L54-L65
139,209
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/StreamUtil.java
StreamUtil.safeClose
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 static void safeClose(final Closeable stream) { if (stream != null) { try { stream.close(); } catch (IOException e) { LOG.error("Failed to close resource stream", e); } } }
[ "public", "static", "void", "safeClose", "(", "final", "Closeable", "stream", ")", "{", "if", "(", "stream", "!=", "null", ")", "{", "try", "{", "stream", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOG", ".", "error", "(", "\"Failed to close resource stream\"", ",", "e", ")", ";", "}", "}", "}" ]
Closes an OutputStream, logging any exceptions. @param stream the stream to close.
[ "Closes", "an", "OutputStream", "logging", "any", "exceptions", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/StreamUtil.java#L86-L94
139,210
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WMessageBoxExample.java
WMessageBoxExample.applySettings
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.setDisabled(messageList.isEmpty()); messageBox.setType( (com.github.bordertech.wcomponents.WMessageBox.Type) messageBoxTypeSelect. getSelected()); messageBox.setVisible(cbVisible.isSelected()); if (tfTitle.getText() != null && !"".equals(tfTitle.getText())) { messageBox.setTitleText(tfTitle.getText()); } else { messageBox.setTitleText(null); } }
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.setDisabled(messageList.isEmpty()); messageBox.setType( (com.github.bordertech.wcomponents.WMessageBox.Type) messageBoxTypeSelect. getSelected()); messageBox.setVisible(cbVisible.isSelected()); if (tfTitle.getText() != null && !"".equals(tfTitle.getText())) { messageBox.setTitleText(tfTitle.getText()); } else { messageBox.setTitleText(null); } }
[ "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", ".", "setDisabled", "(", "messageList", ".", "isEmpty", "(", ")", ")", ";", "messageBox", ".", "setType", "(", "(", "com", ".", "github", ".", "bordertech", ".", "wcomponents", ".", "WMessageBox", ".", "Type", ")", "messageBoxTypeSelect", ".", "getSelected", "(", ")", ")", ";", "messageBox", ".", "setVisible", "(", "cbVisible", ".", "isSelected", "(", ")", ")", ";", "if", "(", "tfTitle", ".", "getText", "(", ")", "!=", "null", "&&", "!", "\"\"", ".", "equals", "(", "tfTitle", ".", "getText", "(", ")", ")", ")", "{", "messageBox", ".", "setTitleText", "(", "tfTitle", ".", "getText", "(", ")", ")", ";", "}", "else", "{", "messageBox", ".", "setTitleText", "(", "null", ")", ";", "}", "}" ]
applySettings is used to apply the setting to the various controls on the page.
[ "applySettings", "is", "used", "to", "apply", "the", "setting", "to", "the", "various", "controls", "on", "the", "page", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/theme/WMessageBoxExample.java#L152-L175
139,211
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/ContentEscape.java
ContentEscape.escape
@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 (isCacheable()) { getResponse().setHeader("Cache-Control", CacheType.CONTENT_CACHE.getSettings()); } else { getResponse().setHeader("Cache-Control", CacheType.CONTENT_NO_CACHE.getSettings()); } if (contentAccess.getDescription() != null) { String fileName = WebUtilities.encodeForContentDispositionHeader(contentAccess. getDescription()); if (displayInline) { response.setHeader("Content-Disposition", "inline; filename=" + fileName); } else { response.setHeader("Content-Disposition", "attachment; filename=" + fileName); } } if (contentAccess instanceof ContentStreamAccess) { InputStream stream = null; try { stream = ((ContentStreamAccess) contentAccess).getStream(); if (stream == null) { throw new SystemException( "ContentAccess returned null stream, access=" + contentAccess); } StreamUtil.copy(stream, response.getOutputStream()); } finally { StreamUtil.safeClose(stream); } } else { byte[] bytes = contentAccess.getBytes(); if (bytes == null) { throw new SystemException( "ContentAccess returned null data, access=" + contentAccess); } response.getOutputStream().write(bytes); } } }
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 (isCacheable()) { getResponse().setHeader("Cache-Control", CacheType.CONTENT_CACHE.getSettings()); } else { getResponse().setHeader("Cache-Control", CacheType.CONTENT_NO_CACHE.getSettings()); } if (contentAccess.getDescription() != null) { String fileName = WebUtilities.encodeForContentDispositionHeader(contentAccess. getDescription()); if (displayInline) { response.setHeader("Content-Disposition", "inline; filename=" + fileName); } else { response.setHeader("Content-Disposition", "attachment; filename=" + fileName); } } if (contentAccess instanceof ContentStreamAccess) { InputStream stream = null; try { stream = ((ContentStreamAccess) contentAccess).getStream(); if (stream == null) { throw new SystemException( "ContentAccess returned null stream, access=" + contentAccess); } StreamUtil.copy(stream, response.getOutputStream()); } finally { StreamUtil.safeClose(stream); } } else { byte[] bytes = contentAccess.getBytes(); if (bytes == null) { throw new SystemException( "ContentAccess returned null data, access=" + contentAccess); } response.getOutputStream().write(bytes); } } }
[ "@", "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", "(", "isCacheable", "(", ")", ")", "{", "getResponse", "(", ")", ".", "setHeader", "(", "\"Cache-Control\"", ",", "CacheType", ".", "CONTENT_CACHE", ".", "getSettings", "(", ")", ")", ";", "}", "else", "{", "getResponse", "(", ")", ".", "setHeader", "(", "\"Cache-Control\"", ",", "CacheType", ".", "CONTENT_NO_CACHE", ".", "getSettings", "(", ")", ")", ";", "}", "if", "(", "contentAccess", ".", "getDescription", "(", ")", "!=", "null", ")", "{", "String", "fileName", "=", "WebUtilities", ".", "encodeForContentDispositionHeader", "(", "contentAccess", ".", "getDescription", "(", ")", ")", ";", "if", "(", "displayInline", ")", "{", "response", ".", "setHeader", "(", "\"Content-Disposition\"", ",", "\"inline; filename=\"", "+", "fileName", ")", ";", "}", "else", "{", "response", ".", "setHeader", "(", "\"Content-Disposition\"", ",", "\"attachment; filename=\"", "+", "fileName", ")", ";", "}", "}", "if", "(", "contentAccess", "instanceof", "ContentStreamAccess", ")", "{", "InputStream", "stream", "=", "null", ";", "try", "{", "stream", "=", "(", "(", "ContentStreamAccess", ")", "contentAccess", ")", ".", "getStream", "(", ")", ";", "if", "(", "stream", "==", "null", ")", "{", "throw", "new", "SystemException", "(", "\"ContentAccess returned null stream, access=\"", "+", "contentAccess", ")", ";", "}", "StreamUtil", ".", "copy", "(", "stream", ",", "response", ".", "getOutputStream", "(", ")", ")", ";", "}", "finally", "{", "StreamUtil", ".", "safeClose", "(", "stream", ")", ";", "}", "}", "else", "{", "byte", "[", "]", "bytes", "=", "contentAccess", ".", "getBytes", "(", ")", ";", "if", "(", "bytes", "==", "null", ")", "{", "throw", "new", "SystemException", "(", "\"ContentAccess returned null data, access=\"", "+", "contentAccess", ")", ";", "}", "response", ".", "getOutputStream", "(", ")", ".", "write", "(", "bytes", ")", ";", "}", "}", "}" ]
Writes the content to the response. @throws IOException if there is an error writing the content.
[ "Writes", "the", "content", "to", "the", "response", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/ContentEscape.java#L54-L109
139,212
podio/podio-java
src/main/java/com/podio/embed/EmbedAPI.java
EmbedAPI.createEmbed
public Embed createEmbed(String url) { return getResourceFactory().getApiResource("/embed/") .entity(new EmbedCreate(url), MediaType.APPLICATION_JSON_TYPE) .post(Embed.class); }
java
public Embed createEmbed(String url) { return getResourceFactory().getApiResource("/embed/") .entity(new EmbedCreate(url), MediaType.APPLICATION_JSON_TYPE) .post(Embed.class); }
[ "public", "Embed", "createEmbed", "(", "String", "url", ")", "{", "return", "getResourceFactory", "(", ")", ".", "getApiResource", "(", "\"/embed/\"", ")", ".", "entity", "(", "new", "EmbedCreate", "(", "url", ")", ",", "MediaType", ".", "APPLICATION_JSON_TYPE", ")", ".", "post", "(", "Embed", ".", "class", ")", ";", "}" ]
Grabs metadata and returns metadata for the given url such as title, description and thumbnails. @param url The URL of the embed @return The full embed data
[ "Grabs", "metadata", "and", "returns", "metadata", "for", "the", "given", "url", "such", "as", "title", "description", "and", "thumbnails", "." ]
a520b23bac118c957ce02cdd8ff42a6c7d17b49a
https://github.com/podio/podio-java/blob/a520b23bac118c957ce02cdd8ff42a6c7d17b49a/src/main/java/com/podio/embed/EmbedAPI.java#L26-L30
139,213
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WFieldRenderer.java
WFieldRenderer.doRender
@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()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", field.isHidden(), "true"); xml.appendOptionalAttribute("inputWidth", inputWidth > 0, inputWidth); xml.appendClose(); // Label WLabel label = field.getLabel(); if (label != null) { label.paint(renderContext); } // Field if (field.getField() != null) { xml.appendTag("ui:input"); field.getField().paint(renderContext); if (field.getErrorIndicator() != null) { field.getErrorIndicator().paint(renderContext); } if (field.getWarningIndicator() != null) { field.getWarningIndicator().paint(renderContext); } xml.appendEndTag("ui:input"); } xml.appendEndTag("ui:field"); }
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()); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", field.isHidden(), "true"); xml.appendOptionalAttribute("inputWidth", inputWidth > 0, inputWidth); xml.appendClose(); // Label WLabel label = field.getLabel(); if (label != null) { label.paint(renderContext); } // Field if (field.getField() != null) { xml.appendTag("ui:input"); field.getField().paint(renderContext); if (field.getErrorIndicator() != null) { field.getErrorIndicator().paint(renderContext); } if (field.getWarningIndicator() != null) { field.getWarningIndicator().paint(renderContext); } xml.appendEndTag("ui:input"); } xml.appendEndTag("ui:field"); }
[ "@", "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", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"track\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "field", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"inputWidth\"", ",", "inputWidth", ">", "0", ",", "inputWidth", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "// Label", "WLabel", "label", "=", "field", ".", "getLabel", "(", ")", ";", "if", "(", "label", "!=", "null", ")", "{", "label", ".", "paint", "(", "renderContext", ")", ";", "}", "// Field", "if", "(", "field", ".", "getField", "(", ")", "!=", "null", ")", "{", "xml", ".", "appendTag", "(", "\"ui:input\"", ")", ";", "field", ".", "getField", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "if", "(", "field", ".", "getErrorIndicator", "(", ")", "!=", "null", ")", "{", "field", ".", "getErrorIndicator", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "}", "if", "(", "field", ".", "getWarningIndicator", "(", ")", "!=", "null", ")", "{", "field", ".", "getWarningIndicator", "(", ")", ".", "paint", "(", "renderContext", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:input\"", ")", ";", "}", "xml", ".", "appendEndTag", "(", "\"ui:field\"", ")", ";", "}" ]
Paints the given WField. @param component the WField to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WField", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WFieldRenderer.java#L23-L61
139,214
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WHorizontalRuleRenderer.java
WHorizontalRuleRenderer.doRender
@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
@Override public void doRender(final WComponent component, final WebXmlRenderContext renderContext) { XmlStringBuilder xml = renderContext.getWriter(); xml.appendTagOpen("hr"); xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendEnd(); }
[ "@", "Override", "public", "void", "doRender", "(", "final", "WComponent", "component", ",", "final", "WebXmlRenderContext", "renderContext", ")", "{", "XmlStringBuilder", "xml", "=", "renderContext", ".", "getWriter", "(", ")", ";", "xml", ".", "appendTagOpen", "(", "\"hr\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"class\"", ",", "component", ".", "getHtmlClass", "(", ")", ")", ";", "xml", ".", "appendEnd", "(", ")", ";", "}" ]
Paints the given WHorizontalRule. @param component the WHorizontalRule to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WHorizontalRule", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WHorizontalRuleRenderer.java#L23-L29
139,215
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/menu/MenuFlyoutExample.java
MenuFlyoutExample.addMenuItem
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 { ((WMenuItemGroup) parent).add(menuItem); } }
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 { ((WMenuItemGroup) parent).add(menuItem); } }
[ "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", "{", "(", "(", "WMenuItemGroup", ")", "parent", ")", ".", "add", "(", "menuItem", ")", ";", "}", "}" ]
Adds an example menu item with the given text and an example action to the a parent component. @param parent the component to add the menu item to. @param text the text to display on the menu item. @param selectedMenuText the WText to display the selected menu item.
[ "Adds", "an", "example", "menu", "item", "with", "the", "given", "text", "and", "an", "example", "action", "to", "the", "a", "parent", "component", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/menu/MenuFlyoutExample.java#L138-L147
139,216
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/menu/MenuFlyoutExample.java
MenuFlyoutExample.createImageMenuItem
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 WMenuItem(label, new ExampleMenuAction(selectedMenuText)); menuItem.setActionObject(desc); return menuItem; }
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 WMenuItem(label, new ExampleMenuAction(selectedMenuText)); menuItem.setActionObject(desc); return menuItem; }
[ "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", "WMenuItem", "(", "label", ",", "new", "ExampleMenuAction", "(", "selectedMenuText", ")", ")", ";", "menuItem", ".", "setActionObject", "(", "desc", ")", ";", "return", "menuItem", ";", "}" ]
Creates an example menu item using an image. @param resource the name of the image resource @param desc the description for the image @param cacheKey the cache key for this image @param selectedMenuText the WText to display the selected menu item. @return a menu item using an image
[ "Creates", "an", "example", "menu", "item", "using", "an", "image", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/menu/MenuFlyoutExample.java#L158-L167
139,217
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java
WPartialDateField.setPaddingChar
@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
@Deprecated public void setPaddingChar(final char paddingChar) { if (Character.isDigit(paddingChar)) { throw new IllegalArgumentException("Padding character should not be a digit."); } getOrCreateComponentModel().paddingChar = paddingChar; }
[ "@", "Deprecated", "public", "void", "setPaddingChar", "(", "final", "char", "paddingChar", ")", "{", "if", "(", "Character", ".", "isDigit", "(", "paddingChar", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Padding character should not be a digit.\"", ")", ";", "}", "getOrCreateComponentModel", "(", ")", ".", "paddingChar", "=", "paddingChar", ";", "}" ]
The padding character used in the partial date value. The default padding character is a space. If the padding character is a space, then the date value will be right trimmed to remove the trailing spaces. @param paddingChar the padding character used in the partial date value. @deprecated will be removed so padding character is immutable
[ "The", "padding", "character", "used", "in", "the", "partial", "date", "value", ".", "The", "default", "padding", "character", "is", "a", "space", ".", "If", "the", "padding", "character", "is", "a", "space", "then", "the", "date", "value", "will", "be", "right", "trimmed", "to", "remove", "the", "trailing", "spaces", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java#L284-L290
139,218
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java
WPartialDateField.validateComponent
@Override protected void validateComponent(final List<Diagnostic> diags) { if (isValidDate()) { super.validateComponent(diags); } else { diags.add(createErrorDiagnostic(getComponentModel().errorMessage, this)); } }
java
@Override protected void validateComponent(final List<Diagnostic> diags) { if (isValidDate()) { super.validateComponent(diags); } else { diags.add(createErrorDiagnostic(getComponentModel().errorMessage, this)); } }
[ "@", "Override", "protected", "void", "validateComponent", "(", "final", "List", "<", "Diagnostic", ">", "diags", ")", "{", "if", "(", "isValidDate", "(", ")", ")", "{", "super", ".", "validateComponent", "(", "diags", ")", ";", "}", "else", "{", "diags", ".", "add", "(", "createErrorDiagnostic", "(", "getComponentModel", "(", ")", ".", "errorMessage", ",", "this", ")", ")", ";", "}", "}" ]
Override WInput's validateComponent to perform further validation on the date. A partial date is invalid if there was text submitted but no date components were parsed. @param diags the list into which any validation diagnostics are added.
[ "Override", "WInput", "s", "validateComponent", "to", "perform", "further", "validation", "on", "the", "date", ".", "A", "partial", "date", "is", "invalid", "if", "there", "was", "text", "submitted", "but", "no", "date", "components", "were", "parsed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java#L401-L408
139,219
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java
WPartialDateField.setDate
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); setPartialDate(day, month, year); } }
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); setPartialDate(day, month, year); } }
[ "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", ")", ";", "setPartialDate", "(", "day", ",", "month", ",", "year", ")", ";", "}", "}" ]
Set the WPartialDateField with the given java date. @param date the date
[ "Set", "the", "WPartialDateField", "with", "the", "given", "java", "date", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java#L416-L427
139,220
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java
WPartialDateField.getDay
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 getDay() { String dateValue = getValue(); if (dateValue != null && dateValue.length() == DAY_END) { return parseDateComponent(dateValue.substring(DAY_START, DAY_END), getPaddingChar()); } else { return null; } }
[ "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", ";", "}", "}" ]
Returns the day of the month value. @return the day of the month, or null if unspecified.
[ "Returns", "the", "day", "of", "the", "month", "value", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java#L497-L505
139,221
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java
WPartialDateField.getMonth
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 getMonth() { String dateValue = getValue(); if (dateValue != null && dateValue.length() >= MONTH_END) { return parseDateComponent(dateValue.substring(MONTH_START, MONTH_END), getPaddingChar()); } else { return null; } }
[ "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", ";", "}", "}" ]
Returns the month value. @return the month, or null if unspecified.
[ "Returns", "the", "month", "value", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java#L512-L520
139,222
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java
WPartialDateField.getYear
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 Integer getYear() { String dateValue = getValue(); if (dateValue != null && dateValue.length() >= YEAR_END) { return parseDateComponent(dateValue.substring(YEAR_START, YEAR_END), getPaddingChar()); } else { return null; } }
[ "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", ";", "}", "}" ]
Returns the year value. @return the year, or null if unspecified.
[ "Returns", "the", "year", "value", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java#L527-L535
139,223
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java
WPartialDateField.getDate
public Date getDate() { if (getYear() != null && getMonth() != null && getDay() != null) { return DateUtilities.createDate(getDay(), getMonth(), getYear()); } return null; }
java
public Date getDate() { if (getYear() != null && getMonth() != null && getDay() != null) { return DateUtilities.createDate(getDay(), getMonth(), getYear()); } return null; }
[ "public", "Date", "getDate", "(", ")", "{", "if", "(", "getYear", "(", ")", "!=", "null", "&&", "getMonth", "(", ")", "!=", "null", "&&", "getDay", "(", ")", "!=", "null", ")", "{", "return", "DateUtilities", ".", "createDate", "(", "getDay", "(", ")", ",", "getMonth", "(", ")", ",", "getYear", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
Returns the java date value, else null if the value cannot be parsed. @return the java date or null
[ "Returns", "the", "java", "date", "value", "else", "null", "if", "the", "value", "cannot", "be", "parsed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java#L542-L548
139,224
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java
WPartialDateField.isValidCharacters
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 (chr == padding) { if (digitChars) { return false; } paddingChars = true; } else if (chr >= '0' && chr <= '9') { // Digit if (paddingChars) { return false; } digitChars = true; } else { return false; } } return true; }
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 (chr == padding) { if (digitChars) { return false; } paddingChars = true; } else if (chr >= '0' && chr <= '9') { // Digit if (paddingChars) { return false; } digitChars = true; } else { return false; } } return true; }
[ "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", "(", "chr", "==", "padding", ")", "{", "if", "(", "digitChars", ")", "{", "return", "false", ";", "}", "paddingChars", "=", "true", ";", "}", "else", "if", "(", "chr", ">=", "'", "'", "&&", "chr", "<=", "'", "'", ")", "{", "// Digit", "if", "(", "paddingChars", ")", "{", "return", "false", ";", "}", "digitChars", "=", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Check the component is either all padding chars or all digit chars. @param component the date component. @param padding the padding character. @return true if the component is valid, otherwise false
[ "Check", "the", "component", "is", "either", "all", "padding", "chars", "or", "all", "digit", "chars", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WPartialDateField.java#L695-L718
139,225
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.getPathToRoot
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 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(); }
[ "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", ",", "'", "'", ")", ";", "}", "buf", ".", "insert", "(", "0", ",", "node", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
Retrieves a "path" of component classes from the given component to the root node. The path is formatted with one component on each line, with the first line being the root node. @param component the component to retrieve the path for @return a "path" of class names from the component to the root.
[ "Retrieves", "a", "path", "of", "component", "classes", "from", "the", "given", "component", "to", "the", "root", "node", ".", "The", "path", "is", "formatted", "with", "one", "component", "on", "each", "line", "with", "the", "first", "line", "being", "the", "root", "node", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L201-L213
139,226
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.getAncestorOfClass
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(); } return null; }
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(); } return null; }
[ "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", "(", ")", ";", "}", "return", "null", ";", "}" ]
Attempts to find a component which is an ancestor of the given component, and that is assignable to the given class. @param clazz the class to look for @param comp the component to start at. @return the matching ancestor, if found, otherwise null. @param <T> the ancestor class
[ "Attempts", "to", "find", "a", "component", "which", "is", "an", "ancestor", "of", "the", "given", "component", "and", "that", "is", "assignable", "to", "the", "given", "class", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L225-L239
139,227
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.getTop
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 WComponent getTop(final WComponent comp) { WComponent top = comp; for (WComponent parent = top.getParent(); parent != null; parent = parent.getParent()) { top = parent; } return top; }
[ "public", "static", "WComponent", "getTop", "(", "final", "WComponent", "comp", ")", "{", "WComponent", "top", "=", "comp", ";", "for", "(", "WComponent", "parent", "=", "top", ".", "getParent", "(", ")", ";", "parent", "!=", "null", ";", "parent", "=", "parent", ".", "getParent", "(", ")", ")", "{", "top", "=", "parent", ";", "}", "return", "top", ";", "}" ]
Retrieves the top-level WComponent in the tree. @param comp the component branch to start from. @return the top-level WComponent in the tree.
[ "Retrieves", "the", "top", "-", "level", "WComponent", "in", "the", "tree", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L268-L276
139,228
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.encodeUrl
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 encodeUrl(final String urlStr) { if (Util.empty(urlStr)) { return urlStr; } // Percent Encode String percentEncode = percentEncodeUrl(urlStr); // XML Enocde return encode(percentEncode); }
[ "public", "static", "String", "encodeUrl", "(", "final", "String", "urlStr", ")", "{", "if", "(", "Util", ".", "empty", "(", "urlStr", ")", ")", "{", "return", "urlStr", ";", "}", "// Percent Encode", "String", "percentEncode", "=", "percentEncodeUrl", "(", "urlStr", ")", ";", "// XML Enocde", "return", "encode", "(", "percentEncode", ")", ";", "}" ]
Encode URL for XML. @param urlStr the URL to escape @return the URL percent encoded
[ "Encode", "URL", "for", "XML", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L284-L292
139,229
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.percentEncodeUrl
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 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; } }
[ "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", ";", "}", "}" ]
Percent encode a URL to include in HTML. @param urlStr the URL to escape @return the URL percent encoded
[ "Percent", "encode", "a", "URL", "to", "include", "in", "HTML", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L300-L313
139,230
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.escapeForUrl
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 char ch = characters[i]; // Section 2.3 - Unreserved chars if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '-' || ch == '_' || ch == '.' || ch == '~') { buffer.append(ch); } else if (ch <= 127) { // Other ASCII characters must be escaped final String hexString = Integer.toHexString(ch); if (hexString.length() == 1) { buffer.append("%0").append(hexString); } else { buffer.append('%').append(hexString); } } else if (ch <= 0x07FF) { // Other non-ASCII chars must be UTF-8 encoded buffer.append('%').append(Integer.toHexString(0xc0 | (ch >> 6))); buffer.append('%').append(Integer.toHexString(0x80 | (ch & 0x3F))); } else { buffer.append('%').append(Integer.toHexString(0xe0 | (ch >> 12))); buffer.append('%').append(Integer.toHexString(0x80 | ((ch >> 6) & 0x3F))); buffer.append('%').append(Integer.toHexString(0x80 | (ch & 0x3F))); } } return buffer.toString(); }
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 char ch = characters[i]; // Section 2.3 - Unreserved chars if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '-' || ch == '_' || ch == '.' || ch == '~') { buffer.append(ch); } else if (ch <= 127) { // Other ASCII characters must be escaped final String hexString = Integer.toHexString(ch); if (hexString.length() == 1) { buffer.append("%0").append(hexString); } else { buffer.append('%').append(hexString); } } else if (ch <= 0x07FF) { // Other non-ASCII chars must be UTF-8 encoded buffer.append('%').append(Integer.toHexString(0xc0 | (ch >> 6))); buffer.append('%').append(Integer.toHexString(0x80 | (ch & 0x3F))); } else { buffer.append('%').append(Integer.toHexString(0xe0 | (ch >> 12))); buffer.append('%').append(Integer.toHexString(0x80 | ((ch >> 6) & 0x3F))); buffer.append('%').append(Integer.toHexString(0x80 | (ch & 0x3F))); } } return buffer.toString(); }
[ "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", "char", "ch", "=", "characters", "[", "i", "]", ";", "// Section 2.3 - Unreserved chars", "if", "(", "(", "ch", ">=", "'", "'", "&&", "ch", "<=", "'", "'", ")", "||", "(", "ch", ">=", "'", "'", "&&", "ch", "<=", "'", "'", ")", "||", "(", "ch", ">=", "'", "'", "&&", "ch", "<=", "'", "'", ")", "||", "ch", "==", "'", "'", "||", "ch", "==", "'", "'", "||", "ch", "==", "'", "'", "||", "ch", "==", "'", "'", ")", "{", "buffer", ".", "append", "(", "ch", ")", ";", "}", "else", "if", "(", "ch", "<=", "127", ")", "{", "// Other ASCII characters must be escaped", "final", "String", "hexString", "=", "Integer", ".", "toHexString", "(", "ch", ")", ";", "if", "(", "hexString", ".", "length", "(", ")", "==", "1", ")", "{", "buffer", ".", "append", "(", "\"%0\"", ")", ".", "append", "(", "hexString", ")", ";", "}", "else", "{", "buffer", ".", "append", "(", "'", "'", ")", ".", "append", "(", "hexString", ")", ";", "}", "}", "else", "if", "(", "ch", "<=", "0x07FF", ")", "{", "// Other non-ASCII chars must be UTF-8 encoded", "buffer", ".", "append", "(", "'", "'", ")", ".", "append", "(", "Integer", ".", "toHexString", "(", "0xc0", "|", "(", "ch", ">>", "6", ")", ")", ")", ";", "buffer", ".", "append", "(", "'", "'", ")", ".", "append", "(", "Integer", ".", "toHexString", "(", "0x80", "|", "(", "ch", "&", "0x3F", ")", ")", ")", ";", "}", "else", "{", "buffer", ".", "append", "(", "'", "'", ")", ".", "append", "(", "Integer", ".", "toHexString", "(", "0xe0", "|", "(", "ch", ">>", "12", ")", ")", ")", ";", "buffer", ".", "append", "(", "'", "'", ")", ".", "append", "(", "Integer", ".", "toHexString", "(", "0x80", "|", "(", "(", "ch", ">>", "6", ")", "&", "0x3F", ")", ")", ")", ";", "buffer", ".", "append", "(", "'", "'", ")", ".", "append", "(", "Integer", ".", "toHexString", "(", "0x80", "|", "(", "ch", "&", "0x3F", ")", ")", ")", ";", "}", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}" ]
Escapes the given string to make it presentable in a URL. This follows RFC 3986, with some extensions for UTF-8. @param input the String to escape. @return an escaped copy of the string.
[ "Escapes", "the", "given", "string", "to", "make", "it", "presentable", "in", "a", "URL", ".", "This", "follows", "RFC", "3986", "with", "some", "extensions", "for", "UTF", "-", "8", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L321-L355
139,231
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.encode
public static String encode(final String input) { if (input == null || input.length() == 0) { return input; } return ENCODE.translate(input); }
java
public static String encode(final String input) { if (input == null || input.length() == 0) { return input; } return ENCODE.translate(input); }
[ "public", "static", "String", "encode", "(", "final", "String", "input", ")", "{", "if", "(", "input", "==", "null", "||", "input", ".", "length", "(", ")", "==", "0", ")", "{", "return", "input", ";", "}", "return", "ENCODE", ".", "translate", "(", "input", ")", ";", "}" ]
Encode all the special characters found in the given string to their escape sequences according to the XML specification, and returns the resultant string. Eg. "cat&amp;dog &gt; ant" becomes "cat&amp;amp;dog &amp;gt; ant". @param input the String to encode @return an encoded copy of the input String.
[ "Encode", "all", "the", "special", "characters", "found", "in", "the", "given", "string", "to", "their", "escape", "sequences", "according", "to", "the", "XML", "specification", "and", "returns", "the", "resultant", "string", ".", "Eg", ".", "cat&amp", ";", "dog", "&gt", ";", "ant", "becomes", "cat&amp", ";", "amp", ";", "dog", "&amp", ";", "gt", ";", "ant", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L365-L370
139,232
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.decode
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 decode(final String encoded) { if (encoded == null || encoded.length() == 0 || encoded.indexOf('&') == -1) { return encoded; } return DECODE.translate(encoded); }
[ "public", "static", "String", "decode", "(", "final", "String", "encoded", ")", "{", "if", "(", "encoded", "==", "null", "||", "encoded", ".", "length", "(", ")", "==", "0", "||", "encoded", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "{", "return", "encoded", ";", "}", "return", "DECODE", ".", "translate", "(", "encoded", ")", ";", "}" ]
This method is required on occasion because WebSphere Portal by default escapes "&lt;" and "&gt;" characters for security reasons. Decode any escape sequences to their original character, and return the resultant string. Eg. "cat&amp;amp;dog &amp;gt; ant" becomes "cat&amp;dog &gt; ant" @param encoded the String to decode @return a decoded copy of the input String.
[ "This", "method", "is", "required", "on", "occasion", "because", "WebSphere", "Portal", "by", "default", "escapes", "&lt", ";", "and", "&gt", ";", "characters", "for", "security", "reasons", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L399-L404
139,233
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.encodeBrackets
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 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); }
[ "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", ")", ";", "}" ]
Encode open or closed brackets in the input String. @param input the String to encode open or closed brackets @return the String with encoded open or closed brackets
[ "Encode", "open", "or", "closed", "brackets", "in", "the", "input", "String", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L424-L429
139,234
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.decodeBrackets
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 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); }
[ "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", ")", ";", "}" ]
Decode open or closed brackets in the input String. @param input the String to decode open or closed brackets @return the String with decode open or closed brackets
[ "Decode", "open", "or", "closed", "brackets", "in", "the", "input", "String", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L437-L442
139,235
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.doubleEncodeBrackets
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 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); }
[ "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", ")", ";", "}" ]
Double encode open or closed brackets in the input String. @param input the String to double encode open or closed brackets @return the String with double encoded open or closed brackets
[ "Double", "encode", "open", "or", "closed", "brackets", "in", "the", "input", "String", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L450-L455
139,236
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.doubleDecodeBrackets
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 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); }
[ "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", ")", ";", "}" ]
Decode double encoded open or closed brackets in the input String. @param input the String to decode double encoded open or closed brackets @return the String with decoded double encoded open or closed brackets
[ "Decode", "double", "encoded", "open", "or", "closed", "brackets", "in", "the", "input", "String", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L463-L468
139,237
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.appendGetParamForJavascript
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 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)); }
[ "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", ")", ")", ";", "}" ]
This is a slightly different version of appendGetParam that doesn't encode the ampersand seperator. It is intended to be used in urls that are generated for javascript functions. @param key the key to append @param value the value to append @param vars the existing query string @param existingVars true if there are already existing query string key/value pairs
[ "This", "is", "a", "slightly", "different", "version", "of", "appendGetParam", "that", "doesn", "t", "encode", "the", "ampersand", "seperator", ".", "It", "is", "intended", "to", "be", "used", "in", "urls", "that", "are", "generated", "for", "javascript", "functions", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L528-L532
139,238
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.generateRandom
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 String generateRandom() { long next = ATOMIC_COUNT.incrementAndGet(); StringBuffer random = new StringBuffer(); random.append(new Date().getTime()).append('-').append(next); return random.toString(); }
[ "public", "static", "String", "generateRandom", "(", ")", "{", "long", "next", "=", "ATOMIC_COUNT", ".", "incrementAndGet", "(", ")", ";", "StringBuffer", "random", "=", "new", "StringBuffer", "(", ")", ";", "random", ".", "append", "(", "new", "Date", "(", ")", ".", "getTime", "(", ")", ")", ".", "append", "(", "'", "'", ")", ".", "append", "(", "next", ")", ";", "return", "random", ".", "toString", "(", ")", ";", "}" ]
Generates a random String. Can be useful for creating unique URLs by adding the String as a query parameter to the URL. @return a random string
[ "Generates", "a", "random", "String", ".", "Can", "be", "useful", "for", "creating", "unique", "URLs", "by", "adding", "the", "String", "as", "a", "query", "parameter", "to", "the", "URL", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L560-L565
139,239
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.isAncestor
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 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; }
[ "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", ";", "}" ]
Indicates whether a component is an ancestor of another. @param component1 a possible ancestor. @param component2 the component to check. @return true if <code>component1</code> is an ancestor of <code>component2</code>, false otherwise.
[ "Indicates", "whether", "a", "component", "is", "an", "ancestor", "of", "another", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L574-L582
139,240
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.getContextForComponent
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)) { result = ((SubUIContext) result).getBacking(); } return result; }
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)) { result = ((SubUIContext) result).getBacking(); } return result; }
[ "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", ")", ")", "{", "result", "=", "(", "(", "SubUIContext", ")", "result", ")", ".", "getBacking", "(", ")", ";", "}", "return", "result", ";", "}" ]
Returns the context for this component. The component may not be in the current context. @param component the component to find the context it belongs to @return the component's context
[ "Returns", "the", "context", "for", "this", "component", ".", "The", "component", "may", "not", "be", "in", "the", "current", "context", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L615-L623
139,241
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.getComponentById
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 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; }
[ "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", ";", "}" ]
Finds a component by its id. @param id the id of the component to search for. @param visibleOnly true if process visible only @return the component and context for the given id, or null if not found.
[ "Finds", "a", "component", "by", "its", "id", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L645-L650
139,242
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.findClosestContext
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 UIContext findClosestContext(final String id) { UIContext uic = UIContextHolder.getCurrent(); WComponent root = uic.getUI(); UIContext closest = TreeUtil.getClosestContextForId(root, id); return closest; }
[ "public", "static", "UIContext", "findClosestContext", "(", "final", "String", "id", ")", "{", "UIContext", "uic", "=", "UIContextHolder", ".", "getCurrent", "(", ")", ";", "WComponent", "root", "=", "uic", ".", "getUI", "(", ")", ";", "UIContext", "closest", "=", "TreeUtil", ".", "getClosestContextForId", "(", "root", ",", "id", ")", ";", "return", "closest", ";", "}" ]
Finds the closest context for the given component id. This handles the case where the component no longer exists due to having been removed from the UI, or having a SubUIContext removed. @param id the id of the component to search for. @return the component and context for the given id, or null if not found.
[ "Finds", "the", "closest", "context", "for", "the", "given", "component", "id", ".", "This", "handles", "the", "case", "where", "the", "component", "no", "longer", "exists", "due", "to", "having", "been", "removed", "from", "the", "UI", "or", "having", "a", "SubUIContext", "removed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L659-L664
139,243
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.updateBeanValue
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) { ((WBeanComponent) component).updateBeanValue(); } // These components recursively update bean values themselves, // as they have special requirements due to repeating data. if (component instanceof WDataTable || component instanceof WTable || component instanceof WRepeater) { return; } if (component instanceof Container) { for (int i = ((Container) component).getChildCount() - 1; i >= 0; i--) { updateBeanValue(((Container) component).getChildAt(i), visibleOnly); } } }
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) { ((WBeanComponent) component).updateBeanValue(); } // These components recursively update bean values themselves, // as they have special requirements due to repeating data. if (component instanceof WDataTable || component instanceof WTable || component instanceof WRepeater) { return; } if (component instanceof Container) { for (int i = ((Container) component).getChildCount() - 1; i >= 0; i--) { updateBeanValue(((Container) component).getChildAt(i), visibleOnly); } } }
[ "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", ")", "{", "(", "(", "WBeanComponent", ")", "component", ")", ".", "updateBeanValue", "(", ")", ";", "}", "// These components recursively update bean values themselves,", "// as they have special requirements due to repeating data.", "if", "(", "component", "instanceof", "WDataTable", "||", "component", "instanceof", "WTable", "||", "component", "instanceof", "WRepeater", ")", "{", "return", ";", "}", "if", "(", "component", "instanceof", "Container", ")", "{", "for", "(", "int", "i", "=", "(", "(", "Container", ")", "component", ")", ".", "getChildCount", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "updateBeanValue", "(", "(", "(", "Container", ")", "component", ")", ".", "getChildAt", "(", "i", ")", ",", "visibleOnly", ")", ";", "}", "}", "}" ]
Updates the bean value with the current value of the component and all its bean-bound children. @param component the component whose contents need to be copied to the bean. @param visibleOnly - whether to include visible components only.
[ "Updates", "the", "bean", "value", "with", "the", "current", "value", "of", "the", "component", "and", "all", "its", "bean", "-", "bound", "children", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L672-L693
139,244
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.render
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); try (PrintWriter writer = new PrintWriter(buffer)) { component.paint(new WebXmlRenderContext(writer)); } return buffer.toString(); } finally { if (needsContext) { UIContextHolder.popContext(); } } }
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); try (PrintWriter writer = new PrintWriter(buffer)) { component.paint(new WebXmlRenderContext(writer)); } return buffer.toString(); } finally { if (needsContext) { UIContextHolder.popContext(); } } }
[ "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", ")", ";", "try", "(", "PrintWriter", "writer", "=", "new", "PrintWriter", "(", "buffer", ")", ")", "{", "component", ".", "paint", "(", "new", "WebXmlRenderContext", "(", "writer", ")", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}", "finally", "{", "if", "(", "needsContext", ")", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}", "}" ]
Renders the given WComponent to a String outside of the context of a Servlet. This is good for getting hold of the XML for debugging, unit testing etc. Also it is good for using the WComponent framework as a more generic templating framework. @param request the request being responded to. @param component the root WComponent to render. @return the rendered output as a String.
[ "Renders", "the", "given", "WComponent", "to", "a", "String", "outside", "of", "the", "context", "of", "a", "Servlet", ".", "This", "is", "good", "for", "getting", "hold", "of", "the", "XML", "for", "debugging", "unit", "testing", "etc", ".", "Also", "it", "is", "good", "for", "using", "the", "WComponent", "framework", "as", "a", "more", "generic", "templating", "framework", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L726-L746
139,245
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.renderWithTransformToHTML
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 { // Link Interceptors InterceptorComponent templateRender = new TemplateRenderInterceptor(); InterceptorComponent transformXML = new TransformXMLInterceptor(); templateRender.setBackingComponent(transformXML); if (includePageShell) { transformXML.setBackingComponent(new PageShellInterceptor()); } // Attach Component and Mock Response InterceptorComponent chain = templateRender; chain.attachUI(component); chain.attachResponse(new MockResponse()); // Render chain StringWriter buffer = new StringWriter(); chain.preparePaint(request); try (PrintWriter writer = new PrintWriter(buffer)) { chain.paint(new WebXmlRenderContext(writer)); } return buffer.toString(); } finally { if (needsContext) { UIContextHolder.popContext(); } } }
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 { // Link Interceptors InterceptorComponent templateRender = new TemplateRenderInterceptor(); InterceptorComponent transformXML = new TransformXMLInterceptor(); templateRender.setBackingComponent(transformXML); if (includePageShell) { transformXML.setBackingComponent(new PageShellInterceptor()); } // Attach Component and Mock Response InterceptorComponent chain = templateRender; chain.attachUI(component); chain.attachResponse(new MockResponse()); // Render chain StringWriter buffer = new StringWriter(); chain.preparePaint(request); try (PrintWriter writer = new PrintWriter(buffer)) { chain.paint(new WebXmlRenderContext(writer)); } return buffer.toString(); } finally { if (needsContext) { UIContextHolder.popContext(); } } }
[ "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", "{", "// Link Interceptors", "InterceptorComponent", "templateRender", "=", "new", "TemplateRenderInterceptor", "(", ")", ";", "InterceptorComponent", "transformXML", "=", "new", "TransformXMLInterceptor", "(", ")", ";", "templateRender", ".", "setBackingComponent", "(", "transformXML", ")", ";", "if", "(", "includePageShell", ")", "{", "transformXML", ".", "setBackingComponent", "(", "new", "PageShellInterceptor", "(", ")", ")", ";", "}", "// Attach Component and Mock Response", "InterceptorComponent", "chain", "=", "templateRender", ";", "chain", ".", "attachUI", "(", "component", ")", ";", "chain", ".", "attachResponse", "(", "new", "MockResponse", "(", ")", ")", ";", "// Render chain", "StringWriter", "buffer", "=", "new", "StringWriter", "(", ")", ";", "chain", ".", "preparePaint", "(", "request", ")", ";", "try", "(", "PrintWriter", "writer", "=", "new", "PrintWriter", "(", "buffer", ")", ")", "{", "chain", ".", "paint", "(", "new", "WebXmlRenderContext", "(", "writer", ")", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}", "finally", "{", "if", "(", "needsContext", ")", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}", "}" ]
Renders and transforms the given WComponent to a HTML String outside of the context of a Servlet. @param request the request being responded to @param component the root WComponent to render @param includePageShell true if include page shell @return the rendered output as a String.
[ "Renders", "and", "transforms", "the", "given", "WComponent", "to", "a", "HTML", "String", "outside", "of", "the", "context", "of", "a", "Servlet", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L766-L801
139,246
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.getContentType
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 = ConfigurationProperties.getFileMimeTypeForExtension(suffix); } if (mimeType == null) { mimeType = URLConnection.guessContentTypeFromName(fileName); if (mimeType == null) { mimeType = ConfigurationProperties.getDefaultMimeType(); } } return mimeType; }
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 = ConfigurationProperties.getFileMimeTypeForExtension(suffix); } if (mimeType == null) { mimeType = URLConnection.guessContentTypeFromName(fileName); if (mimeType == null) { mimeType = ConfigurationProperties.getDefaultMimeType(); } } return mimeType; }
[ "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", "=", "ConfigurationProperties", ".", "getFileMimeTypeForExtension", "(", "suffix", ")", ";", "}", "if", "(", "mimeType", "==", "null", ")", "{", "mimeType", "=", "URLConnection", ".", "guessContentTypeFromName", "(", "fileName", ")", ";", "if", "(", "mimeType", "==", "null", ")", "{", "mimeType", "=", "ConfigurationProperties", ".", "getDefaultMimeType", "(", ")", ";", "}", "}", "return", "mimeType", ";", "}" ]
Attempts to guess the content-type for the given file name. @param fileName the file name to return the content-type for. @return the content-type for the given fileName, or a generic type if unknown.
[ "Attempts", "to", "guess", "the", "content", "-", "type", "for", "the", "given", "file", "name", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L809-L830
139,247
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java
WebUtilities.getParentNamingContext
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); if (naming == null) { break; } if (WebUtilities.isActiveNamingContext(naming)) { parent = naming; break; } child = naming; } return parent; }
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); if (naming == null) { break; } if (WebUtilities.isActiveNamingContext(naming)) { parent = naming; break; } child = naming; } return parent; }
[ "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", ")", ";", "if", "(", "naming", "==", "null", ")", "{", "break", ";", "}", "if", "(", "WebUtilities", ".", "isActiveNamingContext", "(", "naming", ")", ")", "{", "parent", "=", "naming", ";", "break", ";", "}", "child", "=", "naming", ";", "}", "return", "parent", ";", "}" ]
Get this component's parent naming context. @param component the component to process @return true the parent naming context or null
[ "Get", "this", "component", "s", "parent", "naming", "context", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WebUtilities.java#L856-L877
139,248
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.updateBeanValueForColumnInRow
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) rowRenderer.getRenderer(col)).getChildAt(0); UIContextHolder.pushContext(rowContext); try { // If the column is a Container then call updateBeanValue to let the column renderer and its children update // the "bean" returned by getValueAt(row, col) if (renderer instanceof Container) { WebUtilities.updateBeanValue(renderer); } else if (renderer instanceof DataBound) { // Update Databound renderer Object oldValue = model.getValueAt(rowIndex, col); Object newValue = ((DataBound) renderer).getData(); if (!Util.equals(oldValue, newValue)) { model.setValueAt(newValue, rowIndex, col); } } } finally { UIContextHolder.popContext(); } }
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) rowRenderer.getRenderer(col)).getChildAt(0); UIContextHolder.pushContext(rowContext); try { // If the column is a Container then call updateBeanValue to let the column renderer and its children update // the "bean" returned by getValueAt(row, col) if (renderer instanceof Container) { WebUtilities.updateBeanValue(renderer); } else if (renderer instanceof DataBound) { // Update Databound renderer Object oldValue = model.getValueAt(rowIndex, col); Object newValue = ((DataBound) renderer).getData(); if (!Util.equals(oldValue, newValue)) { model.setValueAt(newValue, rowIndex, col); } } } finally { UIContextHolder.popContext(); } }
[ "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", ")", "rowRenderer", ".", "getRenderer", "(", "col", ")", ")", ".", "getChildAt", "(", "0", ")", ";", "UIContextHolder", ".", "pushContext", "(", "rowContext", ")", ";", "try", "{", "// If the column is a Container then call updateBeanValue to let the column renderer and its children update", "// the \"bean\" returned by getValueAt(row, col)", "if", "(", "renderer", "instanceof", "Container", ")", "{", "WebUtilities", ".", "updateBeanValue", "(", "renderer", ")", ";", "}", "else", "if", "(", "renderer", "instanceof", "DataBound", ")", "{", "// Update Databound renderer", "Object", "oldValue", "=", "model", ".", "getValueAt", "(", "rowIndex", ",", "col", ")", ";", "Object", "newValue", "=", "(", "(", "DataBound", ")", "renderer", ")", ".", "getData", "(", ")", ";", "if", "(", "!", "Util", ".", "equals", "(", "oldValue", ",", "newValue", ")", ")", "{", "model", ".", "setValueAt", "(", "newValue", ",", "rowIndex", ",", "col", ")", ";", "}", "}", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}" ]
Update the column in the row. @param rowRenderer the table row renderer @param rowContext the row context @param rowIndex the row id to update @param col the column to update @param model the table model
[ "Update", "the", "column", "in", "the", "row", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L440-L465
139,249
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.updateBeanValueForRowRenderer
private void updateBeanValueForRowRenderer(final WTableRowRenderer rowRenderer, final UIContext rowContext, final Class<? extends WComponent> expandRenderer) { Container expandWrapper = (Container) rowRenderer. getExpandedTreeNodeRenderer(expandRenderer); if (expandWrapper == null) { return; } // The actual component is wrapped in a renderer wrapper, so we have to fetch it from that WComponent expandInstance = expandWrapper.getChildAt(0); UIContextHolder.pushContext(rowContext); try { // Will apply updates to the "bean" returned by the model for this expanded renderer (ie // getValueAt(rowIndex, -1)) WebUtilities.updateBeanValue(expandInstance); } finally { UIContextHolder.popContext(); } }
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; } // The actual component is wrapped in a renderer wrapper, so we have to fetch it from that WComponent expandInstance = expandWrapper.getChildAt(0); UIContextHolder.pushContext(rowContext); try { // Will apply updates to the "bean" returned by the model for this expanded renderer (ie // getValueAt(rowIndex, -1)) WebUtilities.updateBeanValue(expandInstance); } finally { UIContextHolder.popContext(); } }
[ "private", "void", "updateBeanValueForRowRenderer", "(", "final", "WTableRowRenderer", "rowRenderer", ",", "final", "UIContext", "rowContext", ",", "final", "Class", "<", "?", "extends", "WComponent", ">", "expandRenderer", ")", "{", "Container", "expandWrapper", "=", "(", "Container", ")", "rowRenderer", ".", "getExpandedTreeNodeRenderer", "(", "expandRenderer", ")", ";", "if", "(", "expandWrapper", "==", "null", ")", "{", "return", ";", "}", "// The actual component is wrapped in a renderer wrapper, so we have to fetch it from that", "WComponent", "expandInstance", "=", "expandWrapper", ".", "getChildAt", "(", "0", ")", ";", "UIContextHolder", ".", "pushContext", "(", "rowContext", ")", ";", "try", "{", "// Will apply updates to the \"bean\" returned by the model for this expanded renderer (ie", "// getValueAt(rowIndex, -1))", "WebUtilities", ".", "updateBeanValue", "(", "expandInstance", ")", ";", "}", "finally", "{", "UIContextHolder", ".", "popContext", "(", ")", ";", "}", "}" ]
Update the expandable row renderer. @param rowRenderer the table row renderer @param rowContext the row context @param expandRenderer the renderer for the expandable row.
[ "Update", "the", "expandable", "row", "renderer", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L474-L496
139,250
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.setSeparatorType
public void setSeparatorType(final SeparatorType separatorType) { getOrCreateComponentModel().separatorType = separatorType == null ? SeparatorType.NONE : separatorType; }
java
public void setSeparatorType(final SeparatorType separatorType) { getOrCreateComponentModel().separatorType = separatorType == null ? SeparatorType.NONE : separatorType; }
[ "public", "void", "setSeparatorType", "(", "final", "SeparatorType", "separatorType", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "separatorType", "=", "separatorType", "==", "null", "?", "SeparatorType", ".", "NONE", ":", "separatorType", ";", "}" ]
Sets the separator used to visually separate rows or columns. @param separatorType the separator type to set.
[ "Sets", "the", "separator", "used", "to", "visually", "separate", "rows", "or", "columns", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L510-L512
139,251
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.setStripingType
public void setStripingType(final StripingType stripingType) { getOrCreateComponentModel().stripingType = stripingType == null ? StripingType.NONE : stripingType; }
java
public void setStripingType(final StripingType stripingType) { getOrCreateComponentModel().stripingType = stripingType == null ? StripingType.NONE : stripingType; }
[ "public", "void", "setStripingType", "(", "final", "StripingType", "stripingType", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "stripingType", "=", "stripingType", "==", "null", "?", "StripingType", ".", "NONE", ":", "stripingType", ";", "}" ]
Sets the striping type used to highlight alternate rows or columns. @param stripingType the striping type to set.
[ "Sets", "the", "striping", "type", "used", "to", "highlight", "alternate", "rows", "or", "columns", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L545-L547
139,252
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.setPaginationMode
public void setPaginationMode(final PaginationMode paginationMode) { getOrCreateComponentModel().paginationMode = paginationMode == null ? PaginationMode.NONE : paginationMode; }
java
public void setPaginationMode(final PaginationMode paginationMode) { getOrCreateComponentModel().paginationMode = paginationMode == null ? PaginationMode.NONE : paginationMode; }
[ "public", "void", "setPaginationMode", "(", "final", "PaginationMode", "paginationMode", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "paginationMode", "=", "paginationMode", "==", "null", "?", "PaginationMode", ".", "NONE", ":", "paginationMode", ";", "}" ]
Sets the pagination mode. @param paginationMode the paginationMode to set.
[ "Sets", "the", "pagination", "mode", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L702-L704
139,253
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.setPaginationLocation
public void setPaginationLocation(final PaginationLocation location) { getOrCreateComponentModel().paginationLocation = location == null ? PaginationLocation.AUTO : location; }
java
public void setPaginationLocation(final PaginationLocation location) { getOrCreateComponentModel().paginationLocation = location == null ? PaginationLocation.AUTO : location; }
[ "public", "void", "setPaginationLocation", "(", "final", "PaginationLocation", "location", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "paginationLocation", "=", "location", "==", "null", "?", "PaginationLocation", ".", "AUTO", ":", "location", ";", "}" ]
Sets the location in the table to show the pagination controls. @param location the PaginationLocation to set.
[ "Sets", "the", "location", "in", "the", "table", "to", "show", "the", "pagination", "controls", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L797-L799
139,254
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.setType
public void setType(final Type type) { getOrCreateComponentModel().type = type == null ? Type.TABLE : type; }
java
public void setType(final Type type) { getOrCreateComponentModel().type = type == null ? Type.TABLE : type; }
[ "public", "void", "setType", "(", "final", "Type", "type", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "type", "=", "type", "==", "null", "?", "Type", ".", "TABLE", ":", "type", ";", "}" ]
Sets the table type that controls how the table is displayed. @param type the table type to set.
[ "Sets", "the", "table", "type", "that", "controls", "how", "the", "table", "is", "displayed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L870-L872
139,255
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.setSelectAllMode
public void setSelectAllMode(final SelectAllType selectAllMode) { getOrCreateComponentModel().selectAllMode = selectAllMode == null ? SelectAllType.TEXT : selectAllMode; }
java
public void setSelectAllMode(final SelectAllType selectAllMode) { getOrCreateComponentModel().selectAllMode = selectAllMode == null ? SelectAllType.TEXT : selectAllMode; }
[ "public", "void", "setSelectAllMode", "(", "final", "SelectAllType", "selectAllMode", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "selectAllMode", "=", "selectAllMode", "==", "null", "?", "SelectAllType", ".", "TEXT", ":", "selectAllMode", ";", "}" ]
Sets how the table row "select all" function should be displayed. @param selectAllMode the select all mode to set.
[ "Sets", "how", "the", "table", "row", "select", "all", "function", "should", "be", "displayed", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L888-L890
139,256
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.getActions
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 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); }
[ "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", ")", ";", "}" ]
Retrieves the actions for the table. @return the list of table actions
[ "Retrieves", "the", "actions", "for", "the", "table", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L1195-L1205
139,257
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.addActionConstraint
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, constraint); }
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, constraint); }
[ "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", ",", "constraint", ")", ";", "}" ]
Adds a constraint to when the given action can be used. @param button the button which the constraint applies to. @param constraint the constraint to add.
[ "Adds", "a", "constraint", "to", "when", "the", "given", "action", "can", "be", "used", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L1222-L1229
139,258
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.getActionConstraints
public List<ActionConstraint> getActionConstraints(final WButton button) { List<ActionConstraint> constraints = getComponentModel().actionConstraints.get(button); return constraints == null ? null : Collections.unmodifiableList(constraints); }
java
public List<ActionConstraint> getActionConstraints(final WButton button) { List<ActionConstraint> constraints = getComponentModel().actionConstraints.get(button); return constraints == null ? null : Collections.unmodifiableList(constraints); }
[ "public", "List", "<", "ActionConstraint", ">", "getActionConstraints", "(", "final", "WButton", "button", ")", "{", "List", "<", "ActionConstraint", ">", "constraints", "=", "getComponentModel", "(", ")", ".", "actionConstraints", ".", "get", "(", "button", ")", ";", "return", "constraints", "==", "null", "?", "null", ":", "Collections", ".", "unmodifiableList", "(", "constraints", ")", ";", "}" ]
Retrieves the constraints for the given action. @param button the button to retrieve the constraints for. @return the constraints for the given action, or null if there are no constraints.
[ "Retrieves", "the", "constraints", "for", "the", "given", "action", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L1237-L1240
139,259
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.handleSortRequest
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().rowIndexMapping = null; } else { try { int sortCol = Integer.parseInt(sortColStr); // Allow for column order int[] cols = getColumnOrder(); if (cols != null) { sortCol = cols[sortCol]; } boolean sortAsc = !"true".equalsIgnoreCase(sortDescStr); // Only process the sort request if it differs from the current sort order if (sortCol != getSortColumnIndex() || sortAsc != isSortAscending()) { sort(sortCol, sortAsc); setFocussed(); } } catch (NumberFormatException e) { LOG.warn("Invalid sort column: " + sortColStr); } } } }
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().rowIndexMapping = null; } else { try { int sortCol = Integer.parseInt(sortColStr); // Allow for column order int[] cols = getColumnOrder(); if (cols != null) { sortCol = cols[sortCol]; } boolean sortAsc = !"true".equalsIgnoreCase(sortDescStr); // Only process the sort request if it differs from the current sort order if (sortCol != getSortColumnIndex() || sortAsc != isSortAscending()) { sort(sortCol, sortAsc); setFocussed(); } } catch (NumberFormatException e) { LOG.warn("Invalid sort column: " + sortColStr); } } } }
[ "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", "(", ")", ".", "rowIndexMapping", "=", "null", ";", "}", "else", "{", "try", "{", "int", "sortCol", "=", "Integer", ".", "parseInt", "(", "sortColStr", ")", ";", "// Allow for column order", "int", "[", "]", "cols", "=", "getColumnOrder", "(", ")", ";", "if", "(", "cols", "!=", "null", ")", "{", "sortCol", "=", "cols", "[", "sortCol", "]", ";", "}", "boolean", "sortAsc", "=", "!", "\"true\"", ".", "equalsIgnoreCase", "(", "sortDescStr", ")", ";", "// Only process the sort request if it differs from the current sort order", "if", "(", "sortCol", "!=", "getSortColumnIndex", "(", ")", "||", "sortAsc", "!=", "isSortAscending", "(", ")", ")", "{", "sort", "(", "sortCol", ",", "sortAsc", ")", ";", "setFocussed", "(", ")", ";", "}", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "LOG", ".", "warn", "(", "\"Invalid sort column: \"", "+", "sortColStr", ")", ";", "}", "}", "}", "}" ]
Handles a request containing sort instruction data. @param request the request containing sort instruction data.
[ "Handles", "a", "request", "containing", "sort", "instruction", "data", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L1285-L1314
139,260
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.sort
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 indices // with the new order of rows, so we need to clear out the selection. setSelectedRows(null); setExpandedRows(null); } }
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 indices // with the new order of rows, so we need to clear out the selection. setSelectedRows(null); setExpandedRows(null); } }
[ "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 indices", "// with the new order of rows, so we need to clear out the selection.", "setSelectedRows", "(", "null", ")", ";", "setExpandedRows", "(", "null", ")", ";", "}", "}" ]
Sort the table data by the specified column. @param sortCol the column to sort @param sortAsc true if sort ascending, otherwise sort descending
[ "Sort", "the", "table", "data", "by", "the", "specified", "column", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L1322-L1334
139,261
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java
WTable.calcChildrenRowIds
@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); // Add to parent if (parent != null) { parent.addChild(row); } List<Integer> rowIndex = row.getRowIndex(); // If row has a renderer, then dont need to process its children (should not have any anyway as it is a "leaf") if (model.getRendererClass(rowIndex) != null) { return; } // Check row is expandable if (!model.isExpandable(rowIndex)) { return; } // Check has children if (!model.hasChildren(rowIndex)) { return; } row.setHasChildren(true); // Always add children if CLIENT mode or row is expanded boolean addChildren = (mode == ExpandMode.CLIENT) || (expanded != null && expanded.contains( row.getRowKey())); if (!addChildren) { return; } // Get actual child count int children = model.getChildCount(rowIndex); if (children == 0) { // Could be there are no children even though hasChildren returned true row.setHasChildren(false); return; } // Render mode, Keep rows that have been expanded (only if table editable) if (!forUpdate && editable) { addPrevExpandedRow(row.getRowKey()); } // Add children by processing each child row for (int i = 0; i < children; i++) { // Add next level List<Integer> nextRow = new ArrayList<>(row.getRowIndex()); nextRow.add(i); // Create Wrapper Object key = model.getRowKey(nextRow); RowIdWrapper wrapper = new RowIdWrapper(nextRow, key, row); calcChildrenRowIds(rows, wrapper, model, row, expanded, mode, forUpdate, editable); } }
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); // Add to parent if (parent != null) { parent.addChild(row); } List<Integer> rowIndex = row.getRowIndex(); // If row has a renderer, then dont need to process its children (should not have any anyway as it is a "leaf") if (model.getRendererClass(rowIndex) != null) { return; } // Check row is expandable if (!model.isExpandable(rowIndex)) { return; } // Check has children if (!model.hasChildren(rowIndex)) { return; } row.setHasChildren(true); // Always add children if CLIENT mode or row is expanded boolean addChildren = (mode == ExpandMode.CLIENT) || (expanded != null && expanded.contains( row.getRowKey())); if (!addChildren) { return; } // Get actual child count int children = model.getChildCount(rowIndex); if (children == 0) { // Could be there are no children even though hasChildren returned true row.setHasChildren(false); return; } // Render mode, Keep rows that have been expanded (only if table editable) if (!forUpdate && editable) { addPrevExpandedRow(row.getRowKey()); } // Add children by processing each child row for (int i = 0; i < children; i++) { // Add next level List<Integer> nextRow = new ArrayList<>(row.getRowIndex()); nextRow.add(i); // Create Wrapper Object key = model.getRowKey(nextRow); RowIdWrapper wrapper = new RowIdWrapper(nextRow, key, row); calcChildrenRowIds(rows, wrapper, model, row, expanded, mode, forUpdate, editable); } }
[ "@", "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", ")", ";", "// Add to parent", "if", "(", "parent", "!=", "null", ")", "{", "parent", ".", "addChild", "(", "row", ")", ";", "}", "List", "<", "Integer", ">", "rowIndex", "=", "row", ".", "getRowIndex", "(", ")", ";", "// If row has a renderer, then dont need to process its children (should not have any anyway as it is a \"leaf\")", "if", "(", "model", ".", "getRendererClass", "(", "rowIndex", ")", "!=", "null", ")", "{", "return", ";", "}", "// Check row is expandable", "if", "(", "!", "model", ".", "isExpandable", "(", "rowIndex", ")", ")", "{", "return", ";", "}", "// Check has children", "if", "(", "!", "model", ".", "hasChildren", "(", "rowIndex", ")", ")", "{", "return", ";", "}", "row", ".", "setHasChildren", "(", "true", ")", ";", "// Always add children if CLIENT mode or row is expanded", "boolean", "addChildren", "=", "(", "mode", "==", "ExpandMode", ".", "CLIENT", ")", "||", "(", "expanded", "!=", "null", "&&", "expanded", ".", "contains", "(", "row", ".", "getRowKey", "(", ")", ")", ")", ";", "if", "(", "!", "addChildren", ")", "{", "return", ";", "}", "// Get actual child count", "int", "children", "=", "model", ".", "getChildCount", "(", "rowIndex", ")", ";", "if", "(", "children", "==", "0", ")", "{", "// Could be there are no children even though hasChildren returned true", "row", ".", "setHasChildren", "(", "false", ")", ";", "return", ";", "}", "// Render mode, Keep rows that have been expanded (only if table editable)", "if", "(", "!", "forUpdate", "&&", "editable", ")", "{", "addPrevExpandedRow", "(", "row", ".", "getRowKey", "(", ")", ")", ";", "}", "// Add children by processing each child row", "for", "(", "int", "i", "=", "0", ";", "i", "<", "children", ";", "i", "++", ")", "{", "// Add next level", "List", "<", "Integer", ">", "nextRow", "=", "new", "ArrayList", "<>", "(", "row", ".", "getRowIndex", "(", ")", ")", ";", "nextRow", ".", "add", "(", "i", ")", ";", "// Create Wrapper", "Object", "key", "=", "model", ".", "getRowKey", "(", "nextRow", ")", ";", "RowIdWrapper", "wrapper", "=", "new", "RowIdWrapper", "(", "nextRow", ",", "key", ",", "row", ")", ";", "calcChildrenRowIds", "(", "rows", ",", "wrapper", ",", "model", ",", "row", ",", "expanded", ",", "mode", ",", "forUpdate", ",", "editable", ")", ";", "}", "}" ]
Calculate the row ids of a row's children. @param rows the list of row ids @param row the current row @param model the table model @param parent the row's parent @param expanded the set of expanded rows @param mode the table expand mode @param forUpdate true if building list of row ids to update @param editable true if the table is editable
[ "Calculate", "the", "row", "ids", "of", "a", "row", "s", "children", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTable.java#L1833-L1894
139,262
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/ContextCleanupInterceptor.java
ContextCleanupInterceptor.paint
@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.debug("Performing session tidy up of WComponents (any WComponents disconnected from the active top component will not be tidied up."); getUI().tidyUpUIContextForTree(); LOG.debug("After paint - Clearing scratch maps."); uic.clearScratchMap(); uic.clearRequestScratchMap(); }
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.debug("Performing session tidy up of WComponents (any WComponents disconnected from the active top component will not be tidied up."); getUI().tidyUpUIContextForTree(); LOG.debug("After paint - Clearing scratch maps."); uic.clearScratchMap(); uic.clearRequestScratchMap(); }
[ "@", "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", ".", "debug", "(", "\"Performing session tidy up of WComponents (any WComponents disconnected from the active top component will not be tidied up.\"", ")", ";", "getUI", "(", ")", ".", "tidyUpUIContextForTree", "(", ")", ";", "LOG", ".", "debug", "(", "\"After paint - Clearing scratch maps.\"", ")", ";", "uic", ".", "clearScratchMap", "(", ")", ";", "uic", ".", "clearRequestScratchMap", "(", ")", ";", "}" ]
Override paint to clear out the scratch map and component models which are no longer necessary. @param renderContext the renderContext to send the output to.
[ "Override", "paint", "to", "clear", "out", "the", "scratch", "map", "and", "component", "models", "which", "are", "no", "longer", "necessary", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/ContextCleanupInterceptor.java#L47-L63
139,263
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WCheckBoxSelect.java
WCheckBoxSelect.setButtonColumns
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
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; }
[ "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", ";", "}" ]
Sets the layout to be a certain number of columns. @param numColumns the number of columns.
[ "Sets", "the", "layout", "to", "be", "a", "certain", "number", "of", "columns", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WCheckBoxSelect.java#L103-L111
139,264
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WSuggestions.java
WSuggestions.doHandleAjaxRefresh
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); } }; invokeLater(later); }
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); } }; invokeLater(later); }
[ "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", ")", ";", "}", "}", ";", "invokeLater", "(", "later", ")", ";", "}" ]
Handle the AJAX refresh request.
[ "Handle", "the", "AJAX", "refresh", "request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WSuggestions.java#L104-L119
139,265
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WSuggestions.java
WSuggestions.getSuggestions
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<?> lookupSuggestions = APPLICATION_LOOKUP_TABLE.getTable(table); if (lookupSuggestions == null || lookupSuggestions.isEmpty()) { return Collections.EMPTY_LIST; } // Build list of String suggestions List<String> suggestions = new ArrayList<>(lookupSuggestions.size()); for (Object suggestion : lookupSuggestions) { String sugg = APPLICATION_LOOKUP_TABLE.getDescription(table, suggestion); if (sugg != null) { suggestions.add(sugg); } } return Collections.unmodifiableList(suggestions); } }
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<?> lookupSuggestions = APPLICATION_LOOKUP_TABLE.getTable(table); if (lookupSuggestions == null || lookupSuggestions.isEmpty()) { return Collections.EMPTY_LIST; } // Build list of String suggestions List<String> suggestions = new ArrayList<>(lookupSuggestions.size()); for (Object suggestion : lookupSuggestions) { String sugg = APPLICATION_LOOKUP_TABLE.getDescription(table, suggestion); if (sugg != null) { suggestions.add(sugg); } } return Collections.unmodifiableList(suggestions); } }
[ "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", "<", "?", ">", "lookupSuggestions", "=", "APPLICATION_LOOKUP_TABLE", ".", "getTable", "(", "table", ")", ";", "if", "(", "lookupSuggestions", "==", "null", "||", "lookupSuggestions", ".", "isEmpty", "(", ")", ")", "{", "return", "Collections", ".", "EMPTY_LIST", ";", "}", "// Build list of String suggestions", "List", "<", "String", ">", "suggestions", "=", "new", "ArrayList", "<>", "(", "lookupSuggestions", ".", "size", "(", ")", ")", ";", "for", "(", "Object", "suggestion", ":", "lookupSuggestions", ")", "{", "String", "sugg", "=", "APPLICATION_LOOKUP_TABLE", ".", "getDescription", "(", "table", ",", "suggestion", ")", ";", "if", "(", "sugg", "!=", "null", ")", "{", "suggestions", ".", "add", "(", "sugg", ")", ";", "}", "}", "return", "Collections", ".", "unmodifiableList", "(", "suggestions", ")", ";", "}", "}" ]
Returns the complete list of suggestions available for selection for this user's session. @return the list of suggestions available for the given user's session.
[ "Returns", "the", "complete", "list", "of", "suggestions", "available", "for", "selection", "for", "this", "user", "s", "session", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WSuggestions.java#L126-L149
139,266
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WSuggestions.java
WSuggestions.setSuggestions
public void setSuggestions(final List<String> suggestions) { SuggestionsModel model = getOrCreateComponentModel(); model.setSuggestions(suggestions); }
java
public void setSuggestions(final List<String> suggestions) { SuggestionsModel model = getOrCreateComponentModel(); model.setSuggestions(suggestions); }
[ "public", "void", "setSuggestions", "(", "final", "List", "<", "String", ">", "suggestions", ")", "{", "SuggestionsModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "model", ".", "setSuggestions", "(", "suggestions", ")", ";", "}" ]
Set the complete list of suggestions available for selection for this user's session. @param suggestions the list of suggestions available to the user.
[ "Set", "the", "complete", "list", "of", "suggestions", "available", "for", "selection", "for", "this", "user", "s", "session", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WSuggestions.java#L172-L175
139,267
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/DebugValidateXML.java
DebugValidateXML.validateXMLAgainstSchema
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.newInstance(); spf.setNamespaceAware(true); spf.setValidating(true); // Create SAX Parser SAXParser parser = spf.newSAXParser(); parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", XMLConstants.W3C_XML_SCHEMA_NS_URI); // Set schema location Object schema = DebugValidateXML.class.getResource(getSchemaPath()).toString(); parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schema); // Setup the handler to throw an exception when an error occurs DefaultHandler handler = new DefaultHandler() { @Override public void warning(final SAXParseException e) throws SAXException { LOG.warn("XML Schema warning: " + e.getMessage(), e); super.warning(e); } @Override public void fatalError(final SAXParseException e) throws SAXException { throw e; } @Override public void error(final SAXParseException e) throws SAXException { throw e; } }; // Validate the XML InputSource xmlSource = new InputSource(new StringReader(testXML)); parser.parse(xmlSource, handler); } catch (SAXParseException e) { return "At line " + e.getLineNumber() + ", column: " + e.getColumnNumber() + " ==> " + e.getMessage(); } catch (Exception e) { return e.getMessage(); } } return null; }
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.newInstance(); spf.setNamespaceAware(true); spf.setValidating(true); // Create SAX Parser SAXParser parser = spf.newSAXParser(); parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", XMLConstants.W3C_XML_SCHEMA_NS_URI); // Set schema location Object schema = DebugValidateXML.class.getResource(getSchemaPath()).toString(); parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schema); // Setup the handler to throw an exception when an error occurs DefaultHandler handler = new DefaultHandler() { @Override public void warning(final SAXParseException e) throws SAXException { LOG.warn("XML Schema warning: " + e.getMessage(), e); super.warning(e); } @Override public void fatalError(final SAXParseException e) throws SAXException { throw e; } @Override public void error(final SAXParseException e) throws SAXException { throw e; } }; // Validate the XML InputSource xmlSource = new InputSource(new StringReader(testXML)); parser.parse(xmlSource, handler); } catch (SAXParseException e) { return "At line " + e.getLineNumber() + ", column: " + e.getColumnNumber() + " ==> " + e.getMessage(); } catch (Exception e) { return e.getMessage(); } } return null; }
[ "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", ".", "newInstance", "(", ")", ";", "spf", ".", "setNamespaceAware", "(", "true", ")", ";", "spf", ".", "setValidating", "(", "true", ")", ";", "// Create SAX Parser", "SAXParser", "parser", "=", "spf", ".", "newSAXParser", "(", ")", ";", "parser", ".", "setProperty", "(", "\"http://java.sun.com/xml/jaxp/properties/schemaLanguage\"", ",", "XMLConstants", ".", "W3C_XML_SCHEMA_NS_URI", ")", ";", "// Set schema location", "Object", "schema", "=", "DebugValidateXML", ".", "class", ".", "getResource", "(", "getSchemaPath", "(", ")", ")", ".", "toString", "(", ")", ";", "parser", ".", "setProperty", "(", "\"http://java.sun.com/xml/jaxp/properties/schemaSource\"", ",", "schema", ")", ";", "// Setup the handler to throw an exception when an error occurs", "DefaultHandler", "handler", "=", "new", "DefaultHandler", "(", ")", "{", "@", "Override", "public", "void", "warning", "(", "final", "SAXParseException", "e", ")", "throws", "SAXException", "{", "LOG", ".", "warn", "(", "\"XML Schema warning: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "super", ".", "warning", "(", "e", ")", ";", "}", "@", "Override", "public", "void", "fatalError", "(", "final", "SAXParseException", "e", ")", "throws", "SAXException", "{", "throw", "e", ";", "}", "@", "Override", "public", "void", "error", "(", "final", "SAXParseException", "e", ")", "throws", "SAXException", "{", "throw", "e", ";", "}", "}", ";", "// Validate the XML", "InputSource", "xmlSource", "=", "new", "InputSource", "(", "new", "StringReader", "(", "testXML", ")", ")", ";", "parser", ".", "parse", "(", "xmlSource", ",", "handler", ")", ";", "}", "catch", "(", "SAXParseException", "e", ")", "{", "return", "\"At line \"", "+", "e", ".", "getLineNumber", "(", ")", "+", "\", column: \"", "+", "e", ".", "getColumnNumber", "(", ")", "+", "\" ==> \"", "+", "e", ".", "getMessage", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "e", ".", "getMessage", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
Validate the component to make sure the generated XML is schema compliant. @param xml the xml to validate @return Any errors found, or null if the XML is valid.
[ "Validate", "the", "component", "to", "make", "sure", "the", "generated", "XML", "is", "schema", "compliant", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/DebugValidateXML.java#L55-L107
139,268
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/DebugValidateXML.java
DebugValidateXML.wrapXMLInRootElement
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:root" + XMLUtil.STANDARD_NAMESPACES + ">" + xml + "</ui:root>"; } }
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:root" + XMLUtil.STANDARD_NAMESPACES + ">" + xml + "</ui:root>"; } }
[ "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:root\"", "+", "XMLUtil", ".", "STANDARD_NAMESPACES", "+", "\">\"", "+", "xml", "+", "\"</ui:root>\"", ";", "}", "}" ]
Wrap the XML in a root element before validating. @param xml the XML to wrap @return the XML wrapped in a root element
[ "Wrap", "the", "XML", "in", "a", "root", "element", "before", "validating", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/DebugValidateXML.java#L115-L124
139,269
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/InternalResourceMap.java
InternalResourceMap.registerResource
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 void registerResource(final InternalResource resource) { String resourceName = resource.getResourceName(); if (!RESOURCES.containsKey(resourceName)) { RESOURCES.put(resourceName, resource); RESOURCE_CACHE_KEYS.put(resourceName, computeHash(resource)); } }
[ "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", ")", ")", ";", "}", "}" ]
Adds a resource to the resource map. @param resource the resource.
[ "Adds", "a", "resource", "to", "the", "resource", "map", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/InternalResourceMap.java#L48-L55
139,270
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/InternalResourceMap.java
InternalResourceMap.computeHash
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 checksumEngine = new Adler32(); Checksum checksumEngine = new CRC32(); byte[] buf = new byte[bufferSize]; for (int read = stream.read(buf); read != -1; read = stream.read(buf)) { checksumEngine.update(buf, 0, read); } return Long.toHexString(checksumEngine.getValue()); } catch (Exception e) { throw new SystemException("Error calculating resource hash", e); } }
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 checksumEngine = new Adler32(); Checksum checksumEngine = new CRC32(); byte[] buf = new byte[bufferSize]; for (int read = stream.read(buf); read != -1; read = stream.read(buf)) { checksumEngine.update(buf, 0, read); } return Long.toHexString(checksumEngine.getValue()); } catch (Exception e) { throw new SystemException("Error calculating resource hash", e); } }
[ "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 checksumEngine = new Adler32();", "Checksum", "checksumEngine", "=", "new", "CRC32", "(", ")", ";", "byte", "[", "]", "buf", "=", "new", "byte", "[", "bufferSize", "]", ";", "for", "(", "int", "read", "=", "stream", ".", "read", "(", "buf", ")", ";", "read", "!=", "-", "1", ";", "read", "=", "stream", ".", "read", "(", "buf", ")", ")", "{", "checksumEngine", ".", "update", "(", "buf", ",", "0", ",", "read", ")", ";", "}", "return", "Long", ".", "toHexString", "(", "checksumEngine", ".", "getValue", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "SystemException", "(", "\"Error calculating resource hash\"", ",", "e", ")", ";", "}", "}" ]
Computes a simple hash of the resource contents. @param resource the resource to hash. @return a hash of the resource contents.
[ "Computes", "a", "simple", "hash", "of", "the", "resource", "contents", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/InternalResourceMap.java#L83-L105
139,271
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/template/TemplateWriter.java
TemplateWriter.doReplace
@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
@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(); } }
[ "@", "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", "(", ")", ";", "}", "}" ]
Replaces the search string by rendering the corresponding component. @param search the search String that was matched. @param backing the underlying writer to write the replacement to.
[ "Replaces", "the", "search", "string", "by", "rendering", "the", "corresponding", "component", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/template/TemplateWriter.java#L53-L63
139,272
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableModel.java
SimpleBeanBoundTableModel.getTopRowBean
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 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; }
[ "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", ";", "}" ]
Return the top level bean for this row index. @param row the row index @return the root row bean (ie top level) for this index
[ "Return", "the", "top", "level", "bean", "for", "this", "row", "index", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableModel.java#L457-L468
139,273
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableModel.java
SimpleBeanBoundTableModel.getBeanPropertyValue
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 property " + property + " on " + bean, e); return null; } }
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 property " + property + " on " + bean, e); return null; } }
[ "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 property \"", "+", "property", "+", "\" on \"", "+", "bean", ",", "e", ")", ";", "return", "null", ";", "}", "}" ]
Get the bean property value. @param property the bean property @param bean the bean @return the bean property value
[ "Get", "the", "bean", "property", "value", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableModel.java#L521-L537
139,274
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableModel.java
SimpleBeanBoundTableModel.setBeanPropertyValue
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); } catch (Exception e) { LOG.error("Failed to set bean property " + property + " on " + bean, e); } }
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); } catch (Exception e) { LOG.error("Failed to set bean property " + property + " on " + bean, e); } }
[ "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", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"Failed to set bean property \"", "+", "property", "+", "\" on \"", "+", "bean", ",", "e", ")", ";", "}", "}" ]
Set the bean property value. @param property the bean property @param bean the bean @param value the value to set
[ "Set", "the", "bean", "property", "value", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/SimpleBeanBoundTableModel.java#L546-L561
139,275
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WDataTableRenderer.java
WDataTableRenderer.doRender
@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", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", table.isHidden(), "true"); xml.appendOptionalAttribute("caption", table.getCaption()); switch (table.getType()) { case TABLE: xml.appendAttribute("type", "table"); break; case HIERARCHIC: xml.appendAttribute("type", "hierarchic"); break; default: throw new SystemException("Unknown table type: " + table.getType()); } switch (table.getStripingType()) { case ROWS: xml.appendAttribute("striping", "rows"); break; case COLUMNS: xml.appendAttribute("striping", "cols"); break; case NONE: break; default: throw new SystemException("Unknown striping type: " + table.getStripingType()); } switch (table.getSeparatorType()) { case HORIZONTAL: xml.appendAttribute("separators", "horizontal"); break; case VERTICAL: xml.appendAttribute("separators", "vertical"); break; case BOTH: xml.appendAttribute("separators", "both"); break; case NONE: break; default: throw new SystemException("Unknown separator type: " + table.getSeparatorType()); } xml.appendClose(); if (table.getPaginationMode() != PaginationMode.NONE) { paintPaginationElement(table, xml); } if (table.getSelectMode() != SelectMode.NONE) { paintRowSelectionElement(table, xml); } if (table.getExpandMode() != ExpandMode.NONE) { paintRowExpansionElement(table, xml); } if (table.isSortable()) { paintSortElement(table, xml); } paintColumnHeadings(table, renderContext); paintRows(table, renderContext); paintTableActions(table, renderContext); xml.appendEndTag("ui:table"); }
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", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", table.isHidden(), "true"); xml.appendOptionalAttribute("caption", table.getCaption()); switch (table.getType()) { case TABLE: xml.appendAttribute("type", "table"); break; case HIERARCHIC: xml.appendAttribute("type", "hierarchic"); break; default: throw new SystemException("Unknown table type: " + table.getType()); } switch (table.getStripingType()) { case ROWS: xml.appendAttribute("striping", "rows"); break; case COLUMNS: xml.appendAttribute("striping", "cols"); break; case NONE: break; default: throw new SystemException("Unknown striping type: " + table.getStripingType()); } switch (table.getSeparatorType()) { case HORIZONTAL: xml.appendAttribute("separators", "horizontal"); break; case VERTICAL: xml.appendAttribute("separators", "vertical"); break; case BOTH: xml.appendAttribute("separators", "both"); break; case NONE: break; default: throw new SystemException("Unknown separator type: " + table.getSeparatorType()); } xml.appendClose(); if (table.getPaginationMode() != PaginationMode.NONE) { paintPaginationElement(table, xml); } if (table.getSelectMode() != SelectMode.NONE) { paintRowSelectionElement(table, xml); } if (table.getExpandMode() != ExpandMode.NONE) { paintRowExpansionElement(table, xml); } if (table.isSortable()) { paintSortElement(table, xml); } paintColumnHeadings(table, renderContext); paintRows(table, renderContext); paintTableActions(table, renderContext); xml.appendEndTag("ui:table"); }
[ "@", "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\"", ",", "component", ".", "isTracking", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"hidden\"", ",", "table", ".", "isHidden", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"caption\"", ",", "table", ".", "getCaption", "(", ")", ")", ";", "switch", "(", "table", ".", "getType", "(", ")", ")", "{", "case", "TABLE", ":", "xml", ".", "appendAttribute", "(", "\"type\"", ",", "\"table\"", ")", ";", "break", ";", "case", "HIERARCHIC", ":", "xml", ".", "appendAttribute", "(", "\"type\"", ",", "\"hierarchic\"", ")", ";", "break", ";", "default", ":", "throw", "new", "SystemException", "(", "\"Unknown table type: \"", "+", "table", ".", "getType", "(", ")", ")", ";", "}", "switch", "(", "table", ".", "getStripingType", "(", ")", ")", "{", "case", "ROWS", ":", "xml", ".", "appendAttribute", "(", "\"striping\"", ",", "\"rows\"", ")", ";", "break", ";", "case", "COLUMNS", ":", "xml", ".", "appendAttribute", "(", "\"striping\"", ",", "\"cols\"", ")", ";", "break", ";", "case", "NONE", ":", "break", ";", "default", ":", "throw", "new", "SystemException", "(", "\"Unknown striping type: \"", "+", "table", ".", "getStripingType", "(", ")", ")", ";", "}", "switch", "(", "table", ".", "getSeparatorType", "(", ")", ")", "{", "case", "HORIZONTAL", ":", "xml", ".", "appendAttribute", "(", "\"separators\"", ",", "\"horizontal\"", ")", ";", "break", ";", "case", "VERTICAL", ":", "xml", ".", "appendAttribute", "(", "\"separators\"", ",", "\"vertical\"", ")", ";", "break", ";", "case", "BOTH", ":", "xml", ".", "appendAttribute", "(", "\"separators\"", ",", "\"both\"", ")", ";", "break", ";", "case", "NONE", ":", "break", ";", "default", ":", "throw", "new", "SystemException", "(", "\"Unknown separator type: \"", "+", "table", ".", "getSeparatorType", "(", ")", ")", ";", "}", "xml", ".", "appendClose", "(", ")", ";", "if", "(", "table", ".", "getPaginationMode", "(", ")", "!=", "PaginationMode", ".", "NONE", ")", "{", "paintPaginationElement", "(", "table", ",", "xml", ")", ";", "}", "if", "(", "table", ".", "getSelectMode", "(", ")", "!=", "SelectMode", ".", "NONE", ")", "{", "paintRowSelectionElement", "(", "table", ",", "xml", ")", ";", "}", "if", "(", "table", ".", "getExpandMode", "(", ")", "!=", "ExpandMode", ".", "NONE", ")", "{", "paintRowExpansionElement", "(", "table", ",", "xml", ")", ";", "}", "if", "(", "table", ".", "isSortable", "(", ")", ")", "{", "paintSortElement", "(", "table", ",", "xml", ")", ";", "}", "paintColumnHeadings", "(", "table", ",", "renderContext", ")", ";", "paintRows", "(", "table", ",", "renderContext", ")", ";", "paintTableActions", "(", "table", ",", "renderContext", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:table\"", ")", ";", "}" ]
Paints the given WDataTable. @param component the WDataTable to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WDataTable", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WDataTableRenderer.java#L39-L113
139,276
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WDataTableRenderer.java
WDataTableRenderer.paintPaginationElement
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 = ((TreeTableDataModel) model).getNodeAtLine(0); xml.appendAttribute("rows", firstNode == null ? 0 : firstNode.getParent(). getChildCount()); } else { xml.appendAttribute("rows", model.getRowCount()); } xml.appendAttribute("rowsPerPage", table.getRowsPerPage()); xml.appendAttribute("currentPage", table.getCurrentPage()); switch (table.getPaginationMode()) { case CLIENT: xml.appendAttribute("mode", "client"); break; case DYNAMIC: case SERVER: xml.appendAttribute("mode", "dynamic"); break; case NONE: break; default: throw new SystemException("Unknown pagination mode: " + table. getPaginationMode()); } xml.appendEnd(); }
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 = ((TreeTableDataModel) model).getNodeAtLine(0); xml.appendAttribute("rows", firstNode == null ? 0 : firstNode.getParent(). getChildCount()); } else { xml.appendAttribute("rows", model.getRowCount()); } xml.appendAttribute("rowsPerPage", table.getRowsPerPage()); xml.appendAttribute("currentPage", table.getCurrentPage()); switch (table.getPaginationMode()) { case CLIENT: xml.appendAttribute("mode", "client"); break; case DYNAMIC: case SERVER: xml.appendAttribute("mode", "dynamic"); break; case NONE: break; default: throw new SystemException("Unknown pagination mode: " + table. getPaginationMode()); } xml.appendEnd(); }
[ "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", "=", "(", "(", "TreeTableDataModel", ")", "model", ")", ".", "getNodeAtLine", "(", "0", ")", ";", "xml", ".", "appendAttribute", "(", "\"rows\"", ",", "firstNode", "==", "null", "?", "0", ":", "firstNode", ".", "getParent", "(", ")", ".", "getChildCount", "(", ")", ")", ";", "}", "else", "{", "xml", ".", "appendAttribute", "(", "\"rows\"", ",", "model", ".", "getRowCount", "(", ")", ")", ";", "}", "xml", ".", "appendAttribute", "(", "\"rowsPerPage\"", ",", "table", ".", "getRowsPerPage", "(", ")", ")", ";", "xml", ".", "appendAttribute", "(", "\"currentPage\"", ",", "table", ".", "getCurrentPage", "(", ")", ")", ";", "switch", "(", "table", ".", "getPaginationMode", "(", ")", ")", "{", "case", "CLIENT", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"client\"", ")", ";", "break", ";", "case", "DYNAMIC", ":", "case", "SERVER", ":", "xml", ".", "appendAttribute", "(", "\"mode\"", ",", "\"dynamic\"", ")", ";", "break", ";", "case", "NONE", ":", "break", ";", "default", ":", "throw", "new", "SystemException", "(", "\"Unknown pagination mode: \"", "+", "table", ".", "getPaginationMode", "(", ")", ")", ";", "}", "xml", ".", "appendEnd", "(", ")", ";", "}" ]
Paint the pagination aspects of the WDataTable. @param table the WDataTable being rendered @param xml the string builder in use
[ "Paint", "the", "pagination", "aspects", "of", "the", "WDataTable", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WDataTableRenderer.java#L120-L152
139,277
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMenuItem.java
WMenuItem.setAction
public void setAction(final Action action) { MenuItemModel model = getOrCreateComponentModel(); model.action = action; model.url = null; }
java
public void setAction(final Action action) { MenuItemModel model = getOrCreateComponentModel(); model.action = action; model.url = null; }
[ "public", "void", "setAction", "(", "final", "Action", "action", ")", "{", "MenuItemModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "model", ".", "action", "=", "action", ";", "model", ".", "url", "=", "null", ";", "}" ]
Sets the action to execute when the menu item is invoked. @param action the menu item's action.
[ "Sets", "the", "action", "to", "execute", "when", "the", "menu", "item", "is", "invoked", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMenuItem.java#L138-L142
139,278
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMenuItem.java
WMenuItem.setUrl
public void setUrl(final String url) { MenuItemModel model = getOrCreateComponentModel(); model.url = url; model.action = null; }
java
public void setUrl(final String url) { MenuItemModel model = getOrCreateComponentModel(); model.url = url; model.action = null; }
[ "public", "void", "setUrl", "(", "final", "String", "url", ")", "{", "MenuItemModel", "model", "=", "getOrCreateComponentModel", "(", ")", ";", "model", ".", "url", "=", "url", ";", "model", ".", "action", "=", "null", ";", "}" ]
Sets the URL to navigate to when the menu item is invoked. @param url the url to set.
[ "Sets", "the", "URL", "to", "navigate", "to", "when", "the", "menu", "item", "is", "invoked", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMenuItem.java#L158-L162
139,279
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMenuItem.java
WMenuItem.setMessage
public void setMessage(final String message, final Serializable... args) { getOrCreateComponentModel().message = I18nUtilities.asMessage(message, args); }
java
public void setMessage(final String message, final Serializable... args) { getOrCreateComponentModel().message = I18nUtilities.asMessage(message, args); }
[ "public", "void", "setMessage", "(", "final", "String", "message", ",", "final", "Serializable", "...", "args", ")", "{", "getOrCreateComponentModel", "(", ")", ".", "message", "=", "I18nUtilities", ".", "asMessage", "(", "message", ",", "args", ")", ";", "}" ]
Sets the confirmation message that is to be displayed to the user for this menu item. @param message the confirmation message to display, using {@link MessageFormat} syntax. @param args optional arguments for the message format string.
[ "Sets", "the", "confirmation", "message", "that", "is", "to", "be", "displayed", "to", "the", "user", "for", "this", "menu", "item", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMenuItem.java#L404-L406
139,280
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMenuItem.java
WMenuItem.handleRequest
@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 POST if (!"POST".equals(request.getMethod())) { LOG.warn("Menu item on a request that is not a POST. Will be ignored."); return; } // Execute associated action, if set final Action action = getAction(); if (action != null) { final ActionEvent event = new ActionEvent(this, this.getActionCommand(), this. getActionObject()); Runnable later = new Runnable() { @Override public void run() { action.execute(event); } }; invokeLater(later); } } } }
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 POST if (!"POST".equals(request.getMethod())) { LOG.warn("Menu item on a request that is not a POST. Will be ignored."); return; } // Execute associated action, if set final Action action = getAction(); if (action != null) { final ActionEvent event = new ActionEvent(this, this.getActionCommand(), this. getActionObject()); Runnable later = new Runnable() { @Override public void run() { action.execute(event); } }; invokeLater(later); } } } }
[ "@", "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 POST", "if", "(", "!", "\"POST\"", ".", "equals", "(", "request", ".", "getMethod", "(", ")", ")", ")", "{", "LOG", ".", "warn", "(", "\"Menu item on a request that is not a POST. Will be ignored.\"", ")", ";", "return", ";", "}", "// Execute associated action, if set", "final", "Action", "action", "=", "getAction", "(", ")", ";", "if", "(", "action", "!=", "null", ")", "{", "final", "ActionEvent", "event", "=", "new", "ActionEvent", "(", "this", ",", "this", ".", "getActionCommand", "(", ")", ",", "this", ".", "getActionObject", "(", ")", ")", ";", "Runnable", "later", "=", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "action", ".", "execute", "(", "event", ")", ";", "}", "}", ";", "invokeLater", "(", "later", ")", ";", "}", "}", "}", "}" ]
Override handleRequest in order to perform processing for this component. This implementation checks for selection of the menu item, and executes the associated action if it has been set. @param request the request being responded to.
[ "Override", "handleRequest", "in", "order", "to", "perform", "processing", "for", "this", "component", ".", "This", "implementation", "checks", "for", "selection", "of", "the", "menu", "item", "and", "executes", "the", "associated", "action", "if", "it", "has", "been", "set", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMenuItem.java#L428-L463
139,281
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMenuItem.java
WMenuItem.isMenuPresent
protected boolean isMenuPresent(final Request request) { WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, this); if (menu != null) { return menu.isPresent(request); } return false; }
java
protected boolean isMenuPresent(final Request request) { WMenu menu = WebUtilities.getAncestorOfClass(WMenu.class, this); if (menu != null) { return menu.isPresent(request); } return false; }
[ "protected", "boolean", "isMenuPresent", "(", "final", "Request", "request", ")", "{", "WMenu", "menu", "=", "WebUtilities", ".", "getAncestorOfClass", "(", "WMenu", ".", "class", ",", "this", ")", ";", "if", "(", "menu", "!=", "null", ")", "{", "return", "menu", ".", "isPresent", "(", "request", ")", ";", "}", "return", "false", ";", "}" ]
Determine if this WMenuItem's parent WMenu is on the Request. @param request the request being responded to. @return true if this WMenuItem's WMenu is on the Request, otherwise return false.
[ "Determine", "if", "this", "WMenuItem", "s", "parent", "WMenu", "is", "on", "the", "Request", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WMenuItem.java#L471-L479
139,282
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDropdown.java
WDropdown.setEditable
@Deprecated @Override public void setEditable(final boolean editable) { setType(editable ? DropdownType.COMBO : DropdownType.NATIVE); }
java
@Deprecated @Override public void setEditable(final boolean editable) { setType(editable ? DropdownType.COMBO : DropdownType.NATIVE); }
[ "@", "Deprecated", "@", "Override", "public", "void", "setEditable", "(", "final", "boolean", "editable", ")", "{", "setType", "(", "editable", "?", "DropdownType", ".", "COMBO", ":", "DropdownType", ".", "NATIVE", ")", ";", "}" ]
Sets whether the users are able to enter in an arbitrary value, rather than having to pick one from the drop-down list. @param editable true for editable, false for fixed. @deprecated editable no longer required. WSuggestions and a WTextfield should be used instead
[ "Sets", "whether", "the", "users", "are", "able", "to", "enter", "in", "an", "arbitrary", "value", "rather", "than", "having", "to", "pick", "one", "from", "the", "drop", "-", "down", "list", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDropdown.java#L192-L196
139,283
BorderTech/wcomponents
wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/TreePicker.java
TreePicker.buildUI
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(exampleSection); // An application footer? WPanel footer = new WPanel(WPanel.Type.FOOTER); footer.add(lastLoaded); add(footer); add(new WAjaxControl(menuPanel.getTree(), new AjaxTarget[]{menuPanel.getMenu(), exampleSection})); }
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(exampleSection); // An application footer? WPanel footer = new WPanel(WPanel.Type.FOOTER); footer.add(lastLoaded); add(footer); add(new WAjaxControl(menuPanel.getTree(), new AjaxTarget[]{menuPanel.getMenu(), exampleSection})); }
[ "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", "(", "exampleSection", ")", ";", "// An application footer?", "WPanel", "footer", "=", "new", "WPanel", "(", "WPanel", ".", "Type", ".", "FOOTER", ")", ";", "footer", ".", "add", "(", "lastLoaded", ")", ";", "add", "(", "footer", ")", ";", "add", "(", "new", "WAjaxControl", "(", "menuPanel", ".", "getTree", "(", ")", ",", "new", "AjaxTarget", "[", "]", "{", "menuPanel", ".", "getMenu", "(", ")", ",", "exampleSection", "}", ")", ")", ";", "}" ]
Add all the bits in the right order.
[ "Add", "all", "the", "bits", "in", "the", "right", "order", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/picker/TreePicker.java#L96-L114
139,284
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPopupRenderer.java
WPopupRenderer.doRender
@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.appendTagOpen("ui:popup"); xml.appendUrlAttribute("url", popup.getUrl()); xml.appendOptionalAttribute("width", width > 0, width); xml.appendOptionalAttribute("height", height > 0, height); xml.appendOptionalAttribute("resizable", popup.isResizable(), "true"); xml.appendOptionalAttribute("showScrollbars", popup.isScrollable(), "true"); xml.appendOptionalAttribute("targetWindow", !Util.empty(targetWindow), targetWindow); xml.appendClose(); xml.appendEndTag("ui:popup"); }
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.appendTagOpen("ui:popup"); xml.appendUrlAttribute("url", popup.getUrl()); xml.appendOptionalAttribute("width", width > 0, width); xml.appendOptionalAttribute("height", height > 0, height); xml.appendOptionalAttribute("resizable", popup.isResizable(), "true"); xml.appendOptionalAttribute("showScrollbars", popup.isScrollable(), "true"); xml.appendOptionalAttribute("targetWindow", !Util.empty(targetWindow), targetWindow); xml.appendClose(); xml.appendEndTag("ui:popup"); }
[ "@", "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", ".", "appendTagOpen", "(", "\"ui:popup\"", ")", ";", "xml", ".", "appendUrlAttribute", "(", "\"url\"", ",", "popup", ".", "getUrl", "(", ")", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"width\"", ",", "width", ">", "0", ",", "width", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"height\"", ",", "height", ">", "0", ",", "height", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"resizable\"", ",", "popup", ".", "isResizable", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"showScrollbars\"", ",", "popup", ".", "isScrollable", "(", ")", ",", "\"true\"", ")", ";", "xml", ".", "appendOptionalAttribute", "(", "\"targetWindow\"", ",", "!", "Util", ".", "empty", "(", "targetWindow", ")", ",", "targetWindow", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "xml", ".", "appendEndTag", "(", "\"ui:popup\"", ")", ";", "}" ]
Paints the given WPopup. @param component the WPopup to paint. @param renderContext the RenderContext to paint to.
[ "Paints", "the", "given", "WPopup", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/WPopupRenderer.java#L24-L41
139,285
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.dump
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
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; }
[ "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", ";", "}" ]
Dumps the contents of the session attributes. @param obj the object to dump. @return the dump of the given object.
[ "Dumps", "the", "contents", "of", "the", "session", "attributes", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L64-L71
139,286
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.visit
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)) { ObjectGraphNode ref = visitedNodes.get(currentValue); currentNode.setRefNode(ref); return; } markObjectVisited(currentNode); if (currentValue instanceof List) { // ArrayList's elementData is marked transient, and others may be as well, so we have to do this ourselves. visitList(currentNode); } else if (currentValue instanceof Map) { // HashMap's table is marked transient, and others may be as well, so we have to do this ourselves. visitMap(currentNode); } else if (currentValue instanceof ComponentModel) { // Special case for ComponentModel, so we can figure out if any fields are overridden visitComponentModel(currentNode); } else if (currentValue instanceof Field) { visitComplexType(currentNode); summariseNode(currentNode); } else if (currentValue.getClass().isArray()) { visitArray(currentNode); } else { visitComplexType(currentNode); } }
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)) { ObjectGraphNode ref = visitedNodes.get(currentValue); currentNode.setRefNode(ref); return; } markObjectVisited(currentNode); if (currentValue instanceof List) { // ArrayList's elementData is marked transient, and others may be as well, so we have to do this ourselves. visitList(currentNode); } else if (currentValue instanceof Map) { // HashMap's table is marked transient, and others may be as well, so we have to do this ourselves. visitMap(currentNode); } else if (currentValue instanceof ComponentModel) { // Special case for ComponentModel, so we can figure out if any fields are overridden visitComponentModel(currentNode); } else if (currentValue instanceof Field) { visitComplexType(currentNode); summariseNode(currentNode); } else if (currentValue.getClass().isArray()) { visitArray(currentNode); } else { visitComplexType(currentNode); } }
[ "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", ")", ")", "{", "ObjectGraphNode", "ref", "=", "visitedNodes", ".", "get", "(", "currentValue", ")", ";", "currentNode", ".", "setRefNode", "(", "ref", ")", ";", "return", ";", "}", "markObjectVisited", "(", "currentNode", ")", ";", "if", "(", "currentValue", "instanceof", "List", ")", "{", "// ArrayList's elementData is marked transient, and others may be as well, so we have to do this ourselves.", "visitList", "(", "currentNode", ")", ";", "}", "else", "if", "(", "currentValue", "instanceof", "Map", ")", "{", "// HashMap's table is marked transient, and others may be as well, so we have to do this ourselves.", "visitMap", "(", "currentNode", ")", ";", "}", "else", "if", "(", "currentValue", "instanceof", "ComponentModel", ")", "{", "// Special case for ComponentModel, so we can figure out if any fields are overridden", "visitComponentModel", "(", "currentNode", ")", ";", "}", "else", "if", "(", "currentValue", "instanceof", "Field", ")", "{", "visitComplexType", "(", "currentNode", ")", ";", "summariseNode", "(", "currentNode", ")", ";", "}", "else", "if", "(", "currentValue", ".", "getClass", "(", ")", ".", "isArray", "(", ")", ")", "{", "visitArray", "(", "currentNode", ")", ";", "}", "else", "{", "visitComplexType", "(", "currentNode", ")", ";", "}", "}" ]
Implementation of the tree walk. @param currentNode the node being visited.
[ "Implementation", "of", "the", "tree", "walk", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L78-L112
139,287
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.visitComplexType
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 ObjectGraphNode(++nodeCount, fields[i].getName(), fieldType, fieldValue); node.add(childNode); visit(childNode); } }
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 ObjectGraphNode(++nodeCount, fields[i].getName(), fieldType, fieldValue); node.add(childNode); visit(childNode); } }
[ "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", "ObjectGraphNode", "(", "++", "nodeCount", ",", "fields", "[", "i", "]", ".", "getName", "(", ")", ",", "fieldType", ",", "fieldValue", ")", ";", "node", ".", "add", "(", "childNode", ")", ";", "visit", "(", "childNode", ")", ";", "}", "}" ]
Visits all the fields in the given complex object. @param node the ObjectGraphNode containing the object.
[ "Visits", "all", "the", "fields", "in", "the", "given", "complex", "object", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L119-L131
139,288
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.visitComplexTypeWithDiff
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.length; i++) { Object fieldValue = readField(fields[i], node.getValue()); Object otherValue = readField(fields[i], otherInstance); String fieldType = fields[i].getType().getName(); String nodeFieldName = fields[i].getName() + (Util.equals(fieldValue, otherValue) ? "" : "*"); ObjectGraphNode childNode = new ObjectGraphNode(++nodeCount, nodeFieldName, fieldType, fieldValue); node.add(childNode); visit(childNode); } } }
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.length; i++) { Object fieldValue = readField(fields[i], node.getValue()); Object otherValue = readField(fields[i], otherInstance); String fieldType = fields[i].getType().getName(); String nodeFieldName = fields[i].getName() + (Util.equals(fieldValue, otherValue) ? "" : "*"); ObjectGraphNode childNode = new ObjectGraphNode(++nodeCount, nodeFieldName, fieldType, fieldValue); node.add(childNode); visit(childNode); } } }
[ "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", ".", "length", ";", "i", "++", ")", "{", "Object", "fieldValue", "=", "readField", "(", "fields", "[", "i", "]", ",", "node", ".", "getValue", "(", ")", ")", ";", "Object", "otherValue", "=", "readField", "(", "fields", "[", "i", "]", ",", "otherInstance", ")", ";", "String", "fieldType", "=", "fields", "[", "i", "]", ".", "getType", "(", ")", ".", "getName", "(", ")", ";", "String", "nodeFieldName", "=", "fields", "[", "i", "]", ".", "getName", "(", ")", "+", "(", "Util", ".", "equals", "(", "fieldValue", ",", "otherValue", ")", "?", "\"\"", ":", "\"*\"", ")", ";", "ObjectGraphNode", "childNode", "=", "new", "ObjectGraphNode", "(", "++", "nodeCount", ",", "nodeFieldName", ",", "fieldType", ",", "fieldValue", ")", ";", "node", ".", "add", "(", "childNode", ")", ";", "visit", "(", "childNode", ")", ";", "}", "}", "}" ]
Visits all the fields in the given complex object, noting differences. @param node the ObjectGraphNode containing the object. @param otherInstance the other instance to compare to
[ "Visits", "all", "the", "fields", "in", "the", "given", "complex", "object", "noting", "differences", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L139-L158
139,289
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.visitComponentModel
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 (int i = 0; i < fields.length; i++) { if (ComponentModel.class.equals(fields[i].getDeclaringClass()) && "sharedModel".equals(fields[i].getName())) { sharedModel = (ComponentModel) readField(fields[i], model); } } visitComplexTypeWithDiff(node, sharedModel); }
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 (int i = 0; i < fields.length; i++) { if (ComponentModel.class.equals(fields[i].getDeclaringClass()) && "sharedModel".equals(fields[i].getName())) { sharedModel = (ComponentModel) readField(fields[i], model); } } visitComplexTypeWithDiff(node, sharedModel); }
[ "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", "(", "int", "i", "=", "0", ";", "i", "<", "fields", ".", "length", ";", "i", "++", ")", "{", "if", "(", "ComponentModel", ".", "class", ".", "equals", "(", "fields", "[", "i", "]", ".", "getDeclaringClass", "(", ")", ")", "&&", "\"sharedModel\"", ".", "equals", "(", "fields", "[", "i", "]", ".", "getName", "(", ")", ")", ")", "{", "sharedModel", "=", "(", "ComponentModel", ")", "readField", "(", "fields", "[", "i", "]", ",", "model", ")", ";", "}", "}", "visitComplexTypeWithDiff", "(", "node", ",", "sharedModel", ")", ";", "}" ]
Visits all the fields in the given ComponentModel. @param node the ObjectGraphNode containing the ComponentModel.
[ "Visits", "all", "the", "fields", "in", "the", "given", "ComponentModel", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L165-L180
139,290
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.readField
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 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; }
[ "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", ";", "}" ]
Reads the contents of a field. @param field the field definition. @param obj the object to read the value from. @return the value of the field in the given object.
[ "Reads", "the", "contents", "of", "a", "field", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L189-L198
139,291
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.visitArray
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 childNode = new ObjectGraphNode(++nodeCount, "[" + i + "]", entryType, array[i]); node.add(childNode); visit(childNode); } } else { ObjectGraphNode childNode = new ObjectGraphNode(++nodeCount, "[primitive array]", node. getValue().getClass().getName(), node.getValue()); node.add(childNode); } }
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 childNode = new ObjectGraphNode(++nodeCount, "[" + i + "]", entryType, array[i]); node.add(childNode); visit(childNode); } } else { ObjectGraphNode childNode = new ObjectGraphNode(++nodeCount, "[primitive array]", node. getValue().getClass().getName(), node.getValue()); node.add(childNode); } }
[ "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", "childNode", "=", "new", "ObjectGraphNode", "(", "++", "nodeCount", ",", "\"[\"", "+", "i", "+", "\"]\"", ",", "entryType", ",", "array", "[", "i", "]", ")", ";", "node", ".", "add", "(", "childNode", ")", ";", "visit", "(", "childNode", ")", ";", "}", "}", "else", "{", "ObjectGraphNode", "childNode", "=", "new", "ObjectGraphNode", "(", "++", "nodeCount", ",", "\"[primitive array]\"", ",", "node", ".", "getValue", "(", ")", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "node", ".", "getValue", "(", ")", ")", ";", "node", ".", "add", "(", "childNode", ")", ";", "}", "}" ]
Visits all the elements of the given array. @param node the ObjectGraphNode containing the array.
[ "Visits", "all", "the", "elements", "of", "the", "given", "array", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L205-L223
139,292
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.visitList
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(++nodeCount, "[" + index++ + "]", entryType, entry); node.add(childNode); visit(childNode); } adjustOverhead(node); }
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(++nodeCount, "[" + index++ + "]", entryType, entry); node.add(childNode); visit(childNode); } adjustOverhead(node); }
[ "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", "(", "++", "nodeCount", ",", "\"[\"", "+", "index", "++", "+", "\"]\"", ",", "entryType", ",", "entry", ")", ";", "node", ".", "add", "(", "childNode", ")", ";", "visit", "(", "childNode", ")", ";", "}", "adjustOverhead", "(", "node", ")", ";", "}" ]
Visits all the elements of the given list. @param node the ObjectGraphNode containing the list.
[ "Visits", "all", "the", "elements", "of", "the", "given", "list", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L230-L244
139,293
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.summariseNode
private void summariseNode(final ObjectGraphNode node) { int size = node.getSize(); node.removeAll(); node.setSize(size); }
java
private void summariseNode(final ObjectGraphNode node) { int size = node.getSize(); node.removeAll(); node.setSize(size); }
[ "private", "void", "summariseNode", "(", "final", "ObjectGraphNode", "node", ")", "{", "int", "size", "=", "node", ".", "getSize", "(", ")", ";", "node", ".", "removeAll", "(", ")", ";", "node", ".", "setSize", "(", "size", ")", ";", "}" ]
For some types, we don't care about their internals, so just summarise the size. @param node the node to summarise.
[ "For", "some", "types", "we", "don", "t", "care", "about", "their", "internals", "so", "just", "summarise", "the", "size", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L251-L255
139,294
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.visitMap
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", key.getClass(). getName(), key); node.add(keyNode); visit(keyNode); } else { ObjectGraphNode keyNode = new ObjectGraphNode(++nodeCount, "key", Object.class. getName(), null); node.add(keyNode); } Object value = entry.getValue(); if (value != null) { ObjectGraphNode valueNode = new ObjectGraphNode(++nodeCount, "value", value. getClass().getName(), value); node.add(valueNode); visit(valueNode); } else { ObjectGraphNode valueNode = new ObjectGraphNode(++nodeCount, "value", Object.class. getName(), null); node.add(valueNode); } } adjustOverhead(node); }
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", key.getClass(). getName(), key); node.add(keyNode); visit(keyNode); } else { ObjectGraphNode keyNode = new ObjectGraphNode(++nodeCount, "key", Object.class. getName(), null); node.add(keyNode); } Object value = entry.getValue(); if (value != null) { ObjectGraphNode valueNode = new ObjectGraphNode(++nodeCount, "value", value. getClass().getName(), value); node.add(valueNode); visit(valueNode); } else { ObjectGraphNode valueNode = new ObjectGraphNode(++nodeCount, "value", Object.class. getName(), null); node.add(valueNode); } } adjustOverhead(node); }
[ "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\"", ",", "key", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "key", ")", ";", "node", ".", "add", "(", "keyNode", ")", ";", "visit", "(", "keyNode", ")", ";", "}", "else", "{", "ObjectGraphNode", "keyNode", "=", "new", "ObjectGraphNode", "(", "++", "nodeCount", ",", "\"key\"", ",", "Object", ".", "class", ".", "getName", "(", ")", ",", "null", ")", ";", "node", ".", "add", "(", "keyNode", ")", ";", "}", "Object", "value", "=", "entry", ".", "getValue", "(", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "ObjectGraphNode", "valueNode", "=", "new", "ObjectGraphNode", "(", "++", "nodeCount", ",", "\"value\"", ",", "value", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "value", ")", ";", "node", ".", "add", "(", "valueNode", ")", ";", "visit", "(", "valueNode", ")", ";", "}", "else", "{", "ObjectGraphNode", "valueNode", "=", "new", "ObjectGraphNode", "(", "++", "nodeCount", ",", "\"value\"", ",", "Object", ".", "class", ".", "getName", "(", ")", ",", "null", ")", ";", "node", ".", "add", "(", "valueNode", ")", ";", "}", "}", "adjustOverhead", "(", "node", ")", ";", "}" ]
Visits all the keys and entries of the given map. @param node the ObjectGraphNode containing the map.
[ "Visits", "all", "the", "keys", "and", "entries", "of", "the", "given", "map", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L292-L325
139,295
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java
ObjectGraphDump.getAllInstanceFields
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()]); instanceFieldsByClass.put(obj.getClass(), fields); } return fields; }
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()]); instanceFieldsByClass.put(obj.getClass(), fields); } return fields; }
[ "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", "(", ")", "]", ")", ";", "instanceFieldsByClass", ".", "put", "(", "obj", ".", "getClass", "(", ")", ",", "fields", ")", ";", "}", "return", "fields", ";", "}" ]
Retrieves all the instance fields for the given object. @param obj the object to examine @return an array of instance fields for the given object
[ "Retrieves", "all", "the", "instance", "fields", "for", "the", "given", "object", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/util/ObjectGraphDump.java#L352-L364
139,296
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/DiagnosticRenderUtil.java
DiagnosticRenderUtil.renderHelper
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", "_wc_".concat(UUID.randomUUID().toString())); xml.appendAttribute("type", getLevel(severity)); xml.appendAttribute("for", component.getId()); xml.appendClose(); for (Diagnostic diagnostic : diags) { xml.appendTag(MESSAGE_TAG_NAME); xml.appendEscaped(diagnostic.getDescription()); xml.appendEndTag(MESSAGE_TAG_NAME); } xml.appendEndTag(TAG_NAME); }
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", "_wc_".concat(UUID.randomUUID().toString())); xml.appendAttribute("type", getLevel(severity)); xml.appendAttribute("for", component.getId()); xml.appendClose(); for (Diagnostic diagnostic : diags) { xml.appendTag(MESSAGE_TAG_NAME); xml.appendEscaped(diagnostic.getDescription()); xml.appendEndTag(MESSAGE_TAG_NAME); } xml.appendEndTag(TAG_NAME); }
[ "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\"", ",", "\"_wc_\"", ".", "concat", "(", "UUID", ".", "randomUUID", "(", ")", ".", "toString", "(", ")", ")", ")", ";", "xml", ".", "appendAttribute", "(", "\"type\"", ",", "getLevel", "(", "severity", ")", ")", ";", "xml", ".", "appendAttribute", "(", "\"for\"", ",", "component", ".", "getId", "(", ")", ")", ";", "xml", ".", "appendClose", "(", ")", ";", "for", "(", "Diagnostic", "diagnostic", ":", "diags", ")", "{", "xml", ".", "appendTag", "(", "MESSAGE_TAG_NAME", ")", ";", "xml", ".", "appendEscaped", "(", "diagnostic", ".", "getDescription", "(", ")", ")", ";", "xml", ".", "appendEndTag", "(", "MESSAGE_TAG_NAME", ")", ";", "}", "xml", ".", "appendEndTag", "(", "TAG_NAME", ")", ";", "}" ]
Render the diagnostics. @param renderContext the current renderContext @param component the component being rendered @param diags the list of Diagnostic objects @param severity the severity we are rendering
[ "Render", "the", "diagnostics", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/DiagnosticRenderUtil.java#L59-L80
139,297
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/DiagnosticRenderUtil.java
DiagnosticRenderUtil.renderDiagnostics
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.WARNING); if (diags != null) { renderHelper(renderContext, component, diags, Diagnostic.WARNING); } diags = component.getDiagnostics(Diagnostic.INFO); if (diags != null) { renderHelper(renderContext, component, diags, Diagnostic.INFO); } diags = component.getDiagnostics(Diagnostic.SUCCESS); if (diags != null) { renderHelper(renderContext, component, diags, Diagnostic.SUCCESS); } }
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.WARNING); if (diags != null) { renderHelper(renderContext, component, diags, Diagnostic.WARNING); } diags = component.getDiagnostics(Diagnostic.INFO); if (diags != null) { renderHelper(renderContext, component, diags, Diagnostic.INFO); } diags = component.getDiagnostics(Diagnostic.SUCCESS); if (diags != null) { renderHelper(renderContext, component, diags, Diagnostic.SUCCESS); } }
[ "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", ".", "WARNING", ")", ";", "if", "(", "diags", "!=", "null", ")", "{", "renderHelper", "(", "renderContext", ",", "component", ",", "diags", ",", "Diagnostic", ".", "WARNING", ")", ";", "}", "diags", "=", "component", ".", "getDiagnostics", "(", "Diagnostic", ".", "INFO", ")", ";", "if", "(", "diags", "!=", "null", ")", "{", "renderHelper", "(", "renderContext", ",", "component", ",", "diags", ",", "Diagnostic", ".", "INFO", ")", ";", "}", "diags", "=", "component", ".", "getDiagnostics", "(", "Diagnostic", ".", "SUCCESS", ")", ";", "if", "(", "diags", "!=", "null", ")", "{", "renderHelper", "(", "renderContext", ",", "component", ",", "diags", ",", "Diagnostic", ".", "SUCCESS", ")", ";", "}", "}" ]
Render diagnostics for the component. @param component the component being rendered @param renderContext the RenderContext to paint to.
[ "Render", "diagnostics", "for", "the", "component", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/render/webxml/DiagnosticRenderUtil.java#L87-L104
139,298
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/WrongStepAjaxInterceptor.java
WrongStepAjaxInterceptor.handleWarpToTheFuture
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 handleStepError method will be called on WApplication."); ((WApplication) application).handleStepError(); } }
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 handleStepError method will be called on WApplication."); ((WApplication) application).handleStepError(); } }
[ "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 handleStepError method will be called on WApplication.\"", ")", ";", "(", "(", "WApplication", ")", "application", ")", ".", "handleStepError", "(", ")", ";", "}", "}" ]
Warp the user to the future by replacing the entire page. @param uic the current user context
[ "Warp", "the", "user", "to", "the", "future", "by", "replacing", "the", "entire", "page", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/WrongStepAjaxInterceptor.java#L141-L154
139,299
BorderTech/wcomponents
wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/WrongStepAjaxInterceptor.java
WrongStepAjaxInterceptor.handleRenderRedirect
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.getXMLDeclarationWithThemeXslt(uic)); writer.print("<ui:ajaxresponse "); writer.print(XMLUtil.UI_NAMESPACE); writer.print(">"); writer.print("<ui:ajaxtarget id=\"" + triggerId + "\" action=\"replace\">"); // Redirect URL writer.print("<ui:redirect url=\"" + redirectUrl + "\" />"); writer.print("</ui:ajaxtarget>"); writer.print("</ui:ajaxresponse>"); }
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.getXMLDeclarationWithThemeXslt(uic)); writer.print("<ui:ajaxresponse "); writer.print(XMLUtil.UI_NAMESPACE); writer.print(">"); writer.print("<ui:ajaxtarget id=\"" + triggerId + "\" action=\"replace\">"); // Redirect URL writer.print("<ui:redirect url=\"" + redirectUrl + "\" />"); writer.print("</ui:ajaxtarget>"); writer.print("</ui:ajaxresponse>"); }
[ "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", ".", "getXMLDeclarationWithThemeXslt", "(", "uic", ")", ")", ";", "writer", ".", "print", "(", "\"<ui:ajaxresponse \"", ")", ";", "writer", ".", "print", "(", "XMLUtil", ".", "UI_NAMESPACE", ")", ";", "writer", ".", "print", "(", "\">\"", ")", ";", "writer", ".", "print", "(", "\"<ui:ajaxtarget id=\\\"\"", "+", "triggerId", "+", "\"\\\" action=\\\"replace\\\">\"", ")", ";", "// Redirect URL", "writer", ".", "print", "(", "\"<ui:redirect url=\\\"\"", "+", "redirectUrl", "+", "\"\\\" />\"", ")", ";", "writer", ".", "print", "(", "\"</ui:ajaxtarget>\"", ")", ";", "writer", ".", "print", "(", "\"</ui:ajaxresponse>\"", ")", ";", "}" ]
Redirect the user via the AJAX response. @param writer the print writer for the response
[ "Redirect", "the", "user", "via", "the", "AJAX", "response", "." ]
d1a2b2243270067db030feb36ca74255aaa94436
https://github.com/BorderTech/wcomponents/blob/d1a2b2243270067db030feb36ca74255aaa94436/wcomponents-core/src/main/java/com/github/bordertech/wcomponents/container/WrongStepAjaxInterceptor.java#L161-L180