/** * Create an MMURL from the server URL. For use by the server-side. * @param serverURL Expected format: mm[s]://server1:port1[,server2:port2] * @throws MalformedURLException * @since 4.2 */ public TeiidURL(String serverURL) throws MalformedURLException { if (serverURL == null) { throw new MalformedURLException(INVALID_FORMAT_SERVER); } if (StringUtil.startsWithIgnoreCase(serverURL, SECURE_PROTOCOL)) { usingSSL = true; } else if (!StringUtil.startsWithIgnoreCase(serverURL, DEFAULT_PROTOCOL)) { throw new MalformedURLException(INVALID_FORMAT_SERVER); } appServerURL = serverURL; parseServerURL(serverURL.substring(usingSSL?SECURE_PROTOCOL.length():DEFAULT_PROTOCOL.length()), INVALID_FORMAT_SERVER); }
/** * Create an MMURL from the server URL. For use by the server-side. * @param serverURL Expected format: mm[s]://server1:port1[,server2:port2] * @throws MalformedURLException * @since 4.2 */ public TeiidURL(String serverURL) throws MalformedURLException { if (serverURL == null) { throw new MalformedURLException(INVALID_FORMAT_SERVER); } if (StringUtil.startsWithIgnoreCase(serverURL, SECURE_PROTOCOL)) { usingSSL = true; } else if (!StringUtil.startsWithIgnoreCase(serverURL, DEFAULT_PROTOCOL)) { throw new MalformedURLException(INVALID_FORMAT_SERVER); } appServerURL = serverURL; parseServerURL(serverURL.substring(usingSSL?SECURE_PROTOCOL.length():DEFAULT_PROTOCOL.length()), INVALID_FORMAT_SERVER); }
static List<ElementSymbol> getElementsUnderNode(Object mid, Collection<ElementSymbol> validElements, QueryMetadataInterface metadata) throws TeiidComponentException, QueryMetadataException { List<ElementSymbol> elements = new ArrayList<ElementSymbol>(); String nodeName = metadata.getFullName(mid); for (ElementSymbol validElement : validElements) { String qualifiedName = validElement.getName(); if (StringUtil.startsWithIgnoreCase(qualifiedName, nodeName) && (qualifiedName.length() == nodeName.length() || qualifiedName.charAt(nodeName.length()) == '.')) { elements.add(validElement); } } return elements; }
public static String getCompletionTag(String sql, Integer count) { String tag; if (StringUtil.startsWithIgnoreCase(sql, "BEGIN")) { tag = "BEGIN"; } else if (StringUtil.startsWithIgnoreCase(sql, "START TRANSACTION")) { tag = "START TRANSACTION"; } else if (sql.indexOf(' ') == -1 || sql.equals("CLOSE CURSOR")) { //should already be a completion tag tag = sql.toUpperCase(); if (count != null) { tag += " " + count; } } else if (StringUtil.startsWithIgnoreCase(sql, "SET ")) { tag = "SET"; } else { tag = SqlUtil.getKeyword(sql).toUpperCase(); if (tag.equals("EXEC") || tag.equals("CALL")) { tag = "SELECT"; } if (count != null && !(tag.equalsIgnoreCase("ROLLBACK") || tag.equalsIgnoreCase("SAVEPOINT") || tag.equalsIgnoreCase("RELEASE"))) { tag += " " + count; } } return tag; }
private void parseOptions(Matcher m, Option.MakeDep option) { if (m.group(3) != null) { if (StringUtil.startsWithIgnoreCase(m.group(3), "no")) { //$NON-NLS-1$ option.setJoin(false); } else { option.setJoin(true); } } if (m.group(2) != null) { option.setMax(Integer.valueOf(m.group(2).trim().substring(4))); } }
private void parseOptions(Matcher m, Option.MakeDep option) { if (m.group(3) != null) { if (StringUtil.startsWithIgnoreCase(m.group(3), "no")) { //$NON-NLS-1$ option.setJoin(false); } else { option.setJoin(true); } } if (m.group(2) != null) { option.setMax(Integer.valueOf(m.group(2).trim().substring(4))); } }
private void parseOptions(Matcher m, Option.MakeDep option) { if (m.group(3) != null) { if (StringUtil.startsWithIgnoreCase(m.group(3), "no")) { //$NON-NLS-1$ option.setJoin(false); } else { option.setJoin(true); } } if (m.group(2) != null) { option.setMax(Integer.valueOf(m.group(2).trim().substring(4))); } }
protected boolean matchesPartialName(String partialGroupName, String name, Schema schema) { if (!StringUtil.endsWithIgnoreCase(name, partialGroupName)) { return false; } int schemaMatch = partialGroupName.length() - name.length(); if (schemaMatch > 0) { if (schemaMatch != schema.getName().length() + 1 || !StringUtil.startsWithIgnoreCase(partialGroupName, schema.getName()) || partialGroupName.charAt(schemaMatch + 1) != '.') { return false; } } else if (schemaMatch < 0 && name.charAt(-schemaMatch - 1) != '.') { return false; } return true; }
protected boolean matchesPartialName(String partialGroupName, String name, Schema schema) { if (!StringUtil.endsWithIgnoreCase(name, partialGroupName)) { return false; } int schemaMatch = partialGroupName.length() - name.length(); if (schemaMatch > 0) { if (schemaMatch != schema.getName().length() + 1 || !StringUtil.startsWithIgnoreCase(partialGroupName, schema.getName()) || partialGroupName.charAt(schemaMatch + 1) != '.') { return false; } } else if (schemaMatch < 0 && name.charAt(-schemaMatch - 1) != '.') { return false; } return true; }
protected boolean matchesPartialName(String partialGroupName, String name, Schema schema) { if (!StringUtil.endsWithIgnoreCase(name, partialGroupName)) { return false; } int schemaMatch = partialGroupName.length() - name.length(); if (schemaMatch > 0) { if (schemaMatch != schema.getName().length() + 1 || !StringUtil.startsWithIgnoreCase(partialGroupName, schema.getName()) || partialGroupName.charAt(schemaMatch + 1) != '.') { return false; } } else if (schemaMatch < 0 && name.charAt(-schemaMatch - 1) != '.') { return false; } return true; }
public void addNamespace(String prefix, String uri) { if (uri == null || uri.indexOf('}') != -1) { throw new MetadataException(DataPlugin.Event.TEIID60018, DataPlugin.Util.gs(DataPlugin.Event.TEIID60018, uri)); } if (StringUtil.startsWithIgnoreCase(prefix, MetadataFactory.TEIID_RESERVED)) { String validURI = MetadataFactory.BUILTIN_NAMESPACES.get(prefix); if (validURI == null || !uri.equals(validURI)) { throw new MetadataException(DataPlugin.Event.TEIID60017, DataPlugin.Util.gs(DataPlugin.Event.TEIID60017, prefix)); } } if (this.namespaces == null) { this.namespaces = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); } String old = this.namespaces.put(prefix, uri); if (old != null && !old.equals(uri)) { throw new MetadataException(DataPlugin.Event.TEIID60037, DataPlugin.Util.gs(DataPlugin.Event.TEIID60037, prefix, old, uri)); } }
String hint = m.group(1); start = m.end(); if (StringUtil.startsWithIgnoreCase(hint, "make")) { //$NON-NLS-1$ if (hint.equalsIgnoreCase(Option.MAKENOTDEP)) { fromClause.setMakeNotDep(true); } else if (StringUtil.startsWithIgnoreCase(hint, Option.MAKEDEP)) { Option.MakeDep option = new Option.MakeDep(); fromClause.setMakeDep(option); parseOptions(m, option); } else if (StringUtil.startsWithIgnoreCase(hint, SQLConstants.Reserved.MAKEIND)) { Option.MakeDep option = new Option.MakeDep(); fromClause.setMakeInd(option);
String hint = m.group(1); start = m.end(); if (StringUtil.startsWithIgnoreCase(hint, "make")) { //$NON-NLS-1$ if (hint.equalsIgnoreCase(Option.MAKENOTDEP)) { fromClause.setMakeNotDep(true); } else if (StringUtil.startsWithIgnoreCase(hint, Option.MAKEDEP)) { Option.MakeDep option = new Option.MakeDep(); fromClause.setMakeDep(option); parseOptions(m, option); } else if (StringUtil.startsWithIgnoreCase(hint, SQLConstants.Reserved.MAKEIND)) { Option.MakeDep option = new Option.MakeDep(); fromClause.setMakeInd(option);
String hint = m.group(1); start = m.end(); if (StringUtil.startsWithIgnoreCase(hint, "make")) { //$NON-NLS-1$ if (hint.equalsIgnoreCase(Option.MAKENOTDEP)) { fromClause.setMakeNotDep(true); } else if (StringUtil.startsWithIgnoreCase(hint, Option.MAKEDEP)) { Option.MakeDep option = new Option.MakeDep(); fromClause.setMakeDep(option); parseOptions(m, option); } else if (StringUtil.startsWithIgnoreCase(hint, SQLConstants.Reserved.MAKEIND)) { Option.MakeDep option = new Option.MakeDep(); fromClause.setMakeInd(option);
@Test public void testStartsWithIgnoreCase() { String text = "test"; //$NON-NLS-1$ assertEquals(false,StringUtil.startsWithIgnoreCase(null,text)); assertEquals(false,StringUtil.startsWithIgnoreCase("",text)); //$NON-NLS-1$ assertEquals(false,StringUtil.startsWithIgnoreCase(text,null)); assertEquals(true,StringUtil.startsWithIgnoreCase(text,"")); //$NON-NLS-1$ assertEquals(false,StringUtil.startsWithIgnoreCase(text,"testing")); //$NON-NLS-1$ assertEquals(false,StringUtil.startsWithIgnoreCase(text,"es")); //$NON-NLS-1$ assertEquals(true,StringUtil.startsWithIgnoreCase(text,"te")); //$NON-NLS-1$ assertEquals(true,StringUtil.startsWithIgnoreCase(text,"Te")); //$NON-NLS-1$ assertEquals(true,StringUtil.startsWithIgnoreCase(text,"tE")); //$NON-NLS-1$ assertEquals(true,StringUtil.startsWithIgnoreCase(text,"TE")); //$NON-NLS-1$ }
@Override public List<?> translate(Function function) { if (function.getParameters().get(0) instanceof ColumnReference) { ColumnReference cr = (ColumnReference)function.getParameters().get(0); String nativeType = cr.getMetadataObject().getNativeType(); if (nativeType != null && StringUtil.indexOfIgnoreCase(nativeType, "char") == -1) { //$NON-NLS-1$ Function cast = ConvertModifier.createConvertFunction(getLanguageFactory(), cr, (StringUtil.startsWithIgnoreCase(nativeType.trim(), "n")?"n":"")+"varchar(max)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ cast.setName("cast"); //$NON-NLS-1$ function.getParameters().set(0, cast); } } return super.translate(function); } }
private void setIsolationLevel(String value) throws SQLException { if (StringUtil.endsWithIgnoreCase(value, "uncommitted")) { //$NON-NLS-1$ this.getMMConnection().setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); } else if (StringUtil.endsWithIgnoreCase(value, "committed")) { //$NON-NLS-1$ this.getMMConnection().setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); } else if (StringUtil.startsWithIgnoreCase(value, "repeatable")) { //$NON-NLS-1$ this.getMMConnection().setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); } else if ("serializable".equalsIgnoreCase(value)) { //$NON-NLS-1$ this.getMMConnection().setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); } }
private void setIsolationLevel(String value) throws SQLException { if (StringUtil.endsWithIgnoreCase(value, "uncommitted")) { //$NON-NLS-1$ this.getMMConnection().setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); } else if (StringUtil.endsWithIgnoreCase(value, "committed")) { //$NON-NLS-1$ this.getMMConnection().setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); } else if (StringUtil.startsWithIgnoreCase(value, "repeatable")) { //$NON-NLS-1$ this.getMMConnection().setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); } else if ("serializable".equalsIgnoreCase(value)) { //$NON-NLS-1$ this.getMMConnection().setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); } }
@Override public void visit(MappingBaseNode baseNode) { if (baseNode.getSource() == null) { return; } if (StringUtil.startsWithIgnoreCase(baseNode.getFullyQualifiedName(), prefix)) { try { ResolverUtil.addTempGroup(metadata, new GroupSymbol(baseNode.getFullyQualifiedName()), Collections.EMPTY_LIST, false).setMetadataType(Type.XML); } catch (QueryResolverException e) { throw new TeiidRuntimeException(e); } } } }));
ColumnReference cr = (ColumnReference)obj; return cr.getMetadataObject() != null && (StringUtil.startsWithIgnoreCase(cr.getMetadataObject().getNativeType(), "N")); //$NON-NLS-1$