/* (non-Javadoc)
@see org.parosproxy.paros.db.paros.TableSessionUrl#getUrlsForType(int)
188471
@Override
	public List<RecordSessionUrl> getUrlsForType (int type) throws DatabaseException {
    	SqlPreparedStatementWrapper psGetAlluRLSForType = null;
        try {
        	psGetAlluRLSForType = DbSQL.getSingleton().getPreparedStatement("sessionurl.ps.geturlsfortype");
			psGetAlluRLSForType.getPs().setInt(1, type);
			try (ResultSet rs = psGetAlluRLSForType.getPs().executeQuery()) {
				List<RecordSessionUrl> result = new ArrayList<>();
				while (rs.next()) {
					result.add(new RecordSessionUrl(rs.getLong(URLID), rs.getInt(TYPE), rs.getString(URL)));
				}
				return result;
			}
		} catch (SQLException e) {
			throw new DatabaseException(e);
		} finally {
			DbSQL.getSingleton().releasePreparedStatement(psGetAlluRLSForType);
		}
    }
700223
public static DatabaseType getDatabaseType(final String url) {
        switch (getDriverClassName(url)) {
            case "com.mysql.cj.jdbc.Driver":
            case "com.mysql.jdbc.Driver":
                return DatabaseType.MySQL;
            case "org.postgresql.Driver":
                return DatabaseType.PostgreSQL;
            case "oracle.jdbc.driver.OracleDriver":
                return DatabaseType.Oracle;
            case "com.microsoft.sqlserver.jdbc.SQLServerDriver":
                return DatabaseType.SQLServer;
            case "org.h2.Driver":
                return DatabaseType.H2;
            default:
                throw new ShardingException("Cannot resolve JDBC url `%s`", url);
        }
    }
1239020
@Override
	public synchronized void deleteAllUrlsForType(int type) throws DatabaseException {
    	try {
			psDeleteAllUrlsForType.setInt(1, type);
			psDeleteAllUrlsForType.executeUpdate();
		} catch (SQLException e) {
			throw new DatabaseException(e);
		}
    }
747539
public static final void getActivitySessions(ActivitySessionAttribute[] asAttrs,
                                                 int type,
                                                 String[] methodNames,
                                                 Class<?>[][] methodParamTypes,
                                                 List<ActivitySessionMethod> asAttrList,
                                                 String ejbName,
                                                 boolean usesBeanManagedAS)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "getActivitySessions", (Object[])asAttrs);

        if (!usesBeanManagedAS) { // d127328

            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "Bean is CMAS");

            if (asAttrList != null) {
                if (isTraceOn && tc.isDebugEnabled())
                    Tr.debug(tc, "asAttrList non-null");

                // array to keep track of what kind of style last set the method-specific behavior
                int[] highestStyleOnMethod = new int[methodNames.length];

                // Elements of highestStyleOnMethod[] are initialized to zero by Java rules.

                // i : asAttrList loop
                // j : MethodElements loop
                // k : Method loop

                for (int i = 0; i < asAttrList.size(); ++i) {
                    ActivitySessionMethod asMethod = asAttrList.get(i);
                    ActivitySessionAttribute asAttr = asMethod.getActivitySessionAttribute();
                    @SuppressWarnings("unchecked")
                    List<com.ibm.ws.javaee.dd.ejb.Method> methodElements = asMethod.getMethodElements();
                    for (int j = 0; j < methodElements.size(); ++j) {
                        com.ibm.ws.javaee.dd.ejb.Method me = methodElements.get(j);
                        if (isTraceOn && tc.isDebugEnabled()) {
                            trace(me, me.getInterfaceTypeValue() == com.ibm.ws.javaee.dd.ejb.Method.INTERFACE_TYPE_UNSPECIFIED ?
                                            "Interface type unspecified" :
                                            "Interface type: " + me.getInterfaceTypeValue());
                        }
                        // Is this method element for the bean we are processing?
                        if ((me.getEnterpriseBeanName()).equals(ejbName)) {
                            String meName = me.getMethodName().trim();
                            int meType = me.getInterfaceTypeValue();

                            if (meName.equals("*")) {
                                if (meType == com.ibm.ws.javaee.dd.ejb.Method.INTERFACE_TYPE_UNSPECIFIED) {
                                    // style type 1 -- wildcard on all bean methods
                                    if (isTraceOn && tc.isDebugEnabled())
                                        Tr.debug(tc, "Style type 1 - all bean methods:", asAttr);
                                    for (int k = 0; k < methodNames.length; ++k) {
                                        if (highestStyleOnMethod[k] <= 1) {
                                            asAttrs[k] = asAttr;
                                            highestStyleOnMethod[k] = 1;
                                        }
                                    }

                                } else if (meType == type) { //LIDB2257.19
                                    // style type 2 -- wildcard on home or remote interface methods
                                    if (isTraceOn && tc.isDebugEnabled())
                                        Tr.debug(tc, "Style type 2 - home/remote methods only:", asAttr);
                                    for (int k = 0; k < methodNames.length; ++k) {
                                        if (highestStyleOnMethod[k] <= 2) {
                                            asAttrs[k] = asAttr;
                                            highestStyleOnMethod[k] = 2;
                                        }
                                    }
                                }
                            } else if (meType == com.ibm.ws.javaee.dd.ejb.Method.INTERFACE_TYPE_UNSPECIFIED || meType == type) { //LIDB2257.19
                                // It is not a wildcard, and either has an unspecified
                                // type, or is of the right type (Remote/Home/Local),
                                // so check for a method name match.             d123321
                                for (int k = 0; k < methodNames.length; ++k) {
                                    if (meName.equals(methodNames[k])) {
                                        List<String> meParms = me.getMethodParamList();
                                        if (meParms == null) {
                                            // style type 3 - matching method name, no signature
                                            //                specified
                                            if (isTraceOn && tc.isDebugEnabled())
                                                Tr.debug(tc, "Style type 3 - method name only:", asAttr);
                                            if (highestStyleOnMethod[k] <= 3) {
                                                asAttrs[k] = asAttr;
                                                highestStyleOnMethod[k] = 3;
                                            }
                                        } else {
                                            if (DDUtil.methodParamsMatch(meParms, methodParamTypes[k])) {
                                                // style type 4 - matching method name and signature
                                                if (isTraceOn && tc.isDebugEnabled())
                                                    Tr.debug(tc, "Style type 4 - method name and signature:", asAttr);
                                                asAttrs[k] = asAttr;
                                                highestStyleOnMethod[k] = 4;
                                            } // method parms match specified parms
                                        } // method parms were specified
                                    } // methodExtension name matches method name
                                } // method loop (k)
                            } // if/then/else for meName='*'
                        } // enterpriseBean name matches parm in methodExtension
                    } // methodElements loop (j)
                } // asAttrList loop (i)
            } // asAttrList != null

        } else if (usesBeanManagedAS) {
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "Bean is BMAS -- all methods will be set to AS_BEAN_MANAGED");
            for (int i = 0; i < asAttrs.length; i++) {
                asAttrs[i] = ActivitySessionAttribute.AS_BEAN_MANAGED;
            }
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "getActivitySessions");

        return;
    }
165642
public static String getResultSetTypeString(int type) {
        switch (type) {
            case ResultSet.TYPE_FORWARD_ONLY:
                return "TYPE FORWARD ONLY (" + type + ')'; 

            case ResultSet.TYPE_SCROLL_INSENSITIVE:
                return "TYPE SCROLL INSENSITIVE (" + type + ')'; 

            case ResultSet.TYPE_SCROLL_SENSITIVE:
                return "TYPE SCROLL SENSITIVE (" + type + ')'; 

            case TYPE_SS_SCROLL_DYNAMIC: 
                return "TYPE SS SCROLL DYNAMIC (" + type + ')'; 

            case TYPE_SS_DIRECT_FORWARD_ONLY: 
                return "TYPE SS DIRECT FORWARD ONLY (" + type + ')'; 

            case TYPE_SS_SERVER_CURSOR_FORWARD_ONLY: 
                return "TYPE SS SERVER CURSOR FORWARD ONLY (" + type + ')'; 
        }

        return "UNKNOWN RESULT SET TYPE CONSTANT (" + type + ')'; 
    }
1014450
@Pure
	@Inline(value = "URISchemeType.JAR.isURL($1)", imported = {URISchemeType.class})
	public static boolean isJarURL(URL url) {
		return URISchemeType.JAR.isURL(url);
	}
818376
Object getDataValuesForType(Entity entity, Attribute attribute) {
    String attributeName = attribute.getName();
    switch (attribute.getDataType()) {
      case DATE:
        return entity.getLocalDate(attributeName);
      case DATE_TIME:
        return entity.getInstant(attributeName);
      case BOOL:
        return entity.getBoolean(attributeName);
      case DECIMAL:
        return entity.getDouble(attributeName);
      case LONG:
        return entity.getLong(attributeName);
      case INT:
        return entity.getInt(attributeName);
      case HYPERLINK:
      case ENUM:
      case HTML:
      case TEXT:
      case SCRIPT:
      case EMAIL:
      case STRING:
        return entity.getString(attributeName);
      case CATEGORICAL:
      case XREF:
      case FILE:
        Entity refEntity = entity.getEntity(attributeName);
        if (refEntity != null) return refEntity.getIdValue();
        else return "";
      case CATEGORICAL_MREF:
      case MREF:
        List<String> mrefValues = newArrayList();
        for (Entity mrefEntity : entity.getEntities(attributeName)) {
          if (mrefEntity != null) {
            mrefValues.add(mrefEntity.getIdValue().toString());
          }
        }
        return mrefValues;
      case COMPOUND:
        return "";
      default:
        return "";
    }
  }
1165393
private void generateGetType(SQLiteDatabaseSchema schema) {
		MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("getType").addModifiers(Modifier.PUBLIC).addAnnotation(Override.class).returns(String.class);
		methodBuilder.addParameter(Uri.class, "uri");

		methodBuilder.beginControlFlow("switch (sURIMatcher.match(uri))");
		for (Entry<String, ContentEntry> item : uriSet.entrySet()) {
			methodBuilder.beginControlFlow("case $L:", item.getValue().pathIndex);
			methodBuilder.addStatement("return $S", item.getValue().getContentType());
			methodBuilder.endControlFlow();
		}
		methodBuilder.endControlFlow();

		methodBuilder.addStatement("throw new $T(\"Unknown URI for $L operation: \" + uri)", IllegalArgumentException.class, "getType");

		classBuilder.addMethod(methodBuilder.build());

	}
742007
public static String extractServerUrl(String url)
    {
        int rightIndex = url.length();
        if (url.lastIndexOf("/") != -1) { rightIndex = url.lastIndexOf("/"); }
        else if (url.lastIndexOf(":") != -1) { rightIndex = url.lastIndexOf(":"); }
        
        StringBuilder baseUrl = new StringBuilder();
        baseUrl.append(url.substring(0, rightIndex));

        // TODO This next line is pretty ugly, but it works for nearly every postgresql server.
        // If we have to add another exception to this for another database server, then I highly recommend refactoring this to a more elegant solution.
        if (POSTGRESQL.equals(databaseType(url))) { baseUrl.append("/postgres"); }

        int optionsIndex = url.indexOf("?");
        if (optionsIndex == -1) { optionsIndex = url.indexOf(";"); }
        if (optionsIndex != -1) { baseUrl.append(url.substring(optionsIndex)); }

        return baseUrl.toString();
    }
106217
public String getURL(WebPage page) throws IOException, SQLException {
		return getURL(page, (Object)null);
	}
257171
public Connection getConnectionByUrl(String dbPoolUrl) throws SQLException {

        return CmsDriverManager.m_pools.get(dbPoolUrl).getConnection();
    }
1166070
public java.lang.String getEnctype() {
        return (java.lang.String) getStateHelper().eval(PropertyKeys.enctype, "application/x-www-form-urlencoded");

    }
118285
public static String getOfficialDataTypeURI(Datatype datatype) {
    	for(Uris uris : datatype.getUris()) {
    		for(Uri uri : uris.getUri()) {
    			if(!isDeprecated(uri) && uri.getType() == UriType.URN) {
    				return uri.getValue();
    			}
    		}
    	}
    	
    	return null;
    }
988294
public String get(Context context, String url) {
        final Cursor cursor = context.getContentResolver().query(getUri(OfflinerDBHelper.TABLE_CACHE),
                OfflinerDBHelper.PARAMS_CACHE, OfflinerDBHelper.REQUEST_URL
                        + " = '" + url + "'", null, null);
        String result = null;

        if (cursor != null) {
            if (cursor.getCount() != 0) {
                cursor.moveToFirst();
                result = cursor.getString(cursor.getColumnIndex(OfflinerDBHelper.REQUEST_RESULT));
            }
            cursor.close();
        }

        return result;
    }
704117
public String getRequestedSessionIdFromURL(ServletRequest request, boolean force) {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[GET_REQUESTED_SESSION_ID_FROM_URL],"force="+force);
        }
        String sessionID = null;
        if (_smc.getEnableUrlRewriting() || force) {
            String requestURI = ((IExtendedRequest) request).getEncodedRequestURI();
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[GET_REQUESTED_SESSION_ID_FROM_URL], "request uri:" + requestURI);
            }
            int prefix = requestURI.indexOf(_smc.getSessUrlRewritePrefix());
            if (prefix != -1) {
                int sessionIDstart = requestURI.indexOf("=", prefix + 1);
                int i = requestURI.indexOf(";", prefix + 1);
                int j = requestURI.indexOf("?", prefix + 1);
                int postfix = -1;
                if (i == -1) {
                    postfix = j;
                } else if (j == -1) {
                    postfix = i;
                } else
                    postfix = (i > j) ? j : i;

                if (postfix != -1) {
                    sessionID = requestURI.substring(sessionIDstart + 1, postfix);
                } else {
                    sessionID = requestURI.substring(sessionIDstart + 1);
                }
            }
        }
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[GET_REQUESTED_SESSION_ID_FROM_URL], sessionID);
        }
        return sessionID;
    }
1326801
public static DbTypeRegister getRegistry(final Connection connection) throws SQLException {

        // if connection URL is null we can't proceed. fail fast
        Preconditions.checkNotNull(connection);

        final String connectionURL = connection.getMetaData().getURL();
        Preconditions.checkNotNull(connection.getMetaData().getURL(), "connection URL is null");

        // check if we have the value in memory
        DbTypeRegister cachedRegisters = registers.get(connectionURL);

        // First check (no locking)
        if (cachedRegisters == null) {
            synchronized (typeRegisterLock) {
                cachedRegisters = registers.get(connectionURL);

                // Second check (with locking)
                if (cachedRegisters == null) {
                    cachedRegisters = new DbTypeRegister(connection);

                    // read optimization. We are not expecting so many different DBMS URLs, so read is really fast and
                    // the write is a little bit slower which is ok because most of the
                    // times we will use what we have in memory.  Copy all previous entries to the new immutable map.
                    // This soudnd't happen very often.
                    registers = ImmutableMap.<String, DbTypeRegister>builder().putAll(registers)
                                            .put(connectionURL, cachedRegisters).build();
                }
            }
        }

        return cachedRegisters;
    }
546783
@Override
  public OperationHandle getTypeInfo(SessionHandle sessionHandle) throws HiveSQLException {
    try {
      TGetTypeInfoReq req = new TGetTypeInfoReq(sessionHandle.toTSessionHandle());
      TGetTypeInfoResp resp = cliService.GetTypeInfo(req);
      checkStatus(resp.getStatus());
      TProtocolVersion protocol = sessionHandle.getProtocolVersion();
      return new OperationHandle(resp.getOperationHandle(), protocol);
    } catch (HiveSQLException e) {
      throw e;
    } catch (Exception e) {
      throw new HiveSQLException(e);
    }
  }