idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
10,700 | public static String getInstance ( Date startDate , Granularity startGran , Date endDate , Granularity endGran ) { ActiveStatusCodeStartDate codeStartDate ; if ( startDate == null ) { codeStartDate = ActiveStatusCodeStartDate . UNKNOWN ; } else if ( startGran == AbsoluteTimeGranularity . YEAR ) { codeStartDate = ActiveStatusCodeStartDate . YEAR ; } else if ( startGran == AbsoluteTimeGranularity . MONTH ) { codeStartDate = ActiveStatusCodeStartDate . MONTH ; } else if ( startGran == AbsoluteTimeGranularity . DAY ) { codeStartDate = ActiveStatusCodeStartDate . DAY ; } else if ( startGran == AbsoluteTimeGranularity . HOUR ) { codeStartDate = ActiveStatusCodeStartDate . HOUR ; } else if ( startGran == AbsoluteTimeGranularity . MINUTE ) { codeStartDate = ActiveStatusCodeStartDate . MINUTE ; } else if ( startGran == AbsoluteTimeGranularity . SECOND ) { codeStartDate = ActiveStatusCodeStartDate . SECOND ; } else { codeStartDate = ActiveStatusCodeStartDate . NULL ; } ActiveStatusCodeEndDate codeEndDate ; if ( startDate == null ) { codeEndDate = ActiveStatusCodeEndDate . UNKNOWN ; } else if ( startGran == AbsoluteTimeGranularity . YEAR ) { codeEndDate = ActiveStatusCodeEndDate . YEAR ; } else if ( startGran == AbsoluteTimeGranularity . MONTH ) { codeEndDate = ActiveStatusCodeEndDate . MONTH ; } else if ( startGran == AbsoluteTimeGranularity . DAY ) { codeEndDate = ActiveStatusCodeEndDate . DAY ; } else if ( startGran == AbsoluteTimeGranularity . HOUR ) { codeEndDate = ActiveStatusCodeEndDate . HOUR ; } else if ( startGran == AbsoluteTimeGranularity . MINUTE ) { codeEndDate = ActiveStatusCodeEndDate . MINUTE ; } else if ( startGran == AbsoluteTimeGranularity . SECOND ) { codeEndDate = ActiveStatusCodeEndDate . SECOND ; } else { codeEndDate = ActiveStatusCodeEndDate . NULL ; } return codeEndDate . getCode ( ) + codeStartDate . getCode ( ) ; } | Infer the correct active status code given what dates are available and whether or not the encounter information is finalized . |
10,701 | public Launch synchLaunch ( ) throws LaunchException { JobDataMap jobDataMap = new JobDataMap ( ) ; jobDataMap . put ( Launch . PARAMETERS , this . launch . getParameters ( ) ) ; jobDataMap . put ( Launch . DEFAULT_EXECUTOR_KEY , this . launch . getExecutorService ( ) ) ; try { this . launch . synchLaunch ( ) ; } catch ( org . parallelj . launching . LaunchException e ) { throw new LaunchException ( e ) ; } org . parallelj . launching . LaunchResult result = this . launch . getLaunchResult ( ) ; jobDataMap . put ( QuartzUtils . RETURN_CODE , result . getStatusCode ( ) ) ; jobDataMap . put ( QuartzUtils . USER_RETURN_CODE , result . getReturnCode ( ) ) ; jobDataMap . put ( QuartzUtils . PROCEDURES_IN_ERROR , result . getProceduresInError ( ) ) ; jobDataMap . put ( Launch . OUTPUTS , this . launch . getLaunchResult ( ) . getOutputParameters ( ) ) ; this . legacyLaunchResult = new LaunchResult ( launch . getLaunchId ( ) , jobDataMap ) ; return this ; } | Launch a Program and wait until it s terminated . |
10,702 | public Launch aSynchLaunch ( ) throws LaunchException { JobDataMap jobDataMap = new JobDataMap ( ) ; jobDataMap . put ( Launch . PARAMETERS , this . launch . getParameters ( ) ) ; jobDataMap . put ( Launch . DEFAULT_EXECUTOR_KEY , this . launch . getExecutorService ( ) ) ; try { this . launch . aSynchLaunch ( ) ; } catch ( org . parallelj . launching . LaunchException e ) { throw new LaunchException ( e ) ; } this . legacyLaunchResult = new LaunchResult ( launch . getLaunchId ( ) , jobDataMap ) ; return this ; } | Launch a Program and continue . |
10,703 | @ SuppressWarnings ( "unchecked" ) public synchronized Launch addDatas ( final JobDataMap jobDataMap ) { Map < String , Object > data = new HashMap < > ( ) ; for ( String key : jobDataMap . getKeys ( ) ) { data . put ( key , jobDataMap . get ( key ) ) ; } this . launch . addParameters ( data ) ; return this ; } | Add a Quartz JobData to the one used to launch the Program . This JobData is used to initialize Programs arguments for launching . |
10,704 | public boolean add ( int left , int right ) { if ( line [ left ] == null ) { line [ left ] = new IntBitSet ( ) ; } else { if ( line [ left ] . contains ( right ) ) { return false ; } } line [ left ] . add ( right ) ; return true ; } | Adds a new pair to the relation . |
10,705 | public void add ( int left , IntBitSet right ) { if ( line [ left ] == null ) { line [ left ] = new IntBitSet ( ) ; } line [ left ] . addAll ( right ) ; } | Adds a set of pairs . |
10,706 | public void addAll ( IntBitRelation right ) { int i , max ; max = right . line . length ; for ( i = 0 ; i < max ; i ++ ) { if ( right . line [ i ] != null ) { add ( i , right . line [ i ] ) ; } } } | Adds all element from the relation specified . |
10,707 | public boolean contains ( int left , int right ) { if ( line [ left ] == null ) { return false ; } return line [ left ] . contains ( right ) ; } | Element test . |
10,708 | public void addRightWhere ( int left , IntBitSet result ) { if ( line [ left ] != null ) { result . addAll ( line [ left ] ) ; } } | Returns all right values from the relation that have the left value specified . |
10,709 | public boolean contains ( IntBitRelation sub ) { int i ; if ( line . length != sub . line . length ) { return false ; } for ( i = 0 ; i < line . length ; i ++ ) { if ( line [ i ] == null ) { if ( sub . line [ i ] != null ) { return false ; } } else { if ( ( sub . line [ i ] != null ) && ! line [ i ] . containsAll ( sub . line [ i ] ) ) { return false ; } } } return true ; } | Subset test . |
10,710 | public void transitiveClosure ( ) { IntBitRelation next ; while ( true ) { next = new IntBitRelation ( getMax ( ) ) ; next . composeRightLeft ( this , this ) ; if ( contains ( next ) ) { return ; } addAll ( next ) ; } } | Transitive closure . |
10,711 | public AutoComplete autoCompleteDirectory ( String prefix ) { final Trie < CliValueType > possibilities = childDirectories . subTrie ( prefix ) . mapValues ( CliValueType . DIRECTORY . < CliDirectory > getMapper ( ) ) ; return new AutoComplete ( prefix , possibilities ) ; } | Auto complete the given prefix with child directory possibilities . |
10,712 | public AutoComplete autoCompleteCommand ( String prefix ) { final Trie < CliValueType > possibilities = childCommands . subTrie ( prefix ) . mapValues ( CliValueType . COMMAND . < CliCommand > getMapper ( ) ) ; return new AutoComplete ( prefix , possibilities ) ; } | Auto complete the given prefix with child command possibilities . |
10,713 | public AutoComplete autoCompleteEntry ( String prefix ) { final AutoComplete directoryAutoComplete = autoCompleteDirectory ( prefix ) ; final AutoComplete commandAutoComplete = autoCompleteCommand ( prefix ) ; return directoryAutoComplete . union ( commandAutoComplete ) ; } | Auto complete the given prefix with child directory or command possibilities . |
10,714 | public static CliDirectory from ( Identifier identifier , CliCommand ... commands ) { final Trie < CliCommand > childCommands = createChildCommands ( commands ) ; return new CliDirectory ( identifier , Tries . < CliDirectory > emptyTrie ( ) , childCommands ) ; } | Construct a CLI directory from the given parameters . |
10,715 | private IContext findMultiwordsInContextStructure ( IContext context ) throws ContextPreprocessorException { for ( Iterator < INode > i = context . getNodes ( ) ; i . hasNext ( ) ; ) { INode sourceNode = i . next ( ) ; for ( Iterator < IAtomicConceptOfLabel > j = sourceNode . getNodeData ( ) . getACoLs ( ) ; j . hasNext ( ) ; ) { IAtomicConceptOfLabel synSource = j . next ( ) ; findMultiwordsAmong ( sourceNode . getDescendants ( ) , synSource ) ; findMultiwordsAmong ( sourceNode . getAncestors ( ) , synSource ) ; } } return context ; } | Finds multiwords in context . |
10,716 | public Set < URI > listServices ( ) { String queryStr = new StringBuilder ( ) . append ( "SELECT DISTINCT ?svc WHERE { \n" ) . append ( " GRAPH ?g { \n" ) . append ( "?svc " ) . append ( "<" ) . append ( RDF . type . getURI ( ) ) . append ( ">" ) . append ( " " ) . append ( "<" ) . append ( MSM . Service . getURI ( ) ) . append ( "> . \n" ) . append ( " } \n" ) . append ( "} \n" ) . toString ( ) ; return this . graphStoreManager . listResourcesByQuery ( queryStr , "svc" ) ; } | Obtains a list of service URIs with all the services known to the system |
10,717 | public Service getService ( URI serviceUri ) throws ServiceException { if ( serviceUri == null || ! serviceUri . isAbsolute ( ) ) { log . warn ( "The Service URI is either absent or relative. Provide an absolute URI" ) ; return null ; } OntModel model = null ; try { model = this . graphStoreManager . getGraph ( URIUtil . getNameSpace ( serviceUri ) ) ; } catch ( URISyntaxException e ) { log . error ( "The namespace of the service is not a correct URI" , e ) ; return null ; } ServiceReaderImpl reader = new ServiceReaderImpl ( ) ; List < Service > services = reader . parseService ( model ) ; if ( services != null && ! services . isEmpty ( ) ) { return services . get ( 0 ) ; } return null ; } | Obtains the service description of the service identified by the URI |
10,718 | public Set < Service > getServices ( Set < URI > serviceUris ) throws ServiceException { ImmutableSet . Builder < Service > result = ImmutableSet . builder ( ) ; Service svc ; for ( URI svcUri : serviceUris ) { svc = this . getService ( svcUri ) ; if ( svc != null ) { result . add ( svc ) ; } } return result . build ( ) ; } | Obtains the service descriptions for all the services identified by the URI Set |
10,719 | public boolean clearServices ( ) throws ServiceException { if ( ! this . graphStoreManager . canBeModified ( ) ) { log . warn ( "The dataset cannot be modified." ) ; return false ; } log . info ( "Clearing services registry." ) ; this . graphStoreManager . clearDataset ( ) ; this . getEventBus ( ) . post ( new ServicesClearedEvent ( new Date ( ) ) ) ; return true ; } | Deletes all the services on the registry . This operation cannot be undone . Use with care . |
10,720 | public boolean serviceExists ( URI serviceUri ) throws ServiceException { if ( serviceUri == null || ! serviceUri . isAbsolute ( ) ) { log . warn ( "The Service URI is either absent or relative. Provide an absolute URI" ) ; return false ; } URI graphUri ; try { graphUri = getGraphUriForElement ( serviceUri ) ; } catch ( URISyntaxException e ) { log . warn ( "The namespace of the URI of the message content is incorrect." , e ) ; return Boolean . FALSE ; } if ( graphUri == null ) { log . warn ( "Could not obtain a graph URI for the element. The URI may not be managed by the server - " + serviceUri ) ; return Boolean . FALSE ; } String queryStr = new StringBuilder ( ) . append ( "ASK { \n" ) . append ( "GRAPH <" ) . append ( graphUri . toASCIIString ( ) ) . append ( "> {" ) . append ( "<" ) . append ( serviceUri . toASCIIString ( ) ) . append ( "> <" ) . append ( RDF . type . getURI ( ) ) . append ( "> <" ) . append ( MSM . Service ) . append ( "> }\n}" ) . toString ( ) ; Query query = QueryFactory . create ( queryStr ) ; QueryExecution qe = QueryExecutionFactory . sparqlService ( this . graphStoreManager . getSparqlQueryEndpoint ( ) . toASCIIString ( ) , query ) ; MonitoredQueryExecution qexec = new MonitoredQueryExecution ( qe ) ; try { return qexec . execAsk ( ) ; } finally { qexec . close ( ) ; } } | Determines whether a service is known to the registry |
10,721 | public Set < URI > listServicesWithModelReference ( URI modelReference ) { if ( modelReference == null ) { return ImmutableSet . of ( ) ; } StringBuilder queryBuilder = new StringBuilder ( ) ; queryBuilder . append ( "PREFIX msm: <" ) . append ( MSM . getURI ( ) ) . append ( "> " ) . append ( "PREFIX rdf: <" ) . append ( RDF . getURI ( ) ) . append ( "> " ) . append ( "PREFIX sawsdl: <" ) . append ( SAWSDL . getURI ( ) ) . append ( "> " ) . append ( "SELECT ?service WHERE { ?service rdf:type msm:Service . ?service sawsdl:modelReference <" ) . append ( modelReference ) . append ( "> . }" ) ; String query = queryBuilder . toString ( ) ; return this . graphStoreManager . listResourcesByQuery ( query , "service" ) ; } | Given the URI of a modelReference this method figures out all the services that have this as model references . This method uses SPARQL 1 . 1 to avoid using regexs for performance . |
10,722 | public Set < URI > getMsmType ( URI elementUri ) { if ( elementUri == null || ! elementUri . isAbsolute ( ) ) { log . warn ( "The Element URI is either absent or relative. Provide an absolute URI" ) ; return ImmutableSet . of ( ) ; } URI graphUri ; try { graphUri = getGraphUriForElement ( elementUri ) ; } catch ( URISyntaxException e ) { log . warn ( "The namespace of the URI of the message content is incorrect." , e ) ; return ImmutableSet . of ( ) ; } if ( graphUri == null ) { log . warn ( "Could not obtain a graph URI for the element. The URI may not be managed by the server - " + elementUri ) ; return ImmutableSet . of ( ) ; } String queryStr = new StringBuilder ( ) . append ( "SELECT * WHERE { \n" ) . append ( " GRAPH <" ) . append ( graphUri . toASCIIString ( ) ) . append ( "> { \n" ) . append ( "<" ) . append ( elementUri . toASCIIString ( ) ) . append ( "> <" ) . append ( RDF . type . getURI ( ) ) . append ( "> ?type ." ) . append ( "FILTER(STRSTARTS(STR(?type), \"" ) . append ( MSM . NAMESPACE . getURI ( ) ) . append ( "\"))" ) . append ( " } \n " ) . append ( "} \n " ) . toString ( ) ; return this . graphStoreManager . listResourcesByQuery ( queryStr , "type" ) ; } | Given the URI of an element this method returns the URI of the element from the Minimal Service Model it corresponds to . That is it will say if it is a service operation etc . This method uses SPARQL 1 . 1 to avoid using regexs for performance . |
10,723 | public Set < URI > listElementsAnnotatedWith ( URI modelReference ) { if ( modelReference == null ) { return ImmutableSet . of ( ) ; } String queryStr = new StringBuilder ( ) . append ( "SELECT DISTINCT ?element WHERE { \n" ) . append ( " GRAPH ?g { \n" ) . append ( " ?element <" ) . append ( SAWSDL . modelReference . getURI ( ) ) . append ( "> <" ) . append ( modelReference . toASCIIString ( ) ) . append ( "> ." ) . append ( " } \n " ) . append ( "} \n " ) . toString ( ) ; return this . graphStoreManager . listResourcesByQuery ( queryStr , "element" ) ; } | Given a modelReference this method finds all the elements that have been annotated with it . This method finds exact annotations . Note that the elements can be services operations inputs etc . |
10,724 | private void replaceUris ( uk . ac . open . kmi . msm4j . Resource resource , URI newUriBase ) throws URISyntaxException { if ( resource == null || newUriBase == null || ! newUriBase . isAbsolute ( ) ) return ; resource . setUri ( URIUtil . replaceNamespace ( resource . getUri ( ) , newUriBase ) ) ; if ( resource instanceof Service ) { List < Operation > operations = ( ( Service ) resource ) . getOperations ( ) ; for ( Operation op : operations ) { replaceUris ( op , resource . getUri ( ) ) ; } } if ( resource instanceof Operation ) { List < MessageContent > mcs ; mcs = ( ( Operation ) resource ) . getInputs ( ) ; for ( MessageContent mc : mcs ) { replaceUris ( mc , resource . getUri ( ) ) ; } mcs = ( ( Operation ) resource ) . getInputFaults ( ) ; for ( MessageContent mc : mcs ) { replaceUris ( mc , resource . getUri ( ) ) ; } mcs = ( ( Operation ) resource ) . getOutputs ( ) ; for ( MessageContent mc : mcs ) { replaceUris ( mc , resource . getUri ( ) ) ; } mcs = ( ( Operation ) resource ) . getOutputFaults ( ) ; for ( MessageContent mc : mcs ) { replaceUris ( mc , resource . getUri ( ) ) ; } mcs = ( ( Operation ) resource ) . getFaults ( ) ; for ( MessageContent mc : mcs ) { replaceUris ( mc , resource . getUri ( ) ) ; } } if ( resource instanceof MessagePart ) { List < MessagePart > mps ; mps = ( ( MessagePart ) resource ) . getMandatoryParts ( ) ; for ( MessagePart mp : mps ) { replaceUris ( mp , resource . getUri ( ) ) ; } mps = ( ( MessagePart ) resource ) . getOptionalParts ( ) ; for ( MessagePart mp : mps ) { replaceUris ( mp , resource . getUri ( ) ) ; } } if ( resource instanceof InvocableEntity ) { List < Effect > effects = ( ( InvocableEntity ) resource ) . getEffects ( ) ; for ( Effect effect : effects ) { replaceUris ( effect , resource . getUri ( ) ) ; } List < Condition > conditions = ( ( InvocableEntity ) resource ) . getConditions ( ) ; for ( Condition condition : conditions ) { replaceUris ( condition , resource . getUri ( ) ) ; } } if ( resource instanceof AnnotableResource ) { List < NonFunctionalProperty > nfps = ( ( AnnotableResource ) resource ) . getNfps ( ) ; for ( NonFunctionalProperty nfp : nfps ) { replaceUris ( nfp , resource . getUri ( ) ) ; } } } | Given a Resource and the new Uri base to use modify each and every URL accordingly . This methods maintains the naming used by the service already . Recursive implementation that traverses the entire graph |
10,725 | public void commit ( ) throws CpoException { JdbcCpoAdapter currentResource = getCurrentResource ( ) ; if ( currentResource != getLocalResource ( ) ) ( ( JdbcCpoTrxAdapter ) currentResource ) . commit ( ) ; } | Commits the current transaction behind the CpoTrxAdapter |
10,726 | public void rollback ( ) throws CpoException { JdbcCpoAdapter currentResource = getCurrentResource ( ) ; if ( currentResource != getLocalResource ( ) ) ( ( JdbcCpoTrxAdapter ) currentResource ) . rollback ( ) ; } | Rollback the current transaction behind the CpoTrxAdapter |
10,727 | public boolean isClosed ( ) throws CpoException { JdbcCpoAdapter currentResource = getCurrentResource ( ) ; if ( currentResource != getLocalResource ( ) ) return ( ( JdbcCpoTrxAdapter ) currentResource ) . isClosed ( ) ; else return true ; } | Returns true if the TrxAdapter has been closed false if it is still active |
10,728 | public boolean isBusy ( ) throws CpoException { JdbcCpoAdapter currentResource = getCurrentResource ( ) ; if ( currentResource != getLocalResource ( ) ) return ( ( JdbcCpoTrxAdapter ) currentResource ) . isBusy ( ) ; else return false ; } | Returns true if the TrxAdapter is processing a request false if it is not |
10,729 | public < T > T retrieveBean ( T bean ) throws CpoException { return getCurrentResource ( ) . retrieveBean ( bean ) ; } | Retrieves the Bean from the datasource . The assumption is that the bean exists in the datasource . If the retrieve function defined for these beans returns more than one row an exception will be thrown . |
10,730 | public Launcher dir ( FileNode dir ) { return dir ( dir . toPath ( ) . toFile ( ) , dir . getWorld ( ) . getSettings ( ) . encoding ) ; } | initializes the directory to execute the command in |
10,731 | public void exec ( Writer stdout , Writer stderr , boolean flushDest , Reader stdin , boolean stdinInherit ) throws Failure { launch ( stdout , stderr , flushDest , stdin , stdinInherit ) . await ( ) ; } | Executes a command in this directory wired with the specified streams . None of the argument stream is closed . |
10,732 | public char match ( ISense source , ISense target ) throws MatcherLibraryException { List < ISense > sourceList = getAncestors ( source , depth ) ; List < ISense > targetList = getAncestors ( target , depth ) ; targetList . retainAll ( sourceList ) ; if ( targetList . size ( ) > 0 ) return IMappingElement . EQUIVALENCE ; else return IMappingElement . IDK ; } | Matches two strings with WNHeirarchy matcher . |
10,733 | public char match ( String str1 , String str2 ) { if ( null == str1 || null == str2 || 0 == str1 . length ( ) || 0 == str2 . length ( ) ) { return IMappingElement . IDK ; } String [ ] grams1 = generateNGrams ( str1 , gramlength ) ; String [ ] grams2 = generateNGrams ( str2 , gramlength ) ; int count = 0 ; for ( String aGrams1 : grams1 ) for ( String aGrams2 : grams2 ) { if ( aGrams1 . equals ( aGrams2 ) ) { count ++ ; break ; } } float sim = ( float ) 2 * count / ( grams1 . length + grams2 . length ) ; if ( threshold <= sim ) { return IMappingElement . EQUIVALENCE ; } else { return IMappingElement . IDK ; } } | Computes the relation with NGram matcher . |
10,734 | private static String [ ] generateNGrams ( String str , int gramlength ) { if ( str == null || str . length ( ) == 0 ) return null ; ArrayList < String > grams = new ArrayList < String > ( ) ; int length = str . length ( ) ; String gram ; if ( length < gramlength ) { for ( int i = 1 ; i <= length ; i ++ ) { gram = str . substring ( 0 , i ) ; if ( grams . indexOf ( gram ) == - 1 ) grams . add ( gram ) ; } gram = str . substring ( length - 1 , length ) ; if ( grams . indexOf ( gram ) == - 1 ) grams . add ( gram ) ; } else { for ( int i = 1 ; i <= gramlength - 1 ; i ++ ) { gram = str . substring ( 0 , i ) ; if ( grams . indexOf ( gram ) == - 1 ) grams . add ( gram ) ; } for ( int i = 0 ; i < length - gramlength + 1 ; i ++ ) { gram = str . substring ( i , i + gramlength ) ; if ( grams . indexOf ( gram ) == - 1 ) grams . add ( gram ) ; } for ( int i = length - gramlength + 1 ; i < length ; i ++ ) { gram = str . substring ( i , length ) ; if ( grams . indexOf ( gram ) == - 1 ) grams . add ( gram ) ; } } return grams . toArray ( new String [ grams . size ( ) ] ) ; } | Produces nGrams for nGram matcher . |
10,735 | public static CommandLine forExecute ( String rawCommandLine ) { final List < String > elements = splitCommandLine ( rawCommandLine ) ; return new CommandLine ( elements ) ; } | Parse the command line for execution . If the given command line is empty an empty command line will be returned . |
10,736 | static List < String > splitCommandLine ( String commandLine ) { if ( Objects . requireNonNull ( commandLine , "commandLine" ) . isEmpty ( ) ) { return new LinkedList < > ( ) ; } final List < String > elements = new ArrayList < > ( ) ; final QuoteStack quoteStack = new QuoteStack ( ) ; char c = commandLine . charAt ( 0 ) ; boolean matching = ! isWhitespace ( c ) ; int matchStart = 0 ; if ( isQuote ( c ) ) { quoteStack . push ( c ) ; matchStart = 1 ; } for ( int i = 1 ; i < commandLine . length ( ) ; i ++ ) { c = commandLine . charAt ( i ) ; if ( matching ) { if ( isWhitespace ( c ) && quoteStack . isEmpty ( ) ) { elements . add ( commandLine . substring ( matchStart , i ) ) ; matching = false ; } else if ( isQuote ( c ) && quoteStack . quoteMatches ( c ) ) { elements . add ( commandLine . substring ( matchStart , i ) ) ; quoteStack . pop ( ) ; matching = false ; } } else if ( isQuote ( c ) ) { quoteStack . push ( c ) ; matchStart = i + 1 ; matching = true ; } else if ( ! isWhitespace ( c ) ) { matching = true ; matchStart = i ; } } if ( matching ) { elements . add ( commandLine . substring ( matchStart , commandLine . length ( ) ) ) ; } return elements ; } | Package - protected for testing |
10,737 | public ConnectionSpec toConnectionSpec ( ) { try { return getDatabaseAPI ( ) . newConnectionSpecInstance ( getConnect ( ) , getUser ( ) , getPasswd ( ) , false ) ; } catch ( InvalidConnectionSpecArguments ex ) { throw new AssertionError ( ex ) ; } } | Gets a connection spec configured with the user password and connection string specified . Connections created from this connection spec will have auto commit turned off . |
10,738 | public void add ( Namespace namespace ) { if ( has ( namespace ) ) { get ( namespace . getNamespace ( ) ) . addPaths ( namespace . getPaths ( ) ) ; } else { namespace . addPropertyChangeListener ( listener ) ; set ( namespace . getNamespace ( ) , namespace ) ; } } | Adds a new dependency . |
10,739 | public Namespace getNamespaceForPath ( String path ) { for ( Namespace nmspc : properties . values ( ) ) { if ( nmspc . has ( path ) ) { return nmspc ; } } return null ; } | Returns the namespace for a given path or null if the path isn t found |
10,740 | public char match ( ISense source , ISense target ) { String sSynset = source . getGloss ( ) ; String tSynset = target . getGloss ( ) ; StringTokenizer stSource = new StringTokenizer ( sSynset , " ,.\"'();" ) ; String lemmaS , lemmaT ; int counter = 0 ; while ( stSource . hasMoreTokens ( ) ) { StringTokenizer stTarget = new StringTokenizer ( tSynset , " ,.\"'();" ) ; lemmaS = stSource . nextToken ( ) ; if ( ! meaninglessWords . contains ( lemmaS ) ) while ( stTarget . hasMoreTokens ( ) ) { lemmaT = stTarget . nextToken ( ) ; if ( ! meaninglessWords . contains ( lemmaT ) ) if ( lemmaS . equals ( lemmaT ) ) counter ++ ; } } if ( counter >= threshold ) return IMappingElement . EQUIVALENCE ; else return IMappingElement . IDK ; } | Computes the relations with WordNet gloss comparison matcher . |
10,741 | public char match ( String str1 , String str2 ) { if ( str1 == null || str2 == null ) return IMappingElement . IDK ; if ( str1 . equals ( str2 ) ) { return IMappingElement . EQUIVALENCE ; } else return IMappingElement . IDK ; } | Computes relation with synonym matcher |
10,742 | private MatchType getMatchType ( QuerySolution soln ) { if ( soln . contains ( EXACT_VAR ) ) return LogicConceptMatchType . Exact ; if ( soln . contains ( SUPER_VAR ) ) return LogicConceptMatchType . Plugin ; if ( soln . contains ( SUB_VAR ) ) return LogicConceptMatchType . Subsume ; return LogicConceptMatchType . Fail ; } | Obtain the type of Match . The bindings indicate the relationship between the destination and the origin That is the subclasses of origin will have a true value at binding sub |
10,743 | public Document parseString ( String text ) throws SAXException { try { return parse ( new InputSource ( new StringReader ( text ) ) ) ; } catch ( IOException e ) { throw new RuntimeException ( "unexpected world exception while reading memory stream" , e ) ; } } | This method is not called parse to avoid confusion with file parsing methods |
10,744 | public Document literal ( String text ) { try { return parseString ( text ) ; } catch ( SAXException e ) { throw new RuntimeException ( text , e ) ; } } | asserts a valid document |
10,745 | public static CliCommand from ( Identifier identifier , List < CliParam > params , CommandExecutor executor ) { final CliParamManager paramManager = new CliParamManagerImpl ( params ) ; return new CliCommand ( identifier , paramManager , executor ) ; } | Construct a CLI command from the given parameters . |
10,746 | public String getMinimumStability ( ) { String stabi = getAsString ( "minimum-stability" ) ; if ( stabi == null ) { return ComposerConstants . STABILITIES [ 0 ] ; } else { return stabi ; } } | Returns the minimum - stability property |
10,747 | synchronized public static void loadAdapters ( String configFile ) { InputStream is = CpoClassLoader . getResourceAsStream ( configFile ) ; if ( is == null ) { logger . info ( "Resource Not Found: " + configFile ) ; try { is = new FileInputStream ( configFile ) ; } catch ( FileNotFoundException fnfe ) { logger . info ( "File Not Found: " + configFile ) ; is = null ; } } try { CpoConfigDocument configDoc ; if ( is == null ) { configDoc = CpoConfigDocument . Factory . parse ( configFile ) ; } else { configDoc = CpoConfigDocument . Factory . parse ( is ) ; } String errMsg = XmlBeansHelper . validateXml ( configDoc ) ; if ( errMsg != null ) { logger . error ( "Invalid CPO Config file: " + configFile + ":" + errMsg ) ; } else { logger . info ( "Processing Config File: " + configFile ) ; CpoMetaDescriptor . clearAllInstances ( ) ; clearCpoAdapterFactoryCache ( ) ; CtCpoConfig cpoConfig = configDoc . getCpoConfig ( ) ; if ( cpoConfig . isSetDefaultConfig ( ) ) { defaultContext = cpoConfig . getDefaultConfig ( ) ; } else { defaultContext = cpoConfig . getDataConfigArray ( 0 ) . getName ( ) ; } for ( CtMetaDescriptor metaDescriptor : cpoConfig . getMetaConfigArray ( ) ) { boolean caseSensitive = true ; if ( metaDescriptor . isSetCaseSensitive ( ) ) { caseSensitive = metaDescriptor . getCaseSensitive ( ) ; } CpoMetaDescriptor . getInstance ( metaDescriptor . getName ( ) , metaDescriptor . getMetaXmlArray ( ) , caseSensitive ) ; } for ( CtDataSourceConfig dataSourceConfig : cpoConfig . getDataConfigArray ( ) ) { CpoAdapterFactory cpoAdapterFactory = makeCpoAdapterFactory ( dataSourceConfig ) ; if ( cpoAdapterFactory != null ) { addCpoAdapterFactory ( dataSourceConfig . getName ( ) , cpoAdapterFactory ) ; } } } } catch ( IOException ioe ) { logger . error ( "Error reading " + configFile + ": " , ioe ) ; } catch ( XmlException xe ) { logger . error ( "Error processing " + configFile + ": Invalid XML" ) ; } catch ( CpoException ce ) { logger . error ( "Error processing " + configFile + ": " , ce ) ; } } | LoadAdapters is responsible for loading the config file and then subsequently loading all the metadata . |
10,748 | public void printCommandInfo ( CommandInfo info ) { final PrintContext context = new PrintContext ( ) ; final CliCommand command = info . getCommand ( ) ; printIdentifiable ( context , command ) ; final BoundParams boundParams = info . getBoundParams ( ) ; printBoundParams ( context , command , boundParams ) ; } | Print information about a command . Called to display assistance information about a command or if a parse error occurred while parsing the command s parameters . |
10,749 | public void printSuggestions ( Suggestions suggestions ) { final PrintContext context = new PrintContext ( ) ; context . append ( "Suggestions:" ) . println ( ) ; context . incIndent ( ) ; printSuggestions0 ( context , suggestions . getDirectorySuggestions ( ) , "Directories" ) ; printSuggestions0 ( context , suggestions . getCommandSuggestions ( ) , "Commands" ) ; printSuggestions0 ( context , suggestions . getParamNameSuggestions ( ) , "Parameter names" ) ; printSuggestions0 ( context , suggestions . getParamValueSuggestions ( ) , "Parameter values" ) ; context . decIndent ( ) ; } | Print suggestions . |
10,750 | public long copy ( InputStream in , OutputStream out , long max ) throws IOException { int chunk ; long all ; long remaining ; remaining = max ; all = 0 ; while ( remaining > 0 ) { chunk = in . read ( buffer , 0 , ( int ) Math . min ( remaining , buffer . length ) ) ; if ( chunk < 0 ) { break ; } out . write ( buffer , 0 , chunk ) ; all += chunk ; remaining -= chunk ; } out . flush ( ) ; return all ; } | Copies up to max bytes . |
10,751 | public long skip ( InputStream src , long n ) throws IOException { long done ; int chunk ; if ( n <= 0 ) { return 0 ; } done = 0 ; while ( done < n ) { chunk = src . read ( buffer , 0 , ( int ) Math . min ( Integer . MAX_VALUE , n - done ) ) ; if ( chunk == - 1 ) { break ; } done += chunk ; } return done ; } | skip the specified number of bytes - or less if eof is reached |
10,752 | public String next ( ) throws IOException { String result ; int len ; Matcher matcher ; while ( true ) { matcher = format . separator . matcher ( buffer ) ; if ( matcher . find ( ) ) { len = matcher . end ( ) ; if ( buffer . start + len == buffer . end ) { if ( buffer . isFull ( ) ) { buffer . grow ( ) ; } buffer . fill ( reader ) ; matcher = format . separator . matcher ( buffer ) ; if ( ! matcher . find ( ) ) { throw new IllegalStateException ( ) ; } len = matcher . end ( ) ; } result = new String ( buffer . chars , buffer . start , format . trim == LineFormat . Trim . NOTHING ? len : matcher . start ( ) ) ; buffer . start += len ; } else { if ( buffer . isFull ( ) ) { buffer . grow ( ) ; } if ( buffer . fill ( reader ) ) { continue ; } else { if ( buffer . isEmpty ( ) ) { return null ; } else { result = buffer . eat ( ) ; } } } line ++ ; if ( format . trim == LineFormat . Trim . ALL ) { result = result . trim ( ) ; } if ( ! format . excludes . matcher ( result ) . matches ( ) ) { return result ; } } } | Never closes the underlying reader . |
10,753 | private static String buildDescription ( final List < String > missingFields ) { final StringBuilder description = new StringBuilder ( "Message missing required fields: " ) ; boolean first = true ; for ( final String field : missingFields ) { if ( first ) { first = false ; } else { description . append ( ", " ) ; } description . append ( field ) ; } return description . toString ( ) ; } | Construct the description string for this exception . |
10,754 | public BioCCollection readCollection ( ) throws XMLStreamException { if ( collection != null ) { BioCCollection thisCollection = collection ; collection = null ; return thisCollection ; } return null ; } | Reads the collection of documents . |
10,755 | public boolean visitBegin ( Node node ) throws Exception { BindableCpoWhere jcw = ( BindableCpoWhere ) node ; whereClause . append ( jcw . toString ( cpoClass ) ) ; if ( jcw . hasParent ( ) || jcw . getLogical ( ) != CpoWhere . LOGIC_NONE ) { whereClause . append ( " (" ) ; } else { whereClause . append ( " " ) ; } return true ; } | This is called by composite nodes prior to visiting children |
10,756 | public boolean visitEnd ( Node node ) throws Exception { BindableCpoWhere bcw = ( BindableCpoWhere ) node ; if ( bcw . hasParent ( ) || bcw . getLogical ( ) != CpoWhere . LOGIC_NONE ) { whereClause . append ( ")" ) ; } return true ; } | This is called by composite nodes after visiting children |
10,757 | public boolean visit ( Node node ) throws Exception { BindableCpoWhere bcw = ( BindableCpoWhere ) node ; CpoAttribute attribute ; whereClause . append ( bcw . toString ( cpoClass ) ) ; if ( bcw . getValue ( ) != null ) { attribute = cpoClass . getAttributeJava ( bcw . getAttribute ( ) ) ; if ( attribute == null ) { attribute = cpoClass . getAttributeJava ( bcw . getRightAttribute ( ) ) ; } if ( attribute == null ) { if ( bcw . getComparison ( ) == CpoWhere . COMP_IN && bcw . getValue ( ) instanceof Collection ) { for ( Object obj : ( Collection ) bcw . getValue ( ) ) { bindValues . add ( new BindAttribute ( bcw . getAttribute ( ) == null ? bcw . getRightAttribute ( ) : bcw . getAttribute ( ) , obj ) ) ; } } else { bindValues . add ( new BindAttribute ( bcw . getAttribute ( ) == null ? bcw . getRightAttribute ( ) : bcw . getAttribute ( ) , bcw . getValue ( ) ) ) ; } } else { if ( bcw . getComparison ( ) == CpoWhere . COMP_IN && bcw . getValue ( ) instanceof Collection ) { for ( Object obj : ( Collection ) bcw . getValue ( ) ) { bindValues . add ( new BindAttribute ( attribute , obj ) ) ; } } else { bindValues . add ( new BindAttribute ( attribute , bcw . getValue ( ) ) ) ; } } } return true ; } | This is called for component elements which have no children |
10,758 | public static void sendPageView ( String pageWithParameters ) { if ( analytics == null ) { return ; } analytics . sendPageView ( ) . documentPath ( pageWithParameters ) . go ( ) ; } | Tracks a page view . Do nothing if the UniversalAnalyticsTracker is not configured . |
10,759 | public void setCategorySortingComparator ( Comparator comp ) { Comparator old = categorySortingComparator ; categorySortingComparator = comp ; if ( categorySortingComparator != old ) { buildModel ( ) ; } } | Set the comparator used for sorting categories . If this changes the comparator the model will be rebuilt . |
10,760 | public void setPropertySortingComparator ( Comparator comp ) { Comparator old = propertySortingComparator ; propertySortingComparator = comp ; if ( propertySortingComparator != old ) { buildModel ( ) ; } } | Set the comparator used for sorting properties . If this changes the comparator the model will be rebuilt . |
10,761 | private void addPropertiesToModel ( List < Property > localProperties , Item parent ) { for ( Property property : localProperties ) { Item propertyItem = new Item ( property , parent ) ; model . add ( propertyItem ) ; Property [ ] subProperties = property . getSubProperties ( ) ; if ( subProperties != null && subProperties . length > 0 ) { addPropertiesToModel ( Arrays . asList ( subProperties ) , propertyItem ) ; } } } | Add the specified properties to the model using the specified parent . |
10,762 | private List < Property > getPropertiesForCategory ( List < Property > localProperties , String category ) { List < Property > categoryProperties = new ArrayList < Property > ( ) ; for ( Property property : localProperties ) { if ( property . getCategory ( ) != null && property . getCategory ( ) . equals ( category ) ) { categoryProperties . add ( property ) ; } } return categoryProperties ; } | Convenience method to get all the properties of one category . |
10,763 | public boolean isWordMoreGeneral ( String source , String target ) throws MatcherLibraryException { try { List < ISense > sSenses = linguisticOracle . getSenses ( source ) ; List < ISense > tSenses = linguisticOracle . getSenses ( target ) ; for ( ISense sSense : sSenses ) { for ( ISense tSense : tSenses ) { if ( senseMatcher . isSourceMoreGeneralThanTarget ( sSense , tSense ) ) return true ; } } return false ; } catch ( LinguisticOracleException e ) { final String errMessage = e . getClass ( ) . getSimpleName ( ) + ": " + e . getMessage ( ) ; log . error ( errMessage , e ) ; throw new MatcherLibraryException ( errMessage , e ) ; } catch ( SenseMatcherException e ) { final String errMessage = e . getClass ( ) . getSimpleName ( ) + ": " + e . getMessage ( ) ; log . error ( errMessage , e ) ; throw new MatcherLibraryException ( errMessage , e ) ; } } | Checks the source is more general than the target or not . |
10,764 | public void writeCollection ( BioCCollection collection ) throws XMLStreamException { if ( hasWritten ) { throw new IllegalStateException ( "writeCollection can only be invoked once." ) ; } hasWritten = true ; writer . writeStartDocument ( collection . getEncoding ( ) , collection . getVersion ( ) , collection . isStandalone ( ) ) . writeBeginCollectionInfo ( collection ) ; for ( BioCDocument doc : collection . getDocuments ( ) ) { writer . write ( doc ) ; } writer . writeEndCollection ( ) . writeEndDocument ( ) ; } | Writes the whole BioC collection into the BioC file . This method can only be called once . |
10,765 | private static String hexFormat ( int trgt ) { String s = Integer . toHexString ( trgt ) ; int sz = s . length ( ) ; if ( sz == 8 ) { return s ; } int fill = 8 - sz ; StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < fill ; ++ i ) { buf . append ( '0' ) ; } buf . append ( s ) ; return buf . toString ( ) ; } | Returns an 8 character hexidecimal representation of trgt . If the result is not equal to eight characters leading zeros are prefixed . |
10,766 | public long longer ( Node element , String path ) throws XmlException { String str ; str = string ( element , path ) ; try { return Long . parseLong ( str ) ; } catch ( NumberFormatException e ) { throw new XmlException ( "number expected node " + path + ": " + str ) ; } } | Checkstyle rejects method name long_ |
10,767 | public T End ( ) { if ( procceed ) if ( initVal != null && ! initVal . equals ( false ) ) { return body . apply ( initVal ) ; } else { return null ; } else return this . val ; } | execute the if expression without an Else block |
10,768 | @ SuppressWarnings ( "unchecked" ) public static < T > T createObject ( String className , ClassLoader classLoader , Class < T > clazzToCast ) throws InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException , NoSuchMethodException , SecurityException , ClassNotFoundException { Class < ? > clazz = classLoader != null ? Class . forName ( className , false , classLoader ) : Class . forName ( className ) ; Constructor < ? > constructor = clazz . getDeclaredConstructor ( ) ; constructor . setAccessible ( true ) ; Object result = constructor . newInstance ( ) ; return result != null && clazz . isAssignableFrom ( result . getClass ( ) ) ? ( T ) result : null ; } | Create a new object . |
10,769 | public static String toJson ( BaseBo bo ) { if ( bo == null ) { return null ; } String clazz = bo . getClass ( ) . getName ( ) ; Map < String , Object > data = new HashMap < > ( ) ; data . put ( FIELD_CLASSNAME , clazz ) ; data . put ( FIELD_BODATA , bo . toJson ( ) ) ; return SerializationUtils . toJsonString ( data ) ; } | Serialize a BO to JSON string . |
10,770 | public static byte [ ] toBytes ( BaseBo bo ) { if ( bo == null ) { return null ; } String clazz = bo . getClass ( ) . getName ( ) ; Map < String , Object > data = new HashMap < > ( ) ; data . put ( FIELD_CLASSNAME , clazz ) ; data . put ( FIELD_BODATA , bo . toBytes ( ) ) ; return SerializationUtils . toByteArray ( data ) ; } | Serialize a BO to a byte array . |
10,771 | @ SuppressWarnings ( "unchecked" ) public static Map < String , Object > bytesToDocument ( byte [ ] data ) { return data != null && data . length > 0 ? SerializationUtils . fromByteArrayFst ( data , Map . class ) : null ; } | De - serialize byte array to document . |
10,772 | public static byte [ ] documentToBytes ( Map < String , Object > doc ) { return doc != null ? SerializationUtils . toByteArrayFst ( doc ) : ArrayUtils . EMPTY_BYTE_ARRAY ; } | Serialize document to byte array . |
10,773 | public void save ( ) { FileWriter fw = null ; BufferedWriter bw = null ; try { fw = new FileWriter ( file ) ; bw = new BufferedWriter ( fw ) ; for ( Iterator < Object > iterator = ini . keySet ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { String key = iterator . next ( ) . toString ( ) ; bw . write ( key + "=" + getKey ( key ) ) ; bw . newLine ( ) ; } bw . close ( ) ; bw = null ; fw . close ( ) ; fw = null ; } catch ( Exception ex ) { Log . e ( TAG , "" , ex ) ; } finally { if ( bw != null ) { try { bw . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } bw = null ; } if ( fw != null ) { try { fw . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } fw = null ; } } } | save the file . |
10,774 | public static String getElasticSearchAddDocument ( Map < String , String > values ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "{" ) ; boolean first = true ; for ( Map . Entry < String , String > pair : values . entrySet ( ) ) { if ( ! first ) { builder . append ( "," ) ; } JSONUtils . addElasticSearchField ( builder , pair ) ; first = false ; } builder . append ( "}" ) ; return builder . toString ( ) ; } | Returns ElasticSearch add command . |
10,775 | public static String getElasticSearchBulkHeader ( SimpleDataEvent event , String index , String type ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "{\"index\":{\"_index\":\"" ) ; builder . append ( index ) ; builder . append ( "\",\"_type\":\"" ) ; builder . append ( type ) ; builder . append ( "\",\"_id\":\"" ) ; builder . append ( event . getId ( ) ) ; builder . append ( "\"}}" ) ; return builder . toString ( ) ; } | Constructs ES bulk header for the document . |
10,776 | public Long getId ( ) { if ( this . genericRecordAttributes . getId ( ) != null ) { return this . genericRecordAttributes . getId ( ) ; } else if ( this . typeARecordAttributes . getId ( ) != null ) { return this . typeARecordAttributes . getId ( ) ; } else if ( this . typeAAAARecordAttributes . getId ( ) != null ) { return this . typeAAAARecordAttributes . getId ( ) ; } else if ( this . typeNSRecordAttributes . getId ( ) != null ) { return this . typeNSRecordAttributes . getId ( ) ; } else if ( this . typeSOARecordAttributes . getId ( ) != null ) { return this . typeSOARecordAttributes . getId ( ) ; } else if ( this . typeMXRecordAttributes . getId ( ) != null ) { return this . typeMXRecordAttributes . getId ( ) ; } else if ( this . typePTRRecordAttributes . getId ( ) != null ) { return this . typePTRRecordAttributes . getId ( ) ; } else if ( this . typeTXTRecordAttributes . getId ( ) != null ) { return this . typeTXTRecordAttributes . getId ( ) ; } else { return null ; } } | FIXME Better way of accessing the variables? |
10,777 | public static ProfilingRecord addProfiling ( long execTimeMs , String command , long durationMs ) { ProfilingRecord record = new ProfilingRecord ( execTimeMs , command , durationMs ) ; List < ProfilingRecord > records = profilingRecords . get ( ) ; records . add ( record ) ; while ( records . size ( ) > 100 ) { records . remove ( 0 ) ; } return record ; } | Adds a new profiling record . |
10,778 | protected void removeFromCache ( String cacheName , String key ) { try { ICache cache = getCache ( cacheName ) ; if ( cache != null ) { cache . delete ( key ) ; } } catch ( CacheException e ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } } | Removes an entry from cache . |
10,779 | protected void putToCache ( String cacheName , String key , Object value ) { putToCache ( cacheName , key , value , 0 ) ; } | Puts an entry to cache with default TTL . |
10,780 | protected void putToCache ( String cacheName , String key , Object value , long ttlSeconds ) { if ( cacheItemsExpireAfterWrite ) { putToCache ( cacheName , key , value , ttlSeconds , 0 ) ; } else { putToCache ( cacheName , key , value , 0 , ttlSeconds ) ; } } | Puts an entry to cache with specific TTL . |
10,781 | protected void reset ( ) { this . active = false ; synchronized ( this . cachedChannelsNonTransactional ) { for ( ChannelProxy channel : this . cachedChannelsNonTransactional ) { try { channel . getTargetChannel ( ) . close ( ) ; } catch ( Throwable ex ) { this . logger . trace ( "Could not close cached Rabbit Channel" , ex ) ; } } this . cachedChannelsNonTransactional . clear ( ) ; } synchronized ( this . cachedChannelsTransactional ) { for ( ChannelProxy channel : this . cachedChannelsTransactional ) { try { channel . getTargetChannel ( ) . close ( ) ; } catch ( Throwable ex ) { this . logger . trace ( "Could not close cached Rabbit Channel" , ex ) ; } } this . cachedChannelsTransactional . clear ( ) ; } this . active = true ; } | Reset the Channel cache and underlying shared Connection to be reinitialized on next access . |
10,782 | public static String extractKeyHead ( String key , String delimeter ) { int index = key . indexOf ( delimeter ) ; if ( index == - 1 ) { return key ; } String result = key . substring ( 0 , index ) ; return result ; } | Extract the value of keyHead . |
10,783 | public static String extractKeyTail ( String key , String delimeter ) { int index = key . indexOf ( delimeter ) ; if ( index == - 1 ) { return null ; } String result = key . substring ( index + delimeter . length ( ) ) ; return result ; } | Extract the value of keyTail . |
10,784 | public void asyncPost ( final String url , final String mediaType , final Supplier < String > supplier , final Callback callback ) { requireNonNull ( supplier , "A valid supplier expected" ) ; asyncPostBytes ( url , mediaType , ( ) -> ofNullable ( supplier . get ( ) ) . orElse ( "" ) . getBytes ( ) , callback ) ; } | Posts data to a server via a HTTP POST request . |
10,785 | public void asyncPostBytes ( final String url , final String mediaType , final Supplier < byte [ ] > supplier , final Callback callback ) { final String url2 = requireNonNull ( trimToNull ( url ) , "A non-empty URL expected" ) ; final String mediaType2 = requireNonNull ( trimToNull ( mediaType ) , "A non-empty media type expected" ) ; requireNonNull ( supplier , "A valid supplier expected" ) ; requireNonNull ( callback , "A valid callback expected" ) ; final Request request = new Request . Builder ( ) . url ( url2 ) . post ( new RequestBody ( ) { public MediaType contentType ( ) { return MediaType . parse ( mediaType2 + "; charset=utf-8" ) ; } public void writeTo ( final BufferedSink sink ) throws IOException { sink . write ( supplier . get ( ) ) ; } } ) . build ( ) ; client . newCall ( request ) . enqueue ( callback ) ; } | Posts the content of a buffer of bytes to a server via a HTTP POST request . |
10,786 | public void asyncPut ( final String url , final String mediaType , final Supplier < String > supplier , final Callback callback ) { requireNonNull ( supplier , "A valid supplier expected" ) ; asyncPutBytes ( url , mediaType , ( ) -> ofNullable ( supplier . get ( ) ) . orElse ( "" ) . getBytes ( ) , callback ) ; } | Puts data to a server via a HTTP PUT request . |
10,787 | public void asyncDelete ( final String url , final Callback callback ) { final String url2 = requireNonNull ( trimToNull ( url ) , "A non-empty URL expected" ) ; requireNonNull ( callback , "A valid callback expected" ) ; final Request request = new Request . Builder ( ) . url ( url2 ) . delete ( ) . build ( ) ; client . newCall ( request ) . enqueue ( callback ) ; } | Delete HTTP method . |
10,788 | public List < Change > asRemovedChanges ( ) { final WeeklyOpeningHours normalized = this . normalize ( ) ; final List < Change > changes = new ArrayList < > ( ) ; for ( final DayOpeningHours doh : normalized ) { changes . addAll ( doh . asRemovedChanges ( ) ) ; } return changes ; } | Returns all days and hour ranges as if they were removed . |
10,789 | public void addHistory ( Object historyKey ) { if ( this . history == null ) { this . history = new KeyHistory ( ) ; } this . history . addKey ( historyKey . toString ( ) ) ; } | Add key to history . |
10,790 | public void addAdditionalHeader ( String key , String value ) { if ( this . additionalHeader == null ) { this . additionalHeader = Maps . newLinkedHashMap ( ) ; } this . additionalHeader . put ( key , value ) ; } | Add value to additional header . |
10,791 | public static final boolean isValid ( final String value ) { if ( value == null ) { return true ; } if ( ( value . length ( ) < 3 ) || ( value . length ( ) > 20 ) ) { return false ; } return PATTERN . matcher ( value . toString ( ) ) . matches ( ) ; } | Check that a given string is a well - formed user id . |
10,792 | public Object get ( Object key ) { Object val = super . get ( key ) ; if ( val == null && key instanceof Option ) { val = ( ( Option ) key ) . defaultValue ; } return val ; } | Looks up key in the options . |
10,793 | public static < TYPE > Set < ConstraintViolation < TYPE > > validate ( final Validator validator , final TYPE value , final Class < ? > ... groups ) { if ( value == null ) { return new HashSet < ConstraintViolation < TYPE > > ( ) ; } return validator . validate ( value , groups ) ; } | Validates the given object . |
10,794 | public static < TYPE > Set < ConstraintViolation < TYPE > > validate ( final TYPE value , final Class < ? > ... groups ) { return validate ( getValidator ( ) , value , groups ) ; } | Validates the given object using a default validator . |
10,795 | public static String getMacAddr ( Context context ) { String mac = "" ; try { WifiManager wifiManager = ( WifiManager ) context . getSystemService ( Context . WIFI_SERVICE ) ; WifiInfo wifi = wifiManager . getConnectionInfo ( ) ; mac = wifi . getMacAddress ( ) ; } catch ( Exception e ) { mac = null ; Log . e ( TAG , "" , e ) ; } if ( StringUtils . isNullOrEmpty ( mac ) ) mac = getLocalMacAddressFromBusybox ( ) ; if ( StringUtils . isNullOrEmpty ( mac ) ) mac = MAC_EMPTY ; return mac ; } | get mac address . |
10,796 | public static int getStatusBarHeight ( Context context ) { if ( context == null ) return 0 ; Class < ? > c = null ; Object obj = null ; int x = 0 , statusBarHeight = 0 ; try { c = Class . forName ( "com.android.internal.R$dimen" ) ; obj = c . newInstance ( ) ; Field field = c . getField ( "status_bar_height" ) ; x = Integer . parseInt ( field . get ( obj ) . toString ( ) ) ; statusBarHeight = context . getResources ( ) . getDimensionPixelSize ( x ) ; } catch ( Exception e1 ) { Log . e ( TAG , "" , e1 ) ; } return statusBarHeight ; } | get status bar height in px . |
10,797 | public void onOpen ( Session session ) { logger . info ( "WebSocket connected. : SessionId={}" , session . getId ( ) ) ; AmLogServerAdapter . getInstance ( ) . onOpen ( session ) ; } | Websocket connection open . |
10,798 | public void onClose ( Session session , CloseReason closeReason ) { logger . info ( "WebSocket closed. : SessionId={}, Reason={}" , session . getId ( ) , closeReason . toString ( ) ) ; AmLogServerAdapter . getInstance ( ) . onClose ( session ) ; } | Websocket connection close . |
10,799 | public final ClassTextInfo createClassInfo ( final Class < ? > clasz , final Locale locale , final Class < ? extends Annotation > annotationClasz ) { Contract . requireArgNotNull ( "clasz" , clasz ) ; Contract . requireArgNotNull ( "locale" , locale ) ; Contract . requireArgNotNull ( "annotationClasz" , annotationClasz ) ; final Annotation annotation = clasz . getAnnotation ( annotationClasz ) ; if ( annotation == null ) { return null ; } try { final ResourceBundle bundle = getResourceBundle ( annotation , locale , clasz ) ; final String text = getText ( bundle , annotation , clasz . getSimpleName ( ) + "." + annotationClasz . getSimpleName ( ) ) ; return new ClassTextInfo ( clasz , text ) ; } catch ( final MissingResourceException ex ) { if ( getValue ( annotation ) . equals ( "" ) ) { return new ClassTextInfo ( clasz , null ) ; } return new ClassTextInfo ( clasz , getValue ( annotation ) ) ; } } | Returns the text information for a given class . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.