idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
11,800
public MediaCreditList getSeasonCredits ( int tvID , int seasonNumber ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , tvID ) ; parameters . add ( Param . SEASON_NUMBER , seasonNumber ) ; URL url = new ApiUrl ( apiKey , MethodBase . SEASON ) . subMethod ( ...
Get the cast & crew credits for a TV season by season number .
11,801
public URL buildUrl ( final TmdbParameters params ) { StringBuilder urlString = new StringBuilder ( TMDB_API_BASE ) ; LOG . trace ( "Method: '{}', Sub-method: '{}', Params: {}" , method . getValue ( ) , submethod . getValue ( ) , ToStringBuilder . reflectionToString ( params , ToStringStyle . SHORT_PREFIX_STYLE ) ) ; i...
Build the URL from the pre - created parameters .
11,802
private StringBuilder queryProcessing ( TmdbParameters params ) { StringBuilder urlString = new StringBuilder ( ) ; if ( submethod != MethodSub . NONE ) { urlString . append ( "/" ) . append ( submethod . getValue ( ) ) ; } urlString . append ( DELIMITER_FIRST ) . append ( Param . API_KEY . getValue ( ) ) . append ( ap...
Create the query based URL portion
11,803
private StringBuilder idProcessing ( final TmdbParameters params ) { StringBuilder urlString = new StringBuilder ( ) ; if ( params . has ( Param . ID ) ) { urlString . append ( "/" ) . append ( params . get ( Param . ID ) ) ; } if ( params . has ( Param . SEASON_NUMBER ) ) { urlString . append ( "/season/" ) . append (...
Create the ID based URL portion
11,804
private StringBuilder otherProcessing ( final TmdbParameters params ) { StringBuilder urlString = new StringBuilder ( ) ; for ( Map . Entry < Param , String > argEntry : params . getEntries ( ) ) { if ( IGNORE_PARAMS . contains ( argEntry . getKey ( ) ) ) { continue ; } urlString . append ( DELIMITER_SUBSEQUENT ) . app...
Create a string of the remaining parameters
11,805
public Review getReview ( String reviewId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , reviewId ) ; URL url = new ApiUrl ( apiKey , MethodBase . REVIEW ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { return MAPPER ...
Get the full details of a review by ID .
11,806
private String convertToJson ( Map < String , ? > map ) throws MovieDbException { try { return MAPPER . writeValueAsString ( map ) ; } catch ( JsonProcessingException ex ) { throw new MovieDbException ( ApiExceptionType . MAPPING_FAILED , "JSON conversion failed" , "" , ex ) ; } }
Use Jackson to convert Map to JSON string .
11,807
public ResultList < ChangeListItem > getChangeList ( MethodBase method , Integer page , String startDate , String endDate ) throws MovieDbException { TmdbParameters params = new TmdbParameters ( ) ; params . add ( Param . PAGE , page ) ; params . add ( Param . START_DATE , startDate ) ; params . add ( Param . END_DATE ...
Get a list of Media IDs that have been edited .
11,808
public Discover year ( int year ) { if ( checkYear ( year ) ) { params . add ( Param . YEAR , year ) ; } return this ; }
Filter the results release dates to matches that include this value .
11,809
public Discover primaryReleaseYear ( int primaryReleaseYear ) { if ( checkYear ( primaryReleaseYear ) ) { params . add ( Param . PRIMARY_RELEASE_YEAR , primaryReleaseYear ) ; } return this ; }
Filter the results so that only the primary release date year has this value
11,810
public Discover firstAirDateYear ( int year ) { if ( checkYear ( year ) ) { params . add ( Param . FIRST_AIR_DATE_YEAR , year ) ; } return this ; }
Filter the air dates that match this year
11,811
public Discover firstAirDateYearGte ( int year ) { if ( checkYear ( year ) ) { params . add ( Param . FIRST_AIR_DATE_GTE , year ) ; } return this ; }
Filter the air dates to years that are greater than or equal to this year
11,812
public Discover firstAirDateYearLte ( int year ) { if ( checkYear ( year ) ) { params . add ( Param . FIRST_AIR_DATE_LTE , year ) ; } return this ; }
Filter the air dates to years that are less than or equal to this year
11,813
public boolean isValidPosterSize ( String posterSize ) { if ( StringUtils . isBlank ( posterSize ) || posterSizes . isEmpty ( ) ) { return false ; } return posterSizes . contains ( posterSize ) ; }
Check that the poster size is valid
11,814
public boolean isValidBackdropSize ( String backdropSize ) { if ( StringUtils . isBlank ( backdropSize ) || backdropSizes . isEmpty ( ) ) { return false ; } return backdropSizes . contains ( backdropSize ) ; }
Check that the backdrop size is valid
11,815
public boolean isValidProfileSize ( String profileSize ) { if ( StringUtils . isBlank ( profileSize ) || profileSizes . isEmpty ( ) ) { return false ; } return profileSizes . contains ( profileSize ) ; }
Check that the profile size is valid
11,816
public boolean isValidLogoSize ( String logoSize ) { if ( StringUtils . isBlank ( logoSize ) || logoSizes . isEmpty ( ) ) { return false ; } return logoSizes . contains ( logoSize ) ; }
Check that the logo size is valid
11,817
public boolean isValidSize ( String sizeToCheck ) { return isValidPosterSize ( sizeToCheck ) || isValidBackdropSize ( sizeToCheck ) || isValidProfileSize ( sizeToCheck ) || isValidLogoSize ( sizeToCheck ) ; }
Check to see if the size is valid for any of the images types
11,818
public ListItem < MovieInfo > getList ( String listId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , listId ) ; URL url = new ApiUrl ( apiKey , MethodBase . LIST ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { return...
Get a list by its ID
11,819
public boolean checkItemStatus ( String listId , int mediaId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , listId ) ; parameters . add ( Param . MOVIE_ID , mediaId ) ; URL url = new ApiUrl ( apiKey , MethodBase . LIST ) . subMethod ( MethodSub . ITEM_ST...
Check to see if an ID is already on a list .
11,820
private StatusCode modifyMovieList ( String sessionId , String listId , int movieId , MethodSub operation ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . SESSION_ID , sessionId ) ; parameters . add ( Param . ID , listId ) ; String jsonBody = new PostTools ( ) ...
Modify a list
11,821
public StatusCode removeItem ( String sessionId , String listId , int mediaId ) throws MovieDbException { return modifyMovieList ( sessionId , listId , mediaId , MethodSub . REMOVE_ITEM ) ; }
This method lets users delete items from a list that they created .
11,822
public StatusCode clear ( String sessionId , String listId , boolean confirm ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . SESSION_ID , sessionId ) ; parameters . add ( Param . ID , listId ) ; parameters . add ( Param . CONFIRM , confirm ) ; URL url = new Ap...
Clear all of the items within a list .
11,823
public Keyword getKeyword ( String keywordId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , keywordId ) ; URL url = new ApiUrl ( apiKey , MethodBase . KEYWORD ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { return MA...
Get the basic information for a specific keyword id .
11,824
public String getRequest ( final URL url ) throws MovieDbException { try { HttpGet httpGet = new HttpGet ( url . toURI ( ) ) ; httpGet . addHeader ( HttpHeaders . ACCEPT , APPLICATION_JSON ) ; DigestedResponse response = DigestedResponseReader . requestContent ( httpClient , httpGet , CHARSET ) ; long retryCount = 0L ;...
GET data from the URL
11,825
private void delay ( long multiplier ) { try { Thread . sleep ( TimeUnit . SECONDS . toMillis ( RETRY_DELAY * multiplier ) ) ; } catch ( InterruptedException ex ) { } }
Sleep for a period of time
11,826
public String deleteRequest ( final URL url ) throws MovieDbException { try { HttpDelete httpDel = new HttpDelete ( url . toURI ( ) ) ; return validateResponse ( DigestedResponseReader . deleteContent ( httpClient , httpDel , CHARSET ) , url ) ; } catch ( URISyntaxException | IOException ex ) { throw new MovieDbExcepti...
Execute a DELETE on the URL
11,827
public String postRequest ( final URL url , final String jsonBody ) throws MovieDbException { try { HttpPost httpPost = new HttpPost ( url . toURI ( ) ) ; httpPost . addHeader ( HTTP . CONTENT_TYPE , APPLICATION_JSON ) ; httpPost . addHeader ( HttpHeaders . ACCEPT , APPLICATION_JSON ) ; StringEntity params = new String...
POST content to the URL with the specified body
11,828
private String validateResponse ( final DigestedResponse response , final URL url ) throws MovieDbException { if ( response . getStatusCode ( ) == 0 ) { throw new MovieDbException ( ApiExceptionType . CONNECTION_ERROR , response . getContent ( ) , response . getStatusCode ( ) , url , null ) ; } else if ( response . get...
Check the status codes of the response and throw exceptions if needed
11,829
public void add ( final Param key , final String [ ] value ) { if ( value != null && value . length > 0 ) { parameters . put ( key , toList ( value ) ) ; } }
Add an array parameter to the collection
11,830
public void add ( final Param key , final String value ) { if ( StringUtils . isNotBlank ( value ) ) { parameters . put ( key , value ) ; } }
Add a string parameter to the collection
11,831
public void add ( final Param key , final Integer value ) { if ( value != null && value > 0 ) { parameters . put ( key , String . valueOf ( value ) ) ; } }
Add an integer parameter to the collection
11,832
public String toList ( final String [ ] appendToResponse ) { StringBuilder sb = new StringBuilder ( ) ; boolean first = Boolean . TRUE ; for ( String append : appendToResponse ) { if ( first ) { first = Boolean . FALSE ; } else { sb . append ( "," ) ; } sb . append ( append ) ; } return sb . toString ( ) ; }
Append any optional parameters to the URL
11,833
protected static TypeReference getTypeReference ( Class aClass ) throws MovieDbException { if ( TYPE_REFS . containsKey ( aClass ) ) { return TYPE_REFS . get ( aClass ) ; } else { throw new MovieDbException ( ApiExceptionType . UNKNOWN_CAUSE , "Class type reference for '" + aClass . getSimpleName ( ) + "' not found!" )...
Helper function to get a pre - generated TypeReference for a class
11,834
protected < T > List < T > processWrapperList ( TypeReference typeRef , URL url , String errorMessageSuffix ) throws MovieDbException { WrapperGenericList < T > val = processWrapper ( typeRef , url , errorMessageSuffix ) ; return val . getResults ( ) ; }
Process the wrapper list and return the results
11,835
protected < T > WrapperGenericList < T > processWrapper ( TypeReference typeRef , URL url , String errorMessageSuffix ) throws MovieDbException { String webpage = httpTools . getRequest ( url ) ; try { return MAPPER . readValue ( webpage , typeRef ) ; } catch ( IOException ex ) { throw new MovieDbException ( ApiExcepti...
Process the wrapper list and return the whole wrapper
11,836
public ResultList < JobDepartment > getJobs ( ) throws MovieDbException { URL url = new ApiUrl ( apiKey , MethodBase . JOB ) . subMethod ( MethodSub . LIST ) . buildUrl ( ) ; String webpage = httpTools . getRequest ( url ) ; try { WrapperJobList wrapper = MAPPER . readValue ( webpage , WrapperJobList . class ) ; Result...
Get a list of valid jobs
11,837
public ResultsMap < String , List < String > > getTimezones ( ) throws MovieDbException { URL url = new ApiUrl ( apiKey , MethodBase . TIMEZONES ) . subMethod ( MethodSub . LIST ) . buildUrl ( ) ; String webpage = httpTools . getRequest ( url ) ; List < Map < String , List < String > > > tzList ; try { tzList = MAPPER ...
Get the list of supported timezones for the API methods that support them
11,838
public ResultList < Genre > getGenreMovieList ( String language ) throws MovieDbException { return getGenreList ( language , MethodSub . MOVIE_LIST ) ; }
Get the list of movie genres .
11,839
public ResultList < Genre > getGenreTVList ( String language ) throws MovieDbException { return getGenreList ( language , MethodSub . TV_LIST ) ; }
Get the list of TV genres .
11,840
private ResultList < Genre > getGenreList ( String language , MethodSub sub ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . LANGUAGE , language ) ; URL url = new ApiUrl ( apiKey , MethodBase . GENRE ) . subMethod ( sub ) . buildUrl ( parameters ) ; String webp...
Get the list of genres for movies or TV
11,841
public ResultList < MovieBasic > getGenreMovies ( int genreId , String language , Integer page , Boolean includeAllMovies , Boolean includeAdult ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , genreId ) ; parameters . add ( Param . LANGUAGE , language ) ;...
Get the list of movies for a particular genre by id .
11,842
public ResultList < ChangeKeyItem > getEpisodeChanges ( int episodeID , String startDate , String endDate ) throws MovieDbException { return getMediaChanges ( episodeID , startDate , endDate ) ; }
Look up a TV episode s changes by episode ID
11,843
public Account getAccount ( String sessionId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . SESSION_ID , sessionId ) ; URL url = new ApiUrl ( apiKey , MethodBase . ACCOUNT ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { r...
Get the basic information for an account . You will need to have a valid session id .
11,844
public StatusCode modifyWatchList ( String sessionId , int accountId , MediaType mediaType , Integer movieId , boolean addToWatchlist ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . SESSION_ID , sessionId ) ; parameters . add ( Param . ID , accountId ) ; Strin...
Add or remove a movie to an accounts watch list .
11,845
public Company getCompanyInfo ( int companyId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , companyId ) ; URL url = new ApiUrl ( apiKey , MethodBase . COMPANY ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { return M...
This method is used to retrieve the basic information about a production company on TMDb .
11,846
public ResultList < AlternativeTitle > getTVAlternativeTitles ( int tvID ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , tvID ) ; URL url = new ApiUrl ( apiKey , MethodBase . TV ) . subMethod ( MethodSub . ALT_TITLES ) . buildUrl ( parameters ) ; WrapperG...
Get the alternative titles for a specific show ID .
11,847
public ResultList < ChangeKeyItem > getTVChanges ( int tvID , String startDate , String endDate ) throws MovieDbException { return getMediaChanges ( tvID , startDate , endDate ) ; }
Get the changes for a specific TV show id .
11,848
public ResultList < ContentRating > getTVContentRatings ( int tvID ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , tvID ) ; URL url = new ApiUrl ( apiKey , MethodBase . TV ) . subMethod ( MethodSub . CONTENT_RATINGS ) . buildUrl ( parameters ) ; WrapperGe...
Get the content ratings for a specific TV show id .
11,849
public ResultList < Keyword > getTVKeywords ( int tvID ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , tvID ) ; URL url = new ApiUrl ( apiKey , MethodBase . TV ) . subMethod ( MethodSub . KEYWORDS ) . buildUrl ( parameters ) ; WrapperGenericList < Keyword...
Get the plot keywords for a specific TV show id .
11,850
protected void init ( ) { Log . d ( TAG , "init" ) ; if ( isInEditMode ( ) ) return ; this . mediaPlayer = null ; this . shouldAutoplay = false ; this . fullscreen = false ; this . initialConfigOrientation = - 1 ; this . videoIsReady = false ; this . surfaceIsReady = false ; this . initialMovieHeight = - 1 ; this . ini...
Initializes the default configuration
11,851
protected void release ( ) { Log . d ( TAG , "release" ) ; releaseObjects ( ) ; if ( this . mediaPlayer != null ) { this . mediaPlayer . setOnBufferingUpdateListener ( null ) ; this . mediaPlayer . setOnPreparedListener ( null ) ; this . mediaPlayer . setOnErrorListener ( null ) ; this . mediaPlayer . setOnSeekComplete...
Releases and ends the current Object
11,852
protected void initObjects ( ) { Log . d ( TAG , "initObjects" ) ; if ( this . mediaPlayer == null ) { this . mediaPlayer = new MediaPlayer ( ) ; this . mediaPlayer . setOnInfoListener ( this ) ; this . mediaPlayer . setOnErrorListener ( this ) ; this . mediaPlayer . setOnPreparedListener ( this ) ; this . mediaPlayer ...
Initializes all objects FullscreenVideoView depends on It does not interfere with configuration properties because it is supposed to be called when this Object still exists
11,853
protected void releaseObjects ( ) { Log . d ( TAG , "releaseObjects" ) ; if ( this . mediaPlayer != null ) { this . mediaPlayer . setSurface ( null ) ; this . mediaPlayer . reset ( ) ; } this . videoIsReady = false ; this . surfaceIsReady = false ; this . initialMovieHeight = - 1 ; this . initialMovieWidth = - 1 ; if (...
Releases all objects FullscreenVideoView depends on It does not interfere with configuration properties because it is supposed to be called when this Object still exists
11,854
protected void tryToPrepare ( ) { Log . d ( TAG , "tryToPrepare" ) ; if ( this . surfaceIsReady && this . videoIsReady ) { if ( this . mediaPlayer != null && this . mediaPlayer . getVideoWidth ( ) != 0 && this . mediaPlayer . getVideoHeight ( ) != 0 ) { this . initialMovieWidth = this . mediaPlayer . getVideoWidth ( ) ...
Try to call state PREPARED Only if SurfaceView is already created and MediaPlayer is prepared Video is loaded and is ok to play .
11,855
public void setFullscreen ( final boolean fullscreen ) throws RuntimeException { if ( mediaPlayer == null ) throw new RuntimeException ( "Media Player is not initialized" ) ; if ( this . currentState != State . ERROR ) { if ( FullscreenVideoView . this . fullscreen == fullscreen ) return ; FullscreenVideoView . this . ...
Turn VideoView fulllscreen mode on or off .
11,856
public void onClick ( View v ) { if ( v . getId ( ) == R . id . vcv_img_play ) { if ( isPlaying ( ) ) { pause ( ) ; } else { start ( ) ; } } else { setFullscreen ( ! isFullscreen ( ) ) ; } }
Onclick action Controls play button and fullscreen button .
11,857
public void populate ( final AnnotationData data , final Annotation annotation , final Class < ? extends Annotation > expectedAnnotationClass , final Method targetMethod ) throws Exception { if ( support ( expectedAnnotationClass ) ) { build ( data , annotation , expectedAnnotationClass , targetMethod ) ; } }
Populates additional data into annotation data .
11,858
protected Cache createCache ( ) throws IOException { if ( cache != null ) { throw new IllegalStateException ( String . format ( "This factory has already created memcached client for cache %s" , cacheName ) ) ; } if ( isCacheDisabled ( ) ) { LOGGER . warn ( "Cache {} is disabled" , cacheName ) ; cache = ( Cache ) Proxy...
Only one cache is created .
11,859
public String getCacheKey ( final Object keyObject , final String namespace ) { return namespace + SEPARATOR + defaultKeyProvider . generateKey ( keyObject ) ; }
Builds cache key from one key object .
11,860
private String buildCacheKey ( final String [ ] objectIds , final String namespace ) { if ( objectIds . length == 1 ) { checkKeyPart ( objectIds [ 0 ] ) ; return namespace + SEPARATOR + objectIds [ 0 ] ; } StringBuilder cacheKey = new StringBuilder ( namespace ) ; cacheKey . append ( SEPARATOR ) ; for ( String id : obj...
Build cache key .
11,861
public void removeCache ( final String nameOrAlias ) { final Cache cache = cacheMap . get ( nameOrAlias ) ; if ( cache == null ) { return ; } final SSMCache ssmCache = ( SSMCache ) cache ; if ( ssmCache . isRegisterAliases ( ) ) { ssmCache . getCache ( ) . getAliases ( ) . forEach ( this :: unregisterCache ) ; } unregi...
Removes given cache and related aliases .
11,862
protected Object deserialize ( final byte [ ] in ) { Object o = null ; ByteArrayInputStream bis = null ; ConfigurableObjectInputStream is = null ; try { if ( in != null ) { bis = new ByteArrayInputStream ( in ) ; is = new ConfigurableObjectInputStream ( bis , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; o...
Deserialize given stream using java deserialization .
11,863
@ SuppressWarnings ( "unchecked" ) public < T > T get ( final Object key , final Class < T > type ) { if ( ! cache . isEnabled ( ) ) { LOGGER . warn ( "Cache {} is disabled. Cannot get {} from cache" , cache . getName ( ) , key ) ; return null ; } Object value = getValue ( key ) ; if ( value == null ) { LOGGER . info (...
Required by Spring 4 . 0
11,864
@ SuppressWarnings ( "unchecked" ) public < T > T get ( final Object key , final Callable < T > valueLoader ) { if ( ! cache . isEnabled ( ) ) { LOGGER . warn ( "Cache {} is disabled. Cannot get {} from cache" , cache . getName ( ) , key ) ; return loadValue ( key , valueLoader ) ; } final ValueWrapper valueWrapper = g...
Required by Spring 4 . 3
11,865
public ValueWrapper putIfAbsent ( final Object key , final Object value ) { if ( ! cache . isEnabled ( ) ) { LOGGER . warn ( "Cache {} is disabled. Cannot put value under key {}" , cache . getName ( ) , key ) ; return null ; } if ( key != null ) { final String cacheKey = getKey ( key ) ; try { LOGGER . info ( "Put '{}'...
Required by Spring 4 . 1
11,866
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public static Seq toScalaSeq ( Object [ ] o ) { ArrayList list = new ArrayList ( ) ; for ( int i = 0 ; i < o . length ; i ++ ) { list . add ( o [ i ] ) ; } return scala . collection . JavaConversions . asScalaBuffer ( list ) . toList ( ) ; }
Takes an array of objects and returns a scala Seq
11,867
public static UnsignedInteger64 add ( UnsignedInteger64 x , UnsignedInteger64 y ) { return new UnsignedInteger64 ( x . bigInt . add ( y . bigInt ) ) ; }
Add an unsigned integer to another unsigned integer .
11,868
public static UnsignedInteger64 add ( UnsignedInteger64 x , int y ) { return new UnsignedInteger64 ( x . bigInt . add ( BigInteger . valueOf ( y ) ) ) ; }
Add an unsigned integer to an int .
11,869
public byte [ ] toByteArray ( ) { byte [ ] raw = new byte [ 8 ] ; byte [ ] bi = bigIntValue ( ) . toByteArray ( ) ; System . arraycopy ( bi , 0 , raw , raw . length - bi . length , bi . length ) ; return raw ; }
Returns a byte array encoded with the unsigned integer .
11,870
public void remove ( SshPublicKey key ) throws SshException , PublicKeySubsystemException { try { Packet msg = createPacket ( ) ; msg . writeString ( "remove" ) ; msg . writeString ( key . getAlgorithm ( ) ) ; msg . writeBinaryString ( key . getEncoded ( ) ) ; sendMessage ( msg ) ; readStatusResponse ( ) ; } catch ( IO...
Remove a public key from the users list of acceptable keys .
11,871
public SshPublicKey [ ] list ( ) throws SshException , PublicKeySubsystemException { try { Packet msg = createPacket ( ) ; msg . writeString ( "list" ) ; sendMessage ( msg ) ; Vector < SshPublicKey > keys = new Vector < SshPublicKey > ( ) ; while ( true ) { ByteArrayReader response = new ByteArrayReader ( nextMessage (...
List all of the users acceptable keys .
11,872
public void associateCommand ( SshPublicKey key , String command ) throws SshException , PublicKeySubsystemException { try { Packet msg = createPacket ( ) ; msg . writeString ( "command" ) ; msg . writeString ( key . getAlgorithm ( ) ) ; msg . writeBinaryString ( key . getEncoded ( ) ) ; msg . writeString ( command ) ;...
Associate a command with an accepted public key . The request will fail if the public key is not currently in the users acceptable list . Also some server implementations may choose not to support this feature .
11,873
void readStatusResponse ( ) throws SshException , PublicKeySubsystemException { ByteArrayReader msg = new ByteArrayReader ( nextMessage ( ) ) ; try { msg . readString ( ) ; int status = ( int ) msg . readInt ( ) ; String desc = msg . readString ( ) ; if ( status != PublicKeySubsystemException . SUCCESS ) { throw new Pu...
Read a status response and throw an exception if an error has occurred .
11,874
public void setTerminalMode ( int mode , int value ) throws SshException { try { encodedModes . write ( mode ) ; if ( version == 1 && mode <= 127 ) { encodedModes . write ( value ) ; } else { encodedModes . writeInt ( value ) ; } } catch ( IOException ex ) { throw new SshException ( SshException . INTERNAL_ERROR , ex )...
Set an integer value mode
11,875
protected ProxyMessage exchange ( ProxyMessage request ) throws SocksException { ProxyMessage reply ; try { request . write ( out ) ; reply = formMessage ( in ) ; } catch ( SocksException s_ex ) { throw s_ex ; } catch ( IOException ioe ) { throw ( new SocksException ( SOCKS_PROXY_IO_ERROR , "" + ioe ) ) ; } return repl...
Sends the request reads reply and returns it throws exception if something wrong with IO or the reply code is not zero
11,876
public String [ ] matchFileNamesWithPattern ( File [ ] files , String fileNameRegExp ) throws SshException , SftpStatusException { String [ ] thefile = new String [ 1 ] ; thefile [ 0 ] = files [ 0 ] . getName ( ) ; return thefile ; }
opens and returns the requested filename string
11,877
public synchronized void addListener ( String threadPrefix , EventListener listener ) { if ( threadPrefix . trim ( ) . equals ( "" ) ) { globalListeners . addElement ( listener ) ; } else { keyedListeners . put ( threadPrefix . trim ( ) , listener ) ; } }
Add a J2SSH Listener to the list of listeners that will be sent events
11,878
public synchronized void fireEvent ( Event evt ) { if ( evt == null ) { return ; } for ( Enumeration < EventListener > keys = globalListeners . elements ( ) ; keys . hasMoreElements ( ) ; ) { EventListener mListener = keys . nextElement ( ) ; try { mListener . processEvent ( evt ) ; } catch ( Throwable t ) { } } String...
Send an SSH Event to each registered listener
11,879
public void close ( ) throws IOException { try { while ( processNextResponse ( 0 ) ) ; file . close ( ) ; } catch ( SshException ex ) { throw new SshIOException ( ex ) ; } catch ( SftpStatusException ex ) { throw new IOException ( ex . getMessage ( ) ) ; } }
Closes the file s handle
11,880
public static void setCharsetEncoding ( String charset ) { try { String test = "123456890" ; test . getBytes ( charset ) ; CHARSET_ENCODING = charset ; encode = true ; } catch ( UnsupportedEncodingException ex ) { CHARSET_ENCODING = "" ; encode = false ; } }
Allows the default encoding to be overriden for String variables processed by the class . This currently defaults to UTF - 8 .
11,881
public BigInteger readBigInteger ( ) throws IOException { int len = ( int ) readInt ( ) ; byte [ ] raw = new byte [ len ] ; readFully ( raw ) ; return new BigInteger ( raw ) ; }
Read a BigInteger from the array .
11,882
public String readString ( String charset ) throws IOException { long len = readInt ( ) ; if ( len > available ( ) ) throw new IOException ( "Cannot read string of length " + len + " bytes when only " + available ( ) + " bytes are available" ) ; byte [ ] raw = new byte [ ( int ) len ] ; readFully ( raw ) ; if ( encode ...
Read a String from the array converting using the given character set .
11,883
public BigInteger readMPINT32 ( ) throws IOException { int bits = ( int ) readInt ( ) ; byte [ ] raw = new byte [ ( bits + 7 ) / 8 + 1 ] ; raw [ 0 ] = 0 ; readFully ( raw , 1 , raw . length - 1 ) ; return new BigInteger ( raw ) ; }
Reads an MPINT using the first 32 bits as the length prefix
11,884
public BigInteger readMPINT ( ) throws IOException { short bits = readShort ( ) ; byte [ ] raw = new byte [ ( bits + 7 ) / 8 + 1 ] ; raw [ 0 ] = 0 ; readFully ( raw , 1 , raw . length - 1 ) ; return new BigInteger ( raw ) ; }
Reads a standard SSH1 MPINT using the first 16 bits as the length prefix
11,885
public static SocksProxyTransport connectViaSocks4Proxy ( String remoteHost , int remotePort , String proxyHost , int proxyPort , String userId ) throws IOException , UnknownHostException { SocksProxyTransport proxySocket = new SocksProxyTransport ( remoteHost , remotePort , proxyHost , proxyPort , SOCKS4 ) ; proxySock...
Connect the socket to a SOCKS 4 proxy and request forwarding to our remote host .
11,886
protected void sendMessage ( byte [ ] msg ) throws SshException { try { Packet pkt = createPacket ( ) ; pkt . write ( msg ) ; sendMessage ( pkt ) ; } catch ( IOException ex ) { throw new SshException ( SshException . UNEXPECTED_TERMINATION , ex ) ; } }
Send a byte array as a message .
11,887
protected Packet createPacket ( ) throws IOException { synchronized ( packets ) { if ( packets . size ( ) == 0 ) return new Packet ( ) ; Packet p = ( Packet ) packets . elementAt ( 0 ) ; packets . removeElementAt ( 0 ) ; return p ; } }
Get a packet from the available pool or create if non available
11,888
public static SshKeyPair generateKeyPair ( String algorithm , int bits ) throws IOException , SshException { if ( ! SSH2_RSA . equalsIgnoreCase ( algorithm ) && ! SSH2_DSA . equalsIgnoreCase ( algorithm ) ) { throw new IOException ( algorithm + " is not a supported key algorithm!" ) ; } SshKeyPair pair = new SshKeyPair...
Generates a new key pair .
11,889
public void setUID ( String uid ) { if ( version > 3 ) { flags |= SSH_FILEXFER_ATTR_OWNERGROUP ; } else flags |= SSH_FILEXFER_ATTR_UIDGID ; this . uid = uid ; }
Set the UID of the owner .
11,890
public void setGID ( String gid ) { if ( version > 3 ) { flags |= SSH_FILEXFER_ATTR_OWNERGROUP ; } else flags |= SSH_FILEXFER_ATTR_UIDGID ; this . gid = gid ; }
Set the GID of this file .
11,891
public void setSize ( UnsignedInteger64 size ) { this . size = size ; if ( size != null ) { flags |= SSH_FILEXFER_ATTR_SIZE ; } else { flags ^= SSH_FILEXFER_ATTR_SIZE ; } }
Set the size of the file .
11,892
public void setPermissions ( UnsignedInteger32 permissions ) { this . permissions = permissions ; if ( permissions != null ) { flags |= SSH_FILEXFER_ATTR_PERMISSIONS ; } else { flags ^= SSH_FILEXFER_ATTR_PERMISSIONS ; } }
Set the permissions of the file . This value should be a valid mask of the permissions flags defined within this class .
11,893
public void setPermissionsFromMaskString ( String mask ) { if ( mask . length ( ) != 4 ) { throw new IllegalArgumentException ( "Mask length must be 4" ) ; } try { setPermissions ( new UnsignedInteger32 ( String . valueOf ( Integer . parseInt ( mask , 8 ) ) ) ) ; } catch ( NumberFormatException nfe ) { throw new Illega...
Set permissions given a UNIX style mask for example 0644
11,894
public void setPermissionsFromUmaskString ( String umask ) { if ( umask . length ( ) != 4 ) { throw new IllegalArgumentException ( "umask length must be 4" ) ; } try { setPermissions ( new UnsignedInteger32 ( String . valueOf ( Integer . parseInt ( umask , 8 ) ^ 0777 ) ) ) ; } catch ( NumberFormatException ex ) { throw...
Set the permissions given a UNIX style umask for example 0022 will result in 0022 ^ 0777 .
11,895
public String getMaskString ( ) { StringBuffer buf = new StringBuffer ( ) ; if ( permissions != null ) { int i = ( int ) permissions . longValue ( ) ; buf . append ( '0' ) ; buf . append ( octal ( i , 6 ) ) ; buf . append ( octal ( i , 3 ) ) ; buf . append ( octal ( i , 0 ) ) ; } else { buf . append ( "----" ) ; } retu...
Return the UNIX style mode mask
11,896
public boolean isDirectory ( ) { if ( sftp . getVersion ( ) > 3 ) { return type == SSH_FILEXFER_TYPE_DIRECTORY ; } else if ( permissions != null && ( permissions . longValue ( ) & SftpFileAttributes . S_IFDIR ) == SftpFileAttributes . S_IFDIR ) { return true ; } else { return false ; } }
Determine whether these attributes refer to a directory
11,897
public boolean isLink ( ) { if ( sftp . getVersion ( ) > 3 ) { return type == SSH_FILEXFER_TYPE_SYMLINK ; } else if ( permissions != null && ( permissions . longValue ( ) & SftpFileAttributes . S_IFLNK ) == SftpFileAttributes . S_IFLNK ) { return true ; } else { return false ; } }
Determine whether these attributes refer to a symbolic link .
11,898
public boolean isFifo ( ) { if ( permissions != null && ( permissions . longValue ( ) & SftpFileAttributes . S_IFIFO ) == SftpFileAttributes . S_IFIFO ) { return true ; } return false ; }
Determine whether these attributes refer to a pipe .
11,899
public boolean isBlock ( ) { if ( permissions != null && ( permissions . longValue ( ) & SftpFileAttributes . S_IFBLK ) == SftpFileAttributes . S_IFBLK ) { return true ; } return false ; }
Determine whether these attributes refer to a block special file .