idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
30,400 | public static boolean isEmptyCriteria ( final Criteria criteria ) { return isEmpty ( criteria . getAliases ( ) ) && isEmpty ( criteria . getDeviceTypes ( ) ) && isEmpty ( criteria . getCategories ( ) ) ; } | Helper method to check if all criteria are empty . Useful in FCM land where we use topics . |
30,401 | public DashboardData loadDashboardData ( ) { long totalApps = totalApplicationNumber ( ) ; long totalDevices = totalDeviceNumber ( ) ; long totalMessages = totalMessages ( ) ; final DashboardData data = new DashboardData ( ) ; data . setApplications ( totalApps ) ; data . setDevices ( totalDevices ) ; data . setMessage... | Receives the dashboard data for the given user |
30,402 | public List < ApplicationVariant > getVariantsWithWarnings ( ) { final List < String > warningIDs = flatPushMessageInformationDao . findVariantIDsWithWarnings ( ) ; if ( warningIDs . isEmpty ( ) ) { return Collections . emptyList ( ) ; } return wrapApplicationVariant ( pushApplicationDao . findByVariantIds ( warningIDs... | Loads all the Variant objects where we did notice some failures on sending for the given user |
30,403 | @ Path ( "/application/{id}" ) @ Produces ( MediaType . APPLICATION_JSON ) public Response pushMessageInformationPerApplication ( @ PathParam ( "id" ) String id , @ QueryParam ( "page" ) Integer page , @ QueryParam ( "per_page" ) Integer pageSize , @ QueryParam ( "sort" ) String sorting , @ QueryParam ( "search" ) Stri... | GET info about submitted push messages for the given Push Application |
30,404 | public static String tryGetGlobalProperty ( String key , String defaultValue ) { try { String value = System . getenv ( formatEnvironmentVariable ( key ) ) ; if ( value == null ) { value = tryGetProperty ( key , defaultValue ) ; } return value ; } catch ( SecurityException e ) { logger . error ( "Could not get value of... | Get a global string property . This method will first try to get the value from an environment variable and if that does not exist it will look up a system property . |
30,405 | public static Integer tryGetGlobalIntegerProperty ( String key , Integer defaultValue ) { try { String value = System . getenv ( formatEnvironmentVariable ( key ) ) ; if ( value == null ) { return tryGetIntegerProperty ( key , defaultValue ) ; } else { return Integer . parseInt ( value ) ; } } catch ( SecurityException... | Get a global integer property . This method will first try to get the value from an environment variable and if that does not exist it will look up a system property . |
30,406 | @ Produces ( MediaType . APPLICATION_JSON ) public Response listAllWindowsVariationsForPushApp ( @ PathParam ( "pushAppID" ) String pushApplicationID ) { final PushApplication application = getSearch ( ) . findByPushApplicationIDForDeveloper ( pushApplicationID ) ; return Response . ok ( getVariants ( application ) ) .... | List Windows Variants for Push Application |
30,407 | @ Path ( "/{windowsID}" ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public Response updateWindowsVariant ( @ PathParam ( "windowsID" ) String windowsID , WindowsVariant updatedWindowsVariant ) { WindowsVariant windowsVariant = ( WindowsVariant ) variantService . findByVaria... | Update Windows Variant |
30,408 | protected void sendNonTransacted ( Destination destination , Serializable message ) { send ( destination , message , null , null , false ) ; } | Sends message to the destination in non - transactional manner . |
30,409 | protected void sendTransacted ( Destination destination , Serializable message ) { send ( destination , message , null , null , true ) ; } | Sends message to the destination in transactional manner . |
30,410 | protected void sendNonTransacted ( Destination destination , Serializable message , String propertyName , String propertValue ) { send ( destination , message , propertyName , propertValue , false ) ; } | Sends message to destination with given JMS message property name and value in non - transactional manner . |
30,411 | protected void sendTransacted ( Destination destination , Serializable message , String propertyName , String propertValue ) { send ( destination , message , propertyName , propertValue , true ) ; } | Sends message to destination with given JMS message property name and value in transactional manner . |
30,412 | public void disconnectOnChange ( final iOSVariantUpdateEvent iOSVariantUpdateEvent ) { final iOSVariant variant = iOSVariantUpdateEvent . getiOSVariant ( ) ; final String connectionKey = extractConnectionKey ( variant ) ; final ApnsClient client = apnsClientExpiringMap . remove ( connectionKey ) ; logger . debug ( "Rem... | Receives iOS variant change event to remove client from the cache and also tear down the connection . |
30,413 | public ResultsStream . QueryBuilder < String > findAllDeviceTokenForVariantIDByCriteria ( String variantID , List < String > categories , List < String > aliases , List < String > deviceTypes , int maxResults , String lastTokenFromPreviousBatch ) { return installationDao . findAllDeviceTokenForVariantIDByCriteria ( var... | Finder for send used for Android and iOS clients |
30,414 | @ Path ( "/{installationID}" ) @ Produces ( MediaType . APPLICATION_JSON ) public Response findInstallation ( @ PathParam ( "variantID" ) String variantId , @ PathParam ( "installationID" ) String installationId ) { Installation installation = clientInstallationService . findById ( installationId ) ; if ( installation ... | Get Installation of specified Variant |
30,415 | @ Path ( "/{installationID}" ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public Response updateInstallation ( Installation entity , @ PathParam ( "variantID" ) String variantId , @ PathParam ( "installationID" ) String installationId ) { Installation installation = clientIn... | Update Installation of specified Variant |
30,416 | @ Path ( "/{variantId}/installations/" ) @ Produces ( MediaType . APPLICATION_JSON ) public Response exportInstallations ( @ PathParam ( "variantId" ) String variantId ) { return Response . ok ( getSearch ( ) . findAllInstallationsByVariantForDeveloper ( variantId , 0 , Integer . MAX_VALUE , null ) . getResultList ( ) ... | Endpoint for exporting as JSON file device installations for a given variant . Only Keycloak authenticated can access it |
30,417 | private void processFCM ( AndroidVariant androidVariant , List < String > pushTargets , Message fcmMessage , ConfigurableFCMSender sender ) throws IOException { if ( pushTargets . get ( 0 ) . startsWith ( Constants . TOPIC_PREFIX ) ) { for ( String topic : pushTargets ) { logger . info ( String . format ( "Sent push no... | Process the HTTP POST to the FCM infrastructure for the given list of registrationIDs . |
30,418 | @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public Response registerPushApplication ( PushApplication pushApp ) { try { validateModelClass ( pushApp ) ; } catch ( ConstraintViolationException cve ) { logger . trace ( "Unable to create Push Application" ) ; return createBadReq... | Create Push Application |
30,419 | @ Produces ( MediaType . APPLICATION_JSON ) public Response listAllPushApplications ( @ QueryParam ( "page" ) Integer page , @ QueryParam ( "per_page" ) Integer pageSize , @ QueryParam ( "includeDeviceCount" ) @ DefaultValue ( "false" ) boolean includeDeviceCount , @ QueryParam ( "includeActivity" ) @ DefaultValue ( "f... | List Push Applications |
30,420 | @ Path ( "/{pushAppID}" ) @ Produces ( MediaType . APPLICATION_JSON ) public Response findById ( @ PathParam ( "pushAppID" ) String pushApplicationID , @ QueryParam ( "includeDeviceCount" ) @ DefaultValue ( "false" ) boolean includeDeviceCount , @ QueryParam ( "includeActivity" ) @ DefaultValue ( "false" ) boolean incl... | Get Push Application . |
30,421 | @ Path ( "/{pushAppID}" ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public Response updatePushApplication ( @ PathParam ( "pushAppID" ) String pushApplicationID , PushApplication updatedPushApp ) { PushApplication pushApp = getSearch ( ) . findByPushApplicationIDForDevelope... | Update Push Application |
30,422 | @ Path ( "/{pushAppID}/reset" ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public Response resetMasterSecret ( @ PathParam ( "pushAppID" ) String pushApplicationID ) { PushApplication pushApp = getSearch ( ) . findByPushApplicationIDForDeveloper ( pushApplicationID ) ; if ( ... | Reset MasterSecret for Push Application |
30,423 | @ Path ( "/{pushAppID}" ) @ Produces ( MediaType . APPLICATION_JSON ) public Response deletePushApplication ( @ PathParam ( "pushAppID" ) String pushApplicationID ) { PushApplication pushApp = getSearch ( ) . findByPushApplicationIDForDeveloper ( pushApplicationID ) ; if ( pushApp != null ) { logger . trace ( "Invoke s... | Delete Push Application |
30,424 | @ Path ( "/{pushAppID}/count" ) @ Produces ( MediaType . APPLICATION_JSON ) public Response countInstallations ( @ PathParam ( "pushAppID" ) String pushApplicationID ) { logger . trace ( "counting devices by type for push application '{}'" , pushApplicationID ) ; Map < String , Long > result = pushAppService . countIns... | Count Push Applications |
30,425 | private SenderConfiguration validateAndSanitizeConfiguration ( VariantType type , SenderConfiguration configuration ) { switch ( type ) { case ANDROID : if ( configuration . batchSize ( ) > 1000 ) { logger . warn ( String . format ( "Sender configuration -D%s=%s is invalid: at most 1000 tokens can be submitted to GCM i... | Validates that configuration is correct with regards to push networks limitations or implementation etc . |
30,426 | public static Boolean isAscendingOrder ( String sorting ) { return "desc" . equalsIgnoreCase ( sorting ) ? Boolean . FALSE : Boolean . TRUE ; } | Verify if the string sorting matches with asc or desc Returns FALSE when sorting query value matches desc otherwise it returns TRUE . |
30,427 | public String toStrippedJsonString ( ) { try { final Map < String , Object > json = new LinkedHashMap < > ( ) ; json . put ( "alert" , this . message . getAlert ( ) ) ; json . put ( "priority" , this . message . getPriority ( ) . toString ( ) ) ; if ( this . getMessage ( ) . getBadge ( ) > 0 ) { json . put ( "badge" , ... | Returns a JSON representation of the payload . This does not include any pushed data just the alert of the message . This also contains the entire criteria object . |
30,428 | public String toMinimizedJsonString ( ) { try { final Map < String , Object > json = new LinkedHashMap < > ( ) ; json . put ( "alert" , this . message . getAlert ( ) ) ; if ( this . getMessage ( ) . getBadge ( ) > 0 ) { json . put ( "badge" , Integer . toString ( this . getMessage ( ) . getBadge ( ) ) ) ; } json . put ... | Returns a minimized JSON representation of the payload . This does not include potentially large objects like alias or category from the given criteria . |
30,429 | protected void validateModelClass ( Object model ) { final Set < ConstraintViolation < Object > > violations = validator . validate ( model ) ; if ( ! violations . isEmpty ( ) ) { throw new ConstraintViolationException ( new HashSet < > ( violations ) ) ; } } | Generic validator used to identify constraint violations of the given model class . |
30,430 | protected ResponseBuilder createBadRequestResponse ( Set < ConstraintViolation < ? > > violations ) { final Map < String , String > responseObj = violations . stream ( ) . collect ( Collectors . toMap ( v -> v . getPropertyPath ( ) . toString ( ) , ConstraintViolation :: getMessage ) ) ; return Response . status ( Resp... | Helper function to create a 400 Bad Request response containing a JSON map giving details about the violations |
30,431 | private static void checkBlockEndContext ( RenderUnitNode node , Context endContext ) { if ( ! endContext . isValidEndContextForContentKind ( MoreObjects . firstNonNull ( node . getContentKind ( ) , SanitizedContentKind . HTML ) ) ) { String msg = String . format ( "A block of kind=\"%s\" cannot end in context %s. Like... | Checks that the end context of a block is compatible with its start context . |
30,432 | static void inferStrictRenderUnitNode ( RenderUnitNode node , Inferences inferences , ErrorReporter errorReporter ) { InferenceEngine inferenceEngine = new InferenceEngine ( inferences , errorReporter ) ; Context endContext = inferenceEngine . inferChildren ( node , Context . getStartContextForContentKind ( node . getC... | Applies strict contextual autoescaping to the given node s children . |
30,433 | private static String parseFormat ( List < ? extends TargetExpr > args ) { String numberFormatType = ! args . isEmpty ( ) ? args . get ( 0 ) . getText ( ) : "'" + DEFAULT_FORMAT + "'" ; if ( ! JS_ARGS_TO_ENUM . containsKey ( numberFormatType ) ) { String validKeys = Joiner . on ( "', '" ) . join ( JS_ARGS_TO_ENUM . key... | Validates that the provided format matches a supported format and returns the value if not this throws an exception . |
30,434 | private ProtoClass clazz ( ) { ProtoClass localClazz = clazz ; if ( localClazz == null ) { localClazz = classCache . getUnchecked ( proto . getDescriptorForType ( ) ) ; clazz = localClazz ; } return localClazz ; } | it if we can |
30,435 | public SoyValue getProtoField ( String name ) { FieldWithInterpreter field = clazz ( ) . fields . get ( name ) ; if ( field == null ) { throw new IllegalArgumentException ( "Proto " + proto . getClass ( ) . getName ( ) + " does not have a field of name " + name ) ; } if ( field . shouldCheckFieldPresenceToEmulateJspbNu... | Gets a value for the field for the underlying proto object . Not intended for general use . |
30,436 | public static < T extends Field > ImmutableMap < String , T > getFieldsForType ( Descriptor descriptor , Set < FieldDescriptor > extensions , Factory < T > factory ) { ImmutableMap . Builder < String , T > fields = ImmutableMap . builder ( ) ; for ( FieldDescriptor fieldDescriptor : descriptor . getFields ( ) ) { if ( ... | Returns the set of fields indexed by soy accessor name for the given type . |
30,437 | private Optional < SoyType > soyTypeForProtoOrEnum ( Class < ? > type , Method method ) { if ( type == Message . class ) { reporter . invalidReturnType ( Message . class , method ) ; return Optional . absent ( ) ; } Optional < String > fullName = nameFromDescriptor ( type ) ; if ( ! fullName . isPresent ( ) ) { reporte... | Attempts to discover the SoyType for a proto or proto enum reporting an error if unable to . |
30,438 | private boolean isOrContains ( SoyType type , SoyType . Kind kind ) { if ( type . getKind ( ) == kind ) { return true ; } if ( type . getKind ( ) == SoyType . Kind . UNION ) { for ( SoyType member : ( ( UnionType ) type ) . getMembers ( ) ) { if ( member . getKind ( ) == kind ) { return true ; } } } return false ; } | Returns true if the type is the given kind or contains the given kind . |
30,439 | public static String getFieldName ( Descriptors . FieldDescriptor field , boolean capitializeFirstLetter ) { String fieldName = field . getName ( ) ; if ( SPECIAL_CASES . containsKey ( fieldName ) ) { String output = SPECIAL_CASES . get ( fieldName ) ; if ( capitializeFirstLetter ) { return output ; } else { return ( (... | Returns the Java name for a proto field . |
30,440 | public static String underscoresToCamelCase ( String input , boolean capitializeNextLetter ) { StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < input . length ( ) ; i ++ ) { char ch = input . charAt ( i ) ; if ( 'a' <= ch && ch <= 'z' ) { if ( capitializeNextLetter ) { result . append ( ( char ) ( c... | Converts underscore field names to camel case while preserving camel case field names . |
30,441 | private static boolean hasConflictingClassName ( DescriptorProto messageDesc , String name ) { if ( name . equals ( messageDesc . getName ( ) ) ) { return true ; } for ( EnumDescriptorProto enumDesc : messageDesc . getEnumTypeList ( ) ) { if ( name . equals ( enumDesc . getName ( ) ) ) { return true ; } } for ( Descrip... | Used by the other overload descends recursively into messages . |
30,442 | private static boolean hasConflictingClassName ( FileDescriptorProto file , String name ) { for ( EnumDescriptorProto enumDesc : file . getEnumTypeList ( ) ) { if ( name . equals ( enumDesc . getName ( ) ) ) { return true ; } } for ( ServiceDescriptorProto serviceDesc : file . getServiceList ( ) ) { if ( name . equals ... | Checks whether any generated classes conflict with the given name . |
30,443 | public static IntegerData forValue ( long value ) { if ( value > 10 || value < - 1 ) { return new IntegerData ( value ) ; } switch ( ( int ) value ) { case - 1 : return MINUS_ONE ; case 0 : return ZERO ; case 1 : return ONE ; case 2 : return TWO ; case 3 : return THREE ; case 4 : return FOUR ; case 5 : return FIVE ; ca... | Gets a IntegerData instance for the given value . |
30,444 | PyExpr exec ( CallNode callNode , LocalVariableStack localVarStack , ErrorReporter errorReporter ) { this . localVarStack = localVarStack ; this . errorReporter = errorReporter ; PyExpr callExpr = visit ( callNode ) ; this . localVarStack = null ; this . errorReporter = null ; return callExpr ; } | Generates the Python expression for a given call . |
30,445 | protected PyExpr visitCallBasicNode ( CallBasicNode node ) { String calleeName = node . getCalleeName ( ) ; String calleeExprText ; TemplateNode template = getTemplateIfInSameFile ( node ) ; if ( template != null ) { calleeExprText = getLocalTemplateName ( template ) ; } else { int secondToLastDotIndex = calleeName . l... | Visits basic call nodes and builds the call expression . If the callee is in the file it can be accessed directly but if it s in another file the module name must be prefixed . |
30,446 | protected PyExpr visitCallDelegateNode ( CallDelegateNode node ) { ExprRootNode variantSoyExpr = node . getDelCalleeVariantExpr ( ) ; PyExpr variantPyExpr ; if ( variantSoyExpr == null ) { variantPyExpr = new PyStringExpr ( "''" ) ; } else { TranslateToPyExprVisitor translator = new TranslateToPyExprVisitor ( localVarS... | Visits a delegate call node and builds the call expression to retrieve the function and execute it . The get_delegate_fn returns the function directly so its output can be called directly . |
30,447 | public String genObjToPass ( CallNode callNode ) { TranslateToPyExprVisitor translator = new TranslateToPyExprVisitor ( localVarStack , pluginValueFactory , errorReporter ) ; String dataToPass ; if ( callNode . isPassingAllData ( ) ) { dataToPass = "data" ; } else if ( callNode . isPassingData ( ) ) { dataToPass = tran... | Generates the Python expression for the object to pass in a given call . This expression will be a combination of passed data and additional content params . If both are passed they ll be combined into one dictionary . |
30,448 | private PyExpr escapeCall ( String callExpr , ImmutableList < SoyPrintDirective > directives ) { PyExpr escapedExpr = new PyExpr ( callExpr , Integer . MAX_VALUE ) ; if ( directives . isEmpty ( ) ) { return escapedExpr ; } for ( SoyPrintDirective directive : directives ) { Preconditions . checkState ( directive instanc... | Escaping directives might apply to the output of the call node so wrap the output with all required directives . |
30,449 | static String getLocalTemplateName ( TemplateNode node ) { String templateName = node . getPartialTemplateName ( ) . substring ( 1 ) ; if ( node . getVisibility ( ) == Visibility . PRIVATE ) { return "__" + templateName ; } return templateName ; } | Returns the python name for the template . Suitable for calling within the same module . |
30,450 | void checkConformance ( ) { resetErrorReporter ( ) ; parse ( passManagerBuilder ( ) . disableAllTypeChecking ( ) . addPassContinuationRule ( SoyConformancePass . class , PassContinuationRule . STOP_AFTER_PASS ) ) ; throwIfErrorsPresent ( ) ; reportWarnings ( ) ; } | A simple tool to enforce conformance and only conformance . |
30,451 | public void extractAndWriteMsgs ( SoyMsgBundleHandler msgBundleHandler , OutputFileOptions options , ByteSink output ) throws IOException { resetErrorReporter ( ) ; SoyMsgBundle bundle = doExtractMsgs ( ) ; msgBundleHandler . writeExtractedMsgs ( bundle , options , output , errorReporter ) ; throwIfErrorsPresent ( ) ; ... | Extracts all messages from this Soy file set and writes the messages to an output sink . |
30,452 | private SoyMsgBundle doExtractMsgs ( ) { SoyFileSetNode soyTree = parse ( passManagerBuilder ( ) . allowUnknownGlobals ( ) . allowV1Expression ( ) . setTypeRegistry ( SoyTypeRegistry . DEFAULT_UNKNOWN ) . setPluginResolver ( new PluginResolver ( PluginResolver . Mode . ALLOW_UNDEFINED , printDirectives , soyFunctionMap... | Performs the parsing and extraction logic . |
30,453 | private ServerCompilationPrimitives compileForServerRendering ( ) { ParseResult result = parse ( ) ; throwIfErrorsPresent ( ) ; SoyFileSetNode soyTree = result . fileSet ( ) ; TemplateRegistry registry = result . registry ( ) ; if ( cache == null ) { new ClearSoyDocStringsVisitor ( ) . exec ( soyTree ) ; } throwIfError... | Runs common compiler logic shared by tofu and jbcsrc backends . |
30,454 | public List < String > compileToIncrementalDomSrc ( SoyIncrementalDomSrcOptions jsSrcOptions ) { resetErrorReporter ( ) ; ParseResult result = parse ( passManagerBuilder ( ) . desugarHtmlNodes ( false ) ) ; throwIfErrorsPresent ( ) ; List < String > generatedSrcs = new IncrementalDomSrcMain ( scopedData . enterable ( )... | Compiles this Soy file set into iDOM source code files and returns these JS files as a list of strings one per file . |
30,455 | void compileToPySrcFiles ( String outputPathFormat , SoyPySrcOptions pySrcOptions ) throws IOException { resetErrorReporter ( ) ; ParseResult result = parse ( ) ; throwIfErrorsPresent ( ) ; new PySrcMain ( scopedData . enterable ( ) ) . genPyFiles ( result . fileSet ( ) , pySrcOptions , outputPathFormat , errorReporter... | Compiles this Soy file set into Python source code files and writes these Python files to disk . |
30,456 | ParseResult compileMinimallyForHeaders ( ) { resetErrorReporter ( ) ; ParseResult result = parse ( passManagerBuilder ( ) . addPassContinuationRule ( ResolveExpressionTypesPass . class , PassContinuationRule . STOP_AFTER_PASS ) . allowV1Expression ( ) , typeRegistry ) ; throwIfErrorsPresent ( ) ; reportWarnings ( ) ; r... | Performs the minimal amount of work needed to calculate TemplateMetadata objects for header compilation . |
30,457 | private void reportWarnings ( ) { ImmutableList < SoyError > warnings = errorReporter . getWarnings ( ) ; if ( warnings . isEmpty ( ) ) { return ; } if ( generalOptions . getExperimentalFeatures ( ) . contains ( "testonly_throw_on_warnings" ) ) { errorReporter = null ; throw new SoyCompilationException ( warnings ) ; }... | Reports warnings ot the user configured warning sink . Should be called at the end of successful compiles . |
30,458 | @ SuppressWarnings ( "unchecked" ) public synchronized < T > T intern ( T value ) { Preconditions . checkNotNull ( value ) ; Random generator = new java . util . Random ( value . hashCode ( ) ) ; int tries = 0 ; while ( true ) { int index = generator . nextInt ( table . length ) ; Object candidate = table [ index ] ; i... | Returns either the input or an instance that equals it that was previously passed to this method . |
30,459 | @ GuardedBy ( "this" ) private void rehashIfNeeded ( ) { int currentSize = table . length ; if ( currentSize - count >= currentSize / ( MAX_EXPECTED_COLLISION_COUNT + 1 ) ) { return ; } Object [ ] oldTable = table ; int newSize = currentSize + currentSize / GROWTH_DENOMINATOR ; table = new Object [ newSize ] ; count = ... | Doubles the table size . |
30,460 | private Statement handleBasicTranslation ( List < SoyPrintDirective > escapingDirectives , Expression soyMsgParts ) { SoyExpression text = SoyExpression . forString ( soyMsgParts . invoke ( MethodRef . LIST_GET , constant ( 0 ) ) . checkedCast ( SoyMsgRawTextPart . class ) . invoke ( MethodRef . SOY_MSG_RAW_TEXT_PART_G... | Handles a translation consisting of a single raw text node . |
30,461 | private Statement handleTranslationWithPlaceholders ( MsgNode msg , ImmutableList < SoyPrintDirective > escapingDirectives , Expression soyMsgParts , Expression locale , MsgPartsAndIds partsAndId ) { Map < String , Function < Expression , Statement > > placeholderNameToPutStatement = new LinkedHashMap < > ( ) ; putPlac... | Handles a complex message with placeholders . |
30,462 | private Function < Expression , Statement > addNodeToPlaceholderMap ( String mapKey , StandaloneNode node ) { return putToMapFunction ( mapKey , placeholderCompiler . compileToSoyValueProvider ( mapKey , node , ExtraCodeCompiler . NO_OP , ExtraCodeCompiler . NO_OP ) ) ; } | Returns a statement that adds the content rendered by the call to the map . |
30,463 | public static JsExpr concatJsExprs ( List < ? extends JsExpr > jsExprs ) { if ( jsExprs . isEmpty ( ) ) { return EMPTY_STRING ; } if ( jsExprs . size ( ) == 1 ) { return jsExprs . get ( 0 ) ; } int plusOpPrec = Operator . PLUS . getPrecedence ( ) ; StringBuilder resultSb = new StringBuilder ( ) ; boolean isFirst = true... | Builds one JS expression that computes the concatenation of the given JS expressions . The + operator is used for concatenation . Operands will be protected with an extra pair of parentheses if and only if needed . |
30,464 | static JsExpr wrapWithFunction ( String functionExprText , JsExpr jsExpr ) { Preconditions . checkNotNull ( functionExprText ) ; return new JsExpr ( functionExprText + "(" + jsExpr . getText ( ) + ")" , Integer . MAX_VALUE ) ; } | Wraps an expression in a function call . |
30,465 | @ SuppressWarnings ( "unchecked" ) private int mergeRange ( ParentSoyNode < ? > parent , int start , int lastNonEmptyRawTextNode , int end ) { checkArgument ( start < end ) ; if ( start == - 1 || end == start + 1 ) { return end ; } RawTextNode newNode = RawTextNode . concat ( ( List < RawTextNode > ) parent . getChildr... | RawTextNodes and if we can remove a RawTextNode we can also add one . |
30,466 | public void writeEntry ( String path , ByteSource contents ) throws IOException { stream . putNextEntry ( new ZipEntry ( path ) ) ; contents . copyTo ( stream ) ; stream . closeEntry ( ) ; } | Writes a single entry to the jar . |
30,467 | private static Manifest standardSoyJarManifest ( ) { Manifest mf = new Manifest ( ) ; mf . getMainAttributes ( ) . put ( Attributes . Name . MANIFEST_VERSION , "1.0" ) ; mf . getMainAttributes ( ) . put ( new Attributes . Name ( "Created-By" ) , "soy" ) ; return mf ; } | Returns a simple jar manifest . |
30,468 | private void addTypeSubstitutions ( Map < Wrapper < ExprNode > , SoyType > substitutionsToAdd ) { for ( Map . Entry < Wrapper < ExprNode > , SoyType > entry : substitutionsToAdd . entrySet ( ) ) { ExprNode expr = entry . getKey ( ) . get ( ) ; SoyType previousType = expr . getType ( ) ; for ( TypeSubstitution subst = s... | active substitutions . |
30,469 | private SoyType getElementType ( SoyType collectionType , ForNonemptyNode node ) { Preconditions . checkNotNull ( collectionType ) ; switch ( collectionType . getKind ( ) ) { case UNKNOWN : return UnknownType . getInstance ( ) ; case LIST : if ( collectionType == ListType . EMPTY_LIST ) { errorReporter . report ( node ... | Given a collection type compute the element type . |
30,470 | public SoySauceBuilder withPluginInstances ( Map < String , Supplier < Object > > pluginInstances ) { this . userPluginInstances = ImmutableMap . copyOf ( pluginInstances ) ; return this ; } | Sets the plugin instance factories to be used when constructing the SoySauce . |
30,471 | SoySauceBuilder withFunctions ( Map < String , ? extends SoyFunction > userFunctions ) { this . userFunctions = ImmutableMap . copyOf ( userFunctions ) ; return this ; } | Sets the user functions . |
30,472 | SoySauceBuilder withDirectives ( Map < String , ? extends SoyPrintDirective > userDirectives ) { this . userDirectives = ImmutableMap . copyOf ( userDirectives ) ; return this ; } | Sets user directives . Not exposed externally because internal directives should be enough and additional functionality can be built as SoySourceFunctions . |
30,473 | public SoySauce build ( ) { if ( scopedData == null ) { scopedData = new SoySimpleScope ( ) ; } if ( loader == null ) { loader = SoySauceBuilder . class . getClassLoader ( ) ; } return new SoySauceImpl ( new CompiledTemplates ( readDelTemplatesFromMetaInf ( loader ) , loader ) , scopedData . enterable ( ) , userFunctio... | Creates a SoySauce . |
30,474 | private static ImmutableSet < String > readDelTemplatesFromMetaInf ( ClassLoader loader ) { try { ImmutableSet . Builder < String > builder = ImmutableSet . builder ( ) ; Enumeration < URL > resources = loader . getResources ( Names . META_INF_DELTEMPLATE_PATH ) ; while ( resources . hasMoreElements ( ) ) { URL url = r... | Walks all resources with the META_INF_DELTEMPLATE_PATH and collects the deltemplates . |
30,475 | public boolean exec ( TemplateNode template ) { boolean hasOptional = false ; for ( TemplateParam param : template . getParams ( ) ) { if ( param . isRequired ( ) ) { return false ; } else { hasOptional = true ; } } if ( hasOptional ) { return true ; } return new AbstractNodeVisitor < Node , Boolean > ( ) { boolean sho... | Runs this pass on the given template . |
30,476 | static void checkId ( String id ) { if ( ! ID . matcher ( id ) . matches ( ) ) { throw new IllegalArgumentException ( String . format ( "not a valid js identifier: %s" , id ) ) ; } } | Validates that the given string is a valid javascript identifier . |
30,477 | Iterable < ClassData > compile ( ) { List < ClassData > classes = new ArrayList < > ( ) ; if ( templateNode . getVisibility ( ) != Visibility . PRIVATE ) { new TemplateFactoryCompiler ( template , templateNode , innerClasses ) . compile ( ) ; } writer = SoyClassWriter . builder ( template . typeInfo ( ) ) . setAccess (... | Returns the list of classes needed to implement this template . |
30,478 | private void generateConstructor ( ImmutableMap < TemplateParam , SoyExpression > defaultParamInitializers ) { final Label start = new Label ( ) ; final Label end = new Label ( ) ; final LocalVariable thisVar = createThisVar ( template . typeInfo ( ) , start , end ) ; final LocalVariable paramsVar = createLocal ( "para... | Generate a public constructor that assigns our final field and checks for missing required params . |
30,479 | static void checkTypes ( ImmutableList < Type > types , Iterable < ? extends Expression > exprs ) { int size = Iterables . size ( exprs ) ; checkArgument ( size == types . size ( ) , "Supplied the wrong number of parameters. Expected %s, got %s" , types . size ( ) , size ) ; if ( Flags . DEBUG ) { int i = 0 ; for ( Exp... | Checks that the given expressions are compatible with the given types . |
30,480 | public Statement toStatement ( ) { return new Statement ( ) { protected void doGen ( CodeBuilder adapter ) { Expression . this . gen ( adapter ) ; switch ( resultType ( ) . getSize ( ) ) { case 0 : throw new AssertionError ( "void expressions are not allowed" ) ; case 1 : adapter . pop ( ) ; break ; case 2 : adapter . ... | Convert this expression to a statement by executing it and throwing away the result . |
30,481 | public Expression checkedCast ( final Type target ) { checkArgument ( target . getSort ( ) == Type . OBJECT , "cast targets must be reference types. (%s)" , target . getClassName ( ) ) ; checkArgument ( resultType ( ) . getSort ( ) == Type . OBJECT , "you may only cast from reference types. (%s)" , resultType ( ) . get... | Returns an expression that performs a checked cast from the current type to the target type . |
30,482 | public Expression labelStart ( final Label label ) { return new Expression ( resultType ( ) , features ) { protected void doGen ( CodeBuilder adapter ) { adapter . mark ( label ) ; Expression . this . gen ( adapter ) ; } } ; } | Returns a new expression identical to this one but with the given label applied at the start of the expression . |
30,483 | public void setParamsToRuntimeCheck ( Predicate < String > paramNames ) { checkState ( this . paramsToRuntimeTypeCheck == null ) ; this . paramsToRuntimeTypeCheck = checkNotNull ( paramNames ) ; } | Sets the names of the params that require runtime type checking against callee s types . |
30,484 | public static SanitizedContent cleanHtml ( SoyValue value , Collection < ? extends OptionalSafeTag > optionalSafeTags ) { value = normalizeNull ( value ) ; Dir valueDir = null ; if ( value instanceof SanitizedContent ) { SanitizedContent sanitizedContent = ( SanitizedContent ) value ; if ( sanitizedContent . getContent... | Normalizes the input HTML while preserving safe tags and the known directionality . |
30,485 | public static SanitizedContent cleanHtml ( String value , Collection < ? extends OptionalSafeTag > optionalSafeTags ) { return cleanHtml ( value , null , optionalSafeTags ) ; } | Normalizes the input HTML while preserving safe tags . The content directionality is unknown . |
30,486 | public static SanitizedContent cleanHtml ( String value , Dir contentDir , Collection < ? extends OptionalSafeTag > optionalSafeTags ) { return UnsafeSanitizedContentOrdainer . ordainAsSafe ( stripHtmlTags ( value , TagWhitelist . FORMATTING . withOptionalSafeTags ( optionalSafeTags ) , true ) , ContentKind . HTML , co... | Normalizes the input HTML of a given directionality while preserving safe tags . |
30,487 | public static String normalizeHtml ( SoyValue value ) { value = normalizeNull ( value ) ; return normalizeHtml ( value . coerceToString ( ) ) ; } | Normalizes HTML to HTML making sure quotes and other specials are entity encoded . |
30,488 | public static String normalizeHtmlNospace ( SoyValue value ) { value = normalizeNull ( value ) ; return normalizeHtmlNospace ( value . coerceToString ( ) ) ; } | Normalizes HTML to HTML making sure quotes spaces and other specials are entity encoded so that the result can be safely embedded in a valueless attribute . |
30,489 | public static String escapeHtmlAttribute ( SoyValue value ) { value = normalizeNull ( value ) ; if ( isSanitizedContentOfKind ( value , SanitizedContent . ContentKind . HTML ) ) { return stripHtmlTags ( value . coerceToString ( ) , null , true ) ; } return escapeHtmlAttribute ( value . coerceToString ( ) ) ; } | Converts the input to HTML by entity escaping stripping tags in sanitized content so the result can safely be embedded in an HTML attribute value . |
30,490 | public static String escapeHtmlAttributeNospace ( SoyValue value ) { value = normalizeNull ( value ) ; if ( isSanitizedContentOfKind ( value , SanitizedContent . ContentKind . HTML ) ) { return stripHtmlTags ( value . coerceToString ( ) , null , false ) ; } return escapeHtmlAttributeNospace ( value . coerceToString ( )... | Converts plain text to HTML by entity escaping stripping tags in sanitized content so the result can safely be embedded in an unquoted HTML attribute value . |
30,491 | public static String escapeUri ( SoyValue value ) { value = normalizeNull ( value ) ; return escapeUri ( value . coerceToString ( ) ) ; } | Converts the input to a piece of a URI by percent encoding the value as UTF - 8 bytes . |
30,492 | public static String filterNormalizeMediaUri ( String value ) { if ( EscapingConventions . FilterNormalizeMediaUri . INSTANCE . getValueFilter ( ) . matcher ( value ) . find ( ) ) { return EscapingConventions . FilterNormalizeMediaUri . INSTANCE . escape ( value ) ; } logger . log ( Level . WARNING , "|filterNormalizeM... | Checks that a URI is safe to be an image source . |
30,493 | public static String filterTrustedResourceUri ( SoyValue value ) { value = normalizeNull ( value ) ; if ( isSanitizedContentOfKind ( value , SanitizedContent . ContentKind . TRUSTED_RESOURCE_URI ) ) { return value . coerceToString ( ) ; } logger . log ( Level . WARNING , "|filterTrustedResourceUri received bad value ''... | Makes sure the given input is an instance of either trustedResourceUrl or trustedString . |
30,494 | public static SanitizedContent filterImageDataUri ( SoyValue value ) { value = normalizeNull ( value ) ; return filterImageDataUri ( value . coerceToString ( ) ) ; } | Makes sure that the given input is a data URI corresponding to an image . |
30,495 | public static SanitizedContent filterSipUri ( SoyValue value ) { value = normalizeNull ( value ) ; return filterSipUri ( value . coerceToString ( ) ) ; } | Makes sure that the given input is a sip URI . |
30,496 | public static SanitizedContent filterTelUri ( SoyValue value ) { value = normalizeNull ( value ) ; return filterTelUri ( value . coerceToString ( ) ) ; } | Makes sure that the given input is a tel URI . |
30,497 | public static String filterHtmlAttributes ( SoyValue value ) { value = normalizeNull ( value ) ; if ( isSanitizedContentOfKind ( value , SanitizedContent . ContentKind . ATTRIBUTES ) ) { String content = value . coerceToString ( ) ; if ( content . length ( ) > 0 ) { if ( shouldAppendSpace ( content . charAt ( content .... | Checks that the input is a valid HTML attribute name with normal keyword or textual content or known safe attribute content . |
30,498 | public static String filterHtmlAttributes ( String value ) { if ( EscapingConventions . FilterHtmlAttributes . INSTANCE . getValueFilter ( ) . matcher ( value ) . find ( ) ) { return value ; } logger . log ( Level . WARNING , "|filterHtmlAttributes received bad value ''{0}''" , value ) ; return EscapingConventions . Fi... | Checks that the input is a valid HTML attribute name with normal keyword or textual content . |
30,499 | private static boolean isSanitizedContentOfKind ( SoyValue value , SanitizedContent . ContentKind kind ) { return value instanceof SanitizedContent && kind == ( ( SanitizedContent ) value ) . getContentKind ( ) ; } | True iff the given value is sanitized content of the given kind . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.