idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
126,000
public static String selectOne ( final String title , final String [ ] optionNames , final String [ ] optionValues , final int defaultOption ) { if ( optionNames . length != optionValues . length ) { throw new IllegalArgumentException ( "option names and values must have same length" ) ; } ConsoleMenu . println ( "Plea...
Generates a menu with a list of options and return the value selected .
126,001
public String selectMajorCurrency ( final String ccy1 , final String ccy2 ) { return ranks . getOrDefault ( StringUtil . toUpperCase ( ccy1 ) , DEFAULT_UNRANKED_VALUE ) . intValue ( ) <= ranks . getOrDefault ( StringUtil . toUpperCase ( ccy2 ) , DEFAULT_UNRANKED_VALUE ) . intValue ( ) ? ccy1 : ccy2 ; }
Given 2 currencies return the major one if there is one otherwise returns the first currency .
126,002
public String selectMajorCurrency ( final CurrencyPair pair ) { return selectMajorCurrency ( pair . getCcy1 ( ) , pair . getCcy2 ( ) ) ; }
Given a CurrencyPair return the major Currency if there is one otherwise returns the first currency .
126,003
public boolean isMarketConvention ( final String ccy1 , final String ccy2 ) { return selectMajorCurrency ( ccy1 , ccy2 ) . equals ( ccy1 ) ; }
returns true if the ccy1 is the major one for the given currency pair .
126,004
public void setCurrenciesSubjectToCrossCcyForT1 ( final Map < String , Set < String > > currenciesSubjectToCrossCcyForT1 ) { final Map < String , Set < String > > copy = new HashMap < > ( ) ; if ( currenciesSubjectToCrossCcyForT1 != null ) { copy . putAll ( currenciesSubjectToCrossCcyForT1 ) ; } this . currenciesSubjec...
Will take a copy of a non null set but doing so by replacing the internal one in one go for consistency .
126,005
public void setWorkingWeeks ( final Map < String , WorkingWeek > workingWeeks ) { final Map < String , WorkingWeek > ww = new HashMap < > ( ) ; ww . putAll ( workingWeeks ) ; this . workingWeeks = ww ; }
Will take a copy of a non null map but doing so by replacing the internal one in one go for consistency .
126,006
public WorkingWeek withWorkingDayFromCalendar ( final boolean working , final int dayOfWeek ) { final int day = adjustDay ( dayOfWeek ) ; WorkingWeek ret = this ; if ( working && ! isWorkingDayFromCalendar ( dayOfWeek ) ) { ret = new WorkingWeek ( ( byte ) ( workingDays + WORKING_WEEK_DAYS_OFFSET [ day ] ) ) ; } else i...
If the value for the given day has changed return a NEW WorkingWeek .
126,007
public static boolean anyNull ( final Object ... o1s ) { if ( o1s != null && o1s . length > 0 ) { for ( final Object o1 : o1s ) { if ( o1 == null ) { return true ; } } } else { return true ; } return false ; }
Return true if any of the given objects are null .
126,008
public static boolean allNull ( final Object ... o1s ) { if ( o1s != null && o1s . length > 0 ) { for ( final Object o1 : o1s ) { if ( o1 != null ) { return false ; } } } return true ; }
Return true if ALL of the given objects are null .
126,009
public static boolean atLeastOneNotNull ( final Object ... o1s ) { if ( o1s != null && o1s . length > 0 ) { for ( final Object o1 : o1s ) { if ( o1 != null ) { return true ; } } } return false ; }
Return true if at least one of the given objects is not null .
126,010
protected void setHolidays ( final String name , final DateCalculator < E > dc ) { if ( name != null ) { dc . setHolidayCalendar ( holidays . get ( name ) ) ; } }
Used by extensions to set holidays in a DateCalculator .
126,011
protected CurrencyDateCalculatorBuilder < E > configureCurrencyCalculatorBuilder ( final CurrencyDateCalculatorBuilder < E > builder ) { return builder . ccy1Calendar ( getHolidayCalendar ( builder . getCcy1 ( ) ) ) . ccy1Week ( getCurrencyCalculatorConfig ( ) . getWorkingWeek ( builder . getCcy1 ( ) ) ) . ccy2Calendar...
Method that may be called by the specialised factory methods and will fetch the registered holidayCalendar for all 3 currencies and the working weeks via the currencyCalculatorConfig and assigning currencyCalculatorConfig to the builder using the DefaultCurrencyCalculatorConfig if not modified .
126,012
public static FxRate calculateCross ( final CurrencyPair targetPair , final FxRate fx1 , final FxRate fx2 , final int precision , final int precisionForInverseFxRate , final MajorCurrencyRanking ranking , final int bidRounding , final int askRounding , CurrencyProvider currencyProvider ) { final Optional < String > cro...
Calculate the cross rate use this only if required .
126,013
public static String buildStackTraceString ( final Throwable ex ) { final StringBuilder context = new StringBuilder ( ex . toString ( ) ) ; final StringWriter sw = new StringWriter ( ) ; ex . printStackTrace ( new PrintWriter ( sw , true ) ) ; context . append ( '\n' ) ; context . append ( sw . toString ( ) ) ; return ...
finds out the stack trace up to where the exception was thrown .
126,014
public static String dumpThreads ( ) { final StringWriter sout = new StringWriter ( ) ; final PrintWriter out = new PrintWriter ( sout ) ; Util . listAllThreads ( out ) ; out . flush ( ) ; return sout . toString ( ) ; }
Finds information about the threads and dumps them into a String .
126,015
private static void listAllThreads ( final PrintWriter out ) { final ThreadGroup currentThreadGroup = Thread . currentThread ( ) . getThreadGroup ( ) ; ThreadGroup rootThreadGroup = currentThreadGroup ; ThreadGroup parent = rootThreadGroup . getParent ( ) ; while ( parent != null ) { rootThreadGroup = parent ; parent =...
Find the root thread group and list it recursively
126,016
private static void printGroupInfo ( final PrintWriter out , final ThreadGroup group , final String indent ) { if ( group == null ) { return ; } final int numThreads = group . activeCount ( ) ; final int numGroups = group . activeGroupCount ( ) ; final Thread [ ] threads = new Thread [ numThreads ] ; final ThreadGroup ...
Display info about a thread group and its threads and groups
126,017
public static String replaceToken ( final String original , final String token , final String replacement ) { final StringBuilder tok = new StringBuilder ( TOKEN ) ; tok . append ( token ) . append ( TOKEN ) ; final String toReplace = replaceCRToken ( original ) ; return StringUtil . replace ( tok . toString ( ) , repl...
Replaces the token surrounded by % within a string with new value . Also replaces any %CR% tokens with the newline character .
126,018
public static String replaceCRToken ( final String original ) { String toReplace = original ; if ( original != null && original . indexOf ( NEWLINE_TOKEN ) >= 0 ) { toReplace = StringUtil . replace ( NEWLINE_TOKEN , NEW_LINE , original ) ; } return toReplace ; }
Replaces any %CR% tokens with the newline character .
126,019
public static String wrapText ( final String inString , final String newline , final int wrapColumn ) { if ( inString == null ) { return null ; } final StringTokenizer lineTokenizer = new StringTokenizer ( inString , newline , true ) ; final StringBuilder builder = new StringBuilder ( ) ; while ( lineTokenizer . hasMor...
Takes a block of text which might have long lines in it and wraps the long lines based on the supplied wrapColumn parameter . It was initially implemented for use by VelocityEmail . If there are tabs in inString you are going to get results that are a bit strange since tabs are a single character but are displayed as 4...
126,020
public static String singleQuote ( final String text ) { final StringBuilder b = new StringBuilder ( ( text != null ? text . length ( ) : 0 ) + 2 ) ; b . append ( SINGLE_QUOTE ) ; if ( text != null ) { b . append ( text ) ; } b . append ( SINGLE_QUOTE ) ; return b . toString ( ) ; }
Add single quotes around the text .
126,021
public static boolean allEquals ( final String value , final String ... strings ) { if ( strings != null ) { for ( final String s : strings ) { if ( s == null && value != null || s != null && ! s . equals ( value ) ) { return false ; } } } else { return value == null ; } return true ; }
Return true if all strings are the same .
126,022
public static String prepareForNumericParsing ( final String inputStr ) { if ( inputStr == null ) { return EMPTY ; } final Matcher matcher = PATTERN_FOR_NUM_PARSING_PREP . matcher ( inputStr ) ; return matcher . replaceAll ( "" ) ; }
Remove and spaces from the input string .
126,023
public static int compareTo ( final String s1 , final String s2 ) { int ret ; if ( s1 != null && s2 != null ) { ret = s1 . compareTo ( s2 ) ; } else if ( s1 == null && s2 == null ) { ret = 0 ; } else if ( s2 == null ) { ret = 1 ; } else { ret = - 1 ; } return ret ; }
Handle null .
126,024
public static String boxify ( final char boxing , final String text ) { if ( boxing != 0 && StringUtils . isNotBlank ( text ) ) { final StringBuilder b = new StringBuilder ( ) ; b . append ( NEW_LINE ) ; final String line = StringUtils . repeat ( String . valueOf ( boxing ) , text . length ( ) + 4 ) ; b . append ( line...
Returns a String which is surrounded by a box made of boxing char .
126,025
public static Integer assign ( final Integer value , final Integer defaultValueIfNull ) { return value != null ? value : defaultValueIfNull ; }
Return the value unless it is null in which case it returns the default value .
126,026
public static void setInternalComments ( Node node , ParserRuleContext parserRuleContext , AdapterParameters adapterParameters ) { BufferedTokenStream tokens = adapterParameters . getTokens ( ) ; if ( node == null || parserRuleContext == null || tokens == null ) { throw new IllegalArgumentException ( "Parameters must n...
If there are no statements within a block we need a special method to grab any comments that might exist between braces .
126,027
public static CompilationUnit parse ( String javaSource ) throws IOException , ParseException { ByteArrayInputStream inputStream = new ByteArrayInputStream ( javaSource . getBytes ( "UTF-8" ) ) ; return parse ( inputStream ) ; }
Parses a UTF - 8 encoded string as java source .
126,028
public String format ( Comment comment , int indentLevel , CommentLocation commentLocation ) { if ( comment == null || comment . getContent ( ) == null ) { return null ; } return format ( comment . getContent ( ) , indentLevel , commentLocation ) ; }
Format a given comment with the indent level specified .
126,029
public String format ( String comment , int indentLevel , CommentLocation commentLocation ) { if ( comment == null ) { return null ; } final StringBuilder indentString = new StringBuilder ( ) ; for ( int i = 0 ; i < indentLevel ; i ++ ) { indentString . append ( " " ) ; } boolean endsWithNewline = ( comment . endsWi...
Format a given comment string with the indent level specified .
126,030
public void animateOpen ( ) { prepareContent ( ) ; if ( onDrawerScrollListener != null ) { onDrawerScrollListener . onScrollStarted ( ) ; } animateOpen ( vertical ? viewHandle . getTop ( ) : viewHandle . getLeft ( ) ) ; sendAccessibilityEvent ( AccessibilityEvent . TYPE_WINDOW_STATE_CHANGED ) ; if ( onDrawerScrollListe...
Opens the drawer with an animation .
126,031
public void animateClose ( ) { prepareContent ( ) ; if ( onDrawerScrollListener != null ) { onDrawerScrollListener . onScrollStarted ( ) ; } animateClose ( vertical ? viewHandle . getTop ( ) : viewHandle . getLeft ( ) ) ; if ( onDrawerScrollListener != null ) { onDrawerScrollListener . onScrollEnded ( ) ; } }
Closes the drawer with an animation .
126,032
public static ManifestBuilder builder ( ClassLoader classLoader , KnowledgeComponentImplementationModel implementationModel ) { ManifestModel manifestModel = implementationModel != null ? implementationModel . getManifest ( ) : null ; return new ManifestBuilder ( classLoader , manifestModel ) ; }
Creates a ManifestBuilder .
126,033
public static void registerOperations ( KnowledgeComponentImplementationModel model , Map < String , KnowledgeOperation > operations , KnowledgeOperation defaultOperation ) { OperationsModel operationsModel = model . getOperations ( ) ; if ( operationsModel != null ) { for ( OperationModel operationModel : operationsMo...
Registers operations .
126,034
public static void setGlobals ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime , boolean singleton ) { Globals globals = runtime . getSessionGlobals ( ) ; if ( globals != null ) { Map < String , Object > globalsMap = new HashMap < String , Object > ( ) ; globalsMap . put ( GLOBALS , new...
Sets the globals .
126,035
public static boolean containsGlobals ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime ) { Map < String , Object > expressionMap = getMap ( message , operation . getGlobalExpressionMappings ( ) , null ) ; return expressionMap != null && expressionMap . size ( ) > 0 ; }
Contains the globals .
126,036
public static Object getInput ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime ) { List < Object > list = getList ( message , operation . getInputExpressionMappings ( ) ) ; switch ( list . size ( ) ) { case 0 : return filterRemoteDefaultInputContent ( message . getContent ( ) , runtime ...
Gets the input .
126,037
public static List < Object > getInputOnlyList ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime ) { return getInputList ( message , operation . getInputOnlyExpressionMappings ( ) , runtime ) ; }
Gets an input - only list .
126,038
public static Map < String , Object > getInputOutputMap ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime ) { Map < String , Object > map = new LinkedHashMap < String , Object > ( ) ; Map < String , ExpressionMapping > inputs = operation . getInputOutputExpressionMappings ( ) ; for ( Ent...
Gets an input - output map .
126,039
public static Map < String , Object > getInputMap ( Message message , KnowledgeOperation operation , KnowledgeRuntimeEngine runtime ) { Map < String , Object > map = new HashMap < String , Object > ( ) ; List < ExpressionMapping > inputs = operation . getInputExpressionMappings ( ) ; if ( inputs . size ( ) > 0 ) { map ...
Gets an input map .
126,040
public static void setOutputs ( Message message , KnowledgeOperation operation , Map < String , Object > contextOverrides ) { try { setOutputsOrFaults ( message , operation . getOutputExpressionMappings ( ) , contextOverrides , RESULT , false ) ; } catch ( Exception e ) { setOutputsOrFaults ( message , operation . getO...
Sets the outputs .
126,041
public static void setFaults ( Message message , KnowledgeOperation operation , Map < String , Object > contextOverrides ) { setOutputsOrFaults ( message , operation . getFaultExpressionMappings ( ) , contextOverrides , FAULT , false ) ; }
Sets the faults .
126,042
public static Map < String , List < Object > > getListMap ( Message message , List < ExpressionMapping > expressionMappings , boolean expand , String undefinedVariable ) { return getListMap ( message , expressionMappings , expand , undefinedVariable , null ) ; }
Gets a list map .
126,043
@ Transformer ( to = "{urn:switchyard-quickstart-demo:helpdesk:1.0}openTicketResponse" ) public Element transformToElement ( TicketAck ticketAck ) { StringBuilder ackXml = new StringBuilder ( ) . append ( "<helpdesk:openTicketResponse xmlns:helpdesk=\"urn:switchyard-quickstart-demo:helpdesk:1.0\">" ) . append ( "<ticke...
Transform to element .
126,044
public Ticket transformToTicket ( TicketAck ticketAck ) { Ticket ticket = new Ticket ( ) ; ticket . setId ( ticketAck . getId ( ) ) ; return ticket ; }
Transform to ticket .
126,045
private String getElementValue ( Element parent , String elementName ) { String value = null ; NodeList nodes = parent . getElementsByTagName ( elementName ) ; if ( nodes . getLength ( ) > 0 ) { value = nodes . item ( 0 ) . getChildNodes ( ) . item ( 0 ) . getNodeValue ( ) ; } return value ; }
Gets the element value .
126,046
private Element toElement ( String xml ) { DOMResult dom = new DOMResult ( ) ; try { TransformerFactory . newInstance ( ) . newTransformer ( ) . transform ( new StreamSource ( new StringReader ( xml ) ) , dom ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return ( ( Document ) dom . getNode ( ) ) . getDocume...
To element .
126,047
public void generateCommand ( Exchange exchange ) throws Exception { System . out . println ( ">> We will fire all rules commands" ) ; FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand ( ) ; exchange . getIn ( ) . setBody ( fireAllRulesCommand ) ; }
Generate command .
126,048
public void insertAndFireAll ( Exchange exchange ) { final Message in = exchange . getIn ( ) ; final Object body = in . getBody ( ) ; BatchExecutionCommandImpl command = new BatchExecutionCommandImpl ( ) ; final List < GenericCommand < ? > > commands = command . getCommands ( ) ; commands . add ( new InsertObjectComman...
Insert and fire all .
126,049
@ Transformer ( from = "{urn:switchyard-quickstart:rules-interview-dtable:0.1.0}verify" ) public Applicant transformVerifyToApplicant ( Element e ) { String name = getElementValue ( e , "name" ) ; int age = Integer . valueOf ( getElementValue ( e , "age" ) ) . intValue ( ) ; return new Applicant ( name , age ) ; }
Transform verify to applicant .
126,050
public ExtendedRegisterableItemsFactory build ( ) { return new NoopExtendedRegisterableItemsFactory ( ) { private RuntimeEngine _runtime ; private List < EventListener > _listeners = new ArrayList < EventListener > ( ) ; private synchronized List < EventListener > listeners ( RuntimeEngine runtime ) { if ( _runtime != ...
Builds a ExtendedRegisterableItemsFactory .
126,051
public UserGroupCallback build ( ) { UserGroupCallback callback = null ; Properties properties = _propertiesBuilder . build ( ) ; if ( _userGroupCallbackClass != null ) { callback = construct ( properties ) ; } if ( callback == null && USER_CALLBACK_IMPL != null ) { try { if ( "props" . equalsIgnoreCase ( USER_CALLBACK...
Builds a UserGroupCallback .
126,052
public static UserGroupCallbackBuilder builder ( ClassLoader classLoader , KnowledgeComponentImplementationModel implementationModel ) { UserGroupCallbackModel userGroupCallbackModel = implementationModel != null ? implementationModel . getUserGroupCallback ( ) : null ; return new UserGroupCallbackBuilder ( classLoader...
Creates a UserGroupCallbackBuilder .
126,053
public static final synchronized BPMTaskService getTaskService ( QName serviceDomainName , QName serviceName ) { KnowledgeRuntimeManager runtimeManager = KnowledgeRuntimeManagerRegistry . getRuntimeManager ( serviceDomainName , serviceName ) ; if ( runtimeManager != null ) { RuntimeEngine runtimeEngine = runtimeManager...
Gets a task service .
126,054
@ Transformer ( to = "{urn:switchyard-quickstart:rules-interview:0.1.0}verifyResponse" ) public Element transformBooleanToVerifyResponse ( boolean b ) { String xml = new StringBuilder ( ) . append ( "<urn:verifyResponse xmlns:urn='urn:switchyard-quickstart:rules-interview:0.1.0'>" ) . append ( "<return>" ) . append ( b...
Transform boolean to verify response .
126,055
public SwitchYardServiceResponse invoke ( SwitchYardServiceRequest request ) { Map < String , Object > contextOut = new HashMap < String , Object > ( ) ; Object contentOut = null ; Object fault = null ; try { QName serviceName = request . getServiceName ( ) ; if ( serviceName == null ) { throw CommonKnowledgeMessages ....
Invokes the request and returns the response .
126,056
public static final synchronized KnowledgeRuntimeManager getRuntimeManager ( QName serviceDomainName , QName serviceName ) { if ( serviceDomainName == null ) { serviceDomainName = ROOT_DOMAIN ; } Map < QName , KnowledgeRuntimeManager > reg = REGISTRY . get ( serviceDomainName ) ; return reg != null ? reg . get ( servic...
Gets a runtime manager .
126,057
public static final synchronized void putRuntimeManager ( QName serviceDomainName , QName serviceName , KnowledgeRuntimeManager runtimeManager ) { if ( serviceDomainName == null ) { serviceDomainName = ROOT_DOMAIN ; } Map < QName , KnowledgeRuntimeManager > reg = REGISTRY . get ( serviceDomainName ) ; if ( reg == null ...
Puts a runtime manager .
126,058
public WorkItemHandler build ( ProcessRuntime processRuntime , RuntimeManager runtimeManager ) { WorkItemHandler workItemHandler = construct ( processRuntime , runtimeManager ) ; if ( workItemHandler instanceof SwitchYardServiceTaskHandler ) { SwitchYardServiceTaskHandler systh = ( SwitchYardServiceTaskHandler ) workIt...
Builds a WorkItemHandler .
126,059
public static List < WorkItemHandlerBuilder > builders ( ClassLoader classLoader , ServiceDomain serviceDomain , KnowledgeComponentImplementationModel implementationModel ) { List < WorkItemHandlerBuilder > builders = new ArrayList < WorkItemHandlerBuilder > ( ) ; Set < String > registeredNames = new HashSet < String >...
Creates WorkItemHandlerBuilders .
126,060
public KieRuntimeLogger build ( KieRuntimeEventManager runtimeEventManager ) { KieRuntimeLogger logger = null ; if ( _loggerType != null && runtimeEventManager != null ) { KieLoggers loggers = KieServices . Factory . get ( ) . getLoggers ( ) ; switch ( _loggerType ) { case CONSOLE : logger = loggers . newConsoleLogger ...
Builds a KieRuntimeLogger .
126,061
public static List < LoggerBuilder > builders ( ClassLoader classLoader , KnowledgeComponentImplementationModel implementationModel ) { List < LoggerBuilder > builders = new ArrayList < LoggerBuilder > ( ) ; if ( implementationModel != null ) { LoggersModel loggersModel = implementationModel . getLoggers ( ) ; if ( log...
Creates LoggerBuilders .
126,062
public String getFaultMessage ( ) { String fmsg = null ; Object fault = getFault ( ) ; if ( fault != null ) { if ( fault instanceof Throwable ) { fmsg = String . format ( CommonKnowledgeMessages . MESSAGES . faultEncountered ( ) + " [%s(message=%s)]: %s" , fault . getClass ( ) . getName ( ) , ( ( Throwable ) fault ) . ...
Gets a fault message if a fault exists .
126,063
public String getGroupId ( ) { List < String > groups = USERS_GROUPS . get ( _userId ) ; return ( groups != null && groups . size ( ) > 0 ) ? groups . get ( 0 ) : null ; }
Gets the group id .
126,064
public Map < String , String > getUsersGroups ( ) { Map < String , String > usersGroups = new LinkedHashMap < String , String > ( ) ; for ( Map . Entry < String , List < String > > entry : USERS_GROUPS . entrySet ( ) ) { String key = entry . getKey ( ) ; usersGroups . put ( key + " (" + entry . getValue ( ) . get ( 0 )...
Gets the users groups .
126,065
private void fetchTasks ( ) { synchronized ( _userTasks ) { _userTasks . clear ( ) ; _userTickets . clear ( ) ; List < TaskSummary > tasks = _taskService . getTasksAssignedAsPotentialOwner ( _userId , EN_UK ) ; for ( TaskSummary task : tasks ) { _userTasks . add ( task ) ; Map < String , Object > params = _taskService ...
Fetch tasks .
126,066
private void completeTasks ( ) { synchronized ( _userTasks ) { if ( _userTasks . size ( ) > 0 ) { for ( TaskSummary task : _userTasks ) { _taskService . claim ( task . getId ( ) , _userId ) ; _taskService . start ( task . getId ( ) , _userId ) ; Map < String , Object > results = new HashMap < String , Object > ( ) ; Ti...
Complete tasks .
126,067
public PropertiesBuilder setModelProperties ( PropertiesModel propertiesModel ) { _modelProperties = propertiesModel != null ? propertiesModel . toProperties ( ) : null ; return this ; }
Sets the model properties .
126,068
public Properties build ( ) { Properties buildProperties = new Properties ( ) ; merge ( _defaultProperties , buildProperties ) ; merge ( _modelProperties , buildProperties ) ; merge ( _overrideProperties , buildProperties ) ; return buildProperties ; }
Builds a Properties .
126,069
public static PropertiesBuilder builder ( KnowledgeComponentImplementationModel implementationModel ) { PropertiesModel propertiesModel = null ; if ( implementationModel != null ) { propertiesModel = implementationModel . getProperties ( ) ; } return new PropertiesBuilder ( propertiesModel ) ; }
Creates a PropertiesBuilder .
126,070
public List < Resource > buildResources ( ) { List < Resource > resources = new ArrayList < Resource > ( ) ; for ( ResourceBuilder builder : _resourceBuilders ) { Resource resource = builder . build ( ) ; if ( resource != null ) { resources . add ( resource ) ; } } return resources ; }
Builds the Resources .
126,071
public Channel build ( ) { Channel channel = null ; if ( _channelClass != null ) { channel = Construction . construct ( _channelClass ) ; if ( channel instanceof SwitchYardServiceChannel ) { SwitchYardServiceChannel sysc = ( SwitchYardServiceChannel ) channel ; sysc . setServiceName ( _serviceName ) ; sysc . setOperati...
Builds a Channel .
126,072
public static List < ChannelBuilder > builders ( ClassLoader classLoader , ServiceDomain serviceDomain , KnowledgeComponentImplementationModel implementationModel ) { List < ChannelBuilder > builders = new ArrayList < ChannelBuilder > ( ) ; if ( implementationModel != null ) { ChannelsModel channelsModel = implementati...
Creates ChannelBuilders .
126,073
private void addBook ( String isbn , String title , String synopsis , int quantity ) { Book book = new Book ( ) ; book . setIsbn ( isbn ) ; book . setTitle ( title ) ; book . setSynopsis ( synopsis ) ; isbns_to_books . put ( isbn , book ) ; isbns_to_quantities . put ( isbn , quantity ) ; }
Adds the book .
126,074
public Collection < Book > getAvailableBooks ( ) { synchronized ( librarian ) { Collection < Book > books = new LinkedList < Book > ( ) ; for ( Entry < String , Integer > entry : isbns_to_quantities . entrySet ( ) ) { if ( entry . getValue ( ) > 0 ) { books . add ( getBook ( entry . getKey ( ) ) ) ; } } return books ; ...
Gets the available books .
126,075
public Loan attemptLoan ( String isbn , String loanId ) { Loan loan = new Loan ( ) ; loan . setId ( loanId ) ; Book book = getBook ( isbn ) ; if ( book != null ) { synchronized ( librarian ) { int quantity = getQuantity ( book ) ; if ( quantity > 0 ) { quantity -- ; isbns_to_quantities . put ( isbn , quantity ) ; loan ...
Attempt loan .
126,076
public boolean returnLoan ( Loan loan ) { if ( loan != null ) { Book book = loan . getBook ( ) ; if ( book != null ) { String isbn = book . getIsbn ( ) ; if ( isbn != null ) { synchronized ( librarian ) { Integer quantity = isbns_to_quantities . get ( isbn ) ; if ( quantity != null ) { quantity = new Integer ( quantity...
Return loan .
126,077
public Resource build ( ) { Resource resource = null ; if ( _url != null ) { resource = _kieResources . newUrlResource ( _url ) ; if ( resource != null ) { if ( _resourceType != null ) { resource . setResourceType ( _resourceType ) ; } if ( _resourceConfiguration != null ) { resource . setConfiguration ( _resourceConfi...
Builds a Resource .
126,078
public RuntimeEnvironmentBuilder entityManagerFactory ( Object emf ) { if ( emf == null ) { return this ; } if ( ! ( emf instanceof EntityManagerFactory ) ) { throw new IllegalArgumentException ( "Argument is not of type EntityManagerFactory" ) ; } _runtimeEnvironment . setEmf ( ( EntityManagerFactory ) emf ) ; return ...
Sets entityManagerFactory .
126,079
public RuntimeEnvironmentBuilder addAsset ( Resource asset , ResourceType type ) { if ( asset == null || type == null ) { return this ; } _runtimeEnvironment . addAsset ( asset , type ) ; return this ; }
Adds and asset .
126,080
public RuntimeEnvironmentBuilder schedulerService ( Object globalScheduler ) { if ( globalScheduler == null ) { return this ; } if ( ! ( globalScheduler instanceof GlobalSchedulerService ) ) { throw new IllegalArgumentException ( "Argument is not of type GlobalSchedulerService" ) ; } _runtimeEnvironment . setSchedulerS...
Sets the schedulerService .
126,081
public KnowledgeRuntimeManager newRuntimeManager ( KnowledgeRuntimeManagerType type ) { RuntimeManager runtimeManager ; final String identifier = _identifierRoot + IDENTIFIER_COUNT . incrementAndGet ( ) ; final ClassLoader origTCCL = Classes . setTCCL ( _classLoader ) ; try { runtimeManager = _runtimeManagerBuilder . b...
Creates a new KnowledgeRuntimeManager .
126,082
public static List < ListenerBuilder > builders ( ClassLoader classLoader , KnowledgeComponentImplementationModel implementationModel ) { List < ListenerBuilder > builders = new ArrayList < ListenerBuilder > ( ) ; if ( implementationModel != null ) { ListenersModel listenersModel = implementationModel . getListeners ( ...
Creates ListenerBuilders .
126,083
protected boolean isBoolean ( Exchange exchange , Message message , String name ) { Boolean b = getBoolean ( exchange , message , name ) ; return b != null && b . booleanValue ( ) ; }
Gets a primitive boolean context property .
126,084
protected Boolean getBoolean ( Exchange exchange , Message message , String name ) { Object value = getObject ( exchange , message , name ) ; if ( value instanceof Boolean ) { return ( Boolean ) value ; } else if ( value instanceof String ) { return Boolean . valueOf ( ( ( String ) value ) . trim ( ) ) ; } return false...
Gets a Boolean context property .
126,085
protected Integer getInteger ( Exchange exchange , Message message , String name ) { Object value = getObject ( exchange , message , name ) ; if ( value instanceof Integer ) { return ( Integer ) value ; } else if ( value instanceof Number ) { return Integer . valueOf ( ( ( Number ) value ) . intValue ( ) ) ; } else if ...
Gets an Integer context property .
126,086
protected Long getLong ( Exchange exchange , Message message , String name ) { Object value = getObject ( exchange , message , name ) ; if ( value instanceof Long ) { return ( Long ) value ; } else if ( value instanceof Number ) { return Long . valueOf ( ( ( Number ) value ) . longValue ( ) ) ; } else if ( value instan...
Gets a Long context property .
126,087
protected String getString ( Exchange exchange , Message message , String name ) { Object value = getObject ( exchange , message , name ) ; if ( value instanceof String ) { return ( String ) value ; } else if ( value != null ) { return String . valueOf ( value ) ; } return null ; }
Gets a String context property .
126,088
protected Object getObject ( Exchange exchange , Message message , String name ) { Context context = message != null ? exchange . getContext ( message ) : exchange . getContext ( ) ; return context . getPropertyValue ( name ) ; }
Gets an Object context property .
126,089
protected Map < String , Object > getGlobalVariables ( KnowledgeRuntimeEngine runtimeEngine ) { Map < String , Object > globalVariables = new HashMap < String , Object > ( ) ; if ( runtimeEngine != null ) { Globals globals = runtimeEngine . getSessionGlobals ( ) ; if ( globals != null ) { for ( String key : globals . g...
Gets the global variables from the knowledge runtime engine .
126,090
public RuntimeManager build ( KnowledgeRuntimeManagerType type , String identifier ) { final RuntimeManager runtimeManager ; final RuntimeEnvironment runtimeEnvironment = _runtimeEnvironmentBuilder . build ( ) ; final RemoteManifest remoteManifest = RemoteManifest . removeFromEnvironment ( runtimeEnvironment . getEnvir...
Builds a RuntimeManager .
126,091
protected ChannelsModel toChannelsModel ( Channel [ ] channelAnnotations , KnowledgeNamespace knowledgeNamespace , ComponentModel componentModel , SwitchYardNamespace switchyardNamespace ) { if ( channelAnnotations == null || channelAnnotations . length == 0 ) { return null ; } ChannelsModel channelsModel = new V1Chann...
Converts channel annotations to a channels model .
126,092
protected ContainerModel toContainerModel ( Container containerAnnotation , KnowledgeNamespace knowledgeNamespace ) { if ( containerAnnotation == null ) { return null ; } ContainerModel containerModel = new V1ContainerModel ( knowledgeNamespace . uri ( ) ) ; String baseName = containerAnnotation . baseName ( ) ; if ( !...
Converts container annotation to container model
126,093
protected ListenersModel toListenersModel ( Listener [ ] listenerAnnotations , KnowledgeNamespace knowledgeNamespace ) { if ( listenerAnnotations == null || listenerAnnotations . length == 0 ) { return null ; } ListenersModel listenersModel = new V1ListenersModel ( knowledgeNamespace . uri ( ) ) ; for ( Listener listen...
Converts listener annotations to listeners model .
126,094
protected LoggersModel toLoggersModel ( Logger [ ] loggerAnnotations , KnowledgeNamespace knowledgeNamespace ) { if ( loggerAnnotations == null || loggerAnnotations . length == 0 ) { return null ; } LoggersModel loggersModel = new V1LoggersModel ( knowledgeNamespace . uri ( ) ) ; for ( Logger loggerAnnotation : loggerA...
Converts logger annotations to loggers model .
126,095
protected ManifestModel toManifestModel ( Manifest [ ] manifestAnnotations , KnowledgeNamespace knowledgeNamespace ) { if ( manifestAnnotations == null || manifestAnnotations . length == 0 ) { return null ; } Manifest manifestAnnotation = manifestAnnotations [ 0 ] ; ManifestModel manifestModel = new V1ManifestModel ( k...
Converts manifest annotations to manifest model .
126,096
protected GlobalsModel toGlobalsModel ( Global [ ] globals , KnowledgeNamespace knowledgeNamespace ) { GlobalsModel globalsModel = null ; if ( globals != null ) { for ( Global global : globals ) { if ( global != null ) { GlobalModel globalModel = new V1GlobalModel ( knowledgeNamespace . uri ( ) ) ; String from = global...
Converts globals to mappings model .
126,097
protected InputsModel toInputsModel ( Input [ ] inputs , KnowledgeNamespace knowledgeNamespace ) { InputsModel inputsModel = null ; if ( inputs != null ) { for ( Input input : inputs ) { if ( input != null ) { InputModel inputModel = new V1InputModel ( knowledgeNamespace . uri ( ) ) ; String from = input . from ( ) ; i...
Converts inputs to mappings model .
126,098
protected OutputsModel toOutputsModel ( Output [ ] outputs , KnowledgeNamespace knowledgeNamespace ) { OutputsModel outputsModel = null ; if ( outputs != null ) { for ( Output output : outputs ) { if ( output != null ) { OutputModel outputModel = new V1OutputModel ( knowledgeNamespace . uri ( ) ) ; String from = output...
Converts outputs to mappings model .
126,099
protected FaultsModel toFaultsModel ( Fault [ ] faults , KnowledgeNamespace knowledgeNamespace ) { FaultsModel faultsModel = null ; if ( faults != null ) { for ( Fault fault : faults ) { if ( fault != null ) { FaultModel faultModel = new V1FaultModel ( knowledgeNamespace . uri ( ) ) ; String from = fault . from ( ) ; i...
Converts faults to mappings model .