signature:
public class AccessControlManagerImpl { /** * Content Tokens activate ACEs for a user that holds the content token . The
 * token is signed by the secret key associated with the target Object / acl
 * and the token is token content item is then returned for the caller to
 * save . */
public void signContentToken ( Content token , String securityZone , String objectPath ) throws StorageClientException , AccessDeniedException { } }

implementation:
long t = System . currentTimeMillis ( ) ; try { checkOpen ( ) ; check ( Security . ZONE_CONTENT , objectPath , Permissions . CAN_WRITE_ACL ) ; check ( Security . ZONE_CONTENT , objectPath , Permissions . CAN_READ_ACL ) ; String key = this . getAclKey ( securityZone , objectPath ) ; Map < String , Object > currentAcl = getCached ( keySpace , aclColumnFamily , key ) ; String secretKey = ( String ) currentAcl . get ( _SECRET_KEY ) ; principalTokenValidator . signToken ( token , secretKey ) ; // the caller must save the target .
} finally { statsService . apiCall ( AccessControlManagerImpl . class . getName ( ) , "signContentToken" , System . currentTimeMillis ( ) - t ) ; }


signature:
public class CollectionUtilities { /** * Take key and value pairs from source and create map from value to key in target . */
public static < K , V > void reverse ( Map < K , V > source , Map < V , K > target ) { } }

implementation: Iterator < K > i = source . keySet ( ) . iterator ( ) ; while ( i . hasNext ( ) ) { K key = i . next ( ) ; V value = source . get ( key ) ; target . put ( value , key ) ; }


signature:
public class CollectionUtilities { /** * New empty collection with similar type to source . The known concrete types replicated exactly are
 * { @ link ArrayList } , { @ link LinkedList } , { @ link TreeSet } , { @ link HashSet } , { @ link Stack } , { @ link Stack } ,
 * { @ link PriorityQueue } , { @ link LinkedHashSet } , { @ link Vector } .
 * Otherwise , the method only guarantees common conformance to one of the abstractions
 * { @ link Queue } , { @ link SortedSet } , { @ link Set } , { @ link List } . */
public static < T > Collection < T > like ( Collection < T > source ) { } }

implementation:
// known concrete types
if ( source instanceof FilterableArrayList ) return new FilterableArrayList ( ) ; if ( source instanceof ArrayList ) return new ArrayList ( ) ; if ( source instanceof LinkedList ) return new LinkedList ( ) ; if ( source instanceof TreeSet ) return new TreeSet ( ( ( TreeSet ) source ) . comparator ( ) ) ; if ( source instanceof LinkedHashSet ) return new LinkedHashSet ( ) ; if ( source instanceof HashSet ) return new HashSet ( ) ; if ( source instanceof Stack ) return new Stack ( ) ; if ( source instanceof PriorityQueue ) return new PriorityQueue ( 10 , ( ( PriorityQueue ) source ) . comparator ( ) ) ; if ( source instanceof Vector ) return new Vector ( ) ; // known abstract types
if ( source instanceof Queue ) return new LinkedList ( ) ; if ( source instanceof SortedSet ) return new TreeSet ( ( ( SortedSet ) source ) . comparator ( ) ) ; if ( source instanceof Set ) return new HashSet ( ) ; if ( source instanceof List ) return new ArrayList ( ) ; throw new IllegalArgumentException ( "Unknown collection type " + source . getClass ( ) . getCanonicalName ( ) ) ;


signature:
public class CartesianProduct { /** * Creates Cartesian product of two lists . */
private Set < R > multiplication ( ) { } }

implementation: final Set < R > answer = new LinkedHashSet < > ( this . one . size ( ) * this . two . size ( ) ) ; for ( final A left : this . one ) { for ( final B right : this . two ) { final R element = this . function . apply ( left , right ) ; if ( answer . contains ( element ) ) { throw new IllegalStateException ( String . format ( "Cartesian product result contains duplicated element %s" , element ) ) ; } answer . add ( element ) ; } } return ImmutableSet . copyOf ( answer ) ;


signature:
public class WorkerThread { /** * Sets the thread running */
@ Override public synchronized void start ( ) { } }

implementation: if ( ! running && ! used ) { this . running = true ; this . used = true ; this . setDaemon ( true ) ; super . start ( ) ; }


signature:
public class WorkerThread { /** * execute
 * @ param clsName
 * @ param methName
 * @ param params
 * @ param synObj */
public synchronized void execute ( Runnable runnable , Object synObj ) { } }

implementation:
this . runnable = runnable ; this . syncObject = synObj ; if ( ! running ) { // If this is the first time , then kick off the thread .
start ( ) ; } else { // we already have a thread running so wakeup the waiting thread .
this . notifyAll ( ) ; }


signature:
public class WorkerThread { /** * / * ( non - Javadoc )
 * @ see java . lang . Runnable # run ( ) */
@ Override public void run ( ) { } }

implementation:
while ( running ) { Runnable _runnable = null ; synchronized ( this ) { while ( running && runnable == null ) { try { this . wait ( ) ; } catch ( InterruptedException e ) { } // Ignore , as interrupts are not used by the pool itself
} _runnable = runnable ; } if ( _runnable != null ) { try { _runnable . run ( ) ; } catch ( Exception e ) { log . error ( "" , e ) ; } finally { synchronized ( this ) { if ( syncObject != null ) { synchronized ( syncObject ) { syncObject . notify ( ) ; } } reset ( ) ; returnToPool ( ) ; } } } }


signature:
public class WorkerThread { /** * Returns the thread to the pool . */
private void returnToPool ( ) { } }

implementation: if ( pool != null ) { try { pool . returnObject ( this ) ; } catch ( Exception e1 ) { log . error ( "Exception :" , e1 ) ; } this . pool = null ; }


signature:
public class SynchronizedBidiMap { /** * Factory method to create a synchronized map .
 * @ param map the map to decorate , must not be null
 * @ throws IllegalArgumentException if map is null */
public static < K , V > BidiMap < K , V > decorate ( BidiMap < K , V > map ) { } }

implementation: return new SynchronizedBidiMap < K , V > ( map ) ;


signature:
public class EndedEvent { /** * creates a new EndedEvent
 * @ param source the caller
 * @ return the optional StartMusicRequest */
public static Optional < EndedEvent > createEndedEvent ( Identification source ) { } }

implementation: try { EndedEvent stopRequest = new EndedEvent ( source ) ; return Optional . of ( stopRequest ) ; } catch ( IllegalArgumentException e ) { return Optional . empty ( ) ; }


signature:
public class Playlist { /** * returns the current played track or null
 * @ return an instance of TrackInfo */
public TrackInfo getCurrent ( ) { } }

implementation: TrackInfo trackInfo = null ; try { trackInfo = queue . get ( position ) ; } catch ( IndexOutOfBoundsException e ) { trackInfo = null ; } return trackInfo ;


signature:
public class Playlist { /** * gets the name ( optional )
 * playlist doesn ' t need to have a name
 * @ return the optional name */
public Optional < String > getName ( ) { } }

implementation: if ( name == null ) { return Optional . empty ( ) ; } else { return Optional . of ( name ) ; }


signature:
public class Playlist { /** * returns the associated data ( not really specified , specified by implementation )
 * @ return the optional data - element */
public Optional < String > getData ( ) { } }

implementation: if ( data == null ) { return Optional . empty ( ) ; } else { return Optional . of ( data ) ; }


signature:
public class Playlist { /** * updates the TrackInfo - Object
 * @ param old the old TrackInfo
 * @ param newTrackInfo the new TrackInfo
 * @ return the resulting new Playlist */
public Playlist update ( TrackInfo old , TrackInfo newTrackInfo ) { } }

implementation: List < TrackInfo > list = new ArrayList < > ( queue ) ; list . set ( list . indexOf ( old ) , newTrackInfo ) ; return new Playlist ( queue , name , playbackModes , position ) ;


signature:
public class Playlist { /** * Shuffles the playlist and returns the shuffled playlist , so the original stays intact .
 * Only the part of the playlist after the current position is shuffled .
 * @ return a shuffled copy of this playlist */
public Playlist shuffle ( ) { } }

implementation: int position = getPosition ( ) ; long seed = System . nanoTime ( ) ; if ( position >= 0 && position < queue . size ( ) ) { List < TrackInfo > trackInfos = queue . subList ( 0 , position ) ; List < TrackInfo > notPlayed = queue . subList ( position , queue . size ( ) ) ; List < TrackInfo > shuffledNotPlayed = new ArrayList < > ( notPlayed ) ; Collections . shuffle ( shuffledNotPlayed , new Random ( seed ) ) ; trackInfos . addAll ( shuffledNotPlayed ) ; return new Playlist ( trackInfos ) ; } else { List < TrackInfo > trackInfos = new ArrayList < > ( queue ) ; Collections . shuffle ( trackInfos , new Random ( seed ) ) ; return new Playlist ( trackInfos ) ; }


signature:
public class Playlist { /** * returns true if all the active playbackModes are supported
 * @ param capabilities the Capabilities to match against
 * @ return true if the player is capable , false if not */
public boolean verify ( Capabilities capabilities ) { } }

implementation: for ( PlaybackMode playbackMode : playbackModes ) { switch ( playbackMode ) { case REPEAT : if ( ! capabilities . canRepeatPlayback ( ) ) { return false ; } else { break ; } case REPEAT_SONG : if ( ! capabilities . canRepeatPlaybackOfSong ( ) ) { return false ; } else { break ; } case SHUFFLE : if ( ! capabilities . canShufflePlayback ( ) ) { return false ; } else { break ; } } } return true ;


signature:
public class Playlist { /** * exports the Playlist to a HashMap
 * @ return a HashMap */
public HashMap < String , Object > export ( ) { } }

implementation: HashMap < String , Object > data = new HashMap < > ( ) ; for ( int i = 0 ; i < queue . size ( ) ; i ++ ) { data . put ( QUEUE_DESCRIPTOR + i , queue . get ( i ) . export ( ) ) ; } for ( int i = 0 ; i < playbackModes . size ( ) ; i ++ ) { data . put ( PLAYBACK_MODE_DESCRIPTOR + i , playbackModes . get ( i ) . name ( ) ) ; } data . put ( NAME_DESCRIPTOR , name ) ; data . put ( POSITION_DESCRIPTOR , position ) ; data . put ( DATA_DESCRIPTOR , this . data ) ; return data ;


signature:
public class Playlist { /** * constructs ( if no errors were found ) the Playlist from the Resource
 * @ param resourceModel the resourceModel to import from
 * @ return the optional Playlist */
public static Optional < Playlist > importResource ( ResourceModel resourceModel ) { } }

implementation:
Object resource = resourceModel . getResource ( ) ; try { // noinspection unchecked
HashMap < String , Object > data = ( HashMap < String , Object > ) resource ; ArrayList < TrackInfo > queue = new ArrayList < > ( ) ; ArrayList < PlaybackMode > playbackModes = new ArrayList < > ( ) ; final String [ ] name = { null } ; final int [ ] position = { - 1 } ; final String [ ] dataString = { null } ; data . entrySet ( ) . forEach ( entry -> { if ( entry . getKey ( ) . startsWith ( QUEUE_DESCRIPTOR ) ) { int index = Integer . parseInt ( entry . getKey ( ) . replace ( QUEUE_DESCRIPTOR , "" ) ) ; // noinspection unchecked
TrackInfo . importFromHashMap ( ( HashMap < String , Object > ) entry . getValue ( ) ) . ifPresent ( trackInfo -> queue . add ( index , trackInfo ) ) ; } else if ( entry . getKey ( ) . startsWith ( PLAYBACK_MODE_DESCRIPTOR ) ) { try { int index = Integer . parseInt ( entry . getKey ( ) . replace ( PLAYBACK_MODE_DESCRIPTOR , "" ) ) ; // noinspection unchecked
playbackModes . add ( index , PlaybackMode . valueOf ( ( String ) entry . getValue ( ) ) ) ; } catch ( IllegalArgumentException ignored ) { // happens when the name is not present . . . maybe future sdks define other playbackModes
} } else if ( entry . getKey ( ) . equals ( NAME_DESCRIPTOR ) ) { name [ 0 ] = ( String ) entry . getValue ( ) ; } else if ( entry . getKey ( ) . equals ( POSITION_DESCRIPTOR ) ) { position [ 0 ] = ( int ) entry . getValue ( ) ; } else if ( entry . getKey ( ) . equals ( DATA_DESCRIPTOR ) ) { dataString [ 0 ] = ( String ) entry . getValue ( ) ; } } ) ; return Optional . of ( new Playlist ( queue , name [ 0 ] , playbackModes , position [ 0 ] , dataString [ 0 ] ) ) ; } catch ( ClassCastException | IllegalArgumentException e ) { return Optional . empty ( ) ; }


signature:
public class Base64 { /** * Decodes four bytes from array < var > source < / var > and writes the resulting
 * bytes ( up to three of them ) to < var > destination < / var > . The source and
 * destination arrays can be manipulated anywhere along their length by
 * specifying < var > srcOffset < / var > and < var > destOffset < / var > . This method
 * does not check to make sure your arrays are large enough to accomodate
 * < var > srcOffset < / var > + 4 for the < var > source < / var > array or
 * < var > destOffset < / var > + 3 for the < var > destination < / var > array . This
 * method returns the actual number of bytes that were converted from the
 * Base64 encoding .
 * This is the lowest level of the decoding methods with all possible
 * parameters .
 * @ param source
 * the array to convert
 * @ param srcOffset
 * the index where conversion begins
 * @ param destination
 * the array to hold the conversion
 * @ param destOffset
 * the index where output will be put
 * @ param options
 * alphabet type is pulled from this ( standard , url - safe ,
 * ordered )
 * @ return the number of decoded bytes converted
 * @ since 1.3 */
private static int decode4to3 ( byte [ ] source , int srcOffset , byte [ ] destination , int destOffset , int options ) { } }

implementation:
byte [ ] DECODABET = getDecodabet ( options ) ; // Example : Dk = =
if ( source [ srcOffset + 2 ] == EQUALS_SIGN ) { // Two ways to do the same thing . Don ' t know which way I like best .
// int outBuff = ( ( DECODABET [ source [ srcOffset ] ] < < 24 ) > > > 6
// | ( ( DECODABET [ source [ srcOffset + 1 ] ] < < 24 ) > > > 12 ) ;
int outBuff = ( ( DECODABET [ source [ srcOffset ] ] & 0xFF ) << 18 ) | ( ( DECODABET [ source [ srcOffset + 1 ] ] & 0xFF ) << 12 ) ; destination [ destOffset ] = ( byte ) ( outBuff >>> 16 ) ; return 1 ; } // Example : DkL =
else if ( source [ srcOffset + 3 ] == EQUALS_SIGN ) { // Two ways to do the same thing . Don ' t know which way I like best .
// int outBuff = ( ( DECODABET [ source [ srcOffset ] ] < < 24 ) > > > 6
// | ( ( DECODABET [ source [ srcOffset + 1 ] ] < < 24 ) > > > 12 )
// | ( ( DECODABET [ source [ srcOffset + 2 ] ] < < 24 ) > > > 18 ) ;
int outBuff = ( ( DECODABET [ source [ srcOffset ] ] & 0xFF ) << 18 ) | ( ( DECODABET [ source [ srcOffset + 1 ] ] & 0xFF ) << 12 ) | ( ( DECODABET [ source [ srcOffset + 2 ] ] & 0xFF ) << 6 ) ; destination [ destOffset ] = ( byte ) ( outBuff >>> 16 ) ; destination [ destOffset + 1 ] = ( byte ) ( outBuff >>> 8 ) ; return 2 ; } // Example : DkLE
else { try { // Two ways to do the same thing . Don ' t know which way I like
// best .
// int outBuff = ( ( DECODABET [ source [ srcOffset ] ] < < 24 )
// | ( ( DECODABET [ source [ srcOffset + 1 ] ] < < 24 ) > > > 12 )
// | ( ( DECODABET [ source [ srcOffset + 2 ] ] < < 24 ) > > > 18 )
// | ( ( DECODABET [ source [ srcOffset + 3 ] ] < < 24 ) > > > 24 ) ;
int outBuff = ( ( DECODABET [ source [ srcOffset ] ] & 0xFF ) << 18 ) | ( ( DECODABET [ source [ srcOffset + 1 ] ] & 0xFF ) << 12 ) | ( ( DECODABET [ source [ srcOffset + 2 ] ] & 0xFF ) << 6 ) | ( ( DECODABET [ source [ srcOffset + 3 ] ] & 0xFF ) ) ; destination [ destOffset ] = ( byte ) ( outBuff >> 16 ) ; destination [ destOffset + 1 ] = ( byte ) ( outBuff >> 8 ) ; destination [ destOffset + 2 ] = ( byte ) ( outBuff ) ; return 3 ; } catch ( Exception e ) { log . log ( Level . ERROR , e . getMessage ( ) , e ) ; log . error ( "" + source [ srcOffset ] + ": " + ( DECODABET [ source [ srcOffset ] ] ) ) ; log . error ( "" + source [ srcOffset + 1 ] + ": " + ( DECODABET [ source [ srcOffset + 1 ] ] ) ) ; log . error ( "" + source [ srcOffset + 2 ] + ": " + ( DECODABET [ source [ srcOffset + 2 ] ] ) ) ; log . error ( "" + source [ srcOffset + 3 ] + ": " + ( DECODABET [ source [ srcOffset + 3 ] ] ) ) ; return - 1 ; } // end catch
}


signature:
public class BatchProcessor { /** * Takes the original request and starts the batching .
 * @ param request
 * @ param response
 * @ throws IOException
 * @ throws ServletException */
protected void batchRequest ( HttpServletRequest request , HttpServletResponse response , String jsonRequest , boolean allowModify ) throws IOException , ServletException { } }

implementation: JsonParser jsonParser = new JsonParser ( ) ; JsonElement element = jsonParser . parse ( jsonRequest ) ; if ( ! element . isJsonArray ( ) ) { response . sendError ( HttpServletResponse . SC_BAD_REQUEST , "Failed to parse the requests parameter" ) ; return ; } JsonArray arr = element . getAsJsonArray ( ) ; response . setContentType ( "application/json" ) ; response . setCharacterEncoding ( "UTF-8" ) ; String key = null ; try { MessageDigest md = MessageDigest . getInstance ( "SHA-1" ) ; key = Base64 . encodeBase64URLSafeString ( md . digest ( jsonRequest . getBytes ( "UTF-8" ) ) ) ; String cachedResult = responseCache . get ( key ) ; if ( cachedResult != null ) { LOGGER . debug ( "Using Cache" ) ; response . getWriter ( ) . write ( cachedResult ) ; return ; } } catch ( Exception e ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } boolean cache = ( key != null ) ; CaptureResponseWriter captureResponseWriter = new CaptureResponseWriter ( response . getWriter ( ) ) ; JsonWriter write = new JsonWriter ( captureResponseWriter ) ; write . beginObject ( ) ; write . name ( "results" ) ; write . beginArray ( ) ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { JsonObject obj = arr . get ( i ) . getAsJsonObject ( ) ; try { RequestInfo r = new RequestInfo ( obj ) ; if ( r . isValid ( ) && ( allowModify || r . isSafe ( ) ) ) { cache = doRequest ( request , response , r , write ) && cache ; } else { outputFailure ( "Bad request, ignored " + obj . toString ( ) , write ) ; } } catch ( MalformedURLException e ) { outputFailure ( "Bad request, ignored " + obj . toString ( ) , write ) ; } } write . endArray ( ) ; write . endObject ( ) ; write . flush ( ) ; if ( cache ) { responseCache . put ( key , captureResponseWriter . toString ( ) ) ; }


signature:
public class Capabilities { /** * creates a TrackInfo from the resourceModel
 * @ param resourceModel the resourceModel
 * @ return the optional TrackInfo */
public static Optional < Capabilities > importFromResource ( ResourceModel resourceModel , Context context ) { } }

implementation: Object resource = resourceModel . getResource ( ) ; try { @ SuppressWarnings ( "unchecked" ) HashMap < String , Boolean > hashMap = ( HashMap < String , Boolean > ) resource ; return Optional . of ( constructCapabilites ( hashMap , context ) ) ; } catch ( ClassCastException e ) { return Optional . empty ( ) ; }


signature:
public class StopEvent { /** * creates a new StopEvent
 * @ param source the caller
 * @ param target the target who should start playing
 * @ return the optional StartMusicRequest */
public static Optional < StopEvent > createStopEvent ( Identification source , Identification target ) { } }

implementation: if ( target == null || target . equals ( source ) ) return Optional . empty ( ) ; try { StopEvent stopRequest = new StopEvent ( source ) ; stopRequest . addResource ( new SelectorResource ( source , target ) ) ; return Optional . of ( stopRequest ) ; } catch ( IllegalArgumentException e ) { return Optional . empty ( ) ; }


signature:
public class StopEvent { /** * creates a new StopEvent
 * @ param source the caller
 * @ return the optional StartMusicRequest */
public static Optional < StopEvent > createStopEvent ( Identification source ) { } }

implementation: try { StopEvent stopRequest = new StopEvent ( source ) ; return Optional . of ( stopRequest ) ; } catch ( IllegalArgumentException e ) { return Optional . empty ( ) ; }


signature:
public class StringUtils { /** * Returns the name portion of a XMPP address . For example , for the address
 * " matt @ jivesoftware . com / Smack " , " matt " would be returned . If no username
 * is present in the address , the empty string will be returned .
 * @ param XMPPAddress
 * the XMPP address .
 * @ return the name portion of the XMPP address . */
public static String parseName ( String XMPPAddress ) { } }

implementation: if ( XMPPAddress == null ) { return null ; } int atIndex = XMPPAddress . indexOf ( "@" ) ; if ( atIndex <= 0 ) { return "" ; } else { return XMPPAddress . substring ( 0 , atIndex ) ; }


signature:
public class StringUtils { /** * Escapes all necessary characters in the String so that it can be used in
 * an XML doc .
 * @ param string
 * the string to escape .
 * @ return the string with appropriate characters escaped . */
public static final String escapeForXML ( String string ) { } }

implementation:
if ( string == null ) { return null ; } char ch ; int i = 0 ; int last = 0 ; char [ ] input = string . toCharArray ( ) ; int len = input . length ; StringBuffer out = new StringBuffer ( ( int ) ( len * 1.3 ) ) ; for ( ; i < len ; i ++ ) { ch = input [ i ] ; if ( ch > '>' ) { continue ; } else if ( ch == '<' ) { if ( i > last ) { out . append ( input , last , i - last ) ; } last = i + 1 ; out . append ( LT_ENCODE ) ; } else if ( ch == '>' ) { if ( i > last ) { out . append ( input , last , i - last ) ; } last = i + 1 ; out . append ( GT_ENCODE ) ; } else if ( ch == '&' ) { if ( i > last ) { out . append ( input , last , i - last ) ; } // Do nothing if the string is of the form & # 235 ; ( unicode
// value )
if ( ! ( len > i + 5 && input [ i + 1 ] == '#' && Character . isDigit ( input [ i + 2 ] ) && Character . isDigit ( input [ i + 3 ] ) && Character . isDigit ( input [ i + 4 ] ) && input [ i + 5 ] == ';' ) ) { last = i + 1 ; out . append ( AMP_ENCODE ) ; } } else if ( ch == '"' ) { if ( i > last ) { out . append ( input , last , i - last ) ; } last = i + 1 ; out . append ( QUOTE_ENCODE ) ; } } if ( last == 0 ) { return string ; } if ( i > last ) { out . append ( input , last , i - last ) ; } return out . toString ( ) ;


signature:
public class StringUtils { /** * Hashes a String using the SHA - 1 algorithm and returns the result as a
 * String of hexadecimal numbers . This method is synchronized to avoid
 * excessive MessageDigest object creation . If calling this method becomes a
 * bottleneck in your code , you may wish to maintain a pool of MessageDigest
 * objects instead of using this method .
 * A hash is a one - way function - - that is , given an input , an output is
 * easily computed . However , given the output , the input is almost
 * impossible to compute . This is useful for passwords since we can store
 * the hash and a hacker will then have a very hard time determining the
 * original password .
 * @ param data
 * the String to compute the hash of .
 * @ return a hashed version of the passed - in String */
public synchronized static final String hash ( String data ) { } }

implementation:
if ( digest == null ) { try { digest = MessageDigest . getInstance ( "SHA-1" ) ; } catch ( NoSuchAlgorithmException nsae ) { System . err . println ( "Failed to load the SHA-1 MessageDigest. " + "Jive will be unable to function normally." ) ; } } // Now , compute hash .
try { digest . update ( data . getBytes ( "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { System . err . println ( e ) ; } return encodeHex ( digest . digest ( ) ) ;


signature:
public class StringUtils { /** * Turns an array of bytes into a String representing each byte as an
 * unsigned hex number .
 * Method by Santeri Paavolainen , Helsinki Finland 1996 < br >
 * ( c ) Santeri Paavolainen , Helsinki Finland 1996 < br >
 * Distributed under LGPL .
 * @ param bytes
 * an array of bytes to convert to a hex - string
 * @ return generated hex string */
public static final String encodeHex ( byte [ ] bytes ) { } }

implementation: StringBuffer buf = new StringBuffer ( bytes . length * 2 ) ; int i ; for ( i = 0 ; i < bytes . length ; i ++ ) { if ( ( ( int ) bytes [ i ] & 0xff ) < 0x10 ) { buf . append ( "0" ) ; } buf . append ( Long . toString ( ( int ) bytes [ i ] & 0xff , 16 ) ) ; } return buf . toString ( ) ;


signature:
public class SASLMechanism { /** * Builds and sends the < tt > auth < / tt > stanza to the server . Note that this
 * method of authentication is not recommended , since it is very inflexable .
 * Use { @ link # authenticate ( String , String , CallbackHandler ) } whenever
 * possible .
 * Explanation of auth stanza :
 * The client authentication stanza needs to include the digest - uri of the
 * form : xmpp / serverName From RFC - 2831 : digest - uri = " digest - uri " " = "
 * digest - uri - value digest - uri - value = serv - type " / " host [ " / " serv - name ]
 * digest - uri : Indicates the principal name of the service with which the
 * client wishes to connect , formed from the serv - type , host , and serv - name .
 * For example , the FTP service on " ftp . example . com " would have a
 * " digest - uri " value of " ftp / ftp . example . com " ; the SMTP server from the
 * example above would have a " digest - uri " value of
 * " smtp / mail3 . example . com / example . com " .
 * host : The DNS host name or IP address for the service requested . The DNS
 * host name must be the fully - qualified canonical name of the host . The DNS
 * host name is the preferred form ; see notes on server processing of the
 * digest - uri .
 * serv - name : Indicates the name of the service if it is replicated . The
 * service is considered to be replicated if the client ' s service - location
 * process involves resolution using standard DNS lookup operations , and if
 * these operations involve DNS records ( such as SRV , or MX ) which resolve
 * one DNS name into a set of other DNS names . In this case , the initial
 * name used by the client is the " serv - name " , and the final name is the
 * " host " component . For example , the incoming mail service for
 * " example . com " may be replicated through the use of MX records stored in
 * the DNS , one of which points at an SMTP server called
 * " mail3 . example . com " ; it ' s " serv - name " would be " example . com " , it ' s " host "
 * would be " mail3 . example . com " . If the service is not replicated , or the
 * serv - name is identical to the host , then the serv - name component MUST be
 * omitted
 * digest - uri verification is needed for ejabberd 2.0.3 and higher
 * @ param username
 * the username of the user being authenticated .
 * @ param host
 * the hostname where the user account resides .
 * @ param serviceName
 * the xmpp service location - used by the SASL client in
 * digest - uri creation serviceName format is : host [ " / "
 * serv - name ] as per RFC - 2831
 * @ param password
 * the password for this account .
 * @ throws IOException
 * If a network error occurs while authenticating .
 * @ throws XMPPException
 * If a protocol error occurs or the user is not authenticated . */
public void authenticate ( String username , String host , String serviceName , String password ) throws IOException , XMPPException { } }

implementation:
// Since we were not provided with a CallbackHandler , we will use our
// own with the given
// information
// Set the authenticationID as the username , since they must be the same
// in this case .
this . authenticationId = username ; this . password = password ; this . hostname = host ; String [ ] mechanisms = { getName ( ) } ; Map < String , String > props = new HashMap < String , String > ( ) ; sc = Sasl . createSaslClient ( mechanisms , username , "xmpp" , serviceName , props , this ) ; authenticate ( ) ;


signature:
public class SASLMechanism { /** * Same as { @ link # authenticate ( String , String , String , String ) } , but with
 * the hostname used as the serviceName .
 * Kept for backward compatibility only .
 * @ param username
 * the username of the user being authenticated .
 * @ param host
 * the hostname where the user account resides .
 * @ param password
 * the password for this account .
 * @ throws IOException
 * If a network error occurs while authenticating .
 * @ throws XMPPException
 * If a protocol error occurs or the user is not authenticated .
 * @ deprecated Please use
 * { @ link # authenticate ( String , String , String , String ) }
 * instead . */
public void authenticate ( String username , String host , String password ) throws IOException , XMPPException { } }

implementation: authenticate ( username , host , host , password ) ;


signature:
public class SASLMechanism { /** * Builds and sends the < tt > auth < / tt > stanza to the server . The callback
 * handler will handle any additional information , such as the
 * authentication ID or realm , if it is needed .
 * @ param username
 * the username of the user being authenticated .
 * @ param host
 * the hostname where the user account resides .
 * @ param cbh
 * the CallbackHandler to obtain user information .
 * @ throws IOException
 * If a network error occures while authenticating .
 * @ throws XMPPException
 * If a protocol error occurs or the user is not authenticated . */
public void authenticate ( String username , String host , CallbackHandler cbh ) throws IOException , XMPPException { } }

implementation: String [ ] mechanisms = { getName ( ) } ; Map < String , String > props = new HashMap < String , String > ( ) ; sc = Sasl . createSaslClient ( mechanisms , username , "xmpp" , host , props , cbh ) ; authenticate ( ) ;


signature:
public class SASLMechanism { /** * The server is challenging the SASL mechanism for the stanza he just sent .
 * Send a response to the server ' s challenge .
 * @ param challenge
 * a base64 encoded string representing the challenge .
 * @ throws IOException
 * if an exception sending the response occurs . */
public void challengeReceived ( String challenge ) throws IOException { } }

implementation:
byte response [ ] ; if ( challenge != null ) { response = sc . evaluateChallenge ( StringUtils . decodeBase64 ( challenge ) ) ; } else { response = sc . evaluateChallenge ( new byte [ 0 ] ) ; } Packet responseStanza ; if ( response == null ) { responseStanza = new Response ( ) ; } else { responseStanza = new Response ( StringUtils . encodeBase64 ( response , false ) ) ; } // Send the authentication to the server
getSASLAuthentication ( ) . send ( responseStanza ) ;


signature:
public class GoodwillSchemaField { /** * Create a JSON representation of the GoodwillSchemaField . It will always contain
 * the name , type and position . Description and SQL attributes are however
 * optional .
 * @ return JSONObject containing all fields
 * @ throws IOException if a serialization exception occurs
 * @ throws JsonGenerationException if a serialization exception occurs */
public ByteArrayOutputStream toJSON ( ) throws IOException { } }

implementation: final ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; mapper . writeValue ( out , this ) ; return out ;


signature:
public class GoodwillSchemaField { /** * Pretty print the SQL type .
 * TODO : add layer of abstraction , too Netezza specific
 * @ return a human readable representation of the SQL type */
@ SuppressWarnings ( "unused" ) public String getFullSQLType ( ) { } }

implementation: String fullSQLType = null ; if ( sql . type == null ) { return null ; } else if ( sql . type . equals ( "decimal" ) || sql . type . equals ( "numeric" ) ) { if ( sql . precision != null ) { if ( sql . scale != null ) { fullSQLType = sql . type + "(" + sql . precision + ", " + sql . scale + ")" ; } else { fullSQLType = sql . type + "(" + sql . precision + ")" ; } } } else { if ( sql . type . equals ( "nvarchar" ) || sql . type . equals ( "varchar" ) ) { if ( sql . length != null ) { fullSQLType = sql . type + "(" + sql . length + ")" ; } } } if ( fullSQLType == null ) { fullSQLType = sql . type ; } return fullSQLType ;


signature:
public class OutputPluginArgument { /** * main method for outputPlugin , runs the data - conversion and output - renderer
 * it will instruct the outputManager to let the outputExtensions generate the data . Wait for the time specified
 * in getTimeoutLimit ( ) ( standard is 1000 milliseconds ) abd the call renderFinalOutput ( ) with the resulting data . */
@ Override public void run ( ) { } }

implementation:
while ( ! stop ) { EventModel event ; try { event = blockingQueueHandling ( ) ; // gets the new Event if one was added to the blockingQueue
} catch ( InterruptedException e ) { getContext ( ) . getLogger ( ) . warn ( e ) ; continue ; } List < CompletableFuture < X > > outputExtensions = getContext ( ) . getOutput ( ) . generateAllOutputExtensions ( this , getArgument ( ) , event ) ; try { outputExtensions = timeOut ( outputExtensions , getTimeoutLimit ( ) ) ; } catch ( InterruptedException e ) { getContext ( ) . getLogger ( ) . warn ( e ) ; } handleFutures ( outputExtensions , event ) ; // notifies output - manager when done processing
isDone ( event ) ; }


signature:
public class ContentEventListener { /** * Handles an event from OSGi and places it in the appropriate queue .
 * @ see org . osgi . service . event . EventHandler # handleEvent ( org . osgi . service . event . Event ) */
public void handleEvent ( Event event ) { } }

implementation:
String topic = event . getTopic ( ) ; LOGGER . debug ( "Got Event {} {} " , event , handlers ) ; Collection < IndexingHandler > contentIndexHandler = handlers . get ( topic ) ; if ( contentIndexHandler != null && contentIndexHandler . size ( ) > 0 ) { try { int ttl = Utils . toInt ( event . getProperty ( TopicIndexer . TTL ) , Integer . MAX_VALUE ) ; for ( IndexingHandler indexingHandler : contentIndexHandler ) { if ( indexingHandler instanceof QoSIndexHandler ) { ttl = Math . min ( ttl , Utils . defaultMax ( ( ( QoSIndexHandler ) indexingHandler ) . getTtl ( event ) ) ) ; } } QueueManager q = null ; // queues is ordered by ascending ttl , so the fastest queue is queues [ 0 ] ,
// if the ttl is less that that , we can ' t satisfy it , so we will put it
// in the fastest queue
if ( ttl < queues [ 0 ] . batchDelay ) { LOGGER . warn ( "Unable to satisfy TTL of {} on event {}, posting to the highest priority queue. " + "If this message is logged a lot please adjust the queues or change the event ttl to something that can be satisfied. " + "Filling the highest priority queue is counter productive. " , ttl , event ) ; queues [ 0 ] . saveEvent ( event ) ; } else { for ( QueueManager qm : queues ) { if ( ttl < qm . batchDelay ) { q . saveEvent ( event ) ; q = null ; break ; } q = qm ; } if ( q != null ) { q . saveEvent ( event ) ; } } } catch ( IOException e ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } }


signature:
public class ContentEventListener { /** * used only for testing */
protected void joinAll ( ) throws InterruptedException { } }

implementation: if ( queues != null ) { for ( QueueManager q : queues ) { q . getQueueDispatcher ( ) . join ( ) ; } }


signature:
public class Authorizable { /** * Set a property . The property will only be set if writable . If the property or this athorizable is read only , nothing will happen .
 * @ param name the name of the property
 * @ param value the value of the property . */
public void setProperty ( String name , Object value ) { } }

implementation: if ( ! readOnly && ! FILTER_PROPERTIES . contains ( name ) ) { Object cv = authorizableMap . get ( name ) ; if ( value == null ) { if ( cv != null && ! ( cv instanceof RemoveProperty ) ) { modifiedMap . put ( name , new RemoveProperty ( ) ) ; } } else if ( ! value . equals ( cv ) ) { modifiedMap . put ( name , value ) ; } else if ( modifiedMap . containsKey ( name ) && ! value . equals ( modifiedMap . get ( name ) ) ) { modifiedMap . put ( name , value ) ; } }


signature:
public class Authorizable { /** * remove the property .
 * @ param name */
public void removeProperty ( String key ) { } }

implementation: if ( ! readOnly && ( authorizableMap . containsKey ( key ) || modifiedMap . containsKey ( key ) ) ) { modifiedMap . put ( key , new RemoveProperty ( ) ) ; }


signature:
public class Authorizable { /** * add a principal to this authorizable .
 * @ param principal */
public void addPrincipal ( String principal ) { } }

implementation: if ( ! readOnly && ! principals . contains ( principal ) ) { principals . add ( principal ) ; principalsModified = true ; }


signature:
public class Authorizable { /** * remove a principal from this authorizable .
 * @ param principal */
public void removePrincipal ( String principal ) { } }

implementation: if ( ! readOnly && principals . contains ( principal ) ) { principals . remove ( principal ) ; principalsModified = true ; }


signature:
public class XMPPBase { /** * @ throws ComponentException */
public void process ( boolean block ) { } }

implementation: Runnable componentRunnable = new Runnable ( ) { @ Override public void run ( ) { try { mutex . acquire ( ) ; } catch ( InterruptedException e ) { LOGGER . fatal ( "Main loop." , e ) ; } } } ; Thread t = new Thread ( componentRunnable , "jamppa-hanging-thread" ) ; if ( block ) { t . run ( ) ; } else { t . start ( ) ; }


signature:
public class PlayerCommand { /** * Creates a new Event Object
 * @ param source the source of the Event , most likely a this reference .
 * @ param target the target who should start playing
 * @ param capabilities the capabilities of the player
 * @ param command the command
 * @ param context the context to use
 * @ return the optional PlayerCommand
 * @ throws IllegalArgumentException if one of the Arguments is null or empty */
public static Optional < PlayerCommand > createPlayerCommand ( Identification source , Identification target , String command , Capabilities capabilities , Context context ) { } }

implementation: try { Optional < CommandResource > commandResource = CommandResource . createCommandResource ( source , command , capabilities , context ) ; if ( ! commandResource . isPresent ( ) ) { context . getLogger ( ) . error ( "unable to obtain commandResource" ) ; return Optional . empty ( ) ; } PlayerCommand playerCommand = new PlayerCommand ( source ) ; playerCommand . addResource ( new SelectorResource ( source , target ) ) ; playerCommand . addResource ( commandResource . get ( ) ) ; return Optional . of ( playerCommand ) ; } catch ( IllegalArgumentException e ) { return Optional . empty ( ) ; }


signature:
public class LiteDebugger { /** * Notification that the root window is closing . Stop listening for received
 * and transmitted packets .
 * @ param evt
 * the event that indicates that the root window is closing */
public void rootWindowClosing ( WindowEvent evt ) { } }

implementation: connection . removePacketListener ( listener ) ; ( ( ObservableReader ) reader ) . removeReaderListener ( readerListener ) ; ( ( ObservableWriter ) writer ) . removeWriterListener ( writerListener ) ;


signature:
public class SynchronizedFilterableMap { /** * Factory method to create a synchronized map .
 * @ param map the map to decorate , must not be null
 * @ throws IllegalArgumentException if map is null */
public static < K , V > FilterableMap < K , V > decorate ( FilterableMap < K , V > map ) { } }

implementation: return new SynchronizedFilterableMap < K , V > ( map ) ;


signature:
public class TrustedLoginTokenProxyPostProcessor { /** * { @ inheritDoc }
 * @ see uk . co . tfd . sm . api . proxy . ProxyPostProcessor # process ( java . util . Map ,
 * org . apache . sling . api . SlingHttpServletResponse ,
 * uk . co . tfd . sm . api . proxy . ProxyResponse ) */
public void process ( Map < String , Object > config , Map < String , Object > templateParams , HttpServletResponse response , ProxyResponse proxyResponse ) throws IOException { } }

implementation:
LOG . debug ( "process(Map<String, Object> {}, SlingHttpServletResponse response, ProxyResponse proxyResponse)" , templateParams ) ; if ( templateParams == null || ! tltppp . hostname . equals ( templateParams . get ( "hostname" ) ) || tltppp . port != ( Integer ) templateParams . get ( "port" ) ) { response . sendError ( HttpServletResponse . SC_BAD_REQUEST ) ; return ; } // just use DefaultProxyPostProcessorImpl behavior
dpppi . process ( config , templateParams , response , proxyResponse ) ; return ;


signature:
public class AuthorizableManagerImpl { /** * TODO : Unit test */
public void changePassword ( Authorizable authorizable , String password , String oldPassword ) throws StorageClientException , AccessDeniedException { } }

implementation: long t = System . currentTimeMillis ( ) ; try { String id = authorizable . getId ( ) ; if ( thisUser . isAdmin ( ) || currentUserId . equals ( id ) ) { if ( ! thisUser . isAdmin ( ) ) { User u = authenticator . authenticate ( id , oldPassword ) ; if ( u == null ) { throw new IllegalArgumentException ( "Unable to change passwords, old password does not match" ) ; } } putCached ( keySpace , authorizableColumnFamily , id , ImmutableMap . of ( Authorizable . LASTMODIFIED_FIELD , ( Object ) System . currentTimeMillis ( ) , Authorizable . ID_FIELD , id , Authorizable . LASTMODIFIED_BY_FIELD , accessControlManager . getCurrentUserId ( ) , Authorizable . PASSWORD_FIELD , StorageClientUtils . secureHash ( password ) ) , false ) ; storeListener . onUpdate ( Security . ZONE_AUTHORIZABLES , id , currentUserId , getType ( authorizable ) , false , null , "op:change-password" ) ; } else { throw new AccessDeniedException ( Security . ZONE_ADMIN , id , "Not allowed to change the password, must be the user or an admin user" , currentUserId ) ; } } finally { statsService . apiCall ( AuthorizableManagerImpl . class . getName ( ) , "changePassword" , System . currentTimeMillis ( ) - t ) ; }


signature:
public class SessionIdentifier { /** * Helper method to get an instance of { @ link SessionIdentifier } .
 * @ param hostsAndPorts
 * example { @ code " localhost : 9042 , host2 , host3:19042 " }
 * @ param username
 * username to authenticate against Cassandra cluster
 * @ param password
 * password to authenticate against Cassandra cluster
 * @ param keyspace
 * keyspace to connect to
 * @ return */
public static SessionIdentifier getInstance ( String hostsAndPorts , String username , String password , String keyspace ) { } }

implementation: return getInstance ( hostsAndPorts , username , password , null , keyspace ) ;


signature:
public class PresenceNonConstant { /** * call this method when you have encountered the user */
@ SuppressWarnings ( "unused" ) public void userEncountered ( ) { } }

implementation:
List < String > descriptors = new ArrayList < > ( ) ; /* if ( strict & & ( ( ! present & & ! fireUnknownIfNotPresent ) | | ! strictPresent ) & & addResponseDescriptors ) {
 if ( lastSeen . until ( LocalDateTime . now ( ) , ChronoUnit . MINUTES ) > getMajorMinuteThresholdNotPresent ( ) ) {
 descriptors . add ( CommonEvents . Response . MAJOR _ RESPONSE _ DESCRIPTOR ) ;
 } else if ( lastSeen . until ( LocalDateTime . now ( ) , ChronoUnit . MINUTES ) > getMinorMinuteThresholdNotPresent ( ) ) {
 descriptors . add ( CommonEvents . Response . MINOR _ RESPONSE _ DESCRIPTOR ) ;
 } else if ( present & & strict & & addResponseDescriptors ) {
 if ( lastSeen . until ( LocalDateTime . now ( ) , ChronoUnit . MINUTES ) > getMajorMinuteThresholdPresent ( ) ) {
 descriptors . add ( CommonEvents . Response . MAJOR _ RESPONSE _ DESCRIPTOR ) ;
 } else if ( lastSeen . until ( LocalDateTime . now ( ) , ChronoUnit . MINUTES ) > getMinorMinuteThresholdNotPresent ( ) ) {
 descriptors . add ( CommonEvents . Response . MINOR _ RESPONSE _ DESCRIPTOR ) ; */
descriptors . add ( CommonEvents . Descriptors . NOT_INTERRUPT ) ; boolean known = ! fireUnknownIfNotPresent || present ; boolean firstPresent = ( ! strict && ! present ) || ( strict && ! strictPresent ) ; long lastSeen = this . lastSeen . until ( LocalDateTime . now ( ) , ChronoUnit . SECONDS ) ; Optional < Event > presenceEvent = IdentificationManagerM . getInstance ( ) . getIdentification ( this ) . flatMap ( id -> PresenceEvent . createPresenceEvent ( id , strict , known , firstPresent , descriptors , lastSeen ) ) . map ( event -> event . addEventLifeCycleListener ( EventLifeCycle . APPROVED , lifeCycle -> { if ( known ) { this . lastSeen = LocalDateTime . now ( ) ; if ( strict ) this . strictPresent = true ; present = true ; } } ) ) ; if ( ! presenceEvent . isPresent ( ) ) { error ( "unable to create PresenceEvent" ) ; } else { fire ( presenceEvent . get ( ) , 5 ) ; }


signature:
public class PresenceNonConstant { /** * Invoked when an activator - event occurs .
 * @ param event an instance of Event */
@ Override public void eventFired ( EventModel event ) { } }

implementation: if ( event . containsDescriptor ( LeavingEvent . ID ) || event . containsDescriptor ( PresenceEvent . ID ) ) { if ( event . containsDescriptor ( LeavingEvent . ID ) ) { if ( event . containsDescriptor ( LeavingEvent . GENERAL_DESCRIPTOR ) ) { present = false ; strictPresent = false ; } else if ( event . containsDescriptor ( LeavingEvent . STRICT_DESCRIPTOR ) ) { nonStrictAvailable ( ) . thenAccept ( available -> { if ( ! available ) present = false ; strictPresent = false ; } ) ; } } else { present = true ; if ( event . containsDescriptor ( PresenceEvent . STRICT_DESCRIPTOR ) ) strictPresent = true ; } if ( event . containsDescriptor ( PresenceEvent . STRICT_DESCRIPTOR ) ) lastSeen = LocalDateTime . now ( ) ; }


signature:
public class ContentManagerImpl { /** * { @ inheritDoc }
 * @ see org . sakaiproject . nakamura . api . lite . content . ContentManager # copy ( java . lang . String ,
 * java . lang . String , boolean ) */
public void copy ( String from , String to , boolean withStreams ) throws StorageClientException , AccessDeniedException , IOException { } }

implementation:
long ts = System . currentTimeMillis ( ) ; try { checkOpen ( ) ; // To Copy , get the to object out and copy everything over .
Content f = get ( from ) ; if ( f == null ) { throw new StorageClientException ( " Source content " + from + " does not exist" ) ; } if ( f . getProperty ( UUID_FIELD ) == null ) { LOGGER . warn ( "Bad Content item with no ID cant be copied {} " , f ) ; throw new StorageClientException ( " Source content " + from + "  Has no " + UUID_FIELD ) ; } Content t = get ( to ) ; if ( t != null ) { LOGGER . debug ( "Deleting {} " , to ) ; delete ( to ) ; } Set < String > streams = Sets . newHashSet ( ) ; Map < String , Object > copyProperties = Maps . newHashMap ( ) ; if ( withStreams ) { for ( Entry < String , Object > p : f . getProperties ( ) . entrySet ( ) ) { // Protected fields ( such as ID and path ) will differ
// between
// the source and destination , so don ' t copy them .
if ( ! PROTECTED_FIELDS . contains ( p . getKey ( ) ) ) { if ( p . getKey ( ) . startsWith ( BLOCKID_FIELD ) ) { streams . add ( p . getKey ( ) ) ; } else { copyProperties . put ( p . getKey ( ) , p . getValue ( ) ) ; } } } } else { copyProperties . putAll ( f . getProperties ( ) ) ; } copyProperties . put ( COPIED_FROM_PATH_FIELD , from ) ; copyProperties . put ( COPIED_FROM_ID_FIELD , f . getProperty ( UUID_FIELD ) ) ; copyProperties . put ( COPIED_DEEP_FIELD , withStreams ) ; t = new Content ( to , copyProperties ) ; update ( t ) ; LOGGER . debug ( "Copy Updated {} {} " , to , t ) ; for ( String stream : streams ) { String streamId = null ; if ( stream . length ( ) > BLOCKID_FIELD . length ( ) ) { streamId = stream . substring ( BLOCKID_FIELD . length ( ) + 1 ) ; } InputStream fromStream = getInputStream ( from , streamId ) ; writeBody ( to , fromStream ) ; fromStream . close ( ) ; } eventListener . onUpdate ( Security . ZONE_CONTENT , to , accessControlManager . getCurrentUserId ( ) , getResourceType ( f ) , true , null , "op:copy" ) ; } finally { statsService . apiCall ( ContentManagerImpl . class . getName ( ) , "copy" , System . currentTimeMillis ( ) - ts ) ; }


signature:
public class ContentManagerImpl { /** * TODO : Unit test */
public void move ( String from , String to ) throws AccessDeniedException , StorageClientException { } }

implementation:
// to move , get the structure object out and modify , recreating parent
// objects as necessary .
long t = System . currentTimeMillis ( ) ; try { checkOpen ( ) ; accessControlManager . check ( Security . ZONE_CONTENT , from , Permissions . CAN_ANYTHING ) ; accessControlManager . check ( Security . ZONE_CONTENT , to , Permissions . CAN_READ . combine ( Permissions . CAN_WRITE ) ) ; Map < String , Object > fromStructure = Maps . newHashMap ( getCached ( keySpace , contentColumnFamily , from ) ) ; if ( ! exists ( fromStructure ) ) { throw new StorageClientException ( "The source content to move from " + from + " does not exist, move operation failed" ) ; } if ( exists ( fromStructure ) ) { String contentId = ( String ) fromStructure . get ( STRUCTURE_UUID_FIELD ) ; Map < String , Object > content = getCached ( keySpace , contentColumnFamily , contentId ) ; if ( content == null || content . size ( ) == 0 && TRUE . equals ( content . get ( DELETED_FIELD ) ) ) { throw new StorageClientException ( "The source content to move from " + from + " does not exist, move operation failed" ) ; } } Map < String , Object > toStructure = getCached ( keySpace , contentColumnFamily , to ) ; if ( exists ( toStructure ) ) { String contentId = ( String ) toStructure . get ( STRUCTURE_UUID_FIELD ) ; Map < String , Object > content = getCached ( keySpace , contentColumnFamily , contentId ) ; if ( exists ( content ) ) { throw new StorageClientException ( "The destination content to move to " + to + "  exists, move operation failed" ) ; } } String idStore = ( String ) fromStructure . get ( STRUCTURE_UUID_FIELD ) ; // move the content to the new location , then delete the old .
if ( ! StorageClientUtils . isRoot ( to ) ) { // if not a root , modify the new parent location , creating the
// structured if necessary
String parent = StorageClientUtils . getParentObjectPath ( to ) ; Map < String , Object > parentToStructure = getCached ( keySpace , contentColumnFamily , parent ) ; if ( ! exists ( parentToStructure ) ) { // create a new parent
Content content = new Content ( parent , null ) ; update ( content ) ; } } // update the content data to reflect the new primary location .
putCached ( keySpace , contentColumnFamily , idStore , ImmutableMap . of ( PATH_FIELD , ( Object ) to ) , false ) ; // insert the new to Structure and remove the from
fromStructure . put ( PATH_FIELD , to ) ; putCached ( keySpace , contentColumnFamily , to , fromStructure , true ) ; // remove the old from .
putCached ( keySpace , contentColumnFamily , from , ImmutableMap . of ( DELETED_FIELD , ( Object ) TRUE ) , false ) ; // move does not add resourceTypes to events .
eventListener . onDelete ( Security . ZONE_CONTENT , from , accessControlManager . getCurrentUserId ( ) , null , null , "op:move" ) ; eventListener . onUpdate ( Security . ZONE_CONTENT , to , accessControlManager . getCurrentUserId ( ) , null , true , null , "op:move" ) ; } finally { statsService . apiCall ( ContentManagerImpl . class . getName ( ) , "move" , System . currentTimeMillis ( ) - t ) ; }


signature:
public class ContentManagerImpl { /** * TODO : Unit test */
public void link ( String from , String to ) throws AccessDeniedException , StorageClientException { } }

implementation:
// a link places a pointer to the content in the parent of from , but
// does not delete or modify the structure of to .
// read from is required and write to .
long t = System . currentTimeMillis ( ) ; try { checkOpen ( ) ; accessControlManager . check ( Security . ZONE_CONTENT , to , Permissions . CAN_READ ) ; accessControlManager . check ( Security . ZONE_CONTENT , from , Permissions . CAN_READ . combine ( Permissions . CAN_WRITE ) ) ; Map < String , Object > toStructure = getCached ( keySpace , contentColumnFamily , to ) ; if ( ! exists ( toStructure ) ) { throw new StorageClientException ( "The source content to link from " + to + " does not exist, link operation failed" ) ; } Map < String , Object > fromStructure = getCached ( keySpace , contentColumnFamily , from ) ; if ( exists ( fromStructure ) ) { throw new StorageClientException ( "The destination content to link to " + from + "  exists, link operation failed" ) ; } if ( StorageClientUtils . isRoot ( from ) ) { throw new StorageClientException ( "The link " + to + "  is a root, not possible to create a soft link" ) ; } // create a new structure object pointing back to the shared
// location
Object idStore = toStructure . get ( STRUCTURE_UUID_FIELD ) ; // if not a root , modify the new parent location , creating the
// structured if necessary
String parent = StorageClientUtils . getParentObjectPath ( from ) ; Map < String , Object > parentToStructure = getCached ( keySpace , contentColumnFamily , parent ) ; if ( ! exists ( parentToStructure ) ) { // create a new parent
Content content = new Content ( parent , null ) ; update ( content ) ; } // create the new object for the path , pointing to the Object
putCached ( keySpace , contentColumnFamily , from , ImmutableMap . of ( STRUCTURE_UUID_FIELD , idStore , PATH_FIELD , from , LINKED_PATH_FIELD , to , DELETED_FIELD , new RemoveProperty ( ) ) , true ) ; } finally { statsService . apiCall ( ContentManagerImpl . class . getName ( ) , "link" , System . currentTimeMillis ( ) - t ) ; }


signature:
public class ContentManagerImpl { /** * TODO : Unit test */
public InputStream getVersionInputStream ( String path , String versionId ) throws AccessDeniedException , StorageClientException , IOException { } }

implementation: return getVersionInputStream ( path , versionId , null ) ;


signature:
public class ContentManagerImpl { /** * TODO : Unit test */
public InputStream getVersionInputStream ( String path , String versionId , String streamId ) throws AccessDeniedException , StorageClientException , IOException { } }

implementation: long t = System . currentTimeMillis ( ) ; try { accessControlManager . check ( Security . ZONE_CONTENT , path , Permissions . CAN_READ ) ; checkOpen ( ) ; Map < String , Object > structure = getCached ( keySpace , contentColumnFamily , path ) ; if ( exists ( structure ) ) { String contentId = ( String ) structure . get ( STRUCTURE_UUID_FIELD ) ; Map < String , Object > content = getCached ( keySpace , contentColumnFamily , contentId ) ; if ( exists ( content ) ) { String versionHistoryId = ( String ) content . get ( VERSION_HISTORY_ID_FIELD ) ; if ( versionHistoryId != null ) { Map < String , Object > versionHistory = getCached ( keySpace , contentColumnFamily , versionHistoryId ) ; if ( versionHistory != null && versionHistory . containsKey ( versionId ) ) { return internalGetInputStream ( versionId , streamId ) ; } } } } return null ; } finally { statsService . apiCall ( ContentManagerImpl . class . getName ( ) , "egtVersionInputStream" , System . currentTimeMillis ( ) - t ) ; }


signature:
public class XMPPComponent { /** * ( non - Javadoc )
 * @ see
 * org . xmpp . component . AbstractComponent # handleIQResult ( org . xmpp . packet . IQ ) */
@ Override protected void handleIQResult ( IQ iq ) { } }

implementation: String packetCallbackId = iq . getID ( ) + "@" + iq . getFrom ( ) . toBareJID ( ) ; PacketCallback callback = packetCallbacks . get ( packetCallbackId ) ; if ( callback != null ) { callback . handle ( iq ) ; packetCallbacks . remove ( packetCallbackId ) ; }


signature:
public class XMPPComponent { /** * ( non - Javadoc )
 * @ see
 * org . jamppa . component . PacketSender # syncSendPacket ( org . xmpp . packet . Packet ) */
@ Override public Packet syncSendPacket ( Packet packet ) { } }

implementation: final BlockingQueue < Packet > queue = new ArrayBlockingQueue < Packet > ( 1 ) ; packetCallbacks . put ( packet . getID ( ) + "@" + packet . getTo ( ) . toBareJID ( ) , new PacketCallback ( ) { @ Override public void handle ( Packet packet ) { queue . add ( packet ) ; } } ) ; send ( packet ) ; try { return queue . poll ( timeOutMilliSeconds , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } finally { packetCallbacks . remove ( packet . getID ( ) ) ; }


signature:
public class MusicUsageResource { /** * gets whether the request is permanent ( = permanent resource is available and true )
 * @ param eventModel the EventModel
 * @ return true if permanent */
public static boolean isPermanent ( EventModel eventModel ) { } }

implementation: if ( eventModel . getListResourceContainer ( ) . containsResourcesFromSource ( ID ) ) { return eventModel . getListResourceContainer ( ) . provideResource ( ID ) . stream ( ) . map ( ResourceModel :: getResource ) . filter ( ob -> ob instanceof Boolean ) . map ( ob -> ( Boolean ) ob ) . findAny ( ) . orElse ( false ) ; } else { return false ; }


signature:
public class MusicUsageResource { /** * returns true if the resource is true , otherwise returns false
 * @ param resourceModel the resourceModel
 * @ return true if permanent */
public static boolean isPermanent ( ResourceModel resourceModel ) { } }

implementation: Object resource = resourceModel . getResource ( ) ; try { return ( Boolean ) resource ; } catch ( ClassCastException e ) { return false ; }


signature:
public class RosterGroup { /** * Sets the name of the group . Changing the group ' s name is like moving all
 * the group entries of the group to a new group specified by the new name .
 * Since this group won ' t have entries it will be removed from the roster .
 * This means that all the references to this object will be invalid and
 * will need to be updated to the new group specified by the new name .
 * @ param name
 * the name of the group . */
public void setName ( String name ) { } }

implementation: synchronized ( entries ) { for ( RosterEntry entry : entries ) { Roster packet = new Roster ( ) ; packet . setType ( IQ . Type . set ) ; List < String > groupNames = new LinkedList < String > ( entry . getGroupNames ( ) ) ; groupNames . remove ( this . name ) ; groupNames . add ( name ) ; packet . addItem ( new JID ( entry . getUser ( ) ) , entry . getName ( ) , entry . getAsk ( ) , entry . getSubscription ( ) , groupNames ) ; connection . sendPacket ( packet ) ; } }


signature:
public class RosterGroup { /** * Returns the roster entry associated with the given XMPP address or
 * < tt > null < / tt > if the user is not an entry in the group .
 * @ param user
 * the XMPP address of the user ( eg " jsmith @ example . com " ) .
 * @ return the roster entry or < tt > null < / tt > if it does not exist in the
 * group . */
public RosterEntry getEntry ( String user ) { } }

implementation:
if ( user == null ) { return null ; } // Roster entries never include a resource so remove the resource
// if it ' s a part of the XMPP address .
user = StringUtils . parseBareAddress ( user ) ; String userLowerCase = user . toLowerCase ( ) ; synchronized ( entries ) { for ( RosterEntry entry : entries ) { if ( entry . getUser ( ) . equals ( userLowerCase ) ) { return entry ; } } } return null ;


signature:
public class RosterGroup { /** * Adds a roster entry to this group . If the entry was unfiled then it will
 * be removed from the unfiled list and will be added to this group . Note
 * that this is an asynchronous call - - Smack must wait for the server to
 * receive the updated roster .
 * @ param entry
 * a roster entry .
 * @ throws XMPPException
 * if an error occured while trying to add the entry to the
 * group . */
public void addEntry ( RosterEntry entry ) throws XMPPException { } }

implementation:
PacketCollector collector = null ; // Only add the entry if it isn ' t already in the list .
synchronized ( entries ) { if ( ! entries . contains ( entry ) ) { Roster packet = new Roster ( ) ; packet . setType ( IQ . Type . set ) ; List < String > groupNames = new LinkedList < String > ( entry . getGroupNames ( ) ) ; groupNames . add ( getName ( ) ) ; packet . addItem ( new JID ( entry . getUser ( ) ) , entry . getName ( ) , entry . getAsk ( ) , entry . getSubscription ( ) , groupNames ) ; // Wait up to a certain number of seconds for a reply from the
// server .
collector = connection . createPacketCollector ( new PacketIDFilter ( packet . getID ( ) ) ) ; connection . sendPacket ( packet ) ; } } if ( collector != null ) { IQ response = ( IQ ) collector . nextResult ( SmackConfiguration . getPacketReplyTimeout ( ) ) ; collector . cancel ( ) ; if ( response == null ) { throw new XMPPException ( "No response from the server." ) ; } // If the server replied with an error , throw an exception .
else if ( response . getType ( ) == IQ . Type . error ) { throw new XMPPException ( response . getError ( ) ) ; } }


signature:
public class AbstractHashedMap { /** * Gets the value mapped to the key specified .
 * @ param key
 * the key
 * @ return the mapped value , null if no match */
public V get ( Object key ) { } }

implementation:
int hashCode = hash ( ( key == null ) ? NULL : key ) ; HashEntry < K , V > entry = data [ hashIndex ( hashCode , data . length ) ] ; // no
// local
// for
// hash
// index
while ( entry != null ) { if ( entry . hashCode == hashCode && isEqualKey ( key , entry . key ) ) { return entry . getValue ( ) ; } entry = entry . next ; } return null ;


signature:
public class AbstractHashedMap { /** * Checks whether the map contains the specified key .
 * @ param key
 * the key to search for
 * @ return true if the map contains the key */
public boolean containsKey ( Object key ) { } }

implementation:
int hashCode = hash ( ( key == null ) ? NULL : key ) ; HashEntry entry = data [ hashIndex ( hashCode , data . length ) ] ; // no local
// for hash
// index
while ( entry != null ) { if ( entry . hashCode == hashCode && isEqualKey ( key , entry . getKey ( ) ) ) { return true ; } entry = entry . next ; } return false ;


signature:
public class AbstractHashedMap { /** * Checks whether the map contains the specified value .
 * @ param value
 * the value to search for
 * @ return true if the map contains the value */
public boolean containsValue ( Object value ) { } }

implementation: if ( value == null ) { for ( int i = 0 , isize = data . length ; i < isize ; i ++ ) { HashEntry entry = data [ i ] ; while ( entry != null ) { if ( entry . getValue ( ) == null ) { return true ; } entry = entry . next ; } } } else { for ( int i = 0 , isize = data . length ; i < isize ; i ++ ) { HashEntry entry = data [ i ] ; while ( entry != null ) { if ( isEqualValue ( value , entry . getValue ( ) ) ) { return true ; } entry = entry . next ; } } } return false ;


signature:
public class AbstractHashedMap { /** * Puts a key - value mapping into this map .
 * @ param key
 * the key to add
 * @ param value
 * the value to add
 * @ return the value previously mapped to this key , null if none */
public V put ( K key , V value ) { } }

implementation: int hashCode = hash ( ( key == null ) ? NULL : key ) ; int index = hashIndex ( hashCode , data . length ) ; HashEntry < K , V > entry = data [ index ] ; while ( entry != null ) { if ( entry . hashCode == hashCode && isEqualKey ( key , entry . getKey ( ) ) ) { V oldValue = entry . getValue ( ) ; updateEntry ( entry , value ) ; return oldValue ; } entry = entry . next ; } addMapping ( index , hashCode , key , value ) ; return null ;


signature:
public class AbstractHashedMap { /** * Puts all the values from the specified map into this map .
 * This implementation iterates around the specified map and uses
 * { @ link # put ( Object , Object ) } .
 * @ param map
 * the map to add
 * @ throws NullPointerException
 * if the map is null */
public void putAll ( Map < ? extends K , ? extends V > map ) { } }

implementation:
int mapSize = map . size ( ) ; if ( mapSize == 0 ) { return ; } int newSize = ( int ) ( ( size + mapSize ) / loadFactor + 1 ) ; ensureCapacity ( calculateNewCapacity ( newSize ) ) ; // Have to cast here because of compiler inference problems .
for ( Iterator it = map . entrySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { Map . Entry < ? extends K , ? extends V > entry = ( Map . Entry < ? extends K , ? extends V > ) it . next ( ) ; put ( entry . getKey ( ) , entry . getValue ( ) ) ; }


signature:
public class AbstractHashedMap { /** * Removes the specified mapping from this map .
 * @ param key
 * the mapping to remove
 * @ return the value mapped to the removed key , null if key not in map */
public V remove ( Object key ) { } }

implementation: int hashCode = hash ( ( key == null ) ? NULL : key ) ; int index = hashIndex ( hashCode , data . length ) ; HashEntry < K , V > entry = data [ index ] ; HashEntry < K , V > previous = null ; while ( entry != null ) { if ( entry . hashCode == hashCode && isEqualKey ( key , entry . getKey ( ) ) ) { V oldValue = entry . getValue ( ) ; removeMapping ( entry , index , previous ) ; return oldValue ; } previous = entry ; entry = entry . next ; } return null ;


signature:
public class AbstractHashedMap { /** * Clears the map , resetting the size to zero and nullifying references to
 * avoid garbage collection issues . */
public void clear ( ) { } }

implementation: modCount ++ ; HashEntry [ ] data = this . data ; for ( int i = data . length - 1 ; i >= 0 ; i -- ) { data [ i ] = null ; } size = 0 ;


signature:
public class AbstractHashedMap { /** * Gets the hash code for the key specified . This implementation uses the
 * additional hashing routine from JDK1.4 . Subclasses can override this to
 * return alternate hash codes .
 * @ param key
 * the key to get a hash code for
 * @ return the hash code */
protected int hash ( Object key ) { } }


signature:
public class AbstractHashedMap { /** * Compares two keys , in internal converted form , to see if they are equal .
 * This implementation uses the equals method . Subclasses can override this
 * to match differently .
 * @ param key1
 * the first key to compare passed in from outside
 * @ param key2
 * the second key extracted from the entry via
 * < code > entry . key < / code >
 * @ return true if equal */
protected boolean isEqualKey ( Object key1 , Object key2 ) { } }

implementation: return ( key1 == key2 || ( ( key1 != null ) && key1 . equals ( key2 ) ) ) ;


signature:
public class AbstractHashedMap { /** * Compares two values , in external form , to see if they are equal . This
 * implementation uses the equals method and assumes neither value is null .
 * Subclasses can override this to match differently .
 * @ param value1
 * the first value to compare passed in from outside
 * @ param value2
 * the second value extracted from the entry via
 * < code > getValue ( ) < / code >
 * @ return true if equal */
protected boolean isEqualValue ( Object value1 , Object value2 ) { } }

implementation: return ( value1 == value2 || value1 . equals ( value2 ) ) ;


signature:
public class AbstractHashedMap { /** * Gets the entry mapped to the key specified .
 * This method exists for subclasses that may need to perform a multi - step
 * process accessing the entry . The public methods in this class don ' t use
 * this method to gain a small performance boost .
 * @ param key
 * the key
 * @ return the entry , null if no match */
protected HashEntry < K , V > getEntry ( Object key ) { } }

implementation:
int hashCode = hash ( ( key == null ) ? NULL : key ) ; HashEntry < K , V > entry = data [ hashIndex ( hashCode , data . length ) ] ; // no
// local
// for
// hash
// index
while ( entry != null ) { if ( entry . hashCode == hashCode && isEqualKey ( key , entry . getKey ( ) ) ) { return entry ; } entry = entry . next ; } return null ;


signature:
public class AbstractHashedMap { /** * Updates an existing key - value mapping to change the value .
 * This implementation calls < code > setValue ( ) < / code > on the entry .
 * Subclasses could override to handle changes to the map .
 * @ param entry
 * the entry to update
 * @ param newValue
 * the new value to store */
protected void updateEntry ( HashEntry < K , V > entry , V newValue ) { } }

implementation: entry . setValue ( newValue ) ;


signature:
public class AbstractHashedMap { /** * Reuses an existing key - value mapping , storing completely new data .
 * This implementation sets all the data fields on the entry . Subclasses
 * could populate additional entry fields .
 * @ param entry
 * the entry to update , not null
 * @ param hashIndex
 * the index in the data array
 * @ param hashCode
 * the hash code of the key to add
 * @ param key
 * the key to add
 * @ param value
 * the value to add */
protected void reuseEntry ( HashEntry < K , V > entry , int hashIndex , int hashCode , K key , V value ) { } }

implementation: entry . next = data [ hashIndex ] ; entry . hashCode = hashCode ; entry . key = key ; entry . value = value ;


signature:
public class AbstractHashedMap { /** * Adds a new key - value mapping into this map .
 * This implementation calls < code > createEntry ( ) < / code > ,
 * < code > addEntry ( ) < / code > and < code > checkCapacity ( ) < / code > . It also handles
 * changes to < code > modCount < / code > and < code > size < / code > . Subclasses could
 * override to fully control adds to the map .
 * @ param hashIndex
 * the index into the data array to store at
 * @ param hashCode
 * the hash code of the key to add
 * @ param key
 * the key to add
 * @ param value
 * the value to add */
protected void addMapping ( int hashIndex , int hashCode , K key , V value ) { } }

implementation: modCount ++ ; HashEntry < K , V > entry = createEntry ( data [ hashIndex ] , hashCode , key , value ) ; addEntry ( entry , hashIndex ) ; size ++ ; checkCapacity ( ) ;


signature:
public class AbstractHashedMap { /** * Removes a mapping from the map .
 * This implementation calls < code > removeEntry ( ) < / code > and
 * < code > destroyEntry ( ) < / code > . It also handles changes to
 * < code > modCount < / code > and < code > size < / code > . Subclasses could override to
 * fully control removals from the map .
 * @ param entry
 * the entry to remove
 * @ param hashIndex
 * the index into the data structure
 * @ param previous
 * the previous entry in the chain */
protected void removeMapping ( HashEntry < K , V > entry , int hashIndex , HashEntry < K , V > previous ) { } }

implementation: modCount ++ ; removeEntry ( entry , hashIndex , previous ) ; size -- ; destroyEntry ( entry ) ;


signature:
public class AbstractHashedMap { /** * Removes an entry from the chain stored in a particular index .
 * This implementation removes the entry from the data storage table . The
 * size is not updated . Subclasses could override to handle changes to the
 * map .
 * @ param entry
 * the entry to remove
 * @ param hashIndex
 * the index into the data structure
 * @ param previous
 * the previous entry in the chain */
protected void removeEntry ( HashEntry < K , V > entry , int hashIndex , HashEntry < K , V > previous ) { } }

implementation: if ( previous == null ) { data [ hashIndex ] = entry . next ; } else { previous . next = entry . next ; }


signature:
public class AbstractHashedMap { /** * Kills an entry ready for the garbage collector .
 * This implementation prepares the HashEntry for garbage collection .
 * Subclasses can override this to implement caching ( override clear as
 * well ) .
 * @ param entry
 * the entry to destroy */
protected void destroyEntry ( HashEntry < K , V > entry ) { } }

implementation: entry . next = null ; entry . key = null ; entry . value = null ;


signature:
public class AbstractHashedMap { /** * Checks the capacity of the map and enlarges it if necessary .
 * This implementation uses the threshold to check if the map needs
 * enlarging */
protected void checkCapacity ( ) { } }

implementation: if ( size >= threshold ) { int newCapacity = data . length * 2 ; if ( newCapacity <= MAXIMUM_CAPACITY ) { ensureCapacity ( newCapacity ) ; } }


signature:
public class AbstractHashedMap { /** * Changes the size of the data structure to the capacity proposed .
 * @ param newCapacity
 * the new capacity of the array ( a power of two , less or equal
 * to max ) */
protected void ensureCapacity ( int newCapacity ) { } }

implementation:
int oldCapacity = data . length ; if ( newCapacity <= oldCapacity ) { return ; } if ( size == 0 ) { threshold = calculateThreshold ( newCapacity , loadFactor ) ; data = new HashEntry [ newCapacity ] ; } else { HashEntry < K , V > oldEntries [ ] = data ; HashEntry < K , V > newEntries [ ] = new HashEntry [ newCapacity ] ; modCount ++ ; for ( int i = oldCapacity - 1 ; i >= 0 ; i -- ) { HashEntry < K , V > entry = oldEntries [ i ] ; if ( entry != null ) { oldEntries [ i ] = null ; // gc
do { HashEntry < K , V > next = entry . next ; int index = hashIndex ( entry . hashCode , newCapacity ) ; entry . next = newEntries [ index ] ; newEntries [ index ] = entry ; entry = next ; } while ( entry != null ) ; } } threshold = calculateThreshold ( newCapacity , loadFactor ) ; data = newEntries ; }


signature:
public class AbstractHashedMap { /** * Calculates the new capacity of the map . This implementation normalizes
 * the capacity to a power of two .
 * @ param proposedCapacity
 * the proposed capacity
 * @ return the normalized new capacity */
protected int calculateNewCapacity ( int proposedCapacity ) { } }

implementation:
int newCapacity = 1 ; if ( proposedCapacity > MAXIMUM_CAPACITY ) { newCapacity = MAXIMUM_CAPACITY ; } else { while ( newCapacity < proposedCapacity ) { newCapacity <<= 1 ; // multiply by two
} if ( newCapacity > MAXIMUM_CAPACITY ) { newCapacity = MAXIMUM_CAPACITY ; } } return newCapacity ;


signature:
public class AbstractHashedMap { /** * Gets the < code > next < / code > field from a < code > HashEntry < / code > . Used in
 * subclasses that have no visibility of the field .
 * @ param entry
 * the entry to query , must not be null
 * @ return the < code > next < / code > field of the entry
 * @ throws NullPointerException
 * if the entry is null
 * @ since Commons Collections 3.1 */
protected HashEntry < K , V > entryNext ( HashEntry < K , V > entry ) { } }

implementation: return entry . next ;


signature:
public class AbstractHashedMap { /** * Gets an iterator over the map . Changes made to the iterator affect this
 * map .
 * A MapIterator returns the keys in the map . It also provides convenient
 * methods to get the key and value , and set the value . It avoids the need
 * to create an entrySet / keySet / values object . It also avoids creating the
 * Map . Entry object .
 * @ return the map iterator */
public MapIterator < K , V > mapIterator ( ) { } }

implementation: if ( size == 0 ) { return EmptyMapIterator . INSTANCE ; } return new HashMapIterator < K , V > ( this ) ;


signature:
public class AbstractHashedMap { /** * Creates an entry set iterator . Subclasses can override this to return
 * iterators with different properties .
 * @ return the entrySet iterator */
protected Iterator < Map . Entry < K , V > > createEntrySetIterator ( ) { } }

implementation: if ( size ( ) == 0 ) { return EmptyIterator . INSTANCE ; } return new EntrySetIterator < K , V > ( this ) ;


signature:
public class AbstractHashedMap { /** * Gets the keySet view of the map . Changes made to the view affect this
 * map . To simply iterate through the keys , use { @ link # mapIterator ( ) } .
 * @ return the keySet view */
public Set < K > keySet ( ) { } }

implementation: if ( keySet == null ) { keySet = new KeySet < K , V > ( this ) ; } return keySet ;


signature:
public class AbstractHashedMap { /** * Writes the map data to the stream . This method must be overridden if a
 * subclass must be setup before < code > put ( ) < / code > is used .
 * Serialization is not one of the JDK ' s nicest topics . Normal serialization
 * will initialise the superclass before the subclass . Sometimes however ,
 * this isn ' t what you want , as in this case the < code > put ( ) < / code > method
 * on read can be affected by subclass state .
 * The solution adopted here is to serialize the state data of this class in
 * this protected method . This method must be called by the
 * < code > writeObject ( ) < / code > of the first serializable subclass .
 * Subclasses may override if they have a specific field that must be
 * present on read before this implementation will work . Generally , the read
 * determines what must be serialized here , if anything .
 * @ param out
 * the output stream */
protected void doWriteObject ( ObjectOutputStream out ) throws IOException { } }

implementation: out . writeFloat ( loadFactor ) ; out . writeInt ( data . length ) ; out . writeInt ( size ) ; for ( MapIterator it = mapIterator ( ) ; it . hasNext ( ) ; ) { out . writeObject ( it . next ( ) ) ; out . writeObject ( it . getValue ( ) ) ; }


signature:
public class AbstractHashedMap { /** * Reads the map data from the stream . This method must be overridden if a
 * subclass must be setup before < code > put ( ) < / code > is used .
 * Serialization is not one of the JDK ' s nicest topics . Normal serialization
 * will initialise the superclass before the subclass . Sometimes however ,
 * this isn ' t what you want , as in this case the < code > put ( ) < / code > method
 * on read can be affected by subclass state .
 * The solution adopted here is to deserialize the state data of this class
 * in this protected method . This method must be called by the
 * < code > readObject ( ) < / code > of the first serializable subclass .
 * Subclasses may override if the subclass has a specific field that must be
 * present before < code > put ( ) < / code > or < code > calculateThreshold ( ) < / code >
 * will work correctly .
 * @ param in
 * the input stream */
protected void doReadObject ( ObjectInputStream in ) throws IOException , ClassNotFoundException { } }

implementation: loadFactor = in . readFloat ( ) ; int capacity = in . readInt ( ) ; int size = in . readInt ( ) ; init ( ) ; data = new HashEntry [ capacity ] ; for ( int i = 0 ; i < size ; i ++ ) { K key = ( K ) in . readObject ( ) ; V value = ( V ) in . readObject ( ) ; put ( key , value ) ; } threshold = calculateThreshold ( data . length , loadFactor ) ;


signature:
public class Types { /** * Load a Map from binary stream
 * @ param output
 * @ param binaryStream
 * @ throws IOException */
public static void loadFromStream ( String key , Map < String , Object > output , InputStream binaryStream , String type ) throws IOException { } }

implementation: DataInputStream dis = new DataInputStream ( binaryStream ) ; String ckey = dis . readUTF ( ) ; if ( ! key . equals ( ckey ) ) { throw new IOException ( "Body Key does not match row key, unable to read" ) ; } readMapFromStream ( output , dis ) ; String cftype = null ; try { cftype = dis . readUTF ( ) ; } catch ( IOException e ) { LOGGER . debug ( "No type specified" ) ; } if ( cftype != null && ! cftype . equals ( type ) ) { throw new IOException ( "Object is not of expected column family, unable to read expected [" + type + "] was [" + cftype + "]" ) ; } LOGGER . debug ( "Finished Reading" ) ; dis . close ( ) ; binaryStream . close ( ) ;


signature:
public class Types { /** * the data isnt there . See the last writeUTF for an example . */
public static InputStream storeMapToStream ( String key , Map < String , Object > m , String type ) throws IOException { } }

implementation:
ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; DataOutputStream dos = new DataOutputStream ( baos ) ; dos . writeUTF ( key ) ; writeMapToStream ( m , dos ) ; // add the type in
dos . writeUTF ( type ) ; dos . flush ( ) ; baos . flush ( ) ; byte [ ] b = baos . toByteArray ( ) ; baos . close ( ) ; dos . close ( ) ; return new ByteArrayInputStream ( b ) ;


signature:
public class Types { /** * the data isnt there . See the last writeUTF for an example . */
public static void writeMapToStream ( Map < String , Object > m , DataOutputStream dos ) throws IOException { } }

implementation: int size = 0 ; for ( Entry < String , ? > e : m . entrySet ( ) ) { Object o = e . getValue ( ) ; if ( o != null && ! ( o instanceof RemoveProperty ) ) { size ++ ; } } dos . writeInt ( size ) ; LOGGER . debug ( "Write {} items" , size ) ; for ( Entry < String , ? > e : m . entrySet ( ) ) { Object o = e . getValue ( ) ; if ( o != null && ! ( o instanceof RemoveProperty ) ) { String k = e . getKey ( ) ; LOGGER . debug ( "Write {} " , k ) ; dos . writeUTF ( k ) ; Type < ? > t = getTypeOfObject ( o ) ; dos . writeInt ( t . getTypeId ( ) ) ; t . save ( dos , o ) ; } } LOGGER . debug ( "Finished Writen {} items" , size ) ;


signature:
public class AddOn { /** * This method is used to register the modules */
@ Override public void register ( ) { } }

implementation: prepare ( ) ; ContentGenerator [ ] contentGenerators = registerContentGenerator ( ) ; if ( contentGenerators != null ) { for ( ContentGenerator contentGenerator : contentGenerators ) { try { getContext ( ) . getContentGenerators ( ) . registerContentGenerator ( contentGenerator ) ; } catch ( IllegalIDException e ) { context . getLogger ( ) . fatal ( "Illegal Id for Module: " + contentGenerator . getID ( ) , e ) ; } } } EventsControllerModel [ ] eventsControllerModels = registerEventController ( ) ; if ( eventsControllerModels != null ) { for ( EventsControllerModel eventsController : eventsControllerModels ) { try { getContext ( ) . getEvents ( ) . distributor ( ) . registerEventsController ( eventsController ) ; } catch ( IllegalIDException e ) { context . getLogger ( ) . fatal ( "Illegal Id for Module: " + eventsController . getID ( ) , e ) ; } } } OutputPluginModel [ ] outputPluginModels = registerOutputPlugin ( ) ; if ( outputPluginModels != null ) { for ( OutputPluginModel outputPlugin : outputPluginModels ) { try { getContext ( ) . getOutput ( ) . addOutputPlugin ( outputPlugin ) ; } catch ( IllegalIDException e ) { context . getLogger ( ) . fatal ( "Illegal Id for Module: " + outputPlugin . getID ( ) , e ) ; } } } OutputExtensionModel [ ] outputExtensionModels = registerOutputExtension ( ) ; if ( outputExtensionModels != null ) { for ( OutputExtensionModel outputExtension : outputExtensionModels ) { try { getContext ( ) . getOutput ( ) . addOutputExtension ( outputExtension ) ; } catch ( IllegalIDException e ) { context . getLogger ( ) . fatal ( "Illegal Id for Module: " + outputExtension . getID ( ) , e ) ; } } } OutputControllerModel [ ] outputControllerModels = registerOutputController ( ) ; if ( outputControllerModels != null ) { for ( OutputControllerModel outputController : outputControllerModels ) { try { getContext ( ) . getOutput ( ) . addOutputController ( outputController ) ; } catch ( IllegalIDException e ) { context . getLogger ( ) . fatal ( "Illegal Id for Module: " + outputController . getID ( ) , e ) ; } } } ActivatorModel [ ] activatorModels = registerActivator ( ) ; getContext ( ) . getSystem ( ) . registerInitializedListener ( ( ) -> { if ( activatorModels != null ) { for ( ActivatorModel activator : activatorModels ) { try { getContext ( ) . getActivators ( ) . addActivator ( activator ) ; } catch ( IllegalIDException e ) { context . getLogger ( ) . fatal ( "Illegal Id for Module: " + activator . getID ( ) , e ) ; } } } } ) ;


signature:
public class AddOn { /** * Internal initiation of addOn - fake constructor , comes before prepare
 * @ param context the context to initialize with */
@ Override public void initAddOn ( org . intellimate . izou . system . Context context ) { } }

implementation: this . context = new Context ( context ) ;


signature:
public class ReconnectionManager { /** * Fires listeners when a reconnection attempt has failed .
 * @ param exception
 * the exception that occured . */
protected void notifyReconnectionFailed ( Exception exception ) { } }

implementation: if ( isReconnectionAllowed ( ) ) { for ( ConnectionListener listener : connection . connectionListeners ) { listener . reconnectionFailed ( exception ) ; } }


signature:
public class ReconnectionManager { /** * Fires listeners when The Connection will retry a reconnection . Expressed
 * in seconds .
 * @ param seconds
 * the number of seconds that a reconnection will be attempted
 * in . */
protected void notifyAttemptToReconnectIn ( int seconds ) { } }

implementation: if ( isReconnectionAllowed ( ) ) { for ( ConnectionListener listener : connection . connectionListeners ) { listener . reconnectingIn ( seconds ) ; } }