idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
151,000 | @ IntRange ( from = 0 , to = OPAQUE ) private static int resolveLineAlpha ( @ IntRange ( from = 0 , to = OPAQUE ) final int sceneAlpha , final float maxDistance , final float distance ) { final float alphaPercent = 1f - distance / maxDistance ; final int alpha = ( int ) ( ( float ) OPAQUE * alphaPercent ) ; return alph... | Resolves line alpha based on distance comparing to max distance . Where alpha is close to 0 for maxDistance and close to 1 to 0 distance . |
151,001 | void applyFreshParticleOnScreen ( final Scene scene , final int position ) { final int w = scene . getWidth ( ) ; final int h = scene . getHeight ( ) ; if ( w == 0 || h == 0 ) { throw new IllegalStateException ( "Cannot generate particles if scene width or height is 0" ) ; } final double direction = Math . toRadians ( ... | Set new point coordinates somewhere on screen and apply new direction |
151,002 | void applyFreshParticleOffScreen ( final Scene scene , final int position ) { final int w = scene . getWidth ( ) ; final int h = scene . getHeight ( ) ; if ( w == 0 || h == 0 ) { throw new IllegalStateException ( "Cannot generate particles if scene width or height is 0" ) ; } float x = random . nextInt ( w ) ; float y ... | Set new particle coordinates somewhere off screen and apply new direction towards the screen |
151,003 | private static float angleDeg ( final float ax , final float ay , final float bx , final float by ) { final double angleRad = Math . atan2 ( ay - by , ax - bx ) ; double angle = Math . toDegrees ( angleRad ) ; if ( angleRad < 0 ) { angle += 360 ; } return ( float ) angle ; } | Returns angle in degrees between two points |
151,004 | private float newRandomIndividualParticleRadius ( final SceneConfiguration scene ) { return scene . getParticleRadiusMin ( ) == scene . getParticleRadiusMax ( ) ? scene . getParticleRadiusMin ( ) : scene . getParticleRadiusMin ( ) + ( random . nextInt ( ( int ) ( ( scene . getParticleRadiusMax ( ) - scene . getParticle... | Generates new individual particle radius based on min and max radius setting . |
151,005 | public static float distance ( final float ax , final float ay , final float bx , final float by ) { return ( float ) Math . sqrt ( ( ax - bx ) * ( ax - bx ) + ( ay - by ) * ( ay - by ) ) ; } | Calculates the distance between two points |
151,006 | public Credentials toGrgit ( ) { if ( username != null && password != null ) { return new Credentials ( username , password ) ; } else { return null ; } } | Converts to credentials for use in Grgit . |
151,007 | @ OnClick ( R . id . navigateToSampleActivity ) public void onSampleActivityCTAClick ( ) { StringParcel parcel1 = new StringParcel ( "Andy" ) ; StringParcel parcel2 = new StringParcel ( "Tony" ) ; List < StringParcel > parcelList = new ArrayList < > ( ) ; parcelList . add ( parcel1 ) ; parcelList . add ( parcel2 ) ; Sp... | Launch Sample Activity residing in the same module |
151,008 | @ OnClick ( R . id . navigateToModule1Service ) public void onNavigationServiceCTAClick ( ) { Intent intentService = HensonNavigator . gotoModule1Service ( this ) . stringExtra ( "foo" ) . build ( ) ; startService ( intentService ) ; } | Launch Navigation Service residing in the navigation module |
151,009 | public static boolean isValidFqcn ( String str ) { if ( isNullOrEmpty ( str ) ) { return false ; } final String [ ] parts = str . split ( "\\." ) ; if ( parts . length < 2 ) { return false ; } for ( String part : parts ) { if ( ! isValidJavaIdentifier ( part ) ) { return false ; } } return true ; } | Returns true if the string is a valid Java full qualified class name . |
151,010 | public TaskProvider < GenerateHensonNavigatorTask > createHensonNavigatorGenerationTask ( BaseVariant variant , String hensonNavigatorPackageName , File destinationFolder ) { TaskProvider < GenerateHensonNavigatorTask > generateHensonNavigatorTask = project . getTasks ( ) . register ( "generate" + capitalize ( variant ... | A henson navigator is a class that helps a consumer to consume the navigation api that it declares in its dependencies . The henson navigator will wrap the intent builders . Thus a henson navigator is driven by consumption of intent builders whereas the henson classes are driven by the production of an intent builder . |
151,011 | public Bundler put ( String key , Bundle value ) { delegate . putBundle ( key , value ) ; return this ; } | Inserts a Bundle value into the mapping of the underlying Bundle replacing any existing value for the given key . Either key or value may be null . |
151,012 | public Bundler put ( String key , String value ) { delegate . putString ( key , value ) ; return this ; } | Inserts a String value into the mapping of the underlying Bundle replacing any existing value for the given key . Either key or value may be null . |
151,013 | public Bundler put ( String key , String [ ] value ) { delegate . putStringArray ( key , value ) ; return this ; } | Inserts a String array value into the mapping of the underlying Bundle replacing any existing value for the given key . Either key or value may be null . |
151,014 | public Bundler put ( String key , CharSequence value ) { delegate . putCharSequence ( key , value ) ; return this ; } | Inserts a CharSequence value into the mapping of the underlying Bundle replacing any existing value for the given key . Either key or value may be null . |
151,015 | public Bundler put ( String key , CharSequence [ ] value ) { delegate . putCharSequenceArray ( key , value ) ; return this ; } | Inserts a CharSequence array value into the mapping of the underlying Bundle replacing any existing value for the given key . Either key or value may be null . |
151,016 | public Bundler put ( String key , Parcelable value ) { delegate . putParcelable ( key , value ) ; return this ; } | Inserts a Parcelable value into the mapping of the underlying Bundle replacing any existing value for the given key . Either key or value may be null . |
151,017 | public Bundler put ( String key , Parcelable [ ] value ) { delegate . putParcelableArray ( key , value ) ; return this ; } | Inserts an array of Parcelable values into the mapping of the underlying Bundle replacing any existing value for the given key . Either key or value may be null . |
151,018 | public Bundler put ( String key , Serializable value ) { delegate . putSerializable ( key , value ) ; return this ; } | Inserts a Serializable value into the mapping of the underlying Bundle replacing any existing value for the given key . Either key or value may be null . |
151,019 | public void validate ( ) throws HostNameException { if ( parsedHost != null ) { return ; } if ( validationException != null ) { throw validationException ; } synchronized ( this ) { if ( parsedHost != null ) { return ; } if ( validationException != null ) { throw validationException ; } try { parsedHost = getValidator ... | Validates that this string is a valid host name or IP address and if not throws an exception with a descriptive message indicating why it is not . |
151,020 | public boolean isValid ( ) { if ( parsedHost != null ) { return true ; } if ( validationException != null ) { return false ; } try { validate ( ) ; return true ; } catch ( HostNameException e ) { return false ; } } | Returns whether this represents a valid host name or address format . |
151,021 | public String toNormalizedString ( ) { String result = normalizedString ; if ( result == null ) { normalizedString = result = toNormalizedString ( false ) ; } return result ; } | Provides a normalized string which is lowercase for host strings and which is a normalized string for addresses . |
151,022 | public String [ ] getNormalizedLabels ( ) { if ( isValid ( ) ) { return parsedHost . getNormalizedLabels ( ) ; } if ( host . length ( ) == 0 ) { return new String [ 0 ] ; } return new String [ ] { host } ; } | Returns an array of normalized strings for this host name instance . |
151,023 | public boolean matches ( HostName host ) { if ( this == host ) { return true ; } if ( isValid ( ) ) { if ( host . isValid ( ) ) { if ( isAddressString ( ) ) { return host . isAddressString ( ) && asAddressString ( ) . equals ( host . asAddressString ( ) ) && Objects . equals ( getPort ( ) , host . getPort ( ) ) && Obje... | Returns whether the given host matches this one . For hosts to match they must represent the same addresses or have the same host names . Hosts are not resolved when matching . Also hosts must have the same port and service . They must have the same masks if they are host names . Even if two hosts are invalid they matc... |
151,024 | public IPAddress toAddress ( ) throws UnknownHostException , HostNameException { IPAddress addr = resolvedAddress ; if ( addr == null && ! resolvedIsNull ) { validate ( ) ; synchronized ( this ) { addr = resolvedAddress ; if ( addr == null && ! resolvedIsNull ) { if ( parsedHost . isAddressString ( ) ) { addr = parsedH... | If this represents an ip address returns that address . If this represents a host returns the resolved ip address of that host . Otherwise returns null but only for strings that are considered valid address strings but cannot be converted to address objects . |
151,025 | protected Iterator < MACAddress > iterator ( MACAddress original ) { MACAddressCreator creator = getAddressCreator ( ) ; boolean isSingle = ! isMultiple ( ) ; return iterator ( isSingle ? original : null , creator , isSingle ? null : segmentsIterator ( ) , getNetwork ( ) . getPrefixConfiguration ( ) . allPrefixedAddres... | these are the iterators used by MACAddress |
151,026 | public String toHexString ( boolean with0xPrefix ) { String result ; if ( hasNoStringCache ( ) || ( result = ( with0xPrefix ? stringCache . hexStringPrefixed : stringCache . hexString ) ) == null ) { result = toHexString ( with0xPrefix , null ) ; if ( with0xPrefix ) { stringCache . hexStringPrefixed = result ; } else {... | Writes this address as a single hexadecimal value with always the exact same number of characters with or without a preceding 0x prefix . |
151,027 | public String toCompressedString ( ) { String result ; if ( hasNoStringCache ( ) || ( result = getStringCache ( ) . compressedString ) == null ) { getStringCache ( ) . compressedString = result = toNormalizedString ( MACStringCache . compressedParams ) ; } return result ; } | This produces a shorter string for the address that uses the canonical representation but not using leading zeroes . |
151,028 | public String toDottedString ( ) { String result = null ; if ( hasNoStringCache ( ) || ( result = getStringCache ( ) . dottedString ) == null ) { AddressDivisionGrouping dottedGrouping = getDottedGrouping ( ) ; getStringCache ( ) . dottedString = result = toNormalizedString ( MACStringCache . dottedParams , dottedGroup... | This produces the dotted hexadecimal format aaaa . bbbb . cccc |
151,029 | public < S extends AddressSegment > void getSplitSegments ( S segs [ ] , int index , AddressSegmentCreator < S > creator ) { if ( ! isMultiple ( ) ) { int bitSizeSplit = IPv6Address . BITS_PER_SEGMENT >>> 1 ; Integer myPrefix = getSegmentPrefixLength ( ) ; Integer highPrefixBits = getSplitSegmentPrefix ( bitSizeSplit ,... | Converts this IPv6 address segment into smaller segments copying them into the given array starting at the given index . |
151,030 | public boolean containsPrefixBlock ( int prefixLength ) { checkSubnet ( this , prefixLength ) ; int divisionCount = getDivisionCount ( ) ; int prevBitCount = 0 ; for ( int i = 0 ; i < divisionCount ; i ++ ) { AddressDivision division = getDivision ( i ) ; int bitCount = division . getBitCount ( ) ; int totalBitCount = ... | Returns whether the values of this division grouping contain the prefix block for the given prefix length |
151,031 | protected static < S extends IPAddressSegment > void normalizePrefixBoundary ( int sectionPrefixBits , S segments [ ] , int segmentBitCount , int segmentByteCount , BiFunction < S , Integer , S > segProducer ) { int networkSegmentIndex = getNetworkSegmentIndex ( sectionPrefixBits , segmentByteCount , segmentBitCount ) ... | In the case where the prefix sits at a segment boundary and the prefix sequence is null - null - 0 this changes to prefix sequence of null - x - 0 where x is segment bit length . |
151,032 | protected static < R extends AddressSection , S extends AddressSegment > R fastIncrement ( R section , long increment , AddressCreator < ? , R , ? , S > addrCreator , Supplier < R > lowerProducer , Supplier < R > upperProducer , Integer prefixLength ) { if ( increment >= 0 ) { BigInteger count = section . getCount ( ) ... | Handles the cases in which we can use longs rather than BigInteger |
151,033 | public StringBuilder getSQLCondition ( StringBuilder builder , String columnName ) { String string = networkString . getString ( ) ; if ( isEntireAddress ) { matchString ( builder , columnName , string ) ; } else { matchSubString ( builder , columnName , networkString . getTrailingSegmentSeparator ( ) , networkString .... | Get an SQL condition to match this address section representation |
151,034 | protected static BigInteger getRadixPower ( BigInteger radix , int power ) { long key = ( ( ( long ) radix . intValue ( ) ) << 32 ) | power ; BigInteger result = radixPowerMap . get ( key ) ; if ( result == null ) { if ( power == 1 ) { result = radix ; } else if ( ( power & 1 ) == 0 ) { BigInteger halfPower = getRadixP... | Caches the results of radix to the given power . |
151,035 | protected byte [ ] getBytesInternal ( ) { byte cached [ ] ; if ( hasNoValueCache ( ) || ( cached = valueCache . lowerBytes ) == null ) { valueCache . lowerBytes = cached = getBytesImpl ( true ) ; } return cached ; } | gets the bytes sharing the cached array and does not clone it |
151,036 | protected byte [ ] getUpperBytesInternal ( ) { byte cached [ ] ; if ( hasNoValueCache ( ) ) { ValueCache cache = valueCache ; cache . upperBytes = cached = getBytesImpl ( false ) ; if ( ! isMultiple ( ) ) { cache . lowerBytes = cached ; } } else { ValueCache cache = valueCache ; if ( ( cached = cache . upperBytes ) == ... | Gets the bytes for the highest address in the range represented by this address . |
151,037 | public int getMinPrefixLengthForBlock ( ) { int count = getDivisionCount ( ) ; int totalPrefix = getBitCount ( ) ; for ( int i = count - 1 ; i >= 0 ; i -- ) { AddressDivisionBase div = getDivision ( i ) ; int segBitCount = div . getBitCount ( ) ; int segPrefix = div . getMinPrefixLengthForBlock ( ) ; if ( segPrefix == ... | Returns the smallest prefix length possible such that this address division grouping includes the block of addresses for that prefix . |
151,038 | public Integer getPrefixLengthForSingleBlock ( ) { int count = getDivisionCount ( ) ; int totalPrefix = 0 ; for ( int i = 0 ; i < count ; i ++ ) { AddressDivisionBase div = getDivision ( i ) ; Integer divPrefix = div . getPrefixLengthForSingleBlock ( ) ; if ( divPrefix == null ) { return null ; } totalPrefix += divPref... | Returns a prefix length for which the range of this segment grouping matches the the block of addresses for that prefix . |
151,039 | public BigInteger getCount ( ) { BigInteger cached = cachedCount ; if ( cached == null ) { cachedCount = cached = getCountImpl ( ) ; } return cached ; } | gets the count of addresses that this address division grouping may represent |
151,040 | public static int validateZone ( CharSequence zone ) { for ( int i = 0 ; i < zone . length ( ) ; i ++ ) { char c = zone . charAt ( i ) ; if ( c == IPAddress . PREFIX_LEN_SEPARATOR ) { return i ; } if ( c == IPv6Address . SEGMENT_SEPARATOR ) { return i ; } } return - 1 ; } | Returns the index of the first invalid character of the zone or - 1 if the zone is valid |
151,041 | private static long switchValue8 ( long currentHexValue , int digitCount ) { long result = 0x7 & currentHexValue ; int shift = 0 ; while ( -- digitCount > 0 ) { shift += 3 ; currentHexValue >>>= 4 ; result |= ( 0x7 & currentHexValue ) << shift ; } return result ; } | The digits were stored as a hex value thix switches them to an octal value . |
151,042 | static ParsedHost validateHostImpl ( HostName fromHost ) throws HostNameException { final String str = fromHost . toString ( ) ; HostNameParameters validationOptions = fromHost . getValidationOptions ( ) ; return validateHost ( fromHost , str , validationOptions ) ; } | So we will follow rfc 1035 and in addition allow the underscore . |
151,043 | private static CharSequence convertReverseDNSIPv4 ( String str , int suffixStartIndex ) throws AddressStringException { StringBuilder builder = new StringBuilder ( suffixStartIndex ) ; int segCount = 0 ; int j = suffixStartIndex ; for ( int i = suffixStartIndex - 1 ; i > 0 ; i -- ) { char c1 = str . charAt ( i ) ; if (... | 123 . 2 . 3 . 4 is 4 . 3 . 2 . 123 . in - addr . arpa . |
151,044 | protected boolean isPrefixBlock ( long divisionValue , long upperValue , int divisionPrefixLen ) { if ( divisionPrefixLen == 0 ) { return divisionValue == 0 && upperValue == getMaxValue ( ) ; } long ones = ~ 0L ; long divisionBitMask = ~ ( ones << getBitCount ( ) ) ; long divisionPrefixMask = ones << ( getBitCount ( ) ... | Returns whether the division range includes the block of values for its prefix length |
151,045 | public boolean matchesWithMask ( long lowerValue , long upperValue , long mask ) { if ( lowerValue == upperValue ) { return matchesWithMask ( lowerValue , mask ) ; } if ( ! isMultiple ( ) ) { return false ; } long thisValue = getDivisionValue ( ) ; long thisUpperValue = getUpperDivisionValue ( ) ; if ( ! isMaskCompatib... | returns whether masking with the given mask results in a valid contiguous range for this segment and if it does if it matches the range obtained when masking the given values with the same mask . |
151,046 | protected static boolean isMaskCompatibleWithRange ( long value , long upperValue , long maskValue , long maxValue ) { if ( value == upperValue || maskValue == maxValue || maskValue == 0 ) { return true ; } long differing = value ^ upperValue ; boolean foundDiffering = ( differing != 0 ) ; boolean differingIsLowestBit ... | when divisionPrefixLen is null isAutoSubnets has no effect |
151,047 | public boolean isEUI64 ( boolean partial ) { int segmentCount = getSegmentCount ( ) ; int endIndex = addressSegmentIndex + segmentCount ; if ( addressSegmentIndex <= 5 ) { if ( endIndex > 6 ) { int index3 = 5 - addressSegmentIndex ; IPv6AddressSegment seg3 = getSegment ( index3 ) ; IPv6AddressSegment seg4 = getSegment ... | Whether this section is consistent with an EUI64 section which means it came from an extended 8 byte address and the corresponding segments in the middle match 0xff and 0xfe |
151,048 | public MACAddressSection toEUI ( boolean extended ) { MACAddressSegment [ ] segs = toEUISegments ( extended ) ; if ( segs == null ) { return null ; } MACAddressCreator creator = getMACNetwork ( ) . getAddressCreator ( ) ; return createSectionInternal ( creator , segs , Math . max ( 0 , addressSegmentIndex - 4 ) << 1 , ... | Returns the corresponding mac section or null if this address section does not correspond to a mac section . If this address section has a prefix length it is ignored . |
151,049 | MACAddressSegment [ ] toEUISegments ( boolean extended ) { IPv6AddressSegment seg0 , seg1 , seg2 , seg3 ; int start = addressSegmentIndex ; int segmentCount = getSegmentCount ( ) ; int segmentIndex ; if ( start < 4 ) { start = 0 ; segmentIndex = 4 - start ; } else { start -= 4 ; segmentIndex = 0 ; } int originalSegment... | prefix length in this section is ignored when converting to MAC |
151,050 | public IPv4AddressSection getEmbeddedIPv4AddressSection ( int startIndex , int endIndex ) { if ( startIndex == ( ( IPv6Address . MIXED_ORIGINAL_SEGMENT_COUNT - this . addressSegmentIndex ) << 1 ) && endIndex == ( getSegmentCount ( ) << 1 ) ) { return getEmbeddedIPv4AddressSection ( ) ; } IPv4AddressCreator creator = ge... | Produces an IPv4 address section from any sequence of bytes in this IPv6 address section |
151,051 | public boolean hasUppercaseVariations ( int base , boolean lowerOnly ) { if ( base > 10 ) { int count = getSegmentCount ( ) ; for ( int i = 0 ; i < count ; i ++ ) { IPv6AddressSegment seg = getSegment ( i ) ; if ( seg . hasUppercaseVariations ( base , lowerOnly ) ) { return true ; } } } return false ; } | Returns whether this subnet or address has alphabetic digits when printed . |
151,052 | public IPv6AddressSection [ ] mergeToSequentialBlocks ( IPv6AddressSection ... sections ) throws SizeMismatchException { List < IPAddressSegmentSeries > blocks = getMergedSequentialBlocks ( this , sections , true , createSeriesCreator ( getAddressCreator ( ) , getMaxSegmentValue ( ) ) ) ; return blocks . toArray ( new ... | Merges this with the list of sections to produce the smallest array of sequential block subnets going from smallest to largest |
151,053 | public String toCanonicalString ( ) { String result ; if ( hasNoStringCache ( ) || ( result = stringCache . canonicalString ) == null ) { stringCache . canonicalString = result = toNormalizedString ( IPv6StringCache . canonicalParams ) ; } return result ; } | This produces a canonical string . |
151,054 | public String toFullString ( ) { String result ; if ( hasNoStringCache ( ) || ( result = getStringCache ( ) . fullString ) == null ) { getStringCache ( ) . fullString = result = toNormalizedString ( IPv6StringCache . fullParams ) ; } return result ; } | This produces a string with no compressed segments and all segments of full length which is 4 characters for IPv6 segments and 3 characters for IPv4 segments . |
151,055 | public String toNormalizedString ( ) { String result ; if ( hasNoStringCache ( ) || ( result = getStringCache ( ) . normalizedString ) == null ) { getStringCache ( ) . normalizedString = result = toNormalizedString ( IPv6StringCache . normalizedParams ) ; } return result ; } | The normalized string returned by this method is consistent with java . net . Inet6address . IPs are not compressed nor mixed in this representation . |
151,056 | private int [ ] getCompressIndexAndCount ( CompressOptions options , boolean createMixed ) { if ( options != null ) { CompressionChoiceOptions rangeSelection = options . rangeSelection ; RangeList compressibleSegs = rangeSelection . compressHost ( ) ? getZeroRangeSegments ( ) : getZeroSegments ( ) ; int maxIndex = - 1 ... | Chooses a single segment to be compressed or null if no segment could be chosen . |
151,057 | public static int getHostSegmentIndex ( int networkPrefixLength , int bytesPerSegment , int bitsPerSegment ) { if ( bytesPerSegment > 1 ) { if ( bytesPerSegment == 2 ) { return networkPrefixLength >> 4 ; } return networkPrefixLength / bitsPerSegment ; } return networkPrefixLength >> 3 ; } | Returns the index of the segment containing the first byte outside the network prefix . When networkPrefixLength is null or it matches or exceeds the bit length returns the segment count . |
151,058 | public void validate ( ) throws AddressStringException { if ( isValidated ( ) ) { return ; } synchronized ( this ) { if ( isValidated ( ) ) { return ; } try { parsedAddress = getValidator ( ) . validateAddress ( this ) ; isValid = true ; } catch ( AddressStringException e ) { cachedException = e ; isValid = false ; thr... | Validates this string is a valid address and if not throws an exception with a descriptive message indicating why it is not . |
151,059 | protected boolean isChangedByMask ( int maskValue , Integer segmentPrefixLength ) throws IncompatibleAddressException { boolean hasBits = ( segmentPrefixLength != null ) ; if ( hasBits && ( segmentPrefixLength < 0 || segmentPrefixLength > getBitCount ( ) ) ) { throw new PrefixLenException ( this , segmentPrefixLength )... | returns a new segment masked by the given mask |
151,060 | public boolean isMaskCompatibleWithRange ( int maskValue , Integer segmentPrefixLength ) throws PrefixLenException { if ( ! isMultiple ( ) ) { return true ; } return super . isMaskCompatibleWithRange ( maskValue , segmentPrefixLength , getNetwork ( ) . getPrefixConfiguration ( ) . allPrefixedAddressesAreSubnets ( ) ) ;... | Check that the range resulting from the mask is contiguous otherwise we cannot represent it . |
151,061 | public boolean isBitwiseOrCompatibleWithRange ( int maskValue , Integer segmentPrefixLength ) throws PrefixLenException { return super . isBitwiseOrCompatibleWithRange ( maskValue , segmentPrefixLength , getNetwork ( ) . getPrefixConfiguration ( ) . allPrefixedAddressesAreSubnets ( ) ) ; } | Similar to masking checks that the range resulting from the bitwise or is contiguous . |
151,062 | public IPv6AddressSegment join ( IPv6AddressCreator creator , IPv4AddressSegment low ) throws IncompatibleAddressException { int shift = IPv4Address . BITS_PER_SEGMENT ; Integer prefix = getJoinedSegmentPrefixLength ( shift , getSegmentPrefixLength ( ) , low . getSegmentPrefixLength ( ) ) ; if ( isMultiple ( ) ) { if (... | Joins with another IPv4 segment to produce a IPv6 segment . |
151,063 | public HostName toHostName ( ) { HostName host = fromHost ; if ( host == null ) { fromHost = host = toCanonicalHostName ( ) ; } return host ; } | If this address was resolved from a host returns that host . Otherwise does a reverse name lookup . |
151,064 | public boolean matchesWithMask ( IPAddress other , IPAddress mask ) { return getSection ( ) . matchesWithMask ( other . getSection ( ) , mask . getSection ( ) ) ; } | Applies the mask to this address and then compares values with the given address |
151,065 | public IPv6Address toLinkLocalIPv6 ( ) { IPv6AddressNetwork network = getIPv6Network ( ) ; IPv6AddressSection linkLocalPrefix = network . getLinkLocalPrefix ( ) ; IPv6AddressCreator creator = network . getAddressCreator ( ) ; return creator . createAddress ( linkLocalPrefix . append ( toEUI64IPv6 ( ) ) ) ; } | Converts to a link - local Ipv6 address . Any MAC prefix length is ignored . Other elements of this address section are incorporated into the conversion . This will provide the latter 4 segments of an IPv6 address to be paired with the link - local IPv6 prefix of 4 segments . |
151,066 | public MACAddress toEUI64 ( boolean asMAC ) { if ( ! isExtended ( ) ) { MACAddressCreator creator = getAddressCreator ( ) ; MACAddressSegment segs [ ] = creator . createSegmentArray ( EXTENDED_UNIQUE_IDENTIFIER_64_SEGMENT_COUNT ) ; MACAddressSection section = getSection ( ) ; section . getSegments ( 0 , 3 , segs , 0 ) ... | Convert to IPv6 EUI - 64 section |
151,067 | public Iterator < ? extends IPAddressSeqRange > prefixIterator ( int prefixLength ) { if ( ! isMultiple ( ) ) { return new Iterator < IPAddressSeqRange > ( ) { IPAddressSeqRange orig = IPAddressSeqRange . this ; public boolean hasNext ( ) { return orig != null ; } public IPAddressSeqRange next ( ) { if ( orig == null )... | Iterates through the range of prefixes in this range instance using the given prefix length . |
151,068 | public static IPAddressSeqRange [ ] join ( IPAddressSeqRange ... ranges ) { int joinedCount = 0 ; Arrays . sort ( ranges , Address . ADDRESS_LOW_VALUE_COMPARATOR ) ; for ( int i = 0 ; i < ranges . length ; i ++ ) { IPAddressSeqRange range = ranges [ i ] ; if ( range == null ) { continue ; } for ( int j = i + 1 ; j < ra... | Joins the given ranges into the fewest number of ranges . If no joining can take place the original array is returned . |
151,069 | public IPAddressSeqRange intersect ( IPAddressSeqRange other ) { IPAddress otherLower = other . getLower ( ) ; IPAddress otherUpper = other . getUpper ( ) ; IPAddress lower = this . getLower ( ) ; IPAddress upper = this . getUpper ( ) ; if ( compareLowValues ( lower , otherLower ) <= 0 ) { if ( compareLowValues ( upper... | Returns the intersection of this range with the given range a range which includes those addresses in both this and the given rqnge . |
151,070 | public IPAddressSeqRange [ ] subtract ( IPAddressSeqRange other ) { IPAddress otherLower = other . getLower ( ) ; IPAddress otherUpper = other . getUpper ( ) ; IPAddress lower = this . getLower ( ) ; IPAddress upper = this . getUpper ( ) ; if ( compareLowValues ( lower , otherLower ) < 0 ) { if ( compareLowValues ( upp... | Subtracts the given range from this range to produce either zero one or two address ranges that contain the addresses in this range and not in the given range . If the result has length 2 the two ranges are in increasing order . |
151,071 | protected boolean isNetworkSection ( int networkPrefixLength , boolean withPrefixLength ) { int segmentCount = getSegmentCount ( ) ; if ( segmentCount == 0 ) { return true ; } int bitsPerSegment = getBitsPerSegment ( ) ; int prefixedSegmentIndex = getNetworkSegmentIndex ( networkPrefixLength , getBytesPerSegment ( ) , ... | this method is basically checking whether we can return this for getNetworkSection |
151,072 | public Integer getBlockMaskPrefixLength ( boolean network ) { Integer prefixLen ; if ( network ) { if ( hasNoPrefixCache ( ) || ( prefixLen = prefixCache . networkMaskPrefixLen ) == null ) { prefixLen = setNetworkMaskPrefix ( checkForPrefixMask ( network ) ) ; } } else { if ( hasNoPrefixCache ( ) || ( prefixLen = prefi... | If this address section is equivalent to the mask for a CIDR prefix block it returns that prefix length . Otherwise it returns null . A CIDR network mask is an address with all 1s in the network section and then all 0s in the host section . A CIDR host mask is an address with all 0s in the network section and then all ... |
151,073 | public boolean containsNonZeroHosts ( IPAddressSection other ) { if ( ! other . isPrefixed ( ) ) { return contains ( other ) ; } int otherPrefixLength = other . getNetworkPrefixLength ( ) ; if ( otherPrefixLength == other . getBitCount ( ) ) { return contains ( other ) ; } return containsNonZeroHostsImpl ( other , othe... | Returns whether this address contains the non - zero host addresses in other . |
151,074 | public boolean matchesWithMask ( IPAddressSection other , IPAddressSection mask ) { checkMaskSectionCount ( mask ) ; checkSectionCount ( other ) ; int divCount = getSegmentCount ( ) ; for ( int i = 0 ; i < divCount ; i ++ ) { IPAddressSegment div = getSegment ( i ) ; IPAddressSegment maskSegment = mask . getSegment ( i... | Applies the mask to this address section and then compares values with the given address section |
151,075 | protected String toHexString ( boolean with0xPrefix , CharSequence zone ) { if ( isDualString ( ) ) { return toNormalizedStringRange ( toIPParams ( with0xPrefix ? IPStringCache . hexPrefixedParams : IPStringCache . hexParams ) , getLower ( ) , getUpper ( ) , zone ) ; } return toIPParams ( with0xPrefix ? IPStringCache .... | overridden in ipv6 to handle zone |
151,076 | public IPv4Address getEmbeddedIPv4Address ( int byteIndex ) { if ( byteIndex == IPv6Address . MIXED_ORIGINAL_SEGMENT_COUNT * IPv6Address . BYTES_PER_SEGMENT ) { return getEmbeddedIPv4Address ( ) ; } IPv4AddressCreator creator = getIPv4Network ( ) . getAddressCreator ( ) ; return creator . createAddress ( getSection ( )... | Produces an IPv4 address from any sequence of 4 bytes in this IPv6 address . |
151,077 | public boolean isIPv4Mapped ( ) { if ( getSegment ( 5 ) . matches ( IPv6Address . MAX_VALUE_PER_SEGMENT ) ) { for ( int i = 0 ; i < 5 ; i ++ ) { if ( ! getSegment ( i ) . isZero ( ) ) { return false ; } } return true ; } return false ; } | Whether the address is IPv4 - mapped |
151,078 | public boolean isIPv4Compatible ( ) { return getSegment ( 0 ) . isZero ( ) && getSegment ( 1 ) . isZero ( ) && getSegment ( 2 ) . isZero ( ) && getSegment ( 3 ) . isZero ( ) && getSegment ( 4 ) . isZero ( ) && getSegment ( 5 ) . isZero ( ) ; } | Whether the address is IPv4 - compatible |
151,079 | public boolean isWellKnownIPv4Translatable ( ) { if ( getSegment ( 0 ) . matches ( 0x64 ) && getSegment ( 1 ) . matches ( 0xff9b ) ) { for ( int i = 2 ; i <= 5 ; i ++ ) { if ( ! getSegment ( i ) . isZero ( ) ) { return false ; } } return true ; } return false ; } | Whether the address has the well - known prefix for IPv4 translatable addresses as in rfc 6052 and 6144 |
151,080 | public Inet6Address toInetAddress ( ) { if ( hasZone ( ) ) { Inet6Address result ; if ( hasNoValueCache ( ) || ( result = valueCache . inetAddress ) == null ) { valueCache . inetAddress = result = ( Inet6Address ) toInetAddressImpl ( getBytes ( ) ) ; } return result ; } return ( Inet6Address ) super . toInetAddress ( )... | we need to cache the address in here and not in the address section if there is a zone |
151,081 | public String toMixedString ( ) { String result ; if ( hasNoStringCache ( ) || ( result = stringCache . mixedString ) == null ) { if ( hasZone ( ) ) { stringCache . mixedString = result = toNormalizedString ( IPv6StringCache . mixedParams ) ; } else { result = getSection ( ) . toMixedString ( ) ; } } return result ; } | Produces a string in which the lower 4 bytes are expressed as an IPv4 address and the remaining upper bytes are expressed in IPv6 format . |
151,082 | public String toNormalizedString ( ) { String result ; if ( hasNoStringCache ( ) || ( result = stringCache . normalizedString ) == null ) { if ( hasZone ( ) ) { stringCache . normalizedString = result = toNormalizedString ( IPv6StringCache . normalizedParams ) ; } else { result = getSection ( ) . toNormalizedString ( )... | The normalized string returned by this method is consistent with java . net . Inet6address . |
151,083 | public String toNormalizedWildcardString ( ) { String result ; if ( hasNoStringCache ( ) || ( result = stringCache . normalizedWildcardString ) == null ) { if ( hasZone ( ) ) { stringCache . normalizedWildcardString = result = toNormalizedString ( IPv6StringCache . wildcardNormalizedParams ) ; } else { result = getSect... | note this string is used by hashCode |
151,084 | public String toNormalizedString ( boolean keepMixed , IPv6StringOptions params ) { if ( keepMixed && fromString != null && getAddressfromString ( ) . isMixedIPv6 ( ) && ! params . makeMixed ( ) ) { params = new IPv6StringOptions ( params . base , params . expandSegments , params . wildcardOption , params . wildcards ,... | Constructs a string representing this address according to the given parameters |
151,085 | public IPv4AddressSection mask ( IPv4AddressSection mask , boolean retainPrefix ) throws IncompatibleAddressException , PrefixLenException , SizeMismatchException { checkMaskSectionCount ( mask ) ; return getSubnetSegments ( this , retainPrefix ? getPrefixLength ( ) : null , getAddressCreator ( ) , true , this :: getSe... | Does the bitwise conjunction with this address . Useful when subnetting . |
151,086 | 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 . |
151,087 | @ 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 . |
151,088 | 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 . |
151,089 | 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 . addressPr... | 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 . |
151,090 | 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 == nu... | Converts this address to a prefix length |
151,091 | 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 . getDivision... | 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 . |
151,092 | 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 . getDivisionVa... | 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 . |
151,093 | 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 . |
151,094 | 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 . |
151,095 | public IPv6Address getIPv6Address ( IPv6AddressSegment segs [ ] ) { IPv6AddressCreator creator = getIPv6Network ( ) . getAddressCreator ( ) ; return creator . createAddress ( IPv6AddressSection . createSection ( creator , segs , this ) ) ; } | Create an IPv6 mixed address using the given ipv6 segments and using this address for the embedded IPv4 segments |
151,096 | public boolean isPrivate ( ) { 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 |
151,097 | 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 |
151,098 | 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 . u... | Adopts an xml dom element to the owner document of this element if necessary . |
151,099 | 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.