List of usage examples for org.apache.commons.lang ArrayUtils isNotEmpty
public static boolean isNotEmpty(boolean[] array)
Checks if an array of primitive booleans is not empty or not null
.
From source file:net.ymate.platform.webmvc.support.MultipartRequestWrapper.java
/** * @return ?//from w ww.ja v a2 s . c o m */ public Set<IUploadFileWrapper> getUploadFiles() { Set<IUploadFileWrapper> _returnValues = new HashSet<IUploadFileWrapper>(); for (IUploadFileWrapper[] _fileWraps : __formWarpper.getFileMap().values()) { if (ArrayUtils.isNotEmpty(_fileWraps)) { Collections.addAll(_returnValues, _fileWraps); } } return _returnValues; }
From source file:net.ymate.platform.webmvc.support.RequestExecutor.java
private IView __doProcessResultToView(Object result) throws Exception { IView _view = null;//from w ww .jav a 2 s . co m if (result == null) { if (__requestMeta.getResponseView() != null) { ResponseView _respView = __requestMeta.getResponseView(); String[] _viewParts = StringUtils.split(_respView.value(), ":"); switch (_respView.type()) { case BINARY: _view = BinaryView.bind(new File(_viewParts[0])) .useAttachment(_viewParts.length > 1 ? _viewParts[1] : null); break; case FORWARD: _view = ForwardView.bind(_respView.value()); break; case FREEMARKER: _view = FreemarkerView.bind(__owner, _respView.value()); break; case VELOCITY: _view = VelocityView.bind(__owner, _respView.value()); break; case HTML: _view = HtmlView.bind(__owner, _respView.value()); break; case HTTP_STATES: _view = HttpStatusView.bind(Integer.parseInt(_viewParts[0]), _viewParts.length > 1 ? _viewParts[1] : null); break; case JSON: _view = JsonView.bind(_viewParts[0]); break; case JSP: _view = JspView.bind(__owner, _viewParts[0]); break; case REDIRECT: _view = RedirectView.bind(_viewParts[0]); break; case TEXT: _view = TextView.bind(_viewParts[0]); break; default: _view = NullView.bind(); } } else { // _view = JspView.bind(__owner); } } else if (result instanceof IView) { _view = (IView) result; } else if (result instanceof String) { String[] _parts = StringUtils.split((String) result, ":"); if (ArrayUtils.isNotEmpty(_parts) && _parts.length > 1) { switch (Type.View.valueOf(_parts[0].toUpperCase())) { case BINARY: _view = BinaryView.bind(new File(_parts[1])) .useAttachment(_parts.length >= 3 ? _parts[2] : null); break; case FORWARD: _view = ForwardView.bind(_parts[1]); break; case FREEMARKER: _view = FreemarkerView.bind(__owner, _parts[1]); break; case VELOCITY: _view = VelocityView.bind(__owner, _parts[1]); break; case HTML: _view = HtmlView.bind(__owner, _parts[1]); break; case HTTP_STATES: _view = HttpStatusView.bind(Integer.parseInt(_parts[1]), _parts.length >= 3 ? _parts[2] : null); break; case JSON: _view = JsonView.bind(_parts[1]); break; case JSP: _view = JspView.bind(__owner, _parts[1]); break; case NULL: _view = NullView.bind(); break; case REDIRECT: _view = RedirectView.bind(_parts[1]); break; case TEXT: _view = TextView.bind(_parts[1]); } } else { _view = HtmlView.bind((String) result); } } // if (_view != null) { for (Header _header : __requestMeta.getResponseHeaders()) { switch (_header.type()) { case STRING: _view.addHeader(_header.name(), _header.value()); break; case DATE: _view.addDateHeader(_header.name(), BlurObject.bind(_header.value()).toLongValue()); break; case INT: _view.addIntHeader(_header.name(), BlurObject.bind(_header.value()).toIntValue()); } } } return _view; }
From source file:net.zcarioca.zcommons.config.data.BeanPropertySetterFactory.java
private static void addAnnotationsToMap(Map<Class<? extends Annotation>, Annotation> annotationMap, Annotation[] annotations) { if (ArrayUtils.isNotEmpty(annotations)) { for (Annotation annotation : annotations) { if (!annotationMap.containsKey(annotation.annotationType())) { annotationMap.put(annotation.annotationType(), annotation); }/*from w w w .j av a2 s .co m*/ } } }
From source file:net.zcarioca.zcommons.config.source.spi.FilesystemConfigurationSourceServiceProvider.java
private File getFromPattern(File directory, Pattern pattern) { File[] match = directory.listFiles(new PatternFileFilter(pattern)); return ArrayUtils.isNotEmpty(match) ? match[0] : null; }
From source file:nl.strohalm.cyclos.controls.members.SearchMembersAjaxAction.java
/** * Resolves the possible groups for the logged user to see *///w w w .j a v a 2s. co m private Collection<MemberGroup> resolveGroups(final ActionContext context) { // Ensure that only normal groups (not removed) are used Collection<MemberGroup> groups = null; final SearchMembersAjaxForm form = context.getForm(); if (ArrayUtils.isNotEmpty(form.getGroupIds())) { groups = new HashSet<MemberGroup>(); for (final Long id : form.getGroupIds()) { if (id > 0) { groups.add((MemberGroup) groupService.load(id)); } } } return groups; }
From source file:nl.strohalm.cyclos.controls.members.sms.SearchSmsMailingVariablesAjaxAction.java
/** * Resolves the possible groups for the logged user to see *//* w w w. ja va 2 s . c om*/ private List<MemberGroup> resolveGroups(final ActionContext context) { // Ensure that only normal groups (not removed) are used List<MemberGroup> groups = null; final SearchSmsMailingVariablesAjaxForm form = context.getForm(); if (ArrayUtils.isNotEmpty(form.getGroupIds())) { groups = new ArrayList<MemberGroup>(); for (final Long id : form.getGroupIds()) { if (id > 0) { groups.add((MemberGroup) groupService.load(id)); } } } return groups; }
From source file:nl.strohalm.cyclos.dao.accounts.transactions.TicketDAOImpl.java
@Override public <T extends Ticket> T load(final String value, final Relationship... fetch) { final Map<String, ?> params = Collections.singletonMap("ticket", value); T ticket = this.<T>uniqueResult("from " + getEntityType().getName() + " t where t.ticket = :ticket", params);//from w w w.j a v a 2s . co m if (ticket == null) { throw new EntityNotFoundException(Ticket.class); } if (ArrayUtils.isNotEmpty(fetch)) { ticket = getFetchDao().fetch(ticket, fetch); } return ticket; }
From source file:nl.strohalm.cyclos.webservices.utils.MemberHelper.java
/** * Loads a member using the given principal, according to the current channel *//*from w w w . j a v a 2s. c o m*/ public Member loadByPrincipal(PrincipalType principalType, final String principal, final Relationship... relationships) { if (StringUtils.isNotEmpty(principal)) { final Channel channel = WebServiceContext.getChannel(); if (channel != null) { if (principalType == null) { principalType = channel.getDefaultPrincipalType(); } else if (!channel.getPrincipalTypes().contains(principalType)) { return null; } } Member member; if (ArrayUtils.isNotEmpty(relationships)) { Relationship[] tmp = new Relationship[relationships.length + 2]; tmp[0] = Element.Relationships.USER; tmp[1] = Element.Relationships.GROUP; System.arraycopy(relationships, 0, tmp, 2, relationships.length); member = elementServiceLocal.loadByPrincipal(principalType, principal, tmp); } else { member = elementServiceLocal.loadByPrincipal(principalType, principal, Element.Relationships.USER, Element.Relationships.GROUP); } if (!permissionService.relatesTo(member)) { throw new EntityNotFoundException(Member.class); } return member; } return null; }
From source file:org.apache.carbondata.processing.loading.parser.impl.ArrayParserImpl.java
@Override public ArrayObject parse(Object data) { if (data != null) { String value = data.toString(); if (!value.isEmpty() && !value.equals(nullFormat)) { String[] split = pattern.split(value, -1); if (ArrayUtils.isNotEmpty(split)) { Object[] array = new Object[split.length]; for (int i = 0; i < split.length; i++) { array[i] = child.parse(split[i]); }/* w w w . ja va 2s . c o m*/ return new ArrayObject(array); } } else if (value.isEmpty()) { Object[] array = new Object[1]; array[0] = child.parse(value); return new ArrayObject(array); } } return null; }
From source file:org.apache.carbondata.processing.loading.parser.impl.MapParserImpl.java
@Override public ArrayObject parse(Object data) { if (data != null) { String value = data.toString(); if (!value.isEmpty() && !value.equals(nullFormat)) { String[] split = pattern.split(value, -1); if (ArrayUtils.isNotEmpty(split)) { ArrayList<Object> array = new ArrayList<>(); Set<Object> set = new HashSet<>(); for (int i = 0; i < split.length; i++) { Object currKey = split[i].split(keyValueDelimiter)[0]; if (set.add(currKey)) { array.add(child.parse(split[i])); }//from w w w. j a v a 2 s. c o m } return new ArrayObject(array.toArray()); } } } return null; }