idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
27,300
public final static int readMdLink ( final StringBuilder out , final String in , final int start ) { int pos = start ; int counter = 1 ; while ( pos < in . length ( ) ) { final char ch = in . charAt ( pos ) ; if ( ch == '\\' && pos + 1 < in . length ( ) ) { pos = escape ( out , in . charAt ( pos + 1 ) , pos ) ; } else ...
Reads a markdown link .
27,301
public final static int readMdLinkId ( final StringBuilder out , final String in , final int start ) { int pos = start ; int counter = 1 ; while ( pos < in . length ( ) ) { final char ch = in . charAt ( pos ) ; boolean endReached = false ; switch ( ch ) { case '\n' : out . append ( ' ' ) ; break ; case '[' : counter ++...
Reads a markdown link ID .
27,302
public final static int readXMLUntil ( final StringBuilder out , final String in , final int start , final char ... end ) { int pos = start ; boolean inString = false ; char stringChar = 0 ; while ( pos < in . length ( ) ) { final char ch = in . charAt ( pos ) ; if ( inString ) { if ( ch == '\\' ) { out . append ( ch )...
Reads characters until any end character is encountered ignoring escape sequences .
27,303
public final static void appendCode ( final StringBuilder out , final String in , final int start , final int end ) { for ( int i = start ; i < end ; i ++ ) { final char c ; switch ( c = in . charAt ( i ) ) { case '&' : out . append ( "&amp;" ) ; break ; case '<' : out . append ( "&lt;" ) ; break ; case '>' : out . app...
Appends the given string encoding special HTML characters .
27,304
public final static void appendDecEntity ( final StringBuilder out , final char value ) { out . append ( "&#" ) ; out . append ( ( int ) value ) ; out . append ( ';' ) ; }
Append the given char as a decimal HTML entity .
27,305
public final static void codeEncode ( final StringBuilder out , final String value , final int offset ) { for ( int i = offset ; i < value . length ( ) ; i ++ ) { final char c = value . charAt ( i ) ; switch ( c ) { case '&' : out . append ( "&amp;" ) ; break ; case '<' : out . append ( "&lt;" ) ; break ; case '>' : ou...
Appends the given string to the given StringBuilder replacing &amp ; &lt ; and &gt ; by their respective HTML entities .
27,306
private int countCharsStart ( final char ch , final boolean allowSpaces ) { int count = 0 ; for ( int i = 0 ; i < this . value . length ( ) ; i ++ ) { final char c = this . value . charAt ( i ) ; if ( c == ' ' && allowSpaces ) { continue ; } if ( c == ch ) { count ++ ; } else { break ; } } return count ; }
Counts the amount of ch at the start of this line optionally ignoring spaces .
27,307
public SimplifySpanBuild append ( String text ) { if ( TextUtils . isEmpty ( text ) ) return this ; mNormalSizeText . append ( text ) ; mStringBuilder . append ( text ) ; return this ; }
append normal text
27,308
public SimplifySpanBuild appendMultiClickable ( SpecialClickableUnit specialClickableUnit , Object ... specialUnitOrStrings ) { processMultiClickableSpecialUnit ( false , specialClickableUnit , specialUnitOrStrings ) ; return this ; }
append multi clickable SpecialUnit or String
27,309
public void Invoke ( final String method , JSONArray args , HubInvokeCallback callback ) { if ( method == null ) { throw new IllegalArgumentException ( "method" ) ; } if ( args == null ) { throw new IllegalArgumentException ( "args" ) ; } final String callbackId = mConnection . RegisterCallback ( callback ) ; HubInvoca...
Executes a method on the server asynchronously
27,310
@ 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 .
27,311
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
27,312
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
27,313
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
27,314
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 .
27,315
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
27,316
public Credentials toGrgit ( ) { if ( username != null && password != null ) { return new Credentials ( username , password ) ; } else { return null ; } }
Converts to credentials for use in Grgit .
27,317
@ 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
27,318
@ 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
27,319
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 .
27,320
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 .
27,321
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 .
27,322
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 .
27,323
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 .
27,324
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 .
27,325
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 .
27,326
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 .
27,327
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 .
27,328
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 .
27,329
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 .
27,330
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 .
27,331
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 .
27,332
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 .
27,333
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...
27,334
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 .
27,335
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
27,336
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 .
27,337
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 .
27,338
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
27,339
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 .
27,340
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
27,341
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 .
27,342
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
27,343
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
27,344
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 .
27,345
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
27,346
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 .
27,347
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 .
27,348
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 .
27,349
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
27,350
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
27,351
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 .
27,352
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 .
27,353
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 .
27,354
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
27,355
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 .
27,356
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
27,357
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
27,358
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 .
27,359
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
27,360
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
27,361
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 .
27,362
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
27,363
public String toCanonicalString ( ) { String result ; if ( hasNoStringCache ( ) || ( result = stringCache . canonicalString ) == null ) { stringCache . canonicalString = result = toNormalizedString ( IPv6StringCache . canonicalParams ) ; } return result ; }
This produces a canonical string .
27,364
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 .
27,365
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 .
27,366
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 .
27,367
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 .
27,368
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 .
27,369
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
27,370
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 .
27,371
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 .
27,372
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 .
27,373
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 .
27,374
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
27,375
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 .
27,376
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
27,377
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 .
27,378
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 .
27,379
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 .
27,380
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 .
27,381
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
27,382
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 ...
27,383
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 .
27,384
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
27,385
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
27,386
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 .
27,387
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
27,388
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
27,389
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
27,390
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
27,391
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 .
27,392
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 .
27,393
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
27,394
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
27,395
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 .
27,396
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 .
27,397
@ 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 .
27,398
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 .
27,399
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 .