idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
35,000
protected static String getStatusClass ( RLOGLevel level ) { String rowClass = "" ; switch ( level ) { case WARN : rowClass = "warning" ; break ; case ERROR : rowClass = "danger" ; break ; case INFO : rowClass = "info" ; break ; default : break ; } return rowClass ; }
return a css class
70
5
35,001
private static String nodeTargetPattern ( ShapeTargetValueShape target ) { return " " + formatNode ( target . getNode ( ) ) + " " + writePropertyChain ( target . pathChain ) + " ?this . " ; }
FIXME add focus node
49
5
35,002
private Model initModel ( ) { OntModel m = ModelFactory . createOntologyModel ( OntModelSpec . OWL_DL_MEM , ModelFactory . createDefaultModel ( ) ) ; try { schemaReader . read ( m ) ; } catch ( RdfReaderException e ) { log . error ( "Cannot load ontology: {} " , getSchema ( ) , e ) ; } return m ; }
lazy loaded via lombok
89
7
35,003
public static SerializationFormat getInputFormat ( String name ) { for ( SerializationFormat ft : Instance . serializationFormats ) { if ( ft . isAcceptedAsInput ( name ) ) { return ft ; } } return null ; }
returns an input FormatType for a given name
52
10
35,004
public static SerializationFormat getOutputFormat ( String name ) { for ( SerializationFormat ft : Instance . serializationFormats ) { if ( ft . isAcceptedAsOutput ( name ) ) { return ft ; } } return null ; }
returns an output FormatType for a given name
52
10
35,005
public static Collection < SerializationFormat > getAllFormats ( ) { ArrayList < SerializationFormat > serializationFormats = new ArrayList <> ( ) ; // single graph formats serializationFormats . add ( createTurtle ( ) ) ; serializationFormats . add ( createN3 ( ) ) ; serializationFormats . add ( createNTriples ( ) ) ;...
Returns a list with all the defined serialization formats
264
10
35,006
static HttpResponse executeHeadRequest ( URI uri , SerializationFormat format ) throws IOException { HttpHead headMethod = new HttpHead ( uri ) ; MyRedirectHandler redirectHandler = new MyRedirectHandler ( uri ) ; String acceptHeader = format . getMimeType ( ) != null && ! format . getMimeType ( ) . trim ( ) . isEmpty ...
Will execute a HEAD only request following redirects trying to locate an rdf document .
303
17
35,007
public static RdfReader createDereferenceReader ( String uri ) { Collection < RdfReader > readers = new ArrayList <> ( ) ; if ( ! IOUtils . isFile ( uri ) ) { readers . add ( new RdfDereferenceReader ( uri ) ) ; //readers.add(new RDFaReader(uri)); } else { readers . add ( new RdfStreamReader ( uri ) ) ; readers . add (...
Generates a Dereference reader . This can be either a remote url a local file or a resource
128
21
35,008
public String getNamespaceFromURI ( String uri ) { String breakChar = "/" ; if ( uri . contains ( "#" ) ) { breakChar = "#" ; } else { if ( uri . substring ( 6 ) . contains ( ":" ) ) { breakChar = ":" ; } } int pos = Math . min ( uri . lastIndexOf ( breakChar ) , uri . length ( ) ) ; return uri . substring ( 0 , pos + ...
Gets namespace from uRI .
108
7
35,009
private Runnable decorateTask ( Runnable task , boolean isRepeatingTask ) { Runnable result = TaskUtils . decorateTaskWithErrorHandler ( task , this . errorHandler , isRepeatingTask ) ; if ( this . enterpriseConcurrentScheduler ) { result = ManagedTaskBuilder . buildManagedTask ( result , task . toString ( ) ) ; } retu...
Decorate task .
88
4
35,010
public void registerMbeans ( ) { ServerAdminMBean serverAdministrationBean = new ServerAdmin ( ) ; try { mbeanServer . registerMBean ( serverAdministrationBean , JMXUtils . getObjectName ( jmxConfig . getContextName ( ) , "ServerAdmin" ) ) ; } catch ( InstanceAlreadyExistsException e ) { throw new InitializationExcepti...
Register mbeans .
166
4
35,011
public static CommandProcessor getInstance ( ) { if ( null == instance ) { synchronized ( CommandProcessor . class ) { if ( null == instance ) { instance = new CommandProcessor ( ) ; } } } return instance ; }
Gets the single instance of CommandProcessor .
49
10
35,012
private static Configuration getDefault ( ) { Configuration config = new Configuration ( ) ; config . addHandler ( new ConsoleAuditHandler ( ) ) ; config . setMetaData ( new DummyMetaData ( ) ) ; config . setLayout ( new SimpleLayout ( ) ) ; config . addProperty ( "log.file.location" , "user.dir" ) ; return config ; }
Gets the default .
81
5
35,013
public void addHandler ( Handler handler ) { if ( null == handlers ) { handlers = new ArrayList <> ( ) ; } handlers . add ( handler ) ; }
Adds the handler .
35
4
35,014
public void addProperty ( String key , String value ) { if ( null == properties ) { properties = new HashMap <> ( ) ; } properties . put ( key , value ) ; }
Adds the property .
40
4
35,015
public boolean audit ( Class < ? > clazz , Method method , Object [ ] args ) { return audit ( new AnnotationAuditEvent ( clazz , method , args ) ) ; }
Audit with annotation .
40
5
35,016
public static IAuditManager getInstance ( ) { IAuditManager result = auditManager ; if ( result == null ) { synchronized ( AuditManager . class ) { result = auditManager ; if ( result == null ) { Context . init ( ) ; auditManager = result = new AuditManager ( ) ; } } } return result ; }
Gets the single instance of AuditHelper .
71
9
35,017
@ Override public Date nextExecutionTime ( TriggerContext triggerContext ) { if ( triggerContext . lastScheduledExecutionTime ( ) == null ) { return new Date ( System . currentTimeMillis ( ) + this . initialDelay ) ; } else if ( this . fixedRate ) { return new Date ( triggerContext . lastScheduledExecutionTime ( ) . ge...
Returns the time after which a task should run again .
117
11
35,018
public String convertDateToString ( final Date date ) { if ( date == null ) { return null ; } return dateFormat . get ( ) . format ( date ) ; }
Convert date to string .
37
6
35,019
public static Schedulers newThreadPoolScheduler ( int poolSize ) { createSingleton ( ) ; Schedulers . increaseNoOfSchedullers ( ) ; ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler ( ) ; CustomizableThreadFactory factory = new CustomizableThreadFactory ( ) ; scheduler . initializeExecutor ( factory , new...
New thread pool scheduler .
153
6
35,020
public static Schedulers stopAll ( ) { createSingleton ( ) ; if ( instance . runningSchedullers . isEmpty ( ) ) { throw new IllegalStateException ( "No schedulers available." ) ; } for ( Entry < String , ScheduledFuture < ? > > entry : instance . runningSchedullers . entrySet ( ) ) { ScheduledFuture < ? > future = entr...
Stop all .
129
3
35,021
public List < I > getNewInstanceList ( String [ ] clsssList ) { List < I > instances = new ArrayList <> ( ) ; for ( String className : clsssList ) { I instance = new ReflectUtil < I > ( ) . getNewInstance ( className ) ; instances . add ( instance ) ; } return instances ; }
Gets the new instance list .
78
7
35,022
public void update ( Date lastScheduledExecutionTime , Date lastActualExecutionTime , Date lastCompletionTime ) { this . lastScheduledExecutionTime = lastScheduledExecutionTime ; this . lastActualExecutionTime = lastActualExecutionTime ; this . lastCompletionTime = lastCompletionTime ; }
Update this holder s state with the latest time values .
75
11
35,023
public static DelegatingErrorHandlingRunnable decorateTaskWithErrorHandler ( Runnable task , ErrorHandler errorHandler , boolean isRepeatingTask ) { if ( task instanceof DelegatingErrorHandlingRunnable ) { return ( DelegatingErrorHandlingRunnable ) task ; } ErrorHandler eh = errorHandler != null ? errorHandler : getDef...
Decorate the task for error handling . If the provided
107
11
35,024
public static Date addDate ( final Date date , final Integer different ) { final Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; cal . add ( Calendar . DATE , different ) ; return cal . getTime ( ) ; }
Add days .
55
3
35,025
private static CopyStreamListener createListener ( ) { return new CopyStreamListener ( ) { private long megsTotal = 0 ; // @Override @ Override public void bytesTransferred ( CopyStreamEvent event ) { bytesTransferred ( event . getTotalBytesTransferred ( ) , event . getBytesTransferred ( ) , event . getStreamSize ( ) )...
Creates the listener .
157
5
35,026
public static void info ( Object ... message ) { StringBuilder builder = new StringBuilder ( APP_INFO ) ; for ( Object object : message ) { builder . append ( object . toString ( ) ) ; } infoStream . println ( builder . toString ( ) ) ; }
Write information in the console .
58
6
35,027
public static void warn ( Object ... message ) { StringBuilder builder = new StringBuilder ( APP_WARN ) ; for ( Object object : message ) { builder . append ( object . toString ( ) ) ; } warnStream . println ( builder . toString ( ) ) ; }
Write warn messasge on console .
58
8
35,028
public static void warn ( final Object message , final Throwable t ) { warnStream . println ( APP_WARN + message . toString ( ) ) ; warnStream . println ( stackTraceToString ( t ) ) ; }
Write warn message on console with exception .
48
8
35,029
public static void error ( Object ... message ) { StringBuilder builder = new StringBuilder ( APP_ERROR ) ; for ( Object object : message ) { builder . append ( object . toString ( ) ) ; } errorStream . println ( builder . toString ( ) ) ; }
Write error message on console .
58
6
35,030
public static void error ( final Object message , final Throwable t ) { errorStream . println ( APP_ERROR + message . toString ( ) ) ; errorStream . println ( stackTraceToString ( t ) ) ; }
Write error messages on console with exception .
48
8
35,031
static ObjectName getObjectName ( String type , String name ) { try { return new ObjectName ( JMXUtils . class . getPackage ( ) . getName ( ) + ":type=" + type + ",name=" + name ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Gets the object name .
69
6
35,032
void printBanner ( ) { PrintStream printStream = System . out ; for ( String lineLocal : BANNER ) { printStream . println ( lineLocal ) ; } printStream . print ( line ) ; String version = Audit4jBanner . class . getPackage ( ) . getImplementationVersion ( ) ; if ( version == null ) { printStream . println ( "(v" + Core...
Prints banner using system out .
123
7
35,033
protected File [ ] getAvailableFiles ( final String logFileLocation , final Date maxDate ) { File dir = new File ( logFileLocation ) ; return dir . listFiles ( new FilenameFilter ( ) { @ Override public boolean accept ( File dir , String fileName ) { boolean extentionMatch = fileName . endsWith ( compressionExtention )...
Gets the available files .
106
6
35,034
private Date fileCreatedDate ( String fileName ) { String [ ] splittedWithoutExtention = fileName . split ( "." ) ; String fileNameWithoutExtention = splittedWithoutExtention [ 0 ] ; String [ ] splittedWithoutPrefix = fileNameWithoutExtention . split ( "-" ) ; String fileNameDateInStr = splittedWithoutPrefix [ 1 ] ; tr...
File created date .
141
4
35,035
static ConfigurationStream resolveConfigFileAsStream ( String configFilePath ) throws ConfigurationException { InputStream fileStream ; String fileExtention ; if ( configFilePath != null ) { if ( new File ( configFilePath ) . isDirectory ( ) ) { String path = scanConfigFile ( configFilePath ) ; fileStream = getFileAsSt...
Resolve config path .
595
5
35,036
static String scanConfigFile ( String dirPath ) throws ConfigurationException { String filePath = dirPath + File . separator + CONFIG_FILE_NAME + "." ; String fullFilePath ; // Scan for Yaml file if ( AuditUtil . isFileExists ( filePath + YML_EXTENTION ) ) { fullFilePath = filePath + YML_EXTENTION ; } else if ( AuditUt...
Scan config file .
198
4
35,037
static void generateConfigFile ( String configFilePath ) throws ConfigurationException { String fileExtention = FilenameUtils . getExtension ( configFilePath ) ; ConfigProvider < Configuration > provider = getProviderByFileExtention ( fileExtention ) ; if ( ! AuditUtil . isFileExists ( configFilePath ) ) { provider . g...
Generate config file .
88
5
35,038
private static ConfigProvider < Configuration > getProviderByFileExtention ( String extention ) throws ConfigurationException { ConfigProvider < Configuration > provider ; if ( XML_EXTENTION . equals ( extention ) ) { provider = new XMLConfigProvider <> ( Configuration . class ) ; } else if ( YML_EXTENTION . equals ( e...
Gets the provider by file extention .
143
9
35,039
static Path getEnvironemtVariableConfigFilePath ( ) { final String value = System . getenv ( ENVIRONMENT_CONFIG_VARIABLE_NAME ) ; return Paths . get ( value ) ; }
Gets the environemt variable config file path .
50
12
35,040
static boolean hasEnvironmentVariable ( String variable ) { final String value = System . getenv ( variable ) ; if ( value != null ) { return true ; } return false ; }
Checks for environment variable .
37
6
35,041
static Path getSystemPropertyConfigFilePath ( ) { final String path = System . getProperty ( SYSTEM_PROPERTY_CONFIG_VARIABLE_NAME ) ; return Paths . get ( path ) ; }
Gets the system property config file path .
47
9
35,042
static boolean hasSystemPropertyVariable ( String variable ) { final String path = System . getProperty ( variable ) ; if ( path != null ) { return true ; } return false ; }
Checks for system property variable .
38
7
35,043
static InputStream getFileAsStream ( File resourceFile ) throws ConfigurationException { try { return new FileInputStream ( resourceFile ) ; } catch ( FileNotFoundException e ) { Log . error ( "File Resource could not be resolved. Given Resource:" + resourceFile , e ) ; throw new ConfigurationException ( "File Resource...
Gets the file as stream .
92
7
35,044
static boolean hasDiskAccess ( final String path ) { try { AccessController . checkPermission ( new FilePermission ( path , "read,write" ) ) ; return true ; } catch ( AccessControlException e ) { return false ; } }
Checks for disk access .
52
6
35,045
public static ClassLoader getClassLoader ( final Class < ? > clazz ) { // Context class loader can be null final ClassLoader contextClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( contextClassLoader != null ) { return contextClassLoader ; } if ( clazz != null ) { // The class loader for a sp...
Gets the class loader .
145
6
35,046
public List < E > getBuffered ( ) { List < E > temp = new ArrayList <> ( buff ) ; clear ( ) ; return temp ; }
Gets the buffered .
34
6
35,047
public void setRepository ( String repository ) { if ( meta == null ) { meta = new EventMeta ( ) ; } meta . setRepository ( repository ) ; }
Sets the repository .
36
5
35,048
public void setClient ( String client ) { if ( meta == null ) { meta = new EventMeta ( ) ; } meta . setClient ( client ) ; }
Sets the client .
34
5
35,049
public static String encodeLines ( final byte [ ] input , final int iOff , final int iLen , final int lineLen , final String lineSeparator ) { final int blockLen = ( lineLen * CONSTANT_3 ) / CONSTANT_4 ; if ( blockLen <= 0 ) { throw new IllegalArgumentException ( ) ; } final int lines = ( iLen + blockLen - 1 ) / blockL...
Encode lines .
219
4
35,050
public static byte [ ] decodeLines ( final String text ) { char [ ] buf = new char [ text . length ( ) ] ; int pValue = 0 ; for ( int ip = 0 ; ip < text . length ( ) ; ip ++ ) { final char cValue = text . charAt ( ip ) ; if ( cValue != ' ' && cValue != ' ' && cValue != ' ' && cValue != ' ' ) { buf [ pValue ++ ] = cValu...
Decode lines .
118
4
35,051
public final static String toJson ( Object object , DeIdentify deidentify ) { if ( isPrimitive ( object ) ) { Object deidentifiedObj = deidentifyObject ( object , deidentify ) ; String primitiveValue = String . valueOf ( deidentifiedObj ) ; if ( object instanceof String || object instanceof Character || ! object . equa...
Converts an object to json .
119
7
35,052
public static String deidentifyLeft ( String str , int size ) { int repeat ; if ( size > str . length ( ) ) { repeat = str . length ( ) ; } else { repeat = size ; } return StringUtils . overlay ( str , StringUtils . repeat ( ' ' , repeat ) , 0 , size ) ; }
Deidentify left .
72
5
35,053
public static String deidentifyRight ( String str , int size ) { int end = str . length ( ) ; int repeat ; if ( size > str . length ( ) ) { repeat = str . length ( ) ; } else { repeat = size ; } return StringUtils . overlay ( str , StringUtils . repeat ( ' ' , repeat ) , end - size , end ) ; }
Deidentify right .
83
5
35,054
public static String deidentifyMiddle ( String str , int start , int end ) { int repeat ; if ( end - start > str . length ( ) ) { repeat = str . length ( ) ; } else { repeat = ( str . length ( ) - end ) - start ; } return StringUtils . overlay ( str , StringUtils . repeat ( ' ' , repeat ) , start , str . length ( ) - e...
Deidentify middle .
93
5
35,055
public static String deidentifyEdge ( String str , int start , int end ) { return deidentifyLeft ( deidentifyRight ( str , end ) , start ) ; }
Deidentify edge .
38
5
35,056
final static void stop ( ) { if ( lifeCycle . getStatus ( ) . equals ( RunStatus . RUNNING ) || lifeCycle . getStatus ( ) . equals ( RunStatus . DISABLED ) ) { lifeCycle . setStatus ( RunStatus . STOPPED ) ; Log . info ( "Preparing to shutdown Audit4j..." ) ; Log . info ( "Closing Streams..." ) ; auditStream . close ( ...
The Audit4j context shutdown method . This will release the all allocated resources by the Audit4j Context initialization .
208
23
35,057
final static void enable ( ) { if ( lifeCycle . getStatus ( ) . equals ( RunStatus . READY ) || lifeCycle . getStatus ( ) . equals ( RunStatus . STOPPED ) ) { init ( ) ; } else if ( lifeCycle . getStatus ( ) . equals ( RunStatus . DISABLED ) ) { lifeCycle . setStatus ( RunStatus . RUNNING ) ; } }
Enable Audit4j core services .
91
7
35,058
private final static void checkEnvironment ( ) { // Check java support.! boolean javaSupport = EnvUtil . isJDK7OrHigher ( ) ; if ( ! javaSupport ) { Log . error ( "Your Java version (" , EnvUtil . getJavaersion ( ) , ") is not supported for Audit4j. " , ErrorGuide . getGuide ( ErrorGuide . JAVA_VERSION_ERROR ) ) ; thro...
Check environment .
109
3
35,059
private final static void loadConfig ( ) { try { conf = Configurations . loadConfig ( configFilePath ) ; } catch ( ConfigurationException e ) { terminate ( ) ; throw new InitializationException ( INIT_FAILED , e ) ; } }
Load configuration items .
54
4
35,060
private static void loadRegistry ( ) { // Load audit filters to runtime configurations. for ( AuditEventFilter filter : PreConfigurationContext . getPrefilters ( ) ) { configContext . addFilter ( filter ) ; } // Load audit annotation filters to runtime configurations. for ( AuditAnnotationFilter annotationFilter : PreC...
Load initial configurations from Registry .
92
6
35,061
private static void initHandlers ( ) { Log . info ( "Initializing Handlers..." ) ; for ( Handler handler : conf . getHandlers ( ) ) { try { if ( ! configContext . getHandlers ( ) . contains ( handler ) ) { Map < String , String > handlerproperties = new HashMap <> ( ) ; handlerproperties . putAll ( configContext . getP...
Initialize handlers .
213
4
35,062
private static void initStreams ( ) { Log . info ( "Initializing Streams..." ) ; MetadataCommand command = ( MetadataCommand ) PreConfigurationContext . getCommandByName ( "-metadata" ) ; BatchCommand batchCommand = ( BatchCommand ) PreConfigurationContext . getCommandByName ( "-batchSize" ) ; AsyncAnnotationAuditOutpu...
Initialize streams .
419
4
35,063
private static AnnotationTransformer < AuditEvent > getDefaultAnnotationTransformer ( ) { DefaultAnnotationTransformer defaultAnnotationTransformer = new DefaultAnnotationTransformer ( ) ; ObjectSerializerCommand serializerCommand = ( ObjectSerializerCommand ) PreConfigurationContext . getCommandByName ( "-objectSerial...
Initializes and returns the default annotation transformer .
138
9
35,064
static void validateConfigurations ( Configuration conf ) throws ValidationException { if ( null == conf . getHandlers ( ) ) { Log . error ( "Handler should not be null, One or more handler implementation shuld be configured in the configuration" , ErrorGuide . getGuide ( ErrorGuide . EMPTY_HANDLERS ) ) ; throw new Val...
Validate configurations .
181
4
35,065
static boolean isSerializable ( Object object ) { final boolean retVal ; if ( implementsInterface ( object ) ) { retVal = attemptToSerialize ( object ) ; } else { retVal = false ; } return retVal ; }
Checks if is serializable .
49
7
35,066
private static boolean implementsInterface ( final Object o ) { final boolean retVal ; retVal = ( o instanceof Serializable ) || ( o instanceof Externalizable ) ; return retVal ; }
Implements interface .
40
5
35,067
private static boolean attemptToSerialize ( final Object o ) { final OutputStream sink ; ObjectOutputStream stream ; stream = null ; try { sink = new ByteArrayOutputStream ( ) ; stream = new ObjectOutputStream ( sink ) ; stream . writeObject ( o ) ; // could also re-serilalize at this point too } catch ( final IOExcept...
Attempt to serialize .
123
5
35,068
protected List < String > getOptionsByCommand ( String command ) { String rawOption = commands . get ( command ) ; String [ ] options = rawOption . split ( CoreConstants . COMMA ) ; return Arrays . asList ( options ) ; }
Gets the options by command .
54
7
35,069
public void scanClass ( InputStream bits ) throws IOException { DataInputStream dstream = new DataInputStream ( new BufferedInputStream ( bits ) ) ; ClassFile cf = null ; try { cf = new ClassFile ( dstream ) ; classIndex . put ( cf . getName ( ) , new HashSet < String > ( ) ) ; if ( scanClassAnnotations ) scanClass ( c...
Parse a . class file for annotations
214
8
35,070
protected void scanMethods ( ClassFile cf ) { List < ClassFile > methods = cf . getMethods ( ) ; if ( methods == null ) return ; for ( Object obj : methods ) { MethodInfo method = ( MethodInfo ) obj ; if ( scanMethodAnnotations ) { AnnotationsAttribute visible = ( AnnotationsAttribute ) method . getAttribute ( Annotati...
Scanns both the method and its parameters for annotations .
332
12
35,071
public void outputAnnotationIndex ( PrintWriter writer ) { for ( String ann : annotationIndex . keySet ( ) ) { writer . print ( ann ) ; writer . print ( ": " ) ; Set < String > classes = annotationIndex . get ( ann ) ; Iterator < String > it = classes . iterator ( ) ; while ( it . hasNext ( ) ) { writer . print ( it . ...
Prints out annotationIndex
116
5
35,072
boolean canSearchConfigFile ( ServletContext servletContext ) { String searchConfigFile = servletContext . getInitParameter ( "searchConfigFile" ) ; if ( searchConfigFile == null || searchConfigFile . equals ( "" ) ) { return false ; } else if ( "true" . equals ( searchConfigFile ) ) { return true ; } return false ; }
Can search config file .
80
5
35,073
boolean hasHandlers ( ServletContext servletContext ) { String handlers = servletContext . getInitParameter ( "handlers" ) ; return ! ( handlers == null || handlers . equals ( "" ) ) ; }
Checks for handlers .
47
5
35,074
private void setNumberHits ( BitSet bits , String value , int min , int max ) { String [ ] fields = StringUtils . delimitedListToStringArray ( value , "," ) ; for ( String field : fields ) { if ( ! field . contains ( "/" ) ) { // Not an incrementer so it must be a range (possibly empty) int [ ] range = getRange ( field...
Sets the number hits .
272
6
35,075
private int [ ] getRange ( String field , int min , int max ) { int [ ] result = new int [ 2 ] ; if ( field . contains ( "*" ) ) { result [ 0 ] = min ; result [ 1 ] = max - 1 ; return result ; } if ( ! field . contains ( "-" ) ) { result [ 0 ] = result [ 1 ] = Integer . valueOf ( field ) ; } else { String [ ] split = S...
Gets the range .
308
5
35,076
@ Override public void execute ( Runnable task ) { try { this . concurrentExecutor . execute ( task ) ; } catch ( RejectedExecutionException ex ) { throw new TaskRejectedException ( "Executor [" + this . concurrentExecutor + "] did not accept task: " + task , ex ) ; } }
Delegates to the specified JDK concurrent executor .
71
11
35,077
private void executeArchive ( ) { for ( AbstractArchiveJob archiveJob : jobs ) { archiveJob . setArchiveDateDiff ( extractArchiveDateCount ( archiveEnv . getDatePattern ( ) ) ) ; archiveJob . setPath ( archiveEnv . getDirPath ( ) ) ; archiveJob . setCompressionExtention ( archiveEnv . getCompression ( ) . getExtention ...
Execute archive .
99
4
35,078
public Integer extractArchiveDateCount ( String datePattern ) { int dateCount = 0 ; String [ ] splits = datePattern . split ( "d|M|y" ) ; if ( splits . length > 0 ) { dateCount = dateCount + Integer . valueOf ( splits [ 0 ] ) ; } if ( splits . length > 1 ) { dateCount = dateCount + ( Integer . valueOf ( splits [ 1 ] ) ...
Extract archive date count .
132
6
35,079
private static boolean isJDK_N_OrHigher ( int n ) { List < String > versionList = new ArrayList < String > ( ) ; // this code should work at least until JDK 10 (assuming n parameter is // always 6 or more) for ( int i = 0 ; i < 5 ; i ++ ) { //Till JDK 1.8 versioning is 1.x after 10 its will JDK N.x if ( n + i < 10 ) ve...
Checks if is jD k_ n_ or higher .
189
13
35,080
static public boolean isJaninoAvailable ( ) { ClassLoader classLoader = EnvUtil . class . getClassLoader ( ) ; try { Class < ? > bindingClass = classLoader . loadClass ( "org.codehaus.janino.ScriptEvaluator" ) ; return bindingClass != null ; } catch ( ClassNotFoundException e ) { return false ; } }
Checks if is janino available .
81
8
35,081
public static boolean hasConfigFileExists ( String dirPath ) { String filePath = dirPath + File . separator + Configurations . CONFIG_FILE_NAME + "." ; if ( AuditUtil . isFileExists ( filePath + Configurations . YML_EXTENTION ) || AuditUtil . isFileExists ( filePath + Configurations . YAML_EXTENTION ) || AuditUtil . is...
Checks whether config file exists in directory .
115
9
35,082
public static URL findClassBase ( Class clazz ) { String resource = clazz . getName ( ) . replace ( ' ' , ' ' ) + ".class" ; return findResourceBase ( resource , clazz . getClassLoader ( ) ) ; }
Find the classpath for the particular class
54
8
35,083
private Cipher getCipher ( int mode ) throws InvalidKeyException , InvalidAlgorithmParameterException , UnsupportedEncodingException , NoSuchAlgorithmException , NoSuchPaddingException { Cipher c = Cipher . getInstance ( ALGORYITHM ) ; byte [ ] iv = CoreConstants . IV . getBytes ( CoreConstants . ENCODE_UTF8 ) ; c . in...
Gets the cipher .
101
5
35,084
public static EncryptionUtil getInstance ( String key , String salt ) throws NoSuchAlgorithmException , UnsupportedEncodingException , InvalidKeySpecException { if ( instance == null ) { synchronized ( EncryptionUtil . class ) { if ( instance == null ) { instance = new EncryptionUtil ( ) ; generateKeyIfNotAvailable ( k...
Gets the Encryptor .
85
7
35,085
public static String getGuide ( String code ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( " see " ) . append ( code ) . append ( " for further details." ) ; return builder . toString ( ) ; }
Gets the guide .
52
5
35,086
public List < Field > getAllFields ( final Method method , final Object [ ] arg1 ) { final Annotation [ ] [ ] parameterAnnotations = method . getParameterAnnotations ( ) ; List < Field > actionItems = new ArrayList < Field > ( ) ; int i = 0 ; String paramName = null ; String paramValue = null ; Class < ? > paramType ; ...
Gets the all params .
334
6
35,087
public static Object quoteIfString ( Object obj ) { return obj instanceof String ? quote ( ( String ) obj ) : obj ; }
Turn the given Object into a String with single quotes if it is a String ; keeping the Object as - is else .
28
24
35,088
@ Override public AuditEvent transformToEvent ( AnnotationAuditEvent annotationEvent ) { AuditEvent event = null ; if ( annotationEvent . getClazz ( ) . isAnnotationPresent ( Audit . class ) && ! annotationEvent . getMethod ( ) . isAnnotationPresent ( IgnoreAudit . class ) ) { event = new AuditEvent ( ) ; Audit audit =...
Transform annotation informations to Audit Event object .
435
9
35,089
private List < Field > getFields ( final Method method , final Object [ ] params ) { final Annotation [ ] [ ] parameterAnnotations = method . getParameterAnnotations ( ) ; final List < Field > fields = new ArrayList < Field > ( ) ; int i = 0 ; String paramName = null ; for ( final Annotation [ ] annotations : parameter...
Extract fields based on annotations .
243
7
35,090
private Runnable errorHandlingTask ( Runnable task , boolean isRepeatingTask ) { return TaskUtils . decorateTaskWithErrorHandler ( task , this . errorHandler , isRepeatingTask ) ; }
Error handling task .
47
4
35,091
public static Map < String , String > transformMap ( final Map < String , Object > paramMap ) { final Map < String , String > paramStrMap = new LinkedHashMap < String , String > ( ) ; for ( final Map . Entry < String , Object > entry : paramMap . entrySet ( ) ) { paramStrMap . put ( entry . getKey ( ) , entry . getValu...
Transform map .
101
3
35,092
public static String dateToString ( final Date date , final String format ) { if ( date == null ) { return null ; } final DateFormat dateFormat = new SimpleDateFormat ( format , Locale . US ) ; return dateFormat . format ( date ) ; }
Date to string .
56
4
35,093
public static Date stringTodate ( String dateString , String format ) throws ParseException { final DateFormat dateFormat = new SimpleDateFormat ( format , Locale . US ) ; return dateFormat . parse ( dateString ) ; }
Convert string to date .
50
6
35,094
public static String timeStampToString ( final Timestamp timestamp , final String format ) { return dateToString ( new Date ( timestamp . getTime ( ) ) , format ) ; }
Time stamp to string .
39
5
35,095
public static boolean isFileExists ( String filePathString ) { File file = new File ( filePathString ) ; if ( file . exists ( ) && ! file . isDirectory ( ) ) return true ; return false ; }
Checks if is file exists .
48
7
35,096
public Timestamp parseTimestamp ( String strValue ) throws IllegalArgumentException { if ( fmt != null ) { Optional < Timestamp > parsed = tryParseWithFormat ( strValue ) ; if ( parsed . isPresent ( ) ) { return parsed . get ( ) ; } } // Otherwise try default timestamp parsing return Timestamp . valueOf ( strValue ) ; ...
Parse the input string and return a timestamp value
78
10
35,097
@ Override public Object deserialize ( Writable blob ) throws SerDeException { Text t = ( Text ) blob ; JsonParser p ; List < Object > r = new ArrayList < Object > ( Collections . nCopies ( columnNames . size ( ) , null ) ) ; try { p = jsonFactory . createJsonParser ( new ByteArrayInputStream ( ( t . getBytes ( ) ) ) )...
Takes JSON string in Text form and has to return an object representation above it that s readable by the corresponding object inspector .
300
25
35,098
@ Override public Writable serialize ( Object obj , ObjectInspector objInspector ) throws SerDeException { StringBuilder sb = new StringBuilder ( ) ; try { StructObjectInspector soi = ( StructObjectInspector ) objInspector ; List < ? extends StructField > structFields = soi . getAllStructFieldRefs ( ) ; assert ( column...
Given an object and object inspector pair traverse the object and generate a Text representation of the object .
319
19
35,099
private void setupCompositeInspector ( ) { ForgePropertyStyleConfig forgePropertyStyleConfig = new ForgePropertyStyleConfig ( ) ; forgePropertyStyleConfig . setProject ( this . project ) ; ForgeInspectorConfig forgeInspectorConfig = new ForgeInspectorConfig ( ) ; forgeInspectorConfig . setProject ( this . project ) ; f...
Setup the composite inspector . This is not done at construction time since Metawidget inspectors cache trait lookups and hence report incorrect values when underlying Java classes change in projects . Therefore the composite inspector setup and configuration is perform explicitly upon every inspection .
364
48