当前位置: 首页>>代码示例>>Java>>正文


Java BeanComparator类代码示例

本文整理汇总了Java中org.apache.commons.beanutils.BeanComparator的典型用法代码示例。如果您正苦于以下问题:Java BeanComparator类的具体用法?Java BeanComparator怎么用?Java BeanComparator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BeanComparator类属于org.apache.commons.beanutils包,在下文中一共展示了BeanComparator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getObject

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
public Object getObject(final String command) throws Exception {
	final Object templates = Gadgets.createTemplatesImpl(command);
	// mock method name until armed
	final BeanComparator comparator = new BeanComparator("lowestSetBit");

	// create queue with numbers and basic comparator
	final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator);
	// stub data for replacement later
	queue.add(new BigInteger("1"));
	queue.add(new BigInteger("1"));

	// switch method called by comparator
	Reflections.setFieldValue(comparator, "property", "outputProperties");

	// switch contents of queue
	final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
	queueArray[0] = templates;
	queueArray[1] = templates;

	return queue;
}
 
开发者ID:hucheat,项目名称:APacheSynapseSimplePOC,代码行数:22,代码来源:CommonsBeanutils1.java

示例2: initialize

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
@PostConstruct
public void initialize() {

    comparatorChain.addComparator(new BeanComparator("roleKey"), true);
    comparatorChain.addComparator(new BeanComparator("userId"));

    model.setSubscriptionExisting(true);

    try {
        if (!model.isInitialized()) {
            final long key = sessionBean.getSelectedSubscriptionKey();
            initializeSubscription(key);
        }
    } catch (ObjectNotFoundException | ValidationException
            | OrganizationAuthoritiesException
            | OperationNotPermittedException e) {

        ui.handleException(e);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:21,代码来源:ManageSubscriptionCtrl.java

示例3: getObject

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
public Object getObject(CmdExecuteHelper cmdHelper) throws Exception {
  
	final Object templates = Gadgets.createTemplatesImpl(cmdHelper.getCommandArray());
	// mock method name until armed
	final BeanComparator comparator = new BeanComparator("lowestSetBit");

	// create queue with numbers and basic comparator
	final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator);
	// stub data for replacement later
	queue.add(new BigInteger("1"));
	queue.add(new BigInteger("1"));

	// switch method called by comparator
	Reflections.setFieldValue(comparator, "property", "outputProperties");

	// switch contents of queue
	final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
	queueArray[0] = templates;
	queueArray[1] = templates;

	return queue;
}
 
开发者ID:pimps,项目名称:ysoserial-modified,代码行数:23,代码来源:CommonsBeanutils1.java

示例4: getProviderList

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static ArrayList<ArrayList<String>> getProviderList() {
	try {
		ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();
		ProviderDao dao = SpringUtils.getBean(ProviderDao.class);
		List<Provider> providers = dao.getProvidersByType(ProviderDao.PR_TYPE_DOCTOR);
		Collections.sort(providers, new BeanComparator("formattedName"));
		for (Provider p : providers) {
			ArrayList<String> provider = new ArrayList<String>();
			provider.add(p.getProviderNo());
			provider.add(p.getFirstName());
			provider.add(p.getLastName());
			result.add(provider);
		}
		return result;
	} catch (Exception e) {
		MiscUtils.getLogger().debug("exception in ProviderData:" + e);
		return null;
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:21,代码来源:ProviderData.java

示例5: getProviderListWithLabNo

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static ArrayList<ArrayList<String>> getProviderListWithLabNo() {
	try {
		ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>();

		ProviderDao dao = SpringUtils.getBean(ProviderDao.class);
		List<Provider> providers = dao.getProvidersByTypeWithNonEmptyOhipNo(ProviderDao.PR_TYPE_DOCTOR);
		Collections.sort(providers, new BeanComparator("formattedName"));
		for (Provider p : providers) {
			ArrayList<String> provider = new ArrayList<String>();
			provider.add(p.getProviderNo());
			provider.add(p.getFirstName());
			provider.add(p.getLastName());
			result.add(provider);
		}
		return result;
	} catch (Exception e) {
		MiscUtils.getLogger().debug("exception in ProviderData:" + e);
		return null;
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:22,代码来源:ProviderData.java

示例6: setUpVector

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
/**
 * Sets up three vectors used in for the CreateMessage.jsp page
 * They are used to init the checkboxes that can be checked to send messages
 */
@SuppressWarnings("unchecked")
private void setUpVector() {
	providerNoVector = new Vector<String>();
	providerLastName = new Vector<String>();
	providerFirstName = new Vector<String>();

	ProviderDao dao = SpringUtils.getBean(ProviderDao.class);
	List<Provider> ps = dao.getProviders();
	Collections.sort(ps, new BeanComparator("firstName"));
	for (Provider p : ps) {
		providerNoVector.add(p.getProviderNo());
		providerFirstName.add(p.getFirstName());
		providerLastName.add(p.getLastName());
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:20,代码来源:MsgDocListForm.java

示例7: sortListBeans

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
/**
 * 根据给定的条件,把 list 中的 javabean 排序。
 * 用到了 commons beanutils 和  commons.collections
 *
 * @param list           待排序的 list
 * @param listOrderedMap 排序条件。
 *                       这是一个有序的 list ,排序条件按照加入到 list 的 bean 的属性(map 的 key)的先后顺序排序。
 *                       listOrderedMap 的 key 为待排序的 bean 的属性名称,值为是否按该属性的正序排序,true 为正序,false 为逆序。
 *                       使用方法见本类的 testSortListBeans() 方法例子,使用时注意不要写错 bean 的属性名称。
 * @param <T>            list 中的 bean 类型
 */
public static <T> void sortListBeans(List<T> list, ListOrderedMap listOrderedMap) {

    int num = listOrderedMap.size();
    ArrayList sortFields = new ArrayList();

    for (int i = 0; i < num; i++) {
        //  System.out.println("key =" + listOrderedMap.get(i) + " , value=" + listOrderedMap.getValue(i));
        Comparator comp = ComparableComparator.getInstance();

        comp = ComparatorUtils.nullLowComparator(comp);  //允许null

        if ((Boolean) listOrderedMap.getValue(i) == false)
            comp = ComparatorUtils.reversedComparator(comp); //逆序

        Comparator cmp = new BeanComparator((String) listOrderedMap.get(i), comp);
        sortFields.add(cmp);
    }

    ComparatorChain multiSort = new ComparatorChain(sortFields);
    Collections.sort(list, multiSort);
}
 
开发者ID:h819,项目名称:spring-boot,代码行数:33,代码来源:MyBeanUtils.java

示例8: buildSubjectAreasChildren

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
private void buildSubjectAreasChildren(Model aModel,
									   DefaultMutableTreeNode aParent, List<SubjectArea> aList) {
	DefaultMutableTreeNode theSANode = new DefaultMutableTreeNode(
			TreeGroupingElement.SUBJECTAREAS);
       aList.stream().filter(theArea -> isVisible(theArea)).forEach(theArea -> {
           DefaultMutableTreeNode theAreaNode = new DefaultMutableTreeNode(
                   theArea);
           theSANode.add(theAreaNode);

           registerUserObject(theArea, theAreaNode);

           List<Table> theSATables = new ArrayList<>();
           theSATables.addAll(theArea.getTables());
           Collections.sort(theSATables, new BeanComparator("name"));
           buildTablesChildren(aModel, theAreaNode, theSATables);

           List<View> theSAViews = new ArrayList<>();
           theSAViews.addAll(theArea.getViews());
           Collections.sort(theSAViews, new BeanComparator("name"));
           buildViewsChildren(aModel, theAreaNode, theSAViews);

       });
	aParent.add(theSANode);
}
 
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:25,代码来源:OutlineComponent.java

示例9: getAvailableDataTypes

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
/**
 * Get the available data types.
 * <p/>
 * The available data types are the dialect datatypes plus the defined
 * domains.
 *
 * @return the available data types
 */
public DataTypeList getAvailableDataTypes() {
    DataTypeList theResult = new DataTypeList();
    if (dialect != null) {
        theResult.addAll(dialect.getDataTypes());

        if (dialect.isSupportsCustomTypes()) {
            theResult.addAll(customTypes);
        }

        // Domains can be added by ui every time...
        theResult.addAll(domains);
    }

    Collections.sort(theResult, new BeanComparator("name"));

    return theResult;
}
 
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:26,代码来源:Model.java

示例10: getObject

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
public Object getObject(final String command) throws Exception {
	final TemplatesImpl templates = Gadgets.createTemplatesImpl(command);
	// mock method name until armed
	final BeanComparator comparator = new BeanComparator("lowestSetBit");

	// create queue with numbers and basic comparator
	final PriorityQueue<Object> queue = new PriorityQueue<Object>(2, comparator);
	// stub data for replacement later
	queue.add(new BigInteger("1"));
	queue.add(new BigInteger("1"));

	// switch method called by comparator
	Reflections.setFieldValue(comparator, "property", "outputProperties");

	// switch contents of queue
	final Object[] queueArray = (Object[]) Reflections.getFieldValue(queue, "queue");
	queueArray[0] = templates;
	queueArray[1] = templates;

	return queue;
}
 
开发者ID:NetSPI,项目名称:JavaSerialKiller,代码行数:22,代码来源:CommonsBeanutilsCollectionsLogging1.java

示例11: sortResults

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
/**
 * sort the result set for the user locale
 * 
 * @param locale
 *            The locale to use.
 * @param results
 *            the result
 * @param <L>
 *            the list item
 */
@SuppressWarnings("unchecked")
public static <L extends TagData> void sortResults(Locale locale,
        List<L> results) {
    if (results.size() == 0) {
        return;
    }
    Collator primaryCollator = Collator.getInstance(locale);
    primaryCollator.setStrength(Collator.SECONDARY);
    Collator secondaryCollator = Collator.getInstance(locale);
    secondaryCollator.setStrength(Collator.TERTIARY);
    ComparatorChain chain = new ComparatorChain();
    chain.addComparator(new BeanComparator("name", primaryCollator));
    chain.addComparator(new BeanComparator("name", secondaryCollator));
    Collections.sort(results, chain);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:26,代码来源:TagHelper.java

示例12: sort

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
/**
 * This method will sort a passed Collection
 *
 * @param c The collection to sort
 * @param sortProperty The javabean property to sort the elements of the Collection by
 * @param reverseOrder Boolean indicating whether or not to reverse the order of the collection
 * @return A sorted List of the passed elements
 */
public static <T> List<T> sort(Collection<T> c, String sortProperty, Boolean reverseOrder) {
	if (StringUtils.isEmpty(sortProperty)) {
		throw new IllegalArgumentException("sortProperty = " + sortProperty);
	}
	// fail early if the passed collection is null
	if (c == null) {
		return null;
	}
	
	// fail early if the passed collection is empty
	if (c.size() == 0) {
		return Collections.emptyList();
	}
	
	List<T> l = new ArrayList<T>(c);
	Comparator comp = new BeanComparator(sortProperty, new ComparableComparator());
	Collections.sort(l, comp);
	if (reverseOrder) {
		Collections.reverse(l);
	}
	return l;
}
 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:31,代码来源:Sort.java

示例13: alphabetiseChildNodes

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
/**
 * Alphabetises the top level children of the node root.
 * @param root
 * @return The alphabetised root node.
 */
public static Node alphabetiseChildNodes(Node root) throws XPathExpressionException
{
    root = removeEmptyElements(root);
    NodeList list = selectNodeList(root, "child::*");
    removeAllChildNodes(root);

    if(list.getLength() > 0)
    {
        Vector<Node> nodes = new Vector<Node>(list.getLength());

        for(int i = 0; i < list.getLength(); nodes.add(list.item(i)), i++);

        Collections.sort(nodes, new BeanComparator("localName"));

        for(Node node : nodes)
        {
            root.appendChild(node);
        }
    }

    return root;
}
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:28,代码来源:DOMUtil.java

示例14: showHistory

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
public ActionForward showHistory(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    final String codeString = request.getParameter("externalId");
    String code = null;
    if (codeString == null) {
        code = (String) request.getAttribute("externalId");
    } else {
        code = codeString;
    }
    final ParkingRequest parkingRequest = FenixFramework.getDomainObject(code);
    List<ParkingPartyHistory> parkingPartyHistories =
            new ArrayList<ParkingPartyHistory>(parkingRequest.getParkingParty().getParty().getParkingPartyHistoriesSet());

    Collections.sort(parkingPartyHistories, new BeanComparator("historyDate"));
    request.setAttribute("parkingPartyHistories", parkingPartyHistories);
    request.setAttribute("parkingParty", parkingRequest.getParkingParty());
    return mapping.findForward("showParkingHistories");
}
 
开发者ID:ist-dsi-archive,项目名称:fenix-parking,代码行数:19,代码来源:ParkingManagerDispatchAction.java

示例15: showParkingPartyHistory

import org.apache.commons.beanutils.BeanComparator; //导入依赖的package包/类
public ActionForward showParkingPartyHistory(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    final String codeString = request.getParameter("externalId");
    String code = null;
    if (codeString == null) {
        code = (String) request.getAttribute("externalId");
    } else {
        code = codeString;
    }
    final ParkingParty parkingParty = FenixFramework.getDomainObject(code);
    List<ParkingPartyHistory> parkingPartyHistories =
            new ArrayList<ParkingPartyHistory>(parkingParty.getParty().getParkingPartyHistoriesSet());

    Collections.sort(parkingPartyHistories, new BeanComparator("historyDate"));
    request.setAttribute("parkingPartyHistories", parkingPartyHistories);
    request.setAttribute("parkingParty", parkingParty);
    return mapping.findForward("showParkingHistories");
}
 
开发者ID:ist-dsi-archive,项目名称:fenix-parking,代码行数:19,代码来源:ParkingManagerDispatchAction.java


注:本文中的org.apache.commons.beanutils.BeanComparator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。