signature:
public class RdfIo { /** * Creates an { @ link IoWriter } using the given { @ link XMLStreamWriter } object .
 * < p > This { @ link IoWriter } provides a method to write { @ link DocumentRoot } objects in RDF / XML format .
 * During the serialisation , the RDF namespace is added if it is not provided in the { @ link NamespaceBinding } s property of a { @ link DocumentRoot } .
 * @ param writer The { @ link XMLStreamWriter } writer to serialise a { @ link DocumentRoot } .
 * @ return { @ link IoWriter } */
public IoWriter < QName > createIoWriter ( final XMLStreamWriter writer ) { } }

implementation:
return new IoWriter < QName > ( ) { @ Override public void write ( DocumentRoot < QName > document ) throws CoreIoException { try { writer . writeStartDocument ( ) ; writeStartElement ( RDF ) ; setPrefix ( rdf ) ; if ( ! document . getNamespaceBindings ( ) . contains ( rdf ) ) { writeNamespace ( rdf ) ; } for ( NamespaceBinding nb : document . getNamespaceBindings ( ) ) { setPrefix ( nb ) ; writeNamespace ( nb ) ; } for ( TopLevelDocument < QName > child : document . getTopLevelDocuments ( ) ) { write ( child ) ; } writer . writeEndElement ( ) ; writer . writeEndDocument ( ) ; } catch ( XMLStreamException xse ) { throw new CoreIoException ( xse ) ; } } private void write ( IdentifiableDocument < QName > doc ) throws XMLStreamException { writeStartElement ( doc . getType ( ) ) ; writeAttribute ( rdfAbout , doc . getIdentity ( ) . toString ( ) ) ; for ( NamedProperty < QName > property : doc . getProperties ( ) ) { write ( property ) ; } writer . writeEndElement ( ) ; } private void write ( final NamedProperty < QName > property ) { new PropertyValue . Visitor < QName > ( ) { @ Override public void visit ( NestedDocument < QName > v ) throws XMLStreamException { writeStartElement ( property . getName ( ) ) ; write ( v ) ; writer . writeEndElement ( ) ; } @ Override public void visit ( Literal < QName > v ) throws XMLStreamException { if ( isEmptyElementValue ( v ) ) { writeEmptyElement ( property . getName ( ) ) ; write ( v ) ; } else { writeStartElement ( property . getName ( ) ) ; write ( v ) ; writer . writeEndElement ( ) ; } } } . visit ( property . getValue ( ) ) ; } private boolean isEmptyElementValue ( Literal < QName > literal ) { return /* literal instanceof Literal . QNameLiteral | | */
literal instanceof Literal . UriLiteral ; } private void write ( Literal < QName > literal ) { new Literal . Visitor < QName > ( ) { @ Override public void visit ( Literal . StringLiteral < QName > l ) throws XMLStreamException { writer . writeCharacters ( l . getValue ( ) ) ; } @ Override public void visit ( Literal . UriLiteral < QName > l ) throws XMLStreamException { writeAttribute ( rdfResource , l . getValue ( ) . toString ( ) ) ; } @ Override public void visit ( Literal . IntegerLiteral < QName > l ) throws XMLStreamException { writer . writeCharacters ( l . getValue ( ) . toString ( ) ) ; } @ Override public void visit ( Literal . DoubleLiteral < QName > l ) throws XMLStreamException { writer . writeCharacters ( l . getValue ( ) . toString ( ) ) ; } @ Override public void visit ( Literal . TypedLiteral < QName > l ) throws XMLStreamException { writer . writeCharacters ( l . getValue ( ) + "^^" + l . getType ( ) . getPrefix ( ) + ":" + l . getType ( ) . getLocalPart ( ) ) ; } @ Override public void visit ( Literal . BooleanLiteral < QName > l ) throws XMLStreamException { writer . writeCharacters ( l . getValue ( ) . toString ( ) ) ; } } . visit ( literal ) ; } private void writeEmptyElement ( QName tagName ) throws XMLStreamException { writer . writeEmptyElement ( tagName . getPrefix ( ) , tagName . getLocalPart ( ) , tagName . getNamespaceURI ( ) ) ; } private void writeStartElement ( QName tagName ) throws XMLStreamException { writer . writeStartElement ( tagName . getPrefix ( ) , tagName . getLocalPart ( ) , tagName . getNamespaceURI ( ) ) ; } private void setPrefix ( NamespaceBinding binding ) throws XMLStreamException { writer . setPrefix ( binding . getPrefix ( ) , binding . getNamespaceURI ( ) ) ; } private void writeNamespace ( NamespaceBinding binding ) throws XMLStreamException { writer . writeNamespace ( binding . getPrefix ( ) , binding . getNamespaceURI ( ) ) ; } private void writeAttribute ( QName attrName , String attrValue ) throws XMLStreamException { writer . writeAttribute ( attrName . getPrefix ( ) , attrName . getNamespaceURI ( ) , attrName . getLocalPart ( ) , attrValue ) ; } } ;


signature:
public class ThreadPoolExecutor { /** * ( non - Javadoc )
 * @ see com . azaptree . services . executor . ThreadPoolExecutorJmxApi # allowCoreThreadTimeOut ( boolean ) */
@ ManagedOperation ( description = "Sets the policy governing whether core threads may time out and terminate if no tasks arrive within the keep-alive time, being replaced if needed when new tasks arrive." ) @ ManagedOperationParameters ( { } }

implementation: @ ManagedOperationParameter ( name = "value" , description = "true if should time out, else false" ) } ) @ Override public void allowCoreThreadTimeOut ( final boolean value ) { super . allowCoreThreadTimeOut ( value ) ;


signature:
public class ThreadPoolExecutor { /** * ( non - Javadoc )
 * @ see com . azaptree . services . executor . ThreadPoolExecutorJmxApi # setCorePoolSize ( int ) */
@ ManagedOperation ( description = "Sets the core number of threads. If the new value is smaller than the current value, excess existing threads will be terminated when they next become idle. If larger, new threads will, if needed, be started to execute any queued tasks" ) @ ManagedOperationParameters ( { } }

implementation: @ ManagedOperationParameter ( name = "corePoolSize" , description = "the new core size" ) } ) @ Override public void setCorePoolSize ( final int corePoolSize ) { super . setCorePoolSize ( corePoolSize ) ;


signature:
public class ThreadPoolExecutor { /** * ( non - Javadoc )
 * @ see com . azaptree . services . executor . ThreadPoolExecutorJmxApi # setKeepAliveTimeSecs ( int ) */
@ Override @ ManagedOperation ( description = "Sets the time limit in seconds for which threads may remain idle before being terminated." ) @ ManagedOperationParameters ( { } }

implementation: @ ManagedOperationParameter ( name = "time" , description = "the time in seconds to wait. A time value of zero will cause excess threads to terminate immediately after executing tasks." ) } ) public void setKeepAliveTimeSecs ( final int time ) { super . setKeepAliveTime ( time , TimeUnit . SECONDS ) ;


signature:
public class ThreadPoolExecutor { /** * ( non - Javadoc )
 * @ see com . azaptree . services . executor . ThreadPoolExecutorJmxApi # setMaximumPoolSize ( int ) */
@ ManagedOperation ( description = "Sets the maximum allowed number of threads." ) @ ManagedOperationParameters ( { } }

implementation: @ ManagedOperationParameter ( name = "maximumPoolSize" , description = "the new maximum" ) } ) @ Override public void setMaximumPoolSize ( final int maximumPoolSize ) { super . setMaximumPoolSize ( maximumPoolSize ) ;


signature:
public class WorkflowHarvester { /** * Basic init ( ) function . Notice the lack of parameters . This is not part
 * of the Plugin API but from the GenericHarvester implementation . It will
 * be called following the constructor verifies configuration is available .
 * @ throws HarvesterException : If there are problems during instantiation */
@ Override public void init ( ) throws HarvesterException { } }

implementation:
forceLocalStorage = getJsonConfig ( ) . getBoolean ( true , "harvester" , "workflow-harvester" , "force-storage" ) ; forceUpdate = getJsonConfig ( ) . getBoolean ( false , "harvester" , "workflow-harvester" , "force-update" ) ; // Order is significant
renderChains = new LinkedHashMap < String , Map < String , List < String > > > ( ) ; JsonObject renderTypes = getJsonConfig ( ) . getObject ( "renderTypes" ) ; if ( renderTypes != null ) { for ( Object name : renderTypes . keySet ( ) ) { Map < String , List < String > > details = new HashMap < String , List < String > > ( ) ; JsonObject chain = ( JsonObject ) renderTypes . get ( name ) ; details . put ( "fileTypes" , JsonSimple . getStringList ( chain , "fileTypes" ) ) ; details . put ( "harvestQueue" , JsonSimple . getStringList ( chain , "harvestQueue" ) ) ; details . put ( "indexOnHarvest" , JsonSimple . getStringList ( chain , "indexOnHarvest" ) ) ; details . put ( "renderQueue" , JsonSimple . getStringList ( chain , "renderQueue" ) ) ; renderChains . put ( ( String ) name , details ) ; } }


signature:
public class WorkflowHarvester { /** * Get an individual uploaded file as a digital object . For consistency this
 * should be in a list .
 * @ return a list of one object ID
 * @ throws HarvesterException if there was an error retrieving the objects */
@ Override public Set < String > getObjectId ( File uploadedFile ) throws HarvesterException { } }

implementation: Set < String > objectIds = new HashSet < String > ( ) ; try { objectIds . add ( createDigitalObject ( uploadedFile ) ) ; } catch ( StorageException se ) { throw new HarvesterException ( se ) ; } return objectIds ;


signature:
public class WorkflowHarvester { /** * Store the provided file in storage . Ensure proper queue routing is set
 * in object properties .
 * @ param file : The file to store
 * @ return String : The OID of the stored object
 * @ throws HarvesterException : if there was an error accessing storage
 * @ throws StorageException : if there was an error writing to storage */
private String createDigitalObject ( File file ) throws HarvesterException , StorageException { } }

implementation:
String objectId ; DigitalObject object ; if ( forceUpdate ) { object = StorageUtils . storeFile ( getStorage ( ) , file , ! forceLocalStorage ) ; } else { String oid = StorageUtils . generateOid ( file ) ; String pid = StorageUtils . generatePid ( file ) ; object = getStorage ( ) . createObject ( oid ) ; if ( forceLocalStorage ) { try { object . createStoredPayload ( pid , new FileInputStream ( file ) ) ; } catch ( FileNotFoundException ex ) { throw new HarvesterException ( ex ) ; } } else { object . createLinkedPayload ( pid , file . getAbsolutePath ( ) ) ; } } // update object metadata
Properties props = object . getMetadata ( ) ; props . setProperty ( "render-pending" , "true" ) ; props . setProperty ( "file.path" , FilenameUtils . separatorsToUnix ( file . getAbsolutePath ( ) ) ) ; objectId = object . getId ( ) ; // Store rendition information if we have it
String ext = FilenameUtils . getExtension ( file . getName ( ) ) ; for ( String chain : renderChains . keySet ( ) ) { Map < String , List < String > > details = renderChains . get ( chain ) ; if ( details . get ( "fileTypes" ) . contains ( ext ) ) { storeList ( props , details , "harvestQueue" ) ; storeList ( props , details , "indexOnHarvest" ) ; storeList ( props , details , "renderQueue" ) ; } } object . close ( ) ; return objectId ;


signature:
public class WorkflowHarvester { /** * Take a list of strings from a Java Map , concatenate the values together
 * and store them in a Properties object using the Map ' s original key .
 * @ param props : Properties object to store into
 * @ param details : The full Java Map
 * @ param field : The key to use in both objects */
private void storeList ( Properties props , Map < String , List < String > > details , String field ) { } }

implementation:
Set < String > valueSet = new LinkedHashSet < String > ( ) ; // merge with original property value if exists
String currentValue = props . getProperty ( field , "" ) ; if ( ! "" . equals ( currentValue ) ) { String [ ] currentList = currentValue . split ( "," ) ; valueSet . addAll ( Arrays . asList ( currentList ) ) ; } valueSet . addAll ( details . get ( field ) ) ; String joinedList = StringUtils . join ( valueSet , "," ) ; props . setProperty ( field , joinedList ) ;


signature:
public class DryDescriptor { /** * Performs on - the - fly validation on threshold for high warnings .
 * @ param highThreshold
 * the threshold for high warnings
 * @ param normalThreshold
 * the threshold for normal warnings
 * @ return the validation result */
public FormValidation doCheckHighThreshold ( @ QueryParameter final String highThreshold , @ QueryParameter final String normalThreshold ) { } }

implementation: return VALIDATION . validateHigh ( highThreshold , normalThreshold ) ;


signature:
public class DryDescriptor { /** * Performs on - the - fly validation on threshold for normal warnings .
 * @ param highThreshold
 * the threshold for high warnings
 * @ param normalThreshold
 * the threshold for normal warnings
 * @ return the validation result */
public FormValidation doCheckNormalThreshold ( @ QueryParameter final String highThreshold , @ QueryParameter final String normalThreshold ) { } }

implementation: return VALIDATION . validateNormal ( highThreshold , normalThreshold ) ;


signature:
public class MetadataManager { /** * Make sure that the metadata exists . If it does not exist , create
 * the metadata table from scratch and register its creation .
 * @ return A migration result if the table was created or null if it already existed . */
public List < MetadataInfo > ensureMetadata ( final MigratoryOption [ ] options ) throws MigratoryException { } }

implementation:
if ( migratoryContext . getDbSupport ( ) . tableExists ( migratoryConfig . getMetadataTableName ( ) ) ) { return null ; } if ( migratoryConfig . isReadOnly ( ) ) { throw new MigratoryException ( Reason . IS_READONLY ) ; } // Table does not exist . The way we get one , is that we run a special migration for the internal metadata schema
final MigrationPlanner migrationPlanner = new MigrationPlanner ( new MigrationManager ( migratoryContext , METADATA_MIGRATION_NAME ) , 0 , Integer . MAX_VALUE ) ; migrationPlanner . plan ( ) ; if ( migrationPlanner . getDirection ( ) != MigrationDirection . FORWARD ) { throw new MigratoryException ( Reason . INTERNAL , "Migration planner could not plan a migration for the metadata table!" ) ; } final DbMigrator migrator = new DbMigrator ( migratoryContext , migrationPlanner ) ; try { lock ( METADATA_MIGRATION_NAME ) ; final List < MigrationResult > results = migrator . migrate ( options ) ; return commit ( results ) ; } catch ( MigratoryException e ) { rollback ( ) ; throw e ; } catch ( RuntimeException e ) { rollback ( ) ; throw e ; }


signature:
public class DryDetailBuilder { /** * Creates the dry source detail view .
 * @ param owner
 * the owner
 * @ param container
 * the container
 * @ param defaultEncoding
 * the default encoding
 * @ param fromString
 * from ID
 * @ param toString
 * to ID
 * @ return the detail view or < code > null < / code > */
private Object createDrySourceDetail ( final AbstractBuild < ? , ? > owner , final AnnotationContainer container , final String defaultEncoding , final String fromString , final String toString ) { } }

implementation: long from = Long . parseLong ( fromString ) ; long to = Long . parseLong ( toString ) ; FileAnnotation fromAnnotation = container . getAnnotation ( from ) ; if ( fromAnnotation instanceof DuplicateCode ) { return new SourceDetail ( owner , ( ( DuplicateCode ) fromAnnotation ) . getLink ( to ) , defaultEncoding ) ; } return null ;


signature:
public class DuplicationParserRegistry { /** * { @ inheritDoc } */
public Collection < FileAnnotation > parse ( final File file , final String moduleName ) throws InvocationTargetException { } }

implementation: String oldProperty = System . getProperty ( SAX_DRIVER_PROPERTY ) ; if ( oldProperty != null ) { System . setProperty ( SAX_DRIVER_PROPERTY , SAXParser . class . getName ( ) ) ; } FileInputStream inputStream = null ; try { for ( AbstractDryParser parser : parsers ) { inputStream = new FileInputStream ( file ) ; if ( parser . accepts ( inputStream ) ) { IOUtils . closeQuietly ( inputStream ) ; inputStream = new FileInputStream ( file ) ; Collection < DuplicateCode > result = parser . parse ( inputStream , moduleName ) ; createLinkNames ( result ) ; Set < FileAnnotation > warnings = Sets . newHashSet ( ) ; warnings . addAll ( result ) ; ContextHashCode hashCode = new ContextHashCode ( ) ; for ( FileAnnotation duplication : warnings ) { duplication . setContextHashCode ( hashCode . create ( duplication . getFileName ( ) , duplication . getPrimaryLineNumber ( ) , defaultEncoding ) ) ; } return warnings ; } } throw new IOException ( "No parser found for duplicated code results file " + file . getAbsolutePath ( ) ) ; } catch ( IOException exception ) { throw new InvocationTargetException ( exception ) ; } finally { IOUtils . closeQuietly ( inputStream ) ; if ( oldProperty != null ) { System . setProperty ( SAX_DRIVER_PROPERTY , oldProperty ) ; } }


signature:
public class DuplicationParserRegistry { /** * For each duplicate code annotation that does not have a package name
 * ( i . e . , for non Java sources ) , a link name is generated .
 * @ param result the annotations */
private void createLinkNames ( final Collection < DuplicateCode > result ) { } }

implementation: if ( workspacePath != null ) { for ( FileAnnotation duplication : result ) { duplication . setPathName ( workspacePath ) ; } }


signature:
public class ThresholdValidation { /** * Performs on - the - fly validation on threshold for high warnings .
 * @ param highThreshold
 * the threshold for high warnings
 * @ param normalThreshold
 * the threshold for normal warnings
 * @ return the validation result */
public FormValidation validateHigh ( final String highThreshold , final String normalThreshold ) { } }

implementation: return validate ( highThreshold , normalThreshold , Messages . DRY_ValidationError_HighThreshold ( ) ) ;


signature:
public class ThresholdValidation { /** * Performs on - the - fly validation on threshold for normal warnings .
 * @ param highThreshold
 * the threshold for high warnings
 * @ param normalThreshold
 * the threshold for normal warnings
 * @ return the validation result */
public FormValidation validateNormal ( final String highThreshold , final String normalThreshold ) { } }

implementation: return validate ( highThreshold , normalThreshold , Messages . DRY_ValidationError_NormalThreshold ( ) ) ;


signature:
public class ThresholdValidation { /** * Performs on - the - fly validation on thresholds for high and normal warnings .
 * @ param highThreshold
 * the threshold for high warnings
 * @ param normalThreshold
 * the threshold for normal warnings
 * @ param message
 * the validation message
 * @ return the validation result */
private FormValidation validate ( final String highThreshold , final String normalThreshold , final String message ) { } }

implementation:
try { int high = Integer . parseInt ( highThreshold ) ; int normal = Integer . parseInt ( normalThreshold ) ; if ( isValid ( normal , high ) ) { return FormValidation . ok ( ) ; } } catch ( NumberFormatException exception ) { // ignore and return failure
} return FormValidation . error ( message ) ;


signature:
public class WebRequestCommand { /** * Creates a relative resource for this command . The resource path is set to the command name , and a POST method is added :
 * < code >
 * < resource path = " command - name " >
 * < method name = " POST " > < / method >
 * < / resource >
 * < / code >
 * Override this method to further describe the REST API for the is command . For example :
 * < ul >
 * < li > you may want add documentation , via Doc elements < / li >
 * < li > describe further HTTP error responses < / li >
 * < / ul >
 * @ return */
public Resource createCommandResourceWadl ( ) { } }

implementation: final Resource resource = new Resource ( ) ; resource . setPath ( getName ( ) ) ; final Method method = new Method ( ) ; method . setName ( "POST" ) ; resource . getMethodOrResource ( ) . add ( method ) ; definePostMethodWadl ( method ) ; return resource ;


signature:
public class HandlerScanner { /** * Scans the package " module . application . service . handler " for classes
 * annotated with " @ Handler ( protocol = . . . ) " . For every class found with this
 * annotation an instance of this class is created per Java - Reflection and
 * added to the result list of handlers .
 * @ return A list of instantiated and proxied handler .
 * @ throws Exception
 * Reflection - Exception */
public static < T , D > List < IHandler < T , D > > scan ( ) throws Exception { } }

implementation: return scan ( false ) ;


signature:
public class HandlerScanner { /** * Scans the package " module . application . service . handler " for classes
 * annotated with " @ Handler ( protocol = . . . ) " . For every class found with this
 * annotation an instance of this class is created per Java - Reflection and
 * added to the result list of handlers . The difference between this method
 * and the scan - Method is that this method creates a proxy - object for each
 * created instance . The reason for doing this is that upon calling any
 * method of these proxied - instances , a small logic has to be done after
 * this method has returned and just before the caller receives the result .
 * @ return A list of instantiated and proxied handler .
 * @ throws Exception
 * Reflection - Exception */
public static < T , D > List < IHandler < T , D > > proxyScan ( ) throws Exception { } }

implementation: return scan ( true ) ;


signature:
public class JarLoader { /** * This method loads a file from a file : / . . . URI . This is probably not what you are looking for . */
@ Override public String loadFile ( final URI fileUri ) throws IOException { } }

implementation: return Resources . toString ( fileUri . toURL ( ) , charset ) ;


signature:
public class Utils { /** * Validate that the method parameters if Bean Validation 1.1 is available
 * on classpath . */
static void validateArgs ( List < Object > args , Object instance , Method m , Command cmd ) { } }

implementation: if ( ! onClasspath ( JSR303_1_1_CLASSNAME ) ) { return ; } try { Object validator = getValidator ( ) ; Method validate = validator . getClass ( ) . getMethod ( "validateArgs" , List . class , Object . class , Method . class , Command . class ) ; validate . invoke ( validator , args , instance , m , cmd ) ; } catch ( InvocationTargetException e ) { if ( e . getTargetException ( ) instanceof RuntimeException ) { throw ( RuntimeException ) e . getCause ( ) ; } throw new RuntimeException ( e . getCause ( ) ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; }


signature:
public class Utils { /** * Validate that the options if Bean Validation is available on classpath . */
static void validateOpts ( Object instance ) { } }

implementation: if ( ! onClasspath ( JSR303_1_0_CLASSNAME ) ) { return ; } try { Object validator = getValidator ( ) ; Method validate = validator . getClass ( ) . getMethod ( "validateOpts" , Object . class ) ; validate . invoke ( validator , instance ) ; } catch ( InvocationTargetException e ) { if ( e . getTargetException ( ) instanceof RuntimeException ) { throw ( RuntimeException ) e . getTargetException ( ) ; } throw new RuntimeException ( e . getTargetException ( ) ) ; } catch ( RuntimeException e ) { throw e ; } catch ( Throwable e ) { throw new RuntimeException ( e ) ; }


signature:
public class Utils { /** * Checks to see if JSR303 implementation is
 * available on classpath . */
static boolean onClasspath ( String className ) { } }

implementation: ClassLoader cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { cl . loadClass ( className ) ; } catch ( ClassNotFoundException e ) { return false ; } return true ;


signature:
public class DryReporterDescriptor { /** * Performs on - the - fly validation on threshold for high warnings .
 * @ param highThreshold
 * the threshold for high warnings
 * @ param normalThreshold
 * the threshold for normal warnings
 * @ return the validation result */
public FormValidation doCheckHighThreshold ( @ QueryParameter final String highThreshold , @ QueryParameter final String normalThreshold ) { } }

implementation: return THRESHOLD_VALIDATION . validateHigh ( highThreshold , normalThreshold ) ;


signature:
public class DryReporterDescriptor { /** * Performs on - the - fly validation on threshold for normal warnings .
 * @ param highThreshold
 * the threshold for high warnings
 * @ param normalThreshold
 * the threshold for normal warnings
 * @ return the validation result */
public FormValidation doCheckNormalThreshold ( @ QueryParameter final String highThreshold , @ QueryParameter final String normalThreshold ) { } }

implementation: return THRESHOLD_VALIDATION . validateNormal ( highThreshold , normalThreshold ) ;


signature:
public class LoaderManager { /** * Returns true if this loader accepts the URI . */
public boolean accept ( final URI uri ) { } }

implementation: for ( final MigrationLoader loader : loaders ) { if ( loader . accept ( uri ) ) { return true ; } } return false ;


signature:
public class LoaderManager { /** * Loads a collection of URIs from a given location . The resulting
 * URIs may or may not loadable using this loader ( e . g . a classpath folder
 * can contain File or Jar URIs . */
public Collection < URI > loadFolder ( final URI folderUri , final String pattern ) { } }

implementation: try { for ( final MigrationLoader loader : loaders ) { if ( loader . accept ( folderUri ) ) { return loader . loadFolder ( folderUri , pattern ) ; } } return null ; } catch ( IOException ioe ) { throw new MigratoryException ( Reason . INTERNAL , ioe ) ; }


signature:
public class LoaderManager { /** * Load a file from an URI . */
public String loadFile ( final URI fileUri ) { } }

implementation: try { for ( final MigrationLoader loader : loaders ) { if ( loader . accept ( fileUri ) ) { return loader . loadFile ( fileUri ) ; } } return null ; } catch ( IOException ioe ) { throw new MigratoryException ( Reason . INTERNAL , ioe ) ; }


signature:
public class CliMain { /** * Start evaluating the user input and eventually execute the command
 * requested by the user .
 * @ throws RuntimeException Any runtime exceptions thrown by either this
 * library or user commands will fall through and thrown from this method . */
public void run ( ) throws RuntimeException { } }

implementation: if ( terminalArgs == null ) { terminalArgs = new String [ 0 ] ; } p = GNUishParser . parse ( terminalArgs ) ; readCommands ( ) ; if ( p . getCommand ( ) == null || "" . equals ( p . getCommand ( ) ) ) { Utils . printAvailableCommandsHelp ( commands ) ; return ; } final Command cmd = commands . get ( p . getCommand ( ) ) ; if ( cmd == null ) { throw CliException . COMMAND_NOT_FOUND ( p . getCommand ( ) ) ; } if ( p . help ( ) ) { Utils . printCommandHelp ( cmd ) ; return ; } try { cmd . execute ( p ) ; } catch ( Exception e ) { if ( p . debug ( ) ) { e . printStackTrace ( ) ; } if ( e instanceof RuntimeException ) { throw ( RuntimeException ) e ; } }


signature:
public class CliMain { /** * Find all commands available on classpath . */
private void readCommands ( ) { } }

implementation: try { final Enumeration < URL > urls = Thread . currentThread ( ) . getContextClassLoader ( ) . getResources ( XmlCommands . FILEPATH ) ; while ( urls . hasMoreElements ( ) ) { URL url = urls . nextElement ( ) ; InputStream in = url . openStream ( ) ; for ( Command command : XmlCommands . fromXml ( in ) ) { commands . put ( command . getCommand ( ) , command ) ; } } } catch ( IOException e ) { throw new RuntimeException ( e ) ; }


signature:
public class AsyncHttpHandlerSupport { /** * The purpose of this methods is to allow the Handler to return an HTTP response . For example , return an appropriate response that the request was accepted
 * per the requirements of a REST API .
 * * * * NOTE : to indicate that this method handled the request , set Request . handled to true : < code > baseRequest . setHandled ( true ) ; < / code >
 * @ param target
 * @ param baseRequest
 * @ param request
 * @ param response
 * @ throws IOException
 * @ throws ServletException */
protected void postProcess ( final String target , final Request baseRequest , final HttpServletRequest request , final HttpServletResponse response ) throws IOException , ServletException { } }

implementation: // NOOP


signature:
public class AsyncHttpHandlerSupport { /** * Validate the request and extract any data from the HTTP request that will be required to process the request asynchronously .
 * If the request is invalid , then handle the request appropriately .
 * * * * NOTE : to indicate that this method handled the request , set Request . handled to true : < code > baseRequest . setHandled ( true ) ; < / code >
 * @ param target
 * @ param baseRequest
 * @ param request
 * @ param response
 * @ return */
protected Map < String , Object > preProcess ( final String target , final Request baseRequest , final HttpServletRequest request , final HttpServletResponse response ) throws IOException , ServletException { } }

implementation: return Collections . emptyMap ( ) ;


signature:
public class Migratory { /** * Bring the current database to the requested levels . */
public Map < String , List < MetadataInfo > > dbMigrate ( final MigrationPlan migrationPlan , final MigratoryOption ... options ) throws MigratoryException { } }

implementation: init ( ) ; final InternalMigrator migrator = new InternalMigrator ( this ) ; return migrator . migrate ( migrationPlan , options ) ;


signature:
public class Migratory { /** * Run validation on the database . Make sure that all the changes recorded in the database are the same as the ones that should be applied . */
public Map < String , ValidationResult > dbValidate ( final Collection < String > personalities , final MigratoryOption ... options ) throws MigratoryException { } }

implementation: init ( ) ; final InternalValidator validator = new InternalValidator ( this ) ; return validator . validate ( personalities , options ) ;


signature:
public class Migratory { /** * Drops all objects ( tables , views , procedures , triggers , . . . ) in the current schema . */
public void dbClean ( final MigratoryOption ... options ) { } }

implementation: init ( ) ; final InternalClean internalClean = new InternalClean ( this ) ; internalClean . clean ( options ) ;


signature:
public class Migratory { /** * Returns the status ( current version ) of the database . */
public Map < String , StatusResult > dbStatus ( final Collection < String > personalities , final MigratoryOption ... options ) { } }

implementation: init ( ) ; final InternalStatus internalStatus = new InternalStatus ( this ) ; return internalStatus . status ( personalities , options ) ;


signature:
public class Migratory { /** * Returns the full history of all applied migrations . */
public Map < String , List < MetadataInfo > > dbHistory ( final Collection < String > personalities , final MigratoryOption ... options ) throws MigratoryException { } }

implementation: init ( ) ; final InternalHistory internalHistory = new InternalHistory ( this ) ; return internalHistory . history ( personalities , options ) ;


signature:
public class Migratory { /** * Creates and initializes the Migratory metadata table .
 * Returns null if the table already exists , returns a list of migration results
 * for the migrations executed otherwise . */
public List < MetadataInfo > dbInit ( final MigratoryOption ... options ) throws MigratoryException { } }

implementation: init ( ) ; final InternalInit internalInit = new InternalInit ( this ) ; return internalInit . init ( options ) ;


signature:
public class Migratory { /** * Add support for an additional database type . The dbName is * not * the canonical name used but the
 * name returned from the database engine on the JDBC metadata ! */
public Migratory addDbSupport ( final String dbName , final Class < ? extends DbSupport > dbSupport ) { } }

implementation: if ( initialized ) { throw new MigratoryException ( Reason . INIT , "Already initialized!" ) ; } dbSupportFactory . addDbSupport ( dbName , dbSupport ) ; return this ;


signature:
public class CORSConfiguration { /** * Helper method to check whether requests from the specified origin
 * must be allowed . This is done by looking up { @ link # allowAnyOrigin }
 * and { @ link # allowedOrigins } as well as the { @ link # allowSubdomains }
 * setting .
 * @ param origin The origin as reported by the web client ( browser ) ,
 * { @ code null } if unknown .
 * @ return { @ code true } if the origin is allowed , else { @ code false } . */
public final boolean isAllowedOrigin ( final Origin origin ) { } }

implementation: if ( allowAnyOrigin ) return true ; if ( origin == null ) return false ; if ( allowedOrigins . contains ( origin ) ) return true ; else if ( allowSubdomains ) return isAllowedSubdomainOrigin ( origin ) ; return false ;


signature:
public class CORSConfiguration { /** * Helper method to check whether the specified origin is a subdomain
 * origin of the { @ link # allowedOrigins } . This is done by looking up the
 * origin ' s scheme , hostname and port and matching them with each of the
 * { @ link # allowedOrigins } .
 * < p > Example :
 * < p > { @ code Origin : https : / / foo . example . com } matches
 * { @ code cors . allowedOrigin = https : / / example . com } whereas
 * { @ code cors . allowedOrigin = http : / / example . com } would not match .
 * @ param origin The origin as reported by the web client ( browser ) ,
 * { @ code null } if unknown .
 * @ return { @ code true } if the origin is an allowed subdomain origin ,
 * else { @ code false } . */
public final boolean isAllowedSubdomainOrigin ( final Origin origin ) { } }

implementation: try { ValidatedOrigin validatedOrigin = origin . validate ( ) ; String scheme = validatedOrigin . getScheme ( ) ; String suffix = validatedOrigin . getSuffix ( ) ; for ( ValidatedOrigin allowedOrigin : allowedOrigins ) { if ( suffix . endsWith ( "." + allowedOrigin . getSuffix ( ) ) && scheme . equalsIgnoreCase ( allowedOrigin . getScheme ( ) ) ) return true ; } } catch ( OriginException e ) { return false ; } return false ;


signature:
public class CORSConfiguration { /** * Parses a string containing words separated by space and / or comma .
 * @ param s The string to parse . Must not be { @ code null } .
 * @ return An array of the parsed words , empty if none were found . */
protected static String [ ] parseWords ( final String s ) { } }

implementation: String s1 = s . trim ( ) ; if ( s1 . isEmpty ( ) ) return new String [ ] { } ; else return s1 . split ( "\\s*,\\s*|\\s+" ) ;


signature:
public class CommandContextValidatorSupport { /** * Checks required input keys , and then delegates to checkInput ( ) ; */
@ Override public void validateInput ( final Command command , final Context ctx ) throws ValidationException { } }

implementation: checkRequiredInputKeys ( command , ctx ) ; checkInput ( command , ctx ) ;


signature:
public class CommandContextValidatorSupport { /** * Checks required output keys , and then delegates to checkOutput ( ) ; */
@ Override public void validateOutput ( final Command command , final Context ctx ) throws ValidationException { } }

implementation: checkRequiredOutputKeys ( command , ctx ) ; checkOutput ( command , ctx ) ;


signature:
public class SqlScript { /** * Turns these lines in a series of statements . */
List < SqlStatement > linesToStatements ( List < String > lines ) { } }

implementation:
final List < SqlStatement > statements = Lists . newArrayList ( ) ; final StringBuilder statementSql = new StringBuilder ( ) ; int count = 0 ; String delimiter = DEFAULT_STATEMENT_DELIMITER ; for ( final String line : lines ) { if ( StringUtils . isBlank ( line ) ) { continue ; } if ( statementSql . length ( ) > 0 ) { statementSql . append ( " " ) ; } statementSql . append ( line ) ; final String oldDelimiter = delimiter ; delimiter = changeDelimiterIfNecessary ( statementSql . toString ( ) , line , delimiter ) ; if ( ! StringUtils . equals ( delimiter , oldDelimiter ) && isDelimiterChangeExplicit ( ) ) { statementSql . setLength ( 0 ) ; continue ; // for
} if ( StringUtils . endsWith ( line , delimiter ) ) { // Trim off the delimiter at the end .
statementSql . setLength ( statementSql . length ( ) - delimiter . length ( ) ) ; statements . add ( new SqlStatement ( count ++ , StringUtils . trimToEmpty ( statementSql . toString ( ) ) ) ) ; LOG . debug ( "Found statement: {}" , statementSql ) ; if ( ! isDelimiterChangeExplicit ( ) ) { delimiter = DEFAULT_STATEMENT_DELIMITER ; } statementSql . setLength ( 0 ) ; } } // Catch any statements not followed by delimiter .
if ( statementSql . length ( ) > 0 ) { statements . add ( new SqlStatement ( count ++ , StringUtils . trimToEmpty ( statementSql . toString ( ) ) ) ) ; } return statements ;


signature:
public class NotableLinkRepository { /** * region > findByNote ( programmatic ) */
@ Programmatic public NotableLink findByNote ( final Note note ) { } }

implementation: return repositoryService . firstMatch ( new QueryDefault < > ( NotableLink . class , "findByNote" , "note" , note ) ) ;


signature:
public class NotableLinkRepository { /** * region > findByNotable ( programmatic ) */
@ Programmatic public List < NotableLink > findByNotable ( final Object notable ) { } }

implementation: if ( notable == null ) { return null ; } final Bookmark bookmark = bookmarkService . bookmarkFor ( notable ) ; if ( bookmark == null ) { return null ; } final String notableStr = bookmark . toString ( ) ; return repositoryService . allMatches ( new QueryDefault < > ( NotableLink . class , "findByNotable" , "notableStr" , notableStr ) ) ;


signature:
public class NotableLinkRepository { /** * Each notable can only have one note per calendar , thus this method returns a single object rather than a list . */
@ Programmatic public NotableLink findByNotableAndCalendarName ( final Object notable , final String calendarName ) { } }

implementation: if ( notable == null ) { return null ; } if ( calendarName == null ) { return null ; } final Bookmark bookmark = bookmarkService . bookmarkFor ( notable ) ; if ( bookmark == null ) { return null ; } final String notableStr = bookmark . toString ( ) ; return repositoryService . firstMatch ( new QueryDefault < > ( NotableLink . class , "findByNotableAndCalendarName" , "notableStr" , notableStr , "calendarName" , calendarName ) ) ;


signature:
public class NotableLinkRepository { /** * region > findByNotableInDateRange ( programmatic ) */
@ Programmatic public List < NotableLink > findByNotableInDateRange ( final Object notable , final LocalDate startDate , final LocalDate endDate ) { } }

implementation: if ( notable == null ) { return null ; } final Bookmark bookmark = bookmarkService . bookmarkFor ( notable ) ; if ( bookmark == null ) { return null ; } if ( startDate == null ) { return null ; } if ( endDate == null ) { return null ; } final String notableStr = bookmark . toString ( ) ; return repositoryService . allMatches ( new QueryDefault < > ( NotableLink . class , "findByNotableInDateRange" , "notableStr" , notableStr , "startDate" , startDate , "endDate" , endDate ) ) ;


signature:
public class NotableLinkRepository { /** * region > createLink ( programmatic ) */
@ Programmatic public NotableLink createLink ( final Note note , final Object notable ) { } }

implementation: final Class < ? extends NotableLink > subtype = subtypeClassFor ( notable ) ; final NotableLink link = repositoryService . instantiate ( subtype ) ; link . setNote ( note ) ; final Bookmark bookmark = bookmarkService . bookmarkFor ( notable ) ; link . setNotable ( notable ) ; link . setNotableStr ( bookmark . toString ( ) ) ; repositoryService . persistAndFlush ( link ) ; return link ;


signature:
public class NotableLinkRepository { /** * region > updateLink */
@ Programmatic public void updateLink ( final Note note ) { } }

implementation: final NotableLink link = findByNote ( note ) ; sync ( note , link ) ;


signature:
public class NotableLinkRepository { /** * copy over details from the { @ link Note # } to the { @ link NotableLink } ( derived propoerties to support querying ) . */
void sync ( final Note note , final NotableLink link ) { } }

implementation: if ( link == null ) { return ; } link . setDate ( note . getDate ( ) ) ; link . setCalendarName ( note . getCalendarName ( ) ) ;


signature:
public class GNUishParser { /** * Parse the options for the command .
 * @ param args includes the options and arguments , command word have been stripped .
 * @ return the remaining terminal args , if any */
private String [ ] parseOpts ( String [ ] args ) { } }

implementation:
if ( args == null || args . length == 0 ) { return new String [ 0 ] ; } final List < String > remainingArgs = new ArrayList < String > ( ) ; final List < String > argsList = Arrays . asList ( args ) ; final ListIterator < String > argsIt = argsList . listIterator ( ) ; while ( argsIt . hasNext ( ) ) { String word = argsIt . next ( ) ; if ( word . startsWith ( "--" ) ) { // long option - - foo
final String option = stripLeadingHyphens ( word ) ; if ( VERBOSE_LONG_OPT . equals ( option ) ) { longOpts . put ( option , "true" ) ; } else if ( DEBUG_LONG_OPT . equals ( option ) ) { longOpts . put ( option , "true" ) ; } else if ( HELP_LONG_OPT . equals ( option ) ) { longOpts . put ( option , "true" ) ; } else { final String arg = parseOptionArg ( option , argsIt ) ; longOpts . put ( option , arg ) ; } } else if ( word . startsWith ( "-" ) ) { String options = stripLeadingHyphens ( word ) ; // single short option - f
if ( options . length ( ) == 1 ) { // only slurp argument if option is argumented
final String arg = parseOptionArg ( options , argsIt ) ; shortOpts . put ( options , arg ) ; continue ; } // multiple short options - fxy ,
// treat as non - argumented java . lang . Boolean variables , no slurp
for ( int i = 0 ; i < options . length ( ) ; i ++ ) { final String option = Character . toString ( options . charAt ( i ) ) ; shortOpts . put ( option , "true" ) ; } } else { remainingArgs . add ( word ) ; } } return remainingArgs . toArray ( new String [ 0 ] ) ;


signature:
public class IntraVMClient { /** * Transmit a message to clients and listeners . */
public void transmit ( Command c , Map h , String b ) { } }

implementation: _server . receive ( c , h , b , this ) ;


signature:
public class NoteRepository { /** * region > findByNotable ( programmatic ) */
@ Programmatic public List < Note > findByNotable ( final Object notable ) { } }

implementation: final List < NotableLink > links = linkRepository . findByNotable ( notable ) ; return Lists . newArrayList ( Iterables . transform ( links , NotableLink . Functions . note ( ) ) ) ;


signature:
public class NoteRepository { /** * region > findByNotableAndCalendarName ( programmatic ) */
@ Programmatic public Note findByNotableAndCalendarName ( final Object notable , final String calendarName ) { } }

implementation: final NotableLink link = linkRepository . findByNotableAndCalendarName ( notable , calendarName ) ; return NotableLink . Functions . note ( ) . apply ( link ) ;


signature:
public class NoteRepository { /** * region > findInDateRange ( programmatic ) */
@ Programmatic public List < Note > findInDateRange ( final LocalDate startDate , final LocalDate endDate ) { } }

implementation: return repositoryService . allMatches ( new QueryDefault < > ( Note . class , "findInDateRange" , "startDate" , startDate , "endDate" , endDate ) ) ;


signature:
public class NoteRepository { /** * region > findByNotableInDateRange ( programmatic ) */
@ Programmatic public Iterable < Note > findByNotableInDateRange ( final Object notable , final LocalDate startDate , final LocalDate endDate ) { } }

implementation: final List < NotableLink > link = linkRepository . findByNotableInDateRange ( notable , startDate , endDate ) ; return Iterables . transform ( link , NotableLink . Functions . note ( ) ) ;


signature:
public class NoteRepository { /** * region > add ( programmatic ) */
@ Programmatic public Note add ( final Object notable , final String noteText , final LocalDate date , final String calendarName ) { } }

implementation:
final Note note = repositoryService . instantiate ( Note . class ) ; note . setDate ( date ) ; note . setCalendarName ( calendarName ) ; note . setContent ( noteText ) ; repositoryService . persistAndFlush ( note ) ; final NotableLink link = notableLinkRepository . createLink ( note , notable ) ; // stored redundantly for querying . . .
link . setCalendarName ( calendarName ) ; link . setDate ( date ) ; return note ;


signature:
public class NoteRepository { /** * region > remove ( programmatic ) */
@ Programmatic public void remove ( Note note ) { } }

implementation: final NotableLink link = linkRepository . findByNote ( note ) ; repositoryService . removeAndFlush ( link ) ; repositoryService . removeAndFlush ( note ) ;


signature:
public class DuplicateCode { /** * { @ inheritDoc } */
public String getToolTip ( ) { } }

implementation:
StringBuilder message = new StringBuilder ( ) ; message . append ( "
" ) ; message . append ( Messages . DRY_Duplications_Header ( ) ) ; message . append ( "
" ) ; for ( DuplicateCode duplication : links ) { message . append ( "
" ) ; message . append ( String . format ( "%s (%s)" , getKey ( ) , duplication . getKey ( ) , duplication . getPrimaryLineNumber ( ) , duplication . getLinkName ( ) , duplication . getPrimaryLineNumber ( ) ) ) ; message . append ( "
" ) ; } message . append ( "
" ) ; message . append ( "
" ) ; return message . toString ( ) ;


signature:
public class DuplicateCode { /** * Returns the duplicate source code fragment as formatted HTML string .
 * @ return the duplicate source code fragment */
public String getFormattedSourceCode ( ) { } }

implementation: try { JavaSource source = new JavaSourceParser ( ) . parse ( new StringReader ( sourceCode ) ) ; JavaSource2HTMLConverter converter = new JavaSource2HTMLConverter ( ) ; StringWriter writer = new StringWriter ( ) ; JavaSourceConversionOptions options = JavaSourceConversionOptions . getDefault ( ) ; options . setShowLineNumbers ( false ) ; options . setAddLineAnchors ( false ) ; converter . convert ( source , options , writer ) ; return writer . toString ( ) ; } catch ( IllegalConfigurationException exception ) { return sourceCode ; } catch ( IOException exception ) { return sourceCode ; }


signature:
public class DuplicateCode { /** * Returns the link with the specified hash code .
 * @ param linkHashCode
 * the hash code of the linked annotation
 * @ return the link with the specified hash code */
public FileAnnotation getLink ( final long linkHashCode ) { } }

implementation: for ( FileAnnotation link : links ) { if ( link . getKey ( ) == linkHashCode ) { return link ; } } throw new NoSuchElementException ( "Linked annotation not found: key=" + linkHashCode ) ;


signature:
public class Client { /** * Transmit a message to the server */
public void transmit ( Command c , Map h , String b ) { } }

implementation: try { Transmitter . transmit ( c , h , b , _output ) ; } catch ( Exception e ) { receive ( Command . ERROR , null , e . getMessage ( ) ) ; }


signature:
public class JAXBContextCache { /** * If the JAXBContext is not cached , then it will create a new instance and cache it .
 * @ param contextPath
 * REQUIRED
 * @ return */
public static JAXBContext get ( final String contextPath ) { } }

implementation: Assert . hasText ( contextPath , "contextPath is required" ) ; JAXBContext ctx = jaxbContexts . get ( contextPath ) ; if ( ctx == null ) { try { ctx = JAXBContext . newInstance ( contextPath ) ; } catch ( final JAXBException e ) { throw new IllegalArgumentException ( "Failed to create JAXBContext - invalid JAXB context path: " + contextPath , e ) ; } jaxbContexts . put ( contextPath , ctx ) ; LoggerFactory . getLogger ( JAXBContextCache . class ) . info ( "cached : {}" , contextPath ) ; } return ctx ;


signature:
public class CLI { /** * java - Drouter . port = 1097 - Drouter . address = localhost - jar path / to / com . myapp . caller - 1.0.0 . jar jobId
 * @ param args jobId ( mandatory ) */
public static void main ( String [ ] args ) { } }

implementation: if ( args . length < 1 ) throw new IllegalArgumentException ( "You must specify a job id" ) ; String jobId = args [ 0 ] ; RmiProxyFactoryBean factoryBean = new RmiProxyFactoryBean ( ) ; factoryBean . setServiceInterface ( RouteAPI . class ) ; factoryBean . setServiceUrl ( String . format ( "rmi://%s:%s/router" , System . getProperty ( "router.address" , "localhost" ) , System . getProperty ( "router.port" , "1097" ) ) ) ; factoryBean . afterPropertiesSet ( ) ; RouteAPI router = ( RouteAPI ) factoryBean . getObject ( ) ; Object result = router . perform ( jobId ) ; System . out . println ( "Got router response: " + result ) ;


signature: public class CSSBoxTreeBuilder { protected BrowserCanvas renderUrl ( URL url , Dimension pageSize ) throws IOException , SAXException { } }

implementation:
DocumentSource src = new DefaultDocumentSource ( url ) ; pageUrl = src . getURL ( ) ; InputStream is = src . getInputStream ( ) ; String mime = src . getContentType ( ) ; if ( mime == null ) mime = "text/html" ; int p = mime . indexOf ( ';' ) ; if ( p != - 1 ) mime = mime . substring ( 0 , p ) . trim ( ) ; log . info ( "File type: " + mime ) ; if ( mime . equals ( "application/pdf" ) ) { PDDocument doc = loadPdf ( is ) ; BrowserCanvas canvas = new PdfBrowserCanvas ( doc , null , pageSize , src . getURL ( ) ) ; doc . close ( ) ; pageTitle = "" ; return canvas ; } else { DOMSource parser = new DefaultDOMSource ( src ) ; Document doc = parser . parse ( ) ; pageTitle = findPageTitle ( doc ) ; String encoding = parser . getCharset ( ) ; MediaSpec media = new MediaSpec ( "screen" ) ; // updateCurrentMedia ( media ) ;
DOMAnalyzer da = new DOMAnalyzer ( doc , src . getURL ( ) ) ; if ( encoding == null ) encoding = da . getCharacterEncoding ( ) ; da . setDefaultEncoding ( encoding ) ; da . setMediaSpec ( media ) ; da . attributesToStyles ( ) ; da . addStyleSheet ( null , CSSNorm . stdStyleSheet ( ) , DOMAnalyzer . Origin . AGENT ) ; da . addStyleSheet ( null , CSSNorm . userStyleSheet ( ) , DOMAnalyzer . Origin . AGENT ) ; da . addStyleSheet ( null , CSSNorm . formsStyleSheet ( ) , DOMAnalyzer . Origin . AGENT ) ; da . getStyleSheets ( ) ; BrowserCanvas contentCanvas = new BrowserCanvas ( da . getRoot ( ) , da , src . getURL ( ) ) ; contentCanvas . getConfig ( ) . setLoadImages ( false ) ; contentCanvas . getConfig ( ) . setLoadBackgroundImages ( false ) ; contentCanvas . getConfig ( ) . setLoadFonts ( false ) ; contentCanvas . getConfig ( ) . setReplaceImagesWithAlt ( replaceImagesWithAlt ) ; contentCanvas . createLayout ( pageSize ) ; src . close ( ) ; return contentCanvas ; }


signature: public class CSSBoxTreeBuilder { protected BoxNode buildTree ( ElementBox rootbox ) { } }

implementation:
// create the working list of nodes
log . trace ( "LIST" ) ; Vector < BoxNode > boxlist = new Vector < BoxNode > ( ) ; order_counter = 1 ; createBoxList ( rootbox , boxlist ) ; // create the tree
if ( useVisualBounds ) { // two - phase algorithm considering the visual bounds
log . trace ( "A1" ) ; BoxNode root = createBoxTree ( rootbox , boxlist , true , true , true ) ; // create a nesting tree based on the content bounds
System . out . println ( "ZOOM " + zoom ) ; log . trace ( "A2" ) ; Color bg = rootbox . getBgcolor ( ) ; if ( bg == null ) bg = Color . WHITE ; computeBackgrounds ( root , bg ) ; // compute the efficient background colors
log . trace ( "A2.5" ) ; root . recomputeVisualBounds ( ) ; // compute the visual bounds for the whole tree
log . trace ( "A3" ) ; root = createBoxTree ( rootbox , boxlist , true , true , preserveAux ) ; // create the nesting tree based on the visual bounds or content bounds depending on the settings
root . recomputeVisualBounds ( ) ; // compute the visual bounds for the whole tree
root . recomputeBounds ( ) ; // compute the real bounds of each node
log . trace ( "A4" ) ; // root . applyTransforms ( ) ; / / TODO test this first ; actually the transform should be applied according to the drawing tree , not this tree
return root ; } else { // simplified algorihm - use the original box nesting
BoxNode root = createBoxTree ( rootbox , boxlist , false , true , true ) ; Color bg = rootbox . getBgcolor ( ) ; if ( bg == null ) bg = Color . WHITE ; computeBackgrounds ( root , bg ) ; // compute the efficient background colors
root . recomputeVisualBounds ( ) ; // compute the visual bounds for the whole tree
root . recomputeBounds ( ) ; // compute the real bounds of each node
root . applyTransforms ( ) ; return root ; }


signature:
public class CSSBoxTreeBuilder { /** * Recursively creates a list of all the visible boxes in a box subtree . The nodes are
 * added to the end of a specified list . The previous content of the list
 * remains unchanged . The ' viewport ' box is ignored .
 * @ param root the source root box
 * @ param list the list that will be filled with the nodes */
private void createBoxList ( Box root , Vector < BoxNode > list ) { } }

implementation: if ( root . isDisplayed ( ) ) { if ( ! ( root instanceof Viewport ) && root . isVisible ( ) ) { BoxNode newnode = new BoxNode ( root , page , zoom ) ; newnode . setOrder ( order_counter ++ ) ; list . add ( newnode ) ; } if ( root instanceof ElementBox ) { ElementBox elem = ( ElementBox ) root ; for ( int i = elem . getStartChild ( ) ; i < elem . getEndChild ( ) ; i ++ ) createBoxList ( elem . getSubBox ( i ) , list ) ; } }


signature:
public class CSSBoxTreeBuilder { /** * Creates a tree of box nesting based on the content bounds of the boxes .
 * This tree is only used for determining the backgrounds .
 * @ param boxlist the list of boxes to build the tree from
 * @ param useBounds when set to { @ code true } , the full or visual bounds are used for constructing the tree
 * depending on the { @ code useVisualBounds } parameter . Otherwise , the original box hierarchy is used .
 * @ param useVisualBounds when set to { @ code true } the visual bounds are used for constructing the tree . Otherwise ,
 * the content bounds are used .
 * @ param preserveAux when set to { @ code true } , all boxes are preserved . Otherwise , only the visually
 * distinguished ones are preserved . */
private BoxNode createBoxTree ( ElementBox rootbox , Vector < BoxNode > boxlist , boolean useBounds , boolean useVisualBounds , boolean preserveAux ) { } }

implementation:
// a working copy of the box list
Vector < BoxNode > list = new Vector < BoxNode > ( boxlist ) ; // an artificial root node
BoxNode root = new BoxNode ( rootbox , page , zoom ) ; root . setOrder ( 0 ) ; // detach the nodes from any old trees
for ( BoxNode node : list ) node . removeFromTree ( ) ; // when working with visual bounds , remove the boxes that are not visually separated
if ( ! preserveAux ) { for ( Iterator < BoxNode > it = list . iterator ( ) ; it . hasNext ( ) ; ) { BoxNode node = it . next ( ) ; if ( ! node . isVisuallySeparated ( ) || ! node . isVisible ( ) ) it . remove ( ) ; } } // let each node choose it ' s children - find the roots and parents
for ( BoxNode node : list ) { if ( useBounds ) node . markNodesInside ( list , useVisualBounds ) ; else node . markChildNodes ( list ) ; } // choose the roots
for ( Iterator < BoxNode > it = list . iterator ( ) ; it . hasNext ( ) ; ) { BoxNode node = it . next ( ) ; /* if ( ! full ) / / DEBUG
 if ( node . toString ( ) . contains ( " mediawiki " ) | | node . toString ( ) . contains ( " globalWrapper " ) )
 System . out . println ( node + " = > " + node . nearestParent ) ; */
if ( node . isRootNode ( ) ) { root . appendChild ( node ) ; it . remove ( ) ; } } // recursively choose the children
for ( int i = 0 ; i < root . getChildCount ( ) ; i ++ ) ( ( BoxNode ) root . getChildAt ( i ) ) . takeChildren ( list ) ; return root ;


signature:
public class CSSBoxTreeBuilder { /** * Computes efficient background color for all the nodes in the tree */
private void computeBackgrounds ( BoxNode root , Color currentbg ) { } }

implementation: Color newbg = root . getBackgroundColor ( ) ; if ( newbg == null ) newbg = currentbg ; root . setEfficientBackground ( newbg ) ; root . setBackgroundSeparated ( ! newbg . equals ( currentbg ) ) ; for ( int i = 0 ; i < root . getChildCount ( ) ; i ++ ) computeBackgrounds ( ( BoxNode ) root . getChildAt ( i ) , newbg ) ;


signature: public class CSSBoxTreeBuilder { private List < URL > loadList ( String filename ) { } }

implementation: List < URL > ret = new ArrayList < URL > ( ) ; try { BufferedReader read = new BufferedReader ( new FileReader ( filename ) ) ; String line ; while ( ( line = read . readLine ( ) ) != null ) { line = line . trim ( ) ; if ( ! line . isEmpty ( ) && ! line . startsWith ( "#" ) ) { ret . add ( new URL ( line ) ) ; } } read . close ( ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return ret ;


signature:
public class SpringComponentPackaging { /** * < h2 > 把artifact文件copy到目标文件 , 如果另外一个相应的文件存在 , 则移动之 < / h2 >
 * @ param artifact 原始文件
 * @ param dest 目标文件
 * @ param prevent 防止的文件 */
protected void copyFile ( File artifact , File dest , File prevent ) throws IOException , MojoExecutionException { } }

implementation:
if ( dest . exists ( ) ) { if ( prevent . exists ( ) ) // noinspection ResultOfMethodCallIgnored
prevent . delete ( ) ; } else { if ( prevent . exists ( ) ) org . apache . commons . io . FileUtils . moveFile ( prevent , dest ) ; else super . copyFile ( artifact , dest ) ; }


signature:
public class SpringComponentPackaging { /** * interpolate xml , bat file content with $ { } */
private String interpolate ( String content , Map < String , Object > replaces , char mode ) { } }

implementation: Pattern pattern = mode == 'A' ? INTERPOLATE_PTN_A : INTERPOLATE_PTN_B ; Matcher m = pattern . matcher ( content ) ; StringBuffer sb = new StringBuffer ( ) ; while ( m . find ( ) ) { String variable = m . group ( 1 ) ; Object replace = replaces . get ( variable ) ; String replacement = replace == null ? "" : replace . toString ( ) ; if ( pattern . matcher ( replacement ) . find ( ) ) replacement = interpolate ( replacement , replaces , mode ) ; try { m . appendReplacement ( sb , replacement ) ; } catch ( Exception e ) { System . err . println ( e . getMessage ( ) ) ; } } m . appendTail ( sb ) ; return sb . toString ( ) . trim ( ) ;


signature:
public class SpringComponentPackaging { /** * interpolate properties file like : http . port = the . default . value */
private String interpolate ( List < String > lines , Map < String , Object > replaces , char mode ) { } }

implementation:
for ( int i = 0 ; i < lines . size ( ) ; i ++ ) { String line = lines . get ( i ) ; if ( ! line . trim ( ) . startsWith ( "#" ) && line . contains ( "=" ) ) { String [ ] array = line . split ( "=" ) ; String key = array [ 0 ] . trim ( ) ; // string like : neo4j . user = split array length = = 1
String value ; if ( array . length == 2 ) { value = array [ 1 ] ; } else if ( array . length == 1 ) { value = "" ; } else { continue ; // don ' t touch them
} value = interpolate ( value , replaces , mode ) ; if ( replaces . containsKey ( key ) ) { value = replaces . get ( key ) . toString ( ) ; } lines . set ( i , key + "=" + value ) ; } } return StringUtils . join ( lines , lineSeparator ) ;


signature:
public class ComponentURLStreamHandlerFactory { /** * Set the real file of component url
 * @ param url the component url
 * @ param realFile the real file */
public void setMappingFile ( URL url , String realFile ) { } }

implementation: if ( componentFiles == null ) initFastIndexes ( "app" , "lib" , "repository" ) ; File file = new File ( realFile ) ; componentFiles . put ( url . getFile ( ) , file ) ;


signature:
public class ComponentURLStreamHandlerFactory { /** * Get the real file of component url
 * @ param url the component url
 * @ return the real file
 * @ throws IOException */
public File getMappingFile ( URL url ) throws IOException { } }

implementation:
if ( componentFiles == null ) initFastIndexes ( "app" , "lib" , "repository" ) ; String fileName = FilenameUtils . normalize ( url . getFile ( ) , true ) ; if ( ! fileName . endsWith ( ".jar" ) ) fileName = fileName + ".jar" ; if ( fileName . startsWith ( "boot/" ) || fileName . startsWith ( "boot\\" ) ) { fileName = "net.happyonroad/" + FilenameUtils . getName ( fileName ) ; } else if ( fileName . startsWith ( "lib/" ) || fileName . startsWith ( "lib\\" ) ) { /* Only 3rd lib file will be put into jar classpath */
// 正常的组件component url里面肯定不是lib开头 ;
// 但是 spring - component - framework的Class - Path指定的那些url被normalize之后却会如此
fileName = ComponentUtils . relativePath ( fileName ) ; } File componentFile = componentFiles . get ( fileName ) ; if ( componentFile == null ) { // 当第一次建立的快速索引中没有相应文件时
// 尝试看lib下后来有没有相应的文件
componentFile = guessFile ( url , "app" , "lib" , "repository" ) ; if ( componentFile == null ) throw new IOException ( "there is no component named as " + fileName ) ; } return componentFile ;


signature:
public class AbstractUserConfig { /** * < h2 > 导入某个服务 < / h2 >
 * @ param serviceClass 服务的接口
 * @ param < T > 服务的类型
 * @ return 服务的实例
 * @ throws net . happyonroad . spring . exception . ServiceConfigurationException 找不到服务时抛出 */
protected < T > T imports ( Class < T > serviceClass ) throws ServiceConfigurationException { } }

implementation: return importer . imports ( serviceClass ) ;


signature:
public class AbstractUserConfig { /** * < h2 > 导入某个服务 < / h2 >
 * @ param serviceClass 服务的接口
 * @ param hint 服务的提示
 * @ param < T > 服务的类型
 * @ return 服务的实例
 * @ throws net . happyonroad . spring . exception . ServiceConfigurationException 找不到服务时抛出 */
protected < T > T imports ( Class < T > serviceClass , String hint ) throws ServiceConfigurationException { } }

implementation: return importer . imports ( serviceClass , hint ) ;


signature:
public class Dependency { /** * 判断某个组件是否满足特定依赖信息
 * < pre >
 * 如 , dependency1 = { groupId : dnt , artifactId : component }
 * dependency2 = { groupId : dnt , artifactId : component , version : 1.0.0}
 * 那么 : dependency1 . accept ( dependency2 ) = true
 * 反之 : dependency2 . accept ( dependency1 ) = false
 * < / pre >
 * @ param componentOrDependency 被判断的组件或者其他依赖
 * @ return 是否依赖 */
public boolean accept ( Versionize componentOrDependency ) { } }

implementation:
boolean accept = getGroupId ( ) . equals ( componentOrDependency . getGroupId ( ) ) && getArtifactId ( ) . equals ( componentOrDependency . getArtifactId ( ) ) ; if ( ! accept ) return false ; if ( getVersion ( ) != null ) { // 有version需要 , 暂时不知道是否需要支持version的表达式 , maven自身好像没有这个机制
accept = getVersion ( ) . equals ( componentOrDependency . getVersion ( ) ) ; if ( ! accept ) return false ; } if ( range != null ) { // Temp solution
if ( componentOrDependency . getVersion ( ) == null ) return true ; accept = range . containsVersion ( new ComponentVersion ( componentOrDependency . getVersion ( ) ) ) ; if ( ! accept ) return false ; } /* if ( getClassifier ( ) ! = null ) {
 accept = getClassifier ( ) . equals ( componentOrDependency . getClassifier ( ) ) ;
 if ( ! accept ) return false ; */
/* if ( getType ( ) ! = null ) {
 accept = getType ( ) . equals ( componentOrDependency . getType ( ) ) ;
 if ( ! accept ) return false ; */
return true ;


signature:
public class Dependency { /** * 为某个依赖补齐信息
 * @ param parentDefined 父组件中定义的依赖信息 */
public void merge ( Dependency parentDefined ) { } }

implementation: if ( optional == null ) { setOptional ( parentDefined . isOptional ( ) ) ; } if ( version == null ) { setVersion ( parentDefined . getVersion ( ) ) ; } if ( classifier == null ) { setClassifier ( parentDefined . getClassifier ( ) ) ; } if ( scope == null ) { setScope ( parentDefined . getScope ( ) ) ; } if ( exclusions == null ) { setExclusions ( parentDefined . getExclusions ( ) ) ; }


signature:
public class Dependency { /** * 根据组件的上下文 , 替换依赖中的信息
 * @ param component 所属的组件 */
public void interpolate ( DefaultComponent component ) { } }

implementation:
if ( groupId != null ) this . groupId = component . interpolate ( groupId ) ; if ( artifactId != null ) this . artifactId = component . interpolate ( artifactId ) ; // 暂时主要处理一些启动相关的关键属性 , 如version
if ( version != null ) this . setVersion ( component . interpolate ( version ) ) ; if ( classifier != null ) this . classifier = component . interpolate ( classifier ) ; if ( scope != null ) this . scope = component . interpolate ( scope ) ;


signature:
public class DefaultComponentLoader { /** * 注册一个扩展特性解析器
 * @ param resolver 解析器 */
public void registerResolver ( FeatureResolver resolver ) { } }

implementation: resolver . bind ( this ) ; featureResolvers . add ( resolver ) ; reverseResolvers . add ( resolver ) ; Collections . sort ( featureResolvers , new LoadOrder ( ) ) ; Collections . sort ( reverseResolvers , new UnloadOrder ( ) ) ;


signature:
public class DefaultComponentLoader { /** * 自顶向下的加载组件
 * @ param component 被加载的组件 */
@ Override public void load ( Component component ) throws Exception { } }

implementation:
if ( isLoaded ( component ) ) return ; logger . debug ( "Before loading {}" , component ) ; // 首先加载父组件
if ( component . getParent ( ) != null ) { // 上面会自动检测是否已经加载 , 防止重复加载
load ( component . getParent ( ) ) ; } // 而后加载依赖的组件
for ( Component depended : component . getDependedComponents ( ) ) { // 上面会自动检测是否已经加载 , 防止重复加载
Dependency textualDependency = new Dependency ( depended . getGroupId ( ) , depended . getArtifactId ( ) ) ; Dependency actualDependency = component . getDependency ( textualDependency ) ; if ( actualDependency . isProvided ( ) || actualDependency . isTest ( ) ) continue ; load ( depended ) ; } quickLoad ( component ) ; // 最后 , 加载自身
logger . debug ( "After  loaded  {}" , component ) ;


signature:
public class DefaultComponentLoader { /** * 剥洋葱一样的卸载组件
 * @ param component 被卸载的组件 */
@ Override public void unload ( Component component ) { } }

implementation:
if ( ! isLoaded ( component ) ) return ; logger . debug ( "Before unloading {}" , component ) ; // 先卸载自身
quickUnload ( component ) ; // 再卸载依赖
for ( Component depended : component . getDependedComponents ( ) ) { // 上面会自动检测是否已经加载 , 防止重复加载
unload ( depended ) ; } // 最后卸载其父组件
if ( component . getParent ( ) != null ) { // 上面会自动检测是否已经加载 , 防止重复加载
unload ( component . getParent ( ) ) ; } logger . debug ( "After  unloaded  {}" , component ) ;


signature:
public class DefaultComponentLoader { /** * 实际卸载一个组件 , 不考虑依赖情况
 * @ param component 被加载的组件
 * @ throws IOException 加载过程中的IO错误 */
public void quickLoad ( Component component ) throws Exception { } }

implementation: if ( component . isAggregating ( ) ) { logger . trace ( "Needn't real load aggregating component {}" , component ) ; loadedFeatures . put ( component , FeatureResolver . AggregatingFlag ) ; } else if ( component . isPlain ( ) ) { logger . trace ( "Needn't real load plain component {}" , component ) ; loadedFeatures . put ( component , FeatureResolver . PlainFlag ) ; } else { if ( isLoading ( component ) ) return ; long start = System . currentTimeMillis ( ) ; loading ( component ) ; ComponentResource resource = component . getResource ( ) ; if ( resource == null ) { throw new IOException ( "The component " + component + " without resource" ) ; } logger . info ( "Loading {}" , component ) ; List < FeatureResolver > resolvers = new ArrayList < FeatureResolver > ( featureResolvers . size ( ) ) ; for ( FeatureResolver featureResolver : featureResolvers ) { featureResolver . applyDefaults ( component ) ; if ( featureResolver . hasFeature ( component ) ) { resolvers . add ( featureResolver ) ; } } for ( FeatureResolver featureResolver : resolvers ) { featureResolver . beforeResolve ( component ) ; } for ( FeatureResolver featureResolver : resolvers ) { featureResolver . resolve ( component ) ; } for ( FeatureResolver featureResolver : resolvers ) { featureResolver . afterResolve ( component ) ; } loaded ( component ) ; logger . info ( "Loaded  {} ({})" , component , formatDurationHMS ( System . currentTimeMillis ( ) - start ) ) ; }


signature:
public class DefaultComponentLoader { /** * 实际卸载一个组件
 * @ param component 被卸载的组件 */
public void quickUnload ( Component component ) { } }

implementation: if ( component . isAggregating ( ) ) { logger . trace ( "Remove aggregating component {}" , component ) ; loadedFeatures . remove ( component ) ; } else if ( component . isPlain ( ) ) { logger . trace ( "Remove plain component {}" , component ) ; loadedFeatures . remove ( component ) ; } else { if ( isUnloading ( component ) ) return ; long start = System . currentTimeMillis ( ) ; unloading ( component ) ; logger . info ( "Unloading {}" , component ) ; for ( FeatureResolver resolver : reverseResolvers ) { if ( resolver . hasFeature ( component ) ) { resolver . release ( component ) ; } } loadedFeatures . remove ( component ) ; unloaded ( component ) ; logger . info ( "Unloaded  {} ({})" , component , formatDurationHMS ( System . currentTimeMillis ( ) - start ) ) ; }


signature:
public class ComponentVersion { /** * 解析版本字符串
 * 1.0.1-1
 * 1.0.1 - snapshot
 * @ param version 字符串 */
public final void parseVersion ( String version ) { } }

implementation:
unparsed = version ; int index = version . indexOf ( "-" ) ; String part1 ; String part2 = null ; if ( index < 0 ) { part1 = version ; } else { part1 = version . substring ( 0 , index ) ; part2 = version . substring ( index + 1 ) ; } if ( part2 != null ) { try { if ( ( part2 . length ( ) == 1 ) || ! part2 . startsWith ( "0" ) ) { buildNumber = Integer . valueOf ( part2 ) ; } else { qualifier = part2 ; } } catch ( NumberFormatException e ) { qualifier = part2 ; } } if ( ! part1 . contains ( "." ) && ! part1 . startsWith ( "0" ) ) { try { majorVersion = Integer . valueOf ( part1 ) ; } catch ( NumberFormatException e ) { // qualifier is the whole version , including " - "
qualifier = version ; buildNumber = null ; } } else { boolean fallback = false ; StringTokenizer tok = new StringTokenizer ( part1 , "." ) ; try { majorVersion = getNextIntegerToken ( tok ) ; if ( tok . hasMoreTokens ( ) ) { minorVersion = getNextIntegerToken ( tok ) ; } if ( tok . hasMoreTokens ( ) ) { incrementalVersion = getNextIntegerToken ( tok ) ; } if ( tok . hasMoreTokens ( ) ) { fallback = true ; } // string tokenzier won ' t detect these and ignores them
if ( part1 . contains ( ".." ) || part1 . startsWith ( "." ) || part1 . endsWith ( "." ) ) { fallback = true ; } } catch ( NumberFormatException e ) { fallback = true ; } if ( fallback ) { // qualifier is the whole version , including " - "
qualifier = version ; majorVersion = null ; minorVersion = null ; incrementalVersion = null ; buildNumber = null ; } }


signature: public class ComponentFolderResource { @ Override public InputStream getInputStream ( String relativePath ) throws IOException { } }

implementation: File file = new File ( folder , relativePath ) ; if ( ! file . exists ( ) ) { String msg = String . format ( "Can't find any file with relative path = `%s` in folder: `%s`" , relativePath , folder . getAbsolutePath ( ) ) ; throw new IllegalArgumentException ( msg ) ; } return new FileInputStream ( file ) ;


signature:
public class VersionRange { /** * Create a version range from a string representation
 * Some spec examples are
 * < ul >
 * < li > < code > 1.0 < / code > Version 1.0 < / li >
 * < li > < code > [ 1.0,2.0 ) < / code > Versions 1.0 ( included ) to 2.0 ( not included ) < / li >
 * < li > < code > [ 1.0,2.0 ] < / code > Versions 1.0 to 2.0 ( both included ) < / li >
 * < li > < code > [ 1.5 , ) < / code > Versions 1.5 and higher < / li >
 * < li > < code > ( , 1.0 ] , [ 1.2 , ) < / code > Versions up to 1.0 ( included ) and 1.2 or higher < / li >
 * < / ul >
 * @ param spec string representation of a version or version range
 * @ return a new { @ link VersionRange } object that represents the spec
 * @ throws net . happyonroad . component . core . exception . InvalidVersionSpecificationException */
public static VersionRange createFromVersionSpec ( String spec ) throws InvalidVersionSpecificationException { } }

implementation: if ( spec == null ) { return null ; } List < Restriction > restrictions = new ArrayList < Restriction > ( ) ; String process = spec ; ComponentVersion version = null ; ComponentVersion upperBound = null ; ComponentVersion lowerBound = null ; while ( process . startsWith ( "[" ) || process . startsWith ( "(" ) ) { int index1 = process . indexOf ( ")" ) ; int index2 = process . indexOf ( "]" ) ; int index = index2 ; if ( index2 < 0 || index1 < index2 ) { if ( index1 >= 0 ) { index = index1 ; } } if ( index < 0 ) { throw new InvalidVersionSpecificationException ( "Unbounded range: " + spec ) ; } Restriction restriction = parseRestriction ( process . substring ( 0 , index + 1 ) ) ; if ( lowerBound == null ) { lowerBound = restriction . getLowerBound ( ) ; } if ( upperBound != null ) { if ( restriction . getLowerBound ( ) == null || restriction . getLowerBound ( ) . compareTo ( upperBound ) < 0 ) { throw new InvalidVersionSpecificationException ( "Ranges overlap: " + spec ) ; } } restrictions . add ( restriction ) ; upperBound = restriction . getUpperBound ( ) ; process = process . substring ( index + 1 ) . trim ( ) ; if ( process . length ( ) > 0 && process . startsWith ( "," ) ) { process = process . substring ( 1 ) . trim ( ) ; } } if ( process . length ( ) > 0 ) { if ( restrictions . size ( ) > 0 ) { throw new InvalidVersionSpecificationException ( "Only fully-qualified sets allowed in multiple set scenario: " + spec ) ; } else { version = new ComponentVersion ( process ) ; restrictions . add ( Restriction . EVERYTHING ) ; } } return new VersionRange ( version , restrictions ) ;


signature:
public class VersionRange { /** * Creates and returns a new < code > VersionRange < / code > that is a restriction of this
 * version range and the specified version range .
 * Note : Precedence is given to the recommended version from this version range over the
 * recommended version from the specified version range .
 * @ param restriction the < code > VersionRange < / code > that will be used to restrict this version
 * range .
 * @ return the < code > VersionRange < / code > that is a restriction of this version range and the
 * specified version range .
 * The restrictions of the returned version range will be an intersection of the restrictions
 * of this version range and the specified version range if both version ranges have
 * restrictions . Otherwise , the restrictions on the returned range will be empty .
 * The recommended version of the returned version range will be the recommended version of
 * this version range , provided that ranges falls within the intersected restrictions . If
 * the restrictions are empty , this version range ' s recommended version is used if it is not
 * < code > null < / code > . If it is < code > null < / code > , the specified version range ' s recommended
 * version is used ( provided it is non - < code > null < / code > ) . If no recommended version can be
 * obtained , the returned version range ' s recommended version is set to < code > null < / code > .
 * @ throws NullPointerException if the specified < code > VersionRange < / code > is
 * < code > null < / code > . */
public VersionRange restrict ( VersionRange restriction ) throws OverConstrainedVersionException { } }

implementation:
List < Restriction > r1 = this . restrictions ; List < Restriction > r2 = restriction . restrictions ; List < Restriction > restrictions ; if ( r1 . isEmpty ( ) || r2 . isEmpty ( ) ) { restrictions = Collections . emptyList ( ) ; } else { restrictions = intersection ( r1 , r2 ) ; } ComponentVersion version = null ; if ( restrictions . size ( ) > 0 ) { boolean found = false ; for ( Iterator i = restrictions . iterator ( ) ; i . hasNext ( ) && ! found ; ) { Restriction r = ( Restriction ) i . next ( ) ; if ( recommendedVersion != null && r . containsVersion ( recommendedVersion ) ) { // if we find the original , use that
version = recommendedVersion ; found = true ; } else if ( version == null && restriction . getRecommendedVersion ( ) != null && r . containsVersion ( restriction . getRecommendedVersion ( ) ) ) { // use this if we can , but prefer the original if possible
version = restriction . getRecommendedVersion ( ) ; } } } // Either the original or the specified version ranges have no restructions
else if ( recommendedVersion != null ) { // Use the original recommended version since it exists
version = recommendedVersion ; } else if ( restriction . recommendedVersion != null ) { // Use the recommended version from the specified VersionRange since there is no
// original recommended version
version = restriction . recommendedVersion ; } else { // TODO : the component is null
throw new OverConstrainedVersionException ( "Restricting incompatible version ranges" , null ) ; } return new VersionRange ( version , restrictions ) ;


signature:
public class ComponentResource { /** * 判断本组件包是否被索引
 * @ return 存在META - INF / INDEX . DETAIL 文件即为被索引 */
public boolean isIndexed ( ) { } }

implementation:
if ( indexes == null ) { InputStream stream = null ; try { stream = getInputStream ( "META-INF/INDEX.DETAIL" ) ; List < String > lines = IOUtils . readLines ( stream ) ; // 是否应该讲indexes hash化 ?
indexes = lines . toArray ( new String [ lines . size ( ) ] ) ; // to be quick searched
Arrays . sort ( indexes ) ; } catch ( Exception e ) { indexes = new String [ 0 ] ; } finally { IOUtils . closeQuietly ( stream ) ; } } return indexes . length > 0 ;


signature:
public class ComponentResource { /** * 根据index信息 , 判断本组件包是否包含特点文件
 * @ param path 资源的路径
 * @ return 是否存在 */
public boolean contains ( String path ) { } }

implementation: if ( isIndexed ( ) ) { return Arrays . binarySearch ( indexes , path ) >= 0 ; } else { return getLocalResourceUnder ( path ) != null ; }


signature:
public class DefaultLaunchEnvironment { /** * 根据Main Resource的元信息 , 创建相应的Launcher对象
 * @ param component 主启动组件
 * @ return App Launcher对象 */
@ Override public AppLauncher createLauncher ( Component component ) throws IOException { } }

implementation:
AppLauncher launcher = new AppLauncher ( component , this ) ; // 配置 class world
this . loader = createLoader ( component ) ; this . context = ( ComponentContext ) this . loader ; return launcher ;


signature: public class DefaultLaunchEnvironment { @ Override public Component resolveComponent ( String strDependency ) throws DependencyNotMeetException , InvalidComponentNameException { } }

implementation: return repository . resolveComponent ( strDependency ) ;


signature:
public class DefaultLaunchEnvironment { /** * 自顶向下的加载组件
 * @ param component 被加载的组件 */
public void load ( Component component ) throws Exception { } }

implementation:
long start = System . currentTimeMillis ( ) ; /* Set < Component > dependedComponents = component . getAllDependedComponents ( ) ;
 ArrayList < Component > depends = new ArrayList < Component > ( dependedComponents ) ;
 repository . sortComponents ( depends ) ;
 if ( logger . isDebugEnabled ( ) ) {
 logger . debug ( " Loading components by : \ n \ t { } " ,
 org . apache . commons . lang . StringUtils . join ( depends , " \ n \ t " ) ) ;
 / / 把自己放在最后面
 depends . add ( component ) ;
 / / 已经按照依赖排序了
 for ( Component depend : depends ) {
 loader . quickLoad ( depend ) ; */
loader . load ( component ) ; registerWorldAndComponents ( component ) ; banner ( "Container starts took {}" , formatDurationHMS ( System . currentTimeMillis ( ) - start ) ) ; publishContainerStartedEvent ( ) ;


signature:
public class DefaultComponentRepository { /** * 启动时预加载 lib目录 , lib / poms 下所有的组件信息 */
public void start ( ) { } }

implementation:
logger . info ( banner ( "Scanning jars" ) ) ; // 先寻找 boot / * . jar , 将其预加载为component
File bootFolder = new File ( home , "boot" ) ; try { scanJars ( bootFolder ) ; } catch ( Exception e ) { logger . error ( "Failed to scan {} dir: {}" , bootFolder , e . getMessage ( ) ) ; } File appFolder = new File ( home , "app" ) ; try { scanJars ( appFolder ) ; } catch ( Exception e ) { logger . error ( "Failed to scan {} dir for jars: {}" , appFolder , e . getMessage ( ) ) ; } // 再寻找 lib / * . jar , 将其预加载为component
File libFolder = new File ( home , "lib" ) ; try { scanJars ( libFolder ) ; } catch ( Exception e ) { logger . error ( "Failed to scan {} dir for jars: {}" , libFolder , e . getMessage ( ) ) ; } File poms = libFolder ; try { // 而后再遍历lib / poms下面的pom . xml , 把packaging = pom 的父pom预加载进来
scanPoms ( poms ) ; } catch ( Exception e ) { logger . error ( "Failed to scan {} dir for poms: {}" , poms , e . getMessage ( ) ) ; } File pomsJar = new File ( libFolder , "poms.jar" ) ; if ( pomsJar . exists ( ) ) try { // 而后再遍历lib / poms下面的pom . xml , 把packaging = pom 的父pom预加载进来
scanPomsJar ( pomsJar ) ; } catch ( Exception e ) { logger . error ( "Failed to scan {} poms.jar in {}" , poms , e . getMessage ( ) ) ; } // 最后还要扫描扩展仓库目录 repository / * . jar
File repositoryFolder = new File ( home , "repository" ) ; try { scanJars ( repositoryFolder ) ; } catch ( Exception e ) { logger . error ( "Failed to scan {} dir for jars: {}" , repositoryFolder , e . getMessage ( ) ) ; } poms = repositoryFolder ; try { // 而后再遍历repository / poms下面的pom . xml , 把不存在对应jar的 group pom预加载进来
scanPoms ( poms ) ; } catch ( Exception e ) { logger . error ( "Failed to scan {} dir for poms: {}" , poms , e . getMessage ( ) ) ; } pomsJar = new File ( repositoryFolder , "poms.jar" ) ; if ( pomsJar . exists ( ) ) try { // 而后再遍历lib / poms下面的pom . xml , 把packaging = pom 的父pom预加载进来
scanPomsJar ( pomsJar ) ; } catch ( Exception e ) { logger . error ( "Failed to scan poms.jar in {}: {}" , poms , e . getMessage ( ) ) ; } logger . info ( banner ( "Scanned  jars" ) ) ;


signature: public class DefaultComponentRepository { @ Override public Component resolveComponent ( Dependency dependency ) throws InvalidComponentNameException , DependencyNotMeetException { } }

implementation:
List < Component > meets = resolveComponents ( dependency ) ; if ( meets . isEmpty ( ) ) { Set < Dependency > dependencies = new HashSet < Dependency > ( cache . keySet ( ) ) ; for ( Dependency dep : dependencies ) { if ( dependency . accept ( dep ) ) { Resource resource = cache . get ( dep ) ; meets . add ( resolver . resolveComponent ( dependency , resource ) ) ; // cache . remove ( dep ) ;
} } } if ( meets . isEmpty ( ) ) { logger . trace ( "Can't find {} in current repository" , dependency ) ; throw new DependencyNotMeetException ( dependency ) ; } return meets . get ( 0 ) ;


signature:
public class DefaultComponentRepository { /** * 从当前已经解析的组件中找到符合依赖的组件列表 , 这不会触发实际解析动作
 * @ param dependency 依赖信息
 * @ return 组件列表 */
@ Override public List < Component > resolveComponents ( Dependency dependency ) { } }

implementation:
logger . trace ( "Finding   {}" , dependency ) ; List < Component > meets = new ArrayList < Component > ( ) ; for ( Component component : components ) { if ( dependency . accept ( component ) ) { meets . add ( component ) ; } } if ( meets . isEmpty ( ) ) { logger . trace ( "Missing   {}" , dependency ) ; } else { logger . trace ( "Found     {} {} components" , dependency , meets . size ( ) ) ; } // 对所有满足的依赖进行排序
Collections . sort ( meets ) ; // 排序的原则是越高版本越好
Collections . reverse ( meets ) ; return meets ;


signature:
public class DefaultComponentRepository { /** * 基于依赖关系进行排序 , 最多被依赖的组件排在最前面 , 没有被依赖的排在最后面
 * < pre >
 * 这个排序算法不能基于java的quick sort , 默认快速排序 , 排到前面的 , 不会再和后面的继续比较
 * 基本的算法原理是 :
 * 先为components集合构建一个相互之间的依赖关系 , map结构
 * < / pre >
 * @ param components 被排序的组件 */
@ Override public void sortComponents ( List < Component > components ) { } }

implementation:
// 将组件集合之间的依赖关系以map的形式展现出来
Map < Component , Set < Component > > dependencies = dependsMap ( components ) ; // 清空待排序的components , 用于做结果的容器
components . clear ( ) ; // 基于依赖关系进行处理
arrange ( components , dependencies ) ;


signature: public class DefaultComponentRepository { @ Override public void addComponent ( Component component ) { } }

implementation: logger . debug ( "Register  {} into repository" , component ) ; components . add ( component ) ;


signature:
public class BoxTransform { /** * Concatenates another transformation to this transformation .
 * @ param src
 * @ return A new concatenated transformation . */
public BoxTransform concatenate ( BoxTransform src ) { } }

implementation: if ( src . isEmpty ( ) ) return this ; else if ( this . isEmpty ( ) ) return src ; else { BoxTransform ret = new BoxTransform ( this ) ; ret . transform = new AffineTransform ( transform ) ; ret . transform . concatenate ( src . transform ) ; return ret ; }


signature:
public class BoxTransform { /** * Transforms a rectangle to other rectangle using the given transformation .
 * @ param rect the source rectangle
 * @ return the bounding box of the transformed rectangle . */
public Rectangular transformRect ( Rectangular rect ) { } }

implementation: if ( transform != null ) { Rectangle src = new Rectangle ( rect . getX1 ( ) , rect . getY1 ( ) , rect . getWidth ( ) , rect . getHeight ( ) ) ; Shape dest = transform . createTransformedShape ( src ) ; Rectangle destr ; if ( dest instanceof Rectangle ) destr = ( Rectangle ) dest ; else destr = dest . getBounds ( ) ; return new Rectangular ( destr ) ; } else return rect ;


signature: public class BoxTransform { protected AffineTransform createTransform ( ElementBox elem ) { } }

implementation:
if ( elem . isBlock ( ) || elem . isReplaced ( ) ) { CSSDecoder dec = new CSSDecoder ( elem . getVisualContext ( ) ) ; Rectangle bounds = elem . getAbsoluteBorderBounds ( ) ; // decode the origin
int ox , oy ; CSSProperty . TransformOrigin origin = elem . getStyle ( ) . getProperty ( "transform-origin" ) ; if ( origin == CSSProperty . TransformOrigin . list_values ) { TermList values = elem . getStyle ( ) . getValue ( TermList . class , "transform-origin" ) ; ox = dec . getLength ( ( TermLengthOrPercent ) values . get ( 0 ) , false , bounds . width / 2 , 0 , bounds . width ) ; oy = dec . getLength ( ( TermLengthOrPercent ) values . get ( 1 ) , false , bounds . height / 2 , 0 , bounds . height ) ; } else { ox = bounds . width / 2 ; oy = bounds . height / 2 ; } ox += bounds . x ; oy += bounds . y ; // compute the transformation matrix
AffineTransform ret = null ; CSSProperty . Transform trans = elem . getStyle ( ) . getProperty ( "transform" ) ; if ( trans == CSSProperty . Transform . list_values ) { ret = new AffineTransform ( ) ; ret . translate ( ox , oy ) ; TermList values = elem . getStyle ( ) . getValue ( TermList . class , "transform" ) ; for ( Term < ? > term : values ) { if ( term instanceof TermFunction ) { final TermFunction func = ( TermFunction ) term ; final String fname = func . getFunctionName ( ) . toLowerCase ( ) ; if ( fname . equals ( "rotate" ) ) { if ( func . size ( ) == 1 && func . get ( 0 ) instanceof TermAngle ) { double theta = dec . getAngle ( ( TermAngle ) func . get ( 0 ) ) ; ret . rotate ( theta ) ; } } else if ( fname . equals ( "translate" ) ) { if ( func . size ( ) == 1 && func . get ( 0 ) instanceof TermLengthOrPercent ) { int tx = dec . getLength ( ( TermLengthOrPercent ) func . get ( 0 ) , false , 0 , 0 , bounds . width ) ; ret . translate ( tx , 0.0 ) ; } else if ( func . size ( ) == 2 && func . get ( 0 ) instanceof TermLengthOrPercent && func . get ( 1 ) instanceof TermLengthOrPercent ) { int tx = dec . getLength ( ( TermLengthOrPercent ) func . get ( 0 ) , false , 0 , 0 , bounds . width ) ; int ty = dec . getLength ( ( TermLengthOrPercent ) func . get ( 1 ) , false , 0 , 0 , bounds . height ) ; ret . translate ( tx , ty ) ; } } else if ( fname . equals ( "translatex" ) ) { if ( func . size ( ) == 1 && func . get ( 0 ) instanceof TermLengthOrPercent ) { int tx = dec . getLength ( ( TermLengthOrPercent ) func . get ( 0 ) , false , 0 , 0 , bounds . width ) ; ret . translate ( tx , 0.0 ) ; } } else if ( fname . equals ( "translatey" ) ) { if ( func . size ( ) == 1 && func . get ( 0 ) instanceof TermLengthOrPercent ) { int ty = dec . getLength ( ( TermLengthOrPercent ) func . get ( 0 ) , false , 0 , 0 , bounds . height ) ; ret . translate ( 0.0 , ty ) ; } } else if ( fname . equals ( "scale" ) ) { if ( func . size ( ) == 1 && isNumber ( func . get ( 0 ) ) ) { float sx = getNumber ( func . get ( 0 ) ) ; ret . scale ( sx , sx ) ; } else if ( func . size ( ) == 2 && isNumber ( func . get ( 0 ) ) && isNumber ( func . get ( 1 ) ) ) { float sx = getNumber ( func . get ( 0 ) ) ; float sy = getNumber ( func . get ( 1 ) ) ; ret . scale ( sx , sy ) ; } } else if ( fname . equals ( "scalex" ) ) { if ( func . size ( ) == 1 && isNumber ( func . get ( 0 ) ) ) { float sx = getNumber ( func . get ( 0 ) ) ; ret . scale ( sx , 1.0 ) ; } } else if ( fname . equals ( "scaley" ) ) { if ( func . size ( ) == 1 && isNumber ( func . get ( 0 ) ) ) { float sy = getNumber ( func . get ( 0 ) ) ; ret . scale ( 1.0 , sy ) ; } } else if ( fname . equals ( "skew" ) ) { if ( func . size ( ) == 1 && func . get ( 0 ) instanceof TermAngle ) { double ax = dec . getAngle ( ( TermAngle ) func . get ( 0 ) ) ; ret . shear ( Math . tan ( ax ) , 0.0 ) ; } else if ( func . size ( ) == 2 && func . get ( 0 ) instanceof TermAngle && func . get ( 1 ) instanceof TermAngle ) { double ax = dec . getAngle ( ( TermAngle ) func . get ( 0 ) ) ; double ay = dec . getAngle ( ( TermAngle ) func . get ( 1 ) ) ; ret . shear ( Math . tan ( ax ) , Math . tan ( ay ) ) ; } } else if ( fname . equals ( "skewx" ) ) { if ( func . size ( ) == 1 && func . get ( 0 ) instanceof TermAngle ) { double ax = dec . getAngle ( ( TermAngle ) func . get ( 0 ) ) ; ret . shear ( Math . tan ( ax ) , 0.0 ) ; } } else if ( fname . equals ( "skewy" ) ) { if ( func . size ( ) == 1 && func . get ( 0 ) instanceof TermAngle ) { double ay = dec . getAngle ( ( TermAngle ) func . get ( 0 ) ) ; ret . shear ( 0.0 , Math . tan ( ay ) ) ; } } else if ( fname . equals ( "matrix" ) ) { if ( func . size ( ) == 6 ) { double [ ] vals = new double [ 6 ] ; boolean typesOk = true ; for ( int i = 0 ; i < 6 ; i ++ ) { if ( isNumber ( func . get ( i ) ) ) vals [ i ] = getNumber ( func . get ( i ) ) ; else typesOk = false ; } if ( typesOk ) { ret . concatenate ( new AffineTransform ( vals ) ) ; } } } } } ret . translate ( - ox , - oy ) ; } return ret ; } else return null ;


signature: public class ComponentJarResource { public InputStream getInputStream ( String innerPath ) throws IOException { } }

implementation:
JarEntry entry = file . getJarEntry ( innerPath ) ; if ( entry == null ) throw new IllegalArgumentException ( "Can't find " + innerPath + " from " + file . getName ( ) ) ; // class loader可能还没有正确配置好 , 此时直接从file里面获取
try { return super . getResource ( innerPath ) . getInputStream ( ) ; } catch ( IOException e ) { return file . getInputStream ( entry ) ; }


signature:
public class ApplicationFeatureResolver { /** * XML方式解析独立的应用程序包
 * @ param component 组件对象
 * @ return 加载出来的应用程序上下文 */
protected AbstractApplicationContext resolveByXml ( Component component , ApplicationContext parent ) { } }

implementation: XmlComponentApplicationContext context = new XmlComponentApplicationContext ( component , parent ) ; try { Resource resource = component . getResourceLoader ( ) . getResource ( APP_XML ) ; context . load ( resource ) ; } catch ( Exception e ) { throw new ApplicationConfigurationException ( "Can't load context from application stream" , e ) ; } return context ;


signature:
public class ApplicationFeatureResolver { /** * Annotation方式解析独立的应用程序包
 * @ param component 组件对象
 * @ return 加载出来的应用程序上下文 */
protected AbstractApplicationContext resolveByConfig ( Component component , ApplicationContext parent ) { } }

implementation: String appConfig = component . getManifestAttribute ( APP_CONFIG ) ; Class appConfigClass ; try { appConfigClass = Class . forName ( appConfig , true , component . getClassLoader ( ) ) ; } catch ( ClassNotFoundException e ) { throw new ApplicationConfigurationException ( "The app config class: " + appConfig + " can't be loaded by the component:" + component , e ) ; } AnnotationComponentApplicationContext context = new AnnotationComponentApplicationContext ( component , parent ) ; context . register ( appConfigClass ) ; return context ;


signature:
public class BoxNode { /** * Returns the minimal bounds of the box for enclosing all the contained boxes .
 * @ return the minimal visual bounds */
private Rectangular getMinimalVisualBounds ( ) { } }

implementation:
final Box box = getBox ( ) ; if ( box instanceof TextBox ) return new RectangularZ ( box . getAbsoluteBounds ( ) . intersection ( box . getClipBlock ( ) . getClippedContentBounds ( ) ) , zoom ) ; else if ( box != null && box . isReplaced ( ) ) return new RectangularZ ( box . getMinimalAbsoluteBounds ( ) . intersection ( box . getClipBlock ( ) . getClippedContentBounds ( ) ) , zoom ) ; else { Rectangular ret = null ; for ( int i = 0 ; i < getChildCount ( ) ; i ++ ) { BoxNode subnode = ( BoxNode ) getChildAt ( i ) ; Box sub = subnode . getBox ( ) ; Rectangular sb = subnode . getVisualBounds ( ) ; if ( sub . isDisplayed ( ) && subnode . isVisible ( ) && sb . getWidth ( ) > 0 && sb . getHeight ( ) > 0 ) { if ( ret == null ) ret = new Rectangular ( sb ) ; else ret . expandToEnclose ( sb ) ; } } // if nothing has been found return an empty rectangle at the top left corner
if ( ret == null ) { Rectangle b = box . getAbsoluteBounds ( ) . intersection ( box . getClipBlock ( ) . getClippedContentBounds ( ) ) ; return new RectangularZ ( b . x , b . y , zoom ) ; } else return ret ; }


signature:
public class BoxNode { /** * Re - computes the visual bounds of the whole subtree . */
public void recomputeVisualBounds ( ) { } }

implementation: for ( int i = 0 ; i < getChildCount ( ) ; i ++ ) ( ( BoxNode ) getChildAt ( i ) ) . recomputeVisualBounds ( ) ; visual = computeVisualBounds ( ) ;


signature:
public class BoxNode { /** * Recomputes the total bounds of the whole subtree . The bounds of each box will
 * correspond to its visual bounds . If the child boxes exceed the parent box ,
 * the parent box bounds will be expanded accordingly . */
public void recomputeBounds ( ) { } }

implementation: bounds = new Rectangular ( visual ) ; for ( int i = 0 ; i < getChildCount ( ) ; i ++ ) { BoxNode child = ( BoxNode ) getChildAt ( i ) ; child . recomputeBounds ( ) ; expandToEnclose ( child ) ; }


signature:
public class BoxNode { /** * Computes node the content bounds . They correspond to the background bounds
 * however , when a border is present , it is included in the contents . Moreover ,
 * the box is clipped by its clipping box . */
private Rectangular computeContentBounds ( ) { } }

implementation:
Box box = getBox ( ) ; Rectangular ret = null ; if ( box instanceof Viewport ) { ret = new RectangularZ ( ( ( Viewport ) box ) . getClippedBounds ( ) , zoom ) ; } else if ( box instanceof ElementBox ) { ElementBox elem = ( ElementBox ) box ; // at least one border - take the border bounds
// TODO : when only one border is present , we shouldn ' t take the whole border box ?
if ( elem . getBorder ( ) . top > 0 || elem . getBorder ( ) . left > 0 || elem . getBorder ( ) . bottom > 0 || elem . getBorder ( ) . right > 0 ) { ret = new RectangularZ ( elem . getAbsoluteBorderBounds ( ) , zoom ) ; } // no border
else { ret = new RectangularZ ( elem . getAbsoluteBackgroundBounds ( ) , zoom ) ; } } else // not an element - return the whole box
ret = new RectangularZ ( box . getAbsoluteBounds ( ) , zoom ) ; // clip with the clipping bounds
if ( box . getClipBlock ( ) != null ) { Rectangular clip = new RectangularZ ( box . getClipBlock ( ) . getClippedContentBounds ( ) , zoom ) ; ret = ret . intersection ( clip ) ; } return ret ;


signature:
public class BoxNode { /** * Obtains the top border of the box
 * @ return the width of the border or 0 when there is no border */
@ Override public int getTopBorder ( ) { } }

implementation: Box box = getBox ( ) ; if ( box instanceof ElementBox ) return ( ( ElementBox ) box ) . getBorder ( ) . top ; else return 0 ;


signature:
public class BoxNode { /** * Obtains the bottom border of the box
 * @ return the width of the border or 0 when there is no border */
@ Override public int getBottomBorder ( ) { } }

implementation: Box box = getBox ( ) ; if ( box instanceof ElementBox ) return ( ( ElementBox ) box ) . getBorder ( ) . bottom ; else return 0 ;


signature:
public class BoxNode { /** * Obtains the left border of the box
 * @ return the width of the border or 0 when there is no border */
@ Override public int getLeftBorder ( ) { } }

implementation: Box box = getBox ( ) ; if ( box instanceof ElementBox ) return ( ( ElementBox ) box ) . getBorder ( ) . left ; else return 0 ;


signature:
public class BoxNode { /** * Obtains the right border of the box
 * @ return the width of the border or 0 when there is no border */
@ Override public int getRightBorder ( ) { } }

implementation: Box box = getBox ( ) ; if ( box instanceof ElementBox ) return ( ( ElementBox ) box ) . getBorder ( ) . right ; else return 0 ;


signature:
public class BoxNode { /** * Get the effective text color . If the text color is set , it is returned .
 * When the color is not set , the parent boxes are considered .
 * @ return the background color string */
public String getEfficientColor ( ) { } }

implementation: Box box = getBox ( ) ; do { if ( box instanceof ElementBox ) { String color = ( ( ElementBox ) box ) . getStylePropertyValue ( "color" ) ; if ( ! color . equals ( "" ) ) return color ; } box = box . getParent ( ) ; } while ( box != null ) ; return "" ;


signature:
public class BoxNode { /** * Checks if the box text is visible ( it does not contain spaces only ) . This is not equivalent to isWhitespace ( ) because
 * non - beraking spaces are not whitespace characters but they are not visible .
 * @ return < true > if the box text consists of space characters only */
public boolean containsVisibleTextString ( ) { } }

implementation: String s = getText ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char ch = s . charAt ( i ) ; if ( ! Character . isSpaceChar ( ch ) ) return true ; } return false ;