idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
136,900
private int readInt ( ) throws IOException { latestRead = ( int ) SerializationUtils . readIntegerType ( input , WriterImpl . INT_BYTE_SIZE , true , input . useVInts ( ) ) ; return latestRead ; }
Read an int value from the stream .
136,901
public static boolean needsSymbolData ( ObjectCreationExpr n ) { final SymbolType st = symbolDataType ( n ) ; return st == null || ! st . isLoadedAnonymousClass ( ) ; }
For anonymous creations the initial symbol data is symbol data of super class . That needs to be replaced with symbol data of anonymous class . If we don t have symbol data we assume we need one . ; - )
136,902
public void setFieldNames ( List < String > fieldNames ) { this . fieldNames = fieldNames ; if ( fields . length != fieldNames . size ( ) ) { Object [ ] oldFields = fields ; fields = new Object [ fieldNames . size ( ) ] ; System . arraycopy ( oldFields , 0 , fields , 0 , Math . min ( oldFields . length , fieldNames . s...
Change the names and number of fields in the struct . No effect if the number of fields is the same . The old field values are copied to the new array .
136,903
public boolean isSkipLine ( String line ) { return skipLinePattern != null && line != null && skipLinePattern . matcher ( line ) . matches ( ) ; }
Tells if the given content line must be skipped according to this header definition . The header is outputted after any skipped line if any pattern defined on this point or on the first line if not pattern defined .
136,904
public boolean isFirstHeaderLine ( String line ) { return firstLineDetectionPattern != null && line != null && firstLineDetectionPattern . matcher ( line ) . matches ( ) ; }
Tells if the given content line is the first line of a possible header of this definition kind .
136,905
public boolean isLastHeaderLine ( String line ) { return lastLineDetectionPattern != null && line != null && lastLineDetectionPattern . matcher ( line ) . matches ( ) ; }
Tells if the given content line is the last line of a possible header of this definition kind .
136,906
public void validate ( ) { check ( "firstLine" , this . firstLine ) ; check ( "beforeEachLine" , this . beforeEachLine ) ; check ( "endLine" , this . endLine ) ; check ( "firstLineDetectionPattern" , this . firstLineDetectionPattern ) ; check ( "lastLineDetectionPattern" , this . lastLineDetectionPattern ) ; check ( "i...
Checks this header definition consistency in other words if all the mandatory properties of the definition have been set .
136,907
protected DestroyableManager configureManager ( final DestroyableManager manager ) { bind ( DestroyableManager . class ) . toInstance ( manager ) ; Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( manager ) ) ; return manager ; }
Registers destroyable manager in injector and adds shutdown hook to process destroy on jvm shutdown .
136,908
public static void skip32 ( byte [ ] key , int [ ] buf , boolean encrypt ) { int k ; int i ; int kstep ; int wl , wr ; if ( encrypt ) { kstep = 1 ; k = 0 ; } else { kstep = - 1 ; k = 23 ; } wl = ( buf [ 0 ] << 8 ) + buf [ 1 ] ; wr = ( buf [ 2 ] << 8 ) + buf [ 3 ] ; for ( i = 0 ; i < 24 / 2 ; ++ i ) { wr ^= g ( key , k ...
Applies the SKIP32 function on the provided value stored in buf and modifies it inplace . This is a low - level function used by the encrypt and decrypt functions .
136,909
public static int encrypt ( int value , byte [ ] key ) { int [ ] buf = new int [ 4 ] ; buf [ 0 ] = ( ( value >> 24 ) & 0xff ) ; buf [ 1 ] = ( ( value >> 16 ) & 0xff ) ; buf [ 2 ] = ( ( value >> 8 ) & 0xff ) ; buf [ 3 ] = ( ( value >> 0 ) & 0xff ) ; skip32 ( key , buf , true ) ; int out = ( ( buf [ 0 ] ) << 24 ) | ( ( b...
Encrypts the provided value using the specified key
136,910
public static int decrypt ( int value , byte [ ] key ) { int [ ] buf = new int [ 4 ] ; buf [ 0 ] = ( ( value >> 24 ) & 0xff ) ; buf [ 1 ] = ( ( value >> 16 ) & 0xff ) ; buf [ 2 ] = ( ( value >> 8 ) & 0xff ) ; buf [ 3 ] = ( ( value >> 0 ) & 0xff ) ; skip32 ( key , buf , false ) ; int out = ( ( buf [ 0 ] ) << 24 ) | ( ( ...
Decrypts the provided value using the specified key
136,911
public static Object toBasicType ( String value , String type ) throws SQLException { if ( value == null ) { return null ; } if ( type == null || type . equals ( String . class . getName ( ) ) ) { return value ; } if ( type . equals ( Integer . class . getName ( ) ) || type . equals ( int . class . getName ( ) ) ) { tr...
Transforms the given value to an instance of the given type .
136,912
public static void throwSQLException ( Exception cause , String theType , String value ) throws SQLException { throw new SQLException ( "Invalid " + theType + " value: " + value , cause ) ; }
An helper method to build and throw a SQL Exception when a property cannot be set .
136,913
protected final void bindPropertiesWithOverrides ( final String propertyFile ) { checkNotNull ( propertyFile , "classpath resource property file must not be null" ) ; Properties properties = new Properties ( ) ; InputStream inputStream = getClass ( ) . getResourceAsStream ( propertyFile ) ; if ( inputStream != null ) {...
Bind properties from the specified classpath resource property file overriding those values with system properties and with environment variables after replacing key underscores _ by dots . .
136,914
protected static final boolean looksLikeAnnotationName ( final String name ) { return name . startsWith ( "org.nmdp" ) && Character . isUpperCase ( name . charAt ( name . lastIndexOf ( "." ) + 1 ) ) ; }
Return true if the specified property name looks like an annotation name .
136,915
@ SuppressWarnings ( "unchecked" ) protected static final < A extends Annotation > Class < A > annotation ( final String annotationClassName ) { try { return ( Class < A > ) Class . forName ( annotationClassName ) ; } catch ( ClassNotFoundException e ) { throw new ProvisionException ( format ( "could not create annotat...
Return an instance of an annotation with the specified class name .
136,916
@ SuppressWarnings ( "unchecked" ) public static Optional < AlexaIntentHandler > createHandler ( final AlexaInput input ) { try { final Class factoryImpl = Class . forName ( FACTORY_PACKAGE + "." + FACTORY_CLASS_NAME ) ; final Method method = factoryImpl . getMethod ( FACTORY_METHOD_NAME , AlexaInput . class ) ; final ...
Constructs the AlexaIntentHandler which is tagged with the AlexaIntentListener - annotation . If more than one handler for an intent is found it returns the one whose verify - method returns true . If even then there s more than one handler the one with the highest priority wins ( you set the priority of an AlexaIntent...
136,917
public void setLogFileDir ( String logDirName ) { File logDir = new File ( logDirName ) ; if ( ! logDir . isAbsolute ( ) ) { logDir = new File ( serverBaseDir , logDirName ) ; } this . logFileDir = logDirName ; if ( started ) { configuration . setLogFileDir ( logDir . getAbsolutePath ( ) ) ; } }
Sets the log dir .
136,918
public void start ( ) throws Exception { started = true ; setLogFileDir ( logFileDir ) ; LOGGER . debug ( "Initiating transaction manager recovery" ) ; recovered = new HashMap < > ( ) ; logger . open ( null ) ; ReplayListener replayListener = new GeronimoReplayListener ( xidFactory , recovered ) ; logger . replayActive...
Starts the logger .
136,919
public Object prepare ( Xid xid , List < ? extends TransactionBranchInfo > branches ) throws LogException { int branchCount = branches . size ( ) ; byte [ ] [ ] data = new byte [ 3 + 2 * branchCount ] [ ] ; data [ 0 ] = intToBytes ( xid . getFormatId ( ) ) ; data [ 1 ] = xid . getGlobalTransactionId ( ) ; data [ 2 ] = ...
Prepares a transaction
136,920
public void commit ( Xid xid , Object logMark ) throws LogException { byte [ ] [ ] data = new byte [ 4 ] [ ] ; data [ 0 ] = new byte [ ] { COMMIT } ; data [ 1 ] = intToBytes ( xid . getFormatId ( ) ) ; data [ 2 ] = xid . getGlobalTransactionId ( ) ; data [ 3 ] = xid . getBranchQualifier ( ) ; try { logger . putDone ( d...
Commits a transaction
136,921
protected final Allele loadAllele ( final String glstring , final String accession ) throws IOException { final String id = glstringResolver . resolveAllele ( glstring ) ; Allele allele = idResolver . findAllele ( id ) ; if ( allele == null ) { Matcher m = ALLELE_PATTERN . matcher ( glstring ) ; if ( m . matches ( ) ) ...
Load and register the specified allele in GL String format .
136,922
protected Elements getFirst ( Elements elems ) { @ SuppressWarnings ( "unchecked" ) IterableElements < Elements > iterableElems = elems . as ( IterableElements . class ) ; return Iterables . getFirst ( iterableElems , null ) ; }
Gets the first .
136,923
protected boolean triggerReverse ( Type type , Throwable e ) { return trigger ( Lists . reverse ( getAllListeners ( ) ) , type , e ) ; }
Trigger reverse .
136,924
public DataSource createDataSource ( Properties props ) throws SQLException { if ( props == null ) { props = new Properties ( ) ; } DataSource dataSource = newDataSource ( ) ; setBeanProperties ( dataSource , props ) ; return dataSource ; }
Creates a DataSource object .
136,925
public ConnectionPoolDataSource createConnectionPoolDataSource ( Properties props ) throws SQLException { if ( props == null ) props = new Properties ( ) ; ConnectionPoolDataSource dataSource = newConnectionPoolDataSource ( ) ; setBeanProperties ( dataSource , props ) ; return dataSource ; }
Create a ConnectionPoolDataSource object .
136,926
public XADataSource createXADataSource ( Properties props ) throws SQLException { if ( props == null ) props = new Properties ( ) ; XADataSource dataSource = newXADataSource ( ) ; setBeanProperties ( dataSource , props ) ; return dataSource ; }
Creates an XADataSource object .
136,927
public Driver createDriver ( Properties props ) throws SQLException { Driver driver = newJdbcDriver ( ) ; setBeanProperties ( driver , props ) ; return driver ; }
Creates a new JDBC Driver instance .
136,928
static void setBeanProperties ( Object object , Properties props ) throws SQLException { if ( props != null ) { Enumeration < ? > enumeration = props . keys ( ) ; while ( enumeration . hasMoreElements ( ) ) { String name = ( String ) enumeration . nextElement ( ) ; setProperty ( object , name , props . getProperty ( na...
Sets the given properties on the target object .
136,929
public String nextToken ( String separators ) { separator = 0 ; if ( peek != null ) { String tmp = peek ; peek = null ; return tmp ; } if ( index == string . length ( ) ) { return null ; } StringBuilder sb = new StringBuilder ( ) ; boolean hadstring = false ; boolean validspace = false ; while ( index < string . length...
Retrieve next token .
136,930
private EntityManager getEM ( ) throws IllegalStateException { if ( ! open ) { throw new IllegalStateException ( "The JPA bridge has closed" ) ; } try { EntityManager em = perThreadEntityManager . get ( ) ; if ( em != null ) { return em ; } final Transaction transaction = transactionManager . getTransaction ( ) ; if ( ...
The delegated methods call this method to get the delegate . This method verifies if we re still open if there already is an Entity Manager for this thread and otherwise creates it and enlists it for auto close at the current transaction .
136,931
public OutputSpeech getOutputSpeech ( ) { if ( outputSpeech != null ) { return outputSpeech ; } final String utterance ; try { utterance = yamlReader . getRandomUtterance ( output ) . orElseThrow ( IOException :: new ) ; LOG . debug ( "Random utterance read out from YAML file: " + utterance ) ; } catch ( IOException e ...
Gets the generated output speech .
136,932
public Reprompt getReprompt ( ) { if ( reprompt != null || ! output . shouldReprompt ( ) ) { return reprompt ; } final String repromptSpeech = yamlReader . getRandomReprompt ( output ) . orElse ( null ) ; if ( repromptSpeech != null ) { final String utteranceSsml = resolveSlotsInUtterance ( repromptSpeech ) ; final Ssm...
Gets the generated reprompt .
136,933
private Transaction getActiveTransaction ( ) throws SystemException { Transaction tx = manager . getTransaction ( ) ; if ( tx != null && tx . getStatus ( ) != Status . STATUS_NO_TRANSACTION ) { return tx ; } else { return null ; } }
Checks whether or not we have an active transaction . If so returns it .
136,934
public void onEntry ( Propagation propagation , int timeout , String interceptionId ) throws SystemException , NotSupportedException , RollbackException { Transaction transaction = getActiveTransaction ( ) ; switch ( propagation ) { case REQUIRES : if ( transaction == null ) { if ( timeout > 0 ) { manager . setTransact...
Enters a transactional bloc .
136,935
public void onExit ( Propagation propagation , String interceptionId , TransactionCallback callback ) throws HeuristicRollbackException , HeuristicMixedException , SystemException , InvalidTransactionException { Transaction current = getActiveTransaction ( ) ; if ( callback == null ) { callback = new TransactionCallbac...
Leaves a transactional bloc . This method decides what do to with the current transaction . This includes committing or resuming a transaction .
136,936
public void onError ( Exception e , Propagation propagation , Class < ? extends Exception > [ ] noRollbackFor , Class < ? extends Exception > [ ] rollbackFor , String interceptionId , TransactionCallback callback ) throws SystemException , HeuristicRollbackException , HeuristicMixedException , InvalidTransactionExcepti...
A transactional bloc has thrown an exception . This method decides what needs to be done in that case .
136,937
public static < T extends AlexaSpeechlet > T createSpeechletFromRequest ( final byte [ ] serializedSpeechletRequest , final Class < T > speechletClass , final UtteranceReader utteranceReader ) throws IOException { final ObjectMapper mapper = new ObjectMapper ( ) ; final JsonNode parser = mapper . readTree ( serializedS...
Creates an AlexaSpeechlet from bytes of a speechlet request . It will extract the locale from the request and uses it for creating a new instance of AlexaSpeechlet
136,938
public String build ( ) { if ( locus == null && tree . isEmpty ( ) ) { throw new IllegalStateException ( "must call locus(String) or allele(String) at least once" ) ; } if ( tree . isEmpty ( ) ) { return locus ; } String glstring = tree . toString ( ) ; char last = glstring . charAt ( glstring . length ( ) - 1 ) ; if (...
Build and return a new GL String configured from the properties of this GL String builder .
136,939
public Path download ( Appcast appcast , Path targetDir ) throws IOException , Exception { Path downloaded = null ; Enclosure enclosure = appcast . getLatestEnclosure ( ) ; if ( enclosure != null ) { String url = enclosure . getUrl ( ) ; if ( url != null && ! url . isEmpty ( ) ) { URL enclosureUrl = new URL ( url ) ; S...
Download the file from the given URL to the specified target
136,940
private Stream < Object > flatten ( final Object o ) { if ( o instanceof Map < ? , ? > ) { return ( ( Map < ? , ? > ) o ) . values ( ) . stream ( ) . flatMap ( this :: flatten ) ; } return Stream . of ( o ) ; }
Recursively go along yaml nodes beneath the given one to flatten string values
136,941
protected List < File > findEntityClassFiles ( ) throws MojoExecutionException { try { return FileUtils . getFiles ( classes , includes , excludes ) ; } catch ( IOException e ) { throw new MojoExecutionException ( "Error while scanning for '" + includes + "' in " + "'" + classes . getAbsolutePath ( ) + "'." , e ) ; } }
Locates and returns a list of class files found under specified class directory .
136,942
protected Options getOptions ( ) throws MojoExecutionException { File persistence = ensurePersistenceXml ( ) ; Options opts = new Options ( ) ; if ( toolProperties != null ) { opts . putAll ( toolProperties ) ; } opts . put ( OPTION_PROPERTIES_FILE , persistence . getAbsolutePath ( ) ) ; if ( connectionDriverName != nu...
Get the options for the OpenJPA enhancer tool .
136,943
private void enhance ( List < File > files ) throws MojoExecutionException { Options opts = getOptions ( ) ; String [ ] args = getFilePaths ( files ) ; boolean ok ; final ClassLoader original = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { if ( ! tmpClassLoader ) { extendRealmClasspath ( ) ; } ok = PCE...
Processes a list of class file resources that are to be enhanced .
136,944
protected void handleAlert ( Alert alert ) { if ( LOGGEER . isDebugEnabled ( ) ) { LOGGEER . debug ( "Accepting alert box with message: {}" , alert . getText ( ) ) ; } alert . accept ( ) ; }
by default we accept the alert
136,945
public static Path update ( Path applicationFile , Path updateDir , boolean removeUpdateFiles ) throws IOException { Path newApplicationJar = null ; String applicationName = applicationFile . getFileName ( ) . toString ( ) ; applicationName = applicationName . substring ( 0 , applicationName . lastIndexOf ( "." ) ) ; A...
Update the application file with the content from the update directory .
136,946
protected WebElement getFirstElement ( Elements elems ) { DocumentWebElement documentWebElement = Iterables . getFirst ( elems . as ( InternalWebElements . class ) . wrappedNativeElements ( ) , null ) ; return documentWebElement == null ? null : documentWebElement . getWrappedWebElement ( ) ; }
Gets the first element .
136,947
public < R > FluentTransaction < R > . Intermediate transaction ( Callable < R > callable ) { return FluentTransaction . transaction ( getTransactionManager ( ) ) . with ( callable ) ; }
Create a FluentTransaction with the given transaction block .
136,948
public T findOne ( final I id ) { return inTransaction ( new Callable < T > ( ) { public T call ( ) throws Exception { return entityManager . find ( entity , id ) ; } } ) ; }
Retrieves an entity by its id .
136,949
public Iterable < T > findAll ( ) { return inTransaction ( new Callable < Iterable < T > > ( ) { public Iterable < T > call ( ) throws Exception { CriteriaQuery < T > cq = entityManager . getCriteriaBuilder ( ) . createQuery ( entity ) ; Root < T > pet = cq . from ( entity ) ; cq . select ( pet ) ; return entityManager...
Returns all instances of the entity .
136,950
public T findOne ( EntityFilter < T > filter ) { for ( T object : findAll ( ) ) { if ( filter . accept ( object ) ) { return object ; } } return null ; }
Retrieves the entity matching the given filter . If several entities matches the first is returned .
136,951
public Iterable < T > findAll ( Iterable < I > ids ) { List < T > results = new ArrayList < > ( ) ; for ( I id : ids ) { T t = findOne ( id ) ; if ( t != null ) { results . add ( t ) ; } } return results ; }
Returns all instances of the type with the given IDs .
136,952
public Iterable < T > findAll ( EntityFilter < T > filter ) { List < T > results = new ArrayList < > ( ) ; for ( T object : findAll ( ) ) { if ( filter . accept ( object ) ) { results . add ( object ) ; } } return results ; }
Retrieves the entities matching the given filter . Be aware that the implementation may load all stored entities in memory to retrieve the right set of entities .
136,953
public T delete ( final T t ) { return inTransaction ( new Callable < T > ( ) { public T call ( ) throws Exception { T attached = getAttached ( t ) ; if ( attached != null ) { entityManager . remove ( attached ) ; } return t ; } } ) ; }
Deletes the given entity instance . The instance is removed from the persistent layer .
136,954
@ SuppressWarnings ( "unchecked" ) private T getAttached ( T object ) { if ( entityManager . contains ( object ) ) { return object ; } else { return findOne ( ( I ) entityManager . getEntityManagerFactory ( ) . getPersistenceUnitUtil ( ) . getIdentifier ( object ) ) ; } }
Gets the managed version of the given entity instance .
136,955
public Iterable < T > delete ( final Iterable < T > entities ) { return inTransaction ( new Callable < Iterable < T > > ( ) { public Iterable < T > call ( ) throws Exception { for ( T object : entities ) { T attached = getAttached ( object ) ; if ( attached != null ) { entityManager . remove ( attached ) ; } } return e...
Deletes the given entity instances . The instances are removed from the persistent layer .
136,956
public Iterable < T > save ( final Iterable < T > entities ) { return inTransaction ( new Callable < Iterable < T > > ( ) { public Iterable < T > call ( ) throws Exception { for ( T object : entities ) { entityManager . persist ( object ) ; } return entities ; } } ) ; }
Saves all given entities . Use the returned instances for further operations as the operation might have changed the entity instances completely .
136,957
private ComponentInstance createUnitInstance ( Persistence . PersistenceUnit unit ) throws MissingHandlerException , UnacceptableConfiguration , ConfigurationException { LOGGER . info ( "Creating persistence unit instance for unit {}" , unit . getName ( ) ) ; Dictionary < String , Object > configuration = new Hashtable...
Creates the component instance for the given unit . This function computes the filters to retrieve the data sources . If a data source is not set in inject a filter that will never match .
136,958
public boolean hasSlot ( final String slotName ) { return intentRequest != null && intentRequest . getIntent ( ) . getSlots ( ) . containsKey ( slotName ) ; }
Checks if a slot is contained in the intent request . This is no guarantee that the slot value is not null .
136,959
public boolean hasSlotIsEqual ( final String slotName , final String value ) { final String slotValue = getSlotValue ( slotName ) ; return ( slotValue != null && slotValue . equals ( value ) ) || slotValue == value ; }
Checks if a slot is contained in the intent request and also got the value provided .
136,960
public boolean hasSlotIsDoubleMetaphoneEqual ( final String slotName , final String value ) { final String slotValue = getSlotValue ( slotName ) ; return hasSlotNotBlank ( slotName ) && value != null && new DoubleMetaphone ( ) . isDoubleMetaphoneEqual ( slotValue , value ) ; }
Checks if a slot is contained in the intent request and has a value which is a phonetic sibling of the string given to this method . Double metaphone algorithm is optimized for English language and in this case is used to match slot value with value given to this method .
136,961
public boolean hasSlotIsCologneEqual ( final String slotName , final String value ) { final String slotValue = getSlotValue ( slotName ) ; return hasSlotNotBlank ( slotName ) && value != null && new ColognePhonetic ( ) . isEncodeEqual ( slotValue , value ) ; }
Checks if a slot is contained in the intent request and has a value which is a phonetic sibling of the string given to this method . Cologne phonetic algorithm is optimized for German language and in this case is used to match slot value with value given to this method .
136,962
public boolean hasSlotIsPhoneticallyEqual ( final String slotName , final String value ) { return getLocale ( ) . equals ( "de-DE" ) ? hasSlotIsCologneEqual ( slotName , value ) : hasSlotIsDoubleMetaphoneEqual ( slotName , value ) ; }
Checks if a slot is contained in the intent request and has a value which is a phonetic sibling of the string given to this method . This method picks the correct algorithm depending on the locale coming in with the speechlet request . For example the German locale compares the slot value and the given value with the C...
136,963
public boolean hasSlotNotBlank ( final String slotName ) { return hasSlot ( slotName ) && StringUtils . isNotBlank ( intentRequest . getIntent ( ) . getSlot ( slotName ) . getValue ( ) ) ; }
Checks if a slot is contained in the intent request and its value is not blank .
136,964
public boolean hasSlotIsNumber ( final String slotName ) { return hasSlot ( slotName ) && NumberUtils . isNumber ( intentRequest . getIntent ( ) . getSlot ( slotName ) . getValue ( ) ) ; }
Checks if a slot is contained in the intent request and its value is a number .
136,965
public String getSlotValue ( final String slotName ) { return hasSlot ( slotName ) ? intentRequest . getIntent ( ) . getSlot ( slotName ) . getValue ( ) : null ; }
Gets the slot value as a string in case slot exists otherwise null
136,966
public Class < ? extends AlexaSpeechlet > getSpeechlet ( ) { final AlexaApplication app = this . getClass ( ) . getAnnotation ( AlexaApplication . class ) ; return app != null ? app . speechlet ( ) : AlexaSpeechlet . class ; }
Provides the speechlet used to handle the request .
136,967
public void handleRequest ( final InputStream input , final OutputStream output , final Context context ) throws IOException { byte [ ] serializedSpeechletRequest = IOUtils . toByteArray ( input ) ; final AlexaSpeechlet speechlet = AlexaSpeechletFactory . createSpeechletFromRequest ( serializedSpeechletRequest , getSpe...
The handler method is called on a Lambda execution .
136,968
private SpeechletRequestHandler getRequestStreamHandler ( ) { final Set < String > supportedApplicationIds = getSupportedApplicationIds ( ) ; Validate . notEmpty ( supportedApplicationIds , "Must provide supported application-id either with overriding the getter or using AlexaApplication-annotation in " + this . getCla...
Constructs the stream handler giving it all the provided information .
136,969
public static GlClient create ( ) { Injector injector = Guice . createInjector ( getLocalModules ( ) ) ; return injector . getInstance ( GlClient . class ) ; }
Create and return a new instance of LocalGlClient configured with the default nomenclature .
136,970
public static GlClient createStrict ( final Class < ? extends Nomenclature > nomenclatureClass ) throws IOException { checkNotNull ( nomenclatureClass ) ; Injector injector = Guice . createInjector ( getLocalStrictModules ( nomenclatureClass ) ) ; Nomenclature nomenclature = injector . getInstance ( Nomenclature . clas...
Create and return a new instance of LocalGlClient configured in strict mode with the specified nomenclature .
136,971
public static List < AbstractModule > getLocalStrictModules ( final Class < ? extends Nomenclature > nomenclatureClass ) { checkNotNull ( nomenclatureClass ) ; return ImmutableList . of ( new LocalStrictModule ( ) , new CacheModule ( ) , new IdModule ( ) , new AbstractModule ( ) { protected void configure ( ) { bind ( ...
Return the list of modules that configure LocalGlClient in strict mode with the specified nomenclature .
136,972
public Collection < Crud < ? , ? > > getCrudServices ( ) { List < Crud < ? , ? > > list = new ArrayList < > ( ) ; list . addAll ( cruds ) ; return list ; }
Gets the list of Crud service managed by the current repository .
136,973
public void dispose ( ) { for ( ServiceRegistration registration : registrations ) { registration . unregister ( ) ; } registrations . clear ( ) ; for ( AbstractJTACrud crud : cruds ) { crud . dispose ( ) ; } }
Stops the repository . It un - registers all crud services .
136,974
public GlResourceBuilder reset ( ) { alleles . clear ( ) ; alleleLists . clear ( ) ; haplotypes . clear ( ) ; genotypes . clear ( ) ; genotypeLists . clear ( ) ; locus = null ; allele = null ; alleleList = null ; haplotype = null ; genotype = null ; genotypeList = null ; return this ; }
Return this gl resource builder with its configuration reset .
136,975
public void start ( ) { try { Map < String , Object > map = new HashMap < > ( ) ; for ( Persistence . PersistenceUnit . Properties . Property p : persistenceUnitXml . getProperties ( ) . getProperty ( ) ) { map . put ( p . getName ( ) , p . getValue ( ) ) ; } if ( isOpenJPA ( ) ) { map . put ( "openjpa.ManagedRuntime" ...
Starts the unit . It creates the entity manager factory and entity manager as well as the repository and crud services .
136,976
public ClassLoader getNewTempClassLoader ( ) { return new ClassLoader ( getClassLoader ( ) ) { protected Class findClass ( String className ) throws ClassNotFoundException { String path = className . replace ( '.' , '/' ) . concat ( ".class" ) ; URL resource = getParent ( ) . getResource ( path ) ; if ( resource == nul...
In this method we just create a simple temporary class loader . This class loader uses the bundle s class loader as parent but defines the classes in this class loader . This has the implicit assumption that the temp class loader is used BEFORE any bundle s classes are loaded since a class loader does parent delegation...
136,977
public Xid createXid ( ) { byte [ ] globalId = baseId . clone ( ) ; long id ; synchronized ( this ) { id = count ++ ; } insertLong ( id , globalId , 0 ) ; return new XidImpl ( globalId ) ; }
Creates the Xid .
136,978
public Xid createBranch ( Xid globalId , int branch ) { byte [ ] branchId = baseId . clone ( ) ; branchId [ 0 ] = ( byte ) branch ; branchId [ 1 ] = ( byte ) ( branch >>> 8 ) ; branchId [ 2 ] = ( byte ) ( branch >>> 16 ) ; branchId [ 3 ] = ( byte ) ( branch >>> 24 ) ; insertLong ( start , branchId , 4 ) ; return new Xi...
Create a branch Xid .
136,979
public boolean matchesGlobalId ( byte [ ] globalTransactionId ) { if ( globalTransactionId . length != Xid . MAXGTRIDSIZE ) { return false ; } for ( int i = 8 ; i < globalTransactionId . length ; i ++ ) { if ( globalTransactionId [ i ] != baseId [ i ] ) { return false ; } } long id = extractLong ( globalTransactionId ,...
Checks whether or not the given byte array matches the global id .
136,980
public boolean matchesBranchId ( byte [ ] branchQualifier ) { if ( branchQualifier . length != Xid . MAXBQUALSIZE ) { return false ; } long id = extractLong ( branchQualifier , 4 ) ; if ( id >= start ) { return false ; } for ( int i = 12 ; i < branchQualifier . length ; i ++ ) { if ( branchQualifier [ i ] != baseId [ i...
Checks whether or not the given byte array matches the branch id .
136,981
public static boolean isPackageInstalled ( Context context , String packageName ) { try { context . getPackageManager ( ) . getApplicationInfo ( packageName , 0 ) ; return true ; } catch ( Exception e ) { return false ; } }
Checks if a package is installed .
136,982
public static String getBaseActivityClassName ( Context context ) { ComponentName activity = getBaseActivity ( context ) ; if ( activity == null ) { return null ; } return activity . getClassName ( ) ; }
Returns Class name of base activity
136,983
public static String getTopActivityPackageName ( Context context ) { ComponentName activity = getTopActivity ( context ) ; if ( activity == null ) { return null ; } return activity . getPackageName ( ) ; }
Returns Package name of top activity
136,984
public static String getTopActivityClassName ( Context context ) { ComponentName activity = getTopActivity ( context ) ; if ( activity == null ) { return null ; } return activity . getClassName ( ) ; }
Returns Class name of top activity
136,985
public static boolean isTopApplication ( Context context ) { ComponentName activity = getTopActivity ( context ) ; if ( activity == null ) { return false ; } return activity . getPackageName ( ) . equals ( context . getApplicationInfo ( ) . packageName ) ; }
Determines if this application is top activity
136,986
public static boolean isContextForeground ( Context context ) { ActivityManager activityManager = ( ActivityManager ) context . getSystemService ( Context . ACTIVITY_SERVICE ) ; List < RunningAppProcessInfo > appProcesses = activityManager . getRunningAppProcesses ( ) ; int pid = getPid ( ) ; for ( RunningAppProcessInf...
Checks if this application is foreground
136,987
public DeviceType getDeviceType ( Context activityContext ) { boolean xlarge = ( ( activityContext . getResources ( ) . getConfiguration ( ) . screenLayout & Configuration . SCREENLAYOUT_SIZE_MASK ) == SCREENLAYOUT_SIZE_XLARGE ) ; if ( xlarge ) { DisplayMetrics metrics = new DisplayMetrics ( ) ; Activity activity = ( A...
Checks if the device is a tablet or a phone
136,988
public static int getCurrentVolume ( Context context ) { AudioManager mAudioManager = ( AudioManager ) context . getSystemService ( Context . AUDIO_SERVICE ) ; return mAudioManager . getStreamVolume ( AudioManager . STREAM_MUSIC ) ; }
Returns current media volume
136,989
public static int getMaximumVolume ( Context context ) { return ( ( AudioManager ) context . getSystemService ( Context . AUDIO_SERVICE ) ) . getStreamMaxVolume ( AudioManager . STREAM_MUSIC ) ; }
Returns maximum volume the media volume can have
136,990
private void registerConnectivityReceiver ( ) { IntentFilter intentFilter = new IntentFilter ( ) ; intentFilter . addAction ( ConnectivityManager . CONNECTIVITY_ACTION ) ; context . registerReceiver ( connectivityReceiver , intentFilter ) ; }
Registers receiver to be notified of broadcast event when network connection changes
136,991
public boolean isWifiFake ( String ipAddress , int port ) { SocketChannel socketChannel = null ; try { socketChannel = SocketChannel . open ( ) ; socketChannel . connect ( new InetSocketAddress ( ipAddress , port ) ) ; } catch ( IOException e ) { Log . d ( TAG , "Current Wifi is stupid!!! by IOException" ) ; return tru...
Checks if currently connected Access Point is either rogue or incapable of routing packet
136,992
public final Object instantiateItem ( final ViewGroup container , final int position ) { if ( Constants . DEBUG ) { Log . i ( "InfiniteViewPager" , String . format ( "instantiating position %s" , position ) ) ; } final PageModel < T > model = createPageModel ( position ) ; mPageModels [ position ] = model ; container ....
This method is only called when this pagerAdapter is initialized .
136,993
private void printPageModels ( final String tag ) { for ( int i = 0 ; i < PAGE_COUNT ; i ++ ) { printPageModel ( tag , mPageModels [ i ] , i ) ; } }
Debug related methods
136,994
public final Position predict ( double distanceKm , double courseDegrees ) { assertWithMsg ( alt == 0.0 , "Predictions only valid for Earth's surface" ) ; double dr = distanceKm / EARTH_RADIUS_KM ; double latR = toRadians ( lat ) ; double lonR = toRadians ( lon ) ; double courseR = toRadians ( courseDegrees ) ; double ...
Predicts position travelling along a great circle arc based on the Haversine formula .
136,995
public final double getBearingDegrees ( Position position ) { double lat1 = toRadians ( lat ) ; double lat2 = toRadians ( position . lat ) ; double lon1 = toRadians ( lon ) ; double lon2 = toRadians ( position . lon ) ; double dLon = lon2 - lon1 ; double sinDLon = sin ( dLon ) ; double cosLat2 = cos ( lat2 ) ; double y...
Returns a great circle bearing in degrees in the range 0 to 360 .
136,996
public static double getBearingDifferenceDegrees ( double bearing1 , double bearing2 ) { if ( bearing1 < 0 ) bearing1 += 360 ; if ( bearing2 > 180 ) bearing2 -= 360 ; double result = bearing1 - bearing2 ; if ( result > 180 ) result -= 360 ; return result ; }
returns difference in degrees in the range - 180 to 180
136,997
public final Position getPositionAlongPath ( Position position , double proportion ) { if ( proportion >= 0 && proportion <= 1 ) { double courseDegrees = this . getBearingDegrees ( position ) ; double distanceKm = this . getDistanceToKm ( position ) ; Position retPosition = this . predict ( proportion * distanceKm , co...
Returns a position along a path according to the proportion value
136,998
public static double longitudeDiff ( double a , double b ) { a = to180 ( a ) ; b = to180 ( b ) ; return Math . abs ( to180 ( a - b ) ) ; }
Returns the difference between two longitude values . The returned value is always > = 0 .
136,999
public static double to180 ( double d ) { if ( d < 0 ) return - to180 ( abs ( d ) ) ; else { if ( d > 180 ) { long n = round ( floor ( ( d + 180 ) / 360.0 ) ) ; return d - n * 360 ; } else return d ; } }
Converts an angle in degrees to range - 180< x < = 180 .