signature:
public class ModelUtils { /** * Finds the index of the first local name character in an ( non - relative )
 * URI . This index is determined by the following the following steps :
 * < ul >
 * < li > Find the < em > first < / em > occurrence of the ' # ' character ,
 * < li > If this fails , find the < em > last < / em > occurrence of the ' / ' character ,
 * < li > If this fails , find the < em > last < / em > occurrence of the ' : ' character .
 * < li > Add < tt > 1 < tt > to the found index and return this value .
 * < / ul >
 * Note that the third step should never fail as every legal ( non - relative )
 * URI contains at least one ' : ' character to separate the scheme from the
 * rest of the URI . If this fails anyway , the method will throw an
 * { @ link IllegalArgumentException } .
 * @ param uri
 * A URI string .
 * @ return The index of the first local name character in the URI string .
 * Note that this index does not reference an actual character if the
 * algorithm determines that there is not local name . In that case ,
 * the return index is equal to the length of the URI string .
 * @ throws IllegalArgumentException
 * If the supplied URI string doesn ' t contain any of the separator
 * characters . Every legal ( non - relative ) URI contains at least one
 * ' : ' character to separate the scheme from the rest of the URI . */
static int getLocalNameIndex ( String uri ) { } }

implementation: int separatorIdx = uri . indexOf ( HASH ) ; if ( separatorIdx < 0 ) { separatorIdx = uri . lastIndexOf ( SLASH ) ; } if ( separatorIdx < 0 ) { separatorIdx = uri . lastIndexOf ( COLON ) ; } if ( separatorIdx < 0 ) { throw new IllegalArgumentException ( "No separator character founds in URI: " + uri ) ; } return separatorIdx + 1 ;


signature:
public class ModelUtils { /** * Checks whether the URI consisting of the specified namespace and local
 * name has been split correctly according to the URI splitting rules
 * specified in { @ link URI } .
 * @ param namespace
 * The URI ' s namespace , must not be < tt > null < / tt > .
 * @ param localName
 * The URI ' s local name , must not be < tt > null < / tt > .
 * @ return < tt > true < / tt > if the specified URI has been correctly split into a
 * namespace and local name , < tt > false < / tt > otherwise .
 * @ see URI
 * @ see # getLocalNameIndex ( String ) */
static boolean isCorrectURISplit ( String namespace , String localName ) { } }

implementation: assert namespace != null : "namespace must not be null" ; assert localName != null : "localName must not be null" ; boolean result = false ; int nsLength = namespace . length ( ) ; if ( nsLength > 0 ) { char lastNsChar = namespace . charAt ( nsLength - 1 ) ; result = isCorrectHashNamespaceURISplit ( namespace , nsLength , lastNsChar ) || isCorrectSlashNamespaceURISplit ( namespace , localName , lastNsChar ) || isCorrectColonNamespaceURISplit ( namespace , localName , lastNsChar ) ; } return result ;


signature:
public class ImmutableQueryParameter { /** * { @ inheritDoc } */
@ Override public < T > T rawValueAs ( Class < ? extends T > clazz ) { } }

implementation: return ObjectUtil . fromString ( clazz , rawValue ( ) ) ;


signature:
public class ImmutableQueryParameter { /** * { @ inheritDoc } */
@ Override public < T > List < T > rawValuesAs ( Class < ? extends T > clazz ) { } }

implementation: Builder < T > builder = ImmutableList . < T > builder ( ) ; for ( String rawValue : this . rawValues ) { builder . add ( ObjectUtil . fromString ( clazz , rawValue ) ) ; } return builder . build ( ) ;


signature:
public class RuntimeDelegate { /** * Obtain a { @ code RuntimeInstance } instance using the method described in
 * { @ link # getInstance } .
 * @ return an instance of { @ code RuntimeInstance } . */
private static RuntimeDelegate findDelegate ( ) { } }

implementation: try { RuntimeDelegate result = createRuntimeInstanceFromSPI ( ) ; if ( result == null ) { result = createRuntimeInstanceFromConfigurationFile ( ) ; } if ( result == null ) { String delegateClassName = System . getProperty ( LDP4J_APPLICATION_SPI_PROPERTY ) ; if ( delegateClassName != null ) { result = createRuntimeInstanceForClassName ( delegateClassName ) ; } } if ( result == null ) { result = new DefaultRuntimeInstance ( ) ; } return result ; } catch ( Exception ex ) { throw new IllegalStateException ( "Could not find runtime delegate" , ex ) ; }


signature:
public class ApplicationContext { /** * Create a { @ code WriteSession } . Only one write session can be active per
 * thread . Sessions should not be shared among threads .
 * @ return the write session
 * @ throws ApplicationContextException
 * if no write session can be created for whichever reason ,
 * e . g . , the Application Engine is off - line or is not available . */
public synchronized WriteSession createSession ( ) throws ApplicationContextException { } }

implementation: if ( this . threadSession . containsKey ( Thread . currentThread ( ) . getId ( ) ) ) { throw failure ( "Thread already has an active session" ) ; } if ( this . delegate . isOffline ( ) ) { throw failure ( "The Application Engine is off-line" ) ; } WriteSession nativeSession = this . delegate . createSession ( ) ; if ( nativeSession == null ) { throw failure ( "Could not create native write session" ) ; } setUpWriteSessionCleaner ( ) ; return trackSession ( new ContextWriteSessionState ( nativeSession , new CleanerContextWriteSessionStateListener ( ) ) ) ;


signature:
public class HttpUtils { /** * Checks the given type name for illegal characters , as defined in RFC
 * 7230 , section 3.2.6.
 * @ param token
 * the string to validate
 * @ throws IllegalArgumentException
 * in case of illegal characters
 * @ see < a href = " http : / / tools . ietf . org / html / rfc7230 # section - 3.2.6 " > Hypertext
 * Transfer Protocol ( HTTP / 1.1 ) : Message Syntax and Routing , Section
 * 3.2.6 < / a > */
static void checkToken ( final String token , final String message , Object ... args ) { } }

implementation: checkNotNull ( message , "Message cannot be null" ) ; try { validateLength ( token ) ; validateCharacters ( token ) ; } catch ( IllegalArgumentException e ) { throw new InvalidTokenException ( String . format ( message , args ) , token , e ) ; }


signature:
public class Reflection { /** * TODO : Relax this constraint , it should be possible to do it from
 * named - inner classes .
 * @ param scopeClass
 * the parent class from which to retrieve the subclass in the
 * scope .
 * @ return the subclass of the specified that is within the scope if found ,
 * { @ code null } otherwise . */
public static Class < ? > getSubclassInScope ( final Class < ? > scopeClass ) { } }

implementation: final String callerClass = Thread . currentThread ( ) . getStackTrace ( ) [ 3 ] . getClassName ( ) ; try { final Class < ? > candidateClass = Class . forName ( callerClass , false , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; if ( ! scopeClass . isAssignableFrom ( candidateClass ) ) { return null ; } return candidateClass ; } catch ( final ClassNotFoundException e ) { throw new IllegalStateException ( "The class should always exist" , e ) ; }


signature:
public class DataTransformator { /** * Create transformator with the specified media type
 * @ param mediaType
 * the new media type
 * @ return a new transformator with the same configuration except for the
 * media type , which is set to the specified one
 * @ throws UnsupportedMediaTypeException
 * if the media type is not valid */
public DataTransformator mediaType ( MediaType mediaType ) { } }

implementation: checkNotNull ( mediaType , MEDIA_TYPE_CANNOT_BE_NULL ) ; DataTransformator result = new DataTransformator ( this ) ; result . setMediaType ( mediaType ) ; return result ;


signature:
public class RuntimeInstance { /** * Obtain a { @ code RuntimeInstance } instance using the method described in
 * { @ link # getInstance } .
 * @ return an instance of { @ code RuntimeInstance } . */
private static RuntimeInstance findDelegate ( ) { } }

implementation: try { RuntimeInstance result = createRuntimeInstanceFromSPI ( ) ; if ( result == null ) { result = createRuntimeInstanceFromConfigurationFile ( ) ; } if ( result == null ) { final String delegateClassName = System . getProperty ( RDF_API_SPI_PROPERTY ) ; if ( delegateClassName != null ) { result = createRuntimeInstanceForClassName ( delegateClassName ) ; } } if ( result == null ) { result = new DefaultRuntimeInstance ( ) ; } return result ; } catch ( final Exception ex ) { throw new IllegalStateException ( "Could not find runtime delegate" , ex ) ; }


signature:
public class InMemoryResource { /** * { @ inheritDoc } */
@ Override public Attachment findAttachment ( ResourceId resourceId ) { } }

implementation: checkNotNull ( resourceId , "Attached resource identifier cannot be null" ) ; return this . attachments . get ( this . attachmentsByResourceId . get ( resourceId ) ) ;


signature:
public class InMemoryResource { /** * { @ inheritDoc } */
@ Override public < T extends Resource > T attach ( String attachmentId , ResourceId resourceId , Class < ? extends T > clazz ) { } }

implementation: checkNotNull ( attachmentId , "Attachment identifier cannot be null" ) ; checkNotNull ( resourceId , "Attached resource identifier cannot be null" ) ; checkNotNull ( clazz , "Attached resource class cannot be null" ) ; AttachmentId aId = AttachmentId . createId ( attachmentId , resourceId ) ; checkState ( ! attachments . containsKey ( aId ) , "Resource '%s' is already attached as '%s'" , resourceId , attachmentId ) ; checkState ( ! attachmentsById . containsKey ( attachmentId ) , "A resource is already attached as '%s'" , attachmentId ) ; checkState ( ! attachmentsByResourceId . containsKey ( resourceId ) , "Resource '%s' is already attached" , resourceId ) ; ResourceTemplate attachmentTemplate = super . getTemplate ( resourceId ) ; checkState ( Resources . areCompatible ( clazz , attachmentTemplate ) , "Attachment '%s' is not of type '%s' (%s)" , attachmentId , clazz . getCanonicalName ( ) , attachmentTemplate . getClass ( ) . getCanonicalName ( ) ) ; InMemoryResource newResource = createChild ( resourceId , attachmentTemplate ) ; InMemoryAttachment newAttachment = new InMemoryAttachment ( aId , this . versionGenerator . nextVersion ( attachmentId ) ) ; attachments . put ( newAttachment . attachmentId ( ) , newAttachment ) ; attachmentsById . put ( aId . id ( ) , aId ) ; attachmentsByResourceId . put ( aId . resourceId ( ) , aId ) ; return clazz . cast ( newResource ) ;


signature:
public class InMemoryResource { /** * { @ inheritDoc } */
@ Override public boolean detach ( Attachment attachment ) { } }

implementation: boolean found = this . attachments . containsValue ( attachment ) ; if ( found ) { AttachmentId remove = this . attachmentsById . remove ( attachment . id ( ) ) ; this . attachmentsByResourceId . remove ( attachment . resourceId ( ) ) ; this . attachments . remove ( remove ) ; } return found ;


signature:
public class InMemoryResource { /** * { @ inheritDoc } */
@ Override public Set < InMemoryAttachment > attachments ( ) { } }

implementation: return Collections . unmodifiableSet ( new LinkedHashSet < InMemoryAttachment > ( this . attachments . values ( ) ) ) ;


signature:
public class InMemoryResource { /** * { @ inheritDoc } */
@ Override public Set < ConstraintReportId > constraintReports ( ) { } }

implementation: Set < ConstraintReportId > currentReports = null ; synchronized ( this ) { currentReports = ImmutableSet . copyOf ( this . reports . values ( ) ) ; } return currentReports ;


signature:
public class InMemoryResource { /** * { @ inheritDoc } */
@ Override public void removeFailure ( ConstraintReport report ) { } }

implementation: if ( report != null ) { String failureId = report . id ( ) . failureId ( ) ; synchronized ( this ) { this . reports . remove ( failureId ) ; } }


signature:
public class DateConverter { /** * { @ inheritDoc } */
@ Override public String convertToDatabaseColumn ( Date attribute ) { } }

implementation: if ( attribute == null ) { return null ; } return Long . toString ( attribute . getTime ( ) ) ;


signature:
public class DateConverter { /** * { @ inheritDoc } */
@ Override public Date convertToEntityAttribute ( String dbData ) { } }

implementation: if ( dbData == null ) { return null ; } return new Date ( Long . parseLong ( dbData ) ) ;


signature:
public class EndpointManagementService { /** * Enforce http : / / tools . ietf . org / html / rfc7232 # section - 2.2:
 * if the clock in the request is ahead of the clock of the origin
 * server ( e . g . , I request from Spain the update of a resource held in USA )
 * the last - modified data should be changed to that of the request and not
 * a generated date from the origin server */
private Date getModificationDate ( Endpoint endpoint , Date modificationDate ) { } }

implementation: Date result = endpoint . lastModified ( ) ; if ( modificationDate . after ( result ) ) { result = modificationDate ; } return result ;


signature:
public class InMemoryEndpointRepository { /** * { @ inheritDoc } */
@ Override public Endpoint endpointOfPath ( String path ) { } }

implementation: this . readLock . lock ( ) ; try { return this . endpointsByPath . get ( path ) ; } finally { this . readLock . unlock ( ) ; }


signature:
public class InMemoryEndpointRepository { /** * { @ inheritDoc } */
@ Override public Endpoint endpointOfResource ( ResourceId id ) { } }

implementation: this . readLock . lock ( ) ; try { Endpoint endpoint = this . endpointsByResourceName . get ( id ) ; if ( endpoint != null && endpoint . deleted ( ) != null ) { endpoint = null ; } return endpoint ; } finally { this . readLock . unlock ( ) ; }


signature:
public class InMemoryEndpointRepository { /** * { @ inheritDoc } */
@ Override public void add ( Endpoint endpoint ) { } }

implementation: this . writeLock . lock ( ) ; try { if ( this . endpointsByPath . containsKey ( endpoint . path ( ) ) ) { throw new IllegalArgumentException ( "An endpoint with path '" + endpoint . path ( ) + "' already exists" ) ; } Endpoint other = endpointOfResource ( endpoint . resourceId ( ) ) ; if ( other != null ) { throw new IllegalArgumentException ( "An endpoint with resource name '" + endpoint . resourceId ( ) + "' already exists (" + other + ")" ) ; } this . endpointsByPath . put ( endpoint . path ( ) , endpoint ) ; this . endpointsByResourceName . put ( endpoint . resourceId ( ) , endpoint ) ; } finally { this . writeLock . unlock ( ) ; }


signature:
public class InMemoryEndpointRepository { /** * { @ inheritDoc } */
@ Override public void shutdown ( ) throws LifecycleException { } }

implementation: this . writeLock . lock ( ) ; try { this . endpointsByPath . clear ( ) ; this . endpointsByResourceName . clear ( ) ; } finally { this . writeLock . unlock ( ) ; }


signature:
public class ContextWriteSessionState { /** * { @ inheritDoc } */
@ Override public synchronized < S extends ResourceSnapshot > S resolve ( Class < ? extends S > snapshotClass , Individual < ? , ? > individual ) { } }

implementation: verifyExecutability ( ) ; return this . delegate . resolve ( snapshotClass , individual ) ;


signature:
public class ContextWriteSessionState { /** * { @ inheritDoc } */
@ Override public synchronized < S extends ResourceSnapshot > S find ( Class < ? extends S > snapshotClass , Name < ? > id , Class < ? extends ResourceHandler > handlerClass ) { } }

implementation: verifyExecutability ( ) ; return this . delegate . find ( snapshotClass , id , handlerClass ) ;


signature:
public class EntityTagConverter { /** * { @ inheritDoc } */
@ Override public String convertToDatabaseColumn ( EntityTag attribute ) { } }

implementation: if ( attribute == null ) { return null ; } return attribute . toString ( ) ;


signature:
public class EntityTagConverter { /** * { @ inheritDoc } */
@ Override public EntityTag convertToEntityAttribute ( String dbData ) { } }

implementation: if ( dbData == null ) { return null ; } return EntityTag . valueOf ( dbData ) ;


signature:
public class MonitorizedPropertyPlaceholderConfigurer { /** * TODO : Enable selecting where the configuration should be logged to : System . out or a Logger */
@ Override protected Properties mergeProperties ( ) throws IOException { } }

implementation:
Properties result = super . mergeProperties ( ) ; if ( canShowConfiguration ( getModuleName ( ) ) ) { table . setProperties ( result ) ; table . dump ( System . out ) ; // NOSONAR
} return result ;


signature:
public class TypeAdapter { /** * Register a new adapter class .
 * @ param clazz
 * the adapter class .
 * @ throws NullPointerException
 * if the adapter class is { @ code null } . */
static void registerAdapterClass ( Class < ? > clazz ) { } }

implementation: Objects . requireNonNull ( clazz , "Adapter class cannot be null" ) ; TypeAdapter . ADAPTER_CLASSES . addIfAbsent ( clazz ) ;


signature:
public class TypeAdapter { /** * Get an adapter capable of transforming instances of a source type into
 * instances of a target type .
 * @ param sourceType
 * The type of the instances that the adapter should be able to
 * transform .
 * @ param targetType
 * The type of instances that the adapter should be able to
 * create .
 * @ return An adapter capable of transforming instances of the { @ code sourceType }
 * into instances of the { @ code targetType } .
 * @ throws CannotAdaptClassesException
 * when no adapter capable of carrying out such transformation
 * is available . */
static < S , T > TypeAdapter < S , T > createAdapter ( Class < ? extends S > sourceType , Class < ? extends T > targetType ) { } }

implementation: return doCreateAdapter ( targetType , AdapterMethodValidator . newInstance ( targetType , sourceType ) ) ;


signature:
public class TypeAdapter { /** * Transform a given object into an instance of the specified type .
 * @ param object
 * The object that is to be transformed .
 * @ param resultClass
 * The type of instance that is to be created .
 * @ return An instance of type { @ code resultClass } created upon the
 * specified @ object } .
 * @ throws CannotAdaptClassesException
 * when no adapter capable of carrying out such transformation
 * is available . */
static < S , T > T adapt ( S object , Class < ? extends T > resultClass ) { } }

implementation: return TypeAdapter . < S , T > doCreateAdapter ( resultClass , AdapterMethodValidator . newInstance ( resultClass , object ) ) . adapt ( object ) ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public < T > T firstValue ( final Class < ? extends T > aClazz ) { } }

implementation: Property property = getProperty ( ) ; if ( property == null ) { return null ; } LiteralValueExtractor < T > extractor = LiteralValueExtractor . newInstance ( aClazz ) ; for ( Value value : property ) { value . accept ( extractor ) ; if ( extractor . isAvailable ( ) ) { break ; } } return extractor . getValue ( ) ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualHelper firstIndividual ( ) { } }

implementation: Property property = getProperty ( ) ; if ( property == null ) { return null ; } for ( Value value : property ) { if ( value instanceof Individual < ? , ? > ) { return new IndividualHelperImpl ( ( Individual < ? , ? > ) value ) ; } } return null ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public < T extends Serializable , S extends Individual < T , S > > T firstIndividual ( final Class < ? extends S > clazz ) { } }

implementation: Property property = getProperty ( ) ; if ( property == null ) { return null ; } IndividualExtractor < T , S > extractor = IndividualExtractor . newInstance ( clazz ) ; for ( Value value : property ) { value . accept ( extractor ) ; if ( extractor . isAvailable ( ) ) { return extractor . getValue ( ) . id ( ) ; } } return null ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualPropertyHelper withLiteral ( Object rawValue ) { } }

implementation: if ( rawValue != null ) { Literal < ? > value = Literals . newLiteral ( rawValue ) ; this . individual . addValue ( this . propertyId , value ) ; } return new IndividualPropertyHelperImpl ( new IndividualHelperImpl ( this . individual ) , this ) ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualPropertyHelper withIndividual ( Name < ? > id ) { } }

implementation: if ( id != null ) { @ SuppressWarnings ( "rawtypes" ) Individual < ? , ? > srcIndividual = this . individual . dataSet ( ) . individual ( ( Name ) id , LocalIndividual . class ) ; this . individual . addValue ( this . propertyId , srcIndividual ) ; } return new IndividualPropertyHelperImpl ( new IndividualHelperImpl ( this . individual ) , this ) ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualPropertyHelper withIndividual ( Name < ? > id , String managerId ) { } }

implementation: if ( id != null ) { Individual < ? , ? > srcIndividual = this . individual . dataSet ( ) . individual ( ManagedIndividualId . createId ( id , managerId ) , ManagedIndividual . class ) ; this . individual . addValue ( this . propertyId , srcIndividual ) ; } return new IndividualPropertyHelperImpl ( new IndividualHelperImpl ( this . individual ) , this ) ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualPropertyHelper withIndividual ( Name < ? > id , String managerId , URI path ) { } }

implementation: if ( id != null ) { ManagedIndividualId parentId = ManagedIndividualId . createId ( id , managerId ) ; RelativeIndividualId individualId = RelativeIndividualId . createId ( parentId , path ) ; Individual < ? , ? > srcIndividual = this . individual . dataSet ( ) . individual ( individualId , RelativeIndividual . class ) ; this . individual . addValue ( this . propertyId , srcIndividual ) ; } return new IndividualPropertyHelperImpl ( new IndividualHelperImpl ( this . individual ) , this ) ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualPropertyHelper withIndividual ( Name < ? > id , String managerId , String path ) { } }

implementation: if ( id != null ) { return withIndividual ( id , managerId , URI . create ( path ) ) ; } return new IndividualPropertyHelperImpl ( new IndividualHelperImpl ( this . individual ) , this ) ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualPropertyHelper withIndividual ( URI id ) { } }

implementation: if ( id != null ) { Individual < ? , ? > srcIndividual = null ; if ( id . isAbsolute ( ) ) { srcIndividual = this . individual . dataSet ( ) . individual ( id , ExternalIndividual . class ) ; } else { srcIndividual = this . individual . dataSet ( ) . individual ( id , NewIndividual . class ) ; } this . individual . addValue ( this . propertyId , srcIndividual ) ; } return new IndividualPropertyHelperImpl ( new IndividualHelperImpl ( this . individual ) , this ) ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualPropertyHelper withIndividual ( String id ) { } }

implementation: if ( id != null ) { withIndividual ( URI . create ( id ) ) ; } return new IndividualPropertyHelperImpl ( new IndividualHelperImpl ( this . individual ) , this ) ;


signature:
public class PropertyHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualPropertyHelper withIndividual ( Term id ) { } }

implementation: if ( id != null ) { withIndividual ( id . qualifiedEntityName ( ) ) ; } return new IndividualPropertyHelperImpl ( new IndividualHelperImpl ( this . individual ) , this ) ;


signature:
public class RuntimeDelegate { /** * Obtain an { @ code RuntimeDelegate } instance using the method described
 * in { @ link RuntimeDelegate # getInstance ( ) } .
 * @ return an instance of { @ code RuntimeDelegate } if available , or null if
 * a default implementation class is to be selected . */
private static RuntimeDelegate findDelegate ( ) { } }

implementation: RuntimeDelegate result = null ; try { result = createRuntimeDelegateFromSPI ( ) ; if ( result == null ) { result = createRuntimeDelegateFromConfigurationFile ( ) ; } if ( result == null ) { String delegateClassName = System . getProperty ( APPLICATION_ENGINE_SPI_PROPERTY ) ; if ( delegateClassName != null ) { result = createRuntimeDelegateForClassName ( delegateClassName ) ; } } } catch ( Exception ex ) { LOGGER . warn ( "Could not find application engine" , ex ) ; } return result ;


signature:
public class RuntimeDelegate { /** * Set the { @ code RuntimeDelegate } that will be used by clients . If this method
 * is not called prior to { @ link RuntimeDelegate # getInstance ( ) } then an
 * implementation will be sought as described in
 * { @ link RuntimeDelegate # getInstance ( ) } .
 * @ param delegate
 * the { @ code RuntimeDelegate } runtime delegate instance .
 * @ throws SecurityException
 * if there is a security manager and the permission
 * ReflectPermission ( " suppressAccessChecks " ) has not been
 * granted . */
public static void setInstance ( final RuntimeDelegate delegate ) { } }

implementation: SecurityManager security = getSecurityManager ( ) ; if ( security != null ) { security . checkPermission ( SUPPRESS_ACCESS_CHECKS_PERMISSION ) ; } synchronized ( RuntimeDelegate . CACHED_DELEGATE ) { RuntimeDelegate . CACHED_DELEGATE . set ( delegate ) ; }


signature:
public class BooleanObjectFactory { /** * Returns a { @ code Boolean } with a value represented by the specified
 * string . The { @ code Boolean } returned represents :
 * < ol >
 * < li >
 * a { @ code true } value if the string argument is not { @ code null } and is equal ,
 * ignoring case , to the string { @ code " true " } . < / li >
 * < li >
 * a { @ code false } value if the string argument is not { @ code null } and is equal ,
 * ignoring case , to the string { @ code " false " } . < / li >
 * < / ol >
 * @ param rawValue
 * a string .
 * @ return the { @ code Boolean } value represented by the string .
 * @ throws ObjectParseException
 * iff the specified raw value cannot be converted to a
 * { @ code Boolean } object . */
@ Override public Boolean fromString ( final String rawValue ) { } }

implementation: try { return PrimitiveObjectFactory . parseBoolean ( rawValue ) ; } catch ( final IllegalArgumentException e ) { throw new ObjectParseException ( e , Boolean . class , rawValue ) ; }


signature:
public class ContentNegotiator { /** * Carry out the content negotiation taking into account both the supported
 * and the acceptable media types , character encodings , and languages .
 * The method implements a simplified version of the < b > Remote Variant
 * Selection Algorithm < / b > defined in < a
 * href = " https : / / tools . ietf . org / html / rfc2296 " > RFC 2296 < / a > .
 * The differences between the implemented algorithm and the original one
 * are the following :
 * < ol >
 * < li > There is no support for < i > features < / i > ,
 * < li > Variant < i > source - quality < / i > is assigned linearly ( with ratio
 * - 0.125 ) of the values suggested in Section 5.3 of RFC 2296;
 * < li > The < i > round5 < / i > function is not applied during the computation of
 * overall quality values .
 * < / ol >
 * The reason for this latter difference is that in the presence of
 * fine - grained qualities ( < i > i . e . < / i > , 0.001 ) computed quality values
 * converge to 10 < sup > - 12 < / sup > , and can make variants with non - zero
 * computed qualities appear like they are not amenable to selection .
 * @ return the result of the content negotiation
 * @ see < a href = " https : / / tools . ietf . org / html / rfc2296 " > RFC 2296 : HTTP Remote
 * Variant Selection Algorithm - - RVSA / 1.0 < / a > */
public NegotiationResult negotiate ( ) { } }

implementation: return new ContentNegotiationAlgorithm ( this . mediaTypes . build ( ) , this . characterEncodings . build ( ) , this . languages . build ( ) , this . supported . build ( ) , this . accepts . build ( ) , this . acceptCharsets . build ( ) , this . acceptLanguages . build ( ) , this . errorVariant ) . execute ( ) ;


signature:
public class ImmutableNamespaces { /** * Create a copy of the namespaces which includes a mapping between a given
 * prefix and namespace URI .
 * @ param prefix
 * the prefix to be added
 * @ param namespaceURI
 * the namespace URI to be mapped to the prefix
 * @ return a copy of the instance that includes the mapping between the
 * specified namespace URI and prefix .
 * @ throws NullPointerException if the prefix or namespace URI are null . */
public ImmutableNamespaces withPrefix ( String prefix , String namespaceURI ) { } }

implementation: Objects . requireNonNull ( prefix , "Prefix cannot be null" ) ; Objects . requireNonNull ( namespaceURI , "Namespace URI cannot be null" ) ; ImmutableNamespaces result = new ImmutableNamespaces ( this . map ) ; result . map . put ( prefix , namespaceURI ) ; return result ;


signature:
public class ImmutableNamespaces { /** * Create a copy of the namespaces without the prefixes .
 * @ param prefixes
 * the prefixes to be excluded from the copy
 * @ return a copy of the instance that excludes the mappings for the
 * specified prefixes . */
public ImmutableNamespaces withoutPrefix ( String ... prefixes ) { } }

implementation: ImmutableNamespaces result = new ImmutableNamespaces ( this . map ) ; for ( String prefix : prefixes ) { result . map . remove ( prefix ) ; } return result ;


signature:
public class ImmutableNamespaces { /** * { @ inheritDoc } */
@ Override public String getPrefix ( String namespaceURI ) { } }

implementation: for ( Entry < String , String > entry : this . map . entrySet ( ) ) { if ( entry . getValue ( ) . equals ( namespaceURI ) ) { return entry . getKey ( ) ; } } return null ;


signature:
public class ImmutableNamespaces { /** * { @ inheritDoc } */
@ Override public List < String > getPrefixes ( String namespaceURI ) { } }

implementation: List < String > list = new ArrayList < String > ( ) ; for ( Entry < String , String > entry : this . map . entrySet ( ) ) { if ( entry . getValue ( ) . equals ( namespaceURI ) ) { list . add ( entry . getKey ( ) ) ; } } return list ;


signature:
public class XMLUtils { /** * Escapes a character sequence so that it is valid XML .
 * @ param s
 * The character sequence .
 * @ return The escaped version of the character sequence . */
public static String escapeXML ( final CharSequence s ) { } }

implementation: final StringBuilder sb = new StringBuilder ( s . length ( ) * 2 ) ; final CodePointIterator iterator = new CodePointIterator ( s ) ; while ( iterator . hasNext ( ) ) { final int codePoint = iterator . next ( ) ; if ( codePoint == '<' ) { sb . append ( LT ) ; } else if ( codePoint == '>' ) { sb . append ( GT ) ; } else if ( codePoint == '\"' ) { sb . append ( QUOT ) ; } else if ( codePoint == '&' ) { sb . append ( AMP ) ; } else if ( codePoint == '\'' ) { sb . append ( APOS ) ; } else { sb . appendCodePoint ( codePoint ) ; } } return sb . toString ( ) ;


signature:
public class ValueEncoder { /** * { @ inheritDoc } */
@ SuppressWarnings ( "unchecked" ) @ Override protected < T extends Serializable > Name < T > assemble ( Serializable subject ) throws IOException { } }

implementation: return ( Name < T > ) NamingScheme . getDefault ( ) . name ( subject ) ;


signature:
public class QueryableResourceHandler { /** * Instead of retrieving the contents of the resource , return a description
 * of the query received . */
@ Override public DataSet query ( ResourceSnapshot resource , Query query , ReadSession session ) throws InvalidQueryException { } }

implementation: return QuerySupport . getDescription ( resource . name ( ) , query ) ;


signature:
public class InMemoryContainerHandler { /** * Add a name provider for a container resource .
 * @ param containerName
 * the name of the container .
 * @ param provider
 * the name provider . */
public final void addNameProvider ( Name < String > containerName , NameProvider provider ) { } }

implementation: this . nameProviders . put ( containerName , provider ) ;


signature:
public class InMemoryContainerHandler { /** * Return the name provider registered for a given container resource .
 * @ param containerName
 * the name of the container .
 * @ return the provider for the specified container resource . */
public final NameProvider nameProvider ( Name < ? > containerName ) { } }

implementation: NameProvider result = this . nameProviders . get ( containerName ) ; if ( result == null ) { throw new ApplicationRuntimeException ( "Unknown container '" + containerName + "'" ) ; } return result ;


signature:
public class MoreStrings { /** * Compares two CharSequences , returning { @ code true } if they represent
 * equal sequences of characters , ignoring case .
 * { @ code null } s are handled without exceptions . Two { @ code null }
 * references are considered equal . Comparison is case insensitive .
 * < pre >
 * equalsIgnoreCase ( null , null ) = true
 * equalsIgnoreCase ( null , " abc " ) = false
 * equalsIgnoreCase ( " abc " , null ) = false
 * equalsIgnoreCase ( " abc " , " abc " ) = true
 * equalsIgnoreCase ( " abc " , " ABC " ) = true
 * < / pre >
 * @ param str1
 * the first CharSequence , may be { @ code null }
 * @ param str2
 * the second CharSequence , may be { @ code null }
 * @ return { @ code true } if the CharSequence are equal , case insensitive ,
 * or both { @ code null } ; { @ code false } otherwise */
static boolean equalsIgnoreCase ( final CharSequence str1 , final CharSequence str2 ) { } }

implementation: if ( str1 == str2 ) { return true ; } else if ( str1 == null || str2 == null ) { return false ; } else if ( str1 . length ( ) != str2 . length ( ) ) { return false ; } else { return regionMatches ( str1 , true , 0 , str2 , 0 , str1 . length ( ) ) ; }


signature:
public class MoreStrings { /** * Tests if two { @ link CharSequence charsequence } regions are equal .
 * A region of the { @ code target } charsequence is compared to a region of
 * the { @ code other } charsequence . The result is { @ code true } if these regions
 * represent character sequences that are the same , ignoring case if and
 * only if { @ code ignoreCase } is true . The region of the { @ code target }
 * charsequence to be compared begins at index { @ code offset }
 * , whereas the region of the { @ code other } charsequence begins at index { @ code start } . Both
 * regions have a length { @ code length } .
 * The result is { @ code false } if and only if at least one of the following
 * is true :
 * < ul >
 * < li > { @ code toffset } is negative .
 * < li > { @ code ooffset } is negative .
 * < li > { @ code toffset + length } is greater than the length of { @ code target }
 * argument .
 * < li > { @ code ooffset + length } is greater than the length of { @ code other }
 * argument .
 * < li > { @ code ignoreCase } is { @ code false } and there is some nonnegative
 * integer < i > k < / i > less than { @ code length } such that : < blockquote >
 * < pre >
 * target . charAt ( toffset + k ) ! = other . charAt ( ooffset + k )
 * < / pre >
 * < / blockquote >
 * < li > { @ code ignoreCase } is { @ code true } and there is some nonnegative
 * integer < i > k < / i > less than { @ code length } such that : < blockquote >
 * < pre >
 * let :
 * char u1 = Character . toUpperCase ( target . charAt ( toffset + k ) )
 * char u2 = Character . toUpperCase ( other . charAt ( ooffset + k ) )
 * u1 ! = u2 & & Character . toLowerCase ( u1 ) ! = Character . toLowerCase ( u2)
 * < / pre >
 * < / ul >
 * @ param target
 * the first charsequence to compare .
 * @ param ignoreCase
 * if { @ code true } , ignore case when comparing characters .
 * @ param toffset
 * the starting offset of the subregion of the { @ code target }
 * argument .
 * @ param other
 * the second charsequence to compare .
 * @ param ooffset
 * the starting offset of the subregion in the { @ code other }
 * argument .
 * @ param length
 * the number of characters to compare .
 * @ return { @ code true } if the specified subregion of the { @ code target }
 * argument matches the specified subregion of the { @ code other }
 * argument ; { @ code false } otherwise . Whether the matching is exact
 * or case insensitive depends on the { @ code ignoreCase } argument . */
static boolean regionMatches ( final CharSequence target , final boolean ignoreCase , final int toffset , final CharSequence other , final int ooffset , final int length ) { } }

implementation: boolean result ; if ( target instanceof String && other instanceof String ) { result = delegateCheck ( ( String ) target , ignoreCase , toffset , ooffset , length , ( String ) other ) ; } else { result = carryOutCheck ( target , ignoreCase , toffset , other , ooffset , length ) ; } return result ;


signature:
public class EndpointControllerUtils { /** * Link : rel = ' type ' headers " */
private static void addProtocolSpecificHeaders ( ResponseBuilder builder , Class < ? extends PublicResource > clazz ) { } }

implementation: List < Term > types = new ArrayList < Term > ( ) ; if ( PublicRDFSource . class . isAssignableFrom ( clazz ) ) { types . add ( LDP . RESOURCE ) ; } if ( PublicBasicContainer . class . isAssignableFrom ( clazz ) ) { types . add ( LDP . BASIC_CONTAINER ) ; } else if ( PublicDirectContainer . class . isAssignableFrom ( clazz ) ) { types . add ( LDP . DIRECT_CONTAINER ) ; } else if ( PublicIndirectContainer . class . isAssignableFrom ( clazz ) ) { types . add ( LDP . INDIRECT_CONTAINER ) ; } for ( Term type : types ) { builder . header ( MoreHttp . LINK_HEADER , MoreHttp . createLink ( type , "type" ) ) ; }


signature:
public class EndpointControllerUtils { /** * Get a text / plain representation that indicates the acceptable media types
 * and charsets for the specified resource . The current implementation
 * < b > only < / b > takes care of the media type , nor language , nor encodings are
 * taken into consideration for generating the acceptable content .
 * @ param variants
 * The acceptable variants
 * @ param resourceLocation
 * The location of the resource
 * @ param supportedCharsets
 * The supported charsets
 * @ return A content instance that outlines the acceptable media types
 * together with the locations from where the resource contents for
 * those media types can be retrieved , and the charsets supported . */
static String getAcceptableContent ( List < Variant > variants , URI resourceLocation , List < String > supportedCharsets ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; for ( Variant variant : variants ) { MediaType mediaType = variant . getMediaType ( ) ; builder . append ( mediaType ) . append ( " : %1$s%n" ) ; for ( String supportedCharset : supportedCharsets ) { builder . append ( mediaType . withCharset ( supportedCharset ) ) . append ( " : %1$s%n" ) ; } } return String . format ( builder . toString ( ) , resourceLocation ) ;


signature:
public class ApplicationEngine { /** * Obtain an { @ code ApplicationEngine } instance using the method described
 * in { @ link ApplicationEngine # engine ( ) } .
 * @ return an instance of { @ code ApplicationEngine } if available , or null if
 * a default implementation class is to be selected . */
private static ApplicationEngine findDelegate ( ) { } }

implementation: try { ApplicationEngine result = createApplicationEngineFromSPI ( ) ; if ( result == null ) { result = createApplicationEngineFromConfigurationFile ( ) ; } if ( result == null ) { final String delegateClassName = System . getProperty ( LDP4J_APPLICATION_ENGINE_PROPERTY ) ; if ( delegateClassName != null ) { result = createApplicationEngineForClassName ( delegateClassName ) ; } } return result ; } catch ( final Exception ex ) { throw new IllegalStateException ( "Could not find application engine" , ex ) ; }


signature:
public class ApplicationEngine { /** * Obtain a { @ code ApplicationEngine } instance . If an instance had not
 * already been created and set via { @ link # setEngine ( ApplicationEngine ) } ,
 * the first invocation will create an instance which will then be cached
 * for future use .
 * The algorithm used to locate the { @ code ApplicationEngine } subclass to
 * use consists of the following steps :
 * < ul >
 * < li >
 * If a resource with the name of
 * { @ code META - INF / services / org . ldp4j . application . engine . ApplicationEngine }
 * exists , then its first line , if present , is used as the UTF - 8 encoded
 * name of the implementation class . < / li >
 * < li >
 * If a file named { @ value # LDP4J _ APPLICATION _ ENGINE _ CFG } in the
 * < code > lib < / code > directory of current JAVA _ HOME exists and it is readable
 * by the { @ code java . util . Properties . load ( InputStream ) } method and it
 * contains an entry whose key is
 * { @ value # LDP4J _ APPLICATION _ ENGINE _ PROPERTY } , then the value of that entry
 * is used as the name of the implementation class . < / li >
 * < li >
 * If a system property named { @ value # LDP4J _ APPLICATION _ ENGINE _ PROPERTY } is
 * defined , then its value is used as the name of the implementation class . < / li >
 * < li >
 * Finally , a default implementation class name is used . < / li >
 * < / ul >
 * @ return an instance of { @ code ApplicationEngine } . */
public static ApplicationEngine engine ( ) { } }

implementation: ApplicationEngine result = ApplicationEngine . CACHED_DELEGATE . get ( ) ; if ( result != null ) { return result ; } synchronized ( ApplicationEngine . CACHED_DELEGATE ) { result = ApplicationEngine . CACHED_DELEGATE . get ( ) ; if ( result == null ) { result = findDelegate ( ) ; ApplicationEngineState state = ApplicationEngineState . AVAILABLE ; if ( result == null ) { result = new DefaultApplicationEngine ( ) ; state = ApplicationEngineState . UNDEFINED ; } ApplicationEngine . CACHED_DELEGATE . set ( result ) ; result . setState ( state ) ; } return result ; }


signature:
public class ApplicationEngine { /** * Set the application engine that will be used by clients . If this method
 * is not called prior to { @ link ApplicationEngine # engine ( ) } then an
 * implementation will be sought as described in
 * { @ link ApplicationEngine # engine ( ) } .
 * @ param delegate
 * the { @ code ApplicationEngine } runtime delegate instance .
 * @ throws SecurityException
 * if there is a security manager and the permission
 * ReflectPermission ( " suppressAccessChecks " ) has not been
 * granted . */
public static void setEngine ( final ApplicationEngine delegate ) { } }

implementation: final SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { security . checkPermission ( SUPPRESS_ACCESS_CHECKS_PERMISSION ) ; } synchronized ( ApplicationEngine . CACHED_DELEGATE ) { final ApplicationEngine current = ApplicationEngine . CACHED_DELEGATE . get ( ) ; if ( current != null ) { try { current . shutdown ( ) ; } catch ( final ApplicationEngineLifecycleException e ) { LOGGER . error ( "Shutdown of previous engine failed. Full stacktrace follows:" , e ) ; } } ApplicationEngine . CACHED_DELEGATE . set ( delegate ) ; if ( delegate != null ) { delegate . setState ( ApplicationEngineState . AVAILABLE ) ; } }


signature:
public class ApplicationEngine { /** * Return an object of the specified type to allow access to the
 * provider - specific API . If the provider ' s ApplicationEngine implementation
 * does not support the specified class , the ApplicationEngineException is
 * thrown .
 * @ param < T > the type of object to be returned
 * @ param clazz
 * the class of the object to be returned . This is normally
 * either the underlying { @ code ApplicationEngine } implementation
 * class or an interface that it implements .
 * @ return an instance of the specified class
 * @ throws ApplicationEngineException
 * if the provider does not support the call */
public < T > T unwrap ( final Class < ? extends T > clazz ) throws ApplicationEngineException { } }

implementation: checkNotNull ( clazz , "Target class cannot be null" ) ; if ( ! clazz . isInstance ( this ) ) { throw new ApplicationEngineException ( "Application Engine implementation is not compatible with " + clazz . getCanonicalName ( ) ) ; } return clazz . cast ( this ) ;


signature:
public class RFC6838MediaRangeValidator { /** * Checks the given { @ code type } for illegal characters , as defined in RFC
 * 6838 , section 4.2 . NOTE : ' * ' is accepted as a valid type .
 * @ param type
 * the string to validate
 * @ throws IllegalArgumentException
 * in case of illegal characters
 * @ see < a href = " https : / / tools . ietf . org / html / rfc6838 # section - 4.2 " > Media Type
 * Specifications and Registration Procedures , Section 4.2 < / a > */
@ Override public void checkType ( final String type ) { } }

implementation: validateLength ( type , "Type" ) ; validateFirstChar ( type , "type" ) ; validateOtherChars ( type , "type" ) ;


signature:
public class RFC6838MediaRangeValidator { /** * Checks the given { @ code subtype } for illegal characters , as defined in RFC
 * 6838 , section 4.2 . NOTE : ' * ' is accepted as a valid subtype .
 * @ param subType
 * the string to validate
 * @ throws IllegalArgumentException
 * in case of illegal characters
 * @ see < a href = " https : / / tools . ietf . org / html / rfc6838 # section - 4.2 " > Media Type
 * Specifications and Registration Procedures , Section 4.2 < / a > */
@ Override public void checkSubType ( final String subType ) { } }

implementation: validateLength ( subType , "Subtype" ) ; validateFirstChar ( subType , "subtype" ) ; validateOtherChars ( subType , "subtype" ) ;


signature:
public class DefaultPublicContainer { /** * { @ inheritDoc } */
@ Override public final Collection < PublicResource > members ( ) { } }

implementation: List < PublicResource > members = Lists . newArrayList ( ) ; for ( Member member : resolveAs ( Container . class ) . members ( ) ) { members . add ( createResource ( member . memberId ( ) ) ) ; } return Collections . unmodifiableList ( members ) ;


signature:
public class DefaultPublicContainer { /** * { @ inheritDoc } */
@ Override public DefaultPublicResource createResource ( DataSet dataSet , CreationPreferences preferences ) throws ApplicationExecutionException { } }

implementation: verifyInteractionModel ( preferences . getInteractionModel ( ) ) ; Resource resource = applicationContext ( ) . createResource ( endpoint ( ) , dataSet , preferences . getPath ( ) ) ; return createResource ( resource . id ( ) ) ;


signature:
public class DefaultPublicContainer { /** * NOTE : For the time being containers will always behave as containers .
 * Whenever we support downgrading containers to resources the visitor will
 * have to be updated to reflect that . */
private void verifyInteractionModel ( InteractionModel interactionModel ) { } }

implementation: if ( interactionModel == null ) { return ; } Set < InteractionModel > acceptable = Sets . newHashSet ( ) ; containerTemplate ( ) . memberTemplate ( ) . accept ( new AcceptableInteractionModelCollector ( acceptable ) ) ; if ( ! acceptable . contains ( interactionModel ) ) { throw new UnsupportedInteractionModelException ( interactionModel , acceptable ) ; }


signature:
public class MyApplication { /** * { @ inheritDoc } */
@ Override public void setup ( Environment environment , Bootstrap < Configuration > bootstrap ) throws ApplicationSetupException { } }

implementation: LOGGER . info ( "Configuring application: {}, {}" , environment , bootstrap ) ; PersonHandler resourceHandler = new PersonHandler ( ) ; PersonContainerHandler containerHandler = new PersonContainerHandler ( ) ; RelativeContainerHandler relativesHandler = new RelativeContainerHandler ( ) ; QueryableResourceHandler queryableHandler = new QueryableResourceHandler ( ) ; this . dynamicResourceHandler = new DynamicResourceHandler ( ) ; BadDataResourceHandler badDataHandler = new BadDataResourceHandler ( ) ; containerHandler . setHandler ( resourceHandler ) ; relativesHandler . setHandler ( resourceHandler ) ; resourceHandler . add ( this . personResourceName , getInitialData ( PersonHandler . ID , PERSON_RESOURCE_NAME ) ) ; containerHandler . add ( this . personContainerName , getInitialData ( PersonContainerHandler . ID , PERSON_CONTAINER_NAME ) ) ; relativesHandler . add ( this . relativeContainerResourceName , getInitialData ( RelativeContainerHandler . ID , RELATIVE_CONTAINER_NAME ) ) ; queryableHandler . add ( this . queryableResourceName , getInitialData ( QueryableResourceHandler . ID , QUERYABLE_RESOURCE_NAME ) ) ; this . dynamicResourceHandler . add ( this . dynamicResourceName , getInitialData ( DynamicResourceHandler . ID , DYNAMIC_RESOURCE_NAME ) ) ; badDataHandler . add ( this . badDataResourceName , badDataHandler . getRepresentation ( ) ) ; bootstrap . addHandler ( resourceHandler ) ; bootstrap . addHandler ( containerHandler ) ; bootstrap . addHandler ( relativesHandler ) ; bootstrap . addHandler ( queryableHandler ) ; bootstrap . addHandler ( this . dynamicResourceHandler ) ; bootstrap . addHandler ( badDataHandler ) ; environment . publishResource ( this . personResourceName , PersonHandler . class , ROOT_PERSON_RESOURCE_PATH ) ; environment . publishResource ( this . personContainerName , PersonContainerHandler . class , ROOT_PERSON_CONTAINER_PATH ) ; environment . publishResource ( this . queryableResourceName , QueryableResourceHandler . class , ROOT_QUERYABLE_RESOURCE_PATH ) ; environment . publishResource ( this . dynamicResourceName , DynamicResourceHandler . class , ROOT_DYNAMIC_RESOURCE_PATH ) ; environment . publishResource ( this . badDataResourceName , BadDataResourceHandler . class , ROOT_BAD_DATA_RESOURCE_PATH ) ; this . executorService = Executors . newScheduledThreadPool ( 1 , new ThreadFactoryBuilder ( ) . setNameFormat ( "daemon-updater-thread-%d" ) . setUncaughtExceptionHandler ( new LoggedUncaughtExceptionHandler ( LOGGER ) ) . build ( ) ) ; LOGGER . info ( "Configuration completed." ) ;


signature:
public class MyApplication { /** * { @ inheritDoc } */
@ Override public void initialize ( WriteSession session ) throws ApplicationInitializationException { } }

implementation: LOGGER . info ( "Initializing application: {}" , session ) ; ResourceSnapshot person = session . find ( ResourceSnapshot . class , this . personResourceName , PersonHandler . class ) ; LOGGER . info ( "Root resource.......: " + person ) ; LOGGER . info ( "Root basic container: " + session . find ( ResourceSnapshot . class , this . personContainerName , PersonContainerHandler . class ) ) ; ContainerSnapshot relativesContainer = person . createAttachedResource ( ContainerSnapshot . class , PersonHandler . RELATIVES_ID , this . relativeContainerResourceName , RelativeContainerHandler . class ) ; LOGGER . info ( "Attached resource...: " + relativesContainer ) ; try { session . saveChanges ( ) ; } catch ( WriteSessionException e ) { throw new ApplicationInitializationException ( "Could not initialize application" , e ) ; } this . executorService . scheduleAtFixedRate ( new DynamicResourceUpdater ( this . dynamicResourceHandler , this . dynamicResourceName ) , 1 , 15 , TimeUnit . SECONDS ) ; this . executorService . schedule ( new DynamicResourceResolver ( this . dynamicResourceHandler , this . dynamicResourceName ) , 3 , TimeUnit . SECONDS ) ; LOGGER . info ( "Initialization completed." ) ;


signature:
public class MyApplication { /** * { @ inheritDoc } */
@ Override public void shutdown ( ) { } }

implementation: LOGGER . info ( "Shutting down application..." ) ; this . executorService . shutdown ( ) ; boolean finished = this . executorService . isTerminated ( ) ; while ( ! finished ) { try { this . executorService . awaitTermination ( 100 , TimeUnit . MILLISECONDS ) ; finished = this . executorService . isTerminated ( ) ; } catch ( InterruptedException e ) { finished = true ; } } LOGGER . info ( "Shutdown completed." ) ;


signature:
public class Path { /** * Checks if the path is out of the scope .
 * @ return { @ code true } , if is out of the scope , { @ code false } otherwise */
public boolean isOutOfScope ( ) { } }

implementation:
// Files are always on scope
if ( this . directory == null ) { return false ; } // First , normalize
final Path normalize = normalize ( ) ; // If now we are a file , we are in scope
if ( normalize . directory == null ) { return false ; } // If we find a segment which is ' . . ' we are out of scope
final String [ ] segments = normalize . segments ( ) ; boolean result = false ; for ( int i = 0 ; i < segments . length && ! result ; i ++ ) { result = isDotSegment ( segments [ i ] ) ; } return result ;


signature:
public class Path { /** * Create a new path with a given directory .
 * @ param directory the directory for the path
 * @ return the new path */
public Path withDirectory ( final String directory ) { } }

implementation: final Path result = new Path ( this ) ; result . setDirectory ( directory ) ; return result ;


signature:
public class Path { /** * Create a new path with a given file .
 * @ param file the file for the path
 * @ return the new path */
public Path withFile ( final String file ) { } }

implementation: final Path result = new Path ( this ) ; result . setFile ( file ) ; return result ;


signature:
public class Path { /** * Computes relative relative path to reference " target " from " base " . Uses
 * " . . " if needed , in contrast to { @ link URI # relativize ( URI ) } .
 * @ param path the path to be relativized
 * @ return the relative path */
public Path relativize ( final Path path ) { } }

implementation:
Objects . requireNonNull ( "Path cannot be null" ) ; final Path base = this ; // By default , we return the normalized form of the input path
final Path defaultRelative = path . normalize ( ) ; // Either root or not
if ( base . isRoot ( ) != path . isRoot ( ) ) { return defaultRelative ; } // If the path is not root , return its normalized base
if ( ! path . isRoot ( ) ) { return defaultRelative ; } // Beyond this point we need the normalized form
final Path nBase = base . normalize ( ) ; // If we are out of the scope . . .
if ( base . isOutOfScope ( ) ) { // . . . we must return the input path because it will define the
// scope
Path relative = defaultRelative ; if ( nBase . equals ( relative ) ) { // . . . unless the path is the same as ourselves , in which
// case it is safe to return the empty path
relative = EMPTY_PATH ; } return relative ; } // Can only compare for equality iff normalized .
final Path unBase = nBase . unroot ( ) ; final Path unPath = defaultRelative . unroot ( ) ; // If the base and the target are the same , return the empty path
if ( unBase . equals ( unPath ) ) { return EMPTY_PATH ; } return assembleRelativeSegments ( path , base , getRelativeSegments ( unBase . segments ( ) , unPath . segments ( ) ) ) ;


signature:
public class Path { /** * If there are no segments in the resolved path , and we are trying to
 * resolve a directory coming from a path , we have to make explicit that we
 * want the directory */
private Path assembleRelativeSegments ( final Path path , final Path base , final Deque < String > segments ) { } }

implementation: if ( segments . isEmpty ( ) && path . isDirectory ( ) && base . isFile ( ) ) { segments . add ( CURRENT ) ; } return Path . create ( assembleSegments ( segments , path . getFile ( ) ) ) ;


signature:
public class ExistingEndpointController { /** * TODO : This could be improved by returning an OK with an additional
 * description of all the resources that were deleted as a side effect . */
@ Override public Response deleteResource ( OperationContext context ) { } }

implementation: context . checkOperationSupport ( ) . checkPreconditions ( ) ; try { context . resource ( ) . delete ( ) ; return Response . noContent ( ) . build ( ) ; } catch ( ApplicationExecutionException e ) { throw diagnoseApplicationExecutionException ( context , e ) ; } catch ( ApplicationContextException e ) { throw new InternalServerException ( context , e ) ; }


signature:
public class ExistingEndpointController { /** * TODO : This could be improved by returning an OK with an additional
 * description of all the resources that were modified ( updated , created ,
 * deleted ) as a side effect . */
@ Override public Response modifyResource ( OperationContext context ) { } }

implementation: context . checkOperationSupport ( ) . checkContents ( ) . checkPreconditions ( ) ; try { context . resource ( ) . modify ( context . dataSet ( ) ) ; ResponseBuilder builder = Response . noContent ( ) ; EndpointControllerUtils . populateRequiredHeaders ( builder , context ) ; return builder . build ( ) ; } catch ( ApplicationExecutionException e ) { throw diagnoseApplicationExecutionException ( context , e ) ; } catch ( ApplicationContextException e ) { throw new InternalServerException ( context , e ) ; }


signature:
public class DataSetHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualHelper managedIndividual ( final Name < ? > name , final String managerId ) { } }

implementation: final ManagedIndividualId individualId = ManagedIndividualId . createId ( name , managerId ) ; final ManagedIndividual individual = this . dataSet . individual ( individualId , ManagedIndividual . class ) ; return new IndividualHelperImpl ( individual ) ;


signature:
public class DataSetHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualHelper relativeIndividual ( final Name < ? > name , final String managerId , final URI path ) { } }

implementation: final ManagedIndividualId parentId = ManagedIndividualId . createId ( name , managerId ) ; final RelativeIndividualId individualId = RelativeIndividualId . createId ( parentId , path ) ; final RelativeIndividual individual = this . dataSet . individual ( individualId , RelativeIndividual . class ) ; return new IndividualHelperImpl ( individual ) ;


signature:
public class DataSetHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualHelper localIndividual ( final Name < ? > name ) { } }

implementation: @ SuppressWarnings ( "rawtypes" ) final LocalIndividual individual = this . dataSet . individual ( ( Name ) name , LocalIndividual . class ) ; return new IndividualHelperImpl ( individual ) ;


signature:
public class DataSetHelperImpl { /** * { @ inheritDoc } */
@ Override public IndividualHelper externalIndividual ( final URI uri ) { } }

implementation: Individual < ? , ? > individual = null ; if ( uri . isAbsolute ( ) ) { individual = this . dataSet . individual ( uri , ExternalIndividual . class ) ; } else { individual = this . dataSet . individual ( uri , NewIndividual . class ) ; } return new IndividualHelperImpl ( individual ) ;


signature:
public class CharacterObjectFactory { /** * { @ inheritDoc } */
@ Override public Character fromString ( String rawValue ) { } }

implementation: try { return PrimitiveObjectFactory . parseCharacter ( rawValue ) ; } catch ( IllegalArgumentException e ) { throw new ObjectParseException ( e , targetClass ( ) , rawValue ) ; }


signature:
public class PrimitiveObjectFactory { /** * { @ inheritDoc } */
@ Override @ SuppressWarnings ( "unchecked" ) public T fromString ( final String rawValue ) { } }

implementation:
// NOSONAR
try { Object result = null ; if ( byte . class . equals ( this . valueClass ) ) { result = Byte . decode ( rawValue ) ; } else if ( short . class . equals ( this . valueClass ) ) { result = Short . decode ( rawValue ) ; } else if ( int . class . equals ( this . valueClass ) ) { result = Integer . decode ( rawValue ) ; } else if ( long . class . equals ( this . valueClass ) ) { result = Long . decode ( rawValue ) ; } else if ( double . class . equals ( this . valueClass ) ) { result = Double . valueOf ( rawValue ) ; } else if ( float . class . equals ( this . valueClass ) ) { result = Float . valueOf ( rawValue ) ; } else if ( boolean . class . equals ( this . valueClass ) ) { result = parseBoolean ( rawValue ) ; } else { // Must be char
result = parseCharacter ( rawValue ) ; } return ( T ) result ; } catch ( final Exception e ) { throw new ObjectParseException ( e , this . valueClass , rawValue ) ; }


signature:
public class PrimitiveObjectFactory { /** * Create a primitive object factory for the specified primitive class
 * @ param < T >
 * the primitive class type
 * @ param valueClass
 * the primitive class to use
 * @ return an object factory
 * @ throws NullPointerException
 * if the specified class is { @ code null }
 * @ throws IllegalArgumentException
 * if the specified class is not a primitive class */
public static < T > PrimitiveObjectFactory < T > create ( final Class < ? extends T > valueClass ) { } }

implementation: checkNotNull ( valueClass , "Value class cannot be null" ) ; checkArgument ( valueClass . isPrimitive ( ) , "Value class '" + valueClass . getName ( ) + "' is not primitive" ) ; return new PrimitiveObjectFactory < T > ( valueClass ) ;


signature:
public class VariantUtils { /** * Get a list of acceptable variants . Current implementation only leverages
 * media type for the specification of variants .
 * @ param mediaTypes
 * The list of acceptable media types .
 * @ return A list of acceptable variants . */
public static List < Variant > createVariants ( MediaType ... mediaTypes ) { } }

implementation: return Variant . VariantListBuilder . newInstance ( ) . mediaTypes ( mediaTypes ) . encodings ( ) . languages ( ) . add ( ) . build ( ) ;


signature:
public class IndividualReference { /** * Find the individual of the data set with the same identifier
 * @ param dataSet
 * the data set
 * @ return the individual with the same identifier , or { @ code null } if no
 * individual has the same identifier . */
@ SuppressWarnings ( "unchecked" ) public Individual < T , S > resolve ( DataSet dataSet ) { } }

implementation: return ( Individual < T , S > ) dataSet . individualOfId ( ref ( ) ) ;


signature:
public class ExtendedActivityMonitor { /** * Returns the most recently started { @ link Activity } . In most cases , this
 * will be the activity currently visible on screen . */
public Activity getMostRecentlyStartedActivity ( ) { } }

implementation: List < StartedActivity > activities = getStartedActivities ( ) ; if ( activities . size ( ) == 0 ) { return null ; } return activities . get ( activities . size ( ) - 1 ) . getActivity ( ) ;


signature:
public class ExtendedActivityMonitor { /** * Blocks until an { @ link Activity } of the given type is started . The
 * instance of the started activity is then returned . If such an activity is
 * not started within the given amount of milliseconds , returns null .
 * @ param activityClass
 * the type of activity to wait for
 * @ param timeout
 * amount to wait for activity start
 * @ param timeUnit
 * the unit of the timeout parameter
 * @ return the activity waited for , or null if timeout was reached before
 * any suitable activity was started */
@ SuppressWarnings ( "unchecked" ) public final < T extends Activity > T waitForActivity ( Class < T > activityClass , long timeout , TimeUnit timeUnit ) { } }

implementation:
long timeoutInMs = timeUnit . toMillis ( timeout ) ; Activity mostRecentlyStartedActivity = getMostRecentlyStartedActivity ( ) ; if ( mostRecentlyStartedActivity != null && mostRecentlyStartedActivity . getClass ( ) . equals ( activityClass ) ) { return ( T ) mostRecentlyStartedActivity ; } int startedActivitiesCount = startedActivities . size ( ) ; if ( startedActivitiesCount > 0 ) { StartedActivity startedActivity = startedActivities . get ( startedActivitiesCount - 1 ) ; if ( startedActivity . getActivity ( ) . getClass ( ) . equals ( activityClass ) ) { return ( T ) startedActivity . getActivity ( ) ; } } // we need some kind of container to be shared between two threads
final List < T > activityContainer = new LinkedList < T > ( ) ; // register the listener , we are now informed when the activity starts
registerActivityStartListener ( activityClass , new ActivityStartListener ( ) { public void started ( Activity activity ) { synchronized ( activityContainer ) { // OK , the activity has been started . Put its
// instance in the container and notify .
activityContainer . add ( ( T ) activity ) ; activityContainer . notifyAll ( ) ; } } } ) ; // Now , wait for the activity start by waiting on the container object .
synchronized ( activityContainer ) { try { long time = System . currentTimeMillis ( ) ; while ( activityContainer . isEmpty ( ) ) { activityContainer . wait ( 2000 ) ; if ( System . currentTimeMillis ( ) - time > timeoutInMs ) { return null ; } } } catch ( InterruptedException e ) { } if ( activityContainer . size ( ) > 0 ) { return activityContainer . get ( 0 ) ; } } /* * Container was empty , we were either interrupted or more likely , the
 * timeout was reached . Return null . */
return null ;


signature:
public class ExtendedActivityMonitor { /** * Not synchronized , do that in the caller code . */
private List < ActivityStartListener > getActivityStartListeners ( Class < ? extends Activity > activityClass ) { } }

implementation: List < ActivityStartListener > result = this . activityStartListeners . get ( activityClass ) ; if ( result == null ) { result = new ArrayList < ActivityStartListener > ( ) ; this . activityStartListeners . put ( activityClass , result ) ; } return result ;


signature:
public class AndroidMatchers { /** * Evaluates to true if the value is a { @ link TextView } with a text equal to
 * the parameter . */
public static < T extends View > Matcher < T > hasText ( String text ) { } }

implementation: return HasText . < T > hasText ( text ) ;


signature:
public class AndroidMatchers { /** * Has the { @ link ViewGroup } more children than value ? */
public static < T extends ViewGroup > Matcher < T > equalChildrenCountAs ( final int value ) { } }

implementation: return ViewGroupComparison . < T > equalChildrenCountAs ( value ) ;


signature:
public class ViewGroupComparison { /** * Is value = expected ? */
@ Factory public static < T extends ViewGroup > Matcher < T > equalChildrenCountAs ( int value ) { } }

implementation: return new ViewGroupComparison < T > ( value , EQUAL , EQUAL ) ;


signature:
public class ViewGroupComparison { /** * Is value > expected ? */
@ Factory public static < T extends ViewGroup > Matcher < T > moreChildrenThan ( int value ) { } }

implementation: return new ViewGroupComparison < T > ( value , GREATER_THAN , GREATER_THAN ) ;


signature:
public class ViewGroupComparison { /** * Is value > = expected ? */
@ Factory public static < T extends ViewGroup > Matcher < T > moreChildrenOrEqual ( int value ) { } }

implementation: return new ViewGroupComparison < T > ( value , EQUAL , GREATER_THAN ) ;


signature:
public class ViewGroupComparison { /** * Is value < expected ? */
@ Factory public static < T extends ViewGroup > Matcher < T > lessChildrenThan ( int value ) { } }

implementation: return new ViewGroupComparison < T > ( value , LESS_THAN , LESS_THAN ) ;


signature:
public class ViewGroupComparison { /** * Is value < = expected ? */
@ Factory public static < T extends ViewGroup > Matcher < T > lessChildrenOrEqual ( int value ) { } }

implementation: return new ViewGroupComparison < T > ( value , LESS_THAN , EQUAL ) ;


signature:
public class MeasureClass { /** * This method returns a list of state ballot measures in a given year .
 * @ param year
 * @ param stateId
 * @ return { @ link Measures } : List of minimal measure information . */
public Measures getMeasuresByYearState ( String year , String stateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Measure.getMeasuresByYearState" , new ArgMap ( "year" , year , "stateId" , stateId ) , Measures . class ) ;


signature:
public class MeasureClass { /** * This method returns a single Ballot Measure detail .
 * @ param measureId
 * @ return { @ link Measure } : detail on single measure */
public Measure getMeasure ( String measureId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Measure.getMeasure" , new ArgMap ( "measureId" , measureId ) , Measure . class ) ;


signature:
public class RatingClass { /** * This method dumps categories that contain released ratings according to state .
 * Input : stateId ( default : ' NA ' )
 * @ param stateId
 * @ return { @ link Categories } */
public Categories getCategories ( String stateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Rating.getCategories" , new ArgMap ( "stateId" , stateId ) , Categories . class ) ;


signature:
public class RatingClass { /** * This method dumps Special Interest Groups according to category and state .
 * Input : categoryId * , stateId ( default : ' NA ' )
 * @ param categoryId
 * @ return { @ link Sigs } */
public Sigs getSigList ( String categoryId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Rating.getSigList" , new ArgMap ( "categoryId" , categoryId ) , Sigs . class ) ;


signature:
public class RatingClass { /** * This method dumps detailed information an a Special Interest Group .
 * Input : sigId *
 * @ param sigId
 * @ return { @ link Sig } */
public Sig getSig ( String sigId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Rating.getSig" , new ArgMap ( "sigId" , sigId ) , Sig . class ) ;


signature:
public class RatingClass { /** * This method dumps all ratings ( scorecards ) by a Special Interest Group .
 * Input : sigId *
 * @ param sigId
 * @ return { @ link SigRating } */
public SigRating getSigRatings ( String sigId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Rating.getSigRatings" , new ArgMap ( "sigId" , sigId ) , SigRating . class ) ;


signature:
public class RatingClass { /** * This method dumps a candidate ' s rating by an SIG .
 * @ param candidateId
 * @ return { @ link CandidateRating } */
public CandidateRating getCandidateRating ( String candidateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Rating.getCandidateRating" , new ArgMap ( "candidateId" , candidateId ) , CandidateRating . class ) ;


signature:
public class RatingClass { /** * This method dumps all candidate ratings from a scorecard by an SIG .
 * @ param ratingId
 * @ return { @ link Rating }
 * @ throws VoteSmartException , VoteSmartErrorException */
public Rating getRating ( String ratingId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Rating.getRating" , new ArgMap ( "ratingId" , ratingId ) , Rating . class ) ;


signature:
public class ElectionClass { /** * This method grabs district IDs according to the office and state .
 * @ param electionId
 * @ return { @ link Elections } : */
public Elections getElection ( String electionId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Election.getElection" , new ArgMap ( "electionId" , electionId ) , Elections . class ) ;


signature:
public class ElectionClass { /** * This method grabs district basic election data according to year and stateid .
 * @ param year
 * @ return { @ link Elections } */
public Elections getElectionByYearState ( String year ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Election.getElectionByYearState" , new ArgMap ( "year" , year ) , Elections . class ) ;


signature:
public class ElectionClass { /** * This method grabs district basic election data according to zip code .
 * @ param zip5
 * @ return { @ link ElectionByZip } : */
public ElectionByZip getElectionByZip ( String zip5 ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Election.getElectionByZip" , new ArgMap ( "zip5" , zip5 ) , ElectionByZip . class ) ;


signature:
public class ElectionClass { /** * This method grabs district basic election data according to electionId and stageId .
 * Per state lists of a Presidential election are available by specifying the stateId .
 * @ param electionId
 * @ param stageId
 * @ param party
 * @ return { @ link StageCandidates } : */
public StageCandidates getStageCandidates ( String electionId , String stageId , String party ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Election.getStageCandidates" , new ArgMap ( "electionId" , electionId , "stageId" , stageId , "party" , party ) , StageCandidates . class ) ;


signature:
public class AddressClass { /** * This method grabs campaign office ( s ) and basic candidate information for the specified candidate .
 * @ param candidateId
 * @ return { @ link AddressOffice } : address and list of office addresses . */
public AddressOffice getCampaign ( String candidateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Address.getCampaign" , new ArgMap ( "candidateId" , candidateId ) , AddressOffice . class ) ;


signature:
public class AddressClass { /** * This method grabs campaign office ( s ) and basic candidate information for the specified election .
 * @ param electionId
 * @ return { @ link AddressOffice } : Candidate name and list of office addresses */
public AddressOffice getCampaignByElection ( String electionId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Address.getCampaignByElection" , new ArgMap ( "electionId" , electionId ) , AddressOffice . class ) ;


signature:
public class AddressClass { /** * This method grabs office ' s Web address ( es ) and basic candidate information for the specified candidate .
 * @ param candidateId
 * @ return { @ link WebAddress } : Candidate name and list of URL ' s */
public WebAddress getOfficeWebAddress ( String candidateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Address.getOfficeWebAddress" , new ArgMap ( "candidateId" , candidateId ) , WebAddress . class ) ;


signature:
public class AddressClass { /** * This method grabs office address and basic candidate information according to the officeId and state .
 * @ param officeId
 * @ return { @ link AddressAddress } : Candidate name and list of offices */
public AddressAddress getOfficeByOfficeState ( String officeId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Address.getOfficeByOfficeState" , new ArgMap ( "officeId" , officeId ) , AddressAddress . class ) ;


signature:
public class DistrictClass { /** * This method grabs district IDs according to the office and state .
 * @ param officeId
 * @ param stateId
 * @ return { @ link DistrictList } : */
public DistrictList getByOfficeState ( String officeId , String stateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "District.getByOfficeState" , new ArgMap ( "officeId" , officeId , "stateId" , stateId ) , DistrictList . class ) ;


signature:
public class OfficeClass { /** * This method dumps offices we keep track of according to type .
 * @ param officeTypeId
 * @ return { @ link Offices } : */
public Offices getOfficesByType ( String officeTypeId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Office.getOfficesByType" , new ArgMap ( "officeTypeId" , officeTypeId ) , Offices . class ) ;


signature:
public class OfficeClass { /** * This method dumps offices we keep track of according to level .
 * @ param levelId
 * @ return { @ link Offices } : */
public Offices getOfficesByLevel ( String levelId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Office.getOfficesByLevel" , new ArgMap ( "levelId" , levelId ) , Offices . class ) ;


signature:
public class OfficeClass { /** * This method dumps offices we keep track of according to type and level .
 * @ param officeTypeId
 * @ param officeLevelId
 * @ return { @ link Offices } : */
public Offices getOfficesByTypeLevel ( String officeTypeId , String officeLevelId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Office.getOfficesByTypeLevel" , new ArgMap ( "officeTypeId" , officeTypeId , "officeLevelId" , officeLevelId ) , Offices . class ) ;


signature:
public class OfficeClass { /** * This method dumps offices we keep track of according to branch and level .
 * @ param branchId
 * @ param levelId
 * @ return { @ link Offices } : */
public Offices getOfficesByBranchLevel ( String branchId , String levelId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Office.getOfficesByBranchLevel" , new ArgMap ( "branchId" , branchId , "levelId" , levelId ) , Offices . class ) ;


signature:
public class LocalClass { /** * Fetches counties in a state .
 * @ param stateId
 * @ return { @ link Counties } : */
public Counties getCounties ( String stateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Local.getCounties" , new ArgMap ( "stateId" , stateId ) , Counties . class ) ;


signature:
public class LocalClass { /** * Fetches cities in a state .
 * @ param stateId
 * @ return { @ link Cities } : */
public Cities getCities ( String stateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Local.getCities" , new ArgMap ( "stateId" , stateId ) , Cities . class ) ;


signature:
public class LocalClass { /** * Fetches officials for a locality .
 * @ param localId
 * @ return { @ link LocalCandidateList } : */
public LocalCandidateList getOfficials ( String localId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Local.getOfficials" , new ArgMap ( "localId" , localId ) , LocalCandidateList . class ) ;


signature:
public class VoteSmart { /** * Modify whether or not the cache is first checked for files .
 * Note that any JSON read will always be written to the
 * cache .
 * @ param checkCache the check cache */
public static void setCache ( boolean checkCache ) { } }

implementation: if ( VoteSmart . checkCache != checkCache ) logger . fine ( "Setting checkCache to " + checkCache ) ; VoteSmart . checkCache = checkCache ;


signature:
public class VoteSmart { /** * Queries the API server for the information requested
 * @ param method
 * @ param argMap
 * @ param responseType
 * @ throws VoteSmartErrorException */
public < T > T query ( String method , ArgMap argMap , Class < T > responseType ) throws VoteSmartException , VoteSmartErrorException { } }

implementation:
BufferedReader reader = null ; HttpURLConnection conn = null ; String charSet = "utf-8" ; try { if ( isCaching ( method , argMap ) ) { File file = getCacheFile ( method , argMap ) ; long fileLength = file . length ( ) ; logger . fine ( "Length of File in cache:" + fileLength + ": " + file . getName ( ) ) ; if ( fileLength == 0L ) { VoteSmart . cacheFileFromAPI ( method , argMap , file ) ; } reader = new BufferedReader ( new InputStreamReader ( new FileInputStream ( file ) , charSet ) ) ; } else { conn = VoteSmart . getConnectionFromAPI ( method , argMap ) ; charSet = getCharset ( conn ) ; reader = new BufferedReader ( new InputStreamReader ( conn . getInputStream ( ) , charSet ) ) ; } JAXBElement < T > e = unmarshaller . unmarshal ( new StreamSource ( reader ) , responseType ) ; if ( e . getName ( ) . getLocalPart ( ) . equals ( "error" ) ) { // ErrorBase error = unmarshaller . unmarshal ( new StreamSource ( reader = new StringReader ( XMLStr ) ) , ErrorBase . class ) . getValue ( ) ;
throw new VoteSmartErrorException ( ( ( ErrorBase ) e . getValue ( ) ) , method , argMap ) ; } else { return e . getValue ( ) ; } /* Object o = unmarshaller . unmarshal ( new StreamSource ( reader ) ) ;
 if ( o instanceof ErrorBase ) {
 throw new VoteSmartErrorException ( ( ErrorBase ) o , method , argMap ) ;
 } else {
 @ SuppressWarnings ( " unchecked " )
 T e = ( T ) o ;
 return e ; */
} catch ( JAXBException e ) { throw new VoteSmartException ( e ) ; } catch ( URISyntaxException e ) { throw new VoteSmartException ( e ) ; } catch ( IOException e ) { throw new VoteSmartException ( e ) ; } finally { suspendCache = false ; if ( conn != null ) conn . disconnect ( ) ; if ( reader != null ) { try { reader . close ( ) ; } catch ( IOException e ) { throw new VoteSmartException ( e ) ; } } }


signature:
public class OfficialsClass { /** * This method grabs a list of officials according to state representation .
 * @ param stateId
 * @ return { @ link CandidateList } */
public CandidateList getStatewide ( String stateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Officials.getStatewide" , new ArgMap ( "stateId" , stateId ) , CandidateList . class ) ;


signature:
public class OfficialsClass { /** * This method grabs a list of officials according to office type and state representation .
 * @ param officeTypeId
 * @ param stateId
 * @ return { @ link CandidateList } */
public CandidateList getByOfficeTypeState ( String officeTypeId , String stateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Officials.getByOfficeTypeState" , new ArgMap ( "officeTypeId" , officeTypeId , "stateId" , stateId ) , CandidateList . class ) ;


signature:
public class OfficialsClass { /** * This method grabs a list of officials according to the zip code they represent .
 * @ param zip5
 * @ return { @ link CandidateList } */
public CandidateList getByZip ( String zip5 ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Officials.getByZip" , new ArgMap ( "zip5" , zip5 ) , CandidateList . class ) ;


signature:
public class CandidateBioClass { /** * This method grabs the extended bio for each candidate that has one .
 * @ param candidateId
 * @ return { @ link AddlBio } : Additional items in a list . */
public AddlBio getAddlBio ( String candidateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "CandidateBio.getAddlBio" , new ArgMap ( "candidateId" , candidateId ) , AddlBio . class ) ;


signature:
public class CandidateBioClass { /** * This method grabs the extended bio for each candidate that has one .
 * It uses the updated version ' getDetailedBio ' of the call .
 * @ param candidateId
 * @ return { @ link AddlBio } : Additional items in a list . */
public Bio getBio ( String candidateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "CandidateBio.getDetailedBio" , new ArgMap ( "candidateId" , candidateId ) , Bio . class ) ;


signature:
public class CandidatesClass { /** * This method grabs a list of candidates according to a lastname match .
 * @ param lastName
 * @ param electionYear
 * @ return { @ link CandidateList } : list of detailed candidate information . */
public CandidateList getByLastname ( String lastName , String electionYear ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Candidates.getByLastname" , new ArgMap ( "lastName" , lastName , "electionYear" , electionYear ) , CandidateList . class ) ;


signature:
public class CandidatesClass { /** * This method grabs a list of candidates according to a fuzzy lastname match .
 * @ param electionId
 * @ return { @ link CandidateList } : list of detailed candidate information . */
public CandidateList getByElection ( String electionId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Candidates.getByElection" , new ArgMap ( "electionId" , electionId ) , CandidateList . class ) ;


signature:
public class CandidatesClass { /** * This method grabs a list of candidates according to the district they represent .
 * @ param districtId
 * @ param electionYear
 * @ return { @ link CandidateList } : list of detailed candidate information . */
public CandidateList getByDistrict ( String districtId , String electionYear ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Candidates.getByDistrict" , new ArgMap ( "districtId" , districtId , "electionYear" , electionYear ) , CandidateList . class ) ;


signature:
public class CommitteeClass { /** * Returns the list of committees that fit the criteria .
 * @ param typeId
 * @ return { @ link Committees } : */
public Committees getCommitteesByTypeState ( String typeId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Committee.getCommitteesByTypeState" , new ArgMap ( "typeId" , typeId ) , Committees . class ) ;


signature:
public class CommitteeClass { /** * Returns detailed committee data .
 * @ param committeeId
 * @ return { @ link Committee } : */
public Committee getCommittee ( String committeeId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Committee.getCommittee" , new ArgMap ( "committeeId" , committeeId ) , Committee . class ) ;


signature:
public class CommitteeClass { /** * Returns members of the committee .
 * @ param committeeId
 * @ return { @ link CommitteeMembers } : */
public CommitteeMembers getCommitteeMembers ( String committeeId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Committee.getCommitteeMembers" , new ArgMap ( "committeeId" , committeeId ) , CommitteeMembers . class ) ;


signature:
public class LeadershipClass { /** * Gets leadership positions by state and office .
 * @ param stateId
 * @ return { @ link Leadership } : */
public Leadership getPositions ( String stateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Leadership.getPositions" , new ArgMap ( "stateId" , stateId ) , Leadership . class ) ;


signature:
public class LeadershipClass { /** * Gets officials that hold the leadership role in certain states .
 * @ param leadershipId
 * @ return { @ link Leaders } : */
public Leaders getOfficials ( String leadershipId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Leadership.getOfficials" , new ArgMap ( "leadershipId" , leadershipId ) , Leaders . class ) ;


signature:
public class VotesClass { /** * This method dumps categories that contain released bills according to year and state .
 * Input : year * , stateId ( default : ' NA ' )
 * @ param year
 * @ return { @ link VotesCategories } */
public VotesCategories getCategories ( String year ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getCategories" , new ArgMap ( "year" , year ) , VotesCategories . class ) ;


signature:
public class VotesClass { /** * This method dumps general information on a bill .
 * Input : billId *
 * @ param billId
 * @ return { @ link Bill } */
public Bill getBill ( String billId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getBill" , new ArgMap ( "billId" , billId ) , Bill . class ) ;


signature:
public class VotesClass { /** * This gets detailed action information on a certain stage of the bill
 * Input : actionId *
 * @ param actionId
 * @ return { @ link BillAction } */
public BillAction getBillAction ( String actionId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getBillAction" , new ArgMap ( "actionId" , actionId ) , BillAction . class ) ;


signature:
public class VotesClass { /** * Method provides votes listed by candidate on a certain bill action .
 * Input : actionId *
 * @ param actionId
 * @ return { @ link BillActionVotes } */
public BillActionVotes getBillActionVotes ( String actionId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getBillActionVotes" , new ArgMap ( "actionId" , actionId ) , BillActionVotes . class ) ;


signature:
public class VotesClass { /** * Returns a single vote according to official and action .
 * Input : actionId * , candidateId *
 * @ param actionId
 * @ param candidateId
 * @ return { @ link BillActionVotes } */
public BillActionVotes getBillActionVoteByOfficial ( String actionId , String candidateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getBillActionVoteByOfficial" , new ArgMap ( "actionId" , actionId , "candidateId" , candidateId ) , BillActionVotes . class ) ;


signature:
public class VotesClass { /** * Returns a list of bills that are like the billNumber input .
 * Input : billNumber *
 * @ param billNumber
 * @ return { @ link Bills } */
public Bills getByBillNumber ( String billNumber ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getByBillNumber" , new ArgMap ( "billNumber" , billNumber ) , Bills . class ) ;


signature:
public class VotesClass { /** * Returns a list of bills that fit the category , year , and state input .
 * Input : categoryId * , year * , stateId
 * @ param categoryId
 * @ param year
 * @ return { @ link Bills } */
public Bills getBillsByCategoryYearState ( String categoryId , String year ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getBillsByCategoryYearState" , new ArgMap ( "categoryId" , categoryId , "year" , year ) , Bills . class ) ;


signature:
public class VotesClass { /** * This method dumps all the bills an official has voted on based on the candidateId , officeId , categoryId , and year
 * Input : candidateId * , officeId , categoryId , year
 * @ param candidateId
 * @ param officeId
 * @ param categoryId
 * @ return { @ link BillsByOfficial } */
public BillsByOfficial getByOfficial ( String candidateId , String officeId , String categoryId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getByOfficial" , new ArgMap ( "candidateId" , candidateId , "officeId" , officeId , "categoryId" , categoryId ) , BillsByOfficial . class ) ;


signature:
public class VotesClass { /** * Returns a list of bills that fit the sponsor ' s candidateId and year .
 * Input : candidateId * , year *
 * @ param candidateId
 * @ param year
 * @ return { @ link Bills } */
public Bills getBillsBySponsorYear ( String candidateId , String year ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getBillsBySponsorYear" , new ArgMap ( "candidateId" , candidateId , "year" , year ) , Bills . class ) ;


signature:
public class VotesClass { /** * Returns a list of bills that fit the sponsor ' s candidateId and category .
 * Input : candidateId * , categoryId *
 * @ param candidateId
 * @ param categoryId
 * @ return { @ link Bills } */
public Bills getBillsBySponsorCategory ( String candidateId , String categoryId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getBillsBySponsorCategory" , new ArgMap ( "candidateId" , candidateId , "categoryId" , categoryId ) , Bills . class ) ;


signature:
public class VotesClass { /** * Returns a list of recent bills according to the state . Max returned is 100 or however much less you want .
 * Input : amount ( default : 100 , max : 100 ) , state ( default : ' NA ' )
 * Note : Currently , the caching will only the most recent call . It won ' t cache all calls .
 * @ param amount
 * @ param state
 * @ return { @ link Bills } */
public Bills getBillsByStateRecent ( String amount , String state ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getBillsByStateRecent" , new ArgMap ( "amount" , amount , "state" , state ) , Bills . class ) ;


signature:
public class VotesClass { /** * Returns a list of vetoes according to candidate .
 * Input : candidateId
 * @ param candidateId
 * @ return { @ link BillVetoes } */
public BillVetoes getVetoes ( String candidateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Votes.getVetoes" , new ArgMap ( "candidateId" , candidateId ) , BillVetoes . class ) ;


signature:
public class StateClass { /** * This method grabs a various data we keep on a state .
 * Input : stateId *
 * @ param stateId
 * @ return { @ link State } */
public State getState ( String stateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "State.getState" , new ArgMap ( "stateId" , stateId ) , State . class ) ;


signature:
public class NpatClass { /** * This method returns the candidates most recently filled out NPAT / PCT .
 * NOTE : This is the only class that responds with recursive data .
 * @ param candidateId
 * @ return { @ link Npat } : */
public Npat getNpat ( String candidateId ) throws VoteSmartException , VoteSmartErrorException { } }

implementation: return api . query ( "Npat.getNpat" , new ArgMap ( "candidateId" , candidateId ) , Npat . class ) ;


signature:
public class RateLimitInputStream { /** * len < = num */
private int realRead ( byte [ ] b , int off , int len ) throws IOException { } }

implementation: int lenToRead = rateHelper . take ( len ) ; int rd = real . read ( b , off , lenToRead ) ; if ( rd != lenToRead ) rateHelper . giveBack ( lenToRead - rd ) ; return rd ;


signature:
public class RateLimitInputStream { /** * This method complies with { @ link InputStream # read ( byte [ ] , int , int ) } and
 * imposes stronger postconditions .
 * Reads up to < code > len < / code > bytes from the stream . This method blocks for
 * the first byte reagrdless of the stream ' s boring flag . For all subsequent
 * bytes , the behavior depends on the boring flag :
 * < ul >
 * < li > In boring mode , the stream blocks until all bytes actually available
 * from the underlying InputStream ( reported by
 * { @ link InputStream # available ( ) } ) have been read , even if this means
 * waiting for the next tick . < / li >
 * < li > In non - boring mode , the stream does not block for the first byte ' s
 * subsequent bytes . This means that if a rate limitation is in place ( ie .
 * the rate has been reached for the current tick ) , this method does not
 * attempt to read the bytes ( the number of actually read bytes is returned
 * conforming with { @ link InputStream # read ( byte [ ] , int , int ) } . < / li >
 * < / ul > */
@ Override public int read ( byte [ ] b , int off , int len ) throws IOException { } }

implementation: int done = 0 ; while ( done < len && ( done == 0 || available ( ) > 0 || ( boring && real . available ( ) > 0 ) ) ) done += realRead ( b , off + done , Math . min ( len - done , Math . max ( 1 , rateHelper . getThingsPerTick ( ) ) ) ) ; return done ;


signature:
public class SleepWakeup { /** * Sleeps for the provided amount of milliseconds , ignoring thread
 * interrupts .
 * @ param ms
 * how many milliseconds to sleep */
public static void sleep ( int ms ) { } }

implementation: long deadline = System . currentTimeMillis ( ) + ms ; while ( System . currentTimeMillis ( ) < deadline ) { try { Thread . sleep ( Math . max ( 1 , ( deadline - System . currentTimeMillis ( ) ) / 2 ) ) ; } catch ( InterruptedException ignore ) { } }


signature:
public class RateHelper { /** * Takes one thing ( eg . byte ) . This method blocks until one thing can be used
 * according to the current rate and prescaling settings . */
public void takeOne ( ) { } }

implementation: while ( true ) { int stored = spent . get ( ) ; if ( stored >= thingsPerTick ) sleep ( ) ; else if ( spent . compareAndSet ( stored , stored + 1 ) ) break ; }


signature:
public class RateHelper { /** * Takes several things ( eg . bytes ) . This method blocks until at least one
 * thing can be used according to the current rate and prescaling settings .
 * This method returns at least 1.
 * @ param n
 * up to how many things to take
 * @ return the number of things that have been taken , at least 1 */
public int take ( int n ) { } }

implementation: int lenToTake ; while ( true ) { int stored = spent . get ( ) ; lenToTake = Math . min ( n , thingsPerTick - stored ) ; if ( stored >= thingsPerTick ) sleep ( ) ; else if ( spent . compareAndSet ( stored , stored + lenToTake ) ) break ; } timewiseAvailable -= lenToTake ; return lenToTake ;


signature:
public class DelayCalculator { /** * Returns a result for the given delay and epsilon ( error rate ) . Epsilon
 * must be between 0 and 1 , exclusively . See { @ link DelayCalculator } for
 * details .
 * @ param nanoseconds
 * The required delay in nanoseconds
 * @ param epsilon
 * The permitted error ( 0 & lt ; epsilon & lt ; 1)
 * @ return The calculation result */
public static Result calculate ( long nanoseconds , float epsilon ) { } }

implementation: if ( epsilon <= 0 || epsilon >= 1 ) throw new IllegalArgumentException ( "0 < epsilon < 1 not satisfied" ) ; long max_divider = ( int ) ( 1D / epsilon ) ; if ( nanoseconds < max_divider ) return new Result ( nanoseconds , 1 ) ; long interval = Math . min ( MAX_INTERVAL , nanoseconds / max_divider ) ; long correction = nanoseconds / interval ; return new Result ( interval , correction ) ;


signature:
public class RealTimeTickSource { /** * If the last tick listener has been removed from this source , it shuts
 * itself down via { @ link # stop ( ) } , if it ' s not set to keepAlive mode using
 * { @ link # setKeepAlive ( boolean ) } . */
@ Override public void removeListener ( TickListener listener ) { } }

implementation: super . removeListener ( listener ) ; if ( listeners . isEmpty ( ) && ! keepAlive ) stop ( ) ;


signature:
public class RealTimeTickSource { /** * Starts generating tick events , starting from 0 . This method must not be
 * called when the tick source is already running . */
public void start ( ) { } }

implementation: if ( timer != null ) throw new IllegalStateException ( "already running" ) ; if ( interval < BUSY_WAITING_THRESHOLD ) timer = new MyBusyTimer ( ) ; else if ( interval < MILLISECOND_THRESHOLD ) timer = new MyWaitingTimer ( ) ; else timer = new MyMillisecondTimer ( ) ; Thread thread = new Thread ( timer , "timer" ) ; thread . setDaemon ( true ) ; thread . start ( ) ;