idx
int64 0
41.2k
| question
stringlengths 73
5.81k
| target
stringlengths 5
918
|
|---|---|---|
5,400
|
private String tokenize ( String text ) throws JellyException { int parenthesis = 0 ; for ( int idx = 0 ; idx < text . length ( ) ; idx ++ ) { char ch = text . charAt ( idx ) ; switch ( ch ) { case ',' : if ( parenthesis == 0 ) return text . substring ( 0 , idx ) ; break ; case '(' : case '{' : case '[' : parenthesis ++ ; break ; case ')' : if ( parenthesis == 0 ) return text . substring ( 0 , idx ) ; case '}' : case ']' : parenthesis -- ; break ; case '"' : case '\'' : idx = text . indexOf ( ch , idx + 1 ) ; break ; } } throw new JellyException ( expressionText + " is missing ')' at the end" ) ; }
|
Takes a string like arg ) or arg arg ... ) then find arg and returns it .
|
5,401
|
public static < T > Class < T > erasure ( Type t ) { return eraser . visit ( t , null ) ; }
|
Returns the runtime representation of the given type .
|
5,402
|
public static Type getBaseClass ( Type type , Class baseType ) { return baseClassFinder . visit ( type , baseType ) ; }
|
Gets the parameterization of the given base type .
|
5,403
|
private void ensureDependencies ( XMLOutput out ) throws JellyTagException { AdjunctsInPage adjuncts = AdjunctsInPage . get ( ) ; if ( adjuncts . isIncluded ( "org.kohsuke.stapler.framework.prototype.prototype" ) ) return ; if ( adjuncts . isIncluded ( "org.kohsuke.stapler.jquery" ) ) { include ( out , "org.kohsuke.stapler.json2" ) ; } else { include ( out , "org.kohsuke.stapler.framework.prototype.prototype" ) ; } }
|
Ensures that we have the dependencies properly available to run bind . js .
|
5,404
|
public final String getProxyScript ( ) { StringBuilder buf = new StringBuilder ( "makeStaplerProxy('" ) . append ( getURL ( ) ) . append ( "','" ) . append ( WebApp . getCurrent ( ) . getCrumbIssuer ( ) . issueCrumb ( ) ) . append ( "',[" ) ; boolean first = true ; for ( Method m : getTarget ( ) . getClass ( ) . getMethods ( ) ) { Collection < String > names ; if ( m . getName ( ) . startsWith ( "js" ) ) { names = Collections . singleton ( camelize ( m . getName ( ) . substring ( 2 ) ) ) ; } else { JavaScriptMethod a = m . getAnnotation ( JavaScriptMethod . class ) ; if ( a != null ) { names = Arrays . asList ( a . name ( ) ) ; if ( names . isEmpty ( ) ) names = Collections . singleton ( m . getName ( ) ) ; } else continue ; } for ( String n : names ) { if ( first ) first = false ; else buf . append ( ',' ) ; buf . append ( '\'' ) . append ( n ) . append ( '\'' ) ; } } buf . append ( "])" ) ; return buf . toString ( ) ; }
|
Returns a JavaScript expression which evaluates to a JavaScript proxy that talks back to the bound object that this handle represents .
|
5,405
|
public String _ ( String key , Object ... args ) { ResourceBundle resourceBundle = getResourceBundle ( ) ; args = Stapler . htmlSafeArguments ( args ) ; return resourceBundle . format ( LocaleProvider . getLocale ( ) , key , args ) ; }
|
Looks up the resource bundle with the given key formats with arguments then return that formatted string .
|
5,406
|
private TagScript createTagScript ( QName n , Map < ? , ? > attributes ) throws JellyException { TagLibrary lib = context . getTagLibrary ( n . getNamespaceURI ( ) ) ; if ( lib != null ) { String localName = n . getLocalPart ( ) ; TagScript tagScript = lib . createTagScript ( localName , null ) ; if ( tagScript == null ) tagScript = lib . createTagScript ( localName . replace ( '_' , '-' ) , null ) ; if ( tagScript != null ) { if ( attributes != null ) { for ( Entry e : attributes . entrySet ( ) ) { Object v = e . getValue ( ) ; if ( v != null ) tagScript . addAttribute ( e . getKey ( ) . toString ( ) , new ConstantExpression ( v ) ) ; } } return tagScript ; } } return null ; }
|
Create a tag script if the given QName is a taglib invocation or return null to handle it like a literal static tag .
|
5,407
|
private Object getValue ( Entry entry , Class type ) { Object value = entry . getValue ( ) ; if ( type == Expression . class ) value = new ConstantExpression ( entry . getValue ( ) ) ; return value ; }
|
Obtains the value from the map entry in the right type .
|
5,408
|
public Element redirectToDom ( Closure c ) { SAXContentHandler sc = new SAXContentHandler ( ) ; with ( new XMLOutput ( sc ) , c ) ; return sc . getDocument ( ) . getRootElement ( ) ; }
|
Captures the XML fragment generated by the given closure into dom4j DOM tree and return the root element .
|
5,409
|
public void text ( Object o ) throws SAXException { if ( o != null ) output . write ( escape ( o . toString ( ) ) ) ; }
|
Writes PCDATA .
|
5,410
|
public void raw ( Object o ) throws SAXException { if ( o != null ) output . write ( o . toString ( ) ) ; }
|
Generates HTML fragment from string .
|
5,411
|
public Object taglib ( Class type ) throws IllegalAccessException , InstantiationException , IOException , SAXException { GroovyClosureScript o = taglibs . get ( type ) ; if ( o == null ) { o = ( GroovyClosureScript ) type . newInstance ( ) ; o . setDelegate ( this ) ; taglibs . put ( type , o ) ; adjunct ( type . getName ( ) ) ; } return o ; }
|
Loads a Groovy tag lib instance .
|
5,412
|
public void adjunct ( String name ) throws IOException , SAXException { try { AdjunctsInPage aip = AdjunctsInPage . get ( ) ; aip . generate ( output , name ) ; } catch ( NoSuchAdjunctException e ) { } }
|
Includes the specified adjunct .
|
5,413
|
public Namespace jelly ( Class t ) { String n = t . getName ( ) ; if ( TagLibrary . class . isAssignableFrom ( t ) ) { context . registerTagLibrary ( n , n ) ; } else { String path = n . replace ( '.' , '/' ) ; URL res = t . getClassLoader ( ) . getResource ( path + "/taglib" ) ; if ( res != null ) { JellyContext parseContext = MetaClassLoader . get ( t . getClassLoader ( ) ) . loadTearOff ( JellyClassLoaderTearOff . class ) . createContext ( ) ; context . registerTagLibrary ( n , new CustomTagLibrary ( parseContext , t . getClassLoader ( ) , n , path ) ) ; } else { throw new IllegalArgumentException ( "Cannot find taglib from " + t ) ; } } return new Namespace ( this , n , "-" ) ; }
|
Loads a jelly tag library .
|
5,414
|
public String res ( Object base , String localName ) { Class c ; if ( base instanceof Class ) c = ( Class ) base ; else c = base . getClass ( ) ; return adjunctManager . rootURL + '/' + c . getName ( ) . replace ( '.' , '/' ) + '/' + localName ; }
|
Yields a URL to the given resource .
|
5,415
|
public FunctionList union ( FunctionList that ) { Set < Function > combined = new LinkedHashSet < Function > ( ) ; combined . addAll ( Arrays . asList ( this . functions ) ) ; combined . addAll ( Arrays . asList ( that . functions ) ) ; return new FunctionList ( combined ) ; }
|
Compute set unions of two lists .
|
5,416
|
public boolean isArray ( C clazz ) { Class j = toJavaClass ( clazz ) ; return j . isArray ( ) || List . class . isAssignableFrom ( j ) ; }
|
If the given type is an array that supports index retrieval .
|
5,417
|
private Object instantiate ( Class actualType , JSONObject j ) { Object r = bindInterceptor . instantiate ( actualType , j ) ; if ( r != BindInterceptor . DEFAULT ) return r ; for ( BindInterceptor bi : getWebApp ( ) . bindInterceptors ) { r = bi . instantiate ( actualType , j ) ; if ( r != BindInterceptor . DEFAULT ) return r ; } if ( actualType == JSONObject . class || actualType == JSON . class ) return actualType . cast ( j ) ; String [ ] names = new ClassDescriptor ( actualType ) . loadConstructorParamNames ( ) ; Object [ ] args = new Object [ names . length ] ; Constructor c = findConstructor ( actualType , names . length ) ; Class [ ] types = c . getParameterTypes ( ) ; Type [ ] genTypes = c . getGenericParameterTypes ( ) ; for ( int i = 0 ; i < names . length ; i ++ ) { try { args [ i ] = bindJSON ( genTypes [ i ] , types [ i ] , j . get ( names [ i ] ) ) ; } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException ( "Failed to convert the " + names [ i ] + " parameter of the constructor " + c , e ) ; } } Object o = injectSetters ( invokeConstructor ( c , args ) , j , Arrays . asList ( names ) ) ; o = bindResolve ( o , j ) ; return o ; }
|
Called after the actual type of the binding is figured out .
|
5,418
|
private void invokePostConstruct ( SingleLinkedList < MethodRef > methods , Object r ) { if ( methods . isEmpty ( ) ) return ; invokePostConstruct ( methods . tail , r ) ; try { methods . head . invoke ( r ) ; } catch ( InvocationTargetException e ) { throw new IllegalArgumentException ( "Unable to post-construct " + r , e ) ; } catch ( IllegalAccessException e ) { throw ( Error ) new IllegalAccessError ( ) . initCause ( e ) ; } }
|
Invoke PostConstruct method from the base class to subtypes .
|
5,419
|
protected URL findResource ( Klass c , String fileName ) { boolean ends = false ; for ( String ext : allowedExtensions ) { if ( fileName . endsWith ( ext ) ) { ends = true ; break ; } } if ( ! ends ) return null ; for ( ; c != null ; c = c . getSuperClass ( ) ) { URL res = c . getResource ( fileName ) ; if ( res != null ) return res ; } return null ; }
|
Determines if this resource can be served
|
5,420
|
public static Annotation [ ] union ( Annotation [ ] a , Annotation [ ] b ) { if ( a . length == 0 ) return b ; if ( b . length == 0 ) return a ; List < Annotation > combined = new ArrayList < Annotation > ( a . length + b . length ) ; combined . addAll ( Arrays . asList ( a ) ) ; OUTER : for ( Annotation x : b ) { for ( int i = 0 ; i < a . length ; i ++ ) { if ( x . annotationType ( ) == combined . get ( i ) . annotationType ( ) ) { combined . set ( i , x ) ; continue OUTER ; } } combined . add ( x ) ; } return combined . toArray ( new Annotation [ combined . size ( ) ] ) ; }
|
Merge two sets of annotations . If both contains the same annotation the definition in b overrides the definition in a and shows up in the result
|
5,421
|
private void indent ( ) throws IOException { if ( indent >= 0 ) { out . write ( '\n' ) ; for ( int i = indent * 2 ; i > 0 ; ) { int len = Math . min ( i , INDENT . length ) ; out . write ( INDENT , 0 , len ) ; i -= len ; } } }
|
Prints indentation .
|
5,422
|
static String decamelize ( String s ) { return s . replaceAll ( "(\\p{javaLetterOrDigit})(\\p{javaUpperCase}\\p{javaLowerCase})" , "$1_$2" ) . replaceAll ( "(\\p{javaLowerCase})(\\p{javaUpperCase})" , "$1_$2" ) . toLowerCase ( Locale . ENGLISH ) ; }
|
Converts FooBarZot to foo_bar_zot
|
5,423
|
public void invokeTaglib ( final IJRubyContext rcon , JellyContext context , XMLOutput output , String uri , String localName , Map < RubySymbol , ? > attributes , final RubyProc proc ) throws JellyException { TagScript tagScript = createTagScript ( context , uri , localName ) ; if ( attributes != null ) { for ( Entry < RubySymbol , ? > e : attributes . entrySet ( ) ) { tagScript . addAttribute ( e . getKey ( ) . asJavaString ( ) , new ConstantExpression ( e . getValue ( ) ) ) ; } } if ( proc != null ) { final Ruby runtime = ( ( IRubyObject ) rcon ) . getRuntime ( ) ; tagScript . setTagBody ( new Script ( ) { public Script compile ( ) throws JellyException { return this ; } public void run ( JellyContext context , XMLOutput output ) throws JellyTagException { JellyContext oc = rcon . getJellyContext ( ) ; XMLOutput oo = rcon . getOutput ( ) ; try { rcon . setJellyContext ( context ) ; rcon . setOutput ( output ) ; proc . getBlock ( ) . yield ( runtime . getCurrentContext ( ) , null ) ; } finally { rcon . setJellyContext ( oc ) ; rcon . setOutput ( oo ) ; } } } ) ; } tagScript . run ( context , output ) ; }
|
Invokes other Jelly tag libraries .
|
5,424
|
public void buildResourcePaths ( ) { try { if ( Boolean . getBoolean ( Stapler . class . getName ( ) + ".noResourcePathCache" ) ) { resourcePaths = null ; return ; } Map < String , URL > paths = new HashMap < String , URL > ( ) ; Stack < String > q = new Stack < String > ( ) ; q . push ( "/" ) ; while ( ! q . isEmpty ( ) ) { String dir = q . pop ( ) ; Set < String > children = context . getResourcePaths ( dir ) ; if ( children != null ) { for ( String child : children ) { if ( child . endsWith ( "/" ) ) q . push ( child ) ; else { URL v = context . getResource ( child ) ; if ( v == null ) { resourcePaths = null ; return ; } paths . put ( child , v ) ; } } } } resourcePaths = Collections . unmodifiableMap ( paths ) ; } catch ( MalformedURLException e ) { resourcePaths = null ; } }
|
Rebuild the internal cache for static resources .
|
5,425
|
public void invoke ( HttpServletRequest req , HttpServletResponse rsp , Object root , String url ) throws IOException , ServletException { RequestImpl sreq = new RequestImpl ( this , req , new ArrayList < AncestorImpl > ( ) , new TokenList ( url ) ) ; RequestImpl oreq = CURRENT_REQUEST . get ( ) ; CURRENT_REQUEST . set ( sreq ) ; ResponseImpl srsp = new ResponseImpl ( this , rsp ) ; ResponseImpl orsp = CURRENT_RESPONSE . get ( ) ; CURRENT_RESPONSE . set ( srsp ) ; try { invoke ( sreq , srsp , root ) ; } finally { CURRENT_REQUEST . set ( oreq ) ; CURRENT_RESPONSE . set ( orsp ) ; } }
|
Performs stapler processing on the given root object and request URL .
|
5,426
|
public static boolean isSocketException ( Throwable x ) { if ( x == null ) { return false ; } if ( x instanceof SocketException ) { return true ; } if ( String . valueOf ( x . getMessage ( ) ) . equals ( "Broken pipe" ) ) { return true ; } if ( x instanceof EOFException ) { return true ; } if ( x instanceof IOException && "Closed" . equals ( x . getMessage ( ) ) ) { return true ; } if ( x instanceof IOException && "finished" . equals ( x . getMessage ( ) ) ) { return true ; } return isSocketException ( x . getCause ( ) ) ; }
|
Used to detect exceptions thrown when writing content that seem to be due merely to a closed socket .
|
5,427
|
void invoke ( RequestImpl req , ResponseImpl rsp , Object node ) throws IOException , ServletException { if ( node == null ) { if ( ! Dispatcher . isTraceEnabled ( req ) ) { rsp . sendError ( SC_NOT_FOUND ) ; } else { rsp . setStatus ( SC_NOT_FOUND ) ; rsp . setContentType ( "text/html;charset=UTF-8" ) ; PrintWriter w = rsp . getWriter ( ) ; w . println ( "<html><body>" ) ; w . println ( "<h1>404 Not Found</h1>" ) ; w . println ( "<p>Stapler processed this HTTP request as follows, but couldn't find the resource to consume the request" ) ; w . println ( "<pre>" ) ; EvaluationTrace . get ( req ) . printHtml ( w ) ; w . println ( "<font color=red>-> unexpected null!</font>" ) ; w . println ( "</pre>" ) ; w . println ( "<p>If this 404 is unexpected, double check the last part of the trace to see if it should have evaluated to null." ) ; w . println ( "</body></html>" ) ; } return ; } if ( tryInvoke ( req , rsp , node ) ) return ; if ( ! Dispatcher . isTraceEnabled ( req ) ) { rsp . sendError ( SC_NOT_FOUND ) ; } else { rsp . setStatus ( SC_NOT_FOUND ) ; rsp . setContentType ( "text/html;charset=UTF-8" ) ; PrintWriter w = rsp . getWriter ( ) ; w . println ( "<html><body>" ) ; w . println ( "<h1>404 Not Found</h1>" ) ; w . println ( "<p>Stapler processed this HTTP request as follows, but couldn't find the resource to consume the request" ) ; w . println ( "<pre>" ) ; EvaluationTrace . get ( req ) . printHtml ( w ) ; w . printf ( "<font color=red>-> No matching rule was found on <%s> for \"%s\"</font>\n" , escape ( node . toString ( ) ) , req . tokens . assembleOriginalRestOfPath ( ) ) ; w . println ( "</pre>" ) ; w . printf ( "<p><%s> has the following URL mappings, in the order of preference:" , escape ( node . toString ( ) ) ) ; w . println ( "<ol>" ) ; MetaClass metaClass = webApp . getMetaClass ( node ) ; for ( Dispatcher d : metaClass . dispatchers ) { w . println ( "<li>" ) ; w . println ( d . toString ( ) ) ; } w . println ( "</ol>" ) ; w . println ( "</body></html>" ) ; } }
|
Try to dispatch the request against the given node and if it fails report an error to the client .
|
5,428
|
@ SuppressWarnings ( { "ThrowableInstanceNeverThrown" } ) public static HttpResponseException error ( int code , String errorMessage ) { return error ( code , new Exception ( errorMessage ) ) ; }
|
Sends an error with a stack trace .
|
5,429
|
public static HttpResponseException errorWithoutStack ( final int code , final String errorMessage ) { return new HttpResponseException ( ) { public void generateResponse ( StaplerRequest req , StaplerResponse rsp , Object node ) throws IOException , ServletException { rsp . sendError ( code , errorMessage ) ; } } ; }
|
Sends an error without a stack trace .
|
5,430
|
public static HttpResponse staticResource ( final URL resource , final long expiration ) { return new HttpResponse ( ) { public void generateResponse ( StaplerRequest req , StaplerResponse rsp , Object node ) throws IOException , ServletException { rsp . serveFile ( req , resource , expiration ) ; } } ; }
|
Serves a static resource specified by the URL .
|
5,431
|
public static HttpResponse literalHtml ( final String text ) { return new HttpResponse ( ) { public void generateResponse ( StaplerRequest req , StaplerResponse rsp , Object node ) throws IOException , ServletException { rsp . setContentType ( "text/html;charset=UTF-8" ) ; PrintWriter pw = rsp . getWriter ( ) ; pw . print ( text ) ; pw . flush ( ) ; } } ; }
|
Serves an HTML response .
|
5,432
|
static boolean retainPresenterInstance ( boolean keepPresenterInstance , Controller controller ) { return keepPresenterInstance && ( controller . getActivity ( ) . isChangingConfigurations ( ) || ! controller . getActivity ( ) . isFinishing ( ) ) && ! controller . isBeingDestroyed ( ) ; }
|
Determines whether or not a Presenter Instance should be kept
|
5,433
|
StreamingConnectionImpl connect ( ) throws IOException , InterruptedException { boolean exThrown = false ; io . nats . client . Connection nc = getNatsConnection ( ) ; if ( nc == null ) { nc = createNatsConnection ( ) ; setNatsConnection ( nc ) ; ncOwned = true ; } else if ( nc . getStatus ( ) != Connection . Status . CONNECTED ) { throw new IOException ( NatsStreaming . ERR_BAD_CONNECTION ) ; } try { this . hbSubject = this . newInbox ( ) ; this . ackSubject = String . format ( "%s.%s" , NatsStreaming . DEFAULT_ACK_PREFIX , this . nuid . next ( ) ) ; this . ackDispatcher = nc . createDispatcher ( msg -> { this . processAck ( msg ) ; } ) ; this . heartbeatDispatcher = nc . createDispatcher ( msg -> { this . processHeartBeat ( msg ) ; } ) ; this . messageDispatcher = nc . createDispatcher ( msg -> { this . processMsg ( msg ) ; } ) ; this . heartbeatDispatcher . subscribe ( this . hbSubject ) ; this . ackDispatcher . subscribe ( this . ackSubject ) ; this . heartbeatDispatcher . setPendingLimits ( - 1 , - 1 ) ; this . ackDispatcher . setPendingLimits ( - 1 , - 1 ) ; this . messageDispatcher . setPendingLimits ( - 1 , - 1 ) ; this . customDispatchers = new HashMap < > ( ) ; String discoverSubject = String . format ( "%s.%s" , opts . getDiscoverPrefix ( ) , clusterId ) ; ConnectRequest req = ConnectRequest . newBuilder ( ) . setClientID ( clientId ) . setHeartbeatInbox ( this . hbSubject ) . build ( ) ; byte [ ] bytes = req . toByteArray ( ) ; Message reply = nc . request ( discoverSubject , bytes , opts . getConnectTimeout ( ) ) ; if ( reply == null ) { throw new IOException ( ERR_CONNECTION_REQ_TIMEOUT ) ; } ConnectResponse cr = ConnectResponse . parseFrom ( reply . getData ( ) ) ; if ( ! cr . getError ( ) . isEmpty ( ) ) { throw new IOException ( cr . getError ( ) ) ; } pubPrefix = cr . getPubPrefix ( ) ; subRequests = cr . getSubRequests ( ) ; unsubRequests = cr . getUnsubRequests ( ) ; subCloseRequests = cr . getSubCloseRequests ( ) ; closeRequests = cr . getCloseRequests ( ) ; pubAckMap = new HashMap < > ( ) ; subMap = new HashMap < > ( ) ; pubAckChan = new LinkedBlockingQueue < > ( opts . getMaxPubAcksInFlight ( ) ) ; } catch ( IOException e ) { exThrown = true ; throw e ; } finally { if ( exThrown ) { try { close ( ) ; } catch ( Exception e ) { } } } return this ; }
|
Connect will form a connection to the STAN subsystem .
|
5,434
|
public void publish ( String subject , byte [ ] data ) throws IOException , InterruptedException , TimeoutException { final BlockingQueue < String > ch = createErrorChannel ( ) ; publish ( subject , data , null , ch ) ; String err ; if ( ! ch . isEmpty ( ) ) { err = ch . take ( ) ; if ( ! err . isEmpty ( ) ) { throw new IOException ( err ) ; } } }
|
Publish will publish to the cluster and wait for an ACK .
|
5,435
|
void processAck ( Message msg ) { PubAck pa ; Exception ex = null ; try { pa = PubAck . parseFrom ( msg . getData ( ) ) ; } catch ( InvalidProtocolBufferException e ) { System . err . println ( "Protocol error: " + e . getStackTrace ( ) ) ; return ; } AckClosure ackClosure = removeAck ( pa . getGuid ( ) ) ; if ( ackClosure != null ) { String ackError = pa . getError ( ) ; if ( ackClosure . ah != null ) { if ( ! ackError . isEmpty ( ) ) { ex = new IOException ( ackError ) ; } ackClosure . ah . onAck ( pa . getGuid ( ) , ex ) ; } else if ( ackClosure . ch != null ) { try { ackClosure . ch . put ( ackError ) ; } catch ( InterruptedException e ) { } } } }
|
Process an ack from the STAN cluster
|
5,436
|
public void ack ( ) throws IOException { String ackSubject ; boolean isManualAck ; StreamingConnectionImpl sc ; sub . rLock ( ) ; try { ackSubject = sub . getAckInbox ( ) ; isManualAck = sub . getOptions ( ) . isManualAcks ( ) ; sc = sub . getConnection ( ) ; } finally { sub . rUnlock ( ) ; } if ( sc == null ) { throw new IllegalStateException ( NatsStreaming . ERR_BAD_SUBSCRIPTION ) ; } if ( ! isManualAck ) { throw new IllegalStateException ( StreamingConnectionImpl . ERR_MANUAL_ACK ) ; } Ack ack = Ack . newBuilder ( ) . setSubject ( getSubject ( ) ) . setSequence ( getSequence ( ) ) . build ( ) ; sc . getNatsConnection ( ) . publish ( ackSubject , ack . toByteArray ( ) ) ; }
|
Acknowledges the message to the streaming cluster .
|
5,437
|
public static List < Integer > msgsPerClient ( int numMsgs , int numClients ) { List < Integer > counts = new ArrayList < Integer > ( numClients ) ; if ( numClients == 0 || numMsgs == 0 ) { return counts ; } int mc = numMsgs / numClients ; for ( int i = 0 ; i < numClients ; i ++ ) { counts . add ( mc ) ; } int extra = numMsgs % numClients ; for ( int i = 0 ; i < extra ; i ++ ) { counts . set ( i , counts . get ( i ) + 1 ) ; } return counts ; }
|
MsgsPerClient divides the number of messages by the number of clients and tries to distribute them as evenly as possible .
|
5,438
|
public long getStartTime ( TimeUnit unit ) { long totalNanos = TimeUnit . SECONDS . toNanos ( startTime . getEpochSecond ( ) ) ; totalNanos += startTime . getNano ( ) ; return unit . convert ( totalNanos , TimeUnit . NANOSECONDS ) ; }
|
Returns the desired start time position in the requested units .
|
5,439
|
public StreamingConnection createConnection ( ) throws IOException , InterruptedException { StreamingConnectionImpl conn = new StreamingConnectionImpl ( clusterId , clientId , options ( ) ) ; conn . connect ( ) ; return conn ; }
|
Creates an active connection to a NATS Streaming server .
|
5,440
|
public void setAckTimeout ( long ackTimeout , TimeUnit unit ) { this . ackTimeout = Duration . ofMillis ( unit . toMillis ( ackTimeout ) ) ; }
|
Sets the ACK timeout in the specified time unit .
|
5,441
|
public void setConnectTimeout ( long connectTimeout , TimeUnit unit ) { this . connectTimeout = Duration . ofMillis ( unit . toMillis ( connectTimeout ) ) ; }
|
Sets the connect timeout in the specified time unit .
|
5,442
|
private static Duration parseDuration ( String duration ) throws ParseException { Matcher matcher = pattern . matcher ( duration ) ; long nanoseconds = 0L ; if ( matcher . find ( ) && matcher . groupCount ( ) == 4 ) { int days = Integer . parseInt ( matcher . group ( 1 ) ) ; nanoseconds += TimeUnit . NANOSECONDS . convert ( days , TimeUnit . DAYS ) ; int hours = Integer . parseInt ( matcher . group ( 2 ) ) ; nanoseconds += TimeUnit . NANOSECONDS . convert ( hours , TimeUnit . HOURS ) ; int minutes = Integer . parseInt ( matcher . group ( 3 ) ) ; nanoseconds += TimeUnit . NANOSECONDS . convert ( minutes , TimeUnit . MINUTES ) ; int seconds = Integer . parseInt ( matcher . group ( 4 ) ) ; nanoseconds += TimeUnit . NANOSECONDS . convert ( seconds , TimeUnit . SECONDS ) ; long nanos = Long . parseLong ( matcher . group ( 5 ) ) ; nanoseconds += nanos ; } else { throw new ParseException ( "Cannot parse duration " + duration , 0 ) ; } return Duration . ofNanos ( nanoseconds ) ; }
|
Parses a duration string of the form 98d 01h 23m 45s into milliseconds .
|
5,443
|
public static void main ( String [ ] args ) throws Exception { try { new Subscriber ( args ) . run ( ) ; } catch ( IllegalArgumentException e ) { System . out . flush ( ) ; System . err . println ( e . getMessage ( ) ) ; Subscriber . usage ( ) ; System . err . flush ( ) ; throw e ; } }
|
Subscribes to a subject .
|
5,444
|
public static StreamingConnection connect ( String clusterId , String clientId ) throws IOException , InterruptedException { return connect ( clusterId , clientId , defaultOptions ( ) ) ; }
|
Creates a NATS Streaming connection using the supplied cluster ID and client ID .
|
5,445
|
public void set ( String key , Object value ) { if ( ! StringUtil . isEmpty ( key ) && null != value ) { pendingInstanceData . put ( key , value ) ; } }
|
Add a key - value pair to this conversation
|
5,446
|
public Object get ( String key ) { if ( ! StringUtil . isEmpty ( key ) ) { if ( pendingInstanceData . containsKey ( key ) ) { return pendingInstanceData . get ( key ) ; } if ( instanceData . containsKey ( key ) ) { return instanceData . get ( key ) ; } } return null ; }
|
Access a value
|
5,447
|
public void updateMessage ( final AVIMMessage oldMessage , final AVIMMessage newMessage , final AVIMMessageUpdatedCallback callback ) { if ( null == oldMessage || null == newMessage ) { if ( null != callback ) { callback . internalDone ( new AVException ( new IllegalArgumentException ( "oldMessage/newMessage shouldn't be null" ) ) ) ; } return ; } final AVIMCommonJsonCallback tmpCallback = new AVIMCommonJsonCallback ( ) { public void done ( Map < String , Object > result , AVIMException e ) { if ( null != e || null == result ) { if ( null != callback ) { callback . internalDone ( null , e ) ; } } else { long patchTime = 0 ; if ( result . containsKey ( Conversation . PARAM_MESSAGE_PATCH_TIME ) ) { patchTime = ( Long ) result . get ( Conversation . PARAM_MESSAGE_PATCH_TIME ) ; } copyMessageWithoutContent ( oldMessage , newMessage ) ; newMessage . setUpdateAt ( patchTime ) ; updateLocalMessage ( newMessage ) ; if ( null != callback ) { callback . internalDone ( newMessage , null ) ; } } } } ; InternalConfiguration . getOperationTube ( ) . updateMessage ( client . getClientId ( ) , getType ( ) , oldMessage , newMessage , tmpCallback ) ; }
|
update message content
|
5,448
|
public static AVIMConversation parseFromJson ( AVIMClient client , JSONObject jsonObj ) { if ( null == jsonObj || null == client ) { return null ; } String conversationId = jsonObj . getString ( AVObject . KEY_OBJECT_ID ) ; if ( StringUtil . isEmpty ( conversationId ) ) { return null ; } boolean systemConv = false ; boolean transientConv = false ; boolean tempConv = false ; if ( jsonObj . containsKey ( Conversation . SYSTEM ) ) { systemConv = jsonObj . getBoolean ( Conversation . SYSTEM ) ; } if ( jsonObj . containsKey ( Conversation . TRANSIENT ) ) { transientConv = jsonObj . getBoolean ( Conversation . TRANSIENT ) ; } if ( jsonObj . containsKey ( Conversation . TEMPORARY ) ) { tempConv = jsonObj . getBoolean ( Conversation . TEMPORARY ) ; } AVIMConversation originConv = null ; if ( systemConv ) { originConv = new AVIMServiceConversation ( client , conversationId ) ; } else if ( tempConv ) { originConv = new AVIMTemporaryConversation ( client , conversationId ) ; } else if ( transientConv ) { originConv = new AVIMChatRoom ( client , conversationId ) ; } else { originConv = new AVIMConversation ( client , conversationId ) ; } originConv . latestConversationFetch = System . currentTimeMillis ( ) ; return updateConversation ( originConv , jsonObj ) ; }
|
parse AVIMConversation from jsonObject
|
5,449
|
public static AVIMClient getInstance ( String clientId ) { if ( StringUtil . isEmpty ( clientId ) ) { return null ; } AVIMClient client = clients . get ( clientId ) ; if ( null == client ) { client = new AVIMClient ( clientId ) ; AVIMClient elderClient = clients . putIfAbsent ( clientId , client ) ; if ( null != elderClient ) { client = elderClient ; } } return client ; }
|
get AVIMClient instance by clientId .
|
5,450
|
public static AVIMClient getInstance ( String clientId , String tag ) { AVIMClient client = getInstance ( clientId ) ; client . tag = tag ; return client ; }
|
get AVIMClient instance by clientId and tag .
|
5,451
|
public static AVIMClient getInstance ( AVUser user ) { if ( null == user ) { return null ; } String clientId = user . getObjectId ( ) ; String sessionToken = user . getSessionToken ( ) ; if ( StringUtil . isEmpty ( clientId ) || StringUtil . isEmpty ( sessionToken ) ) { return null ; } AVIMClient client = getInstance ( clientId ) ; client . userSessionToken = sessionToken ; return client ; }
|
get AVIMClient instance by AVUser
|
5,452
|
public void open ( AVIMClientOpenOption option , final AVIMClientCallback callback ) { boolean reConnect = null == option ? false : option . isReconnect ( ) ; OperationTube operationTube = InternalConfiguration . getOperationTube ( ) ; operationTube . openClient ( clientId , tag , userSessionToken , reConnect , callback ) ; }
|
Open Client with options .
|
5,453
|
public void getOnlineClients ( List < String > clients , final AVIMOnlineClientsCallback callback ) { InternalConfiguration . getOperationTube ( ) . queryOnlineClients ( this . clientId , clients , callback ) ; }
|
Query online clients .
|
5,454
|
public void createTemporaryConversation ( final List < String > conversationMembers , int ttl , final AVIMConversationCreatedCallback callback ) { this . createConversation ( conversationMembers , null , null , false , true , true , ttl , callback ) ; }
|
Create a new temporary Conversation
|
5,455
|
public void createChatRoom ( final List < String > conversationMembers , String name , final Map < String , Object > attributes , final boolean isUnique , final AVIMConversationCreatedCallback callback ) { this . createConversation ( conversationMembers , name , attributes , true , false , callback ) ; }
|
Create a new Chatroom
|
5,456
|
public AVIMConversation getConversation ( String conversationId ) { if ( StringUtil . isEmpty ( conversationId ) ) { return null ; } return this . getConversation ( conversationId , false , conversationId . startsWith ( Conversation . TEMPCONV_ID_PREFIX ) ) ; }
|
get conversation by id
|
5,457
|
public AVIMConversation getConversation ( String conversationId , int convType ) { AVIMConversation result = null ; switch ( convType ) { case Conversation . CONV_TYPE_SYSTEM : result = getServiceConversation ( conversationId ) ; break ; case Conversation . CONV_TYPE_TEMPORARY : result = getTemporaryConversation ( conversationId ) ; break ; case Conversation . CONV_TYPE_TRANSIENT : result = getChatRoom ( conversationId ) ; break ; default : result = getConversation ( conversationId ) ; break ; } return result ; }
|
get conversation by id and type
|
5,458
|
public AVIMConversation getConversation ( String conversationId , boolean isTransient , boolean isTemporary ) { return this . getConversation ( conversationId , isTransient , isTemporary , false ) ; }
|
get an existed conversation
|
5,459
|
public void close ( final AVIMClientCallback callback ) { final AVIMClientCallback internalCallback = new AVIMClientCallback ( ) { public void done ( AVIMClient client , AVIMException e ) { if ( null == e ) { AVIMClient . this . localClose ( ) ; } if ( null != callback ) { callback . done ( client , e ) ; } } } ; InternalConfiguration . getOperationTube ( ) . closeClient ( this . clientId , internalCallback ) ; }
|
close client .
|
5,460
|
public static void setWriteTimeout ( int seconds ) throws AVException { if ( seconds <= 0 ) { throw new AVException ( new IllegalArgumentException ( "Timeout too small" ) ) ; } if ( seconds > 60 * 60 ) { throw new AVException ( new IllegalArgumentException ( "Timeout too large" ) ) ; } writeTimeout = seconds ; }
|
Sets the write timeout for s3
|
5,461
|
public void onOpen ( ServerHandshake var1 ) { gLogger . d ( "onOpen status=" + var1 . getHttpStatus ( ) + ", statusMsg=" + var1 . getHttpStatusMessage ( ) ) ; this . heartBeatPolicy . start ( ) ; if ( null != this . socketClientMonitor ) { this . socketClientMonitor . onOpen ( ) ; } }
|
WebSocketClient interfaces .
|
5,462
|
public void add ( T object ) { if ( object == null ) throw new IllegalArgumentException ( "null AVObject" ) ; if ( StringUtil . isEmpty ( targetClass ) ) { targetClass = object . getClassName ( ) ; } if ( ! StringUtil . isEmpty ( targetClass ) && ! targetClass . equals ( object . getClassName ( ) ) ) { throw new IllegalArgumentException ( "Could not add class '" + object . getClassName ( ) + "' to this relation,expect class is '" + targetClass + "'" ) ; } parent . addRelation ( object , key ) ; }
|
Adds an object to this relation .
|
5,463
|
public void addAll ( Collection < T > objects ) { if ( objects != null ) { for ( T obj : objects ) { add ( obj ) ; } } }
|
Adds many objects to this relation .
|
5,464
|
@ JSONField ( serialize = false ) public AVQuery < T > getQuery ( Class < T > clazz ) { if ( getParent ( ) == null || StringUtil . isEmpty ( getParent ( ) . getObjectId ( ) ) ) { throw new IllegalStateException ( "unable to encode an association with an unsaved AVObject" ) ; } Map < String , Object > map = new HashMap < String , Object > ( ) ; map . put ( "object" , Utils . mapFromPointerObject ( AVRelation . this . getParent ( ) ) ) ; map . put ( "key" , AVRelation . this . getKey ( ) ) ; Map < String , Object > result = new HashMap < String , Object > ( ) ; result . put ( "$relatedTo" , map ) ; String targetClassName = getTargetClass ( ) ; if ( StringUtil . isEmpty ( getTargetClass ( ) ) ) { targetClassName = getParent ( ) . getClassName ( ) ; } AVQuery < T > query = new AVQuery < T > ( targetClassName , clazz ) ; query . addWhereItem ( "$relatedTo" , null , map ) ; if ( StringUtil . isEmpty ( getTargetClass ( ) ) ) { query . getParameters ( ) . put ( "redirectClassNameForKey" , this . getKey ( ) ) ; } return query ; }
|
Gets a query that can be used to query the subclass objects in this relation .
|
5,465
|
public static String encodeToString ( byte [ ] input , int flags ) { try { return new String ( encode ( input , flags ) , "US-ASCII" ) ; } catch ( UnsupportedEncodingException e ) { throw new AssertionError ( e ) ; } }
|
Base64 - encode the given data and return a newly allocated String with the result .
|
5,466
|
public void setLabels ( FileChooserLabels labels ) { this . labels = labels ; if ( labels != null ) { LinearLayout root = this . chooser . getRootLayout ( ) ; if ( labels . labelAddButton != null ) { Button addButton = ( Button ) root . findViewById ( R . id . buttonAdd ) ; addButton . setText ( labels . labelAddButton ) ; } if ( labels . labelSelectButton != null ) { Button okButton = ( Button ) root . findViewById ( R . id . buttonOk ) ; okButton . setText ( labels . labelSelectButton ) ; } } }
|
Defines the value of the labels .
|
5,467
|
public void setFilter ( String filter ) { if ( filter == null || filter . length ( ) == 0 ) { this . filter = null ; } else { this . filter = filter ; } this . loadFolder ( this . currentFolder ) ; }
|
Set a regular expression to filter the files that can be selected .
|
5,468
|
private void updateButtonsLayout ( ) { LinearLayout root = this . chooser . getRootLayout ( ) ; LinearLayout buttonsLayout = ( LinearLayout ) root . findViewById ( R . id . linearLayoutButtons ) ; View addButton = root . findViewById ( R . id . buttonAdd ) ; addButton . setVisibility ( this . canCreateFiles ? View . VISIBLE : View . INVISIBLE ) ; addButton . getLayoutParams ( ) . width = this . canCreateFiles ? ViewGroup . LayoutParams . MATCH_PARENT : 0 ; View okButton = root . findViewById ( R . id . buttonOk ) ; okButton . setVisibility ( this . folderMode ? View . VISIBLE : View . INVISIBLE ) ; okButton . getLayoutParams ( ) . width = this . folderMode ? ViewGroup . LayoutParams . MATCH_PARENT : 0 ; ViewGroup . LayoutParams params = buttonsLayout . getLayoutParams ( ) ; if ( this . canCreateFiles || this . folderMode ) { params . height = ViewGroup . LayoutParams . WRAP_CONTENT ; buttonsLayout . removeAllViews ( ) ; if ( this . folderMode && ! this . canCreateFiles ) { buttonsLayout . addView ( okButton ) ; buttonsLayout . addView ( addButton ) ; } else { buttonsLayout . addView ( addButton ) ; buttonsLayout . addView ( okButton ) ; } } else { params . height = 0 ; } }
|
Changes the height of the layout for the buttons according if the buttons are visible or not .
|
5,469
|
@ TargetApi ( Build . VERSION_CODES . HONEYCOMB_MR2 ) private void showProgress ( final boolean show ) { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB_MR2 ) { int shortAnimTime = getResources ( ) . getInteger ( android . R . integer . config_shortAnimTime ) ; mLoginFormView . setVisibility ( show ? View . GONE : View . VISIBLE ) ; mLoginFormView . animate ( ) . setDuration ( shortAnimTime ) . alpha ( show ? 0 : 1 ) . setListener ( new AnimatorListenerAdapter ( ) { public void onAnimationEnd ( Animator animation ) { mLoginFormView . setVisibility ( show ? View . GONE : View . VISIBLE ) ; } } ) ; mProgressView . setVisibility ( show ? View . VISIBLE : View . GONE ) ; mProgressView . animate ( ) . setDuration ( shortAnimTime ) . alpha ( show ? 1 : 0 ) . setListener ( new AnimatorListenerAdapter ( ) { public void onAnimationEnd ( Animator animation ) { mProgressView . setVisibility ( show ? View . VISIBLE : View . GONE ) ; } } ) ; } else { mProgressView . setVisibility ( show ? View . VISIBLE : View . GONE ) ; mLoginFormView . setVisibility ( show ? View . GONE : View . VISIBLE ) ; } }
|
Shows the progress UI and hides the login form .
|
5,470
|
public static void configCacheSettings ( String imFileDir , String docDir , String fileDir , String queryResultDir , String commandDir , String analyticsDir , SystemSetting setting ) { importantFileDir = imFileDir ; if ( ! importantFileDir . endsWith ( "/" ) ) { importantFileDir += "/" ; } documentDir = docDir ; if ( ! documentDir . endsWith ( "/" ) ) { documentDir += "/" ; } fileCacheDir = fileDir ; if ( ! fileCacheDir . endsWith ( "/" ) ) { fileCacheDir += "/" ; } queryResultCacheDir = queryResultDir ; if ( ! queryResultCacheDir . endsWith ( "/" ) ) { queryResultCacheDir += "/" ; } commandCacheDir = commandDir ; if ( ! commandCacheDir . endsWith ( "/" ) ) { commandCacheDir += "/" ; } analyticsCacheDir = analyticsDir ; if ( ! analyticsCacheDir . endsWith ( "/" ) ) { analyticsCacheDir += "/" ; } makeSureCacheDirWorkable ( ) ; defaultSetting = setting ; }
|
config local cache setting .
|
5,471
|
public static < T extends AVObject > AVQuery < T > getQuery ( String theClassName ) { return new AVQuery < T > ( theClassName ) ; }
|
Constructs a query . A default query with no further parameters will retrieve all AVObjects of the provided class .
|
5,472
|
public static < T extends AVObject > AVQuery < T > getQuery ( Class < T > clazz ) { return new AVQuery < T > ( Transformer . getSubClassName ( clazz ) , clazz ) ; }
|
Create a AVQuery with special sub - class .
|
5,473
|
public AVQuery < T > whereContainedIn ( String key , Collection < ? extends Object > values ) { conditions . whereContainedIn ( key , values ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value to be contained in the provided list of values .
|
5,474
|
public AVQuery < T > whereContains ( String key , String substring ) { conditions . whereContains ( key , substring ) ; return this ; }
|
Add a constraint for finding string values that contain a provided string . This will be slow for large datasets .
|
5,475
|
public AVQuery < T > whereContainsAll ( String key , Collection < ? > values ) { conditions . whereContainsAll ( key , values ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value match another AVQuery . This only works on keys whose values are AVObjects or lists of AVObjects . Add a constraint to the query that requires a particular key s value to contain every one of the provided list of values .
|
5,476
|
public AVQuery < T > whereEndsWith ( String key , String suffix ) { conditions . whereEndsWith ( key , suffix ) ; return this ; }
|
Add a constraint for finding string values that end with a provided string . This will be slow for large datasets .
|
5,477
|
public AVQuery < T > whereEqualTo ( String key , Object value ) { conditions . whereEqualTo ( key , value ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value to be equal to the provided value .
|
5,478
|
public AVQuery < T > whereGreaterThan ( String key , Object value ) { conditions . whereGreaterThan ( key , value ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value to be greater than the provided value . w
|
5,479
|
public AVQuery < T > whereGreaterThanOrEqualTo ( String key , Object value ) { conditions . whereGreaterThanOrEqualTo ( key , value ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value to be greater or equal to than the provided value .
|
5,480
|
public AVQuery < T > whereLessThan ( String key , Object value ) { conditions . whereLessThan ( key , value ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value to be less than the provided value .
|
5,481
|
public AVQuery < T > whereLessThanOrEqualTo ( String key , Object value ) { conditions . whereLessThanOrEqualTo ( key , value ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value to be less or equal to than the provided value .
|
5,482
|
public AVQuery < T > whereMatches ( String key , String regex ) { conditions . whereMatches ( key , regex ) ; return this ; }
|
Add a regular expression constraint for finding string values that match the provided regular expression . This may be slow for large datasets .
|
5,483
|
public AVQuery < T > whereNear ( String key , AVGeoPoint point ) { conditions . whereNear ( key , point ) ; return this ; }
|
Add a proximity based constraint for finding objects with key point values near the point given .
|
5,484
|
public AVQuery < T > whereNotEqualTo ( String key , Object value ) { conditions . whereNotEqualTo ( key , value ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value to be not equal to the provided value .
|
5,485
|
public AVQuery < T > whereStartsWith ( String key , String prefix ) { conditions . whereStartsWith ( key , prefix ) ; return this ; }
|
Add a constraint for finding string values that start with a provided string . This query will use the backend index so it will be fast even for large datasets .
|
5,486
|
public AVQuery < T > whereWithinGeoBox ( String key , AVGeoPoint southwest , AVGeoPoint northeast ) { conditions . whereWithinGeoBox ( key , southwest , northeast ) ; return this ; }
|
Add a constraint to the query that requires a particular key s coordinates be contained within a given rectangular geographic bounding box .
|
5,487
|
public AVQuery < T > whereWithinKilometers ( String key , AVGeoPoint point , double maxDistance ) { conditions . whereWithinKilometers ( key , point , maxDistance ) ; return this ; }
|
Add a proximity based constraint for finding objects with key point values near the point given and within the maximum distance given . Radius of earth used is 6371 . 0 kilometers .
|
5,488
|
public AVQuery < T > whereMatchesKeyInQuery ( String key , String keyInQuery , AVQuery < ? > query ) { Map < String , Object > inner = new HashMap < String , Object > ( ) ; inner . put ( "className" , query . getClassName ( ) ) ; inner . put ( "where" , query . conditions . compileWhereOperationMap ( ) ) ; if ( query . conditions . getSkip ( ) > 0 ) inner . put ( "skip" , query . conditions . getSkip ( ) ) ; if ( query . conditions . getLimit ( ) > 0 ) inner . put ( "limit" , query . conditions . getLimit ( ) ) ; if ( ! StringUtil . isEmpty ( query . getOrder ( ) ) ) inner . put ( "order" , query . getOrder ( ) ) ; Map < String , Object > queryMap = new HashMap < String , Object > ( ) ; queryMap . put ( "query" , inner ) ; queryMap . put ( "key" , keyInQuery ) ; return addWhereItem ( key , "$select" , queryMap ) ; }
|
Add a constraint to the query that requires a particular key s value matches a value for a key in the results of another AVQuery
|
5,489
|
public AVQuery < T > whereMatchesQuery ( String key , AVQuery < ? > query ) { Map < String , Object > map = AVUtils . createMap ( "where" , query . conditions . compileWhereOperationMap ( ) ) ; map . put ( "className" , query . className ) ; if ( query . conditions . getSkip ( ) > 0 ) map . put ( "skip" , query . conditions . getSkip ( ) ) ; if ( query . conditions . getLimit ( ) > 0 ) map . put ( "limit" , query . conditions . getLimit ( ) ) ; if ( ! StringUtil . isEmpty ( query . getOrder ( ) ) ) map . put ( "order" , query . getOrder ( ) ) ; addWhereItem ( key , "$inQuery" , map ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value match another AVQuery . This only works on keys whose values are AVObjects or lists of AVObjects .
|
5,490
|
public AVQuery < T > whereDoesNotMatchKeyInQuery ( String key , String keyInQuery , AVQuery < ? > query ) { Map < String , Object > map = AVUtils . createMap ( "className" , query . className ) ; map . put ( "where" , query . conditions . compileWhereOperationMap ( ) ) ; Map < String , Object > queryMap = AVUtils . createMap ( "query" , map ) ; queryMap . put ( "key" , keyInQuery ) ; addWhereItem ( key , "$dontSelect" , queryMap ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value does not match any value for a key in the results of another AVQuery .
|
5,491
|
public AVQuery < T > whereDoesNotMatchQuery ( String key , AVQuery < ? > query ) { Map < String , Object > map = AVUtils . createMap ( "className" , query . className ) ; map . put ( "where" , query . conditions . compileWhereOperationMap ( ) ) ; addWhereItem ( key , "$notInQuery" , map ) ; return this ; }
|
Add a constraint to the query that requires a particular key s value does not match another AVQuery . This only works on keys whose values are AVObjects or lists of AVObjects .
|
5,492
|
public static < T extends AVObject > AVQuery < T > or ( List < AVQuery < T > > queries ) { if ( null == queries || queries . isEmpty ( ) ) { throw new IllegalArgumentException ( "queries must be non-empty." ) ; } String className = queries . get ( 0 ) . getClassName ( ) ; AVQuery < T > result = new AVQuery < T > ( className ) ; if ( queries . size ( ) > 1 ) { for ( AVQuery < T > query : queries ) { if ( ! className . equals ( query . getClassName ( ) ) ) { throw new IllegalArgumentException ( "All queries must be for the same class" ) ; } result . addOrItems ( new QueryOperation ( "$or" , "$or" , query . conditions . compileWhereOperationMap ( ) ) ) ; } } else { result . setWhere ( queries . get ( 0 ) . conditions . getWhere ( ) ) ; } return result ; }
|
Constructs a query that is the or of the given queries .
|
5,493
|
private byte [ ] addPadding ( byte [ ] plain ) { byte plainpad [ ] = null ; int shortage = 16 - ( plain . length % 16 ) ; if ( shortage == 0 ) shortage = 16 ; plainpad = new byte [ plain . length + shortage ] ; for ( int i = 0 ; i < plain . length ; i ++ ) { plainpad [ i ] = plain [ i ] ; } for ( int i = plain . length ; i < plain . length + shortage ; i ++ ) { plainpad [ i ] = ( byte ) shortage ; } return plainpad ; }
|
number in range 1 .. 16 ) .
|
5,494
|
private byte [ ] dropPadding ( byte [ ] plainpad ) { byte plain [ ] = null ; int drop = plainpad [ plainpad . length - 1 ] ; plain = new byte [ plainpad . length - drop ] ; for ( int i = 0 ; i < plain . length ; i ++ ) { plain [ i ] = plainpad [ i ] ; plainpad [ i ] = 0 ; } return plain ; }
|
This method removes the padding bytes
|
5,495
|
public static < T extends AVObject > SingleObjectObserver < T > buildSingleObserver ( GetCallback < T > callback ) { return new SingleObjectObserver < T > ( callback ) ; }
|
Single Object Observer .
|
5,496
|
public static < T extends AVObject > CollectionObserver < T > buildSingleObserver ( FindCallback < T > callback ) { return new CollectionObserver < T > ( callback ) ; }
|
Multiple Objects Observer .
|
5,497
|
public void add ( String key , Object value ) { validFieldName ( key ) ; ObjectFieldOperation op = OperationBuilder . gBuilder . create ( OperationBuilder . OperationType . Add , key , value ) ; addNewOperation ( op ) ; }
|
changable operations .
|
5,498
|
public boolean hasCircleReference ( Map < AVObject , Boolean > markMap ) { if ( null == markMap ) { return false ; } markMap . put ( this , true ) ; boolean rst = false ; for ( ObjectFieldOperation op : operations . values ( ) ) { rst = rst || op . checkCircleReference ( markMap ) ; } return rst ; }
|
judge operations value include circle reference or not .
|
5,499
|
public String toJSONString ( ) { return JSON . toJSONString ( this , ObjectValueFilter . instance , SerializerFeature . WriteClassName , SerializerFeature . DisableCircularReferenceDetect ) ; }
|
generate a json string .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.