idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
18,300 | protected void fire ( ActionRuntime runtime ) throws IOException , ServletException { final ActionResponseReflector reflector = createResponseReflector ( runtime ) ; ready ( runtime , reflector ) ; final OptionalThing < VirtualForm > form = prepareActionForm ( runtime ) ; populateParameter ( runtime , form ) ; final VirtualAction action = createAction ( runtime , reflector ) ; final NextJourney journey = performAction ( action , form , runtime ) ; toNext ( runtime , journey ) ; } | Fire the action creating populating performing and to next . |
18,301 | protected GsonJsonEngine createGsonJsonEngine ( JsonEngineResource resource ) { final boolean serializeNulls = isGsonSerializeNulls ( ) ; final boolean prettyPrinting = isGsonPrettyPrinting ( ) ; final Consumer < GsonBuilder > builderSetupper = prepareGsonBuilderSetupper ( serializeNulls , prettyPrinting ) ; final Consumer < JsonMappingOption > optionSetupper = prepareMappingOptionSetupper ( resource . getMappingOption ( ) ) ; return resource . getYourEngineCreator ( ) . map ( creator -> { return createYourEngine ( creator , builderSetupper , optionSetupper ) ; } ) . orElseGet ( ( ) -> { return newGsonJsonEngine ( builderSetupper , optionSetupper ) ; } ) ; } | mappingOption is specified for another engine |
18,302 | public static BegunTx < ? > getBegunTxOnThread ( ) { final Stack < BegunTx < ? > > stack = threadLocal . get ( ) ; return stack != null ? stack . peek ( ) : null ; } | Get prepared begun - tx on thread . |
18,303 | public static void setBegunTxOnThread ( BegunTx < ? > begunTx ) { if ( begunTx == null ) { String msg = "The argument[begunTx] must not be null." ; throw new IllegalArgumentException ( msg ) ; } Stack < BegunTx < ? > > stack = threadLocal . get ( ) ; if ( stack == null ) { stack = new Stack < BegunTx < ? > > ( ) ; threadLocal . set ( stack ) ; } stack . add ( begunTx ) ; } | Set prepared begun - tx on thread . |
18,304 | public static boolean existsBegunTxOnThread ( ) { final Stack < BegunTx < ? > > stack = threadLocal . get ( ) ; return stack != null ? ! stack . isEmpty ( ) : false ; } | Is existing prepared begun - tx on thread? |
18,305 | public static void clearBegunTxOnThread ( ) { final Stack < BegunTx < ? > > stack = threadLocal . get ( ) ; if ( stack != null ) { stack . pop ( ) ; if ( stack . isEmpty ( ) ) { perfectlyClear ( ) ; } } } | Clear prepared begun - tx on thread . |
18,306 | public static RomanticTransaction getRomanticTransaction ( ) { final Stack < RomanticTransaction > stack = threadLocal . get ( ) ; return stack != null ? stack . peek ( ) : null ; } | Get the value of the romantic transaction . |
18,307 | public static void setRomanticTransaction ( RomanticTransaction romanticTransaction ) { if ( romanticTransaction == null ) { String msg = "The argument 'romanticTransaction' should not be null." ; throw new IllegalArgumentException ( msg ) ; } Stack < RomanticTransaction > stack = threadLocal . get ( ) ; if ( stack == null ) { stack = new Stack < RomanticTransaction > ( ) ; threadLocal . set ( stack ) ; } stack . push ( romanticTransaction ) ; } | Set the value of the romantic transaction . |
18,308 | private boolean visitColumnsAndColumnFacets ( VisitContext context , VisitCallback callback , boolean visitRows ) { if ( visitRows ) { setRowIndex ( - 1 ) ; } if ( getChildCount ( ) > 0 ) { for ( UIComponent column : getChildren ( ) ) { if ( column instanceof UIColumn ) { VisitResult result = context . invokeVisitCallback ( column , callback ) ; if ( result == VisitResult . COMPLETE ) { return true ; } if ( column . getFacetCount ( ) > 0 ) { for ( UIComponent columnFacet : column . getFacets ( ) . values ( ) ) { if ( columnFacet . visitTree ( context , callback ) ) { return true ; } } } } } } return false ; } | Visit each UIColumn and any facets it may have defined exactly once |
18,309 | private boolean visitRows ( VisitContext context , VisitCallback callback , boolean visitRows ) { int processed = 0 ; int rowIndex = 0 ; int rows = 0 ; if ( visitRows ) { rowIndex = getFirst ( ) - 1 ; rows = getRows ( ) ; } while ( true ) { if ( visitRows ) { if ( ( rows > 0 ) && ( ++ processed > rows ) ) { break ; } setRowIndex ( ++ rowIndex ) ; if ( ! isRowAvailable ( ) ) { break ; } } if ( getChildCount ( ) > 0 ) { for ( UIComponent kid : getChildren ( ) ) { if ( ! ( kid instanceof UIColumn ) ) { continue ; } if ( kid . getChildCount ( ) > 0 ) { for ( UIComponent grandkid : kid . getChildren ( ) ) { if ( grandkid . visitTree ( context , callback ) ) { return true ; } } } } } if ( ! visitRows ) { break ; } } return false ; } | Visit each column and row |
18,310 | public boolean isForwardToHtml ( ) { if ( ! isHtmlResponse ( ) ) { return false ; } final HtmlResponse htmlResponse = ( ( HtmlResponse ) actionResponse ) ; return ! htmlResponse . isRedirectTo ( ) && isHtmlTemplateResponse ( htmlResponse ) ; } | Is the result of the action execute forward to HTML template? |
18,311 | public boolean handleActionPath ( String requestPath , ActionFoundPathHandler handler ) throws Exception { assertArgumentNotNull ( "requestPath" , requestPath ) ; assertArgumentNotNull ( "handler" , handler ) ; final MappingPathResource pathResource = customizeActionMapping ( requestPath ) ; return mappingActionPath ( pathResource , handler ) ; } | Handle the action path from the specified request path . |
18,312 | public synchronized String encrypt ( String plainText ) { assertArgumentNotNull ( "plainText" , plainText ) ; if ( encryptingCipher == null ) { initialize ( ) ; } return new String ( encodeHex ( doEncrypt ( plainText ) ) ) ; } | Encrypt the text as invertible . |
18,313 | public UrlChain moreUrl ( Object ... urlParts ) { final String argTitle = "urlParts" ; assertArgumentNotNull ( argTitle , urlParts ) ; checkWrongUrlChainUse ( argTitle , urlParts ) ; this . urlParts = urlParts ; return this ; } | Set up more URL parts as URL chain . |
18,314 | public UrlChain params ( Object ... paramsOnGet ) { final String argTitle = "paramsOnGet" ; assertArgumentNotNull ( argTitle , paramsOnGet ) ; checkWrongUrlChainUse ( argTitle , paramsOnGet ) ; this . paramsOnGet = paramsOnGet ; return this ; } | Set up parameters on GET as URL chain . |
18,315 | protected void assertArgumentNotNull ( String argumentName , Object value ) { if ( argumentName == null ) { String msg = "The argument name should not be null: argName=null value=" + value ; throw new IllegalArgumentException ( msg ) ; } if ( value == null ) { String msg = "The value should not be null: argName=" + argumentName ; throw new IllegalArgumentException ( msg ) ; } } | Assert that the argument is not null . |
18,316 | public BigDecimal toBigDecimal ( ) { int scale = 0 ; String text = getIntegerPart ( ) ; String t_fraction = getFractionalPart ( ) ; if ( t_fraction != null ) { text += getFractionalPart ( ) ; scale += t_fraction . length ( ) ; } String t_exponent = getExponent ( ) ; if ( t_exponent != null ) scale -= Integer . parseInt ( t_exponent ) ; BigInteger unscaled = new BigInteger ( text , getBase ( ) ) ; return new BigDecimal ( unscaled , scale ) ; } | So it turns out that parsing arbitrary bases into arbitrary precision numbers is nontrivial and this routine gets it wrong in many important cases . |
18,317 | protected void handleSqlCount ( ActionRuntime runtime ) { final CallbackContext context = CallbackContext . getCallbackContextOnThread ( ) ; if ( context == null ) { return ; } final SqlStringFilter filter = context . getSqlStringFilter ( ) ; if ( filter == null || ! ( filter instanceof ExecutedSqlCounter ) ) { return ; } final ExecutedSqlCounter counter = ( ( ExecutedSqlCounter ) filter ) ; final int sqlExecutionCountLimit = getSqlExecutionCountLimit ( runtime ) ; if ( sqlExecutionCountLimit >= 0 && counter . getTotalCountOfSql ( ) > sqlExecutionCountLimit ) { handleTooManySqlExecution ( runtime , counter , sqlExecutionCountLimit ) ; } saveRequestedSqlCount ( counter ) ; } | Handle count of SQL execution in the request . |
18,318 | protected void handleTooManySqlExecution ( ActionRuntime runtime , ExecutedSqlCounter sqlCounter , int sqlExecutionCountLimit ) { final int totalCountOfSql = sqlCounter . getTotalCountOfSql ( ) ; final String actionDisp = buildActionDisp ( runtime ) ; logger . warn ( "*Too many SQL executions: {}/{} in {}" , totalCountOfSql , sqlExecutionCountLimit , actionDisp ) ; } | Handle too many SQL executions . |
18,319 | protected void handleMailCount ( ActionRuntime runtime ) { if ( ThreadCacheContext . exists ( ) ) { final PostedMailCounter counter = ThreadCacheContext . findMailCounter ( ) ; if ( counter != null ) { saveRequestedMailCount ( counter ) ; } } } | Handle count of mail posting in the request . |
18,320 | protected void handleRemoteApiCount ( ActionRuntime runtime ) { if ( ThreadCacheContext . exists ( ) ) { final CalledRemoteApiCounter counter = ThreadCacheContext . findRemoteApiCounter ( ) ; if ( counter != null ) { saveRequestedRemoteApiCount ( counter ) ; } } } | Handle count of remoteApi calling in the request . |
18,321 | public UIComponent getFacet ( String name ) { if ( facets != null ) { return ( facets . get ( name ) ) ; } else { return ( null ) ; } } | Do not allocate the facets Map to answer this question |
18,322 | private Object saveBehaviorsState ( FacesContext context ) { Object state = null ; if ( null != behaviors && behaviors . size ( ) > 0 ) { boolean stateWritten = false ; Object [ ] attachedBehaviors = new Object [ behaviors . size ( ) ] ; int i = 0 ; for ( List < ClientBehavior > eventBehaviors : behaviors . values ( ) ) { Object [ ] attachedEventBehaviors = new Object [ eventBehaviors . size ( ) ] ; for ( int j = 0 ; j < attachedEventBehaviors . length ; j ++ ) { attachedEventBehaviors [ j ] = ( ( initialStateMarked ( ) ) ? saveBehavior ( context , eventBehaviors . get ( j ) ) : saveAttachedState ( context , eventBehaviors . get ( j ) ) ) ; if ( ! stateWritten ) { stateWritten = ( attachedEventBehaviors [ j ] != null ) ; } } attachedBehaviors [ i ++ ] = attachedEventBehaviors ; } if ( stateWritten ) { state = new Object [ ] { behaviors . keySet ( ) . toArray ( new String [ behaviors . size ( ) ] ) , attachedBehaviors } ; } } return state ; } | Save state of the behaviors map . |
18,323 | @ SuppressWarnings ( "unchecked" ) public static < OBJ > OBJ getObject ( String key ) { if ( ! exists ( ) ) { throwThreadCacheNotInitializedException ( key ) ; } return ( OBJ ) threadLocal . get ( ) . get ( key ) ; } | Get the value of the object by the key . |
18,324 | public static void setObject ( String key , Object value ) { if ( ! exists ( ) ) { throwThreadCacheNotInitializedException ( key ) ; } threadLocal . get ( ) . put ( key , value ) ; } | Set the value of the object . |
18,325 | @ SuppressWarnings ( "unchecked" ) public static < OBJ > OBJ removeObject ( String key ) { if ( ! exists ( ) ) { throwThreadCacheNotInitializedException ( key ) ; } return ( OBJ ) threadLocal . get ( ) . remove ( key ) ; } | Remove the value of the object from the cache . |
18,326 | public static boolean determineObject ( String key ) { if ( ! exists ( ) ) { throwThreadCacheNotInitializedException ( key ) ; } final Object obj = threadLocal . get ( ) . get ( key ) ; return obj != null && ( boolean ) obj ; } | Determine the object as boolean . |
18,327 | public static void clearAccessContextOnThread ( ) { final Stack < AccessContext > stack = threadLocal . get ( ) ; if ( stack != null ) { stack . pop ( ) ; if ( stack . isEmpty ( ) ) { perfectlyClear ( ) ; } } } | Clear prepared access - context on thread . |
18,328 | public static void endAccessContext ( ) { AccessContext . clearAccessContextOnThread ( ) ; final AccessContext accessContext = SuspendedAccessContext . getAccessContextOnThread ( ) ; if ( accessContext != null ) { AccessContext . setAccessContextOnThread ( accessContext ) ; SuspendedAccessContext . clearAccessContextOnThread ( ) ; } } | End access - context use for DBFlute . |
18,329 | protected TreeMap < String , Object > prepareOrderedMap ( Object form , Set < ConstraintViolation < Object > > vioSet ) { final Map < String , Object > vioPropMap = new HashMap < > ( vioSet . size ( ) ) ; for ( ConstraintViolation < Object > vio : vioSet ) { final String propertyPath = extractPropertyPath ( vio ) ; final boolean nested = propertyPath . contains ( "." ) ; final String propertyName = nested ? Srl . substringFirstFront ( propertyPath , "." ) : propertyPath ; Object holder = vioPropMap . get ( propertyName ) ; if ( holder == null ) { holder = nested ? new ArrayList < > ( 4 ) : vio ; vioPropMap . put ( propertyName , holder ) ; } else if ( holder instanceof ConstraintViolation < ? > ) { @ SuppressWarnings ( "unchecked" ) final ConstraintViolation < Object > existing = ( ( ConstraintViolation < Object > ) holder ) ; final List < Object > listHolder = new ArrayList < > ( 4 ) ; listHolder . add ( existing ) ; listHolder . add ( vio ) ; vioPropMap . put ( propertyName , listHolder ) ; } if ( holder instanceof List < ? > ) { @ SuppressWarnings ( "unchecked" ) final List < Object > listHolder = ( List < Object > ) holder ; listHolder . add ( vio ) ; } } final BeanDesc beanDesc = BeanDescFactory . getBeanDesc ( form . getClass ( ) ) ; final int pdSize = beanDesc . getPropertyDescSize ( ) ; final Map < String , Integer > priorityMap = new HashMap < > ( vioPropMap . size ( ) ) ; for ( int i = 0 ; i < pdSize ; i ++ ) { final PropertyDesc pd = beanDesc . getPropertyDesc ( i ) ; final String propertyName = pd . getPropertyName ( ) ; if ( vioPropMap . containsKey ( propertyName ) ) { priorityMap . put ( propertyName , i ) ; } } final TreeMap < String , Object > orderedMap = new TreeMap < String , Object > ( ( key1 , key2 ) -> { final String rootProperty1 = Srl . substringFirstFront ( key1 , "[" , "." ) ; final String rootProperty2 = Srl . substringFirstFront ( key2 , "[" , "." ) ; final Integer priority1 = priorityMap . getOrDefault ( rootProperty1 , Integer . MAX_VALUE ) ; final Integer priority2 = priorityMap . getOrDefault ( rootProperty2 , Integer . MAX_VALUE ) ; if ( priority1 > priority2 ) { return 1 ; } else if ( priority2 > priority1 ) { return - 1 ; } else { return key1 . compareTo ( key2 ) ; } } ) ; orderedMap . putAll ( vioPropMap ) ; return orderedMap ; } | basically for batch display |
18,330 | public static boolean cannotBeValidatable ( Object value ) { return value instanceof String || value instanceof Number || DfTypeUtil . isAnyLocalDate ( value ) || value instanceof Boolean || value instanceof Classification || value . getClass ( ) . isPrimitive ( ) ; } | similar logic is on action response reflector |
18,331 | public String getPath ( ) { Source parent = getParent ( ) ; if ( parent != null ) return parent . getPath ( ) ; return null ; } | Returns the File currently being lexed . |
18,332 | public String getName ( ) { Source parent = getParent ( ) ; if ( parent != null ) return parent . getName ( ) ; return null ; } | Returns the human - readable name of the current Source . |
18,333 | public Token skipline ( boolean white ) throws IOException , LexerException { for ( ; ; ) { Token tok = token ( ) ; switch ( tok . getType ( ) ) { case EOF : warning ( tok . getLine ( ) , tok . getColumn ( ) , "No newline before end of file" ) ; return new Token ( NL , tok . getLine ( ) , tok . getColumn ( ) , "\n" ) ; case NL : return tok ; case CCOMMENT : case CPPCOMMENT : case WHITESPACE : break ; default : if ( white ) warning ( tok . getLine ( ) , tok . getColumn ( ) , "Unexpected nonwhite token" ) ; break ; } } } | Skips tokens until the end of line . |
18,334 | void notifyListenersOnStateChange ( ) { LOGGER . debug ( "Notifying connection listeners about state change to {}" , state ) ; for ( ConnectionListener listener : connectionListeners ) { switch ( state ) { case CONNECTED : listener . onConnectionEstablished ( connection ) ; break ; case CONNECTING : listener . onConnectionLost ( connection ) ; break ; case CLOSED : listener . onConnectionClosed ( connection ) ; break ; default : break ; } } } | Notifies all connection listener about a state change . |
18,335 | void establishConnection ( ) throws IOException { synchronized ( operationOnConnectionMonitor ) { if ( state == State . CLOSED ) { throw new IOException ( "Attempt to establish a connection with a closed connection factory" ) ; } else if ( state == State . CONNECTED ) { LOGGER . warn ( "Establishing new connection although a connection is already established" ) ; } try { LOGGER . info ( "Trying to establish connection to {}:{}" , getHost ( ) , getPort ( ) ) ; connection = super . newConnection ( executorService ) ; connection . addShutdownListener ( connectionShutdownListener ) ; LOGGER . info ( "Established connection to {}:{}" , getHost ( ) , getPort ( ) ) ; changeState ( State . CONNECTED ) ; } catch ( IOException e ) { LOGGER . error ( "Failed to establish connection to {}:{}" , getHost ( ) , getPort ( ) ) ; throw e ; } } } | Establishes a new connection . |
18,336 | public static String sliceOf ( String str , int start , int end ) { return slc ( str , start , end ) ; } | Get slice of string |
18,337 | public static String slcEnd ( String str , int end ) { return FastStringUtils . noCopyStringFromChars ( Chr . slcEnd ( FastStringUtils . toCharArray ( str ) , end ) ) ; } | Gets end slice of a string . |
18,338 | public static char idx ( String str , int index ) { int i = calculateIndex ( str . length ( ) , index ) ; char c = str . charAt ( i ) ; return c ; } | Gets character at index |
18,339 | public static String idx ( String str , int index , char c ) { char [ ] chars = str . toCharArray ( ) ; Chr . idx ( chars , index , c ) ; return new String ( chars ) ; } | Puts character at index |
18,340 | public static boolean in ( char c , String str ) { return Chr . in ( c , FastStringUtils . toCharArray ( str ) ) ; } | See if a char is in another string |
18,341 | public static String add ( String str , String str2 ) { return FastStringUtils . noCopyStringFromChars ( Chr . add ( FastStringUtils . toCharArray ( str ) , FastStringUtils . toCharArray ( str2 ) ) ) ; } | Add one string to another |
18,342 | public static String add ( String ... strings ) { int length = 0 ; for ( String str : strings ) { if ( str == null ) { continue ; } length += str . length ( ) ; } CharBuf builder = CharBuf . createExact ( length ) ; for ( String str : strings ) { if ( str == null ) { continue ; } builder . add ( str ) ; } return builder . toString ( ) ; } | Add many strings together to another |
18,343 | public static String sputl ( Object ... messages ) { CharBuf buf = CharBuf . create ( 100 ) ; return sputl ( buf , messages ) . toString ( ) ; } | like putl but writes to a string . |
18,344 | public static String sputs ( Object ... messages ) { CharBuf buf = CharBuf . create ( 80 ) ; return sputs ( buf , messages ) . toString ( ) ; } | Like puts but writes to a String . |
18,345 | public static CharBuf sputl ( CharBuf buf , Object ... messages ) { for ( Object message : messages ) { if ( message == null ) { buf . add ( "<NULL>" ) ; } else if ( message . getClass ( ) . isArray ( ) ) { buf . add ( toListOrSingletonList ( message ) . toString ( ) ) ; } else { buf . add ( message . toString ( ) ) ; } buf . add ( '\n' ) ; } buf . add ( '\n' ) ; return buf ; } | Writes to a char buf . A char buf is like a StringBuilder . |
18,346 | private Object parseFile ( File file , String scharset ) { Charset charset = scharset == null || scharset . length ( ) == 0 ? StandardCharsets . UTF_8 : Charset . forName ( scharset ) ; if ( file . length ( ) > 2_000_000 ) { try ( Reader reader = Files . newBufferedReader ( Classpaths . path ( file . toString ( ) ) , charset ) ) { return parse ( reader ) ; } catch ( IOException ioe ) { throw new JsonException ( "Unable to process file: " + file . getPath ( ) , ioe ) ; } } else { try { return JsonFactory . create ( ) . fromJson ( Files . newBufferedReader ( Classpaths . path ( file . toString ( ) ) , charset ) ) ; } catch ( IOException e ) { throw new JsonException ( "Unable to process file: " + file . getPath ( ) , e ) ; } } } | Slight changes to remove groovy dependencies . |
18,347 | public static void puts ( Object ... messages ) { for ( Object message : messages ) { IO . print ( message ) ; if ( ! ( message instanceof Terminal . Escape ) ) IO . print ( ' ' ) ; } IO . println ( ) ; } | Like print but prints out a whole slew of objects on the same line . |
18,348 | private int compareOrder ( CacheEntry other ) { if ( order > other . order ) { return 1 ; } else if ( order < other . order ) { return - 1 ; } else if ( order == other . order ) { return 0 ; } die ( ) ; return 0 ; } | Compare the order . |
18,349 | private int compareToLFU ( CacheEntry other ) { int cmp = compareReadCount ( other ) ; if ( cmp != 0 ) { return cmp ; } cmp = compareTime ( other ) ; if ( cmp != 0 ) { return cmp ; } return compareOrder ( other ) ; } | Compares the read counts . |
18,350 | private int compareToLRU ( CacheEntry other ) { int cmp = compareTime ( other ) ; if ( cmp != 0 ) { return cmp ; } cmp = compareOrder ( other ) ; if ( cmp != 0 ) { return cmp ; } return compareReadCount ( other ) ; } | Compare the time . |
18,351 | private int compareToFIFO ( CacheEntry other ) { int cmp = compareOrder ( other ) ; if ( cmp != 0 ) { return cmp ; } cmp = compareTime ( other ) ; if ( cmp != 0 ) { return cmp ; } return cmp = compareReadCount ( other ) ; } | Compare for FIFO |
18,352 | @ SuppressWarnings ( "unchecked" ) public < T > T readBodyAs ( Class < T > type ) { if ( String . class . isAssignableFrom ( type ) ) { return ( T ) readBodyAsString ( ) ; } else if ( Number . class . isAssignableFrom ( type ) ) { return ( T ) readBodyAsNumber ( ( Class < Number > ) type ) ; } else if ( Boolean . class . isAssignableFrom ( type ) ) { return ( T ) readBodyAsBoolean ( ) ; } else if ( Character . class . isAssignableFrom ( type ) ) { return ( T ) readBodyAsChar ( ) ; } return readBodyAsObject ( type ) ; } | Extracts the message body and interprets it as the given Java type |
18,353 | public String readBodyAsString ( ) { Charset charset = readCharset ( ) ; byte [ ] bodyContent = message . getBodyContent ( ) ; return new String ( bodyContent , charset ) ; } | Extracts the message body and interprets it as a string . |
18,354 | @ SuppressWarnings ( "unchecked" ) public < T > T readBodyAsObject ( Class < T > type ) { Charset charset = readCharset ( ) ; InputStream inputStream = new ByteArrayInputStream ( message . getBodyContent ( ) ) ; InputStreamReader inputReader = new InputStreamReader ( inputStream , charset ) ; StreamSource streamSource = new StreamSource ( inputReader ) ; try { Unmarshaller unmarshaller = JAXBContext . newInstance ( type ) . createUnmarshaller ( ) ; if ( type . isAnnotationPresent ( XmlRootElement . class ) ) { return ( T ) unmarshaller . unmarshal ( streamSource ) ; } else { JAXBElement < T > element = unmarshaller . unmarshal ( streamSource , type ) ; return element . getValue ( ) ; } } catch ( JAXBException e ) { throw new RuntimeException ( e ) ; } } | Extracts the message body and interprets it as the XML representation of an object of the given type . |
18,355 | public < T > void addEvent ( Class < T > eventType , PublisherConfiguration configuration ) { publisherConfigurations . put ( eventType , configuration ) ; } | Adds events of the given type to the CDI events to which the event publisher listens in order to publish them . The publisher configuration is used to decide where to and how to publish messages . |
18,356 | MessagePublisher providePublisher ( PublisherReliability reliability , Class < ? > eventType ) { Map < Class < ? > , MessagePublisher > localPublishers = publishers . get ( ) ; if ( localPublishers == null ) { localPublishers = new HashMap < Class < ? > , MessagePublisher > ( ) ; publishers . set ( localPublishers ) ; } MessagePublisher publisher = localPublishers . get ( eventType ) ; if ( publisher == null ) { publisher = new GenericPublisher ( connectionFactory , reliability ) ; localPublishers . put ( eventType , publisher ) ; } return publisher ; } | Provides a publisher with the specified reliability . Within the same thread the same producer instance is provided for the given event type . |
18,357 | static Message buildMessage ( PublisherConfiguration publisherConfiguration , Object event ) { Message message = new Message ( publisherConfiguration . basicProperties ) . exchange ( publisherConfiguration . exchange ) . routingKey ( publisherConfiguration . routingKey ) ; if ( publisherConfiguration . persistent ) { message . persistent ( ) ; } if ( event instanceof ContainsData ) { message . body ( ( ( ContainsData ) event ) . getData ( ) ) ; } else if ( event instanceof ContainsContent ) { message . body ( ( ( ContainsContent ) event ) . getContent ( ) ) ; } else if ( event instanceof ContainsId ) { message . body ( ( ( ContainsId ) event ) . getId ( ) ) ; } return message ; } | Builds a message based on a CDI event and its publisher configuration . |
18,358 | public < T > Message body ( T body , Charset charset ) { messageWriter . writeBody ( body , charset ) ; return this ; } | Serializes and adds the given object as body to the message using the given charset for encoding . |
18,359 | public Message contentEncoding ( String charset ) { basicProperties = basicProperties . builder ( ) . contentEncoding ( charset ) . build ( ) ; return this ; } | Sets the content charset encoding of this message . |
18,360 | public Message contentType ( String contentType ) { basicProperties = basicProperties . builder ( ) . contentType ( contentType ) . build ( ) ; return this ; } | Sets the content type of this message . |
18,361 | public void publish ( Channel channel , DeliveryOptions deliveryOptions ) throws IOException { if ( basicProperties . getTimestamp ( ) == null ) { basicProperties . builder ( ) . timestamp ( new Date ( ) ) ; } boolean mandatory = deliveryOptions == DeliveryOptions . MANDATORY ; boolean immediate = deliveryOptions == DeliveryOptions . IMMEDIATE ; LOGGER . info ( "Publishing message to exchange '{}' with routing key '{}' (deliveryOptions: {}, persistent: {})" , new Object [ ] { exchange , routingKey , deliveryOptions , basicProperties . getDeliveryMode ( ) == 2 } ) ; channel . basicPublish ( exchange , routingKey , mandatory , immediate , basicProperties , bodyContent ) ; LOGGER . info ( "Successfully published message to exchange '{}' with routing key '{}'" , exchange , routingKey ) ; } | Publishes a message via the given channel while using the specified delivery options . |
18,362 | @ SuppressWarnings ( "unchecked" ) Object buildEvent ( Message message ) { Object event = eventPool . get ( ) ; if ( event instanceof ContainsData ) { ( ( ContainsData ) event ) . setData ( message . getBodyContent ( ) ) ; } else if ( event instanceof ContainsContent ) { Class < ? > parameterType = getParameterType ( event , ContainsContent . class ) ; ( ( ContainsContent ) event ) . setContent ( message . getBodyAs ( parameterType ) ) ; } else if ( event instanceof ContainsId ) { Class < ? > parameterType = getParameterType ( event , ContainsId . class ) ; ( ( ContainsId ) event ) . setId ( message . getBodyAs ( parameterType ) ) ; } return event ; } | Builds a CDI event from a message . The CDI event instance is retrieved from the injection container . |
18,363 | @ SuppressWarnings ( "unchecked" ) static Class < ? > getParameterType ( Object object , Class < ? > expectedType ) { Collection < Class < ? > > extendedAndImplementedTypes = getExtendedAndImplementedTypes ( object . getClass ( ) , new LinkedList < Class < ? > > ( ) ) ; for ( Class < ? > type : extendedAndImplementedTypes ) { Type [ ] implementedInterfaces = type . getGenericInterfaces ( ) ; for ( Type implementedInterface : implementedInterfaces ) { if ( implementedInterface instanceof ParameterizedType ) { ParameterizedType parameterizedCandidateType = ( ParameterizedType ) implementedInterface ; if ( parameterizedCandidateType . getRawType ( ) . equals ( expectedType ) ) { Type [ ] typeArguments = parameterizedCandidateType . getActualTypeArguments ( ) ; Type typeArgument ; if ( typeArguments . length == 0 ) { typeArgument = Object . class ; } else { typeArgument = parameterizedCandidateType . getActualTypeArguments ( ) [ 0 ] ; } return ( Class < ? > ) typeArgument ; } } } } throw new RuntimeException ( "Expected type " + expectedType + " is not in class hierarchy of " + object . getClass ( ) ) ; } | Gets the type parameter of the expected generic interface which is actually used by the class of the given object . The generic interface can be implemented by an class or interface in the object s class hierarchy |
18,364 | static List < Class < ? > > getExtendedAndImplementedTypes ( Class < ? > clazz , List < Class < ? > > hierarchy ) { hierarchy . add ( clazz ) ; Class < ? > superClass = clazz . getSuperclass ( ) ; if ( superClass != null ) { hierarchy = getExtendedAndImplementedTypes ( superClass , hierarchy ) ; } for ( Class < ? > implementedInterface : clazz . getInterfaces ( ) ) { hierarchy = getExtendedAndImplementedTypes ( implementedInterface , hierarchy ) ; } return hierarchy ; } | Gets all classes and interfaces in the class hierarchy of the given class including the class itself . |
18,365 | protected Channel provideChannel ( ) throws IOException { if ( channel == null || ! channel . isOpen ( ) ) { Connection connection = connectionFactory . newConnection ( ) ; channel = connection . createChannel ( ) ; } return channel ; } | Initializes a channel if there is not already an open channel . |
18,366 | protected void handleIoException ( int attempt , IOException ioException ) throws IOException { if ( channel != null && channel . isOpen ( ) ) { try { channel . close ( ) ; } catch ( IOException e ) { LOGGER . warn ( "Failed to close channel after failed publish" , e ) ; } } channel = null ; if ( attempt == DEFAULT_RETRY_ATTEMPTS ) { throw ioException ; } try { Thread . sleep ( DEFAULT_RETRY_INTERVAL ) ; } catch ( InterruptedException e ) { LOGGER . warn ( "Sending message interrupted while waiting for retry attempt" , e ) ; } } | Handles an IOException depending on the already used attempts to send a message . Also performs a soft reset of the currently used channel . |
18,367 | public static String getSortableFieldFromClass ( Class < ? > clazz ) { String fieldName = getSortableField ( clazz ) ; if ( fieldName == null ) { for ( String name : fieldSortNames ) { if ( classHasStringField ( clazz , name ) ) { fieldName = name ; break ; } } if ( fieldName == null ) { for ( String name : fieldSortNamesSuffixes ) { fieldName = getFirstStringFieldNameEndsWithFromClass ( clazz , name ) ; if ( fieldName != null ) { break ; } } } if ( fieldName == null ) { fieldName = getFirstComparableOrPrimitiveFromClass ( clazz ) ; } if ( fieldName == null ) { setSortableField ( clazz , "NOT FOUND" ) ; Exceptions . die ( "Could not find a sortable field for type " + clazz ) ; } setSortableField ( clazz , fieldName ) ; } return fieldName ; } | Gets the first sortable field . |
18,368 | public void configureFactory ( Class < ? > clazz ) { ConnectionConfiguration connectionConfiguration = resolveConnectionConfiguration ( clazz ) ; if ( connectionConfiguration == null ) { return ; } connectionFactory . setHost ( connectionConfiguration . host ( ) ) ; connectionFactory . setVirtualHost ( connectionConfiguration . virtualHost ( ) ) ; connectionFactory . setPort ( connectionConfiguration . port ( ) ) ; connectionFactory . setConnectionTimeout ( connectionConfiguration . timeout ( ) ) ; connectionFactory . setRequestedHeartbeat ( connectionConfiguration . heartbeat ( ) ) ; connectionFactory . setUsername ( connectionConfiguration . username ( ) ) ; connectionFactory . setPassword ( connectionConfiguration . password ( ) ) ; connectionFactory . setRequestedFrameMax ( connectionConfiguration . frameMax ( ) ) ; } | Configures the connection factory supplied by dependency injection using the connection configuration annotated at the given class . |
18,369 | private final void buildIfNeededMap ( ) { if ( map == null ) { map = new HashMap < > ( items . length ) ; for ( Entry < String , Value > miv : items ) { if ( miv == null ) { break ; } map . put ( miv . getKey ( ) , miv . getValue ( ) ) ; } } } | Build the map if requested to it does this lazily . |
18,370 | public static boolean respondsTo ( Object object , String method ) { if ( object instanceof Class ) { return Reflection . respondsTo ( ( Class ) object , method ) ; } else { return Reflection . respondsTo ( object , method ) ; } } | Checks to see if an object responds to a method . Helper facade over Reflection library . |
18,371 | public < T > void writeBodyFromObject ( T bodyAsObject , Charset charset ) { @ SuppressWarnings ( "unchecked" ) Class < T > clazz = ( Class < T > ) bodyAsObject . getClass ( ) ; ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; Writer outputWriter = new OutputStreamWriter ( outputStream , charset ) ; try { Marshaller marshaller = JAXBContext . newInstance ( clazz ) . createMarshaller ( ) ; if ( clazz . isAnnotationPresent ( XmlRootElement . class ) ) { marshaller . marshal ( bodyAsObject , outputWriter ) ; } else { String tagName = unCapitalizedClassName ( clazz ) ; JAXBElement < T > element = new JAXBElement < T > ( new QName ( "" , tagName ) , clazz , bodyAsObject ) ; marshaller . marshal ( element , outputWriter ) ; } } catch ( JAXBException e ) { throw new RuntimeException ( e ) ; } byte [ ] bodyContent = outputStream . toByteArray ( ) ; message . contentType ( Message . APPLICATION_XML ) . contentEncoding ( charset . name ( ) ) ; message . body ( bodyContent ) ; } | Writes the body by serializing the given object to XML . |
18,372 | public static boolean toBoolean ( Object obj , boolean defaultValue ) { if ( obj == null ) { return defaultValue ; } if ( obj instanceof Boolean ) { return ( ( Boolean ) obj ) . booleanValue ( ) ; } else if ( obj instanceof Number || obj . getClass ( ) . isPrimitive ( ) ) { int value = toInt ( obj ) ; return value != 0 ? true : false ; } else if ( obj instanceof Value ) { return ( ( Value ) obj ) . booleanValue ( ) ; } else if ( obj instanceof String || obj instanceof CharSequence ) { String str = Conversions . toString ( obj ) ; if ( str . length ( ) == 0 ) { return false ; } if ( str . equals ( "false" ) ) { return false ; } else { return true ; } } else if ( isArray ( obj ) ) { return len ( obj ) > 0 ; } else if ( obj instanceof Collection ) { if ( len ( obj ) > 0 ) { List list = Lists . list ( ( Collection ) obj ) ; while ( list . remove ( null ) ) { } return Lists . len ( list ) > 0 ; } else { return false ; } } else { return toBoolean ( Conversions . toString ( obj ) ) ; } } | Converts the value to boolean and if it is null it uses the default value passed . |
18,373 | public void addConsumer ( Consumer consumer , String queue ) { addConsumer ( consumer , new ConsumerConfiguration ( queue ) , DEFAULT_AMOUNT_OF_INSTANCES ) ; } | Adds a consumer to the container and binds it to the given queue with auto acknowledge disabled . Does NOT enable the consumer to consume from the message broker until the container is started . |
18,374 | public synchronized void addConsumer ( Consumer consumer , ConsumerConfiguration configuration , int instances ) { for ( int i = 0 ; i < instances ; i ++ ) { this . consumerHolders . add ( new ConsumerHolder ( consumer , configuration ) ) ; } } | Adds a consumer to the container and configures it according to the consumer configuration . Does NOT enable the consumer to consume from the message broker until the container is started . |
18,375 | protected List < ConsumerHolder > filterConsumersForClass ( Class < ? extends Consumer > consumerClass ) { List < ConsumerHolder > consumerHolderSubList = new LinkedList < ConsumerHolder > ( ) ; for ( ConsumerHolder consumerHolder : consumerHolders ) { if ( consumerClass . isAssignableFrom ( consumerHolder . getConsumer ( ) . getClass ( ) ) ) { consumerHolderSubList . add ( consumerHolder ) ; } } return consumerHolderSubList ; } | Filters the consumers being an instance extending or implementing the given class from the list of managed consumers . |
18,376 | protected List < ConsumerHolder > filterConsumersForEnabledFlag ( boolean enabled ) { List < ConsumerHolder > consumerHolderSubList = new LinkedList < ConsumerHolder > ( ) ; for ( ConsumerHolder consumerHolder : consumerHolders ) { if ( consumerHolder . isEnabled ( ) == enabled ) { consumerHolderSubList . add ( consumerHolder ) ; } } return consumerHolderSubList ; } | Filters the consumers matching the given enabled flag from the list of managed consumers . |
18,377 | protected List < ConsumerHolder > filterConsumersForActiveFlag ( boolean active ) { List < ConsumerHolder > consumerHolderSubList = new LinkedList < ConsumerHolder > ( ) ; for ( ConsumerHolder consumerHolder : consumerHolders ) { if ( consumerHolder . isActive ( ) == active ) { consumerHolderSubList . add ( consumerHolder ) ; } } return consumerHolderSubList ; } | Filters the consumers matching the given active flag from the list of managed consumers . |
18,378 | protected void enableConsumers ( List < ConsumerHolder > consumerHolders ) throws IOException { checkPreconditions ( consumerHolders ) ; try { for ( ConsumerHolder consumerHolder : consumerHolders ) { consumerHolder . enable ( ) ; } } catch ( IOException e ) { LOGGER . error ( "Failed to enable consumers - disabling already enabled consumers" ) ; disableConsumers ( consumerHolders ) ; throw e ; } } | Enables all consumers in the given list and hands them over for activation afterwards . |
18,379 | protected void activateConsumers ( List < ConsumerHolder > consumerHolders ) throws IOException { synchronized ( activationMonitor ) { for ( ConsumerHolder consumerHolder : consumerHolders ) { try { consumerHolder . activate ( ) ; } catch ( IOException e ) { LOGGER . error ( "Failed to activate consumer - deactivating already activated consumers" ) ; deactivateConsumers ( consumerHolders ) ; throw e ; } } } } | Activates all consumers in the given list . |
18,380 | protected void deactivateConsumers ( List < ConsumerHolder > consumerHolders ) { synchronized ( activationMonitor ) { for ( ConsumerHolder consumerHolder : consumerHolders ) { consumerHolder . deactivate ( ) ; } } } | Deactivates all consumers in the given list . |
18,381 | protected void checkPreconditions ( List < ConsumerHolder > consumerHolders ) throws IOException { Channel channel = createChannel ( ) ; for ( ConsumerHolder consumerHolder : consumerHolders ) { String queue = consumerHolder . getConfiguration ( ) . getQueueName ( ) ; try { channel . queueDeclarePassive ( queue ) ; LOGGER . debug ( "Queue {} found on broker" , queue ) ; } catch ( IOException e ) { LOGGER . error ( "Queue {} not found on broker" , queue ) ; throw e ; } } channel . close ( ) ; } | Checks if all preconditions are fulfilled on the broker to successfully register a consumer there . One important precondition is the existence of the queue the consumer shall consume from . |
18,382 | protected Channel createChannel ( ) throws IOException { LOGGER . debug ( "Creating channel" ) ; Connection connection = connectionFactory . newConnection ( ) ; Channel channel = connection . createChannel ( ) ; LOGGER . debug ( "Created channel" ) ; return channel ; } | Creates a channel to be used for consuming from the broker . |
18,383 | public final char [ ] findNextChar ( boolean inMiddleOfString , boolean wasEscapeChar , int match , int esc ) { try { ensureBuffer ( ) ; int idx = index ; char [ ] _chars = readBuf ; int length = this . length ; int ch = this . ch ; if ( ! inMiddleOfString ) { foundEscape = false ; if ( ch == match ) { } else if ( idx < length - 1 ) { ch = _chars [ idx ] ; if ( ch == match ) { idx ++ ; } } } if ( idx < length ) { ch = _chars [ idx ] ; } if ( ch == '"' && ! wasEscapeChar ) { index = idx ; index ++ ; return EMPTY_CHARS ; } int start = idx ; if ( wasEscapeChar ) { idx ++ ; } boolean foundEnd = false ; char [ ] results ; boolean _foundEscape = false ; while ( true ) { ch = _chars [ idx ] ; if ( ch == match || ch == esc ) { if ( ch == match ) { foundEnd = true ; break ; } else if ( ch == esc ) { wasEscapeChar = true ; _foundEscape = true ; if ( idx + 1 < length ) { wasEscapeChar = false ; idx ++ ; } } } if ( idx >= length ) break ; idx ++ ; } foundEscape = _foundEscape ; if ( idx == 0 ) { results = EMPTY_CHARS ; } else { results = Arrays . copyOfRange ( _chars , start , idx ) ; } index = idx ; if ( foundEnd ) { index ++ ; if ( index < length ) { ch = _chars [ index ] ; this . ch = ch ; } return results ; } else { if ( index >= length && ! done ) { ensureBuffer ( ) ; char results2 [ ] = findNextChar ( true , wasEscapeChar , match , esc ) ; return Chr . add ( results , results2 ) ; } else { return Exceptions . die ( char [ ] . class , "Unable to find close char " + ( char ) match + " " + new String ( results ) ) ; } } } catch ( Exception ex ) { String str = CharScanner . errorDetails ( "findNextChar issue" , readBuf , index , ch ) ; return Exceptions . handle ( char [ ] . class , str , ex ) ; } } | Remember that this must work past buffer reader boundaries so we need to keep track where we were in the nested run . |
18,384 | public boolean addArray ( float ... values ) { if ( end + values . length >= this . values . length ) { this . values = grow ( this . values , ( this . values . length + values . length ) * 2 ) ; } System . arraycopy ( values , 0 , this . values , end , values . length ) ; end += values . length ; return true ; } | Add a new array to the list . |
18,385 | private static PropertyDescriptor getPropertyDescriptor ( final Class < ? > type , final String propertyName ) { Exceptions . requireNonNull ( type ) ; Exceptions . requireNonNull ( propertyName ) ; if ( ! propertyName . contains ( "." ) ) { return doGetPropertyDescriptor ( type , propertyName ) ; } else { String [ ] propertyNames = propertyName . split ( "[.]" ) ; Class < ? > clazz = type ; PropertyDescriptor propertyDescriptor = null ; for ( String pName : propertyNames ) { propertyDescriptor = doGetPropertyDescriptor ( clazz , pName ) ; if ( propertyDescriptor == null ) { return null ; } clazz = propertyDescriptor . getPropertyType ( ) ; } return propertyDescriptor ; } } | This needs refactor and put into Refleciton . |
18,386 | public boolean open ( ) { LibMediaInfo lib = LibMediaInfo . INSTANCE ; handle = lib . MediaInfo_New ( ) ; if ( handle != null ) { int opened = lib . MediaInfo_Open ( handle , new WString ( filename ) ) ; if ( opened == 1 ) { return true ; } else { lib . MediaInfo_Delete ( handle ) ; } } return false ; } | Open the media file . |
18,387 | public void close ( ) { if ( handle != null ) { LibMediaInfo . INSTANCE . MediaInfo_Close ( handle ) ; LibMediaInfo . INSTANCE . MediaInfo_Delete ( handle ) ; } } | Close the media file . |
18,388 | MediaInfo parse ( ) { try { BufferedReader reader = new BufferedReader ( new StringReader ( data ) ) ; MediaInfo mediaInfo = new MediaInfo ( ) ; String sectionName ; String line ; Sections sections ; Section section = null ; while ( parseState != ParseState . FINISHED ) { switch ( parseState ) { case DEFAULT : parseState = ParseState . NEXT_SECTION ; break ; case NEXT_SECTION : sectionName = reader . readLine ( ) ; if ( sectionName == null ) { parseState = ParseState . FINISHED ; } else if ( sectionName . length ( ) > 0 ) { parseState = ParseState . SECTION ; sections = mediaInfo . sections ( sectionName ) ; section = sections . newSection ( ) ; } break ; case SECTION : line = reader . readLine ( ) ; if ( line == null ) { parseState = ParseState . FINISHED ; } else if ( line . length ( ) == 0 ) { parseState = ParseState . NEXT_SECTION ; } else { String [ ] values = line . split ( ":" , 2 ) ; section . put ( values [ 0 ] . trim ( ) , values [ 1 ] . trim ( ) ) ; } break ; default : throw new IllegalStateException ( ) ; } } return mediaInfo ; } catch ( IOException e ) { throw new MediaInfoParseException ( "Failed to parse media info" , e ) ; } } | Parse the raw data . |
18,389 | private void checkChildrenCount ( ) { if ( getChildCount ( ) != 2 ) Log . e ( getResources ( ) . getString ( R . string . tag ) , getResources ( ) . getString ( R . string . wrong_number_children_error ) ) ; } | Checks if children number is correct and logs an error if it is not |
18,390 | public static MediaInfo mediaInfo ( String filename ) { MediaInfo result ; LibMediaInfo lib = LibMediaInfo . INSTANCE ; Pointer handle = lib . MediaInfo_New ( ) ; if ( handle != null ) { try { int opened = lib . MediaInfo_Open ( handle , new WString ( filename ) ) ; if ( opened == 1 ) { WString data = lib . MediaInfo_Inform ( handle ) ; lib . MediaInfo_Close ( handle ) ; result = new Parser ( data . toString ( ) ) . parse ( ) ; } else { result = null ; } } finally { lib . MediaInfo_Delete ( handle ) ; } } else { result = null ; } return result ; } | Extract media information for a particular file . |
18,391 | public Sections sections ( String type ) { Sections result = sectionsByType . get ( type ) ; if ( result == null ) { result = new Sections ( ) ; sectionsByType . put ( type , result ) ; } return result ; } | Get all of the sections of a particular type . |
18,392 | public Section first ( String type ) { Section result ; Sections sections = sections ( type ) ; if ( sections != null ) { result = sections . first ( ) ; } else { result = null ; } return result ; } | Get the first section of a particular type . |
18,393 | public void completeAnimationToFullHeight ( int completeExpandAnimationSpeed ) { HeightAnimation heightAnim = new HeightAnimation ( animableView , animableView . getMeasuredHeight ( ) , displayHeight ) ; heightAnim . setDuration ( completeExpandAnimationSpeed ) ; heightAnim . setInterpolator ( new DecelerateInterpolator ( ) ) ; animableView . startAnimation ( heightAnim ) ; } | Animates animableView until it reaches full screen height |
18,394 | public void completeAnimationToInitialHeight ( int completeShrinkAnimationSpeed , int initialAnimableLayoutHeight ) { HeightAnimation heightAnim = new HeightAnimation ( animableView , animableView . getMeasuredHeight ( ) , initialAnimableLayoutHeight ) ; heightAnim . setDuration ( completeShrinkAnimationSpeed ) ; heightAnim . setInterpolator ( new DecelerateInterpolator ( ) ) ; animableView . startAnimation ( heightAnim ) ; } | Animates animableView to get its initial height back |
18,395 | static Integer integer ( String value ) { Integer result ; if ( value != null ) { value = value . trim ( ) ; Matcher matcher = INTEGER_PATTERN . matcher ( value ) ; if ( matcher . matches ( ) ) { result = Integer . parseInt ( matcher . group ( 1 ) . replace ( " " , "" ) ) ; } else { throw new IllegalArgumentException ( "Unknown format for value: " + value ) ; } } else { result = null ; } return result ; } | Convert a string to an integer . |
18,396 | static BigDecimal decimal ( String value ) { BigDecimal result ; if ( value != null ) { value = value . trim ( ) ; Matcher matcher = DECIMAL_PATTERN . matcher ( value ) ; if ( matcher . matches ( ) ) { result = new BigDecimal ( matcher . group ( 1 ) ) ; } else { throw new IllegalArgumentException ( "Unknown format for value: " + value ) ; } } else { result = null ; } return result ; } | Convert a string to a big decimal . |
18,397 | static Duration duration ( String value ) { Duration result ; if ( value != null ) { value = value . trim ( ) ; Matcher matcher = DURATION_PATTERN . matcher ( value ) ; if ( matcher . matches ( ) ) { int hours = matcher . group ( 1 ) != null ? Integer . parseInt ( matcher . group ( 1 ) ) : 0 ; int minutes = matcher . group ( 2 ) != null ? Integer . parseInt ( matcher . group ( 2 ) ) : 0 ; int seconds = matcher . group ( 3 ) != null ? Integer . parseInt ( matcher . group ( 3 ) ) : 0 ; int millis = matcher . group ( 4 ) != null ? Integer . parseInt ( matcher . group ( 4 ) ) : 0 ; result = new Duration ( hours , minutes , seconds , millis ) ; } else { throw new IllegalArgumentException ( "Unknown format for value: " + value ) ; } } else { result = null ; } return result ; } | Convert a string to a duration . |
18,398 | private void loadWebConfigs ( Environment environment , SpringConfiguration config , ApplicationContext appCtx ) throws ClassNotFoundException { loadFilters ( config . getFilters ( ) , environment ) ; environment . servlets ( ) . addServletListeners ( new RestContextLoaderListener ( ( XmlRestWebApplicationContext ) appCtx ) ) ; loadServlets ( config . getServlets ( ) , environment ) ; } | Load filter servlets or listeners for WebApplicationContext . |
18,399 | @ SuppressWarnings ( "unchecked" ) private void loadFilters ( Map < String , FilterConfiguration > filters , Environment environment ) throws ClassNotFoundException { if ( filters != null ) { for ( Map . Entry < String , FilterConfiguration > filterEntry : filters . entrySet ( ) ) { FilterConfiguration filter = filterEntry . getValue ( ) ; FilterHolder filterHolder = new FilterHolder ( ( Class < ? extends Filter > ) Class . forName ( filter . getClazz ( ) ) ) ; filterHolder . setName ( filterEntry . getKey ( ) ) ; if ( filter . getParam ( ) != null ) { for ( Map . Entry < String , String > entry : filter . getParam ( ) . entrySet ( ) ) { filterHolder . setInitParameter ( entry . getKey ( ) , entry . getValue ( ) ) ; } } environment . getApplicationContext ( ) . addFilter ( filterHolder , filter . getUrl ( ) , EnumSet . of ( DispatcherType . REQUEST ) ) ; } } } | Load all filters . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.