idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
8,800
public void sendMessage ( String channel , Message message ) { ensureChannel ( channel ) ; admin . getRabbitTemplate ( ) . convertAndSend ( exchange . getName ( ) , channel , message ) ; }
Sends an event to the default exchange .
8,801
protected boolean putToQueue ( IQueueMessage < ID , DATA > msg ) { try { BytesMessage message = getProducerSession ( ) . createBytesMessage ( ) ; message . writeBytes ( serialize ( msg ) ) ; getMessageProducer ( ) . send ( message ) ; return true ; } catch ( Exception e ) { throw e instanceof QueueException ? ( QueueException ) e : new QueueException ( e ) ; } }
Puts a message to ActiveMQ queue .
8,802
public boolean hasException ( Class < ? extends Throwable > type ) { for ( Throwable exception : exceptions ) { if ( type . isInstance ( exception ) ) { return true ; } } return false ; }
Returns true if this instance contains an exception of the given type .
8,803
public StackTraceElement [ ] getStackTrace ( ) { ArrayList < StackTraceElement > stackTrace = new ArrayList < > ( ) ; for ( Throwable exception : exceptions ) { stackTrace . addAll ( Arrays . asList ( exception . getStackTrace ( ) ) ) ; } return stackTrace . toArray ( new StackTraceElement [ stackTrace . size ( ) ] ) ; }
Returns the stack trace which is the union of all stack traces of contained exceptions .
8,804
public int dot ( int [ ] other ) { int dot = 0 ; for ( int c = 0 ; c < used && indices [ c ] < other . length ; c ++ ) { if ( indices [ c ] > Integer . MAX_VALUE ) { break ; } dot += values [ c ] * other [ SafeCast . safeLongToInt ( indices [ c ] ) ] ; } return dot ; }
Computes the dot product of this vector with the given vector .
8,805
public int dot ( int [ ] [ ] matrix , int col ) { int ret = 0 ; for ( int c = 0 ; c < used && indices [ c ] < matrix . length ; c ++ ) { if ( indices [ c ] > Integer . MAX_VALUE ) { break ; } ret += values [ c ] * matrix [ SafeCast . safeLongToInt ( indices [ c ] ) ] [ col ] ; } return ret ; }
Computes the dot product of this vector with the column of the given matrix .
8,806
public static void copyResourceToFile ( String resourceAbsoluteClassPath , File targetFile ) throws IOException { InputStream is = ResourceUtil . class . getResourceAsStream ( resourceAbsoluteClassPath ) ; if ( is == null ) { throw new IOException ( "Resource not found! " + resourceAbsoluteClassPath ) ; } OutputStream os = null ; try { os = new FileOutputStream ( targetFile ) ; byte [ ] buffer = new byte [ 2048 ] ; int length ; while ( ( length = is . read ( buffer ) ) != - 1 ) { os . write ( buffer , 0 , length ) ; } os . flush ( ) ; } finally { try { is . close ( ) ; if ( os != null ) { os . close ( ) ; } } catch ( Exception ignore ) { } } }
Copy resources to file system .
8,807
public static String getAbsolutePath ( String classPath ) { URL configUrl = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( classPath . substring ( 1 ) ) ; if ( configUrl == null ) { configUrl = ResourceUtil . class . getResource ( classPath ) ; } if ( configUrl == null ) { return null ; } try { return configUrl . toURI ( ) . getPath ( ) ; } catch ( URISyntaxException e ) { throw new RuntimeException ( e ) ; } }
Get absolute path in file system from a classPath . If this resource not exists return null .
8,808
public void setFocus ( ) { Radiobutton radio = editor . getSelected ( ) ; if ( radio == null ) { radio = ( Radiobutton ) editor . getChildren ( ) . get ( 0 ) ; } radio . setFocus ( true ) ; }
Sets focus to the selected radio button .
8,809
public static DesignContextMenu getInstance ( ) { Page page = ExecutionContext . getPage ( ) ; DesignContextMenu contextMenu = page . getAttribute ( DesignConstants . ATTR_DESIGN_MENU , DesignContextMenu . class ) ; if ( contextMenu == null ) { contextMenu = create ( ) ; page . setAttribute ( DesignConstants . ATTR_DESIGN_MENU , contextMenu ) ; } return contextMenu ; }
Returns an instance of the design context menu . This is a singleton with the page scope and is cached once created .
8,810
public static DesignContextMenu create ( ) { return PageUtil . createPage ( DesignConstants . RESOURCE_PREFIX + "designContextMenu.fsp" , ExecutionContext . getPage ( ) ) . get ( 0 ) . getAttribute ( "controller" , DesignContextMenu . class ) ; }
Creates an instance of the design context menu .
8,811
private void disable ( IDisable comp , boolean disabled ) { if ( comp != null ) { comp . setDisabled ( disabled ) ; if ( comp instanceof BaseUIComponent ) { ( ( BaseUIComponent ) comp ) . addStyle ( "opacity" , disabled ? ".2" : "1" ) ; } } }
Sets the disabled state of the specified component .
8,812
public static double logAdd ( double x , double y ) { if ( FastMath . useLogAddTable ) { return SmoothedLogAddTable . logAdd ( x , y ) ; } else { return FastMath . logAddExact ( x , y ) ; } }
Adds two probabilities that are stored as log probabilities .
8,813
public static int mod ( int val , int mod ) { val = val % mod ; if ( val < 0 ) { val += mod ; } return val ; }
Modulo operator where all numbers evaluate to a positive remainder .
8,814
protected void prepareXMLReader ( ) throws VerifierConfigurationException { try { SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; reader = factory . newSAXParser ( ) . getXMLReader ( ) ; } catch ( SAXException e ) { throw new VerifierConfigurationException ( e ) ; } catch ( ParserConfigurationException pce ) { throw new VerifierConfigurationException ( pce ) ; } }
Creates and sets a sole instance of XMLReader which will be used by this verifier .
8,815
private Mode makeBuiltinMode ( String name , Class cls ) { Mode mode = lookupCreateMode ( name ) ; ActionSet actions = new ActionSet ( ) ; ModeUsage modeUsage = new ModeUsage ( Mode . CURRENT , mode ) ; if ( cls == AttachAction . class ) actions . setResultAction ( new AttachAction ( modeUsage ) ) ; else if ( cls == AllowAction . class ) actions . addNoResultAction ( new AllowAction ( modeUsage ) ) ; else if ( cls == UnwrapAction . class ) actions . setResultAction ( new UnwrapAction ( modeUsage ) ) ; else actions . addNoResultAction ( new RejectAction ( modeUsage ) ) ; mode . bindElement ( NamespaceSpecification . ANY_NAMESPACE , NamespaceSpecification . DEFAULT_WILDCARD , actions ) ; mode . noteDefined ( null ) ; AttributeActionSet attributeActions = new AttributeActionSet ( ) ; if ( attributesSchema ) attributeActions . setReject ( true ) ; else attributeActions . setAttach ( true ) ; mode . bindAttribute ( NamespaceSpecification . ANY_NAMESPACE , NamespaceSpecification . DEFAULT_WILDCARD , attributeActions ) ; return mode ; }
Makes a built in mode .
8,816
SchemaFuture installHandlers ( XMLReader in , SchemaReceiverImpl sr ) { Handler h = new Handler ( sr ) ; in . setContentHandler ( h ) ; return h ; }
Installs the schema handler on the reader .
8,817
private Mode getModeAttribute ( Attributes attributes , String localName ) { return lookupCreateMode ( attributes . getValue ( "" , localName ) ) ; }
Get the mode specified by an attribute from no namespace .
8,818
private Mode lookupCreateMode ( String name ) { if ( name == null ) return null ; name = name . trim ( ) ; Mode mode = ( Mode ) modeMap . get ( name ) ; if ( mode == null ) { mode = new Mode ( name , defaultBaseMode ) ; modeMap . put ( name , mode ) ; } return mode ; }
Gets a mode with the given name from the mode map . If not present then it creates a new mode extending the default base mode .
8,819
private Date _advanceToNextDayOfWeekIfNecessary ( final Date aFireTime , final boolean forceToAdvanceNextDay ) { Date fireTime = aFireTime ; final TimeOfDay sTimeOfDay = getStartTimeOfDay ( ) ; final Date fireTimeStartDate = sTimeOfDay . getTimeOfDayForDate ( fireTime ) ; final Calendar fireTimeStartDateCal = _createCalendarTime ( fireTimeStartDate ) ; int nDayOfWeekOfFireTime = fireTimeStartDateCal . get ( Calendar . DAY_OF_WEEK ) ; final int nCalDay = nDayOfWeekOfFireTime ; DayOfWeek eDayOfWeekOfFireTime = PDTHelper . getAsDayOfWeek ( nCalDay ) ; final Set < DayOfWeek > daysOfWeekToFire = getDaysOfWeek ( ) ; if ( forceToAdvanceNextDay || ! daysOfWeekToFire . contains ( eDayOfWeekOfFireTime ) ) { for ( int i = 1 ; i <= 7 ; i ++ ) { fireTimeStartDateCal . add ( Calendar . DATE , 1 ) ; nDayOfWeekOfFireTime = fireTimeStartDateCal . get ( Calendar . DAY_OF_WEEK ) ; final int nCalDay1 = nDayOfWeekOfFireTime ; eDayOfWeekOfFireTime = PDTHelper . getAsDayOfWeek ( nCalDay1 ) ; if ( daysOfWeekToFire . contains ( eDayOfWeekOfFireTime ) ) { fireTime = fireTimeStartDateCal . getTime ( ) ; break ; } } } final Date eTime = getEndTime ( ) ; if ( eTime != null && fireTime . getTime ( ) > eTime . getTime ( ) ) { return null ; } return fireTime ; }
Given fireTime time determine if it is on a valid day of week . If so simply return it unaltered if not advance to the next valid week day and set the time of day to the start time of day
8,820
public static IScheduler getScheduler ( final boolean bStartAutomatically ) { try { final IScheduler aScheduler = s_aSchedulerFactory . getScheduler ( ) ; if ( bStartAutomatically && ! aScheduler . isStarted ( ) ) aScheduler . start ( ) ; return aScheduler ; } catch ( final SchedulerException ex ) { throw new IllegalStateException ( "Failed to create" + ( bStartAutomatically ? " and start" : "" ) + " scheduler!" , ex ) ; } }
Get the underlying Quartz scheduler
8,821
public static SchedulerMetaData getSchedulerMetaData ( ) { try { return s_aSchedulerFactory . getScheduler ( ) . getMetaData ( ) ; } catch ( final SchedulerException ex ) { throw new IllegalStateException ( "Failed to get scheduler metadata" , ex ) ; } }
Get the metadata of the scheduler . The state of the scheduler is not changed within this method .
8,822
public void setCronExpression ( final String expression ) throws ParseException { final CronExpression newExp = new CronExpression ( expression ) ; setCronExpression ( newExp ) ; }
Sets the cron expression for the calendar to a new value
8,823
public static < T extends Key < T > > GroupMatcher < T > groupEquals ( final String compareTo ) { return new GroupMatcher < > ( compareTo , StringOperatorName . EQUALS ) ; }
Create a GroupMatcher that matches groups equaling the given string .
8,824
public static < T extends Key < T > > GroupMatcher < T > groupStartsWith ( final String compareTo ) { return new GroupMatcher < > ( compareTo , StringOperatorName . STARTS_WITH ) ; }
Create a GroupMatcher that matches groups starting with the given string .
8,825
public static < T extends Key < T > > GroupMatcher < T > groupEndsWith ( final String compareTo ) { return new GroupMatcher < > ( compareTo , StringOperatorName . ENDS_WITH ) ; }
Create a GroupMatcher that matches groups ending with the given string .
8,826
public static < T extends Key < T > > GroupMatcher < T > groupContains ( final String compareTo ) { return new GroupMatcher < > ( compareTo , StringOperatorName . CONTAINS ) ; }
Create a GroupMatcher that matches groups containing the given string .
8,827
public static < U extends Key < U > > KeyMatcher < U > keyEquals ( final U compareTo ) { return new KeyMatcher < > ( compareTo ) ; }
Create a KeyMatcher that matches Keys that equal the given key .
8,828
public static < T > T instantiate ( Class < T > clazz , CRestConfig crestConfig ) throws InvocationTargetException , IllegalAccessException , InstantiationException , NoSuchMethodException { try { return accessible ( clazz . getDeclaredConstructor ( CRestConfig . class ) ) . newInstance ( crestConfig ) ; } catch ( NoSuchMethodException e ) { return accessible ( clazz . getDeclaredConstructor ( ) ) . newInstance ( ) ; } }
Instanciate the given component class passing the CRestConfig to the constructor if available otherwise uses the default empty constructor .
8,829
public Object doReverseOne ( JTransfo jTransfo , Object domainObject , SyntheticField toField , Class < ? > toType , String ... tags ) throws JTransfoException { return jTransfo . convertTo ( domainObject , jTransfo . getToSubType ( toType , domainObject ) , tags ) ; }
Do the actual reverse conversion of one object .
8,830
public void addJobChainLink ( final JobKey firstJob , final JobKey secondJob ) { ValueEnforcer . notNull ( firstJob , "FirstJob" ) ; ValueEnforcer . notNull ( firstJob . getName ( ) , "FirstJob.Name" ) ; ValueEnforcer . notNull ( secondJob , "SecondJob" ) ; ValueEnforcer . notNull ( secondJob . getName ( ) , "SecondJob.Name" ) ; m_aChainLinks . put ( firstJob , secondJob ) ; }
Add a chain mapping - when the Job identified by the first key completes the job identified by the second key will be triggered .
8,831
private void checkM ( ) throws DatatypeException , IOException { if ( context . length ( ) == 0 ) { appendToContext ( current ) ; } current = reader . read ( ) ; appendToContext ( current ) ; skipSpaces ( ) ; checkArg ( 'M' , "x coordinate" ) ; skipCommaSpaces ( ) ; checkArg ( 'M' , "y coordinate" ) ; boolean expectNumber = skipCommaSpaces2 ( ) ; _checkL ( 'M' , expectNumber ) ; }
Checks an M command .
8,832
private void checkC ( ) throws DatatypeException , IOException { if ( context . length ( ) == 0 ) { appendToContext ( current ) ; } current = reader . read ( ) ; appendToContext ( current ) ; skipSpaces ( ) ; boolean expectNumber = true ; for ( ; ; ) { switch ( current ) { default : if ( expectNumber ) reportNonNumber ( 'C' , current ) ; return ; case '+' : case '-' : case '.' : case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : break ; } checkArg ( 'C' , "x1 coordinate" ) ; skipCommaSpaces ( ) ; checkArg ( 'C' , "y1 coordinate" ) ; skipCommaSpaces ( ) ; checkArg ( 'C' , "x2 coordinate" ) ; skipCommaSpaces ( ) ; checkArg ( 'C' , "y2 coordinate" ) ; skipCommaSpaces ( ) ; checkArg ( 'C' , "x coordinate" ) ; skipCommaSpaces ( ) ; checkArg ( 'C' , "y coordinate" ) ; expectNumber = skipCommaSpaces2 ( ) ; } }
Checks a C command .
8,833
public boolean before ( final TimeOfDay timeOfDay ) { if ( timeOfDay . m_nHour > m_nHour ) return true ; if ( timeOfDay . m_nHour < m_nHour ) return false ; if ( timeOfDay . m_nMinute > m_nMinute ) return true ; if ( timeOfDay . m_nMinute < m_nMinute ) return false ; if ( timeOfDay . m_nSecond > m_nSecond ) return true ; if ( timeOfDay . m_nSecond < m_nSecond ) return false ; return false ; }
Determine with this time of day is before the given time of day .
8,834
public Date getTimeOfDayForDate ( final Date dateTime ) { if ( dateTime == null ) return null ; final Calendar cal = PDTFactory . createCalendar ( ) ; cal . setTime ( dateTime ) ; cal . set ( Calendar . HOUR_OF_DAY , m_nHour ) ; cal . set ( Calendar . MINUTE , m_nMinute ) ; cal . set ( Calendar . SECOND , m_nSecond ) ; cal . clear ( Calendar . MILLISECOND ) ; return cal . getTime ( ) ; }
Return a date with time of day reset to this object values . The millisecond value will be zero .
8,835
public Document parse ( InputSource inputsource ) throws SAXException , IOException { return verify ( _WrappedBuilder . parse ( inputsource ) ) ; }
Parses the given InputSource and validates the resulting DOM .
8,836
public Document parse ( File file ) throws SAXException , IOException { return verify ( _WrappedBuilder . parse ( file ) ) ; }
Parses the given File and validates the resulting DOM .
8,837
public Document parse ( InputStream strm ) throws SAXException , IOException { return verify ( _WrappedBuilder . parse ( strm ) ) ; }
Parses the given InputStream and validates the resulting DOM .
8,838
public Document parse ( String url ) throws SAXException , IOException { return verify ( _WrappedBuilder . parse ( url ) ) ; }
Parses the given url and validates the resulting DOM .
8,839
private int convertNonNegativeInteger ( String str ) { str = str . trim ( ) ; DecimalDatatype decimal = new DecimalDatatype ( ) ; if ( ! decimal . lexicallyAllows ( str ) ) return - 1 ; str = decimal . getValue ( str , null ) . toString ( ) ; if ( str . charAt ( 0 ) == '-' || str . indexOf ( '.' ) >= 0 ) return - 1 ; try { return Integer . parseInt ( str ) ; } catch ( NumberFormatException e ) { return Integer . MAX_VALUE ; } }
Return Integer . MAX_VALUE for values that are too big
8,840
private void checkItem ( Element root , Deque < Element > parents ) throws SAXException { Deque < Element > pending = new ArrayDeque < Element > ( ) ; Set < Element > memory = new HashSet < Element > ( ) ; memory . add ( root ) ; for ( Element child : root . children ) { pending . push ( child ) ; } if ( root . itemRef != null ) { for ( String id : root . itemRef ) { Element refElm = idmap . get ( id ) ; if ( refElm != null ) { pending . push ( refElm ) ; } else { err ( "The \u201Citemref\u201D attribute referenced \u201C" + id + "\u201D, but there is no element with an \u201Cid\u201D attribute with that value." , root . locator ) ; } } } boolean memoryError = false ; while ( pending . size ( ) > 0 ) { Element current = pending . pop ( ) ; if ( memory . contains ( current ) ) { memoryError = true ; continue ; } memory . add ( current ) ; if ( ! current . itemScope ) { for ( Element child : current . children ) { pending . push ( child ) ; } } if ( current . itemProp != null ) { properties . remove ( current ) ; if ( current . itemScope ) { if ( ! parents . contains ( current ) ) { parents . push ( root ) ; checkItem ( current , parents ) ; parents . pop ( ) ; } else { err ( "The \u201Citemref\u201D attribute created a circular reference with another item." , current . locator ) ; } } } } if ( memoryError ) { err ( "The \u201Citemref\u201D attribute contained redundant references." , root . locator ) ; } }
Check itemref constraints .
8,841
public static < T > ContractCondition < T > condition ( final Predicate < T > condition , final Function < T , String > describer ) { return ContractCondition . of ( condition , describer ) ; }
Construct a predicate from the given predicate function and describer .
8,842
static int compare ( final Date nextFireTime1 , final int priority1 , final TriggerKey key1 , final Date nextFireTime2 , final int priority2 , final TriggerKey key2 ) { if ( nextFireTime1 != null || nextFireTime2 != null ) { if ( nextFireTime1 == null ) return 1 ; if ( nextFireTime2 == null ) return - 1 ; if ( nextFireTime1 . before ( nextFireTime2 ) ) return - 1 ; if ( nextFireTime1 . after ( nextFireTime2 ) ) return 1 ; } int comp = priority2 - priority1 ; if ( comp == 0 ) comp = key1 . compareTo ( key2 ) ; return comp ; }
This static method exists for comparator in TC clustered quartz
8,843
public List < Connector > getSipConnectors ( ) { List < Connector > connectors = new ArrayList < Connector > ( ) ; Connector [ ] conns = service . findConnectors ( ) ; for ( Connector conn : conns ) { if ( conn . getProtocolHandler ( ) instanceof SipProtocolHandler ) { connectors . add ( conn ) ; } } return connectors ; }
Return the SipConnectors
8,844
void perform ( SectionState state ) throws SAXException { final ModeUsage modeUsage = getModeUsage ( ) ; state . reject ( ) ; state . addChildMode ( modeUsage , null ) ; state . addAttributeValidationModeUsage ( modeUsage ) ; }
Perform this action on the session state .
8,845
public Object getAttribute ( String key ) { Object result ; if ( attributes == null ) { result = null ; } else { result = attributes . get ( key ) ; } return result ; }
Gets an attribute attached to a call . Attributes are arbitrary contextual objects attached to a call .
8,846
private int reverseIndex ( int k ) { if ( reverseIndexMap == null ) { reverseIndexMap = new int [ attributes . getLength ( ) ] ; for ( int i = 0 , len = indexSet . size ( ) ; i < len ; i ++ ) reverseIndexMap [ indexSet . get ( i ) ] = i + 1 ; } return reverseIndexMap [ k ] - 1 ; }
Gets the index in the filtered set for a given real index . If the reverseIndexMap is not computed it computes it otherwise it just uses the previously computed map .
8,847
public String getURI ( int index ) { if ( index < 0 || index >= indexSet . size ( ) ) return null ; return attributes . getURI ( indexSet . get ( index ) ) ; }
Get the URI for the index - th attribute .
8,848
public String getLocalName ( int index ) { if ( index < 0 || index >= indexSet . size ( ) ) return null ; return attributes . getLocalName ( indexSet . get ( index ) ) ; }
Get the local name for the index - th attribute .
8,849
public String getQName ( int index ) { if ( index < 0 || index >= indexSet . size ( ) ) return null ; return attributes . getQName ( indexSet . get ( index ) ) ; }
Get the QName for the index - th attribute .
8,850
public String getType ( int index ) { if ( index < 0 || index >= indexSet . size ( ) ) return null ; return attributes . getType ( indexSet . get ( index ) ) ; }
Get the type for the index - th attribute .
8,851
public String getValue ( int index ) { if ( index < 0 || index >= indexSet . size ( ) ) return null ; return attributes . getValue ( indexSet . get ( index ) ) ; }
Get the value for the index - th attribute .
8,852
public String getType ( String uri , String localName ) { return attributes . getType ( getRealIndex ( uri , localName ) ) ; }
Get the type of the attribute .
8,853
public String getValue ( String uri , String localName ) { return attributes . getValue ( getRealIndex ( uri , localName ) ) ; }
Get the value of the attribute .
8,854
void perform ( SectionState state ) { state . addChildMode ( getModeUsage ( ) , null ) ; state . addAttributeValidationModeUsage ( getModeUsage ( ) ) ; }
Perform this action on the section state .
8,855
public CalendarIntervalScheduleBuilder withIntervalInSeconds ( final int intervalInSeconds ) { _validateInterval ( intervalInSeconds ) ; m_nInterval = intervalInSeconds ; m_eIntervalUnit = EIntervalUnit . SECOND ; return this ; }
Specify an interval in the IntervalUnit . SECOND that the produced Trigger will repeat at .
8,856
public CalendarIntervalScheduleBuilder withIntervalInMinutes ( final int intervalInMinutes ) { _validateInterval ( intervalInMinutes ) ; m_nInterval = intervalInMinutes ; m_eIntervalUnit = EIntervalUnit . MINUTE ; return this ; }
Specify an interval in the IntervalUnit . MINUTE that the produced Trigger will repeat at .
8,857
public CalendarIntervalScheduleBuilder withIntervalInHours ( final int intervalInHours ) { _validateInterval ( intervalInHours ) ; m_nInterval = intervalInHours ; m_eIntervalUnit = EIntervalUnit . HOUR ; return this ; }
Specify an interval in the IntervalUnit . HOUR that the produced Trigger will repeat at .
8,858
public CalendarIntervalScheduleBuilder withIntervalInDays ( final int intervalInDays ) { _validateInterval ( intervalInDays ) ; m_nInterval = intervalInDays ; m_eIntervalUnit = EIntervalUnit . DAY ; return this ; }
Specify an interval in the IntervalUnit . DAY that the produced Trigger will repeat at .
8,859
public CalendarIntervalScheduleBuilder withIntervalInWeeks ( final int intervalInWeeks ) { _validateInterval ( intervalInWeeks ) ; m_nInterval = intervalInWeeks ; m_eIntervalUnit = EIntervalUnit . WEEK ; return this ; }
Specify an interval in the IntervalUnit . WEEK that the produced Trigger will repeat at .
8,860
public CalendarIntervalScheduleBuilder withIntervalInMonths ( final int intervalInMonths ) { _validateInterval ( intervalInMonths ) ; m_nInterval = intervalInMonths ; m_eIntervalUnit = EIntervalUnit . MONTH ; return this ; }
Specify an interval in the IntervalUnit . MONTH that the produced Trigger will repeat at .
8,861
public CalendarIntervalScheduleBuilder withIntervalInYears ( final int intervalInYears ) { _validateInterval ( intervalInYears ) ; m_nInterval = intervalInYears ; m_eIntervalUnit = EIntervalUnit . YEAR ; return this ; }
Specify an interval in the IntervalUnit . YEAR that the produced Trigger will repeat at .
8,862
static int checkResult ( int result ) { if ( exceptionsEnabled && result != cusolverStatus . CUSOLVER_STATUS_SUCCESS ) { throw new CudaException ( cusolverStatus . stringFor ( result ) ) ; } return result ; }
If the given result is not cusolverStatus . CUSOLVER_STATUS_SUCCESS and exceptions have been enabled this method will throw a CudaException with an error message that corresponds to the given result code . Otherwise the given result is simply returned .
8,863
public NonBlockingProperties getPropertyGroup ( final String sPrefix , final boolean bStripPrefix , final String [ ] excludedPrefixes ) { final NonBlockingProperties group = new NonBlockingProperties ( ) ; String prefix = sPrefix ; if ( ! prefix . endsWith ( "." ) ) prefix += "." ; for ( final String key : m_aProps . keySet ( ) ) { if ( key . startsWith ( prefix ) ) { boolean bExclude = false ; if ( excludedPrefixes != null ) { for ( int i = 0 ; i < excludedPrefixes . length && ! bExclude ; i ++ ) { bExclude = key . startsWith ( excludedPrefixes [ i ] ) ; } } if ( ! bExclude ) { final String value = getStringProperty ( key , "" ) ; if ( bStripPrefix ) group . put ( key . substring ( prefix . length ( ) ) , value ) ; else group . put ( key , value ) ; } } } return group ; }
Get all properties that start with the given prefix .
8,864
public void partialDeserialize ( TBase < ? , ? > base , DBObject dbObject , TFieldIdEnum ... fieldIds ) throws TException { try { protocol_ . setDBOject ( dbObject ) ; protocol_ . setBaseObject ( base ) ; protocol_ . setFieldIdsFilter ( base , fieldIds ) ; base . read ( protocol_ ) ; } finally { protocol_ . reset ( ) ; } }
Deserialize only a single Thrift object from a byte record .
8,865
public Verifier newVerifier ( String uri ) throws VerifierConfigurationException , SAXException , IOException { return compileSchema ( uri ) . newVerifier ( ) ; }
parses a schema at the specified location and returns a Verifier object that validates documents by using that schema .
8,866
public Verifier newVerifier ( File file ) throws VerifierConfigurationException , SAXException , IOException { return compileSchema ( file ) . newVerifier ( ) ; }
parses a schema from the specified file and returns a Verifier object that validates documents by using that schema .
8,867
public Verifier newVerifier ( InputSource source ) throws VerifierConfigurationException , SAXException , IOException { return compileSchema ( source ) . newVerifier ( ) ; }
parses a schema from the specified InputSource and returns a Verifier object that validates documents by using that schema .
8,868
public static VerifierFactory newInstance ( String language , ClassLoader classLoader ) throws VerifierConfigurationException { Iterator itr = providers ( VerifierFactoryLoader . class , classLoader ) ; while ( itr . hasNext ( ) ) { VerifierFactoryLoader loader = ( VerifierFactoryLoader ) itr . next ( ) ; try { VerifierFactory factory = loader . createFactory ( language ) ; if ( factory != null ) return factory ; } catch ( Throwable t ) { } } throw new VerifierConfigurationException ( "no validation engine available for: " + language ) ; }
Creates a new instance of a VerifierFactory for the specified schema language .
8,869
public void deleteUnpackedWAR ( StandardContext standardContext ) { File unpackDir = new File ( standardHost . getAppBase ( ) , standardContext . getPath ( ) . substring ( 1 ) ) ; if ( unpackDir . exists ( ) ) { ExpandWar . deleteDir ( unpackDir ) ; } }
Make sure an the unpacked WAR is not left behind you would think Tomcat would cleanup an unpacked WAR but it doesn t
8,870
public boolean sameValue ( Object value1 , Object value2 ) { return ( ( BigDecimal ) value1 ) . compareTo ( ( BigDecimal ) value2 ) == 0 ; }
BigDecimal . equals considers objects distinct if they have the different scales but the same mathematical value . Similarly for hashCode .
8,871
public void addSchema ( String uri , IslandSchema s ) { if ( schemata . containsKey ( uri ) ) throw new IllegalArgumentException ( ) ; schemata . put ( uri , s ) ; }
adds a new IslandSchema .
8,872
public String generateNonce ( ) { Date date = new Date ( ) ; long time = date . getTime ( ) ; Random rand = new Random ( ) ; long pad = rand . nextLong ( ) ; String nonceString = ( Long . valueOf ( time ) ) . toString ( ) + ( Long . valueOf ( pad ) ) . toString ( ) ; byte mdbytes [ ] = messageDigest . digest ( nonceString . getBytes ( ) ) ; return toHexString ( mdbytes ) ; }
Generate the challenge string .
8,873
public static String formatException ( final Exception e ) { final StringBuilder sb = new StringBuilder ( ) ; Throwable t = e ; while ( t != null ) { sb . append ( t . getMessage ( ) ) . append ( "\n" ) ; t = t . getCause ( ) ; } return sb . toString ( ) ; }
Formats the given exception in a multiline error message with all causes .
8,874
public DailyTimeIntervalScheduleBuilder onDaysOfTheWeek ( final Set < DayOfWeek > onDaysOfWeek ) { ValueEnforcer . notEmpty ( onDaysOfWeek , "OnDaysOfWeek" ) ; m_aDaysOfWeek = onDaysOfWeek ; return this ; }
Set the trigger to fire on the given days of the week .
8,875
public DailyTimeIntervalScheduleBuilder endingDailyAfterCount ( final int count ) { ValueEnforcer . isGT0 ( count , "Count" ) ; if ( m_aStartTimeOfDay == null ) throw new IllegalArgumentException ( "You must set the startDailyAt() before calling this endingDailyAfterCount()!" ) ; final Date today = new Date ( ) ; final Date startTimeOfDayDate = m_aStartTimeOfDay . getTimeOfDayForDate ( today ) ; final Date maxEndTimeOfDayDate = TimeOfDay . hourMinuteAndSecondOfDay ( 23 , 59 , 59 ) . getTimeOfDayForDate ( today ) ; final long remainingMillisInDay = maxEndTimeOfDayDate . getTime ( ) - startTimeOfDayDate . getTime ( ) ; long intervalInMillis ; if ( m_eIntervalUnit == EIntervalUnit . SECOND ) intervalInMillis = m_nInterval * CGlobal . MILLISECONDS_PER_SECOND ; else if ( m_eIntervalUnit == EIntervalUnit . MINUTE ) intervalInMillis = m_nInterval * CGlobal . MILLISECONDS_PER_MINUTE ; else if ( m_eIntervalUnit == EIntervalUnit . HOUR ) intervalInMillis = m_nInterval * DateBuilder . MILLISECONDS_IN_DAY ; else throw new IllegalArgumentException ( "The IntervalUnit: " + m_eIntervalUnit + " is invalid for this trigger." ) ; if ( remainingMillisInDay - intervalInMillis <= 0 ) throw new IllegalArgumentException ( "The startTimeOfDay is too late with given Interval and IntervalUnit values." ) ; final long maxNumOfCount = ( remainingMillisInDay / intervalInMillis ) ; if ( count > maxNumOfCount ) throw new IllegalArgumentException ( "The given count " + count + " is too large! The max you can set is " + maxNumOfCount ) ; final long incrementInMillis = ( count - 1 ) * intervalInMillis ; final Date endTimeOfDayDate = new Date ( startTimeOfDayDate . getTime ( ) + incrementInMillis ) ; if ( endTimeOfDayDate . getTime ( ) > maxEndTimeOfDayDate . getTime ( ) ) throw new IllegalArgumentException ( "The given count " + count + " is too large! The max you can set is " + maxNumOfCount ) ; final Calendar cal = PDTFactory . createCalendar ( ) ; cal . setTime ( endTimeOfDayDate ) ; final int hour = cal . get ( Calendar . HOUR_OF_DAY ) ; final int minute = cal . get ( Calendar . MINUTE ) ; final int second = cal . get ( Calendar . SECOND ) ; m_aEndTimeOfDay = TimeOfDay . hourMinuteAndSecondOfDay ( hour , minute , second ) ; return this ; }
Calculate and set the endTimeOfDay using count interval and starTimeOfDay . This means that these must be set before this method is call .
8,876
protected void onValidMarkup ( AppendingStringBuffer responseBuffer , ValidationReport report ) { IRequestablePage responsePage = getResponsePage ( ) ; DocType doctype = getDocType ( responseBuffer ) ; log . info ( "Markup for {} is valid {}" , responsePage != null ? responsePage . getClass ( ) . getName ( ) : "<unable to determine page class>" , doctype . name ( ) ) ; String head = report . getHeadMarkup ( ) ; String body = report . getBodyMarkup ( ) ; int indexOfHeadClose = responseBuffer . lastIndexOf ( "</head>" ) ; responseBuffer . insert ( indexOfHeadClose , head ) ; int indexOfBodyClose = responseBuffer . lastIndexOf ( "</body>" ) ; responseBuffer . insert ( indexOfBodyClose , body ) ; }
Called when the validated markup does not contain any errors .
8,877
protected void onInvalidMarkup ( AppendingStringBuffer responseBuffer , ValidationReport report ) { String head = report . getHeadMarkup ( ) ; String body = report . getBodyMarkup ( ) ; int indexOfHeadClose = responseBuffer . lastIndexOf ( "</head>" ) ; responseBuffer . insert ( indexOfHeadClose , head ) ; int indexOfBodyClose = responseBuffer . lastIndexOf ( "</body>" ) ; responseBuffer . insert ( indexOfBodyClose , body ) ; }
Called when the validated markup contains errors .
8,878
< T > Class < T > loadClass ( String name ) throws ClassNotFoundException { ClassLoader cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( null == cl ) { cl = ToHelper . class . getClassLoader ( ) ; } return ( Class < T > ) cl . loadClass ( name ) ; }
Load class with given name from the correct class loader .
8,879
List < Field > getFields ( Class < ? > clazz ) { List < Field > result = new ArrayList < > ( ) ; Set < String > fieldNames = new HashSet < > ( ) ; Class < ? > searchType = clazz ; while ( ! Object . class . equals ( searchType ) && searchType != null ) { Field [ ] fields = searchType . getDeclaredFields ( ) ; for ( Field field : fields ) { if ( ! fieldNames . contains ( field . getName ( ) ) ) { fieldNames . add ( field . getName ( ) ) ; makeAccessible ( field ) ; result . add ( field ) ; } } searchType = searchType . getSuperclass ( ) ; } return result ; }
Find all declared fields of a class . Fields which are hidden by a child class are not included .
8,880
Method getMethod ( Class < ? > type , Class < ? > returnType , String name , Class < ? > ... parameters ) { Method method = null ; try { method = type . getMethod ( name , parameters ) ; if ( null != returnType && ! returnType . isAssignableFrom ( method . getReturnType ( ) ) ) { method = null ; } } catch ( NoSuchMethodException nsme ) { log . trace ( nsme . getMessage ( ) , nsme ) ; } if ( null == method ) { method = getNonPublicMethod ( type , returnType , name , parameters ) ; } return method ; }
Get method with given name and parameters and given return type .
8,881
protected static void triggerCustomExceptionHandler ( final Throwable t , final String sJobClassName , final IJob aJob ) { exceptionCallbacks ( ) . forEach ( x -> x . onScheduledJobException ( t , sJobClassName , aJob ) ) ; }
Called when an exception of the specified type occurred
8,882
public static Response toResponse ( Response . Status status , String wwwAuthHeader ) { Response . ResponseBuilder rb = Response . status ( status ) ; if ( wwwAuthHeader != null ) { rb . header ( "WWW-Authenticate" , wwwAuthHeader ) ; } return rb . build ( ) ; }
Maps this exception to a response object .
8,883
public void execute ( final FifoTask < E > task ) throws InterruptedException { final int id ; synchronized ( this ) { id = idCounter ++ ; taskMap . put ( id , task ) ; while ( activeCounter >= maxThreads ) { wait ( ) ; } activeCounter ++ ; } this . threadPoolExecutor . execute ( new Runnable ( ) { public void run ( ) { try { try { final E outcome = task . runParallel ( ) ; synchronized ( resultMap ) { resultMap . put ( id , new Result ( outcome ) ) ; } } catch ( Throwable th ) { synchronized ( resultMap ) { resultMap . put ( id , new Result ( null , th ) ) ; } } finally { processResults ( ) ; synchronized ( FifoTaskExecutor . this ) { activeCounter -- ; FifoTaskExecutor . this . notifyAll ( ) ; } } } catch ( Exception ex ) { Logger . getLogger ( FifoTaskExecutor . class . getName ( ) ) . log ( Level . SEVERE , ex . getMessage ( ) , ex ) ; } } } ) ; }
Executes the submitted task . If the maximum number of pooled threads is in use this method blocks until one of a them is available .
8,884
public static String executeProcess ( Map < String , String > env , File workingFolder , String ... command ) throws ProcessException , InterruptedException { ProcessBuilder pb = new ProcessBuilder ( command ) ; if ( workingFolder != null ) { pb . directory ( workingFolder ) ; } if ( env != null ) { pb . environment ( ) . clear ( ) ; pb . environment ( ) . putAll ( env ) ; } pb . redirectErrorStream ( true ) ; int code ; try { Process process = pb . start ( ) ; String payload ; try { code = process . waitFor ( ) ; } catch ( InterruptedException ex ) { process . destroy ( ) ; throw ex ; } payload = Miscellaneous . toString ( process . getInputStream ( ) , "UTF-8" ) ; if ( code == 0 ) { return payload ; } else { StringBuilder sb = new StringBuilder ( "Process returned code: " + code + "." ) ; if ( payload != null ) { sb . append ( "\n" ) . append ( payload ) ; } throw new ProcessException ( code , sb . toString ( ) ) ; } } catch ( IOException ex ) { throw new RuntimeException ( ex ) ; } }
Executes a native process with small stdout and stderr payloads
8,885
public static int cusolverRfGetMatrixFormat ( cusolverRfHandle handle , int [ ] format , int [ ] diag ) { return checkResult ( cusolverRfGetMatrixFormatNative ( handle , format , diag ) ) ; }
CUSOLVERRF set and get input format
8,886
public static int cusolverRfSetNumericProperties ( cusolverRfHandle handle , double zero , double boost ) { return checkResult ( cusolverRfSetNumericPropertiesNative ( handle , zero , boost ) ) ; }
CUSOLVERRF set and get numeric properties
8,887
public static int cusolverRfSetAlgs ( cusolverRfHandle handle , int factAlg , int solveAlg ) { return checkResult ( cusolverRfSetAlgsNative ( handle , factAlg , solveAlg ) ) ; }
CUSOLVERRF choose the triangular solve algorithm
8,888
public static int cusolverRfSetupHost ( int n , int nnzA , Pointer h_csrRowPtrA , Pointer h_csrColIndA , Pointer h_csrValA , int nnzL , Pointer h_csrRowPtrL , Pointer h_csrColIndL , Pointer h_csrValL , int nnzU , Pointer h_csrRowPtrU , Pointer h_csrColIndU , Pointer h_csrValU , Pointer h_P , Pointer h_Q , cusolverRfHandle handle ) { return checkResult ( cusolverRfSetupHostNative ( n , nnzA , h_csrRowPtrA , h_csrColIndA , h_csrValA , nnzL , h_csrRowPtrL , h_csrColIndL , h_csrValL , nnzU , h_csrRowPtrU , h_csrColIndU , h_csrValU , h_P , h_Q , handle ) ) ; }
CUSOLVERRF setup of internal structures from host or device memory
8,889
public static int cusolverRfBatchSetupHost ( int batchSize , int n , int nnzA , Pointer h_csrRowPtrA , Pointer h_csrColIndA , Pointer h_csrValA_array , int nnzL , Pointer h_csrRowPtrL , Pointer h_csrColIndL , Pointer h_csrValL , int nnzU , Pointer h_csrRowPtrU , Pointer h_csrColIndU , Pointer h_csrValU , Pointer h_P , Pointer h_Q , cusolverRfHandle handle ) { return checkResult ( cusolverRfBatchSetupHostNative ( batchSize , n , nnzA , h_csrRowPtrA , h_csrColIndA , h_csrValA_array , nnzL , h_csrRowPtrL , h_csrColIndL , h_csrValL , nnzU , h_csrRowPtrU , h_csrColIndU , h_csrValU , h_P , h_Q , handle ) ) ; }
CUSOLVERRF - batch setup of internal structures from host
8,890
public static RegexPathTemplate create ( String urlTemplate ) { StringBuffer baseUrl = new StringBuffer ( ) ; Map < String , PathTemplate > templates = new HashMap < String , PathTemplate > ( ) ; CurlyBraceTokenizer t = new CurlyBraceTokenizer ( urlTemplate ) ; while ( t . hasNext ( ) ) { String tok = t . next ( ) ; if ( CurlyBraceTokenizer . insideBraces ( tok ) ) { tok = CurlyBraceTokenizer . stripBraces ( tok ) ; int index = tok . indexOf ( ':' ) ; String name ; Pattern validationPattern ; if ( index > - 1 ) { name = tok . substring ( 0 , index ) ; validationPattern = Pattern . compile ( "^" + tok . substring ( index + 1 ) + "$" ) ; } else { name = tok ; validationPattern = DEFAULT_VALIDATION_PATTERN ; } Validate . isTrue ( TEMPLATE_NAME_PATTERN . matcher ( name ) . matches ( ) , "Template name '%s' doesn't match the expected format: %s" , name , TEMPLATE_NAME_PATTERN ) ; Validate . isFalse ( templates . containsKey ( name ) , "Template name '%s' is already defined!" , name ) ; templates . put ( name , new PathTemplate ( name , validationPattern ) ) ; baseUrl . append ( "{" ) . append ( name ) . append ( "}" ) ; } else { baseUrl . append ( tok ) ; } } String url = baseUrl . toString ( ) ; isTrue ( ! Urls . hasQueryString ( url ) , "Given url contains a query string: %s" , url ) ; return new RegexPathTemplate ( url , templates ) ; }
Creates a regex path template for the given URI template
8,891
public void addValidator ( Schema schema , ModeUsage modeUsage ) { schemas . addElement ( schema ) ; Validator validator = createValidator ( schema ) ; validators . addElement ( validator ) ; activeHandlers . addElement ( validator . getContentHandler ( ) ) ; activeHandlersAttributeModeUsage . addElement ( modeUsage ) ; attributeProcessing = Math . max ( attributeProcessing , modeUsage . getAttributeProcessing ( ) ) ; childPrograms . addElement ( new Program ( modeUsage , validator . getContentHandler ( ) ) ) ; if ( modeUsage . isContextDependent ( ) ) contextDependent = true ; }
Adds a validator .
8,892
public static void writeStringToFile ( File file , String data , String charset ) throws IOException { FileOutputStream fos = openOutputStream ( file , false ) ; fos . write ( data . getBytes ( charset ) ) ; fos . close ( ) ; }
Writes a String to a file creating the file if it does not exist .
8,893
public static Thread pipeAsynchronously ( final InputStream is , final ErrorHandler errorHandler , final boolean closeResources , final OutputStream ... os ) { Thread t = new Thread ( ) { public void run ( ) { try { pipeSynchronously ( is , closeResources , os ) ; } catch ( Throwable th ) { if ( errorHandler != null ) { errorHandler . onThrowable ( th ) ; } } } } ; t . setDaemon ( true ) ; t . start ( ) ; return t ; }
Asynchronous writing from is to os
8,894
public static File createFile ( String filePath ) throws IOException { boolean isDirectory = filePath . endsWith ( "/" ) || filePath . endsWith ( "\\" ) ; String formattedFilePath = formatFilePath ( filePath ) ; File f = new File ( formattedFilePath ) ; if ( f . exists ( ) ) { return f ; } if ( isDirectory ) { f . mkdirs ( ) ; } else { f . getParentFile ( ) . mkdirs ( ) ; f . createNewFile ( ) ; } if ( f . exists ( ) ) { f . setExecutable ( true , false ) ; f . setReadable ( true , false ) ; f . setWritable ( true , false ) ; return f ; } throw new IOException ( "Error creating file: " + f . getAbsolutePath ( ) ) ; }
Creates a file in the specified path . Creates also any necessary folder needed to achieve the file level of nesting .
8,895
public boolean compete ( NamespaceSpecification other ) { if ( "" . equals ( other . wildcard ) ) { return covers ( other . ns ) ; } String [ ] otherParts = split ( other . ns , other . wildcard ) ; if ( otherParts . length == 1 ) { return covers ( other . ns ) ; } if ( "" . equals ( wildcard ) ) { return other . covers ( ns ) ; } String [ ] parts = split ( ns , wildcard ) ; if ( parts . length == 1 ) { return other . covers ( ns ) ; } return matchPrefix ( parts [ 0 ] , otherParts [ 0 ] ) && matchPrefix ( parts [ parts . length - 1 ] , otherParts [ otherParts . length - 1 ] ) ; }
Check if this namespace specification competes with another namespace specification .
8,896
static private boolean matchPrefix ( String s1 , String s2 ) { return s1 . startsWith ( s2 ) || s2 . startsWith ( s1 ) ; }
Checks with either of the strings starts with the other .
8,897
public boolean covers ( String uri ) { if ( ANY_NAMESPACE . equals ( ns ) || "" . equals ( wildcard ) ) { return ns . equals ( uri ) ; } String [ ] parts = split ( ns , wildcard ) ; if ( parts . length == 1 ) { return ns . equals ( uri ) ; } if ( ! uri . startsWith ( parts [ 0 ] ) ) { return false ; } if ( ! uri . endsWith ( parts [ parts . length - 1 ] ) ) { return false ; } int start = parts [ 0 ] . length ( ) ; int end = uri . length ( ) - parts [ parts . length - 1 ] . length ( ) ; for ( int i = 1 ; i < parts . length - 1 ; i ++ ) { if ( start > end ) { return false ; } int match = uri . indexOf ( parts [ i ] , start ) ; if ( match == - 1 || match + parts [ i ] . length ( ) > end ) { return false ; } start = match + parts [ i ] . length ( ) ; } return true ; }
Checks if a namespace specification covers a specified URI . any namespace pattern covers only the any namespace uri .
8,898
public void reloadContext ( ) throws DeploymentException { Archive < ? > archive = mssContainer . getArchive ( ) ; deployableContainer . undeploy ( archive ) ; deployableContainer . deploy ( archive ) ; }
Context related methods
8,899
private Mode resolve ( Mode mode ) { if ( mode == Mode . CURRENT ) { return currentMode ; } if ( mode . isAnonymous ( ) && ! mode . isDefined ( ) ) { return currentMode ; } return mode ; }
Resolves the Mode . CURRENT to the currentMode for this mode usage . If Mode . CURRENT is not passed as argument then the same mode is returned with the exception of an anonymous mode that is not defined when we get also the current mode .