idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
135,600 | public boolean apply ( List < E > tokens ) { if ( this . find ( tokens ) != null ) { return true ; } else { return false ; } } | Apply the expression against a list of tokens . |
135,601 | public Match < E > find ( List < E > tokens , int start ) { Match < E > match ; for ( int i = start ; i <= tokens . size ( ) - auto . minMatchingLength ( ) ; i ++ ) { match = this . lookingAt ( tokens , i ) ; if ( match != null ) { return match ; } } return null ; } | Find the first match of the regular expression against tokens starting at the specified index . |
135,602 | public Match < E > lookingAt ( List < E > tokens , int start ) { return auto . lookingAt ( tokens , start ) ; } | Determine if the regular expression matches the supplied tokens starting at the specified index . |
135,603 | public List < Match < E > > findAll ( List < E > tokens ) { List < Match < E > > results = new ArrayList < Match < E > > ( ) ; int start = 0 ; Match < E > match ; do { match = this . find ( tokens , start ) ; if ( match != null ) { start = match . endIndex ( ) ; if ( ! match . isEmpty ( ) ) { results . add ( match ) ; ... | Find all non - overlapping matches of the regular expression against tokens . |
135,604 | public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; RegularExpression < String > regex = RegularExpressionParsers . word . parse ( args [ 0 ] ) ; System . out . println ( "regex: " + regex ) ; System . out . println ( ) ; while ( scan . hasNextLine ( ) ) { String line = scan . nex... | An interactive program that compiles a word - based regular expression specified in arg1 and then reads strings from stdin evaluating them against the regular expression . |
135,605 | public boolean isEquivalent ( CompilationUnit other ) { if ( ! destination . getAbsoluteFile ( ) . equals ( other . destination . getAbsoluteFile ( ) ) ) return false ; if ( encoding != null ? ! encoding . equals ( other . encoding ) : other . encoding != null ) return false ; if ( resourceReader != null ? ! resourceRe... | Checks whether two compilation units represent the same compilation . Only the imports may be different when they have not yet been set . |
135,606 | private static MessageDigest SHA512_Init ( ) { Log . d ( "Ed25519" , "SHA512_Init" ) ; try { return MessageDigest . getInstance ( "SHA-512" ) ; } catch ( NoSuchAlgorithmException e ) { e . printStackTrace ( ) ; } return null ; } | jni c code calls this for sha512 . |
135,607 | public void addIndexWarning ( String noIndexGiven ) { if ( jsonResponse == null ) { jsonResponse = new JSONObject ( ) ; } jsonResponse . put ( "warning:noIndexGiven" , noIndexGiven ) ; } | not implemented yet |
135,608 | public static DeleteFollowRequest checkRequest ( final HttpServletRequest request , final DeleteRequest deleteRequest , final DeleteFollowResponse deleteFollowResponse ) { final Node user = checkUserIdentifier ( request , deleteFollowResponse ) ; if ( user != null ) { final Node followed = checkFollowedIdentifier ( req... | check a delete follow edge request for validity concerning NSSP |
135,609 | protected void doGet ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { long start = System . nanoTime ( ) ; ProcessRetrieveResponse responseObject = ProcessRetrieveRequest . checkRequestParameter ( request , this . getServletContext ( ) ) ; String resultJson = respons... | de . metalcon . autocompleteServer . Retrieve . RetrieveServlet |
135,610 | private static CreateRequestType checkType ( final FormItemList formItemList , final CreateResponse createResponse ) { final String sType = formItemList . getField ( ProtocolConstants . Parameters . Create . TYPE ) ; if ( sType != null ) { if ( CreateRequestType . USER . getIdentifier ( ) . equals ( sType ) ) { return ... | check if the request contains a valid create request type |
135,611 | private void writeFiles ( final StatusUpdateTemplate template , final FormItemList items ) throws Exception { FormFile fileItem ; TemplateFileInfo fileInfo ; for ( String fileIdentifier : items . getFileIdentifiers ( ) ) { fileItem = items . getFile ( fileIdentifier ) ; fileInfo = template . getFiles ( ) . get ( fileId... | write the files posted if they are matching to the template targeted |
135,612 | private File writeFile ( final FormFile fileItem ) throws Exception { final String directory = this . getFileDir ( fileItem . getContentType ( ) ) ; final File file = new File ( directory + System . currentTimeMillis ( ) + "-" + fileItem . getOriginalFileName ( ) ) ; fileItem . getFormItem ( ) . write ( file ) ; return... | write a file to the directory matching its content type |
135,613 | @ SuppressWarnings ( "unchecked" ) public JSONObject toJSONObject ( ) { final JSONObject activity = new JSONObject ( ) ; activity . put ( "published" , dateFormatter . format ( new Date ( this . timestamp ) ) ) ; activity . put ( "verb" , "read" ) ; final Map < String , Object > object = this . toObjectJSON ( ) ; activ... | parse the status update to an Activity JSON String |
135,614 | protected Map < String , Object > toObjectJSON ( ) { final Map < String , Object > objectJSON = new LinkedHashMap < String , Object > ( ) ; objectJSON . put ( "objectType" , "article" ) ; objectJSON . put ( "type" , this . type ) ; objectJSON . put ( "id" , this . id ) ; return objectJSON ; } | parse the status update to an Object JSON map |
135,615 | private static Properties loadProperties ( String propertiesFile ) { Properties properties = new Properties ( ) ; try ( InputStream is = new FileInputStream ( propertiesFile ) ) { properties . load ( is ) ; } catch ( IOException e ) { throw new RuntimeException ( "failed to load properties" , e ) ; } return properties ... | Loads properties from a properties file on the local filesystem . |
135,616 | private static Properties loadPropertiesFromClasspath ( String propertiesFile ) { Properties properties = new Properties ( ) ; try ( InputStream is = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( propertiesFile ) ) { properties . load ( is ) ; } catch ( IOException e ) { throw new Runti... | Loads properties from a properties file on the classpath . |
135,617 | public < T > Collection < T > getCollection ( String prefix , Function < String , T > factory ) { Collection < T > collection = new ArrayList < > ( ) ; for ( String property : properties . stringPropertyNames ( ) ) { if ( property . startsWith ( prefix + "." ) ) { collection . add ( factory . apply ( property ) ) ; } }... | Reads a collection of properties based on a prefix . |
135,618 | public < K , V > Map < K , V > getMap ( String prefix , Function < String , K > keyFactory , Function < String , V > valueFactory ) { Map < K , V > map = new HashMap < > ( ) ; for ( String property : properties . stringPropertyNames ( ) ) { if ( property . startsWith ( prefix + "." ) ) { map . put ( keyFactory . apply ... | Returns a map of properties for a given prefix . |
135,619 | public Class < ? > getClass ( String property ) { return getProperty ( property , className -> { try { return Class . forName ( className ) ; } catch ( ClassNotFoundException e ) { throw new ConfigurationException ( "unknown class: " + className , e ) ; } } ) ; } | Reads a class property . |
135,620 | public File getFile ( String property , File defaultValue ) { return getProperty ( property , defaultValue , File :: new ) ; } | Reads a file property . |
135,621 | public < T extends Enum < T > > T getEnum ( String property , Class < T > type ) { return Enum . valueOf ( type , getString ( property ) ) ; } | Reads an enum property . |
135,622 | public String getString ( String property , String defaultValue ) { return getProperty ( property , defaultValue , v -> v ) ; } | Reads a string property returning a default value if the property is not present . |
135,623 | public boolean getBoolean ( String property ) { return getProperty ( property , value -> { switch ( value . trim ( ) . toLowerCase ( ) ) { case "true" : case "1" : return true ; case "false" : case "0" : return false ; default : throw new ConfigurationException ( "invalid property value: " + property + " must be a bool... | Reads a boolean property . |
135,624 | public short getShort ( String property ) { return getProperty ( property , value -> { try { return Short . valueOf ( value ) ; } catch ( NumberFormatException e ) { throw new ConfigurationException ( "malformed property value: " + property + " must be a short" ) ; } } ) ; } | Reads a short property . |
135,625 | public int getInteger ( String property ) { return getProperty ( property , value -> { try { return Integer . valueOf ( value ) ; } catch ( NumberFormatException e ) { throw new ConfigurationException ( "malformed property value: " + property + " must be an integer" ) ; } } ) ; } | Reads an integer property . |
135,626 | public long getLong ( String property ) { return getProperty ( property , value -> { try { return Long . valueOf ( value ) ; } catch ( NumberFormatException e ) { throw new ConfigurationException ( "malformed property value: " + property + " must be a long" ) ; } } ) ; } | Reads a long property . |
135,627 | public float getFloat ( String property ) { return getProperty ( property , value -> { try { return Float . valueOf ( value ) ; } catch ( NumberFormatException e ) { throw new ConfigurationException ( "malformed property value: " + property + " must be a float" ) ; } } ) ; } | Reads a float property . |
135,628 | public double getDouble ( String property ) { return getProperty ( property , value -> { try { return Double . valueOf ( value ) ; } catch ( NumberFormatException e ) { throw new ConfigurationException ( "malformed property value: " + property + " must be a double" ) ; } } ) ; } | Reads a double property . |
135,629 | private < T > T getProperty ( String property , Function < String , T > transformer ) { Assert . notNull ( property , "property" ) ; String value = properties . getProperty ( property ) ; if ( value == null ) throw new ConfigurationException ( "missing property: " + property ) ; return transformer . apply ( value ) ; } | Reads an arbitrary property . |
135,630 | public void addFriend ( Friend friend ) { try { get ( ) . addEntry ( friend . get ( ) ) ; } catch ( NoResponseException | XMPPErrorException | NotConnectedException e ) { e . printStackTrace ( ) ; } } | Moves a friend to this group and removes the friend from his previous group . This is an asynchronous call . |
135,631 | public boolean contains ( Friend friend ) { for ( final Friend f : getFriends ( ) ) { if ( StringUtils . parseName ( f . getUserId ( ) ) . equals ( StringUtils . parseName ( friend . getUserId ( ) ) ) ) { return true ; } } return false ; } | Checks if a given Friend is part of this group . |
135,632 | public List < Friend > getFriends ( ) { final List < Friend > friends = new ArrayList < > ( ) ; for ( final RosterEntry e : get ( ) . getEntries ( ) ) { friends . add ( new Friend ( api , con , e ) ) ; } return friends ; } | Gets a list of all Friends in this FriendGroup . |
135,633 | public void setName ( String name ) { try { get ( ) . setName ( name ) ; } catch ( final NotConnectedException e ) { e . printStackTrace ( ) ; } } | Changes the name of this group . Case sensitive . |
135,634 | public static DeleteRequest checkRequest ( final HttpServletRequest request , final DeleteResponse deleteResponse ) { final DeleteRequestType type = checkType ( request , deleteResponse ) ; if ( type != null ) { return new DeleteRequest ( type ) ; } return null ; } | check a delete request for validity concerning NSSP |
135,635 | private static DeleteRequestType checkType ( final HttpServletRequest request , final DeleteResponse deleteResponse ) { { final String sType = request . getParameter ( ProtocolConstants . Parameters . Delete . TYPE ) ; if ( sType != null ) { if ( DeleteRequestType . USER . getIdentifier ( ) . equals ( sType ) ) { retur... | check if the request contains a valid delete request type |
135,636 | public static ProcessRetrieveResponse checkRequestParameter ( HttpServletRequest request , ServletContext context ) { ProcessRetrieveResponse response = new ProcessRetrieveResponse ( context ) ; Integer numItems = checkNumItems ( request , response ) ; String term = checkTerm ( request , response ) ; if ( term == null ... | checks if the request Parameters follow the Protocol or corrects them . |
135,637 | private static SuggestTree checkIndexName ( HttpServletRequest request , ProcessRetrieveResponse response , ServletContext context ) { String indexName = request . getParameter ( ProtocolConstants . INDEX_PARAMETER ) ; SuggestTree index = null ; if ( indexName == null ) { indexName = ProtocolConstants . DEFAULT_INDEX_N... | Returns the search Index according to the indexName Parameter of the ASTP if no Parameter was in the request the default index will be used . if the parameter did not match any known index the default index will be used . returns null if the default index is requested but does not exist |
135,638 | public static org . neo4j . graphdb . Node createTemplateFileInfoNode ( final AbstractGraphDatabase graphDatabase , final TemplateFileInfo fileInfo ) { final org . neo4j . graphdb . Node fileNode = TemplateItemInfo . createTemplateItemNode ( graphDatabase , fileInfo ) ; fileNode . setProperty ( TemplateXMLFields . FILE... | create a database node representing a template file information |
135,639 | @ SuppressWarnings ( "unchecked" ) public void addActivityStream ( final List < JSONObject > activities ) { final JSONArray items = new JSONArray ( ) ; for ( JSONObject activity : activities ) { items . add ( activity ) ; } this . json . put ( "items" , items ) ; } | add the news stream according to the Activitystrea . ms format |
135,640 | protected static CatalystThread getThread ( ExecutorService executor ) { final AtomicReference < CatalystThread > thread = new AtomicReference < > ( ) ; try { executor . submit ( ( ) -> { thread . set ( ( CatalystThread ) Thread . currentThread ( ) ) ; } ) . get ( ) ; } catch ( InterruptedException | ExecutionException... | Gets the thread from a single threaded executor service . |
135,641 | public static org . neo4j . graphdb . Node createTemplateFieldInfoNode ( final AbstractGraphDatabase graphDatabase , final TemplateFieldInfo fieldInfo ) { final org . neo4j . graphdb . Node fieldNode = TemplateItemInfo . createTemplateItemNode ( graphDatabase , fieldInfo ) ; fieldNode . setProperty ( TemplateXMLFields ... | create a database node representing a template field information |
135,642 | public static BitArray allocate ( long bits ) { if ( ! ( bits > 0 & ( bits & ( bits - 1 ) ) == 0 ) ) throw new IllegalArgumentException ( "size must be a power of 2" ) ; return new BitArray ( UnsafeHeapBytes . allocate ( Math . max ( bits / 8 + 8 , 8 ) ) , bits ) ; } | Allocates a new direct bit set . |
135,643 | public boolean set ( long index ) { if ( ! ( index < size ) ) throw new IndexOutOfBoundsException ( ) ; if ( ! get ( index ) ) { bytes . writeLong ( offset ( index ) , bytes . readLong ( offset ( index ) ) | ( 1l << position ( index ) ) ) ; count ++ ; return true ; } return false ; } | Sets the bit at the given index . |
135,644 | public boolean get ( long index ) { if ( ! ( index < size ) ) throw new IndexOutOfBoundsException ( ) ; return ( bytes . readLong ( offset ( index ) ) & ( 1l << ( position ( index ) ) ) ) != 0 ; } | Gets the bit at the given index . |
135,645 | public BitArray resize ( long size ) { bytes . resize ( Math . max ( size / 8 + 8 , 8 ) ) ; this . size = size ; return this ; } | Resizes the bit array to a new count . |
135,646 | BufferAllocator allocator ( ) { Class < ? > allocator = reader . getClass ( ALLOCATOR , UnpooledUnsafeHeapAllocator . class ) ; try { return ( BufferAllocator ) allocator . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException e ) { throw new ConfigurationException ( e ) ; } catch ( ClassCastExcep... | Returns the serializer buffer allocator . |
135,647 | private int idToInt ( String value ) { try { return Integer . valueOf ( value ) ; } catch ( NumberFormatException e ) { throw new ConfigurationException ( "invalid type ID: " + value ) ; } } | Converts a string to an integer . |
135,648 | private Class < ? > serializerToClass ( String value ) { try { return Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( value ) ; } catch ( ClassNotFoundException e ) { throw new ConfigurationException ( "unknown serializable type: " + value ) ; } } | Converts a string to a class . |
135,649 | CompletableFuture < Void > connect ( LocalConnection connection ) { LocalConnection localConnection = new LocalConnection ( listener . context , connections ) ; connections . add ( localConnection ) ; connection . connect ( localConnection ) ; localConnection . connect ( connection ) ; return CompletableFuture . runAsy... | Connects to the server . |
135,650 | public Serializer registerClassLoader ( String className , ClassLoader classLoader ) { classLoaders . put ( className , classLoader ) ; return this ; } | Registers a ClassLoader for a class . |
135,651 | @ SuppressWarnings ( "unchecked" ) private BufferOutput writeById ( int id , Object object , BufferOutput output , TypeSerializer serializer ) { for ( Identifier identifier : Identifier . values ( ) ) { if ( identifier . accept ( id ) ) { identifier . write ( id , output . writeByte ( identifier . code ( ) ) ) ; serial... | Writes an object to the buffer using the given serialization ID . |
135,652 | @ SuppressWarnings ( "unchecked" ) private BufferOutput writeByClass ( Class < ? > type , Object object , BufferOutput output , TypeSerializer serializer ) { if ( whitelistRequired . get ( ) ) throw new SerializationException ( "cannot serialize unregistered type: " + type ) ; serializer . write ( object , output . wri... | Writes an object to the buffer with its class name . |
135,653 | @ SuppressWarnings ( "unchecked" ) private < T > T readById ( int id , BufferInput < ? > buffer ) { Class < T > type = ( Class < T > ) registry . type ( id ) ; if ( type == null ) throw new SerializationException ( "cannot deserialize: unknown type" ) ; TypeSerializer < T > serializer = getSerializer ( type ) ; if ( se... | Reads a serializable object . |
135,654 | @ SuppressWarnings ( "unchecked" ) private < T > T readByClass ( BufferInput < ? > buffer ) { String name = buffer . readUTF8 ( ) ; if ( whitelistRequired . get ( ) ) throw new SerializationException ( "cannot deserialize unregistered type: " + name ) ; Class < T > type = ( Class < T > ) types . get ( name ) ; if ( typ... | Reads a writable object . |
135,655 | public static org . neo4j . graphdb . Node createTemplateNode ( final AbstractGraphDatabase graphDatabase , final StatusUpdateTemplate template ) { final org . neo4j . graphdb . Node templateNode = graphDatabase . createNode ( ) ; templateNode . setProperty ( Properties . Templates . IDENTIFIER , template . getName ( )... | create a database node representing a status update template |
135,656 | public void createUser ( final String userId , final String displayName , final String profilePicturePath ) { final Node user = NeoUtils . createUserNode ( userId ) ; user . setProperty ( Properties . User . DISPLAY_NAME , displayName ) ; user . setProperty ( Properties . User . PROFILE_PICTURE_PATH , profilePicturePat... | create a new user |
135,657 | public void deleteUser ( final Node user ) { Node userReplica , following ; for ( Relationship replica : user . getRelationships ( SocialGraphRelationshipType . REPLICA , Direction . INCOMING ) ) { userReplica = replica . getEndNode ( ) ; following = NeoUtils . getPrevSingleNode ( userReplica , SocialGraphRelationshipT... | delete a user removing it from all replica layers of following users |
135,658 | private int getInt ( XMLProperty p , int defaultValue ) { final String value = get ( p ) ; if ( value . isEmpty ( ) ) { return defaultValue ; } return Integer . parseInt ( value ) ; } | If the value exists it returns its value else the default value |
135,659 | public void start ( ) { this . workerThread = new Thread ( this ) ; System . out . println ( "starting worker thread" ) ; this . workerThread . start ( ) ; System . out . println ( "worker thread started" ) ; } | start the worker thread |
135,660 | private void sendRequest ( Object request , ContextualFuture future ) { if ( open && connection . open ) { long requestId = ++ this . requestId ; futures . put ( requestId , future ) ; connection . handleRequest ( requestId , request ) ; } else { future . context . executor ( ) . execute ( ( ) -> future . completeExcep... | Sends a request . |
135,661 | private void handleResponseError ( long requestId , Throwable error ) { ContextualFuture future = futures . remove ( requestId ) ; if ( future != null ) { future . context . execute ( ( ) -> future . completeExceptionally ( error ) ) ; } } | Handles a response error . |
135,662 | @ SuppressWarnings ( "unchecked" ) private void handleRequest ( long requestId , Object request ) { HandlerHolder holder = handlers . get ( request . getClass ( ) ) ; if ( holder == null ) { connection . handleResponseError ( requestId , new ConnectException ( "no handler registered" ) ) ; return ; } Function < Object ... | Receives a message . |
135,663 | private static Map < String , String > loadDatabaseConfig ( final Configuration config ) { final Map < String , String > databaseConfig = new HashMap < String , String > ( ) ; databaseConfig . put ( "cache_type" , config . getCacheType ( ) ) ; databaseConfig . put ( "use_memory_mapped_buffers" , config . getUseMemoryMa... | load the database configuration map for neo4j databases |
135,664 | private static void loadLuceneIndices ( final AbstractGraphDatabase graphDatabase ) { INDEX_STATUS_UPDATE_TEMPLATES = graphDatabase . index ( ) . forNodes ( "tmpl" ) ; INDEX_USERS = graphDatabase . index ( ) . forNodes ( "user" ) ; INDEX_STATUS_UPDATES = graphDatabase . index ( ) . forNodes ( "stup" ) ; } | load the lucene indices for a database |
135,665 | public static AbstractGraphDatabase getSocialGraphDatabase ( final Configuration config ) { final Map < String , String > graphConfig = loadDatabaseConfig ( config ) ; AbstractGraphDatabase database ; if ( config . getReadOnly ( ) ) { database = new EmbeddedReadOnlyGraphDatabase ( config . getDatabasePath ( ) , graphCo... | open the neo4j graph database |
135,666 | public static boolean deleteFile ( final File file ) { if ( file . isDirectory ( ) ) { final File [ ] children = file . listFiles ( ) ; for ( File child : children ) { if ( ! deleteFile ( child ) ) { return false ; } } } return file . delete ( ) ; } | delete file or directory |
135,667 | public static Node getPrevSingleNode ( final Node user , RelationshipType relationshipType ) { final Relationship rel = user . getSingleRelationship ( relationshipType , Direction . INCOMING ) ; return ( rel == null ) ? ( null ) : ( rel . getStartNode ( ) ) ; } | find an incoming relation from the user passed of the specified type |
135,668 | public static Node getNextSingleNode ( final Node user , RelationshipType relationshipType ) { Relationship rel = null ; try { rel = user . getSingleRelationship ( relationshipType , Direction . OUTGOING ) ; } catch ( final NonWritableChannelException e ) { } return ( rel == null ) ? ( null ) : ( rel . getEndNode ( ) )... | find an outgoing relation from the user passed of the specified type |
135,669 | public static Relationship getRelationshipBetween ( final Node source , final Node target , final RelationshipType relationshipType , final Direction direction ) { for ( Relationship relationship : source . getRelationships ( relationshipType , direction ) ) { if ( relationship . getEndNode ( ) . equals ( target ) ) { ... | Search for a relationship between two nodes |
135,670 | public static Node createUserNode ( final String userId ) { if ( INDEX_USERS . get ( IDENTIFIER , userId ) . getSingle ( ) == null ) { final Node user = DATABASE . createNode ( ) ; user . setProperty ( Properties . User . IDENTIFIER , userId ) ; INDEX_USERS . add ( user , IDENTIFIER , userId ) ; return user ; } throw n... | create a user node in the active database |
135,671 | public static Node createStatusUpdateNode ( final String statusUpdateId ) { if ( INDEX_STATUS_UPDATES . get ( IDENTIFIER , statusUpdateId ) . getSingle ( ) == null ) { final Node statusUpdate = DATABASE . createNode ( ) ; statusUpdate . setProperty ( Properties . StatusUpdate . IDENTIFIER , statusUpdateId ) ; INDEX_STA... | create a status update node in the active database |
135,672 | public static void storeStatusUpdateTemplateNode ( final AbstractGraphDatabase graphDatabase , final String templateId , final Node templateNode , final Node previousTemplateNode ) { if ( previousTemplateNode != null ) { INDEX_STATUS_UPDATE_TEMPLATES . remove ( previousTemplateNode , IDENTIFIER , templateId ) ; } INDEX... | store a status update template node in the index replacing previous occurrences |
135,673 | public void start ( ) { this . commandWorker . start ( ) ; while ( ! this . commandWorker . isRunning ( ) ) { System . out . println ( "waiting for worker to connect..." ) ; try { Thread . sleep ( 50 ) ; } catch ( final InterruptedException e ) { System . out . println ( "server thread could not wait for worker" ) ; e ... | start the server and wait for it to be running |
135,674 | private void handleRequestFailure ( long requestId , Throwable error , ThreadContext context ) { ByteBuf buffer = channel . alloc ( ) . buffer ( 10 ) . writeByte ( RESPONSE ) . writeLong ( requestId ) . writeByte ( FAILURE ) ; try { writeError ( buffer , error , context ) ; } catch ( SerializationException e ) { return... | Handles a request failure . |
135,675 | void handleResponse ( ByteBuf response ) { long requestId = response . readLong ( ) ; byte status = response . readByte ( ) ; switch ( status ) { case SUCCESS : try { handleResponseSuccess ( requestId , readResponse ( response ) ) ; } catch ( SerializationException e ) { handleResponseFailure ( requestId , e ) ; } brea... | Handles response . |
135,676 | @ SuppressWarnings ( "unchecked" ) private void handleResponseSuccess ( long requestId , Object response ) { ContextualFuture future = responseFutures . remove ( requestId ) ; if ( future != null ) { future . context . executor ( ) . execute ( ( ) -> future . complete ( response ) ) ; } } | Handles a successful response . |
135,677 | private void handleResponseFailure ( long requestId , Throwable t ) { ContextualFuture future = responseFutures . remove ( requestId ) ; if ( future != null ) { future . context . executor ( ) . execute ( ( ) -> future . completeExceptionally ( t ) ) ; } } | Handles a failure response . |
135,678 | private ByteBuf writeRequest ( ByteBuf buffer , Object request , ThreadContext context ) { context . serializer ( ) . writeObject ( request , OUTPUT . get ( ) . setByteBuf ( buffer ) ) ; if ( request instanceof ReferenceCounted ) { ( ( ReferenceCounted ) request ) . release ( ) ; } return buffer ; } | Writes a request to the given buffer . |
135,679 | private ByteBuf writeResponse ( ByteBuf buffer , Object request , ThreadContext context ) { context . serializer ( ) . writeObject ( request , OUTPUT . get ( ) . setByteBuf ( buffer ) ) ; return buffer ; } | Writes a response to the given buffer . |
135,680 | private ByteBuf writeError ( ByteBuf buffer , Throwable t , ThreadContext context ) { context . serializer ( ) . writeObject ( t , OUTPUT . get ( ) . setByteBuf ( buffer ) ) ; return buffer ; } | Writes an error to the given buffer . |
135,681 | private Object readRequest ( ByteBuf buffer ) { return context . serializer ( ) . readObject ( INPUT . get ( ) . setByteBuf ( buffer ) ) ; } | Reads a request from the given buffer . |
135,682 | private Throwable readError ( ByteBuf buffer ) { return context . serializer ( ) . readObject ( INPUT . get ( ) . setByteBuf ( buffer ) ) ; } | Reads an error from the given buffer . |
135,683 | void handleException ( Throwable t ) { if ( failure == null ) { failure = t ; for ( ContextualFuture < ? > responseFuture : responseFutures . values ( ) ) { responseFuture . context . executor ( ) . execute ( ( ) -> responseFuture . completeExceptionally ( t ) ) ; } responseFutures . clear ( ) ; for ( Listener < Throwa... | Handles an exception . |
135,684 | void handleClosed ( ) { if ( ! closed ) { closed = true ; for ( ContextualFuture < ? > responseFuture : responseFutures . values ( ) ) { responseFuture . context . executor ( ) . execute ( ( ) -> responseFuture . completeExceptionally ( new ConnectException ( "connection closed" ) ) ) ; } responseFutures . clear ( ) ; ... | Handles the channel being closed . |
135,685 | void timeout ( ) { long time = System . currentTimeMillis ( ) ; Iterator < Map . Entry < Long , ContextualFuture > > iterator = responseFutures . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { ContextualFuture future = iterator . next ( ) . getValue ( ) ; if ( future . time + requestTimeout < time ) {... | Times out requests . |
135,686 | protected static org . neo4j . graphdb . Node createTemplateItemNode ( final AbstractGraphDatabase graphDatabase , final TemplateItemInfo itemInfo ) { final org . neo4j . graphdb . Node itemNode = graphDatabase . createNode ( ) ; itemNode . setProperty ( TemplateXMLFields . ITEM_NAME , itemInfo . getName ( ) ) ; return... | create a database node representing a template item information |
135,687 | public static CreateUserRequest checkRequest ( final FormItemList formItemList , final CreateRequest createRequest , final CreateUserResponse createUserResponse ) { final String userId = checkUserIdentifier ( formItemList , createUserResponse ) ; if ( userId != null ) { final String displayName = checkDisplayName ( for... | check a create user request for validity concerning NSSP |
135,688 | private static String checkDisplayName ( final FormItemList formItemList , final CreateUserResponse createUserResponse ) { final String displayName = formItemList . getField ( ProtocolConstants . Parameters . Create . User . DISPLAY_NAME ) ; if ( displayName != null ) { return displayName ; } else { createUserResponse ... | check if the request contains a display name |
135,689 | private static String checkProfilePicturePath ( final FormItemList formItemList , final CreateUserResponse createUserResponse ) { final String profilePicturePath = formItemList . getField ( ProtocolConstants . Parameters . Create . User . PROFILE_PICTURE_PATH ) ; if ( profilePicturePath != null ) { return profilePictur... | check if the request contains a profile picture path |
135,690 | public Listener < T > add ( Consumer < T > listener ) { Assert . notNull ( listener , "listener" ) ; ListenerHolder holder = new ListenerHolder ( listener , ThreadContext . currentContext ( ) ) ; listeners . add ( holder ) ; return holder ; } | Adds a listener to the set of listeners . |
135,691 | public CompletableFuture < Void > accept ( T event ) { List < CompletableFuture < Void > > futures = new ArrayList < > ( listeners . size ( ) ) ; for ( ListenerHolder listener : listeners ) { if ( listener . context != null ) { futures . add ( listener . context . execute ( ( ) -> listener . listener . accept ( event )... | Applies an event to all listeners . |
135,692 | private ThreadContext getOrCreateContext ( Channel channel ) { ThreadContext context = ThreadContext . currentContext ( ) ; if ( context != null ) { return context ; } return new SingleThreadContext ( Thread . currentThread ( ) , channel . eventLoop ( ) , this . context . serializer ( ) . clone ( ) ) ; } | Returns the current execution context or creates one . |
135,693 | private void handleResponse ( ByteBuf response , ChannelHandlerContext context ) { NettyConnection connection = getConnection ( context . channel ( ) ) ; if ( connection != null ) { connection . handleResponse ( response ) ; } } | Handles a response . |
135,694 | private int calculateTypeId ( Class < ? > type ) { if ( type == null ) throw new NullPointerException ( "type cannot be null" ) ; return hasher . hash32 ( type . getName ( ) ) ; } | Returns the type ID for the given class . |
135,695 | public SerializerRegistry registerDefault ( Class < ? > baseType , Class < ? extends TypeSerializer > serializer ) { return registerDefault ( baseType , new DefaultTypeSerializerFactory ( serializer ) ) ; } | Registers the given class as a default serializer for the given base type . |
135,696 | public synchronized SerializerRegistry registerDefault ( Class < ? > baseType , TypeSerializerFactory factory ) { defaultFactories . put ( baseType , factory ) ; return this ; } | Registers the given factory as a default serializer factory for the given base type . |
135,697 | private Class < ? > findBaseType ( Class < ? > type , Map < Class < ? > , TypeSerializerFactory > factories ) { if ( factories . containsKey ( type ) ) return type ; List < Map . Entry < Class < ? > , TypeSerializerFactory > > orderedFactories = new ArrayList < > ( factories . entrySet ( ) ) ; Collections . reverse ( o... | Finds a serializable base type for the given type in the given factories map . |
135,698 | synchronized int id ( Class < ? > type ) { Integer id = ids . get ( type ) ; if ( id != null ) return id ; Class < ? > baseType = findBaseType ( type , abstractFactories ) ; if ( baseType != null ) { id = ids . get ( baseType ) ; if ( id != null ) { return id ; } } return 0 ; } | Looks up the serializable type ID for the given type . |
135,699 | @ SuppressWarnings ( "unchecked" ) private T readReference ( Class < T > type , BufferInput < ? > buffer , Serializer serializer ) { ReferencePool < ? > pool = pools . get ( type ) ; if ( pool == null ) { Constructor < ? > constructor = constructorMap . get ( type ) ; if ( constructor == null ) { try { constructor = ty... | Reads an object reference . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.