idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
23,800
public static InternetPrintWriter createForEncoding ( OutputStream outputStream , boolean autoFlush , Charset charset ) { return new InternetPrintWriter ( new OutputStreamWriter ( outputStream , charset ) , autoFlush ) ; }
Creates a new InternetPrintWriter for given charset encoding .
23,801
protected Map < String , AbstractServer > createServices ( ServerSetup [ ] config , Managers mgr ) { Map < String , AbstractServer > srvc = new HashMap < > ( ) ; for ( ServerSetup setup : config ) { if ( srvc . containsKey ( setup . getProtocol ( ) ) ) { throw new IllegalArgumentException ( "Server '" + setup . getProtocol ( ) + "' was found at least twice in the array" ) ; } final String protocol = setup . getProtocol ( ) ; if ( protocol . startsWith ( ServerSetup . PROTOCOL_SMTP ) ) { srvc . put ( protocol , new SmtpServer ( setup , mgr ) ) ; } else if ( protocol . startsWith ( ServerSetup . PROTOCOL_POP3 ) ) { srvc . put ( protocol , new Pop3Server ( setup , mgr ) ) ; } else if ( protocol . startsWith ( ServerSetup . PROTOCOL_IMAP ) ) { srvc . put ( protocol , new ImapServer ( setup , mgr ) ) ; } } return srvc ; }
Create the required services according to the server setup
23,802
public void okResponse ( String responseCode , String message ) { untagged ( ) ; message ( OK ) ; responseCode ( responseCode ) ; message ( message ) ; end ( ) ; }
Writes an untagged OK response with the supplied response code and an optional message .
23,803
public void close ( ) { synchronized ( closeMonitor ) { if ( socket != null ) { try { socket . close ( ) ; } catch ( IOException e ) { log . warn ( "Can not close socket" , e ) ; } finally { socket = null ; } } session = null ; response = null ; } }
Resets the handler data to a basic state .
23,804
public static InputStream toStream ( String content , Charset charset ) { byte [ ] bytes = content . getBytes ( charset ) ; return new ByteArrayInputStream ( bytes ) ; }
Converts the string of given content to an input stream .
23,805
public GreenMailConfiguration build ( Properties properties ) { GreenMailConfiguration configuration = new GreenMailConfiguration ( ) ; String usersParam = properties . getProperty ( GREENMAIL_USERS ) ; if ( null != usersParam ) { String [ ] usersArray = usersParam . split ( "," ) ; for ( String user : usersArray ) { extractAndAddUser ( configuration , user ) ; } } String disabledAuthentication = properties . getProperty ( GREENMAIL_AUTH_DISABLED ) ; if ( null != disabledAuthentication ) { configuration . withDisabledAuthentication ( ) ; } return configuration ; }
Builds a configuration object based on given properties .
23,806
private ServerSetup [ ] createServerSetup ( ) { List < ServerSetup > setups = new ArrayList < > ( ) ; if ( smtpProtocol ) { smtpServerSetup = createTestServerSetup ( ServerSetup . SMTP ) ; setups . add ( smtpServerSetup ) ; } if ( smtpsProtocol ) { smtpsServerSetup = createTestServerSetup ( ServerSetup . SMTPS ) ; setups . add ( smtpsServerSetup ) ; } if ( pop3Protocol ) { setups . add ( createTestServerSetup ( ServerSetup . POP3 ) ) ; } if ( pop3sProtocol ) { setups . add ( createTestServerSetup ( ServerSetup . POP3S ) ) ; } if ( imapProtocol ) { setups . add ( createTestServerSetup ( ServerSetup . IMAP ) ) ; } if ( imapsProtocol ) { setups . add ( createTestServerSetup ( ServerSetup . IMAPS ) ) ; } return setups . toArray ( new ServerSetup [ setups . size ( ) ] ) ; }
Creates the server setup depending on the protocol flags .
23,807
public String tag ( ImapRequestLineReader request ) throws ProtocolException { CharacterValidator validator = new TagCharValidator ( ) ; return consumeWord ( request , validator ) ; }
Reads a command tag from the request .
23,808
public String astring ( ImapRequestLineReader request ) throws ProtocolException { char next = request . nextWordChar ( ) ; switch ( next ) { case '"' : return consumeQuoted ( request ) ; case '{' : return consumeLiteral ( request ) ; default : return atom ( request ) ; } }
Reads an argument of type astring from the request .
23,809
public String nstring ( ImapRequestLineReader request ) throws ProtocolException { char next = request . nextWordChar ( ) ; switch ( next ) { case '"' : return consumeQuoted ( request ) ; case '{' : return consumeLiteral ( request ) ; default : String value = atom ( request ) ; if ( "NIL" . equals ( value ) ) { return null ; } else { throw new ProtocolException ( "Invalid nstring value: valid values are '\"...\"', '{12} CRLF *CHAR8', and 'NIL'." ) ; } } }
Reads an argument of type nstring from the request .
23,810
public Date dateTime ( ImapRequestLineReader request ) throws ProtocolException { char next = request . nextWordChar ( ) ; String dateString ; if ( next == '"' ) { dateString = consumeQuoted ( request ) ; } else { throw new ProtocolException ( "DateTime values must be quoted." ) ; } try { return new SimpleDateFormat ( "dd-MMM-yyyy hh:mm:ss Z" , Locale . US ) . parse ( dateString ) ; } catch ( ParseException e ) { throw new ProtocolException ( "Invalid date format <" + dateString + ">, should comply to dd-MMM-yyyy hh:mm:ss Z" ) ; } }
Reads a date - time argument from the request .
23,811
protected String consumeWord ( ImapRequestLineReader request , CharacterValidator validator ) throws ProtocolException { StringBuilder atom = new StringBuilder ( ) ; char next = request . nextWordChar ( ) ; while ( ! isWhitespace ( next ) ) { if ( validator . isValid ( next ) ) { atom . append ( next ) ; request . consume ( ) ; } else { throw new ProtocolException ( "Invalid character: '" + next + '\'' ) ; } next = request . nextChar ( ) ; } return atom . toString ( ) ; }
Reads the next word from the request comprising all characters up to the next SPACE . Characters are tested by the supplied CharacterValidator and an exception is thrown if invalid characters are encountered .
23,812
protected void consumeChar ( ImapRequestLineReader request , char expected ) throws ProtocolException { char consumed = request . consume ( ) ; if ( consumed != expected ) { throw new ProtocolException ( "Expected:'" + expected + "' found:'" + consumed + '\'' ) ; } }
Consumes the next character in the request checking that it matches the expected one . This method should be used when the
23,813
protected String consumeQuoted ( ImapRequestLineReader request ) throws ProtocolException { consumeChar ( request , '"' ) ; StringBuilder quoted = new StringBuilder ( ) ; char next = request . nextChar ( ) ; while ( next != '"' ) { if ( next == '\\' ) { request . consume ( ) ; next = request . nextChar ( ) ; if ( ! isQuotedSpecial ( next ) ) { throw new ProtocolException ( "Invalid escaped character in quote: '" + next + '\'' ) ; } } quoted . append ( next ) ; request . consume ( ) ; next = request . nextChar ( ) ; } consumeChar ( request , '"' ) ; return quoted . toString ( ) ; }
Reads a quoted string value from the request .
23,814
public Flags flagList ( ImapRequestLineReader request ) throws ProtocolException { Flags flags = new Flags ( ) ; request . nextWordChar ( ) ; consumeChar ( request , '(' ) ; CharacterValidator validator = new NoopCharValidator ( ) ; String nextWord = consumeWord ( request , validator ) ; while ( ! nextWord . endsWith ( ")" ) ) { setFlag ( nextWord , flags ) ; nextWord = consumeWord ( request , validator ) ; } if ( nextWord . length ( ) > 1 ) { setFlag ( nextWord . substring ( 0 , nextWord . length ( ) - 1 ) , flags ) ; } return flags ; }
Reads a flags argument from the request .
23,815
public long number ( ImapRequestLineReader request ) throws ProtocolException { String digits = consumeWord ( request , new DigitCharValidator ( ) ) ; return Long . parseLong ( digits ) ; }
Reads an argument of type number from the request .
23,816
public IdRange [ ] parseIdRange ( ImapRequestLineReader request ) throws ProtocolException { CharacterValidator validator = new MessageSetCharValidator ( ) ; String nextWord = consumeWord ( request , validator ) ; int commaPos = nextWord . indexOf ( ',' ) ; if ( commaPos == - 1 ) { return new IdRange [ ] { IdRange . parseRange ( nextWord ) } ; } List < IdRange > rangeList = new ArrayList < > ( ) ; int pos = 0 ; while ( commaPos != - 1 ) { String range = nextWord . substring ( pos , commaPos ) ; IdRange set = IdRange . parseRange ( range ) ; rangeList . add ( set ) ; pos = commaPos + 1 ; commaPos = nextWord . indexOf ( ',' , pos ) ; } String range = nextWord . substring ( pos ) ; rangeList . add ( IdRange . parseRange ( range ) ) ; return rangeList . toArray ( new IdRange [ rangeList . size ( ) ] ) ; }
Reads a message set argument and parses into an IdSet . Currently only supports a single range of values .
23,817
public ServerSetup [ ] build ( Properties properties ) { List < ServerSetup > serverSetups = new ArrayList < > ( ) ; String hostname = properties . getProperty ( "greenmail.hostname" , ServerSetup . getLocalHostAddress ( ) ) ; long serverStartupTimeout = Long . parseLong ( properties . getProperty ( "greenmail.startup.timeout" , "-1" ) ) ; addDefaultSetups ( hostname , properties , serverSetups ) ; addTestSetups ( hostname , properties , serverSetups ) ; for ( String protocol : ServerSetup . PROTOCOLS ) { addSetup ( hostname , protocol , properties , serverSetups ) ; } for ( ServerSetup setup : serverSetups ) { if ( properties . containsKey ( GREENMAIL_VERBOSE ) ) { setup . setVerbose ( true ) ; } if ( serverStartupTimeout >= 0L ) { setup . setServerStartupTimeout ( serverStartupTimeout ) ; } } return serverSetups . toArray ( new ServerSetup [ serverSetups . size ( ) ] ) ; }
Creates a server setup based on provided properties .
23,818
public static String format ( Flags flags ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( '(' ) ; if ( flags . contains ( Flags . Flag . ANSWERED ) ) { buf . append ( "\\Answered " ) ; } if ( flags . contains ( Flags . Flag . DELETED ) ) { buf . append ( "\\Deleted " ) ; } if ( flags . contains ( Flags . Flag . DRAFT ) ) { buf . append ( "\\Draft " ) ; } if ( flags . contains ( Flags . Flag . FLAGGED ) ) { buf . append ( "\\Flagged " ) ; } if ( flags . contains ( Flags . Flag . RECENT ) ) { buf . append ( "\\Recent " ) ; } if ( flags . contains ( Flags . Flag . SEEN ) ) { buf . append ( "\\Seen " ) ; } String [ ] userFlags = flags . getUserFlags ( ) ; if ( null != userFlags ) { for ( String uf : userFlags ) { buf . append ( uf ) . append ( ' ' ) ; } } if ( buf . length ( ) > 1 ) { buf . setLength ( buf . length ( ) - 1 ) ; } buf . append ( ')' ) ; return buf . toString ( ) ; }
Returns IMAP formatted String of MessageFlags for named user
23,819
public void eol ( ) throws ProtocolException { char next = nextChar ( ) ; while ( next == ' ' ) { consume ( ) ; next = nextChar ( ) ; } if ( next == '\r' ) { consume ( ) ; next = nextChar ( ) ; } if ( next != '\n' ) { throw new ProtocolException ( "Expected end-of-line, found more character(s): " + next ) ; } dumpLine ( ) ; }
Moves the request line reader to end of the line checking that no non - space character are found .
23,820
public void read ( byte [ ] holder ) throws ProtocolException { int readTotal = 0 ; try { while ( readTotal < holder . length ) { int count = input . read ( holder , readTotal , holder . length - readTotal ) ; if ( count == - 1 ) { throw new ProtocolException ( "Unexpected end of stream." ) ; } readTotal += count ; } nextSeen = false ; nextChar = 0 ; } catch ( IOException e ) { throw new ProtocolException ( "Error reading from stream." , e ) ; } }
Reads and consumes a number of characters from the underlying reader filling the byte array provided .
23,821
public void commandContinuationRequest ( ) throws ProtocolException { try { output . write ( '+' ) ; output . write ( ' ' ) ; output . write ( 'O' ) ; output . write ( 'K' ) ; output . write ( '\r' ) ; output . write ( '\n' ) ; output . flush ( ) ; } catch ( IOException e ) { throw new ProtocolException ( "Unexpected exception in sending command continuation request." , e ) ; } }
Sends a server command continuation request + back to the client requesting more data to be sent .
23,822
public static void createUsers ( GreenMailOperations greenMail , InternetAddress ... addresses ) { for ( InternetAddress address : addresses ) { greenMail . setUser ( address . getAddress ( ) , address . getAddress ( ) ) ; } }
Create users for the given array of addresses . The passwords will be set to the email addresses .
23,823
public static boolean containsUid ( IdRange [ ] idRanges , long uid ) { if ( null != idRanges && idRanges . length > 0 ) { for ( IdRange range : idRanges ) { if ( range . includes ( uid ) ) { return true ; } } } return false ; }
Checks if ranges contain the uid
23,824
SimpleJsonEncoder appendToJSON ( final String key , final Object value ) { if ( closed ) { throw new IllegalStateException ( "Encoder already closed" ) ; } if ( value != null ) { appendKey ( key ) ; if ( value instanceof Number ) { sb . append ( value . toString ( ) ) ; } else { sb . append ( QUOTE ) . append ( escapeString ( value . toString ( ) ) ) . append ( QUOTE ) ; } } return this ; }
Append field with quotes and escape characters added if required .
23,825
SimpleJsonEncoder appendToJSONUnquoted ( final String key , final Object value ) { if ( closed ) { throw new IllegalStateException ( "Encoder already closed" ) ; } if ( value != null ) { appendKey ( key ) ; sb . append ( value ) ; } return this ; }
Append field with quotes and escape characters added in the key if required . The value is added without quotes and any escape characters .
23,826
@ SuppressWarnings ( "checkstyle:illegalcatch" ) private boolean sendMessage ( final byte [ ] messageToSend ) { try { connectionPool . execute ( new PooledObjectConsumer < TcpConnection > ( ) { public void accept ( final TcpConnection tcpConnection ) throws IOException { tcpConnection . write ( messageToSend ) ; } } ) ; } catch ( final Exception e ) { addError ( String . format ( "Error sending message via tcp://%s:%s" , getGraylogHost ( ) , getGraylogPort ( ) ) , e ) ; return false ; } return true ; }
Send message to socket s output stream .
23,827
public void run ( ) { try { startBarrier . await ( ) ; int idleCount = 0 ; while ( ! isRunning . compareAndSet ( idleCount > lingerIterations && pidToProcessMap . isEmpty ( ) , false ) ) { idleCount = ( ! shutdown && process ( ) ) ? 0 : ( idleCount + 1 ) ; } } catch ( Exception e ) { isRunning . set ( false ) ; } }
The primary run loop of the event processor .
23,828
public static String dump ( final int displayOffset , final byte [ ] data , final int offset , final int len ) { StringBuilder sb = new StringBuilder ( ) ; Formatter formatter = new Formatter ( sb ) ; StringBuilder ascii = new StringBuilder ( ) ; int dataNdx = offset ; final int maxDataNdx = offset + len ; final int lines = ( len + 16 ) / 16 ; for ( int i = 0 ; i < lines ; i ++ ) { ascii . append ( " |" ) ; formatter . format ( "%08x " , displayOffset + ( i * 16 ) ) ; for ( int j = 0 ; j < 16 ; j ++ ) { if ( dataNdx < maxDataNdx ) { byte b = data [ dataNdx ++ ] ; formatter . format ( "%02x " , b ) ; ascii . append ( ( b > MIN_VISIBLE && b < MAX_VISIBLE ) ? ( char ) b : ' ' ) ; } else { sb . append ( " " ) ; } if ( j == 7 ) { sb . append ( ' ' ) ; } } ascii . append ( '|' ) ; sb . append ( ascii ) . append ( '\n' ) ; ascii . setLength ( 0 ) ; } formatter . close ( ) ; return sb . toString ( ) ; }
Dump an array of bytes in hexadecimal .
23,829
public void run ( ) { try { startBarrier . await ( ) ; int idleCount = 0 ; while ( ! isRunning . compareAndSet ( idleCount > LINGER_ITERATIONS && deadPool . isEmpty ( ) && completionKeyToProcessMap . isEmpty ( ) , false ) ) { idleCount = ( ! shutdown && process ( ) ) ? 0 : ( idleCount + 1 ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; isRunning . set ( false ) ; } }
The primary run loop of the kqueue event processor .
23,830
public Snackbar actionLabel ( CharSequence actionButtonLabel ) { mActionLabel = actionButtonLabel ; if ( snackbarAction != null ) { snackbarAction . setText ( mActionLabel ) ; } return this ; }
Sets the action label to be displayed if any . Note that if this is not set the action button will not be displayed
23,831
public static void setBackgroundDrawable ( View view , Drawable drawable ) { if ( android . os . Build . VERSION . SDK_INT < android . os . Build . VERSION_CODES . JELLY_BEAN ) { view . setBackgroundDrawable ( drawable ) ; } else { view . setBackground ( drawable ) ; } }
Set a Background Drawable using the appropriate Android version api call
23,832
public void visitRequire ( String module , int access , String version ) { if ( mv != null ) { mv . visitRequire ( module , access , version ) ; } }
Visits a dependence of the current module .
23,833
public void visitExport ( String packaze , int access , String ... modules ) { if ( mv != null ) { mv . visitExport ( packaze , access , modules ) ; } }
Visit an exported package of the current module .
23,834
public void visitOpen ( String packaze , int access , String ... modules ) { if ( mv != null ) { mv . visitOpen ( packaze , access , modules ) ; } }
Visit an open package of the current module .
23,835
private int [ ] readTypeAnnotations ( final MethodVisitor mv , final Context context , int u , boolean visible ) { char [ ] c = context . buffer ; int [ ] offsets = new int [ readUnsignedShort ( u ) ] ; u += 2 ; for ( int i = 0 ; i < offsets . length ; ++ i ) { offsets [ i ] = u ; int target = readInt ( u ) ; switch ( target >>> 24 ) { case 0x00 : case 0x01 : case 0x16 : u += 2 ; break ; case 0x13 : case 0x14 : case 0x15 : u += 1 ; break ; case 0x40 : case 0x41 : for ( int j = readUnsignedShort ( u + 1 ) ; j > 0 ; -- j ) { int start = readUnsignedShort ( u + 3 ) ; int length = readUnsignedShort ( u + 5 ) ; createLabel ( start , context . labels ) ; createLabel ( start + length , context . labels ) ; u += 6 ; } u += 3 ; break ; case 0x47 : case 0x48 : case 0x49 : case 0x4A : case 0x4B : u += 4 ; break ; default : u += 3 ; break ; } int pathLength = readByte ( u ) ; if ( ( target >>> 24 ) == 0x42 ) { TypePath path = pathLength == 0 ? null : new TypePath ( b , u ) ; u += 1 + 2 * pathLength ; u = readAnnotationValues ( u + 2 , c , true , mv . visitTryCatchAnnotation ( target , path , readUTF8 ( u , c ) , visible ) ) ; } else { u = readAnnotationValues ( u + 3 + 2 * pathLength , c , true , null ) ; } } return offsets ; }
Parses a type annotation table to find the labels and to visit the try catch block annotations .
23,836
private void visitImplicitFirstFrame ( ) { int frameIndex = startFrame ( 0 , descriptor . length ( ) + 1 , 0 ) ; if ( ( access & Opcodes . ACC_STATIC ) == 0 ) { if ( ( access & ACC_CONSTRUCTOR ) == 0 ) { frame [ frameIndex ++ ] = Frame . OBJECT | cw . addType ( cw . thisName ) ; } else { frame [ frameIndex ++ ] = Frame . UNINITIALIZED_THIS ; } } int i = 1 ; loop : while ( true ) { int j = i ; switch ( descriptor . charAt ( i ++ ) ) { case 'Z' : case 'C' : case 'B' : case 'S' : case 'I' : frame [ frameIndex ++ ] = Frame . INTEGER ; break ; case 'F' : frame [ frameIndex ++ ] = Frame . FLOAT ; break ; case 'J' : frame [ frameIndex ++ ] = Frame . LONG ; break ; case 'D' : frame [ frameIndex ++ ] = Frame . DOUBLE ; break ; case '[' : while ( descriptor . charAt ( i ) == '[' ) { ++ i ; } if ( descriptor . charAt ( i ) == 'L' ) { ++ i ; while ( descriptor . charAt ( i ) != ';' ) { ++ i ; } } frame [ frameIndex ++ ] = Frame . type ( cw , descriptor . substring ( j , ++ i ) ) ; break ; case 'L' : while ( descriptor . charAt ( i ) != ';' ) { ++ i ; } frame [ frameIndex ++ ] = Frame . OBJECT | cw . addType ( descriptor . substring ( j + 1 , i ++ ) ) ; break ; default : break loop ; } } frame [ 1 ] = frameIndex - 3 ; endFrame ( ) ; }
Visit the implicit first frame of this method .
23,837
Item newStringishItem ( final int type , final String value ) { key2 . set ( type , value , null , null ) ; Item result = get ( key2 ) ; if ( result == null ) { pool . put12 ( type , newUTF8 ( value ) ) ; result = new Item ( index ++ , key2 ) ; put ( result ) ; } return result ; }
Adds a string reference a class reference a method type a module or a package to the constant pool of the class being build . Does nothing if the constant pool already contains a similar item .
23,838
public void visitParameter ( String name , int access ) { if ( mv != null ) { mv . visitParameter ( name , access ) ; } }
Visits a parameter of this method .
23,839
public void visitMethodInsn ( int opcode , String owner , String name , String desc , boolean itf ) { if ( mv != null ) { mv . visitMethodInsn ( opcode , owner , name , desc , itf ) ; } }
Visits a method instruction . A method instruction is an instruction that invokes a method .
23,840
public AnnotationVisitor visitLocalVariableAnnotation ( int typeRef , TypePath typePath , Label [ ] start , Label [ ] end , int [ ] index , String desc , boolean visible ) { if ( mv != null ) { return mv . visitLocalVariableAnnotation ( typeRef , typePath , start , end , index , desc , visible ) ; } return null ; }
Visits an annotation on a local variable type .
23,841
public void setHeader ( String header ) { headerLabel . getElement ( ) . setInnerSafeHtml ( SafeHtmlUtils . fromString ( header ) ) ; addStyleName ( CssName . WITH_HEADER ) ; ListItem item = new ListItem ( headerLabel ) ; UiHelper . addMousePressedHandlers ( item ) ; item . setStyleName ( CssName . COLLECTION_HEADER ) ; insert ( item , 0 ) ; }
Sets the header of the collection component .
23,842
public void setHtml ( String html ) { this . html = html ; if ( widget != null ) { if ( widget . isAttached ( ) ) { tooltipElement . find ( "span" ) . html ( html != null ? html : "" ) ; } else { widget . addAttachHandler ( event -> tooltipElement . find ( "span" ) . html ( html != null ? html : "" ) ) ; } } else { GWT . log ( "Please initialize the Target widget." , new IllegalStateException ( ) ) ; } }
Set the html as value inside the tooltip .
23,843
public void addItem ( T value , String text , boolean reload ) { values . add ( value ) ; listBox . addItem ( text , keyFactory . generateKey ( value ) ) ; if ( reload ) { reload ( ) ; } }
Adds an item to the list box specifying an initial value for the item .
23,844
public void addItem ( T value , Direction dir , String text ) { addItem ( value , dir , text , true ) ; }
Adds an item to the list box specifying its direction and an initial value for the item .
23,845
public void removeValue ( T value , boolean reload ) { int idx = getIndex ( value ) ; if ( idx >= 0 ) { removeItemInternal ( idx , reload ) ; } }
Removes a value from the list box . Nothing is done if the value isn t on the list box .
23,846
public void clear ( ) { values . clear ( ) ; listBox . clear ( ) ; clearStatusText ( ) ; if ( emptyPlaceHolder != null ) { insertEmptyPlaceHolder ( emptyPlaceHolder ) ; } reload ( ) ; if ( isAllowBlank ( ) ) { addBlankItemIfNeeded ( ) ; } }
Removes all items from the list box .
23,847
public String [ ] getItemsSelected ( ) { List < String > selected = new LinkedList < > ( ) ; for ( int i = getIndexOffset ( ) ; i < listBox . getItemCount ( ) ; i ++ ) { if ( listBox . isItemSelected ( i ) ) { selected . add ( listBox . getValue ( i ) ) ; } } return selected . toArray ( new String [ selected . size ( ) ] ) ; }
Returns all selected values of the list box or empty array if none .
23,848
public void setValueSelected ( T value , boolean selected ) { int idx = getIndex ( value ) ; if ( idx >= 0 ) { setItemSelectedInternal ( idx , selected ) ; } }
Sets whether an individual list value is selected .
23,849
public int getIndex ( T value ) { int count = getItemCount ( ) ; for ( int i = 0 ; i < count ; i ++ ) { if ( Objects . equals ( getValue ( i ) , value ) ) { return i ; } } return - 1 ; }
Gets the index of the specified value .
23,850
public HandlerRegistration addSearchFinishHandler ( final SearchFinishEvent . SearchFinishHandler handler ) { return addHandler ( handler , SearchFinishEvent . TYPE ) ; }
This handler will be triggered when search is finish
23,851
public HandlerRegistration addSearchNoResultHandler ( final SearchNoResultEvent . SearchNoResultHandler handler ) { return addHandler ( handler , SearchNoResultEvent . TYPE ) ; }
This handler will be triggered when there s no search result
23,852
public void setSize ( ButtonSize size ) { if ( this . size != null ) { removeStyleName ( this . size . getCssName ( ) ) ; } this . size = size ; if ( size != null ) { addStyleName ( size . getCssName ( ) ) ; } }
Set the buttons size .
23,853
public void setText ( String text ) { span . setText ( text ) ; if ( ! span . isAttached ( ) ) { add ( span ) ; } }
Set the buttons span text .
23,854
public static < E extends Enum < ? extends Style . HasCssName > > E fromStyleName ( final String styleName , final Class < E > enumClass , final E defaultValue ) { return EnumHelper . fromStyleName ( styleName , enumClass , defaultValue , true ) ; }
Returns first enum constant found ..
23,855
public void stopAnimation ( ) { if ( widget != null ) { widget . removeStyleName ( "animated" ) ; widget . removeStyleName ( transition . getCssName ( ) ) ; widget . removeStyleName ( CssName . INFINITE ) ; } }
Stop an animation .
23,856
public void clear ( ) { valueBoxBase . setText ( "" ) ; clearStatusText ( ) ; if ( getPlaceholder ( ) == null || getPlaceholder ( ) . isEmpty ( ) ) { label . removeStyleName ( CssName . ACTIVE ) ; } }
Resets the text box by removing its content and resetting visual state .
23,857
protected void updateLabelActiveStyle ( ) { if ( this . valueBoxBase . getText ( ) != null && ! this . valueBoxBase . getText ( ) . isEmpty ( ) ) { label . addStyleName ( CssName . ACTIVE ) ; } else { label . removeStyleName ( CssName . ACTIVE ) ; } }
Updates the style of the field label according to the field value if the field value is empty - null or - removes the label active style else will add the active style to the field label .
23,858
protected void checkActiveState ( Widget child ) { String href = child . getElement ( ) . getAttribute ( "href" ) ; String url = Window . Location . getHref ( ) ; int pos = url . indexOf ( "#" ) ; String location = pos >= 0 ? url . substring ( pos , url . length ( ) ) : "" ; if ( ! href . isEmpty ( ) && location . startsWith ( href ) ) { ListItem li = findListItemParent ( child ) ; if ( li != null ) { makeActive ( li ) ; } } else if ( child instanceof HasWidgets ) { for ( Widget w : ( HasWidgets ) child ) { checkActiveState ( w ) ; } } }
Checks if this child holds the current active state . If the child is or contains the active state it is applied .
23,859
public void setActive ( boolean active ) { this . active = active ; if ( parent != null ) { fireCollapsibleHandler ( ) ; removeStyleName ( CssName . ACTIVE ) ; if ( header != null ) { header . removeStyleName ( CssName . ACTIVE ) ; } if ( active ) { if ( parent != null && parent . isAccordion ( ) ) { parent . clearActive ( ) ; } addStyleName ( CssName . ACTIVE ) ; if ( header != null ) { header . addStyleName ( CssName . ACTIVE ) ; } } if ( body != null ) { body . setDisplay ( active ? Display . BLOCK : Display . NONE ) ; } } else { GWT . log ( "Please make sure that the Collapsible parent is attached or existed." , new IllegalStateException ( ) ) ; } }
Make this item active .
23,860
public void setDateMin ( Date dateMin ) { this . dateMin = dateMin ; if ( isAttached ( ) && dateMin != null ) { getPicker ( ) . set ( "min" , JsDate . create ( ( double ) dateMin . getTime ( ) ) ) ; } }
Set the minimum date limit .
23,861
public void setDateMax ( Date dateMax ) { this . dateMax = dateMax ; if ( isAttached ( ) && dateMax != null ) { getPicker ( ) . set ( "max" , JsDate . create ( ( double ) dateMax . getTime ( ) ) ) ; } }
Set the maximum date limit .
23,862
protected Date getPickerDate ( ) { try { JsDate pickerDate = getPicker ( ) . get ( "select" ) . obj ; return new Date ( ( long ) pickerDate . getTime ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return null ; } }
Get the pickers date .
23,863
public void setSelectionType ( MaterialDatePickerType selectionType ) { this . selectionType = selectionType ; switch ( selectionType ) { case MONTH_DAY : options . selectMonths = true ; break ; case YEAR_MONTH_DAY : options . selectYears = yearsToDisplay ; options . selectMonths = true ; break ; case YEAR : options . selectYears = yearsToDisplay ; options . selectMonths = false ; break ; } }
Set the pickers selection type .
23,864
public void setAutoClose ( boolean autoClose ) { this . autoClose = autoClose ; if ( autoCloseHandlerRegistration != null ) { autoCloseHandlerRegistration . removeHandler ( ) ; autoCloseHandlerRegistration = null ; } if ( autoClose ) { autoCloseHandlerRegistration = registerHandler ( addValueChangeHandler ( event -> close ( ) ) ) ; } }
Enables or disables auto closing when selecting a date .
23,865
public void setAllowBlank ( boolean allowBlank ) { this . allowBlank = allowBlank ; if ( ! allowBlank ) { if ( blankValidator == null ) { blankValidator = createBlankValidator ( ) ; } setupBlurValidation ( ) ; addValidator ( blankValidator ) ; } else { removeValidator ( blankValidator ) ; } }
Enable or disable the default blank validator .
23,866
protected String ensureTextColorFormat ( String textColor ) { String formatted = "" ; boolean mainColor = true ; for ( String style : textColor . split ( " " ) ) { if ( mainColor ) { if ( ! style . endsWith ( "-text" ) ) { style += "-text" ; } mainColor = false ; } else { if ( ! style . startsWith ( "text-" ) ) { style = " text-" + style ; } } formatted += style ; } return formatted ; }
Allow for the use of text shading and auto formatting .
23,867
public void selectTab ( ) { for ( Widget child : getChildren ( ) ) { if ( child instanceof HasHref ) { String href = ( ( HasHref ) child ) . getHref ( ) ; if ( parent != null && ! href . isEmpty ( ) ) { parent . selectTab ( href . replaceAll ( "[^a-zA-Z\\d\\s:]" , "" ) ) ; parent . reload ( ) ; break ; } } } }
Select this tab item .
23,868
public static String format ( String pattern , Object ... arguments ) { String msg = pattern ; if ( arguments != null ) { for ( int index = 0 ; index < arguments . length ; index ++ ) { msg = msg . replaceAll ( "\\{" + ( index + 1 ) + "\\}" , String . valueOf ( arguments [ index ] ) ) ; } } return msg ; }
Format the message using the pattern and the arguments .
23,869
public void setValue ( Boolean value , boolean fireEvents ) { boolean oldValue = getValue ( ) ; if ( value ) { input . getElement ( ) . setAttribute ( "checked" , "true" ) ; } else { input . getElement ( ) . removeAttribute ( "checked" ) ; } if ( fireEvents && oldValue != value ) { ValueChangeEvent . fire ( this , getValue ( ) ) ; } }
Set the value of switch component .
23,870
public static < E extends Style . HasCssName , F extends Enum < ? extends Style . HasCssName > > void addUniqueEnumStyleName ( final UIObject uiObject , final Class < F > enumClass , final E style ) { removeEnumStyleNames ( uiObject , enumClass ) ; addEnumStyleName ( uiObject , style ) ; }
Convenience method for first removing all enum style constants and then adding the single one .
23,871
public static void toggleStyleName ( final UIObject uiObject , final boolean toggleStyle , final String styleName ) { if ( toggleStyle ) { uiObject . addStyleName ( styleName ) ; } else { uiObject . removeStyleName ( styleName ) ; } }
Toggles a style name on a ui object
23,872
protected void setupRegistration ( ) { if ( isServiceWorkerSupported ( ) ) { Navigator . serviceWorker . register ( getResource ( ) ) . then ( object -> { logger . info ( "Service worker has been successfully registered" ) ; registration = ( ServiceWorkerRegistration ) object ; onRegistered ( new ServiceEvent ( ) , registration ) ; observeLifecycle ( registration ) ; setupOnControllerChangeEvent ( ) ; setupOnMessageEvent ( ) ; setupOnErrorEvent ( ) ; return null ; } , error -> { logger . info ( "ServiceWorker registration failed: " + error ) ; return null ; } ) ; } else { logger . info ( "Service worker is not supported by this browser." ) ; } }
Initial setup of the service worker registration .
23,873
public HandlerRegistration addChangeHandler ( final ChangeHandler handler ) { return getRangeInputElement ( ) . addDomHandler ( handler , ChangeEvent . getType ( ) ) ; }
Register the ChangeHandler to become notified if the user changes the slider . The Handler is called when the user releases the mouse only at the end of the slide operation .
23,874
public ViewPort then ( Functions . Func1 < ViewPortChange > then , ViewPortFallback fallback ) { assert then != null : "'then' callback cannot be null" ; this . then = then ; this . fallback = fallback ; return load ( ) ; }
Load the view port execution .
23,875
protected ViewPort load ( ) { resize = Window . addResizeHandler ( event -> { execute ( event . getWidth ( ) , event . getHeight ( ) ) ; } ) ; execute ( window ( ) . width ( ) , ( int ) window ( ) . height ( ) ) ; return viewPort ; }
Load the windows resize handler with initial view port detection .
23,876
public static String format ( String format ) { if ( format == null ) { format = DEFAULT_FORMAT ; } else { if ( format . contains ( "M" ) ) { format = format . replace ( "M" , "m" ) ; } if ( format . contains ( "Y" ) ) { format = format . replace ( "Y" , "y" ) ; } if ( format . contains ( "D" ) ) { format = format . replace ( "D" , "d" ) ; } } return format ; }
Will auto format the given string to provide support for pickadate . js formats .
23,877
public void setWidth ( int width ) { this . width = width ; getElement ( ) . getStyle ( ) . setWidth ( width , Style . Unit . PX ) ; }
Set the menu s width in pixels .
23,878
public void setAccordion ( boolean accordion ) { getElement ( ) . setAttribute ( "data-collapsible" , accordion ? CssName . ACCORDION : CssName . EXPANDABLE ) ; reload ( ) ; }
Configure if you want this collapsible container to accordion its child elements or use expandable .
23,879
public String getInvalidMessage ( String key ) { return invalidMessageOverride == null ? messageMixin . lookup ( key , messageValueArgs ) : MessageFormat . format ( invalidMessageOverride , messageValueArgs ) ; }
Gets the invalid message .
23,880
public void installApp ( Functions . Func callback ) { if ( isPwaSupported ( ) ) { appInstaller = new AppInstaller ( callback ) ; appInstaller . prompt ( ) ; } }
Will prompt a user the Add to Homescreen feature
23,881
public void show ( ) { if ( ! ( container instanceof RootPanel ) ) { if ( ! ( container instanceof MaterialDialog ) ) { container . getElement ( ) . getStyle ( ) . setPosition ( Style . Position . RELATIVE ) ; } div . getElement ( ) . getStyle ( ) . setPosition ( Style . Position . ABSOLUTE ) ; } if ( scrollDisabled ) { RootPanel . get ( ) . getElement ( ) . getStyle ( ) . setOverflow ( Style . Overflow . HIDDEN ) ; } if ( type == LoaderType . CIRCULAR ) { div . setStyleName ( CssName . VALIGN_WRAPPER + " " + CssName . LOADER_WRAPPER ) ; div . add ( preLoader ) ; } else if ( type == LoaderType . PROGRESS ) { div . setStyleName ( CssName . VALIGN_WRAPPER + " " + CssName . PROGRESS_WRAPPER ) ; progress . getElement ( ) . getStyle ( ) . setProperty ( "margin" , "auto" ) ; div . add ( progress ) ; } container . add ( div ) ; }
Shows the Loader component
23,882
public void hide ( ) { div . removeFromParent ( ) ; if ( scrollDisabled ) { RootPanel . get ( ) . getElement ( ) . getStyle ( ) . setOverflow ( Style . Overflow . AUTO ) ; } if ( type == LoaderType . CIRCULAR ) { preLoader . removeFromParent ( ) ; } else if ( type == LoaderType . PROGRESS ) { progress . removeFromParent ( ) ; } }
Hides the Loader component
23,883
public static void detectAndApply ( Widget widget ) { if ( ! widget . isAttached ( ) ) { widget . addAttachHandler ( event -> { if ( event . isAttached ( ) ) { detectAndApply ( ) ; } } ) ; } else { detectAndApply ( ) ; } }
Detect and apply waves now or when the widget is attached .
23,884
public void setType ( CheckBoxType type ) { this . type = type ; switch ( type ) { case FILLED : Element input = DOM . getChild ( getElement ( ) , 0 ) ; input . setAttribute ( "class" , CssName . FILLED_IN ) ; break ; case INTERMEDIATE : addStyleName ( type . getCssName ( ) + "-checkbox" ) ; break ; default : addStyleName ( type . getCssName ( ) ) ; break ; } }
Setting the type of Checkbox .
23,885
ArgumentsBuilder param ( String param , Integer value ) { if ( value != null ) { args . add ( param ) ; args . add ( value . toString ( ) ) ; } return this ; }
Adds a parameter to the argument list if the given integer is non - null . If the value is null then the argument list remains unchanged .
23,886
ArgumentsBuilder param ( String param , String value ) { if ( value != null ) { args . add ( param ) ; args . add ( value ) ; } return this ; }
Adds a parameter that requires a string argument to the argument list . If the given argument is null then the argument list remains unchanged .
23,887
protected List < String > arguments ( ) { List < String > args = new ArgumentsBuilder ( ) . flag ( "-v" , verbose ) . flag ( "--package-dir" , packageDir ) . param ( "-d" , outputDirectory . getPath ( ) ) . param ( "-p" , packageName ) . map ( "--package:" , packageNameMap ( ) ) . param ( "--class-prefix" , classPrefix ) . param ( "--param-prefix" , parameterPrefix ) . param ( "--chunk-size" , chunkSize ) . flag ( "--no-dispatch-client" , ! generateDispatchClient ) . flag ( "--dispatch-as" , generateDispatchAs ) . param ( "--dispatch-version" , dispatchVersion ) . flag ( "--no-runtime" , ! generateRuntime ) . intersperse ( "--wrap-contents" , wrapContents ) . param ( "--protocol-file" , protocolFile ) . param ( "--protocol-package" , protocolPackage ) . param ( "--attribute-prefix" , attributePrefix ) . flag ( "--prepend-family" , prependFamily ) . flag ( "--blocking" , ! async ) . flag ( "--lax-any" , laxAny ) . flag ( "--no-varargs" , ! varArgs ) . flag ( "--ignore-unknown" , ignoreUnknown ) . flag ( "--autopackages" , autoPackages ) . flag ( "--mutable" , mutable ) . flag ( "--visitor" , visitor ) . getArguments ( ) ; return unmodifiableList ( args ) ; }
Returns the command line options to be used for scalaxb excluding the input file names .
23,888
Map < String , String > packageNameMap ( ) { if ( packageNames == null ) { return emptyMap ( ) ; } Map < String , String > names = new LinkedHashMap < String , String > ( ) ; for ( PackageName name : packageNames ) { names . put ( name . getUri ( ) , name . getPackage ( ) ) ; } return names ; }
Returns a map of URIs to package name as specified by the packageNames parameter .
23,889
public static String placeholders ( final int numberOfPlaceholders ) { if ( numberOfPlaceholders == 1 ) { return "?" ; } else if ( numberOfPlaceholders == 0 ) { return "" ; } else if ( numberOfPlaceholders < 0 ) { throw new IllegalArgumentException ( "numberOfPlaceholders must be >= 0, but was = " + numberOfPlaceholders ) ; } final StringBuilder stringBuilder = new StringBuilder ( ( numberOfPlaceholders * 2 ) - 1 ) ; for ( int i = 0 ; i < numberOfPlaceholders ; i ++ ) { stringBuilder . append ( '?' ) ; if ( i != numberOfPlaceholders - 1 ) { stringBuilder . append ( ',' ) ; } } return stringBuilder . toString ( ) ; }
Generates required number of placeholders as string .
23,890
public Tuple get ( RowKey key ) { AssociationOperation result = currentState . get ( key ) ; if ( result == null ) { return cleared ? null : snapshot . get ( key ) ; } else if ( result . getType ( ) == REMOVE ) { return null ; } return result . getValue ( ) ; }
Returns the association row with the given key .
23,891
public void remove ( RowKey key ) { currentState . put ( key , new AssociationOperation ( key , null , REMOVE ) ) ; }
Removes the row with the specified key from this association .
23,892
public boolean isEmpty ( ) { int snapshotSize = cleared ? 0 : snapshot . size ( ) ; if ( snapshotSize == 0 && currentState . isEmpty ( ) ) { return true ; } if ( snapshotSize > currentState . size ( ) ) { return false ; } return size ( ) == 0 ; }
Whether this association contains no rows .
23,893
public int size ( ) { int size = cleared ? 0 : snapshot . size ( ) ; for ( Map . Entry < RowKey , AssociationOperation > op : currentState . entrySet ( ) ) { switch ( op . getValue ( ) . getType ( ) ) { case PUT : if ( cleared || ! snapshot . containsKey ( op . getKey ( ) ) ) { size ++ ; } break ; case REMOVE : if ( ! cleared && snapshot . containsKey ( op . getKey ( ) ) ) { size -- ; } break ; } } return size ; }
Returns the number of rows within this association .
23,894
public Iterable < RowKey > getKeys ( ) { if ( currentState . isEmpty ( ) ) { if ( cleared ) { return Collections . emptyList ( ) ; } else { return snapshot . getRowKeys ( ) ; } } else { Set < RowKey > keys = CollectionHelper . newLinkedHashSet ( cleared ? currentState . size ( ) : snapshot . size ( ) + currentState . size ( ) ) ; if ( ! cleared ) { for ( RowKey rowKey : snapshot . getRowKeys ( ) ) { keys . add ( rowKey ) ; } } for ( Map . Entry < RowKey , AssociationOperation > op : currentState . entrySet ( ) ) { switch ( op . getValue ( ) . getType ( ) ) { case PUT : keys . add ( op . getKey ( ) ) ; break ; case REMOVE : keys . remove ( op . getKey ( ) ) ; break ; } } return keys ; } }
Returns all keys of all rows contained within this association .
23,895
public Object getColumnValue ( String columnName ) { for ( int j = 0 ; j < columnNames . length ; j ++ ) { if ( columnNames [ j ] . equals ( columnName ) ) { return columnValues [ j ] ; } } return null ; }
Get the value of the specified column .
23,896
public boolean contains ( String column ) { for ( String columnName : columnNames ) { if ( columnName . equals ( column ) ) { return true ; } } return false ; }
Check if a column is part of the row key columns .
23,897
private void loadResourceFile ( URL configurationResourceUrl , Properties hotRodConfiguration ) { if ( configurationResourceUrl != null ) { try ( InputStream openStream = configurationResourceUrl . openStream ( ) ) { hotRodConfiguration . load ( openStream ) ; } catch ( IOException e ) { throw log . failedLoadingHotRodConfigurationProperties ( e ) ; } } }
Load the properties from the resource file if one is specified
23,898
private static < D extends DatastoreConfiguration < G > , G extends GlobalContext < ? , ? > > AppendableConfigurationContext invokeOptionConfigurator ( OptionConfigurator configurator ) { ConfigurableImpl configurable = new ConfigurableImpl ( ) ; configurator . configure ( configurable ) ; return configurable . getContext ( ) ; }
Invokes the given configurator obtaining the correct global context type via the datastore configuration type of the current datastore provider .
23,899
public boolean isKeyColumn ( String columnName ) { for ( String keyColumName : getColumnNames ( ) ) { if ( keyColumName . equals ( columnName ) ) { return true ; } } return false ; }
Whether the given column is part of this key family or not .