List of usage examples for org.apache.commons.lang StringUtils startsWithIgnoreCase
public static boolean startsWithIgnoreCase(String str, String prefix)
Case insensitive check if a String starts with a specified prefix.
From source file:com.microsoft.alm.plugin.external.commands.FindWorkspaceCommand.java
/** * This method parses a single line of output returning the mapping if one was found * Examples://from w ww.ja v a 2s . co m * "$/TFVC_11/folder1: D:\tmp\notdefault\folder1" * "(cloaked) $/TFVC_11/folder1:" */ private Workspace.Mapping getMapping(final String line) { final boolean isCloaked = StringUtils.startsWithIgnoreCase(line.trim(), "(cloaked)"); final int endIndex = line.indexOf(":"); final int startIndex = isCloaked ? line.indexOf(")") + 1 : 0; if (endIndex >= 0) { final String serverPath = line.substring(startIndex, endIndex).trim(); final String localPath = line.substring(endIndex + 1).trim(); return new Workspace.Mapping(serverPath, localPath, isCloaked); } return null; }
From source file:com.microsoft.alm.plugin.external.utils.CommandUtils.java
public static String tryGetLocalPath(final ServerContext context, final String serverPath, final String workspace) { final Command<String> getLocalPathCommand = new GetLocalPathCommand(context, serverPath, workspace); try {//from ww w . j av a 2 s . c o m final String result = getLocalPathCommand.runSynchronously(); if (StringUtils.startsWithIgnoreCase(result, "ERROR [main] Application - Unexpected exception:")) { return null; } return result; } catch (Throwable t) { logger.warn("Failed to find local path for server path " + serverPath, t); return null; } }
From source file:com.microsoft.alm.common.utils.UrlHelper.java
public static String getHttpsUrlFromHttpUrl(final String httpUrl) { final URI uri = createUri(httpUrl); String httpsUrl = httpUrl;/* www. ja v a2 s. co m*/ if (uri != null && StringUtils.equalsIgnoreCase(uri.getScheme(), "http")) { final URI httpsUri = createUri("https://" + uri.getAuthority() + uri.getPath()); httpsUrl = httpsUri.toString(); } if (StringUtils.startsWithIgnoreCase(httpsUrl, "https://")) { return httpsUrl; } else { return null; } }
From source file:com.echosource.ada.rules.AdaProfileExporter.java
static boolean isInTreeWalker(String configKey) { return StringUtils.startsWithIgnoreCase(configKey, "Checker/TreeWalker/"); }
From source file:gobblin.runtime.util.JobMetrics.java
/** * * Builds the clusterIdentifier tag./*www . j a va 2s. co m*/ * * <p><b>MapReduce mode</b> * Gets the value for "yarn.resourcemanager.address" from {@link Configuration} excluding the port number. * If "yarn.resourcemanager.address" is not set, (possible in Hadoop1), falls back to "mapreduce.jobtracker.address"</p> * *<p><b>Standalone mode (outside of hadoop)</b> * returns the Hostname of {@link InetAddress#getLocalHost()}</p> * */ public static String getClusterIdentifierTag() { // ResourceManager address in Hadoop2 String clusterIdentifier = HADOOP_CONFIGURATION.get("yarn.resourcemanager.address"); // If job is running on Hadoop1 use jobtracker address if (clusterIdentifier == null) { clusterIdentifier = HADOOP_CONFIGURATION.get("mapreduce.jobtracker.address"); } clusterIdentifier = ClustersNames.getInstance().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.engine.sql.util.tables.SQLResultLabelProvider.java
/** * table? Column? ?./*from w w w . ja va 2 s . c o m*/ */ public static void createTableColumn(final TableViewer tableViewer, final ResultSetUtilDTO rsDAO, final SQLResultSorter tableSorter) { // 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(); } }); // tc.setEditingSupport(new FirstNameEditingSupport(viewer)); } // end for } catch (Exception e) { logger.error("SQLResult TableViewer", e); } }
From source file:com.hangum.tadpole.rdb.core.editors.main.execute.sub.ExecuteOtherSQL.java
/** * select ?? //from w ww. ja v a 2 s. co m * * @param reqQuery * @exception */ public static void runSQLOther(final RequestQuery reqQuery, final UserDBDAO userDB, final String userType, final String userEmail) throws SQLException, Exception { // is tajo if (DBDefine.TAJO_DEFAULT == userDB.getDBDefine()) { new TajoConnectionManager().executeUpdate(userDB, reqQuery.getSql()); } else { // commit rollback ? . if (TransactionManger.calledCommitOrRollback(reqQuery.getSql(), userEmail, userDB)) return; java.sql.Connection javaConn = null; Statement statement = null; try { if (reqQuery.isAutoCommit()) { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); javaConn = client.getDataSource().getConnection(); } else { javaConn = TadpoleSQLTransactionManager.getInstance(userEmail, userDB); } statement = javaConn.createStatement(); // TODO mysql? https://github.com/hangum/TadpoleForDBTools/issues/3 ? create table ? ?? '(' ?? ? ?? . if (userDB.getDBDefine() == DBDefine.MYSQL_DEFAULT || userDB.getDBDefine() == DBDefine.MARIADB_DEFAULT) { final String checkSQL = reqQuery.getSql().trim().toUpperCase(); if (StringUtils.startsWithIgnoreCase(checkSQL, "CREATE TABLE")) { //$NON-NLS-1$ reqQuery.setSql(StringUtils.replaceOnce(reqQuery.getSql(), "(", " (")); //$NON-NLS-1$ //$NON-NLS-2$ } } // hive executeUpdate() ? . 13.08.19-hangum if (userDB.getDBDefine() == DBDefine.HIVE_DEFAULT || userDB.getDBDefine() == DBDefine.HIVE2_DEFAULT || userDB.getDBDefine() == DBDefine.SQLite_DEFAULT) { statement.execute(reqQuery.getSql()); } else { statement.executeUpdate(reqQuery.getSql()); } } finally { try { statement.close(); } catch (Exception e) { } if (reqQuery.isAutoCommit()) { try { javaConn.close(); } catch (Exception e) { } } } } // end which db }
From source file:hydrograph.ui.propertywindow.widgets.utility.OutputRecordCountUtility.java
private String getPortCount(String sourceTerminalId) { String portCount = null;//from www . j ava2 s. co m if (StringUtils.startsWithIgnoreCase(sourceTerminalId, Constants.UNUSED_SOCKET_TYPE)) { portCount = StringUtils.remove(sourceTerminalId, Constants.UNUSED_SOCKET_TYPE); } else if (StringUtils.startsWithIgnoreCase(sourceTerminalId, Constants.OUTPUT_SOCKET_TYPE)) { portCount = StringUtils.remove(sourceTerminalId, Constants.OUTPUT_SOCKET_TYPE); } return portCount; }
From source file:com.microsoft.alm.common.utils.UrlHelper.java
public static String getHttpsGitUrlFromSshUrl(final String sshGitRemoteUrl) { if (isSshGitRemoteUrl(sshGitRemoteUrl)) { final URI sshUrl; if (!StringUtils.startsWithIgnoreCase(sshGitRemoteUrl, "ssh://")) { sshUrl = UrlHelper.createUri("ssh://" + sshGitRemoteUrl); } else {// ww w . j av a 2s . c o m sshUrl = UrlHelper.createUri(sshGitRemoteUrl); } final String host = sshUrl.getHost(); final String path = sshUrl.getPath(); final URI httpsUrl = UrlHelper.createUri("https://" + host + path); return httpsUrl.toString(); } return null; }
From source file:com.mnxfst.basar.switchboard.Switchboard.java
/** * Handles messages of type {@link RegisterMessageListenerMsg}. The component referenced through * contained {@link RegisterMessageListenerMsg#getReceiverRef()} will be registered for all messages * of selected {@link RegisterMessageListenerMsg#getMessageType() type}. * @param msg/*from w ww . j a v a 2 s. c o m*/ */ protected void handleMessageReceiverRegistration(RegisterMessageListenerMsg msg) { if (StringUtils.startsWithIgnoreCase(getSelf().path().toString(), msg.getReceiverRef())) { System.out.println("Switchboard must not be able to register itself as message receiver"); return; } // fetch actor as well the message type the contained receiver wishes to register itself for Class<? extends BasarMessage> messageType = msg.getMessageType(); ActorRef receivingActorRef = getContext().system().actorFor(msg.getReceiverRef()); // retrieve the list of message receivers for a specific type, add the actor and put back everything into the map Set<ActorRef> receivers = messageListeners.get(messageType); if (receivers == null) receivers = new HashSet<>(); receivers.add(receivingActorRef); this.messageListeners.put(messageType, receivers); // finally: notify the actor which send the request about its successful registration - keep the sequence identifier to allow // the sender a valid association between request and response ... if he does in any way receivingActorRef.tell(new ListenerRegistrationSuccessMsg(getSelf().path().toString(), msg.getSequenceId(), System.currentTimeMillis()), getSelf()); }