Example usage for java.util SortedMap put

List of usage examples for java.util SortedMap put

Introduction

In this page you can find the example usage for java.util SortedMap put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamSecGroupTable.java

public void createSecGroup(CFAccAuthorization Authorization, CFAccSecGroupBuff Buff) {
    CFAccSecGroupPKey pkey = schema.getFactorySecGroup().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupId(((CFAccRamClusterTable) schema.getTableCluster())
            .nextSecGroupIdGen(Authorization, Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredSecGroupId(pkey.getRequiredSecGroupId());
    CFAccSecGroupByClusterIdxKey keyClusterIdx = schema.getFactorySecGroup().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFAccSecGroupByUNameIdxKey keyUNameIdx = schema.getFactorySecGroup().newUNameIdxKey();
    keyUNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUNameIdx.setRequiredName(Buff.getRequiredName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createSecGroup",
                pkey);/*from  w w  w  .j ava  2 s  . c o m*/
    }

    if (dictByUNameIdx.containsKey(keyUNameIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createSecGroup",
                "SecGroupUNameIdx", keyUNameIdx);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredClusterId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createSecGroup", "Container", "SecGroupCluster", "Cluster", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFAccSecGroupPKey, CFAccSecGroupBuff> subdictClusterIdx;
    if (dictByClusterIdx.containsKey(keyClusterIdx)) {
        subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
    } else {
        subdictClusterIdx = new TreeMap<CFAccSecGroupPKey, CFAccSecGroupBuff>();
        dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
    }
    subdictClusterIdx.put(pkey, Buff);

    dictByUNameIdx.put(keyUNameIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamSecGroupTable.java

public void createSecGroup(CFAstAuthorization Authorization, CFAstSecGroupBuff Buff) {
    CFAstSecGroupPKey pkey = schema.getFactorySecGroup().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupId(((CFAstRamClusterTable) schema.getTableCluster())
            .nextSecGroupIdGen(Authorization, Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredSecGroupId(pkey.getRequiredSecGroupId());
    CFAstSecGroupByClusterIdxKey keyClusterIdx = schema.getFactorySecGroup().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFAstSecGroupByUNameIdxKey keyUNameIdx = schema.getFactorySecGroup().newUNameIdxKey();
    keyUNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUNameIdx.setRequiredName(Buff.getRequiredName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createSecGroup",
                pkey);/*from w  w w. ja  v  a2s  .  c  o m*/
    }

    if (dictByUNameIdx.containsKey(keyUNameIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createSecGroup",
                "SecGroupUNameIdx", keyUNameIdx);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization,
                    Buff.getRequiredClusterId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createSecGroup", "Container", "SecGroupCluster", "Cluster", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFAstSecGroupPKey, CFAstSecGroupBuff> subdictClusterIdx;
    if (dictByClusterIdx.containsKey(keyClusterIdx)) {
        subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
    } else {
        subdictClusterIdx = new TreeMap<CFAstSecGroupPKey, CFAstSecGroupBuff>();
        dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
    }
    subdictClusterIdx.put(pkey, Buff);

    dictByUNameIdx.put(keyUNameIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamContactListTable.java

public void createContactList(CFAccAuthorization Authorization, CFAccContactListBuff Buff) {
    CFAccContactListPKey pkey = schema.getFactoryContactList().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredContactListId(((CFAccRamTenantTable) schema.getTableTenant())
            .nextContactListIdGen(Authorization, Buff.getRequiredTenantId()));
    Buff.setRequiredTenantId(pkey.getRequiredTenantId());
    Buff.setRequiredContactListId(pkey.getRequiredContactListId());
    CFAccContactListByTenantIdxKey keyTenantIdx = schema.getFactoryContactList().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccContactListByUDescrIdxKey keyUDescrIdx = schema.getFactoryContactList().newUDescrIdxKey();
    keyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
        throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createContactList",
                pkey);/*  w ww.j  a  v  a  2 s  . c om*/
    }

    if (dictByUDescrIdx.containsKey(keyUDescrIdx)) {
        throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                "createContactList", "ContactListUDescrIdx", keyUDescrIdx);
    }

    // Validate foreign keys

    {
        boolean allNull = true;
        allNull = false;
        if (!allNull) {
            if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
                throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                        "createContactList", "Container", "ContactListTenant", "Tenant", null);
            }
        }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    SortedMap<CFAccContactListPKey, CFAccContactListBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
        subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
        subdictTenantIdx = new TreeMap<CFAccContactListPKey, CFAccContactListBuff>();
        dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);

    dictByUDescrIdx.put(keyUDescrIdx, Buff);

}

From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgRspnHandler.CFGCashXMsgRspnAccountConfigRecHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from ww  w .jav a2 s .  c om*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // AccountConfig Attributes
        String attrTenantId = null;
        String attrDefaultCurrencyId = null;
        String attrCustContactListTenantId = null;
        String attrCustContactListId = null;
        String attrEmpContactListTenantId = null;
        String attrEmpContactListId = null;
        String attrVendContactListTenantId = null;
        String attrVendContactListId = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("AccountConfig");

        CFGCashXMsgRspnHandler xmsgRspnHandler = (CFGCashXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFGCashSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("TenantId")) {
                if (attrTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("DefaultCurrencyId")) {
                if (attrDefaultCurrencyId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrDefaultCurrencyId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CustContactListTenantId")) {
                if (attrCustContactListTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustContactListTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CustContactListId")) {
                if (attrCustContactListId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCustContactListId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("EmpContactListTenantId")) {
                if (attrEmpContactListTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrEmpContactListTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("EmpContactListId")) {
                if (attrEmpContactListId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrEmpContactListId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("VendContactListTenantId")) {
                if (attrVendContactListTenantId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrVendContactListTenantId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("VendContactListId")) {
                if (attrVendContactListId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrVendContactListId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrTenantId == null) || (attrTenantId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "TenantId");
        }
        if ((attrDefaultCurrencyId == null) || (attrDefaultCurrencyId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "DefaultCurrencyId");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = xmsgRspnHandler.getCurContext();

        // Convert string attributes to native Java types

        long natTenantId = Long.parseLong(attrTenantId);

        short natDefaultCurrencyId = Short.parseShort(attrDefaultCurrencyId);

        Long natCustContactListTenantId;
        if ((attrCustContactListTenantId == null) || (attrCustContactListTenantId.length() <= 0)) {
            natCustContactListTenantId = null;
        } else {
            natCustContactListTenantId = new Long(Long.parseLong(attrCustContactListTenantId));
        }

        Long natCustContactListId;
        if ((attrCustContactListId == null) || (attrCustContactListId.length() <= 0)) {
            natCustContactListId = null;
        } else {
            natCustContactListId = new Long(Long.parseLong(attrCustContactListId));
        }

        Long natEmpContactListTenantId;
        if ((attrEmpContactListTenantId == null) || (attrEmpContactListTenantId.length() <= 0)) {
            natEmpContactListTenantId = null;
        } else {
            natEmpContactListTenantId = new Long(Long.parseLong(attrEmpContactListTenantId));
        }

        Long natEmpContactListId;
        if ((attrEmpContactListId == null) || (attrEmpContactListId.length() <= 0)) {
            natEmpContactListId = null;
        } else {
            natEmpContactListId = new Long(Long.parseLong(attrEmpContactListId));
        }

        Long natVendContactListTenantId;
        if ((attrVendContactListTenantId == null) || (attrVendContactListTenantId.length() <= 0)) {
            natVendContactListTenantId = null;
        } else {
            natVendContactListTenantId = new Long(Long.parseLong(attrVendContactListTenantId));
        }

        Long natVendContactListId;
        if ((attrVendContactListId == null) || (attrVendContactListId.length() <= 0)) {
            natVendContactListId = null;
        } else {
            natVendContactListId = new Long(Long.parseLong(attrVendContactListId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Get the parent context
        CFLibXmlCoreContext parentContext = curContext.getPrevContext();
        // Instantiate a buffer for the parsed information
        ICFGCashAccountConfigObj obj = schemaObj.getAccountConfigTableObj().newInstance();
        CFGCashAccountConfigBuff dataBuff = obj.getAccountConfigBuff();
        dataBuff.setRequiredTenantId(natTenantId);
        dataBuff.setRequiredDefaultCurrencyId(natDefaultCurrencyId);
        dataBuff.setOptionalCustContactListTenantId(natCustContactListTenantId);
        dataBuff.setOptionalCustContactListId(natCustContactListId);
        dataBuff.setOptionalEmpContactListTenantId(natEmpContactListTenantId);
        dataBuff.setOptionalEmpContactListId(natEmpContactListId);
        dataBuff.setOptionalVendContactListTenantId(natVendContactListTenantId);
        dataBuff.setOptionalVendContactListId(natVendContactListId);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        SortedMap<CFGCashAccountConfigPKey, ICFGCashAccountConfigObj> sortedMap = (SortedMap<CFGCashAccountConfigPKey, ICFGCashAccountConfigObj>) xmsgRspnHandler
                .getSortedMapOfObjects();
        ICFGCashAccountConfigObj realized = (ICFGCashAccountConfigObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
        if (sortedMap != null) {
            sortedMap.put(realized.getPKey(), realized);
        }
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:hivemall.topicmodel.OnlineLDAModel.java

@Nonnull
public SortedMap<Float, List<String>> getTopicWords(@Nonnegative final int k, @Nonnegative int topN) {
    double lambdaSum = 0.d;
    final SortedMap<Float, List<String>> sortedLambda = new TreeMap<Float, List<String>>(
            Collections.reverseOrder());

    for (Map.Entry<String, float[]> e : _lambda.entrySet()) {
        final float lambda_k = e.getValue()[k];
        lambdaSum += lambda_k;/*ww w.  j  a  va 2  s.c o  m*/

        List<String> labels = sortedLambda.get(lambda_k);
        if (labels == null) {
            labels = new ArrayList<String>();
            sortedLambda.put(lambda_k, labels);
        }
        labels.add(e.getKey());
    }

    final SortedMap<Float, List<String>> ret = new TreeMap<Float, List<String>>(Collections.reverseOrder());

    topN = Math.min(topN, _lambda.keySet().size());
    int tt = 0;
    for (Map.Entry<Float, List<String>> e : sortedLambda.entrySet()) {
        float key = (float) (e.getKey().floatValue() / lambdaSum);
        ret.put(Float.valueOf(key), e.getValue());

        if (++tt == topN) {
            break;
        }
    }

    return ret;
}

From source file:org.wrml.runtime.format.text.html.WrmldocFormatter.java

protected ObjectNode buildApiNode(final ObjectMapper objectMapper, final Model model) {

    final ObjectNode apiNode = objectMapper.createObjectNode();
    if (!(model instanceof Document)) {
        return apiNode;
    }//from w w w .  ja va2s .  com

    final Context context = getContext();

    final Document document = (Document) model;
    final URI uri = document.getUri();
    final ApiLoader apiLoader = context.getApiLoader();
    final ApiNavigator apiNavigator = apiLoader.getParentApiNavigator(uri);
    final Api api = apiNavigator.getApi();
    final Resource endpointResource = apiNavigator.getResource(uri);

    final URI apiUri = api.getUri();

    apiNode.put(PropertyName.uri.name(), apiUri.toString());
    apiNode.put(PropertyName.title.name(), api.getTitle());
    apiNode.put(PropertyName.description.name(), api.getDescription());
    apiNode.put(PropertyName.version.name(), api.getVersion());

    final Map<URI, ObjectNode> schemaNodes = new HashMap<>();
    final Map<URI, LinkRelation> linkRelationCache = new HashMap<>();

    if (document instanceof Api) {

        final Map<UUID, Resource> allResources = apiNavigator.getAllResources();
        final SortedMap<String, Resource> orderedResources = new TreeMap<>();

        for (final Resource resource : allResources.values()) {
            orderedResources.put(resource.getPathText(), resource);
        }

        final ArrayNode allResourcesNode = objectMapper.createArrayNode();
        for (final Resource resource : orderedResources.values()) {
            final ObjectNode resourceNode = buildResourceNode(objectMapper, schemaNodes, linkRelationCache,
                    apiNavigator, resource);
            allResourcesNode.add(resourceNode);
        }

        apiNode.put(PropertyName.allResources.name(), allResourcesNode);
    } else {
        final ObjectNode endpointResourceNode = buildResourceNode(objectMapper, schemaNodes, linkRelationCache,
                apiNavigator, endpointResource);
        apiNode.put(PropertyName.resource.name(), endpointResourceNode);
    }

    return apiNode;
}

From source file:com.medvision360.medrecord.pv.PVReader.java

public SortedMap<String, String> toMap(InputStream is) throws IOException, ParseException {
    ObjectMapper mapper = new ObjectMapper();
    JsonNode rootNode = mapper.readValue(is, JsonNode.class);

    Iterator<Map.Entry<String, JsonNode>> fields = rootNode.fields();
    SortedMap<String, String> pv = new TreeMap<>(new ExactPathComparator());
    while (fields.hasNext()) {
        Map.Entry<String, JsonNode> field = fields.next();
        String key = field.getKey();
        JsonNode node = field.getValue();
        JsonNodeType nodeType = node.getNodeType();
        String value;/*from ww w.  ja va2 s .  c o  m*/
        switch (nodeType) {
        case NULL:
            value = null;
            break;
        case BOOLEAN:
        case NUMBER:
        case STRING:
            value = node.asText();
            break;
        case ARRAY:
        case BINARY:
        case OBJECT:
        case MISSING:
        case POJO:
        default:
            throw new ParseException(
                    String.format("Path %s value is of type %s, need a primitive", key, nodeType));
        }
        pv.put(key, value);
    }

    return pv;
}

From source file:com.baidubce.auth.BceV1Signer.java

private SortedMap<String, String> getHeadersToSign(Map<String, String> headers, Set<String> headersToSign) {
    SortedMap<String, String> ret = Maps.newTreeMap();
    if (headersToSign != null) {
        Set<String> tempSet = Sets.newHashSet();
        for (String header : headersToSign) {
            tempSet.add(header.trim().toLowerCase());
        }/*from   www  .j av  a  2 s.  c om*/
        headersToSign = tempSet;
    }
    for (Map.Entry<String, String> entry : headers.entrySet()) {
        String key = entry.getKey();
        if (entry.getValue() != null && !entry.getValue().isEmpty()) {
            if ((headersToSign == null && this.isDefaultHeaderToSign(key))
                    || (headersToSign != null && headersToSign.contains(key.toLowerCase())
                            && !Headers.AUTHORIZATION.equalsIgnoreCase(key))) {
                ret.put(key, entry.getValue());
            }
        }
    }
    return ret;
}

From source file:com.citic.zxyjs.zwlscx.mapreduce.join.api.DataJoinReducerBase.java

/**
 * This is the function that re-groups values for a key into sub-groups
 * based on a secondary key (input tag).
 * //from  w ww  .  j  a va  2s  .co m
 * @param values
 * @return
 */
private SortedMap<Text, ResetableIterator<TaggedMapOutput>> regroup(Text key, Iterator<TaggedMapOutput> values,
        Context context) throws IOException {
    this.numOfValues = 0;
    SortedMap<Text, ResetableIterator<TaggedMapOutput>> retv = new TreeMap<Text, ResetableIterator<TaggedMapOutput>>();
    TaggedMapOutput aRecord = null;
    while (values.hasNext()) {
        this.numOfValues += 1;
        if (this.numOfValues % 100 == 0) {
            reporter.setStatus("key: " + key.toString() + " numOfValues: " + this.numOfValues);
        }
        if (this.numOfValues > this.maxNumOfValuesPerGroup) {
            continue;
        }
        aRecord = values.next().clone(context.getConfiguration());
        Text tag = aRecord.getTag();
        ResetableIterator<TaggedMapOutput> data = retv.get(tag);
        if (data == null) {
            data = createResetableIterator();
            retv.put(tag, data);
        }
        data.add(aRecord);
    }
    if (this.numOfValues > this.largestNumOfValues) {
        this.largestNumOfValues = numOfValues;
        LOG.info("key: " + key.toString() + " this.largestNumOfValues: " + this.largestNumOfValues);
    }
    return retv;
}

From source file:org.squale.squaleweb.applicationlayer.action.export.ppt.AuditReportPPTData.java

/**
 * Build factors sorted map : key = factorName value = result for current audit
 * // w w w  .j a va 2  s .c o  m
 * @param qualityResults quality results
 * @return the sorted map for kiviat graph
 */
private SortedMap buildSortedMapForKiviat(List qualityResults) {
    SortedMap results = new TreeMap();
    for (int i = 0; i < qualityResults.size(); i++) {
        QualityReportDTO factor = (QualityReportDTO) qualityResults.get(i);
        results.put(factor.getRule().getName().replaceFirst("rule\\.", ""), new Float(factor.getMeanMark()));
    }
    return results;
}