idx
int64 0
165k
| question
stringlengths 73
4.15k
| target
stringlengths 5
918
| len_question
int64 21
890
| len_target
int64 3
255
|
|---|---|---|---|---|
150,800
|
@ Override public String toFullString ( ) { String result ; if ( hasNoStringCache ( ) || ( result = stringCache . fullString ) == null ) { stringCache . fullString = result = toNormalizedString ( IPv4StringCache . fullParams ) ; } return result ; }
|
This produces a string with no compressed segments and all segments of full length which is 3 characters for IPv4 segments .
| 64
| 23
|
150,801
|
@ SuppressWarnings ( "unchecked" ) public < S extends IPAddressPartConfiguredString < T , P > > SQLStringMatcher < T , P , S > getNetworkStringMatcher ( boolean isEntireAddress , IPAddressSQLTranslator translator ) { return new SQLStringMatcher < T , P , S > ( ( S ) this , isEntireAddress , translator ) ; }
|
Provides an object that can build SQL clauses to match this string representation .
| 89
| 15
|
150,802
|
public boolean isValid ( ) { if ( addressProvider . isUninitialized ( ) ) { try { validate ( ) ; return true ; } catch ( AddressStringException e ) { return false ; } } return ! addressProvider . isInvalid ( ) ; }
|
Returns whether this is a valid address string format .
| 53
| 10
|
150,803
|
@ Override public int compareTo ( IPAddressString other ) { if ( this == other ) { return 0 ; } boolean isValid = isValid ( ) ; boolean otherIsValid = other . isValid ( ) ; if ( ! isValid && ! otherIsValid ) { return toString ( ) . compareTo ( other . toString ( ) ) ; } return addressProvider . providerCompare ( other . addressProvider ) ; }
|
All address strings are comparable . If two address strings are invalid their strings are compared . Otherwise address strings are compared according to which type or version of string and then within each type or version they are compared using the comparison rules for addresses .
| 91
| 47
|
150,804
|
public String convertToPrefixLength ( ) throws AddressStringException { IPAddress address = toAddress ( ) ; Integer prefix ; if ( address == null ) { if ( isPrefixOnly ( ) ) { prefix = getNetworkPrefixLength ( ) ; } else { return null ; } } else { prefix = address . getBlockMaskPrefixLength ( true ) ; if ( prefix == null ) { return null ; } } return IPAddressSegment . toUnsignedString ( prefix , 10 , new StringBuilder ( IPAddressSegment . toUnsignedStringLength ( prefix , 10 ) + 1 ) . append ( IPAddress . PREFIX_LEN_SEPARATOR ) ) . toString ( ) ; }
|
Converts this address to a prefix length
| 154
| 8
|
150,805
|
public int getTrailingBitCount ( boolean network ) { int count = getDivisionCount ( ) ; if ( count == 0 ) { return 0 ; } long back = network ? 0 : getDivision ( 0 ) . getMaxValue ( ) ; int bitLen = 0 ; for ( int i = count - 1 ; i >= 0 ; i -- ) { IPAddressDivision seg = getDivision ( i ) ; long value = seg . getDivisionValue ( ) ; if ( value != back ) { return bitLen + seg . getTrailingBitCount ( network ) ; } bitLen += seg . getBitCount ( ) ; } return bitLen ; }
|
Returns the number of consecutive trailing one or zero bits . If network is true returns the number of consecutive trailing zero bits . Otherwise returns the number of consecutive trailing one bits .
| 146
| 34
|
150,806
|
public int getLeadingBitCount ( boolean network ) { int count = getDivisionCount ( ) ; if ( count == 0 ) { return 0 ; } long front = network ? getDivision ( 0 ) . getMaxValue ( ) : 0 ; int prefixLen = 0 ; for ( int i = 0 ; i < count ; i ++ ) { IPAddressDivision seg = getDivision ( i ) ; long value = seg . getDivisionValue ( ) ; if ( value != front ) { return prefixLen + seg . getLeadingBitCount ( network ) ; } prefixLen += seg . getBitCount ( ) ; } return prefixLen ; }
|
Returns the number of consecutive leading one or zero bits . If network is true returns the number of consecutive leading one bits . Otherwise returns the number of consecutive leading zero bits .
| 144
| 34
|
150,807
|
@ Override public boolean isPrefixBlock ( ) { Integer networkPrefixLength = getNetworkPrefixLength ( ) ; if ( networkPrefixLength == null ) { return false ; } if ( getNetwork ( ) . getPrefixConfiguration ( ) . allPrefixedAddressesAreSubnets ( ) ) { return true ; } return containsPrefixBlock ( networkPrefixLength ) ; }
|
Returns whether this address section represents a subnet block of addresses associated its prefix length .
| 83
| 17
|
150,808
|
@ Override public boolean isSinglePrefixBlock ( ) { Integer networkPrefixLength = getNetworkPrefixLength ( ) ; if ( networkPrefixLength == null ) { return false ; } return containsSinglePrefixBlock ( networkPrefixLength ) ; }
|
Returns whether the division grouping range matches the block of values for its prefix length . In other words returns true if and only if it has a prefix length and it has just a single prefix .
| 55
| 38
|
150,809
|
public IPv6Address getIPv6Address ( IPv6AddressSegment segs [ ] ) { IPv6AddressCreator creator = getIPv6Network ( ) . getAddressCreator ( ) ; return creator . createAddress ( IPv6AddressSection . createSection ( creator , segs , this ) ) ; /* address creation */ }
|
Create an IPv6 mixed address using the given ipv6 segments and using this address for the embedded IPv4 segments
| 71
| 23
|
150,810
|
public boolean isPrivate ( ) { // refer to RFC 1918 // 10/8 prefix // 172.16/12 prefix (172.16.0.0 – 172.31.255.255) // 192.168/16 prefix IPv4AddressSegment seg0 = getSegment ( 0 ) ; IPv4AddressSegment seg1 = getSegment ( 1 ) ; return seg0 . matches ( 10 ) || seg0 . matches ( 172 ) && seg1 . matchesWithPrefixMask ( 16 , 4 ) || seg0 . matches ( 192 ) && seg1 . matches ( 168 ) ; }
|
Unicast addresses allocated for private use
| 133
| 8
|
150,811
|
public SpinJsonDataFormatException unableToParseValue ( String expectedType , JsonNodeType type ) { return new SpinJsonDataFormatException ( exceptionMessage ( "002" , "Expected '{}', got '{}'" , expectedType , type . toString ( ) ) ) ; }
|
Exception handler if we are unable to parse a json value into a java representation
| 66
| 15
|
150,812
|
protected void adoptElement ( DomXmlElement elementToAdopt ) { Document document = this . domElement . getOwnerDocument ( ) ; Element element = elementToAdopt . domElement ; if ( ! document . equals ( element . getOwnerDocument ( ) ) ) { Node node = document . adoptNode ( element ) ; if ( node == null ) { throw LOG . unableToAdoptElement ( elementToAdopt ) ; } } }
|
Adopts an xml dom element to the owner document of this element if necessary .
| 93
| 17
|
150,813
|
public static void ensureChildElement ( DomXmlElement parentElement , DomXmlElement childElement ) { Node parent = childElement . unwrap ( ) . getParentNode ( ) ; if ( parent == null || ! parentElement . unwrap ( ) . isEqualNode ( parent ) ) { throw LOG . elementIsNotChildOfThisElement ( childElement , parentElement ) ; } }
|
Ensures that the element is child element of the parent element .
| 83
| 14
|
150,814
|
public static void ensureXPathNotNull ( Node node , String expression ) { if ( node == null ) { throw LOG . unableToFindXPathExpression ( expression ) ; } }
|
Ensure that the node is not null .
| 39
| 9
|
150,815
|
public static void ensureXPathNotEmpty ( NodeList nodeList , String expression ) { if ( nodeList == null || nodeList . getLength ( ) == 0 ) { throw LOG . unableToFindXPathExpression ( expression ) ; } }
|
Ensure that the nodeList is either null or empty .
| 52
| 12
|
150,816
|
public String getCanonicalTypeName ( Object object ) { ensureNotNull ( "object" , object ) ; for ( TypeDetector typeDetector : typeDetectors ) { if ( typeDetector . canHandle ( object ) ) { return typeDetector . detectType ( object ) ; } } throw LOG . unableToDetectCanonicalType ( object ) ; }
|
Identifies the canonical type of an object heuristically .
| 79
| 12
|
150,817
|
protected Transformer getTransformer ( ) { TransformerFactory transformerFactory = domXmlDataFormat . getTransformerFactory ( ) ; try { Transformer transformer = transformerFactory . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . ENCODING , "UTF-8" ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; transformer . setOutputProperty ( "{http://xml.apache.org/xslt}indent-amount" , "2" ) ; return transformer ; } catch ( TransformerConfigurationException e ) { throw LOG . unableToCreateTransformer ( e ) ; } }
|
Returns a configured transformer to write XML .
| 137
| 8
|
150,818
|
public static Class < ? > loadClass ( String classname , DataFormat < ? > dataFormat ) { // first try context classoader ClassLoader cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( cl != null ) { LOG . tryLoadingClass ( classname , cl ) ; try { return cl . loadClass ( classname ) ; } catch ( Exception e ) { // ignore } } // else try the classloader which loaded the dataformat cl = dataFormat . getClass ( ) . getClassLoader ( ) ; try { LOG . tryLoadingClass ( classname , cl ) ; return cl . loadClass ( classname ) ; } catch ( ClassNotFoundException e ) { throw LOG . classNotFound ( classname , e ) ; } }
|
Used by dataformats if they need to load a class
| 165
| 12
|
150,819
|
public static String getExtension ( String language ) { language = language . toLowerCase ( ) ; if ( "ecmascript" . equals ( language ) ) { language = "javascript" ; } return extensions . get ( language ) ; }
|
Get file extension for script language .
| 51
| 7
|
150,820
|
public static String get ( String language ) { language = language . toLowerCase ( ) ; if ( "ecmascript" . equals ( language ) ) { language = "javascript" ; } String extension = extensions . get ( language ) ; if ( extension == null ) { return null ; } else { return loadScriptEnv ( language , extension ) ; } }
|
Get the spin scripting environment
| 76
| 5
|
150,821
|
protected Integer getCorrectIndex ( Integer index ) { Integer size = jsonNode . size ( ) ; Integer newIndex = index ; // reverse walking through the array if ( index < 0 ) { newIndex = size + index ; } // the negative index would be greater than the size a second time! if ( newIndex < 0 ) { throw LOG . indexOutOfBounds ( index , size ) ; } // the index is greater as the actual size if ( index > size ) { throw LOG . indexOutOfBounds ( index , size ) ; } return newIndex ; }
|
fetch correct array index if index is less than 0
| 120
| 11
|
150,822
|
public void setNamespace ( String prefix , String namespaceURI ) { ensureNotNull ( "Prefix" , prefix ) ; ensureNotNull ( "Namespace URI" , namespaceURI ) ; namespaces . put ( prefix , namespaceURI ) ; }
|
Maps a single prefix uri pair as namespace .
| 52
| 10
|
150,823
|
public static < T extends Spin < ? > > T S ( Object input , DataFormat < T > format ) { return SpinFactory . INSTANCE . createSpin ( input , format ) ; }
|
Creates a spin wrapper for a data input of a given data format .
| 41
| 15
|
150,824
|
public static SpinXmlElement XML ( Object input ) { return SpinFactory . INSTANCE . createSpin ( input , DataFormats . xml ( ) ) ; }
|
Creates a spin wrapper for a data input . The data format of the input is assumed to be XML .
| 35
| 22
|
150,825
|
public static SpinJsonNode JSON ( Object input ) { return SpinFactory . INSTANCE . createSpin ( input , DataFormats . json ( ) ) ; }
|
Creates a spin wrapper for a data input . The data format of the input is assumed to be JSON .
| 35
| 22
|
150,826
|
public synchronized void stop ( ) throws DatastoreEmulatorException { // We intentionally don't check the internal state. If people want to try and stop the server // multiple times that's fine. stopEmulatorInternal ( ) ; if ( state != State . STOPPED ) { state = State . STOPPED ; if ( projectDirectory != null ) { try { Process process = new ProcessBuilder ( "rm" , "-r" , projectDirectory . getAbsolutePath ( ) ) . start ( ) ; if ( process . waitFor ( ) != 0 ) { throw new IOException ( "Temporary project directory deletion exited with " + process . exitValue ( ) ) ; } } catch ( IOException e ) { throw new IllegalStateException ( "Could not delete temporary project directory" , e ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; throw new IllegalStateException ( "Could not delete temporary project directory" , e ) ; } } } }
|
Stops the emulator . Multiple calls are allowed .
| 210
| 10
|
150,827
|
private void sendEmptyRequest ( String path , String method ) throws DatastoreEmulatorException { HttpURLConnection connection = null ; try { URL url = new URL ( this . host + path ) ; connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . setDoOutput ( true ) ; connection . setRequestMethod ( method ) ; connection . getOutputStream ( ) . close ( ) ; if ( connection . getResponseCode ( ) != HttpURLConnection . HTTP_OK ) { throw new DatastoreEmulatorException ( String . format ( "%s request to %s returned HTTP status %s" , method , path , connection . getResponseCode ( ) ) ) ; } } catch ( IOException e ) { throw new DatastoreEmulatorException ( String . format ( "Exception connecting to emulator on %s request to %s" , method , path ) , e ) ; } finally { if ( connection != null ) { connection . disconnect ( ) ; } } }
|
Send an empty request using a standard HTTP connection .
| 211
| 10
|
150,828
|
public InputStream call ( String methodName , MessageLite request ) throws DatastoreException { logger . fine ( "remote datastore call " + methodName ) ; long startTime = System . currentTimeMillis ( ) ; try { HttpResponse httpResponse ; try { rpcCount . incrementAndGet ( ) ; ProtoHttpContent payload = new ProtoHttpContent ( request ) ; HttpRequest httpRequest = client . buildPostRequest ( resolveURL ( methodName ) , payload ) ; httpRequest . getHeaders ( ) . put ( API_FORMAT_VERSION_HEADER , API_FORMAT_VERSION ) ; // Don't throw an HTTPResponseException on error. It converts the response to a String and // throws away the original, whereas we need the raw bytes to parse it as a proto. httpRequest . setThrowExceptionOnExecuteError ( false ) ; // Datastore requests typically time out after 60s; set the read timeout to slightly longer // than that by default (can be overridden via the HttpRequestInitializer). httpRequest . setReadTimeout ( 65 * 1000 ) ; if ( initializer != null ) { initializer . initialize ( httpRequest ) ; } httpResponse = httpRequest . execute ( ) ; if ( ! httpResponse . isSuccessStatusCode ( ) ) { try ( InputStream content = GzipFixingInputStream . maybeWrap ( httpResponse . getContent ( ) ) ) { throw makeException ( url , methodName , content , httpResponse . getContentType ( ) , httpResponse . getContentCharset ( ) , null , httpResponse . getStatusCode ( ) ) ; } } return GzipFixingInputStream . maybeWrap ( httpResponse . getContent ( ) ) ; } catch ( SocketTimeoutException e ) { throw makeException ( url , methodName , Code . DEADLINE_EXCEEDED , "Deadline exceeded" , e ) ; } catch ( IOException e ) { throw makeException ( url , methodName , Code . UNAVAILABLE , "I/O error" , e ) ; } } finally { long elapsedTime = System . currentTimeMillis ( ) - startTime ; logger . fine ( "remote datastore call " + methodName + " took " + elapsedTime + " ms" ) ; } }
|
Makes an RPC call using the client . Logs how long it took and any exceptions .
| 493
| 19
|
150,829
|
private void addGreeting ( String guestbookName , String user , String message ) throws DatastoreException { Entity . Builder greeting = Entity . newBuilder ( ) ; greeting . setKey ( makeKey ( GUESTBOOK_KIND , guestbookName , GREETING_KIND ) ) ; greeting . getMutableProperties ( ) . put ( USER_PROPERTY , makeValue ( user ) . build ( ) ) ; greeting . getMutableProperties ( ) . put ( MESSAGE_PROPERTY , makeValue ( message ) . build ( ) ) ; greeting . getMutableProperties ( ) . put ( DATE_PROPERTY , makeValue ( new Date ( ) ) . build ( ) ) ; Key greetingKey = insert ( greeting . build ( ) ) ; System . out . println ( "greeting key is: " + greetingKey ) ; }
|
Add a greeting to the specified guestbook .
| 192
| 9
|
150,830
|
private void listGreetings ( String guestbookName ) throws DatastoreException { Query . Builder query = Query . newBuilder ( ) ; query . addKindBuilder ( ) . setName ( GREETING_KIND ) ; query . setFilter ( makeFilter ( KEY_PROPERTY , PropertyFilter . Operator . HAS_ANCESTOR , makeValue ( makeKey ( GUESTBOOK_KIND , guestbookName ) ) ) ) ; query . addOrder ( makeOrder ( DATE_PROPERTY , PropertyOrder . Direction . DESCENDING ) ) ; List < Entity > greetings = runQuery ( query . build ( ) ) ; if ( greetings . size ( ) == 0 ) { System . out . println ( "no greetings in " + guestbookName ) ; } for ( Entity greeting : greetings ) { Map < String , Value > propertyMap = greeting . getProperties ( ) ; System . out . println ( DatastoreHelper . toDate ( propertyMap . get ( DATE_PROPERTY ) ) + ": " + DatastoreHelper . getString ( propertyMap . get ( USER_PROPERTY ) ) + " says " + DatastoreHelper . getString ( propertyMap . get ( MESSAGE_PROPERTY ) ) ) ; } }
|
List the greetings in the specified guestbook .
| 280
| 10
|
150,831
|
private Key insert ( Entity entity ) throws DatastoreException { CommitRequest req = CommitRequest . newBuilder ( ) . addMutations ( Mutation . newBuilder ( ) . setInsert ( entity ) ) . setMode ( CommitRequest . Mode . NON_TRANSACTIONAL ) . build ( ) ; return datastore . commit ( req ) . getMutationResults ( 0 ) . getKey ( ) ; }
|
Insert an entity into the datastore .
| 88
| 9
|
150,832
|
private List < Entity > runQuery ( Query query ) throws DatastoreException { RunQueryRequest . Builder request = RunQueryRequest . newBuilder ( ) ; request . setQuery ( query ) ; RunQueryResponse response = datastore . runQuery ( request . build ( ) ) ; if ( response . getBatch ( ) . getMoreResults ( ) == QueryResultBatch . MoreResultsType . NOT_FINISHED ) { System . err . println ( "WARNING: partial results\n" ) ; } List < EntityResult > results = response . getBatch ( ) . getEntityResultsList ( ) ; List < Entity > entities = new ArrayList < Entity > ( results . size ( ) ) ; for ( EntityResult result : results ) { entities . add ( result . getEntity ( ) ) ; } return entities ; }
|
Run a query on the datastore .
| 177
| 9
|
150,833
|
private void validateFilter ( Filter filter ) throws IllegalArgumentException { switch ( filter . getFilterTypeCase ( ) ) { case COMPOSITE_FILTER : for ( Filter subFilter : filter . getCompositeFilter ( ) . getFiltersList ( ) ) { validateFilter ( subFilter ) ; } break ; case PROPERTY_FILTER : if ( UNSUPPORTED_OPERATORS . contains ( filter . getPropertyFilter ( ) . getOp ( ) ) ) { throw new IllegalArgumentException ( "Query cannot have any inequality filters." ) ; } break ; default : throw new IllegalArgumentException ( "Unsupported filter type: " + filter . getFilterTypeCase ( ) ) ; } }
|
Validates that we only have allowable filters .
| 153
| 9
|
150,834
|
private void validateQuery ( Query query ) throws IllegalArgumentException { if ( query . getKindCount ( ) != 1 ) { throw new IllegalArgumentException ( "Query must have exactly one kind." ) ; } if ( query . getOrderCount ( ) != 0 ) { throw new IllegalArgumentException ( "Query cannot have any sort orders." ) ; } if ( query . hasFilter ( ) ) { validateFilter ( query . getFilter ( ) ) ; } }
|
Verifies that the given query can be properly scattered .
| 99
| 11
|
150,835
|
private List < Key > getScatterKeys ( int numSplits , Query query , PartitionId partition , Datastore datastore ) throws DatastoreException { Query . Builder scatterPointQuery = createScatterQuery ( query , numSplits ) ; List < Key > keySplits = new ArrayList < Key > ( ) ; QueryResultBatch batch ; do { RunQueryRequest scatterRequest = RunQueryRequest . newBuilder ( ) . setPartitionId ( partition ) . setQuery ( scatterPointQuery ) . build ( ) ; batch = datastore . runQuery ( scatterRequest ) . getBatch ( ) ; for ( EntityResult result : batch . getEntityResultsList ( ) ) { keySplits . add ( result . getEntity ( ) . getKey ( ) ) ; } scatterPointQuery . setStartCursor ( batch . getEndCursor ( ) ) ; scatterPointQuery . getLimitBuilder ( ) . setValue ( scatterPointQuery . getLimit ( ) . getValue ( ) - batch . getEntityResultsCount ( ) ) ; } while ( batch . getMoreResults ( ) == MoreResultsType . NOT_FINISHED ) ; Collections . sort ( keySplits , DatastoreHelper . getKeyComparator ( ) ) ; return keySplits ; }
|
Gets a list of split keys given a desired number of splits .
| 275
| 14
|
150,836
|
private Query . Builder createScatterQuery ( Query query , int numSplits ) { // TODO(pcostello): We can potentially support better splits with equality filters in our query // if there exists a composite index on property, __scatter__, __key__. Until an API for // metadata exists, this isn't possible. Note that ancestor and inequality queries fall into // the same category. Query . Builder scatterPointQuery = Query . newBuilder ( ) ; scatterPointQuery . addAllKind ( query . getKindList ( ) ) ; scatterPointQuery . addOrder ( DatastoreHelper . makeOrder ( DatastoreHelper . SCATTER_PROPERTY_NAME , Direction . ASCENDING ) ) ; // There is a split containing entities before and after each scatter entity: // ||---*------*------*------*------*------*------*---|| = scatter entity // If we represent each split as a region before a scatter entity, there is an extra region // following the last scatter point. Thus, we do not need the scatter entities for the last // region. scatterPointQuery . getLimitBuilder ( ) . setValue ( ( numSplits - 1 ) * KEYS_PER_SPLIT ) ; scatterPointQuery . addProjection ( Projection . newBuilder ( ) . setProperty ( PropertyReference . newBuilder ( ) . setName ( "__key__" ) ) ) ; return scatterPointQuery ; }
|
Creates a scatter query from the given user query
| 304
| 10
|
150,837
|
private Iterable < Key > getSplitKey ( List < Key > keys , int numSplits ) { // If the number of keys is less than the number of splits, we are limited in the number of // splits we can make. if ( keys . size ( ) < numSplits - 1 ) { return keys ; } // Calculate the number of keys per split. This should be KEYS_PER_SPLIT, but may // be less if there are not KEYS_PER_SPLIT * (numSplits - 1) scatter entities. // // Consider the following dataset, where - represents an entity and * represents an entity // that is returned as a scatter entity: // ||---*-----*----*-----*-----*------*----*----|| // If we want 4 splits in this data, the optimal split would look like: // ||---*-----*----*-----*-----*------*----*----|| // | | | // The scatter keys in the last region are not useful to us, so we never request them: // ||---*-----*----*-----*-----*------*---------|| // | | | // With 6 scatter keys we want to set scatter points at indexes: 1, 3, 5. // // We keep this as a double so that any "fractional" keys per split get distributed throughout // the splits and don't make the last split significantly larger than the rest. double numKeysPerSplit = Math . max ( 1.0 , ( ( double ) keys . size ( ) ) / ( numSplits - 1 ) ) ; List < Key > keysList = new ArrayList < Key > ( numSplits - 1 ) ; // Grab the last sample for each split, otherwise the first split will be too small. for ( int i = 1 ; i < numSplits ; i ++ ) { int splitIndex = ( int ) Math . round ( i * numKeysPerSplit ) - 1 ; keysList . add ( keys . get ( splitIndex ) ) ; } return keysList ; }
|
Given a list of keys and a number of splits find the keys to split on .
| 430
| 17
|
150,838
|
public HttpRequestFactory makeClient ( DatastoreOptions options ) { Credential credential = options . getCredential ( ) ; HttpTransport transport = options . getTransport ( ) ; if ( transport == null ) { transport = credential == null ? new NetHttpTransport ( ) : credential . getTransport ( ) ; transport = transport == null ? new NetHttpTransport ( ) : transport ; } return transport . createRequestFactory ( credential ) ; }
|
Constructs a Google APIs HTTP client with the associated credentials .
| 100
| 12
|
150,839
|
String buildProjectEndpoint ( DatastoreOptions options ) { if ( options . getProjectEndpoint ( ) != null ) { return options . getProjectEndpoint ( ) ; } // DatastoreOptions ensures either project endpoint or project ID is set. String projectId = checkNotNull ( options . getProjectId ( ) ) ; if ( options . getHost ( ) != null ) { return validateUrl ( String . format ( "https://%s/%s/projects/%s" , options . getHost ( ) , VERSION , projectId ) ) ; } else if ( options . getLocalHost ( ) != null ) { return validateUrl ( String . format ( "http://%s/%s/projects/%s" , options . getLocalHost ( ) , VERSION , projectId ) ) ; } return validateUrl ( String . format ( "%s/%s/projects/%s" , DEFAULT_HOST , VERSION , projectId ) ) ; }
|
Build a valid datastore URL .
| 210
| 8
|
150,840
|
private static synchronized StreamHandler getStreamHandler ( ) { if ( methodHandler == null ) { methodHandler = new ConsoleHandler ( ) ; methodHandler . setFormatter ( new Formatter ( ) { @ Override public String format ( LogRecord record ) { return record . getMessage ( ) + "\n" ; } } ) ; methodHandler . setLevel ( Level . FINE ) ; } return methodHandler ; }
|
running in App Engine
| 87
| 4
|
150,841
|
public static Credential getServiceAccountCredential ( String serviceAccountId , String privateKeyFile , Collection < String > serviceAccountScopes ) throws GeneralSecurityException , IOException { return getCredentialBuilderWithoutPrivateKey ( serviceAccountId , serviceAccountScopes ) . setServiceAccountPrivateKeyFromP12File ( new File ( privateKeyFile ) ) . build ( ) ; }
|
Constructs credentials for the given account and key file .
| 83
| 11
|
150,842
|
public static PropertyOrder . Builder makeOrder ( String property , PropertyOrder . Direction direction ) { return PropertyOrder . newBuilder ( ) . setProperty ( makePropertyReference ( property ) ) . setDirection ( direction ) ; }
|
Make a sort order for use in a query .
| 47
| 10
|
150,843
|
public static Filter . Builder makeAncestorFilter ( Key ancestor ) { return makeFilter ( DatastoreHelper . KEY_PROPERTY_NAME , PropertyFilter . Operator . HAS_ANCESTOR , makeValue ( ancestor ) ) ; }
|
Makes an ancestor filter .
| 51
| 6
|
150,844
|
public static Filter . Builder makeAndFilter ( Iterable < Filter > subfilters ) { return Filter . newBuilder ( ) . setCompositeFilter ( CompositeFilter . newBuilder ( ) . addAllFilters ( subfilters ) . setOp ( CompositeFilter . Operator . AND ) ) ; }
|
Make a composite filter from the given sub - filters using AND to combine filters .
| 64
| 16
|
150,845
|
public static Value . Builder makeValue ( Value value1 , Value value2 , Value ... rest ) { ArrayValue . Builder arrayValue = ArrayValue . newBuilder ( ) ; arrayValue . addValues ( value1 ) ; arrayValue . addValues ( value2 ) ; arrayValue . addAllValues ( Arrays . asList ( rest ) ) ; return Value . newBuilder ( ) . setArrayValue ( arrayValue ) ; }
|
Make a list value containing the specified values .
| 90
| 9
|
150,846
|
public static Value . Builder makeValue ( Date date ) { return Value . newBuilder ( ) . setTimestampValue ( toTimestamp ( date . getTime ( ) * 1000L ) ) ; }
|
Make a timestamp value given a date .
| 42
| 8
|
150,847
|
public static < T extends Comparable < ? super T > > List < T > sortInplace ( List < T > list ) { Collections . sort ( list ) ; return list ; }
|
Sorts the specified list itself into ascending order according to the natural ordering of its elements .
| 39
| 18
|
150,848
|
public static < T , C extends Comparable < ? super C > > List < T > sortInplaceBy ( List < T > list , final Functions . Function1 < ? super T , C > key ) { if ( key == null ) throw new NullPointerException ( "key" ) ; Collections . sort ( list , new KeyComparator < T , C > ( key ) ) ; return list ; }
|
Sorts the specified list itself according to the order induced by applying a key function to each element which yields a comparable criteria .
| 87
| 25
|
150,849
|
@ Pure public static < T > List < T > reverseView ( List < T > list ) { return Lists . reverse ( list ) ; }
|
Provides a reverse view on the given list which is especially useful to traverse a list backwards in a for - each loop . The list itself is not modified by calling this method .
| 30
| 36
|
150,850
|
public void set ( Object receiver , String fieldName , /* @Nullable */ Object value ) throws SecurityException , NoSuchFieldException , IllegalArgumentException , IllegalAccessException { Preconditions . checkNotNull ( receiver , "receiver" ) ; Preconditions . checkNotNull ( fieldName , "fieldName" ) ; Class < ? extends Object > clazz = receiver . getClass ( ) ; Field f = getDeclaredField ( clazz , fieldName ) ; if ( ! f . isAccessible ( ) ) f . setAccessible ( true ) ; f . set ( receiver , value ) ; }
|
Sets the given value on an the receivers s accessible field with the given name .
| 131
| 17
|
150,851
|
@ SuppressWarnings ( "unchecked" ) /* @Nullable */ public < T > T get ( Object receiver , String fieldName ) throws SecurityException , NoSuchFieldException , IllegalArgumentException , IllegalAccessException { Preconditions . checkNotNull ( receiver , "receiver" ) ; Preconditions . checkNotNull ( fieldName , "fieldName" ) ; Class < ? extends Object > clazz = receiver . getClass ( ) ; Field f = getDeclaredField ( clazz , fieldName ) ; if ( ! f . isAccessible ( ) ) f . setAccessible ( true ) ; return ( T ) f . get ( receiver ) ; }
|
Retrieves the value of the given accessible field of the given receiver .
| 145
| 15
|
150,852
|
public void append ( Object object , String indentation ) { append ( object , indentation , segments . size ( ) ) ; }
|
Add the string representation of the given object to this sequence . The given indentation will be prepended to each line except the first one if the object has a multi - line string representation .
| 27
| 38
|
150,853
|
public void append ( String str , String indentation ) { if ( indentation . isEmpty ( ) ) { append ( str ) ; } else if ( str != null ) append ( indentation , str , segments . size ( ) ) ; }
|
Add the given string to this sequence . The given indentation will be prepended to each line except the first one if the object has a multi - line string representation .
| 51
| 34
|
150,854
|
protected void append ( Object object , String indentation , int index ) { if ( indentation . length ( ) == 0 ) { append ( object , index ) ; return ; } if ( object == null ) return ; if ( object instanceof String ) { append ( indentation , ( String ) object , index ) ; } else if ( object instanceof StringConcatenation ) { StringConcatenation other = ( StringConcatenation ) object ; List < String > otherSegments = other . getSignificantContent ( ) ; appendSegments ( indentation , index , otherSegments , other . lineDelimiter ) ; } else if ( object instanceof StringConcatenationClient ) { StringConcatenationClient other = ( StringConcatenationClient ) object ; other . appendTo ( new IndentedTarget ( this , indentation , index ) ) ; } else { final String text = getStringRepresentation ( object ) ; if ( text != null ) { append ( indentation , text , index ) ; } } }
|
Add the string representation of the given object to this sequence at the given index . The given indentation will be prepended to each line except the first one if the object has a multi - line string representation .
| 221
| 42
|
150,855
|
public void appendImmediate ( Object object , String indentation ) { for ( int i = segments . size ( ) - 1 ; i >= 0 ; i -- ) { String segment = segments . get ( i ) ; for ( int j = 0 ; j < segment . length ( ) ; j ++ ) { if ( ! WhitespaceMatcher . isWhitespace ( segment . charAt ( j ) ) ) { append ( object , indentation , i + 1 ) ; return ; } } } append ( object , indentation , 0 ) ; }
|
Add the string representation of the given object to this sequence immediately . That is all the trailing whitespace of this sequence will be ignored and the string is appended directly after the last segment that contains something besides whitespace . The given indentation will be prepended to each line except the first one if the object has a multi - line string representation .
| 115
| 70
|
150,856
|
public void newLineIfNotEmpty ( ) { for ( int i = segments . size ( ) - 1 ; i >= 0 ; i -- ) { String segment = segments . get ( i ) ; if ( lineDelimiter . equals ( segment ) ) { segments . subList ( i + 1 , segments . size ( ) ) . clear ( ) ; cachedToString = null ; return ; } for ( int j = 0 ; j < segment . length ( ) ; j ++ ) { if ( ! WhitespaceMatcher . isWhitespace ( segment . charAt ( j ) ) ) { newLine ( ) ; return ; } } } segments . clear ( ) ; cachedToString = null ; }
|
Add a newline to this sequence according to the configured lineDelimiter if the last line contains something besides whitespace .
| 148
| 25
|
150,857
|
protected List < String > splitLinesAndNewLines ( String text ) { if ( text == null ) return Collections . emptyList ( ) ; int idx = initialSegmentSize ( text ) ; if ( idx == text . length ( ) ) { return Collections . singletonList ( text ) ; } return continueSplitting ( text , idx ) ; }
|
Return a list of segments where each segment is either the content of a line in the given text or a line - break according to the configured delimiter . Existing line - breaks in the text will be replaced by this s instances delimiter .
| 78
| 49
|
150,858
|
@ Pure public static < K , V > Pair < K , V > of ( K k , V v ) { return new Pair < K , V > ( k , v ) ; }
|
Creates a new instance with the given key and value . May be used instead of the constructor for convenience reasons .
| 39
| 23
|
150,859
|
@ Pure public static < P1 > Procedure0 curry ( final Procedure1 < ? super P1 > procedure , final P1 argument ) { if ( procedure == null ) throw new NullPointerException ( "procedure" ) ; return new Procedure0 ( ) { @ Override public void apply ( ) { procedure . apply ( argument ) ; } } ; }
|
Curries a procedure that takes one argument .
| 76
| 9
|
150,860
|
@ Pure public static < P1 , P2 > Procedure1 < P2 > curry ( final Procedure2 < ? super P1 , ? super P2 > procedure , final P1 argument ) { if ( procedure == null ) throw new NullPointerException ( "procedure" ) ; return new Procedure1 < P2 > ( ) { @ Override public void apply ( P2 p ) { procedure . apply ( argument , p ) ; } } ; }
|
Curries a procedure that takes two arguments .
| 97
| 9
|
150,861
|
@ Pure public static < P1 , P2 , P3 > Procedure2 < P2 , P3 > curry ( final Procedure3 < ? super P1 , ? super P2 , ? super P3 > procedure , final P1 argument ) { if ( procedure == null ) throw new NullPointerException ( "procedure" ) ; return new Procedure2 < P2 , P3 > ( ) { @ Override public void apply ( P2 p2 , P3 p3 ) { procedure . apply ( argument , p2 , p3 ) ; } } ; }
|
Curries a procedure that takes three arguments .
| 121
| 9
|
150,862
|
@ Pure public static < P1 , P2 , P3 , P4 , P5 > Procedure4 < P2 , P3 , P4 , P5 > curry ( final Procedure5 < ? super P1 , ? super P2 , ? super P3 , ? super P4 , ? super P5 > procedure , final P1 argument ) { if ( procedure == null ) throw new NullPointerException ( "procedure" ) ; return new Procedure4 < P2 , P3 , P4 , P5 > ( ) { @ Override public void apply ( P2 p2 , P3 p3 , P4 p4 , P5 p5 ) { procedure . apply ( argument , p2 , p3 , p4 , p5 ) ; } } ; }
|
Curries a procedure that takes five arguments .
| 165
| 9
|
150,863
|
public Path getParent ( ) { if ( ! isAbsolute ( ) ) throw new IllegalStateException ( "path is not absolute: " + toString ( ) ) ; if ( segments . isEmpty ( ) ) return null ; return new Path ( segments . subList ( 0 , segments . size ( ) - 1 ) , true ) ; }
|
Returns the parent of this path or null if this path is the root path .
| 72
| 16
|
150,864
|
public Path relativize ( Path other ) { if ( other . isAbsolute ( ) != isAbsolute ( ) ) throw new IllegalArgumentException ( "This path and the given path are not both absolute or both relative: " + toString ( ) + " | " + other . toString ( ) ) ; if ( startsWith ( other ) ) { return internalRelativize ( this , other ) ; } else if ( other . startsWith ( this ) ) { return internalRelativize ( other , this ) ; } return null ; }
|
Constructs a relative path between this path and a given path .
| 118
| 13
|
150,865
|
@ Inline ( value = "$1.put($2.getKey(), $2.getValue())" , statementExpression = true ) public static < K , V > V operator_add ( Map < K , V > map , Pair < ? extends K , ? extends V > entry ) { return map . put ( entry . getKey ( ) , entry . getValue ( ) ) ; }
|
Add the given pair into the map .
| 84
| 8
|
150,866
|
@ Inline ( value = "$1.putAll($2)" , statementExpression = true ) public static < K , V > void operator_add ( Map < K , V > outputMap , Map < ? extends K , ? extends V > inputMap ) { outputMap . putAll ( inputMap ) ; }
|
Add the given entries of the input map into the output map .
| 67
| 13
|
150,867
|
@ Pure @ Inline ( value = "$3.union($1, $4.singletonMap($2.getKey(), $2.getValue()))" , imported = { MapExtensions . class , Collections . class } ) public static < K , V > Map < K , V > operator_plus ( Map < K , V > left , final Pair < ? extends K , ? extends V > right ) { return union ( left , Collections . singletonMap ( right . getKey ( ) , right . getValue ( ) ) ) ; }
|
Add the given pair to a given map for obtaining a new map .
| 117
| 14
|
150,868
|
@ Pure @ Inline ( value = "$3.union($1, $2)" , imported = MapExtensions . class ) public static < K , V > Map < K , V > operator_plus ( Map < K , V > left , Map < ? extends K , ? extends V > right ) { return union ( left , right ) ; }
|
Merge the two maps .
| 74
| 6
|
150,869
|
@ Inline ( value = "$1.remove($2)" , statementExpression = true ) public static < K , V > V operator_remove ( Map < K , V > map , K key ) { return map . remove ( key ) ; }
|
Remove a key from the given map .
| 53
| 8
|
150,870
|
@ Inline ( value = "$1.remove($2.getKey(), $2.getValue())" , statementExpression = true ) public static < K , V > boolean operator_remove ( Map < K , V > map , Pair < ? extends K , ? extends V > entry ) { //TODO use the JRE 1.8 API: map.remove(entry.getKey(), entry.getValue()); final K key = entry . getKey ( ) ; final V storedValue = map . get ( entry . getKey ( ) ) ; if ( ! Objects . equal ( storedValue , entry . getValue ( ) ) || ( storedValue == null && ! map . containsKey ( key ) ) ) { return false ; } map . remove ( key ) ; return true ; }
|
Remove the given pair into the map .
| 168
| 8
|
150,871
|
public static < K , V > void operator_remove ( Map < K , V > map , Iterable < ? super K > keysToRemove ) { for ( final Object key : keysToRemove ) { map . remove ( key ) ; } }
|
Remove pairs with the given keys from the map .
| 52
| 10
|
150,872
|
@ Pure public static < K , V > Map < K , V > operator_minus ( Map < K , V > left , final Pair < ? extends K , ? extends V > right ) { return Maps . filterEntries ( left , new Predicate < Entry < K , V > > ( ) { @ Override public boolean apply ( Entry < K , V > input ) { return ! Objects . equal ( input . getKey ( ) , right . getKey ( ) ) || ! Objects . equal ( input . getValue ( ) , right . getValue ( ) ) ; } } ) ; }
|
Remove the given pair from a given map for obtaining a new map .
| 126
| 14
|
150,873
|
@ Pure public static < K , V > Map < K , V > operator_minus ( Map < K , V > map , final K key ) { return Maps . filterKeys ( map , new Predicate < K > ( ) { @ Override public boolean apply ( K input ) { return ! Objects . equal ( input , key ) ; } } ) ; }
|
Replies the elements of the given map except the pair with the given key .
| 76
| 16
|
150,874
|
@ Pure public static < K , V > Map < K , V > operator_minus ( Map < K , V > left , final Map < ? extends K , ? extends V > right ) { return Maps . filterEntries ( left , new Predicate < Entry < K , V > > ( ) { @ Override public boolean apply ( Entry < K , V > input ) { final V value = right . get ( input . getKey ( ) ) ; if ( value == null ) { return input . getValue ( ) == null && right . containsKey ( input . getKey ( ) ) ; } return ! Objects . equal ( input . getValue ( ) , value ) ; } } ) ; }
|
Replies the elements of the left map without the pairs in the right map . If the pair s values differ from the value within the map the map entry is not removed .
| 148
| 35
|
150,875
|
@ Pure public static < K , V > Map < K , V > operator_minus ( Map < K , V > map , final Iterable < ? > keys ) { return Maps . filterKeys ( map , new Predicate < K > ( ) { @ Override public boolean apply ( K input ) { return ! Iterables . contains ( keys , input ) ; } } ) ; }
|
Replies the elements of the given map except the pairs with the given keys .
| 81
| 16
|
150,876
|
@ Pure @ Inline ( value = "(new $3<$5, $6>($1, $2))" , imported = UnmodifiableMergingMapView . class , constantExpression = true ) public static < K , V > Map < K , V > union ( Map < ? extends K , ? extends V > left , Map < ? extends K , ? extends V > right ) { return new UnmodifiableMergingMapView < K , V > ( left , right ) ; }
|
Merge the given maps .
| 106
| 6
|
150,877
|
@ Pure public static < P1 , RESULT > Function0 < RESULT > curry ( final Function1 < ? super P1 , ? extends RESULT > function , final P1 argument ) { if ( function == null ) throw new NullPointerException ( "function" ) ; return new Function0 < RESULT > ( ) { @ Override public RESULT apply ( ) { return function . apply ( argument ) ; } } ; }
|
Curries a function that takes one argument .
| 92
| 9
|
150,878
|
@ Pure public static < P1 , P2 , RESULT > Function1 < P2 , RESULT > curry ( final Function2 < ? super P1 , ? super P2 , ? extends RESULT > function , final P1 argument ) { if ( function == null ) throw new NullPointerException ( "function" ) ; return new Function1 < P2 , RESULT > ( ) { @ Override public RESULT apply ( P2 p ) { return function . apply ( argument , p ) ; } } ; }
|
Curries a function that takes two arguments .
| 111
| 9
|
150,879
|
@ Pure public static < P1 , P2 , P3 , RESULT > Function2 < P2 , P3 , RESULT > curry ( final Function3 < ? super P1 , ? super P2 , ? super P3 , ? extends RESULT > function , final P1 argument ) { if ( function == null ) throw new NullPointerException ( "function" ) ; return new Function2 < P2 , P3 , RESULT > ( ) { @ Override public RESULT apply ( P2 p2 , P3 p3 ) { return function . apply ( argument , p2 , p3 ) ; } } ; }
|
Curries a function that takes three arguments .
| 135
| 9
|
150,880
|
@ Pure public static < P1 , P2 , P3 , P4 , RESULT > Function3 < P2 , P3 , P4 , RESULT > curry ( final Function4 < ? super P1 , ? super P2 , ? super P3 , ? super P4 , ? extends RESULT > function , final P1 argument ) { if ( function == null ) throw new NullPointerException ( "function" ) ; return new Function3 < P2 , P3 , P4 , RESULT > ( ) { @ Override public RESULT apply ( P2 p2 , P3 p3 , P4 p4 ) { return function . apply ( argument , p2 , p3 , p4 ) ; } } ; }
|
Curries a function that takes four arguments .
| 157
| 9
|
150,881
|
@ Pure public static < T > Iterable < T > filterNull ( Iterable < T > unfiltered ) { return Iterables . filter ( unfiltered , Predicates . notNull ( ) ) ; }
|
Returns a new iterable filtering any null references .
| 45
| 10
|
150,882
|
public static < T extends Comparable < ? super T > > List < T > sort ( Iterable < T > iterable ) { List < T > asList = Lists . newArrayList ( iterable ) ; if ( iterable instanceof SortedSet < ? > ) { if ( ( ( SortedSet < T > ) iterable ) . comparator ( ) == null ) { return asList ; } } return ListExtensions . sortInplace ( asList ) ; }
|
Creates a sorted list that contains the items of the given iterable . The resulting list is in ascending order according to the natural ordering of the elements in the iterable .
| 102
| 35
|
150,883
|
public static < T > List < T > sortWith ( Iterable < T > iterable , Comparator < ? super T > comparator ) { return ListExtensions . sortInplace ( Lists . newArrayList ( iterable ) , comparator ) ; }
|
Creates a sorted list that contains the items of the given iterable . The resulting list is sorted according to the order induced by the specified comparator .
| 55
| 31
|
150,884
|
public static < T , C extends Comparable < ? super C > > List < T > sortBy ( Iterable < T > iterable , final Functions . Function1 < ? super T , C > key ) { return ListExtensions . sortInplaceBy ( Lists . newArrayList ( iterable ) , key ) ; }
|
Creates a sorted list that contains the items of the given iterable . The resulting list is sorted according to the order induced by applying a key function to each element which yields a comparable criteria .
| 69
| 39
|
150,885
|
private static Object checkComponentType ( Object array , Class < ? > expectedComponentType ) { Class < ? > actualComponentType = array . getClass ( ) . getComponentType ( ) ; if ( ! expectedComponentType . isAssignableFrom ( actualComponentType ) ) { throw new ArrayStoreException ( String . format ( "The expected component type %s is not assignable from the actual type %s" , expectedComponentType . getCanonicalName ( ) , actualComponentType . getCanonicalName ( ) ) ) ; } return array ; }
|
Checks the component type of the given array against the expected component type .
| 119
| 15
|
150,886
|
@ GwtIncompatible ( "Class.getDeclaredFields" ) public ToStringBuilder addDeclaredFields ( ) { Field [ ] fields = instance . getClass ( ) . getDeclaredFields ( ) ; for ( Field field : fields ) { addField ( field ) ; } return this ; }
|
Adds all fields declared directly in the object s class to the output
| 67
| 13
|
150,887
|
@ GwtIncompatible ( "Class.getDeclaredFields" ) public ToStringBuilder addAllFields ( ) { List < Field > fields = getAllDeclaredFields ( instance . getClass ( ) ) ; for ( Field field : fields ) { addField ( field ) ; } return this ; }
|
Adds all fields declared in the object s class and its superclasses to the output .
| 67
| 17
|
150,888
|
@ Pure public static < T > Iterator < T > filterNull ( Iterator < T > unfiltered ) { return Iterators . filter ( unfiltered , Predicates . notNull ( ) ) ; }
|
Returns a new iterator filtering any null references .
| 45
| 9
|
150,889
|
public static < T > List < T > toList ( Iterator < ? extends T > iterator ) { return Lists . newArrayList ( iterator ) ; }
|
Returns a list that contains all the entries of the given iterator in the same order .
| 33
| 17
|
150,890
|
public static < T > Set < T > toSet ( Iterator < ? extends T > iterator ) { return Sets . newLinkedHashSet ( toIterable ( iterator ) ) ; }
|
Returns a set that contains all the unique entries of the given iterator in the order of their appearance . The result set is a copy of the iterator with stable order .
| 40
| 33
|
150,891
|
public HomekitRoot createBridge ( HomekitAuthInfo authInfo , String label , String manufacturer , String model , String serialNumber ) throws IOException { HomekitRoot root = new HomekitRoot ( label , http , localAddress , authInfo ) ; root . addAccessory ( new HomekitBridge ( label , serialNumber , model , manufacturer ) ) ; return root ; }
|
Creates a bridge accessory capable of holding multiple child accessories . This has the advantage over multiple standalone accessories of only requiring a single pairing from iOS for the bridge .
| 77
| 32
|
150,892
|
protected CompletableFuture < JsonObjectBuilder > makeBuilder ( int instanceId ) { CompletableFuture < T > futureValue = getValue ( ) ; if ( futureValue == null ) { logger . error ( "Could not retrieve value " + this . getClass ( ) . getName ( ) ) ; return null ; } return futureValue . exceptionally ( t -> { logger . error ( "Could not retrieve value " + this . getClass ( ) . getName ( ) , t ) ; return null ; } ) . thenApply ( value -> { JsonArrayBuilder perms = Json . createArrayBuilder ( ) ; if ( isWritable ) { perms . add ( "pw" ) ; } if ( isReadable ) { perms . add ( "pr" ) ; } if ( isEventable ) { perms . add ( "ev" ) ; } JsonObjectBuilder builder = Json . createObjectBuilder ( ) . add ( "iid" , instanceId ) . add ( "type" , shortType ) . add ( "perms" , perms . build ( ) ) . add ( "format" , format ) . add ( "ev" , false ) . add ( "description" , description ) ; setJsonValue ( builder , value ) ; return builder ; } ) ; }
|
Creates the JSON serialized form of the accessory for use over the Homekit Accessory Protocol .
| 283
| 20
|
150,893
|
protected void setJsonValue ( JsonObjectBuilder builder , T value ) { // I don't like this - there should really be a way to construct a disconnected JSONValue... if ( value instanceof Boolean ) { builder . add ( "value" , ( Boolean ) value ) ; } else if ( value instanceof Double ) { builder . add ( "value" , ( Double ) value ) ; } else if ( value instanceof Integer ) { builder . add ( "value" , ( Integer ) value ) ; } else if ( value instanceof Long ) { builder . add ( "value" , ( Long ) value ) ; } else if ( value instanceof BigInteger ) { builder . add ( "value" , ( BigInteger ) value ) ; } else if ( value instanceof BigDecimal ) { builder . add ( "value" , ( BigDecimal ) value ) ; } else if ( value == null ) { builder . addNull ( "value" ) ; } else { builder . add ( "value" , value . toString ( ) ) ; } }
|
Writes the value key to the serialized characteristic
| 225
| 10
|
150,894
|
public void removeAll ( ) { LOGGER . debug ( "Removing {} reverse connections from subscription manager" , reverse . size ( ) ) ; Iterator < HomekitClientConnection > i = reverse . keySet ( ) . iterator ( ) ; while ( i . hasNext ( ) ) { HomekitClientConnection connection = i . next ( ) ; LOGGER . debug ( "Removing connection {}" , connection . hashCode ( ) ) ; removeConnection ( connection ) ; } LOGGER . debug ( "Subscription sizes are {} and {}" , reverse . size ( ) , subscriptions . size ( ) ) ; }
|
Remove all existing subscriptions
| 129
| 4
|
150,895
|
public void addAccessory ( HomekitAccessory accessory ) { if ( accessory . getId ( ) <= 1 && ! ( accessory instanceof Bridge ) ) { throw new IndexOutOfBoundsException ( "The ID of an accessory used in a bridge must be greater than 1" ) ; } addAccessorySkipRangeCheck ( accessory ) ; }
|
Add an accessory to be handled and advertised by this root . Any existing Homekit connections will be terminated to allow the clients to reconnect and see the updated accessory list . When using this for a bridge the ID of the accessory must be greater than 1 as that ID is reserved for the Bridge itself .
| 69
| 59
|
150,896
|
public void removeAccessory ( HomekitAccessory accessory ) { this . registry . remove ( accessory ) ; logger . info ( "Removed accessory " + accessory . getLabel ( ) ) ; if ( started ) { registry . reset ( ) ; webHandler . resetConnections ( ) ; } }
|
Removes an accessory from being handled or advertised by this root . Any existing Homekit connections will be terminated to allow the clients to reconnect and see the updated accessory list .
| 59
| 34
|
150,897
|
@ Override public int add ( DownloadRequest request ) throws IllegalArgumentException { checkReleased ( "add(...) called on a released ThinDownloadManager." ) ; if ( request == null ) { throw new IllegalArgumentException ( "DownloadRequest cannot be null" ) ; } return mRequestQueue . add ( request ) ; }
|
Add a new download . The download will start automatically once the download manager is ready to execute it and connectivity is available .
| 69
| 24
|
150,898
|
public DownloadRequest addCustomHeader ( String key , String value ) { mCustomHeader . put ( key , value ) ; return this ; }
|
Adds custom header to request
| 29
| 5
|
150,899
|
private void cleanupDestination ( DownloadRequest request , boolean forceClean ) { if ( ! request . isResumable ( ) || forceClean ) { Log . d ( "cleanupDestination() deleting " + request . getDestinationURI ( ) . getPath ( ) ) ; File destinationFile = new File ( request . getDestinationURI ( ) . getPath ( ) ) ; if ( destinationFile . exists ( ) ) { destinationFile . delete ( ) ; } } }
|
Called just before the thread finishes regardless of status to take any necessary action on the downloaded file with mDownloadedCacheSize file .
| 101
| 27
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.