List of usage examples for org.apache.commons.lang ArrayUtils getLength
public static int getLength(Object array)
Returns the length of the specified array.
From source file:org.soaplab.clients.spinet.Service.java
/************************************************************************* * *************************************************************************/ protected void createInput(Map<String, Object> app, Map<String, Object> input, List<String> names, List<String> classes, List<String> uis, StringBuilder tooltips, StringBuilder js) { boolean emboss = BooleanUtils.toBoolean((String) app.get(SoaplabConstants.ANALYSIS_EMBOSS)); String name = (String) input.get(SoaplabConstants.INPUT_NAME); String type = (String) input.get(SoaplabConstants.INPUT_TYPE); String defaultValue = (String) input.get(SoaplabConstants.INPUT_DEFAULT_VALUE); String[] allowedValues = (String[]) input.get(SoaplabConstants.INPUT_ALLOWED_VALUES); String format = (String) input.get(SoaplabConstants.INPUT_FORMAT); String datatype = (String) input.get(SoaplabConstants.DATA_TYPE); boolean mandatory = BooleanUtils.toBoolean((String) input.get(SoaplabConstants.INPUT_MANDATORY)); // something only for EMBOSS if (emboss) { if (name.startsWith("send_") || name.startsWith("sbegin_")) { format = "%d"; }/*from ww w .java 2s. c o m*/ } if (ArrayUtils.getLength(allowedValues) > 0) { // allowed values => SELECT names.add(Html.esc(name)); classes.add(createInputTooltipAndClass(name, input, tooltips)); // it's never used but initiates creation of a special select option if (!mandatory && StringUtils.isEmpty(defaultValue)) { defaultValue = "something"; } uis.add(createSelect(name + S_INPUT, defaultValue, allowedValues)); } else if (type.equals(SoaplabConstants.TYPE_BOOLEAN_SIMPLE)) { // boolean type => RADIO GROUP names.add(Html.esc(name)); classes.add(createInputTooltipAndClass(name, input, tooltips)); uis.add(createRadioPair(name + S_INPUT, defaultValue)); } else if (isInputFile(input)) { // input file names.add(Html.esc(name)); classes.add(createInputTooltipAndClass(name, input, tooltips)); uis.add(createDataInput(name, js, input)); } else if (format != null) { // formatted field (requiring some validation) names.add(Html.esc(name)); classes.add(createInputTooltipAndClass(name, input, tooltips)); uis.add(createValidText(name + S_INPUT, input, mandatory, js, format, defaultValue)); } else if ("filelist".equals(datatype)) { // filelist is not supported in Spinet, inform about it names.add(Html.esc(name)); classes.add(createInputTooltipAndClass(name, input, tooltips)); uis.add(createTextWithWarning(name + S_INPUT, mandatory, js, FILELIST_WARNING, VALUE, defaultValue, CLASS, "input-text")); } else { // ...and the rest names.add(Html.esc(name)); classes.add(createInputTooltipAndClass(name, input, tooltips)); uis.add(createText(name + S_INPUT, mandatory, js, VALUE, defaultValue, CLASS, "input-text")); } }
From source file:org.xwiki.platform.patchservice.impl.PositionImpl.java
/** * {@inheritDoc}//from w ww . j a v a2 s .c o m */ public String getTextBeforePosition(String text) { String[] rows = StringUtils.splitPreserveAllTokens(text, SEPARATOR); if (ArrayUtils.getLength(rows) <= this.row) { return StringUtils.defaultString(StringUtils.join(rows, SEPARATOR)) + (this.row == 0 ? "" : "\n"); } return StringUtils.join(ArrayUtils.subarray(rows, 0, this.row), SEPARATOR) + ((this.row > 0) ? SEPARATOR : "") + StringUtils.substring(rows[this.row], 0, this.column); }
From source file:org.xwiki.platform.patchservice.impl.PositionImpl.java
/** * {@inheritDoc}//from w ww.j av a 2s . com */ public String getTextAfterPosition(String text) { String[] rows = StringUtils.splitPreserveAllTokens(text, SEPARATOR); if (ArrayUtils.getLength(rows) <= this.row) { return ""; } String textAfter = StringUtils.substring(rows[this.row], this.column) + ((this.row + 1 < rows.length) ? SEPARATOR : "") + StringUtils.join(ArrayUtils.subarray(rows, this.row + 1, rows.length), SEPARATOR); return (this.span <= 0) ? textAfter : StringUtils.substring(textAfter, this.span); }