List of usage examples for org.apache.commons.lang ArrayUtils add
public static short[] add(short[] array, short element)
Copies the given array and adds the given element at the end of the new array.
From source file:org.LexGrid.LexBIG.Impl.Extensions.Search.AbstractLiteralSearch.java
/** * Gets the tokens with special characters. * /* w ww .ja v a2 s. c om*/ * @param tokens the tokens * * @return the tokens with special characters */ protected String[] getTokensWithSpecialCharacters(String[] tokens) { String[] returnArray = new String[0]; for (String token : tokens) { if (doesSearchStringContainSpecialCharacters(token)) { returnArray = (String[]) ArrayUtils.add(returnArray, token); } } return returnArray; }
From source file:org.LexGrid.LexBIG.Impl.Extensions.Search.AbstractLiteralSearch.java
/** * Gets the tokens without special characters. * //from w w w . ja v a2 s . c om * @param tokens the tokens * * @return the tokens without special characters */ protected String[] getTokensWithoutSpecialCharacters(String[] tokens) { String[] returnArray = new String[0]; for (String token : tokens) { if (!doesSearchStringContainSpecialCharacters(token)) { returnArray = (String[]) ArrayUtils.add(returnArray, token); } } return returnArray; }
From source file:org.lilyproject.tools.tester.ReadAction.java
private void readBlobs(Record readRecord, QName fieldName, Object value, ValueType valueType, int... indexes) throws RepositoryException, InterruptedException, IOException { if (valueType.getBaseName().equals("LIST")) { List<Object> multivalues = (List<Object>) (value); int multivalueIndex = randomIndex(multivalues.size()); Object subValue = (multivalues.get(multivalueIndex)); indexes = ArrayUtils.add(indexes, multivalueIndex); readBlobs(readRecord, fieldName, subValue, valueType.getNestedValueType(), indexes); } else if (valueType.getBaseName().equals("PATH")) { Object[] hierarchyValues = ((HierarchyPath) (value)).getElements(); int hierarchyIndex = randomIndex(hierarchyValues.length); Object subValue = hierarchyValues[hierarchyIndex]; indexes = ArrayUtils.add(indexes, hierarchyIndex); readBlobs(readRecord, fieldName, subValue, valueType.getNestedValueType(), indexes); } else {/*from w ww .j a v a 2 s.co m*/ Blob blob = (Blob) value; InputStream inputStream = testActionContext.table.getInputStream(readRecord, fieldName, indexes); readBlobBytes(blob, inputStream); } }
From source file:org.marketcetera.util.file.SmartLinksDirectoryWalkerTest.java
@Test public void walk() throws Exception { String root;/* www.j av a2 s.c o m*/ String dir; String[] files = TEST_FILE_LIST; if (OperatingSystem.LOCAL.isUnix()) { dir = TEST_DIR_UNIX; root = TEST_ROOT_UNIX; files = (String[]) ArrayUtils.add(files, TEST_LINK_NAME); } else if (OperatingSystem.LOCAL.isWin32()) { dir = TEST_DIR_WIN32; root = TEST_ROOT_WIN32; } else { throw new AssertionError("Unknown platform"); } String[] dirs = (String[]) ArrayUtils.add(TEST_DIR_LIST, dir); ListWalker walker = new ListWalker(false); walker.apply(root); assertArrayPermutation(files, walker.getFiles()); assertArrayPermutation(dirs, walker.getDirectories()); assertEquals(3, walker.getMaxDepth()); Vector<String> results = new Vector<String>(); walker = new ListWalker(false); walker.apply(root, results); assertArrayPermutation(files, walker.getFiles()); assertArrayPermutation(dirs, walker.getDirectories()); assertArrayPermutation(ArrayUtils.addAll(files, dirs), results.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); assertEquals(3, walker.getMaxDepth()); files = TEST_FILE_LIST; dirs = (String[]) ArrayUtils.add(TEST_DIR_LIST, dir); if (OperatingSystem.LOCAL.isUnix()) { files = (String[]) ArrayUtils.add(files, TEST_LINK_CONTENTS); dirs = (String[]) ArrayUtils.add(dirs, TEST_LINK_NAME); } walker = new ListWalker(true); walker.apply(root); assertArrayPermutation(files, walker.getFiles()); assertArrayPermutation(dirs, walker.getDirectories()); assertEquals(3, walker.getMaxDepth()); results = new Vector<String>(); walker = new ListWalker(true); walker.apply(root, results); assertArrayPermutation(files, walker.getFiles()); assertArrayPermutation(dirs, walker.getDirectories()); assertArrayPermutation(ArrayUtils.addAll(files, dirs), results.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); assertEquals(3, walker.getMaxDepth()); }
From source file:org.moneta.config.dropwizard.MonetaDropwizardApplication.java
public static void main(String[] args) throws Exception { String[] localArgs = args;//from ww w . j a v a 2s . c om if (!containsConfiguration(args)) { // Add default config if nothing specified localArgs = (String[]) ArrayUtils.add(args, "/moneta-config.yaml"); } new MonetaDropwizardApplication().run(localArgs); }
From source file:org.moneta.SearchRequestFactory.java
public SearchRequest deriveSearchRequest(HttpServletRequest request) { String[] uriNodes = deriveSearchNodes(request); if (ArrayUtils.isEmpty(uriNodes)) { throw new MonetaException("Search topic not provided in request uri") .addContextValue("request path info", request.getPathInfo()) .addContextValue("request context path", request.getContextPath()) .addContextValue("request uri", request.getRequestURI()); }//from w w w . j a va 2 s. c o m SearchRequest searchRequest = new SearchRequest(); String topicRequested = uriNodes[0]; Topic searchTopic = findSearchTopic(topicRequested); searchRequest.setTopic(searchTopic.getTopicName()); CompositeCriteria baseCriteria = new CompositeCriteria(); searchRequest.setSearchCriteria(baseCriteria); baseCriteria.setOperator(CompositeCriteria.Operator.AND); baseCriteria.setSearchCriteria(new FilterCriteria[0]); FilterCriteria filterCriteria = null; TopicKeyField keyField = null; // TODO put in logic for request parms startRow, maxRows, and returnFields String parmStr = request.getParameter(RequestConstants.PARM_START_ROW); if (StringUtils.isNotEmpty(parmStr)) { try { searchRequest.setStartRow(Long.valueOf(parmStr)); } catch (Exception e) { throw new MonetaException("Invalid start row request parm", e) .addContextValue(RequestConstants.PARM_START_ROW, parmStr); } } parmStr = request.getParameter(RequestConstants.PARM_MAX_ROWS); if (StringUtils.isNotEmpty(parmStr)) { try { searchRequest.setMaxRows(Long.valueOf(parmStr)); } catch (Exception e) { throw new MonetaException("Invalid max rows request parm", e) .addContextValue(RequestConstants.PARM_MAX_ROWS, parmStr); } } for (int pathParamOffset = 1; pathParamOffset < uriNodes.length; pathParamOffset++) { if (searchTopic.getKeyFieldList().size() < pathParamOffset) { throw new MonetaException("Search key in request uri not configured for topic") .addContextValue("search key", uriNodes[pathParamOffset]) .addContextValue("topic", searchRequest.getTopic()) .addContextValue("request path info", request.getPathInfo()) .addContextValue("request context path", request.getContextPath()) .addContextValue("request uri", request.getRequestURI()); } keyField = searchTopic.getKeyFieldList().get(pathParamOffset - 1); filterCriteria = new FilterCriteria(); filterCriteria.setFieldName(keyField.getColumnName()); filterCriteria.setOperation(FilterCriteria.Operation.EQUAL); if (TopicKeyField.DataType.STRING.equals(keyField.getDataType())) { filterCriteria.setValue(uriNodes[pathParamOffset]); } else { // TODO Need to do a better job of normalizing numeric keys and error handling filterCriteria.setValue(Long.valueOf(uriNodes[pathParamOffset])); } baseCriteria.setSearchCriteria( (Criteria[]) ArrayUtils.add(baseCriteria.getSearchCriteria(), filterCriteria)); } // TODO Put in logic for detecting search criteria return searchRequest; }
From source file:org.mrgeo.image.MrsImagePyramidMetadata.java
public void setImageMetadata(final ImageMetadata[] metadata) { // this will make sure the size of the image metadata matched the zoom, with empty levels as needed if (metadata == null) { imageData = metadata;/*from ww w.ja v a2 s.c o m*/ for (int i = 0; i <= maxZoomLevel; i++) { imageData = (ImageMetadata[]) ArrayUtils.add(imageData, new ImageMetadata()); } return; } // this could be the case when reading the data in, but the maxzoom comes after the imagedata // in the JSON if (maxZoomLevel <= 0) { setMaxZoomLevel(metadata.length - 1); } imageData = metadata; if ((maxZoomLevel + 1) < imageData.length) { imageData = (ImageMetadata[]) ArrayUtils.subarray(metadata, 0, maxZoomLevel + 1); } else if (maxZoomLevel > imageData.length) { for (int i = imageData.length; i <= maxZoomLevel; i++) { imageData = (ImageMetadata[]) ArrayUtils.add(imageData, new ImageMetadata()); } } }
From source file:org.mrgeo.image.MrsImagePyramidMetadata.java
@Override public void setMaxZoomLevel(final int zoomlevel) { if (imageData == null) { for (int i = 0; i <= zoomlevel; i++) { imageData = (ImageMetadata[]) ArrayUtils.add(imageData, new ImageMetadata()); }//from w ww . j a va2 s . co m } else if (zoomlevel < maxZoomLevel) { imageData = (ImageMetadata[]) ArrayUtils.subarray(imageData, 0, zoomlevel + 1); } else if (zoomlevel > maxZoomLevel) { for (int i = maxZoomLevel + 1; i <= zoomlevel; i++) { imageData = (ImageMetadata[]) ArrayUtils.add(imageData, new ImageMetadata()); } } this.maxZoomLevel = zoomlevel; }
From source file:org.mrgeo.vector.mrsvector.MrsVectorPyramidMetadata.java
public void setMaxZoomLevel(final int zoomlevel) { if (vectorData == null) { for (int i = 0; i <= zoomlevel; i++) { vectorData = (VectorMetadata[]) ArrayUtils.add(vectorData, new VectorMetadata()); }/*from w w w .j a v a2 s . c o m*/ } else if (zoomlevel < maxZoomLevel) { vectorData = (VectorMetadata[]) ArrayUtils.subarray(vectorData, 0, zoomlevel + 1); } else if (zoomlevel > maxZoomLevel) { for (int i = maxZoomLevel + 1; i <= zoomlevel; i++) { vectorData = (VectorMetadata[]) ArrayUtils.add(vectorData, new VectorMetadata()); } } this.maxZoomLevel = zoomlevel; }
From source file:org.nuxeo.ecm.platform.forms.layout.facelets.plugins.AbstractSelectWidgetTypeHandler.java
protected void apply(FaceletContext ctx, UIComponent parent, Widget widget, String componentType, String rendererType) throws WidgetException, IOException { FaceletHandlerHelper helper = new FaceletHandlerHelper(tagConfig); String mode = widget.getMode(); String widgetId = widget.getId(); String widgetName = widget.getName(); String widgetTagConfigId = widget.getTagConfigId(); List<String> excludedProps = getExcludedProperties(); TagAttributes attributes = helper.getTagAttributes(widget, excludedProps, true); // BBB for CSS style classes on directory select components if (widget.getProperty("cssStyle") != null) { attributes = FaceletHandlerHelper.addTagAttribute(attributes, helper.createAttribute("style", (String) widget.getProperty("cssStyle"))); }/*from ww w .j a va2s. c om*/ if (widget.getProperty("cssStyleClass") != null) { attributes = FaceletHandlerHelper.addTagAttribute(attributes, helper.createAttribute("styleClass", (String) widget.getProperty("cssStyleClass"))); } if (!BuiltinWidgetModes.isLikePlainMode(mode)) { attributes = FaceletHandlerHelper.addTagAttribute(attributes, helper.createAttribute("id", widgetId)); } if (BuiltinWidgetModes.EDIT.equals(mode)) { FaceletHandler optionsHandler = getOptionsFaceletHandler(ctx, helper, widget); FaceletHandler[] nextHandlers = new FaceletHandler[] {}; nextHandlers = (FaceletHandler[]) ArrayUtils.add(nextHandlers, optionsHandler); FaceletHandler leaf = getNextHandler(ctx, tagConfig, widget, nextHandlers, helper, true, true); // maybe add convert handler for easier integration of select2 // widgets handling multiple values if (HtmlSelectManyListbox.COMPONENT_TYPE.equals(componentType) || HtmlSelectManyCheckbox.COMPONENT_TYPE.equals(componentType) || HtmlSelectManyMenu.COMPONENT_TYPE.equals(componentType)) { // add hint for value conversion to collection attributes = FaceletHandlerHelper.addTagAttribute(attributes, helper.createAttribute("collectionType", ArrayList.class.getName())); } ComponentHandler input = helper.getHtmlComponentHandler(widgetTagConfigId, attributes, leaf, componentType, rendererType); String msgId = FaceletHandlerHelper.generateMessageId(ctx, widgetName); ComponentHandler message = helper.getMessageComponentHandler(widgetTagConfigId, msgId, widgetId, null); FaceletHandler[] handlers = { getComponentFaceletHandler(ctx, helper, widget, input), message }; FaceletHandler h = new CompositeFaceletHandler(handlers); h.apply(ctx, parent); } else { // TODO return; } }