Example usage for org.apache.commons.collections4.map LinkedMap LinkedMap

List of usage examples for org.apache.commons.collections4.map LinkedMap LinkedMap

Introduction

In this page you can find the example usage for org.apache.commons.collections4.map LinkedMap LinkedMap.

Prototype

public LinkedMap() 

Source Link

Document

Constructs a new empty map with default size and load factor.

Usage

From source file:com.yahoo.elide.core.ResourceLineage.java

/**
 * Empty lineage for objects rooted in the URL.
 */
public ResourceLineage() {
    resourceMap = new LinkedMap<>();
}

From source file:cop.raml.utils.javadoc.MethodJavaDoc.java

@NotNull
private static Map<String, TagParam> getParams(List<String> doc) {
    if (CollectionUtils.isEmpty(doc))
        return Collections.emptyMap();

    Map<String, TagParam> params = new LinkedMap<>();
    String paramName = null;//from ww w . j a  v a  2 s  .com
    StringBuilder buf = null;
    Matcher matcher;

    for (String line : doc) {
        line = line.trim();

        if ((matcher = JavaDocTag.PARAM.getPattern().matcher(line)).find()) {
            if (paramName != null)
                addParameter(paramName, buf, params);

            paramName = matcher.group("name");
            buf = new StringBuilder(StringUtils.defaultString(matcher.group("text"), ""));
        } else if (paramName != null) {
            if (TAG.matcher(line).find()) {
                addParameter(paramName, buf, params);
                paramName = null;
            } else if (buf.length() > 0)
                buf.append('\n').append(line);
            else
                buf.append(line);
        }
    }

    if (paramName != null)
        addParameter(paramName, buf, params);

    return params.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(params);
}

From source file:com.haulmont.cuba.gui.data.impl.GroupDelegate.java

protected void doGroup() {
    roots = new LinkedList<>();
    parents = new LinkedHashMap<>();
    children = new HashMap<>();
    groupItems = new HashMap<>();
    itemGroups = new HashMap<>();

    final Collection<K> itemIds = datasource.getItemIds();
    for (final K id : itemIds) {
        final T item = datasource.getItem(id);
        GroupInfo<MetaPropertyPath> groupInfo = groupItems(0, null, roots, item, new LinkedMap());

        if (groupInfo == null) {
            throw new IllegalStateException("Item group cannot be NULL");
        }/*from ww w.jav  a2 s.c o m*/

        List<K> itemsIds = groupItems.computeIfAbsent(groupInfo, k -> new ArrayList<>());
        itemsIds.add(id);
    }
}

From source file:net.sf.jasperreports.engine.convert.ReportConverter.java

protected void setStyles(JRReport report) {
    //styleFactory = new StyleFactory();
    stylesMap = new LinkedMap<String, JRStyle>();

    loadReportStyles(report);/*w  w  w  . j  a  v  a  2 s . co m*/

    try {
        for (Iterator<JRStyle> it = stylesMap.values().iterator(); it.hasNext();) {
            JRStyle style = it.next();
            jasperPrint.addStyle(style);
        }
    } catch (JRException e) {
        throw new JRRuntimeException(e);
    }

    JRStyle reportDefault = report.getDefaultStyle();
    JRStyle printDefault = null;
    if (reportDefault == null) {
        //search for the last default style
        for (Iterator<JRStyle> it = stylesMap.values().iterator(); it.hasNext();) {
            JRStyle style = it.next();
            if (style.isDefault()) {
                printDefault = style;
            }
        }
    } else {
        printDefault = reportDefault;
    }

    if (printDefault != null) {
        jasperPrint.setDefaultStyle(printDefault);
    }
}

From source file:net.sf.jasperreports.crosstabs.design.JRDesignCrosstab.java

/**
 * Creates a new crosstab./* www .  ja v  a  2  s. c om*/
 * 
 * @param defaultStyleProvider default style provider
 */
public JRDesignCrosstab(JRDefaultStyleProvider defaultStyleProvider) {
    super(defaultStyleProvider);

    parametersList = new ArrayList<JRCrosstabParameter>();
    parametersMap = new HashMap<String, JRCrosstabParameter>();
    rowGroupsMap = new HashMap<String, Integer>();
    rowGroups = new ArrayList<JRCrosstabRowGroup>();
    columnGroupsMap = new HashMap<String, Integer>();
    columnGroups = new ArrayList<JRCrosstabColumnGroup>();
    measuresMap = new HashMap<String, Integer>();
    measures = new ArrayList<JRCrosstabMeasure>();

    cellsMap = new HashMap<Pair<String, String>, JRCrosstabCell>();
    cellsList = new ArrayList<JRCrosstabCell>();

    addBuiltinParameters();

    variablesList = new LinkedMap<String, JRVariable>();
    addBuiltinVariables();

    dataset = new JRDesignCrosstabDataset();
    lineBox = new JRBaseLineBox(this);
}

From source file:com.emarsys.predict.Transaction.java

void serialize(HttpUrl.Builder builder) {
    errors.clear();//  w ww . j  ava  2s.c  om

    // Validate commands
    validateCommands();

    // Handle customerId
    Session session = Session.getInstance();
    String customerId = session.getCustomerId();
    if (customerId != null) {
        if (customerId.isEmpty()) {
            ErrorParameter e = new ErrorParameter("INVALId_ARG", "customer",
                    "Invalid argument in customer command: customer should not be an empty string");
            Log.d(TAG, e.toString());
            errors.add(e);
        }
        builder.addQueryParameter("ci", customerId);
    }

    // Handle customerEmail
    String customerEmail = session.getCustomerEmail();
    if (customerEmail != null) {
        if (customerEmail.isEmpty()) {
            ErrorParameter e = new ErrorParameter("INVALId_ARG", "email",
                    "Invalid argument in email command: email should not be an empty string");
            Log.d(TAG, e.toString());
            errors.add(e);
        }
        String sha1 = StringUtil.sha1(customerEmail.trim().toLowerCase());
        builder.addQueryParameter("eh", sha1.toLowerCase().substring(0, 16) + "1");
    }

    // Handle keywords
    if (!keywords.isEmpty()) {
        KeywordCommand cmd = keywords.get(keywords.size() - 1);
        cmd.buildQuery(builder);
    }

    // Handle tags
    if (!tags.isEmpty()) {
        TagCommand cmd = tags.get(tags.size() - 1);
        cmd.buildQuery(builder);
    }

    // Handle availabilityZones
    if (!availabilityZones.isEmpty()) {
        AvailabilityZoneCommand cmd = availabilityZones.get(availabilityZones.size() - 1);
        cmd.buildQuery(builder);
    }

    // Handle carts
    if (!carts.isEmpty()) {
        builder.addQueryParameter("cv", String.valueOf(1));
        CartCommand cmd = carts.get(carts.size() - 1);
        cmd.buildQuery(builder);
    }

    // Handle categories
    if (!categories.isEmpty()) {
        CategoryCommand cmd = categories.get(categories.size() - 1);
        cmd.buildQuery(builder);
    }

    // Handle purchases
    if (!purchases.isEmpty()) {
        PurchaseCommand cmd = purchases.get(purchases.size() - 1);
        cmd.buildQuery(builder);
    }

    // Handle recommends
    List<String> features = new ArrayList<String>();
    List<String> baselines = new ArrayList<String>();
    List<Filter> filters = new ArrayList<Filter>();
    for (RecommendCommand next : recommends) {
        RecommendationRequest req = next.getRecommendationRequest();
        // Accumulate features
        features.add(next.toString());
        // Accumulate baselines
        if (req.getBaseline() != null) {
            String pi = req.getLogic() + StringUtil.toStringWithDelimiter(req.getBaseline(), "|");
            baselines.add(pi);
        }
        // Accumulate filters
        filters.addAll(req.getFilters());
    }
    if (!features.isEmpty()) {
        // Append features
        builder.addQueryParameter("f", StringUtil.toStringWithDelimiter(features, "|"));
    }
    if (!baselines.isEmpty()) {
        // Append baselines
        for (String next : baselines) {
            builder.addQueryParameter("pi", next);
        }
    }
    if (!filters.isEmpty()) {
        // Append filters
        List<Map<String, String>> l = new ArrayList<Map<String, String>>();
        for (Filter next : filters) {
            Map<String, String> m = new HashMap<String, String>();
            m.put("f", next.catalogField);
            m.put("r", next.rule);
            m.put("v", StringUtil.toStringWithDelimiter(next.values, "|"));
            m.put("n", (next instanceof ExcludeCommand) ? "false" : "true");
            l.add(m);
        }
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        builder.addQueryParameter("ex", gson.toJson(l));
    }

    // Handle searchTerms
    if (!searchTerms.isEmpty()) {
        SearchTermCommand cmd = searchTerms.get(searchTerms.size() - 1);
        cmd.buildQuery(builder);
    }

    // Handle views
    if (!views.isEmpty()) {
        ViewCommand cmd = views.get(views.size() - 1);
        cmd.buildQuery(builder);
    }

    // MAGIC
    builder.addQueryParameter("cp", String.valueOf(1));

    // Handle advertiserId
    String advertisingIdentifier = IdentifierManager.getInstance().getAdvertisingIdentifier();
    if (advertisingIdentifier != null) {
        builder.addQueryParameter("vi", advertisingIdentifier);
    }

    // Handle session
    String sessionId = session.getSession();
    if (sessionId != null) {
        builder.addQueryParameter("s", sessionId);
    }

    // Append errors
    if (!errors.isEmpty()) {
        List<Map<String, String>> l = new ArrayList<Map<String, String>>();
        for (ErrorParameter next : errors) {
            Map<String, String> m = new LinkedMap<String, String>();
            m.put("t", next.type);
            m.put("c", next.command);
            m.put("m", next.message);
            l.add(m);
        }
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        builder.addQueryParameter("error", gson.toJson(l));
    }
}

From source file:eu.artist.postmigration.eubt.executiontrace.abstractor.SOAPTraceAbstractor.java

/**
 * Validates soap trace (i.e., list of soap responses) against schema and
 * stores the result/* www  .ja va2  s .c o m*/
 * 
 * @param soapResponseTrace trace that contains soap responses
 * @return map of soap responses and their respective validation result
 * @throws EUBTException in case the schema location could not be found
 */
private LinkedMap<SOAPResponse, String> validateSoapTrace(final SOAPTrace soapResponseTrace)
        throws EUBTException {
    final LinkedMap<SOAPResponse, String> validationResults = new LinkedMap<SOAPResponse, String>();

    final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Validator validator;
    try {
        final Schema schema = schemaFactory.newSchema(new URL(schemaLocation));
        validator = schema.newValidator();
    } catch (SAXException | IOException e) {
        throw new EUBTException("Failed to create Schema from Schema location " + schemaLocation
                + ". Detailed Exception: " + e.getMessage());
    }
    // for each soap response
    for (final Response response : soapResponseTrace.getResponses()) {
        String validationResult = VALIDATION_INVALID;
        final SOAPResponse soapResponse = (SOAPResponse) response;
        final SOAPEnvelope soapEnvelope = (SOAPEnvelope) soapResponse.getData();
        final OMElement bodyContent = soapEnvelope.getBody().getFirstElement();

        // create some invalid content
        //         SOAP12Factory factory = new SOAP12Factory();
        //         OMElement invalidElement = factory.createOMElement(new QName("blah"));
        //         OMNamespace invalidNamespace = factory.createOMNamespace("http://notMyNamespace.com", "invNS");
        //         OMAttribute invalidAttribute = factory.createOMAttribute("someAttribute", invalidNamespace, "attributeValue");
        //         bodyContent.addChild(invalidElement);
        //         bodyContent.addAttribute(invalidAttribute);

        // validate soap body content -> will cause an exception if not valid
        try {
            validator.validate(bodyContent.getSAXSource(true));
            // validation succeeded
            validationResult = VALIDATION_VALID;
            Debug.debug(this, "Successfully validated SOAP body content " + bodyContent);
        } catch (final IOException e) {
            throw new EUBTException("Failed to validate SOAP body content " + bodyContent
                    + ". Detailed Exception: " + e.getMessage());
        } catch (final SAXException e) {
            // validation failed
            Debug.debug(this, "Failed to validate soap SOAP content " + bodyContent + ". Detailed Exception: "
                    + e.getMessage());
        }
        // finished validating, store result
        validationResults.put(soapResponse, validationResult);
        validator.reset();
    } // for each soap response

    return validationResults;
}

From source file:net.sf.jasperreports.engine.fill.JRFillObjectFactory.java

public List<JRStyle> setStyles(List<JRStyle> styles) {
    originalStyleList = new HashSet<JRStyle>(styles);

    //filtering requested styles
    Set<JRStyle> requestedStyles = collectRequestedStyles(styles);

    //collect used styles
    Map<JRStyle, Object> usedStylesMap = new LinkedMap<JRStyle, Object>();
    Map<String, JRStyle> allStylesMap = new HashMap<String, JRStyle>();
    for (Iterator<JRStyle> it = styles.iterator(); it.hasNext();) {
        JRStyle style = it.next();/*from  w  w  w.  ja v  a2 s.  c  om*/
        if (requestedStyles.contains(style)) {
            collectUsedStyles(style, usedStylesMap, allStylesMap);
        }
        allStylesMap.put(style.getName(), style);
    }

    List<JRStyle> includedStyles = new ArrayList<JRStyle>();
    for (Iterator<JRStyle> it = usedStylesMap.keySet().iterator(); it.hasNext();) {
        JRStyle style = it.next();
        JRStyle newStyle = getStyle(style);

        includedStyles.add(newStyle);
        if (requestedStyles.contains(style)) {
            useDelayedStyle(newStyle);
        }
    }

    checkUnresolvedReferences();

    return includedStyles;
}

From source file:org.apache.syncope.client.cli.commands.connector.ConnectorDetails.java

public void details() {
    if (input.parameterNumber() == 0) {
        try {//from  w  w w  .j  a  va 2  s. c o  m
            final Map<String, String> details = new LinkedMap<>();
            final List<ConnInstanceTO> connInstanceTOs = connectorSyncopeOperations.list();
            int withCreateCapability = 0;
            int withDeleteCapability = 0;
            int withSearchCapability = 0;
            int withSyncCapability = 0;
            int withUpdateCapability = 0;
            for (final ConnInstanceTO connInstanceTO : connInstanceTOs) {
                if (connInstanceTO.getCapabilities().contains(ConnectorCapability.CREATE)) {
                    withCreateCapability++;
                }
                if (connInstanceTO.getCapabilities().contains(ConnectorCapability.DELETE)) {
                    withDeleteCapability++;
                }
                if (connInstanceTO.getCapabilities().contains(ConnectorCapability.SEARCH)) {
                    withSearchCapability++;
                }
                if (connInstanceTO.getCapabilities().contains(ConnectorCapability.SYNC)) {
                    withSyncCapability++;
                }
                if (connInstanceTO.getCapabilities().contains(ConnectorCapability.UPDATE)) {
                    withUpdateCapability++;
                }
            }
            details.put("Total number", String.valueOf(connInstanceTOs.size()));
            details.put("With create capability", String.valueOf(withCreateCapability));
            details.put("With delete capability", String.valueOf(withDeleteCapability));
            details.put("With search capability", String.valueOf(withSearchCapability));
            details.put("With sync capability", String.valueOf(withSyncCapability));
            details.put("With update capability", String.valueOf(withUpdateCapability));
            details.put("Bundles number", String.valueOf(connectorSyncopeOperations.getBundles().size()));
            connectorResultManager.printDetails(details);
        } catch (final SyncopeClientException ex) {
            LOG.error("Error reading details about connector", ex);
            connectorResultManager.genericError(ex.getMessage());
        }
    } else {
        connectorResultManager.unnecessaryParameters(input.listParameters(), DETAILS_HELP_MESSAGE);
    }
}

From source file:org.apache.syncope.client.cli.commands.domain.DomainDetails.java

public void details() {
    if (input.parameterNumber() == 0) {
        try {//from  w  ww .  ja  v  a2 s .  c om
            final Map<String, String> details = new LinkedMap<>();
            details.put("Total number", String.valueOf(domainSyncopeOperations.list().size()));
            domainResultManager.printDetails(details);
        } catch (final SyncopeClientException ex) {
            LOG.error("Error reading details about domain", ex);
            domainResultManager.genericError(ex.getMessage());
        }
    } else {
        domainResultManager.unnecessaryParameters(input.listParameters(), LIST_HELP_MESSAGE);
    }

}