idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
41,200
public static Dictionary read ( URL dictURL ) throws IOException { final URL expectedMetadataURL ; try { String external = dictURL . toExternalForm ( ) ; expectedMetadataURL = new URL ( DictionaryMetadata . getExpectedMetadataFileName ( external ) ) ; } catch ( MalformedURLException e ) { throw new IOException ( "Could...
Attempts to load a dictionary using the URL to the FSA file and the expected metadata extension .
41,201
public static Dictionary read ( InputStream fsaStream , InputStream metadataStream ) throws IOException { return new Dictionary ( FSA . read ( fsaStream ) , DictionaryMetadata . read ( metadataStream ) ) ; }
Attempts to load a dictionary from opened streams of FSA dictionary data and associated metadata . Input streams are not closed automatically .
41,202
public void set ( final int i , final int j , final int val ) { p [ ( j - i + editDistance + 1 ) * rowLength + j ] = val ; }
Set an item in hMatrix . No checking for i &amp ; j is done . They must be correct .
41,203
private final ByteBuffer advance ( ) { if ( position == 0 ) { return null ; } while ( position > 0 ) { final int lastIndex = position - 1 ; final int arc = arcs [ lastIndex ] ; if ( arc == 0 ) { position -- ; continue ; } arcs [ lastIndex ] = fsa . getNextArc ( arc ) ; final int bufferLength = this . buffer . length ; ...
Advances to the next available final state .
41,204
private void pushNode ( int node ) { if ( position == arcs . length ) { arcs = Arrays . copyOf ( arcs , arcs . length + EXPECTED_MAX_STATES ) ; } arcs [ position ++ ] = fsa . getFirstArc ( node ) ; }
Descends to a given node adds its arcs to the stack to be traversed .
41,205
public static FSAHeader read ( InputStream in ) throws IOException { if ( in . read ( ) != ( ( FSA_MAGIC >>> 24 ) ) || in . read ( ) != ( ( FSA_MAGIC >>> 16 ) & 0xff ) || in . read ( ) != ( ( FSA_MAGIC >>> 8 ) & 0xff ) || in . read ( ) != ( ( FSA_MAGIC ) & 0xff ) ) { throw new IOException ( "Invalid file header, probab...
Read FSA header and version from a stream consuming read bytes .
41,206
public static void write ( OutputStream os , byte version ) throws IOException { os . write ( FSA_MAGIC >> 24 ) ; os . write ( FSA_MAGIC >> 16 ) ; os . write ( FSA_MAGIC >> 8 ) ; os . write ( FSA_MAGIC ) ; os . write ( version ) ; }
Writes FSA magic bytes and version information .
41,207
static final int decodeFromBytes ( final byte [ ] arcs , final int start , final int n ) { int r = 0 ; for ( int i = n ; -- i >= 0 ; ) { r = r << 8 | ( arcs [ start + i ] & 0xff ) ; } return r ; }
Returns an n - byte integer encoded in byte - packed representation .
41,208
protected static void main ( String [ ] args , CliTool ... commands ) { if ( commands . length == 1 ) { main ( args , commands [ 0 ] ) ; } else { JCommander jc = new JCommander ( ) ; for ( CliTool command : commands ) { jc . addCommand ( command ) ; } jc . addConverterFactory ( new CustomParameterConverters ( ) ) ; jc ...
Parse and execute one of the commands .
41,209
protected static void main ( String [ ] args , CliTool command ) { JCommander jc = new JCommander ( command ) ; jc . addConverterFactory ( new CustomParameterConverters ( ) ) ; jc . setProgramName ( command . getClass ( ) . getAnnotation ( Parameters . class ) . commandNames ( ) [ 0 ] ) ; ExitStatus exitStatus = ExitSt...
Parse and execute a single command .
41,210
static String byteAsChar ( byte v ) { int chr = v & 0xff ; return String . format ( Locale . ROOT , "%s (0x%02x)" , ( Character . isWhitespace ( chr ) || chr > 127 ) ? "[non-printable]" : Character . toString ( ( char ) chr ) , v & 0xFF ) ; }
Convert a byte to an informative string .
41,211
public static FSA read ( InputStream stream ) throws IOException { final FSAHeader header = FSAHeader . read ( stream ) ; switch ( header . version ) { case FSA5 . VERSION : return new FSA5 ( stream ) ; case CFSA . VERSION : return new CFSA ( stream ) ; case CFSA2 . VERSION : return new CFSA2 ( stream ) ; default : thr...
A factory for reading automata in any of the supported versions .
41,212
public static < T extends FSA > T read ( InputStream stream , Class < ? extends T > clazz ) throws IOException { FSA fsa = read ( stream ) ; if ( ! clazz . isInstance ( fsa ) ) { throw new IOException ( String . format ( Locale . ROOT , "Expected FSA type %s, but read an incompatible type %s." , clazz . getName ( ) , f...
A factory for reading a specific FSA subclass including proper casting .
41,213
private static int forAllLines ( InputStream is , byte separator , LineConsumer lineConsumer ) throws IOException { int lines = 0 ; byte [ ] buffer = new byte [ 0 ] ; int b , pos = 0 ; while ( ( b = is . read ( ) ) != - 1 ) { if ( b == separator ) { buffer = lineConsumer . process ( buffer , pos ) ; pos = 0 ; lines ++ ...
Read all byte - separated sequences .
41,214
public static NtlmPasswordAuthentication authenticate ( HttpServletRequest req , HttpServletResponse resp , byte [ ] challenge ) throws IOException , ServletException { String msg = req . getHeader ( "Authorization" ) ; if ( msg != null && msg . startsWith ( "NTLM " ) ) { byte [ ] src = Base64 . decode ( msg . substrin...
Performs NTLM authentication for the servlet request .
41,215
boolean verify ( byte [ ] data , int offset , ServerMessageBlock response ) { update ( macSigningKey , 0 , macSigningKey . length ) ; int index = offset ; update ( data , index , ServerMessageBlock . SIGNATURE_OFFSET ) ; index += ServerMessageBlock . SIGNATURE_OFFSET ; byte [ ] sequence = new byte [ 8 ] ; ServerMessage...
Performs MAC signature verification . This calculates the signature of the SMB and compares it to the signature field on the SMB itself .
41,216
public static String encode ( byte [ ] bytes ) { int length = bytes . length ; if ( length == 0 ) return "" ; StringBuffer buffer = new StringBuffer ( ( int ) Math . ceil ( ( double ) length / 3d ) * 4 ) ; int remainder = length % 3 ; length -= remainder ; int block ; int i = 0 ; while ( i < length ) { block = ( ( byte...
Base - 64 encodes the supplied block of data . Line wrapping is not applied on output .
41,217
public static byte [ ] decode ( String string ) { int length = string . length ( ) ; if ( length == 0 ) return new byte [ 0 ] ; int pad = ( string . charAt ( length - 2 ) == '=' ) ? 2 : ( string . charAt ( length - 1 ) == '=' ) ? 1 : 0 ; int size = length * 3 / 4 - pad ; byte [ ] buffer = new byte [ size ] ; int block ...
Decodes the supplied Base - 64 encoded string .
41,218
public Post reblog ( String blogName , Map < String , ? > options ) { return client . postReblog ( blogName , id , reblog_key , options ) ; }
Reblog this post
41,219
public void setDate ( Date date ) { DateFormat df = new SimpleDateFormat ( "yyyy/MM/dd HH:mm:ss" ) ; df . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; setDate ( df . format ( date ) ) ; }
Set the date as a date
41,220
public void addTag ( String tag ) { if ( this . tags == null ) { tags = new ArrayList < String > ( ) ; } this . tags . add ( tag ) ; }
Add a tag
41,221
public void save ( ) throws IOException { if ( id == null ) { this . id = client . postCreate ( blog_name , detail ( ) ) ; } else { client . postEdit ( blog_name , id , detail ( ) ) ; } }
Save this post
41,222
protected Map < String , Object > detail ( ) { final Map < String , Object > map = new HashMap < String , Object > ( ) ; map . put ( "state" , state ) ; map . put ( "tags" , getTagString ( ) ) ; map . put ( "format" , format ) ; map . put ( "slug" , slug ) ; map . put ( "date" , date ) ; map . put ( "type" , getType ( ...
Detail for this post
41,223
public void setPhoto ( Photo photo ) { PhotoType type = photo . getType ( ) ; if ( postType != null && ! postType . equals ( type ) ) { throw new IllegalArgumentException ( "Photos must all be the same type (source or data)" ) ; } else if ( postType == PhotoType . SOURCE && pendingPhotos . size ( ) > 0 ) { throw new Il...
Set the photo for this post
41,224
public List < Blog > getBlogs ( ) { if ( blogs != null ) { for ( Blog blog : blogs ) { blog . setClient ( client ) ; } } return this . blogs ; }
Get the blog List for this user
41,225
private void extractErrors ( JsonObject object ) { JsonObject response ; try { response = object . getAsJsonObject ( "response" ) ; } catch ( ClassCastException ex ) { return ; } if ( response == null ) { return ; } JsonArray e = response . getAsJsonArray ( "errors" ) ; if ( e == null ) { return ; } errors = new ArrayL...
Pull the errors out of the response if present
41,226
private void extractMessage ( JsonObject object ) { JsonObject meta = object . getAsJsonObject ( "meta" ) ; if ( meta != null ) { JsonPrimitive msg = meta . getAsJsonPrimitive ( "msg" ) ; if ( msg != null ) { this . message = msg . getAsString ( ) ; return ; } } JsonPrimitive error = object . getAsJsonPrimitive ( "erro...
Pull the message out of the response
41,227
public void xauth ( final String email , final String password ) { setToken ( this . requestBuilder . postXAuth ( email , password ) ) ; }
Performs an XAuth authentication .
41,228
public List < Post > userDashboard ( Map < String , ? > options ) { return requestBuilder . get ( "/user/dashboard" , options ) . getPosts ( ) ; }
Get the user dashboard for the authenticated User
41,229
public List < Blog > userFollowing ( Map < String , ? > options ) { return requestBuilder . get ( "/user/following" , options ) . getBlogs ( ) ; }
Get the blogs the given user is following