idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
29,900
public static Set < Method > getMethods ( Class < ? > clazz , Filter < Method > filter ) { Set < Method > methods = new HashSet < Method > ( ) ; Class < ? > cursor = clazz ; while ( cursor != null && cursor != Object . class ) { methods . addAll ( Filter . apply ( filter , cursor . getDeclaredMethods ( ) ) ) ; cursor = cursor . getSuperclass ( ) ; } return methods ; }
Returns the filtered set of methods of the given class including those inherited from the super - classes ; if provided complex filter criteria can be applied .
29,901
public static String getPackageName ( Class < ? > cls ) { Package pkg ; String str ; int pos ; if ( cls == null ) throw new NullPointerException ( "cls is null" ) ; if ( ( pkg = cls . getPackage ( ) ) != null ) return pkg . getName ( ) ; str = cls . getName ( ) ; if ( ( pos = str . lastIndexOf ( '.' ) ) >= 0 ) return str . substring ( 0 , pos ) ; return "" ; }
Get the package name for a class .
29,902
public static String getPackageName ( Object obj ) { if ( obj == null ) throw new NullPointerException ( "obj is null" ) ; return getPackageName ( obj . getClass ( ) ) ; }
Get the package name for a object .
29,903
public static String getResourcePathFor ( CharSequence name , Class < ? > cls ) { int nameLen ; StringBuilder sb ; if ( name == null ) throw new NullPointerException ( "name is null" ) ; if ( cls == null ) throw new NullPointerException ( "cls is null" ) ; nameLen = name . length ( ) ; sb = new StringBuilder ( cls . getName ( ) . length ( ) + nameLen + 2 ) ; appendResourcePathPrefixFor ( sb , cls ) ; cls = null ; if ( name . charAt ( 0 ) != '/' ) sb . append ( name , 1 , nameLen ) ; else sb . append ( name ) ; name = null ; return sb . toString ( ) ; }
Gets a resource path using cls s package name as the prefix .
29,904
public static String getResourcePathFor ( CharSequence name , Object obj ) { if ( obj == null ) throw new NullPointerException ( "obj is null" ) ; return getResourcePathFor ( name , obj . getClass ( ) ) ; }
Gets a resource path using obj s class s package name as the prefix .
29,905
public static InputStream getFor ( String name , Class < ? > cls ) { InputStream ret ; if ( cls == null ) throw new NullPointerException ( "cls is null" ) ; if ( ( ret = cls . getResourceAsStream ( getResourcePathFor ( name , cls ) ) ) == null ) throw new ResourceException ( "Unable to find resource for " + name + " and " + cls ) ; return ret ; }
Gets a InputStream for a class s package .
29,906
public static InputStream getFor ( String name , Object obj ) { if ( obj == null ) throw new NullPointerException ( "obj is null" ) ; return getFor ( name , obj . getClass ( ) ) ; }
Gets a InputStream for a objects s package .
29,907
public InputStream get ( String name ) { InputStream ret ; if ( name == null ) throw new NullPointerException ( "name is null" ) ; if ( ( ret = loader . getResourceAsStream ( prefix + name ) ) == null ) throw new ResourceException ( "Unable to find resource for " + name ) ; return ret ; }
Gets a InputStream for a named resource
29,908
public String getString ( String name ) { InputStream in = null ; if ( name == null ) throw new NullPointerException ( "name is null" ) ; try { if ( ( in = loader . getResourceAsStream ( prefix + name ) ) == null ) throw new ResourceException ( "Unable to find resource for " + name ) ; return IOUtils . toString ( in ) ; } catch ( IOException e ) { throw new ResourceException ( "IOException reading resource " + name , e ) ; } finally { Closer . close ( in , logger , "resource InputStream for " + name ) ; } }
Gets a resource as a String
29,909
public boolean send ( RoxPayload payload ) throws MalformedURLException { final URL payloadResourceUrl = getPayloadResourceUrl ( ) ; if ( payloadResourceUrl == null ) { return false ; } LOGGER . info ( "Connected to ROX Center API at {}" , configuration . getServerConfiguration ( ) . getApiUrl ( ) ) ; if ( configuration . isPayloadPrint ( ) ) { OutputStreamWriter payloadOsw = null ; try { payloadOsw = new OutputStreamWriter ( System . out ) ; serializer . serializePayload ( payloadOsw , payload , true ) ; } catch ( IOException ioe ) { } finally { if ( payloadOsw != null ) { try { payloadOsw . close ( ) ; } catch ( IOException closeIoe ) { } } } } optimizeStart ( ) ; boolean result = sendPayload ( payloadResourceUrl , optimize ( payload ) , true ) ; optimizeStop ( result ) ; if ( ! result ) { result = sendPayload ( payloadResourceUrl , payload , false ) ; } return result ; }
Send a payload to ROX
29,910
private boolean sendPayload ( URL payloadResourceUrl , RoxPayload payload , boolean optimized ) { HttpURLConnection conn = null ; final String payloadLogString = optimized ? "optimized payload" : "payload" ; try { conn = uploadPayload ( payloadResourceUrl , payload ) ; if ( conn . getResponseCode ( ) == 202 ) { LOGGER . info ( "The {} was successfully sent to ROX Center." , payloadLogString ) ; return true ; } else { LOGGER . error ( "Unable to send the {} to Rox. Return code: {}, content: {}" , payloadLogString , conn . getResponseCode ( ) , readInputStream ( conn . getInputStream ( ) ) ) ; } } catch ( IOException ioe ) { if ( ! configuration . isPayloadPrint ( ) ) { OutputStreamWriter baos = null ; try { baos = new OutputStreamWriter ( new ByteArrayOutputStream ( ) , Charset . forName ( Constants . ENCODING ) . newEncoder ( ) ) ; serializer . serializePayload ( baos , payload , true ) ; LOGGER . error ( "The {} in error: {}" , payloadLogString , baos . toString ( ) ) ; } catch ( IOException baosIoe ) { } finally { try { if ( baos != null ) { baos . close ( ) ; } } catch ( IOException baosIoe ) { } } if ( conn != null ) { try { if ( conn . getErrorStream ( ) != null ) { LOGGER . error ( "Unable to send the {} to ROX. Error: {}" , payloadLogString , readInputStream ( conn . getErrorStream ( ) ) ) ; } else { LOGGER . error ( "Unable to send the " + payloadLogString + " to ROX. This is probably due to an unreachable network issue." , ioe ) ; } } catch ( IOException errorIoe ) { LOGGER . error ( "Unable to send the {} to ROX for unknown reason." , payloadLogString ) ; } } else { LOGGER . error ( "Unable to send the |{} to ROX. Error: {}" , payloadLogString , ioe . getMessage ( ) ) ; } } } return false ; }
Internal method to send the payload to ROX center agnostic to the payload optimization
29,911
private void optimizeStart ( ) { if ( configuration . isPayloadCache ( ) ) { if ( configuration . getOptimizerStoreClass ( ) == null ) { store = new CacheOptimizerStore ( ) ; store . start ( configuration ) ; return ; } try { store = ( OptimizerStore ) Class . forName ( configuration . getOptimizerStoreClass ( ) ) . newInstance ( ) ; store . start ( configuration ) ; } catch ( ClassNotFoundException cnfe ) { LOGGER . warn ( "Unable to find the class {}. The payload will be sent without optimizations." , configuration . getOptimizerStoreClass ( ) ) ; } catch ( InstantiationException ex ) { LOGGER . warn ( "Unable to instantiate the class {}. Concrete class required." , configuration . getOptimizerStoreClass ( ) ) ; } catch ( IllegalAccessException ex ) { LOGGER . warn ( "Unable to instantiate the class {}. Empty constructor required." , configuration . getOptimizerStoreClass ( ) ) ; } } }
Start the optimization
29,912
private RoxPayload optimize ( RoxPayload payload ) { if ( store != null ) { return payload . getOptimizer ( ) . optimize ( store , payload ) ; } return payload ; }
Process the payload optimization
29,913
public void start ( ) { logger . info ( "\n###starting..." ) ; try { Container container = this . getActualContainer ( ) ; Server server = new ContainerServer ( container ) ; connection = new SocketConnection ( server ) ; SocketAddress address = new InetSocketAddress ( port ) ; socketAddress = ( InetSocketAddress ) connection . connect ( address ) ; this . isRunning = true ; logger . info ( "\n#Simulator: " + this . getSimulatorName ( ) + "\n#started. " + "\nListening at port: " + socketAddress . getPort ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Starts the simulator at the supplied port exposing the end point .
29,914
public void stop ( ) { try { logger . info ( "\n###stopping..." ) ; connection . close ( ) ; this . isRunning = false ; logger . info ( "\n#" + getSimulatorName ( ) + "\nstopped." ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Stops the simulator .
29,915
private Object [ ] _asArray ( final Object obj ) { Object [ ] array = null ; if ( obj instanceof Object [ ] ) { array = ( Object [ ] ) obj ; if ( array . length == 0 ) { throw new IllegalArgumentException ( "ERROR: empty array" ) ; } } else { array = new Object [ ] { obj } ; } return array ; }
Converts the type of specified object to array . If the type of the object is array it is simply casted . Otherwise an unary array that contains only the specified object is created .
29,916
protected T _jdoLoad ( final K id ) { if ( id == null ) { return null ; } Object p_object = null ; try { p_object = getCastorTemplate ( ) . load ( _objectType , id ) ; } catch ( DataAccessException ex ) { Throwable cause = ex . getMostSpecificCause ( ) ; if ( ObjectNotFoundException . class . isInstance ( cause ) ) { p_object = null ; } else { throw new PersistenceException ( cause ) ; } } T typedObject = _objectType . cast ( p_object ) ; return typedObject ; }
Load the object of the specified identity . If no such object exist this method returns NULL .
29,917
private List < Object > _jdoExecuteQuery ( final String oql , final Object [ ] params ) { List < Object > results = null ; try { results = getExtendedCastorTemplate ( ) . findByQuery ( oql , params ) ; } catch ( DataAccessException ex ) { throw new PersistenceException ( ex . getMostSpecificCause ( ) ) ; } return results ; }
Executes the specified OQL query .
29,918
public static String dumpStack ( final Throwable cause ) { if ( cause == null ) { return "Throwable was null" ; } final StringWriter sw = new StringWriter ( ) ; final PrintWriter s = new PrintWriter ( sw ) ; cause . printStackTrace ( s ) ; final String stack = sw . toString ( ) ; try { sw . close ( ) ; } catch ( final IOException e ) { LOG . warn ( "Could not close writer" , e ) ; } s . close ( ) ; return stack ; }
Returns the stack trace as a string .
29,919
public static Digest valueOf ( final String value ) { final String [ ] parts = value . split ( "=" , 2 ) ; if ( parts . length == 2 ) { return new Digest ( parts [ 0 ] , parts [ 1 ] ) ; } return null ; }
Get a Digest object from a string - based header value
29,920
public Control [ ] getControls ( ) { Control [ ] controls = line . getControls ( ) ; for ( int i = 0 ; i < controls . length ; i ++ ) { Control control = controls [ i ] ; if ( control . getType ( ) . toString ( ) . equals ( BooleanControl . Type . MUTE . toString ( ) ) ) { controls [ i ] = new FakeMuteControl ( ) ; } } return controls ; }
Obtains the set of controls associated with this line . Some controls may only be available when the line is open . If there are no controls this method returns an array of length 0 . The mute - control operation may be overridden by the System .
29,921
public Control getControl ( Control . Type control ) throws IllegalArgumentException { if ( control . toString ( ) . equals ( BooleanControl . Type . MUTE . toString ( ) ) ) { return new FakeMuteControl ( ) ; } else { return line . getControl ( control ) ; } }
Obtains a control of the specified type if there is any . Some controls may only be available when the line is open . The mute - control operation may be overridden by the System .
29,922
protected String parseDateToString ( Date date , Context context , Arguments args ) { final DateFormat dateFormat = parseFormatter ( context , args ) ; dateFormat . setTimeZone ( context . get ( Contexts . TIMEZONE ) ) ; return dateFormat . format ( date ) ; }
Parses the given date to a string depending on the context .
29,923
public List < String > asList ( ) { return Lists . newLinkedList ( Splitter . on ( separator . toString ( ) ) . split ( gets ( ) ) ) ; }
Returns the all lookup results as a list
29,924
public MultiPos < String , String , String > find ( ) { return new MultiPos < String , String , String > ( null , null ) { protected String result ( ) { return findingReplacing ( EMPTY , 'L' , pos , position ) ; } } ; }
Returns a NegateMultiPos instance with all lookup results
29,925
void fileReadCheck ( String filePath ) { File potentialFile = new File ( filePath ) ; String canonicalPath ; try { canonicalPath = potentialFile . getCanonicalPath ( ) ; } catch ( IOException e ) { error ( "Error getting canonical path" , e ) ; throw getException ( filePath ) ; } if ( forbiddenReadFiles . stream ( ) . anyMatch ( canonicalPath :: startsWith ) ) { throw getException ( filePath ) ; } }
Determines if the file at the given file path is safe to read from in all aspects if so returns true else false
29,926
void fileWriteCheck ( String filePath , AddOnModel addOnModel ) { File request ; try { request = new File ( filePath ) . getCanonicalFile ( ) ; } catch ( IOException e ) { error ( "Error getting canonical path" , e ) ; throw getException ( filePath ) ; } isForbidden ( request , addOnModel ) ; boolean success = false ; if ( allowedWriteDirectories . stream ( ) . anyMatch ( compare -> request . toPath ( ) . startsWith ( compare . toPath ( ) ) ) ) { success = true ; } for ( String name : forbiddenWriteFilesNames ) { if ( request . getName ( ) . equals ( name ) ) { success = false ; } } if ( ! success ) { throw getException ( filePath ) ; } if ( ! getSecurityManager ( ) . getSecureAccess ( ) . checkForExistingFileOrDirectory ( request . toString ( ) ) || getSecurityManager ( ) . getSecureAccess ( ) . checkForDirectory ( request . toString ( ) ) ) { return ; } }
Determines if the file at the given file path is safe to write to in all aspects if so returns true else false
29,927
private void isForbidden ( File request , AddOnModel addOnModel ) { if ( forbiddenWriteDirectories . stream ( ) . anyMatch ( compare -> request . toPath ( ) . startsWith ( compare . toPath ( ) ) ) ) { throw getException ( "file: " + request . toString ( ) + " is forbidden. Attempt made by: " + addOnModel . getID ( ) ) ; } }
throws an Exception if the
29,928
public long list ( List < Map < String , Object > > list , Map < String , Object > search , int skip , int max ) { return 0 ; }
Get log messages
29,929
public static BigDecimal cutInvalidSacle ( BigDecimal val ) { if ( val == null ) return null ; double d = val . doubleValue ( ) ; int i = val . intValue ( ) ; if ( d == i ) return new BigDecimal ( i ) ; return new BigDecimal ( Double . toString ( d ) ) ; }
Cut invalid scale .
29,930
public void init ( String name , Map < String , Object > config ) { if ( config == null ) config = Objects . newSOHashMap ( ) ; this . name = name ; this . config = config ; }
Initializing with name and config
29,931
public synchronized Session getSession ( ) { if ( session == null ) { if ( authenticator != null ) { session = Session . getInstance ( properties , authenticator ) ; } else { session = Session . getInstance ( properties ) ; } } return session ; }
Gets the Session - object .
29,932
private void loadPropertiesQueitly ( ) { try { properties = PropertiesFileExtensions . loadProperties ( this , EmailConstants . PROPERTIES_FILENAME ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
On load properties .
29,933
protected Runtime createRuntime ( ResourceLoader resourceLoader , ClassLoader classLoader , RuntimeOptions runtimeOptions ) throws InitializationError , IOException { ClassFinder classFinder = new ResourceLoaderClassFinder ( resourceLoader , classLoader ) ; return new Runtime ( resourceLoader , classFinder , classLoader , runtimeOptions ) ; }
Create the Runtime . Can be overridden to customize the runtime or backend .
29,934
private static void processSeasons ( EpisodeList epList , NodeList nlSeasons ) { if ( nlSeasons == null || nlSeasons . getLength ( ) == 0 ) { return ; } Node nEpisodeList ; for ( int loop = 0 ; loop < nlSeasons . getLength ( ) ; loop ++ ) { nEpisodeList = nlSeasons . item ( loop ) ; if ( nEpisodeList . getNodeType ( ) == Node . ELEMENT_NODE ) { processSeasonEpisodes ( ( Element ) nEpisodeList , epList ) ; } } }
process the individual seasons
29,935
private static void processSeasonEpisodes ( Element eEpisodeList , EpisodeList epList ) { String season = eEpisodeList . getAttribute ( "no" ) ; NodeList nlEpisode = eEpisodeList . getElementsByTagName ( EPISODE ) ; if ( nlEpisode == null || nlEpisode . getLength ( ) == 0 ) { return ; } for ( int eLoop = 0 ; eLoop < nlEpisode . getLength ( ) ; eLoop ++ ) { Node nEpisode = nlEpisode . item ( eLoop ) ; if ( nEpisode . getNodeType ( ) == Node . ELEMENT_NODE ) { epList . addEpisode ( parseEpisode ( ( Element ) nEpisode , season ) ) ; } } }
Process the episodes in the season and add them to the EpisodeList
29,936
private static List < ShowInfo > processShowInfo ( String searchUrl , String tagName ) throws TVRageException { List < ShowInfo > showList = new ArrayList < > ( ) ; ShowInfo showInfo ; Document doc = getDocFromUrl ( searchUrl ) ; NodeList nlShowInfo = doc . getElementsByTagName ( tagName ) ; if ( nlShowInfo == null || nlShowInfo . getLength ( ) == 0 ) { return showList ; } for ( int loop = 0 ; loop < nlShowInfo . getLength ( ) ; loop ++ ) { Node nShowInfo = nlShowInfo . item ( loop ) ; if ( nShowInfo . getNodeType ( ) == Node . ELEMENT_NODE ) { Element eShowInfo = ( Element ) nShowInfo ; showInfo = parseNextShowInfo ( eShowInfo ) ; showList . add ( showInfo ) ; } } return showList ; }
Get a list of the ShowInfo from the specified tag
29,937
private static Episode parseEpisode ( Element eEpisode , String season ) { Episode episode = new Episode ( ) ; EpisodeNumber en = new EpisodeNumber ( ) ; en . setSeason ( season ) ; en . setEpisode ( DOMHelper . getValueFromElement ( eEpisode , "seasonnum" ) ) ; en . setAbsolute ( DOMHelper . getValueFromElement ( eEpisode , "epnum" ) ) ; episode . setEpisodeNumber ( en ) ; episode . setProductionId ( DOMHelper . getValueFromElement ( eEpisode , "prodnum" ) ) ; episode . setAirDate ( DOMHelper . getValueFromElement ( eEpisode , AIRDATE ) ) ; episode . setLink ( DOMHelper . getValueFromElement ( eEpisode , "link" ) ) ; episode . setTitle ( DOMHelper . getValueFromElement ( eEpisode , TITLE ) ) ; episode . setSummary ( DOMHelper . getValueFromElement ( eEpisode , SUMMARY ) ) ; episode . setRating ( DOMHelper . getValueFromElement ( eEpisode , "rating" ) ) ; episode . setScreenCap ( DOMHelper . getValueFromElement ( eEpisode , "screencap" ) ) ; return episode ; }
Parse the episode node into an Episode object
29,938
private static Episode parseEpisodeInfo ( Element eEpisodeInfo ) { Episode episode = new Episode ( ) ; episode . setTitle ( DOMHelper . getValueFromElement ( eEpisodeInfo , TITLE ) ) ; episode . setAirDate ( DOMHelper . getValueFromElement ( eEpisodeInfo , AIRDATE ) ) ; episode . setLink ( DOMHelper . getValueFromElement ( eEpisodeInfo , "url" ) ) ; episode . setSummary ( DOMHelper . getValueFromElement ( eEpisodeInfo , SUMMARY ) ) ; Pattern pattern = Pattern . compile ( "(\\d*)[x](\\d*)" ) ; Matcher matcher = pattern . matcher ( DOMHelper . getValueFromElement ( eEpisodeInfo , "number" ) ) ; if ( matcher . find ( ) ) { EpisodeNumber en = new EpisodeNumber ( ) ; en . setSeason ( matcher . group ( MATCH_SEASON ) ) ; en . setEpisode ( matcher . group ( MATCH_EPISODE ) ) ; episode . setEpisodeNumber ( en ) ; } return episode ; }
Parse the episode info node into an Episode object
29,939
private static ShowInfo parseNextShowInfo ( Element eShowInfo ) { ShowInfo showInfo = new ShowInfo ( ) ; String text ; showInfo . setShowID ( DOMHelper . getValueFromElement ( eShowInfo , "showid" ) ) ; text = DOMHelper . getValueFromElement ( eShowInfo , "showname" ) ; if ( ! TVRageApi . isValidString ( text ) ) { text = DOMHelper . getValueFromElement ( eShowInfo , "name" ) ; } showInfo . setShowName ( text ) ; text = DOMHelper . getValueFromElement ( eShowInfo , "showlink" ) ; if ( ! TVRageApi . isValidString ( text ) ) { text = DOMHelper . getValueFromElement ( eShowInfo , "link" ) ; } showInfo . setShowLink ( text ) ; text = DOMHelper . getValueFromElement ( eShowInfo , COUNTRY ) ; if ( ! TVRageApi . isValidString ( text ) ) { text = DOMHelper . getValueFromElement ( eShowInfo , "origin_country" ) ; } showInfo . setCountry ( text ) ; showInfo . setStarted ( DOMHelper . getValueFromElement ( eShowInfo , "started" ) ) ; showInfo . setStartDate ( DOMHelper . getValueFromElement ( eShowInfo , "startdate" ) ) ; showInfo . setEnded ( DOMHelper . getValueFromElement ( eShowInfo , "ended" ) ) ; showInfo . setTotalSeasons ( DOMHelper . getValueFromElement ( eShowInfo , "seasons" ) ) ; showInfo . setStatus ( DOMHelper . getValueFromElement ( eShowInfo , "status" ) ) ; showInfo . setClassification ( DOMHelper . getValueFromElement ( eShowInfo , "classification" ) ) ; showInfo . setSummary ( DOMHelper . getValueFromElement ( eShowInfo , SUMMARY ) ) ; showInfo . setRuntime ( DOMHelper . getValueFromElement ( eShowInfo , "runtime" ) ) ; showInfo . setAirTime ( DOMHelper . getValueFromElement ( eShowInfo , "airtime" ) ) ; showInfo . setAirDay ( DOMHelper . getValueFromElement ( eShowInfo , "airday" ) ) ; showInfo . setTimezone ( DOMHelper . getValueFromElement ( eShowInfo , "timezone" ) ) ; processNetwork ( showInfo , eShowInfo ) ; processAka ( showInfo , eShowInfo ) ; processGenre ( showInfo , eShowInfo ) ; return showInfo ; }
Parse the show info element into a ShowInfo object
29,940
private static void processNetwork ( ShowInfo showInfo , Element eShowInfo ) { NodeList nlNetwork = eShowInfo . getElementsByTagName ( "network" ) ; for ( int nodeLoop = 0 ; nodeLoop < nlNetwork . getLength ( ) ; nodeLoop ++ ) { Node nShowInfo = nlNetwork . item ( nodeLoop ) ; if ( nShowInfo . getNodeType ( ) == Node . ELEMENT_NODE ) { Element eNetwork = ( Element ) nShowInfo ; CountryDetail newNetwork = new CountryDetail ( ) ; newNetwork . setCountry ( eNetwork . getAttribute ( COUNTRY ) ) ; newNetwork . setDetail ( eNetwork . getTextContent ( ) ) ; showInfo . addNetwork ( newNetwork ) ; } } }
Process network information
29,941
private static void processAka ( ShowInfo showInfo , Element eShowInfo ) { NodeList nlAkas = eShowInfo . getElementsByTagName ( "aka" ) ; for ( int loop = 0 ; loop < nlAkas . getLength ( ) ; loop ++ ) { Node nShowInfo = nlAkas . item ( loop ) ; if ( nShowInfo . getNodeType ( ) == Node . ELEMENT_NODE ) { Element eAka = ( Element ) nShowInfo ; CountryDetail newAka = new CountryDetail ( ) ; newAka . setCountry ( eAka . getAttribute ( COUNTRY ) ) ; newAka . setDetail ( eAka . getTextContent ( ) ) ; showInfo . addAka ( newAka ) ; } } }
Process AKA information
29,942
public Response . ResponseBuilder getTimeMapBuilder ( final LdpRequest req , final IOService serializer , final String baseUrl ) { final List < MediaType > acceptableTypes = req . getHeaders ( ) . getAcceptableMediaTypes ( ) ; final String identifier = getBaseUrl ( baseUrl , req ) + req . getPartition ( ) + req . getPath ( ) ; final List < Link > links = getMementoLinks ( identifier , resource . getMementos ( ) ) . collect ( toList ( ) ) ; final Response . ResponseBuilder builder = Response . ok ( ) . link ( identifier , ORIGINAL + " " + TIMEGATE ) ; builder . links ( links . toArray ( new Link [ 0 ] ) ) . link ( Resource . getIRIString ( ) , "type" ) . link ( RDFSource . getIRIString ( ) , "type" ) . header ( ALLOW , join ( "," , GET , HEAD , OPTIONS ) ) ; final RDFSyntax syntax = getSyntax ( acceptableTypes , of ( APPLICATION_LINK_FORMAT ) ) . orElse ( null ) ; if ( nonNull ( syntax ) ) { final IRI profile = ofNullable ( getProfile ( acceptableTypes , syntax ) ) . orElse ( expanded ) ; final List < Triple > extraData = getExtraTriples ( identifier ) ; for ( final Link l : links ) { if ( l . getRels ( ) . contains ( MEMENTO ) ) { extraData . add ( rdf . createTriple ( rdf . createIRI ( identifier ) , Memento . memento , rdf . createIRI ( l . getUri ( ) . toString ( ) ) ) ) ; } } final StreamingOutput stream = new StreamingOutput ( ) { public void write ( final OutputStream out ) throws IOException { serializer . write ( concat ( links . stream ( ) . flatMap ( linkToTriples ) , extraData . stream ( ) ) , out , syntax , profile ) ; } } ; return builder . type ( syntax . mediaType ) . entity ( stream ) ; } return builder . type ( APPLICATION_LINK_FORMAT ) . entity ( links . stream ( ) . map ( Link :: toString ) . collect ( joining ( ",\n" ) ) + "\n" ) ; }
Create a response builder for a TimeMap response
29,943
public Response . ResponseBuilder getTimeGateBuilder ( final LdpRequest req , final String baseUrl ) { final String identifier = getBaseUrl ( baseUrl , req ) + req . getPartition ( ) + req . getPath ( ) ; return Response . status ( FOUND ) . location ( fromUri ( identifier + "?version=" + req . getDatetime ( ) . getInstant ( ) . toEpochMilli ( ) ) . build ( ) ) . link ( identifier , ORIGINAL + " " + TIMEGATE ) . links ( getMementoLinks ( identifier , resource . getMementos ( ) ) . toArray ( Link [ ] :: new ) ) . header ( VARY , ACCEPT_DATETIME ) ; }
Create a response builder for a TimeGate response
29,944
public static Stream < Link > getMementoLinks ( final String identifier , final List < VersionRange > mementos ) { return concat ( getTimeMap ( identifier , mementos . stream ( ) ) , mementos . stream ( ) . map ( mementoToLink ( identifier ) ) ) ; }
Retrieve all of the Memento - related link headers given a stream of VersionRange objects
29,945
public static void main ( String [ ] args ) { System . out . println ( "Jaguar " + MAJOR + "." + MINER + BUILD ) ; System . out . println ( "Copyright (C) 2009-2011 Eiichiro Uchiumi. All Rights Reserved." ) ; }
Prints the version &amp ; copyright information .
29,946
public String [ ] tokenise ( String string ) { String str = string ; if ( str == null || str . length ( ) == 0 ) { return null ; } List < String > list = new ArrayList < String > ( ) ; int length = delimiter . length ( ) ; int idx = str . indexOf ( delimiter ) ; while ( idx != - 1 ) { String token = str . substring ( 0 , idx ) ; str = str . substring ( idx + length ) ; if ( trimTokens ) { token = token . trim ( ) ; } if ( ! skimEmpty || token . length ( ) > 0 ) { list . add ( token ) ; } idx = str . indexOf ( delimiter ) ; } if ( str . trim ( ) . length ( ) > 0 ) { if ( trimTokens ) { str = str . trim ( ) ; } list . add ( str ) ; } String [ ] tokens = new String [ list . size ( ) ] ; list . toArray ( tokens ) ; return tokens ; }
Tokenises the input string using the given delimiter .
29,947
public static SecureStorage createSecureStorage ( Main main ) throws IllegalAccessException { if ( ! exists ) { SecureStorage secureStorage = new SecureStorageImpl ( main ) ; exists = true ; SecureStorageImpl . secureStorage = secureStorage ; return secureStorage ; } throw new IllegalAccessException ( "Cannot create more than one instance of IzouSecurityManager" ) ; }
Creates an SecureStorage . There can only be one single SecureStorage so calling this method twice will cause an illegal access exception .
29,948
private SecretKey retrieveKey ( ) { SecretKey key = null ; try { String workingDir = getMain ( ) . getFileSystemManager ( ) . getSystemLocation ( ) . getAbsolutePath ( ) ; final String keyStoreFile = workingDir + File . separator + "izou.keystore" ; KeyStore keyStore = createKeyStore ( keyStoreFile , "4b[X:+H4CS&avY<)" ) ; KeyStore . PasswordProtection keyPassword = new KeyStore . PasswordProtection ( "Ev45j>eP}QTR?K9_" . toCharArray ( ) ) ; KeyStore . Entry entry = keyStore . getEntry ( "izou_key" , keyPassword ) ; key = ( ( KeyStore . SecretKeyEntry ) entry ) . getSecretKey ( ) ; } catch ( NullPointerException e ) { return null ; } catch ( UnrecoverableEntryException | NoSuchAlgorithmException | KeyStoreException e ) { logger . error ( "Unable to retrieve key" , e ) ; } return key ; }
Retrieves the izou aes key stored in a keystore
29,949
private void storeKey ( SecretKey key ) { final String keyStoreFile = getMain ( ) . getFileSystemManager ( ) . getSystemLocation ( ) + File . separator + "izou.keystore" ; KeyStore keyStore = createKeyStore ( keyStoreFile , "4b[X:+H4CS&avY<)" ) ; try { KeyStore . SecretKeyEntry keyStoreEntry = new KeyStore . SecretKeyEntry ( key ) ; KeyStore . PasswordProtection keyPassword = new KeyStore . PasswordProtection ( "Ev45j>eP}QTR?K9_" . toCharArray ( ) ) ; keyStore . setEntry ( "izou_key" , keyStoreEntry , keyPassword ) ; keyStore . store ( new FileOutputStream ( keyStoreFile ) , "4b[X:+H4CS&avY<)" . toCharArray ( ) ) ; } catch ( NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e ) { logger . error ( "Unable to store key" , e ) ; } }
Stores the izou aes key in a keystore
29,950
private KeyStore createKeyStore ( String fileName , String password ) { File file = new File ( fileName ) ; KeyStore keyStore = null ; try { keyStore = KeyStore . getInstance ( "JCEKS" ) ; if ( file . exists ( ) ) { keyStore . load ( new FileInputStream ( file ) , password . toCharArray ( ) ) ; } else { keyStore . load ( null , null ) ; keyStore . store ( new FileOutputStream ( fileName ) , password . toCharArray ( ) ) ; } } catch ( CertificateException | IOException | KeyStoreException | NoSuchAlgorithmException e ) { logger . error ( "Unable to create key store" , e ) ; } return keyStore ; }
Creates a new keystore for the izou aes key
29,951
public static byte [ ] decodeHex ( char [ ] data ) throws DecoderException { int len = data . length ; if ( ( len & 0x01 ) != 0 ) { throw new DecoderException ( "Odd number of characters." ) ; } byte [ ] out = new byte [ len >> 1 ] ; for ( int i = 0 , j = 0 ; j < len ; i ++ ) { int f = toDigit ( data [ j ] , j ) << 4 ; j ++ ; f = f | toDigit ( data [ j ] , j ) ; j ++ ; out [ i ] = ( byte ) ( f & 0xFF ) ; } return out ; }
Converts an array of characters representing hexidecimal values into an array of bytes of those same values . The returned array will be half the length of the passed array as it takes two characters to represent any given byte . An exception is thrown if the passed char array has an odd number of elements .
29,952
public static char [ ] encodeHex ( byte [ ] data ) { int l = data . length ; char [ ] out = new char [ l << 1 ] ; for ( int i = 0 , j = 0 ; i < l ; i ++ ) { out [ j ++ ] = DIGITS [ ( 0xF0 & data [ i ] ) >>> 4 ] ; out [ j ++ ] = DIGITS [ 0x0F & data [ i ] ] ; } return out ; }
Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order . The returned array will be double the length of the passed array as it takes two characters to represent any given byte .
29,953
public Object decode ( Object object ) throws DecoderException { try { char [ ] charArray = object instanceof String ? ( ( String ) object ) . toCharArray ( ) : ( char [ ] ) object ; return decodeHex ( charArray ) ; } catch ( ClassCastException e ) { throw new DecoderException ( e . getMessage ( ) ) ; } }
Converts a String or an array of character bytes representing hexidecimal values into an array of bytes of those same values . The returned array will be half the length of the passed String or array as it takes two characters to represent any given byte . An exception is thrown if the passed char array has an odd number of elements .
29,954
public Object encode ( Object object ) throws EncoderException { try { byte [ ] byteArray = object instanceof String ? ( ( String ) object ) . getBytes ( ) : ( byte [ ] ) object ; return encodeHex ( byteArray ) ; } catch ( ClassCastException e ) { throw new EncoderException ( e . getMessage ( ) ) ; } }
Converts a String or an array of bytes into an array of characters representing the hexidecimal values of each byte in order . The returned array will be double the length of the passed String or array as it takes two characters to represent any given byte .
29,955
static TrialContext makeContext ( UUID trialId , int trialNumber , Experiment experiment ) { return new TrialContext ( trialId , trialNumber , experiment ) ; }
Makes a new TrialContext that can be used to invoke
29,956
public void add ( JComponent component , String label ) { components . add ( component ) ; component2LabelMap . put ( component , label ) ; if ( components . size ( ) == 1 ) { baseComponent . add ( component ) ; } else if ( components . size ( ) > 1 ) { baseComponent . removeAll ( ) ; for ( JComponent c : components ) { tabbedPane . add ( component2LabelMap . get ( c ) , c ) ; } baseComponent . add ( tabbedPane ) ; } if ( component instanceof NodeComponent ) { ( ( NodeComponent ) component ) . addedToNode ( this ) ; } }
Adds a component to this node . If there are multiple components they will be stacked in a tabbed pane .
29,957
public String getLabel ( JComponent component ) { String label = component2LabelMap . get ( component ) ; if ( label != null ) { return label ; } else { return "" ; } }
Gets the label for the specified component .
29,958
public boolean anyMatch ( String lookupAny ) { return keyMatch ( lookupAny ) || nameMatch ( lookupAny ) || tagMatch ( lookupAny ) || ticketMatch ( lookupAny ) ; }
Match any condition
29,959
public boolean keyMatch ( String lookupKey ) { if ( key . isEmpty ( ) ) { return technicalName . contains ( lookupKey ) ; } else { return key . contains ( lookupKey ) ; } }
Match key condition
29,960
public static String getSLLL ( String [ ] soilParas ) { if ( soilParas != null && soilParas . length >= 3 ) { return divide ( calcMoisture1500Kpa ( soilParas [ 0 ] , soilParas [ 1 ] , soilParas [ 2 ] ) , "100" , 3 ) ; } else { return null ; } }
For calculating SLLL
29,961
public static String getSLDUL ( String [ ] soilParas ) { if ( soilParas != null && soilParas . length >= 3 ) { return divide ( calcMoisture33Kpa ( soilParas [ 0 ] , soilParas [ 1 ] , soilParas [ 2 ] ) , "100" , 3 ) ; } else { return null ; } }
For calculating SLDUL
29,962
public static String getSLSAT ( String [ ] soilParas ) { if ( soilParas != null && soilParas . length >= 3 ) { return divide ( calcSaturatedMoisture ( soilParas [ 0 ] , soilParas [ 1 ] , soilParas [ 2 ] ) , "100" , 3 ) ; } else { return null ; } }
For calculating SLSAT
29,963
public static String getSKSAT ( String [ ] soilParas ) { if ( soilParas != null && soilParas . length >= 3 ) { if ( soilParas . length >= 4 ) { return divide ( calcSatBulk ( soilParas [ 0 ] , soilParas [ 1 ] , soilParas [ 2 ] , divide ( soilParas [ 3 ] , "100" ) ) , "10" , 3 ) ; } else { return divide ( calcSatMatric ( soilParas [ 0 ] , soilParas [ 1 ] , soilParas [ 2 ] ) , "10" , 3 ) ; } } else { return null ; } }
For calculating SKSAT
29,964
public static String getSLBDM ( String [ ] soilParas ) { if ( soilParas != null && soilParas . length >= 3 ) { if ( soilParas . length >= 4 ) { return round ( calcGravePlusDensity ( soilParas [ 0 ] , soilParas [ 1 ] , soilParas [ 2 ] , divide ( soilParas [ 3 ] , "100" ) ) , 2 ) ; } else { return round ( calcNormalDensity ( soilParas [ 0 ] , soilParas [ 1 ] , soilParas [ 2 ] ) , 2 ) ; } } else { return null ; } }
For calculating SLBDM
29,965
public static String calcMoisture1500Kpa ( String slsnd , String slcly , String omPct ) { if ( ( slsnd = checkPctVal ( slsnd ) ) == null || ( slcly = checkPctVal ( slcly ) ) == null || ( omPct = checkPctVal ( omPct ) ) == null ) { LOG . error ( "Invalid input parameters for calculating 1500 kPa moisture, %v" ) ; return null ; } String ret = sum ( product ( "-0.02736" , slsnd ) , product ( "0.55518" , slcly ) , product ( "0.684" , omPct ) , product ( "0.0057" , slsnd , omPct ) , product ( "-0.01482" , slcly , omPct ) , product ( "0.0007752" , slsnd , slcly ) , "1.534" ) ; LOG . debug ( "Calculate result for 1500 kPa moisture, %v is {}" , ret ) ; return ret ; }
Equation 1 for calculating 1500 kPa moisture %v
29,966
public static String calcMoisture33Kpa ( String slsnd , String slcly , String omPct ) { String ret ; if ( ( slsnd = checkPctVal ( slsnd ) ) == null || ( slcly = checkPctVal ( slcly ) ) == null || ( omPct = checkPctVal ( omPct ) ) == null ) { LOG . error ( "Invalid input parameters for calculating 33 kPa moisture, normal density, %v" ) ; return null ; } String mt33Fst = calcMoisture33KpaFst ( slsnd , slcly , omPct ) ; ret = sum ( product ( pow ( mt33Fst , "2" ) , "0.01283" ) , product ( mt33Fst , "0.626" ) , "-1.5" ) ; LOG . debug ( "Calculate result for 33 kPa moisture, normal density, %v is {}" , ret ) ; return ret ; }
Equation 2 for 33 kPa moisture normal density %v
29,967
private static String calcMoisture33KpaFst ( String slsnd , String slcly , String omPct ) { String ret = sum ( product ( "-0.251" , slsnd ) , product ( "0.195" , slcly ) , product ( "1.1" , omPct ) , product ( "0.006" , slsnd , omPct ) , product ( "-0.027" , slcly , omPct ) , product ( "0.00452" , slsnd , slcly ) , "29.9" ) ; LOG . debug ( "Calculate result for 33 kPa moisture, first solution, %v is {}" , ret ) ; return ret ; }
Equation 2 for calculating 33 kPa moisture first solution %v
29,968
private static String calcLamda ( String slsnd , String slcly , String omPct ) { String mt33 = divide ( calcMoisture33Kpa ( slsnd , slcly , omPct ) , "100" ) ; String mt1500 = divide ( calcMoisture1500Kpa ( slsnd , slcly , omPct ) , "100" ) ; String ret = divide ( substract ( log ( mt33 ) , log ( mt1500 ) ) , CONST_LN1500_LN33 ) ; LOG . debug ( "Calculate result for Slope of logarithmic tension-moisture curve is {}" , ret ) ; return ret ; }
Equation 15 for calculating Slope of logarithmic tension - moisture curve
29,969
public WhereCondition WHERE ( WhereCondition whereCondition ) { checkTokenOrderIsCorrect ( ESqlToken . WHERE ) ; mSgSQL . append ( "(" ) ; mSgSQL . append ( whereCondition . toWhereConditionPart ( ) ) ; mSgSQL . append ( ")" ) ; return WhereCondition . this ; }
Add WhereCondition object itself surrounded with bracket into where clause
29,970
public WhereCondition Col ( String columnName ) { mSgSQL . append ( columnName ) ; checkTokenOrderIsCorrect ( ESqlToken . COLUMN ) ; return WhereCondition . this ; }
Add columnName into WHERE clause
29,971
public WhereCondition Val ( Object val ) { if ( "?" . equals ( val ) ) { mSgSQL . append ( " ?" ) ; } else { mSgSQL . append ( "'" ) ; mSgSQL . append ( val . toString ( ) ) ; mSgSQL . append ( "'" ) ; } checkTokenOrderIsCorrect ( ESqlToken . VALUE ) ; return WhereCondition . this ; }
Add value of column into WHERE clause
29,972
private void checkTokenOrderIsCorrect ( ESqlToken tokenTobeAdded ) { switch ( tokenTobeAdded ) { case COLUMN : if ( mPreviousToken != ESqlToken . CONDITION && mPreviousToken != ESqlToken . NOTHING ) { throw new D6RuntimeException ( "AND or OR method is required at here." + " '" + mSgSQL . toString ( ) + "'<==error occurred around here." ) ; } break ; case OPERATOR : if ( mPreviousToken != ESqlToken . COLUMN ) { throw new D6RuntimeException ( "VALUE is required at here." + " '" + mSgSQL . toString ( ) + "'<==error occurred around here." ) ; } break ; case VALUE : if ( mPreviousToken != ESqlToken . OPERATOR ) { throw new D6RuntimeException ( "COLUMN or PROPERTY method is required at here." + " '" + mSgSQL . toString ( ) + "'<==error occurred around here." ) ; } break ; case CONDITION : if ( mPreviousToken != ESqlToken . VALUE && mPreviousToken != ESqlToken . WHERE ) { throw new D6RuntimeException ( "VALUE is required at here." + " '" + mSgSQL . toString ( ) + "'<==error occurred around here." ) ; } break ; case WHERE : if ( mPreviousToken != ESqlToken . CONDITION && mPreviousToken != ESqlToken . NOTHING ) { throw new D6RuntimeException ( "CONDITION is required at here." + " '" + mSgSQL . toString ( ) + "'<==error occurred around here." ) ; } break ; default : } mPreviousToken = tokenTobeAdded ; }
Confirm whether the token is built in the correct order and throws an exception if there is a problem .
29,973
String toWhereConditionPart ( ) { if ( mPreviousToken != ESqlToken . VALUE && mPreviousToken != ESqlToken . WHERE ) { throw new D6RuntimeException ( "Where condition is not completed." + " '" + mSgSQL . toString ( ) + "'<==error occurred around here." ) ; } return mSgSQL . toString ( ) ; }
where condition part
29,974
public static boolean isWhitespace ( int ch ) { return CHAR_WHITE_SPACE == ch || TAB == ch || LF == ch || CR == ch ; }
Checks if a Character is white space
29,975
public static boolean contains ( String target , String ... containWith ) { return contains ( target , Arrays . asList ( containWith ) ) ; }
Checks if target string contains any string in the given string array
29,976
public static boolean contains ( String target , List < String > containWith ) { if ( isNull ( target ) ) { return false ; } return matcher ( target ) . contains ( containWith ) ; }
Checks if target string contains any string in the given string list
29,977
public static int indexAny ( String target , String ... indexWith ) { return indexAny ( target , 0 , Arrays . asList ( indexWith ) ) ; }
Search target string to find the first index of any string in the given string array
29,978
public static int indexAny ( String target , Integer fromIndex , String ... indexWith ) { return indexAny ( target , fromIndex , Arrays . asList ( indexWith ) ) ; }
Search target string to find the first index of any string in the given string array starting at the specified index
29,979
public static int indexAny ( String target , Integer fromIndex , List < String > indexWith ) { if ( isNull ( target ) ) { return INDEX_NONE_EXISTS ; } return matcher ( target ) . indexs ( fromIndex , checkNotNull ( indexWith ) . toArray ( new String [ indexWith . size ( ) ] ) ) ; }
Search target string to find the first index of any string in the given string list starting at the specified index
29,980
public static boolean endAny ( String target , String ... endWith ) { return endAny ( target , Arrays . asList ( endWith ) ) ; }
Check if target string ends with any of an array of specified strings .
29,981
public static boolean endAny ( String target , List < String > endWith ) { if ( isNull ( target ) ) { return false ; } return matcher ( target ) . ends ( endWith ) ; }
Check if target string ends with any of a list of specified strings .
29,982
public static boolean startAny ( String target , String ... startWith ) { return startAny ( target , 0 , Arrays . asList ( startWith ) ) ; }
Check if target string starts with any of an array of specified strings .
29,983
public static boolean startAny ( String target , Integer toffset , String ... startWith ) { return startAny ( target , toffset , Arrays . asList ( startWith ) ) ; }
Check if target string starts with any of an array of specified strings beginning at the specified index .
29,984
public static boolean startAny ( String target , Integer toffset , List < String > startWith ) { if ( isNull ( target ) ) { return false ; } return matcher ( target ) . starts ( toffset , startWith ) ; }
Check if target string starts with any of a list of specified strings beginning at the specified index .
29,985
static < T > T iterate ( Object o , Closure < IterateBean , Object > closure ) { return ( T ) iterateNamedObjectFromLeaf ( null , "" , o , closure ) ; }
Iterate through Object tree and call callback for each leaf callback call order is - leafs first then root
29,986
public IStack < Object > tierOneUp ( boolean newStack ) { ++ tier ; IStack < Object > result ; if ( newStack || tierStack . size ( ) == tier ) { if ( logging ) { result = new LogStack < > ( new ProcessStack < > ( ) , System . out ) ; } else { result = new ProcessStack < > ( ) ; } tierStack . add ( result ) ; } else { result = getTierStack ( ) ; } return result ; }
get Stack of the next tier if no exist get a new one .
29,987
protected IStack < Object > removeTierStack ( ) { IStack < Object > result = tierStack . remove ( tier ) ; -- tier ; return result ; }
remove tierStack . Remove a tier .
29,988
public Primitive getPrimitiveVariable ( Object key ) { Primitive object = null ; for ( int i = working . size ( ) - 1 ; i >= 0 ; -- i ) { Map < Object , Object > map = working . get ( i ) ; object = ( Primitive ) map . get ( key ) ; if ( object != null ) break ; } if ( object == null ) object = ( Primitive ) global . get ( key ) ; return object ; }
get a Primitive variable first from the highest block hierarchy down to the global variables
29,989
public Object getVariable ( Object key ) { Object object = null ; for ( int i = working . size ( ) - 1 ; i >= 0 ; -- i ) { Map < Object , Object > map = working . get ( i ) ; object = map . get ( key ) ; if ( object != null ) break ; } if ( object == null ) object = global . get ( key ) ; return object ; }
get a variable first from the highest block hierarchy down to the global variables .
29,990
public boolean setVariable ( Object key , Object value ) { boolean success = false ; Object object = null ; for ( int i = working . size ( ) - 1 ; i >= 0 ; -- i ) { Map < Object , Object > map = working . get ( i ) ; object = map . get ( key ) ; if ( object != null ) { map . put ( key , value ) ; success = true ; break ; } } if ( ! success ) { object = global . get ( key ) ; if ( object != null ) { global . put ( key , value ) ; success = true ; } } return success ; }
set an already defined variable first from the highest block hierarchy down to the global variables .
29,991
public boolean setNewVariable ( Object key , Object value ) { boolean success = false ; success = setLocalVariable ( key , value ) ; if ( ! success ) { setGlobalVariable ( key , value ) ; success = true ; } return success ; }
set a new variable on the highest block hierarchy or global if no hierarchy exists .
29,992
public boolean setLocalVariable ( Object key , Object value ) { boolean success = false ; if ( working . size ( ) > 0 ) { Map < Object , Object > map = working . get ( working . size ( ) - 1 ) ; map . put ( key , value ) ; success = true ; } return success ; }
set a new local variable on the highest block hierarchy .
29,993
public boolean removeLastBlockVariableMap ( ) { boolean success = false ; if ( testing ) { success = true ; } else { if ( working . size ( ) > 0 ) { if ( working . remove ( working . size ( ) - 1 ) != null ) success = true ; } } return success ; }
remove the last block hierarchy variable map .
29,994
public boolean restoreLastMapFromArchive ( ) { boolean success = false ; List < Map < Object , Object > > object = null ; if ( oldBlockHierarchy . size ( ) > 0 ) { object = oldBlockHierarchy . remove ( oldBlockHierarchy . size ( ) - 1 ) ; if ( object != null ) { working = object ; success = true ; } } return success ; }
restore the last block hierarchy variable map from archive to working .
29,995
public synchronized ExtendedLogger createFileLogger ( String addOnId , String level ) { try { LoggerContext ctx = LogManager . getContext ( false ) ; Configuration config = ( ( org . apache . logging . log4j . core . LoggerContext ) ctx ) . getConfiguration ( ) ; Layout layout = PatternLayout . createLayout ( "%d %-5p [%t] %C{10} (%F:%L) - %m%n" , config , null , null , true , false , null , null ) ; Appender fileAppender = FileAppender . createAppender ( "logs" + File . separator + addOnId + ".log" , "true" , "false" , "file" , "true" , "false" , "false" , "4000" , layout , null , "false" , null , config ) ; fileAppender . start ( ) ; config . addAppender ( fileAppender ) ; Appender consoleAppender = ConsoleAppender . createAppender ( layout , null , "SYSTEM_OUT" , "console" , null , null ) ; consoleAppender . start ( ) ; config . addAppender ( consoleAppender ) ; AppenderRef fileRef = AppenderRef . createAppenderRef ( "file" , Level . DEBUG , null ) ; AppenderRef consoleRef = AppenderRef . createAppenderRef ( "console" , Level . DEBUG , null ) ; AppenderRef [ ] refs = new AppenderRef [ ] { fileRef , consoleRef } ; LoggerConfig loggerConfig = LoggerConfig . createLogger ( "false" , Level . DEBUG , addOnId , "true" , refs , null , config , null ) ; loggerConfig . addAppender ( fileAppender , Level . DEBUG , null ) ; loggerConfig . addAppender ( consoleAppender , Level . DEBUG , null ) ; config . addLogger ( addOnId , loggerConfig ) ; ( ( org . apache . logging . log4j . core . LoggerContext ) ctx ) . updateLoggers ( ) ; ctx . getLogger ( addOnId ) ; ExtendedLogger logger = ctx . getLogger ( addOnId ) ; return logger ; } catch ( Exception e ) { fileLogger . error ( "Unable to create FileLogger" , e ) ; return null ; } }
Creates a new file - logger for an addOn . The logger will log to a file with the addOnId as name in the logs folder of Izou
29,996
public void setDefault ( String category , String key , String value ) { if ( this . hasProperty ( category , key ) ) return ; this . setProperty ( category , key , value ) ; }
Sets the property unless it already had a value
29,997
public boolean hasProperty ( String category , String key ) { return this . categories . containsKey ( category ) && this . categories . get ( category ) . containsKey ( key ) ; }
Checks whether the specified key is present in the specified category
29,998
public String getProperty ( String category , String key , String defaultValue ) { category = ( this . compressedSpaces ? category . replaceAll ( "\\s+" , " " ) : category ) . trim ( ) ; if ( Strings . isNullOrEmpty ( category ) ) category = "Main" ; key = ( this . compressedSpaces ? key . replaceAll ( "\\s+" , " " ) : key ) . trim ( ) . replace ( " " , "_" ) ; try { return this . categories . get ( category ) . get ( key ) . replace ( "_" , " " ) ; } catch ( NullPointerException e ) { return defaultValue ; } }
Gets a property
29,999
protected void detectHandlerMethods ( ) { processAtmostRequestMappingInfo ( ) ; try { registerNativeFunctionHandlers ( handlerMappingInfoStorage . getHandlerMappingInfos ( ) , NativeFunctionResponseBodyHandler . class ) ; registerNativeFunctionHandlers ( handlerMappingInfoStorage . getHandlerWithViewMappingInfos ( ) , NativeFunctionModelAndViewHandler . class ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } }
read user - defined javascript files in configured directory and register handler methods in those files as Spring MVC handler .