Example usage for java.util LinkedHashSet size

List of usage examples for java.util LinkedHashSet size

Introduction

In this page you can find the example usage for java.util LinkedHashSet size.

Prototype

int size();

Source Link

Document

Returns the number of elements in this set (its cardinality).

Usage

From source file:org.languagetool.tagging.uk.CompoundTagger.java

private List<AnalyzedToken> doGuessMultiHyphens(String word, int firstDashIdx, int dashIdx) {
    String lowerWord = word.toLowerCase();

    String[] parts = lowerWord.split("-");
    LinkedHashSet<String> set = new LinkedHashSet<>(Arrays.asList(parts));

    // try intj/*from   w  w w.  j a  va 2 s .  co m*/
    String leftWd = parts[0];
    if (set.size() == 2) {
        List<TaggedWord> leftWdList = tagEitherCase(leftWd);
        List<TaggedWord> rightWdList = tagEitherCase(new ArrayList<>(set).get(1));

        if (PosTagHelper.hasPosTag2(leftWdList, INTJ_PATTERN)
                && PosTagHelper.hasPosTag2(rightWdList, INTJ_PATTERN)) {
            return Arrays.asList(new AnalyzedToken(word, rightWdList.get(0).getPosTag(), lowerWord));
        }
    } else if (set.size() == 1) {
        if (lowerWord.equals("")) {
            return Arrays.asList(new AnalyzedToken(word, "intj", lowerWord));
        }

        List<TaggedWord> rightWdList = tagEitherCase(leftWd);
        if (PosTagHelper.hasPosTag2(rightWdList, INTJ_PATTERN)) {
            return Arrays.asList(new AnalyzedToken(word, rightWdList.get(0).getPosTag(), lowerWord));
        }
    }
    //      Pattern stretch = Pattern.compile("[-?]+([-?])(-$1)+-[-?]+");
    //      Matcher matcher = stretch.matcher(word);
    // ---
    if (parts.length >= 3 && (set.size() == 3 || set.size() == 2) && parts[1].length() == 1) {

        String rightWd = parts[parts.length - 1];
        List<TaggedWord> wdList = tagEitherCase(leftWd + rightWd);

        if (wdList.isEmpty() && leftWd.charAt(leftWd.length() - 1) == rightWd.charAt(0)
                && rightWd.charAt(0) == parts[1].charAt(0)) {
            // ---
            wdList = tagEitherCase(leftWd + rightWd.substring(1));
        }
        if (!wdList.isEmpty()) {
            return ukrainianTagger.asAnalyzedTokenListForTaggedWordsInternal(word,
                    PosTagHelper.addIfNotContains(wdList, ":coll"));
        }
    }

    return null;
}

From source file:net.sf.maltcms.chromaui.project.spi.nodes.DescriptorNode.java

@Override
public Action[] getActions(boolean context) {
    List<?> interfaces = ClassUtils.getAllInterfaces(getBean().getClass());
    List<?> superClasses = ClassUtils.getAllSuperclasses(getBean().getClass());
    LinkedHashSet<Action> descriptorActions = new LinkedHashSet<>();
    for (Object o : interfaces) {
        Class<?> c = (Class) o;
        descriptorActions.addAll(Utilities.actionsForPath("Actions/DescriptorNodeActions/" + c.getName()));
        descriptorActions/*  w  w w  .  jav  a  2s .c o  m*/
                .addAll(Utilities.actionsForPath("Actions/DescriptorNodeActions/" + c.getSimpleName()));
    }
    for (Object o : superClasses) {
        Class<?> c = (Class) o;
        descriptorActions.addAll(Utilities.actionsForPath("Actions/DescriptorNodeActions/" + c.getName()));
        descriptorActions
                .addAll(Utilities.actionsForPath("Actions/DescriptorNodeActions/" + c.getSimpleName()));
    }
    descriptorActions.addAll(
            Utilities.actionsForPath("Actions/DescriptorNodeActions/" + getBean().getClass().getName()));
    descriptorActions.addAll(
            Utilities.actionsForPath("Actions/DescriptorNodeActions/" + getBean().getClass().getSimpleName()));
    descriptorActions.add(null);
    descriptorActions.addAll(Utilities.actionsForPath("Actions/DescriptorNodeActions/DefaultActions"));
    descriptorActions.add(SystemAction.get(PropertiesAction.class));
    return descriptorActions.toArray(new Action[descriptorActions.size()]);
}

From source file:Simulator.PerformanceCalculation.java

public JPanel waitTime() {
    LinkedHashSet no = new LinkedHashSet();
    LinkedHashMap<Integer, ArrayList<Double>> wait1 = new LinkedHashMap<>();

    for (Map.Entry<Integer, TraceObject> entry : l.getLocalTrace().entrySet()) {
        TraceObject traceObject = entry.getValue();

        if (wait1.get(traceObject.getSurgeonId()) == null) {
            ArrayList details = new ArrayList();
            details.add(traceObject.getWaitTime1());
            details.add(traceObject.getWaitTime2());
            wait1.put(traceObject.getSurgeonId(), details);
        } else {//  w  w w  . j  av a  2  s  .  co m
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime1());
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime2());
        }

        no.add(traceObject.getSurgeonId());
    }
    String[] column = new String[no.size()];

    String series1 = "Wait Time";
    for (int i = 0; i < no.size(); i++) {
        column[i] = "Surgeon " + (i + 1);
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    LinkedHashMap<Integer, Double> average = new LinkedHashMap<>();
    for (Map.Entry<Integer, ArrayList<Double>> entry : wait1.entrySet()) {
        Integer integer = entry.getKey();
        ArrayList<Double> arrayList = entry.getValue();
        double total = 0;
        for (Double double1 : arrayList) {
            total += double1;
        }
        average.put(integer, total / (arrayList.size() / 2));
    }

    for (int i = 1; i <= average.size(); i++) {
        dataset.addValue(Math.round(average.get(i) / 600), series1, column[i - 1]);
    }
    JFreeChart chart = ChartFactory.createBarChart("Wait Time", // chart title
            "Surgeon ID", // domain axis label
            "Days", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    return new ChartPanel(chart);
}

From source file:Simulator.PerformanceCalculation.java

public JPanel costAnaylsis() {
    LinkedHashSet no = new LinkedHashSet();
    LinkedHashMap<Integer, ArrayList<Double>> wait1 = new LinkedHashMap<>();

    for (Map.Entry<Integer, TraceObject> entry : l.getLocalTrace().entrySet()) {
        TraceObject traceObject = entry.getValue();

        if (wait1.get(traceObject.getSurgeonId()) == null) {
            ArrayList details = new ArrayList();
            details.add(traceObject.getWaitTime1());
            details.add(traceObject.getWaitTime2());
            wait1.put(traceObject.getSurgeonId(), details);
        } else {//w  ww .j  a  v a2 s  .c o m
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime1());
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime2());
        }

        no.add(traceObject.getSurgeonId());
    }
    String[] column = new String[no.size()];

    String series1 = "Cost";
    for (int i = 0; i < no.size(); i++) {
        column[i] = "Surgeon " + (i + 1);
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    int totalCost = 0;
    LinkedHashMap<Integer, Double> average = new LinkedHashMap<>();
    for (Map.Entry<Integer, ArrayList<Double>> entry : wait1.entrySet()) {
        Integer integer = entry.getKey();
        ArrayList<Double> arrayList = entry.getValue();
        double total = 0;
        for (Double double1 : arrayList) {
            total += double1;
        }
        totalCost += total * Configuration.costOfPatientWaiting;
        average.put(integer, total / 600);
    }

    for (int i = 1; i <= average.size(); i++) {
        dataset.addValue(Math.round(average.get(i) * Configuration.costOfPatientWaiting), series1,
                column[i - 1]);
    }
    totalCostClass = totalCost;
    JFreeChart chart = ChartFactory.createBarChart("Cost", // chart title
            "Surgeon ID", // domain axis label
            "$", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    return new ChartPanel(chart);
}

From source file:Simulator.PerformanceCalculation.java

private CategoryDataset createDataset() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    LinkedHashSet no = new LinkedHashSet();
    LinkedHashMap<Integer, ArrayList<Double>> wait1 = new LinkedHashMap<>();

    for (Map.Entry<Integer, TraceObject> entry : l.getLocalTrace().entrySet()) {
        TraceObject traceObject = entry.getValue();

        if (wait1.get(traceObject.getSurgeonId()) == null) {
            ArrayList details = new ArrayList();
            details.add(traceObject.getWaitTime1());
            details.add(traceObject.getWaitTime2());
            wait1.put(traceObject.getSurgeonId(), details);
        } else {//from ww w .  j a v  a2s.c om
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime1());
            wait1.get(traceObject.getSurgeonId()).add(traceObject.getWaitTime2());
        }

        no.add(traceObject.getSurgeonId());
    }
    String[] column = new String[no.size()];

    String series1 = "Minimum Cost";
    String series2 = "Acceptable Cost";
    String series3 = "Actual Cost";

    for (int i = 0; i < no.size(); i++) {
        column[i] = "Surgeon " + (i + 1);
    }

    LinkedHashMap<Integer, Double> average = new LinkedHashMap<>();
    for (Map.Entry<Integer, ArrayList<Double>> entry : wait1.entrySet()) {
        Integer integer = entry.getKey();
        ArrayList<Double> arrayList = entry.getValue();
        double total = 0;
        for (Double double1 : arrayList) {
            total += double1;
        }
        average.put(integer, total / 600);
    }

    for (int i = 1; i <= average.size(); i++) {
        int costMin = (Configuration.minimumSurgeryTime * (wait1.get(i).size() / 2)
                * Configuration.costOfPatientWaiting);
        int costAccept = (Configuration.acceptedSurgeryTime * (wait1.get(i).size() / 2)
                * Configuration.costOfPatientWaiting);
        int actualCost = (int) Math.round(average.get(i) * Configuration.costOfPatientWaiting);

        int x = actualCost - (costAccept + costMin);
        if (x > actualCost) {
            x = actualCost;
        }
        dataset.addValue(costMin, series1, column[i - 1]);
        dataset.addValue(costAccept - costMin, series2, column[i - 1]);
        dataset.addValue(x, series3, column[i - 1]);
    }

    return dataset;
}

From source file:org.alfresco.bm.dataload.rm.unfiled.ScheduleUnfiledRecordLoaders.java

/**
 * Helper method that initialize the unfiled record folders that can receive loaded unfiled records.
 * This method, also calculates the number of records to  add to the initialized unfiled record folders.
 *//* ww w.  j  av  a  2s  . c  o  m*/
private void calculateListOfEmptyFolders() {
    if (mapOfRecordsPerUnfiledRecordFolder == null) {
        mapOfRecordsPerUnfiledRecordFolder = new LinkedHashMap<FolderData, Integer>();
        List<FolderData> unfiledRecordFoldersThatNeedRecords = new ArrayList<FolderData>();
        if (paths == null || paths.size() == 0) {
            unfiledRecordFoldersThatNeedRecords.addAll(initialiseFoldersToExistingStructure(UNFILED_CONTEXT));
        } else {
            LinkedHashSet<FolderData> unfiledFolderStructerFromExistentProvidedPaths = new LinkedHashSet<FolderData>();
            for (String path : paths) {
                if (!path.startsWith("/")) {
                    path = "/" + path;
                }
                FolderData folder = fileFolderService.getFolder(UNFILED_CONTEXT,
                        UNFILED_RECORD_CONTAINER_PATH + path);
                if (folder != null)//if folder exists
                {
                    unfiledFolderStructerFromExistentProvidedPaths.addAll(getUnfiledRecordFolders(folder));
                } else {
                    try {
                        folder = createFolder(path);
                        unfiledRecordFoldersThatNeedRecords.add(folder);
                    } catch (Exception e) {
                        // something went wrong on creating current path structure, not all required paths will be created
                    }
                }
            }
            //add unfiled record folders from existent paths
            if (unfiledFolderStructerFromExistentProvidedPaths.size() > 0) {
                unfiledRecordFoldersThatNeedRecords.addAll(unfiledFolderStructerFromExistentProvidedPaths);
            }
            // configured paths did not existed in db and something went wrong with creation for all of them, initialize to existing structure in this case
            if (unfiledRecordFoldersThatNeedRecords.size() == 0) {
                unfiledRecordFoldersThatNeedRecords
                        .addAll(initialiseFoldersToExistingStructure(UNFILED_CONTEXT));
            }
        }
        if (unfiledRecordFoldersThatNeedRecords.size() > 0) {
            mapOfRecordsPerUnfiledRecordFolder = distributeNumberOfRecords(unfiledRecordFoldersThatNeedRecords,
                    unfiledRecordsNumber);
        }
    }
}

From source file:cz.incad.kramerius.pdf.impl.FirstPagePDFServiceImpl.java

String templateSelection(PreparedDocument rdoc, String... pids)
        throws XPathExpressionException, IOException, ParserConfigurationException, SAXException {
    ResourceBundle resourceBundle = resourceBundleService.getResourceBundle("base", localesProvider.get());

    StringTemplate template = new StringTemplate(IOUtils.readAsString(
            this.getClass().getResourceAsStream("templates/_first_page.st"), Charset.forName("UTF-8"), true));
    FirstPageViewObject fpvo = prepareViewObject(resourceBundle);

    // tistena polozka
    GeneratedItem itm = new GeneratedItem();

    Map<String, LinkedHashSet<String>> detailItemValues = new HashMap<String, LinkedHashSet<String>>();
    Map<String, ObjectPidsPath> pathsMapping = new HashMap<String, ObjectPidsPath>();
    LinkedHashSet<String> roots = new LinkedHashSet<String>();
    for (String pid : pids) {
        ObjectPidsPath sPath = selectOnePath(pid);
        pathsMapping.put(pid, sPath);// w ww  .j  av a 2  s  .c o  m
        roots.add(sPath.getRoot());
    }

    for (String pid : pids) {
        ObjectPidsPath path = pathsMapping.get(pid);
        Map<String, Map<String, List<String>>> mods = processModsFromPath(path, null);
        String rootPid = path.getRoot();
        if (mods.get(rootPid).containsKey(TitleBuilder.MODS_TITLE)) {
            List<String> list = mods.get(rootPid).get(TitleBuilder.MODS_TITLE);
            if (!list.isEmpty()) {
                String key = TitleBuilder.MODS_TITLE;
                itemVals(detailItemValues, list, key);
            }
        }

        String[] rProps = renderedProperties(roots.size() == 1);
        String[] fromRootToLeaf = path.getPathFromRootToLeaf();
        for (int i = 0; i < fromRootToLeaf.length; i++) {
            String pidPath = fromRootToLeaf[i];
            for (String prop : rProps) {

                if (mods.get(pidPath).containsKey(prop)) {
                    List<String> list = mods.get(pidPath).get(prop);
                    itemVals(detailItemValues, list, prop);
                }
            }
        }
    }

    // hlavni nazev
    List<DetailItem> details = new ArrayList<FirstPagePDFServiceImpl.DetailItem>();
    LinkedHashSet<String> maintitles = detailItemValues.get(TitleBuilder.MODS_TITLE);
    String key = maintitles != null && maintitles.size() > 1 ? resourceBundle.getString("pdf.fp.titles")
            : resourceBundle.getString("pdf.fp.title");
    if (maintitles != null && (!maintitles.isEmpty())) {
        details.add(new DetailItem(key, vals(maintitles).toString()));
    }

    for (String prop : renderedProperties(roots.size() == 1)) {
        LinkedHashSet<String> vals = detailItemValues.get(prop);
        key = vals != null && vals.size() > 1 ? resourceBundle.getString(i18nKey(prop) + "s")
                : resourceBundle.getString(i18nKey(prop));
        if (vals != null && (!vals.isEmpty())) {
            details.add(new DetailItem(key, vals(vals).toString()));
        }
    }

    // stranky v pdfku
    pagesInSelectiontPdf(rdoc, resourceBundle, details);

    itm.setDetailItems((DetailItem[]) details.toArray(new DetailItem[details.size()]));
    fpvo.setGeneratedItems(new GeneratedItem[] { itm });

    template.setAttribute("viewinfo", fpvo);

    String templateText = template.toString();

    return templateText;
}

From source file:org.pentaho.reporting.engine.classic.extensions.datasources.olap4j.AbstractMDXDataFactory.java

public String[] getReferencedFields(final String queryName, final DataRow parameter)
        throws ReportDataFactoryException {
    final boolean isNewConnection = connection == null;
    try {//from   ww  w  .j ava  2  s. c  o m
        if (connection == null) {
            connection = connectionProvider.createConnection(computeJdbcUser(parameter),
                    computeJdbcPassword(parameter));
            connection.setLocale(getLocale());

            final String role = computeRole(parameter);
            if (role != null) {
                connection.setRoleName(role);
            }
        }

        final MDXCompiler compiler = new MDXCompiler(parameter, getLocale());
        final String value = computedQuery(queryName, parameter);
        final String translatedQuery = compiler.translateAndLookup(value, parameter);
        final LinkedHashSet<String> params = new LinkedHashSet<String>();
        params.addAll(compiler.getParameter());
        if (getRoleField() != null) {
            params.add(getRoleField());
        }
        if (getJdbcPasswordField() != null) {
            params.add(getJdbcPasswordField());
        }
        if (getJdbcUserField() != null) {
            params.add(getJdbcUserField());
        }
        final PreparedOlapStatement statement = connection.prepareOlapStatement(translatedQuery);

        final OlapParameterMetaData data = statement.getParameterMetaData();
        final int count = data.getParameterCount();
        for (int i = 0; i < count; i++) {
            final String parameterName = data.getParameterName(i + 1);
            params.add(parameterName);
        }
        params.add(DataFactory.QUERY_LIMIT);
        return params.toArray(new String[params.size()]);
    } catch (final Throwable e) {
        throw new ReportDataFactoryException("Failed to obtain a connection", e);
    } finally {
        if (isNewConnection) {
            close();
        }
    }
}

From source file:org.alfresco.bm.dataload.rm.fileplan.ScheduleRecordLoaders.java

/**
 * Helper method that initialize the record folders that can receive loaded unfiled records.
 * This method, also calculates the number of records to  add to the initialized record folders.
 *///from  ww w. j a  v a 2  s  .  co  m
private void calculateListOfEmptyFolders() {
    if (mapOfRecordsPerRecordFolder == null) {
        mapOfRecordsPerRecordFolder = new LinkedHashMap<FolderData, Integer>();
        List<FolderData> recordFoldersThatNeedRecords = new ArrayList<FolderData>();
        if (paths == null || paths.size() == 0) {
            // get the existing file plan folder structure
            recordFoldersThatNeedRecords.addAll(initialiseFoldersToExistingStructure(RECORD_FOLDER_CONTEXT));
        } else {
            LinkedHashSet<FolderData> structureFromExistentProvidedPaths = new LinkedHashSet<FolderData>();
            for (String path : paths) {
                if (!path.startsWith("/")) {
                    path = "/" + path;
                }
                //if the path is category and exists
                FolderData folder = fileFolderService.getFolder(RECORD_CATEGORY_CONTEXT,
                        RECORD_CONTAINER_PATH + path);
                if (folder == null)//if folder is not a category verify if it is a record folder and exists
                {
                    folder = fileFolderService.getFolder(RECORD_FOLDER_CONTEXT, RECORD_CONTAINER_PATH + path);
                }
                if (folder != null)// if folder exists
                {
                    structureFromExistentProvidedPaths.addAll(getRecordFolders(folder));
                } else {
                    try {
                        folder = createFolder(path);
                        recordFoldersThatNeedRecords.add(folder);
                    } catch (Exception e) {
                        // something went wrong on creating current path structure, not all required paths will be created
                    }
                }
            }
            // add record folders from existent paths
            if (structureFromExistentProvidedPaths.size() > 0) {
                recordFoldersThatNeedRecords.addAll(structureFromExistentProvidedPaths);
            }
            // configured paths did not existed in db and something went wrong with creation for all of them,
            // initialize to existing structure in this case
            if (recordFoldersThatNeedRecords.size() == 0) {
                recordFoldersThatNeedRecords
                        .addAll(initialiseFoldersToExistingStructure(RECORD_FOLDER_CONTEXT));
            }
        }
        if (recordFoldersThatNeedRecords.size() > 0) {
            mapOfRecordsPerRecordFolder = distributeNumberOfRecords(recordFoldersThatNeedRecords,
                    recordsNumber);
        }
    }
}

From source file:com.sun.faban.driver.transport.hc3.ApacheHC3Transport.java

/**
 * Obtains the list of cookie values by the name of the cookies.
 * @param name The cookie name/* w w  w .j av  a 2 s.co m*/
 * @return An array of non-duplicating cookie values.
 */
public String[] getCookieValuesByName(String name) {
    LinkedHashSet<String> valueSet = new LinkedHashSet<String>();
    Cookie[] cookies = hc.getState().getCookies();
    for (Cookie cookie : cookies) {
        if (name.equals(cookie.getName())) {
            valueSet.add(cookie.getValue());
        }
    }
    String[] values = new String[valueSet.size()];
    return valueSet.toArray(values);
}