repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Doctoror/ParticlesDrawable | library/src/main/java/com/doctoror/particlesdrawable/util/LineColorResolver.java | LineColorResolver.resolveLineAlpha | @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 alpha * sceneAlpha / OPAQUE;
} | java | @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 alpha * sceneAlpha / OPAQUE;
} | [
"@",
"IntRange",
"(",
"from",
"=",
"0",
",",
"to",
"=",
"OPAQUE",
")",
"private",
"static",
"int",
"resolveLineAlpha",
"(",
"@",
"IntRange",
"(",
"from",
"=",
"0",
",",
"to",
"=",
"OPAQUE",
")",
"final",
"int",
"sceneAlpha",
",",
"final",
"float",
"m... | 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.
@param distance line length
@param maxDistance max line length
@return line alpha | [
"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",
"."
] | 97ab510936692b5cf47822df78dd455f5e4b7ddf | https://github.com/Doctoror/ParticlesDrawable/blob/97ab510936692b5cf47822df78dd455f5e4b7ddf/library/src/main/java/com/doctoror/particlesdrawable/util/LineColorResolver.java#L36-L44 | train |
Doctoror/ParticlesDrawable | library/src/main/java/com/doctoror/particlesdrawable/engine/ParticleGenerator.java | ParticleGenerator.applyFreshParticleOnScreen | void applyFreshParticleOnScreen(
@NonNull 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(random.nextInt(360));
final float dCos = (float) Math.cos(direction);
final float dSin = (float) Math.sin(direction);
final float x = random.nextInt(w);
final float y = random.nextInt(h);
final float speedFactor = newRandomIndividualParticleSpeedFactor();
final float radius = newRandomIndividualParticleRadius(scene);
scene.setParticleData(
position,
x,
y,
dCos,
dSin,
radius,
speedFactor);
} | java | void applyFreshParticleOnScreen(
@NonNull 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(random.nextInt(360));
final float dCos = (float) Math.cos(direction);
final float dSin = (float) Math.sin(direction);
final float x = random.nextInt(w);
final float y = random.nextInt(h);
final float speedFactor = newRandomIndividualParticleSpeedFactor();
final float radius = newRandomIndividualParticleRadius(scene);
scene.setParticleData(
position,
x,
y,
dCos,
dSin,
radius,
speedFactor);
} | [
"void",
"applyFreshParticleOnScreen",
"(",
"@",
"NonNull",
"final",
"Scene",
"scene",
",",
"final",
"int",
"position",
")",
"{",
"final",
"int",
"w",
"=",
"scene",
".",
"getWidth",
"(",
")",
";",
"final",
"int",
"h",
"=",
"scene",
".",
"getHeight",
"(",
... | Set new point coordinates somewhere on screen and apply new direction
@param position the point position to apply new values to | [
"Set",
"new",
"point",
"coordinates",
"somewhere",
"on",
"screen",
"and",
"apply",
"new",
"direction"
] | 97ab510936692b5cf47822df78dd455f5e4b7ddf | https://github.com/Doctoror/ParticlesDrawable/blob/97ab510936692b5cf47822df78dd455f5e4b7ddf/library/src/main/java/com/doctoror/particlesdrawable/engine/ParticleGenerator.java#L56-L83 | train |
Doctoror/ParticlesDrawable | library/src/main/java/com/doctoror/particlesdrawable/engine/ParticleGenerator.java | ParticleGenerator.applyFreshParticleOffScreen | void applyFreshParticleOffScreen(
@NonNull 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 = random.nextInt(h);
// The offset to make when creating point of out bounds
final short offset = (short) (scene.getParticleRadiusMin() + scene.getLineLength());
// Point angle range
final float startAngle;
float endAngle;
// Make random offset and calulate angles so that the direction of travel will always be
// towards our View
switch (random.nextInt(4)) {
case 0:
// offset to left
x = (short) -offset;
startAngle = angleDeg(pcc, pcc, x, y);
endAngle = angleDeg(pcc, h - pcc, x, y);
break;
case 1:
// offset to top
y = (short) -offset;
startAngle = angleDeg(w - pcc, pcc, x, y);
endAngle = angleDeg(pcc, pcc, x, y);
break;
case 2:
// offset to right
x = (short) (w + offset);
startAngle = angleDeg(w - pcc, h - pcc, x, y);
endAngle = angleDeg(w - pcc, pcc, x, y);
break;
case 3:
// offset to bottom
y = (short) (h + offset);
startAngle = angleDeg(pcc, h - pcc, x, y);
endAngle = angleDeg(w - pcc, h - pcc, x, y);
break;
default:
throw new IllegalArgumentException("Supplied value out of range");
}
if (endAngle < startAngle) {
endAngle += 360;
}
// Get random angle from angle range
final float randomAngleInRange = startAngle + (random
.nextInt((int) Math.abs(endAngle - startAngle)));
final double direction = Math.toRadians(randomAngleInRange);
final float dCos = (float) Math.cos(direction);
final float dSin = (float) Math.sin(direction);
final float speedFactor = newRandomIndividualParticleSpeedFactor();
final float radius = newRandomIndividualParticleRadius(scene);
scene.setParticleData(
position,
x,
y,
dCos,
dSin,
radius,
speedFactor);
} | java | void applyFreshParticleOffScreen(
@NonNull 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 = random.nextInt(h);
// The offset to make when creating point of out bounds
final short offset = (short) (scene.getParticleRadiusMin() + scene.getLineLength());
// Point angle range
final float startAngle;
float endAngle;
// Make random offset and calulate angles so that the direction of travel will always be
// towards our View
switch (random.nextInt(4)) {
case 0:
// offset to left
x = (short) -offset;
startAngle = angleDeg(pcc, pcc, x, y);
endAngle = angleDeg(pcc, h - pcc, x, y);
break;
case 1:
// offset to top
y = (short) -offset;
startAngle = angleDeg(w - pcc, pcc, x, y);
endAngle = angleDeg(pcc, pcc, x, y);
break;
case 2:
// offset to right
x = (short) (w + offset);
startAngle = angleDeg(w - pcc, h - pcc, x, y);
endAngle = angleDeg(w - pcc, pcc, x, y);
break;
case 3:
// offset to bottom
y = (short) (h + offset);
startAngle = angleDeg(pcc, h - pcc, x, y);
endAngle = angleDeg(w - pcc, h - pcc, x, y);
break;
default:
throw new IllegalArgumentException("Supplied value out of range");
}
if (endAngle < startAngle) {
endAngle += 360;
}
// Get random angle from angle range
final float randomAngleInRange = startAngle + (random
.nextInt((int) Math.abs(endAngle - startAngle)));
final double direction = Math.toRadians(randomAngleInRange);
final float dCos = (float) Math.cos(direction);
final float dSin = (float) Math.sin(direction);
final float speedFactor = newRandomIndividualParticleSpeedFactor();
final float radius = newRandomIndividualParticleRadius(scene);
scene.setParticleData(
position,
x,
y,
dCos,
dSin,
radius,
speedFactor);
} | [
"void",
"applyFreshParticleOffScreen",
"(",
"@",
"NonNull",
"final",
"Scene",
"scene",
",",
"final",
"int",
"position",
")",
"{",
"final",
"int",
"w",
"=",
"scene",
".",
"getWidth",
"(",
")",
";",
"final",
"int",
"h",
"=",
"scene",
".",
"getHeight",
"(",... | Set new particle coordinates somewhere off screen and apply new direction towards the screen
@param position the particle position to apply new values to | [
"Set",
"new",
"particle",
"coordinates",
"somewhere",
"off",
"screen",
"and",
"apply",
"new",
"direction",
"towards",
"the",
"screen"
] | 97ab510936692b5cf47822df78dd455f5e4b7ddf | https://github.com/Doctoror/ParticlesDrawable/blob/97ab510936692b5cf47822df78dd455f5e4b7ddf/library/src/main/java/com/doctoror/particlesdrawable/engine/ParticleGenerator.java#L90-L167 | train |
Doctoror/ParticlesDrawable | library/src/main/java/com/doctoror/particlesdrawable/engine/ParticleGenerator.java | ParticleGenerator.angleDeg | 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;
} | java | 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;
} | [
"private",
"static",
"float",
"angleDeg",
"(",
"final",
"float",
"ax",
",",
"final",
"float",
"ay",
",",
"final",
"float",
"bx",
",",
"final",
"float",
"by",
")",
"{",
"final",
"double",
"angleRad",
"=",
"Math",
".",
"atan2",
"(",
"ay",
"-",
"by",
",... | Returns angle in degrees between two points
@param ax x of the point 1
@param ay y of the point 1
@param bx x of the point 2
@param by y of the point 2
@return angle in degrees between two points | [
"Returns",
"angle",
"in",
"degrees",
"between",
"two",
"points"
] | 97ab510936692b5cf47822df78dd455f5e4b7ddf | https://github.com/Doctoror/ParticlesDrawable/blob/97ab510936692b5cf47822df78dd455f5e4b7ddf/library/src/main/java/com/doctoror/particlesdrawable/engine/ParticleGenerator.java#L178-L186 | train |
Doctoror/ParticlesDrawable | library/src/main/java/com/doctoror/particlesdrawable/engine/ParticleGenerator.java | ParticleGenerator.newRandomIndividualParticleRadius | private float newRandomIndividualParticleRadius(@NonNull final SceneConfiguration scene) {
return scene.getParticleRadiusMin() == scene.getParticleRadiusMax() ?
scene.getParticleRadiusMin() : scene.getParticleRadiusMin() + (random.nextInt(
(int) ((scene.getParticleRadiusMax() - scene.getParticleRadiusMin()) * 100f)))
/ 100f;
} | java | private float newRandomIndividualParticleRadius(@NonNull final SceneConfiguration scene) {
return scene.getParticleRadiusMin() == scene.getParticleRadiusMax() ?
scene.getParticleRadiusMin() : scene.getParticleRadiusMin() + (random.nextInt(
(int) ((scene.getParticleRadiusMax() - scene.getParticleRadiusMin()) * 100f)))
/ 100f;
} | [
"private",
"float",
"newRandomIndividualParticleRadius",
"(",
"@",
"NonNull",
"final",
"SceneConfiguration",
"scene",
")",
"{",
"return",
"scene",
".",
"getParticleRadiusMin",
"(",
")",
"==",
"scene",
".",
"getParticleRadiusMax",
"(",
")",
"?",
"scene",
".",
"getP... | Generates new individual particle radius based on min and max radius setting.
@return new particle radius | [
"Generates",
"new",
"individual",
"particle",
"radius",
"based",
"on",
"min",
"and",
"max",
"radius",
"setting",
"."
] | 97ab510936692b5cf47822df78dd455f5e4b7ddf | https://github.com/Doctoror/ParticlesDrawable/blob/97ab510936692b5cf47822df78dd455f5e4b7ddf/library/src/main/java/com/doctoror/particlesdrawable/engine/ParticleGenerator.java#L203-L208 | train |
Doctoror/ParticlesDrawable | library/src/main/java/com/doctoror/particlesdrawable/util/DistanceResolver.java | DistanceResolver.distance | 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)
);
} | java | 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)
);
} | [
"public",
"static",
"float",
"distance",
"(",
"final",
"float",
"ax",
",",
"final",
"float",
"ay",
",",
"final",
"float",
"bx",
",",
"final",
"float",
"by",
")",
"{",
"return",
"(",
"float",
")",
"Math",
".",
"sqrt",
"(",
"(",
"ax",
"-",
"bx",
")",... | Calculates the distance between two points
@return distance between two points | [
"Calculates",
"the",
"distance",
"between",
"two",
"points"
] | 97ab510936692b5cf47822df78dd455f5e4b7ddf | https://github.com/Doctoror/ParticlesDrawable/blob/97ab510936692b5cf47822df78dd455f5e4b7ddf/library/src/main/java/com/doctoror/particlesdrawable/util/DistanceResolver.java#L28-L34 | train |
ajoberstar/gradle-git | src/main/groovy/org/ajoberstar/gradle/git/auth/BasicPasswordCredentials.java | BasicPasswordCredentials.toGrgit | public Credentials toGrgit() {
if (username != null && password != null) {
return new Credentials(username, password);
} else {
return null;
}
} | java | public Credentials toGrgit() {
if (username != null && password != null) {
return new Credentials(username, password);
} else {
return null;
}
} | [
"public",
"Credentials",
"toGrgit",
"(",
")",
"{",
"if",
"(",
"username",
"!=",
"null",
"&&",
"password",
"!=",
"null",
")",
"{",
"return",
"new",
"Credentials",
"(",
"username",
",",
"password",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
... | Converts to credentials for use in Grgit.
@return {@code null} if both username and password are {@code null},
otherwise returns credentials in Grgit format. | [
"Converts",
"to",
"credentials",
"for",
"use",
"in",
"Grgit",
"."
] | 03b08b9f8dd2b2ff0ee9228906a6e9781b85ec79 | https://github.com/ajoberstar/gradle-git/blob/03b08b9f8dd2b2ff0ee9228906a6e9781b85ec79/src/main/groovy/org/ajoberstar/gradle/git/auth/BasicPasswordCredentials.java#L87-L93 | train |
f2prateek/dart | dart-sample/app/src/main/java/com/f2prateek/dart/example/MainActivity.java | MainActivity.onSampleActivityCTAClick | @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);
SparseArray<StringParcel> parcelSparseArray = new SparseArray<>();
parcelSparseArray.put(0, parcel1);
parcelSparseArray.put(2, parcel2);
Intent intent = HensonNavigator.gotoSampleActivity(this)
.defaultKeyExtra("defaultKeyExtra")
.extraInt(4)
.extraListParcelable(parcelList)
.extraParcel(parcel1)
.extraParcelable(ComplexParcelable.random())
.extraSparseArrayParcelable(parcelSparseArray)
.extraString("a string")
.build();
startActivity(intent);
} | java | @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);
SparseArray<StringParcel> parcelSparseArray = new SparseArray<>();
parcelSparseArray.put(0, parcel1);
parcelSparseArray.put(2, parcel2);
Intent intent = HensonNavigator.gotoSampleActivity(this)
.defaultKeyExtra("defaultKeyExtra")
.extraInt(4)
.extraListParcelable(parcelList)
.extraParcel(parcel1)
.extraParcelable(ComplexParcelable.random())
.extraSparseArrayParcelable(parcelSparseArray)
.extraString("a string")
.build();
startActivity(intent);
} | [
"@",
"OnClick",
"(",
"R",
".",
"id",
".",
"navigateToSampleActivity",
")",
"public",
"void",
"onSampleActivityCTAClick",
"(",
")",
"{",
"StringParcel",
"parcel1",
"=",
"new",
"StringParcel",
"(",
"\"Andy\"",
")",
";",
"StringParcel",
"parcel2",
"=",
"new",
"St... | Launch Sample Activity residing in the same module | [
"Launch",
"Sample",
"Activity",
"residing",
"in",
"the",
"same",
"module"
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/dart-sample/app/src/main/java/com/f2prateek/dart/example/MainActivity.java#L42-L66 | train |
f2prateek/dart | dart-sample/app/src/main/java/com/f2prateek/dart/example/MainActivity.java | MainActivity.onNavigationServiceCTAClick | @OnClick(R.id.navigateToModule1Service)
public void onNavigationServiceCTAClick() {
Intent intentService = HensonNavigator.gotoModule1Service(this)
.stringExtra("foo")
.build();
startService(intentService);
} | java | @OnClick(R.id.navigateToModule1Service)
public void onNavigationServiceCTAClick() {
Intent intentService = HensonNavigator.gotoModule1Service(this)
.stringExtra("foo")
.build();
startService(intentService);
} | [
"@",
"OnClick",
"(",
"R",
".",
"id",
".",
"navigateToModule1Service",
")",
"public",
"void",
"onNavigationServiceCTAClick",
"(",
")",
"{",
"Intent",
"intentService",
"=",
"HensonNavigator",
".",
"gotoModule1Service",
"(",
"this",
")",
".",
"stringExtra",
"(",
"\... | Launch Navigation Service residing in the navigation module | [
"Launch",
"Navigation",
"Service",
"residing",
"in",
"the",
"navigation",
"module"
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/dart-sample/app/src/main/java/com/f2prateek/dart/example/MainActivity.java#L96-L103 | train |
f2prateek/dart | dart-common/src/main/java/dart/common/util/StringUtil.java | StringUtil.isValidFqcn | 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;
} | java | 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;
} | [
"public",
"static",
"boolean",
"isValidFqcn",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"isNullOrEmpty",
"(",
"str",
")",
")",
"{",
"return",
"false",
";",
"}",
"final",
"String",
"[",
"]",
"parts",
"=",
"str",
".",
"split",
"(",
"\"\\\\.\"",
")",
"... | Returns true if the string is a valid Java full qualified class name.
@param str the string to be examined
@return true if str is a valid Java Fqcn | [
"Returns",
"true",
"if",
"the",
"string",
"is",
"a",
"valid",
"Java",
"full",
"qualified",
"class",
"name",
"."
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/dart-common/src/main/java/dart/common/util/StringUtil.java#L129-L143 | train |
f2prateek/dart | henson-plugin/src/main/java/dart/henson/plugin/internal/TaskManager.java | TaskManager.createHensonNavigatorGenerationTask | public TaskProvider<GenerateHensonNavigatorTask> createHensonNavigatorGenerationTask(
BaseVariant variant, String hensonNavigatorPackageName, File destinationFolder) {
TaskProvider<GenerateHensonNavigatorTask> generateHensonNavigatorTask =
project
.getTasks()
.register(
"generate" + capitalize(variant.getName()) + "HensonNavigator",
GenerateHensonNavigatorTask.class,
(Action<GenerateHensonNavigatorTask>)
generateHensonNavigatorTask1 -> {
generateHensonNavigatorTask1.hensonNavigatorPackageName =
hensonNavigatorPackageName;
generateHensonNavigatorTask1.destinationFolder = destinationFolder;
generateHensonNavigatorTask1.variant = variant;
generateHensonNavigatorTask1.logger = logger;
generateHensonNavigatorTask1.project = project;
generateHensonNavigatorTask1.hensonNavigatorGenerator =
hensonNavigatorGenerator;
});
return generateHensonNavigatorTask;
} | java | public TaskProvider<GenerateHensonNavigatorTask> createHensonNavigatorGenerationTask(
BaseVariant variant, String hensonNavigatorPackageName, File destinationFolder) {
TaskProvider<GenerateHensonNavigatorTask> generateHensonNavigatorTask =
project
.getTasks()
.register(
"generate" + capitalize(variant.getName()) + "HensonNavigator",
GenerateHensonNavigatorTask.class,
(Action<GenerateHensonNavigatorTask>)
generateHensonNavigatorTask1 -> {
generateHensonNavigatorTask1.hensonNavigatorPackageName =
hensonNavigatorPackageName;
generateHensonNavigatorTask1.destinationFolder = destinationFolder;
generateHensonNavigatorTask1.variant = variant;
generateHensonNavigatorTask1.logger = logger;
generateHensonNavigatorTask1.project = project;
generateHensonNavigatorTask1.hensonNavigatorGenerator =
hensonNavigatorGenerator;
});
return generateHensonNavigatorTask;
} | [
"public",
"TaskProvider",
"<",
"GenerateHensonNavigatorTask",
">",
"createHensonNavigatorGenerationTask",
"(",
"BaseVariant",
"variant",
",",
"String",
"hensonNavigatorPackageName",
",",
"File",
"destinationFolder",
")",
"{",
"TaskProvider",
"<",
"GenerateHensonNavigatorTask",
... | 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.
<p>This task is created per android variant:
<ul>
<li>we scan the variant compile configuration for navigation api dependencies
<li>we generate a henson navigator class for this variant that wraps the intent builders
</ul>
@param variant the variant for which to create a builder.
@param hensonNavigatorPackageName the package name in which we create the class. | [
"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",
"builder... | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/henson-plugin/src/main/java/dart/henson/plugin/internal/TaskManager.java#L58-L78 | train |
f2prateek/dart | henson/src/main/java/dart/henson/Bundler.java | Bundler.put | public Bundler put(String key, Bundle value) {
delegate.putBundle(key, value);
return this;
} | java | public Bundler put(String key, Bundle value) {
delegate.putBundle(key, value);
return this;
} | [
"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.
@param key a String, or null
@param value a Bundle object, or null
@return this bundler instance to chain method calls | [
"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",
"."
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/henson/src/main/java/dart/henson/Bundler.java#L127-L130 | train |
f2prateek/dart | henson/src/main/java/dart/henson/Bundler.java | Bundler.put | public Bundler put(String key, String value) {
delegate.putString(key, value);
return this;
} | java | public Bundler put(String key, String value) {
delegate.putString(key, value);
return this;
} | [
"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.
@param key a String, or null
@param value a String, or null
@return this bundler instance to chain method calls | [
"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",
"."
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/henson/src/main/java/dart/henson/Bundler.java#L166-L169 | train |
f2prateek/dart | henson/src/main/java/dart/henson/Bundler.java | Bundler.put | public Bundler put(String key, String[] value) {
delegate.putStringArray(key, value);
return this;
} | java | public Bundler put(String key, String[] value) {
delegate.putStringArray(key, value);
return this;
} | [
"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.
@param key a String, or null
@param value a String array object, or null
@return this bundler instance to chain method calls | [
"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",
"."
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/henson/src/main/java/dart/henson/Bundler.java#L179-L182 | train |
f2prateek/dart | henson/src/main/java/dart/henson/Bundler.java | Bundler.put | public Bundler put(String key, CharSequence value) {
delegate.putCharSequence(key, value);
return this;
} | java | public Bundler put(String key, CharSequence value) {
delegate.putCharSequence(key, value);
return this;
} | [
"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.
@param key a String, or null
@param value a CharSequence, or null
@return this bundler instance to chain method calls | [
"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",
"."
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/henson/src/main/java/dart/henson/Bundler.java#L283-L286 | train |
f2prateek/dart | henson/src/main/java/dart/henson/Bundler.java | Bundler.put | public Bundler put(String key, CharSequence[] value) {
delegate.putCharSequenceArray(key, value);
return this;
} | java | public Bundler put(String key, CharSequence[] value) {
delegate.putCharSequenceArray(key, value);
return this;
} | [
"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.
@param key a String, or null
@param value a CharSequence array object, or null
@return this bundler instance to chain method calls | [
"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",
"."
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/henson/src/main/java/dart/henson/Bundler.java#L296-L299 | train |
f2prateek/dart | henson/src/main/java/dart/henson/Bundler.java | Bundler.put | public Bundler put(String key, Parcelable value) {
delegate.putParcelable(key, value);
return this;
} | java | public Bundler put(String key, Parcelable value) {
delegate.putParcelable(key, value);
return this;
} | [
"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.
@param key a String, or null
@param value a Parcelable object, or null
@return this bundler instance to chain method calls | [
"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",
"."
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/henson/src/main/java/dart/henson/Bundler.java#L348-L351 | train |
f2prateek/dart | henson/src/main/java/dart/henson/Bundler.java | Bundler.put | public Bundler put(String key, Parcelable[] value) {
delegate.putParcelableArray(key, value);
return this;
} | java | public Bundler put(String key, Parcelable[] value) {
delegate.putParcelableArray(key, value);
return this;
} | [
"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.
@param key a String, or null
@param value an array of Parcelable objects, or null
@return this bundler instance to chain method calls | [
"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",
"."
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/henson/src/main/java/dart/henson/Bundler.java#L361-L364 | train |
f2prateek/dart | henson/src/main/java/dart/henson/Bundler.java | Bundler.put | public Bundler put(String key, Serializable value) {
delegate.putSerializable(key, value);
return this;
} | java | public Bundler put(String key, Serializable value) {
delegate.putSerializable(key, value);
return this;
} | [
"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.
@param key a String, or null
@param value a Serializable object, or null
@return this bundler instance to chain method calls | [
"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",
"."
] | 7163b1b148e5141817975ae7dad99d58a8589aeb | https://github.com/f2prateek/dart/blob/7163b1b148e5141817975ae7dad99d58a8589aeb/henson/src/main/java/dart/henson/Bundler.java#L426-L429 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java | HostName.validate | @Override
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().validateHost(this);
} catch(HostNameException e) {
validationException = e;
throw e;
}
}
} | java | @Override
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().validateHost(this);
} catch(HostNameException e) {
validationException = e;
throw e;
}
}
} | [
"@",
"Override",
"public",
"void",
"validate",
"(",
")",
"throws",
"HostNameException",
"{",
"if",
"(",
"parsedHost",
"!=",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"validationException",
"!=",
"null",
")",
"{",
"throw",
"validationException",
";",
... | 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.
@throws HostNameException | [
"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",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java#L227-L249 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java | HostName.isValid | public boolean isValid() {
if(parsedHost != null) {
return true;
}
if(validationException != null) {
return false;
}
try {
validate();
return true;
} catch(HostNameException e) {
return false;
}
} | java | public boolean isValid() {
if(parsedHost != null) {
return true;
}
if(validationException != null) {
return false;
}
try {
validate();
return true;
} catch(HostNameException e) {
return false;
}
} | [
"public",
"boolean",
"isValid",
"(",
")",
"{",
"if",
"(",
"parsedHost",
"!=",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"validationException",
"!=",
"null",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"validate",
"(",
")",
";",
... | Returns whether this represents a valid host name or address format.
@return | [
"Returns",
"whether",
"this",
"represents",
"a",
"valid",
"host",
"name",
"or",
"address",
"format",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java#L259-L272 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java | HostName.toNormalizedString | @Override
public String toNormalizedString() {
String result = normalizedString;
if(result == null) {
normalizedString = result = toNormalizedString(false);
}
return result;
} | java | @Override
public String toNormalizedString() {
String result = normalizedString;
if(result == null) {
normalizedString = result = toNormalizedString(false);
}
return result;
} | [
"@",
"Override",
"public",
"String",
"toNormalizedString",
"(",
")",
"{",
"String",
"result",
"=",
"normalizedString",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"normalizedString",
"=",
"result",
"=",
"toNormalizedString",
"(",
"false",
")",
";",
"}"... | Provides a normalized string which is lowercase for host strings, and which is a normalized string for addresses.
@return | [
"Provides",
"a",
"normalized",
"string",
"which",
"is",
"lowercase",
"for",
"host",
"strings",
"and",
"which",
"is",
"a",
"normalized",
"string",
"for",
"addresses",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java#L328-L335 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java | HostName.getNormalizedLabels | public String[] getNormalizedLabels() {
if(isValid()) {
return parsedHost.getNormalizedLabels();
}
if(host.length() == 0) {
return new String[0];
}
return new String[] {host};
} | java | public String[] getNormalizedLabels() {
if(isValid()) {
return parsedHost.getNormalizedLabels();
}
if(host.length() == 0) {
return new String[0];
}
return new String[] {host};
} | [
"public",
"String",
"[",
"]",
"getNormalizedLabels",
"(",
")",
"{",
"if",
"(",
"isValid",
"(",
")",
")",
"{",
"return",
"parsedHost",
".",
"getNormalizedLabels",
"(",
")",
";",
"}",
"if",
"(",
"host",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"... | Returns an array of normalized strings for this host name instance.
If this represents an IP address, the address segments are separated into the returned array.
If this represents a host name string, the domain name segments are separated into the returned array,
with the top-level domain name (right-most segment) as the last array element.
The individual segment strings are normalized in the same way as {@link #toNormalizedString()}
Ports, service name strings, prefix lengths, and masks are all omitted from the returned array.
@return | [
"Returns",
"an",
"array",
"of",
"normalized",
"strings",
"for",
"this",
"host",
"name",
"instance",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java#L459-L467 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java | HostName.matches | 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())
&& Objects.equals(getService(), host.getService());
}
if(host.isAddressString()) {
return false;
}
String thisHost = parsedHost.getHost();
String otherHost = host.parsedHost.getHost();
if(!thisHost.equals(otherHost)) {
return false;
}
return Objects.equals(parsedHost.getEquivalentPrefixLength(), host.parsedHost.getEquivalentPrefixLength()) &&
Objects.equals(parsedHost.getMask(), host.parsedHost.getMask()) &&
Objects.equals(parsedHost.getPort(), host.parsedHost.getPort()) &&
Objects.equals(parsedHost.getService(), host.parsedHost.getService());
}
return false;
}
return !host.isValid() && toString().equals(host.toString());
} | java | 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())
&& Objects.equals(getService(), host.getService());
}
if(host.isAddressString()) {
return false;
}
String thisHost = parsedHost.getHost();
String otherHost = host.parsedHost.getHost();
if(!thisHost.equals(otherHost)) {
return false;
}
return Objects.equals(parsedHost.getEquivalentPrefixLength(), host.parsedHost.getEquivalentPrefixLength()) &&
Objects.equals(parsedHost.getMask(), host.parsedHost.getMask()) &&
Objects.equals(parsedHost.getPort(), host.parsedHost.getPort()) &&
Objects.equals(parsedHost.getService(), host.parsedHost.getService());
}
return false;
}
return !host.isValid() && toString().equals(host.toString());
} | [
"public",
"boolean",
"matches",
"(",
"HostName",
"host",
")",
"{",
"if",
"(",
"this",
"==",
"host",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"isValid",
"(",
")",
")",
"{",
"if",
"(",
"host",
".",
"isValid",
"(",
")",
")",
"{",
"if",
"("... | 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 match if they have the same invalid string.
@param host
@return | [
"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... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java#L495-L523 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java | HostName.toAddress | @Override
public IPAddress toAddress() throws UnknownHostException, HostNameException {
IPAddress addr = resolvedAddress;
if(addr == null && !resolvedIsNull) {
//note that validation handles empty address resolution
validate();
synchronized(this) {
addr = resolvedAddress;
if(addr == null && !resolvedIsNull) {
if(parsedHost.isAddressString()) {
addr = parsedHost.asAddress();
resolvedIsNull = (addr == null);
//note there is no need to apply prefix or mask here, it would have been applied to the address already
} else {
String strHost = parsedHost.getHost();
if(strHost.length() == 0 && !validationOptions.emptyIsLoopback) {
addr = null;
resolvedIsNull = true;
} else {
//Note we do not set resolvedIsNull, so we will attempt to resolve again if the previous attempt threw an exception
InetAddress inetAddress = InetAddress.getByName(strHost);
byte bytes[] = inetAddress.getAddress();
Integer networkPrefixLength = parsedHost.getNetworkPrefixLength();
if(networkPrefixLength == null) {
IPAddress mask = parsedHost.getMask();
if(mask != null) {
byte maskBytes[] = mask.getBytes();
if(maskBytes.length != bytes.length) {
throw new HostNameException(host, "ipaddress.error.ipMismatch");
}
for(int i = 0; i < bytes.length; i++) {
bytes[i] &= maskBytes[i];
}
networkPrefixLength = mask.getBlockMaskPrefixLength(true);
}
}
IPAddressStringParameters addressParams = validationOptions.addressOptions;
if(bytes.length == IPv6Address.BYTE_COUNT) {
IPv6AddressCreator creator = addressParams.getIPv6Parameters().getNetwork().getAddressCreator();
addr = creator.createAddressInternal(bytes, networkPrefixLength, null, this); /* address creation */
} else {
IPv4AddressCreator creator = addressParams.getIPv4Parameters().getNetwork().getAddressCreator();
addr = creator.createAddressInternal(bytes, networkPrefixLength, this); /* address creation */
}
}
}
resolvedAddress = addr;
}
}
}
return addr;
} | java | @Override
public IPAddress toAddress() throws UnknownHostException, HostNameException {
IPAddress addr = resolvedAddress;
if(addr == null && !resolvedIsNull) {
//note that validation handles empty address resolution
validate();
synchronized(this) {
addr = resolvedAddress;
if(addr == null && !resolvedIsNull) {
if(parsedHost.isAddressString()) {
addr = parsedHost.asAddress();
resolvedIsNull = (addr == null);
//note there is no need to apply prefix or mask here, it would have been applied to the address already
} else {
String strHost = parsedHost.getHost();
if(strHost.length() == 0 && !validationOptions.emptyIsLoopback) {
addr = null;
resolvedIsNull = true;
} else {
//Note we do not set resolvedIsNull, so we will attempt to resolve again if the previous attempt threw an exception
InetAddress inetAddress = InetAddress.getByName(strHost);
byte bytes[] = inetAddress.getAddress();
Integer networkPrefixLength = parsedHost.getNetworkPrefixLength();
if(networkPrefixLength == null) {
IPAddress mask = parsedHost.getMask();
if(mask != null) {
byte maskBytes[] = mask.getBytes();
if(maskBytes.length != bytes.length) {
throw new HostNameException(host, "ipaddress.error.ipMismatch");
}
for(int i = 0; i < bytes.length; i++) {
bytes[i] &= maskBytes[i];
}
networkPrefixLength = mask.getBlockMaskPrefixLength(true);
}
}
IPAddressStringParameters addressParams = validationOptions.addressOptions;
if(bytes.length == IPv6Address.BYTE_COUNT) {
IPv6AddressCreator creator = addressParams.getIPv6Parameters().getNetwork().getAddressCreator();
addr = creator.createAddressInternal(bytes, networkPrefixLength, null, this); /* address creation */
} else {
IPv4AddressCreator creator = addressParams.getIPv4Parameters().getNetwork().getAddressCreator();
addr = creator.createAddressInternal(bytes, networkPrefixLength, this); /* address creation */
}
}
}
resolvedAddress = addr;
}
}
}
return addr;
} | [
"@",
"Override",
"public",
"IPAddress",
"toAddress",
"(",
")",
"throws",
"UnknownHostException",
",",
"HostNameException",
"{",
"IPAddress",
"addr",
"=",
"resolvedAddress",
";",
"if",
"(",
"addr",
"==",
"null",
"&&",
"!",
"resolvedIsNull",
")",
"{",
"//note that... | 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.
This method will throw exceptions for invalid formats and failures to resolve the address. The equivalent method {@link #getAddress()} will simply return null rather than throw those exceptions.
If you wish to get the represented address and avoid DNS resolution, use {@link #asAddress()} or {@link #asAddressString()}
@return | [
"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",
"... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/HostName.java#L867-L918 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddressSection.java | MACAddressSection.iterator | protected Iterator<MACAddress> iterator(MACAddress original) {
MACAddressCreator creator = getAddressCreator();
boolean isSingle = !isMultiple();
return iterator(
isSingle ? original : null,
creator,//using a lambda for this one results in a big performance hit
isSingle ? null : segmentsIterator(),
getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets() ? null : getPrefixLength());
} | java | protected Iterator<MACAddress> iterator(MACAddress original) {
MACAddressCreator creator = getAddressCreator();
boolean isSingle = !isMultiple();
return iterator(
isSingle ? original : null,
creator,//using a lambda for this one results in a big performance hit
isSingle ? null : segmentsIterator(),
getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets() ? null : getPrefixLength());
} | [
"protected",
"Iterator",
"<",
"MACAddress",
">",
"iterator",
"(",
"MACAddress",
"original",
")",
"{",
"MACAddressCreator",
"creator",
"=",
"getAddressCreator",
"(",
")",
";",
"boolean",
"isSingle",
"=",
"!",
"isMultiple",
"(",
")",
";",
"return",
"iterator",
"... | these are the iterators used by MACAddress | [
"these",
"are",
"the",
"iterators",
"used",
"by",
"MACAddress"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddressSection.java#L1204-L1212 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddressSection.java | MACAddressSection.toHexString | @Override
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 {
stringCache.hexString = result;
}
}
return result;
} | java | @Override
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 {
stringCache.hexString = result;
}
}
return result;
} | [
"@",
"Override",
"public",
"String",
"toHexString",
"(",
"boolean",
"with0xPrefix",
")",
"{",
"String",
"result",
";",
"if",
"(",
"hasNoStringCache",
"(",
")",
"||",
"(",
"result",
"=",
"(",
"with0xPrefix",
"?",
"stringCache",
".",
"hexStringPrefixed",
":",
... | Writes this address as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix. | [
"Writes",
"this",
"address",
"as",
"a",
"single",
"hexadecimal",
"value",
"with",
"always",
"the",
"exact",
"same",
"number",
"of",
"characters",
"with",
"or",
"without",
"a",
"preceding",
"0x",
"prefix",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddressSection.java#L1323-L1335 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddressSection.java | MACAddressSection.toCompressedString | @Override
public String toCompressedString() {
String result;
if(hasNoStringCache() || (result = getStringCache().compressedString) == null) {
getStringCache().compressedString = result = toNormalizedString(MACStringCache.compressedParams);
}
return result;
} | java | @Override
public String toCompressedString() {
String result;
if(hasNoStringCache() || (result = getStringCache().compressedString) == null) {
getStringCache().compressedString = result = toNormalizedString(MACStringCache.compressedParams);
}
return result;
} | [
"@",
"Override",
"public",
"String",
"toCompressedString",
"(",
")",
"{",
"String",
"result",
";",
"if",
"(",
"hasNoStringCache",
"(",
")",
"||",
"(",
"result",
"=",
"getStringCache",
"(",
")",
".",
"compressedString",
")",
"==",
"null",
")",
"{",
"getStri... | This produces a shorter string for the address that uses the canonical representation but not using leading zeroes.
Each address has a unique compressed string. | [
"This",
"produces",
"a",
"shorter",
"string",
"for",
"the",
"address",
"that",
"uses",
"the",
"canonical",
"representation",
"but",
"not",
"using",
"leading",
"zeroes",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddressSection.java#L1382-L1389 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddressSection.java | MACAddressSection.toDottedString | public String toDottedString() {
String result = null;
if(hasNoStringCache() || (result = getStringCache().dottedString) == null) {
AddressDivisionGrouping dottedGrouping = getDottedGrouping();
getStringCache().dottedString = result = toNormalizedString(MACStringCache.dottedParams, dottedGrouping);
}
return result;
} | java | public String toDottedString() {
String result = null;
if(hasNoStringCache() || (result = getStringCache().dottedString) == null) {
AddressDivisionGrouping dottedGrouping = getDottedGrouping();
getStringCache().dottedString = result = toNormalizedString(MACStringCache.dottedParams, dottedGrouping);
}
return result;
} | [
"public",
"String",
"toDottedString",
"(",
")",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"hasNoStringCache",
"(",
")",
"||",
"(",
"result",
"=",
"getStringCache",
"(",
")",
".",
"dottedString",
")",
"==",
"null",
")",
"{",
"AddressDivisionGrou... | This produces the dotted hexadecimal format aaaa.bbbb.cccc | [
"This",
"produces",
"the",
"dotted",
"hexadecimal",
"format",
"aaaa",
".",
"bbbb",
".",
"cccc"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddressSection.java#L1394-L1401 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSegment.java | IPv6AddressSegment.getSplitSegments | 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, myPrefix, 0);
Integer lowPrefixBits = getSplitSegmentPrefix(bitSizeSplit, myPrefix, 1);
if(index >= 0 && index < segs.length) {
segs[index] = creator.createSegment(highByte(), highPrefixBits);
}
if(++index >= 0 && index < segs.length) {
segs[index] = creator.createSegment(lowByte(), lowPrefixBits);
}
} else {
getSplitSegmentsMultiple(segs, index, creator);
}
} | java | 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, myPrefix, 0);
Integer lowPrefixBits = getSplitSegmentPrefix(bitSizeSplit, myPrefix, 1);
if(index >= 0 && index < segs.length) {
segs[index] = creator.createSegment(highByte(), highPrefixBits);
}
if(++index >= 0 && index < segs.length) {
segs[index] = creator.createSegment(lowByte(), lowPrefixBits);
}
} else {
getSplitSegmentsMultiple(segs, index, creator);
}
} | [
"public",
"<",
"S",
"extends",
"AddressSegment",
">",
"void",
"getSplitSegments",
"(",
"S",
"segs",
"[",
"]",
",",
"int",
"index",
",",
"AddressSegmentCreator",
"<",
"S",
">",
"creator",
")",
"{",
"if",
"(",
"!",
"isMultiple",
"(",
")",
")",
"{",
"int"... | Converts this IPv6 address segment into smaller segments,
copying them into the given array starting at the given index.
If a segment does not fit into the array because the segment index in the array is out of bounds of the array,
then it is not copied.
@param segs
@param index | [
"Converts",
"this",
"IPv6",
"address",
"segment",
"into",
"smaller",
"segments",
"copying",
"them",
"into",
"the",
"given",
"array",
"starting",
"at",
"the",
"given",
"index",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSegment.java#L302-L317 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivisionGrouping.java | AddressDivisionGrouping.containsPrefixBlock | @Override
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 = bitCount + prevBitCount;
if(prefixLength < totalBitCount) {
int divPrefixLen = Math.max(0, prefixLength - prevBitCount);
if(!division.isPrefixBlock(division.getDivisionValue(), division.getUpperDivisionValue(), divPrefixLen)) {
return false;
}
for(++i; i < divisionCount; i++) {
division = getDivision(i);
if(!division.isFullRange()) {
return false;
}
}
return true;
}
prevBitCount = totalBitCount;
}
return true;
} | java | @Override
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 = bitCount + prevBitCount;
if(prefixLength < totalBitCount) {
int divPrefixLen = Math.max(0, prefixLength - prevBitCount);
if(!division.isPrefixBlock(division.getDivisionValue(), division.getUpperDivisionValue(), divPrefixLen)) {
return false;
}
for(++i; i < divisionCount; i++) {
division = getDivision(i);
if(!division.isFullRange()) {
return false;
}
}
return true;
}
prevBitCount = totalBitCount;
}
return true;
} | [
"@",
"Override",
"public",
"boolean",
"containsPrefixBlock",
"(",
"int",
"prefixLength",
")",
"{",
"checkSubnet",
"(",
"this",
",",
"prefixLength",
")",
";",
"int",
"divisionCount",
"=",
"getDivisionCount",
"(",
")",
";",
"int",
"prevBitCount",
"=",
"0",
";",
... | Returns whether the values of this division grouping contain the prefix block for the given prefix length
@param prefixLength
@return | [
"Returns",
"whether",
"the",
"values",
"of",
"this",
"division",
"grouping",
"contain",
"the",
"prefix",
"block",
"for",
"the",
"given",
"prefix",
"length"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivisionGrouping.java#L136-L161 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivisionGrouping.java | AddressDivisionGrouping.normalizePrefixBoundary | protected static <S extends IPAddressSegment> void normalizePrefixBoundary(
int sectionPrefixBits,
S segments[],
int segmentBitCount,
int segmentByteCount,
BiFunction<S, Integer, S> segProducer) {
//we've already verified segment prefixes in super constructor. We simply need to check the case where the prefix is at a segment boundary,
//whether the network side has the correct prefix
int networkSegmentIndex = getNetworkSegmentIndex(sectionPrefixBits, segmentByteCount, segmentBitCount);
if(networkSegmentIndex >= 0) {
S segment = segments[networkSegmentIndex];
if(!segment.isPrefixed()) {
segments[networkSegmentIndex] = segProducer.apply(segment, segmentBitCount);
}
}
} | java | protected static <S extends IPAddressSegment> void normalizePrefixBoundary(
int sectionPrefixBits,
S segments[],
int segmentBitCount,
int segmentByteCount,
BiFunction<S, Integer, S> segProducer) {
//we've already verified segment prefixes in super constructor. We simply need to check the case where the prefix is at a segment boundary,
//whether the network side has the correct prefix
int networkSegmentIndex = getNetworkSegmentIndex(sectionPrefixBits, segmentByteCount, segmentBitCount);
if(networkSegmentIndex >= 0) {
S segment = segments[networkSegmentIndex];
if(!segment.isPrefixed()) {
segments[networkSegmentIndex] = segProducer.apply(segment, segmentBitCount);
}
}
} | [
"protected",
"static",
"<",
"S",
"extends",
"IPAddressSegment",
">",
"void",
"normalizePrefixBoundary",
"(",
"int",
"sectionPrefixBits",
",",
"S",
"segments",
"[",
"]",
",",
"int",
"segmentBitCount",
",",
"int",
"segmentByteCount",
",",
"BiFunction",
"<",
"S",
"... | 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.
Note: We allow both [null, null, 0] and [null, x, 0] where x is segment length. However, to avoid inconsistencies when doing segment replacements,
and when getting subsections, in the calling constructor we normalize [null, null, 0] to become [null, x, 0].
We need to support [null, x, 0] so that we can create subsections and full addresses ending with [null, x] where x is bit length.
So we defer to that when constructing addresses and sections.
Also note that in our append/appendNetowrk/insert/replace we have special handling for cases like inserting [null] into [null, 8, 0] at index 2.
The straight replace would give [null, 8, null, 0] which is wrong.
In that code we end up with [null, null, 8, 0] by doing a special trick:
We remove the end of [null, 8, 0] and do an append [null, 0] and we'd remove prefix from [null, 8] to get [null, null] and then we'd do another append to get [null, null, null, 0]
The final step is this normalization here that gives [null, null, 8, 0]
However, when users construct AddressDivisionGrouping or IPAddressDivisionGrouping, either one is allowed: [null, null, 0] and [null, x, 0].
Since those objects cannot be further subdivided with getSection/getNetworkSection/getHostSection or grown with appended/inserted/replaced,
there are no inconsistencies introduced, we are simply more user-friendly.
Also note that normalization of AddressDivisionGrouping or IPAddressDivisionGrouping is really not possible without the address creator objects we use for addresses and sections,
that allow us to recreate new segments of the correct type.
@param sectionPrefixBits
@param segments
@param segmentBitCount
@param segmentByteCount
@param segProducer | [
"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",
... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivisionGrouping.java#L335-L350 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivisionGrouping.java | AddressDivisionGrouping.fastIncrement | 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();
if(count.compareTo(LONG_MAX) <= 0) {
long longCount = count.longValue();
if(longCount > increment) {
if(longCount == increment + 1) {
return upperProducer.get();
}
return incrementRange(section, increment, addrCreator, lowerProducer, prefixLength);
}
BigInteger value = section.getValue();
BigInteger upperValue;
if(value.compareTo(LONG_MAX) <= 0 && (upperValue = section.getUpperValue()).compareTo(LONG_MAX) <= 0) {
return increment(
section,
increment,
addrCreator,
count.longValue(),
value.longValue(),
upperValue.longValue(),
lowerProducer,
upperProducer,
prefixLength);
}
}
} else {
BigInteger value = section.getValue();
if(value.compareTo(LONG_MAX) <= 0) {
return add(lowerProducer.get(), value.longValue(), increment, addrCreator, prefixLength);
}
}
return null;
} | java | 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();
if(count.compareTo(LONG_MAX) <= 0) {
long longCount = count.longValue();
if(longCount > increment) {
if(longCount == increment + 1) {
return upperProducer.get();
}
return incrementRange(section, increment, addrCreator, lowerProducer, prefixLength);
}
BigInteger value = section.getValue();
BigInteger upperValue;
if(value.compareTo(LONG_MAX) <= 0 && (upperValue = section.getUpperValue()).compareTo(LONG_MAX) <= 0) {
return increment(
section,
increment,
addrCreator,
count.longValue(),
value.longValue(),
upperValue.longValue(),
lowerProducer,
upperProducer,
prefixLength);
}
}
} else {
BigInteger value = section.getValue();
if(value.compareTo(LONG_MAX) <= 0) {
return add(lowerProducer.get(), value.longValue(), increment, addrCreator, prefixLength);
}
}
return null;
} | [
"protected",
"static",
"<",
"R",
"extends",
"AddressSection",
",",
"S",
"extends",
"AddressSegment",
">",
"R",
"fastIncrement",
"(",
"R",
"section",
",",
"long",
"increment",
",",
"AddressCreator",
"<",
"?",
",",
"R",
",",
"?",
",",
"S",
">",
"addrCreator"... | Handles the cases in which we can use longs rather than BigInteger
@param section
@param increment
@param addrCreator
@param lowerProducer
@param upperProducer
@param prefixLength
@return | [
"Handles",
"the",
"cases",
"in",
"which",
"we",
"can",
"use",
"longs",
"rather",
"than",
"BigInteger"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivisionGrouping.java#L1090-L1129 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/util/sql/SQLStringMatcher.java | SQLStringMatcher.getSQLCondition | public StringBuilder getSQLCondition(StringBuilder builder, String columnName) {
String string = networkString.getString();
if(isEntireAddress) {
matchString(builder, columnName, string);
} else {
matchSubString(
builder,
columnName,
networkString.getTrailingSegmentSeparator(),
networkString.getTrailingSeparatorCount() + 1,
string);
}
return builder;
} | java | public StringBuilder getSQLCondition(StringBuilder builder, String columnName) {
String string = networkString.getString();
if(isEntireAddress) {
matchString(builder, columnName, string);
} else {
matchSubString(
builder,
columnName,
networkString.getTrailingSegmentSeparator(),
networkString.getTrailingSeparatorCount() + 1,
string);
}
return builder;
} | [
"public",
"StringBuilder",
"getSQLCondition",
"(",
"StringBuilder",
"builder",
",",
"String",
"columnName",
")",
"{",
"String",
"string",
"=",
"networkString",
".",
"getString",
"(",
")",
";",
"if",
"(",
"isEntireAddress",
")",
"{",
"matchString",
"(",
"builder"... | Get an SQL condition to match this address section representation
@param builder
@param columnName
@return the condition | [
"Get",
"an",
"SQL",
"condition",
"to",
"match",
"this",
"address",
"section",
"representation"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/util/sql/SQLStringMatcher.java#L53-L66 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionBase.java | AddressDivisionBase.getRadixPower | 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 = getRadixPower(radix, power >> 1);
result = halfPower.multiply(halfPower);
} else {
BigInteger halfPower = getRadixPower(radix, (power - 1) >> 1);
result = halfPower.multiply(halfPower).multiply(radix);
}
radixPowerMap.put(key, result);
}
return result;
} | java | 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 = getRadixPower(radix, power >> 1);
result = halfPower.multiply(halfPower);
} else {
BigInteger halfPower = getRadixPower(radix, (power - 1) >> 1);
result = halfPower.multiply(halfPower).multiply(radix);
}
radixPowerMap.put(key, result);
}
return result;
} | [
"protected",
"static",
"BigInteger",
"getRadixPower",
"(",
"BigInteger",
"radix",
",",
"int",
"power",
")",
"{",
"long",
"key",
"=",
"(",
"(",
"(",
"long",
")",
"radix",
".",
"intValue",
"(",
")",
")",
"<<",
"32",
")",
"|",
"power",
";",
"BigInteger",
... | Caches the results of radix to the given power.
@param radix
@param power
@return | [
"Caches",
"the",
"results",
"of",
"radix",
"to",
"the",
"given",
"power",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionBase.java#L351-L367 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionGroupingBase.java | AddressDivisionGroupingBase.getBytesInternal | protected byte[] getBytesInternal() {
byte cached[];
if(hasNoValueCache() || (cached = valueCache.lowerBytes) == null) {
valueCache.lowerBytes = cached = getBytesImpl(true);
}
return cached;
} | java | protected byte[] getBytesInternal() {
byte cached[];
if(hasNoValueCache() || (cached = valueCache.lowerBytes) == null) {
valueCache.lowerBytes = cached = getBytesImpl(true);
}
return cached;
} | [
"protected",
"byte",
"[",
"]",
"getBytesInternal",
"(",
")",
"{",
"byte",
"cached",
"[",
"]",
";",
"if",
"(",
"hasNoValueCache",
"(",
")",
"||",
"(",
"cached",
"=",
"valueCache",
".",
"lowerBytes",
")",
"==",
"null",
")",
"{",
"valueCache",
".",
"lower... | gets the bytes, sharing the cached array and does not clone it | [
"gets",
"the",
"bytes",
"sharing",
"the",
"cached",
"array",
"and",
"does",
"not",
"clone",
"it"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionGroupingBase.java#L136-L142 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionGroupingBase.java | AddressDivisionGroupingBase.getUpperBytesInternal | 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) == null) {
if(!isMultiple()) {
if((cached = cache.lowerBytes) != null) {
cache.upperBytes = cached;
} else {
cache.lowerBytes = cache.upperBytes = cached = getBytesImpl(false);
}
} else {
cache.upperBytes = cached = getBytesImpl(false);
}
}
}
return cached;
} | java | 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) == null) {
if(!isMultiple()) {
if((cached = cache.lowerBytes) != null) {
cache.upperBytes = cached;
} else {
cache.lowerBytes = cache.upperBytes = cached = getBytesImpl(false);
}
} else {
cache.upperBytes = cached = getBytesImpl(false);
}
}
}
return cached;
} | [
"protected",
"byte",
"[",
"]",
"getUpperBytesInternal",
"(",
")",
"{",
"byte",
"cached",
"[",
"]",
";",
"if",
"(",
"hasNoValueCache",
"(",
")",
")",
"{",
"ValueCache",
"cache",
"=",
"valueCache",
";",
"cache",
".",
"upperBytes",
"=",
"cached",
"=",
"getB... | Gets the bytes for the highest address in the range represented by this address.
@return | [
"Gets",
"the",
"bytes",
"for",
"the",
"highest",
"address",
"in",
"the",
"range",
"represented",
"by",
"this",
"address",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionGroupingBase.java#L203-L226 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionGroupingBase.java | AddressDivisionGroupingBase.getMinPrefixLengthForBlock | @Override
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 == segBitCount) {
break;
} else {
totalPrefix -= segBitCount;
if(segPrefix != 0) {
totalPrefix += segPrefix;
break;
}
}
}
return totalPrefix;
} | java | @Override
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 == segBitCount) {
break;
} else {
totalPrefix -= segBitCount;
if(segPrefix != 0) {
totalPrefix += segPrefix;
break;
}
}
}
return totalPrefix;
} | [
"@",
"Override",
"public",
"int",
"getMinPrefixLengthForBlock",
"(",
")",
"{",
"int",
"count",
"=",
"getDivisionCount",
"(",
")",
";",
"int",
"totalPrefix",
"=",
"getBitCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"count",
"-",
"1",
";",
"i",
">... | Returns the smallest prefix length possible such that this address division grouping includes the block of addresses for that prefix.
@return the prefix length | [
"Returns",
"the",
"smallest",
"prefix",
"length",
"possible",
"such",
"that",
"this",
"address",
"division",
"grouping",
"includes",
"the",
"block",
"of",
"addresses",
"for",
"that",
"prefix",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionGroupingBase.java#L347-L366 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionGroupingBase.java | AddressDivisionGroupingBase.getPrefixLengthForSingleBlock | @Override
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 += divPrefix;
if(divPrefix < div.getBitCount()) {
//remaining segments must be full range or we return null
for(i++; i < count; i++) {
AddressDivisionBase laterDiv = getDivision(i);
if(!laterDiv.isFullRange()) {
return null;
}
}
}
}
return cacheBits(totalPrefix);
} | java | @Override
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 += divPrefix;
if(divPrefix < div.getBitCount()) {
//remaining segments must be full range or we return null
for(i++; i < count; i++) {
AddressDivisionBase laterDiv = getDivision(i);
if(!laterDiv.isFullRange()) {
return null;
}
}
}
}
return cacheBits(totalPrefix);
} | [
"@",
"Override",
"public",
"Integer",
"getPrefixLengthForSingleBlock",
"(",
")",
"{",
"int",
"count",
"=",
"getDivisionCount",
"(",
")",
";",
"int",
"totalPrefix",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",... | Returns a prefix length for which the range of this segment grouping matches the the block of addresses for that prefix.
If no such prefix exists, returns null
If this segment grouping represents a single value, returns the bit length
@return the prefix length or null | [
"Returns",
"a",
"prefix",
"length",
"for",
"which",
"the",
"range",
"of",
"this",
"segment",
"grouping",
"matches",
"the",
"the",
"block",
"of",
"addresses",
"for",
"that",
"prefix",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionGroupingBase.java#L377-L399 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionGroupingBase.java | AddressDivisionGroupingBase.getCount | @Override
public BigInteger getCount() {
BigInteger cached = cachedCount;
if(cached == null) {
cachedCount = cached = getCountImpl();
}
return cached;
} | java | @Override
public BigInteger getCount() {
BigInteger cached = cachedCount;
if(cached == null) {
cachedCount = cached = getCountImpl();
}
return cached;
} | [
"@",
"Override",
"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
If this address division grouping is not a subnet block of multiple addresses or has no range of values, then there is only one such address.
@return | [
"gets",
"the",
"count",
"of",
"addresses",
"that",
"this",
"address",
"division",
"grouping",
"may",
"represent"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/AddressDivisionGroupingBase.java#L442-L449 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/validate/Validator.java | Validator.validateZone | 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;
} | java | 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;
} | [
"public",
"static",
"int",
"validateZone",
"(",
"CharSequence",
"zone",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"zone",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"zone",
".",
"charAt",
"(",
"i",
")"... | Returns the index of the first invalid character of the zone, or -1 if the zone is valid
@param sequence
@return | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"invalid",
"character",
"of",
"the",
"zone",
"or",
"-",
"1",
"if",
"the",
"zone",
"is",
"valid"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/validate/Validator.java#L1988-L1999 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/validate/Validator.java | Validator.switchValue8 | 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;
} | java | 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;
} | [
"private",
"static",
"long",
"switchValue8",
"(",
"long",
"currentHexValue",
",",
"int",
"digitCount",
")",
"{",
"long",
"result",
"=",
"0x7",
"&",
"currentHexValue",
";",
"int",
"shift",
"=",
"0",
";",
"while",
"(",
"--",
"digitCount",
">",
"0",
")",
"{... | The digits were stored as a hex value, thix switches them to an octal value.
@param currentHexValue
@param digitCount
@return | [
"The",
"digits",
"were",
"stored",
"as",
"a",
"hex",
"value",
"thix",
"switches",
"them",
"to",
"an",
"octal",
"value",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/validate/Validator.java#L2312-L2321 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/validate/Validator.java | Validator.validateHostImpl | static ParsedHost validateHostImpl(HostName fromHost) throws HostNameException {
final String str = fromHost.toString();
HostNameParameters validationOptions = fromHost.getValidationOptions();
return validateHost(fromHost, str, validationOptions);
} | java | static ParsedHost validateHostImpl(HostName fromHost) throws HostNameException {
final String str = fromHost.toString();
HostNameParameters validationOptions = fromHost.getValidationOptions();
return validateHost(fromHost, str, validationOptions);
} | [
"static",
"ParsedHost",
"validateHostImpl",
"(",
"HostName",
"fromHost",
")",
"throws",
"HostNameException",
"{",
"final",
"String",
"str",
"=",
"fromHost",
".",
"toString",
"(",
")",
";",
"HostNameParameters",
"validationOptions",
"=",
"fromHost",
".",
"getValidati... | So we will follow rfc 1035 and in addition allow the underscore. | [
"So",
"we",
"will",
"follow",
"rfc",
"1035",
"and",
"in",
"addition",
"allow",
"the",
"underscore",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/validate/Validator.java#L2426-L2430 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/validate/Validator.java | Validator.convertReverseDNSIPv4 | 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(c1 == IPv4Address.SEGMENT_SEPARATOR) {
if(j - i <= 1) {
throw new AddressStringException(str, i);
}
for(int k = i + 1; k < j; k++) {
builder.append(str.charAt(k));
}
builder.append(c1);
j = i;
segCount++;
}
}
for(int k = 0; k < j; k++) {
builder.append(str.charAt(k));
}
if(segCount + 1 != IPv4Address.SEGMENT_COUNT) {
throw new AddressStringException(str, 0);
}
return builder;
} | java | 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(c1 == IPv4Address.SEGMENT_SEPARATOR) {
if(j - i <= 1) {
throw new AddressStringException(str, i);
}
for(int k = i + 1; k < j; k++) {
builder.append(str.charAt(k));
}
builder.append(c1);
j = i;
segCount++;
}
}
for(int k = 0; k < j; k++) {
builder.append(str.charAt(k));
}
if(segCount + 1 != IPv4Address.SEGMENT_COUNT) {
throw new AddressStringException(str, 0);
}
return builder;
} | [
"private",
"static",
"CharSequence",
"convertReverseDNSIPv4",
"(",
"String",
"str",
",",
"int",
"suffixStartIndex",
")",
"throws",
"AddressStringException",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"suffixStartIndex",
")",
";",
"int",
"segCou... | 123.2.3.4 is 4.3.2.123.in-addr.arpa. | [
"123",
".",
"2",
".",
"3",
".",
"4",
"is",
"4",
".",
"3",
".",
"2",
".",
"123",
".",
"in",
"-",
"addr",
".",
"arpa",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/validate/Validator.java#L3062-L3087 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivision.java | AddressDivision.isPrefixBlock | 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() - divisionPrefixLen);
long divisionNonPrefixMask = ~divisionPrefixMask;
return testRange(divisionValue,
upperValue,
upperValue,
divisionPrefixMask & divisionBitMask,
divisionNonPrefixMask);
} | java | 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() - divisionPrefixLen);
long divisionNonPrefixMask = ~divisionPrefixMask;
return testRange(divisionValue,
upperValue,
upperValue,
divisionPrefixMask & divisionBitMask,
divisionNonPrefixMask);
} | [
"protected",
"boolean",
"isPrefixBlock",
"(",
"long",
"divisionValue",
",",
"long",
"upperValue",
",",
"int",
"divisionPrefixLen",
")",
"{",
"if",
"(",
"divisionPrefixLen",
"==",
"0",
")",
"{",
"return",
"divisionValue",
"==",
"0",
"&&",
"upperValue",
"==",
"g... | Returns whether the division range includes the block of values for its prefix length | [
"Returns",
"whether",
"the",
"division",
"range",
"includes",
"the",
"block",
"of",
"values",
"for",
"its",
"prefix",
"length"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivision.java#L196-L209 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivision.java | AddressDivision.matchesWithMask | public boolean matchesWithMask(long lowerValue, long upperValue, long mask) {
if(lowerValue == upperValue) {
return matchesWithMask(lowerValue, mask);
}
if(!isMultiple()) {
//we know lowerValue and upperValue are not the same, so impossible to match those two values with a single value
return false;
}
long thisValue = getDivisionValue();
long thisUpperValue = getUpperDivisionValue();
if(!isMaskCompatibleWithRange(thisValue, thisUpperValue, mask, getMaxValue())) {
return false;
}
return lowerValue == (thisValue & mask) && upperValue == (thisUpperValue & mask);
} | java | public boolean matchesWithMask(long lowerValue, long upperValue, long mask) {
if(lowerValue == upperValue) {
return matchesWithMask(lowerValue, mask);
}
if(!isMultiple()) {
//we know lowerValue and upperValue are not the same, so impossible to match those two values with a single value
return false;
}
long thisValue = getDivisionValue();
long thisUpperValue = getUpperDivisionValue();
if(!isMaskCompatibleWithRange(thisValue, thisUpperValue, mask, getMaxValue())) {
return false;
}
return lowerValue == (thisValue & mask) && upperValue == (thisUpperValue & mask);
} | [
"public",
"boolean",
"matchesWithMask",
"(",
"long",
"lowerValue",
",",
"long",
"upperValue",
",",
"long",
"mask",
")",
"{",
"if",
"(",
"lowerValue",
"==",
"upperValue",
")",
"{",
"return",
"matchesWithMask",
"(",
"lowerValue",
",",
"mask",
")",
";",
"}",
... | 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.
@param lowerValue
@param upperValue
@param mask
@return | [
"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",
... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivision.java#L266-L280 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivision.java | AddressDivision.isMaskCompatibleWithRange | protected static boolean isMaskCompatibleWithRange(long value, long upperValue, long maskValue, long maxValue) {
if(value == upperValue || maskValue == maxValue || maskValue == 0) {
return true;
}
//algorithm:
//here we find the highest bit that is part of the range, highestDifferingBitInRange (ie changes from lower to upper)
//then we find the highest bit in the mask that is 1 that is the same or below highestDifferingBitInRange (if such a bit exists)
//this gives us the highest bit that is part of the masked range (ie changes from lower to upper after applying the mask)
//if this latter bit exists, then any bit below it in the mask must be 1 to include the entire range.
long differing = value ^ upperValue;
boolean foundDiffering = (differing != 0);
boolean differingIsLowestBit = (differing == 1);
if(foundDiffering && !differingIsLowestBit) {
int highestDifferingBitInRange = Long.numberOfLeadingZeros(differing);
long maskMask = ~0L >>> highestDifferingBitInRange;
long differingMasked = maskValue & maskMask;
foundDiffering = (differingMasked != 0);
differingIsLowestBit = (differingMasked == 1);
if(foundDiffering && !differingIsLowestBit) {
//anything below highestDifferingBitMasked in the mask must be ones
//Also, if we have masked out any 1 bit in the original, then anything that we do not mask out that follows must be all 1s
int highestDifferingBitMasked = Long.numberOfLeadingZeros(differingMasked);
long hostMask = ~0L >>> (highestDifferingBitMasked + 1);//for the first mask bit that is 1, all bits that follow must also be 1
if((maskValue & hostMask) != hostMask) { //check if all ones below
return false;
}
if(highestDifferingBitMasked > highestDifferingBitInRange) {
//We have masked out a 1 bit, so we need to check that all bits in upper value that we do not mask out are also 1 bits, otherwise we end up missing values in the masked range
//This check is unnecessary for prefix-length subnets, only non-standard ranges might fail this check.
//For instance, if we have range 0000 to 1010
//and we mask upper and lower with 0111
//we get 0000 to 0010, but 0111 was in original range, and the mask of that value retains that value
//so that value needs to be in final range, and it's not.
//What went wrong is that we masked out the top bit, and any other bit that is not masked out must be 1.
//To work, our original range needed to be 0000 to 1111, with the three 1s following the first masked-out 1
long hostMaskUpper = ~0L >>> highestDifferingBitMasked;
if((upperValue & hostMaskUpper) != hostMaskUpper) {
return false;
}
}
}
}
return true;
} | java | protected static boolean isMaskCompatibleWithRange(long value, long upperValue, long maskValue, long maxValue) {
if(value == upperValue || maskValue == maxValue || maskValue == 0) {
return true;
}
//algorithm:
//here we find the highest bit that is part of the range, highestDifferingBitInRange (ie changes from lower to upper)
//then we find the highest bit in the mask that is 1 that is the same or below highestDifferingBitInRange (if such a bit exists)
//this gives us the highest bit that is part of the masked range (ie changes from lower to upper after applying the mask)
//if this latter bit exists, then any bit below it in the mask must be 1 to include the entire range.
long differing = value ^ upperValue;
boolean foundDiffering = (differing != 0);
boolean differingIsLowestBit = (differing == 1);
if(foundDiffering && !differingIsLowestBit) {
int highestDifferingBitInRange = Long.numberOfLeadingZeros(differing);
long maskMask = ~0L >>> highestDifferingBitInRange;
long differingMasked = maskValue & maskMask;
foundDiffering = (differingMasked != 0);
differingIsLowestBit = (differingMasked == 1);
if(foundDiffering && !differingIsLowestBit) {
//anything below highestDifferingBitMasked in the mask must be ones
//Also, if we have masked out any 1 bit in the original, then anything that we do not mask out that follows must be all 1s
int highestDifferingBitMasked = Long.numberOfLeadingZeros(differingMasked);
long hostMask = ~0L >>> (highestDifferingBitMasked + 1);//for the first mask bit that is 1, all bits that follow must also be 1
if((maskValue & hostMask) != hostMask) { //check if all ones below
return false;
}
if(highestDifferingBitMasked > highestDifferingBitInRange) {
//We have masked out a 1 bit, so we need to check that all bits in upper value that we do not mask out are also 1 bits, otherwise we end up missing values in the masked range
//This check is unnecessary for prefix-length subnets, only non-standard ranges might fail this check.
//For instance, if we have range 0000 to 1010
//and we mask upper and lower with 0111
//we get 0000 to 0010, but 0111 was in original range, and the mask of that value retains that value
//so that value needs to be in final range, and it's not.
//What went wrong is that we masked out the top bit, and any other bit that is not masked out must be 1.
//To work, our original range needed to be 0000 to 1111, with the three 1s following the first masked-out 1
long hostMaskUpper = ~0L >>> highestDifferingBitMasked;
if((upperValue & hostMaskUpper) != hostMaskUpper) {
return false;
}
}
}
}
return true;
} | [
"protected",
"static",
"boolean",
"isMaskCompatibleWithRange",
"(",
"long",
"value",
",",
"long",
"upperValue",
",",
"long",
"maskValue",
",",
"long",
"maxValue",
")",
"{",
"if",
"(",
"value",
"==",
"upperValue",
"||",
"maskValue",
"==",
"maxValue",
"||",
"mas... | when divisionPrefixLen is null, isAutoSubnets has no effect | [
"when",
"divisionPrefixLen",
"is",
"null",
"isAutoSubnets",
"has",
"no",
"effect"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/AddressDivision.java#L309-L355 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java | IPv6AddressSection.isEUI64 | 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(index3 + 1);
return seg4.matchesWithMask(0xfe00, 0xff00) && seg3.matchesWithMask(0xff, 0xff);
} else if(partial && endIndex == 6) {
IPv6AddressSegment seg3 = getSegment(5 - addressSegmentIndex);
return seg3.matchesWithMask(0xff, 0xff);
}
} else if(partial && addressSegmentIndex == 6 && endIndex > 6) {
IPv6AddressSegment seg4 = getSegment(6 - addressSegmentIndex);
return seg4.matchesWithMask(0xfe00, 0xff00);
}
return partial;
} | java | 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(index3 + 1);
return seg4.matchesWithMask(0xfe00, 0xff00) && seg3.matchesWithMask(0xff, 0xff);
} else if(partial && endIndex == 6) {
IPv6AddressSegment seg3 = getSegment(5 - addressSegmentIndex);
return seg3.matchesWithMask(0xff, 0xff);
}
} else if(partial && addressSegmentIndex == 6 && endIndex > 6) {
IPv6AddressSegment seg4 = getSegment(6 - addressSegmentIndex);
return seg4.matchesWithMask(0xfe00, 0xff00);
}
return partial;
} | [
"public",
"boolean",
"isEUI64",
"(",
"boolean",
"partial",
")",
"{",
"int",
"segmentCount",
"=",
"getSegmentCount",
"(",
")",
";",
"int",
"endIndex",
"=",
"addressSegmentIndex",
"+",
"segmentCount",
";",
"if",
"(",
"addressSegmentIndex",
"<=",
"5",
")",
"{",
... | 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
@param partial whether missing segments are considered a match
@return | [
"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",
"0... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java#L1133-L1151 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java | IPv6AddressSection.toEUI | 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, extended);
} | java | 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, extended);
} | [
"public",
"MACAddressSection",
"toEUI",
"(",
"boolean",
"extended",
")",
"{",
"MACAddressSegment",
"[",
"]",
"segs",
"=",
"toEUISegments",
"(",
"extended",
")",
";",
"if",
"(",
"segs",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"MACAddressCreator",
... | 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.
@param extended
@return | [
"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",
... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java#L1160-L1167 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java | IPv6AddressSection.toEUISegments | 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 originalSegmentIndex = segmentIndex;
seg0 = (start == 0 && segmentIndex < segmentCount) ? getSegment(segmentIndex++) : null;
seg1 = (start <= 1 && segmentIndex < segmentCount) ? getSegment(segmentIndex++) : null;
seg2 = (start <= 2 && segmentIndex < segmentCount) ? getSegment(segmentIndex++) : null;
seg3 = (start <= 3 && segmentIndex < segmentCount) ? getSegment(segmentIndex++) : null;
int macSegCount = (segmentIndex - originalSegmentIndex) << 1;
if(!extended) {
macSegCount -= 2;
}
if((seg1 != null && !seg1.matchesWithMask(0xff, 0xff)) || (seg2 != null && !seg2.matchesWithMask(0xfe00, 0xff00)) || macSegCount == 0) {
return null;
}
MACAddressCreator creator = getMACNetwork().getAddressCreator();
MACAddressSegment ZERO_SEGMENT = creator.createSegment(0);
MACAddressSegment newSegs[] = creator.createSegmentArray(macSegCount);
int macStartIndex = 0;
if(seg0 != null) {
seg0.getSplitSegments(newSegs, macStartIndex, creator);
//toggle the u/l bit
MACAddressSegment macSegment0 = newSegs[0];
int lower0 = macSegment0.getSegmentValue();
int upper0 = macSegment0.getUpperSegmentValue();
int mask2ndBit = 0x2;
if(!macSegment0.matchesWithMask(mask2ndBit & lower0, mask2ndBit)) {
return null;
}
//you can use matches with mask
lower0 ^= mask2ndBit;//flip the universal/local bit
upper0 ^= mask2ndBit;
newSegs[0] = creator.createSegment(lower0, upper0, null);
macStartIndex += 2;
}
if(seg1 != null) {
seg1.getSplitSegments(newSegs, macStartIndex, creator); //a ff fe b
if(!extended) {
newSegs[macStartIndex + 1] = ZERO_SEGMENT;
}
macStartIndex += 2;
}
if(seg2 != null) {
if(!extended) {
if(seg1 != null) {
macStartIndex -= 2;
MACAddressSegment first = newSegs[macStartIndex];
seg2.getSplitSegments(newSegs, macStartIndex, creator);
newSegs[macStartIndex] = first;
} else {
seg2.getSplitSegments(newSegs, macStartIndex, creator);
newSegs[macStartIndex] = ZERO_SEGMENT;
}
} else {
seg2.getSplitSegments(newSegs, macStartIndex, creator);
}
macStartIndex += 2;
}
if(seg3 != null) {
seg3.getSplitSegments(newSegs, macStartIndex, creator);
}
return newSegs;
} | java | 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 originalSegmentIndex = segmentIndex;
seg0 = (start == 0 && segmentIndex < segmentCount) ? getSegment(segmentIndex++) : null;
seg1 = (start <= 1 && segmentIndex < segmentCount) ? getSegment(segmentIndex++) : null;
seg2 = (start <= 2 && segmentIndex < segmentCount) ? getSegment(segmentIndex++) : null;
seg3 = (start <= 3 && segmentIndex < segmentCount) ? getSegment(segmentIndex++) : null;
int macSegCount = (segmentIndex - originalSegmentIndex) << 1;
if(!extended) {
macSegCount -= 2;
}
if((seg1 != null && !seg1.matchesWithMask(0xff, 0xff)) || (seg2 != null && !seg2.matchesWithMask(0xfe00, 0xff00)) || macSegCount == 0) {
return null;
}
MACAddressCreator creator = getMACNetwork().getAddressCreator();
MACAddressSegment ZERO_SEGMENT = creator.createSegment(0);
MACAddressSegment newSegs[] = creator.createSegmentArray(macSegCount);
int macStartIndex = 0;
if(seg0 != null) {
seg0.getSplitSegments(newSegs, macStartIndex, creator);
//toggle the u/l bit
MACAddressSegment macSegment0 = newSegs[0];
int lower0 = macSegment0.getSegmentValue();
int upper0 = macSegment0.getUpperSegmentValue();
int mask2ndBit = 0x2;
if(!macSegment0.matchesWithMask(mask2ndBit & lower0, mask2ndBit)) {
return null;
}
//you can use matches with mask
lower0 ^= mask2ndBit;//flip the universal/local bit
upper0 ^= mask2ndBit;
newSegs[0] = creator.createSegment(lower0, upper0, null);
macStartIndex += 2;
}
if(seg1 != null) {
seg1.getSplitSegments(newSegs, macStartIndex, creator); //a ff fe b
if(!extended) {
newSegs[macStartIndex + 1] = ZERO_SEGMENT;
}
macStartIndex += 2;
}
if(seg2 != null) {
if(!extended) {
if(seg1 != null) {
macStartIndex -= 2;
MACAddressSegment first = newSegs[macStartIndex];
seg2.getSplitSegments(newSegs, macStartIndex, creator);
newSegs[macStartIndex] = first;
} else {
seg2.getSplitSegments(newSegs, macStartIndex, creator);
newSegs[macStartIndex] = ZERO_SEGMENT;
}
} else {
seg2.getSplitSegments(newSegs, macStartIndex, creator);
}
macStartIndex += 2;
}
if(seg3 != null) {
seg3.getSplitSegments(newSegs, macStartIndex, creator);
}
return newSegs;
} | [
"MACAddressSegment",
"[",
"]",
"toEUISegments",
"(",
"boolean",
"extended",
")",
"{",
"IPv6AddressSegment",
"seg0",
",",
"seg1",
",",
"seg2",
",",
"seg3",
";",
"int",
"start",
"=",
"addressSegmentIndex",
";",
"int",
"segmentCount",
"=",
"getSegmentCount",
"(",
... | prefix length in this section is ignored when converting to MAC | [
"prefix",
"length",
"in",
"this",
"section",
"is",
"ignored",
"when",
"converting",
"to",
"MAC"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java#L1174-L1245 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java | IPv6AddressSection.getEmbeddedIPv4AddressSection | public IPv4AddressSection getEmbeddedIPv4AddressSection(int startIndex, int endIndex) {
if(startIndex == ((IPv6Address.MIXED_ORIGINAL_SEGMENT_COUNT - this.addressSegmentIndex) << 1) && endIndex == (getSegmentCount() << 1)) {
return getEmbeddedIPv4AddressSection();
}
IPv4AddressCreator creator = getIPv4Network().getAddressCreator();
IPv4AddressSegment[] segments = creator.createSegmentArray((endIndex - startIndex) >> 1);
int i = startIndex, j = 0;
if(i % IPv6Address.BYTES_PER_SEGMENT == 1) {
IPv6AddressSegment ipv6Segment = getSegment(i >> 1);
i++;
ipv6Segment.getSplitSegments(segments, j - 1, creator);
j++;
}
for(; i < endIndex; i <<= 1, j <<= 1) {
IPv6AddressSegment ipv6Segment = getSegment(i >> 1);
ipv6Segment.getSplitSegments(segments, j, creator);
}
return createEmbeddedSection(creator, segments, this);
} | java | public IPv4AddressSection getEmbeddedIPv4AddressSection(int startIndex, int endIndex) {
if(startIndex == ((IPv6Address.MIXED_ORIGINAL_SEGMENT_COUNT - this.addressSegmentIndex) << 1) && endIndex == (getSegmentCount() << 1)) {
return getEmbeddedIPv4AddressSection();
}
IPv4AddressCreator creator = getIPv4Network().getAddressCreator();
IPv4AddressSegment[] segments = creator.createSegmentArray((endIndex - startIndex) >> 1);
int i = startIndex, j = 0;
if(i % IPv6Address.BYTES_PER_SEGMENT == 1) {
IPv6AddressSegment ipv6Segment = getSegment(i >> 1);
i++;
ipv6Segment.getSplitSegments(segments, j - 1, creator);
j++;
}
for(; i < endIndex; i <<= 1, j <<= 1) {
IPv6AddressSegment ipv6Segment = getSegment(i >> 1);
ipv6Segment.getSplitSegments(segments, j, creator);
}
return createEmbeddedSection(creator, segments, this);
} | [
"public",
"IPv4AddressSection",
"getEmbeddedIPv4AddressSection",
"(",
"int",
"startIndex",
",",
"int",
"endIndex",
")",
"{",
"if",
"(",
"startIndex",
"==",
"(",
"(",
"IPv6Address",
".",
"MIXED_ORIGINAL_SEGMENT_COUNT",
"-",
"this",
".",
"addressSegmentIndex",
")",
"<... | Produces an IPv4 address section from any sequence of bytes in this IPv6 address section
@param startIndex the byte index in this section to start from
@param endIndex the byte index in this section to end at
@throws IndexOutOfBoundsException
@return
@see #getEmbeddedIPv4AddressSection()
@see #getMixedAddressSection() | [
"Produces",
"an",
"IPv4",
"address",
"section",
"from",
"any",
"sequence",
"of",
"bytes",
"in",
"this",
"IPv6",
"address",
"section"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java#L1258-L1276 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java | IPv6AddressSection.hasUppercaseVariations | 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;
} | java | 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;
} | [
"public",
"boolean",
"hasUppercaseVariations",
"(",
"int",
"base",
",",
"boolean",
"lowerOnly",
")",
"{",
"if",
"(",
"base",
">",
"10",
")",
"{",
"int",
"count",
"=",
"getSegmentCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
... | Returns whether this subnet or address has alphabetic digits when printed.
Note that this method does not indicate whether any address contained within this subnet has alphabetic digits,
only whether the subnet itself when printed has alphabetic digits.
@return whether the section has alphabetic digits when printed. | [
"Returns",
"whether",
"this",
"subnet",
"or",
"address",
"has",
"alphabetic",
"digits",
"when",
"printed",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java#L1410-L1421 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java | IPv6AddressSection.mergeToSequentialBlocks | public IPv6AddressSection[] mergeToSequentialBlocks(IPv6AddressSection ...sections) throws SizeMismatchException {
List<IPAddressSegmentSeries> blocks = getMergedSequentialBlocks(this, sections, true, createSeriesCreator(getAddressCreator(), getMaxSegmentValue()));
return blocks.toArray(new IPv6AddressSection[blocks.size()]);
} | java | public IPv6AddressSection[] mergeToSequentialBlocks(IPv6AddressSection ...sections) throws SizeMismatchException {
List<IPAddressSegmentSeries> blocks = getMergedSequentialBlocks(this, sections, true, createSeriesCreator(getAddressCreator(), getMaxSegmentValue()));
return blocks.toArray(new IPv6AddressSection[blocks.size()]);
} | [
"public",
"IPv6AddressSection",
"[",
"]",
"mergeToSequentialBlocks",
"(",
"IPv6AddressSection",
"...",
"sections",
")",
"throws",
"SizeMismatchException",
"{",
"List",
"<",
"IPAddressSegmentSeries",
">",
"blocks",
"=",
"getMergedSequentialBlocks",
"(",
"this",
",",
"sec... | Merges this with the list of sections to produce the smallest array of sequential block subnets, going from smallest to largest
@param sections the sections to merge with this
@return | [
"Merges",
"this",
"with",
"the",
"list",
"of",
"sections",
"to",
"produce",
"the",
"smallest",
"array",
"of",
"sequential",
"block",
"subnets",
"going",
"from",
"smallest",
"to",
"largest"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java#L2067-L2070 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java | IPv6AddressSection.toCanonicalString | @Override
public String toCanonicalString() {
String result;
if(hasNoStringCache() || (result = stringCache.canonicalString) == null) {
stringCache.canonicalString = result = toNormalizedString(IPv6StringCache.canonicalParams);
}
return result;
} | java | @Override
public String toCanonicalString() {
String result;
if(hasNoStringCache() || (result = stringCache.canonicalString) == null) {
stringCache.canonicalString = result = toNormalizedString(IPv6StringCache.canonicalParams);
}
return result;
} | [
"@",
"Override",
"public",
"String",
"toCanonicalString",
"(",
")",
"{",
"String",
"result",
";",
"if",
"(",
"hasNoStringCache",
"(",
")",
"||",
"(",
"result",
"=",
"stringCache",
".",
"canonicalString",
")",
"==",
"null",
")",
"{",
"stringCache",
".",
"ca... | This produces a canonical string.
RFC 5952 describes canonical representations.
http://en.wikipedia.org/wiki/IPv6_address#Recommended_representation_as_text
http://tools.ietf.org/html/rfc5952 | [
"This",
"produces",
"a",
"canonical",
"string",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java#L2111-L2118 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java | IPv6AddressSection.toFullString | @Override
public String toFullString() {
String result;
if(hasNoStringCache() || (result = getStringCache().fullString) == null) {
getStringCache().fullString = result = toNormalizedString(IPv6StringCache.fullParams);
}
return result;
} | java | @Override
public String toFullString() {
String result;
if(hasNoStringCache() || (result = getStringCache().fullString) == null) {
getStringCache().fullString = result = toNormalizedString(IPv6StringCache.fullParams);
}
return result;
} | [
"@",
"Override",
"public",
"String",
"toFullString",
"(",
")",
"{",
"String",
"result",
";",
"if",
"(",
"hasNoStringCache",
"(",
")",
"||",
"(",
"result",
"=",
"getStringCache",
"(",
")",
".",
"fullString",
")",
"==",
"null",
")",
"{",
"getStringCache",
... | 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. | [
"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",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java#L2135-L2142 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java | IPv6AddressSection.toNormalizedString | @Override
public String toNormalizedString() {
String result;
if(hasNoStringCache() || (result = getStringCache().normalizedString) == null) {
getStringCache().normalizedString = result = toNormalizedString(IPv6StringCache.normalizedParams);
}
return result;
} | java | @Override
public String toNormalizedString() {
String result;
if(hasNoStringCache() || (result = getStringCache().normalizedString) == null) {
getStringCache().normalizedString = result = toNormalizedString(IPv6StringCache.normalizedParams);
}
return result;
} | [
"@",
"Override",
"public",
"String",
"toNormalizedString",
"(",
")",
"{",
"String",
"result",
";",
"if",
"(",
"hasNoStringCache",
"(",
")",
"||",
"(",
"result",
"=",
"getStringCache",
"(",
")",
".",
"normalizedString",
")",
"==",
"null",
")",
"{",
"getStri... | The normalized string returned by this method is consistent with java.net.Inet6address.
IPs are not compressed nor mixed in this representation. | [
"The",
"normalized",
"string",
"returned",
"by",
"this",
"method",
"is",
"consistent",
"with",
"java",
".",
"net",
".",
"Inet6address",
".",
"IPs",
"are",
"not",
"compressed",
"nor",
"mixed",
"in",
"this",
"representation",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java#L2198-L2205 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java | IPv6AddressSection.getCompressIndexAndCount | private int[] getCompressIndexAndCount(CompressOptions options, boolean createMixed) {
if(options != null) {
CompressionChoiceOptions rangeSelection = options.rangeSelection;
RangeList compressibleSegs = rangeSelection.compressHost() ? getZeroRangeSegments() : getZeroSegments();
int maxIndex = -1, maxCount = 0;
int segmentCount = getSegmentCount();
boolean compressMixed = createMixed && options.compressMixedOptions.compressMixed(this);
boolean preferHost = (rangeSelection == CompressOptions.CompressionChoiceOptions.HOST_PREFERRED);
boolean preferMixed = createMixed && (rangeSelection == CompressOptions.CompressionChoiceOptions.MIXED_PREFERRED);
for(int i = compressibleSegs.size() - 1; i >= 0 ; i--) {
Range range = compressibleSegs.getRange(i);
int index = range.index;
int count = range.length;
if(createMixed) {
//so here we shorten the range to exclude the mixed part if necessary
int mixedIndex = IPv6Address.MIXED_ORIGINAL_SEGMENT_COUNT - addressSegmentIndex;
if(!compressMixed ||
index > mixedIndex || index + count < segmentCount) { //range does not include entire mixed part. We never compress only part of a mixed part.
//the compressible range must stop at the mixed part
count = Math.min(count, mixedIndex - index);
}
}
//select this range if is the longest
if(count > 0 && count >= maxCount && (options.compressSingle || count > 1)) {
maxIndex = index;
maxCount = count;
}
if(preferHost && isPrefixed() &&
((index + count) * IPv6Address.BITS_PER_SEGMENT) > getNetworkPrefixLength()) { //this range contains the host
//Since we are going backwards, this means we select as the maximum any zero segment that includes the host
break;
}
if(preferMixed && index + count >= segmentCount) { //this range contains the mixed section
//Since we are going backwards, this means we select to compress the mixed segment
break;
}
}
if(maxIndex >= 0) {
return new int[] {maxIndex, maxCount};
}
}
return null;
} | java | private int[] getCompressIndexAndCount(CompressOptions options, boolean createMixed) {
if(options != null) {
CompressionChoiceOptions rangeSelection = options.rangeSelection;
RangeList compressibleSegs = rangeSelection.compressHost() ? getZeroRangeSegments() : getZeroSegments();
int maxIndex = -1, maxCount = 0;
int segmentCount = getSegmentCount();
boolean compressMixed = createMixed && options.compressMixedOptions.compressMixed(this);
boolean preferHost = (rangeSelection == CompressOptions.CompressionChoiceOptions.HOST_PREFERRED);
boolean preferMixed = createMixed && (rangeSelection == CompressOptions.CompressionChoiceOptions.MIXED_PREFERRED);
for(int i = compressibleSegs.size() - 1; i >= 0 ; i--) {
Range range = compressibleSegs.getRange(i);
int index = range.index;
int count = range.length;
if(createMixed) {
//so here we shorten the range to exclude the mixed part if necessary
int mixedIndex = IPv6Address.MIXED_ORIGINAL_SEGMENT_COUNT - addressSegmentIndex;
if(!compressMixed ||
index > mixedIndex || index + count < segmentCount) { //range does not include entire mixed part. We never compress only part of a mixed part.
//the compressible range must stop at the mixed part
count = Math.min(count, mixedIndex - index);
}
}
//select this range if is the longest
if(count > 0 && count >= maxCount && (options.compressSingle || count > 1)) {
maxIndex = index;
maxCount = count;
}
if(preferHost && isPrefixed() &&
((index + count) * IPv6Address.BITS_PER_SEGMENT) > getNetworkPrefixLength()) { //this range contains the host
//Since we are going backwards, this means we select as the maximum any zero segment that includes the host
break;
}
if(preferMixed && index + count >= segmentCount) { //this range contains the mixed section
//Since we are going backwards, this means we select to compress the mixed segment
break;
}
}
if(maxIndex >= 0) {
return new int[] {maxIndex, maxCount};
}
}
return null;
} | [
"private",
"int",
"[",
"]",
"getCompressIndexAndCount",
"(",
"CompressOptions",
"options",
",",
"boolean",
"createMixed",
")",
"{",
"if",
"(",
"options",
"!=",
"null",
")",
"{",
"CompressionChoiceOptions",
"rangeSelection",
"=",
"options",
".",
"rangeSelection",
"... | Chooses a single segment to be compressed, or null if no segment could be chosen.
@param options
@param createMixed
@return | [
"Chooses",
"a",
"single",
"segment",
"to",
"be",
"compressed",
"or",
"null",
"if",
"no",
"segment",
"could",
"be",
"chosen",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6AddressSection.java#L2731-L2774 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/validate/ParsedAddressGrouping.java | ParsedAddressGrouping.getHostSegmentIndex | 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;
} | java | 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;
} | [
"public",
"static",
"int",
"getHostSegmentIndex",
"(",
"int",
"networkPrefixLength",
",",
"int",
"bytesPerSegment",
",",
"int",
"bitsPerSegment",
")",
"{",
"if",
"(",
"bytesPerSegment",
">",
"1",
")",
"{",
"if",
"(",
"bytesPerSegment",
"==",
"2",
")",
"{",
"... | 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.
@param networkPrefixLength
@param byteLength
@return | [
"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",
... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/validate/ParsedAddressGrouping.java#L52-L60 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/MACAddressString.java | MACAddressString.validate | @Override
public void validate() throws AddressStringException {
if(isValidated()) {
return;
}
synchronized(this) {
if(isValidated()) {
return;
}
//we know nothing about this address. See what it is.
try {
parsedAddress = getValidator().validateAddress(this);
isValid = true;
} catch(AddressStringException e) {
cachedException = e;
isValid = false;
throw e;
}
}
} | java | @Override
public void validate() throws AddressStringException {
if(isValidated()) {
return;
}
synchronized(this) {
if(isValidated()) {
return;
}
//we know nothing about this address. See what it is.
try {
parsedAddress = getValidator().validateAddress(this);
isValid = true;
} catch(AddressStringException e) {
cachedException = e;
isValid = false;
throw e;
}
}
} | [
"@",
"Override",
"public",
"void",
"validate",
"(",
")",
"throws",
"AddressStringException",
"{",
"if",
"(",
"isValidated",
"(",
")",
")",
"{",
"return",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"isValidated",
"(",
")",
")",
"{",
"re... | Validates this string is a valid address, and if not, throws an exception with a descriptive message indicating why it is not.
@throws AddressStringException | [
"Validates",
"this",
"string",
"is",
"a",
"valid",
"address",
"and",
"if",
"not",
"throws",
"an",
"exception",
"with",
"a",
"descriptive",
"message",
"indicating",
"why",
"it",
"is",
"not",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/MACAddressString.java#L243-L262 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java | IPAddressSegment.isChangedByMask | protected boolean isChangedByMask(int maskValue, Integer segmentPrefixLength) throws IncompatibleAddressException {
boolean hasBits = (segmentPrefixLength != null);
if(hasBits && (segmentPrefixLength < 0 || segmentPrefixLength > getBitCount())) {
throw new PrefixLenException(this, segmentPrefixLength);
}
//note that the mask can represent a range (for example a CIDR mask),
//but we use the lowest value (maskSegment.value) in the range when masking (ie we discard the range)
int value = getSegmentValue();
int upperValue = getUpperSegmentValue();
return value != (value & maskValue) ||
upperValue != (upperValue & maskValue) ||
(isPrefixed() ? !getSegmentPrefixLength().equals(segmentPrefixLength) : hasBits);
} | java | protected boolean isChangedByMask(int maskValue, Integer segmentPrefixLength) throws IncompatibleAddressException {
boolean hasBits = (segmentPrefixLength != null);
if(hasBits && (segmentPrefixLength < 0 || segmentPrefixLength > getBitCount())) {
throw new PrefixLenException(this, segmentPrefixLength);
}
//note that the mask can represent a range (for example a CIDR mask),
//but we use the lowest value (maskSegment.value) in the range when masking (ie we discard the range)
int value = getSegmentValue();
int upperValue = getUpperSegmentValue();
return value != (value & maskValue) ||
upperValue != (upperValue & maskValue) ||
(isPrefixed() ? !getSegmentPrefixLength().equals(segmentPrefixLength) : hasBits);
} | [
"protected",
"boolean",
"isChangedByMask",
"(",
"int",
"maskValue",
",",
"Integer",
"segmentPrefixLength",
")",
"throws",
"IncompatibleAddressException",
"{",
"boolean",
"hasBits",
"=",
"(",
"segmentPrefixLength",
"!=",
"null",
")",
";",
"if",
"(",
"hasBits",
"&&",
... | returns a new segment masked by the given mask
This method applies the mask first to every address in the range, and it does not preserve any existing prefix.
The given prefix will be applied to the range of addresses after the mask.
If the combination of the two does not result in a contiguous range, then {@link IncompatibleAddressException} is thrown. | [
"returns",
"a",
"new",
"segment",
"masked",
"by",
"the",
"given",
"mask"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java#L273-L286 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java | IPAddressSegment.isMaskCompatibleWithRange | public boolean isMaskCompatibleWithRange(int maskValue, Integer segmentPrefixLength) throws PrefixLenException {
if(!isMultiple()) {
return true;
}
return super.isMaskCompatibleWithRange(maskValue, segmentPrefixLength, getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets());
} | java | public boolean isMaskCompatibleWithRange(int maskValue, Integer segmentPrefixLength) throws PrefixLenException {
if(!isMultiple()) {
return true;
}
return super.isMaskCompatibleWithRange(maskValue, segmentPrefixLength, getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets());
} | [
"public",
"boolean",
"isMaskCompatibleWithRange",
"(",
"int",
"maskValue",
",",
"Integer",
"segmentPrefixLength",
")",
"throws",
"PrefixLenException",
"{",
"if",
"(",
"!",
"isMultiple",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"super",
".",
"i... | Check that the range resulting from the mask is contiguous, otherwise we cannot represent it.
For instance, for the range 0 to 3 (bits are 00 to 11), if we mask all 4 numbers from 0 to 3 with 2 (ie bits are 10),
then we are left with 1 and 3. 2 is not included. So we cannot represent 1 and 3 as a contiguous range.
The underlying rule is that mask bits that are 0 must be above the resulting range in each segment.
Any bit in the mask that is 0 must not fall below any bit in the masked segment range that is different between low and high.
Any network mask must eliminate the entire segment range. Any host mask is fine.
@param maskValue
@param segmentPrefixLength
@return
@throws PrefixLenException | [
"Check",
"that",
"the",
"range",
"resulting",
"from",
"the",
"mask",
"is",
"contiguous",
"otherwise",
"we",
"cannot",
"represent",
"it",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java#L320-L325 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java | IPAddressSegment.isBitwiseOrCompatibleWithRange | public boolean isBitwiseOrCompatibleWithRange(int maskValue, Integer segmentPrefixLength) throws PrefixLenException {
return super.isBitwiseOrCompatibleWithRange(maskValue, segmentPrefixLength, getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets());
} | java | public boolean isBitwiseOrCompatibleWithRange(int maskValue, Integer segmentPrefixLength) throws PrefixLenException {
return super.isBitwiseOrCompatibleWithRange(maskValue, segmentPrefixLength, getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets());
} | [
"public",
"boolean",
"isBitwiseOrCompatibleWithRange",
"(",
"int",
"maskValue",
",",
"Integer",
"segmentPrefixLength",
")",
"throws",
"PrefixLenException",
"{",
"return",
"super",
".",
"isBitwiseOrCompatibleWithRange",
"(",
"maskValue",
",",
"segmentPrefixLength",
",",
"g... | Similar to masking, checks that the range resulting from the bitwise or is contiguous.
@param maskValue
@param segmentPrefixLength
@return
@throws PrefixLenException | [
"Similar",
"to",
"masking",
"checks",
"that",
"the",
"range",
"resulting",
"from",
"the",
"bitwise",
"or",
"is",
"contiguous",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSegment.java#L335-L337 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4AddressSegment.java | IPv4AddressSegment.join | 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 the high segment has a range, the low segment must match the full range,
//otherwise it is not possible to create an equivalent range when joining
if(!low.isFullRange()) {
throw new IncompatibleAddressException(this, low, "ipaddress.error.invalidMixedRange");
}
}
return creator.createSegment(
(getSegmentValue() << shift) | low.getSegmentValue(),
(getUpperSegmentValue() << shift) | low.getUpperSegmentValue(),
prefix);
} | java | 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 the high segment has a range, the low segment must match the full range,
//otherwise it is not possible to create an equivalent range when joining
if(!low.isFullRange()) {
throw new IncompatibleAddressException(this, low, "ipaddress.error.invalidMixedRange");
}
}
return creator.createSegment(
(getSegmentValue() << shift) | low.getSegmentValue(),
(getUpperSegmentValue() << shift) | low.getUpperSegmentValue(),
prefix);
} | [
"public",
"IPv6AddressSegment",
"join",
"(",
"IPv6AddressCreator",
"creator",
",",
"IPv4AddressSegment",
"low",
")",
"throws",
"IncompatibleAddressException",
"{",
"int",
"shift",
"=",
"IPv4Address",
".",
"BITS_PER_SEGMENT",
";",
"Integer",
"prefix",
"=",
"getJoinedSegm... | Joins with another IPv4 segment to produce a IPv6 segment.
@param creator
@param low
@return | [
"Joins",
"with",
"another",
"IPv4",
"segment",
"to",
"produce",
"a",
"IPv6",
"segment",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4AddressSegment.java#L306-L320 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddress.java | IPAddress.toHostName | public HostName toHostName() {
HostName host = fromHost;
if(host == null) {
fromHost = host = toCanonicalHostName();
}
return host;
} | java | public HostName toHostName() {
HostName host = fromHost;
if(host == null) {
fromHost = host = toCanonicalHostName();
}
return host;
} | [
"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. | [
"If",
"this",
"address",
"was",
"resolved",
"from",
"a",
"host",
"returns",
"that",
"host",
".",
"Otherwise",
"does",
"a",
"reverse",
"name",
"lookup",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddress.java#L164-L170 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddress.java | IPAddress.matchesWithMask | public boolean matchesWithMask(IPAddress other, IPAddress mask) {
return getSection().matchesWithMask(other.getSection(), mask.getSection());
} | java | public boolean matchesWithMask(IPAddress other, IPAddress mask) {
return getSection().matchesWithMask(other.getSection(), mask.getSection());
} | [
"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
@param mask
@param other
@return | [
"Applies",
"the",
"mask",
"to",
"this",
"address",
"and",
"then",
"compares",
"values",
"with",
"the",
"given",
"address"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddress.java#L592-L594 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddress.java | MACAddress.toLinkLocalIPv6 | public IPv6Address toLinkLocalIPv6() {
IPv6AddressNetwork network = getIPv6Network();
IPv6AddressSection linkLocalPrefix = network.getLinkLocalPrefix();
IPv6AddressCreator creator = network.getAddressCreator();
return creator.createAddress(linkLocalPrefix.append(toEUI64IPv6()));
} | java | public IPv6Address toLinkLocalIPv6() {
IPv6AddressNetwork network = getIPv6Network();
IPv6AddressSection linkLocalPrefix = network.getLinkLocalPrefix();
IPv6AddressCreator creator = network.getAddressCreator();
return creator.createAddress(linkLocalPrefix.append(toEUI64IPv6()));
} | [
"public",
"IPv6Address",
"toLinkLocalIPv6",
"(",
")",
"{",
"IPv6AddressNetwork",
"network",
"=",
"getIPv6Network",
"(",
")",
";",
"IPv6AddressSection",
"linkLocalPrefix",
"=",
"network",
".",
"getLinkLocalPrefix",
"(",
")",
";",
"IPv6AddressCreator",
"creator",
"=",
... | 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.
@return | [
"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",
"... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddress.java#L467-L472 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddress.java | MACAddress.toEUI64 | public MACAddress toEUI64(boolean asMAC) {
if(!isExtended()) {//getSegmentCount() == EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT
MACAddressCreator creator = getAddressCreator();
MACAddressSegment segs[] = creator.createSegmentArray(EXTENDED_UNIQUE_IDENTIFIER_64_SEGMENT_COUNT);
MACAddressSection section = getSection();
section.getSegments(0, 3, segs, 0);
MACAddressSegment ffSegment = creator.createSegment(0xff);
segs[3] = ffSegment;
segs[4] = asMAC ? ffSegment : creator.createSegment(0xfe);
section.getSegments(3, 6, segs, 5);
Integer prefLength = getPrefixLength();
if(prefLength != null) {
MACAddressSection resultSection = creator.createSectionInternal(segs, true);
if(prefLength >= 24) {
prefLength += MACAddress.BITS_PER_SEGMENT << 1; //two segments
}
resultSection.assignPrefixLength(prefLength);
}
return creator.createAddressInternal(segs);
} else {
MACAddressSection section = getSection();
MACAddressSegment seg3 = section.getSegment(3);
MACAddressSegment seg4 = section.getSegment(4);
if(seg3.matches(0xff) && seg4.matches(asMAC ? 0xff : 0xfe)) {
return this;
}
}
throw new IncompatibleAddressException(this, "ipaddress.mac.error.not.eui.convertible");
} | java | public MACAddress toEUI64(boolean asMAC) {
if(!isExtended()) {//getSegmentCount() == EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT
MACAddressCreator creator = getAddressCreator();
MACAddressSegment segs[] = creator.createSegmentArray(EXTENDED_UNIQUE_IDENTIFIER_64_SEGMENT_COUNT);
MACAddressSection section = getSection();
section.getSegments(0, 3, segs, 0);
MACAddressSegment ffSegment = creator.createSegment(0xff);
segs[3] = ffSegment;
segs[4] = asMAC ? ffSegment : creator.createSegment(0xfe);
section.getSegments(3, 6, segs, 5);
Integer prefLength = getPrefixLength();
if(prefLength != null) {
MACAddressSection resultSection = creator.createSectionInternal(segs, true);
if(prefLength >= 24) {
prefLength += MACAddress.BITS_PER_SEGMENT << 1; //two segments
}
resultSection.assignPrefixLength(prefLength);
}
return creator.createAddressInternal(segs);
} else {
MACAddressSection section = getSection();
MACAddressSegment seg3 = section.getSegment(3);
MACAddressSegment seg4 = section.getSegment(4);
if(seg3.matches(0xff) && seg4.matches(asMAC ? 0xff : 0xfe)) {
return this;
}
}
throw new IncompatibleAddressException(this, "ipaddress.mac.error.not.eui.convertible");
} | [
"public",
"MACAddress",
"toEUI64",
"(",
"boolean",
"asMAC",
")",
"{",
"if",
"(",
"!",
"isExtended",
"(",
")",
")",
"{",
"//getSegmentCount() == EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT\r",
"MACAddressCreator",
"creator",
"=",
"getAddressCreator",
"(",
")",
";",
"MA... | Convert to IPv6 EUI-64 section
http://standards.ieee.org/develop/regauth/tut/eui64.pdf
@param asMAC if true, this address is considered MAC and the EUI-64 is extended using ff-ff, otherwise this address is considered EUI-48 and extended using ff-fe
Note that IPv6 treats MAC as EUI-48 and extends MAC to IPv6 addresses using ff-fe
@return | [
"Convert",
"to",
"IPv6",
"EUI",
"-",
"64",
"section"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/mac/MACAddress.java#L511-L539 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSeqRange.java | IPAddressSeqRange.prefixIterator | @Override
public Iterator<? extends IPAddressSeqRange> prefixIterator(int prefixLength) {
if(!isMultiple()) {
return new Iterator<IPAddressSeqRange>() {
IPAddressSeqRange orig = IPAddressSeqRange.this;
@Override
public boolean hasNext() {
return orig != null;
}
@Override
public IPAddressSeqRange next() {
if(orig == null) {
throw new NoSuchElementException();
}
IPAddressSeqRange result = orig;
orig = null;
return result;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
return new Iterator<IPAddressSeqRange>() {
Iterator<? extends IPAddress> prefixBlockIterator = prefixBlockIterator(prefixLength);
private boolean first = true;
@Override
public boolean hasNext() {
return prefixBlockIterator.hasNext();
}
@Override
public IPAddressSeqRange next() {
IPAddress next = prefixBlockIterator.next();
if(first) {
first = false;
// next is a prefix block
IPAddress lower = getLower();
if(hasNext()) {
if(!lower.includesZeroHost(prefixLength)) {
return create(lower, next.getUpper());
}
} else {
IPAddress upper = getUpper();
if(!lower.includesZeroHost(prefixLength) || !upper.includesMaxHost(prefixLength)) {
return create(lower, upper);
}
}
} else if(!hasNext()) {
IPAddress upper = getUpper();
if(!upper.includesMaxHost(prefixLength)) {
return create(next.getLower(), upper);
}
}
return next.toSequentialRange();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
} | java | @Override
public Iterator<? extends IPAddressSeqRange> prefixIterator(int prefixLength) {
if(!isMultiple()) {
return new Iterator<IPAddressSeqRange>() {
IPAddressSeqRange orig = IPAddressSeqRange.this;
@Override
public boolean hasNext() {
return orig != null;
}
@Override
public IPAddressSeqRange next() {
if(orig == null) {
throw new NoSuchElementException();
}
IPAddressSeqRange result = orig;
orig = null;
return result;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
return new Iterator<IPAddressSeqRange>() {
Iterator<? extends IPAddress> prefixBlockIterator = prefixBlockIterator(prefixLength);
private boolean first = true;
@Override
public boolean hasNext() {
return prefixBlockIterator.hasNext();
}
@Override
public IPAddressSeqRange next() {
IPAddress next = prefixBlockIterator.next();
if(first) {
first = false;
// next is a prefix block
IPAddress lower = getLower();
if(hasNext()) {
if(!lower.includesZeroHost(prefixLength)) {
return create(lower, next.getUpper());
}
} else {
IPAddress upper = getUpper();
if(!lower.includesZeroHost(prefixLength) || !upper.includesMaxHost(prefixLength)) {
return create(lower, upper);
}
}
} else if(!hasNext()) {
IPAddress upper = getUpper();
if(!upper.includesMaxHost(prefixLength)) {
return create(next.getLower(), upper);
}
}
return next.toSequentialRange();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
} | [
"@",
"Override",
"public",
"Iterator",
"<",
"?",
"extends",
"IPAddressSeqRange",
">",
"prefixIterator",
"(",
"int",
"prefixLength",
")",
"{",
"if",
"(",
"!",
"isMultiple",
"(",
")",
")",
"{",
"return",
"new",
"Iterator",
"<",
"IPAddressSeqRange",
">",
"(",
... | Iterates through the range of prefixes in this range instance using the given prefix length.
@param prefixLength
@return | [
"Iterates",
"through",
"the",
"range",
"of",
"prefixes",
"in",
"this",
"range",
"instance",
"using",
"the",
"given",
"prefix",
"length",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSeqRange.java#L152-L219 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSeqRange.java | IPAddressSeqRange.join | 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 < ranges.length; j++) {
IPAddressSeqRange range2 = ranges[j];
if(range2 == null) {
continue;
}
IPAddress upper = range.getUpper();
IPAddress lower = range2.getLower();
if(compareLowValues(upper, lower) >= 0
|| upper.increment(1).equals(lower)) {
//join them
ranges[i] = range = range.create(range.getLower(), range2.getUpper());
ranges[j] = null;
joinedCount++;
} else break;
}
}
if(joinedCount == 0) {
return ranges;
}
IPAddressSeqRange joined[] = new IPAddressSeqRange[ranges.length - joinedCount];
for(int i = 0, j = 0; i < ranges.length; i++) {
IPAddressSeqRange range = ranges[i];
if(range == null) {
continue;
}
joined[j++] = range;
if(j >= joined.length) {
break;
}
}
return joined;
} | java | 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 < ranges.length; j++) {
IPAddressSeqRange range2 = ranges[j];
if(range2 == null) {
continue;
}
IPAddress upper = range.getUpper();
IPAddress lower = range2.getLower();
if(compareLowValues(upper, lower) >= 0
|| upper.increment(1).equals(lower)) {
//join them
ranges[i] = range = range.create(range.getLower(), range2.getUpper());
ranges[j] = null;
joinedCount++;
} else break;
}
}
if(joinedCount == 0) {
return ranges;
}
IPAddressSeqRange joined[] = new IPAddressSeqRange[ranges.length - joinedCount];
for(int i = 0, j = 0; i < ranges.length; i++) {
IPAddressSeqRange range = ranges[i];
if(range == null) {
continue;
}
joined[j++] = range;
if(j >= joined.length) {
break;
}
}
return joined;
} | [
"public",
"static",
"IPAddressSeqRange",
"[",
"]",
"join",
"(",
"IPAddressSeqRange",
"...",
"ranges",
")",
"{",
"int",
"joinedCount",
"=",
"0",
";",
"Arrays",
".",
"sort",
"(",
"ranges",
",",
"Address",
".",
"ADDRESS_LOW_VALUE_COMPARATOR",
")",
";",
"for",
"... | Joins the given ranges into the fewest number of ranges.
If no joining can take place, the original array is returned.
@param ranges
@return | [
"Joins",
"the",
"given",
"ranges",
"into",
"the",
"fewest",
"number",
"of",
"ranges",
".",
"If",
"no",
"joining",
"can",
"take",
"place",
"the",
"original",
"array",
"is",
"returned",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSeqRange.java#L450-L489 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSeqRange.java | IPAddressSeqRange.intersect | 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, otherUpper) >= 0) {
return other;
} else if(compareLowValues(upper, otherLower) < 0) {
return null;
}
return create(otherLower, upper);
} else if(compareLowValues(otherUpper, upper) >= 0) {
return this;
} else if(compareLowValues(otherUpper, lower) < 0) {
return null;
}
return create(lower, otherUpper);
} | java | 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, otherUpper) >= 0) {
return other;
} else if(compareLowValues(upper, otherLower) < 0) {
return null;
}
return create(otherLower, upper);
} else if(compareLowValues(otherUpper, upper) >= 0) {
return this;
} else if(compareLowValues(otherUpper, lower) < 0) {
return null;
}
return create(lower, otherUpper);
} | [
"public",
"IPAddressSeqRange",
"intersect",
"(",
"IPAddressSeqRange",
"other",
")",
"{",
"IPAddress",
"otherLower",
"=",
"other",
".",
"getLower",
"(",
")",
";",
"IPAddress",
"otherUpper",
"=",
"other",
".",
"getUpper",
"(",
")",
";",
"IPAddress",
"lower",
"="... | Returns the intersection of this range with the given range, a range which includes those addresses in both this and the given rqnge.
@param other
@return | [
"Returns",
"the",
"intersection",
"of",
"this",
"range",
"with",
"the",
"given",
"range",
"a",
"range",
"which",
"includes",
"those",
"addresses",
"in",
"both",
"this",
"and",
"the",
"given",
"rqnge",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSeqRange.java#L533-L551 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSeqRange.java | IPAddressSeqRange.subtract | 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(upper, otherUpper) > 0) { // l ol ou u
return createPair(lower, otherLower.increment(-1), otherUpper.increment(1), upper);
} else {
int comp = compareLowValues(upper, otherLower);
if(comp < 0) { // l u ol ou
return createSingle();
} else if(comp == 0) { // l u == ol ou
return createSingle(lower, upper.increment(-1));
}
return createSingle(lower, otherLower.increment(-1)); // l ol u ou
}
} else if(compareLowValues(otherUpper, upper) >= 0) { // ol l u ou
return createEmpty();
} else {
int comp = compareLowValues(otherUpper, lower);
if(comp < 0) {
return createSingle(); // ol ou l u
} else if(comp == 0) {
return createSingle(lower.increment(1), upper); //ol ou == l u
}
return createSingle(otherUpper.increment(1), upper); // ol l ou u
}
} | java | 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(upper, otherUpper) > 0) { // l ol ou u
return createPair(lower, otherLower.increment(-1), otherUpper.increment(1), upper);
} else {
int comp = compareLowValues(upper, otherLower);
if(comp < 0) { // l u ol ou
return createSingle();
} else if(comp == 0) { // l u == ol ou
return createSingle(lower, upper.increment(-1));
}
return createSingle(lower, otherLower.increment(-1)); // l ol u ou
}
} else if(compareLowValues(otherUpper, upper) >= 0) { // ol l u ou
return createEmpty();
} else {
int comp = compareLowValues(otherUpper, lower);
if(comp < 0) {
return createSingle(); // ol ou l u
} else if(comp == 0) {
return createSingle(lower.increment(1), upper); //ol ou == l u
}
return createSingle(otherUpper.increment(1), upper); // ol l ou u
}
} | [
"public",
"IPAddressSeqRange",
"[",
"]",
"subtract",
"(",
"IPAddressSeqRange",
"other",
")",
"{",
"IPAddress",
"otherLower",
"=",
"other",
".",
"getLower",
"(",
")",
";",
"IPAddress",
"otherUpper",
"=",
"other",
".",
"getUpper",
"(",
")",
";",
"IPAddress",
"... | 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.
@param other
@return | [
"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",... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSeqRange.java#L602-L630 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java | IPAddressSection.isNetworkSection | protected boolean isNetworkSection(int networkPrefixLength, boolean withPrefixLength) {
int segmentCount = getSegmentCount();
if(segmentCount == 0) {
return true;
}
int bitsPerSegment = getBitsPerSegment();
int prefixedSegmentIndex = getNetworkSegmentIndex(networkPrefixLength, getBytesPerSegment(), bitsPerSegment);
if(prefixedSegmentIndex + 1 < segmentCount) {
return false; //not the right number of segments
}
//the segment count matches, now compare the prefixed segment
int segPrefLength = getPrefixedSegmentPrefixLength(bitsPerSegment, networkPrefixLength, prefixedSegmentIndex);
return !getSegment(segmentCount - 1).isNetworkChangedByPrefix(segPrefLength, withPrefixLength);
} | java | protected boolean isNetworkSection(int networkPrefixLength, boolean withPrefixLength) {
int segmentCount = getSegmentCount();
if(segmentCount == 0) {
return true;
}
int bitsPerSegment = getBitsPerSegment();
int prefixedSegmentIndex = getNetworkSegmentIndex(networkPrefixLength, getBytesPerSegment(), bitsPerSegment);
if(prefixedSegmentIndex + 1 < segmentCount) {
return false; //not the right number of segments
}
//the segment count matches, now compare the prefixed segment
int segPrefLength = getPrefixedSegmentPrefixLength(bitsPerSegment, networkPrefixLength, prefixedSegmentIndex);
return !getSegment(segmentCount - 1).isNetworkChangedByPrefix(segPrefLength, withPrefixLength);
} | [
"protected",
"boolean",
"isNetworkSection",
"(",
"int",
"networkPrefixLength",
",",
"boolean",
"withPrefixLength",
")",
"{",
"int",
"segmentCount",
"=",
"getSegmentCount",
"(",
")",
";",
"if",
"(",
"segmentCount",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}... | this method is basically checking whether we can return "this" for getNetworkSection | [
"this",
"method",
"is",
"basically",
"checking",
"whether",
"we",
"can",
"return",
"this",
"for",
"getNetworkSection"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java#L258-L271 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java | IPAddressSection.getBlockMaskPrefixLength | public Integer getBlockMaskPrefixLength(boolean network) {
Integer prefixLen;
if(network) {
if(hasNoPrefixCache() || (prefixLen = prefixCache.networkMaskPrefixLen) == null) {
prefixLen = setNetworkMaskPrefix(checkForPrefixMask(network));
}
} else {
if(hasNoPrefixCache() || (prefixLen = prefixCache.hostMaskPrefixLen) == null) {
prefixLen = setHostMaskPrefix(checkForPrefixMask(network));
}
}
if(prefixLen < 0) {
return null;
}
return prefixLen;
} | java | public Integer getBlockMaskPrefixLength(boolean network) {
Integer prefixLen;
if(network) {
if(hasNoPrefixCache() || (prefixLen = prefixCache.networkMaskPrefixLen) == null) {
prefixLen = setNetworkMaskPrefix(checkForPrefixMask(network));
}
} else {
if(hasNoPrefixCache() || (prefixLen = prefixCache.hostMaskPrefixLen) == null) {
prefixLen = setHostMaskPrefix(checkForPrefixMask(network));
}
}
if(prefixLen < 0) {
return null;
}
return prefixLen;
} | [
"public",
"Integer",
"getBlockMaskPrefixLength",
"(",
"boolean",
"network",
")",
"{",
"Integer",
"prefixLen",
";",
"if",
"(",
"network",
")",
"{",
"if",
"(",
"hasNoPrefixCache",
"(",
")",
"||",
"(",
"prefixLen",
"=",
"prefixCache",
".",
"networkMaskPrefixLen",
... | 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 1s in the host section.
The prefix length is the length of the network section.
Also, keep in mind that the prefix length returned by this method is not equivalent to the prefix length used to construct this object.
The prefix length used to construct indicates the network and host section of this address.
The prefix length returned here indicates the whether the value of this address can be used as a mask for the network and host
section of any other address. Therefore the two values can be different values, or one can be null while the other is not.
This method applies only to the lower value of the range if this section represents multiple values.
@param network whether to check for a network mask or a host mask
@return the prefix length corresponding to this mask, or null if there is no such prefix length | [
"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",
"... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java#L347-L362 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java | IPAddressSection.containsNonZeroHosts | 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, otherPrefixLength);
} | java | 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, otherPrefixLength);
} | [
"public",
"boolean",
"containsNonZeroHosts",
"(",
"IPAddressSection",
"other",
")",
"{",
"if",
"(",
"!",
"other",
".",
"isPrefixed",
"(",
")",
")",
"{",
"return",
"contains",
"(",
"other",
")",
";",
"}",
"int",
"otherPrefixLength",
"=",
"other",
".",
"getN... | Returns whether this address contains the non-zero host addresses in other.
@param other
@return | [
"Returns",
"whether",
"this",
"address",
"contains",
"the",
"non",
"-",
"zero",
"host",
"addresses",
"in",
"other",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java#L803-L812 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java | IPAddressSection.matchesWithMask | 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);
IPAddressSegment otherSegment = other.getSegment(i);
if(!div.matchesWithMask(
otherSegment.getSegmentValue(),
otherSegment.getUpperSegmentValue(),
maskSegment.getSegmentValue())) {
return false;
}
}
return true;
} | java | 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);
IPAddressSegment otherSegment = other.getSegment(i);
if(!div.matchesWithMask(
otherSegment.getSegmentValue(),
otherSegment.getUpperSegmentValue(),
maskSegment.getSegmentValue())) {
return false;
}
}
return true;
} | [
"public",
"boolean",
"matchesWithMask",
"(",
"IPAddressSection",
"other",
",",
"IPAddressSection",
"mask",
")",
"{",
"checkMaskSectionCount",
"(",
"mask",
")",
";",
"checkSectionCount",
"(",
"other",
")",
";",
"int",
"divCount",
"=",
"getSegmentCount",
"(",
")",
... | Applies the mask to this address section and then compares values with the given address section
@param mask
@param other
@return | [
"Applies",
"the",
"mask",
"to",
"this",
"address",
"section",
"and",
"then",
"compares",
"values",
"with",
"the",
"given",
"address",
"section"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java#L1824-L1840 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java | IPAddressSection.toHexString | protected String toHexString(boolean with0xPrefix, CharSequence zone) {
if(isDualString()) {
return toNormalizedStringRange(toIPParams(with0xPrefix ? IPStringCache.hexPrefixedParams : IPStringCache.hexParams), getLower(), getUpper(), zone);
}
return toIPParams(with0xPrefix ? IPStringCache.hexPrefixedParams : IPStringCache.hexParams).toString(this, zone);
} | java | protected String toHexString(boolean with0xPrefix, CharSequence zone) {
if(isDualString()) {
return toNormalizedStringRange(toIPParams(with0xPrefix ? IPStringCache.hexPrefixedParams : IPStringCache.hexParams), getLower(), getUpper(), zone);
}
return toIPParams(with0xPrefix ? IPStringCache.hexPrefixedParams : IPStringCache.hexParams).toString(this, zone);
} | [
"protected",
"String",
"toHexString",
"(",
"boolean",
"with0xPrefix",
",",
"CharSequence",
"zone",
")",
"{",
"if",
"(",
"isDualString",
"(",
")",
")",
"{",
"return",
"toNormalizedStringRange",
"(",
"toIPParams",
"(",
"with0xPrefix",
"?",
"IPStringCache",
".",
"h... | overridden in ipv6 to handle zone | [
"overridden",
"in",
"ipv6",
"to",
"handle",
"zone"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressSection.java#L2331-L2336 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java | IPv6Address.getEmbeddedIPv4Address | 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().getEmbeddedIPv4AddressSection(byteIndex, byteIndex + IPv4Address.BYTE_COUNT)); /* address creation */
} | java | 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().getEmbeddedIPv4AddressSection(byteIndex, byteIndex + IPv4Address.BYTE_COUNT)); /* address creation */
} | [
"public",
"IPv4Address",
"getEmbeddedIPv4Address",
"(",
"int",
"byteIndex",
")",
"{",
"if",
"(",
"byteIndex",
"==",
"IPv6Address",
".",
"MIXED_ORIGINAL_SEGMENT_COUNT",
"*",
"IPv6Address",
".",
"BYTES_PER_SEGMENT",
")",
"{",
"return",
"getEmbeddedIPv4Address",
"(",
")"... | Produces an IPv4 address from any sequence of 4 bytes in this IPv6 address.
@param byteIndex the byte index to start
@throws IndexOutOfBoundsException if the index is less than zero or bigger than 7
@return | [
"Produces",
"an",
"IPv4",
"address",
"from",
"any",
"sequence",
"of",
"4",
"bytes",
"in",
"this",
"IPv6",
"address",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java#L1043-L1049 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java | IPv6Address.isIPv4Mapped | public boolean isIPv4Mapped() {
//::ffff:x:x/96 indicates IPv6 address mapped to IPv4
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;
} | java | public boolean isIPv4Mapped() {
//::ffff:x:x/96 indicates IPv6 address mapped to IPv4
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;
} | [
"public",
"boolean",
"isIPv4Mapped",
"(",
")",
"{",
"//::ffff:x:x/96 indicates IPv6 address mapped to IPv4",
"if",
"(",
"getSegment",
"(",
"5",
")",
".",
"matches",
"(",
"IPv6Address",
".",
"MAX_VALUE_PER_SEGMENT",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0"... | Whether the address is IPv4-mapped
::ffff:x:x/96 indicates IPv6 address mapped to IPv4 | [
"Whether",
"the",
"address",
"is",
"IPv4",
"-",
"mapped"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java#L1117-L1128 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java | IPv6Address.isIPv4Compatible | public boolean isIPv4Compatible() {
return getSegment(0).isZero() && getSegment(1).isZero() && getSegment(2).isZero() &&
getSegment(3).isZero() && getSegment(4).isZero() && getSegment(5).isZero();
} | java | public boolean isIPv4Compatible() {
return getSegment(0).isZero() && getSegment(1).isZero() && getSegment(2).isZero() &&
getSegment(3).isZero() && getSegment(4).isZero() && getSegment(5).isZero();
} | [
"public",
"boolean",
"isIPv4Compatible",
"(",
")",
"{",
"return",
"getSegment",
"(",
"0",
")",
".",
"isZero",
"(",
")",
"&&",
"getSegment",
"(",
"1",
")",
".",
"isZero",
"(",
")",
"&&",
"getSegment",
"(",
"2",
")",
".",
"isZero",
"(",
")",
"&&",
"g... | Whether the address is IPv4-compatible
@see java.net.Inet6Address#isIPv4CompatibleAddress() | [
"Whether",
"the",
"address",
"is",
"IPv4",
"-",
"compatible"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java#L1135-L1138 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java | IPv6Address.isWellKnownIPv4Translatable | public boolean isWellKnownIPv4Translatable() { //rfc 6052 rfc 6144
//64:ff9b::/96 prefix for auto ipv4/ipv6 translation
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;
} | java | public boolean isWellKnownIPv4Translatable() { //rfc 6052 rfc 6144
//64:ff9b::/96 prefix for auto ipv4/ipv6 translation
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;
} | [
"public",
"boolean",
"isWellKnownIPv4Translatable",
"(",
")",
"{",
"//rfc 6052 rfc 6144",
"//64:ff9b::/96 prefix for auto ipv4/ipv6 translation",
"if",
"(",
"getSegment",
"(",
"0",
")",
".",
"matches",
"(",
"0x64",
")",
"&&",
"getSegment",
"(",
"1",
")",
".",
"match... | Whether the address has the well-known prefix for IPv4 translatable addresses as in rfc 6052 and 6144
@return | [
"Whether",
"the",
"address",
"has",
"the",
"well",
"-",
"known",
"prefix",
"for",
"IPv4",
"translatable",
"addresses",
"as",
"in",
"rfc",
"6052",
"and",
"6144"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java#L1192-L1203 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java | IPv6Address.toInetAddress | @Override
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();
} | java | @Override
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();
} | [
"@",
"Override",
"public",
"Inet6Address",
"toInetAddress",
"(",
")",
"{",
"if",
"(",
"hasZone",
"(",
")",
")",
"{",
"Inet6Address",
"result",
";",
"if",
"(",
"hasNoValueCache",
"(",
")",
"||",
"(",
"result",
"=",
"valueCache",
".",
"inetAddress",
")",
"... | we need to cache the address in here and not in the address section if there is a zone | [
"we",
"need",
"to",
"cache",
"the",
"address",
"in",
"here",
"and",
"not",
"in",
"the",
"address",
"section",
"if",
"there",
"is",
"a",
"zone"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java#L1570-L1580 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java | IPv6Address.toMixedString | public String toMixedString() {
String result;
if(hasNoStringCache() || (result = stringCache.mixedString) == null) {
if(hasZone()) {
stringCache.mixedString = result = toNormalizedString(IPv6StringCache.mixedParams);
} else {
result = getSection().toMixedString();//the cache is shared so no need to update it here
}
}
return result;
} | java | public String toMixedString() {
String result;
if(hasNoStringCache() || (result = stringCache.mixedString) == null) {
if(hasZone()) {
stringCache.mixedString = result = toNormalizedString(IPv6StringCache.mixedParams);
} else {
result = getSection().toMixedString();//the cache is shared so no need to update it here
}
}
return result;
} | [
"public",
"String",
"toMixedString",
"(",
")",
"{",
"String",
"result",
";",
"if",
"(",
"hasNoStringCache",
"(",
")",
"||",
"(",
"result",
"=",
"stringCache",
".",
"mixedString",
")",
"==",
"null",
")",
"{",
"if",
"(",
"hasZone",
"(",
")",
")",
"{",
... | 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.
This the mixed IPv6/IPv4 format described in RFC 1884 https://tools.ietf.org/html/rfc1884
@return | [
"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",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java#L1707-L1717 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java | IPv6Address.toNormalizedString | @Override
public String toNormalizedString() {
String result;
if(hasNoStringCache() || (result = stringCache.normalizedString) == null) {
if(hasZone()) {
stringCache.normalizedString = result = toNormalizedString(IPv6StringCache.normalizedParams);
} else {
result = getSection().toNormalizedString();//the cache is shared so no need to update it here
}
}
return result;
} | java | @Override
public String toNormalizedString() {
String result;
if(hasNoStringCache() || (result = stringCache.normalizedString) == null) {
if(hasZone()) {
stringCache.normalizedString = result = toNormalizedString(IPv6StringCache.normalizedParams);
} else {
result = getSection().toNormalizedString();//the cache is shared so no need to update it here
}
}
return result;
} | [
"@",
"Override",
"public",
"String",
"toNormalizedString",
"(",
")",
"{",
"String",
"result",
";",
"if",
"(",
"hasNoStringCache",
"(",
")",
"||",
"(",
"result",
"=",
"stringCache",
".",
"normalizedString",
")",
"==",
"null",
")",
"{",
"if",
"(",
"hasZone",... | The normalized string returned by this method is consistent with java.net.Inet6address.
IPs are not compressed nor mixed in this representation. If this has a prefix length, that will be included in the string. | [
"The",
"normalized",
"string",
"returned",
"by",
"this",
"method",
"is",
"consistent",
"with",
"java",
".",
"net",
".",
"Inet6address",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java#L1773-L1784 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java | IPv6Address.toNormalizedWildcardString | @Override
public String toNormalizedWildcardString() {
String result;
if(hasNoStringCache() || (result = stringCache.normalizedWildcardString) == null) {
if(hasZone()) {
stringCache.normalizedWildcardString = result = toNormalizedString(IPv6StringCache.wildcardNormalizedParams);
} else {
result = getSection().toNormalizedWildcardString();//the cache is shared so no need to update it here
}
}
return result;
} | java | @Override
public String toNormalizedWildcardString() {
String result;
if(hasNoStringCache() || (result = stringCache.normalizedWildcardString) == null) {
if(hasZone()) {
stringCache.normalizedWildcardString = result = toNormalizedString(IPv6StringCache.wildcardNormalizedParams);
} else {
result = getSection().toNormalizedWildcardString();//the cache is shared so no need to update it here
}
}
return result;
} | [
"@",
"Override",
"public",
"String",
"toNormalizedWildcardString",
"(",
")",
"{",
"String",
"result",
";",
"if",
"(",
"hasNoStringCache",
"(",
")",
"||",
"(",
"result",
"=",
"stringCache",
".",
"normalizedWildcardString",
")",
"==",
"null",
")",
"{",
"if",
"... | note this string is used by hashCode | [
"note",
"this",
"string",
"is",
"used",
"by",
"hashCode"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java#L1808-L1819 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java | IPv6Address.toNormalizedString | 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,
params.segmentStrPrefix,
true,
params.ipv4Opts,
params.compressOptions,
params.separator,
params.zoneSeparator,
params.addrLabel,
params.addrSuffix,
params.reverse,
params.splitDigits,
params.uppercase);
}
return toNormalizedString(params);
} | java | 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,
params.segmentStrPrefix,
true,
params.ipv4Opts,
params.compressOptions,
params.separator,
params.zoneSeparator,
params.addrLabel,
params.addrSuffix,
params.reverse,
params.splitDigits,
params.uppercase);
}
return toNormalizedString(params);
} | [
"public",
"String",
"toNormalizedString",
"(",
"boolean",
"keepMixed",
",",
"IPv6StringOptions",
"params",
")",
"{",
"if",
"(",
"keepMixed",
"&&",
"fromString",
"!=",
"null",
"&&",
"getAddressfromString",
"(",
")",
".",
"isMixedIPv6",
"(",
")",
"&&",
"!",
"par... | Constructs a string representing this address according to the given parameters
@param keepMixed if this address was constructed from a string with mixed representation (a:b:c:d:e:f:1.2.3.4), whether to keep it that way (ignored if makeMixed is true in the params argument)
@param params the parameters for the address string | [
"Constructs",
"a",
"string",
"representing",
"this",
"address",
"according",
"to",
"the",
"given",
"parameters"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv6/IPv6Address.java#L1968-L1988 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4AddressSection.java | IPv4AddressSection.mask | public IPv4AddressSection mask(IPv4AddressSection mask, boolean retainPrefix) throws IncompatibleAddressException, PrefixLenException, SizeMismatchException {
checkMaskSectionCount(mask);
return getSubnetSegments(
this,
retainPrefix ? getPrefixLength() : null,
getAddressCreator(),
true,
this::getSegment,
i -> mask.getSegment(i).getSegmentValue(),
false);
} | java | public IPv4AddressSection mask(IPv4AddressSection mask, boolean retainPrefix) throws IncompatibleAddressException, PrefixLenException, SizeMismatchException {
checkMaskSectionCount(mask);
return getSubnetSegments(
this,
retainPrefix ? getPrefixLength() : null,
getAddressCreator(),
true,
this::getSegment,
i -> mask.getSegment(i).getSegmentValue(),
false);
} | [
"public",
"IPv4AddressSection",
"mask",
"(",
"IPv4AddressSection",
"mask",
",",
"boolean",
"retainPrefix",
")",
"throws",
"IncompatibleAddressException",
",",
"PrefixLenException",
",",
"SizeMismatchException",
"{",
"checkMaskSectionCount",
"(",
"mask",
")",
";",
"return"... | Does the bitwise conjunction with this address. Useful when subnetting.
@param mask
@param retainPrefix whether to drop the prefix
@return
@throws IncompatibleAddressException | [
"Does",
"the",
"bitwise",
"conjunction",
"with",
"this",
"address",
".",
"Useful",
"when",
"subnetting",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4AddressSection.java#L1261-L1271 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4AddressSection.java | IPv4AddressSection.toFullString | @Override
public String toFullString() {
String result;
if(hasNoStringCache() || (result = stringCache.fullString) == null) {
stringCache.fullString = result = toNormalizedString(IPv4StringCache.fullParams);
}
return result;
} | java | @Override
public String toFullString() {
String result;
if(hasNoStringCache() || (result = stringCache.fullString) == null) {
stringCache.fullString = result = toNormalizedString(IPv4StringCache.fullParams);
}
return result;
} | [
"@",
"Override",
"public",
"String",
"toFullString",
"(",
")",
"{",
"String",
"result",
";",
"if",
"(",
"hasNoStringCache",
"(",
")",
"||",
"(",
"result",
"=",
"stringCache",
".",
"fullString",
")",
"==",
"null",
")",
"{",
"stringCache",
".",
"fullString",... | This produces a string with no compressed segments and all segments of full length,
which is 3 characters for IPv4 segments. | [
"This",
"produces",
"a",
"string",
"with",
"no",
"compressed",
"segments",
"and",
"all",
"segments",
"of",
"full",
"length",
"which",
"is",
"3",
"characters",
"for",
"IPv4",
"segments",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4AddressSection.java#L1554-L1561 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/util/IPAddressPartConfiguredString.java | IPAddressPartConfiguredString.getNetworkStringMatcher | @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);
} | java | @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);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"S",
"extends",
"IPAddressPartConfiguredString",
"<",
"T",
",",
"P",
">",
">",
"SQLStringMatcher",
"<",
"T",
",",
"P",
",",
"S",
">",
"getNetworkStringMatcher",
"(",
"boolean",
"isEntireAddress",... | Provides an object that can build SQL clauses to match this string representation.
This method can be overridden for other IP address types to match in their own ways.
@param isEntireAddress
@param translator
@return | [
"Provides",
"an",
"object",
"that",
"can",
"build",
"SQL",
"clauses",
"to",
"match",
"this",
"string",
"representation",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/util/IPAddressPartConfiguredString.java#L61-L64 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressString.java | IPAddressString.isValid | public boolean isValid() {
if(addressProvider.isUninitialized()) {
try {
validate();
return true;
} catch(AddressStringException e) {
return false;
}
}
return !addressProvider.isInvalid();
} | java | public boolean isValid() {
if(addressProvider.isUninitialized()) {
try {
validate();
return true;
} catch(AddressStringException e) {
return false;
}
}
return !addressProvider.isInvalid();
} | [
"public",
"boolean",
"isValid",
"(",
")",
"{",
"if",
"(",
"addressProvider",
".",
"isUninitialized",
"(",
")",
")",
"{",
"try",
"{",
"validate",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"AddressStringException",
"e",
")",
"{",
"return",
... | Returns whether this is a valid address string format.
The accepted IP address formats are:
an IPv4 address, an IPv6 address, a network prefix alone, the address representing all addresses of all types, or an empty string.
If this method returns false, and you want more details, call validate() and examine the thrown exception.
@return whether this is a valid address string format | [
"Returns",
"whether",
"this",
"is",
"a",
"valid",
"address",
"string",
"format",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressString.java#L382-L392 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressString.java | IPAddressString.compareTo | @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);
} | java | @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);
} | [
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"IPAddressString",
"other",
")",
"{",
"if",
"(",
"this",
"==",
"other",
")",
"{",
"return",
"0",
";",
"}",
"boolean",
"isValid",
"=",
"isValid",
"(",
")",
";",
"boolean",
"otherIsValid",
"=",
"other",
... | 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.
@param other
@return | [
"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",
"... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressString.java#L517-L528 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressString.java | IPAddressString.convertToPrefixLength | 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();
} | java | 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();
} | [
"public",
"String",
"convertToPrefixLength",
"(",
")",
"throws",
"AddressStringException",
"{",
"IPAddress",
"address",
"=",
"toAddress",
"(",
")",
";",
"Integer",
"prefix",
";",
"if",
"(",
"address",
"==",
"null",
")",
"{",
"if",
"(",
"isPrefixOnly",
"(",
"... | Converts this address to a prefix length
@return the prefix of the indicated IP type represented by this address or null if this address is valid but cannot be represented by a network prefix length
@throws AddressStringException if the address is invalid | [
"Converts",
"this",
"address",
"to",
"a",
"prefix",
"length"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/IPAddressString.java#L1044-L1061 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/IPAddressDivisionGrouping.java | IPAddressDivisionGrouping.getTrailingBitCount | 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;
} | java | 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;
} | [
"public",
"int",
"getTrailingBitCount",
"(",
"boolean",
"network",
")",
"{",
"int",
"count",
"=",
"getDivisionCount",
"(",
")",
";",
"if",
"(",
"count",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"long",
"back",
"=",
"network",
"?",
"0",
":",
"get... | 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.
@param network
@return | [
"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",
"co... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/IPAddressDivisionGrouping.java#L177-L193 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/IPAddressDivisionGrouping.java | IPAddressDivisionGrouping.getLeadingBitCount | 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;
} | java | 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;
} | [
"public",
"int",
"getLeadingBitCount",
"(",
"boolean",
"network",
")",
"{",
"int",
"count",
"=",
"getDivisionCount",
"(",
")",
";",
"if",
"(",
"count",
"==",
"0",
")",
"{",
"return",
"0",
";",
"}",
"long",
"front",
"=",
"network",
"?",
"getDivision",
"... | 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.
@param network
@return | [
"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",
"conse... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/IPAddressDivisionGrouping.java#L203-L219 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/IPAddressDivisionGrouping.java | IPAddressDivisionGrouping.isPrefixBlock | @Override
public boolean isPrefixBlock() {
Integer networkPrefixLength = getNetworkPrefixLength();
if(networkPrefixLength == null) {
return false;
}
if(getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets()) {
return true;
}
return containsPrefixBlock(networkPrefixLength);
} | java | @Override
public boolean isPrefixBlock() {
Integer networkPrefixLength = getNetworkPrefixLength();
if(networkPrefixLength == null) {
return false;
}
if(getNetwork().getPrefixConfiguration().allPrefixedAddressesAreSubnets()) {
return true;
}
return containsPrefixBlock(networkPrefixLength);
} | [
"@",
"Override",
"public",
"boolean",
"isPrefixBlock",
"(",
")",
"{",
"Integer",
"networkPrefixLength",
"=",
"getNetworkPrefixLength",
"(",
")",
";",
"if",
"(",
"networkPrefixLength",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"getNetwork"... | Returns whether this address section represents a subnet block of addresses associated its prefix length.
Returns false if it has no prefix length, if it is a single address with a prefix length (ie not a subnet), or if it is a range of addresses that does not include
the entire subnet block for its prefix length.
If {@link AddressNetwork#getPrefixConfiguration} is set to consider all prefixes as subnets, this returns true for any grouping with prefix length.
@return | [
"Returns",
"whether",
"this",
"address",
"section",
"represents",
"a",
"subnet",
"block",
"of",
"addresses",
"associated",
"its",
"prefix",
"length",
"."
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/IPAddressDivisionGrouping.java#L231-L241 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/IPAddressDivisionGrouping.java | IPAddressDivisionGrouping.isSinglePrefixBlock | @Override
public boolean isSinglePrefixBlock() {
Integer networkPrefixLength = getNetworkPrefixLength();
if(networkPrefixLength == null) {
return false;
}
return containsSinglePrefixBlock(networkPrefixLength);
} | java | @Override
public boolean isSinglePrefixBlock() {
Integer networkPrefixLength = getNetworkPrefixLength();
if(networkPrefixLength == null) {
return false;
}
return containsSinglePrefixBlock(networkPrefixLength);
} | [
"@",
"Override",
"public",
"boolean",
"isSinglePrefixBlock",
"(",
")",
"{",
"Integer",
"networkPrefixLength",
"=",
"getNetworkPrefixLength",
"(",
")",
";",
"if",
"(",
"networkPrefixLength",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"contains... | 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. | [
"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... | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/format/standard/IPAddressDivisionGrouping.java#L257-L264 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4Address.java | IPv4Address.getIPv6Address | public IPv6Address getIPv6Address(IPv6AddressSegment segs[]) {
IPv6AddressCreator creator = getIPv6Network().getAddressCreator();
return creator.createAddress(IPv6AddressSection.createSection(creator, segs, this)); /* address creation */
} | java | public IPv6Address getIPv6Address(IPv6AddressSegment segs[]) {
IPv6AddressCreator creator = getIPv6Network().getAddressCreator();
return creator.createAddress(IPv6AddressSection.createSection(creator, segs, this)); /* address creation */
} | [
"public",
"IPv6Address",
"getIPv6Address",
"(",
"IPv6AddressSegment",
"segs",
"[",
"]",
")",
"{",
"IPv6AddressCreator",
"creator",
"=",
"getIPv6Network",
"(",
")",
".",
"getAddressCreator",
"(",
")",
";",
"return",
"creator",
".",
"createAddress",
"(",
"IPv6Addres... | Create an IPv6 mixed address using the given ipv6 segments and using this address for the embedded IPv4 segments
@param segs
@return | [
"Create",
"an",
"IPv6",
"mixed",
"address",
"using",
"the",
"given",
"ipv6",
"segments",
"and",
"using",
"this",
"address",
"for",
"the",
"embedded",
"IPv4",
"segments"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4Address.java#L341-L344 | train |
seancfoley/IPAddress | IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4Address.java | IPv4Address.isPrivate | 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);
} | java | 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);
} | [
"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",
"=",
"g... | Unicast addresses allocated for private use
@see java.net.InetAddress#isSiteLocalAddress() | [
"Unicast",
"addresses",
"allocated",
"for",
"private",
"use"
] | 90493d0673511d673100c36d020dd93dd870111a | https://github.com/seancfoley/IPAddress/blob/90493d0673511d673100c36d020dd93dd870111a/IPAddress/src/inet.ipaddr/inet/ipaddr/ipv4/IPv4Address.java#L919-L929 | train |
camunda/camunda-spin | dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonLogger.java | JacksonJsonLogger.unableToParseValue | public SpinJsonDataFormatException unableToParseValue(String expectedType, JsonNodeType type) {
return new SpinJsonDataFormatException(exceptionMessage("002", "Expected '{}', got '{}'", expectedType, type.toString()));
} | java | public SpinJsonDataFormatException unableToParseValue(String expectedType, JsonNodeType type) {
return new SpinJsonDataFormatException(exceptionMessage("002", "Expected '{}', got '{}'", expectedType, type.toString()));
} | [
"public",
"SpinJsonDataFormatException",
"unableToParseValue",
"(",
"String",
"expectedType",
",",
"JsonNodeType",
"type",
")",
"{",
"return",
"new",
"SpinJsonDataFormatException",
"(",
"exceptionMessage",
"(",
"\"002\"",
",",
"\"Expected '{}', got '{}'\"",
",",
"expectedTy... | Exception handler if we are unable to parse a json value into a java representation
@param expectedType Name of the expected Type
@param type Type of the json node
@return SpinJsonDataFormatException | [
"Exception",
"handler",
"if",
"we",
"are",
"unable",
"to",
"parse",
"a",
"json",
"value",
"into",
"a",
"java",
"representation"
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/JacksonJsonLogger.java#L52-L54 | train |
camunda/camunda-spin | dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/DomXmlElement.java | DomXmlElement.adoptElement | 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);
}
}
} | java | 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);
}
}
} | [
"protected",
"void",
"adoptElement",
"(",
"DomXmlElement",
"elementToAdopt",
")",
"{",
"Document",
"document",
"=",
"this",
".",
"domElement",
".",
"getOwnerDocument",
"(",
")",
";",
"Element",
"element",
"=",
"elementToAdopt",
".",
"domElement",
";",
"if",
"(",... | Adopts an xml dom element to the owner document of this element if necessary.
@param elementToAdopt the element to adopt | [
"Adopts",
"an",
"xml",
"dom",
"element",
"to",
"the",
"owner",
"document",
"of",
"this",
"element",
"if",
"necessary",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/DomXmlElement.java#L357-L367 | train |
camunda/camunda-spin | dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/util/DomXmlEnsure.java | DomXmlEnsure.ensureChildElement | 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);
}
} | java | 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);
}
} | [
"public",
"static",
"void",
"ensureChildElement",
"(",
"DomXmlElement",
"parentElement",
",",
"DomXmlElement",
"childElement",
")",
"{",
"Node",
"parent",
"=",
"childElement",
".",
"unwrap",
"(",
")",
".",
"getParentNode",
"(",
")",
";",
"if",
"(",
"parent",
"... | Ensures that the element is child element of the parent element.
@param parentElement the parent xml dom element
@param childElement the child element
@throws SpinXmlElementException if the element is not child of the parent element | [
"Ensures",
"that",
"the",
"element",
"is",
"child",
"element",
"of",
"the",
"parent",
"element",
"."
] | cfe65161eb97fd5023a945cb97c47fbfe69e9fdd | https://github.com/camunda/camunda-spin/blob/cfe65161eb97fd5023a945cb97c47fbfe69e9fdd/dataformat-xml-dom/src/main/java/org/camunda/spin/impl/xml/dom/util/DomXmlEnsure.java#L46-L51 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.