idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
11,000
private void getTCerts ( ) { GetTCertBatchRequest req = new GetTCertBatchRequest ( this . member . getName ( ) , this . member . getEnrollment ( ) , this . member . getTCertBatchSize ( ) , attrs ) ; try { List < TCert > tcerts = this . memberServices . getTCertBatch ( req ) ; for ( TCert tcert : tcerts ) { this . tcerts . push ( tcert ) ; } } catch ( GetTCertBatchException e ) { } }
Call member services to get more tcerts
11,001
static public void main ( String [ ] args ) { String propertyValue = args [ 0 ] ; logger . info ( "Property Value: " + propertyValue ) ; String encryptedValue = encryptor . encryptPropertyValue ( propertyValue ) ; logger . info ( "Encrypted Value: " + encryptedValue ) ; }
The main method for this application .
11,002
public static Builder getNodeConfig ( String clusterName , String nodeName , String networkHost , String homePath , boolean nodeIngest ) { return Settings . builder ( ) . put ( "node.name" , nodeName ) . put ( "cluster.name" , clusterName ) . put ( "network.host" , networkHost ) . put ( "path.home" , homePath ) . put ( "transport.type" , "netty4" ) . put ( "http.type" , "netty4" ) . put ( "node.ingest" , nodeIngest ) ; }
Gets node config .
11,003
protected void init ( ) { JButton testButton = new JButton ( ) ; oldDayBackgroundColor = testButton . getBackground ( ) ; selectedColor = new Color ( 160 , 160 , 160 ) ; Date date = calendar . getTime ( ) ; calendar = Calendar . getInstance ( locale ) ; calendar . setTime ( date ) ; drawDayNames ( ) ; drawDays ( ) ; }
Initilizes the locale specific names for the days of the week .
11,004
private void drawDayNames ( ) { int firstDayOfWeek = calendar . getFirstDayOfWeek ( ) ; DateFormatSymbols dateFormatSymbols = new DateFormatSymbols ( locale ) ; dayNames = dateFormatSymbols . getShortWeekdays ( ) ; int day = firstDayOfWeek ; for ( int i = 0 ; i < 7 ; i ++ ) { if ( maxDayCharacters > 0 && maxDayCharacters < 5 ) { if ( dayNames [ day ] . length ( ) >= maxDayCharacters ) { dayNames [ day ] = dayNames [ day ] . substring ( 0 , maxDayCharacters ) ; } } days [ i ] . setText ( dayNames [ day ] ) ; if ( day == 1 ) { days [ i ] . setForeground ( sundayForeground ) ; } else { days [ i ] . setForeground ( weekdayForeground ) ; } if ( day < 7 ) { day ++ ; } else { day -= 6 ; } } }
Draws the day names of the day columnes .
11,005
protected void initDecorations ( ) { for ( int x = 0 ; x < 7 ; x ++ ) { days [ x ] . setContentAreaFilled ( decorationBackgroundVisible ) ; days [ x ] . setBorderPainted ( decorationBordersVisible ) ; days [ x ] . invalidate ( ) ; days [ x ] . repaint ( ) ; weeks [ x ] . setContentAreaFilled ( decorationBackgroundVisible ) ; weeks [ x ] . setBorderPainted ( decorationBordersVisible ) ; weeks [ x ] . invalidate ( ) ; weeks [ x ] . repaint ( ) ; } }
Initializes both day names and weeks of the year .
11,006
protected void drawWeeks ( ) { Calendar tmpCalendar = ( Calendar ) calendar . clone ( ) ; for ( int i = 1 ; i < 7 ; i ++ ) { tmpCalendar . set ( Calendar . DAY_OF_MONTH , ( i * 7 ) - 6 ) ; int week = tmpCalendar . get ( Calendar . WEEK_OF_YEAR ) ; String buttonText = Integer . toString ( week ) ; if ( week < 10 ) { buttonText = "0" + buttonText ; } weeks [ i ] . setText ( buttonText ) ; if ( ( i == 5 ) || ( i == 6 ) ) { weeks [ i ] . setVisible ( days [ i * 7 ] . isVisible ( ) ) ; } } }
Hides and shows the week buttons .
11,007
public void setDay ( int d ) { if ( d < 1 ) { d = 1 ; } Calendar tmpCalendar = ( Calendar ) calendar . clone ( ) ; tmpCalendar . set ( Calendar . DAY_OF_MONTH , 1 ) ; tmpCalendar . add ( Calendar . MONTH , 1 ) ; tmpCalendar . add ( Calendar . DATE , - 1 ) ; int maxDaysInMonth = tmpCalendar . get ( Calendar . DATE ) ; if ( d > maxDaysInMonth ) { d = maxDaysInMonth ; } int oldDay = day ; day = d ; if ( selectedDay != null ) { selectedDay . setBackground ( oldDayBackgroundColor ) ; selectedDay . repaint ( ) ; } for ( int i = 7 ; i < 49 ; i ++ ) { if ( days [ i ] . getText ( ) . equals ( Integer . toString ( day ) ) ) { selectedDay = days [ i ] ; selectedDay . setBackground ( selectedColor ) ; break ; } } if ( alwaysFireDayProperty ) { firePropertyChange ( "day" , 0 , day ) ; } else { firePropertyChange ( "day" , oldDay , day ) ; } }
Sets the day . This is a bound property .
11,008
public void setMonth ( int month ) { calendar . set ( Calendar . MONTH , month ) ; int maxDays = calendar . getActualMaximum ( Calendar . DAY_OF_MONTH ) ; int adjustedDay = day ; if ( day > maxDays ) { adjustedDay = maxDays ; setDay ( adjustedDay ) ; } drawDays ( ) ; }
Sets a specific month . This is needed for correct graphical representation of the days .
11,009
public void setForeground ( Color foreground ) { super . setForeground ( foreground ) ; if ( days != null ) { for ( int i = 7 ; i < 49 ; i ++ ) { days [ i ] . setForeground ( foreground ) ; } drawDays ( ) ; } }
Sets the foregroundColor color .
11,010
public void actionPerformed ( ActionEvent e ) { JButton button = ( JButton ) e . getSource ( ) ; String buttonText = button . getText ( ) ; int day = new Integer ( buttonText ) . intValue ( ) ; setDay ( day ) ; }
JDayChooser is the ActionListener for all day buttons .
11,011
public void setEnabled ( boolean enabled ) { super . setEnabled ( enabled ) ; for ( short i = 0 ; i < days . length ; i ++ ) { if ( days [ i ] != null ) { days [ i ] . setEnabled ( enabled ) ; } } for ( short i = 0 ; i < weeks . length ; i ++ ) { if ( weeks [ i ] != null ) { weeks [ i ] . setEnabled ( enabled ) ; } } }
Enable or disable the JDayChooser .
11,012
public void setWeekOfYearVisible ( boolean weekOfYearVisible ) { if ( weekOfYearVisible == this . weekOfYearVisible ) { return ; } else if ( weekOfYearVisible ) { add ( weekPanel , BorderLayout . WEST ) ; } else { remove ( weekPanel ) ; } this . weekOfYearVisible = weekOfYearVisible ; validate ( ) ; dayPanel . validate ( ) ; }
In some Countries it is often usefull to know in which week of the year a date is .
11,013
public void setDecorationBackgroundColor ( Color decorationBackgroundColor ) { this . decorationBackgroundColor = decorationBackgroundColor ; if ( days != null ) { for ( int i = 0 ; i < 7 ; i ++ ) { days [ i ] . setBackground ( decorationBackgroundColor ) ; } } if ( weeks != null ) { for ( int i = 0 ; i < 7 ; i ++ ) { weeks [ i ] . setBackground ( decorationBackgroundColor ) ; } } }
Sets the background of days and weeks of year buttons .
11,014
public void updateUI ( ) { super . updateUI ( ) ; setFont ( Font . decode ( "Dialog Plain 11" ) ) ; if ( weekPanel != null ) { weekPanel . updateUI ( ) ; } if ( initialized ) { if ( "Windows" . equals ( UIManager . getLookAndFeel ( ) . getID ( ) ) ) { setDayBordersVisible ( false ) ; setDecorationBackgroundVisible ( true ) ; setDecorationBordersVisible ( false ) ; } else { setDayBordersVisible ( true ) ; setDecorationBackgroundVisible ( decorationBackgroundVisible ) ; setDecorationBordersVisible ( decorationBordersVisible ) ; } } }
Updates the UI and sets the day button preferences .
11,015
public void close ( ) throws IOException { synchronized ( lock ) { decoder = null ; if ( in != null ) { in . close ( ) ; in = null ; } } }
Closes this reader . This implementation closes the source InputStream and releases all local storage .
11,016
public int read ( ) throws IOException { synchronized ( lock ) { if ( ! isOpen ( ) ) { throw new IOException ( "InputStreamReader is closed." ) ; } char buf [ ] = new char [ 1 ] ; return read ( buf , 0 , 1 ) != - 1 ? buf [ 0 ] : - 1 ; } }
Reads a single character from this reader and returns it as an integer with the two higher - order bytes set to 0 . Returns - 1 if the end of the reader has been reached . The byte value is either obtained from converting bytes in this reader s buffer or by first filling the buffer from the source InputStream and then reading from the buffer .
11,017
public boolean dependsOn ( DependencyNode dependency ) { boolean dependsDirectly = dependenciesVia . contains ( dependency ) ; if ( dependsDirectly ) return true ; for ( DependencyNode reqDependency : dependency . dependantsVia ) { if ( dependsOn ( reqDependency ) ) return true ; } return false ; }
Directly or indirectly
11,018
public static String tryToTrimToSize ( String s , int length , boolean trimSuffix ) { if ( s == null || s . isEmpty ( ) ) { return s ; } else if ( s . length ( ) <= length ) { return s ; } else if ( s . contains ( File . separator ) ) { String before = s . substring ( 0 , s . lastIndexOf ( File . separator ) ) ; String after = s . substring ( s . lastIndexOf ( File . separator ) ) ; if ( ! trimSuffix && length - after . length ( ) > 4 ) { return Strings . tryToTrimToSize ( before , length - after . length ( ) , true ) + after ; } else { return Strings . tryToTrimToSize ( before , length - 3 , true ) + File . separator + ".." ; } } else { return ".." ; } }
Try to trim a String to the given size .
11,019
public int getShowYear ( ) { Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( getDate ( ) ) ; return cal . get ( Calendar . YEAR ) ; }
Get year val from text field
11,020
public int getShowMonth ( ) { Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( getDate ( ) ) ; return cal . get ( Calendar . MONDAY ) ; }
Get month val from text field
11,021
void selectDay ( int year , int month , int day ) { Calendar cal = Calendar . getInstance ( ) ; cal . set ( year , month , day ) ; Date date = cal . getTime ( ) ; this . field . setText ( simpleDateFormat . format ( date ) ) ; if ( popup != null ) { popup . hide ( ) ; popup = null ; } }
Set date to text field
11,022
public static void datePicker ( JTextField field , String format , DateFilter filter ) { new DatePicker ( field , format , filter ) ; }
Add a date picker to a text field with date format
11,023
public static void dateTimePicker ( JTextField field , String format , DateFilter filter ) { new DateTimePicker ( field , format , filter ) ; }
Add a time picker to a text field with time format
11,024
public int fillWindow ( ByteBuffer buffer ) { assert ! finishing ; if ( readPos >= bufSize - keepSizeAfter ) moveWindow ( ) ; int len = buffer . remaining ( ) ; if ( len > bufSize - writePos ) len = bufSize - writePos ; buffer . get ( buf , writePos , len ) ; writePos += len ; if ( writePos >= keepSizeAfter ) readLimit = writePos - keepSizeAfter ; processPendingBytes ( ) ; return len ; }
Copies new data into the LZEncoder s buffer .
11,025
private void handlePhotoPrivacySelection ( int photoPrivacyIndex , String albumName , String albumGraphPath ) { FacebookSettingsActivity activity = ( FacebookSettingsActivity ) getActivity ( ) ; if ( activity != null && ! activity . isFinishing ( ) ) { String [ ] privacyArray = getResources ( ) . getStringArray ( R . array . wings_facebook_privacy__privacies ) ; String privacyString = privacyArray [ photoPrivacyIndex ] ; String photoPrivacy = null ; if ( getString ( R . string . wings_facebook__privacy__photo_privacy_self ) . equals ( privacyString ) ) { photoPrivacy = FacebookEndpoint . PHOTO_PRIVACY_SELF ; } else if ( getString ( R . string . wings_facebook__privacy__photo_privacy_friends ) . equals ( privacyString ) ) { photoPrivacy = FacebookEndpoint . PHOTO_PRIVACY_FRIENDS ; } else if ( getString ( R . string . wings_facebook__privacy__photo_privacy_friends_of_friends ) . equals ( privacyString ) ) { photoPrivacy = FacebookEndpoint . PHOTO_PRIVACY_FRIENDS_OF_FRIENDS ; } else if ( getString ( R . string . wings_facebook__privacy__photo_privacy_everyone ) . equals ( privacyString ) ) { photoPrivacy = FacebookEndpoint . PHOTO_PRIVACY_EVERYONE ; } if ( photoPrivacy != null && photoPrivacy . length ( ) > 0 && albumName != null && albumName . length ( ) > 0 && albumGraphPath != null && albumGraphPath . length ( ) > 0 ) { activity . mDestinationId = FacebookEndpoint . DestinationId . PROFILE ; activity . mPhotoPrivacy = photoPrivacy ; activity . mAlbumName = albumName ; activity . mAlbumGraphPath = albumGraphPath ; } else { activity . mHasErrorOccurred = true ; } activity . tryFinish ( ) ; } }
Handles the photo privacy selection .
11,026
private < T , R > void applyPredicates ( JoinerQuery < T , R > request , JPAQuery query , Set < Path < ? > > usedAliases , List < JoinDescription > joins ) { if ( request . getWhere ( ) != null ) { Predicate where = predicateAliasResolver . resolvePredicate ( request . getWhere ( ) , joins , usedAliases ) ; checkAliasesArePresent ( where , usedAliases ) ; query . where ( where ) ; } if ( request . getGroupBy ( ) != null ) { Map < AnnotatedElement , List < JoinDescription > > grouped = joins . stream ( ) . collect ( Collectors . groupingBy ( j -> j . getOriginalAlias ( ) . getAnnotatedElement ( ) ) ) ; Path < ? > grouping = predicateAliasResolver . resolvePath ( request . getGroupBy ( ) , grouped , usedAliases ) ; checkAliasesArePresent ( grouping , usedAliases ) ; query . groupBy ( grouping ) ; } if ( request . getHaving ( ) != null ) { Predicate having = predicateAliasResolver . resolvePredicate ( request . getHaving ( ) , joins , usedAliases ) ; checkAliasesArePresent ( having , usedAliases ) ; query . having ( having ) ; } }
Apply where groupBy and having
11,027
public AffineTransform metersToTilePixelsTransform ( int tx , int ty , int zoomLevel ) { AffineTransform result = new AffineTransform ( ) ; double scale = 1.0 / resolution ( zoomLevel ) ; int nTiles = 2 << ( zoomLevel - 1 ) ; int px = tx * - 256 ; int py = ( nTiles - ty ) * - 256 ; result . scale ( 1 , - 1 ) ; result . translate ( px , py ) ; result . scale ( scale , scale ) ; result . translate ( originShift , originShift ) ; return result ; }
Create a transform that converts meters to tile - relative pixels
11,028
public Coordinate metersToTile ( Coordinate coord , int zoomLevel ) { Coordinate pixels = metersToPixels ( coord . x , coord . y , zoomLevel ) ; int tx = ( int ) pixels . x / 256 ; int ty = ( int ) pixels . y / 256 ; return new Coordinate ( tx , ty , zoomLevel ) ; }
Returns the tile coordinate of the meters coordinate
11,029
public Coordinate tileTopLeft ( int tx , int ty , int zoomLevel ) { int px = tx * tileSize ; int py = ty * tileSize ; Coordinate result = pixelsToMeters ( px , py , zoomLevel ) ; return result ; }
Returns the top - left corner of the specific tile coordinate
11,030
public static Timestamp getTimeStamp ( String time ) { if ( time . equalsIgnoreCase ( "now" ) ) { return Timestamp . now ( ) ; } else { int quantity = 0 ; String unit = "" ; Pattern lastNUnitsPattern = Pattern . compile ( "last\\s*(\\d*)\\s*(min|mins|hour|hours|day|days|week|weeks).*" , Pattern . CASE_INSENSITIVE ) ; Matcher lastNUnitsMatcher = lastNUnitsPattern . matcher ( time ) ; while ( lastNUnitsMatcher . find ( ) ) { quantity = "" . equals ( lastNUnitsMatcher . group ( 1 ) ) ? 1 : Integer . valueOf ( lastNUnitsMatcher . group ( 1 ) ) ; unit = lastNUnitsMatcher . group ( 2 ) . toLowerCase ( ) ; switch ( unit ) { case "min" : case "mins" : return Timestamp . now ( ) . minus ( TimeDuration . ofMinutes ( quantity ) ) ; case "hour" : case "hours" : return Timestamp . now ( ) . minus ( TimeDuration . ofHours ( quantity ) ) ; case "day" : case "days" : return Timestamp . now ( ) . minus ( TimeDuration . ofHours ( quantity * 24 ) ) ; case "week" : case "weeks" : return Timestamp . now ( ) . minus ( TimeDuration . ofHours ( quantity * 24 * 7 ) ) ; default : break ; } } Pattern nUnitsAgoPattern = Pattern . compile ( "(\\d*)\\s*(min|mins|hour|hours|day|days|week|weeks)\\s*ago" , Pattern . CASE_INSENSITIVE ) ; Matcher nUnitsAgoMatcher = nUnitsAgoPattern . matcher ( time ) ; while ( nUnitsAgoMatcher . find ( ) ) { quantity = "" . equals ( nUnitsAgoMatcher . group ( 1 ) ) ? 1 : Integer . valueOf ( nUnitsAgoMatcher . group ( 1 ) ) ; unit = nUnitsAgoMatcher . group ( 2 ) . toLowerCase ( ) ; switch ( unit ) { case "min" : case "mins" : return Timestamp . now ( ) . minus ( TimeDuration . ofMinutes ( quantity ) ) ; case "hour" : case "hours" : return Timestamp . now ( ) . minus ( TimeDuration . ofHours ( quantity ) ) ; case "day" : case "days" : return Timestamp . now ( ) . minus ( TimeDuration . ofHours ( quantity * 24 ) ) ; case "week" : case "weeks" : return Timestamp . now ( ) . minus ( TimeDuration . ofHours ( quantity * 24 * 7 ) ) ; default : break ; } } TimestampFormat format = new TimestampFormat ( "yyyy-MM-dd'T'HH:mm:ss" ) ; try { return format . parse ( time ) ; } catch ( ParseException e ) { return null ; } } }
A Helper function to help you convert various string represented time definition to an absolute Timestamp .
11,031
public void write ( byte [ ] bytes ) throws IOException { for ( int i = 0 ; i < bytes . length ; i ++ ) { write ( bytes [ i ] ) ; } }
Writes the given bytes to the destination
11,032
public void write ( byte myByte ) throws IOException { onNewLine = false ; buffer . put ( myByte ) ; if ( ! buffer . hasRemaining ( ) ) { flush ( ) ; } }
Writes the single byte to the destination
11,033
public Collection < PrimaryWorkitem > getCompletedPrimaryWorkitems ( PrimaryWorkitemFilter filter ) { filter = ( filter != null ) ? filter : new PrimaryWorkitemFilter ( ) ; filter . completedIn . clear ( ) ; filter . completedIn . add ( this ) ; return getInstance ( ) . get ( ) . primaryWorkitems ( filter ) ; }
Stories and Defects completed in this Build Run .
11,034
public Collection < Defect > getFoundDefects ( DefectFilter filter ) { filter = ( filter != null ) ? filter : new DefectFilter ( ) ; filter . foundIn . clear ( ) ; filter . foundIn . add ( this ) ; return getInstance ( ) . get ( ) . defects ( filter ) ; }
Defects found in this Build Run .
11,035
public final void execute ( ) { beforeLine = editor . getLine ( ) ; beforeColumn = editor . getColumn ( ) ; doExecute ( ) ; afterLine = editor . getLine ( ) ; afterColumn = editor . getColumn ( ) ; }
Stores cursor coordinates .
11,036
public Date setMaxSelectableDate ( Date max ) { if ( max == null ) { maxSelectableDate = defaultMaxSelectableDate ; } else { maxSelectableDate = max ; } return maxSelectableDate ; }
Sets the maximum selectable date . If null the date 01 \ 01 \ 9999 will be set instead .
11,037
public Date setMinSelectableDate ( Date min ) { if ( min == null ) { minSelectableDate = defaultMinSelectableDate ; } else { minSelectableDate = min ; } return minSelectableDate ; }
Sets the minimum selectable date . If null the date 01 \ 01 \ 0001 will be set instead .
11,038
public boolean checkDate ( Date date ) { Calendar calendar = Calendar . getInstance ( ) ; calendar . setTime ( date ) ; calendar . set ( Calendar . HOUR_OF_DAY , 0 ) ; calendar . set ( Calendar . MINUTE , 0 ) ; calendar . set ( Calendar . SECOND , 0 ) ; calendar . set ( Calendar . MILLISECOND , 0 ) ; Calendar minCal = Calendar . getInstance ( ) ; minCal . setTime ( minSelectableDate ) ; minCal . set ( Calendar . HOUR_OF_DAY , 0 ) ; minCal . set ( Calendar . MINUTE , 0 ) ; minCal . set ( Calendar . SECOND , 0 ) ; minCal . set ( Calendar . MILLISECOND , 0 ) ; Calendar maxCal = Calendar . getInstance ( ) ; maxCal . setTime ( maxSelectableDate ) ; maxCal . set ( Calendar . HOUR_OF_DAY , 0 ) ; maxCal . set ( Calendar . MINUTE , 0 ) ; maxCal . set ( Calendar . SECOND , 0 ) ; maxCal . set ( Calendar . MILLISECOND , 0 ) ; return ! ( calendar . before ( minCal ) || calendar . after ( maxCal ) ) ; }
Checks a given date if it is in the formally specified date range .
11,039
public static Builder getSettingsBuilder ( String nodeName , boolean clientTransportSniff , String clusterName ) { boolean isNullClusterName = Objects . isNull ( clusterName ) ; Builder builder = Settings . builder ( ) . put ( NODE_NAME , nodeName ) . put ( CLIENT_TRANSPORT_SNIFF , clientTransportSniff ) . put ( CLIENT_TRANSPORT_IGNORE_CLUSTER_NAME , isNullClusterName ) ; if ( ! isNullClusterName ) builder . put ( CLUSTER_NAME , clusterName ) ; return builder ; }
Gets settings builder .
11,040
public boolean isExists ( String index ) { IndicesExistsRequestBuilder indicesExistsRequestBuilder = admin ( ) . indices ( ) . prepareExists ( index ) ; return JMElasticsearchUtil . logRequestQueryAndReturn ( "isExists" , indicesExistsRequestBuilder , indicesExistsRequestBuilder . execute ( ) ) . isExists ( ) ; }
Is exists boolean .
11,041
public boolean create ( String index ) { CreateIndexRequestBuilder createIndexRequestBuilder = admin ( ) . indices ( ) . prepareCreate ( index ) ; return JMElasticsearchUtil . logRequestQueryAndReturn ( "create" , createIndexRequestBuilder , createIndexRequestBuilder . execute ( ) ) . isAcknowledged ( ) ; }
Create boolean .
11,042
public List < String > getAllIdList ( String index , String type ) { return extractIdList ( searchAll ( index , type ) ) ; }
Gets all id list .
11,043
public ImmutableOpenMap < String , ImmutableOpenMap < String , MappingMetaData > > getMappingsResponse ( String ... indices ) { GetMappingsRequestBuilder getMappingsRequestBuilder = admin ( ) . indices ( ) . prepareGetMappings ( indices ) ; return JMElasticsearchUtil . logRequestQueryAndReturn ( "getMappingsResponse" , getMappingsRequestBuilder , getMappingsRequestBuilder . execute ( ) ) . getMappings ( ) ; }
Gets mappings response .
11,044
public Map < String , IndexStats > getAllIndicesStats ( ) { IndicesStatsRequestBuilder indicesStatsRequestBuilder = admin ( ) . indices ( ) . prepareStats ( ) . all ( ) ; return JMElasticsearchUtil . logRequestQueryAndReturn ( "getAllIndicesStats" , indicesStatsRequestBuilder , indicesStatsRequestBuilder . execute ( ) ) . getIndices ( ) ; }
Gets all indices stats .
11,045
public List < String > getFilteredIndexList ( String containedString ) { return getAllIndices ( ) . stream ( ) . filter ( index -> index . contains ( containedString ) ) . collect ( toList ( ) ) ; }
Gets filtered index list .
11,046
public Optional < Map < String , ? > > getMappings ( String index , String type ) { try { return Optional . of ( getMappingsResponse ( index ) . get ( index ) . get ( type ) . getSourceAsMap ( ) ) ; } catch ( Exception e ) { return JMExceptionManager . handleExceptionAndReturnEmptyOptional ( log , e , "getMappings" , index , type ) ; } }
Gets mappings .
11,047
public boolean readBoolean ( String message , Boolean defaultValue ) throws IOException { saveCursorPosition ( ) ; Ansi style = ansi ( ) ; if ( getTheme ( ) . getPromptBackground ( ) != null ) { style . bg ( getTheme ( ) . getPromptBackground ( ) ) ; } if ( getTheme ( ) . getPromptForeground ( ) != null ) { style . fg ( getTheme ( ) . getPromptForeground ( ) ) ; } for ( int i = 1 ; i <= getFooterSize ( ) ; i ++ ) { console . out ( ) . print ( ansi ( ) . cursor ( terminal . getHeight ( ) - getFooterSize ( ) + i , 1 ) ) ; console . out ( ) . print ( style . eraseLine ( Ansi . Erase . FORWARD ) ) ; } console . out ( ) . print ( ansi ( ) . cursor ( terminal . getHeight ( ) , 1 ) ) ; console . out ( ) . print ( style . a ( message ) . bold ( ) . eraseLine ( Ansi . Erase . FORWARD ) ) ; restoreCursorPosition ( ) ; flush ( ) ; try { EditorOperation operation ; while ( true ) { operation = readOperation ( ) ; switch ( operation . getType ( ) ) { case NEWLINE : return defaultValue ; case TYPE : if ( "y" . equals ( operation . getInput ( ) ) || "Y" . equals ( operation . getInput ( ) ) ) { return true ; } else if ( "n" . equals ( operation . getInput ( ) ) || "N" . equals ( operation . getInput ( ) ) ) { return false ; } } } } finally { redrawFooter ( ) ; } }
Displays a message and reads a boolean from the user input . The mapping of the user input to a boolean value is specified by the implementation .
11,048
public String readLine ( ) throws IOException { StringBuilder lineBuilder = new StringBuilder ( ) ; EditorOperation operation ; while ( true ) { operation = readOperation ( ) ; switch ( operation . getType ( ) ) { case BACKSAPCE : case DELETE : if ( lineBuilder . length ( ) > 0 ) { lineBuilder . delete ( lineBuilder . length ( ) - 1 , lineBuilder . length ( ) ) ; console . out ( ) . print ( Ansi . ansi ( ) . cursorLeft ( 1 ) ) ; console . out ( ) . print ( " " ) ; console . out ( ) . print ( Ansi . ansi ( ) . cursorLeft ( 1 ) ) ; } break ; case NEWLINE : return lineBuilder . toString ( ) ; case TYPE : console . out ( ) . print ( operation . getInput ( ) ) ; lineBuilder . append ( operation . getInput ( ) ) ; break ; } flush ( ) ; } }
Reads a line from the user input .
11,049
void repaintScreen ( ) { int repaintLine = 1 ; console . out ( ) . print ( ansi ( ) . eraseScreen ( Erase . ALL ) ) ; console . out ( ) . print ( ansi ( ) . cursor ( 1 , 1 ) ) ; console . out ( ) . print ( "\33[" + ( getHeaderSize ( ) + 1 ) + ";" + ( terminal . getHeight ( ) - getFooterSize ( ) ) + ";r" ) ; redrawHeader ( ) ; redrawFooter ( ) ; LinkedList < String > linesToDisplay = new LinkedList < String > ( ) ; int l = 1 ; while ( linesToDisplay . size ( ) < terminal . getHeight ( ) - getFooterSize ( ) ) { String currentLine = getContent ( l ++ ) ; linesToDisplay . addAll ( toDisplayLines ( currentLine ) ) ; } for ( int i = 0 ; i < terminal . getHeight ( ) - getHeaderSize ( ) - getFooterSize ( ) ; i ++ ) { console . out ( ) . print ( ansi ( ) . cursor ( repaintLine + getHeaderSize ( ) , 1 ) ) ; displayText ( linesToDisplay . get ( i ) ) ; repaintLine ++ ; } console . out ( ) . print ( ansi ( ) . cursor ( 2 , 1 ) ) ; }
Repaints the whole screen .
11,050
void redrawRestOfLine ( ) { int maxLinesToRepaint = terminal . getHeight ( ) - getFooterSize ( ) - frameLine ; LinkedList < String > toRepaintLines = new LinkedList < String > ( ) ; String currentLine = getContent ( getLine ( ) ) ; toRepaintLines . addAll ( toDisplayLines ( currentLine ) ) ; int remainingLines = ( getColumn ( ) - 1 ) / terminal . getWidth ( ) ; for ( int r = 0 ; r < remainingLines ; r ++ ) { toRepaintLines . removeFirst ( ) ; } saveCursorPosition ( ) ; for ( int l = 0 ; l < Math . min ( maxLinesToRepaint , toRepaintLines . size ( ) ) ; l ++ ) { console . out ( ) . print ( ansi ( ) . cursor ( frameLine + getHeaderSize ( ) + l , 1 ) ) ; console . out ( ) . print ( ansi ( ) . eraseLine ( Erase . FORWARD ) ) ; displayText ( toRepaintLines . get ( l ) ) ; } restoreCursorPosition ( ) ; }
Redraws the rest of the multi line .
11,051
void redrawRestOfScreen ( ) { int linesToRepaint = terminal . getHeight ( ) - getFooterSize ( ) - frameLine ; LinkedList < String > toRepaintLines = new LinkedList < String > ( ) ; String currentLine = getContent ( getLine ( ) ) ; toRepaintLines . addAll ( toDisplayLines ( currentLine ) ) ; int remainingLines = Math . max ( 0 , getColumn ( ) - 1 ) / terminal . getWidth ( ) ; for ( int r = 0 ; r < remainingLines ; r ++ ) { toRepaintLines . removeFirst ( ) ; } boolean eof = false ; for ( int l = 1 ; toRepaintLines . size ( ) < linesToRepaint && ! eof ; l ++ ) { try { toRepaintLines . addAll ( toDisplayLines ( getContent ( getLine ( ) + l ) ) ) ; } catch ( Exception e ) { eof = true ; } } saveCursorPosition ( ) ; for ( int l = 0 ; l < linesToRepaint ; l ++ ) { console . out ( ) . print ( ansi ( ) . cursor ( frameLine + getHeaderSize ( ) + l , 1 ) ) ; console . out ( ) . print ( ansi ( ) . eraseLine ( Erase . FORWARD ) ) ; if ( toRepaintLines . size ( ) > l ) { displayText ( toRepaintLines . get ( l ) ) ; } else { displayText ( "" ) ; } } restoreCursorPosition ( ) ; }
Redraws content from the current line to the end of the frame .
11,052
private void moveVertical ( int offset ) { if ( offset < 0 ) { moveUp ( Math . abs ( offset ) ) ; } else if ( offset > 0 ) { moveDown ( offset ) ; } }
Moves the cursor vertically and scroll if needed .
11,053
private void moveHorizontally ( int offset ) { if ( offset < 0 ) { moveLeft ( Math . abs ( offset ) ) ; } else if ( offset > 0 ) { moveRight ( offset ) ; } }
Moves the cursor horizontally .
11,054
protected void displayText ( String text ) { if ( highLight != null && ! highLight . isEmpty ( ) && text . contains ( highLight ) ) { String highLightedText = text . replaceAll ( highLight , ansi ( ) . bold ( ) . bg ( theme . getHighLightBackground ( ) ) . fg ( theme . getHighLightForeground ( ) ) . a ( highLight ) . boldOff ( ) . reset ( ) . toString ( ) ) ; console . out ( ) . print ( highLightedText ) ; } else { console . out ( ) . print ( text ) ; } }
Displays Text highlighting the text that was marked as highlighted .
11,055
private LinkedList < String > toDisplayLines ( String line ) { LinkedList < String > displayLines = new LinkedList < String > ( ) ; if ( line . length ( ) <= terminal . getWidth ( ) ) { displayLines . add ( line ) ; } else { int total = Math . max ( 0 , line . length ( ) - 1 ) / terminal . getWidth ( ) + 1 ; int startIndex = 0 ; for ( int l = 0 ; l < total ; l ++ ) { displayLines . add ( line . substring ( startIndex , Math . min ( startIndex + terminal . getWidth ( ) , line . length ( ) ) ) ) ; startIndex += terminal . getWidth ( ) ; } } return displayLines ; }
Creates a list of lines that represent how the line will be displayed on screen .
11,056
public static JTextField getDateField ( String format ) { JTextField field = new JTextField ( ) ; field . setEditable ( false ) ; timePicker ( field ) ; return field ; }
Get time field with format
11,057
public String load ( String location ) throws IOException { File file = new File ( location ) ; return Files . toString ( file , detectCharset ( location ) ) ; }
Loads content from the specified location .
11,058
public boolean save ( String content , String location ) { return save ( content , Charsets . UTF_8 , location ) ; }
Saves content to the specified location .
11,059
public void setYear ( int y ) { super . setValue ( y , true , false ) ; if ( dayChooser != null ) { dayChooser . setYear ( value ) ; } spinner . setValue ( new Integer ( value ) ) ; firePropertyChange ( "year" , oldYear , value ) ; oldYear = value ; }
Sets the year . This is a bound property .
11,060
public Environment extract ( Object specification ) { Assert . notNull ( specification , "The 'specification' argument cannot be null." ) ; final Environment environment = new Environment ( ) ; final Class < ? > clazz = specification . getClass ( ) ; final Jndi annotation = AnnotationUtils . findAnnotation ( clazz , Jndi . class ) ; if ( annotation != null ) { environment . addDataSources ( annotation . dataSources ( ) ) ; environment . addTransactionManagers ( annotation . transactionManager ( ) ) ; environment . addMailSessions ( annotation . mailSessions ( ) ) ; environment . addJmsBrokers ( annotation . jms ( ) ) ; environment . addBeans ( annotation . beans ( ) ) ; environment . setBuilder ( annotation . builder ( ) ) ; } environment . addDataSource ( AnnotationUtils . findAnnotation ( clazz , DataSource . class ) ) ; environment . addTransactionManager ( AnnotationUtils . findAnnotation ( clazz , TransactionManager . class ) ) ; environment . addMailSession ( AnnotationUtils . findAnnotation ( clazz , MailSession . class ) ) ; environment . addBean ( AnnotationUtils . findAnnotation ( clazz , Bean . class ) ) ; return environment ; }
Extracts the environment from the test object .
11,061
public void putState ( String key , String value ) { handler . handlePutState ( key , ByteString . copyFromUtf8 ( value ) , uuid ) ; }
Puts the given state into a ledger automatically wrapping it in a ByteString
11,062
public Map < String , String > rangeQueryState ( String startKey , String endKey ) { Map < String , String > retMap = new HashMap < > ( ) ; for ( Map . Entry < String , ByteString > item : rangeQueryRawState ( startKey , endKey ) . entrySet ( ) ) { retMap . put ( item . getKey ( ) , item . getValue ( ) . toStringUtf8 ( ) ) ; } return retMap ; }
Given a start key and end key this method returns a map of items with value converted to UTF - 8 string .
11,063
public Map < String , ByteString > rangeQueryRawState ( String startKey , String endKey ) { Map < String , ByteString > map = new HashMap < > ( ) ; for ( Chaincode . RangeQueryStateKeyValue mapping : handler . handleRangeQueryState ( startKey , endKey , uuid ) . getKeysAndValuesList ( ) ) { map . put ( mapping . getKey ( ) , mapping . getValue ( ) ) ; } return map ; }
This method is same as rangeQueryState except it returns value in ByteString useful in cases where serialized object can be retrieved .
11,064
public ByteString invokeRawChaincode ( String chaincodeName , String function , List < ByteString > args ) { return handler . handleInvokeChaincode ( chaincodeName , function , args , uuid ) ; }
Invokes the provided chaincode with the given function and arguments and returns the raw ByteString value that invocation generated .
11,065
private void findPrinters ( ) { mOauthObservable . subscribe ( new Action1 < String > ( ) { public void call ( final String token ) { searchPrinters ( token ) . subscribe ( new Action1 < JacksonPrinterSearchResult > ( ) { public void call ( JacksonPrinterSearchResult result ) { onPrinterSearchResult ( result ) ; } } , mShowPrinterNotFoundAction ) ; } } , mAuthErrorAction ) ; }
Finds printers associated with the account .
11,066
public TimeDuration dividedBy ( int factor ) { return createWithCarry ( sec / factor , ( ( sec % factor ) * NANOSEC_IN_SEC + ( long ) nanoSec ) / factor ) ; }
Returns a new duration which is smaller by the given factor .
11,067
public int dividedBy ( TimeDuration duration ) { double thisDuration = ( double ) getSec ( ) * ( double ) NANOSEC_IN_SEC + ( double ) getNanoSec ( ) ; double otherDuration = ( double ) duration . getSec ( ) * ( double ) NANOSEC_IN_SEC + ( double ) duration . getNanoSec ( ) ; return ( int ) ( thisDuration / otherDuration ) ; }
Returns the number of times the given duration is present in this duration .
11,068
public TimeDuration plus ( TimeDuration duration ) { return createWithCarry ( sec + duration . getSec ( ) , nanoSec + duration . getNanoSec ( ) ) ; }
Returns the sum of this duration with the given .
11,069
public TimeDuration minus ( TimeDuration duration ) { return createWithCarry ( sec - duration . getSec ( ) , nanoSec - duration . getNanoSec ( ) ) ; }
Returns the difference between this duration and the given .
11,070
public TimeInterval around ( Timestamp reference ) { TimeDuration half = this . dividedBy ( 2 ) ; return TimeInterval . between ( reference . minus ( half ) , reference . plus ( half ) ) ; }
Returns a time interval that lasts this duration and is centered around the given timestamp .
11,071
public Collection < Project > getTargetedBy ( ProjectFilter filter ) { filter = ( filter != null ) ? filter : new ProjectFilter ( ) ; filter . targets . clear ( ) ; filter . targets . add ( this ) ; return getInstance ( ) . get ( ) . projects ( filter ) ; }
A collection of Projects Targeted by this Goal .
11,072
public Collection < Epic > getEpics ( EpicFilter filter ) { filter = ( filter != null ) ? filter : new EpicFilter ( ) ; filter . goals . clear ( ) ; filter . goals . add ( this ) ; return getInstance ( ) . get ( ) . epics ( filter ) ; }
Epics assigned to this Goal .
11,073
public Collection < Theme > getThemes ( ThemeFilter filter ) { filter = ( filter != null ) ? filter : new ThemeFilter ( ) ; filter . goals . clear ( ) ; filter . goals . add ( this ) ; return getInstance ( ) . get ( ) . themes ( filter ) ; }
Themes assigned to this Goal .
11,074
public boolean isRobotPermitted ( String url , String userAgent ) throws IOException , RobotsUnavailableException { RobotRules rules = getRulesForUrl ( url , userAgent ) ; return ! rules . blocksPathForUA ( new LaxURI ( url , false ) . getPath ( ) , userAgent ) ; }
Returns true if a robot with the given user - agent is allowed to access the given url .
11,075
private void addMonth ( int i ) { Calendar cal = Calendar . getInstance ( ) ; cal . set ( getDisplayYear ( ) , getDisplayMonth ( ) - 1 , 1 ) ; int month = cal . get ( Calendar . MONTH ) + 1 ; if ( i > 0 && month == 12 ) { addYear ( 1 ) ; } if ( i < 0 && month == 1 ) { addYear ( - 1 ) ; } cal . add ( Calendar . MONTH , i ) ; monthTextField . setText ( String . valueOf ( cal . get ( Calendar . MONTH ) + 1 ) ) ; }
Add month count to month field
11,076
private void addYear ( int i ) { Calendar cal = Calendar . getInstance ( ) ; cal . set ( getDisplayYear ( ) , 1 , 1 ) ; cal . add ( Calendar . YEAR , i ) ; yearTextField . setText ( String . valueOf ( cal . get ( Calendar . YEAR ) ) ) ; }
Add year count to year field
11,077
private String [ ] getDays ( int year , int month ) { Calendar cal = Calendar . getInstance ( ) ; cal . set ( year , month , 1 ) ; int dayNum = cal . getActualMaximum ( Calendar . DAY_OF_MONTH ) ; String [ ] days = new String [ dayNum ] ; for ( int i = 0 ; i < dayNum ; i ++ ) { days [ i ] = String . valueOf ( i + 1 ) ; } return days ; }
Get days of a month
11,078
private int getDayIndex ( int year , int month , int day ) { Calendar cal = Calendar . getInstance ( ) ; cal . set ( year , month , day ) ; return cal . get ( Calendar . DAY_OF_WEEK ) ; }
Get DAY_OF_WEEK of a day
11,079
private Date [ ] getBeforeDays ( int year , int month ) { Calendar cal = Calendar . getInstance ( ) ; cal . set ( year , month , 1 ) ; int dayNum = getDayIndex ( year , month , 1 ) - 1 ; Date [ ] date = new Date [ dayNum ] ; if ( dayNum > 0 ) for ( int i = 0 ; i < dayNum ; i ++ ) { cal . add ( Calendar . DAY_OF_MONTH , - 1 ) ; date [ i ] = cal . getTime ( ) ; } return date ; }
Get date arrays before 1st day of the month in that week
11,080
private Date [ ] getAfterDays ( int year , int month ) { Calendar cal = Calendar . getInstance ( ) ; cal . set ( Calendar . YEAR , year ) ; cal . set ( Calendar . MONTH , month ) ; int dayNum = cal . getActualMaximum ( Calendar . DAY_OF_MONTH ) ; cal . set ( year , month , dayNum ) ; int afterDayNum = 7 - getDayIndex ( year , month , dayNum ) ; Date [ ] date = new Date [ afterDayNum ] ; if ( afterDayNum > 0 ) for ( int i = 0 ; i < afterDayNum ; i ++ ) { cal . add ( Calendar . DAY_OF_MONTH , 1 ) ; date [ i ] = cal . getTime ( ) ; } return date ; }
Get date arrays after the last day of the month in that week
11,081
private void addDayHeadLabels ( ) { for ( JLabel it : getDayHeadLabels ( ) ) { it . setVerticalAlignment ( JLabel . CENTER ) ; it . setHorizontalAlignment ( JLabel . CENTER ) ; daysPanel . add ( it ) ; } }
Add day header to top of month btns
11,082
@ SuppressWarnings ( "deprecation" ) private void refreshDayBtns ( ) { remove ( daysPanel ) ; daysPanel = new JPanel ( ) ; daysPanel . removeAll ( ) ; daysPanel . setLayout ( new GridLayout ( 0 , 7 ) ) ; int displayYear = getDisplayYear ( ) ; int displayMonth = getDisplayMonth ( ) ; String [ ] days = getDays ( displayYear , displayMonth - 1 ) ; addDayHeadLabels ( ) ; Date d = picker . getDate ( ) ; Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( d ) ; int currentYear = cal . get ( Calendar . YEAR ) ; int currentMonth = cal . get ( Calendar . MONTH ) ; int currentDay = cal . get ( Calendar . DAY_OF_MONTH ) ; for ( Date it : getBeforeDays ( displayYear , displayMonth - 1 ) ) { JLabel label = new JLabel ( String . valueOf ( it . getDate ( ) ) ) ; label . setVerticalAlignment ( JLabel . CENTER ) ; label . setHorizontalAlignment ( JLabel . CENTER ) ; label . setEnabled ( false ) ; daysPanel . add ( label ) ; } for ( String it : days ) { DayBtn btn = new DayBtn ( it ) ; if ( displayYear == currentYear && displayMonth == currentMonth + 1 && currentDay == Integer . parseInt ( it ) ) { btn . setBackground ( Color . GRAY ) ; btn . clicked = true ; } dayBtns . add ( btn ) ; daysPanel . add ( btn ) ; } for ( Date it : getAfterDays ( displayYear , displayMonth - 1 ) ) { JLabel label = new JLabel ( String . valueOf ( it . getDate ( ) ) ) ; label . setVerticalAlignment ( JLabel . CENTER ) ; label . setHorizontalAlignment ( JLabel . CENTER ) ; daysPanel . add ( label ) ; label . setEnabled ( false ) ; } add ( daysPanel ) ; updateUI ( ) ; if ( picker . getPopup ( ) != null ) { Method method ; try { method = Popup . class . getDeclaredMethod ( "pack" ) ; method . setAccessible ( true ) ; method . invoke ( picker . getPopup ( ) ) ; } catch ( Exception e ) { } } }
Refresh day btn tables
11,083
protected List < Middleware > getMiddleware ( String name ) { final List < Middleware > middleware = this . applicationContext . getBeansOfType ( MiddlewareDefinition . class , true , false ) . values ( ) . stream ( ) . flatMap ( d -> d . getDefinition ( ) . entrySet ( ) . stream ( ) ) . collect ( Collectors . toMap ( Map . Entry :: getKey , Map . Entry :: getValue ) ) . get ( name ) ; return middleware == null ? Collections . emptyList ( ) : middleware ; }
Resolves middleware assigned to action by it s name .
11,084
public static MapOperator with ( final Map map , final Class < ? extends Map > nodeClass ) { return new MapOperator ( map , nodeClass ) ; }
Entry point for mutable map dsl .
11,085
public void mimicClass ( CtClass src , CtClass dst , MimicMode defaultMimicMode , MimicMethod [ ] mimicMethods ) throws NotFoundException , CannotCompileException , MimicException { mimicInterfaces ( src , dst ) ; mimicFields ( src , dst ) ; mimicConstructors ( src , dst ) ; mimicMethods ( src , dst , defaultMimicMode , mimicMethods ) ; }
Copies all fields constructors and methods declared in class src into dst . All interfaces implemented by src will also be implemented by dst .
11,086
public void doFilter ( ServletRequest req , ServletResponse res , FilterChain chain ) throws IOException , ServletException { HttpServletResponse response = ( HttpServletResponse ) res ; response . setHeader ( "Access-Control-Allow-Origin" , allowOrigin ) ; response . setHeader ( "Access-Control-Allow-Methods" , allowMethod ) ; response . setHeader ( "Access-Control-Max-Age" , maxAge ) ; response . setHeader ( "Access-Control-Allow-Headers" , allowHeaders ) ; chain . doFilter ( req , res ) ; }
Sets the headers to support CORS
11,087
public void decodeHeader ( ) throws IOException { if ( ! headerDecoded ) { headerDecoded = true ; int m = getMarker ( ) ; if ( m != 0xD8 ) { throw new IOException ( "no SOI" ) ; } m = getMarker ( ) ; while ( m != 0xC0 && m != 0xC1 ) { processMarker ( m ) ; m = getMarker ( ) ; while ( m == MARKER_NONE ) { m = getMarker ( ) ; } } processSOF ( ) ; } }
Decodes the JPEG header . This must be called before the image size can be queried .
11,088
public boolean startDecode ( ) throws IOException { if ( insideSOS ) { throw new IllegalStateException ( "decode already started" ) ; } if ( foundEOI ) { return false ; } decodeHeader ( ) ; int m = getMarker ( ) ; while ( m != 0xD9 ) { if ( m == 0xDA ) { processScanHeader ( ) ; insideSOS = true ; currentMCURow = 0 ; reset ( ) ; return true ; } else { processMarker ( m ) ; } m = getMarker ( ) ; } foundEOI = true ; return false ; }
Starts the decode process . This will advance the JPEG stream to the start of the image data . It also checks if that JPEG file can be decoded by this library .
11,089
public void decodeRAW ( ByteBuffer [ ] buffer , int [ ] strides , int numMCURows ) throws IOException { if ( ! insideSOS ) { throw new IllegalStateException ( "decode not started" ) ; } if ( numMCURows <= 0 || currentMCURow + numMCURows > mcuCountY ) { throw new IllegalArgumentException ( "numMCURows" ) ; } int scanN = order . length ; if ( scanN != components . length ) { throw new UnsupportedOperationException ( "for RAW decode all components need to be decoded at once" ) ; } if ( scanN > buffer . length || scanN > strides . length ) { throw new IllegalArgumentException ( "not enough buffers" ) ; } for ( int compIdx = 0 ; compIdx < scanN ; compIdx ++ ) { order [ compIdx ] . outPos = buffer [ compIdx ] . position ( ) ; } outer : for ( int j = 0 ; j < numMCURows ; j ++ ) { ++ currentMCURow ; for ( int i = 0 ; i < mcuCountX ; i ++ ) { for ( int compIdx = 0 ; compIdx < scanN ; compIdx ++ ) { Component c = order [ compIdx ] ; int outStride = strides [ compIdx ] ; int outPosY = c . outPos + 8 * ( i * c . blocksPerMCUHorz + j * c . blocksPerMCUVert * outStride ) ; for ( int y = 0 ; y < c . blocksPerMCUVert ; y ++ , outPosY += 8 * outStride ) { for ( int x = 0 , outPos = outPosY ; x < c . blocksPerMCUHorz ; x ++ , outPos += 8 ) { try { decodeBlock ( data , c ) ; } catch ( ArrayIndexOutOfBoundsException ex ) { throwBadHuffmanCode ( ) ; } idct2D . compute ( buffer [ compIdx ] , outPos , outStride , data ) ; } } } if ( -- todo <= 0 ) { if ( ! checkRestart ( ) ) { break outer ; } } } } checkDecodeEnd ( ) ; for ( int compIdx = 0 ; compIdx < scanN ; compIdx ++ ) { Component c = order [ compIdx ] ; buffer [ compIdx ] . position ( c . outPos + numMCURows * c . blocksPerMCUVert * 8 * strides [ compIdx ] ) ; } }
Decodes each color component of the JPEG file separately into a separate ByteBuffer . The number of buffers must match the number of color channels . Each color channel can have a different sub sampling factor .
11,090
public void decodeDCTCoeffs ( ShortBuffer [ ] buffer , int numMCURows ) throws IOException { if ( ! insideSOS ) { throw new IllegalStateException ( "decode not started" ) ; } if ( numMCURows <= 0 || currentMCURow + numMCURows > mcuCountY ) { throw new IllegalArgumentException ( "numMCURows" ) ; } int scanN = order . length ; if ( scanN != components . length ) { throw new UnsupportedOperationException ( "for RAW decode all components need to be decoded at once" ) ; } if ( scanN > buffer . length ) { throw new IllegalArgumentException ( "not enough buffers" ) ; } for ( int compIdx = 0 ; compIdx < scanN ; compIdx ++ ) { order [ compIdx ] . outPos = buffer [ compIdx ] . position ( ) ; } outer : for ( int j = 0 ; j < numMCURows ; j ++ ) { ++ currentMCURow ; for ( int i = 0 ; i < mcuCountX ; i ++ ) { for ( int compIdx = 0 ; compIdx < scanN ; compIdx ++ ) { Component c = order [ compIdx ] ; ShortBuffer sb = buffer [ compIdx ] ; int outStride = 64 * c . blocksPerMCUHorz * mcuCountX ; int outPos = c . outPos + 64 * i * c . blocksPerMCUHorz + j * c . blocksPerMCUVert * outStride ; for ( int y = 0 ; y < c . blocksPerMCUVert ; y ++ ) { sb . position ( outPos ) ; for ( int x = 0 ; x < c . blocksPerMCUHorz ; x ++ ) { try { decodeBlock ( data , c ) ; } catch ( ArrayIndexOutOfBoundsException ex ) { throwBadHuffmanCode ( ) ; } sb . put ( data ) ; } outPos += outStride ; } } if ( -- todo <= 0 ) { if ( ! checkRestart ( ) ) { break outer ; } } } } checkDecodeEnd ( ) ; for ( int compIdx = 0 ; compIdx < scanN ; compIdx ++ ) { Component c = order [ compIdx ] ; int outStride = 64 * c . blocksPerMCUHorz * mcuCountX ; buffer [ compIdx ] . position ( c . outPos + numMCURows * c . blocksPerMCUVert * outStride ) ; } }
Decodes the dequantizied DCT coefficients into a buffer per color component . The number of buffers must match the number of color channels . Each color channel can have a different sub sampling factor .
11,091
public boolean validate ( Entity entity , String attribute ) throws APIException , ConnectionException , OidException { Asset asset = v1Instance . getAsset ( entity . getInstanceKey ( ) ) != null ? v1Instance . getAsset ( entity . getInstanceKey ( ) ) : v1Instance . getAsset ( entity . getID ( ) ) ; IAttributeDefinition attributeDefinition = asset . getAssetType ( ) . getAttributeDefinition ( attribute ) ; return validator . validate ( asset , attributeDefinition ) ; }
Validate single attribute of an entity .
11,092
public List < String > validate ( Entity entity ) throws APIException , ConnectionException , OidException { Asset asset = v1Instance . getAsset ( entity . getInstanceKey ( ) ) != null ? v1Instance . getAsset ( entity . getInstanceKey ( ) ) : v1Instance . getAsset ( entity . getID ( ) ) ; return validate ( asset ) ; }
Validate single Entity .
11,093
public Map < Entity , List < String > > validate ( Entity [ ] entities ) throws APIException , ConnectionException , OidException { Map < Entity , List < String > > results = new HashMap < Entity , List < String > > ( ) ; for ( Entity entity : entities ) { results . put ( entity , validate ( entity ) ) ; } return results ; }
Validate a collection of entities .
11,094
public Image getIcon ( int iconKind ) { switch ( iconKind ) { case ICON_COLOR_16x16 : return iconColor16 ; case ICON_COLOR_32x32 : return iconColor32 ; case ICON_MONO_16x16 : return iconMono16 ; case ICON_MONO_32x32 : return iconMono32 ; } return null ; }
This method returns an image object that can be used to represent the bean in toolboxes toolbars etc .
11,095
public Attachment createAttachment ( String name , String fileName , InputStream stream ) throws AttachmentLengthExceededException , ApplicationUnavailableException { return getInstance ( ) . create ( ) . attachment ( name , this , fileName , stream ) ; }
Create an attachment that belongs to this asset .
11,096
public Conversation createConversation ( Member author , String content ) { Conversation conversation = getInstance ( ) . create ( ) . conversation ( author , content ) ; Iterator < Expression > iterator = conversation . getContainedExpressions ( ) . iterator ( ) ; iterator . next ( ) . getMentions ( ) . add ( this ) ; conversation . save ( ) ; return conversation ; }
Creates conversation with an expression which mentioned this asset .
11,097
public void propertyChange ( PropertyChangeEvent evt ) { if ( calendar != null ) { Calendar c = ( Calendar ) calendar . clone ( ) ; if ( evt . getPropertyName ( ) . equals ( "day" ) ) { c . set ( Calendar . DAY_OF_MONTH , ( ( Integer ) evt . getNewValue ( ) ) . intValue ( ) ) ; setCalendar ( c , false ) ; } else if ( evt . getPropertyName ( ) . equals ( "month" ) ) { c . set ( Calendar . MONTH , ( ( Integer ) evt . getNewValue ( ) ) . intValue ( ) ) ; setCalendar ( c , false ) ; } else if ( evt . getPropertyName ( ) . equals ( "year" ) ) { c . set ( Calendar . YEAR , ( ( Integer ) evt . getNewValue ( ) ) . intValue ( ) ) ; setCalendar ( c , false ) ; } else if ( evt . getPropertyName ( ) . equals ( "date" ) ) { c . setTime ( ( Date ) evt . getNewValue ( ) ) ; setCalendar ( c , true ) ; } } }
JCalendar is a PropertyChangeListener for its day month and year chooser .
11,098
public void setBackground ( Color bg ) { super . setBackground ( bg ) ; if ( dayChooser != null ) { dayChooser . setBackground ( bg ) ; } }
Sets the background color .
11,099
private void setCalendar ( Calendar c , boolean update ) { if ( c == null ) { setDate ( null ) ; } Calendar oldCalendar = calendar ; calendar = c ; if ( update ) { yearChooser . setYear ( c . get ( Calendar . YEAR ) ) ; monthChooser . setMonth ( c . get ( Calendar . MONTH ) ) ; dayChooser . setDay ( c . get ( Calendar . DATE ) ) ; } firePropertyChange ( "calendar" , oldCalendar , calendar ) ; }
Sets the calendar attribute of the JCalendar object