idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
17,300 | public double permutationDeterminant ( ) { int sign = 1 ; double sum = 0 ; PermutationMatrix pm = PermutationMatrix . getInstance ( rows ) ; int perms = pm . rows ; for ( int p = 0 ; p < perms ; p ++ ) { double mul = 1 ; for ( int i = 0 ; i < rows ; i ++ ) { mul *= get ( i , pm . get ( p , i ) ) ; } sum += sign * mul ; sign = - sign ; } return sum ; } | Calculates determinant by using permutations |
17,301 | public DoubleMatrix solve ( DoubleMatrix b ) { DoubleMatrix x = getInstance ( b . rows ( ) , b . columns ( ) ) ; solve ( b , x ) ; return x ; } | Solve linear equation Ax = b returning x |
17,302 | public void solve ( DoubleMatrix b , DoubleMatrix x ) { if ( A == null ) { throw new IllegalArgumentException ( "decompose() not called" ) ; } lupSolve ( A , P , b , x ) ; } | Solve linear equation Ax = b |
17,303 | public static DoubleMatrix getInstance ( int rows , int cols , ItemSupplier s ) { DoubleMatrix m = new DoubleMatrix ( rows , cols ) ; ItemConsumer c = m . consumer ; for ( int i = 0 ; i < rows ; i ++ ) { for ( int j = 0 ; j < cols ; j ++ ) { c . set ( i , j , s . get ( i , j ) ) ; } } return m ; } | Returns new DoubleMatrix initialized by function |
17,304 | public static DoubleMatrix multiply ( DoubleMatrix m1 , DoubleMatrix m2 ) { if ( m1 . cols != m2 . rows ) { throw new IllegalArgumentException ( "Matrices not comfortable" ) ; } int m = m1 . rows ; int n = m1 . cols ; int p = m2 . cols ; ItemSupplier s1 = m1 . supplier ; ItemSupplier s2 = m2 . supplier ; DoubleMatrix mr = DoubleMatrix . getInstance ( m , p ) ; ItemConsumer c = mr . consumer ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < p ; j ++ ) { double s = 0 ; for ( int r = 0 ; r < n ; r ++ ) { s += s1 . get ( i , r ) * s2 . get ( r , j ) ; } c . set ( i , j , s ) ; } } return mr ; } | Returns new DoubleMatrix which is m1 multiplied with m2 . |
17,305 | public static DoubleMatrix identity ( int n ) { return getInstance ( n , n , ( i , j ) -> i == j ? 1 : 0 ) ; } | Returns new identity matrix . |
17,306 | public Config build ( ) throws ConfigException { if ( properties != null ) { Config config = new Config ( "properties" ) ; config . setProperties ( properties ) ; return config ; } try { Loader loader = new Loader ( ) ; SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; SAXParser parser = factory . newSAXParser ( ) ; XMLReader reader = parser . getXMLReader ( ) ; reader . setContentHandler ( loader ) ; reader . parse ( new InputSource ( xmlStream ) ) ; return loader . getConfig ( ) ; } catch ( Exception e ) { throw new ConfigException ( e ) ; } } | Build configuration object . Configuration object is not reusable so this factory creates a new instance for every call . |
17,307 | public int fieldChanged ( boolean bDisplayOption , int iMoveMode ) { int iErrorCode = this . moveIt ( bDisplayOption , iMoveMode ) ; if ( iErrorCode != DBConstants . NORMAL_RETURN ) if ( this . getOwner ( ) != m_fldSource ) if ( this . getOwner ( ) != m_fldDest ) iErrorCode = DBConstants . NORMAL_RETURN ; if ( iErrorCode == DBConstants . NORMAL_RETURN ) iErrorCode = super . fieldChanged ( bDisplayOption , iMoveMode ) ; return iErrorCode ; } | The Field has Changed . Move the source field to the destination field . |
17,308 | public Maker from ( Settable settable ) { Optional < Maker < ? > > makerOptional = context . getPreferredValueMakers ( ) . getMaker ( settable ) ; if ( makerOptional . isPresent ( ) ) { return makerOptional . get ( ) ; } Type type = settable . getType ( ) ; Class < ? > rawType = ClassUtil . getRawType ( type ) ; if ( ClassUtil . isPrimitive ( type ) ) { return new PrimitiveMaker ( type ) ; } if ( type == String . class ) { return StringMaker . from ( settable ) ; } if ( type == Date . class ) { return new DateMaker ( ) ; } if ( Number . class . isAssignableFrom ( rawType ) ) { return NumberMaker . from ( settable ) ; } if ( ClassUtil . isArray ( type ) ) { log . trace ( "array type: {}" , rawType . getComponentType ( ) ) ; return new NullMaker ( ) ; } if ( ClassUtil . isEnum ( type ) ) { log . trace ( "enum type: {}" , type ) ; return new EnumMaker ( rawType . getEnumConstants ( ) ) ; } if ( ClassUtil . isCollection ( type ) ) { log . trace ( "collection: {}" , type ) ; return new NullMaker ( ) ; } if ( ClassUtil . isMap ( type ) ) { log . trace ( "map: {}" , type ) ; return new NullMaker < Object > ( ) ; } if ( ClassUtil . isEntity ( type ) ) { log . trace ( "{} is entity type" , type ) ; return new ReuseOrNullMaker ( context . getBeanValueHolder ( ) , rawType ) ; } log . debug ( "guessing this is a bean {}" , type ) ; return new BeanMaker ( rawType , context ) ; } | produce a maker for given settable |
17,309 | public static void print ( final CharSequence line ) { print ( new Applyable < ConsoleReaderWrapper > ( ) { public void apply ( ConsoleReaderWrapper consoleReaderWrapper ) { consoleReaderWrapper . print ( line ) ; } } ) ; } | Print line to console |
17,310 | public MethodFilterBuilder isDefault ( ) { add ( new NegationMethodFilter ( new ModifierMethodFilter ( Modifier . PUBLIC & Modifier . PROTECTED & Modifier . PRIVATE ) ) ) ; return this ; } | Adds a filter for default access methods only . |
17,311 | public MethodFilter build ( ) { if ( filters . isEmpty ( ) ) { throw new IllegalStateException ( "No filter specified." ) ; } if ( filters . size ( ) == 1 ) { return filters . get ( 0 ) ; } MethodFilter [ ] methodFilters = new MethodFilter [ filters . size ( ) ] ; filters . toArray ( methodFilters ) ; return new MethodFilterList ( methodFilters ) ; } | Returns the MethodFilter built . |
17,312 | public static LocalLongitude getInstance ( double longitude , double latitude ) { if ( Math . abs ( longitude ) < 179 ) { return new LocalLongitude ( latitude ) ; } else { return new PacificLongitude ( latitude ) ; } } | Returns LocalLongitude instance which is usable about 60 NM around starting point . |
17,313 | public void addKeyField ( Field field , boolean bKeyOrder ) { if ( m_vKeyFieldList . size ( ) == 0 ) m_bKeyOrder = bKeyOrder ; m_vKeyFieldList . add ( field ) ; } | Add this field to this Key Area . |
17,314 | public FieldInfo getField ( int iKeyFieldSeq ) { if ( iKeyFieldSeq >= m_vKeyFieldList . size ( ) ) return null ; return ( FieldInfo ) m_vKeyFieldList . elementAt ( iKeyFieldSeq ) ; } | Get the Field in this KeyField . |
17,315 | public void reverseKeyBuffer ( BaseBuffer bufferSource , int iAreaDesc ) { int iKeyFields = this . getKeyFields ( ) ; for ( int iKeyFieldSeq = Constants . MAIN_KEY_FIELD ; iKeyFieldSeq < iKeyFields + Constants . MAIN_KEY_FIELD ; iKeyFieldSeq ++ ) { this . getField ( iKeyFieldSeq ) . setData ( m_rgobjTempData != null ? m_rgobjTempData [ iKeyFieldSeq ] : null ) ; } } | Move the key area to the record . |
17,316 | public GridBagConstraints getGBConstraints ( ) { if ( m_gbconstraints == null ) { m_gbconstraints = new GridBagConstraints ( ) ; m_gbconstraints . insets = new Insets ( 2 , 2 , 2 , 2 ) ; m_gbconstraints . ipadx = 2 ; m_gbconstraints . ipady = 2 ; } return m_gbconstraints ; } | Get the GridBagConstraints . |
17,317 | public void setComponentConstraints ( JComponent component ) { GridBagConstraints c = this . getGBConstraints ( ) ; GridBagLayout gridbag = ( GridBagLayout ) this . getScreenLayout ( ) ; gridbag . setConstraints ( component , c ) ; Application application = BaseApplet . getSharedInstance ( ) . getApplication ( ) ; MuffinManager muffinManager = application . getMuffinManager ( ) ; if ( component instanceof JTextComponent ) if ( muffinManager != null ) { muffinManager . replaceClipboardAction ( component , "cut" ) ; muffinManager . replaceClipboardAction ( component , "copy" ) ; muffinManager . replaceClipboardAction ( component , "paste" ) ; } } | Set the constraints for this component . If you aren t using gridbag override this . |
17,318 | public void addScreenLabels ( Container parent ) { GridBagConstraints c = this . getGBConstraints ( ) ; c . weightx = 0.0 ; c . anchor = GridBagConstraints . NORTHEAST ; c . gridx = 0 ; c . gridy = GridBagConstraints . RELATIVE ; for ( int iIndex = 0 ; ; iIndex ++ ) { Converter converter = this . getFieldForScreen ( iIndex ) ; if ( converter == SKIP_THIS_FIELD ) continue ; if ( converter == null ) break ; this . addScreenLabel ( parent , converter ) ; } } | Add the description labels to the first column of the grid . |
17,319 | public JComponent addScreenLabel ( Container parent , Converter fieldInfo ) { JComponent label = new JLabel ( fieldInfo . getFieldDesc ( ) ) ; this . setComponentConstraints ( label ) ; parent . add ( label ) ; fieldInfo . addComponent ( label ) ; return label ; } | Add this label to the first column of the grid . |
17,320 | public JComponent createScreenComponent ( Converter fieldInfo ) { int iRows = 1 ; int iColumns = fieldInfo . getMaxLength ( ) ; if ( iColumns > 40 ) { iRows = 3 ; iColumns = 30 ; } String strDefault = fieldInfo . toString ( ) ; if ( strDefault == null ) strDefault = Constants . BLANK ; JComponent component = null ; if ( iRows <= 1 ) { component = new JTextField ( strDefault , iColumns ) ; if ( fieldInfo instanceof FieldInfo ) if ( Number . class . isAssignableFrom ( ( ( FieldInfo ) fieldInfo ) . getDataClass ( ) ) ) ( ( JTextField ) component ) . setHorizontalAlignment ( JTextField . RIGHT ) ; } else { component = new JTextArea ( strDefault , iRows , iColumns ) ; component . setBorder ( m_borderLine ) ; } return component ; } | Add the screen controls to the second column of the grid . Create a default component for this fieldInfo . |
17,321 | public void addScreenButtons ( Container parent ) { GridBagLayout gridbag = ( GridBagLayout ) this . getScreenLayout ( ) ; GridBagConstraints c = this . getGBConstraints ( ) ; c . gridheight = GridBagConstraints . REMAINDER ; c . anchor = GridBagConstraints . NORTH ; c . gridwidth = 1 ; ImageIcon icon = BaseApplet . getSharedInstance ( ) . loadImageIcon ( Constants . SUBMIT ) ; JButton button = new JButton ( Constants . SUBMIT , icon ) ; button . setOpaque ( false ) ; button . setName ( Constants . SUBMIT ) ; gridbag . setConstraints ( button , c ) ; parent . add ( button ) ; button . addActionListener ( this ) ; c . gridx = 3 ; c . gridheight = GridBagConstraints . REMAINDER ; c . anchor = GridBagConstraints . NORTH ; icon = BaseApplet . getSharedInstance ( ) . loadImageIcon ( Constants . RESET ) ; button = new JButton ( Constants . RESET , icon ) ; button . setOpaque ( false ) ; button . setName ( Constants . RESET ) ; gridbag . setConstraints ( button , c ) ; parent . add ( button ) ; c . gridheight = 1 ; button . addActionListener ( this ) ; } | Add a submit and reset buttons to the bottom of the grid . |
17,322 | public void focusGained ( FocusEvent e ) { if ( m_componentNextFocus != null ) { m_componentNextFocus . requestFocus ( ) ; return ; } Component component = ( Component ) e . getSource ( ) ; String string = component . getName ( ) ; if ( this . getFieldList ( ) != null ) { FieldInfo field = this . getFieldList ( ) . getField ( string ) ; if ( field != null ) this . getBaseApplet ( ) . setStatusText ( field . getFieldTip ( ) , Constants . INFORMATION ) ; } String strLastError = BaseApplet . getSharedInstance ( ) . getLastError ( 0 ) ; if ( ( strLastError != null ) && ( strLastError . length ( ) > 0 ) ) this . getBaseApplet ( ) . setStatusText ( strLastError , Constants . WARNING ) ; } | Required as part of the FocusListener interface . |
17,323 | public void focusLost ( FocusEvent e ) { m_componentNextFocus = null ; Component component = ( Component ) e . getSource ( ) ; String string = component . getName ( ) ; FieldInfo field = null ; if ( this . getFieldList ( ) != null ) field = this . getFieldList ( ) . getField ( string ) ; if ( field != null ) { int iErrorCode = Constants . NORMAL_RETURN ; if ( component instanceof FieldComponent ) iErrorCode = field . setData ( ( ( FieldComponent ) component ) . getControlValue ( ) , Constants . DISPLAY , Constants . SCREEN_MOVE ) ; else if ( component instanceof JTextComponent ) iErrorCode = field . setString ( ( ( JTextComponent ) component ) . getText ( ) , Constants . DISPLAY , Constants . SCREEN_MOVE ) ; if ( iErrorCode != Constants . NORMAL_RETURN ) { field . displayField ( ) ; m_componentNextFocus = component ; } } } | When a control loses focus move the field to the data area . |
17,324 | public void resetFocus ( ) { for ( int i = 0 ; ; i ++ ) { Converter converter = this . getFieldForScreen ( i ) ; if ( converter == SKIP_THIS_FIELD ) continue ; if ( converter == null ) break ; if ( converter instanceof FieldInfo ) if ( ( ( FieldInfo ) converter ) . getComponent ( CONTROL ) != null ) { ( ( Component ) ( ( FieldInfo ) converter ) . getComponent ( CONTROL ) ) . requestFocus ( ) ; return ; } } } | Focus to the first field . |
17,325 | public void dumpTo ( AreaTree tree , PrintWriter out ) { if ( produceHeader ) { out . println ( "<!DOCTYPE html>" ) ; out . println ( "<html>" ) ; out . println ( "<head>" ) ; out . println ( "<title>" + tree . getRoot ( ) . getPage ( ) . getTitle ( ) + "</title>" ) ; out . println ( "<meta charset=\"utf-8\">" ) ; out . println ( "<meta name=\"generator\" content=\"FITLayout - area tree dump\">" ) ; out . println ( "</head>" ) ; out . println ( "<body>" ) ; } recursiveDumpArea ( tree . getRoot ( ) , 1 , out ) ; if ( produceHeader ) { out . println ( "</body>" ) ; out . println ( "</html>" ) ; } } | Formats the complete area tree to an output stream . |
17,326 | public void dumpTo ( Page page , PrintWriter out ) { if ( produceHeader ) { out . println ( "<!DOCTYPE html>" ) ; out . println ( "<html>" ) ; out . println ( "<head>" ) ; out . println ( "<title>" + page . getTitle ( ) + "</title>" ) ; out . println ( "<meta charset=\"utf-8\">" ) ; out . println ( "<meta name=\"generator\" content=\"FITLayout - box tree dump\">" ) ; out . println ( "</head>" ) ; out . println ( "<body>" ) ; } recursiveDumpBoxes ( page . getRoot ( ) , 1 , out ) ; if ( produceHeader ) { out . println ( "</body>" ) ; out . println ( "</html>" ) ; } } | Formats the complete box tree to an output stream . |
17,327 | public Set < de . uniulm . omi . cloudiator . flexiant . client . domain . Image > getImages ( final String locationUUID ) throws FlexiantException { return this . getResources ( ResourceType . IMAGE , Image . class , locationUUID ) . stream ( ) . map ( de . uniulm . omi . cloudiator . flexiant . client . domain . Image :: new ) . collect ( Collectors . toSet ( ) ) ; } | Returns all images . |
17,328 | public Set < Location > getLocations ( ) throws FlexiantException { Set < Location > locations = new HashSet < Location > ( ) ; for ( Vdc vdc : this . getResources ( ResourceType . VDC , Vdc . class , null ) ) { locations . add ( Location . from ( vdc , this . getResource ( ( vdc ) . getClusterUUID ( ) , ResourceType . CLUSTER , Cluster . class ) ) ) ; } locations . addAll ( this . getResources ( ResourceType . CLUSTER , Cluster . class , null ) . stream ( ) . map ( Location :: from ) . collect ( Collectors . toList ( ) ) ) ; return locations ; } | Returns all locations . |
17,329 | public Set < Hardware > getHardwareFlavors ( final String locationUUID ) throws FlexiantException { return Hardware . from ( this . getResources ( ResourceType . PRODUCTOFFER , ProductOffer . class , locationUUID ) , this . getResources ( ResourceType . CLUSTER , Cluster . class , null ) ) ; } | Returns all hardware . |
17,330 | public Set < de . uniulm . omi . cloudiator . flexiant . client . domain . Network > getNetworks ( final String locationUUID ) throws FlexiantException { return this . getResources ( ResourceType . NETWORK , Network . class , locationUUID ) . stream ( ) . map ( de . uniulm . omi . cloudiator . flexiant . client . domain . Network :: new ) . collect ( Collectors . toSet ( ) ) ; } | Returns all networks . |
17,331 | protected de . uniulm . omi . cloudiator . flexiant . client . domain . Server searchByIp ( Set < de . uniulm . omi . cloudiator . flexiant . client . domain . Server > servers , String ip ) { for ( de . uniulm . omi . cloudiator . flexiant . client . domain . Server server : servers ) { if ( server . getPublicIpAddress ( ) != null && server . getPublicIpAddress ( ) . equals ( ip ) ) { return server ; } if ( server . getPrivateIpAddress ( ) != null && server . getPrivateIpAddress ( ) . equals ( ip ) ) { return server ; } } return null ; } | Searches for the given ip in the given list of servers . |
17,332 | public de . uniulm . omi . cloudiator . flexiant . client . domain . Server createServer ( final ServerTemplate serverTemplate ) throws FlexiantException { checkNotNull ( serverTemplate ) ; io . github . cloudiator . flexiant . extility . Server server = new io . github . cloudiator . flexiant . extility . Server ( ) ; server . setResourceName ( serverTemplate . getServerName ( ) ) ; server . setCustomerUUID ( this . getCustomerUUID ( ) ) ; server . setProductOfferUUID ( serverTemplate . getServerProductOffer ( ) ) ; server . setVdcUUID ( serverTemplate . getVdc ( ) ) ; server . setImageUUID ( serverTemplate . getImage ( ) ) ; Disk disk = new Disk ( ) ; disk . setProductOfferUUID ( serverTemplate . getDiskProductOffer ( ) ) ; disk . setIndex ( 0 ) ; server . getDisks ( ) . add ( disk ) ; final Set < String > networks = new HashSet < String > ( ) ; if ( serverTemplate . getTemplateOptions ( ) . getNetworks ( ) . isEmpty ( ) ) { if ( this . getNetworks ( serverTemplate . getVdc ( ) ) . size ( ) == 1 ) { networks . add ( this . getNetworks ( serverTemplate . getVdc ( ) ) . iterator ( ) . next ( ) . getId ( ) ) ; } else { throw new FlexiantException ( "Could not uniquely identify network." ) ; } } else { networks . addAll ( serverTemplate . getTemplateOptions ( ) . getNetworks ( ) ) ; } for ( String network : networks ) { Nic nic = new Nic ( ) ; nic . setNetworkUUID ( network ) ; server . getNics ( ) . add ( nic ) ; } try { Job serverJob = this . getService ( ) . createServer ( server , null , null , null ) ; this . waitForJob ( serverJob ) ; final de . uniulm . omi . cloudiator . flexiant . client . domain . Server createdServer = this . getServer ( serverJob . getItemUUID ( ) ) ; checkState ( createdServer != null , String . format ( "Execution of job %s for server %s was returned as successful, but the server could not be queried." , serverJob . getResourceUUID ( ) , serverJob . getItemUUID ( ) ) ) ; this . startServer ( createdServer ) ; return createdServer ; } catch ( ExtilityException e ) { throw new FlexiantException ( "Could not create server" , e ) ; } } | Creates a server with the given properties . |
17,333 | public void startServer ( de . uniulm . omi . cloudiator . flexiant . client . domain . Server server ) throws FlexiantException { if ( server == null ) { throw new IllegalArgumentException ( "The given server must not be null." ) ; } this . startServer ( server . getId ( ) ) ; } | Starts the given server |
17,334 | public void deleteServer ( final de . uniulm . omi . cloudiator . flexiant . client . domain . Server server ) throws FlexiantException { this . deleteServer ( server . getId ( ) ) ; } | Deletes the given server . |
17,335 | protected void changeServerStatus ( String serverUUID , ServerStatus status ) throws FlexiantException { try { Job job = this . getService ( ) . changeServerStatus ( serverUUID , status , true , null , null ) ; this . waitForJob ( job ) ; } catch ( ExtilityException e ) { throw new FlexiantException ( "Could not start server" , e ) ; } } | Changes the server status to the given status . |
17,336 | public de . uniulm . omi . cloudiator . flexiant . client . domain . Server getServer ( final String serverUUID ) throws FlexiantException { final io . github . cloudiator . flexiant . extility . Server server = this . getResource ( serverUUID , ResourceType . SERVER , io . github . cloudiator . flexiant . extility . Server . class ) ; if ( server == null ) { return null ; } return new de . uniulm . omi . cloudiator . flexiant . client . domain . Server ( server ) ; } | Returns information about the given server . |
17,337 | public de . uniulm . omi . cloudiator . flexiant . client . domain . Image getImage ( final String imageUUID ) throws FlexiantException { final io . github . cloudiator . flexiant . extility . Image image = this . getResource ( imageUUID , ResourceType . IMAGE , io . github . cloudiator . flexiant . extility . Image . class ) ; if ( image == null ) { return null ; } return new de . uniulm . omi . cloudiator . flexiant . client . domain . Image ( image ) ; } | Retrieves the image identified by the given uuid . |
17,338 | public Hardware getHardware ( final String hardwareUUID , final String locationUUID ) throws FlexiantException { checkNotNull ( hardwareUUID ) ; String [ ] parts = hardwareUUID . split ( ":" ) ; checkArgument ( parts . length == 2 , "Expected hardwareUUID to contain :" ) ; final ProductOffer machineOffer = this . getResource ( parts [ 0 ] , ResourceType . PRODUCTOFFER , ProductOffer . class ) ; final ProductOffer diskOffer = this . getResource ( parts [ 1 ] , ResourceType . PRODUCTOFFER , ProductOffer . class ) ; if ( machineOffer == null || diskOffer == null ) { return null ; } return Hardware . from ( machineOffer , diskOffer , locationUUID ) ; } | Retrieves the hardware identified by the given uuid . |
17,339 | public Location getLocation ( final String locationUUID ) throws FlexiantException { final Cluster cluster = this . getCluster ( locationUUID ) ; if ( cluster != null ) { return Location . from ( cluster ) ; } final Vdc vdc = this . getVdc ( locationUUID ) ; if ( vdc != null ) { final Cluster clusterofVDC = this . getCluster ( vdc . getClusterUUID ( ) ) ; checkState ( clusterofVDC != null , String . format ( "Error while retrieving cluster of vdc %s. VDC is in cluster %s, but this cluster " + "does not exist. Looks like the vdc is corrupted." , vdc , vdc . getClusterUUID ( ) ) ) ; return Location . from ( vdc , clusterofVDC ) ; } return null ; } | Retrieves the location identified by the given uuid . |
17,340 | protected Cluster getCluster ( final String clusterUUID ) throws FlexiantException { return this . getResource ( clusterUUID , ResourceType . CLUSTER , Cluster . class ) ; } | Loads the cluster with the given uuid . |
17,341 | protected Vdc getVdc ( final String vdcUUID ) throws FlexiantException { return this . getResource ( vdcUUID , ResourceType . VDC , Vdc . class ) ; } | Loads the vdc with the given uuid . |
17,342 | protected < T > T getResource ( final String resourceUUID , final ResourceType resourceType , final Class < T > type ) throws FlexiantException { SearchFilter sf = new SearchFilter ( ) ; FilterCondition fc = new FilterCondition ( ) ; fc . setCondition ( Condition . IS_EQUAL_TO ) ; fc . setField ( "resourceUUID" ) ; fc . getValue ( ) . add ( resourceUUID ) ; sf . getFilterConditions ( ) . add ( fc ) ; return this . getSingleResource ( sf , resourceType , type ) ; } | Retrieves a resource |
17,343 | protected < T > T getSingleResource ( final SearchFilter sf , final ResourceType resourceType , final Class < T > type ) throws FlexiantException { try { ListResult result = this . getService ( ) . listResources ( sf , null , resourceType ) ; if ( result . getList ( ) . size ( ) > 1 ) { throw new FlexiantException ( "Found multiple resources, single resource expected." ) ; } if ( result . getList ( ) . isEmpty ( ) ) { return null ; } return ( T ) result . getList ( ) . get ( 0 ) ; } catch ( ExtilityException e ) { throw new FlexiantException ( "Error while retrieving resources" , e ) ; } } | Retrieves a single resource using the given search filter and the given resource type . |
17,344 | protected < T > List < T > getResources ( final String prefix , final String attribute , final ResourceType resourceType , final Class < T > type , final String locationUUID ) throws FlexiantException { SearchFilter sf = new SearchFilter ( ) ; FilterCondition fc = new FilterCondition ( ) ; fc . setCondition ( Condition . STARTS_WITH ) ; fc . setField ( attribute ) ; fc . getValue ( ) . add ( prefix ) ; sf . getFilterConditions ( ) . add ( fc ) ; if ( locationUUID != null ) { FilterCondition fcLocation = new FilterCondition ( ) ; fcLocation . setCondition ( Condition . IS_EQUAL_TO ) ; fcLocation . setField ( "vdcUUID" ) ; fcLocation . getValue ( ) . add ( locationUUID ) ; sf . getFilterConditions ( ) . add ( fcLocation ) ; } try { return ( List < T > ) this . getService ( ) . listResources ( sf , null , resourceType ) . getList ( ) ; } catch ( ExtilityException e ) { throw new FlexiantException ( String . format ( "Error while retrieving resource with prefix %s on attribute %s of resourceType %s" , prefix , attribute , resourceType ) , e ) ; } } | Retrieves a list of resources matching the given prefix on the given attribute which are of the given type . |
17,345 | protected < T > List < T > getResources ( final ResourceType resourceType , final Class < T > type , final String locationUUID ) throws FlexiantException { SearchFilter sf = new SearchFilter ( ) ; if ( locationUUID != null ) { FilterCondition fcLocation = new FilterCondition ( ) ; fcLocation . setCondition ( Condition . IS_EQUAL_TO ) ; fcLocation . setField ( "vdcUUID" ) ; fcLocation . getValue ( ) . add ( locationUUID ) ; sf . getFilterConditions ( ) . add ( fcLocation ) ; } try { return ( List < T > ) this . getService ( ) . listResources ( sf , null , resourceType ) . getList ( ) ; } catch ( ExtilityException e ) { throw new FlexiantException ( String . format ( "Error while retrieving resources of resourceType %s." , resourceType ) , e ) ; } } | Returns all resources of the given type . |
17,346 | public String getPassword ( ) { if ( ( password != null ) && ( password . length ( ) > 0 ) ) return password ; char [ ] rgchPassword = passwordField . getPassword ( ) ; return new String ( rgchPassword ) ; } | Get the password that was typed in . |
17,347 | public void freeRemoteSession ( ) throws RemoteException { if ( m_tableRemote != null ) m_tableRemote . freeRemoteSession ( ) ; m_tableRemote = null ; m_mapCache = null ; m_htCache = null ; } | Free the remote table . |
17,348 | public Object add ( Object data , int iOpenMode ) throws DBException , RemoteException { m_objCurrentPhysicalRecord = NONE ; m_objCurrentLockedRecord = NONE ; m_objCurrentCacheRecord = NONE ; Object bookmark = m_tableRemote . add ( data , iOpenMode ) ; if ( m_iPhysicalLastRecordPlusOne != - 1 ) if ( ( cacheMode == CacheMode . CACHE_ON_WRITE ) || ( cacheMode == CacheMode . PASSIVE_CACHE ) ) { if ( m_mapCache != null ) { m_mapCache . set ( m_iPhysicalLastRecordPlusOne , data ) ; m_iPhysicalLastRecordPlusOne ++ ; } } return bookmark ; } | Add - add this data to the file . |
17,349 | public Object cacheGetMove ( int iRowOrRelative , int iRowCount , int iAbsoluteRow , boolean bGet ) throws DBException , RemoteException { m_bhtGet = bGet ; m_objCurrentPhysicalRecord = NONE ; m_objCurrentCacheRecord = NONE ; m_iCurrentLogicalPosition = iAbsoluteRow ; if ( ( m_iPhysicalLastRecordPlusOne != - 1 ) && ( m_iCurrentLogicalPosition >= m_iPhysicalLastRecordPlusOne ) ) return FieldTable . EOF_RECORD ; try { Object objData = null ; if ( ( m_mapCache == null ) && ( m_htCache == null ) ) m_mapCache = new ArrayCache ( ) ; if ( m_mapCache != null ) if ( iAbsoluteRow != - 1 ) objData = m_mapCache . get ( iAbsoluteRow ) ; if ( objData == NONE ) { objData = FieldTable . DELETED_RECORD ; } else if ( objData != null ) { m_objCurrentCacheRecord = new Integer ( iAbsoluteRow ) ; } else if ( objData == null ) { m_objCurrentLockedRecord = NONE ; if ( m_mapCache != null ) if ( iAbsoluteRow == m_mapCache . getEndIndex ( ) + 1 ) iRowCount = MULTIPLE_READ_COUNT ; if ( bGet ) objData = m_tableRemote . get ( iRowOrRelative , iRowCount ) ; else objData = m_tableRemote . doMove ( iRowOrRelative , iRowCount ) ; if ( objData instanceof Vector ) if ( ( ( Vector ) objData ) . size ( ) > 1 ) if ( ! ( ( ( Vector ) objData ) . get ( 0 ) instanceof Vector ) ) iRowCount = 1 ; if ( objData instanceof Vector ) { if ( m_mapCache != null ) { m_objCurrentCacheRecord = new Integer ( m_iCurrentLogicalPosition ) ; if ( iRowCount == 1 ) { m_mapCache . set ( m_iCurrentLogicalPosition , objData ) ; m_objCurrentPhysicalRecord = m_objCurrentCacheRecord ; } else { Vector < Object > objectVector = ( Vector ) objData ; for ( int i = objectVector . size ( ) - 1 ; i >= 0 ; i -- ) { objData = objectVector . get ( i ) ; if ( objData instanceof Vector ) { if ( iAbsoluteRow != - 1 ) { m_mapCache . set ( iAbsoluteRow + i , objData ) ; if ( i == objectVector . size ( ) - 1 ) m_objCurrentPhysicalRecord = new Integer ( iAbsoluteRow + i ) ; } } else if ( ( m_iPhysicalLastRecordPlusOne == - 1 ) || ( m_iPhysicalLastRecordPlusOne <= m_iCurrentLogicalPosition + i ) ) m_iPhysicalLastRecordPlusOne = m_iCurrentLogicalPosition + i ; else objData = FieldTable . DELETED_RECORD ; } } } } else { if ( ( m_iPhysicalLastRecordPlusOne == - 1 ) || ( m_iPhysicalLastRecordPlusOne <= m_iCurrentLogicalPosition ) ) m_iPhysicalLastRecordPlusOne = m_iCurrentLogicalPosition ; else { if ( ( ! FieldTable . DELETED_RECORD . equals ( objData ) ) && ( ! FieldTable . EOF_RECORD . equals ( objData ) ) ) objData = FieldTable . DELETED_RECORD ; } } } return objData ; } catch ( RemoteException ex ) { throw ex ; } } | Move or get this record and cache multiple records if possible . |
17,350 | public boolean setCache ( Object objTargetRow , Object data ) { if ( objTargetRow != NONE ) { if ( m_mapCache != null ) { int iTargetRow = ( ( Integer ) objTargetRow ) . intValue ( ) ; int iCurrentPhysicalRecord = ( ( Integer ) m_objCurrentPhysicalRecord ) . intValue ( ) ; if ( iTargetRow == iCurrentPhysicalRecord ) { m_objCurrentPhysicalRecord = NONE ; m_objCurrentCacheRecord = NONE ; m_objCurrentLockedRecord = NONE ; } if ( m_iPhysicalLastRecordPlusOne == iTargetRow ) m_iPhysicalLastRecordPlusOne ++ ; m_mapCache . set ( iTargetRow , data ) ; return true ; } if ( m_htCache != null ) { if ( objTargetRow . equals ( m_objCurrentPhysicalRecord ) ) { m_objCurrentPhysicalRecord = NONE ; m_objCurrentCacheRecord = NONE ; m_objCurrentLockedRecord = NONE ; } if ( data != null ) m_htCache . put ( objTargetRow , data ) ; else m_htCache . remove ( objTargetRow ) ; return true ; } } return false ; } | Clear this entry in the cache so the next access will get the remote data . |
17,351 | public org . jbundle . thin . base . db . FieldList makeFieldList ( String strFieldsToInclude ) throws RemoteException { return m_tableRemote . makeFieldList ( strFieldsToInclude ) ; } | make a thin FieldList for this table . Usually used for special queries that don t have a field list available . |
17,352 | public CacheMode setCacheMode ( CacheMode cacheMode , FieldList record ) { CacheMode oldCacheMode = this . cacheMode ; this . cacheMode = cacheMode ; if ( ( cacheMode == CacheMode . PASSIVE_CACHE ) && ( oldCacheMode != CacheMode . PASSIVE_CACHE ) ) { m_mapCache = null ; m_htCache = null ; if ( record != null ) { try { if ( record . getEditMode ( ) == Constants . EDIT_CURRENT ) { record . getTable ( ) . setHandle ( record . getCounterField ( ) . getData ( ) , 0 ) ; } if ( record . getEditMode ( ) == Constants . EDIT_IN_PROGRESS ) { record . getTable ( ) . setHandle ( record . getCounterField ( ) . getData ( ) , 0 ) ; record . getTable ( ) . edit ( ) ; } } catch ( DBException e ) { e . printStackTrace ( ) ; } } } return oldCacheMode ; } | Change the cache mode |
17,353 | public String getString ( Charset charset ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; byte cc = get ( ) ; while ( cc != 0 ) { baos . write ( cc ) ; cc = get ( ) ; } byte [ ] buf = baos . toByteArray ( ) ; return new String ( buf , charset ) ; } | returns null terminated string |
17,354 | public FilterByteBuffer putString ( String str , Charset charset ) throws IOException { byte [ ] bytes = str . getBytes ( charset ) ; put ( bytes ) . put ( ( byte ) 0 ) ; return this ; } | Puts string as null terminated byte array |
17,355 | public FilterByteBuffer get ( ByteBuffer bb ) throws IOException { byte [ ] buf = new byte [ BUFSIZE ] ; while ( bb . hasRemaining ( ) ) { int lim = Math . min ( BUFSIZE , bb . remaining ( ) ) ; get ( buf , 0 , lim ) ; bb . put ( buf , 0 , lim ) ; } return this ; } | Tries to read remaining bytes into ByteBuffer . |
17,356 | public FilterByteBuffer get ( byte [ ] dst , int offset , int length ) throws IOException { checkIn ( ) ; int len = length ; int count = 100 ; while ( len > 0 && count > 0 ) { int rc = in . read ( dst , offset + length - len , len ) ; if ( rc == - 1 ) { throw new EOFException ( ) ; } len -= rc ; count -- ; } if ( count == 0 ) { throw new IOException ( "couldn't fill buffer after 100 tries" ) ; } position += length ; return this ; } | Tries to read length bytes to dst . |
17,357 | public FilterByteBuffer get ( byte [ ] dst ) throws IOException { checkIn ( ) ; int rc = in . read ( dst ) ; if ( rc != dst . length ) { throw new EOFException ( ) ; } position += dst . length ; return this ; } | Tries to fill dst . |
17,358 | public FilterByteBuffer put ( byte [ ] src , int offset , int length ) throws IOException { checkOut ( ) ; out . write ( src , offset , length ) ; position += length ; return this ; } | Puts length bytes . |
17,359 | public FilterByteBuffer put ( byte [ ] src ) throws IOException { checkOut ( ) ; out . write ( src ) ; position += src . length ; return this ; } | Puts whole dst . |
17,360 | public void close ( ) throws IOException { if ( out != null ) { out . close ( ) ; out = null ; } if ( in != null ) { in . close ( ) ; in = null ; } } | Closes underlying streams . |
17,361 | public void dumpContext ( PrintWriter writer ) { try { NamingEnumeration < NameClassPair > list = context . list ( "/" ) ; writer . print ( "\n{\n name: \"" ) ; writer . print ( this . root ) ; writer . println ( "\",\n children: [" ) ; enumerate ( list , "/" , writer ) ; writer . println ( "]}" ) ; writer . flush ( ) ; } catch ( NamingException e ) { e . printStackTrace ( writer ) ; } } | dump the current context to a PrintWriter |
17,362 | public String changePassword ( final String oldPassword , final String newPassword ) { return Security . changePassword ( brokerSession , oldPassword , newPassword ) ; } | Changes the user s password . |
17,363 | public String loginDisabled ( ) { AuthResult result = brokerSession . authenticate ( "dummy" , "dummy" , null ) ; return result . status == AuthStatus . NOLOGINS ? result . reason : null ; } | Return login disabled message . |
17,364 | public boolean logout ( boolean force , String target , String message ) { boolean result = super . logout ( force , target , message ) ; if ( result ) { brokerSession . disconnect ( ) ; } return result ; } | Override to disconnect broker . |
17,365 | public static PermutationMatrix getInstance ( int n ) { PermutationMatrix pm = map . get ( n ) ; if ( pm == null ) { pm = new PermutationMatrix ( n ) ; map . put ( n , pm ) ; } return pm ; } | Returns immutable PermutationMatrix possibly from cache . |
17,366 | public void addButtons ( ) { this . addButton ( Constants . BACK ) ; this . addButton ( Constants . FORM ) ; this . addButton ( Constants . DELETE ) ; this . addButton ( Constants . HELP ) ; } | Add the buttons to this window . Override this to include buttons other than the default buttons . |
17,367 | public void setStatusText ( String status ) { if ( status != null ) oldStatusText = task . getStatusText ( 0 ) ; else status = oldStatusText ; task . setStatusText ( status ) ; } | Change the status display . |
17,368 | public static < T > Long count ( EntityManager em , CriteriaQuery < T > criteria ) { return em . createQuery ( countCriteria ( em , criteria ) ) . getSingleResult ( ) ; } | Result count from a CriteriaQuery |
17,369 | public static < T > CriteriaQuery < Long > countCriteria ( EntityManager em , CriteriaQuery < T > criteria ) { CriteriaBuilder builder = em . getCriteriaBuilder ( ) ; CriteriaQuery < Long > countCriteria = builder . createQuery ( Long . class ) ; copyCriteriaNoSelection ( criteria , countCriteria ) ; countCriteria . select ( builder . count ( findRoot ( countCriteria , criteria . getResultType ( ) ) ) ) ; return countCriteria ; } | Create a row count CriteriaQuery from a CriteriaQuery |
17,370 | public static synchronized < T > String getOrCreateAlias ( Selection < T > selection ) { if ( aliasCount > 1000 ) aliasCount = 0 ; String alias = selection . getAlias ( ) ; if ( alias == null ) { alias = "JDAL_generatedAlias" + aliasCount ++ ; selection . alias ( alias ) ; } return alias ; } | Gets The result alias if none set a default one and return it |
17,371 | public static < T > Root < T > findRoot ( CriteriaQuery < T > query ) { return findRoot ( query , query . getResultType ( ) ) ; } | Find Root of result type |
17,372 | public static < T > Root < T > findRoot ( CriteriaQuery < ? > query , Class < T > clazz ) { for ( Root < ? > r : query . getRoots ( ) ) { if ( clazz . equals ( r . getJavaType ( ) ) ) { return ( Root < T > ) r . as ( clazz ) ; } } return null ; } | Find the Root with type class on CriteriaQuery Root Set |
17,373 | public static Path < ? > getPath ( Path < ? > path , String propertyPath ) { if ( StringUtils . isEmpty ( propertyPath ) ) return path ; String name = StringUtils . substringBefore ( propertyPath , PropertyUtils . PROPERTY_SEPARATOR ) ; Path < ? > p = path . get ( name ) ; return getPath ( p , StringUtils . substringAfter ( propertyPath , PropertyUtils . PROPERTY_SEPARATOR ) ) ; } | Gets a Path from Path using property path |
17,374 | public static String getAlias ( String queryString ) { Matcher m = ALIAS_PATTERN . matcher ( queryString ) ; return m . find ( ) ? m . group ( 1 ) : null ; } | Gets the alias of root entity of JQL query |
17,375 | public static String addOrder ( String queryString , String propertyPath , boolean asc ) { if ( StringUtils . containsIgnoreCase ( queryString , "order by" ) ) { return queryString ; } StringBuilder sb = new StringBuilder ( queryString ) ; sb . append ( " ORDER BY " ) ; sb . append ( getAlias ( queryString ) ) ; sb . append ( "." ) ; sb . append ( propertyPath ) ; sb . append ( " " ) ; sb . append ( asc ? "ASC" : "DESC" ) ; return sb . toString ( ) ; } | Add order by clause to queryString |
17,376 | public static String getKeyQuery ( String queryString , String name ) { Matcher m = FROM_PATTERN . matcher ( queryString ) ; if ( m . find ( ) ) { StringBuilder sb = new StringBuilder ( "SELECT " ) ; sb . append ( getAlias ( queryString ) ) ; sb . append ( "." ) ; sb . append ( name ) ; sb . append ( " " ) ; sb . append ( m . group ( ) ) ; return sb . toString ( ) ; } return null ; } | Gets Query String for selecting primary keys |
17,377 | public static void copyCriteriaNoSelection ( CriteriaQuery < ? > from , CriteriaQuery < ? > to ) { for ( Root < ? > root : from . getRoots ( ) ) { Root < ? > dest = to . from ( root . getJavaType ( ) ) ; dest . alias ( getOrCreateAlias ( root ) ) ; copyJoins ( root , dest ) ; } if ( from . getGroupList ( ) != null ) to . groupBy ( from . getGroupList ( ) ) ; to . distinct ( from . isDistinct ( ) ) ; if ( from . getGroupRestriction ( ) != null ) to . having ( from . getGroupRestriction ( ) ) ; if ( from . getRestriction ( ) != null ) to . where ( from . getRestriction ( ) ) ; if ( from . getOrderList ( ) != null ) to . orderBy ( from . getOrderList ( ) ) ; } | Copy Criteria without Selection |
17,378 | public static ArrayList < String > listBucketNames ( Map < String , Object > m ) { ArrayList < String > acc = new ArrayList < String > ( ) ; for ( Map . Entry < String , Object > entry : m . entrySet ( ) ) { if ( isValidBucket ( entry . getValue ( ) ) ) { acc . add ( entry . getKey ( ) ) ; } } return acc ; } | Returns a list of all bucket names in the provided Map . |
17,379 | private byte [ ] requestChunk ( int requestedSize ) { mPosInChunk = 0 ; if ( mCurrentChunkIndex ++ < mChunkList . size ( ) - 1 ) { return mCurrentChunk = mChunkList . get ( mCurrentChunkIndex ) ; } mChunkList . add ( mCurrentChunk = new byte [ Math . max ( requestedSize , mMinChunkSize ) ] ) ; return mCurrentChunk ; } | Request a new current chunk . |
17,380 | public void trim ( ) { List < byte [ ] > chunkList = mChunkList ; while ( chunkList . size ( ) - 1 > mCurrentChunkIndex ) { chunkList . remove ( chunkList . size ( ) - 1 ) ; } } | Reduce the memory allocated by this object by freeing all unused chunks . |
17,381 | private void addExactActions ( Construction construction , ParserActionSet set , Map < Construction , ParserActionSet > actions ) { for ( Entry < Construction , ParserActionSet > entry : actions . entrySet ( ) ) { Construction c = entry . getKey ( ) ; if ( ! c . getName ( ) . equals ( construction . getName ( ) ) ) { continue ; } if ( c . isNonTerminal ( ) != construction . isNonTerminal ( ) ) { continue ; } if ( construction . isNonTerminal ( ) ) { set . addActions ( entry . getValue ( ) ) ; continue ; } Terminal terminal = ( Terminal ) construction ; if ( terminal . getText ( ) == null ) { continue ; } Terminal t = ( Terminal ) c ; if ( grammar . isIgnoreCase ( ) ) { if ( terminal . getText ( ) . equalsIgnoreCase ( t . getText ( ) ) ) { set . addActions ( entry . getValue ( ) ) ; } } else { if ( terminal . getText ( ) . equals ( t . getText ( ) ) ) { set . addActions ( entry . getValue ( ) ) ; } } } } | This method adds all actions which are concrete what means that name and content match exactly . |
17,382 | private void addNonExcactActions ( Construction construction , ParserActionSet set , Map < Construction , ParserActionSet > actions ) { set . addActions ( actions . get ( new Terminal ( construction . getName ( ) , null ) ) ) ; } | The method is needed for grammars where no keywords are available like Fortran . |
17,383 | public static String composeMessage ( List < ValidationResult > results ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "Validation failed" ) ; if ( results != null && results . size ( ) > 0 ) { boolean first = true ; for ( ValidationResult result : results ) { if ( result . getType ( ) != ValidationResultType . Information ) { if ( ! first ) builder . append ( ": " ) ; else builder . append ( ", " ) ; builder . append ( result . getMessage ( ) ) ; first = false ; } } } return builder . toString ( ) ; } | Composes human readable error message based on validation results . |
17,384 | public static ValidationException fromResults ( String correlationId , List < ValidationResult > results , boolean strict ) throws ValidationException { boolean hasErrors = false ; for ( ValidationResult result : results ) { if ( result . getType ( ) == ValidationResultType . Error ) hasErrors = true ; if ( strict && result . getType ( ) == ValidationResultType . Warning ) hasErrors = true ; } return hasErrors ? new ValidationException ( correlationId , results ) : null ; } | Creates a new ValidationException based on errors in validation results . If validation results have no errors than null is returned . |
17,385 | public static void throwExceptionIfNeeded ( String correlationId , List < ValidationResult > results , boolean strict ) throws ValidationException { ValidationException ex = fromResults ( correlationId , results , strict ) ; if ( ex != null ) throw ex ; } | Throws ValidationException based on errors in validation results . If validation results have no errors than no exception is thrown . |
17,386 | private static String convertByteArrayToString ( byte [ ] byteArray ) { if ( byteArray == null ) { throw new IllegalArgumentException ( "Byte array must not be null!" ) ; } StringBuffer hexString = new StringBuffer ( ) ; for ( int i = 0 ; i < byteArray . length ; i ++ ) { int digit = 0xFF & byteArray [ i ] ; String hexDigits = Integer . toHexString ( digit ) ; if ( hexDigits . length ( ) < 2 ) { hexString . append ( "0" ) ; } hexString . append ( hexDigits ) ; } return hexString . toString ( ) ; } | This method converts a byte array into a string converting each byte into a 2 - digit hex representation and appending them all together . |
17,387 | public static void addParsers ( final List < AbstractWarningsParser > parsers ) { parsers . add ( new ViolationsAdapter ( new CodenarcParser ( ) , Messages . _Warnings_Codenarc_ParserName ( ) , Messages . _Warnings_Codenarc_LinkName ( ) , Messages . _Warnings_Codenarc_TrendName ( ) ) ) ; parsers . add ( new ViolationsAdapter ( new CssLintParser ( ) , Messages . _Warnings_CssLint_ParserName ( ) , Messages . _Warnings_CssLint_LinkName ( ) , Messages . _Warnings_CssLint_TrendName ( ) ) ) ; parsers . add ( new ViolationsAdapter ( new GendarmeParser ( ) , Messages . _Warnings_Gendarme_ParserName ( ) , Messages . _Warnings_Gendarme_LinkName ( ) , Messages . _Warnings_Gendarme_TrendName ( ) ) ) ; parsers . add ( new ViolationsAdapter ( new JcReportParser ( ) , Messages . _Warnings_JCReport_ParserName ( ) , Messages . _Warnings_JCReport_LinkName ( ) , Messages . _Warnings_JCReport_TrendName ( ) ) ) ; parsers . add ( new ViolationsAdapter ( new Pep8Parser ( ) , Messages . _Warnings_Pep8_ParserName ( ) , Messages . _Warnings_Pep8_LinkName ( ) , Messages . _Warnings_Pep8_TrendName ( ) ) ) ; } | Appends the parsers of the violations plug - in to the specified list of parsers . |
17,388 | public static Double toNullableDouble ( Object value ) { if ( value == null ) return null ; if ( value instanceof Date ) return ( double ) ( ( Date ) value ) . getTime ( ) ; if ( value instanceof Calendar ) return ( double ) ( ( Calendar ) value ) . getTimeInMillis ( ) ; if ( value instanceof Duration ) return ( double ) ( ( Duration ) value ) . toMillis ( ) ; if ( value instanceof Boolean ) return ( boolean ) value ? 1.0 : 0.0 ; if ( value instanceof Integer ) return ( double ) ( ( int ) value ) ; if ( value instanceof Short ) return ( double ) ( ( short ) value ) ; if ( value instanceof Long ) return ( double ) ( ( long ) value ) ; if ( value instanceof Float ) return ( double ) ( ( float ) value ) ; if ( value instanceof Double ) return ( double ) value ; if ( value instanceof String ) try { return Double . parseDouble ( ( String ) value ) ; } catch ( NumberFormatException ex ) { return null ; } return null ; } | Converts value into doubles or returns null when conversion is not possible . |
17,389 | public static double toDoubleWithDefault ( Object value , double defaultValue ) { Double result = toNullableDouble ( value ) ; return result != null ? ( double ) result : defaultValue ; } | Converts value into doubles or returns default value when conversion is not possible . |
17,390 | public V put ( K1 key1 , K2 key2 , V value ) { return getOrPutGetNew ( key1 ) . put ( key2 , value ) ; } | Put v . |
17,391 | public V get ( K1 key1 , K2 key2 ) { return JMOptional . getOptional ( nestedMap , key1 ) . map ( map -> map . get ( key2 ) ) . orElse ( null ) ; } | Get v . |
17,392 | public static void notEmpty ( final Collection < ? > collection , final String parameterName ) { if ( collection . isEmpty ( ) ) { throw new IllegalArgumentException ( "\"" + parameterName + "\" must not be null or empty, but was: " + collection ) ; } } | Check that the provided Collection is not empty ) . |
17,393 | public String readPassword ( ) { this . before = "" ; this . after = "" ; terminal . formatln ( "%s: " , message ) ; try { for ( ; ; ) { Char c = terminal . read ( ) ; if ( c == null ) { throw new IOException ( "End of input." ) ; } int ch = c . asInteger ( ) ; if ( ch == Char . CR ) { return before + after ; } if ( ch == Char . DEL || ch == Char . BS ) { if ( before . length ( ) > 0 ) { before = before . substring ( 0 , before . length ( ) - 1 ) ; printInputLine ( ) ; } continue ; } if ( c instanceof Control ) { if ( c . equals ( Control . DELETE ) ) { if ( after . length ( ) > 0 ) { after = after . substring ( 1 ) ; } } else if ( c . equals ( Control . LEFT ) ) { if ( before . length ( ) > 0 ) { after = "" + before . charAt ( before . length ( ) - 1 ) + after ; before = before . substring ( 0 , before . length ( ) - 1 ) ; } } else if ( c . equals ( Control . HOME ) ) { after = before + after ; before = "" ; } else if ( c . equals ( Control . RIGHT ) ) { if ( after . length ( ) > 0 ) { before = before + after . charAt ( 0 ) ; after = after . substring ( 1 ) ; } } else if ( c . equals ( Control . END ) ) { before = before + after ; after = "" ; } else { continue ; } printInputLine ( ) ; continue ; } if ( ch == Char . ESC || ch == Char . ABR || ch == Char . EOF ) { throw new IOException ( "User interrupted: " + c . asString ( ) ) ; } if ( ch < 0x20 ) { continue ; } before = before + c . toString ( ) ; printInputLine ( ) ; } } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } | Read password from terminal . |
17,394 | public void add ( Collection < String > lines ) { for ( String line : lines ) { buffer . add ( line ) ; terminal . println ( line ) ; } } | Add new lines to the end of the buffer and print them out . |
17,395 | public void update ( int offset , List < String > lines ) { if ( lines . isEmpty ( ) ) { throw new IllegalArgumentException ( "Empty line set" ) ; } if ( offset >= count ( ) || offset < 0 ) { throw new IndexOutOfBoundsException ( "Index: " + offset + ", Size: " + count ( ) ) ; } int up = count ( ) - offset - 1 ; for ( int i = 0 ; i < lines . size ( ) ; ++ i ) { String line = lines . get ( i ) ; if ( i == 0 ) { terminal . print ( "\r" ) ; if ( up > 0 ) { terminal . print ( cursorUp ( up ) ) ; } } else { terminal . println ( ) ; -- up ; } String old = offset + i < buffer . size ( ) ? buffer . get ( offset + i ) : null ; buffer . set ( offset + i , line ) ; if ( line . equals ( old ) && ! line . isEmpty ( ) ) { continue ; } terminal . print ( CURSOR_ERASE ) ; terminal . print ( line ) ; } if ( up > 0 ) { terminal . format ( "\r%s%s" , cursorDown ( up ) , cursorRight ( printableWidth ( lastLine ( ) ) ) ) ; } } | Update a number of lines starting at a specific offset . |
17,396 | public void clear ( ) { if ( buffer . size ( ) > 0 ) { terminal . format ( "\r%s" , CURSOR_ERASE ) ; for ( int i = 1 ; i < buffer . size ( ) ; ++ i ) { terminal . format ( "%s%s" , UP , CURSOR_ERASE ) ; } buffer . clear ( ) ; } } | Clear the entire buffer and the terminal area it represents . |
17,397 | public void clearLast ( int N ) { if ( N < 1 ) { throw new IllegalArgumentException ( "Unable to clear " + N + " lines" ) ; } if ( N > count ( ) ) { throw new IllegalArgumentException ( "Count: " + N + ", Size: " + count ( ) ) ; } if ( N == count ( ) ) { clear ( ) ; return ; } terminal . format ( "\r%s" , CURSOR_ERASE ) ; buffer . remove ( buffer . size ( ) - 1 ) ; for ( int i = 1 ; i < N ; ++ i ) { terminal . format ( "%s%s" , UP , CURSOR_ERASE ) ; buffer . remove ( buffer . size ( ) - 1 ) ; } terminal . format ( "%s\r%s" , UP , cursorRight ( printableWidth ( lastLine ( ) ) ) ) ; } | Clear the last N lines and move the cursor to the end of the last remaining line . |
17,398 | public static Path copy ( Path sourcePath , Path destinationPath , CopyOption ... options ) { return operate ( sourcePath , destinationPath , "copy" , finalPath -> { try { return Files . copy ( sourcePath , finalPath , options ) ; } catch ( Exception e ) { return JMExceptionManager . handleExceptionAndReturnNull ( log , e , "copy" , sourcePath , destinationPath , options ) ; } } ) ; } | Copy path . |
17,399 | public static Optional < JMProgressiveManager < Path , Path > > copyDirRecursivelyAsync ( Path targetDirPath , Path destinationDirPath , CopyOption ... options ) { Map < Boolean , List < Path > > directoryOrFilePathMap = JMLambda . groupBy ( JMPath . getSubPathList ( targetDirPath ) , JMPath :: isDirectory ) ; JMOptional . getOptional ( directoryOrFilePathMap , true ) . ifPresent ( list -> list . stream ( ) . map ( dirPath -> JMPath . buildRelativeDestinationPath ( destinationDirPath , targetDirPath , dirPath ) ) . forEach ( JMPathOperation :: createDirectories ) ) ; return operateDir ( targetDirPath , destinationDirPath , directoryOrFilePathMap . get ( false ) , bulkPathList -> new JMProgressiveManager < > ( bulkPathList , path -> Optional . ofNullable ( copy ( path , JMPath . buildRelativeDestinationPath ( destinationDirPath , targetDirPath , path ) , options ) ) ) ) ; } | Copy dir recursively async optional . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.