Java 类org.apache.commons.collections4.map.ListOrderedMap 实例源码

项目:fitnessefixtures    文件:Xml2Json.java   
private Object node2json(Element element) throws Exception {
        Map map = new ListOrderedMap();
        String xpath = getXPath(element);
        if (singles.contains(xpath)) {
                if (element.getFirstChild() != null)
                        return listner.text(element.getFirstChild().getNodeValue());
                else
                        return "";
        }
        NamedNodeMap attrs = element.getAttributes();
        for (int i = 0; i < attrs.getLength(); i++) {
                Node attr = attrs.item(i);
                String name = attr.getNodeName();
                String value = attr.getNodeValue();
                map.put(name, listner.text(value));
        }
        NodeList childs = element.getChildNodes();
        nodelist2json(map, childs);
        return new JSONObject(map);
}
项目:springboot-shiro-cas-mybatis    文件:KryoTranscoderTests.java   
@Test
public void verifyEncodeDecodeTGTWithListOrderedMap() throws Exception {
    final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
    @SuppressWarnings("unchecked")
    final TicketGrantingTicket expectedTGT =
            new MockTicketGrantingTicket(TGT_ID, userPassCredential, ListOrderedMap.listOrderedMap(this.principalAttributes));
    expectedTGT.grantServiceTicket(ST_ID, null, null, false);
    assertEquals(expectedTGT, transcoder.decode(transcoder.encode(expectedTGT)));
}
项目:fitnessefixtures    文件:Xml2Json.java   
public JSONObject xml2jsonObj(NodeList nodes) throws Exception {
        this.basePath = null;
        if (nodes == null || nodes.getLength() == 0)
                return null;
        Node baseNode = nodes.item(0).getParentNode();
        if (baseNode == null)
                return null;
        this.basePath = getXPath((Element) baseNode);
        Map map = new ListOrderedMap();
        nodelist2json(map, nodes);
        return new JSONObject(map);
}
项目:imcms    文件:TextDocumentContentLoader.java   
private Loop toApiObject(com.imcode.imcms.mapping.jpa.doc.content.textdoc.Loop jpaLoop) {
    if (jpaLoop == null) {
        return null;

    } else {
        Map<Integer, Boolean> entries = new ListOrderedMap<>();
        jpaLoop.getEntries().forEach(entry -> entries.put(entry.getNo(), entry.isEnabled()));
        return Loop.of(entries, jpaLoop.getNextEntryNo());
    }
}
项目:imcms    文件:LoopController.java   
@RequestMapping(method = RequestMethod.POST)
protected Object doPost(@RequestParam(value = "indexes[]", required = false) List<Integer> indexes,
                        @RequestParam(value = "isEnabledFlags[]", required = false) List<Boolean> isEnabledFlags,
                        @RequestParam("loopId") Integer loopId,
                        @RequestParam("meta") Integer metaId) throws ServletException, IOException {

    Map<String, Object> result = new HashMap<>();

    if (indexes == null || isEnabledFlags == null) {
        indexes = new ArrayList<>();
        isEnabledFlags = new ArrayList<>();
    }

    if (indexes.size() != isEnabledFlags.size()) {
        result.put("message", "Different sizes of collections");
        result.put("result", false);

    } else {
        try {
            ImcmsServices imcmsServices = Imcms.getServices();
            DocumentMapper documentMapper = imcmsServices.getDocumentMapper();
            TextDocumentDomainObject document = documentMapper.getWorkingDocument(metaId);
            TextDocumentContentSaver contentSaver = imcmsServices.getManagedBean(TextDocumentContentSaver.class);

            Map<Integer, Boolean> entries = new ListOrderedMap<>();

            for (int i = 0; i < indexes.size(); i++) {
                entries.put(indexes.get(i), isEnabledFlags.get(i));
            }

            Loop loop = Loop.of(entries);
            Predicate<TextDocumentDomainObject.LoopItemRef> loopItemRefPredicate = entry ->
                    (loopId.equals(entry.getLoopNo()) && !loop.findEntryIndexByNo(entry.getEntryNo()).isPresent());

            document.getLoopImages().keySet().stream()
                    .filter(loopItemRefPredicate)
                    .forEach(document::deleteImage);

            document.getLoopTexts().keySet().stream()
                    .filter(loopItemRefPredicate)
                    .forEach(entry -> contentSaver.deleteText(document, entry));

            document.setLoop(loopId, loop);
            documentMapper.saveDocument(document, Imcms.getUser());

            TextDocLoopContainer container = new TextDocLoopContainer(document.getVersionRef(), loopId, loop);
            contentSaver.saveLoop(container);
            documentMapper.invalidateDocument(metaId);

            result.put("result", true);

        } catch (Exception e) {
            result.put("message", e);
            result.put("result", false);
        }
    }

    return result;
}
项目:HCFCore    文件:MapUtils.java   
/**
 * Returns a map that maintains the order of keys that are added
 * backed by the given map.
 * <p>
 * If a key is added twice, the order is determined by the first add.
 * The order is observed through the keySet, values and entrySet.
 *
 * @param <K>  the key type
 * @param <V>  the value type
 * @param map  the map to order, must not be null
 * @return an ordered map backed by the given map
 * @throws NullPointerException  if the Map is null
 */
public static <K, V> OrderedMap<K, V> orderedMap(final Map<K, V> map) {
    return ListOrderedMap.listOrderedMap(map);
}
项目:HCFCore    文件:MapUtils.java   
/**
 * Returns a map that maintains the order of keys that are added
 * backed by the given map.
 * <p>
 * If a key is added twice, the order is determined by the first add.
 * The order is observed through the keySet, values and entrySet.
 *
 * @param <K>  the key type
 * @param <V>  the value type
 * @param map  the map to order, must not be null
 * @return an ordered map backed by the given map
 * @throws NullPointerException  if the Map is null
 */
public static <K, V> OrderedMap<K, V> orderedMap(final Map<K, V> map) {
    return ListOrderedMap.listOrderedMap(map);
}