idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
14,000 | public static final String getOwner ( Path file ) throws IOException { if ( supports ( "posix" ) ) { UserPrincipal owner = ( UserPrincipal ) Files . getAttribute ( file , "posix:owner" ) ; return owner . getName ( ) ; } else { JavaLogging . getLogger ( PosixHelp . class ) . warning ( "no owner support. getOwner(%s) returns \"\"" , file ) ; return "" ; } } | Return linux file owner name . Or |
14,001 | public static final String getGroup ( Path file ) throws IOException { if ( supports ( "posix" ) ) { PosixFileAttributeView view = Files . getFileAttributeView ( file , PosixFileAttributeView . class ) ; PosixFileAttributes attrs = view . readAttributes ( ) ; GroupPrincipal group = attrs . group ( ) ; return group . getName ( ) ; } else { JavaLogging . getLogger ( PosixHelp . class ) . warning ( "no posix support. getGroup(%s) returns \"\"" , file ) ; return "" ; } } | Return linux file group name . Or |
14,002 | private static String permsPart ( String perms ) { int length = perms . length ( ) ; if ( length > 10 || length < 9 ) { throw new IllegalArgumentException ( perms + " not permission. E.g. -rwxr--r--" ) ; } return length == 10 ? perms . substring ( 1 ) : perms ; } | Returns permission part of mode string |
14,003 | public static final String getModeString ( Path path ) throws IOException { char letter = getFileTypeLetter ( path ) ; if ( supports ( "posix" ) ) { Set < PosixFilePermission > perms = Files . getPosixFilePermissions ( path ) ; return letter + PosixFilePermissions . toString ( perms ) ; } else { switch ( letter ) { case '-' : return "-rw-r--r--" ; case 'd' : return "drwxr-xr-x" ; case 'l' : return "drw-r--r--" ; } } throw new UnsupportedOperationException ( "should not happen" ) ; } | Returns mode string for path . Real mode for linux . Others guess work . |
14,004 | public static final void setGroup ( String name , Path ... files ) throws IOException { if ( supports ( "posix" ) ) { for ( Path file : files ) { FileSystem fs = file . getFileSystem ( ) ; UserPrincipalLookupService upls = fs . getUserPrincipalLookupService ( ) ; GroupPrincipal group = upls . lookupPrincipalByGroupName ( name ) ; PosixFileAttributeView view = Files . getFileAttributeView ( file , PosixFileAttributeView . class ) ; view . setGroup ( group ) ; } } else { JavaLogging . getLogger ( PosixHelp . class ) . warning ( "no posix support. setGroup(%s)" , name ) ; } } | Change group of given files . Works only in linux |
14,005 | public static final void setOwner ( String name , Path ... files ) throws IOException { if ( supports ( "posix" ) ) { for ( Path file : files ) { FileSystem fs = file . getFileSystem ( ) ; UserPrincipalLookupService upls = fs . getUserPrincipalLookupService ( ) ; UserPrincipal user = upls . lookupPrincipalByName ( name ) ; Files . setOwner ( file , user ) ; } } else { JavaLogging . getLogger ( PosixHelp . class ) . warning ( "no owner support. setOwner(%s)" , name ) ; } } | Change user of given files . Works only in linux . |
14,006 | public static final void setPermission ( Path path , String perms ) throws IOException { checkFileType ( path , perms ) ; if ( supports ( "posix" ) ) { Set < PosixFilePermission > posixPerms = PosixFilePermissions . fromString ( permsPart ( perms ) ) ; Files . setPosixFilePermissions ( path , posixPerms ) ; } else { JavaLogging . getLogger ( PosixHelp . class ) . warning ( "no posix support. setPermission(%s, %s)" , path , perms ) ; } } | Set posix permissions if supported . |
14,007 | public static final void checkFileType ( Path path , String perms ) { if ( perms . length ( ) != 10 ) { throw new IllegalArgumentException ( perms + " not permission. E.g. -rwxr--r--" ) ; } switch ( perms . charAt ( 0 ) ) { case '-' : if ( ! Files . isRegularFile ( path ) ) { throw new IllegalArgumentException ( "file is not regular file" ) ; } break ; case 'd' : if ( ! Files . isDirectory ( path ) ) { throw new IllegalArgumentException ( "file is not directory" ) ; } break ; case 'l' : if ( ! Files . isSymbolicLink ( path ) ) { throw new IllegalArgumentException ( "file is not symbolic link" ) ; } break ; default : throw new UnsupportedOperationException ( perms + " not supported" ) ; } } | Throws IllegalArgumentException if perms length ! = 10 or files type doesn t match with permission . |
14,008 | public static final char getFileTypeLetter ( Path path ) { if ( Files . isRegularFile ( path ) ) { return '-' ; } if ( Files . isDirectory ( path ) ) { return 'd' ; } if ( Files . isSymbolicLink ( path ) ) { return 'l' ; } throw new IllegalArgumentException ( path + " is either regular file, directory or symbolic link" ) ; } | Returns - for regular file d for directory or l for symbolic link . |
14,009 | public static final Path create ( Path path , String perms ) throws IOException { return create ( path , null , perms ) ; } | Creates regular file or directory |
14,010 | public static final Path create ( Path path , Path target , String perms ) throws IOException { FileAttribute < ? > [ ] attrs = getFileAttributes ( perms ) ; switch ( perms . charAt ( 0 ) ) { case '-' : return Files . createFile ( path , attrs ) ; case 'l' : if ( target == null ) { throw new IllegalArgumentException ( "no target" ) ; } return Files . createSymbolicLink ( path , target , attrs ) ; case 'd' : return Files . createDirectories ( path , attrs ) ; default : throw new IllegalArgumentException ( perms + " illegal to this method" ) ; } } | Creates regular file directory or symbolic link |
14,011 | public static final boolean supports ( String view ) { Set < String > supportedFileAttributeViews = FileSystems . getDefault ( ) . supportedFileAttributeViews ( ) ; return supportedFileAttributeViews . contains ( view ) ; } | Return true if default file system supports given view |
14,012 | public static final FileAttribute < UserPrincipal > getOwnerAsAttribute ( String owner ) throws IOException { if ( supports ( "posix" ) ) { UserPrincipalLookupService upls = FileSystems . getDefault ( ) . getUserPrincipalLookupService ( ) ; UserPrincipal user = upls . lookupPrincipalByName ( owner ) ; return new FileAttributeImpl < > ( "posix:owner" , user ) ; } else { return null ; } } | Return file owner as attribute if posix supported . Otherwise returns null . |
14,013 | public static final FileAttribute < GroupPrincipal > getGroupAsAttribute ( String group ) throws IOException { if ( supports ( "posix" ) ) { UserPrincipalLookupService upls = FileSystems . getDefault ( ) . getUserPrincipalLookupService ( ) ; GroupPrincipal grp = upls . lookupPrincipalByGroupName ( group ) ; return new FileAttributeImpl < > ( "posix:group" , grp ) ; } else { return null ; } } | Return file group as attribute if posix supported . Otherwise returns null . |
14,014 | public int request ( String path , HttpServletResponse response , boolean gzip ) throws IOException { Content content ; byte [ ] bytes ; try { content = doRequest ( path ) ; } catch ( IOException e ) { Servlet . LOG . error ( "request failed: " + e . getMessage ( ) , e ) ; response . setStatus ( 500 ) ; response . setContentType ( "text/html" ) ; try ( Writer writer = response . getWriter ( ) ) { writer . write ( "<html><body><h1>" + e . getMessage ( ) + "</h1>" ) ; writer . write ( "<details><br/>" ) ; printException ( e , writer ) ; writer . write ( "</body></html>" ) ; } return - 1 ; } if ( gzip ) { response . setHeader ( "Content-Encoding" , "gzip" ) ; bytes = content . bytes ; } else { bytes = unzip ( content . bytes ) ; } response . addHeader ( "Vary" , "Accept-Encoding" ) ; response . setBufferSize ( 0 ) ; response . setContentType ( content . mimeType ) ; response . setCharacterEncoding ( ENCODING ) ; if ( content . lastModified != - 1 ) { response . setDateHeader ( "Last-Modified" , content . lastModified ) ; } response . getOutputStream ( ) . write ( bytes ) ; return bytes . length ; } | Output is prepared in - memory before the response is written because a ) that s the common case where output is cached . If output is to big for this that whole caching doesn t work b ) I send sent proper error pages c ) I can return the number of bytes actually written |
14,015 | public String request ( String path ) throws IOException { Content content ; content = doRequest ( path ) ; return new String ( unzip ( content . bytes ) , ENCODING ) ; } | Convenience method for testing |
14,016 | private Content doComputeUnlimited ( String path , CountDownLatch gate ) throws IOException { long startContent ; long endContent ; ByteArrayOutputStream result ; References references ; byte [ ] bytes ; String hash ; Content content ; if ( gate . getCount ( ) != 1 ) { throw new IllegalStateException ( path + " " + gate . getCount ( ) ) ; } startContent = System . currentTimeMillis ( ) ; try { try { references = repository . resolve ( Request . parse ( path ) ) ; } catch ( CyclicDependency e ) { throw new RuntimeException ( e . toString ( ) , e ) ; } catch ( IOException e ) { throw new IOException ( path + ": " + e . getMessage ( ) , e ) ; } result = new ByteArrayOutputStream ( ) ; try ( OutputStream dest = new GZIPOutputStream ( result ) ; Writer writer = new OutputStreamWriter ( dest , ENCODING ) ) { references . writeTo ( writer ) ; } bytes = result . toByteArray ( ) ; endContent = System . currentTimeMillis ( ) ; hash = hash ( bytes ) ; content = new Content ( references . type . getMime ( ) , references . getLastModified ( ) , bytes ) ; hashCache . add ( path , hash , endContent , 0 ) ; contentCache . add ( hash , content , startContent , endContent - startContent ) ; } finally { synchronized ( pending ) { if ( gate . getCount ( ) != 1 ) { throw new IllegalStateException ( path + " " + gate . getCount ( ) ) ; } if ( pending . remove ( path ) != gate ) { throw new IllegalStateException ( ) ; } gate . countDown ( ) ; } } return content ; } | exactly one thread will invoke this method for one path |
14,017 | protected void destroyCounter ( ICounter counter ) { try { if ( counter instanceof AbstractCounter ) { ( ( AbstractCounter ) counter ) . destroy ( ) ; } } catch ( Exception e ) { } } | Destroys and removes a counter from the cache . |
14,018 | public void init ( Record record ) { super . init ( record ) ; this . setMasterSlaveFlag ( FileListener . RUN_IN_MASTER | FileListener . DONT_REPLICATE_TO_SLAVE ) ; } | ControlFileHandler - Constructor . |
14,019 | public void setOwner ( ListenerOwner owner ) { super . setOwner ( owner ) ; if ( owner == null ) return ; boolean bEnabledFlag = this . setEnabledListener ( true ) ; try { if ( ! this . getOwner ( ) . isOpen ( ) ) if ( this . isEnabled ( ) ) this . getOwner ( ) . open ( ) ; if ( this . getOwner ( ) . getEditMode ( ) == Constants . EDIT_NONE ) if ( this . isEnabled ( ) ) this . doNewRecord ( true ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { this . setEnabledListener ( bEnabledFlag ) ; } } | Set the field or file that owns this listener . This method calls doNewRecord when the owner is set . |
14,020 | public static ClassInstrumentationCommand create ( String rawMultiLineText ) { List < String > list = rawTextToList ( rawMultiLineText ) ; String classesIncludeRegEx = getStringFromList ( list ) ; ClassInstrumentationCommand cic = new ClassInstrumentationCommand ( ) ; cic . setIncludeClassRegEx ( classesIncludeRegEx ) ; return cic ; } | Designed to take the text straight from the list box . |
14,021 | public < T > T asObject ( String string , Class < T > valueType ) throws ConverterException { try { return ( T ) new URL ( string ) ; } catch ( MalformedURLException e ) { throw new ConverterException ( e . getMessage ( ) ) ; } } | Convert URL string representation into URL instance . |
14,022 | public static ViewFactory getViewFactory ( String strSubPackage , char chPrefix ) { ViewFactory viewFactory = null ; viewFactory = ( ViewFactory ) m_htFactories . get ( strSubPackage ) ; if ( viewFactory == null ) { viewFactory = new ViewFactory ( strSubPackage , chPrefix ) ; m_htFactories . put ( strSubPackage , viewFactory ) ; } return viewFactory ; } | Lookup a standard view factory . |
14,023 | public void addRecord ( Rec record , boolean bMainQuery ) { if ( m_vRecordList == null ) m_vRecordList = new RecordList ( null ) ; if ( record == null ) return ; if ( ( ( Record ) record ) . getRecordOwner ( ) != null ) if ( ( ( Record ) record ) . getRecordOwner ( ) != this ) ( ( Record ) record ) . getRecordOwner ( ) . removeRecord ( record ) ; m_vRecordList . addRecord ( record , bMainQuery ) ; if ( ( ( Record ) record ) . getRecordOwner ( ) == null ) ( ( Record ) record ) . setRecordOwner ( this ) ; } | Add this record to this screen . |
14,024 | public boolean removeRecord ( Rec record ) { if ( m_vRecordList == null ) return false ; boolean bFlag = m_vRecordList . removeRecord ( record ) ; if ( ( ( Record ) record ) . getRecordOwner ( ) == this ) ( ( Record ) record ) . setRecordOwner ( null ) ; return bFlag ; } | Remove this record from this screen . |
14,025 | public void addListenerMessageFilter ( BaseMessageFilter messageFilter ) { if ( m_messageFilterList == null ) m_messageFilterList = new MessageListenerFilterList ( this ) ; m_messageFilterList . addMessageFilter ( messageFilter ) ; } | Add this message filter to my list . |
14,026 | public Environment getEnvironment ( ) { if ( this . getTask ( ) != null ) if ( this . getTask ( ) . getApplication ( ) instanceof BaseApplication ) return ( ( BaseApplication ) this . getTask ( ) . getApplication ( ) ) . getEnvironment ( ) ; return null ; } | Get the environment . From the database owner interface . |
14,027 | public void printHtmlItems ( PrintWriter out , String strTag , String strParams , String strData ) { int iTableColumns = 1 ; String strColumns = this . getProperty ( DBParams . COLUMNS , strParams ) ; if ( ( strColumns != null ) && ( strColumns . length ( ) > 0 ) ) iTableColumns = Integer . parseInt ( strColumns ) ; String strCellFormat = strData ; if ( ( strCellFormat == null ) || ( strCellFormat . length ( ) == 0 ) ) strCellFormat = "<td><a href=\"<link/>\"><img src=\"" + "<icon/>\" width=\"24\" height=\"24\" alt=\"Run this program\"></a></td>" + "<td><a href=\"<link/>&help=\"><img src=\"" + HtmlConstants . HELP_ICON + "\" width=\"24\" height=\"24\"></a></td><td><a href=\"<link/>&help=\">" + HtmlConstants . TITLE_TAG + "</a></td><td>" + HtmlConstants . MENU_DESC_TAG + "</td>" ; this . preSetupGrid ( null ) ; boolean bFirstRow = true ; try { int iRowCount = 0 ; m_recDetail . close ( ) ; out . println ( "<table border=\"0\" cellspacing=\"10\" width=\"100%\">" ) ; while ( m_recDetail . hasNext ( ) ) { m_recDetail . next ( ) ; if ( iRowCount == 0 ) out . println ( "<tr>" ) ; String strHTML = strCellFormat ; int iIndex ; if ( bFirstRow ) { iIndex = strHTML . indexOf ( "<HR" ) ; if ( iIndex == - 1 ) iIndex = strHTML . indexOf ( "<hr" ) ; if ( iIndex != - 1 ) if ( ( iIndex < strHTML . indexOf ( "<A" ) ) || ( iIndex < strHTML . indexOf ( "<a" ) ) ) { strHTML = strHTML . substring ( 0 , iIndex ) + strHTML . substring ( strHTML . indexOf ( '>' , iIndex ) + 1 ) ; } } this . parseHtmlData ( out , strHTML ) ; iRowCount ++ ; if ( ( iRowCount == iTableColumns ) || ( ! m_recDetail . hasNext ( ) ) ) { iRowCount = 0 ; bFirstRow = false ; out . println ( "</tr>" ) ; } } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } if ( bFirstRow ) { out . println ( "<tr><td>Empty Menu</td></tr>" ) ; } out . println ( "</table>" ) ; this . postSetupGrid ( ) ; } | Detail items . |
14,028 | public static < T > T getInstance ( String className , Class < T > ofType ) throws IllegalStateException { return getInstance ( className , ofType , new Class < ? > [ ] { } , new Object [ ] { } ) ; } | Creates and returns a new instance of class with name className loading the class and using the default constructor . |
14,029 | public void addFocusListener ( FocusListener l ) { super . addFocusListener ( l ) ; if ( l instanceof JBasePanel ) { m_tf . addFocusListener ( l ) ; if ( m_button != null ) m_button . addFocusListener ( l ) ; if ( m_buttonTime != null ) m_buttonTime . addFocusListener ( l ) ; } } | When a focus listener is added to this actually add it to the components . |
14,030 | public static Formatter getFormatter ( ) { Formatter formatter = out . get ( ) ; if ( formatter == null ) { formatter = new Formatter ( new StringBuilder ( ) ) ; out . set ( formatter ) ; } else { StringBuilder sb = ( StringBuilder ) formatter . out ( ) ; sb . setLength ( 0 ) ; } return formatter ; } | Returns thread - local formatter . Inner Appendable is StringBuider which s length is set to 0 . |
14,031 | ByteBuffer readView ( int position ) { ByteBuffer bb = content . duplicate ( ) . asReadOnlyBuffer ( ) ; bb . position ( position ) ; return bb ; } | Returns read - only view of content . Position = 0 limit = size ; |
14,032 | ByteBuffer writeView ( int position , int needs ) throws IOException { int waterMark = position + needs ; if ( waterMark > content . capacity ( ) ) { if ( refSet . containsKey ( content ) ) { throw new IOException ( "cannot grow file because of writable mapping for content. (non carbage collected mapping?)" ) ; } int blockSize = fileStore . getBlockSize ( ) ; int newCapacity = Math . max ( ( ( waterMark / blockSize ) + 1 ) * blockSize , 2 * content . capacity ( ) ) ; ByteBuffer newBB = ByteBuffer . allocateDirect ( newCapacity ) ; newBB . put ( content ) ; newBB . flip ( ) ; content = newBB ; } ByteBuffer bb = content . duplicate ( ) ; refSet . add ( content , bb ) ; bb . limit ( waterMark ) . position ( position ) ; return bb ; } | Returns view of content . |
14,033 | void commit ( ByteBuffer bb ) { content . limit ( Math . max ( content . limit ( ) , bb . position ( ) ) ) ; boolean removed = refSet . removeItem ( content , bb ) ; assert removed ; } | called after writing to commit that writing succeeded up to position . If position > size the size is updated . |
14,034 | private SQLQuery query ( Class < ? > ... entity ) { SQLQuery q = session . createSQLQuery ( sql ) ; if ( entity . length == 1 ) { q . addEntity ( entity [ 0 ] ) ; } for ( Map . Entry < String , Type > scalar : scalars . entrySet ( ) ) { q . addScalar ( scalar . getKey ( ) , scalar . getValue ( ) ) ; } for ( int i = 0 ; i < positionedParameters . length ; i ++ ) { q . setParameter ( i , positionedParameters [ i ] ) ; } for ( Map . Entry < String , Object > entry : namedParameters . entrySet ( ) ) { Object value = entry . getValue ( ) ; if ( Types . isArray ( value ) ) { Object [ ] parameter = ( Object [ ] ) value ; if ( parameter . length == 0 ) { throw new HibernateException ( String . format ( "Invalid named parameter |%s|. Empty array." , entry . getKey ( ) ) ) ; } q . setParameterList ( entry . getKey ( ) , parameter ) ; } else if ( Types . isCollection ( value ) ) { Collection < ? > parameter = ( Collection < ? > ) value ; if ( parameter . isEmpty ( ) ) { throw new HibernateException ( String . format ( "Invalid named parameter |%s|. Empty list." , entry . getKey ( ) ) ) ; } q . setParameterList ( entry . getKey ( ) , parameter ) ; } else { q . setParameter ( entry . getKey ( ) , value ) ; } } if ( offset > 0 ) { q . setFirstResult ( offset ) ; } if ( rowsCount > 0 ) { q . setMaxResults ( rowsCount ) ; } return q ; } | Create SQL query object and initialize it from this helper properties . |
14,035 | public static String likePrefix ( String param ) { return param != null ? param . toLowerCase ( ) . replace ( "_" , "\\_" ) . replace ( "%" , "\\%" ) + "%" : null ; } | Builds prefix search parameter for LIKE operator from non - formatted string . Basically this method insert escape character before special symbols and adds % at the end . |
14,036 | public void run ( ) { if ( ( m_url == null ) && ( m_strHtmlText == null ) ) { if ( m_bChangeCursor ) { if ( m_applet != null ) m_applet . setStatus ( 0 , m_editorPane , m_oldCursor ) ; else { Component component = m_editorPane ; while ( component . getParent ( ) != null ) { component = component . getParent ( ) ; } component . setCursor ( ( Cursor ) m_oldCursor ) ; } Container parent = m_editorPane . getParent ( ) ; parent . repaint ( ) ; } } else { if ( m_bChangeCursor ) { if ( m_applet != null ) m_oldCursor = m_applet . setStatus ( Cursor . WAIT_CURSOR , m_editorPane , null ) ; else { Component component = m_editorPane ; boolean bIsVisible = true ; while ( component . getParent ( ) != null ) { component = component . getParent ( ) ; if ( ! component . isVisible ( ) ) bIsVisible = false ; } m_oldCursor = component . getCursor ( ) ; Cursor cursor = Cursor . getPredefinedCursor ( Cursor . WAIT_CURSOR ) ; if ( bIsVisible ) component . setCursor ( cursor ) ; } } synchronized ( m_editorPane ) { Document doc = m_editorPane . getDocument ( ) ; try { if ( m_url != null ) { m_editorPane . setPage ( m_url ) ; } else { this . setText ( doc , m_strHtmlText ) ; } } catch ( IOException ioe ) { String error = ioe . getLocalizedMessage ( ) ; if ( ( error != null ) && ( error . length ( ) > 0 ) ) { String errorText = m_strHtmlErrorText ; if ( errorText == null ) errorText = DEFAULT_ERROR_TEXT ; errorText = MessageFormat . format ( errorText , m_url . toString ( ) , error ) ; this . setText ( doc , errorText ) ; } else m_editorPane . setDocument ( doc ) ; } finally { m_url = null ; m_strHtmlText = null ; if ( m_bChangeCursor ) SwingUtilities . invokeLater ( this ) ; } } } } | Display the target html in the pane . |
14,037 | public void setText ( Document doc , String text ) { StringReader reader = new StringReader ( text ) ; HTMLEditorKit kit = ( HTMLEditorKit ) m_editorPane . getEditorKitForContentType ( HTML_CONTENT ) ; try { int iLength = doc . getLength ( ) ; if ( iLength > 0 ) doc . remove ( 0 , iLength ) ; kit . read ( reader , doc , 0 ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } catch ( BadLocationException ex ) { ex . printStackTrace ( ) ; } } | Set the control to this html text . |
14,038 | public static ImmutableVector2 createVector ( final double x , final double y ) { return new ImmutableVector2 ( new ImmutableData ( 2 , 1 ) { public double getQuick ( int row , int col ) { if ( row == 0 ) return x ; else return y ; } } ) ; } | Creates a new immutable 2D column vector . |
14,039 | public static ImmutableVector3 createVector ( final double x , final double y , final double z ) { return new ImmutableVector3 ( new ImmutableData ( 3 , 1 ) { public double getQuick ( int row , int col ) { switch ( row ) { case 0 : return x ; case 1 : return y ; default : return z ; } } } ) ; } | Creates a new immutable 3D column vector . |
14,040 | public static ImmutableVector4 createVector ( final double x , final double y , final double z , final double h ) { return new ImmutableVector4 ( new ImmutableData ( 4 , 1 ) { public double getQuick ( int row , int col ) { switch ( row ) { case 0 : return x ; case 1 : return y ; case 2 : return z ; default : return h ; } } } ) ; } | Creates a new immutable 4D column vector . |
14,041 | public static ImmutableMatrix zeros ( final int rows , final int cols ) { if ( rows <= 0 || cols <= 0 ) throw new IllegalArgumentException ( "Invalid dimensions" ) ; return create ( new ImmutableData ( rows , cols ) { public double getQuick ( int row , int col ) { return 0 ; } } ) ; } | Returns an immutable matrix of the specified size whose elements are all 0 . |
14,042 | public static ImmutableMatrix identity ( final int size ) { if ( size <= 0 ) throw new IllegalArgumentException ( "Invalid size" ) ; return create ( new ImmutableData ( size , size ) { public double getQuick ( int row , int col ) { return row == col ? 1 : 0 ; } } ) ; } | Returns an immutable identity matrix of the specified dimension . |
14,043 | public int handlePutRawRecordData ( Rec record ) { int iErrorCode = Constant . NORMAL_RETURN ; int iRecordCount = this . getRecordCount ( record ) ; Rec recTargetRecord = this . setDataIndex ( RESET_INDEX , record ) ; for ( int index = 1 ; index <= iRecordCount ; index ++ ) { Rec recNext = this . setDataIndex ( index , recTargetRecord ) ; if ( recNext == null ) break ; iErrorCode = super . handlePutRawRecordData ( recNext ) ; if ( iErrorCode != Constant . NORMAL_RETURN ) break ; } this . setDataIndex ( END_OF_NODES , recTargetRecord ) ; return iErrorCode ; } | Move the correct fields from ALL the detail records to the map . Typically you override this and loop through the records in the table . If this method is used is must be overidden to move the correct fields . |
14,044 | public Rec updateRecord ( Rec record , boolean bRefresh ) { try { Object bookmark = null ; if ( record . getEditMode ( ) == Constant . EDIT_IN_PROGRESS ) { if ( bRefresh ) bookmark = record . getTable ( ) . getHandle ( 0 ) ; record . getTable ( ) . set ( record ) ; } else if ( ( record . getEditMode ( ) == Constant . EDIT_ADD ) && ( record . isModified ( ) ) ) { record . getTable ( ) . add ( record ) ; if ( bRefresh ) bookmark = record . getTable ( ) . getLastModified ( 0 ) ; } if ( bRefresh ) if ( bookmark != null ) { record . getTable ( ) . setHandle ( bookmark , 0 ) ; record . getTable ( ) . edit ( ) ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; if ( record != null ) if ( record . getTask ( ) != null ) record . getTask ( ) . setLastError ( ex . getMessage ( ) ) ; return null ; } return record ; } | Update this record if it has been changed |
14,045 | public boolean freeSubNodeRecord ( Rec record ) { m_recTargetFieldList = null ; if ( record != null ) { record . free ( ) ; return true ; } return false ; } | Create the sub - detail record . |
14,046 | public int getBitsToCheck ( ) { if ( m_iBitsToCheck == 0 ) { Record record = this . makeReferenceRecord ( ) ; try { record . close ( ) ; while ( record . hasNext ( ) ) { record . next ( ) ; int sBitPosition = ( int ) record . getCounterField ( ) . getValue ( ) ; m_iBitsToCheck |= 1 << sBitPosition ; } } catch ( DBException e ) { e . printStackTrace ( ) ; } } return m_iBitsToCheck ; } | Mask of valid bits . |
14,047 | public void basicValidate ( final String section ) throws ConfigException { super . basicValidate ( CONFIG_SECTION ) ; if ( address == null && ( sentinels == null || sentinels . isEmpty ( ) ) ) { throw new ConfigException ( CONFIG_SECTION , "Redis configuration requires either an address or at least one sentinel to connect to" ) ; } if ( sentinels != null && ! sentinels . isEmpty ( ) ) { if ( StringUtils . isBlank ( masterName ) ) { throw new ConfigException ( CONFIG_SECTION , "Redis configuration requires a masterName when connecting to sentinel" ) ; } for ( final HostAndPort sentinel : sentinels ) { sentinel . basicValidate ( CONFIG_SECTION ) ; } } } | Validates the configuration |
14,048 | public EightyPath to ( ) { EightyPath inital = start ; final RealIt it = new RealIt ( start ) ; if ( ! Repeater . repeat ( ) . upto ( 1000 ) . until ( ( ) -> { it . set ( minusOne ( it ) ) ; return ! it . foundSymLink ; } ) ) { throw new IllegalStateException ( "sym link loop detected in path " + start ) ; } EightyPath ret = it . path ; if ( inital . equals ( ret ) ) { inital . setTestedReal ( ) ; return inital ; } ret . setTestedReal ( ) ; return ret ; } | build an absolute normalized and symbolic link free path of the same file or dir |
14,049 | public void free ( ) { if ( ( m_mapChildHolders != null ) && ( m_mapChildHolders . size ( ) > 0 ) ) { Utility . getLogger ( ) . info ( "Not all sub-sessions freed by client - I will free them" ) ; synchronized ( this ) { Object [ ] keys = m_mapChildHolders . keySet ( ) . toArray ( ) ; for ( Object strID : keys ) { BaseHolder baseHolder = ( BaseHolder ) m_mapChildHolders . get ( strID ) ; baseHolder . free ( ) ; } m_mapChildHolders . clear ( ) ; } } m_mapChildHolders = null ; if ( m_parentHolder != null ) m_parentHolder . remove ( this ) ; m_parentHolder = null ; m_remoteObject = null ; } | Free the resources for this holder . |
14,050 | public String getProperty ( String strKey , Map < String , Object > properties ) { String strProperty = null ; if ( properties != null ) if ( properties . get ( strKey ) != null ) strProperty = properties . get ( strKey ) . toString ( ) ; if ( strProperty == null ) if ( m_remoteObject instanceof PropertyOwner ) strProperty = ( ( PropertyOwner ) m_remoteObject ) . getProperty ( strKey ) ; if ( strProperty == null ) { if ( m_parentHolder != null ) strProperty = m_parentHolder . getProperty ( strKey , properties ) ; if ( NULL . equals ( strProperty ) ) strProperty = null ; } return strProperty ; } | Get the servlet s property . |
14,051 | public String find ( BaseHolder baseHolder ) { if ( m_mapChildHolders == null ) return null ; return m_mapChildHolders . find ( baseHolder ) ; } | Find the key for this BaseHolder |
14,052 | public String add ( BaseHolder baseHolder ) { if ( m_mapChildHolders == null ) m_mapChildHolders = new MapList ( ) ; synchronized ( this ) { return m_mapChildHolders . add ( baseHolder ) ; } } | Add this remote object holder to this parent . |
14,053 | public int fieldChanged ( boolean bDisplayOption , int iMoveMode ) { String string = this . getOwner ( ) . toString ( ) ; if ( Utility . isNumeric ( string ) ) { Task task = null ; if ( this . getOwner ( ) != null ) if ( this . getOwner ( ) . getRecord ( ) != null ) if ( this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) != null ) task = this . getOwner ( ) . getRecord ( ) . getRecordOwner ( ) . getTask ( ) ; if ( task == null ) task = BaseApplet . getSharedInstance ( ) ; return task . setLastError ( "Must be non-numeric" ) ; } return super . fieldChanged ( bDisplayOption , iMoveMode ) ; } | Field must be non - numeric . |
14,054 | protected static FileList transformFileList ( final CSNodeWrapper node ) { final List < File > files = new LinkedList < File > ( ) ; if ( node . getChildren ( ) != null && node . getChildren ( ) . getItems ( ) != null ) { final List < CSNodeWrapper > childNodes = node . getChildren ( ) . getItems ( ) ; final HashMap < CSNodeWrapper , File > fileNodes = new HashMap < CSNodeWrapper , File > ( ) ; for ( final CSNodeWrapper childNode : childNodes ) { fileNodes . put ( childNode , transformFile ( childNode ) ) ; } final LinkedHashMap < CSNodeWrapper , File > sortedMap = CSNodeSorter . sortMap ( fileNodes ) ; final Iterator < Map . Entry < CSNodeWrapper , File > > iter = sortedMap . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { final Map . Entry < CSNodeWrapper , File > entry = iter . next ( ) ; files . add ( entry . getValue ( ) ) ; } } return new FileList ( CommonConstants . CS_FILE_TITLE , files ) ; } | Transforms a MetaData CSNode into a FileList that can be added to a ContentSpec object . |
14,055 | protected static InfoTopic transformInfoTopic ( final CSNodeWrapper parentNode , final CSInfoNodeWrapper node ) { final InfoTopic infoTopic = new InfoTopic ( node . getTopicId ( ) , null ) ; infoTopic . setRevision ( node . getTopicRevision ( ) ) ; infoTopic . setConditionStatement ( node . getCondition ( ) ) ; infoTopic . setUniqueId ( parentNode . getId ( ) == null ? null : parentNode . getId ( ) . toString ( ) ) ; return infoTopic ; } | Transform a Topic CSNode entity object into an InfoTopic Object that can be added to a Content Specification . |
14,056 | protected static Comment transformComment ( CSNodeWrapper node ) { final Comment comment ; if ( node . getNodeType ( ) == CommonConstants . CS_NODE_COMMENT ) { comment = new Comment ( node . getTitle ( ) ) ; } else { throw new IllegalArgumentException ( "The passed node is not a Comment" ) ; } comment . setUniqueId ( node . getId ( ) == null ? null : node . getId ( ) . toString ( ) ) ; return comment ; } | Transform a Comment CSNode entity into a Comment object that can be added to a Content Specification . |
14,057 | protected static CommonContent transformCommonContent ( CSNodeWrapper node ) { final CommonContent commonContent ; if ( node . getNodeType ( ) == CommonConstants . CS_NODE_COMMON_CONTENT ) { commonContent = new CommonContent ( node . getTitle ( ) ) ; } else { throw new IllegalArgumentException ( "The passed node is not a Comment" ) ; } commonContent . setUniqueId ( node . getId ( ) == null ? null : node . getId ( ) . toString ( ) ) ; return commonContent ; } | Transform a Common Content CSNode entity into a Comment object that can be added to a Content Specification . |
14,058 | public EntityMakerBuilder reuseEntities ( Collection < Object > entities ) { for ( Object entity : entities ) { Class aClass = entity . getClass ( ) ; valueHolder . putIfNotNull ( aClass , entity ) ; } return this ; } | Reuse a collection of objects when making new entities . |
14,059 | public EntityMakerBuilder reuseEntity ( Serializable entity ) { Class aClass = entity . getClass ( ) ; valueHolder . putIfNotNull ( aClass , entity ) ; return this ; } | Reuse single entity . |
14,060 | public EntityMakerBuilder reuseEntities ( Object first , Object second , Object ... rest ) { List < Object > objects = ImmutableList . builder ( ) . add ( first ) . add ( second ) . add ( rest ) . build ( ) ; return reuseEntities ( objects ) ; } | Reuse entities . |
14,061 | private static boolean isValidStandardOperator ( final Element e ) { if ( e . getKind ( ) == ElementKind . FIELD ) { return e . getModifiers ( ) . containsAll ( EnumSet . of ( Modifier . PUBLIC , Modifier . STATIC , Modifier . FINAL ) ) ; } if ( e . getKind ( ) == ElementKind . METHOD ) { return e . getModifiers ( ) . containsAll ( EnumSet . of ( Modifier . PUBLIC , Modifier . STATIC ) ) && ( ( ExecutableElement ) e ) . getParameters ( ) . isEmpty ( ) ; } if ( e . getKind ( ) == ElementKind . CLASS ) { if ( e . getModifiers ( ) . contains ( Modifier . ABSTRACT ) || findDefaultConstructor ( ( TypeElement ) e ) == null ) { return false ; } Element current = e ; while ( current . getKind ( ) == ElementKind . CLASS ) { final TypeElement t = ( TypeElement ) current ; if ( t . getNestingKind ( ) == NestingKind . TOP_LEVEL ) { return true ; } if ( t . getNestingKind ( ) == NestingKind . MEMBER && t . getModifiers ( ) . contains ( Modifier . STATIC ) ) { current = t . getEnclosingElement ( ) ; continue ; } break ; } } return false ; } | Must be a public static concrete class with a default constructor public static zero - arg method or public static final field . |
14,062 | public static String cleanParam ( String [ ] strParams , boolean bSetDefault , String strDefault ) { if ( ( strParams == null ) || ( strParams . length == 0 ) ) strParams = new String [ 1 ] ; if ( strParams [ 0 ] == null ) if ( bSetDefault ) strParams [ 0 ] = strDefault ; if ( strParams [ 0 ] == null ) return null ; try { return URLDecoder . decode ( strParams [ 0 ] , DBConstants . URL_ENCODING ) ; } catch ( java . io . UnsupportedEncodingException ex ) { return strParams [ 0 ] ; } } | Clean - up the param string |
14,063 | public static String getParam ( HttpServletRequest req , String strParam ) { return BaseHttpTask . getParam ( req , strParam , Constants . BLANK ) ; } | Get the first occurence of this parameter . |
14,064 | public static String getParam ( HttpServletRequest req , String strParam , String strDefault ) { String strParams [ ] = null ; if ( req == null ) return null ; strParams = req . getParameterValues ( strParam ) ; if ( DBParams . URL . equals ( strParam ) ) { strParams = new String [ 1 ] ; strParams [ 0 ] = req . getRequestURL ( ) . toString ( ) ; } if ( DBParams . CODEBASE . equals ( strParam ) ) { strParams = new String [ 1 ] ; strParams [ 0 ] = req . getRequestURL ( ) . toString ( ) ; if ( strParams [ 0 ] . endsWith ( Constants . DEFAULT_SERVLET ) ) strParams [ 0 ] = strParams [ 0 ] . substring ( 0 , strParams [ 0 ] . length ( ) - Constants . DEFAULT_SERVLET . length ( ) ) ; if ( ! strParams [ 0 ] . endsWith ( "/" ) ) strParams [ 0 ] = strParams [ 0 ] + "/" ; } if ( DBParams . DOMAIN . equals ( strParam ) ) { strParams = new String [ 1 ] ; strParams [ 0 ] = req . getRequestURL ( ) . toString ( ) ; return Utility . getDomainFromURL ( strParams [ 0 ] , null ) ; } if ( strParams == null ) if ( DBParams . DATATYPE . equals ( strParam ) ) { strParams = new String [ 1 ] ; strParams [ 0 ] = req . getRequestURL ( ) . toString ( ) ; if ( ( strParams [ 0 ] != null ) && ( strParams [ 0 ] . lastIndexOf ( '/' ) != - 1 ) ) { strParams [ 0 ] = strParams [ 0 ] . substring ( strParams [ 0 ] . lastIndexOf ( '/' ) + 1 ) ; if ( strParams [ 0 ] . indexOf ( '.' ) != - 1 ) strParams [ 0 ] = strParams [ 0 ] . substring ( 0 , strParams [ 0 ] . indexOf ( '.' ) ) ; if ( ( ! DBParams . TABLE_PARAM . equalsIgnoreCase ( strParams [ 0 ] ) ) && ( ! DBParams . WEBSTART_PARAM . equalsIgnoreCase ( strParams [ 0 ] ) ) && ( ! DBParams . WEBSTART_APPLET_PARAM . equalsIgnoreCase ( strParams [ 0 ] ) ) && ( ! DBParams . WSDL_PARAM . equalsIgnoreCase ( strParams [ 0 ] ) ) && ( ! DBParams . IMAGE_PATH . equalsIgnoreCase ( strParams [ 0 ] ) ) ) strParams = null ; } else strParams = null ; } if ( strParams == null ) return strDefault ; if ( strParams . length == 0 ) return Constants . BLANK ; if ( strParams [ 0 ] == null ) return Constants . BLANK ; return strParams [ 0 ] ; } | Get the first occurrence of this parameter . |
14,065 | public String getLastError ( int iErrorCode ) { if ( ( m_strLastError == null ) || ( ( iErrorCode != 0 ) && ( iErrorCode != m_iLastErrorCode ) ) ) return Constants . BLANK ; String string = m_strLastError ; m_strLastError = null ; return string ; } | Get the last error code . This call clears the last error code . |
14,066 | public String getStatusText ( int iWarningLevel ) { String strStatus = m_strCurrentStatus ; if ( m_iCurrentWarningLevel < iWarningLevel ) strStatus = null ; return strStatus ; } | Get the last status message if it is at this level or above . Typically you do this to see if the current message you want to display can be displayed on top of the message that is there already . Calling this method will clear the last status text . |
14,067 | public String getRealPath ( HttpServletRequest request , String path ) { if ( m_servlet != null ) return m_servlet . getRealPath ( request , path ) ; return path ; } | Get the physical path for this internet path . |
14,068 | public String getString ( String strKey ) { if ( this . getApplication ( ) != null ) return this . getApplication ( ) . getString ( strKey ) ; return strKey ; } | Convert this key to a localized string . In thin this just calls the getString method in application in thick a local resource can be saved . |
14,069 | private void add ( ClassFilter filter ) { switch ( operator ) { case NOT : filters . add ( new NegationClassFilter ( filter ) ) ; operator = Operator . NONE ; break ; case OR : filters . set ( filters . size ( ) - 1 , new OrClassFilter ( filters . get ( filters . size ( ) - 1 ) , filter ) ) ; operator = Operator . NONE ; break ; default : filters . add ( filter ) ; break ; } } | Adds a new filter and applies current operator . |
14,070 | public ClassFilterBuilder isDefault ( ) { add ( new NegationClassFilter ( new ModifierClassFilter ( Modifier . PUBLIC & Modifier . PROTECTED & Modifier . PRIVATE ) ) ) ; return this ; } | Adds filter for default access classes . |
14,071 | public ClassFilter build ( ) throws IllegalStateException { if ( filters . isEmpty ( ) ) { throw new IllegalStateException ( "No filters set." ) ; } if ( filters . size ( ) == 1 ) { return filters . get ( 0 ) ; } ClassFilter [ ] classFilters = new ClassFilter [ filters . size ( ) ] ; filters . toArray ( classFilters ) ; return new ClassFilterList ( classFilters ) ; } | Builds the filter and returns the result . |
14,072 | public ChatMember [ ] getChatAdministrators ( ChatId chat_id ) throws IOException { AnalyticsData data = new AnalyticsData ( "getChatAdministrators" ) ; IOException ioException = null ; ChatMember [ ] admins = null ; data . setValue ( "chat_id" , chat_id ) ; try { admins = bot . getChatAdministrators ( chat_id ) ; data . setReturned ( admins ) ; } catch ( IOException e ) { ioException = e ; data . setIoException ( ioException ) ; } analyticsWorker . putData ( data ) ; if ( ioException != null ) { throw ioException ; } return admins ; } | Use this method to get a list of administrators in a chat . |
14,073 | public int getChatMembersCount ( ChatId chat_id ) throws IOException { AnalyticsData data = new AnalyticsData ( "getChatMembersCount" ) ; IOException ioException = null ; int membersCount = 0 ; data . setValue ( "chat_id" , chat_id ) ; try { membersCount = bot . getChatMembersCount ( chat_id ) ; data . setReturned ( membersCount ) ; } catch ( IOException e ) { ioException = e ; data . setIoException ( ioException ) ; } analyticsWorker . putData ( data ) ; if ( ioException != null ) { throw ioException ; } return membersCount ; } | Use this method to get the number of members in a chat . |
14,074 | public ChatMember getChatMember ( ChatId chat_id , long user_id ) throws IOException { AnalyticsData data = new AnalyticsData ( "getChatMember" ) ; IOException ioException = null ; ChatMember chatMember = null ; data . setValue ( "chat_id" , chat_id ) ; data . setValue ( "user_id" , user_id ) ; try { chatMember = bot . getChatMember ( chat_id , user_id ) ; data . setReturned ( chatMember ) ; } catch ( IOException e ) { ioException = e ; data . setIoException ( ioException ) ; } analyticsWorker . putData ( data ) ; if ( ioException != null ) { throw ioException ; } return chatMember ; } | Use this method to get information about a member of a chat . |
14,075 | public void compress ( Stream < Path > paths ) throws IOException { boolean first = true ; Iterator < Path > it = paths . iterator ( ) ; while ( it . hasNext ( ) ) { Path p = it . next ( ) ; if ( Files . isRegularFile ( path ) ) { setFilename ( p . getFileName ( ) . toString ( ) ) ; setLastModified ( Files . getLastModifiedTime ( p ) ) ; if ( ! first ) { nextOutput ( ) ; } first = false ; OutputStream os = Channels . newOutputStream ( this ) ; Files . copy ( p , os ) ; } else { throw new IOException ( p + " is not a regular file" ) ; } } close ( ) ; } | Add file entries to this GZIPChannel . Channel will be closed after this call . |
14,076 | public void extractAll ( Path targetDir , CopyOption ... options ) throws IOException { if ( ! Files . isDirectory ( targetDir ) ) { throw new NotDirectoryException ( targetDir . toString ( ) ) ; } ensureReading ( ) ; do { Path p = targetDir . resolve ( filename ) ; InputStream is = Channels . newInputStream ( this ) ; Files . copy ( is , p , options ) ; Files . setLastModifiedTime ( p , lastModified ) ; } while ( nextInput ( ) ) ; } | Extract files from this GZIPChannel to given directory . |
14,077 | public long position ( ) throws IOException { if ( inflater == null && deflater == null ) { return 0 ; } if ( inflater != null ) { return inflater . getBytesWritten ( ) ; } else { return deflater . getBytesRead ( ) ; } } | return uncompressed position |
14,078 | public GZIPChannel position ( long newPosition ) throws IOException { int skip = ( int ) ( newPosition - position ( ) ) ; if ( skip < 0 ) { throw new UnsupportedOperationException ( "backwards position not supported" ) ; } if ( skip > skipBuffer . capacity ( ) ) { throw new UnsupportedOperationException ( skip + " skip not supported maxSkipSize=" + maxSkipSize ) ; } if ( skip > 0 ) { if ( skipBuffer == null ) { throw new UnsupportedOperationException ( "skip not supported maxSkipSize=" + maxSkipSize ) ; } skipBuffer . clear ( ) ; skipBuffer . limit ( skip ) ; if ( options . contains ( READ ) ) { read ( skipBuffer ) ; } else { write ( skipBuffer ) ; } } return this ; } | Changes uncompressed position . Only forward direction is allowed with small skips . This method is for alignment purposes mostly . |
14,079 | public void close ( ) throws IOException { if ( ! isClosed ) { flush ( ) ; if ( closeChannel ) { channel . close ( ) ; } isClosed = true ; } } | Closes channel . Underlying channel is closed only if it was opened by one of the constructors . |
14,080 | public boolean nextInput ( ) throws IOException { if ( ! options . contains ( READ ) && ! inflater . finished ( ) ) { throw new IllegalStateException ( "should be called after read returns -1" ) ; } if ( ! compBuf . hasRemaining ( ) ) { compBuf . clear ( ) ; int rc = channel . read ( compBuf ) ; if ( rc == - 1 ) { return false ; } compBuf . flip ( ) ; } readHeader ( ) ; inflater . reset ( ) ; crc32 . reset ( ) ; return true ; } | After read returns - 1 call nextInput to advance to nextInput file . |
14,081 | public static ActivityStreamMessage from ( final Event event ) { final ActivityStreamMessage msg = new ActivityStreamMessage ( ) ; msg . id = event . getIdentifier ( ) . getIRIString ( ) ; msg . type = event . getTypes ( ) . stream ( ) . map ( IRI :: getIRIString ) . map ( type -> type . startsWith ( AS . URI ) ? type . substring ( AS . URI . length ( ) ) : type ) . collect ( toList ( ) ) ; msg . published = event . getCreated ( ) . toString ( ) ; final List < String > actors = event . getAgents ( ) . stream ( ) . map ( IRI :: getIRIString ) . collect ( toList ( ) ) ; msg . actor = actors . isEmpty ( ) ? null : actors ; event . getInbox ( ) . map ( IRI :: getIRIString ) . ifPresent ( inbox -> msg . inbox = inbox ) ; event . getTarget ( ) . map ( IRI :: getIRIString ) . ifPresent ( target -> msg . object = new EventResource ( target , event . getTargetTypes ( ) . stream ( ) . map ( IRI :: getIRIString ) . collect ( toList ( ) ) ) ) ; return msg ; } | Populate a ActivityStreamMessage from an Event |
14,082 | E get ( E key ) { int idx = indexOf ( key ) ; if ( idx >= 0 ) { return list . get ( idx ) ; } return null ; } | Returns item if it is found in binary - search |
14,083 | public GetHeadendsResult convert ( Map < String , Headend > value ) { GetHeadendsResult r = new GetHeadendsResult ( ) ; r . setHeadends ( value ) ; return r ; } | Main conversion method . |
14,084 | private Configuration buildVersionConfig ( ) { String jersey2ToolkitVersion = Jersey2ToolkitConfig . class . getPackage ( ) . getImplementationVersion ( ) ; HashMap < String , Object > versionConfigMap = new HashMap < > ( ) ; versionConfigMap . put ( "jersey2-toolkit.version" , jersey2ToolkitVersion ) ; return new MapConfiguration ( versionConfigMap ) ; } | Creates a configuration object that contains the current version of the jersey2 - toolkit library in use . |
14,085 | private Configuration buildToolkitConfig ( ) { try { File configFile = ResourceUtil . getFileForResource ( "jersey2-toolkit.properties" ) ; return new PropertiesConfiguration ( configFile ) ; } catch ( ConfigurationException ce ) { logger . error ( "jersey2-toolkit.properties not readable," + " some features may be misconfigured." ) ; return new MapConfiguration ( new HashMap < String , String > ( ) ) ; } } | Builds the configuration object for our toolkit config . |
14,086 | private void reportGauge ( String name , Gauge gauge ) { String prefixedName = prefix ( name ) ; Object value = gauge . getValue ( ) ; if ( value instanceof Number ) { if ( ! snapshots . hasDescriptor ( prefixedName ) ) { snapshots . setDescriptor ( prefixedName , MetricItem . Builder . create ( ) . count ( "gauge" ) . build ( ) ) ; } long timestamp = getTimestamp ( ) ; snapshots . addSnapshot ( prefixedName , timestamp , ( Map ) map ( "gauge" , value ) ) ; } } | Report a gauge using the field gauge . Only numeric values are used . |
14,087 | public static String partsToName ( Record record , String iNamePrefix , String iNameFirst , String iNameMiddle , String iNameSur , String iNameSuffix , String iNameTitle ) { String string = null ; String strFinal = Constants . BLANK ; if ( iNamePrefix != null ) { string = record . getField ( iNamePrefix ) . getString ( ) ; if ( string . length ( ) != 0 ) strFinal += string + ". " ; } string = record . getField ( iNameFirst ) . getString ( ) ; if ( string . length ( ) != 0 ) strFinal += string + " " ; if ( iNameMiddle != null ) { string = record . getField ( iNameMiddle ) . getString ( ) ; if ( string . length ( ) != 0 ) strFinal += string + " " ; } string = record . getField ( iNameSur ) . getString ( ) ; if ( string . length ( ) != 0 ) strFinal += string ; if ( iNameSuffix != null ) { string = record . getField ( iNameSuffix ) . getString ( ) ; if ( string . length ( ) != 0 ) strFinal += " " + string ; } if ( iNameTitle != null ) { string = record . getField ( iNameTitle ) . getString ( ) ; if ( string . length ( ) != 0 ) strFinal += " " + string ; } return strFinal ; } | Convert this complete name to the component parts . |
14,088 | public int setString ( String strSource , boolean bDisplayOption , int iMoveMode ) { int iErrorReturn = FirstMLastConverter . nameToParts ( strSource , bDisplayOption , iMoveMode , m_recThis , m_iNamePrefix , m_iNameFirst , m_iNameMiddle , m_iNameSur , m_iNameSuffix , m_iNameTitle ) ; if ( iErrorReturn == DBConstants . NORMAL_RETURN ) if ( this . getNextConverter ( ) != null ) iErrorReturn = super . setString ( strSource , bDisplayOption , iMoveMode ) ; return iErrorReturn ; } | Convert and move string to this field . Split the part of this string into the target fields . Override this method to convert the String to the actual Physical Data Type . |
14,089 | public boolean atCurrent ( BaseBuffer buffer ) throws DBException { boolean bAtCurrent = false ; try { if ( ( m_iIndex >= 0 ) && ( m_iIndex < m_VectorObjects . size ( ) ) ) bAtCurrent = ( buffer == m_VectorObjects . elementAt ( m_iIndex ) ) ; } catch ( ArrayIndexOutOfBoundsException e ) { bAtCurrent = false ; } return bAtCurrent ; } | Am I still pointing at this buffer? If this buffer is the buffer at the current index then the current index is correct . |
14,090 | public void insertCurrent ( FieldTable vectorTable , KeyAreaInfo keyArea , BaseBuffer bufferNew , int iRelPosition ) throws DBException { m_iIndex += iRelPosition ; m_VectorObjects . insertElementAt ( bufferNew , m_iIndex ) ; m_iIndex = - 1 ; } | Insert this record at the current location . |
14,091 | public static String getUri ( String uri ) throws IOException { CloseableHttpClient c = newHttpClient ( new URL ( uri ) ) ; HttpGet get = new HttpGet ( uri ) ; LOG . debug ( "GET {}" , uri ) ; CloseableHttpResponse res = c . execute ( get , HttpClientContext . create ( ) ) ; return checkResponse ( res ) ; } | Gets the response body as string of specified uri . |
14,092 | public static Header [ ] headUri ( String uri ) throws IOException { CloseableHttpClient c = newHttpClient ( new URL ( uri ) ) ; HttpHead head = new HttpHead ( uri ) ; LOG . debug ( "HEAD {}" , uri ) ; CloseableHttpResponse res = c . execute ( head , HttpClientContext . create ( ) ) ; checkResponse ( res ) ; return res . getAllHeaders ( ) ; } | Gets the response headers of specified uri . |
14,093 | public static String headUri ( String uri , String name ) throws IOException { return Stream . of ( headUri ( uri ) ) . filter ( h -> h . getName ( ) . equals ( name ) ) . findFirst ( ) . get ( ) . getValue ( ) ; } | Gets the response header value of specified uri . |
14,094 | public void setClientCertificate ( String clientCertificate , String keyPassword ) { LOG . debug ( "use client certificate/password {}/********" , clientCertificate ) ; this . clientCertificate = clientCertificate ; this . keyPassword = keyPassword ; } | Calls this to provide client certificate . |
14,095 | public JSONObject getJsonObject ( String endpoint ) throws IOException { String res = this . get ( endpoint , null , null ) ; try { return new JSONObject ( res ) ; } catch ( JSONException ex ) { LOG . warn ( res ) ; throw ex ; } } | Issues HTTP GET request converts response body to a JSON object . |
14,096 | public JSONArray getJsonArray ( String endpoint ) throws IOException { String res = this . get ( endpoint , null , null ) ; try { return new JSONArray ( res ) ; } catch ( JSONException ex ) { LOG . warn ( res ) ; throw ex ; } } | Issues HTTP GET request converts response body to a JSON array object . |
14,097 | public String delete ( String endpoint , String params ) throws IOException { return this . delete ( endpoint , params , "" ) ; } | Issues HTTP DELETE request returns response body as string . |
14,098 | public static final void clearRemaining ( ByteBuffer bb ) { if ( bb . hasArray ( ) ) { Arrays . fill ( bb . array ( ) , bb . arrayOffset ( ) + bb . position ( ) , bb . arrayOffset ( ) + bb . limit ( ) , ( byte ) 0 ) ; } else { int limit = bb . limit ( ) ; for ( int ii = bb . position ( ) ; ii < limit ; ii ++ ) { bb . put ( ii , ( byte ) 0 ) ; } } } | Fills data from position to limit with zeroes . Doesn t change position . |
14,099 | public static final int move ( byte [ ] buf , int offset , int length , ByteBuffer bb ) { int count = Math . min ( length , bb . remaining ( ) ) ; bb . put ( buf , offset , count ) ; return count ; } | Moves bytes from buf to bb as much as is possible . Positions are moved according to move . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.