Example usage for java.lang String CASE_INSENSITIVE_ORDER

List of usage examples for java.lang String CASE_INSENSITIVE_ORDER

Introduction

In this page you can find the example usage for java.lang String CASE_INSENSITIVE_ORDER.

Prototype

Comparator CASE_INSENSITIVE_ORDER

To view the source code for java.lang String CASE_INSENSITIVE_ORDER.

Click Source Link

Document

A Comparator that orders String objects as by compareToIgnoreCase .

Usage

From source file:br.com.ingenieux.mojo.beanstalk.AbstractBeanstalkMojo.java

@SuppressWarnings("unchecked")
protected List<String> getConfigurationTemplates(String applicationName) {
    List<String> configurationTemplates = getService()
            .describeApplications(new DescribeApplicationsRequest().withApplicationNames(applicationName))
            .getApplications().get(0).getConfigurationTemplates();

    Collections.<String>sort(configurationTemplates, new ReverseComparator(String.CASE_INSENSITIVE_ORDER));

    return configurationTemplates;
}

From source file:com.stimulus.archiva.presentation.ConfigBean.java

public List<String> getFieldLabels() {
    ArrayList<String> fieldLabelList = new ArrayList<String>();
    EmailFields emailFields = Config.getConfig().getEmailFields();
    for (EmailField ef : emailFields.getAvailableFields().values()) {
        fieldLabelList.add(ef.getResource().toLowerCase(Locale.ENGLISH));
    }//from  w w  w  .  ja  va  2s  .c o m
    fieldLabelList.add("field_label_all");
    fieldLabelList.add("field_label_addresses");
    Collections.sort(fieldLabelList, String.CASE_INSENSITIVE_ORDER);
    return translateList(fieldLabelList, true);
}

From source file:org.apache.directory.fortress.core.impl.RoleUtil.java

/**
 * Return Set of RBAC {@link org.apache.directory.fortress.core.model.Role#name}s ascendants.  Used by {@link org.apache.directory.fortress.core.impl.PermDAO#checkPermission}
 * for computing authorized {@link org.apache.directory.fortress.core.model.UserRole#name}s.
 *
 * @param uRoles contains list of Roles activated within a {@link org.apache.directory.fortress.core.model.User}'s {@link org.apache.directory.fortress.core.model.Session}.
 * @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
 * @return contains Set of all authorized RBAC Roles for a given User.
 *//*from  w  ww  . ja va 2s.com*/
static Set<String> getInheritedRoles(List<UserRole> uRoles, String contextId) {
    // create Set with case insensitive comparator:
    Set<String> iRoles = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    if (CollectionUtils.isNotEmpty(uRoles)) {
        for (UserRole uRole : uRoles) {
            String rleName = uRole.getName();
            iRoles.add(rleName);
            Set<String> parents = HierUtil.getAscendants(rleName, getGraph(contextId));
            if (CollectionUtils.isNotEmpty(parents)) {
                iRoles.addAll(parents);
            }
        }
    }
    return iRoles;
}

From source file:org.gcaldaemon.gui.ConfigEditor.java

private ConfigEditor(MainConfig config, ProgressMonitor monitor) throws Exception {
    this.config = config;
    try {//from   w w  w  .  ja  v  a 2  s  .  c o m

        // Init swing
        System.setProperty("sun.awt.noerasebackground", "false"); //$NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("swing.aatext", "true"); //$NON-NLS-1$ //$NON-NLS-2$
        System.setProperty("swing.boldMetal", "false"); //$NON-NLS-1$ //$NON-NLS-2$
        Locale locale = Locale.getDefault();
        String code = null;
        try {
            code = config.getConfigProperty(Configurator.EDITOR_LANGUAGE, null);
            if (code != null) {
                locale = new Locale(code);
            }
        } catch (Exception invalidLocale) {
            log.warn(invalidLocale);
        }
        if (!Messages.setUserLocale(locale)) {
            locale = Locale.ENGLISH;
            Messages.setUserLocale(locale);
            code = null;
        }
        if (code == null) {
            config.setConfigProperty(Configurator.EDITOR_LANGUAGE, locale.getLanguage().toLowerCase());
        }
        try {
            boolean lookAndFeelChanged = false;
            String oldLaf = UIManager.getLookAndFeel().getClass().getName();
            String newLaf = config.getConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL,
                    UIManager.getCrossPlatformLookAndFeelClassName());
            lookAndFeelChanged = !oldLaf.equals(newLaf);
            if (lookAndFeelChanged) {
                UIManager.setLookAndFeel(newLaf);
            }
            if (config.getConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, null) == null) {
                config.setConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, newLaf);
            }
            if (lookAndFeelChanged) {
                new ConfigEditor(config, monitor);
                dispose();
                return;
            }
        } catch (Exception invalidLaf) {
            log.warn(invalidLaf);
        }

        // Window settings
        setTitle(Messages.getString("config.editor") + " - " + config.getConfigPath()); //$NON-NLS-1$ //$NON-NLS-2$
        setIconImage(TOOLKIT.getImage(ConfigEditor.class.getResource("/org/gcaldaemon/gui/icons/icon.gif"))); //$NON-NLS-1$
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        Container root = getContentPane();
        root.setLayout(new BorderLayout());
        root.add(folder, BorderLayout.CENTER);
        folder.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
        folder.setTabPlacement(JTabbedPane.LEFT);
        folder.addChangeListener(this);
        status.setBorder(new BevelBorder(BevelBorder.LOWERED));
        root.add(status, BorderLayout.SOUTH);

        // Create menu items
        fileMenu = new JMenu(Messages.getString("file")); //$NON-NLS-1$
        saveMenu = new JMenuItem(Messages.getString("save"), getIcon("save")); //$NON-NLS-1$ //$NON-NLS-2$
        exitMenu = new JMenuItem(Messages.getString("exit"), getIcon("exit")); //$NON-NLS-1$ //$NON-NLS-2$
        viewMenu = new JMenu(Messages.getString("view")); //$NON-NLS-1$
        langMenu = new JMenu(Messages.getString("language")); //$NON-NLS-1$
        lafMenu = new JMenu(Messages.getString("look.and.feel")); //$NON-NLS-1$
        transMenu = new JMenuItem(Messages.getString("translate")); //$NON-NLS-1$
        logMenu = new JMenuItem(Messages.getString("log.viewer")); //$NON-NLS-1$
        helpMenu = new JMenu(Messages.getString("help")); //$NON-NLS-1$
        aboutMenu = new JMenuItem(Messages.getString("about")); //$NON-NLS-1$

        // Build menu
        setJMenuBar(menuBar);
        menuBar.add(fileMenu);
        fileMenu.add(saveMenu);
        fileMenu.addSeparator();
        fileMenu.add(exitMenu);
        menuBar.add(viewMenu);
        viewMenu.add(logMenu);
        viewMenu.addSeparator();
        viewMenu.add(langMenu);
        viewMenu.add(lafMenu);
        langMenu.add(transMenu);
        menuBar.add(helpMenu);
        helpMenu.add(aboutMenu);

        // Build language menu
        Locale[] locales = Messages.getAvailableLocales();
        String[] names = new String[locales.length];
        String temp;
        int i;
        for (i = 0; i < locales.length; i++) {
            names[i] = locales[i].getDisplayLanguage(Locale.ENGLISH);
            if (names[i] == null || names[i].length() == 0) {
                names[i] = locales[i].getLanguage().toLowerCase();
            }
            temp = locales[i].getDisplayLanguage(locale);
            if (temp != null && temp.length() > 0 && !temp.equals(names[i])) {
                names[i] = names[i] + " [" + temp + ']';
            }
        }
        Arrays.sort(names, String.CASE_INSENSITIVE_ORDER);
        if (locales.length != 0) {
            langMenu.addSeparator();
        }
        for (i = 0; i < locales.length; i++) {
            JMenuItem item = new JMenuItem(names[i]);
            item.setName('!' + names[i]);
            langMenu.add(item);
            item.addActionListener(this);
        }

        // Build look and feel menu
        LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
        LookAndFeelInfo info;
        for (i = 0; i < infos.length; i++) {
            info = infos[i];
            JMenuItem item = new JMenuItem(info.getName());
            item.addActionListener(this);
            item.setName('#' + info.getClassName());
            lafMenu.add(item);
        }

        // Action listeners
        addWindowListener(this);
        folder.addChangeListener(this);
        exitMenu.addActionListener(this);
        saveMenu.addActionListener(this);
        transMenu.addActionListener(this);
        logMenu.addActionListener(this);
        aboutMenu.addActionListener(this);

        // Add pages
        addPage("common.settings", new CommonPage(config, this)); //$NON-NLS-1$
        addPage("http.settings", new HttpPage(config, this)); //$NON-NLS-1$
        addPage("file.settings", new FilePage(config, this)); //$NON-NLS-1$
        addPage("feed.settings", new FeedPage(config, this)); //$NON-NLS-1$
        addPage("ldap.settings", new LdapPage(config, this)); //$NON-NLS-1$
        addPage("notifier.settings", new NotifierPage(config, this)); //$NON-NLS-1$
        addPage("sendmail.settings", new SendmailPage(config, this)); //$NON-NLS-1$
        addPage("mailterm.settings", new MailtermPage(config, this)); //$NON-NLS-1$

        // Set tab colors
        Iterator editors = disabledServices.iterator();
        while (editors.hasNext()) {
            setServiceEnabled((BooleanEditor) editors.next(), false);
        }
        disabledServices = null;

        // Show GUI
        setResizable(true);
        Dimension size = TOOLKIT.getScreenSize();
        int w = size.width - 50;
        int h = size.height - 70;
        w = Math.min(w, 1000);
        h = Math.min(h, 700);
        setSize(w, h);
        setLocation((size.width - w) / 2, (size.height - h) / 2);
        validate();
        if (monitor != null) {
            monitor.dispose();
        }
        setVisible(true);
        toFront();
    } catch (Exception error) {
        if (monitor != null) {
            monitor.dispose();
        }
        error(Messages.getString("error"), "Unable to start configurator: " + error, error);
    }
}

From source file:com.amazonaws.ipnreturnurlvalidation.SignatureUtilsForOutbound.java

/**
 * Calculate String to Sign for SignatureVersion 1
 * /*from   ww  w  .j av a 2 s. c  om*/
 * @param parameters request parameters
 * @return String to Sign
 */
private String calculateStringToSignV1(Map<String, String> parameters) {
    StringBuilder data = new StringBuilder();
    Map<String, String> sorted = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    sorted.putAll(parameters);
    for (Map.Entry<String, String> entry : sorted.entrySet()) {
        if (entry.getKey().equalsIgnoreCase(SIGNATURE_KEYNAME))
            continue;
        data.append(entry.getKey());
        data.append(entry.getValue());
    }
    return data.toString();
}

From source file:org.trosnoth.serveradmin.PlayerActivity.java

private void update() {

    String result;/*from w w w. j ava2s. co m*/
    ArrayList<String> players;

    players = telnet.parseJSON(telnet.readWrite("print json.dumps(getGame().getPlayers().keys())"));
    Collections.sort(players, String.CASE_INSENSITIVE_ORDER);

    if (players.size() == 0) {
        listHelper.setText(R.string.players_no_players);
        playerList.setVisibility(View.INVISIBLE);
        listHelper.setVisibility(View.VISIBLE);
    } else {
        playerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, players));
        playerList.setVisibility(View.VISIBLE);
        listHelper.setVisibility(View.INVISIBLE);
    }

    if (currentPlayer == null || !players.contains(currentPlayer)) {
        currentPlayer = null;
        hide();
        return;
    } else {
        show();
    }

    Resources res = getResources();

    // This could very easily lead to race conditions
    telnet.send("player = getGame().getPlayers()[" + currentPlayer() + "]");

    playerName.setText(currentPlayer);

    // Username
    result = telnet.readWrite("player.user");
    if (result.length() == 0) {
        Boolean bot = (Boolean) telnet.parse(telnet.readWrite("player.bot"));
        if (bot) {
            textUsername.setText(R.string.players_bot);
        } else {
            textUsername.setText(R.string.players_no_username);
        }
    } else {
        result = (String) telnet.parse(telnet.readWrite("player.user.username"));
        textUsername.setText(result);
    }

    // Alive or dead
    Boolean dead = (Boolean) telnet.parse(telnet.readWrite("player.dead"));
    if (dead) {
        textAlive.setText(R.string.players_dead);
        textAlive.setTextColor(res.getColor(R.color.light_red));
        textStars.setVisibility(View.INVISIBLE);
    } else {
        textAlive.setText(R.string.players_alive);
        textAlive.setTextColor(res.getColor(R.color.light_green));
        textStars.setVisibility(View.VISIBLE);

        // Stars
        int stars = Integer.valueOf(telnet.readWrite("player.stars"));
        if (stars == 1) {
            textStars.setText(R.string.players_1_star);
        } else {
            textStars.setText(getApplicationContext().getString(R.string.players_stars, stars));
        }
    }

    // Team
    result = telnet.readWrite("player.team");
    if (result.length() == 0) {
        textTeam.setText(R.string.teams_none);
        textTeam.setTextColor(res.getColor(R.color.neutral_text));
    } else {
        result = (String) telnet.parse(telnet.readWrite("player.team.id"));
        if (result.equals("A")) {
            textTeam.setText(R.string.teams_blue);
            textTeam.setTextColor(res.getColor(R.color.blue_text));
        } else if (result.equals("B")) {
            textTeam.setText(R.string.teams_red);
            textTeam.setTextColor(res.getColor(R.color.red_text));
        } else {
            textTeam.setText(R.string.unknown);
            textTeam.setTextColor(res.getColor(android.R.color.white));
        }
    }

    // Current upgrade
    result = telnet.readWrite("player.upgrade");
    if (result.length() == 0) {
        currentUpgrade.setText(R.string.players_no_upgrade);
        giveUpgrade.setEnabled(true);
        removeUpgrade.setEnabled(false);
    } else {
        result = (String) telnet.parse(telnet.readWrite("player.upgrade.upgradeType"));
        currentUpgrade.setText(upgradeMapping.get(result));
        giveUpgrade.setEnabled(false);
        removeUpgrade.setEnabled(true);
    }

    // Log.i(LOGTAG, "Update complete.");

}

From source file:bookkeepr.xmlable.DatabaseManager.java

public synchronized void restore() {
    Logger.getLogger(DatabaseManager.class.getName()).log(Level.INFO,
            "Restoring from " + rootPath.getAbsolutePath());

    long[] count = new long[256];
    Arrays.fill(count, 0);// w  w w  . java2s .  c o m

    File[] dirList = rootPath.listFiles(new FilenameFilter() {

        public boolean accept(File dir, String name) {
            return name.endsWith(".xml.gz");
        }
    });

    Arrays.sort(dirList, new Comparator<File>() {

        public int compare(File o1, File o2) {
            return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName());
        }
    });

    for (File f : dirList) {
        try {
            Index<IdAble> idx = (Index<IdAble>) XMLReader.read(new GZIPInputStream(new FileInputStream(f)));
            List<IdAble> list = idx.getIndex();
            if (idx.getIndex().size() < 1) {
                continue;// it's an empty list!

            }
            String key = getKey(list.get(0).getId());
            IdAble last = list.get(list.size() - 1);
            int type = getType(last);
            int origin = getOrigin(last);
            if (origin > this.maxOriginId) {
                this.maxOriginId = origin;
            }
            if (last.getId() > latestIds[origin][type]) {
                latestIds[origin][type] = last.getId();
            }
            this.indicies.put(key, idx);

            count[this.getType(list.get(0))] += idx.getSize();

            // notify listeners.
            for (IdAble item : idx.getIndex()) {

                for (Object listener : listeners[this.getType(item)]) {
                    ((ChangeListener) listener).itemUpdated(this, item, this.getOrigin(item) != this.originId,
                            false);
                }
            }
        } catch (SAXException ex) {
            Logger.getLogger(DatabaseManager.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(DatabaseManager.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    for (int type = 0; type < 256; type++) {
        long latest = latestIds[this.getOriginId()][type] & 0x00000FFFFFFFFFFFL;

        if (latest >= this.nextId[type]) {
            this.nextId[type] = latest + 1;
            Logger.getLogger(DatabaseManager.class.getName()).log(Level.WARNING, "Latest index for type "
                    + Integer.toHexString(type)
                    + " is later than our next ID... Updating next ID to avoid database conflicts (latest is: "
                    + Long.toHexString(latest) + ")");
        }
    }

    Logger.getLogger(DatabaseManager.class.getName()).log(Level.INFO,
            "Loaded " + this.indicies.size() + " indexes");
    for (int t = 0; t < count.length; t++) {
        if (count[t] > 0) {
            Logger.getLogger(DatabaseManager.class.getName()).log(Level.INFO,
                    "Loaded " + count[t] + " items of type " + Integer.toHexString(t));
        }
    }

}

From source file:com.evolveum.midpoint.web.page.admin.configuration.PageRepositoryQuery.java

private void initLayout() {
    Form mainForm = new com.evolveum.midpoint.web.component.form.Form(ID_MAIN_FORM);
    add(mainForm);/* ww  w  .j  av a2s  .c o m*/

    List<QName> objectTypeList = WebComponentUtil.createObjectTypeList();
    Collections.sort(objectTypeList, new Comparator<QName>() {
        @Override
        public int compare(QName o1, QName o2) {
            return String.CASE_INSENSITIVE_ORDER.compare(o1.getLocalPart(), o2.getLocalPart());
        }
    });
    DropDownChoice<QName> objectTypeChoice = new DropDownChoice<>(ID_OBJECT_TYPE,
            new PropertyModel<>(model, RepoQueryDto.F_OBJECT_TYPE), new ListModel<>(objectTypeList),
            new QNameChoiceRenderer());
    objectTypeChoice.setOutputMarkupId(true);
    objectTypeChoice.setNullValid(true);
    objectTypeChoice.add(new OnChangeAjaxBehavior() {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(get(ID_MAIN_FORM).get(ID_MIDPOINT_QUERY_BUTTON_BAR));
        }
    });
    mainForm.add(objectTypeChoice);

    AceEditor editorMidPoint = new AceEditor(ID_EDITOR_MIDPOINT,
            new PropertyModel<>(model, RepoQueryDto.F_MIDPOINT_QUERY));
    editorMidPoint.setHeight(400);
    editorMidPoint.setResizeToMaxHeight(false);
    mainForm.add(editorMidPoint);

    AceEditor editorHibernate = new AceEditor(ID_EDITOR_HIBERNATE,
            new PropertyModel<>(model, RepoQueryDto.F_HIBERNATE_QUERY));
    editorHibernate.setHeight(300);
    editorHibernate.setResizeToMaxHeight(false);
    editorHibernate.setReadonly(!isAdmin);
    editorHibernate.setMode(null);
    mainForm.add(editorHibernate);

    AceEditor hibernateParameters = new AceEditor(ID_HIBERNATE_PARAMETERS,
            new PropertyModel<>(model, RepoQueryDto.F_HIBERNATE_PARAMETERS));
    hibernateParameters.setReadonly(true);
    hibernateParameters.setHeight(100);
    hibernateParameters.setResizeToMaxHeight(false);
    hibernateParameters.setMode(null);
    mainForm.add(hibernateParameters);

    WebMarkupContainer hibernateParametersNote = new WebMarkupContainer(ID_HIBERNATE_PARAMETERS_NOTE);
    hibernateParametersNote.setVisible(isAdmin);
    mainForm.add(hibernateParametersNote);

    WebMarkupContainer midPointQueryButtonBar = new WebMarkupContainer(ID_MIDPOINT_QUERY_BUTTON_BAR);
    midPointQueryButtonBar.setOutputMarkupId(true);
    mainForm.add(midPointQueryButtonBar);

    AjaxSubmitButton executeMidPoint = new AjaxSubmitButton(ID_EXECUTE_MIDPOINT,
            createStringResource("PageRepositoryQuery.button.translateAndExecute")) {
        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            queryPerformed(Action.EXECUTE_MIDPOINT, target);
        }
    };
    midPointQueryButtonBar.add(executeMidPoint);

    AjaxSubmitButton compileMidPoint = new AjaxSubmitButton(ID_COMPILE_MIDPOINT,
            createStringResource("PageRepositoryQuery.button.translate")) {
        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            queryPerformed(Action.TRANSLATE_ONLY, target);
        }
    };
    midPointQueryButtonBar.add(compileMidPoint);

    AjaxSubmitButton useInObjectList = new AjaxSubmitButton(ID_USE_IN_OBJECT_LIST,
            createStringResource("PageRepositoryQuery.button.useInObjectList")) {
        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            useInObjectListPerformed(target);
        }
    };
    useInObjectList.add(new VisibleEnableBehaviour() {
        @Override
        public boolean isVisible() {
            return USE_IN_OBJECT_LIST_AVAILABLE_FOR.contains(model.getObject().getObjectType());
        }
    });
    midPointQueryButtonBar.add(useInObjectList);

    final DropDownChoice<String> sampleChoice = new DropDownChoice<>(ID_QUERY_SAMPLE, Model.of(""),
            new AbstractReadOnlyModel<List<String>>() {
                @Override
                public List<String> getObject() {
                    return SAMPLES;
                }
            }, new StringResourceChoiceRenderer("PageRepositoryQuery.sample"));
    sampleChoice.setNullValid(true);
    sampleChoice.add(new OnChangeAjaxBehavior() {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            String sampleName = sampleChoice.getModelObject();
            if (StringUtils.isEmpty(sampleName)) {
                return;
            }
            String resourceName = SAMPLES_DIR + "/" + sampleName + ".xml.data";
            InputStream is = PageRepositoryQuery.class.getResourceAsStream(resourceName);
            if (is != null) {
                try {
                    String localTypeName = StringUtils.substringBefore(sampleName, "_");
                    model.getObject().setObjectType(new QName(SchemaConstants.NS_C, localTypeName));
                    model.getObject().setMidPointQuery(IOUtils.toString(is, "UTF-8"));
                    model.getObject().setHibernateQuery("");
                    model.getObject().setHibernateParameters("");
                    model.getObject().setQueryResultObject(null);
                    model.getObject().resetQueryResultText();
                    target.add(PageRepositoryQuery.this);
                } catch (IOException e) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't read sample from resource {}", e,
                            resourceName);
                }
            } else {
                LOGGER.warn("Resource {} containing sample couldn't be found", resourceName);
            }
        }
    });
    mainForm.add(sampleChoice);

    AjaxSubmitButton executeHibernate = new AjaxSubmitButton(ID_EXECUTE_HIBERNATE,
            createStringResource("PageRepositoryQuery.button.execute")) {
        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            queryPerformed(Action.EXECUTE_HIBERNATE, target);
        }
    };
    executeHibernate.setVisible(isAdmin);
    mainForm.add(executeHibernate);

    Label resultLabel = new Label(ID_RESULT_LABEL, new AbstractReadOnlyModel<String>() {
        @Override
        public String getObject() {
            if (model.getObject().getQueryResultText() == null) {
                return "";
            }
            Object queryResult = model.getObject().getQueryResultObject();
            if (queryResult instanceof List) {
                return getString("PageRepositoryQuery.resultObjects", ((List) queryResult).size());
            } else if (queryResult instanceof Throwable) {
                return getString("PageRepositoryQuery.resultException", queryResult.getClass().getName());
            } else {
                // including null
                return getString("PageRepositoryQuery.result");
            }
        }
    });
    mainForm.add(resultLabel);

    WebMarkupContainer incompleteResultsNote = new WebMarkupContainer(ID_INCOMPLETE_RESULTS_NOTE);
    incompleteResultsNote.add(new VisibleEnableBehaviour() {
        @Override
        public boolean isVisible() {
            return !isAdmin && model.getObject().getQueryResultText() != null;
        }
    });
    mainForm.add(incompleteResultsNote);

    AceEditor resultText = new AceEditor(ID_RESULT_TEXT,
            new PropertyModel<>(model, RepoQueryDto.F_QUERY_RESULT_TEXT));
    resultText.setReadonly(true);
    resultText.setHeight(300);
    resultText.setResizeToMaxHeight(false);
    resultText.setMode(null);
    resultText.add(new VisibleEnableBehaviour() {
        @Override
        public boolean isVisible() {
            return model.getObject().getQueryResultText() != null;
        }
    });
    mainForm.add(resultText);

}

From source file:com.springsource.insight.plugin.ldap.LdapOperationCollectionAspectTestSupport.java

private static Collection<Map<String, Set<String>>> readLdifEntries(BufferedReader rdr) throws IOException {
    Collection<Map<String, Set<String>>> result = new LinkedList<Map<String, Set<String>>>();
    Map<String, Set<String>> curEntry = null;
    for (String line = rdr.readLine(); line != null; line = rdr.readLine()) {
        line = line.trim();//w ww.  j  a v  a 2  s  .  co m
        if (LOG.isTraceEnabled()) {
            LOG.trace("readLdifEntries - " + line);
        }

        // empty line signals end of entry
        if (StringUtil.isEmpty(line)) {
            if (curEntry != null) {
                result.add(curEntry);
            }

            curEntry = null;
            continue;
        }

        if (curEntry == null) {
            curEntry = new TreeMap<String, Set<String>>(String.CASE_INSENSITIVE_ORDER);
        }

        int namePos = line.indexOf(':');
        String name = line.substring(0, namePos), value = line.substring(namePos + 2).trim();
        if (StringUtil.isEmpty(name) || StringUtil.isEmpty(value)) {
            throw new IllegalArgumentException("Bad line: " + line);
        }

        if ("dn".equalsIgnoreCase(name)) {
            assertTrue("DN(" + value + ") not subset of root (" + ROOT_DN + ")",
                    value.toLowerCase().endsWith(ROOT_DN.toLowerCase()));
        }

        Set<String> values = curEntry.get(name);
        if (values == null) {
            values = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
            curEntry.put(name, values);
        }

        if (!values.add(value)) {
            throw new IllegalStateException("Duplicate values for name=" + name + " at line " + line);
        }
    }

    return result;
}

From source file:com.mirth.connect.client.ui.SettingsPanelMap.java

private void updateConfigurationTable(Map<String, ConfigurationProperty> map) {
    RefreshTableModel model = (RefreshTableModel) configurationMapTable.getModel();
    String[][] data = new String[map.size()][3];
    Map<String, ConfigurationProperty> sortedMap = new TreeMap<String, ConfigurationProperty>(
            String.CASE_INSENSITIVE_ORDER);
    sortedMap.putAll(map);//from  w  ww.j  av a2s.c  o m

    int index = 0;
    for (Entry<String, ConfigurationProperty> entry : sortedMap.entrySet()) {
        data[index][0] = entry.getKey();
        data[index][1] = entry.getValue().getValue();
        data[index++][2] = entry.getValue().getComment();
    }

    model.refreshDataVector(data);
}