idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
4,600 | public static byte [ ] newByteArray ( byte [ ] data ) { if ( data == null ) { throw new IllegalArgumentException ( "Data you want to copy are backed by null object." ) ; } byte [ ] buffer = new byte [ data . length ] ; System . arraycopy ( data , 0 , buffer , 0 , data . length ) ; return buffer ; } | Copy the provided data |
4,601 | public static void main ( String [ ] args ) throws IOException , SerialException , SQLException { UCSDAnomalyDAO . init ( args ) ; UCSDAnomalyDAO . dropTable ( ) ; UCSDAnomalyDAO . createTable ( ) ; RawData2DB dp = new RawData2DB ( ) ; System . out . println ( "processing data..." ) ; dp . go ( "./raw/UCSDped1/Train/" , null ) ; dp . go ( "./raw/UCSDped1/Test/" , "UCSDped1.m" ) ; System . out . println ( "done." ) ; UCSDAnomalyDAO . release ( ) ; } | one - based index |
4,602 | public byte [ ] decode ( final String data ) { return data != null ? data . getBytes ( CHARSET ) : null ; } | Decode the provided string |
4,603 | public static void printUsage ( ParseException e , String cmdLine , Options options ) { System . err . println ( e . getMessage ( ) ) ; HelpFormatter formatter = new HelpFormatter ( ) ; PrintWriter pw = new PrintWriter ( System . err ) ; formatter . printUsage ( pw , cmdLine . length ( ) + 7 , cmdLine , options ) ; pw . flush ( ) ; } | Prints the command line usage to the std error output |
4,604 | public static void logCommandLineOptions ( Logger logger , CommandLine line ) { for ( Option myOption : line . getOptions ( ) ) { String message ; String opt = "" ; if ( myOption . getOpt ( ) != null ) { opt += "-" + myOption . getOpt ( ) ; if ( myOption . getLongOpt ( ) != null ) opt += " (--" + myOption . getLongOpt ( ) + ")" ; } else opt += "--" + myOption . getLongOpt ( ) + "" ; if ( myOption . hasArg ( ) ) message = opt + " " + myOption . getValue ( ) ; else message = opt ; logger . info ( "with option: " + message ) ; } } | Displays all command line options in log messages . |
4,605 | public static String join ( String separator , List < String > topicsArray ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < topicsArray . size ( ) ; i ++ ) { if ( sb . length ( ) > 0 ) { sb . append ( "," ) ; } sb . append ( topicsArray . get ( i ) ) ; } return sb . toString ( ) ; } | Joins a list of Strings |
4,606 | public static int getPosition ( Term subTerm , Term term ) { int startingIndex = - 1 ; int j = 0 ; for ( int i = 0 ; i < term . getWords ( ) . size ( ) ; i ++ ) { if ( term . getWords ( ) . get ( i ) . equals ( subTerm . getWords ( ) . get ( j ) ) ) { j ++ ; if ( startingIndex == - 1 ) startingIndex = i ; } else { startingIndex = - 1 ; j = 0 ; } if ( j == subTerm . getWords ( ) . size ( ) ) return startingIndex ; } return - 1 ; } | Finds the index of appearance of a term s sub - term . |
4,607 | public static Iterable < String > split ( String separator , String stringToSplit ) { String [ ] StringArray = stringToSplit . split ( separator ) ; Iterable < String > iterable = Arrays . asList ( StringArray ) ; return iterable ; } | Splits a String into an iterable |
4,608 | public BlockingQueue < CollectionDocument > getQueue ( String queueName ) { Preconditions . checkArgument ( registry . containsKey ( queueName ) , "Queue %s does not exist" , queueName ) ; return registry . get ( queueName ) ; } | Retrieves and returns a registered queue by name . |
4,609 | private Document prepareTBXDocument ( ) throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder builder = factory . newDocumentBuilder ( ) ; Document tbxDocument = builder . newDocument ( ) ; Element martif = tbxDocument . createElement ( "martif" ) ; martif . setAttribute ( "type" , "TBX" ) ; tbxDocument . appendChild ( martif ) ; Element header = tbxDocument . createElement ( "martifHeader" ) ; martif . appendChild ( header ) ; Element fileDesc = tbxDocument . createElement ( "fileDesc" ) ; header . appendChild ( fileDesc ) ; Element encodingDesc = tbxDocument . createElement ( "encodingDesc" ) ; header . appendChild ( encodingDesc ) ; Element encodingP = tbxDocument . createElement ( "p" ) ; encodingP . setAttribute ( "type" , "XCSURI" ) ; encodingP . setTextContent ( "http://ttc-project.googlecode.com/files/ttctbx.xcs" ) ; encodingDesc . appendChild ( encodingP ) ; Element sourceDesc = tbxDocument . createElement ( "sourceDesc" ) ; Element p = tbxDocument . createElement ( "p" ) ; sourceDesc . appendChild ( p ) ; fileDesc . appendChild ( sourceDesc ) ; Element text = tbxDocument . createElement ( "text" ) ; martif . appendChild ( text ) ; Element body = tbxDocument . createElement ( "body" ) ; text . appendChild ( body ) ; return tbxDocument ; } | Prepare the TBX document that will contain the terms . |
4,610 | private void exportTBXDocument ( Document tbxDocument , Writer writer ) throws TransformerException { TransformerFactory transformerFactory = TransformerFactory . newInstance ( ) ; Transformer transformer = transformerFactory . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . ENCODING , "UTF-8" ) ; transformer . setOutputProperty ( OutputKeys . DOCTYPE_SYSTEM , "http://ttc-project.googlecode.com/files/tbxcore.dtd" ) ; transformer . setOutputProperty ( OutputKeys . STANDALONE , "yes" ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; try { transformer . setOutputProperty ( "{http://xml.apache.org/xslt}indent-amount" , "2" ) ; } catch ( IllegalArgumentException e ) { throw new TransformerException ( e ) ; } DOMSource source = new DOMSource ( tbxDocument ) ; StreamResult result = new StreamResult ( writer ) ; transformer . transform ( source , result ) ; } | Export the TBX document to a file specified in parameter . |
4,611 | public double [ ] generate ( WindowType windowType , int nSamples ) { int m = nSamples / 2 ; double r ; double pi = Math . PI ; double [ ] w = new double [ nSamples ] ; switch ( windowType ) { case BARTLETT : for ( int n = 0 ; n < nSamples ; n ++ ) { w [ n ] = 1.0f - Math . abs ( n - m ) / m ; } break ; case HANNING : r = pi / ( m + 1 ) ; for ( int n = - m ; n < m ; n ++ ) { w [ m + n ] = 0.5f + 0.5f * Math . cos ( n * r ) ; } break ; case HAMMING : r = pi / m ; for ( int n = - m ; n < m ; n ++ ) { w [ m + n ] = 0.54f + 0.46f * Math . cos ( n * r ) ; } break ; case BLACKMAN : r = pi / m ; for ( int n = - m ; n < m ; n ++ ) { w [ m + n ] = 0.42f + 0.5f * Math . cos ( n * r ) + 0.08f * Math . cos ( 2 * n * r ) ; } break ; default : for ( int n = 0 ; n < nSamples ; n ++ ) { w [ n ] = 1.0f ; } } return w ; } | Generate a window |
4,612 | public void toAssocRateVector ( Term t , CrossTable table , AssociationRate assocRateFunction , boolean normalize ) { double assocRate ; for ( Entry coterm : t . getContext ( ) . getEntries ( ) ) { ContextData contextData = computeContextData ( table , t , coterm . getCoTerm ( ) ) ; assocRate = assocRateFunction . getValue ( contextData ) ; t . getContext ( ) . setAssocRate ( coterm . getCoTerm ( ) , assocRate ) ; } if ( normalize ) t . getContext ( ) . normalize ( ) ; } | Normalize this vector according to a cross table and an association rate measure . |
4,613 | public static void validate ( byte [ ] cert , String pass ) throws Exception { try { KeyStore keyStore = KeyStore . getInstance ( ALGORITHM ) ; keyStore . load ( new ByteArrayInputStream ( cert ) , pass . toCharArray ( ) ) ; } catch ( Exception e ) { throw new Exception ( "Certificate is not valid!" , e ) ; } } | Check if the file provide is PKCS12 |
4,614 | private List < Reuters21578 > getReuters21578StoriesFromFile ( File file ) throws IOException { List < Reuters21578 > stories = new ArrayList < Reuters21578 > ( ) ; String s = FileUtils . readFileToString ( file , "UTF-8" ) ; List < String > storiesAsString = extractElementAsLines ( s , "REUTERS" ) ; for ( String storyAsString : storiesAsString ) { Reuters21578 reuters21578Story = getReuters21578StoryFromText ( storyAsString ) ; stories . add ( reuters21578Story ) ; } return stories ; } | Get a List of the Reuters21578Story Beans |
4,615 | protected String extractTextBetweenTags ( String stringContainingText , String tagname ) { String openTag = "<" + tagname . toUpperCase ( ) + ">" ; String closeTag = "</" + tagname . toUpperCase ( ) + ">" ; StringBuilder buf = new StringBuilder ( ) ; boolean record = false ; for ( int i = 0 ; i < stringContainingText . length ( ) - openTag . length ( ) ; i ++ ) { if ( stringContainingText . substring ( i , i + closeTag . length ( ) ) . equalsIgnoreCase ( closeTag ) ) { record = false ; break ; } if ( record ) { buf . append ( stringContainingText . charAt ( i ) ) ; } if ( stringContainingText . substring ( i , i + openTag . length ( ) ) . equalsIgnoreCase ( openTag ) ) { buf = new StringBuilder ( ) ; i += openTag . length ( ) - 1 ; record = true ; } } return buf . toString ( ) . trim ( ) ; } | Given some stringContainingText extracts the String between the tags |
4,616 | protected String extractAttribute ( String stringContainingAttributes , String attributeName ) { String attributeValue = "" ; stringContainingAttributes = stringContainingAttributes . replaceAll ( "<" , "" ) . replaceAll ( ">" , "" ) ; String [ ] keyValues = stringContainingAttributes . split ( " " ) ; for ( int i = 0 ; i < keyValues . length ; i ++ ) { String keyValue = keyValues [ i ] . trim ( ) ; String [ ] keyAndValue = keyValue . split ( "=" ) ; if ( keyAndValue [ 0 ] . equalsIgnoreCase ( attributeName ) ) { return keyAndValue [ 1 ] . substring ( 1 , keyAndValue [ 1 ] . length ( ) - 1 ) ; } } return attributeValue ; } | Given a String containing XML - like attributes and a key it extracts a value |
4,617 | public static byte [ ] randomBytes ( int n ) { byte [ ] buffer = new byte [ n ] ; if ( RandomUtils . secureRandom == null ) { try { RandomUtils . secureRandom = SecureRandom . getInstance ( ALGORITHM ) ; } catch ( NoSuchAlgorithmException e ) { e . printStackTrace ( ) ; } } RandomUtils . secureRandom . nextBytes ( buffer ) ; return buffer ; } | Generates a number random bytes specified by the user |
4,618 | public BilingualAlignmentService create ( ) { Preconditions . checkArgument ( sourceCorpus . isPresent ( ) , "No source indexed corpus given" ) ; Preconditions . checkArgument ( dico . isPresent ( ) , "No bilingual dictionary given" ) ; Preconditions . checkArgument ( targetCorpus . isPresent ( ) , "No target indexed corpus given" ) ; Injector sourceInjector = TermSuiteFactory . createExtractorInjector ( sourceCorpus . get ( ) ) ; Injector targetInjector = TermSuiteFactory . createExtractorInjector ( targetCorpus . get ( ) ) ; AlignerModule alignerModule = new AlignerModule ( sourceInjector , targetInjector , dico . get ( ) , distance ) ; Injector alignerInjector = Guice . createInjector ( alignerModule ) ; BilingualAlignmentService alignService = alignerInjector . getInstance ( BilingualAlignmentService . class ) ; return alignService ; } | Creates the bilingual single - word aligner . |
4,619 | public Collection < Collection < RegexOccurrence > > findDuplicates ( ) { Collection < Collection < RegexOccurrence > > setToReturn = Lists . newArrayList ( ) ; if ( ! this . occurrences . isEmpty ( ) ) { List < RegexOccurrence > sortedOcc = Lists . newArrayList ( this . occurrences ) ; Collections . sort ( sortedOcc , new Comparator < RegexOccurrence > ( ) { public int compare ( RegexOccurrence o1 , RegexOccurrence o2 ) { return ComparisonChain . start ( ) . compare ( o1 . getBegin ( ) , o2 . getBegin ( ) ) . compare ( o1 . getEnd ( ) , o2 . getEnd ( ) ) . result ( ) ; } } ) ; ListIterator < RegexOccurrence > it = sortedOcc . listIterator ( ) ; RegexOccurrence current ; List < RegexOccurrence > doublons = Lists . newArrayListWithCapacity ( 3 ) ; doublons . add ( it . next ( ) ) ; while ( it . hasNext ( ) ) { current = it . next ( ) ; if ( current . getBegin ( ) == doublons . get ( 0 ) . getBegin ( ) && current . getEnd ( ) == doublons . get ( 0 ) . getEnd ( ) ) { doublons . add ( current ) ; } else { if ( doublons . size ( ) > 1 ) setToReturn . add ( doublons ) ; doublons = Lists . newArrayListWithCapacity ( 3 ) ; doublons . add ( current ) ; } } if ( doublons . size ( ) > 1 ) setToReturn . add ( doublons ) ; } return setToReturn ; } | Finds duplicated occurrences in this buffer and returns them as a collection of dups lists . |
4,620 | public static Iterator < List < TermOccurrence > > occurrenceChunkIterator ( Collection < TermOccurrence > occurrences ) { List < TermOccurrence > asList = Lists . newArrayList ( occurrences ) ; Collections . sort ( asList , TermOccurrenceUtils . uimaNaturalOrder ) ; final Iterator < TermOccurrence > it = asList . iterator ( ) ; return new AbstractIterator < List < TermOccurrence > > ( ) { private List < TermOccurrence > currentChunk = Lists . newArrayList ( ) ; protected List < TermOccurrence > computeNext ( ) { while ( it . hasNext ( ) ) { TermOccurrence next = it . next ( ) ; if ( currentChunk . isEmpty ( ) || hasOverlappingOffsets ( next , currentChunk ) ) currentChunk . add ( next ) ; else { List < TermOccurrence > ret = copyAndReinit ( ) ; currentChunk . add ( next ) ; return ret ; } } if ( ! currentChunk . isEmpty ( ) ) { return copyAndReinit ( ) ; } else return endOfData ( ) ; } private List < TermOccurrence > copyAndReinit ( ) { List < TermOccurrence > copy = Lists . newArrayList ( currentChunk ) ; currentChunk = Lists . newArrayList ( ) ; return copy ; } } ; } | Returns a virtual iterator on chunks of an occurrence collection . |
4,621 | public static void removeOverlaps ( Collection < TermOccurrence > referenceSet , Collection < TermOccurrence > occurrenceSet ) { Iterator < TermOccurrence > it = occurrenceSet . iterator ( ) ; while ( it . hasNext ( ) ) { TermOccurrence occ = it . next ( ) ; for ( TermOccurrence refOcc : referenceSet ) { if ( occ . getSourceDocument ( ) . equals ( refOcc . getSourceDocument ( ) ) && areOffsetsOverlapping ( occ , refOcc ) ) { it . remove ( ) ; break ; } } } } | Removes from an occurrence set all occurrences that overlap at least one occurrence in a reference occurrence set . |
4,622 | public static boolean hasOverlappingOffsets ( TermOccurrence theOcc , Collection < TermOccurrence > theOccCollection ) { for ( TermOccurrence o : theOccCollection ) if ( areOffsetsOverlapping ( theOcc , o ) ) return true ; return false ; } | True if an occurrence set contains any element overlapping with the param occurrence . |
4,623 | public static boolean areOverlapping ( TermOccurrence a , TermOccurrence b ) { return a . getSourceDocument ( ) . equals ( b . getSourceDocument ( ) ) && areOffsetsOverlapping ( a , b ) ; } | Returns true if two occurrences are in the same document and their offsets overlap . |
4,624 | public static boolean overlaps ( TermOccurrence o1 , TermOccurrence o2 ) { return o1 . getSourceDocument ( ) . equals ( o2 . getSourceDocument ( ) ) && o1 . getBegin ( ) < o2 . getEnd ( ) && o2 . getBegin ( ) < o1 . getEnd ( ) ; } | True if both source documents are the same and if the offsets in the document overlaps . |
4,625 | public void login ( String username , String password ) throws ServletException { this . _getHttpServletRequest ( ) . login ( username , password ) ; } | The default behavior of this method is to call login on the wrapped request object . |
4,626 | public Part getPart ( String name ) throws IOException , ServletException { return this . _getHttpServletRequest ( ) . getPart ( name ) ; } | The default behavior of this method is to call getPart on the wrapped request object . |
4,627 | public static Map toMap ( final Object value , final Locale locale ) { return builder ( ) . locale ( locale ) . build ( ) . mapper ( ) . convertValue ( value , LinkedHashMap . class ) ; } | Returns a serialized version of the object as a Map . |
4,628 | protected static long deinterleave ( long value ) { value &= MAGIC [ 0 ] ; value = ( value ^ value >>> SHIFT [ 0 ] ) & MAGIC [ 1 ] ; value = ( value ^ value >>> SHIFT [ 1 ] ) & MAGIC [ 2 ] ; value = ( value ^ value >>> SHIFT [ 2 ] ) & MAGIC [ 3 ] ; value = ( value ^ value >>> SHIFT [ 3 ] ) & MAGIC [ 4 ] ; value = ( value ^ value >>> SHIFT [ 4 ] ) & MAGIC [ 5 ] ; return value ; } | Returns one of two 32 - bit values that were previously interleaved to produce a 64 - bit value . |
4,629 | public double distance ( final Coordinate c ) { final double dx = getX ( ) - c . getX ( ) ; final double dy = getY ( ) - c . getY ( ) ; return Math . sqrt ( dx * dx + dy * dy ) ; } | Computes the 2 - dimensional Euclidean distance to another location . The Z - ordinate is ignored . |
4,630 | public double distance3D ( final Coordinate c ) { final double dx = getX ( ) - c . getX ( ) ; final double dy = getY ( ) - c . getY ( ) ; final double dz = getZ ( ) - c . getZ ( ) ; return Math . sqrt ( dx * dx + dy * dy + dz * dz ) ; } | Computes the 3 - dimensional Euclidean distance to another location . |
4,631 | public boolean equals2D ( final Coordinate c , final double tolerance ) { if ( ! equalsWithTolerance ( this . getX ( ) , c . getX ( ) , tolerance ) ) { return false ; } if ( ! equalsWithTolerance ( this . getY ( ) , c . getY ( ) , tolerance ) ) { return false ; } return true ; } | Tests if another coordinate has the same values for the X and Y ordinates . The Z ordinate is ignored . |
4,632 | public boolean equals3D ( final Coordinate other ) { return getX ( ) == other . getX ( ) && getY ( ) == other . getY ( ) && ( getZ ( ) == other . getZ ( ) || Double . isNaN ( getZ ( ) ) && Double . isNaN ( other . getZ ( ) ) ) ; } | Tests if another coordinate has the same values for the X Y and Z ordinates . |
4,633 | private void check ( Class clazz ) { final Constructor < ? > [ ] constructors = clazz . getDeclaredConstructors ( ) ; if ( constructors . length > 1 ) { throw new AssertionError ( clazz + " has more than one constructor" ) ; } final Constructor < ? > constructor = constructors [ 0 ] ; constructor . setAccessible ( true ) ; if ( ! Modifier . isPrivate ( constructor . getModifiers ( ) ) ) { throw new AssertionError ( "Constructor of " + clazz + " must be private" ) ; } final Class < ? > [ ] parameterTypes = constructor . getParameterTypes ( ) ; if ( parameterTypes . length > 0 ) { if ( expectedParameters == null ) { throw new AssertionError ( clazz + " has non-default constructor with some parameters" ) ; } else { if ( ! Arrays . equals ( parameterTypes , expectedParameters ) ) { throw new AssertionError ( "Expected constructor with parameters " + getReadableClassesOutput ( expectedParameters ) + " but found constructor with parameters " + getReadableClassesOutput ( parameterTypes ) ) ; } else { return ; } } } try { constructor . newInstance ( ) ; } catch ( InstantiationException e ) { throw new RuntimeException ( "Can not instantiate instance of " + clazz , e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( InvocationTargetException e ) { final Throwable cause = e . getCause ( ) ; if ( expectedTypeOfException != null || expectedExceptionMessage != null ) { if ( expectedTypeOfException != null && ! expectedTypeOfException . equals ( cause . getClass ( ) ) ) { throw new IllegalStateException ( "For " + clazz + " expected exception of type = " + expectedTypeOfException + ", but was exception of type = " + e . getCause ( ) . getClass ( ) ) ; } if ( expectedExceptionMessage != null && ! expectedExceptionMessage . equals ( cause . getMessage ( ) ) ) { throw new IllegalStateException ( "For " + clazz + " expected exception message = '" + expectedExceptionMessage + "', but was = '" + cause . getMessage ( ) + "'" , e . getCause ( ) ) ; } } else { throw new IllegalStateException ( "For " + clazz + " no exception was expected" , e ) ; } } catch ( IllegalArgumentException e ) { throw new RuntimeException ( "Looks like constructor of " + clazz + " is not default" , e ) ; } } | Runs the check which will assert that particular class has one private constructor which throws or not throws exception . |
4,634 | private Collection < String > checkMethodNames ( Collection < HttpMethodConstraintElement > methodConstraints ) { Collection < String > methodNames = new HashSet < String > ( ) ; for ( HttpMethodConstraintElement methodConstraint : methodConstraints ) { String methodName = methodConstraint . getMethodName ( ) ; if ( ! methodNames . add ( methodName ) ) { throw new IllegalArgumentException ( "Duplicate HTTP method name: " + methodName ) ; } } return methodNames ; } | Checks for duplicate method names in methodConstraints . |
4,635 | public ObjectGraph excludeClasses ( Class < ? > ... classes ) { for ( Class < ? > c : classes ) { if ( c == null ) { throw new NullPointerException ( "Null class not allowed" ) ; } excludedClasses . add ( c ) ; } return this ; } | Exclude any object that extends from these classes . |
4,636 | public void traverse ( Object root ) { visited . clear ( ) ; toVisit . clear ( ) ; if ( root == null ) return ; addIfNotVisited ( root , root . getClass ( ) ) ; start ( ) ; } | Conducts a breath first search of the object graph . |
4,637 | private boolean isExcludedClass ( Class < ? > clazz ) { for ( Class < ? > c : excludedClasses ) { if ( c . isAssignableFrom ( clazz ) ) { return true ; } } return false ; } | Is the class on the excluded list . |
4,638 | private void addIfNotVisited ( Object object , Class < ? > clazz ) { if ( object != null && ! visited . containsKey ( object ) ) { toVisit . add ( object ) ; visited . put ( object , clazz ) ; } } | Add this object to be visited if it has not already been visited or scheduled to be . |
4,639 | private List < Field > getAllFields ( List < Field > fields , Class < ? > clazz ) { checkNotNull ( fields ) ; checkNotNull ( clazz ) ; fields . addAll ( Arrays . asList ( clazz . getDeclaredFields ( ) ) ) ; if ( clazz . getSuperclass ( ) != null ) { getAllFields ( fields , clazz . getSuperclass ( ) ) ; } return Collections . unmodifiableList ( fields ) ; } | Return all declared and inherited fields for this class . |
4,640 | Format identifyFormat ( String pom ) { for ( String separator : LINE_SEPARATORS ) { if ( pom . contains ( separator ) ) { return new Format ( separator ) ; } } throw new IllegalArgumentException ( "The pom.xml has no known line separator." ) ; } | Identifies the output format for the given POM . |
4,641 | public void channelClosed ( ChannelHandlerContext ctx , ChannelStateEvent e ) throws Exception { endpoint . onDisconnected ( ) ; super . channelClosed ( ctx , e ) ; } | of those events comes even though the channelConnected came . Using just channelClosed appears to be reliable . |
4,642 | public AnalyzedText analyze ( String text ) throws NetworkException , AnalysisException { if ( null == text ) { throw new RuntimeException ( "text param cannot be null." ) ; } QueryBuilder requestBody = generatePOSTBody ( ) ; try { requestBody . addParam ( "text" , text ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( "Could not url encode form params." ) ; } AnalyzedText response = sendRequest ( "" , requestBody . build ( ) , ContentType . FORM , "POST" , AnalyzedText . class ) ; response . createAnnotationLinks ( ) ; return response ; } | Makes a TextRazor request to analyze a string and returning TextRazor metadata . |
4,643 | public void addExtractor ( String extractor ) { if ( null == this . extractors ) { this . extractors = new ArrayList < String > ( ) ; } this . extractors . add ( extractor ) ; } | Adds a new extractor to the request . |
4,644 | public static String [ ] getServiceTypes ( ) { Set result = new HashSet ( ) ; Provider [ ] providers = Security . getProviders ( ) ; for ( int i = 0 ; i < providers . length ; i ++ ) { Set keys = providers [ i ] . keySet ( ) ; for ( Iterator it = keys . iterator ( ) ; it . hasNext ( ) ; ) { String key = ( String ) it . next ( ) ; key = key . split ( " " ) [ 0 ] ; if ( key . startsWith ( "Alg.Alias." ) ) { key = key . substring ( 10 ) ; } int ix = key . indexOf ( '.' ) ; result . add ( key . substring ( 0 , ix ) ) ; } } return ( String [ ] ) result . toArray ( new String [ result . size ( ) ] ) ; } | Exploratory part . This method returns all available services types |
4,645 | protected String tidy ( String pom ) throws MojoExecutionException { try { return POM_TIDY . tidy ( pom ) ; } catch ( XMLStreamException e ) { throw new MojoExecutionException ( e . getMessage ( ) , e ) ; } } | Tidy the given POM . |
4,646 | public InlineMenuRowBuilder removeLast ( ) { List < InlineMenuButton > buttons = buttons ( ) ; if ( buttons . size ( ) != 0 ) buttons . remove ( buttons . size ( ) - 1 ) ; return this ; } | Remove the last button in the stack |
4,647 | public Conversation begin ( ) { if ( ! virgin ) { throw new IllegalStateException ( "You can only start a virgin conversation!" ) ; } Extensions . get ( context . getBot ( ) , ConversationRegistry . class ) . registerConversation ( this ) ; if ( ! silent ) { SendableMessage response = currentPrompt . promptMessage ( context ) ; if ( response != null ) { sendMessage ( response ) ; } } return this ; } | Initiates the conversation with the first prompt registers the conversation in the registry . |
4,648 | public void end ( ) { if ( endCallback != null ) { endCallback . accept ( this , context ) ; } if ( currentPrompt != null ) { currentPrompt . conversationEnded ( context ) ; currentPrompt = null ; } Extensions . get ( context . getBot ( ) , ConversationRegistry . class ) . removeConversation ( this ) ; virgin = false ; } | Calls the conversation end method of the current prompt and removes conversation from registry . |
4,649 | public static TelegramBot login ( String authToken ) { try { HttpRequestWithBody request = Unirest . post ( API_URL + "bot" + authToken + "/getMe" ) ; HttpResponse < String > response = request . asString ( ) ; JSONObject jsonResponse = Utils . processResponse ( response ) ; if ( jsonResponse != null && Utils . checkResponseStatus ( jsonResponse ) ) { JSONObject result = jsonResponse . getJSONObject ( "result" ) ; return new TelegramBot ( authToken , result . getInt ( "id" ) , result . getString ( "first_name" ) , result . getString ( "username" ) ) ; } } catch ( UnirestException e ) { e . printStackTrace ( ) ; } return null ; } | Use this method to get a new TelegramBot instance with the selected auth token |
4,650 | public Chat getChat ( String chatID ) { try { MultipartBody request = Unirest . post ( getBotAPIUrl ( ) + "getChat" ) . field ( "chat_id" , chatID , "application/json; charset=utf8;" ) ; HttpResponse < String > response = request . asString ( ) ; JSONObject jsonResponse = Utils . processResponse ( response ) ; if ( jsonResponse != null && Utils . checkResponseStatus ( jsonResponse ) ) { JSONObject result = jsonResponse . getJSONObject ( "result" ) ; return ChatImpl . createChat ( result , this ) ; } } catch ( UnirestException e ) { e . printStackTrace ( ) ; } return null ; } | A method used to get a Chat object via the chats ID |
4,651 | public Message editMessageCaption ( Message oldMessage , String caption , InlineReplyMarkup inlineReplyMarkup ) { return this . editMessageCaption ( oldMessage . getChat ( ) . getId ( ) , oldMessage . getMessageId ( ) , caption , inlineReplyMarkup ) ; } | This allows you to edit the caption of any captionable message you have sent previously |
4,652 | public boolean answerInlineQuery ( String inlineQueryId , InlineQueryResponse inlineQueryResponse ) { if ( inlineQueryId != null && inlineQueryResponse != null ) { HttpResponse < String > response ; JSONObject jsonResponse ; try { MultipartBody requests = Unirest . post ( getBotAPIUrl ( ) + "answerInlineQuery" ) . field ( "inline_query_id" , inlineQueryId ) . field ( "results" , GSON . toJson ( inlineQueryResponse . getResults ( ) ) ) . field ( "cache_time" , inlineQueryResponse . getCacheTime ( ) ) . field ( "is_personal" , inlineQueryResponse . isPersonal ( ) ) . field ( "next_offset" , inlineQueryResponse . getNextOffset ( ) ) . field ( "switch_pm_text" , inlineQueryResponse . getSwitchPmText ( ) ) . field ( "switch_pm_parameter" , inlineQueryResponse . getSwitchPmParameter ( ) ) ; response = requests . asString ( ) ; jsonResponse = Utils . processResponse ( response ) ; if ( jsonResponse != null ) { if ( jsonResponse . getBoolean ( "result" ) ) return true ; } } catch ( UnirestException e ) { e . printStackTrace ( ) ; } } return false ; } | This allows you to respond to an inline query with an InlineQueryResponse object |
4,653 | public boolean kickChatMember ( String chatId , int userId ) { HttpResponse < String > response ; JSONObject jsonResponse ; try { MultipartBody request = Unirest . post ( getBotAPIUrl ( ) + "kickChatMember" ) . field ( "chat_id" , chatId , "application/json; charset=utf8;" ) . field ( "user_id" , userId ) ; response = request . asString ( ) ; jsonResponse = Utils . processResponse ( response ) ; if ( jsonResponse != null ) { if ( jsonResponse . getBoolean ( "result" ) ) return true ; } } catch ( UnirestException e ) { e . printStackTrace ( ) ; } return false ; } | Use this method to kick a user from a group or a supergroup . In the case of supergroups the user will not be able to return to the group on their own using invite links etc . unless unbanned first . The bot must be an administrator in the group for this to work |
4,654 | public boolean startUpdates ( boolean getPreviousUpdates ) { if ( updateManager == null ) updateManager = new RequestUpdatesManager ( this , getPreviousUpdates ) ; if ( ! updateManager . isRunning ( ) ) { updateManager . startUpdates ( ) ; return true ; } return false ; } | Use this method to start the update thread which will begin retrieving messages from the API and firing the relevant events for you to process the data |
4,655 | protected Number parseNumber ( String text ) { if ( INTEGER_PATTERN . matcher ( text ) . matches ( ) ) { return Integer . parseInt ( text ) ; } if ( DOUBLE_PATTERN . matcher ( text ) . matches ( ) ) { return Double . parseDouble ( text ) ; } if ( FLOAT_PATTERN . matcher ( text ) . matches ( ) ) { return Float . parseFloat ( text ) ; } return null ; } | Parses a number that matches the text null if no matches |
4,656 | public static < T extends Content > IgnoringPrompt < T > create ( ContentType type , SendableMessage promptMessage ) { return new IgnoringPrompt < > ( type , promptMessage ) ; } | Creates new prompt |
4,657 | public void handlePress ( CallbackQuery query ) { executeCallback ( ) ; if ( textCallback != null && inputGiven ) { inputGiven = false ; Conversation . builder ( query . getBotInstance ( ) ) . forWhom ( owner . getBaseMessage ( ) . getChat ( ) ) . silent ( true ) . prompts ( ) . last ( new TextPrompt ( ) { public boolean process ( ConversationContext context , TextContent input ) { textCallback . accept ( UserInputInlineMenuButton . this , input . getContent ( ) ) ; inputGiven = true ; return false ; } public SendableMessage promptMessage ( ConversationContext context ) { return null ; } } ) . build ( ) . begin ( ) ; } } | Initiates a conversation with the chat awaiting text input On input executes callback |
4,658 | public void handlePress ( CallbackQuery query ) { InlineMenu lastMenu = owner . getLastMenu ( ) ; if ( lastMenu != null ) { executeCallback ( ) ; owner . unregister ( ) ; lastMenu . start ( ) ; } } | If there is a last menu execute callback unregister the current menu and start the parent . |
4,659 | public static SendableTextMessageBuilder html ( String text ) { return builder ( ) . message ( text ) . parseMode ( ParseMode . HTML ) ; } | This builder will be created with the text you provide already added with HTML formatting enabled . |
4,660 | public Message messageAt ( ConversationPrompt prompt , Conversation conversation ) { return messageAt ( conversation . getPrompts ( ) . indexOf ( prompt ) ) ; } | Gets message sent at specified prompt |
4,661 | protected InlineKeyboardButton . InlineKeyboardButtonBuilder keyboardBuilder ( ) { return InlineKeyboardButton . builder ( ) . text ( text ) . callbackData ( "im." + owner . getInternalId ( ) + "." + row + "." + owner . rowAt ( row ) . indexOf ( this ) ) ; } | Sets the text of the button and the callback data to the following . |
4,662 | protected InlineMenu buildMenu ( Message base ) { InlineMenu menu = new InlineMenu ( base ) ; rows . forEach ( ( row ) -> row . buttons . forEach ( ( button ) -> button . assignMenu ( menu ) ) ) ; menu . userPredicate = userPredicate ; menu . rows = rows ; return menu ; } | Build a menu from message base . Adds & ; Registers all buttons . Applies user predicate . Applies rows . |
4,663 | public T allowedUser ( User allowedUser ) { this . userPredicate = ( user ) -> user . getId ( ) == allowedUser . getId ( ) ; return instance ( ) ; } | Allow a single user to use this menu |
4,664 | public static String generateRandomString ( int length ) { char [ ] chars = "abcdefghijklmnopqrstuvwxyz1234567890" . toCharArray ( ) ; StringBuilder sb = new StringBuilder ( ) ; Random random = new Random ( ) ; for ( int i = 0 ; i < 20 ; i ++ ) { char c = chars [ random . nextInt ( chars . length ) ] ; sb . append ( c ) ; } return sb . toString ( ) ; } | Generates a random alphanumeric String of the length specified |
4,665 | public static JSONObject processResponse ( HttpResponse < String > response ) { if ( response != null ) { if ( response . getStatus ( ) == 200 ) { try { return new JSONObject ( response . getBody ( ) ) ; } catch ( JSONException e ) { System . err . println ( "The API didn't return a JSON response. The actual response was " + response . getBody ( ) ) ; } } else { JSONObject jsonResponse = null ; try { jsonResponse = new JSONObject ( response . getBody ( ) ) ; } catch ( JSONException e ) { } if ( jsonResponse != null ) { System . err . println ( "The API returned the following error: " + jsonResponse . getString ( "description" ) ) ; } else { System . err . println ( "The API returned error code " + response . getStatus ( ) ) ; } } } return null ; } | This does some generic processing on HttpResponse objects returned by the Telegram Bot API |
4,666 | public static void processReplyContent ( MultipartBody multipartBody , ReplyingOptions replyingOptions ) { if ( replyingOptions . getReplyTo ( ) != 0 ) multipartBody . field ( "reply_to_message_id" , String . valueOf ( replyingOptions . getReplyTo ( ) ) , "application/json; charset=utf8;" ) ; if ( replyingOptions . getReplyMarkup ( ) != null ) { switch ( replyingOptions . getReplyMarkup ( ) . getType ( ) ) { case FORCE_REPLY : multipartBody . field ( "reply_markup" , TelegramBot . GSON . toJson ( replyingOptions . getReplyMarkup ( ) , ForceReply . class ) , "application/json; charset=utf8;" ) ; break ; case KEYBOARD_HIDE : multipartBody . field ( "reply_markup" , TelegramBot . GSON . toJson ( replyingOptions . getReplyMarkup ( ) , ReplyKeyboardHide . class ) , "application/json; charset=utf8;" ) ; break ; case KEYBOARD_REMOVE : multipartBody . field ( "reply_markup" , TelegramBot . GSON . toJson ( replyingOptions . getReplyMarkup ( ) , ReplyKeyboardRemove . class ) , "application/json; charset=utf8;" ) ; break ; case KEYBOARD_MARKUP : multipartBody . field ( "reply_markup" , TelegramBot . GSON . toJson ( replyingOptions . getReplyMarkup ( ) , ReplyKeyboardMarkup . class ) , "application/json; charset=utf8;" ) ; break ; case INLINE_KEYBOARD_MARKUP : multipartBody . field ( "reply_markup" , TelegramBot . GSON . toJson ( replyingOptions . getReplyMarkup ( ) , InlineKeyboardMarkup . class ) , "application/json; charset=utf8;" ) ; break ; } } } | This does generic processing of ReplyingOptions objects when sending a request to the API |
4,667 | public static void processInputFileField ( MultipartBody request , String fieldName , InputFile inputFile ) { String fileId = inputFile . getFileID ( ) ; if ( fileId != null ) { request . field ( fieldName , fileId , false ) ; } else if ( inputFile . getInputStream ( ) != null ) { request . field ( fieldName , new InputStreamBody ( inputFile . getInputStream ( ) , inputFile . getFileName ( ) ) , true ) ; } else { request . field ( fieldName , new FileContainer ( inputFile ) , true ) ; } } | Adds an input file to a request with the given field name . |
4,668 | public static InlineMenuBuilder builder ( TelegramBot bot , Chat forWhom ) { return new InlineMenuBuilder ( bot ) . forWhom ( forWhom ) ; } | Creates new builder initializes with the required Chat field |
4,669 | public InlineKeyboardMarkup toKeyboard ( ) { InlineKeyboardMarkup . InlineKeyboardMarkupBuilder builder = InlineKeyboardMarkup . builder ( ) ; if ( rows . isEmpty ( ) ) { return null ; } rows . stream ( ) . map ( InlineMenuRow :: toButtons ) . forEach ( builder :: addRow ) ; return builder . build ( ) ; } | Converts rows to the inline keyboard markup used by the Telegram API |
4,670 | public boolean handle ( CallbackQuery query , int row , int button ) { if ( ! validateCaller ( InlineMenuRegistry . class ) ) { throw new UnsupportedOperationException ( "Invalid caller! Caller must implement InlineMenuRegistry" ) ; } return ( userPredicate == null || userPredicate . test ( query . getFrom ( ) ) ) && row < rows . size ( ) && rowAt ( row ) . handle ( query , button ) ; } | Handle an inline query sent . Caller dependent throws exception if called from a class which doesn t implement InlineMenuRegistry |
4,671 | public void setMessageText ( SendableTextMessage . SendableTextMessageBuilder messageBuilder ) { SendableTextMessage message = messageBuilder . build ( ) ; baseMessage . getBotInstance ( ) . editMessageText ( baseMessage , message . getMessage ( ) , message . getParseMode ( ) , message . isDisableWebPagePreview ( ) , toKeyboard ( ) ) ; } | Set the text of the current message updates keyboard |
4,672 | public List < InlineKeyboardButton > toButtons ( ) { return buttons . stream ( ) . map ( InlineMenuButton :: toKeyboardButton ) . collect ( Collectors . toList ( ) ) ; } | Returns row as List< ; InlineKeyboardButtons> ; |
4,673 | public boolean handle ( CallbackQuery query , int button ) { if ( button < 0 || button > buttons . size ( ) ) { return false ; } buttonAt ( button ) . handlePress ( query ) ; return true ; } | Handle callback query |
4,674 | public SuperGroupChat getChat ( ) { return ( SuperGroupChat ) getMessage ( ) . getBotInstance ( ) . getChat ( ( ( MigrateToChatIDContent ) getMessage ( ) . getContent ( ) ) . getContent ( ) ) ; } | Gets the Chat that was migrated to that triggered this Event |
4,675 | public static AbstractMessage createInstance ( byte type ) { switch ( type ) { case EMPTY : return new EmptyMessageImpl ( ) ; case BYTES : return new BytesMessageImpl ( ) ; case MAP : return new MapMessageImpl ( ) ; case OBJECT : return new ObjectMessageImpl ( ) ; case STREAM : return new StreamMessageImpl ( ) ; case TEXT : return new TextMessageImpl ( ) ; default : throw new IllegalArgumentException ( "Unsupported message type : " + type ) ; } } | Create a message instance of the given type |
4,676 | public final void wakeUpConsumers ( ) throws JMSException { synchronized ( consumersMap ) { Iterator < AbstractMessageConsumer > allConsumers = consumersMap . values ( ) . iterator ( ) ; while ( allConsumers . hasNext ( ) ) { AbstractMessageConsumer consumer = allConsumers . next ( ) ; consumer . wakeUp ( ) ; } } } | Wake up all children consumers |
4,677 | protected final void registerConsumer ( AbstractMessageConsumer consumer ) { if ( consumersMap . put ( consumer . getId ( ) , consumer ) != null ) throw new IllegalArgumentException ( "Consumer " + consumer . getId ( ) + " already exists" ) ; } | Register a consumer |
4,678 | protected final void registerProducer ( AbstractMessageProducer producer ) { if ( producersMap . put ( producer . getId ( ) , producer ) != null ) throw new IllegalArgumentException ( "Producer " + producer . getId ( ) + " already exists" ) ; } | Register a producer |
4,679 | protected final void registerBrowser ( AbstractQueueBrowser browser ) { if ( browsersMap . put ( browser . getId ( ) , browser ) != null ) throw new IllegalArgumentException ( "Browser " + browser . getId ( ) + " already exists" ) ; } | Register a browser |
4,680 | protected final void unregisterConsumer ( AbstractMessageConsumer consumerToRemove ) { if ( consumersMap . remove ( consumerToRemove . getId ( ) ) == null ) log . warn ( "Unknown consumer : " + consumerToRemove ) ; } | Unregister a consumer |
4,681 | protected final void unregisterProducer ( AbstractMessageProducer producerToRemove ) { if ( producersMap . remove ( producerToRemove . getId ( ) ) == null ) log . warn ( "Unknown producer : " + producerToRemove ) ; } | Unregister a producer |
4,682 | protected final void unregisterBrowser ( AbstractQueueBrowser browserToRemove ) { if ( browsersMap . remove ( browserToRemove . getId ( ) ) == null ) log . warn ( "Unknown browser : " + browserToRemove ) ; } | Unregister a browser |
4,683 | private void closeRemainingBrowsers ( ) { List < AbstractQueueBrowser > browsersToClose = new ArrayList < > ( browsersMap . size ( ) ) ; synchronized ( browsersMap ) { browsersToClose . addAll ( browsersMap . values ( ) ) ; } for ( int n = 0 ; n < browsersToClose . size ( ) ; n ++ ) { QueueBrowser browser = browsersToClose . get ( n ) ; log . debug ( "Auto-closing unclosed browser : " + browser ) ; try { browser . close ( ) ; } catch ( Exception e ) { log . error ( "Could not close browser " + browser , e ) ; } } } | Close remaining browsers |
4,684 | public static Context getContext ( String jdniInitialContextFactoryName , String providerURL , Hashtable < String , Object > extraEnv ) throws NamingException { Hashtable < String , Object > env = new Hashtable < > ( ) ; env . put ( Context . INITIAL_CONTEXT_FACTORY , jdniInitialContextFactoryName ) ; env . put ( Context . PROVIDER_URL , providerURL ) ; if ( extraEnv != null ) env . putAll ( extraEnv ) ; return createJndiContext ( env ) ; } | Create a JNDI context for the current provider |
4,685 | public static SagaEnvironment create ( final TimeoutManager timeoutManager , final StateStorage storage , final Provider < CurrentExecutionContext > contextProvider , final Set < SagaModule > modules , final Set < SagaLifetimeInterceptor > interceptors , final InstanceResolver sagaInstanceResolver , final ModuleCoordinatorFactory coordinatorFactory ) { return new SagaEnvironment ( timeoutManager , storage , contextProvider , modules , interceptors , sagaInstanceResolver , coordinatorFactory ) ; } | Creates a new SagaEnvironment instance . |
4,686 | public synchronized void removeUpdatesForQueue ( String queueName ) { Iterator < TransactionItem > entries = items . iterator ( ) ; while ( entries . hasNext ( ) ) { TransactionItem item = entries . next ( ) ; if ( item . getDestination ( ) . getName ( ) . equals ( queueName ) ) entries . remove ( ) ; } } | Remove all pending updates for the given queue |
4,687 | public synchronized TransactionItem [ ] clear ( List < String > deliveredMessageIDs ) throws FFMQException { int len = deliveredMessageIDs . size ( ) ; TransactionItem [ ] itemsSnapshot = new TransactionItem [ len ] ; for ( int n = 0 ; n < len ; n ++ ) { String deliveredMessageID = deliveredMessageIDs . get ( len - n - 1 ) ; boolean found = false ; Iterator < TransactionItem > entries = items . iterator ( ) ; while ( entries . hasNext ( ) ) { TransactionItem item = entries . next ( ) ; if ( item . getMessageId ( ) . equals ( deliveredMessageID ) ) { found = true ; itemsSnapshot [ n ] = item ; entries . remove ( ) ; break ; } } if ( ! found ) throw new FFMQException ( "Message does not belong to transaction : " + deliveredMessageID , "INTERNAL_ERROR" ) ; } return itemsSnapshot ; } | Clear items by IDs from the transaction set and return a snapshot of the items |
4,688 | public synchronized TransactionItem [ ] clear ( ) { TransactionItem [ ] itemsSnapshot = items . toArray ( new TransactionItem [ items . size ( ) ] ) ; items . clear ( ) ; return itemsSnapshot ; } | Clear the set and return a snapshot of its content |
4,689 | public void start ( ) throws JMSException { if ( server == null ) { checkProperties ( ) ; log . info ( "Starting FFMQServerBean ..." ) ; Settings settings = loadConfig ( ) ; server = new FFMQServer ( engineName , settings ) ; server . start ( ) ; } } | Starts the server bean |
4,690 | public SagaInstanceInfo createNew ( final SagaType type ) { Saga newSaga = startNewSaga ( type . getSagaClass ( ) ) ; return SagaInstanceInfo . define ( newSaga , true ) ; } | Creates and initializes a new saga instance based on the provided type information . |
4,691 | private Saga startNewSaga ( final Class < ? extends Saga > sagaToStart ) { Saga createdSaga = null ; try { createdSaga = createNewSagaInstance ( sagaToStart ) ; createdSaga . createNewState ( ) ; SagaState newState = createdSaga . state ( ) ; newState . setSagaId ( UUID . randomUUID ( ) . toString ( ) ) ; newState . setType ( sagaToStart . getName ( ) ) ; } catch ( Exception ex ) { LOG . error ( "Unable to create new instance of saga type {}." , sagaToStart , ex ) ; } return createdSaga ; } | Starts a new saga by creating an instance and attaching a new saga state . |
4,692 | public Saga continueExisting ( final Class < ? extends Saga > sagaType , final SagaState state ) throws ExecutionException { Saga saga = createNewSagaInstance ( sagaType ) ; saga . setState ( state ) ; return saga ; } | Creates a new saga instance attaching an existing saga state . |
4,693 | public Saga continueExisting ( final String sagaTypeName , final SagaState state ) throws ExecutionException { return continueSaga ( sagaTypeName , state ) ; } | Create a new saga instance based on fully qualified name and the existing saga state . |
4,694 | public String getUUID ( ) { StringBuilder uuid = new StringBuilder ( 36 ) ; int i = ( int ) System . currentTimeMillis ( ) ; int j = seed . nextInt ( ) ; hexFormat ( i , uuid ) ; uuid . append ( fixedPart ) ; hexFormat ( j , uuid ) ; return uuid . toString ( ) ; } | Generate a new UUID |
4,695 | protected TimeoutId requestTimeout ( final long delay , final TimeUnit unit ) { return requestTimeout ( delay , unit , null , null ) ; } | Requests a timeout event to be sent back to this saga . |
4,696 | protected TimeoutId requestTimeout ( final long delay , final TimeUnit unit , final String name ) { return requestTimeout ( delay , unit , name , null ) ; } | Requests a timeout event with a specific name to this saga . The name can be used to distinguish the timeout if multiple ones have been requested by the saga . |
4,697 | protected TimeoutId requestTimeout ( final long delay , final TimeUnit unit , final Object data ) { return requestTimeout ( delay , unit , null , data ) ; } | Requests a timeout event attaching specific timeout data . This data is returned with the timeout message received . |
4,698 | protected TimeoutId requestTimeout ( final long delay , final TimeUnit unit , final String name , final Object data ) { return timeoutManager . requestTimeout ( context ( ) , state ( ) . getSagaId ( ) , delay , unit , name , data ) ; } | Requests a timeout event with a specific name and attached data . |
4,699 | protected AbstractResponsePacket process ( AbstractQueryPacket query ) throws JMSException { switch ( query . getType ( ) ) { case PacketType . Q_GET : return processGet ( ( GetQuery ) query ) ; case PacketType . Q_PUT : return processPut ( ( PutQuery ) query ) ; case PacketType . Q_COMMIT : return processCommit ( ( CommitQuery ) query ) ; case PacketType . Q_ACKNOWLEDGE : return processAcknowledge ( ( AcknowledgeQuery ) query ) ; case PacketType . Q_ROLLBACK : return processRollback ( ( RollbackQuery ) query ) ; case PacketType . Q_RECOVER : return processRecover ( ( RecoverQuery ) query ) ; case PacketType . Q_CREATE_SESSION : return processCreateSession ( ( CreateSessionQuery ) query ) ; case PacketType . Q_CLOSE_SESSION : return processCloseSession ( ( CloseSessionQuery ) query ) ; case PacketType . Q_CREATE_CONSUMER : return processCreateConsumer ( ( CreateConsumerQuery ) query ) ; case PacketType . Q_CREATE_DURABLE_SUBSCRIBER : return processCreateDurableSubscriber ( ( CreateDurableSubscriberQuery ) query ) ; case PacketType . Q_CREATE_BROWSER : return processCreateBrowser ( ( CreateBrowserQuery ) query ) ; case PacketType . Q_CREATE_BROWSER_ENUM : return processQueueBrowserGetEnumeration ( ( QueueBrowserGetEnumerationQuery ) query ) ; case PacketType . Q_BROWSER_ENUM_FETCH : return processQueueBrowserFetchElement ( ( QueueBrowserFetchElementQuery ) query ) ; case PacketType . Q_CLOSE_CONSUMER : return processCloseConsumer ( ( CloseConsumerQuery ) query ) ; case PacketType . Q_CLOSE_BROWSER : return processCloseBrowser ( ( CloseBrowserQuery ) query ) ; case PacketType . Q_CLOSE_BROWSER_ENUM : return processCloseBrowserEnumeration ( ( CloseBrowserEnumerationQuery ) query ) ; case PacketType . Q_CREATE_TEMP_QUEUE : return processCreateTemporaryQueue ( ( CreateTemporaryQueueQuery ) query ) ; case PacketType . Q_CREATE_TEMP_TOPIC : return processCreateTemporaryTopic ( ( CreateTemporaryTopicQuery ) query ) ; case PacketType . Q_DELETE_TEMP_QUEUE : return processDeleteTemporaryQueue ( ( DeleteTemporaryQueueQuery ) query ) ; case PacketType . Q_DELETE_TEMP_TOPIC : return processDeleteTemporaryTopic ( ( DeleteTemporaryTopicQuery ) query ) ; case PacketType . Q_OPEN_CONNECTION : return processOpenConnection ( ( OpenConnectionQuery ) query ) ; case PacketType . Q_START_CONNECTION : return processStartConnection ( ) ; case PacketType . Q_STOP_CONNECTION : return processStopConnection ( ) ; case PacketType . Q_SET_CLIENT_ID : return processSetClientID ( ( SetClientIDQuery ) query ) ; case PacketType . Q_UNSUBSCRIBE : return processUnsubscribe ( ( UnsubscribeQuery ) query ) ; case PacketType . Q_PREFETCH : return processPrefetch ( ( PrefetchQuery ) query ) ; case PacketType . Q_PING : return processPing ( ) ; case PacketType . Q_ROLLBACK_MESSAGE : return processRollbackMessage ( ( RollbackMessageQuery ) query ) ; default : throw new javax . jms . IllegalStateException ( "Unkown query type id : " + query . getType ( ) ) ; } } | Process an incoming packet |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.