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.eclipse.wb.gef.tree.policies.LayoutEditPolicy.java
/** * Add host widget to tree selection.//from www.j av a2 s . c o m */ private void appendToSelection() { TreeItem widget = getHostWidget(); Tree tree = getTree(); TreeItem[] selection = tree.getSelection(); if (!ArrayUtils.contains(selection, widget)) { selection = (TreeItem[]) ArrayUtils.add(selection, widget); tree.setSelection(selection); } }
From source file:org.eclipse.wb.internal.core.model.creation.ThisCreationSupport.java
/** * Try to apply validator from {@link JavaInfo}. *//*from w ww . j a v a 2s .co m*/ private Object visitMethod_validator(java.lang.reflect.Method method, Object[] args, Object result) throws Exception { Class<?>[] validatorParameterTypes = (Class<?>[]) ArrayUtils.add(method.getParameterTypes(), Object.class); String validatorName = method.getName() + "_validator"; Method validator = ReflectionUtils.getMethod(m_javaInfo.getClass(), validatorName, validatorParameterTypes); if (validator != null) { Object[] validatorArgs = ArrayUtils.add(args, result); result = validator.invoke(m_javaInfo, validatorArgs); } return result; }
From source file:org.eclipse.wb.internal.core.utils.ast.binding.DesignerMethodBinding.java
/** * Adds new {@link ITypeBinding} into throws exceptions. *///from w ww .j av a2 s . c o m public void addExceptionType(ITypeBinding newException) { m_exceptionTypes = (ITypeBinding[]) ArrayUtils.add(m_exceptionTypes, newException); }
From source file:org.eclipse.wb.internal.core.utils.jdt.core.ProjectUtils.java
/** * Adds {@link IClasspathEntry} to the {@link IJavaProject}. * /*from w w w .j a v a 2 s . c om*/ * @param javaProject * the {@link IJavaProject} to add JAR to. * @param entry * the {@link IClasspathEntry} to add. */ public static void addClasspathEntry(IJavaProject javaProject, IClasspathEntry entry) throws CoreException { IClasspathEntry[] entries = javaProject.getRawClasspath(); entries = (IClasspathEntry[]) ArrayUtils.add(entries, entry); javaProject.setRawClasspath(entries, null); }
From source file:org.eclipse.wb.internal.core.utils.jdt.core.ProjectUtils.java
/** * Requires <code>requiredProject</code> in <code>project</code>. *///from w w w .jav a2 s. com public static void requireProject(IJavaProject project, IJavaProject requiredProject) throws JavaModelException { IClasspathEntry[] rawClasspath = project.getRawClasspath(); rawClasspath = (IClasspathEntry[]) ArrayUtils.add(rawClasspath, JavaCore.newProjectEntry(requiredProject.getPath())); project.setRawClasspath(rawClasspath, null); }
From source file:org.eclipse.wb.internal.ercp.wizards.project.AbstractProjectCreationOperation.java
/** * Adds given {@link IClasspathEntry} to the {@link IJavaProject} class path. *//*from w w w . j a v a2 s . c o m*/ protected final void addClassPathEntry(IClasspathEntry entry, IProgressMonitor monitor) throws JavaModelException { IClasspathEntry[] entries = javaProject.getRawClasspath(); entries = (IClasspathEntry[]) ArrayUtils.add(entries, entry); javaProject.setRawClasspath(entries, monitor); }
From source file:org.eclipse.wb.internal.ercp.wizards.project.AbstractProjectCreationOperation.java
/** * Adds nature with given id to the {@link IProject}. *///w w w . j a v a2s . c o m protected final void addNature(String natureId, IProgressMonitor monitor) throws CoreException { IProjectDescription description = project.getDescription(); String[] natureIds = description.getNatureIds(); natureIds = (String[]) ArrayUtils.add(natureIds, natureId); description.setNatureIds(natureIds); project.setDescription(description, monitor); }
From source file:org.eclipse.wb.tests.designer.core.util.jdt.core.CodeUtilsTest.java
/** * {@link IJavaProject} as element, but no separate source folders, so {@link IJavaProject} itself * is source folder.// w w w . java 2 s . c om */ public void test_getPackageFragmentRoot_3() throws Exception { try { IJavaProject javaProject = m_testProject.getJavaProject(); // remove "src" { IClasspathEntry[] rawClasspath = javaProject.getRawClasspath(); rawClasspath = (IClasspathEntry[]) ArrayUtils.remove(rawClasspath, rawClasspath.length - 1); javaProject.setRawClasspath(rawClasspath, new NullProgressMonitor()); } // add "" { IClasspathEntry[] rawClasspath = javaProject.getRawClasspath(); rawClasspath = (IClasspathEntry[]) ArrayUtils.add(rawClasspath, JavaCore.newSourceEntry(new Path("/TestProject"))); javaProject.setRawClasspath(rawClasspath, new NullProgressMonitor()); } // IJavaProject as element { IJavaElement element = javaProject; IPackageFragmentRoot packageFragmentRoot = CodeUtils.getPackageFragmentRoot(element); assertPackageFragmentRootPath("/TestProject", packageFragmentRoot); } } finally { do_projectDispose(); do_projectCreate(); } }
From source file:org.ednovo.gooru.application.util.SerializerUtil.java
/** * @param model//ww w.j a v a2s .c o m * @param type * @param excludes * @param includes * @return */ public static String serialize(Object model, final String type, String[] excludes, boolean deepSerialize, final boolean useBaseExcludes, final boolean excludeNullObject, String... includes) { if (model == null) { return ""; } String serializedData = null; JSONSerializer serializer = new JSONSerializer(); boolean handlingAssessmentQuestion = willSerializeAssessmentQuestion(model); if (type == null || type.equals(JSON)) { if (includes != null) { includes = (String[]) ArrayUtils.add(includes, "*.contentPermissions"); serializer.include(includes); } else { serializer.include("*.contentPermissions"); } serializer.include(includes); if (useBaseExcludes) { if (excludes != null) { excludes = (String[]) ArrayUtils.addAll(excludes, EXCLUDES); } else { excludes = EXCLUDES; } } if (model instanceof User) { deepSerialize = true; } if (model != null) { serializer = appendTransformers(serializer, excludeNullObject); } if (handlingAssessmentQuestion) { serializer = handleAssessmentQuestionTransformers(serializer); } if (excludes != null) { serializer.exclude(excludes); } try { model = protocolSwitch(model); serializedData = deepSerialize ? serializer.deepSerialize(model) : serializer.serialize(model); log(model, serializedData); } catch (Exception ex) { LOGGER.error("serialize: happened to throw exception", ex); if (model instanceof Resource) { LOGGER.error("Serialization failed for resource : " + ((Resource) model).getContentId()); } else if (model instanceof List) { List list = (List<?>) model; if (list != null && list.size() > 0 && list.get(0) instanceof Resource) { LOGGER.error("Serialization failed for list resources of size : " + list.size() + " resource : " + ((Resource) list.get(0)).getContentId()); } } else { LOGGER.error("Serialization failed" + ex); } throw new MethodFailureException(ex.getMessage()); } } else { serializedData = new XStream().toXML(model); } return serializedData; }
From source file:org.ednovo.gooru.controllers.v2.api.CollectionRestV2Controller.java
@AuthorizeOperations(operations = { GooruOperationConstants.OPERATION_SCOLLECTION_UPDATE }) @RequestMapping(value = { "/{id}" }, method = { RequestMethod.PUT }) public ModelAndView updateCollection(@PathVariable(value = ID) final String collectionId, @RequestBody final String data, final HttpServletRequest request, final HttpServletResponse response) throws Exception { final User user = (User) request.getAttribute(Constants.USER); final JSONObject json = requestData(data); final ActionResponseDTO<Collection> responseDTO = getCollectionService().updateCollection( this.buildCopyCollectionFromInputParameters(getValue(COLLECTION, json)), collectionId, getValue(OWNER_UID, json), getValue(CREATOR_UID, json), hasUnrestrictedContentAccess(), getValue(RELATED_CONTENT_ID, json), user, data); if (responseDTO.getErrors().getErrorCount() > 0) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); }//from w w w .j a v a 2 s . c o m String[] includes = (String[]) ArrayUtils.addAll(COLLECTION_INCLUDE_FIELDS, ERROR_INCLUDE); includes = (String[]) ArrayUtils.addAll(includes, COLLECTION_TAXONOMY); if (getValue(RELATED_CONTENT_ID, json) != null) { includes = (String[]) ArrayUtils.add(includes, "*.contentAssociation.associateContent"); } return toModelAndViewWithIoFilter(responseDTO.getModelData(), RESPONSE_FORMAT_JSON, EXCLUDE_ALL, true, includes); }