Example usage for org.apache.commons.lang StringUtils startsWithIgnoreCase

List of usage examples for org.apache.commons.lang StringUtils startsWithIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils startsWithIgnoreCase.

Prototype

public static boolean startsWithIgnoreCase(String str, String prefix) 

Source Link

Document

Case insensitive check if a String starts with a specified prefix.

Usage

From source file:com.hangum.tadpole.rdb.core.editors.main.composite.direct.SQLResultLabelProvider.java

/**
 * table? Column? ?./*from  w ww .ja  va  2 s  . c o  m*/
 */
public static void createTableColumn(final RequestQuery reqQuery, final TableViewer tableViewer,
        final ResultSetUtilDTO rsDAO, final SQLResultSorter tableSorter, final boolean isEditable) {
    //  column? .
    Table table = tableViewer.getTable();
    int columnCount = table.getColumnCount();
    for (int i = 0; i < columnCount; i++) {
        table.getColumn(0).dispose();
    }

    if (rsDAO.getColumnName() == null)
        return;

    try {
        for (int i = 0; i < rsDAO.getColumnName().size(); i++) {
            final int index = i;
            final int columnAlign = RDBTypeToJavaTypeUtils.isNumberType(rsDAO.getColumnType().get(i))
                    ? SWT.RIGHT
                    : SWT.LEFT;
            String strColumnName = rsDAO.getColumnName().get(i);

            /**  ? ? ?   */
            if (StringUtils.startsWithIgnoreCase(strColumnName,
                    PublicTadpoleDefine.SPECIAL_USER_DEFINE_HIDE_COLUMN))
                continue;

            final TableViewerColumn tv = new TableViewerColumn(tableViewer, columnAlign);
            final TableColumn tc = tv.getColumn();

            tc.setText(strColumnName);
            tc.setResizable(true);
            tc.setMoveable(true);

            tc.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    tableSorter.setColumn(index);
                    int dir = tableViewer.getTable().getSortDirection();
                    if (tableViewer.getTable().getSortColumn() == tc) {
                        dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
                    } else {
                        dir = SWT.DOWN;
                    }
                    tableViewer.getTable().setSortDirection(dir);
                    tableViewer.getTable().setSortColumn(tc);
                    tableViewer.refresh();
                }
            });

            // if select statement update
            if (PublicTadpoleDefine.QUERY_DML_TYPE.SELECT == reqQuery.getSqlDMLType() && isEditable) {
                if (i != 0)
                    tv.setEditingSupport(new SQLResultEditingSupport(tableViewer, rsDAO, i));
            }

        } // end for

    } catch (Exception e) {
        logger.error("SQLResult TableViewer", e);
    }
}

From source file:jenkins.scm.api.SCMFile.java

/**
 * The opposite of {@link #isContentBinary()}
 *
 * @return true if this file is not a binary file.
 * @throws IOException if an error occurs while performing the operation.
 *//* w w  w. j  a  va2  s. c o  m*/
public boolean isContentText() throws IOException {
    return StringUtils.startsWithIgnoreCase(contentMimeType(), "text/");
}

From source file:mediathekplugin.Database.java

private Channel findChannel(final String mediathekChannelName) {
    Object result = mNameMapping.get(mediathekChannelName);
    if (result == NON_EXISTING_CHANNEL) {
        return null;
    }/* www  .java  2 s.  c o  m*/
    if (result == null) {
        Channel[] allChannels = Plugin.getPluginManager().getSubscribedChannels();
        for (Channel channel : allChannels) {
            if (channel.getName().equalsIgnoreCase(mediathekChannelName)
                    || StringUtils.startsWithIgnoreCase(channel.getName(), mediathekChannelName + " ")) {
                mNameMapping.put(mediathekChannelName, channel);
                return channel;
            }
            String namePart = StringUtils.substringBetween(channel.getName(), "(", ")");
            if (StringUtils.isNotEmpty(namePart)) {
                mNameMapping.put(mediathekChannelName, channel);
                return channel;
            }
        }
        mNameMapping.put(mediathekChannelName, NON_EXISTING_CHANNEL);
        LOG.info("Ignored Mediathek channel: " + mediathekChannelName);
        return null;
    }
    return (Channel) result;
}

From source file:com.dianping.puma.datahandler.AbstractDataHandler.java

protected void handleQueryEvent(BinlogEvent binlogEvent, DataHandlerResult result) {
    QueryEvent queryEvent = (QueryEvent) binlogEvent;
    String sql = StringUtils.normalizeSpace(queryEvent.getSql());
    if (StringUtils.startsWithIgnoreCase(sql, "ALTER ") || StringUtils.startsWithIgnoreCase(sql, "CREATE ")
            || StringUtils.startsWithIgnoreCase(sql, "DROP ")
            || StringUtils.startsWithIgnoreCase(sql, "RENAME ")
            || StringUtils.startsWithIgnoreCase(sql, "TRUNCATE ")) {

        handleDDlEvent(result, queryEvent, sql);

    } else if (StringUtils.equalsIgnoreCase(sql, "BEGIN")) {

        handleTransactionBeginEvent(binlogEvent, result, queryEvent);
    } else {/*from   w w w  . j  ava  2 s. co  m*/
        result.setEmpty(true);
        result.setFinished(true);
        // log.info("QueryEvent  sql=" + queryEvent.getSql());
    }
}

From source file:com.hangum.tadpole.rdb.core.dialog.export.sqltoapplication.composites.axisj.AxisjFormatterDialog.java

@Override
protected Control createDialogArea(Composite parent) {
    GridLayoutFactory.swtDefaults().applyTo(parent);

    composite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().applyTo(composite);
    composite.setLayout(new GridLayout(1, false));

    Label label = new Label(composite, SWT.WRAP);
    label.setText("Specify " + title);

    GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);

    Composite composite_1 = new Composite(composite, SWT.NONE);
    composite_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    composite_1.setLayout(new GridLayout(5, false));

    Label lblNewLabel = new Label(composite_1, SWT.NONE);
    lblNewLabel.setText("Type");

    Button btnNormal = new Button(composite_1, SWT.RADIO);
    btnNormal.setText("Normal");
    btnNormal.addSelectionListener(new SelectionAdapter() {
        @Override/*from   www.  ja  v a  2 s .c  o  m*/
        public void widgetSelected(SelectionEvent e) {
            textControl.setEnabled(false);
            textControl.setText("\"\"");
        }
    });

    Button btnMoney = new Button(composite_1, SWT.RADIO);
    btnMoney.setText("Money");
    btnMoney.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            textControl.setEnabled(false);
            textControl.setText("\"money\"");
        }
    });

    Button btnDec = new Button(composite_1, SWT.RADIO);
    btnDec.setText("Dec");
    btnDec.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            textControl.setEnabled(false);
            textControl.setText("\"dec\"");
        }
    });

    Button btnHtml = new Button(composite_1, SWT.RADIO);
    btnHtml.setText("HTML");
    btnHtml.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            textControl.setEnabled(false);
            textControl.setText("\"html\"");
        }
    });
    new Label(composite_1, SWT.NONE);

    Button btnCheckbox = new Button(composite_1, SWT.RADIO);
    btnCheckbox.setText("CheckBox");
    btnCheckbox.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            textControl.setEnabled(false);
            textControl.setText("\"checkbox\"");
        }
    });

    Button btnRadio = new Button(composite_1, SWT.RADIO);
    btnRadio.setText("Radio");
    btnRadio.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            textControl.setEnabled(false);
            textControl.setText("\"radio\"");
        }
    });

    Button btnFunction = new Button(composite_1, SWT.RADIO);
    btnFunction.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            textControl.setEnabled(true);
            if (StringUtils.isEmpty(originalValue) | StringUtils.equals(originalValue, "\"\"")) {
                textControl.setText("function(){return this.value.number();}");
            } else {
                textControl.setText(originalValue);
            }
            textControl.setFocus();
            textControl.setSelection(11);
        }
    });
    btnFunction.setText("Function");
    new Label(composite_1, SWT.NONE);

    Label label_1 = new Label(composite, SWT.NONE);
    label_1.setText("<< Function >>");

    textControl = new Text(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    textControl.setEnabled(false);

    GridDataFactory.fillDefaults().grab(true, true).hint(350, 300).applyTo(textControl);

    if (StringUtils.startsWithIgnoreCase(originalValue, "\"\"")) {
        btnNormal.setSelection(true);
    } else if (StringUtils.startsWithIgnoreCase(originalValue, "\"money")) {
        btnMoney.setSelection(true);
    } else if (StringUtils.startsWithIgnoreCase(originalValue, "\"dec")) {
        btnDec.setSelection(true);
    } else if (StringUtils.startsWithIgnoreCase(originalValue, "\"html")) {
        btnHtml.setSelection(true);
    } else if (StringUtils.startsWithIgnoreCase(originalValue, "\"checkbox")) {
        btnHtml.setSelection(true);
    } else if (StringUtils.startsWithIgnoreCase(originalValue, "\"radio")) {
        btnHtml.setSelection(true);
    } else if (StringUtils.startsWithIgnoreCase(originalValue, "function")) {
        btnFunction.setSelection(true);
        textControl.setEnabled(true);
    }
    textControl.setText(originalValue);

    return parent;
}

From source file:ddf.catalog.source.opensearch.OpenSearchConnection.java

/**
 * Creates a new OpenSearch {@link org.apache.cxf.jaxrs.client.Client} based on a String URL
 * @param url// w w w  .  j  a  v a2  s .  com
 * @return {@link org.apache.cxf.jaxrs.client.Client}
 */
public Client newOpenSearchClient(String url) {
    OpenSearch proxy = JAXRSClientFactory.create(url, OpenSearch.class);
    Client tmp = WebClient.client(proxy);
    if (StringUtils.startsWithIgnoreCase(url, "https")) {
        setTLSOptions(tmp);
    }
    return tmp;
}

From source file:gobblin.util.ClustersNames.java

/**
 * Returns the cluster name on which the application is running. Uses Hadoop configuration passed in to get the
 * url of the resourceManager or jobtracker. The URL is then translated into a human readable cluster name using
 * {@link #getClusterName(String)}/*from   ww w  .j  av a 2  s  .  c  o  m*/
 *
 * <p>
 * <b>MapReduce mode</b> Uses the value for "yarn.resourcemanager.address" from {@link Configuration} excluding the
 * port number.
 * </p>
 *
 * <p>
 * <b>Standalone mode (outside of hadoop)</b> Uses the Hostname of {@link InetAddress#getLocalHost()}
 * </p>
 *
 * <p>
 * Use {@link #getClusterName(String)} if you already have the cluster URL
 * </p>
 *
 * @see #getClusterName()
 * @param conf Hadoop configuration to use to get resourceManager or jobTracker URLs
 */
public String getClusterName(Configuration conf) {
    // ResourceManager address in Hadoop2
    String clusterIdentifier = conf.get("yarn.resourcemanager.address");
    clusterIdentifier = getClusterName(clusterIdentifier);

    // If job is running outside of Hadoop (Standalone) use hostname
    // If clusterIdentifier is localhost or 0.0.0.0 use hostname
    if (clusterIdentifier == null || StringUtils.startsWithIgnoreCase(clusterIdentifier, "localhost")
            || StringUtils.startsWithIgnoreCase(clusterIdentifier, "0.0.0.0")) {
        try {
            clusterIdentifier = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            // Do nothing. Tag will not be generated
        }
    }

    return clusterIdentifier;
}

From source file:com.hangum.tadpole.rdb.core.editors.main.utils.ExtMakeContentAssistUtil.java

/**
 * insert   ? ?  ? ,     ./*  ww  w  .  j  a va2  s  . c om*/
 * 
 * @param userDB
 * @param strQuery
 * @param strCursor
 * @return
 */
private String ifInsertGetColumn(UserDBDAO userDB, String strQuery, String strCursor) {
    String listContentAssist = "";
    if (StringUtils.startsWithIgnoreCase(StringUtils.trimToEmpty(strQuery), "insert")) {
        listContentAssist = getTableColumnAlias(userDB, strQuery, strCursor);
    }

    return listContentAssist;
}

From source file:morphy.service.CommandService.java

private CommandService() {
    long startTime = System.currentTimeMillis();

    for (Class<?> clazz : socketCommandsClasses) {
        try {//w w w .j av a2s .  co  m
            Command command = (Command) clazz.newInstance();
            commands.add(command);
        } catch (Throwable t) {
            if (LOG.isErrorEnabled())
                LOG.error("Error inializing SocketCommand: " + clazz.getName(), t);
        }
    }
    Collections.sort(commands);

    for (Command command : commands) {
        String name = command.getContext().getName().toLowerCase();
        firstWordToCommandMap.put(command.getContext().getName(), command);
        for (String alias : command.getContext().getAliases()) {
            firstWordToCommandMap.put(alias, command);
        }
        if (name.length() > 1) {
            for (int i = command.getContext().getName().length() - 2; i >= 0; i--) {
                String shortcut = command.getContext().getName().toLowerCase().substring(0, i);
                boolean isUnique = true;
                for (Command commandToCheck : commands) {
                    if (commandToCheck != command) {
                        String nameToCompare = commandToCheck.getContext().getName().toLowerCase();
                        if (StringUtils.startsWithIgnoreCase(nameToCompare, shortcut)) {
                            isUnique = false;
                            break;
                        }
                    }
                }
                if (isUnique) {
                    firstWordToCommandMap.put(shortcut, command);
                } else {
                    break;
                }
            }
        }
    }

    if (LOG.isInfoEnabled()) {
        LOG.info("Initialized Command Service " + commands.size() + " commands "
                + firstWordToCommandMap.values().size() + " mappings "
                + (System.currentTimeMillis() - startTime) + "ms");
    }

    //debug();

}

From source file:com.gaia3d.tadpole.spatial.data.core.ui.editor.SpatialDataManagerMainEditor.java

/**
 *  ?? ? .//from   w ww  . j  a v a2  s . c  o m
 */
@Override
public void queryEndedExecute(final QueryExecuteResultDTO rsDAO) {
    listGisColumnIndex.clear();
    listNonGisColumnIndex.clear();

    mapColumnNames = rsDAO.getColumnName();
    final List<Map<Integer, Object>> resultData = rsDAO.getDataList().getData();

    for (int i = 0; i < mapColumnNames.size(); i++) {
        String strSearchColumn = mapColumnNames.get(i);

        // geojson   ? ?. 
        if (StringUtils.startsWithIgnoreCase(strSearchColumn,
                PublicTadpoleDefine.SPECIAL_USER_DEFINE_HIDE_COLUMN)) {
            listGisColumnIndex.add(i);
        } else if (!listRealGisColumnIndex.contains(i)) {
            // -1? ? ui    ? ??? ? ?.
            listNonGisColumnIndex.add(i - 1);
        }
    }

    /** ?   */
    clearAllLayersMap();

    /** ?  ?? */
    final int INT_SEND_COUNT = SpatialGetPreferenceData.getSendMapDataCount();
    /** ?  */
    final String USER_OPTIONS = TadpoleEditorUtils.getGrantText(SpatialGetPreferenceData.getUserOptions());

    if (!listGisColumnIndex.isEmpty()) {
        Job job = new Job("Drawing map") {
            @Override
            public IStatus run(IProgressMonitor monitor) {

                final int intRowSize = resultData.size();//toArray().length;
                final int intTotalDrawMapCount = intRowSize / INT_SEND_COUNT + 1;
                monitor.beginTask("Drawing a map", intTotalDrawMapCount);

                try {
                    int intStartIndex = 0;
                    for (int i = 0; i < intTotalDrawMapCount; i++) {
                        monitor.setTaskName(
                                String.format("Drawing a map ( %s / %s )", (i + 1), intTotalDrawMapCount));
                        monitor.worked(1);

                        List<Map<Integer, Object>> listPartData = new ArrayList<>();
                        if (intRowSize < INT_SEND_COUNT + intStartIndex) {
                            listPartData = resultData.subList(intStartIndex, intRowSize);
                        } else {
                            listPartData = resultData.subList(intStartIndex, INT_SEND_COUNT + intStartIndex);
                        }

                        if (i == 0) {
                            drawMapInit(listPartData, USER_OPTIONS);
                        } else {
                            drawMapAddData(listPartData);
                        }

                        if (monitor.isCanceled()) {
                            if (logger.isDebugEnabled())
                                logger.debug("Stop map drawing.");
                            break;
                        }

                        intStartIndex += INT_SEND_COUNT;
                    }
                } catch (Exception e) {
                    logger.error("Drawing map rise exception.", e);

                    return new Status(Status.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
                } finally {
                    monitor.done();
                }

                /////////////////////////////////////////////////////////////////////////////////////////
                return Status.OK_STATUS;
            }

            /**
             * ?? ?? .
             * 
             * @param strGeoJson ??? 
             * @param strUserOptions ?  
             */
            private void drawMapInit(final List<Map<Integer, Object>> listGJson, final String strUserOptions) {
                browserMap.getDisplay().syncExec(new Runnable() {
                    @Override
                    public void run() {

                        browserMap.evaluate(String.format("drawingMapInit('%s', '%s');", makeGeoJSON(listGJson),
                                strUserOptions));
                    }
                });
            }

            /**
             * ?? ?? .
             * 
             * @param strGeoJson
             */
            private void drawMapAddData(final List<Map<Integer, Object>> listGJson) {
                browserMap.getDisplay().syncExec(new Runnable() {
                    @Override
                    public void run() {
                        browserMap.evaluate(String.format("drawMapAddData('%s');", makeGeoJSON(listGJson)));
                    }
                });
            }

        };

        job.addJobChangeListener(new JobChangeAdapter() {
            public void done(IJobChangeEvent event) {
                browserMap.getDisplay().asyncExec(new Runnable() {
                    @Override
                    public void run() {
                        // ? ?? ? ???? .
                        mainEditor.setOrionTextFocus();
                    }
                });
            } // end done
        }); // end job

        job.setName("Drawing map job");
        job.setUser(true);
        job.setPriority(Job.SHORT);
        job.schedule();

    } // end if block
}