當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。