idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
24,800 | public static boolean executeSql ( final String sql , final Connection connection , final boolean isDebug ) throws SQLException { if ( isDebug || LOGGER . isTraceEnabled ( ) ) { LOGGER . log ( Level . INFO , "Executing SQL [" + sql + "]" ) ; } final Statement statement = connection . createStatement ( ) ; final boolean... | Executes the specified SQL with the specified connection . |
24,801 | public static boolean executeSql ( final String sql , final List < Object > paramList , final Connection connection , final boolean isDebug ) throws SQLException { if ( isDebug || LOGGER . isTraceEnabled ( ) ) { LOGGER . log ( Level . INFO , "Executing SQL [" + sql + "]" ) ; } final PreparedStatement preparedStatement ... | Executes the specified SQL with the specified params and connection ... |
24,802 | protected String genHTML ( final HttpServletRequest request , final Map < String , Object > dataModel , final Template template ) throws Exception { final StringWriter stringWriter = new StringWriter ( ) ; template . setOutputEncoding ( "UTF-8" ) ; template . process ( dataModel , stringWriter ) ; final StringBuilder p... | Processes the specified FreeMarker template with the specified request data model . |
24,803 | public static Collection < Class < ? > > discover ( final String scanPath ) throws Exception { if ( StringUtils . isBlank ( scanPath ) ) { throw new IllegalStateException ( "Please specify the [scanPath]" ) ; } LOGGER . debug ( "scanPath[" + scanPath + "]" ) ; final Collection < Class < ? > > ret = new HashSet < > ( ) ... | Scans classpath to discover bean classes . |
24,804 | public static String signHmacSHA1 ( final String source , final String secret ) { try { final Mac mac = Mac . getInstance ( "HmacSHA1" ) ; mac . init ( new SecretKeySpec ( secret . getBytes ( "UTF-8" ) , "HmacSHA1" ) ) ; final byte [ ] signData = mac . doFinal ( source . getBytes ( "UTF-8" ) ) ; return new String ( Bas... | Signs the specified source string using the specified secret . |
24,805 | public static String encryptByAES ( final String content , final String key ) { try { final KeyGenerator kgen = KeyGenerator . getInstance ( "AES" ) ; final SecureRandom secureRandom = SecureRandom . getInstance ( "SHA1PRNG" ) ; secureRandom . setSeed ( key . getBytes ( ) ) ; kgen . init ( 128 , secureRandom ) ; final ... | Encrypts by AES . |
24,806 | public static String decryptByAES ( final String content , final String key ) { try { final byte [ ] data = Hex . decodeHex ( content . toCharArray ( ) ) ; final KeyGenerator kgen = KeyGenerator . getInstance ( "AES" ) ; final SecureRandom secureRandom = SecureRandom . getInstance ( "SHA1PRNG" ) ; secureRandom . setSee... | Decrypts by AES . |
24,807 | public static synchronized String genTimeMillisId ( ) { String ret ; ID_GEN_LOCK . lock ( ) ; try { ret = String . valueOf ( System . currentTimeMillis ( ) ) ; try { Thread . sleep ( ID_GEN_SLEEP_MILLIS ) ; } catch ( final InterruptedException e ) { throw new RuntimeException ( "Generates time millis id fail" ) ; } } f... | Gets current date time string . |
24,808 | public static boolean hasLocale ( final Locale locale ) { try { ResourceBundle . getBundle ( Keys . LANGUAGE , locale ) ; return true ; } catch ( final MissingResourceException e ) { return false ; } } | Determines whether the server has the specified locale configuration or not . |
24,809 | public static void setLocale ( final HttpServletRequest request , final Locale locale ) { final HttpSession session = request . getSession ( false ) ; if ( null == session ) { LOGGER . warn ( "Ignores set locale caused by no session" ) ; return ; } session . setAttribute ( Keys . LOCALE , locale ) ; LOGGER . log ( Leve... | Sets the specified locale into session of the specified request . |
24,810 | public static Locale getLocale ( ) { final Locale ret = LOCALE . get ( ) ; if ( null == ret ) { return Latkes . getLocale ( ) ; } return ret ; } | Gets locale . |
24,811 | public static String getCountry ( final String localeString ) { if ( localeString . length ( ) >= COUNTRY_END ) { return localeString . substring ( COUNTRY_START , COUNTRY_END ) ; } return "" ; } | Gets country from the specified locale string . |
24,812 | public static String getLanguage ( final String localeString ) { if ( localeString . length ( ) >= LANG_END ) { return localeString . substring ( LANG_START , LANG_END ) ; } return "" ; } | Gets language from the specified locale string . |
24,813 | private String createKeyDefinition ( final List < FieldDefinition > keyDefinitionList ) { final StringBuilder sql = new StringBuilder ( ) ; sql . append ( " PRIMARY KEY" ) ; boolean isFirst = true ; for ( FieldDefinition fieldDefinition : keyDefinitionList ) { if ( isFirst ) { sql . append ( "(" ) ; isFirst = false ; }... | the keyDefinitionList tableSql . |
24,814 | public static String escape ( String string ) { char c ; String s = string . trim ( ) ; int length = s . length ( ) ; StringBuilder sb = new StringBuilder ( length ) ; for ( int i = 0 ; i < length ; i += 1 ) { c = s . charAt ( i ) ; if ( c < ' ' || c == '+' || c == '%' || c == '=' || c == ';' ) { sb . append ( '%' ) ; ... | Produce a copy of a string in which the characters + % = ; and control characters are replaced with %hh . This is a gentle form of URL encoding attempting to cause as little distortion to the string as possible . The characters = and ; are meta characters in cookies . By convention they are escaped using the URL - enco... |
24,815 | private < T > T getReference ( final Bean < T > bean ) { T ret = ( T ) beanReferences . get ( bean ) ; if ( null != ret ) { return ret ; } ret = bean . create ( ) ; if ( null != ret ) { beanReferences . put ( bean , ret ) ; return ret ; } throw new RuntimeException ( "Can't create reference for bean [" + bean + "]" ) ;... | Gets reference of the specified bean and creational context . |
24,816 | private < T > void destroyReference ( final Bean < T > bean , final T beanInstance ) { bean . destroy ( beanInstance ) ; } | Destroys the specified bean s instance . |
24,817 | public static void dispose ( ) { final JdbcTransaction jdbcTransaction = TX . get ( ) ; if ( null != jdbcTransaction && jdbcTransaction . getConnection ( ) != null ) { jdbcTransaction . dispose ( ) ; } final Connection connection = CONN . get ( ) ; if ( null != connection ) { try { connection . close ( ) ; } catch ( fi... | Disposes the resources . |
24,818 | private void update ( final String id , final JSONObject oldJsonObject , final JSONObject jsonObject , final List < Object > paramList , final StringBuilder sql ) throws JSONException { final JSONObject needUpdateJsonObject = getNeedUpdateJsonObject ( oldJsonObject , jsonObject ) ; if ( 0 == needUpdateJsonObject . leng... | Compares the specified old json object and new json object updates it if need . |
24,819 | private JSONObject getNeedUpdateJsonObject ( final JSONObject oldJsonObject , final JSONObject jsonObject ) throws JSONException { if ( null == oldJsonObject ) { return jsonObject ; } final JSONObject ret = new JSONObject ( ) ; final Iterator < String > keys = jsonObject . keys ( ) ; String key ; while ( keys . hasNext... | Compares the specified old json object and the new json object returns diff object for updating . |
24,820 | private void remove ( final String id , final StringBuilder sql ) { sql . append ( "DELETE FROM " ) . append ( getName ( ) ) . append ( " WHERE " ) . append ( JdbcRepositories . getDefaultKeyName ( ) ) . append ( " = '" ) . append ( id ) . append ( "'" ) ; } | Removes an record . |
24,821 | private Map < String , Object > buildSQLCount ( final int currentPageNum , final int pageSize , final int pageCount , final Query query , final StringBuilder sqlBuilder , final List < Object > paramList ) throws RepositoryException { final Map < String , Object > ret = new HashMap < > ( ) ; int pageCnt = pageCount ; in... | Builds query SQL and count result . |
24,822 | private void buildSelect ( final StringBuilder selectBuilder , final List < Projection > projections ) { selectBuilder . append ( "SELECT " ) ; if ( null == projections || projections . isEmpty ( ) ) { selectBuilder . append ( " * " ) ; return ; } selectBuilder . append ( projections . stream ( ) . map ( Projection :: ... | Builds SELECT part with the specified select build and projections . |
24,823 | private void buildWhere ( final StringBuilder whereBuilder , final List < Object > paramList , final Filter filter ) throws RepositoryException { if ( null == filter ) { return ; } if ( filter instanceof PropertyFilter ) { processPropertyFilter ( whereBuilder , paramList , ( PropertyFilter ) filter ) ; } else { process... | Builds WHERE part with the specified where build param list and filter . |
24,824 | private void buildOrderBy ( final StringBuilder orderByBuilder , final Map < String , SortDirection > sorts ) { boolean isFirst = true ; String querySortDirection ; for ( final Map . Entry < String , SortDirection > sort : sorts . entrySet ( ) ) { if ( isFirst ) { orderByBuilder . append ( " ORDER BY " ) ; isFirst = fa... | Builds ORDER BY part with the specified order by build and sorts . |
24,825 | private Connection getConnection ( ) { final JdbcTransaction jdbcTransaction = TX . get ( ) ; if ( null != jdbcTransaction && jdbcTransaction . isActive ( ) ) { return jdbcTransaction . getConnection ( ) ; } Connection ret = CONN . get ( ) ; try { if ( null != ret && ! ret . isClosed ( ) ) { return ret ; } ret = Connec... | getConnection . default using current JdbcTransaction s connection if null get a new one . |
24,826 | private void processPropertyFilter ( final StringBuilder whereBuilder , final List < Object > paramList , final PropertyFilter propertyFilter ) throws RepositoryException { String filterOperator ; switch ( propertyFilter . getOperator ( ) ) { case EQUAL : filterOperator = "=" ; break ; case GREATER_THAN : filterOperato... | Processes property filter . |
24,827 | private void processCompositeFilter ( final StringBuilder whereBuilder , final List < Object > paramList , final CompositeFilter compositeFilter ) throws RepositoryException { final List < Filter > subFilters = compositeFilter . getSubFilters ( ) ; if ( 2 > subFilters . size ( ) ) { throw new RepositoryException ( "At ... | Processes composite filter . |
24,828 | private static void toOracleClobEmpty ( final JSONObject jsonObject ) { final Iterator < String > keys = jsonObject . keys ( ) ; try { while ( keys . hasNext ( ) ) { final String name = keys . next ( ) ; final Object val = jsonObject . get ( name ) ; if ( val instanceof String ) { final String valStr = ( String ) val ;... | Process Oracle CLOB empty string . |
24,829 | public < T > Future < T > fireEventAsynchronously ( final Event < ? > event ) { final FutureTask < T > futureTask = new FutureTask < T > ( ( ) -> { synchronizedEventQueue . fireEvent ( event ) ; return null ; } ) ; Latkes . EXECUTOR_SERVICE . execute ( futureTask ) ; return futureTask ; } | Fire the specified event asynchronously . |
24,830 | public static void setRepositoriesWritable ( final boolean writable ) { for ( final Map . Entry < String , Repository > entry : REPOS_HOLDER . entrySet ( ) ) { final String repositoryName = entry . getKey ( ) ; final Repository repository = entry . getValue ( ) ; repository . setWritable ( writable ) ; LOGGER . log ( L... | Sets all repositories whether is writable with the specified flag . |
24,831 | public static JSONArray getRepositoryNames ( ) { final JSONArray ret = new JSONArray ( ) ; if ( null == repositoriesDescription ) { LOGGER . log ( Level . INFO , "Not found repository description[repository.json] file under classpath" ) ; return ret ; } final JSONArray repositories = repositoriesDescription . optJSONAr... | Gets repository names . |
24,832 | public static JSONObject getRepositoryDef ( final String repositoryName ) { if ( StringUtils . isBlank ( repositoryName ) ) { return null ; } if ( null == repositoriesDescription ) { return null ; } final JSONArray repositories = repositoriesDescription . optJSONArray ( "repositories" ) ; for ( int i = 0 ; i < reposito... | Gets the repository definition of an repository specified by the given repository name . |
24,833 | private static void loadRepositoryDescription ( ) { LOGGER . log ( Level . INFO , "Loading repository description...." ) ; final InputStream inputStream = AbstractRepository . class . getResourceAsStream ( "/repository.json" ) ; if ( null == inputStream ) { LOGGER . log ( Level . INFO , "Not found repository descriptio... | Loads repository description . |
24,834 | public void contextInitialized ( final ServletContextEvent servletContextEvent ) { servletContext = servletContextEvent . getServletContext ( ) ; Latkes . init ( ) ; LOGGER . info ( "Initializing the context...." ) ; Latkes . setLocale ( Locale . SIMPLIFIED_CHINESE ) ; LOGGER . log ( Level . INFO , "Default locale [{0}... | Initializes context locale and runtime environment . |
24,835 | private void resolveDependencies ( final Object reference ) { final Class < ? > superclass = reference . getClass ( ) . getSuperclass ( ) . getSuperclass ( ) ; resolveSuperclassFieldDependencies ( reference , superclass ) ; resolveCurrentclassFieldDependencies ( reference ) ; } | Resolves dependencies for the specified reference . |
24,836 | private T instantiateReference ( ) throws Exception { final T ret = proxyClass . newInstance ( ) ; ( ( ProxyObject ) ret ) . setHandler ( javassistMethodHandler ) ; LOGGER . log ( Level . TRACE , "Uses Javassist method handler for bean [class={0}]" , beanClass . getName ( ) ) ; return ret ; } | Constructs the bean object with dependencies resolved . |
24,837 | private void resolveCurrentclassFieldDependencies ( final Object reference ) { for ( final FieldInjectionPoint injectionPoint : fieldInjectionPoints ) { final Object injection = beanManager . getInjectableReference ( injectionPoint ) ; final Field field = injectionPoint . getAnnotated ( ) . getJavaMember ( ) ; try { fi... | Resolves current class field dependencies for the specified reference . |
24,838 | private void resolveSuperclassFieldDependencies ( final Object reference , final Class < ? > clazz ) { if ( clazz . equals ( Object . class ) ) { return ; } final Class < ? > superclass = clazz . getSuperclass ( ) ; resolveSuperclassFieldDependencies ( reference , superclass ) ; if ( Modifier . isAbstract ( clazz . get... | Resolves super class field dependencies for the specified reference . |
24,839 | private void initFieldInjectionPoints ( ) { final Set < AnnotatedField < ? super T > > annotatedFields = annotatedType . getFields ( ) ; for ( final AnnotatedField < ? super T > annotatedField : annotatedFields ) { final FieldInjectionPoint fieldInjectionPoint = new FieldInjectionPoint ( this , annotatedField ) ; field... | Initializes field injection points . |
24,840 | public static String encode ( final String str ) { try { return URLEncoder . encode ( str , "UTF-8" ) ; } catch ( final Exception e ) { LOGGER . log ( Level . WARN , "Encodes str [" + str + "] failed" , e ) ; return str ; } } | Encodes the specified string . |
24,841 | public static String decode ( final String str ) { try { return URLDecoder . decode ( str , "UTF-8" ) ; } catch ( final Exception e ) { LOGGER . log ( Level . WARN , "Decodes str [" + str + "] failed" , e ) ; return str ; } } | Decodes the specified string . |
24,842 | public static List < FieldDefinition > getKeys ( final String repositoryName ) { final List < RepositoryDefinition > repositoryDefs = getRepositoryDefinitions ( ) ; for ( final RepositoryDefinition repositoryDefinition : repositoryDefs ) { if ( StringUtils . equals ( repositoryName , repositoryDefinition . getName ( ) ... | Gets keys of the repository specified by the given repository name . |
24,843 | public static List < RepositoryDefinition > getRepositoryDefinitions ( ) { if ( null == repositoryDefinitions ) { try { initRepositoryDefinitions ( ) ; } catch ( final Exception e ) { LOGGER . log ( Level . ERROR , "Init repository definitions failed" , e ) ; } } return repositoryDefinitions ; } | Gets the repository definitions lazy load . |
24,844 | private static void initRepositoryDefinitions ( ) throws JSONException { final JSONObject jsonObject = Repositories . getRepositoriesDescription ( ) ; if ( null == jsonObject ) { LOGGER . warn ( "Loads repository description [repository.json] failed" ) ; return ; } repositoryDefinitions = new ArrayList < > ( ) ; final ... | Initializes the repository definitions . |
24,845 | public static List < CreateTableResult > initAllTables ( ) { final List < CreateTableResult > ret = new ArrayList < > ( ) ; final List < RepositoryDefinition > repositoryDefs = getRepositoryDefinitions ( ) ; boolean isSuccess = false ; for ( final RepositoryDefinition repositoryDef : repositoryDefs ) { try { isSuccess ... | Initializes all tables from repository . json . |
24,846 | public static Map < String , String > resolve ( final String uri , final String uriTemplate ) { final String [ ] parts = URLs . decode ( uri ) . split ( "/" ) ; final String [ ] templateParts = uriTemplate . split ( "/" ) ; if ( parts . length != templateParts . length ) { return null ; } final Map < String , String > ... | Resolves the specified URI with the specified URI template . |
24,847 | private void initAnnotatedFields ( ) { final Set < Field > hiddenFields = Reflections . getHiddenFields ( beanClass ) ; inject ( hiddenFields ) ; final Set < Field > inheritedFields = Reflections . getInheritedFields ( beanClass ) ; inject ( inheritedFields ) ; final Set < Field > ownFields = Reflections . getOwnFields... | Builds the annotated fields of this annotated type . |
24,848 | public static boolean isStatic ( final HttpServletRequest request ) { final boolean requestStaticResourceChecked = null == request . getAttribute ( Keys . HttpRequest . REQUEST_STATIC_RESOURCE_CHECKED ) ? false : ( Boolean ) request . getAttribute ( Keys . HttpRequest . REQUEST_STATIC_RESOURCE_CHECKED ) ; if ( requestS... | Determines whether the client requests a static resource with the specified request . |
24,849 | private static synchronized void init ( ) { LOGGER . trace ( "Reads static resources definition from [static-resources.xml]" ) ; final File staticResources = Latkes . getWebFile ( "/WEB-INF/static-resources.xml" ) ; if ( null == staticResources || ! staticResources . exists ( ) ) { throw new IllegalStateException ( "No... | Initializes the static resource path patterns . |
24,850 | public static void start ( final Collection < Class < ? > > classes ) { LOGGER . log ( Level . DEBUG , "Initializing Latke IoC container" ) ; final Configurator configurator = getInstance ( ) . getConfigurator ( ) ; if ( null != classes && ! classes . isEmpty ( ) ) { configurator . createBeans ( classes ) ; } LOGGER . ... | Starts the application with the specified bean class and bean modules . |
24,851 | public static void setLocalProperty ( final String key , final String value ) { if ( null == key ) { LOGGER . log ( Level . WARN , "local.props can not set null key" ) ; return ; } if ( null == value ) { LOGGER . log ( Level . WARN , "local.props can not set null value" ) ; return ; } localProps . setProperty ( key , v... | Sets local . props with the specified key and value . |
24,852 | public static void setLatkeProperty ( final String key , final String value ) { if ( null == key ) { LOGGER . log ( Level . WARN , "latke.props can not set null key" ) ; return ; } if ( null == value ) { LOGGER . log ( Level . WARN , "latke.props can not set null value" ) ; return ; } latkeProps . setProperty ( key , v... | Sets latke . props with the specified key and value . |
24,853 | private static void loadLocalProps ( ) { if ( null == localProps ) { localProps = new Properties ( ) ; } try { InputStream resourceAsStream ; final String localPropsEnv = System . getenv ( "LATKE_LOCAL_PROPS" ) ; if ( StringUtils . isNotBlank ( localPropsEnv ) ) { LOGGER . debug ( "Loading local.properties from env var... | Loads the local . props . |
24,854 | private static void loadLatkeProps ( ) { if ( null == latkeProps ) { latkeProps = new Properties ( ) ; } try { InputStream resourceAsStream ; final String latkePropsEnv = System . getenv ( "LATKE_PROPS" ) ; if ( StringUtils . isNotBlank ( latkePropsEnv ) ) { LOGGER . debug ( "Loading latke.properties from env var [$LAT... | Loads the latke . props . |
24,855 | public static String getServerScheme ( ) { String ret = getLatkeProperty ( "serverScheme" ) ; if ( null == ret ) { final RequestContext requestContext = REQUEST_CONTEXT . get ( ) ; if ( null != requestContext ) { ret = requestContext . getRequest ( ) . getScheme ( ) ; } else { ret = "http" ; } } return ret ; } | Gets server scheme . |
24,856 | public static String getServerHost ( ) { String ret = getLatkeProperty ( "serverHost" ) ; if ( null == ret ) { final RequestContext requestContext = REQUEST_CONTEXT . get ( ) ; if ( null != requestContext ) { ret = requestContext . getRequest ( ) . getServerName ( ) ; } else { initPublicIP ( ) ; return PUBLIC_IP ; } } ... | Gets server host . |
24,857 | public synchronized static void initPublicIP ( ) { if ( StringUtils . isNotBlank ( PUBLIC_IP ) ) { return ; } try { final URL url = new URL ( "http://checkip.amazonaws.com" ) ; final HttpURLConnection urlConnection = ( HttpURLConnection ) url . openConnection ( ) ; urlConnection . setConnectTimeout ( 3000 ) ; urlConnec... | Init public IP . |
24,858 | public static String getServerPort ( ) { String ret = getLatkeProperty ( "serverPort" ) ; if ( null == ret ) { final RequestContext requestContext = REQUEST_CONTEXT . get ( ) ; if ( null != requestContext ) { ret = requestContext . getRequest ( ) . getServerPort ( ) + "" ; } } return ret ; } | Gets server port . |
24,859 | public static String getServer ( ) { final StringBuilder serverBuilder = new StringBuilder ( getServerScheme ( ) ) . append ( "://" ) . append ( getServerHost ( ) ) ; final String port = getServerPort ( ) ; if ( StringUtils . isNotBlank ( port ) && ! "80" . equals ( port ) && ! "443" . equals ( port ) ) { serverBuilder... | Gets server . |
24,860 | public static String getStaticServer ( ) { final StringBuilder staticServerBuilder = new StringBuilder ( getStaticServerScheme ( ) ) . append ( "://" ) . append ( getStaticServerHost ( ) ) ; final String port = getStaticServerPort ( ) ; if ( StringUtils . isNotBlank ( port ) && ! "80" . equals ( port ) && ! "443" . equ... | Gets static server . |
24,861 | public static String getContextPath ( ) { if ( null != contextPath ) { return contextPath ; } final String contextPathConf = getLatkeProperty ( "contextPath" ) ; if ( null != contextPathConf ) { contextPath = contextPathConf ; return contextPath ; } final ServletContext servletContext = AbstractServletListener . getSer... | Gets context path . |
24,862 | public static String getStaticPath ( ) { if ( null == staticPath ) { staticPath = getLatkeProperty ( "staticPath" ) ; if ( null == staticPath ) { staticPath = getContextPath ( ) ; } } return staticPath ; } | Gets static path . |
24,863 | public static synchronized void init ( ) { if ( inited ) { return ; } inited = true ; LOGGER . log ( Level . TRACE , "Initializing Latke" ) ; loadLatkeProps ( ) ; loadLocalProps ( ) ; if ( null == runtimeMode ) { final String runtimeModeValue = getLatkeProperty ( "runtimeMode" ) ; if ( null != runtimeModeValue ) { runt... | Initializes Latke framework . |
24,864 | public static RuntimeCache getRuntimeCache ( ) { final String runtimeCache = getLocalProperty ( "runtimeCache" ) ; if ( null == runtimeCache ) { LOGGER . debug ( "Not found [runtimeCache] in local.properties, uses [LOCAL_LRU] as default" ) ; return RuntimeCache . LOCAL_LRU ; } return RuntimeCache . valueOf ( runtimeCac... | Gets the runtime cache . |
24,865 | public static RuntimeDatabase getRuntimeDatabase ( ) { final String runtimeDatabase = getLocalProperty ( "runtimeDatabase" ) ; if ( null == runtimeDatabase ) { throw new RuntimeException ( "Please configures runtime database in local.properties!" ) ; } final RuntimeDatabase ret = RuntimeDatabase . valueOf ( runtimeData... | Gets the runtime database . |
24,866 | public static String getLocalProperty ( final String key ) { String ret = localProps . getProperty ( key ) ; if ( StringUtils . isBlank ( ret ) ) { return ret ; } ret = replaceEnvVars ( ret ) ; return ret ; } | Gets a property specified by the given key from file local . properties . |
24,867 | public static String getLatkeProperty ( final String key ) { String ret = latkeProps . getProperty ( key ) ; if ( StringUtils . isBlank ( ret ) ) { return ret ; } ret = replaceEnvVars ( ret ) ; return ret ; } | Gets a property specified by the given key from file latke . properties . |
24,868 | public static void shutdown ( ) { try { EXECUTOR_SERVICE . shutdown ( ) ; if ( RuntimeCache . REDIS == getRuntimeCache ( ) ) { RedisCache . shutdown ( ) ; } Connections . shutdownConnectionPool ( ) ; if ( RuntimeDatabase . H2 == getRuntimeDatabase ( ) ) { final String newTCPServer = getLocalProperty ( "newTCPServer" ) ... | Shutdowns Latke . |
24,869 | public static File getWebFile ( final String path ) { final ServletContext servletContext = AbstractServletListener . getServletContext ( ) ; File ret ; try { final URL resource = servletContext . getResource ( path ) ; if ( null == resource ) { return null ; } ret = FileUtils . toFile ( resource ) ; if ( null == ret )... | Gets a file in web application with the specified path . |
24,870 | synchronized void fireEvent ( final Event < ? > event ) { final String eventType = event . getType ( ) ; List < Event < ? > > events = synchronizedEvents . get ( eventType ) ; if ( null == events ) { events = new ArrayList < > ( ) ; synchronizedEvents . put ( eventType , events ) ; } events . add ( event ) ; setChanged... | Fires the specified event . |
24,871 | public < E extends Enum < E > > E getEnum ( Class < E > clazz , int index ) throws JSONException { E val = optEnum ( clazz , index ) ; if ( val == null ) { throw new JSONException ( "JSONArray[" + index + "] is not an enum of type " + JSONObject . quote ( clazz . getSimpleName ( ) ) + "." ) ; } return val ; } | Get the enum value associated with an index . |
24,872 | public float optFloat ( int index , float defaultValue ) { final Number val = this . optNumber ( index , null ) ; if ( val == null ) { return defaultValue ; } final float floatValue = val . floatValue ( ) ; return floatValue ; } | Get the optional float value associated with an index . The defaultValue is returned if there is no value for the index or if the value is not a number and cannot be converted to a number . |
24,873 | public int optInt ( int index , int defaultValue ) { final Number val = this . optNumber ( index , null ) ; if ( val == null ) { return defaultValue ; } return val . intValue ( ) ; } | Get the optional int value associated with an index . The defaultValue is returned if there is no value for the index or if the value is not a number and cannot be converted to a number . |
24,874 | public JSONArray optJSONArray ( int index ) { Object o = this . opt ( index ) ; return o instanceof JSONArray ? ( JSONArray ) o : null ; } | Get the optional JSONArray associated with an index . |
24,875 | public JSONObject optJSONObject ( int index ) { Object o = this . opt ( index ) ; return o instanceof JSONObject ? ( JSONObject ) o : null ; } | Get the optional JSONObject associated with an index . Null is returned if the key is not found or null if the index has no value or if the value is not a JSONObject . |
24,876 | public long optLong ( int index , long defaultValue ) { final Number val = this . optNumber ( index , null ) ; if ( val == null ) { return defaultValue ; } return val . longValue ( ) ; } | Get the optional long value associated with an index . The defaultValue is returned if there is no value for the index or if the value is not a number and cannot be converted to a number . |
24,877 | public String optString ( int index , String defaultValue ) { Object object = this . opt ( index ) ; return JSONObject . NULL . equals ( object ) ? defaultValue : object . toString ( ) ; } | Get the optional string associated with an index . The defaultValue is returned if the key is not found . |
24,878 | public JSONArray put ( int index , float value ) throws JSONException { return this . put ( index , Float . valueOf ( value ) ) ; } | Put or replace a float value . If the index is greater than the length of the JSONArray then null elements will be added as necessary to pad it out . |
24,879 | public Writer write ( Writer writer , int indentFactor , int indent ) throws JSONException { try { boolean commanate = false ; int length = this . length ( ) ; writer . write ( '[' ) ; if ( length == 1 ) { try { JSONObject . writeValue ( writer , this . myArrayList . get ( 0 ) , indentFactor , indent ) ; } catch ( Exce... | Write the contents of the JSONArray as JSON text to a writer . |
24,880 | public static void shutdown ( ) { try { Connections . shutdown ( ) ; } catch ( final Exception e ) { LOGGER . log ( Level . ERROR , "Shutdown redis connection pool failed" , e ) ; } } | Shutdowns redis cache . |
24,881 | public static Set < Class < ? extends Annotation > > getStereotypes ( final Class < ? > clazz ) { final Set < Class < ? extends Annotation > > ret = new HashSet < > ( ) ; final Set < Annotation > annotations = getAnnotations ( clazz . getAnnotations ( ) , Stereotype . class ) ; if ( annotations . isEmpty ( ) ) { return... | Gets stereo types of the specified class . |
24,882 | private static Set < Annotation > getAnnotations ( final Annotation [ ] annotations , final Class < ? extends Annotation > neededAnnotationType ) { final Set < Annotation > ret = new HashSet < > ( ) ; for ( final Annotation annotation : annotations ) { annotation . annotationType ( ) . getAnnotations ( ) ; final Annota... | Gets annotations match the needed annotation type from the specified annotation . |
24,883 | public static String [ ] getMethodVariableNames ( final Class < ? > clazz , final String targetMethodName , final Class < ? > [ ] types ) { CtClass cc ; CtMethod cm = null ; try { if ( null == CLASS_POOL . find ( clazz . getName ( ) ) ) { CLASS_POOL . insertClassPath ( new ClassClassPath ( clazz ) ) ; } cc = CLASS_POOL... | Get method variable names of the specified class target method name and parameter types . |
24,884 | public JSONObject accumulate ( String key , Object value ) throws JSONException { testValidity ( value ) ; Object object = this . opt ( key ) ; if ( object == null ) { this . put ( key , value instanceof JSONArray ? new JSONArray ( ) . put ( value ) : value ) ; } else if ( object instanceof JSONArray ) { ( ( JSONArray ... | Accumulate values under a key . It is similar to the put method except that if there is already an object stored under the key then a JSONArray is stored under the key to hold all of the accumulated values . If there is already a JSONArray then the new value is appended to it . In contrast the put method replaces the p... |
24,885 | public boolean getBoolean ( String key ) throws JSONException { Object object = this . get ( key ) ; if ( object . equals ( Boolean . FALSE ) || ( object instanceof String && ( ( String ) object ) . equalsIgnoreCase ( "false" ) ) ) { return false ; } else if ( object . equals ( Boolean . TRUE ) || ( object instanceof S... | Get the boolean value associated with a key . |
24,886 | public JSONArray optJSONArray ( String key ) { Object o = this . opt ( key ) ; return o instanceof JSONArray ? ( JSONArray ) o : null ; } | Get an optional JSONArray associated with a key . It returns null if there is no such key or if its value is not a JSONArray . |
24,887 | private void populateMap ( Object bean ) { Class < ? > klass = bean . getClass ( ) ; boolean includeSuperClass = klass . getClassLoader ( ) != null ; Method [ ] methods = includeSuperClass ? klass . getMethods ( ) : klass . getDeclaredMethods ( ) ; for ( final Method method : methods ) { final int modifiers = method . ... | Populates the internal map of the JSONObject with the bean properties . The bean can not be recursive . |
24,888 | private static < A extends Annotation > A getAnnotation ( final Method m , final Class < A > annotationClass ) { if ( m == null || annotationClass == null ) { return null ; } if ( m . isAnnotationPresent ( annotationClass ) ) { return m . getAnnotation ( annotationClass ) ; } Class < ? > c = m . getDeclaringClass ( ) ;... | Searches the class hierarchy to see if the method or it s super implementations and interfaces has the annotation . |
24,889 | private static int getAnnotationDepth ( final Method m , final Class < ? extends Annotation > annotationClass ) { if ( m == null || annotationClass == null ) { return - 1 ; } if ( m . isAnnotationPresent ( annotationClass ) ) { return 1 ; } Class < ? > c = m . getDeclaringClass ( ) ; if ( c . getSuperclass ( ) == null ... | Searches the class hierarchy to see if the method or it s super implementations and interfaces has the annotation . Returns the depth of the annotation in the hierarchy . |
24,890 | protected static boolean isDecimalNotation ( final String val ) { return val . indexOf ( '.' ) > - 1 || val . indexOf ( 'e' ) > - 1 || val . indexOf ( 'E' ) > - 1 || "-0" . equals ( val ) ; } | Tests if the value should be tried as a decimal . It makes no test if there are actual digits . |
24,891 | protected static Number stringToNumber ( final String val ) throws NumberFormatException { char initial = val . charAt ( 0 ) ; if ( ( initial >= '0' && initial <= '9' ) || initial == '-' ) { if ( isDecimalNotation ( val ) ) { if ( val . length ( ) > 14 ) { return new BigDecimal ( val ) ; } final Double d = Double . val... | Converts a string to a number using the narrowest possible type . Possible returns for this function are BigDecimal Double BigInteger Long and Integer . When a Double is returned it should always be a valid Double and not NaN or + - infinity . |
24,892 | public Writer write ( Writer writer , int indentFactor , int indent ) throws JSONException { try { boolean commanate = false ; final int length = this . length ( ) ; writer . write ( '{' ) ; if ( length == 1 ) { final Entry < String , ? > entry = this . entrySet ( ) . iterator ( ) . next ( ) ; final String key = entry ... | Write the contents of the JSONObject as JSON text to a writer . |
24,893 | public static boolean hasExpression ( final Template template , final String expression ) { final TemplateElement rootTreeNode = template . getRootTreeNode ( ) ; return hasExpression ( template , expression , rootTreeNode ) ; } | Determines whether exists a variable specified by the given expression in the specified template . |
24,894 | public static String exec ( final String cmd , final long timeout ) { final StringTokenizer st = new StringTokenizer ( cmd ) ; final String [ ] cmds = new String [ st . countTokens ( ) ] ; for ( int i = 0 ; st . hasMoreTokens ( ) ; i ++ ) { cmds [ i ] = st . nextToken ( ) ; } return exec ( cmds , timeout ) ; } | Executes the specified command with the specified timeout . |
24,895 | public static String exec ( final String [ ] cmds , final long timeout ) { try { final Process process = new ProcessBuilder ( cmds ) . redirectErrorStream ( true ) . start ( ) ; final StringWriter writer = new StringWriter ( ) ; new Thread ( ( ) -> { try { IOUtils . copy ( process . getInputStream ( ) , writer , "UTF-8... | Executes the specified commands with the specified timeout . |
24,896 | public static synchronized Cache getCache ( final String cacheName ) { LOGGER . log ( Level . INFO , "Constructing cache [name={0}]...." , cacheName ) ; Cache ret = CACHES . get ( cacheName ) ; try { if ( null == ret ) { Class < Cache > cacheClass ; switch ( Latkes . getRuntimeCache ( ) ) { case LOCAL_LRU : cacheClass ... | Gets a cache specified by the given cache name . |
24,897 | public static synchronized void clear ( ) { for ( final Map . Entry < String , Cache > entry : CACHES . entrySet ( ) ) { final Cache cache = entry . getValue ( ) ; cache . clear ( ) ; LOGGER . log ( Level . TRACE , "Cleared cache [name={0}]" , entry . getKey ( ) ) ; } } | Clears all caches . |
24,898 | public Map < String , Object > getDataModel ( ) { final AbstractResponseRenderer renderer = getRenderer ( ) ; if ( null == renderer ) { return null ; } return renderer . getRenderDataModel ( ) ; } | Gets the data model of renderer bound with this context . |
24,899 | public void sendRedirect ( final String location ) { try { response . sendRedirect ( location ) ; } catch ( final Exception e ) { LOGGER . log ( Level . ERROR , "Sends redirect [" + location + "] failed: " + e . getMessage ( ) ) ; } } | Sends redirect to the specified location . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.