idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
600
protected void processClass ( ClassDoc doc ) { defaultProcess ( doc , true ) ; for ( MemberDoc member : doc . fields ( ) ) { processMember ( member ) ; } for ( MemberDoc member : doc . constructors ( ) ) { processMember ( member ) ; } for ( MemberDoc member : doc . methods ( ) ) { processMember ( member ) ; } if ( doc instanceof AnnotationTypeDoc ) { for ( MemberDoc member : ( ( AnnotationTypeDoc ) doc ) . elements ( ) ) { processMember ( member ) ; } } }
Process the class documentation .
601
protected void processPackage ( PackageDoc doc ) { try { Field foundDoc = doc . getClass ( ) . getDeclaredField ( "foundDoc" ) ; foundDoc . setAccessible ( true ) ; foundDoc . set ( doc , false ) ; } catch ( Exception e ) { printWarning ( doc . position ( ) , "Cannot suppress warning about multiple package sources: " + e + "\n" + "Please report this at https://github.com/Abnaxos/markdown-doclet/issues with the exact JavaDoc version you're using" ) ; } defaultProcess ( doc , true ) ; }
Process the package documentation .
602
protected void defaultProcess ( Doc doc , boolean fixLeadingSpaces ) { try { StringBuilder buf = new StringBuilder ( ) ; buf . append ( getOptions ( ) . toHtml ( doc . commentText ( ) , fixLeadingSpaces ) ) ; buf . append ( '\n' ) ; for ( Tag tag : doc . tags ( ) ) { processTag ( tag , buf ) ; buf . append ( '\n' ) ; } doc . setRawCommentText ( buf . toString ( ) ) ; } catch ( final ParserRuntimeException e ) { if ( doc instanceof RootDoc ) { printError ( new SourcePosition ( ) { public File file ( ) { return options . getOverviewFile ( ) ; } public int line ( ) { return 0 ; } public int column ( ) { return 0 ; } } , e . getMessage ( ) ) ; } else { printError ( doc . position ( ) , e . getMessage ( ) ) ; } } }
Default processing of any documentation node .
603
@ SuppressWarnings ( "unchecked" ) protected void processTag ( Tag tag , StringBuilder target ) { TagRenderer < Tag > renderer = ( TagRenderer < Tag > ) tagRenderers . get ( tag . kind ( ) ) ; if ( renderer == null ) { renderer = TagRenderer . VERBATIM ; } renderer . render ( tag , target , this ) ; }
Process a tag .
604
public static void main ( String [ ] args ) throws Exception { args = Arrays . copyOf ( args , args . length + 2 ) ; args [ args . length - 2 ] = "-doclet" ; args [ args . length - 1 ] = MarkdownDoclet . class . getName ( ) ; Main . main ( args ) ; }
Just a main method for debugging .
605
public String [ ] [ ] load ( String [ ] [ ] options , DocErrorReporter errorReporter ) { LinkedList < String [ ] > optionsList = new LinkedList < > ( Arrays . asList ( options ) ) ; Iterator < String [ ] > optionsIter = optionsList . iterator ( ) ; while ( optionsIter . hasNext ( ) ) { String [ ] opt = optionsIter . next ( ) ; if ( ! handleOption ( optionsIter , opt , errorReporter ) ) { return null ; } } if ( pegdownExtensions == null ) { setPegdownExtensions ( DEFAULT_PEGDOWN_EXTENSIONS ) ; } return optionsList . toArray ( new String [ optionsList . size ( ) ] [ ] ) ; }
Loads the options from the command line .
606
public JavadocQuirks getJavadocVersion ( ) { if ( javadocVersion == null ) { String javaVersion = System . getProperty ( "java.version" ) ; if ( javaVersion != null && javaVersion . compareTo ( "1.8" ) >= 0 ) { return JavadocQuirks . V8 ; } else { return JavadocQuirks . V7 ; } } return javadocVersion ; }
Gets the Javadoc version .
607
public void visit ( VerbatimNode node ) { if ( options . isHighlightEnabled ( ) && ! options . isAutoHighlightEnabled ( ) && node . getType ( ) . isEmpty ( ) ) { VerbatimNode noHighlightNode = new VerbatimNode ( node . getText ( ) , "no-highlight" ) ; noHighlightNode . setStartIndex ( node . getStartIndex ( ) ) ; noHighlightNode . setEndIndex ( node . getEndIndex ( ) ) ; super . visit ( noHighlightNode ) ; } else { super . visit ( node ) ; } }
Overrides the default implementation to set the language to no - highlight no language is specified . If highlighting is disabled or auto - highlighting is enabled this method just calls the default implementation .
608
private static String createTagletPattern ( String tagNames ) { final StringBuilder regex = new StringBuilder ( ) ; final int size = STR_TAGS_REGEX_LIST . size ( ) ; for ( int regexIdx = 0 ; regexIdx < size ; regexIdx ++ ) { final String tagRegex = STR_TAGS_REGEX_LIST . get ( regexIdx ) ; final String argsRex = STR_ARGS_REGEX_LIST . get ( regexIdx ) ; if ( regexIdx > 0 ) { regex . append ( '|' ) ; } regex . append ( tagRegex ) . append ( tagNames ) . append ( STR_TAG_ARG_REGEX_SEPARATOR ) . append ( argsRex ) ; } return regex . toString ( ) ; }
Creates the taglet pattern from tagNames .
609
public static ServiceContext createServiceContext ( ServletRequest request ) { if ( ! ( request instanceof HttpServletRequest ) ) { throw new IllegalArgumentException ( "Expected HttpServletRequest" ) ; } return createServiceContext ( ( HttpServletRequest ) request ) ; }
Convenience method it requires that the request is a HttpServletRequest .
610
public static String convertToString ( Collection < ? extends Object > parameters ) { if ( parameters == null || parameters . isEmpty ( ) ) return "" ; StringBuilder result = new StringBuilder ( ) ; for ( Object param : parameters ) { if ( param instanceof String ) param = "'" + param + "'" ; if ( result . length ( ) != 0 ) result . append ( "," ) ; result . append ( param ) ; } log . debug ( "restriction list converted to {}" , result ) ; return result . toString ( ) ; }
Converts a collection with IN parameters to a plain string representation
611
public static List < Field > listFields ( Class < ? > clazz ) { assert clazz != null ; Class < ? > entityClass = clazz ; List < Field > list = new ArrayList < Field > ( ) ; while ( ! Object . class . equals ( entityClass ) && entityClass != null ) { list . addAll ( Arrays . asList ( entityClass . getDeclaredFields ( ) ) ) ; entityClass = entityClass . getSuperclass ( ) ; } return list ; }
lists all fields of a given class
612
public static Field findField ( Class < ? > clazz , String name ) { Class < ? > entityClass = clazz ; while ( ! Object . class . equals ( entityClass ) && entityClass != null ) { Field [ ] fields = entityClass . getDeclaredFields ( ) ; for ( Field field : fields ) { if ( name . equals ( field . getName ( ) ) ) { return field ; } } entityClass = entityClass . getSuperclass ( ) ; } return null ; }
tries to find a field by a field name
613
public static Method findProperty ( Class < ? > clazz , String name ) { assert clazz != null ; assert name != null ; Class < ? > entityClass = clazz ; while ( entityClass != null ) { Method [ ] methods = ( entityClass . isInterface ( ) ? entityClass . getMethods ( ) : entityClass . getDeclaredMethods ( ) ) ; for ( Method method : methods ) { if ( method . getName ( ) . equals ( "get" + StringUtils . capitalize ( name ) ) || method . getName ( ) . equals ( "is" + StringUtils . capitalize ( name ) ) ) { return method ; } } entityClass = entityClass . getSuperclass ( ) ; } return null ; }
tries to find a property method by name
614
public static Object getValue ( Object instance , String name ) { assert instance != null ; assert name != null ; try { Class < ? > clazz = instance . getClass ( ) ; Object value = null ; Method property = findProperty ( clazz , name ) ; if ( property != null ) { value = property . invoke ( instance ) ; } else { Field field = findField ( clazz , name ) ; if ( field != null ) { value = field . get ( instance ) ; } } log . debug ( "Value for field/property '{}' is: '{}'" , name , value ) ; return value ; } catch ( Exception e ) { log . error ( "Could not get a value for field/property '" + name + "'" , e ) ; return null ; } }
tries to get the value from a field or a getter property for a given object instance
615
public static NamedQuery findNamedQuery ( Class < ? > type , String name ) { NamedQuery annotatedNamedQuery = ( NamedQuery ) type . getAnnotation ( NamedQuery . class ) ; if ( annotatedNamedQuery != null ) { return annotatedNamedQuery ; } NamedQueries annotatedNamedQueries = ( NamedQueries ) type . getAnnotation ( NamedQueries . class ) ; if ( annotatedNamedQueries != null ) { NamedQuery [ ] namedQueries = annotatedNamedQueries . value ( ) ; if ( namedQueries != null ) { for ( NamedQuery namedQuery : namedQueries ) { if ( namedQuery . name ( ) . equalsIgnoreCase ( name ) ) { return namedQuery ; } } } } log . debug ( "No NamedQuery with name '{}' exists for type '{}'" , name , type ) ; return null ; }
get a named query from an entity
616
public static String createResultCountQuery ( String query ) { String resultCountQueryString = null ; int select = query . toLowerCase ( ) . indexOf ( "select" ) ; int from = query . toLowerCase ( ) . indexOf ( "from" ) ; if ( select == - 1 || from == - 1 ) { return null ; } resultCountQueryString = "select count(" + query . substring ( select + 6 , from ) . trim ( ) + ") " + query . substring ( from ) ; if ( resultCountQueryString . toLowerCase ( ) . contains ( "order by" ) ) { resultCountQueryString = resultCountQueryString . substring ( 0 , resultCountQueryString . toLowerCase ( ) . indexOf ( "order by" ) ) ; } log . debug ( "Created query for counting results '{}'" , resultCountQueryString ) ; return resultCountQueryString ; }
Build a query based on the original query to count results
617
public static String toSeparatedString ( List < ? > values , String separator ) { return toSeparatedString ( values , separator , null ) ; }
build a single String from a List of objects with a given separator
618
public static String toSeparatedString ( List < ? > values , String separator , String prefix ) { StringBuilder result = new StringBuilder ( ) ; for ( Object each : values ) { if ( each == null ) { continue ; } if ( result . length ( ) > 0 ) { result . append ( separator ) ; } if ( prefix != null ) { result . append ( String . valueOf ( each ) ) ; } else { result . append ( prefix + String . valueOf ( each ) ) ; } } return result . toString ( ) ; }
build a single String from a List of objects with a given separator and prefix
619
private boolean isJoda ( Class < ? > clazz ) { for ( Constructor < ? > each : clazz . getConstructors ( ) ) { Class < ? > [ ] parameterTypes = each . getParameterTypes ( ) ; if ( parameterTypes . length > 0 ) { if ( parameterTypes [ 0 ] . getName ( ) . startsWith ( "org.joda.time." ) ) { return true ; } } } return false ; }
Check if joda date time library is used without introducing runtime dependency .
620
public void afterThrowing ( Method m , Object [ ] args , Object target , ConcurrencyFailureException e ) throws OptimisticLockingException { handleOptimisticLockingException ( target , e ) ; }
Spring exception for Optimistic Locking .
621
public static boolean checkAggregateReferences ( Application app ) { Map < DomainObject , Set < DomainObject > > aggregateGroups = getAggregateGroups ( app ) ; for ( Set < DomainObject > group1 : aggregateGroups . values ( ) ) { for ( Set < DomainObject > group2 : aggregateGroups . values ( ) ) { if ( group1 == group2 ) { continue ; } Set < DomainObject > intersection = new HashSet < DomainObject > ( group1 ) ; intersection . retainAll ( group2 ) ; if ( ! intersection . isEmpty ( ) ) { LOG . warn ( "checkAggregateReferences failed with intersection: " + intersection ) ; return false ; } } } return true ; }
According to DDD the aggregate root is the only member of the aggregate that objects outside the aggregate boundary may hold references to .
622
public void setAsText ( String text ) throws IllegalArgumentException { if ( this . allowEmpty && ! StringUtils . hasText ( text ) ) { setValue ( null ) ; } else { setValue ( new LocalDate ( this . formatter . parseDateTime ( text ) ) ) ; } }
Parse the value from the given text using the specified format .
623
public String getAsText ( ) { LocalDate value = ( LocalDate ) getValue ( ) ; return ( value != null ? value . toString ( this . formatter ) : "" ) ; }
Format the LocalDate as String using the specified format .
624
public String getAsText ( ) { Enum < ? > value = ( Enum < ? > ) getValue ( ) ; if ( value == null ) { return "" ; } String text = getMessagesAccessor ( ) . getMessage ( messagesKeyPrefix + value . name ( ) , ( String ) null ) ; if ( text == null ) { return value . toString ( ) ; } else { return text ; } }
Format the Enum as translated String
625
public void setAsText ( String text ) throws IllegalArgumentException { if ( text == null || text . equals ( "" ) ) { setValue ( null ) ; return ; } Enum < ? > value = Enum . valueOf ( enumClass , text ) ; setValue ( value ) ; }
Parse the value from the given text is not supported by this editor
626
public synchronized Iterator < String > getPropertyKeys ( ) { if ( properties == null ) { properties = new HashMap < String , Serializable > ( ) ; } return properties . keySet ( ) . iterator ( ) ; }
Gets all property keys for attributes of the ServiceContext object
627
public static RouteSpecification forCargo ( Cargo cargo , DateTime arrivalDeadline ) { Validate . notNull ( cargo ) ; Validate . notNull ( arrivalDeadline ) ; return new RouteSpecification ( arrivalDeadline , cargo . getOrigin ( ) , cargo . getDestination ( ) ) ; }
Factory for creatig a route specification for a cargo from cargo origin to cargo destination . Use for initial routing .
628
public static SystemException unwrapSystemException ( Throwable throwable ) { if ( throwable == null ) { return null ; } else if ( throwable instanceof SystemException ) { return ( SystemException ) throwable ; } else if ( throwable . getCause ( ) != null ) { return unwrapSystemException ( throwable . getCause ( ) ) ; } else { return null ; } }
Looks for SystemException in the cause chain .
629
public List < T > getDomainObjectsAsList ( Set < ? extends KEY > keys ) { List < T > all = new ArrayList < T > ( ) ; Iterator < ? extends KEY > iter = keys . iterator ( ) ; List < KEY > chunkKeys = new ArrayList < KEY > ( ) ; for ( int i = 1 ; iter . hasNext ( ) ; i ++ ) { KEY element = iter . next ( ) ; chunkKeys . add ( element ) ; if ( ( i % CHUNK_SIZE ) == 0 ) { all . addAll ( getChunk ( chunkKeys ) ) ; chunkKeys = new ArrayList < KEY > ( ) ; } } if ( ! chunkKeys . isEmpty ( ) ) { all . addAll ( getChunk ( chunkKeys ) ) ; } return all ; }
Fetch existing domain objects based on natural keys
630
protected boolean executeGenerator ( ) throws MojoExecutionException { List < Object > classpathEntries = new ArrayList < Object > ( ) ; classpathEntries . addAll ( project . getResources ( ) ) ; classpathEntries . add ( project . getBuild ( ) . getOutputDirectory ( ) ) ; extendPluginClasspath ( classpathEntries ) ; Properties generatorProperties = new Properties ( ) ; if ( properties != null ) { for ( String key : properties . keySet ( ) ) { generatorProperties . setProperty ( key , properties . get ( key ) ) ; } } generatorProperties . setProperty ( OUTPUT_SLOT_PATH_PREFIX + "TO_SRC" , outletSrcOnceDir . toString ( ) ) ; generatorProperties . setProperty ( OUTPUT_SLOT_PATH_PREFIX + "TO_RESOURCES" , outletResOnceDir . toString ( ) ) ; generatorProperties . setProperty ( OUTPUT_SLOT_PATH_PREFIX + "TO_GEN_SRC" , outletSrcDir . toString ( ) ) ; generatorProperties . setProperty ( OUTPUT_SLOT_PATH_PREFIX + "TO_GEN_RESOURCES" , outletResDir . toString ( ) ) ; generatorProperties . setProperty ( OUTPUT_SLOT_PATH_PREFIX + "TO_WEBROOT" , outletWebrootDir . toString ( ) ) ; generatorProperties . setProperty ( OUTPUT_SLOT_PATH_PREFIX + "TO_SRC_TEST" , outletSrcTestOnceDir . toString ( ) ) ; generatorProperties . setProperty ( OUTPUT_SLOT_PATH_PREFIX + "TO_RESOURCES_TEST" , outletResTestOnceDir . toString ( ) ) ; generatorProperties . setProperty ( OUTPUT_SLOT_PATH_PREFIX + "TO_GEN_SRC_TEST" , outletSrcTestDir . toString ( ) ) ; generatorProperties . setProperty ( OUTPUT_SLOT_PATH_PREFIX + "TO_GEN_RESOURCES_TEST" , outletResTestDir . toString ( ) ) ; generatorProperties . setProperty ( OUTPUT_SLOT_PATH_PREFIX + "TO_DOC" , outletDocDir . toString ( ) ) ; List < File > generatedFiles = doRunGenerator ( generatorProperties ) ; if ( generatedFiles != null ) { if ( isVerbose ( ) ) { for ( File generatedFile : generatedFiles ) { getLog ( ) . info ( "Generated: " + getProjectRelativePath ( generatedFile ) ) ; } } updateStatusFile ( generatedFiles ) ; if ( generatedFiles . size ( ) > 0 ) { refreshEclipseWorkspace ( ) ; } getLog ( ) . info ( "Generated " + generatedFiles . size ( ) + " files" ) ; return true ; } else { getLog ( ) . error ( "Executing generator workflow failed" ) ; } return false ; }
Executes the commandline running the Eclipse MWE2 launcher and returns the commandlines exit value .
631
public static < T > List < Option < T > > createOptions ( Collection < T > domainObjects ) { List < Option < T > > options = new ArrayList < Option < T > > ( ) ; for ( T value : domainObjects ) { String id = String . valueOf ( getId ( value ) ) ; options . add ( new Option < T > ( id , value ) ) ; } return options ; }
Factory method to create a list of Options from a list of DomainObjects . It is expected that the DomainObjects has
632
public static void dispatch ( Object target , Event event , String methodName ) { try { MethodUtils . invokeMethod ( target , methodName , event ) ; } catch ( InvocationTargetException e ) { if ( e . getTargetException ( ) instanceof RuntimeException ) { throw ( RuntimeException ) e . getTargetException ( ) ; } else { throw new UnsupportedOperationException ( e . getTargetException ( ) ) ; } } catch ( RuntimeException e ) { throw e ; } catch ( Exception e ) { throw new UnsupportedOperationException ( e ) ; } }
Runtime dispatch to method with correct event parameter type
633
@ SuppressWarnings ( "unchecked" ) public DataMapper < Object , DBObject > getDataMapper ( Class < ? > domainObjectClass ) { if ( additionalDataMappers != null ) { for ( DataMapper < Object , DBObject > each : additionalDataMappers ) { if ( each . canMapToData ( domainObjectClass ) ) { return each ; } } } if ( dataMapper . canMapToData ( domainObjectClass ) ) { return ( DataMapper < Object , DBObject > ) dataMapper ; } return null ; }
Matching DataMapper if any otherwise null
634
public String getAsText ( ) { Object value = getValue ( ) ; if ( value == null ) { return "" ; } String propertyName = null ; try { StringBuffer label = new StringBuffer ( ) ; for ( int i = 0 ; i < properties . length ; i ++ ) { propertyName = properties [ i ] ; Class < ? > propertyType = PropertyUtils . getPropertyType ( value , propertyName ) ; Object propertyValue = PropertyUtils . getNestedProperty ( value , propertyName ) ; PropertyEditor editor = registry . findCustomEditor ( propertyType , registryPropertyNamePrefix + propertyName ) ; if ( editor == null ) { label . append ( propertyValue ) ; } else { editor . setValue ( propertyValue ) ; label . append ( editor . getAsText ( ) ) ; editor . setValue ( null ) ; } if ( i < ( properties . length - 1 ) ) { label . append ( separator ) ; } } return label . toString ( ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Couldn't access " + propertyName + " of " + value . getClass ( ) . getName ( ) + " : " + e . getMessage ( ) , e ) ; } }
Format the Object as String of concatenated properties .
635
private void cleanDirectory ( File dir ) { if ( isVerbose ( ) || getLog ( ) . isDebugEnabled ( ) ) { getLog ( ) . info ( "Deleting previously generated files in directory: " + dir . getPath ( ) ) ; } if ( dir . exists ( ) ) { try { FileUtils . cleanDirectory ( dir ) ; } catch ( IOException e ) { getLog ( ) . warn ( "Cleaning directory failed: " + e . getMessage ( ) ) ; } } }
Deletes all files within the given directory .
636
protected String getProjectRelativePath ( File file ) { String path = file . getAbsolutePath ( ) ; String prefix = project . getBasedir ( ) . getAbsolutePath ( ) ; if ( path . startsWith ( prefix ) ) { path = path . substring ( prefix . length ( ) + 1 ) ; } if ( File . separatorChar != '/' ) { path = path . replace ( File . separatorChar , '/' ) ; } return path ; }
Returns the path of given file relative to the enclosing Maven project .
637
private String calculateChecksum ( File file ) throws IOException { InputStream is = new FileInputStream ( file ) ; return DigestUtils . md5Hex ( is ) ; }
Returns a hex representation of the MD5 checksum from given file .
638
private void initDerivedDefaults ( @ Named ( "Mutable Defaults" ) MutableConfigurationProvider defaultConfiguration ) { if ( hasProperty ( "test.dbunit.dataSetFile" ) ) { defaultConfiguration . setBoolean ( "generate.test.dbunitTestData" , false ) ; } if ( getProperty ( "deployment.applicationServer" ) . equalsIgnoreCase ( "tomcat" ) || getProperty ( "deployment.applicationServer" ) . equalsIgnoreCase ( "jetty" ) ) { defaultConfiguration . setString ( "deployment.type" , "war" ) ; } if ( getProperty ( "deployment.applicationServer" ) . equalsIgnoreCase ( "appengine" ) ) { initDerivedDefaultsForAppengine ( defaultConfiguration ) ; } if ( ! hasProjectNature ( "business-tier" ) ) { initDerivedDefaultsForNonBusinessTier ( defaultConfiguration ) ; } if ( hasProjectNature ( "business-tier" ) && hasProjectNature ( "pure-ejb3" ) ) { initDerivedDefaultsForPureEjb3 ( defaultConfiguration ) ; } initDerivedDefaultsSystemAttributes ( defaultConfiguration ) ; if ( getBooleanProperty ( "generate.singleLevelFetchEager" ) ) { defaultConfiguration . setString ( "default.fetchStrategy" , "lazy" ) ; } if ( getProperty ( "deployment.type" ) . equals ( "ear" ) ) { defaultConfiguration . setString ( "deployment.applicationServer" , "JBoss" ) ; } if ( getProperty ( "deployment.applicationServer" ) . toLowerCase ( ) . equals ( "jboss" ) ) { defaultConfiguration . setString ( "cache.provider" , "Infinispan" ) ; defaultConfiguration . setBoolean ( "generate.datasource" , true ) ; } if ( getProperty ( "datetime.library" ) . equals ( "joda" ) ) { initDerivedDefaultsForJoda ( defaultConfiguration ) ; } if ( ! getProperty ( "nosql.provider" ) . equals ( "none" ) ) { initDerivedDefaultsForNosql ( defaultConfiguration ) ; } else if ( ! getProperty ( "jpa.provider" ) . equals ( "none" ) ) { initDerivedDefaultsForJpa ( defaultConfiguration ) ; } else { initDerivedDefaultsWithoutPersistence ( defaultConfiguration ) ; } initDerivedDefaultsForRest ( defaultConfiguration ) ; if ( getBooleanProperty ( "generate.quick" ) ) { initQuick ( defaultConfiguration ) ; } LOG . debug ( "Initialized properties: {}" , getAllPConfigurationKeyValues ( configuration ) ) ; }
Prepare the default values with values inherited from the configuration .
639
Properties getProperties ( String prefix , boolean removePrefix ) { Properties result = new Properties ( ) ; for ( String key : getPropertyNames ( ) ) { if ( key . startsWith ( prefix ) ) { result . put ( ( removePrefix ) ? key . substring ( prefix . length ( ) ) : key , getProperty ( key ) ) ; } } return result ; }
Gets all properties with a key starting with prefix .
640
public String mapValidationAnnotation ( String annotation , String defaultAnnotation ) { String key = "validation.annotation." + toFirstUpper ( annotation ) ; if ( hasProperty ( key ) ) { return getProperty ( key ) ; } else { return defaultAnnotation ; } }
Gets a single validation annotation from properties .
641
private List < String > getAllPConfigurationKeyValues ( ConfigurationProvider configuration ) { List < String > keyValues = new ArrayList < String > ( ) ; for ( String key : configuration . keys ( ) ) { keyValues . add ( key + "=\"" + configuration . getString ( key ) + "\"" ) ; } Collections . sort ( keyValues ) ; return keyValues ; }
Returns a sorted list of all key - value pairs defined in given configuration instance .
642
public static SQLException unwrapSQLException ( Throwable throwable ) { if ( throwable == null ) { return null ; } else if ( throwable instanceof SQLException ) { return ( SQLException ) throwable ; } else if ( throwable . getCause ( ) != null ) { return unwrapSQLException ( throwable . getCause ( ) ) ; } else { return null ; } }
Looks for SQLException in the cause chain .
643
private void changeAuditInformation ( Auditable auditableEntity ) { Timestamp lastUpdated = new Timestamp ( System . currentTimeMillis ( ) ) ; auditableEntity . setLastUpdated ( lastUpdated ) ; String lastUpdatedBy = ServiceContextStore . getCurrentUser ( ) ; auditableEntity . setLastUpdatedBy ( lastUpdatedBy ) ; if ( auditableEntity . getCreatedDate ( ) == null ) auditableEntity . setCreatedDate ( lastUpdated ) ; if ( auditableEntity . getCreatedBy ( ) == null ) auditableEntity . setCreatedBy ( lastUpdatedBy ) ; }
set audit informations doesn t modify createdDate and createdBy once set . Only works with DomainObjects that implement the Auditable interface . In other cases a IllegalArgumentException is thrown .
644
public boolean isExpected ( final HandlingEvent event ) { if ( getLegs ( ) . isEmpty ( ) ) { return true ; } if ( event . getType ( ) == Type . RECEIVE ) { final Leg leg = getLegs ( ) . get ( 0 ) ; return ( leg . getFrom ( ) . equals ( event . getLocation ( ) ) ) ; } if ( event . getType ( ) == Type . LOAD ) { for ( Leg leg : getLegs ( ) ) { if ( leg . getFrom ( ) . equals ( event . getLocation ( ) ) && leg . getCarrierMovement ( ) . equals ( event . getCarrierMovement ( ) ) ) return true ; } return false ; } if ( event . getType ( ) == Type . UNLOAD ) { for ( Leg leg : getLegs ( ) ) { if ( leg . getTo ( ) . equals ( event . getLocation ( ) ) && leg . getCarrierMovement ( ) . equals ( event . getCarrierMovement ( ) ) ) return true ; } return false ; } if ( event . getType ( ) == Type . CLAIM ) { final Leg leg = getLegs ( ) . get ( getLegs ( ) . size ( ) - 1 ) ; return ( leg . getTo ( ) . equals ( event . getLocation ( ) ) ) ; } return true ; }
Test if the given handling event is expected when executing this itinerary .
645
public void attachItinerary ( final Itinerary itinerary ) { Validate . notNull ( itinerary ) ; itinerary ( ) . setCargo ( null ) ; setItinerary ( itinerary ) ; itinerary ( ) . setCargo ( this ) ; }
Attach a new itinerary to this cargo .
646
private < T > T nullSafe ( T actual , T safe ) { return actual == null ? safe : actual ; }
Utility for Null Object Pattern - should be moved out of this class
647
private void changeAuditInformation ( JodaAuditable auditableEntity ) { DateTime lastUpdated = new DateTime ( ) ; auditableEntity . setLastUpdated ( lastUpdated ) ; String lastUpdatedBy = ServiceContextStore . getCurrentUser ( ) ; auditableEntity . setLastUpdatedBy ( lastUpdatedBy ) ; if ( auditableEntity . getCreatedDate ( ) == null ) auditableEntity . setCreatedDate ( lastUpdated ) ; if ( auditableEntity . getCreatedBy ( ) == null ) auditableEntity . setCreatedBy ( lastUpdatedBy ) ; }
set audit informations doesn t modify createdDate and createdBy once set . Only works with DomainObjects that implement the JodaAuditable interface . In other cases a IllegalArgumentException is thrown .
648
protected final void processLine ( String line , int level ) { boolean isError = doProcessLine ( line , level ) ; if ( isErrorStream || isError ) { errorCount ++ ; } lineCount ++ ; }
Depending on stream type the given line is logged and the correspondig counter is increased .
649
public void afterThrowing ( Method m , Object [ ] args , Object target , ConstraintViolationException e ) { Logger log = LoggerFactory . getLogger ( target . getClass ( ) ) ; StringBuilder logText = new StringBuilder ( excMessage ( e ) ) ; if ( e . getConstraintViolations ( ) != null && e . getConstraintViolations ( ) . size ( ) > 0 ) { for ( ConstraintViolation < ? > each : e . getConstraintViolations ( ) ) { logText . append ( " : " ) . append ( each . getPropertyPath ( ) ) . append ( " " ) ; logText . append ( "'" ) . append ( each . getMessage ( ) ) . append ( "'" ) ; logText . append ( " " ) ; logText . append ( each . getPropertyPath ( ) ) . append ( "=" ) ; logText . append ( each . getInvalidValue ( ) ) ; } logText . append ( " rootBean=" ) . append ( e . getConstraintViolations ( ) . iterator ( ) . next ( ) . getRootBean ( ) ) ; } if ( isJmsContext ( ) ) { LogMessage message = new LogMessage ( mapLogCode ( mapLogCode ( ValidationException . ERROR_CODE ) ) , logText . toString ( ) ) ; log . error ( "{}" , message ) ; } else { LogMessage message = new LogMessage ( mapLogCode ( ValidationException . ERROR_CODE ) , logText . toString ( ) ) ; log . debug ( "{}" , message ) ; } ValidationException newException = new ValidationException ( excMessage ( e ) ) ; newException . setLogged ( true ) ; newException . setConstraintViolations ( e . getConstraintViolations ( ) ) ; throw newException ; }
Handles validation exception
650
public String getCollectionInterfaceType ( Reference ref ) { String collectionType = getRefCollectionType ( ref ) ; return getCollectionInterfaceType ( collectionType ) ; }
Java interface for the collection type .
651
public String getCollectionImplType ( Reference ref ) { String collectionType = getRefCollectionType ( ref ) ; return getCollectionImplType ( collectionType ) ; }
Java implementation class for the collection type .
652
public String getRefCollectionType ( Reference ref ) { String type = ref . getCollectionType ( ) ; return ( type == null ? "set" : type . toLowerCase ( ) ) ; }
Collection type can be set list bag or map . It corresponds to the Hibernate collection types .
653
public String getGetAccessor ( TypedElement e , String prefix ) { String capName = toFirstUpper ( e . getName ( ) ) ; if ( prefix != null ) { capName = toFirstUpper ( prefix ) + capName ; } String result = isBooleanPrimitiveType ( e ) ? "is" + capName : "get" + ( "Class" . equals ( capName ) ? "Class_" : capName ) ; return result ; }
Get - accessor method name of a property according to JavaBeans naming conventions .
654
public String toFirstUpper ( String name ) { if ( name . length ( ) == 0 ) { return name ; } else { return name . substring ( 0 , 1 ) . toUpperCase ( ) + name . substring ( 1 ) ; } }
First character to upper case .
655
public String toFirstLower ( String name ) { if ( name . length ( ) == 0 ) { return name ; } else { return name . substring ( 0 , 1 ) . toLowerCase ( ) + name . substring ( 1 ) ; } }
First character to lower case .
656
public String substringBefore ( String string , String pattern ) { if ( string == null || pattern == null ) { return string ; } int pos = string . indexOf ( pattern ) ; if ( pos != - 1 ) { return string . substring ( 0 , pos ) ; } return null ; }
Gets the substring before a given pattern
657
public void addDefaultValues ( Service service ) { for ( ServiceOperation op : ( List < ServiceOperation > ) service . getOperations ( ) ) { addDefaultValues ( op ) ; } }
Fill in parameters and return values for operations that delegate to Repository .
658
private void addDefaultValues ( ServiceOperation operation ) { if ( operation . getDelegate ( ) != null ) { copyFromDelegate ( operation , operation . getDelegate ( ) , true ) ; } else if ( operation . getServiceDelegate ( ) != null ) { addDefaultValues ( operation . getServiceDelegate ( ) ) ; copyFromDelegate ( operation , operation . getServiceDelegate ( ) , true ) ; } }
Copy values from delegate RepositoryOperation to this ServiceOperation
659
private void addDefaultValues ( ResourceOperation operation ) { if ( operation . getDelegate ( ) != null ) { copyFromDelegate ( operation , operation . getDelegate ( ) , false ) ; } }
Copy values from delegate ServiceOperation to this ResourceOperation
660
private String handleValidationAnnotations ( String validate ) { if ( validate == null ) return "" ; if ( validate . length ( ) > 15 ) { @ SuppressWarnings ( "unused" ) boolean baa = true ; } validate = validate . replaceAll ( "&&" , " " ) ; validate = validate . replaceAll ( "'" , "\"" ) ; for ( Map . Entry < String , String > entry : propBase . validationAnnotationDefinitions ( ) . entrySet ( ) ) { String firstChar = entry . getKey ( ) . substring ( 0 , 1 ) ; String keyPattern = "[" + firstChar . toUpperCase ( ) + firstChar . toLowerCase ( ) + "]" + entry . getKey ( ) . substring ( 1 ) ; validate = validate . replaceAll ( "@" + keyPattern , "@" + entry . getValue ( ) ) ; } return validate . trim ( ) ; }
Parses the given validation string and tries to map annotations from properties .
661
public boolean isRefInverse ( Reference ref ) { if ( ref . isInverse ( ) ) { return true ; } if ( ! ref . isInverse ( ) && ( ref . getOpposite ( ) != null ) && ref . getOpposite ( ) . isInverse ( ) ) { return false ; } if ( ref . getOpposite ( ) == null ) { return false ; } String name1 = ref . getTo ( ) . getName ( ) ; String name2 = ref . getFrom ( ) . getName ( ) ; return ( name1 . compareTo ( name2 ) < 0 ) ; }
Inverse attribute for many - to - many associations .
662
private List < Reference > getAllManyReferences ( DomainObject domainObject ) { List < Reference > allReferences = domainObject . getReferences ( ) ; List < Reference > allManyReferences = new ArrayList < Reference > ( ) ; for ( Reference ref : allReferences ) { if ( ref . isMany ( ) ) { allManyReferences . add ( ref ) ; } } return allManyReferences ; }
List of references with multiplicity > 1
663
private List < Reference > getAllOneReferences ( DomainObject domainObject ) { List < Reference > allReferences = domainObject . getReferences ( ) ; List < Reference > allOneReferences = new ArrayList < Reference > ( ) ; for ( Reference ref : allReferences ) { if ( ! ref . isMany ( ) ) { allOneReferences . add ( ref ) ; } } return allOneReferences ; }
List of references with multiplicity = 1
664
public String getAsText ( ) { DateTime value = ( DateTime ) getValue ( ) ; return ( value != null ? value . toString ( this . formatter ) : "" ) ; }
Format the DateTime as String using the specified format .
665
public String getGenericType ( RepositoryOperation op ) { GenericAccessObjectStrategy strategy = genericAccessObjectStrategies . get ( op . getName ( ) ) ; if ( strategy == null ) { return "" ; } else { return strategy . getGenericType ( op ) ; } }
Get the generic type declaration for generic access objects .
666
protected boolean acceptToString ( Field field ) { return acceptedToStringTypes . contains ( field . getType ( ) ) || acceptedToStringTypes . contains ( field . getType ( ) . getName ( ) ) ; }
Subclasses may override this method to include or exclude some properties in toString . By default only simple types will be included in toString . Relations to other domain objects can not be included since we don t know if they are fetched and we don t wont toString to fetch them .
667
private static final UByte [ ] mkValues ( ) { UByte [ ] ret = new UByte [ 256 ] ; for ( int i = Byte . MIN_VALUE ; i <= Byte . MAX_VALUE ; i ++ ) ret [ i & MAX_VALUE ] = new UByte ( ( byte ) i ) ; return ret ; }
Generate a cached value for each byte value .
668
private static final UInteger [ ] mkValues ( ) { int precacheSize = getPrecacheSize ( ) ; UInteger [ ] ret ; if ( precacheSize <= 0 ) return null ; ret = new UInteger [ precacheSize ] ; for ( int i = 0 ; i < precacheSize ; i ++ ) ret [ i ] = new UInteger ( i ) ; return ret ; }
Generate a cached value for initial unsigned integer values .
669
private static UInteger getCached ( long value ) { if ( VALUES != null && value < VALUES . length ) return VALUES [ ( int ) value ] ; return null ; }
Retrieve a cached value .
670
private static UInteger valueOfUnchecked ( long value ) { UInteger cached ; if ( ( cached = getCached ( value ) ) != null ) return cached ; return new UInteger ( value , true ) ; }
Get the value of a long without checking the value .
671
private static final int getPrecacheSize ( ) { String prop = null ; long propParsed ; try { prop = System . getProperty ( PRECACHE_PROPERTY ) ; } catch ( SecurityException e ) { return DEFAULT_PRECACHE_SIZE ; } if ( prop == null ) return DEFAULT_PRECACHE_SIZE ; if ( prop . length ( ) <= 0 ) return DEFAULT_PRECACHE_SIZE ; try { propParsed = Long . parseLong ( prop ) ; } catch ( NumberFormatException e ) { return DEFAULT_PRECACHE_SIZE ; } if ( propParsed < 0 ) return 0 ; if ( propParsed > Integer . MAX_VALUE ) return Integer . MAX_VALUE ; return ( int ) propParsed ; }
Figure out the size of the precache .
672
private Object readResolve ( ) throws ObjectStreamException { UInteger cached ; rangeCheck ( value ) ; if ( ( cached = getCached ( value ) ) != null ) return cached ; return this ; }
Replace version read through deserialization with cached version .
673
public ColorReference brighten ( final Float brightness ) { ColorReference copy = copy ( ) ; if ( copy . brightness == null ) { copy . brightness = brightness ; } else { copy . brightness += brightness ; } return copy ; }
Brightens this color by the amount given . Returns a copy of this color object not this object itself .
674
public PointSeries addNumberPoint ( final Number y ) { Point point = new Point ( y ) ; addPoint ( point ) ; return this ; }
Adds a point with only a number .
675
public PointSeries addNumbers ( final List < Number > values ) { for ( Number number : values ) { addNumberPoint ( number ) ; } return this ; }
Adds a list of point with only numbers .
676
private void addCodeContainer ( Chart chart ) { Label codeContainer = new Label ( "code" , new StringFromResourceModel ( chart . getOptions ( ) . getClass ( ) , chart . getOptions ( ) . getClass ( ) . getSimpleName ( ) + ".java" ) ) ; codeContainer . setOutputMarkupId ( true ) ; add ( codeContainer ) ; }
Adds a code container corresponding to the current chart
677
public void setTheme ( final Theme theme ) { if ( this . themeReference != null || this . themeUrl != null ) { throw new IllegalStateException ( "A theme can only be defined once. Calling different setTheme methods is not allowed!" ) ; } this . theme = theme ; }
Sets the theme for this chart by specifying a theme class .
678
protected StringValue getVariableValue ( String parameterName ) { RequestCycle cycle = RequestCycle . get ( ) ; WebRequest webRequest = ( WebRequest ) cycle . getRequest ( ) ; StringValue value = webRequest . getRequestParameters ( ) . getParameterValue ( parameterName ) ; return value ; }
Reads the value of the given javascript variable from the AJAX request .
679
public CssStyle setProperty ( final String key , final String value ) { if ( this . properties == null ) { this . properties = new HashMap < String , String > ( ) ; } this . properties . put ( sanitizeCssPropertyName ( key ) , value ) ; return this ; }
Sets a CSS property .
680
private String sanitizeCssPropertyName ( final String propertyName ) { if ( ! propertyName . contains ( "-" ) ) { return propertyName ; } else { String sanitized = propertyName ; int index = sanitized . indexOf ( '-' ) ; while ( index != - 1 ) { String charToBeReplaced = sanitized . substring ( index + 1 , index + 2 ) ; String replacement = charToBeReplaced . toUpperCase ( ) ; sanitized = sanitized . replaceAll ( "-" + charToBeReplaced , replacement ) ; index = sanitized . indexOf ( '-' ) ; } return sanitized ; } }
Replaces hyphen notation with camel case notation .
681
private int getSelectedTab ( ) { String theme = "default" ; List < PageParameters . NamedPair > pairs = getPageParameters ( ) . getAllNamed ( ) ; theme = pairs . get ( 0 ) . getValue ( ) ; if ( "grid" . equals ( theme ) ) { return 1 ; } else if ( "skies" . equals ( theme ) ) { return 2 ; } else if ( "gray" . equals ( theme ) ) { return 3 ; } else if ( "darkblue" . equals ( theme ) ) { return 4 ; } else if ( "darkgreen" . equals ( theme ) ) { return 5 ; } else { return 0 ; } }
Used in the renderHead method to highlight the currently selected theme tab
682
private List < BrowserUsageData > getBrowserData ( ) { List < BrowserUsageData > browserData = new ArrayList < BrowserUsageData > ( ) ; browserData . add ( getMSIEUsageData ( ) ) ; browserData . add ( getFirefoxUsageData ( ) ) ; browserData . add ( getChromeUsageData ( ) ) ; browserData . add ( getSafariUsageData ( ) ) ; browserData . add ( getOperaUsageData ( ) ) ; return browserData ; }
Creates the data displayed in the donut chart .
683
private BrowserUsageData getChromeUsageData ( ) { BrowserUsageData data = new BrowserUsageData ( ) ; data . setBrowserName ( "Chrome" ) ; data . setMarketShare ( 11.94f ) ; ColorReference chromeColor = new HighchartsColor ( 2 ) ; data . setColor ( chromeColor ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Chrome 5.0" , 0.12f , chromeColor . brighten ( 0.01f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Chrome 6.0" , 0.19f , chromeColor . brighten ( 0.02f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Chrome 7.0" , 0.12f , chromeColor . brighten ( 0.03f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Chrome 8.0" , 0.36f , chromeColor . brighten ( 0.04f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Chrome 9.0" , 0.32f , chromeColor . brighten ( 0.05f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Chrome 10.0" , 9.91f , chromeColor . brighten ( 0.06f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Chrome 11.0" , 0.50f , chromeColor . brighten ( 0.07f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Chrome 12.0" , 0.22f , chromeColor . brighten ( 0.08f ) ) ) ; return data ; }
Creates the Chrome data .
684
private BrowserUsageData getFirefoxUsageData ( ) { BrowserUsageData data = new BrowserUsageData ( ) ; data . setBrowserName ( "Firefox" ) ; data . setMarketShare ( 21.63f ) ; ColorReference ffColor = new HighchartsColor ( 1 ) ; data . setColor ( ffColor ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Firefox 2.0" , 0.20f , ffColor . brighten ( 0.1f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Firefox 3.0" , 0.83f , ffColor . brighten ( 0.2f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Firefox 3.5" , 1.58f , ffColor . brighten ( 0.3f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Firefox 3.6" , 13.12f , ffColor . brighten ( 0.4f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Firefox 4.0" , 5.43f , ffColor . brighten ( 0.5f ) ) ) ; return data ; }
Creates the Firefox data .
685
private BrowserUsageData getMSIEUsageData ( ) { BrowserUsageData data = new BrowserUsageData ( ) ; data . setBrowserName ( "MSIE" ) ; data . setMarketShare ( 55.11f ) ; ColorReference ieColor = new HighchartsColor ( 0 ) ; data . setColor ( ieColor ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "MSIE 6.0" , 10.85f , ieColor . brighten ( 0.1f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "MSIE 7.0" , 7.35f , ieColor . brighten ( 0.2f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "MSIE 8.0" , 33.06f , ieColor . brighten ( 0.3f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "MSIE 9.0" , 2.81f , ieColor . brighten ( 0.4f ) ) ) ; return data ; }
Creates the Internet Explorer data .
686
private BrowserUsageData getOperaUsageData ( ) { BrowserUsageData data = new BrowserUsageData ( ) ; data . setBrowserName ( "Opera" ) ; data . setMarketShare ( 2.14f ) ; ColorReference operaColor = new HighchartsColor ( 4 ) ; data . setColor ( operaColor ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Opera 9.x" , 0.12f , operaColor . brighten ( 0.1f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Opera 10.x" , 0.37f , operaColor . brighten ( 0.2f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Opera 11.x" , 1.65f , operaColor . brighten ( 0.3f ) ) ) ; return data ; }
Creates the Opera data .
687
private BrowserUsageData getSafariUsageData ( ) { BrowserUsageData data = new BrowserUsageData ( ) ; data . setBrowserName ( "Safari" ) ; data . setMarketShare ( 7.15f ) ; ColorReference safariColor = new HighchartsColor ( 3 ) ; data . setColor ( safariColor ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Safari 5.0" , 4.55f , safariColor . brighten ( 0.1f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Safari 4.0" , 1.42f , safariColor . brighten ( 0.2f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Safari Win 5.0" , 0.23f , safariColor . brighten ( 0.3f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Safari 4.1" , 0.21f , safariColor . brighten ( 0.4f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Safari / Maxthon" , 0.20f , safariColor . brighten ( 0.5f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Safari 3.1" , 0.19f , safariColor . brighten ( 0.6f ) ) ) ; data . getVersionUsageData ( ) . add ( new VersionUsageData ( "Safari 4.1" , 0.14f , safariColor . brighten ( 0.7f ) ) ) ; return data ; }
Creates the Safari data .
688
public void renderHead ( final IHeaderResponse response ) { int selectedTab = this . getSelectedTab ( ) ; response . render ( OnDomReadyHeaderItem . forScript ( "$('#themes li:eq(" + selectedTab + ") a').tab('show');" ) ) ; }
Highlights the currently selected theme tab
689
public < T > void addSerializer ( final Class < T > clazz , final JsonSerializer < T > serializer ) { this . jacksonModule . addSerializer ( clazz , serializer ) ; }
This method gives the opportunity to add a custom serializer to serializer one of the highchart option classes . It may be neccessary to serialize certain option classes differently for different web frameworks .
690
public Series < D > addPoint ( final D point ) { if ( this . data == null ) { this . data = new ArrayList < D > ( ) ; } this . data . add ( point ) ; return this ; }
Adds a point to this series .
691
public void setRenderTo ( final Options options , final String renderTo ) { if ( options . getChartOptions ( ) == null ) { options . setChartOptions ( new ChartOptions ( ) ) ; } options . getChartOptions ( ) . setRenderTo ( renderTo ) ; }
Null - safe setter for the renderTo configuration .
692
public static boolean needsFunnelJs ( final Options options ) { return options . getChart ( ) != null && ( options . getChart ( ) . getType ( ) == SeriesType . FUNNEL || options . getChart ( ) . getType ( ) == SeriesType . PYRAMID ) ; }
Checks if the specified Options object needs the javascript file funnel . js to work properly . This method can be called by GUI components to determine whether the javascript file has to be included in the page or not .
693
public static boolean needsHeatmapJs ( final Options options ) { return options . getChart ( ) != null && ( options . getChart ( ) . getType ( ) == SeriesType . HEATMAP ) ; }
Checks if the specified Options object needs the javascript file heatmap . js to work properly . This method can be called by GUI components to determine whether the javascript file has to be included in the page or not .
694
public static boolean needsExportingJs ( final Options options ) { return options . getExporting ( ) == null || ( options . getExporting ( ) . getEnabled ( ) != null && options . getExporting ( ) . getEnabled ( ) ) ; }
Checks if the specified Options object needs the javascript file exporting . js to work properly . This method can be called by GUI components to determine whether the javascript file has to be included in the page or not .
695
private void addCharts ( PageParameters parameters ) { List < Chart > charts = getChartFromParams ( parameters ) ; if ( charts . size ( ) > 1 ) { List < SmallChartComponent > components = new ArrayList < > ( ) ; for ( Chart i : charts ) { components . add ( new SmallChartComponent ( i ) ) ; } add ( new ListView < SmallChartComponent > ( "components" , components ) { protected void populateItem ( ListItem item ) { item . add ( ( SmallChartComponent ) item . getModelObject ( ) ) ; } } ) ; } else { List < ChartComponent > components = new ArrayList < > ( ) ; for ( Chart i : charts ) { components . add ( new ChartComponent ( i ) ) ; } add ( new ListView < ChartComponent > ( "components" , components ) { protected void populateItem ( ListItem item ) { item . add ( ( ChartComponent ) item . getModelObject ( ) ) ; } } ) ; } List < CodeComponent > code_components = new ArrayList < > ( ) ; for ( Chart i : charts ) { code_components . add ( new CodeComponent ( i ) ) ; } add ( new ListView < CodeComponent > ( "code_components" , code_components ) { protected void populateItem ( ListItem item ) { item . add ( ( CodeComponent ) item . getModelObject ( ) ) ; } } ) ; }
Gets the charts and the code containers from the page parameters constructs Wicket componenets from them and adds them to a Wicket ListView .
696
@ SuppressWarnings ( "unchecked" ) private Zipper < K , V > compareDepth ( Tree < K , V > left , Tree < K , V > right ) { return unzipBoth ( left , right , ( List < Tree < K , V > > ) Collections . EMPTY_LIST , ( List < Tree < K , V > > ) Collections . EMPTY_LIST , 0 ) ; }
If the trees were balanced returns an empty zipper
697
private List < Tree < K , V > > unzip ( List < Tree < K , V > > zipper , boolean leftMost ) { Tree < K , V > next = leftMost ? zipper . get ( 0 ) . getLeft ( ) : zipper . get ( 0 ) . getRight ( ) ; if ( next == null ) return zipper ; return unzip ( cons ( next , zipper ) , leftMost ) ; }
Once a side is found to be deeper unzip it to the bottom
698
@ SuppressWarnings ( "unchecked" ) private Zipper < K , V > unzipBoth ( Tree < K , V > left , Tree < K , V > right , List < Tree < K , V > > leftZipper , List < Tree < K , V > > rightZipper , int smallerDepth ) { if ( isBlackTree ( left ) && isBlackTree ( right ) ) { return unzipBoth ( left . getRight ( ) , right . getLeft ( ) , cons ( left , leftZipper ) , cons ( right , rightZipper ) , smallerDepth + 1 ) ; } else if ( isRedTree ( left ) && isRedTree ( right ) ) { return unzipBoth ( left . getRight ( ) , right . getLeft ( ) , cons ( left , leftZipper ) , cons ( right , rightZipper ) , smallerDepth ) ; } else if ( isRedTree ( right ) ) { return unzipBoth ( left , right . getLeft ( ) , leftZipper , cons ( right , rightZipper ) , smallerDepth ) ; } else if ( isRedTree ( left ) ) { return unzipBoth ( left . getRight ( ) , right , cons ( left , leftZipper ) , rightZipper , smallerDepth ) ; } else if ( ( left == null ) && ( right == null ) ) { return new Zipper < K , V > ( ( List < Tree < K , V > > ) Collections . EMPTY_LIST , true , false , smallerDepth ) ; } else if ( ( left == null ) && isBlackTree ( right ) ) { return new Zipper < K , V > ( unzip ( cons ( right , rightZipper ) , true ) , false , true , smallerDepth ) ; } else if ( isBlackTree ( left ) && ( right == null ) ) { return new Zipper < K , V > ( unzip ( cons ( left , leftZipper ) , false ) , false , false , smallerDepth ) ; } else { throw new RuntimeException ( "unmatched trees in unzip: " + left + ", " + right ) ; } }
found to be deeper or the bottom is reached
699
public E get ( int index ) { int idx = checkRangeConvert ( index ) ; return pointer . getElem ( idx , idx ^ focus ) ; }
with local variables exclusively . But we re not quite there yet ...