Example usage for org.apache.commons.lang ArrayUtils EMPTY_CLASS_ARRAY

List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_CLASS_ARRAY

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils EMPTY_CLASS_ARRAY.

Prototype

Class EMPTY_CLASS_ARRAY

To view the source code for org.apache.commons.lang ArrayUtils EMPTY_CLASS_ARRAY.

Click Source Link

Document

An empty immutable Class array.

Usage

From source file:net.navasoft.madcoin.backend.services.WorkRequestQueryFilter.java

/**
 * Choose filter./*from w w  w.  ja  v a 2 s .  co  m*/
 * 
 * @param entryVO
 *            the entry vo
 * @return the generic filter
 * @since 27/07/2014, 06:48:16 PM
 */
@Override
public GenericFilter<WorkRequestQueryVO> chooseFilter(WorkRequestQueryVO entryVO) {
    GenericFilter<WorkRequestQueryVO> selector = null;
    Method[] accessors = WorkRequestQueryVO.class.getMethods();
    try {
        accessors = (Method[]) ArrayUtils.removeElement(accessors,
                WorkRequestQueryVO.class.getMethod("getClass", ArrayUtils.EMPTY_CLASS_ARRAY));
    } catch (NoSuchMethodException e1) {
        e1.printStackTrace();
    } catch (SecurityException e1) {
        e1.printStackTrace();
    }
    try {
        if (entryVO != null) {
            for (Method beanGetters : accessors) {
                if (beanGetters.getName().startsWith("get")) {
                    Object fieldValue;
                    fieldValue = beanGetters.invoke(entryVO, ArrayUtils.EMPTY_OBJECT_ARRAY);
                    if (fieldValue != null) {
                        String fieldToFilter = beanGetters.getName().replace("get", "");
                        EFilters guessedFilters = null;
                        if (ArrayUtils.contains(mandatory, fieldToFilter)) {
                            guessedFilters = EFilters.valueOf(fieldToFilter.toUpperCase() + "_FILTER");
                        } else {
                            if (guessedFilters == null) {
                                guessedFilters = optionalCorrelation.get(fieldToFilter);
                            }
                        }
                        selector = (GenericFilter<WorkRequestQueryVO>) Class
                                .forName(guessedFilters.getImplementingClass()).getConstructor(EFilters.class)
                                .newInstance(guessedFilters);
                    }
                }
            }
            if (selector == null) {
                selector = WorkRequestNoFilter.class.newInstance();
            } else {
                selector.setScope(entryVO);
            }
            return selector;
        } else {
            selector = WorkRequestNoFilter.class.newInstance();
        }
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return selector;
}

From source file:net.navasoft.madcoin.backend.services.vo.request.SuccessRequestVOWrapper.java

/**
 * Gets the attribute./*  www .  jav  a 2 s  .  c  o  m*/
 * 
 * @param field
 *            the field
 * @return the attribute
 * @throws WrapperException
 *             the wrapper exception
 * @since 27/07/2014, 06:49:08 PM
 */
public Object getAttribute(final String field) throws WrapperException {
    try {
        return helper.cast(hidden).getClass().getDeclaredMethod("get" + field, ArrayUtils.EMPTY_CLASS_ARRAY)
                .invoke(helper, ArrayUtils.EMPTY_OBJECT_ARRAY);
    } catch (IllegalAccessException e) {
        throw new WrapperException("Not accessible", e);
    } catch (IllegalArgumentException e) {
        throw new WrapperException("Incorrect parameters", e);
    } catch (InvocationTargetException e) {
        throw new WrapperException("Unexpected VO", e);
    } catch (NoSuchMethodException e) {
        throw new WrapperException("Bad typing of bean", e);
    } catch (SecurityException e) {
        throw new WrapperException("Bad runtime access", e);
    }
}

From source file:net.sf.morph.transform.converters.TextToEnumConverter.java

/**
 * {@inheritDoc}/* ww  w . ja va 2 s . c om*/
 */
protected Class[] getDestinationClassesImpl() throws Exception {
    if (ENUM_TYPE == null) {
        return ArrayUtils.EMPTY_CLASS_ARRAY;
    }
    Set result = ContainerUtils.createOrderedSet();
    result.add(ENUM_TYPE);
    result.addAll(Arrays.asList(getTextConverter().getDestinationClasses()));
    result.add(null);
    return (Class[]) result.toArray(new Class[result.size()]);
}

From source file:net.sf.morph.transform.converters.TextToEnumConverter.java

/**
 * {@inheritDoc}/*  w w w.j  a  v  a 2  s .co  m*/
 */
protected Class[] getSourceClassesImpl() throws Exception {
    if (ENUM_TYPE == null) {
        return ArrayUtils.EMPTY_CLASS_ARRAY;
    }
    Set result = ContainerUtils.createOrderedSet();
    result.add(ENUM_TYPE);
    result.addAll(Arrays.asList(getTextConverter().getSourceClasses()));
    result.add(null);
    return (Class[]) result.toArray(new Class[result.size()]);
}

From source file:bboss.org.apache.velocity.runtime.parser.node.ASTMethod.java

/**
 *  invokes the method.  Returns null if a problem, the
 *  actual return if the method returns something, or
 *  an empty string "" if the method returns void
 * @param o/*  ww  w .ja  v  a  2  s .  co  m*/
 * @param context
 * @return Result or null.
 * @throws MethodInvocationException
 */
public Object execute(Object o, InternalContextAdapter context) throws MethodInvocationException {
    /*
     *  new strategy (strategery!) for introspection. Since we want
     *  to be thread- as well as context-safe, we *must* do it now,
     *  at execution time.  There can be no in-node caching,
     *  but if we are careful, we can do it in the context.
     */
    Object[] params = new Object[paramCount];

    /*
     * sadly, we do need recalc the values of the args, as this can
     * change from visit to visit
     */
    final Class[] paramClasses = paramCount > 0 ? new Class[paramCount] : ArrayUtils.EMPTY_CLASS_ARRAY;

    for (int j = 0; j < paramCount; j++) {
        params[j] = jjtGetChild(j + 1).value(context);
        if (params[j] != null) {
            paramClasses[j] = params[j].getClass();
        }
    }

    VelMethod method = ClassUtils.getMethod(methodName, params, paramClasses, o, context, this, strictRef);
    if (method == null)
        return null;

    try {
        /*
         *  get the returned object.  It may be null, and that is
         *  valid for something declared with a void return type.
         *  Since the caller is expecting something to be returned,
         *  as long as things are peachy, we can return an empty
         *  String so ASTReference() correctly figures out that
         *  all is well.
         */

        Object obj = method.invoke(o, params);

        if (obj == null) {
            if (method.getReturnType() == Void.TYPE) {
                return "";
            }
        }

        return obj;
    } catch (InvocationTargetException ite) {
        return handleInvocationException(o, context, ite.getTargetException());
    }

    /** Can also be thrown by method invocation **/
    catch (IllegalArgumentException t) {
        return handleInvocationException(o, context, t);
    }

    /**
     * pass through application level runtime exceptions
     */
    catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        String msg = "ASTMethod.execute() : exception invoking method '" + methodName + "' in " + o.getClass();
        log.error(msg, e);
        throw new VelocityException(msg, e);
    }
}

From source file:com.google.gdt.eclipse.designer.model.widgets.support.CssSupport.java

/**
 * @return <code>true</code> if one or more CSS files were modified (and schedules them for
 *         reloading with next refresh).
 *//*from   w ww . ja v  a 2s  .c  om*/
boolean isModified() {
    waitRequestSet.clear();
    waitApplySet.clear();
    boolean modified = false;
    // check CSS files
    boolean hasModifiedCSSFiles = false;
    for (Map.Entry<IFile, Long> entry : filesStampMap.entrySet()) {
        IFile file = entry.getKey();
        long storedStamp = entry.getValue();
        long fileStamp = file.getModificationStamp();
        if (fileStamp != storedStamp) {
            modified = true;
            filesStampMap.put(file, fileStamp);
            hasModifiedCSSFiles = true;
        }
    }
    // schedule CSS load waiting
    if (hasModifiedCSSFiles) {
        synchronized (waitRequestSet) {
            for (String resource : resources) {
                String waitRequestName = getWaitRequestName(resource);
                waitRequestSet.add(waitRequestName);
            }
        }
    }
    // if has modified CSS files, ask Browser for reload
    if (modified) {
        ExecutionUtils.runLog(new RunnableEx() {
            public void run() throws Exception {
                state.getHostModeSupport().invokeNativeVoid("__reload_css", ArrayUtils.EMPTY_CLASS_ARRAY,
                        ArrayUtils.EMPTY_OBJECT_ARRAY);
            }
        });
        waitFor();
    }
    // return final modification state
    return modified;
}

From source file:com.cyclopsgroup.tornado.hibernate.impl.DefaultHibernateService.java

/**
 * Override method getEntityClasses in class DefaultHibernateHome
 *
 * @see com.cyclopsgroup.tornado.hibernate.HibernateService#getEntityClasses(java.lang.String)
 *///from   w w w .  ja  va2  s. c o m
public Class[] getEntityClasses(String dataSourceName) {
    Collection classes = (Collection) entityClasses.get(dataSourceName);
    return classes == null ? ArrayUtils.EMPTY_CLASS_ARRAY
            : (Class[]) classes.toArray(ArrayUtils.EMPTY_CLASS_ARRAY);
}

From source file:net.sf.beanlib.hibernate3.Hibernate3DtoCopier.java

/** 
 * Returns a DTO of the specified target entity type
 * by cloning portion of the object graph of the given Hibernate bean,
 * excluding all collection and map properties, and including only those properties
 * with package names that match the application package prefix.
 * <p>/*w  w  w. j a v  a 2 s.co  m*/
 * The replication is typically recursive in that the object graph of the input object is basically replicated 
 * into an equivalent output object graph, resolving circular references, and eagerly fetching proxied instances as necessary.
 *
 * @param targetEntityType target entity type
 * @param entityBean Hibernate entity bean to be cloned
 * 
 * @see #applicationPackagePrefix
 */
public <E, T> E hibernate2dto(Class<E> targetEntityType, T entityBean) {
    if (entityBean == null)
        return null;
    return copy(targetEntityType, entityBean, ArrayUtils.EMPTY_CLASS_ARRAY);
}

From source file:net.navasoft.madcoin.backend.services.vo.request.SuccessRequestVOWrapper.java

/**
 * Gets the processing values.//from   w  w  w.  j  av a 2  s.  c  o  m
 * 
 * @param service
 *            the service
 * @since 27/07/2014, 06:49:08 PM
 */
@Override
public void processValues(IService service) {
    if (isValidService(service)) {
        for (ProcessedField annotatedField : getTarget(service)) {
            for (Method accessor : filterMethods()) {
                Annotation annot = accessor.getAnnotation(ProcessingField.class);
                if (annot != null) {
                    ProcessingField expectedReal = ((ProcessingField) annot);
                    if (!ArrayUtils.contains(alreadyProcessed, expectedReal.expectedVariable())) {
                        try {
                            if (validateProcessAnnotations(annotatedField, expectedReal)) {
                                Object requestValue = null;
                                switch (expectedReal.precedence()) {
                                case BASIC_OPTIONAL:
                                    requestValue = accessor.invoke(hidden, ArrayUtils.EMPTY_OBJECT_ARRAY);
                                    processed.put(expectedReal.expectedVariable(), requestValue);
                                    alreadyProcessed = (String[]) ArrayUtils.add(alreadyProcessed,
                                            expectedReal.expectedVariable());
                                    break;
                                case BASIC_REQUIRED:
                                    requestValue = accessor.invoke(this.hidden, ArrayUtils.EMPTY_OBJECT_ARRAY);
                                    processed.put(expectedReal.expectedVariable(), requestValue);
                                    alreadyProcessed = (String[]) ArrayUtils.add(alreadyProcessed,
                                            expectedReal.expectedVariable());
                                    break;
                                case COMPLEX_OPTIONAL:
                                    requestValue = expectedReal.helperClass().newInstance();
                                    processed.put(expectedReal.expectedVariable(),
                                            expectedReal.helperClass()
                                                    .getMethod(expectedReal.converterMethod(),
                                                            ArrayUtils.EMPTY_CLASS_ARRAY)
                                                    .invoke(requestValue, ArrayUtils.EMPTY_OBJECT_ARRAY));
                                    alreadyProcessed = (String[]) ArrayUtils.add(alreadyProcessed,
                                            expectedReal.expectedVariable());
                                    break;
                                case COMPLEX_REQUIRED:
                                    requestValue = expectedReal.helperClass().newInstance();
                                    processed.put(expectedReal.expectedVariable(),
                                            expectedReal.helperClass()
                                                    .getMethod(expectedReal.converterMethod(),
                                                            ArrayUtils.EMPTY_CLASS_ARRAY)
                                                    .invoke(requestValue, ArrayUtils.EMPTY_OBJECT_ARRAY));
                                    alreadyProcessed = (String[]) ArrayUtils.add(alreadyProcessed,
                                            expectedReal.expectedVariable());
                                    break;
                                default:
                                    break;
                                }
                            }
                        } catch (IllegalAccessException e1) {
                        } catch (IllegalArgumentException e1) {
                        } catch (InvocationTargetException e1) {
                        } catch (NoSuchMethodException e) {
                        } catch (SecurityException e) {
                        } catch (InstantiationException e) {
                        }
                    }
                }
            }
        }
    }
}

From source file:com.google.gdt.eclipse.designer.gxt.databinding.model.bindings.FieldBindingInfo.java

@Override
public void createContentProviders(List<IUiContentProvider> providers, IPageListener listener,
        DatabindingsProvider provider) throws Exception {
    super.createContentProviders(providers, listener, provider);
    if (!m_autobind) {
        if (m_configuration == null) {
            m_configuration = new ChooseClassConfiguration();
            m_configuration.setDialogFieldLabel("Converter:");
            m_configuration.setValueScope("com.extjs.gxt.ui.client.binding.Converter");
            m_configuration.setClearValue("N/S");
            m_configuration.setBaseClassName("com.extjs.gxt.ui.client.binding.Converter");
            m_configuration.setConstructorParameters(ArrayUtils.EMPTY_CLASS_ARRAY);
            m_configuration.setEmptyClassErrorMessage("Converter class is empty.");
            m_configuration.setErrorMessagePrefix("Converter");
        }//from w  w w  . ja  va2s  .c  om
        //
        m_configuration.clearDefaultStrings();
        if (m_converter != null && m_converter.getClassName().indexOf('(') != -1) {
            m_configuration.addDefaultStart(m_converter.getClassName());
        }
        //
        providers.add(new ConverterUiContentProvider(m_configuration, this));
        //
        if (m_parentBinding != null && listener == EmptyPageListener.INSTANCE) {
            ChooseClassAndPropertiesConfiguration configuration = new ChooseClassAndPropertiesConfiguration();
            configuration.setBaseClassName("com.extjs.gxt.ui.client.data.ModelData");
            configuration.setValueScope("beans");
            configuration.setDialogFieldLabel("Model:");
            configuration.setDialogFieldEnabled(false);
            configuration.setPropertiesLabel("Model property:");
            configuration.setLoadedPropertiesCheckedStrategy(LoadedPropertiesCheckedStrategy.None);
            configuration.setPropertiesErrorMessage("Choose model property.");
            //
            providers.add(new ChooseClassAndPropertiesUiContentProvider(configuration,
                    provider.getBeansContainer().getBeanSupport()) {
                public void updateFromObject() throws Exception {
                    if (m_modelProperty == null) {
                        BeanObserveInfo model = getLocalModel();
                        if (model == null) {
                            calculateFinish();
                        } else {
                            setClassName(model.getObjectType().getName());
                        }
                    } else {
                        BeanPropertyObserveInfo modelProperty = (BeanPropertyObserveInfo) m_modelProperty;
                        setClassNameAndProperty(getLocalModel().getObjectType().getName(),
                                new PropertyAdapter(modelProperty.getPresentation().getText(),
                                        modelProperty.getObjectType()),
                                true);
                    }
                }

                @Override
                protected void saveToObject(Class<?> choosenClass, List<PropertyAdapter> choosenProperties)
                        throws Exception {
                    boolean create = m_modelProperty == null;
                    m_modelProperty = getLocalModel()
                            .resolvePropertyReference("\"" + choosenProperties.get(0).getName() + "\"", null);
                    if (!create) {
                        m_modelProperty.createBinding(FieldBindingInfo.this);
                    }
                }
            });
        }
    }
}