idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
11,700 | public void pullRemoteRevision ( final RevisionInternal rev ) { Log . d ( TAG , "%s: pullRemoteRevision with rev: %s" , this , rev ) ; ++ httpConnectionCount ; StringBuilder path = new StringBuilder ( encodeDocumentId ( rev . getDocID ( ) ) ) ; path . append ( "?rev=" ) . append ( URIUtils . encode ( rev . getRevID ( ) ) ) ; path . append ( "&revs=true" ) ; boolean attachments = true ; if ( attachments ) path . append ( "&attachments=true" ) ; AtomicBoolean haveBodies = new AtomicBoolean ( false ) ; List < String > possibleAncestors = null ; possibleAncestors = db . getPossibleAncestorRevisionIDs ( rev , PullerInternal . MAX_NUMBER_OF_ATTS_SINCE , attachments ? haveBodies : null , true ) ; if ( possibleAncestors != null ) { path . append ( haveBodies . get ( ) ? "&atts_since=" : "&revs_from=" ) ; path . append ( joinQuotedEscaped ( possibleAncestors ) ) ; } else { int maxRevTreeDepth = getLocalDatabase ( ) . getMaxRevTreeDepth ( ) ; if ( rev . getGeneration ( ) > maxRevTreeDepth ) { path . append ( "&revs_limit=" ) ; path . append ( maxRevTreeDepth ) ; } } final String pathInside = path . toString ( ) ; CustomFuture future = sendAsyncMultipartDownloaderRequest ( "GET" , pathInside , null , db , new RemoteRequestCompletion ( ) { public void onCompletion ( RemoteRequest remoteRequest , Response httpResponse , Object result , Throwable e ) { if ( e != null ) { Log . w ( TAG , "Error pulling remote revision: %s" , e , this ) ; if ( Utils . isDocumentError ( e ) ) { revisionFailed ( rev , e ) ; } else { setError ( e ) ; } } else { Map < String , Object > properties = ( Map < String , Object > ) result ; long size = 0 ; if ( httpResponse != null && httpResponse . body ( ) != null ) size = httpResponse . body ( ) . contentLength ( ) ; PulledRevision gotRev = new PulledRevision ( properties , size ) ; gotRev . setSequence ( rev . getSequence ( ) ) ; Log . d ( TAG , "%s: pullRemoteRevision add rev: %s to batcher: %s" , PullerInternal . this , gotRev , downloadsToInsert ) ; if ( gotRev . getBody ( ) != null ) queuedMemorySize . addAndGet ( gotRev . getBody ( ) . getSize ( ) ) ; downloadsToInsert . queueObject ( gotRev ) ; if ( queuedMemorySize . get ( ) > MAX_QUEUE_MEMORY_SIZE ) { Log . d ( TAG , "Flushing queued memory size at: " + queuedMemorySize ) ; downloadsToInsert . flushAllAndWait ( ) ; } } -- httpConnectionCount ; pullRemoteRevisions ( ) ; } } ) ; future . setQueue ( pendingFutures ) ; pendingFutures . add ( future ) ; } | Fetches the contents of a revision from the remote db including its parent revision ID . The contents are stored into rev . properties . |
11,701 | protected void queueRemoteRevision ( RevisionInternal rev ) { if ( rev . isDeleted ( ) ) { deletedRevsToPull . add ( rev ) ; } else { revsToPull . add ( rev ) ; } } | Add a revision to the appropriate queue of revs to individually GET |
11,702 | private static boolean isAllowed ( char c , String allow ) { return ( c >= 'A' && c <= 'Z' ) || ( c >= 'a' && c <= 'z' ) || ( c >= '0' && c <= '9' ) || "_-!.~'()*" . indexOf ( c ) != NOT_FOUND || ( allow != null && allow . indexOf ( c ) != NOT_FOUND ) ; } | Returns true if the given character is allowed . |
11,703 | public boolean mutateAttachments ( CollectionUtils . Functor < Map < String , Object > , Map < String , Object > > functor ) { { Map < String , Object > properties = getProperties ( ) ; Map < String , Object > editedProperties = null ; Map < String , Object > attachments = ( Map < String , Object > ) properties . get ( "_attachments" ) ; Map < String , Object > editedAttachments = null ; if ( attachments != null ) { for ( String name : attachments . keySet ( ) ) { Map < String , Object > attachment = new HashMap < String , Object > ( ( Map < String , Object > ) attachments . get ( name ) ) ; attachment . put ( "name" , name ) ; Map < String , Object > editedAttachment = functor . invoke ( attachment ) ; if ( editedAttachment == null ) { return false ; } if ( editedAttachment != attachment ) { if ( editedProperties == null ) { editedProperties = new HashMap < String , Object > ( properties ) ; editedAttachments = new HashMap < String , Object > ( attachments ) ; editedProperties . put ( "_attachments" , editedAttachments ) ; } editedAttachment . remove ( "name" ) ; editedAttachments . put ( name , editedAttachment ) ; } } } if ( editedProperties != null ) { setProperties ( editedProperties ) ; return true ; } return false ; } } | Returns YES if any changes were made . |
11,704 | public void appendData ( byte [ ] data ) throws IOException , SymmetricKeyException { if ( data == null ) return ; appendData ( data , 0 , data . length ) ; } | Appends data to the blob . Call this when new data is available . |
11,705 | public void finish ( ) throws IOException , SymmetricKeyException { if ( outStream != null ) { if ( encryptor != null ) outStream . write ( encryptor . encrypt ( null ) ) ; outStream . close ( ) ; outStream = null ; blobKey = new BlobKey ( sha1Digest . digest ( ) ) ; md5DigestResult = md5Digest . digest ( ) ; } } | Call this after all the data has been added . |
11,706 | public void cancel ( ) { try { if ( outStream != null ) { outStream . close ( ) ; outStream = null ; } encryptor = null ; } catch ( IOException e ) { Log . w ( Log . TAG_BLOB_STORE , "Exception closing buffered output stream" , e ) ; } tempFile . delete ( ) ; } | Call this to cancel before finishing the data . |
11,707 | public boolean install ( ) { if ( tempFile == null ) return true ; String destPath = store . getRawPathForKey ( blobKey ) ; File destPathFile = new File ( destPath ) ; if ( tempFile . renameTo ( destPathFile ) ) tempFile = null ; else cancel ( ) ; return true ; } | Installs a finished blob into the store . |
11,708 | public QueryRow next ( ) { if ( nextRow >= rows . size ( ) ) { return null ; } return rows . get ( nextRow ++ ) ; } | Gets the next QueryRow from the results or null if there are no more results . |
11,709 | Map < String , Object > getProperties ( ) { Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( "continuous" , isContinuous ( ) ) ; props . put ( "create_target" , shouldCreateTarget ( ) ) ; props . put ( "filter" , getFilter ( ) ) ; props . put ( "query_params" , getFilterParams ( ) ) ; props . put ( "doc_ids" , getDocIds ( ) ) ; URL remoteURL = this . getRemoteUrl ( ) ; Map < String , Object > remote = new HashMap < String , Object > ( ) ; remote . put ( "url" , remoteURL . toString ( ) ) ; remote . put ( "headers" , getHeaders ( ) ) ; if ( isPull ( ) ) { props . put ( "source" , remote ) ; props . put ( "target" , db . getName ( ) ) ; } else { props . put ( "source" , db . getName ( ) ) ; props . put ( "target" , remote ) ; } return props ; } | Currently only used for test |
11,710 | public void start ( ) { if ( replicationInternal == null ) { initReplicationInternal ( ) ; } else { if ( replicationInternal . stateMachine . isInState ( ReplicationState . INITIAL ) ) { } else if ( replicationInternal . stateMachine . isInState ( ReplicationState . STOPPED ) ) { initReplicationInternal ( ) ; } else { Log . w ( Log . TAG_SYNC , String . format ( Locale . ENGLISH , "replicationInternal in unexpected state: %s, ignoring start()" , replicationInternal . stateMachine . getState ( ) ) ) ; } } this . lastError = null ; replicationInternal . setError ( null ) ; replicationInternal . triggerStart ( ) ; } | Starts the replication asynchronously . |
11,711 | public void setContinuous ( boolean isContinous ) { if ( isContinous ) { this . lifecycle = Lifecycle . CONTINUOUS ; replicationInternal . setLifecycle ( Lifecycle . CONTINUOUS ) ; } else { this . lifecycle = Lifecycle . ONESHOT ; replicationInternal . setLifecycle ( Lifecycle . ONESHOT ) ; } } | Set whether this replication is continous |
11,712 | public void setAuthenticator ( Authenticator authenticator ) { properties . put ( ReplicationField . AUTHENTICATOR , authenticator ) ; replicationInternal . setAuthenticator ( authenticator ) ; } | Set the Authenticator used for authenticating with the Sync Gateway |
11,713 | public void setCreateTarget ( boolean createTarget ) { properties . put ( ReplicationField . CREATE_TARGET , createTarget ) ; replicationInternal . setCreateTarget ( createTarget ) ; } | Set whether the target database be created if it doesn t already exist? |
11,714 | public void changed ( ChangeEvent event ) { final long lastSeqPushed = ( isPull ( ) || replicationInternal . lastSequence == null ) ? - 1L : Long . valueOf ( replicationInternal . lastSequence ) ; if ( lastSeqPushed >= 0 && lastSeqPushed != _lastSequencePushed ) { db . runAsync ( new AsyncTask ( ) { public void run ( Database database ) { synchronized ( _lockPendingDocIDs ) { _lastSequencePushed = lastSeqPushed ; _pendingDocIDs = null ; } } } ) ; } for ( ChangeListener changeListener : changeListeners ) { try { changeListener . changed ( event ) ; } catch ( Exception e ) { Log . e ( Log . TAG_SYNC , "Exception calling changeListener.changed" , e ) ; } } } | This is called back for changes from the ReplicationInternal . Simply propagate the events back to all listeners . |
11,715 | public void setFilter ( String filterName ) { properties . put ( ReplicationField . FILTER_NAME , filterName ) ; replicationInternal . setFilter ( filterName ) ; } | Set the filter to be used by this replication |
11,716 | public void setDocIds ( List < String > docIds ) { properties . put ( ReplicationField . DOC_IDS , docIds ) ; replicationInternal . setDocIds ( docIds ) ; } | Sets the documents to specify as part of the replication . |
11,717 | public void setFilterParams ( Map < String , Object > filterParams ) { properties . put ( ReplicationField . FILTER_PARAMS , filterParams ) ; replicationInternal . setFilterParams ( filterParams ) ; } | Set parameters to pass to the filter function . |
11,718 | public void setChannels ( List < String > channels ) { properties . put ( ReplicationField . CHANNELS , channels ) ; replicationInternal . setChannels ( channels ) ; } | Set the list of Sync Gateway channel names |
11,719 | private void initWithKey ( byte [ ] key ) throws SymmetricKeyException { if ( key == null ) throw new SymmetricKeyException ( "Key cannot be null" ) ; if ( key . length != KEY_SIZE ) throw new SymmetricKeyException ( "Key size is not " + KEY_SIZE + "bytes" ) ; keyData = key ; } | Initialize the object with a raw key of 32 bytes size . |
11,720 | public byte [ ] encryptData ( byte [ ] data ) throws SymmetricKeyException { Encryptor encryptor = createEncryptor ( ) ; byte [ ] encrypted = encryptor . encrypt ( data ) ; byte [ ] trailer = encryptor . encrypt ( null ) ; if ( encrypted == null || trailer == null ) throw new SymmetricKeyException ( "Cannot encrypt data" ) ; byte [ ] result = ArrayUtils . concat ( encrypted , trailer ) ; return result ; } | Encrypt the byte array data |
11,721 | private static byte [ ] generateKey ( int size ) throws SymmetricKeyException { if ( size <= 0 ) throw new IllegalArgumentException ( "Size cannot be zero or less than zero." ) ; try { SecureRandom secureRandom = new SecureRandom ( ) ; KeyGenerator keyGenerator = KeyGenerator . getInstance ( "AES" ) ; keyGenerator . init ( size * 8 , secureRandom ) ; return keyGenerator . generateKey ( ) . getEncoded ( ) ; } catch ( NoSuchAlgorithmException e ) { throw new SymmetricKeyException ( e ) ; } } | Generate an AES key of the specifies size in bytes . |
11,722 | private static byte [ ] secureRandom ( int size ) { if ( size <= 0 ) throw new IllegalArgumentException ( "Size cannot be zero or less than zero." ) ; SecureRandom secureRandom = new SecureRandom ( ) ; byte [ ] bytes = new byte [ size ] ; secureRandom . nextBytes ( bytes ) ; return bytes ; } | Secure random bytes of size in bytes |
11,723 | private Cipher getCipher ( int mode , byte [ ] iv ) throws SymmetricKeyException { Cipher cipher = null ; try { cipher = getCipherInstance ( "AES/CBC/PKCS7Padding" ) ; if ( cipher == null ) { throw new SymmetricKeyException ( "Cannot get a cipher instance for AES/CBC/PKCS7Padding algorithm" ) ; } SecretKey secret = new SecretKeySpec ( getKey ( ) , "AES" ) ; cipher . init ( mode , secret , new IvParameterSpec ( iv ) ) ; } catch ( InvalidKeyException e ) { throw new SymmetricKeyException ( "Couchbase Lite uses the AES 256-bit key to provide data encryption. " + "Please make sure you have installed 'Java Cryptography Extension (JCE) " + "Unlimited Strength Jurisdiction' Policy provided by Oracle." , e ) ; } catch ( SymmetricKeyException e ) { throw e ; } catch ( Exception e ) { throw new SymmetricKeyException ( e ) ; } return cipher ; } | Get a cipher instance for either encrypt or decrypt mode with an IV header . |
11,724 | private Cipher getCipherInstance ( String algorithm ) { Cipher cipher = null ; if ( ! useBCProvider ) { try { cipher = Cipher . getInstance ( algorithm ) ; } catch ( NoSuchAlgorithmException e ) { Log . v ( Log . TAG_SYMMETRIC_KEY , "Cannot find a cipher (no algorithm); will try with Bouncy Castle provider." ) ; } catch ( NoSuchPaddingException e ) { Log . v ( Log . TAG_SYMMETRIC_KEY , "Cannot find a cipher (no padding); will try with Bouncy Castle provider." ) ; } } if ( cipher == null ) { try { if ( Security . getProvider ( "BC" ) == null ) { try { Class bc = Class . forName ( "org.bouncycastle.jce.provider.BouncyCastleProvider" ) ; Security . addProvider ( ( Provider ) bc . newInstance ( ) ) ; } catch ( Exception e ) { Log . e ( Log . TAG_SYMMETRIC_KEY , "Cannot instantiate Bouncy Castle provider" , e ) ; return null ; } } cipher = Cipher . getInstance ( algorithm , "BC" ) ; useBCProvider = true ; } catch ( Exception e ) { Log . e ( Log . TAG_SYMMETRIC_KEY , "Cannot find a cipher with Bouncy Castle provider" , e ) ; } } return cipher ; } | Get a cipher instance for the algorithm . It will try to use the Cipher from the default security provider by the platform . If it couldn t find the cipher it will try to the cipher from the Bouncy Castle if the BouncyCastle library is available . |
11,725 | public synchronized long addValue ( String value ) { sequences . add ( ++ lastSequence ) ; values . add ( value ) ; return lastSequence ; } | Adds a value to the map assigning it a sequence number and returning it . Sequence numbers start at 1 and increment from there . |
11,726 | public synchronized long getCheckpointedSequence ( ) { long sequence = lastSequence ; if ( ! sequences . isEmpty ( ) ) { sequence = sequences . first ( ) - 1 ; } if ( sequence > firstValueSequence ) { int numToRemove = ( int ) ( sequence - firstValueSequence ) ; for ( int i = 0 ; i < numToRemove ; i ++ ) { values . remove ( 0 ) ; } firstValueSequence += numToRemove ; } return sequence ; } | Returns the maximum consecutively - removed sequence number . This is one less than the minimum remaining sequence number . |
11,727 | public synchronized String getCheckpointedValue ( ) { int index = ( int ) ( getCheckpointedSequence ( ) - firstValueSequence ) ; return ( index >= 0 ) ? values . get ( index ) : null ; } | Returns the value associated with the checkpointedSequence . |
11,728 | public static void serialize ( Serializable obj , ByteArrayOutputStream bout ) { try { ObjectOutputStream out = new ObjectOutputStream ( bout ) ; out . writeObject ( obj ) ; out . close ( ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Could not serialize " + obj , e ) ; } } | Serialize the given object into the given stream |
11,729 | public static List < String > readToList ( File f ) throws IOException { try ( final Reader reader = asReaderUTF8Lenient ( new FileInputStream ( f ) ) ) { return readToList ( reader ) ; } catch ( IOException ioe ) { throw new IllegalStateException ( String . format ( "Failed to read %s: %s" , f . getAbsolutePath ( ) , ioe ) , ioe ) ; } } | Read the file line for line and return the result in a list |
11,730 | public static List < String > readToList ( Reader r ) throws IOException { try ( BufferedReader in = new BufferedReader ( r ) ) { List < String > l = new ArrayList < > ( ) ; String line = null ; while ( ( line = in . readLine ( ) ) != null ) l . add ( line ) ; return Collections . unmodifiableList ( l ) ; } } | Read the Reader line for line and return the result in a list |
11,731 | public static String readFileToString ( File f ) throws IOException { StringWriter sw = new StringWriter ( ) ; IO . copyAndCloseBoth ( Common . asReaderUTF8Lenient ( new FileInputStream ( f ) ) , sw ) ; return sw . toString ( ) ; } | Read the contents of the given file into a string |
11,732 | public void appendToLog ( String logAppendMessage ) { ProfilingTimerNode currentNode = current . get ( ) ; if ( currentNode != null ) { currentNode . appendToLog ( logAppendMessage ) ; } } | Append the given string to the log message of the current subtask |
11,733 | public void mergeTree ( ProfilingTimerNode otherRoot ) { ProfilingTimerNode currentNode = current . get ( ) ; Preconditions . checkNotNull ( currentNode ) ; mergeOrAddNode ( currentNode , otherRoot ) ; } | Merges the specified tree as a child under the current node . |
11,734 | private static void writeToLog ( int level , long totalNanos , long count , ProfilingTimerNode parent , String taskName , Log log , String logAppendMessage ) { if ( log == null ) { return ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < level ; i ++ ) { sb . append ( '\t' ) ; } String durationText = String . format ( "%s%s" , formatElapsed ( totalNanos ) , count == 1 ? "" : String . format ( " across %d invocations, average: %s" , count , formatElapsed ( totalNanos / count ) ) ) ; String text = parent == null ? String . format ( "total time %s" , durationText ) : String . format ( "[%s] took %s" , taskName , durationText ) ; sb . append ( text ) ; sb . append ( logAppendMessage ) ; log . info ( sb . toString ( ) ) ; } | Writes one profiling line of information to the log |
11,735 | public static < T extends TBase > String serializeJson ( T obj ) throws TException { return new TSerializer ( new TJSONProtocol . Factory ( ) ) . toString ( obj , THRIFT_CHARSET ) ; } | Serialize a JSON - encoded thrift object |
11,736 | public static < T extends TBase > T deserializeJson ( T dest , String thriftJson ) throws TException { new TDeserializer ( new TJSONProtocol . Factory ( ) ) . deserialize ( dest , thriftJson , THRIFT_CHARSET ) ; return dest ; } | Deserialize a JSON - encoded thrift object |
11,737 | public static String sepList ( String sep , Iterable < ? > os , int max ) { return sepList ( sep , null , os , max ) ; } | Same as sepList with no wrapping |
11,738 | Word2VecModel train ( Log log , TrainingProgressListener listener , Iterable < List < String > > sentences ) throws InterruptedException { try ( ProfilingTimer timer = ProfilingTimer . createLoggingSubtasks ( log , "Training word2vec" ) ) { final Multiset < String > counts ; try ( AC ac = timer . start ( "Acquiring word frequencies" ) ) { listener . update ( Stage . ACQUIRE_VOCAB , 0.0 ) ; counts = ( vocab . isPresent ( ) ) ? vocab . get ( ) : count ( Iterables . concat ( sentences ) ) ; } final ImmutableMultiset < String > vocab ; try ( AC ac = timer . start ( "Filtering and sorting vocabulary" ) ) { listener . update ( Stage . FILTER_SORT_VOCAB , 0.0 ) ; vocab = filterAndSort ( counts ) ; } final Map < String , HuffmanNode > huffmanNodes ; try ( AC task = timer . start ( "Create Huffman encoding" ) ) { huffmanNodes = new HuffmanCoding ( vocab , listener ) . encode ( ) ; } final NeuralNetworkModel model ; try ( AC task = timer . start ( "Training model %s" , neuralNetworkConfig ) ) { model = neuralNetworkConfig . createTrainer ( vocab , huffmanNodes , listener ) . train ( sentences ) ; } return new Word2VecModel ( vocab . elementSet ( ) , model . layerSize ( ) , Doubles . concat ( model . vectors ( ) ) ) ; } } | Train a model using the given data |
11,739 | private void normalize ( ) { for ( int i = 0 ; i < vocab . size ( ) ; ++ i ) { double len = 0 ; for ( int j = i * layerSize ; j < ( i + 1 ) * layerSize ; ++ j ) len += vectors . get ( j ) * vectors . get ( j ) ; len = Math . sqrt ( len ) ; for ( int j = i * layerSize ; j < ( i + 1 ) * layerSize ; ++ j ) vectors . put ( j , vectors . get ( j ) / len ) ; } } | Normalizes the vectors in this model |
11,740 | protected void init ( ) throws IOException { if ( internalIn2 != null ) return ; String encoding ; byte bom [ ] = new byte [ BOM_SIZE ] ; int n , unread ; n = internalIn . read ( bom , 0 , bom . length ) ; if ( ( bom [ 0 ] == ( byte ) 0x00 ) && ( bom [ 1 ] == ( byte ) 0x00 ) && ( bom [ 2 ] == ( byte ) 0xFE ) && ( bom [ 3 ] == ( byte ) 0xFF ) ) { encoding = "UTF-32BE" ; unread = n - 4 ; } else if ( ( bom [ 0 ] == ( byte ) 0xFF ) && ( bom [ 1 ] == ( byte ) 0xFE ) && ( bom [ 2 ] == ( byte ) 0x00 ) && ( bom [ 3 ] == ( byte ) 0x00 ) ) { encoding = "UTF-32LE" ; unread = n - 4 ; } else if ( ( bom [ 0 ] == ( byte ) 0xEF ) && ( bom [ 1 ] == ( byte ) 0xBB ) && ( bom [ 2 ] == ( byte ) 0xBF ) ) { encoding = "UTF-8" ; unread = n - 3 ; } else if ( ( bom [ 0 ] == ( byte ) 0xFE ) && ( bom [ 1 ] == ( byte ) 0xFF ) ) { encoding = "UTF-16BE" ; unread = n - 2 ; } else if ( ( bom [ 0 ] == ( byte ) 0xFF ) && ( bom [ 1 ] == ( byte ) 0xFE ) ) { encoding = "UTF-16LE" ; unread = n - 2 ; } else { encoding = defaultEnc ; unread = n ; } if ( unread > 0 ) internalIn . unread ( bom , ( n - unread ) , unread ) ; if ( encoding == null ) { internalIn2 = new InputStreamReader ( internalIn ) ; } else if ( strict ) { internalIn2 = new InputStreamReader ( internalIn , Charset . forName ( encoding ) . newDecoder ( ) ) ; } else { internalIn2 = new InputStreamReader ( internalIn , encoding ) ; } } | Read - ahead four bytes and check for BOM . Extra bytes are unread back to the stream only BOM bytes are skipped . |
11,741 | public static File getDir ( File parent , String item ) { File dir = new File ( parent , item ) ; return ( dir . exists ( ) && dir . isDirectory ( ) ) ? dir : null ; } | Returns a subdirectory of a given directory ; the subdirectory is expected to already exist . |
11,742 | public static boolean deleteRecursive ( final File file ) { boolean result = true ; if ( file . isDirectory ( ) ) { for ( final File inner : file . listFiles ( ) ) { result &= deleteRecursive ( inner ) ; } } return result & file . delete ( ) ; } | Deletes a file or directory . If the file is a directory it recursively deletes it . |
11,743 | public static File createTempFile ( byte [ ] fileContents , String namePrefix , String extension ) throws IOException { Preconditions . checkNotNull ( fileContents , "file contents missing" ) ; File tempFile = File . createTempFile ( namePrefix , extension ) ; try ( FileOutputStream fos = new FileOutputStream ( tempFile ) ) { fos . write ( fileContents ) ; } return tempFile ; } | Stores the given contents into a temporary file |
11,744 | public static void demoWord ( ) throws IOException , TException , InterruptedException , UnknownWordException { File f = new File ( "text8" ) ; if ( ! f . exists ( ) ) throw new IllegalStateException ( "Please download and unzip the text8 example from http://mattmahoney.net/dc/text8.zip" ) ; List < String > read = Common . readToList ( f ) ; List < List < String > > partitioned = Lists . transform ( read , new Function < String , List < String > > ( ) { public List < String > apply ( String input ) { return Arrays . asList ( input . split ( " " ) ) ; } } ) ; Word2VecModel model = Word2VecModel . trainer ( ) . setMinVocabFrequency ( 5 ) . useNumThreads ( 20 ) . setWindowSize ( 8 ) . type ( NeuralNetworkType . CBOW ) . setLayerSize ( 200 ) . useNegativeSamples ( 25 ) . setDownSamplingRate ( 1e-4 ) . setNumIterations ( 5 ) . setListener ( new TrainingProgressListener ( ) { public void update ( Stage stage , double progress ) { System . out . println ( String . format ( "%s is %.2f%% complete" , Format . formatEnum ( stage ) , progress * 100 ) ) ; } } ) . train ( partitioned ) ; try ( ProfilingTimer timer = ProfilingTimer . create ( LOG , "Writing output to file" ) ) { FileUtils . writeStringToFile ( new File ( "text8.model" ) , ThriftUtils . serializeJson ( model . toThrift ( ) ) ) ; } try ( final OutputStream os = Files . newOutputStream ( Paths . get ( "text8.bin" ) ) ) { model . toBinFile ( os ) ; } interact ( model . forSearch ( ) ) ; } | Trains a model and allows user to find similar words demo - word . sh example from the open source C implementation |
11,745 | public static void loadModel ( ) throws IOException , TException , UnknownWordException { final Word2VecModel model ; try ( ProfilingTimer timer = ProfilingTimer . create ( LOG , "Loading model" ) ) { String json = Common . readFileToString ( new File ( "text8.model" ) ) ; model = Word2VecModel . fromThrift ( ThriftUtils . deserializeJson ( new Word2VecModelThrift ( ) , json ) ) ; } interact ( model . forSearch ( ) ) ; } | Loads a model and allows user to find similar words |
11,746 | public static void skipGram ( ) throws IOException , TException , InterruptedException , UnknownWordException { List < String > read = Common . readToList ( new File ( "sents.cleaned.word2vec.txt" ) ) ; List < List < String > > partitioned = Lists . transform ( read , new Function < String , List < String > > ( ) { public List < String > apply ( String input ) { return Arrays . asList ( input . split ( " " ) ) ; } } ) ; Word2VecModel model = Word2VecModel . trainer ( ) . setMinVocabFrequency ( 100 ) . useNumThreads ( 20 ) . setWindowSize ( 7 ) . type ( NeuralNetworkType . SKIP_GRAM ) . useHierarchicalSoftmax ( ) . setLayerSize ( 300 ) . useNegativeSamples ( 0 ) . setDownSamplingRate ( 1e-3 ) . setNumIterations ( 5 ) . setListener ( new TrainingProgressListener ( ) { public void update ( Stage stage , double progress ) { System . out . println ( String . format ( "%s is %.2f%% complete" , Format . formatEnum ( stage ) , progress * 100 ) ) ; } } ) . train ( partitioned ) ; try ( ProfilingTimer timer = ProfilingTimer . create ( LOG , "Writing output to file" ) ) { FileUtils . writeStringToFile ( new File ( "300layer.20threads.5iter.model" ) , ThriftUtils . serializeJson ( model . toThrift ( ) ) ) ; } interact ( model . forSearch ( ) ) ; } | Example using Skip - Gram model |
11,747 | private Catalogo copy ( Catalogo catalogo ) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory . newInstance ( ) ; dbf . setNamespaceAware ( true ) ; DocumentBuilder db = dbf . newDocumentBuilder ( ) ; Document doc = db . newDocument ( ) ; Marshaller m = context . createMarshaller ( ) ; m . marshal ( catalogo , doc ) ; Unmarshaller u = context . createUnmarshaller ( ) ; return ( Catalogo ) u . unmarshal ( doc ) ; } | Defensive deep - copy |
11,748 | private String [ ] findFeatureByScenarioName ( String scenarioName ) throws IllegalAccessException { List < Description > testClasses = findTestClassesLevel ( parentDescription . getChildren ( ) ) ; for ( Description testClass : testClasses ) { List < Description > features = findFeaturesLevel ( testClass . getChildren ( ) ) ; for ( Description feature : features ) { for ( Description story : feature . getChildren ( ) ) { Object scenarioType = getTestEntityType ( story ) ; if ( scenarioType instanceof Scenario && story . getDisplayName ( ) . equals ( scenarioName ) ) { return new String [ ] { feature . getDisplayName ( ) , scenarioName } ; } else if ( scenarioType instanceof ScenarioOutline ) { List < Description > examples = story . getChildren ( ) . get ( 0 ) . getChildren ( ) ; for ( Description example : examples ) { if ( example . getDisplayName ( ) . equals ( scenarioName ) ) { return new String [ ] { feature . getDisplayName ( ) , story . getDisplayName ( ) } ; } } } } } } return new String [ ] { "Feature: Undefined Feature" , scenarioName } ; } | Find feature and story for given scenario |
11,749 | Stories getStoriesAnnotation ( final String [ ] value ) { return new Stories ( ) { public String [ ] value ( ) { return value ; } public Class < Stories > annotationType ( ) { return Stories . class ; } } ; } | Creates Story annotation object |
11,750 | Features getFeaturesAnnotation ( final String [ ] value ) { return new Features ( ) { public String [ ] value ( ) { return value ; } public Class < Features > annotationType ( ) { return Features . class ; } } ; } | Creates Feature annotation object |
11,751 | public < E extends Enum < E > > List < E > getTypeList ( Class < E > clz , E [ ] typeList ) { if ( typeList . length > 0 ) { return new ArrayList < > ( Arrays . asList ( typeList ) ) ; } else { return new ArrayList < > ( EnumSet . allOf ( clz ) ) ; } } | Get a list of the enums passed |
11,752 | public ExternalID getPersonExternalIds ( int personId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , personId ) ; URL url = new ApiUrl ( apiKey , MethodBase . PERSON ) . subMethod ( MethodSub . EXTERNAL_IDS ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { return MAPPER . readValue ( webpage , ExternalID . class ) ; } catch ( IOException ex ) { throw new MovieDbException ( ApiExceptionType . MAPPING_FAILED , "Failed to get person external IDs" , url , ex ) ; } } | Get the external ids for a specific person id . |
11,753 | public ResultList < Artwork > getPersonImages ( int personId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , personId ) ; URL url = new ApiUrl ( apiKey , MethodBase . PERSON ) . subMethod ( MethodSub . IMAGES ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { WrapperImages wrapper = MAPPER . readValue ( webpage , WrapperImages . class ) ; ResultList < Artwork > results = new ResultList < > ( wrapper . getAll ( ArtworkType . PROFILE ) ) ; wrapper . setResultProperties ( results ) ; return results ; } catch ( IOException ex ) { throw new MovieDbException ( ApiExceptionType . MAPPING_FAILED , "Failed to get person images" , url , ex ) ; } } | Get the images for a specific person id . |
11,754 | public ResultList < PersonFind > getPersonPopular ( Integer page ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . PAGE , page ) ; URL url = new ApiUrl ( apiKey , MethodBase . PERSON ) . subMethod ( MethodSub . POPULAR ) . buildUrl ( parameters ) ; WrapperGenericList < PersonFind > wrapper = processWrapper ( getTypeReference ( PersonFind . class ) , url , "person popular" ) ; return wrapper . getResultsList ( ) ; } | Get the list of popular people on The Movie Database . |
11,755 | public List < Artwork > getAll ( ArtworkType ... artworkList ) { List < Artwork > artwork = new ArrayList < > ( ) ; List < ArtworkType > types ; if ( artworkList . length > 0 ) { types = new ArrayList < > ( Arrays . asList ( artworkList ) ) ; } else { types = new ArrayList < > ( Arrays . asList ( ArtworkType . values ( ) ) ) ; } if ( types . contains ( ArtworkType . POSTER ) ) { updateArtworkType ( posters , ArtworkType . POSTER ) ; artwork . addAll ( posters ) ; } if ( types . contains ( ArtworkType . BACKDROP ) ) { updateArtworkType ( backdrops , ArtworkType . BACKDROP ) ; artwork . addAll ( backdrops ) ; } if ( types . contains ( ArtworkType . PROFILE ) ) { updateArtworkType ( profiles , ArtworkType . PROFILE ) ; artwork . addAll ( profiles ) ; } if ( types . contains ( ArtworkType . STILL ) ) { updateArtworkType ( stills , ArtworkType . STILL ) ; artwork . addAll ( stills ) ; } return artwork ; } | Return a list of all the artwork with their types . |
11,756 | private void updateArtworkType ( List < Artwork > artworkList , ArtworkType type ) { for ( Artwork artwork : artworkList ) { artwork . setArtworkType ( type ) ; } } | Update the artwork type for the artwork list |
11,757 | public TokenAuthorisation getAuthorisationToken ( ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; URL url = new ApiUrl ( apiKey , MethodBase . AUTH ) . subMethod ( MethodSub . TOKEN_NEW ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { return MAPPER . readValue ( webpage , TokenAuthorisation . class ) ; } catch ( IOException ex ) { throw new MovieDbException ( ApiExceptionType . AUTH_FAILURE , "Failed to get Authorisation Token" , url , ex ) ; } } | This method is used to generate a valid request token for user based authentication . |
11,758 | public TokenSession getSessionToken ( TokenAuthorisation token ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; if ( ! token . getSuccess ( ) ) { throw new MovieDbException ( ApiExceptionType . AUTH_FAILURE , "Authorisation token was not successful!" ) ; } parameters . add ( Param . TOKEN , token . getRequestToken ( ) ) ; URL url = new ApiUrl ( apiKey , MethodBase . AUTH ) . subMethod ( MethodSub . SESSION_NEW ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { return MAPPER . readValue ( webpage , TokenSession . class ) ; } catch ( IOException ex ) { throw new MovieDbException ( ApiExceptionType . MAPPING_FAILED , "Failed to get Session Token" , url , ex ) ; } } | This method is used to generate a session id for user based authentication . |
11,759 | public TokenSession getGuestSessionToken ( ) throws MovieDbException { URL url = new ApiUrl ( apiKey , MethodBase . AUTH ) . subMethod ( MethodSub . GUEST_SESSION ) . buildUrl ( ) ; String webpage = httpTools . getRequest ( url ) ; try { return MAPPER . readValue ( webpage , TokenSession . class ) ; } catch ( IOException ex ) { throw new MovieDbException ( ApiExceptionType . MAPPING_FAILED , "Failed to get Guest Session Token" , url , ex ) ; } } | This method is used to generate a guest session id . |
11,760 | private void initialise ( String apiKey , HttpTools httpTools ) { tmdbAccount = new TmdbAccount ( apiKey , httpTools ) ; tmdbAuth = new TmdbAuthentication ( apiKey , httpTools ) ; tmdbCertifications = new TmdbCertifications ( apiKey , httpTools ) ; tmdbChanges = new TmdbChanges ( apiKey , httpTools ) ; tmdbCollections = new TmdbCollections ( apiKey , httpTools ) ; tmdbCompany = new TmdbCompanies ( apiKey , httpTools ) ; tmdbConfiguration = new TmdbConfiguration ( apiKey , httpTools ) ; tmdbCredits = new TmdbCredits ( apiKey , httpTools ) ; tmdbDiscover = new TmdbDiscover ( apiKey , httpTools ) ; tmdbFind = new TmdbFind ( apiKey , httpTools ) ; tmdbGenre = new TmdbGenres ( apiKey , httpTools ) ; tmdbKeywords = new TmdbKeywords ( apiKey , httpTools ) ; tmdbList = new TmdbLists ( apiKey , httpTools ) ; tmdbMovies = new TmdbMovies ( apiKey , httpTools ) ; tmdbNetworks = new TmdbNetworks ( apiKey , httpTools ) ; tmdbPeople = new TmdbPeople ( apiKey , httpTools ) ; tmdbReviews = new TmdbReviews ( apiKey , httpTools ) ; tmdbSearch = new TmdbSearch ( apiKey , httpTools ) ; tmdbTv = new TmdbTV ( apiKey , httpTools ) ; tmdbSeasons = new TmdbSeasons ( apiKey , httpTools ) ; tmdbEpisodes = new TmdbEpisodes ( apiKey , httpTools ) ; } | Initialise the sub - classes once the API key and http client are known |
11,761 | public ResultList < MovieBasic > getFavoriteMovies ( String sessionId , int accountId ) throws MovieDbException { return tmdbAccount . getFavoriteMovies ( sessionId , accountId ) ; } | Get the account favourite movies |
11,762 | public StatusCode modifyFavoriteStatus ( String sessionId , int accountId , Integer mediaId , MediaType mediaType , boolean isFavorite ) throws MovieDbException { return tmdbAccount . modifyFavoriteStatus ( sessionId , accountId , mediaType , mediaId , isFavorite ) ; } | Add or remove a movie to an accounts favourite list . |
11,763 | public ResultList < TVBasic > getWatchListTV ( String sessionId , int accountId , Integer page , String sortBy , String language ) throws MovieDbException { return tmdbAccount . getWatchListTV ( sessionId , accountId , page , sortBy , language ) ; } | Get the list of movies on an accounts watchlist . |
11,764 | public StatusCode addToWatchList ( String sessionId , int accountId , MediaType mediaType , Integer mediaId ) throws MovieDbException { return tmdbAccount . modifyWatchList ( sessionId , accountId , mediaType , mediaId , true ) ; } | Add a movie to an accounts watch list . |
11,765 | public StatusCode removeFromWatchList ( String sessionId , int accountId , MediaType mediaType , Integer mediaId ) throws MovieDbException { return tmdbAccount . modifyWatchList ( sessionId , accountId , mediaType , mediaId , false ) ; } | Remove a movie from an accounts watch list . |
11,766 | public ResultList < TVBasic > getFavoriteTv ( String sessionId , int accountId ) throws MovieDbException { return tmdbAccount . getFavoriteTv ( sessionId , accountId ) ; } | Get the list of favorite TV series for an account . |
11,767 | public ResultList < ChangeListItem > getMovieChangeList ( Integer page , String startDate , String endDate ) throws MovieDbException { return tmdbChanges . getChangeList ( MethodBase . MOVIE , page , startDate , endDate ) ; } | Get a list of Movie IDs that have been edited . |
11,768 | public ResultList < ChangeListItem > getTvChangeList ( Integer page , String startDate , String endDate ) throws MovieDbException { return tmdbChanges . getChangeList ( MethodBase . TV , page , startDate , endDate ) ; } | Get a list of TV IDs that have been edited . |
11,769 | public ResultList < ChangeListItem > getPersonChangeList ( Integer page , String startDate , String endDate ) throws MovieDbException { return tmdbChanges . getChangeList ( MethodBase . PERSON , page , startDate , endDate ) ; } | Get a list of PersonInfo IDs that have been edited . |
11,770 | public ResultList < MovieBasic > getGenreMovies ( int genreId , String language , Integer page , Boolean includeAllMovies , Boolean includeAdult ) throws MovieDbException { return tmdbGenre . getGenreMovies ( genreId , language , page , includeAllMovies , includeAdult ) ; } | Get a list of movies per genre . |
11,771 | public boolean checkItemStatus ( String listId , Integer mediaId ) throws MovieDbException { return tmdbList . checkItemStatus ( listId , mediaId ) ; } | Check to see if an item is already on a list . |
11,772 | public StatusCode removeItemFromList ( String sessionId , String listId , Integer mediaId ) throws MovieDbException { return tmdbList . removeItem ( sessionId , listId , mediaId ) ; } | This method lets users remove items from a list that they created . |
11,773 | public ResultList < Video > getMovieVideos ( int movieId , String language ) throws MovieDbException { return tmdbMovies . getMovieVideos ( movieId , language ) ; } | This method is used to retrieve all of the trailers for a particular movie . |
11,774 | public ResultList < Review > getMovieReviews ( int movieId , Integer page , String language ) throws MovieDbException { return tmdbMovies . getMovieReviews ( movieId , page , language ) ; } | Get the reviews for a particular movie id . |
11,775 | public ResultList < UserList > getMovieLists ( int movieId , Integer page , String language ) throws MovieDbException { return tmdbMovies . getMovieLists ( movieId , page , language ) ; } | Get the lists that the movie belongs to |
11,776 | public ResultList < MovieInfo > getTopRatedMovies ( Integer page , String language ) throws MovieDbException { return tmdbMovies . getTopRatedMovies ( page , language ) ; } | This method is used to retrieve the top rated movies that have over 10 votes on TMDb . |
11,777 | public PersonCreditList < CreditTVBasic > getPersonTVCredits ( int personId , String language ) throws MovieDbException { return tmdbPeople . getPersonTVCredits ( personId , language ) ; } | Get the TV credits for a specific person id . |
11,778 | public ResultList < ChangeKeyItem > getPersonChanges ( int personId , String startDate , String endDate ) throws MovieDbException { return tmdbPeople . getPersonChanges ( personId , startDate , endDate ) ; } | Get the changes for a specific person id . |
11,779 | public ResultList < Keyword > searchKeyword ( String query , Integer page ) throws MovieDbException { return tmdbSearch . searchKeyword ( query , page ) ; } | Search for keywords by name |
11,780 | public MediaState getTVAccountState ( int tvID , String sessionID ) throws MovieDbException { return tmdbTv . getTVAccountState ( tvID , sessionID ) ; } | This method lets users get the status of whether or not the TV show has been rated or added to their favourite or watch lists . |
11,781 | public ExternalID getTVExternalIDs ( int tvID , String language ) throws MovieDbException { return tmdbTv . getTVExternalIDs ( tvID , language ) ; } | Get the external ids that we have stored for a TV series . |
11,782 | public StatusCode postTVRating ( int tvID , int rating , String sessionID , String guestSessionID ) throws MovieDbException { return tmdbTv . postTVRating ( tvID , rating , sessionID , guestSessionID ) ; } | This method lets users rate a TV show . |
11,783 | public ResultList < TVInfo > getTVSimilar ( int tvID , Integer page , String language ) throws MovieDbException { return tmdbTv . getTVSimilar ( tvID , page , language ) ; } | Get the similar TV shows for a specific tv id . |
11,784 | public ResultList < TVInfo > getTVOnTheAir ( Integer page , String language ) throws MovieDbException { return tmdbTv . getTVOnTheAir ( page , language ) ; } | Get the list of TV shows that are currently on the air . |
11,785 | public ResultList < TVInfo > getTVAiringToday ( Integer page , String language , String timezone ) throws MovieDbException { return tmdbTv . getTVAiringToday ( page , language , timezone ) ; } | Get the list of TV shows that air today . |
11,786 | public ExternalID getSeasonExternalID ( int tvID , int seasonNumber , String language ) throws MovieDbException { return tmdbSeasons . getSeasonExternalID ( tvID , seasonNumber , language ) ; } | Get the external ids that we have stored for a TV season by season number . |
11,787 | public ResultList < Artwork > getSeasonImages ( int tvID , int seasonNumber , String language , String ... includeImageLanguage ) throws MovieDbException { return tmdbSeasons . getSeasonImages ( tvID , seasonNumber , language , includeImageLanguage ) ; } | Get the images that we have stored for a TV season by season number . |
11,788 | public MediaCreditList getEpisodeCredits ( int tvID , int seasonNumber , int episodeNumber ) throws MovieDbException { return tmdbEpisodes . getEpisodeCredits ( tvID , seasonNumber , episodeNumber ) ; } | Get the TV episode credits by combination of season and episode number . |
11,789 | public ExternalID getEpisodeExternalID ( int tvID , int seasonNumber , int episodeNumber , String language ) throws MovieDbException { return tmdbEpisodes . getEpisodeExternalID ( tvID , seasonNumber , episodeNumber , language ) ; } | Get the external ids for a TV episode by comabination of a season and episode number . |
11,790 | public ResultsMap < String , List < Certification > > getMoviesCertification ( ) throws MovieDbException { URL url = new ApiUrl ( apiKey , MethodBase . CERTIFICATION ) . subMethod ( MethodSub . MOVIE_LIST ) . buildUrl ( ) ; String webpage = httpTools . getRequest ( url ) ; try { JsonNode node = MAPPER . readTree ( webpage ) ; Map < String , List < Certification > > results = MAPPER . readValue ( node . elements ( ) . next ( ) . traverse ( ) , new TypeReference < Map < String , List < Certification > > > ( ) { } ) ; return new ResultsMap < > ( results ) ; } catch ( IOException ex ) { throw new MovieDbException ( ApiExceptionType . MAPPING_FAILED , "Failed to get movie certifications" , url , ex ) ; } } | Get a list of movies certification . |
11,791 | private static boolean compareTitles ( String primaryTitle , String firstCompareTitle , String secondCompareTitle , int maxDistance ) { if ( compareDistance ( primaryTitle , firstCompareTitle , maxDistance ) ) { return true ; } return compareDistance ( primaryTitle , secondCompareTitle , maxDistance ) ; } | Compare a title with two other titles . |
11,792 | public static boolean movies ( final MovieInfo moviedb , final String title , final String year , int maxDistance ) { return Compare . movies ( moviedb , title , year , maxDistance , true ) ; } | Compare the MovieDB object with a title and year case sensitive |
11,793 | private static boolean compareDistance ( final String title1 , final String title2 , int distance ) { return StringUtils . getLevenshteinDistance ( title1 , title2 ) <= distance ; } | Compare the Levenshtein Distance between the two strings |
11,794 | public MediaCreditList getMovieCredits ( int movieId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , movieId ) ; URL url = new ApiUrl ( apiKey , MethodBase . MOVIE ) . subMethod ( MethodSub . CREDITS ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { return MAPPER . readValue ( webpage , MediaCreditList . class ) ; } catch ( IOException ex ) { throw new MovieDbException ( ApiExceptionType . MAPPING_FAILED , "Failed to get credits" , url , ex ) ; } } | Get the cast and crew information for a specific movie id . |
11,795 | public ResultList < Keyword > getMovieKeywords ( int movieId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , movieId ) ; URL url = new ApiUrl ( apiKey , MethodBase . MOVIE ) . subMethod ( MethodSub . KEYWORDS ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { WrapperMovieKeywords wrapper = MAPPER . readValue ( webpage , WrapperMovieKeywords . class ) ; ResultList < Keyword > results = new ResultList < > ( wrapper . getKeywords ( ) ) ; wrapper . setResultProperties ( results ) ; return results ; } catch ( IOException ex ) { throw new MovieDbException ( ApiExceptionType . MAPPING_FAILED , "Failed to get keywords" , url , ex ) ; } } | This method is used to retrieve all of the keywords that have been added to a particular movie . |
11,796 | public ResultList < MovieInfo > getRecommendations ( int movieId , String language ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , movieId ) ; parameters . add ( Param . LANGUAGE , language ) ; URL url = new ApiUrl ( apiKey , MethodBase . MOVIE ) . subMethod ( MethodSub . RECOMMENDATIONS ) . buildUrl ( parameters ) ; WrapperGenericList < MovieInfo > wrapper = processWrapper ( getTypeReference ( MovieInfo . class ) , url , "recommendations" ) ; return wrapper . getResultsList ( ) ; } | The recommendations method will let you retrieve the movie recommendations for a particular movie . |
11,797 | public ResultList < ReleaseDates > getReleaseDates ( int movieId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , movieId ) ; URL url = new ApiUrl ( apiKey , MethodBase . MOVIE ) . subMethod ( MethodSub . RELEASE_DATES ) . buildUrl ( parameters ) ; WrapperGenericList < ReleaseDates > wrapper = processWrapper ( getTypeReference ( ReleaseDates . class ) , url , "release dates" ) ; return wrapper . getResultsList ( ) ; } | Get the release dates certifications and related information by country for a specific movie id . |
11,798 | public ResultList < Translation > getMovieTranslations ( int movieId ) throws MovieDbException { TmdbParameters parameters = new TmdbParameters ( ) ; parameters . add ( Param . ID , movieId ) ; URL url = new ApiUrl ( apiKey , MethodBase . MOVIE ) . subMethod ( MethodSub . TRANSLATIONS ) . buildUrl ( parameters ) ; String webpage = httpTools . getRequest ( url ) ; try { WrapperTranslations wrapper = MAPPER . readValue ( webpage , WrapperTranslations . class ) ; ResultList < Translation > results = new ResultList < > ( wrapper . getTranslations ( ) ) ; wrapper . setResultProperties ( results ) ; return results ; } catch ( IOException ex ) { throw new MovieDbException ( ApiExceptionType . MAPPING_FAILED , "Failed to get translations" , url , ex ) ; } } | This method is used to retrieve a list of the available translations for a specific movie . |
11,799 | public ResultList < ChangeKeyItem > getMovieChanges ( int movieId , String startDate , String endDate ) throws MovieDbException { return getMediaChanges ( movieId , startDate , endDate ) ; } | Get the changes for a specific movie ID . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.