id
int32 0
165k
| 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
|
---|---|---|---|---|---|---|---|---|---|---|---|
7,900 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
|
PasswordEditText.removeAllConstraints
|
public final void removeAllConstraints(
@NonNull final Collection<Constraint<CharSequence>> constraints) {
Condition.INSTANCE.ensureNotNull(constraints, "The collection may not be null");
for (Constraint<CharSequence> constraint : constraints) {
removeConstraint(constraint);
}
}
|
java
|
public final void removeAllConstraints(
@NonNull final Collection<Constraint<CharSequence>> constraints) {
Condition.INSTANCE.ensureNotNull(constraints, "The collection may not be null");
for (Constraint<CharSequence> constraint : constraints) {
removeConstraint(constraint);
}
}
|
[
"public",
"final",
"void",
"removeAllConstraints",
"(",
"@",
"NonNull",
"final",
"Collection",
"<",
"Constraint",
"<",
"CharSequence",
">",
">",
"constraints",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"constraints",
",",
"\"The collection may not be null\"",
")",
";",
"for",
"(",
"Constraint",
"<",
"CharSequence",
">",
"constraint",
":",
"constraints",
")",
"{",
"removeConstraint",
"(",
"constraint",
")",
";",
"}",
"}"
] |
Removes all constraints, which are contained by a specific collection.
@param constraints
A collection, which contains the constraints, which should be removed, as an instance
of the type {@link Collection} or an empty collection, if no constraints should be
removed
|
[
"Removes",
"all",
"constraints",
"which",
"are",
"contained",
"by",
"a",
"specific",
"collection",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L428-L435
|
7,901 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
|
PasswordEditText.removeAllConstraints
|
@SafeVarargs
public final void removeAllConstraints(@NonNull final Constraint<CharSequence>... constraints) {
Condition.INSTANCE.ensureNotNull(constraints, "The array may not be null");
removeAllConstraints(Arrays.asList(constraints));
}
|
java
|
@SafeVarargs
public final void removeAllConstraints(@NonNull final Constraint<CharSequence>... constraints) {
Condition.INSTANCE.ensureNotNull(constraints, "The array may not be null");
removeAllConstraints(Arrays.asList(constraints));
}
|
[
"@",
"SafeVarargs",
"public",
"final",
"void",
"removeAllConstraints",
"(",
"@",
"NonNull",
"final",
"Constraint",
"<",
"CharSequence",
">",
"...",
"constraints",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"constraints",
",",
"\"The array may not be null\"",
")",
";",
"removeAllConstraints",
"(",
"Arrays",
".",
"asList",
"(",
"constraints",
")",
")",
";",
"}"
] |
Removes all constraints, which are contained by a specific array.
@param constraints
An array, which contains the constraints, which should be removed, as an array of the
type {@link Constraint}, or an empty array, if no constraints should be removed
|
[
"Removes",
"all",
"constraints",
"which",
"are",
"contained",
"by",
"a",
"specific",
"array",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L444-L448
|
7,902 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
|
PasswordEditText.addHelperText
|
public final void addHelperText(@NonNull final CharSequence helperText) {
Condition.INSTANCE.ensureNotNull(helperText, "The helper text may not be null");
Condition.INSTANCE.ensureNotEmpty(helperText, "The helper text may not be empty");
if (!helperTexts.contains(helperText)) {
helperTexts.add(helperText);
verifyPasswordStrength();
}
}
|
java
|
public final void addHelperText(@NonNull final CharSequence helperText) {
Condition.INSTANCE.ensureNotNull(helperText, "The helper text may not be null");
Condition.INSTANCE.ensureNotEmpty(helperText, "The helper text may not be empty");
if (!helperTexts.contains(helperText)) {
helperTexts.add(helperText);
verifyPasswordStrength();
}
}
|
[
"public",
"final",
"void",
"addHelperText",
"(",
"@",
"NonNull",
"final",
"CharSequence",
"helperText",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"helperText",
",",
"\"The helper text may not be null\"",
")",
";",
"Condition",
".",
"INSTANCE",
".",
"ensureNotEmpty",
"(",
"helperText",
",",
"\"The helper text may not be empty\"",
")",
";",
"if",
"(",
"!",
"helperTexts",
".",
"contains",
"(",
"helperText",
")",
")",
"{",
"helperTexts",
".",
"add",
"(",
"helperText",
")",
";",
"verifyPasswordStrength",
"(",
")",
";",
"}",
"}"
] |
Adds a new helper text, which should be shown, depending on the password strength. Helper
texts, which have been added later than others, are supposed to indicate a higher password
strength.
@param helperText
The helper text, which should be added, as an instance of the type {@link
CharSequence}. The helper text may neither be null, nor empty
|
[
"Adds",
"a",
"new",
"helper",
"text",
"which",
"should",
"be",
"shown",
"depending",
"on",
"the",
"password",
"strength",
".",
"Helper",
"texts",
"which",
"have",
"been",
"added",
"later",
"than",
"others",
"are",
"supposed",
"to",
"indicate",
"a",
"higher",
"password",
"strength",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L479-L487
|
7,903 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
|
PasswordEditText.addAllHelperTexts
|
public final void addAllHelperTexts(@NonNull final Collection<CharSequence> helperTexts) {
Condition.INSTANCE.ensureNotNull(helperTexts, "The collection may not be null");
for (CharSequence helperText : helperTexts) {
addHelperText(helperText);
}
}
|
java
|
public final void addAllHelperTexts(@NonNull final Collection<CharSequence> helperTexts) {
Condition.INSTANCE.ensureNotNull(helperTexts, "The collection may not be null");
for (CharSequence helperText : helperTexts) {
addHelperText(helperText);
}
}
|
[
"public",
"final",
"void",
"addAllHelperTexts",
"(",
"@",
"NonNull",
"final",
"Collection",
"<",
"CharSequence",
">",
"helperTexts",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"helperTexts",
",",
"\"The collection may not be null\"",
")",
";",
"for",
"(",
"CharSequence",
"helperText",
":",
"helperTexts",
")",
"{",
"addHelperText",
"(",
"helperText",
")",
";",
"}",
"}"
] |
Adds all helper texts, which are contained by a specific collection. The helper texts are
added in the given order.
@param helperTexts
A collection, which contains the helper texts, which should be added, as an instance
of the type {@link Collection} or an empty collection, if no helper texts should be
added
|
[
"Adds",
"all",
"helper",
"texts",
"which",
"are",
"contained",
"by",
"a",
"specific",
"collection",
".",
"The",
"helper",
"texts",
"are",
"added",
"in",
"the",
"given",
"order",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L511-L517
|
7,904 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
|
PasswordEditText.removeHelperText
|
public final void removeHelperText(@NonNull final CharSequence helperText) {
Condition.INSTANCE.ensureNotNull(helperText, "The helper text may not be null");
Condition.INSTANCE.ensureNotEmpty(helperText, "The helper text may not be empty");
helperTexts.remove(helperText);
verifyPasswordStrength();
}
|
java
|
public final void removeHelperText(@NonNull final CharSequence helperText) {
Condition.INSTANCE.ensureNotNull(helperText, "The helper text may not be null");
Condition.INSTANCE.ensureNotEmpty(helperText, "The helper text may not be empty");
helperTexts.remove(helperText);
verifyPasswordStrength();
}
|
[
"public",
"final",
"void",
"removeHelperText",
"(",
"@",
"NonNull",
"final",
"CharSequence",
"helperText",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"helperText",
",",
"\"The helper text may not be null\"",
")",
";",
"Condition",
".",
"INSTANCE",
".",
"ensureNotEmpty",
"(",
"helperText",
",",
"\"The helper text may not be empty\"",
")",
";",
"helperTexts",
".",
"remove",
"(",
"helperText",
")",
";",
"verifyPasswordStrength",
"(",
")",
";",
"}"
] |
Removes a specific helper text, which should not be shown, depending on the password
strength, anymore.
@param helperText
The helper text, which should be removed, as an instance of the type {@link
CharSequence}. The helper text may neither be null, nor empty
|
[
"Removes",
"a",
"specific",
"helper",
"text",
"which",
"should",
"not",
"be",
"shown",
"depending",
"on",
"the",
"password",
"strength",
"anymore",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L574-L579
|
7,905 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
|
PasswordEditText.addHelperTextColor
|
public final void addHelperTextColor(@ColorInt final int color) {
if (!helperTextColors.contains(color)) {
helperTextColors.add(color);
verifyPasswordStrength();
}
}
|
java
|
public final void addHelperTextColor(@ColorInt final int color) {
if (!helperTextColors.contains(color)) {
helperTextColors.add(color);
verifyPasswordStrength();
}
}
|
[
"public",
"final",
"void",
"addHelperTextColor",
"(",
"@",
"ColorInt",
"final",
"int",
"color",
")",
"{",
"if",
"(",
"!",
"helperTextColors",
".",
"contains",
"(",
"color",
")",
")",
"{",
"helperTextColors",
".",
"add",
"(",
"color",
")",
";",
"verifyPasswordStrength",
"(",
")",
";",
"}",
"}"
] |
Adds a new helper text color, which should be used to highlight the helper text, which
indicates the password strength.
@param color
The color, which should be added, as an {@link Integer} value
|
[
"Adds",
"a",
"new",
"helper",
"text",
"color",
"which",
"should",
"be",
"used",
"to",
"highlight",
"the",
"helper",
"text",
"which",
"indicates",
"the",
"password",
"strength",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L680-L685
|
7,906 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/PasswordEditText.java
|
PasswordEditText.removeHelperTextColor
|
public final void removeHelperTextColor(@ColorInt final int color) {
int index = helperTextColors.indexOf(color);
if (index != -1) {
helperTextColors.remove(index);
verifyPasswordStrength();
}
}
|
java
|
public final void removeHelperTextColor(@ColorInt final int color) {
int index = helperTextColors.indexOf(color);
if (index != -1) {
helperTextColors.remove(index);
verifyPasswordStrength();
}
}
|
[
"public",
"final",
"void",
"removeHelperTextColor",
"(",
"@",
"ColorInt",
"final",
"int",
"color",
")",
"{",
"int",
"index",
"=",
"helperTextColors",
".",
"indexOf",
"(",
"color",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"helperTextColors",
".",
"remove",
"(",
"index",
")",
";",
"verifyPasswordStrength",
"(",
")",
";",
"}",
"}"
] |
Removes a specific helper text color, which should not be used to highlight the helper text,
which indicates the password strength, anymore.
@param color
The color, which should be removed, as an {@link Integer} value
|
[
"Removes",
"a",
"specific",
"helper",
"text",
"color",
"which",
"should",
"not",
"be",
"used",
"to",
"highlight",
"the",
"helper",
"text",
"which",
"indicates",
"the",
"password",
"strength",
"anymore",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/PasswordEditText.java#L767-L774
|
7,907 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
|
JDBCStorableGenerator.isAlwaysInserted
|
private boolean isAlwaysInserted(JDBCStorableProperty<?> property) {
return property.isVersion() ? (mVersioning == Versioning.AUTO) : !property.isAutomatic();
}
|
java
|
private boolean isAlwaysInserted(JDBCStorableProperty<?> property) {
return property.isVersion() ? (mVersioning == Versioning.AUTO) : !property.isAutomatic();
}
|
[
"private",
"boolean",
"isAlwaysInserted",
"(",
"JDBCStorableProperty",
"<",
"?",
">",
"property",
")",
"{",
"return",
"property",
".",
"isVersion",
"(",
")",
"?",
"(",
"mVersioning",
"==",
"Versioning",
".",
"AUTO",
")",
":",
"!",
"property",
".",
"isAutomatic",
"(",
")",
";",
"}"
] |
Returns true if property value is always part of insert statement.
|
[
"Returns",
"true",
"if",
"property",
"value",
"is",
"always",
"part",
"of",
"insert",
"statement",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java#L1298-L1300
|
7,908 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
|
JDBCStorableGenerator.findLobs
|
private Map<JDBCStorableProperty<S>, Integer> findLobs() {
Map<JDBCStorableProperty<S>, Integer> lobIndexMap =
new IdentityHashMap<JDBCStorableProperty<S>, Integer>();
int lobIndex = 0;
for (JDBCStorableProperty<S> property : mAllProperties.values()) {
if (isLobType(property)) {
lobIndexMap.put(property, lobIndex++);
}
}
return lobIndexMap;
}
|
java
|
private Map<JDBCStorableProperty<S>, Integer> findLobs() {
Map<JDBCStorableProperty<S>, Integer> lobIndexMap =
new IdentityHashMap<JDBCStorableProperty<S>, Integer>();
int lobIndex = 0;
for (JDBCStorableProperty<S> property : mAllProperties.values()) {
if (isLobType(property)) {
lobIndexMap.put(property, lobIndex++);
}
}
return lobIndexMap;
}
|
[
"private",
"Map",
"<",
"JDBCStorableProperty",
"<",
"S",
">",
",",
"Integer",
">",
"findLobs",
"(",
")",
"{",
"Map",
"<",
"JDBCStorableProperty",
"<",
"S",
">",
",",
"Integer",
">",
"lobIndexMap",
"=",
"new",
"IdentityHashMap",
"<",
"JDBCStorableProperty",
"<",
"S",
">",
",",
"Integer",
">",
"(",
")",
";",
"int",
"lobIndex",
"=",
"0",
";",
"for",
"(",
"JDBCStorableProperty",
"<",
"S",
">",
"property",
":",
"mAllProperties",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"isLobType",
"(",
"property",
")",
")",
"{",
"lobIndexMap",
".",
"put",
"(",
"property",
",",
"lobIndex",
"++",
")",
";",
"}",
"}",
"return",
"lobIndexMap",
";",
"}"
] |
Finds all Lob properties and maps them to a zero-based index. This
information is used to update large Lobs after an insert or update.
|
[
"Finds",
"all",
"Lob",
"properties",
"and",
"maps",
"them",
"to",
"a",
"zero",
"-",
"based",
"index",
".",
"This",
"information",
"is",
"used",
"to",
"update",
"large",
"Lobs",
"after",
"an",
"insert",
"or",
"update",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java#L1306-L1319
|
7,909 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
|
JDBCStorableGenerator.getJDBCSupport
|
private LocalVariable getJDBCSupport(CodeBuilder b) {
pushJDBCSupport(b);
LocalVariable supportVar =
b.createLocalVariable("support", TypeDesc.forClass(JDBCSupport.class));
b.storeLocal(supportVar);
return supportVar;
}
|
java
|
private LocalVariable getJDBCSupport(CodeBuilder b) {
pushJDBCSupport(b);
LocalVariable supportVar =
b.createLocalVariable("support", TypeDesc.forClass(JDBCSupport.class));
b.storeLocal(supportVar);
return supportVar;
}
|
[
"private",
"LocalVariable",
"getJDBCSupport",
"(",
"CodeBuilder",
"b",
")",
"{",
"pushJDBCSupport",
"(",
"b",
")",
";",
"LocalVariable",
"supportVar",
"=",
"b",
".",
"createLocalVariable",
"(",
"\"support\"",
",",
"TypeDesc",
".",
"forClass",
"(",
"JDBCSupport",
".",
"class",
")",
")",
";",
"b",
".",
"storeLocal",
"(",
"supportVar",
")",
";",
"return",
"supportVar",
";",
"}"
] |
Generates code to get the JDBCSupport instance and store it in a local
variable.
|
[
"Generates",
"code",
"to",
"get",
"the",
"JDBCSupport",
"instance",
"and",
"store",
"it",
"in",
"a",
"local",
"variable",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java#L1340-L1346
|
7,910 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
|
JDBCStorableGenerator.pushJDBCSupport
|
private void pushJDBCSupport(CodeBuilder b) {
b.loadThis();
b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, TypeDesc.forClass(TriggerSupport.class));
b.checkCast(TypeDesc.forClass(JDBCSupport.class));
}
|
java
|
private void pushJDBCSupport(CodeBuilder b) {
b.loadThis();
b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, TypeDesc.forClass(TriggerSupport.class));
b.checkCast(TypeDesc.forClass(JDBCSupport.class));
}
|
[
"private",
"void",
"pushJDBCSupport",
"(",
"CodeBuilder",
"b",
")",
"{",
"b",
".",
"loadThis",
"(",
")",
";",
"b",
".",
"loadField",
"(",
"StorableGenerator",
".",
"SUPPORT_FIELD_NAME",
",",
"TypeDesc",
".",
"forClass",
"(",
"TriggerSupport",
".",
"class",
")",
")",
";",
"b",
".",
"checkCast",
"(",
"TypeDesc",
".",
"forClass",
"(",
"JDBCSupport",
".",
"class",
")",
")",
";",
"}"
] |
Generates code to push the JDBCSupport instance on the stack.
|
[
"Generates",
"code",
"to",
"push",
"the",
"JDBCSupport",
"instance",
"on",
"the",
"stack",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java#L1351-L1355
|
7,911 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
|
JDBCStorableGenerator.getConnection
|
private LocalVariable getConnection(CodeBuilder b, LocalVariable capVar) {
b.loadLocal(capVar);
b.invokeInterface(TypeDesc.forClass(JDBCConnectionCapability.class),
"getConnection", TypeDesc.forClass(Connection.class), null);
LocalVariable conVar = b.createLocalVariable("con", TypeDesc.forClass(Connection.class));
b.storeLocal(conVar);
return conVar;
}
|
java
|
private LocalVariable getConnection(CodeBuilder b, LocalVariable capVar) {
b.loadLocal(capVar);
b.invokeInterface(TypeDesc.forClass(JDBCConnectionCapability.class),
"getConnection", TypeDesc.forClass(Connection.class), null);
LocalVariable conVar = b.createLocalVariable("con", TypeDesc.forClass(Connection.class));
b.storeLocal(conVar);
return conVar;
}
|
[
"private",
"LocalVariable",
"getConnection",
"(",
"CodeBuilder",
"b",
",",
"LocalVariable",
"capVar",
")",
"{",
"b",
".",
"loadLocal",
"(",
"capVar",
")",
";",
"b",
".",
"invokeInterface",
"(",
"TypeDesc",
".",
"forClass",
"(",
"JDBCConnectionCapability",
".",
"class",
")",
",",
"\"getConnection\"",
",",
"TypeDesc",
".",
"forClass",
"(",
"Connection",
".",
"class",
")",
",",
"null",
")",
";",
"LocalVariable",
"conVar",
"=",
"b",
".",
"createLocalVariable",
"(",
"\"con\"",
",",
"TypeDesc",
".",
"forClass",
"(",
"Connection",
".",
"class",
")",
")",
";",
"b",
".",
"storeLocal",
"(",
"conVar",
")",
";",
"return",
"conVar",
";",
"}"
] |
Generates code to get connection from JDBCConnectionCapability and store
it in a local variable.
@param capVar reference to JDBCConnectionCapability
|
[
"Generates",
"code",
"to",
"get",
"connection",
"from",
"JDBCConnectionCapability",
"and",
"store",
"it",
"in",
"a",
"local",
"variable",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java#L1363-L1370
|
7,912 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
|
JDBCStorableGenerator.branchIfDirty
|
private void branchIfDirty(CodeBuilder b, int propNumber,
Label target, boolean branchIfDirty)
{
String stateFieldName = StorableGenerator.PROPERTY_STATE_FIELD_NAME + (propNumber >> 4);
b.loadThis();
b.loadField(stateFieldName, TypeDesc.INT);
int shift = (propNumber & 0xf) * 2;
b.loadConstant(StorableGenerator.PROPERTY_STATE_MASK << shift);
b.math(Opcode.IAND);
b.loadConstant(StorableGenerator.PROPERTY_STATE_DIRTY << shift);
b.ifComparisonBranch(target, branchIfDirty ? "==" : "!=");
}
|
java
|
private void branchIfDirty(CodeBuilder b, int propNumber,
Label target, boolean branchIfDirty)
{
String stateFieldName = StorableGenerator.PROPERTY_STATE_FIELD_NAME + (propNumber >> 4);
b.loadThis();
b.loadField(stateFieldName, TypeDesc.INT);
int shift = (propNumber & 0xf) * 2;
b.loadConstant(StorableGenerator.PROPERTY_STATE_MASK << shift);
b.math(Opcode.IAND);
b.loadConstant(StorableGenerator.PROPERTY_STATE_DIRTY << shift);
b.ifComparisonBranch(target, branchIfDirty ? "==" : "!=");
}
|
[
"private",
"void",
"branchIfDirty",
"(",
"CodeBuilder",
"b",
",",
"int",
"propNumber",
",",
"Label",
"target",
",",
"boolean",
"branchIfDirty",
")",
"{",
"String",
"stateFieldName",
"=",
"StorableGenerator",
".",
"PROPERTY_STATE_FIELD_NAME",
"+",
"(",
"propNumber",
">>",
"4",
")",
";",
"b",
".",
"loadThis",
"(",
")",
";",
"b",
".",
"loadField",
"(",
"stateFieldName",
",",
"TypeDesc",
".",
"INT",
")",
";",
"int",
"shift",
"=",
"(",
"propNumber",
"&",
"0xf",
")",
"*",
"2",
";",
"b",
".",
"loadConstant",
"(",
"StorableGenerator",
".",
"PROPERTY_STATE_MASK",
"<<",
"shift",
")",
";",
"b",
".",
"math",
"(",
"Opcode",
".",
"IAND",
")",
";",
"b",
".",
"loadConstant",
"(",
"StorableGenerator",
".",
"PROPERTY_STATE_DIRTY",
"<<",
"shift",
")",
";",
"b",
".",
"ifComparisonBranch",
"(",
"target",
",",
"branchIfDirty",
"?",
"\"==\"",
":",
"\"!=\"",
")",
";",
"}"
] |
Generates code to branch if a property is dirty.
@param propNumber property number from all properties map
@param target branch target
@param when true, branch if dirty; when false, branch when not dirty
|
[
"Generates",
"code",
"to",
"branch",
"if",
"a",
"property",
"is",
"dirty",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java#L1940-L1953
|
7,913 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/QueryExecutorCache.java
|
QueryExecutorCache.executor
|
public QueryExecutor<S> executor(Filter<S> filter, OrderingList<S> ordering, QueryHints hints)
throws RepositoryException
{
final Key<S> key = new Key<S>(filter, ordering, hints);
synchronized (mPrimaryCache) {
QueryExecutor<S> executor = mPrimaryCache.get(key);
if (executor != null) {
return executor;
}
}
// Fallback to second level cache, which may still have the executor because
// garbage collection has not reclaimed it yet. It also allows some concurrent
// executor creation, by using filter-specific locks.
SoftValuedCache<Object, QueryExecutor<S>> cache;
synchronized (mFilterToExecutor) {
cache = mFilterToExecutor.get(filter);
if (cache == null) {
cache = SoftValuedCache.newCache(7);
mFilterToExecutor.put(filter, cache);
}
}
Object subKey;
if (hints == null || hints.isEmpty()) {
subKey = ordering;
} else {
// Don't construct key with filter. It is not needed here and it would prevent
// garbage collection of filters.
subKey = new Key(null, ordering, hints);
}
QueryExecutor<S> executor;
synchronized (cache) {
executor = cache.get(subKey);
if (executor == null) {
executor = mFactory.executor(filter, ordering, hints);
cache.put(subKey, executor);
}
}
synchronized (mPrimaryCache) {
mPrimaryCache.put(key, executor);
}
return executor;
}
|
java
|
public QueryExecutor<S> executor(Filter<S> filter, OrderingList<S> ordering, QueryHints hints)
throws RepositoryException
{
final Key<S> key = new Key<S>(filter, ordering, hints);
synchronized (mPrimaryCache) {
QueryExecutor<S> executor = mPrimaryCache.get(key);
if (executor != null) {
return executor;
}
}
// Fallback to second level cache, which may still have the executor because
// garbage collection has not reclaimed it yet. It also allows some concurrent
// executor creation, by using filter-specific locks.
SoftValuedCache<Object, QueryExecutor<S>> cache;
synchronized (mFilterToExecutor) {
cache = mFilterToExecutor.get(filter);
if (cache == null) {
cache = SoftValuedCache.newCache(7);
mFilterToExecutor.put(filter, cache);
}
}
Object subKey;
if (hints == null || hints.isEmpty()) {
subKey = ordering;
} else {
// Don't construct key with filter. It is not needed here and it would prevent
// garbage collection of filters.
subKey = new Key(null, ordering, hints);
}
QueryExecutor<S> executor;
synchronized (cache) {
executor = cache.get(subKey);
if (executor == null) {
executor = mFactory.executor(filter, ordering, hints);
cache.put(subKey, executor);
}
}
synchronized (mPrimaryCache) {
mPrimaryCache.put(key, executor);
}
return executor;
}
|
[
"public",
"QueryExecutor",
"<",
"S",
">",
"executor",
"(",
"Filter",
"<",
"S",
">",
"filter",
",",
"OrderingList",
"<",
"S",
">",
"ordering",
",",
"QueryHints",
"hints",
")",
"throws",
"RepositoryException",
"{",
"final",
"Key",
"<",
"S",
">",
"key",
"=",
"new",
"Key",
"<",
"S",
">",
"(",
"filter",
",",
"ordering",
",",
"hints",
")",
";",
"synchronized",
"(",
"mPrimaryCache",
")",
"{",
"QueryExecutor",
"<",
"S",
">",
"executor",
"=",
"mPrimaryCache",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"executor",
"!=",
"null",
")",
"{",
"return",
"executor",
";",
"}",
"}",
"// Fallback to second level cache, which may still have the executor because\r",
"// garbage collection has not reclaimed it yet. It also allows some concurrent\r",
"// executor creation, by using filter-specific locks.\r",
"SoftValuedCache",
"<",
"Object",
",",
"QueryExecutor",
"<",
"S",
">",
">",
"cache",
";",
"synchronized",
"(",
"mFilterToExecutor",
")",
"{",
"cache",
"=",
"mFilterToExecutor",
".",
"get",
"(",
"filter",
")",
";",
"if",
"(",
"cache",
"==",
"null",
")",
"{",
"cache",
"=",
"SoftValuedCache",
".",
"newCache",
"(",
"7",
")",
";",
"mFilterToExecutor",
".",
"put",
"(",
"filter",
",",
"cache",
")",
";",
"}",
"}",
"Object",
"subKey",
";",
"if",
"(",
"hints",
"==",
"null",
"||",
"hints",
".",
"isEmpty",
"(",
")",
")",
"{",
"subKey",
"=",
"ordering",
";",
"}",
"else",
"{",
"// Don't construct key with filter. It is not needed here and it would prevent\r",
"// garbage collection of filters.\r",
"subKey",
"=",
"new",
"Key",
"(",
"null",
",",
"ordering",
",",
"hints",
")",
";",
"}",
"QueryExecutor",
"<",
"S",
">",
"executor",
";",
"synchronized",
"(",
"cache",
")",
"{",
"executor",
"=",
"cache",
".",
"get",
"(",
"subKey",
")",
";",
"if",
"(",
"executor",
"==",
"null",
")",
"{",
"executor",
"=",
"mFactory",
".",
"executor",
"(",
"filter",
",",
"ordering",
",",
"hints",
")",
";",
"cache",
".",
"put",
"(",
"subKey",
",",
"executor",
")",
";",
"}",
"}",
"synchronized",
"(",
"mPrimaryCache",
")",
"{",
"mPrimaryCache",
".",
"put",
"(",
"key",
",",
"executor",
")",
";",
"}",
"return",
"executor",
";",
"}"
] |
Returns an executor from the cache.
@param filter optional filter
@param ordering optional order-by properties
@param hints optional query hints
|
[
"Returns",
"an",
"executor",
"from",
"the",
"cache",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/QueryExecutorCache.java#L92-L140
|
7,914 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java
|
IndexedRepository.getIndexInfo
|
public <S extends Storable> IndexInfo[] getIndexInfo(Class<S> storableType)
throws RepositoryException
{
if (Unindexed.class.isAssignableFrom(storableType)) {
return new IndexInfo[0];
}
Storage<S> masterStorage = mRepository.storageFor(storableType);
IndexAnalysis<S> analysis = mIndexAnalysisPool.get(masterStorage);
IndexInfo[] infos = new IndexInfo[analysis.allIndexInfoMap.size()];
return analysis.allIndexInfoMap.values().toArray(infos);
}
|
java
|
public <S extends Storable> IndexInfo[] getIndexInfo(Class<S> storableType)
throws RepositoryException
{
if (Unindexed.class.isAssignableFrom(storableType)) {
return new IndexInfo[0];
}
Storage<S> masterStorage = mRepository.storageFor(storableType);
IndexAnalysis<S> analysis = mIndexAnalysisPool.get(masterStorage);
IndexInfo[] infos = new IndexInfo[analysis.allIndexInfoMap.size()];
return analysis.allIndexInfoMap.values().toArray(infos);
}
|
[
"public",
"<",
"S",
"extends",
"Storable",
">",
"IndexInfo",
"[",
"]",
"getIndexInfo",
"(",
"Class",
"<",
"S",
">",
"storableType",
")",
"throws",
"RepositoryException",
"{",
"if",
"(",
"Unindexed",
".",
"class",
".",
"isAssignableFrom",
"(",
"storableType",
")",
")",
"{",
"return",
"new",
"IndexInfo",
"[",
"0",
"]",
";",
"}",
"Storage",
"<",
"S",
">",
"masterStorage",
"=",
"mRepository",
".",
"storageFor",
"(",
"storableType",
")",
";",
"IndexAnalysis",
"<",
"S",
">",
"analysis",
"=",
"mIndexAnalysisPool",
".",
"get",
"(",
"masterStorage",
")",
";",
"IndexInfo",
"[",
"]",
"infos",
"=",
"new",
"IndexInfo",
"[",
"analysis",
".",
"allIndexInfoMap",
".",
"size",
"(",
")",
"]",
";",
"return",
"analysis",
".",
"allIndexInfoMap",
".",
"values",
"(",
")",
".",
"toArray",
"(",
"infos",
")",
";",
"}"
] |
Required by IndexInfoCapability.
|
[
"Required",
"by",
"IndexInfoCapability",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java#L161-L173
|
7,915 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java
|
IndexedRepository.getIndexEntryAccessors
|
public <S extends Storable> IndexEntryAccessor<S>[]
getIndexEntryAccessors(Class<S> storableType)
throws RepositoryException
{
if (Unindexed.class.isAssignableFrom(storableType)) {
return new IndexEntryAccessor[0];
}
Storage<S> masterStorage = mRepository.storageFor(storableType);
IndexAnalysis<S> analysis = mIndexAnalysisPool.get(masterStorage);
List<IndexEntryAccessor<S>> accessors =
new ArrayList<IndexEntryAccessor<S>>(analysis.allIndexInfoMap.size());
for (IndexInfo info : analysis.allIndexInfoMap.values()) {
if (info instanceof IndexEntryAccessor) {
accessors.add((IndexEntryAccessor<S>) info);
}
}
return accessors.toArray(new IndexEntryAccessor[accessors.size()]);
}
|
java
|
public <S extends Storable> IndexEntryAccessor<S>[]
getIndexEntryAccessors(Class<S> storableType)
throws RepositoryException
{
if (Unindexed.class.isAssignableFrom(storableType)) {
return new IndexEntryAccessor[0];
}
Storage<S> masterStorage = mRepository.storageFor(storableType);
IndexAnalysis<S> analysis = mIndexAnalysisPool.get(masterStorage);
List<IndexEntryAccessor<S>> accessors =
new ArrayList<IndexEntryAccessor<S>>(analysis.allIndexInfoMap.size());
for (IndexInfo info : analysis.allIndexInfoMap.values()) {
if (info instanceof IndexEntryAccessor) {
accessors.add((IndexEntryAccessor<S>) info);
}
}
return accessors.toArray(new IndexEntryAccessor[accessors.size()]);
}
|
[
"public",
"<",
"S",
"extends",
"Storable",
">",
"IndexEntryAccessor",
"<",
"S",
">",
"[",
"]",
"getIndexEntryAccessors",
"(",
"Class",
"<",
"S",
">",
"storableType",
")",
"throws",
"RepositoryException",
"{",
"if",
"(",
"Unindexed",
".",
"class",
".",
"isAssignableFrom",
"(",
"storableType",
")",
")",
"{",
"return",
"new",
"IndexEntryAccessor",
"[",
"0",
"]",
";",
"}",
"Storage",
"<",
"S",
">",
"masterStorage",
"=",
"mRepository",
".",
"storageFor",
"(",
"storableType",
")",
";",
"IndexAnalysis",
"<",
"S",
">",
"analysis",
"=",
"mIndexAnalysisPool",
".",
"get",
"(",
"masterStorage",
")",
";",
"List",
"<",
"IndexEntryAccessor",
"<",
"S",
">",
">",
"accessors",
"=",
"new",
"ArrayList",
"<",
"IndexEntryAccessor",
"<",
"S",
">",
">",
"(",
"analysis",
".",
"allIndexInfoMap",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"IndexInfo",
"info",
":",
"analysis",
".",
"allIndexInfoMap",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"info",
"instanceof",
"IndexEntryAccessor",
")",
"{",
"accessors",
".",
"add",
"(",
"(",
"IndexEntryAccessor",
"<",
"S",
">",
")",
"info",
")",
";",
"}",
"}",
"return",
"accessors",
".",
"toArray",
"(",
"new",
"IndexEntryAccessor",
"[",
"accessors",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Required by IndexEntryAccessCapability.
|
[
"Required",
"by",
"IndexEntryAccessCapability",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java#L176-L195
|
7,916 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/MalformedTypeException.java
|
MalformedTypeException.getMessage
|
@Override
public String getMessage() {
String message = super.getMessage();
if (mType != null) {
message = mType.getName() + ": " + message;
}
return message;
}
|
java
|
@Override
public String getMessage() {
String message = super.getMessage();
if (mType != null) {
message = mType.getName() + ": " + message;
}
return message;
}
|
[
"@",
"Override",
"public",
"String",
"getMessage",
"(",
")",
"{",
"String",
"message",
"=",
"super",
".",
"getMessage",
"(",
")",
";",
"if",
"(",
"mType",
"!=",
"null",
")",
"{",
"message",
"=",
"mType",
".",
"getName",
"(",
")",
"+",
"\": \"",
"+",
"message",
";",
"}",
"return",
"message",
";",
"}"
] |
Returns first message, prefixed with the malformed type.
|
[
"Returns",
"first",
"message",
"prefixed",
"with",
"the",
"malformed",
"type",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/MalformedTypeException.java#L53-L60
|
7,917 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java
|
UnionQueryAnalyzer.executor
|
public QueryExecutor<S> executor(Filter<S> filter, OrderingList<S> ordering, QueryHints hints)
throws RepositoryException
{
return analyze(filter, ordering, hints).createExecutor();
}
|
java
|
public QueryExecutor<S> executor(Filter<S> filter, OrderingList<S> ordering, QueryHints hints)
throws RepositoryException
{
return analyze(filter, ordering, hints).createExecutor();
}
|
[
"public",
"QueryExecutor",
"<",
"S",
">",
"executor",
"(",
"Filter",
"<",
"S",
">",
"filter",
",",
"OrderingList",
"<",
"S",
">",
"ordering",
",",
"QueryHints",
"hints",
")",
"throws",
"RepositoryException",
"{",
"return",
"analyze",
"(",
"filter",
",",
"ordering",
",",
"hints",
")",
".",
"createExecutor",
"(",
")",
";",
"}"
] |
Returns an executor that handles the given query specification.
@param filter optional filter which must be {@link Filter#isBound bound}
@param ordering optional properties which define desired ordering
@param hints optional query hints
|
[
"Returns",
"an",
"executor",
"that",
"handles",
"the",
"given",
"query",
"specification",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java#L106-L110
|
7,918 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java
|
UnionQueryAnalyzer.getKeys
|
private List<Set<ChainedProperty<S>>> getKeys()
throws SupportException, RepositoryException
{
StorableInfo<S> info = StorableIntrospector.examine(mIndexAnalyzer.getStorableType());
List<Set<ChainedProperty<S>>> keys = new ArrayList<Set<ChainedProperty<S>>>();
keys.add(stripOrdering(info.getPrimaryKey().getProperties()));
for (StorableKey<S> altKey : info.getAlternateKeys()) {
keys.add(stripOrdering(altKey.getProperties()));
}
// Also fold in all unique indexes, just in case they weren't reported
// as actual keys.
Collection<StorableIndex<S>> indexes =
mRepoAccess.storageAccessFor(getStorableType()).getAllIndexes();
for (StorableIndex<S> index : indexes) {
if (!index.isUnique()) {
continue;
}
int propCount = index.getPropertyCount();
Set<ChainedProperty<S>> props = new LinkedHashSet<ChainedProperty<S>>(propCount);
for (int i=0; i<propCount; i++) {
props.add(index.getOrderedProperty(i).getChainedProperty());
}
keys.add(props);
}
return keys;
}
|
java
|
private List<Set<ChainedProperty<S>>> getKeys()
throws SupportException, RepositoryException
{
StorableInfo<S> info = StorableIntrospector.examine(mIndexAnalyzer.getStorableType());
List<Set<ChainedProperty<S>>> keys = new ArrayList<Set<ChainedProperty<S>>>();
keys.add(stripOrdering(info.getPrimaryKey().getProperties()));
for (StorableKey<S> altKey : info.getAlternateKeys()) {
keys.add(stripOrdering(altKey.getProperties()));
}
// Also fold in all unique indexes, just in case they weren't reported
// as actual keys.
Collection<StorableIndex<S>> indexes =
mRepoAccess.storageAccessFor(getStorableType()).getAllIndexes();
for (StorableIndex<S> index : indexes) {
if (!index.isUnique()) {
continue;
}
int propCount = index.getPropertyCount();
Set<ChainedProperty<S>> props = new LinkedHashSet<ChainedProperty<S>>(propCount);
for (int i=0; i<propCount; i++) {
props.add(index.getOrderedProperty(i).getChainedProperty());
}
keys.add(props);
}
return keys;
}
|
[
"private",
"List",
"<",
"Set",
"<",
"ChainedProperty",
"<",
"S",
">",
">",
">",
"getKeys",
"(",
")",
"throws",
"SupportException",
",",
"RepositoryException",
"{",
"StorableInfo",
"<",
"S",
">",
"info",
"=",
"StorableIntrospector",
".",
"examine",
"(",
"mIndexAnalyzer",
".",
"getStorableType",
"(",
")",
")",
";",
"List",
"<",
"Set",
"<",
"ChainedProperty",
"<",
"S",
">",
">",
">",
"keys",
"=",
"new",
"ArrayList",
"<",
"Set",
"<",
"ChainedProperty",
"<",
"S",
">",
">",
">",
"(",
")",
";",
"keys",
".",
"add",
"(",
"stripOrdering",
"(",
"info",
".",
"getPrimaryKey",
"(",
")",
".",
"getProperties",
"(",
")",
")",
")",
";",
"for",
"(",
"StorableKey",
"<",
"S",
">",
"altKey",
":",
"info",
".",
"getAlternateKeys",
"(",
")",
")",
"{",
"keys",
".",
"add",
"(",
"stripOrdering",
"(",
"altKey",
".",
"getProperties",
"(",
")",
")",
")",
";",
"}",
"// Also fold in all unique indexes, just in case they weren't reported\r",
"// as actual keys.\r",
"Collection",
"<",
"StorableIndex",
"<",
"S",
">",
">",
"indexes",
"=",
"mRepoAccess",
".",
"storageAccessFor",
"(",
"getStorableType",
"(",
")",
")",
".",
"getAllIndexes",
"(",
")",
";",
"for",
"(",
"StorableIndex",
"<",
"S",
">",
"index",
":",
"indexes",
")",
"{",
"if",
"(",
"!",
"index",
".",
"isUnique",
"(",
")",
")",
"{",
"continue",
";",
"}",
"int",
"propCount",
"=",
"index",
".",
"getPropertyCount",
"(",
")",
";",
"Set",
"<",
"ChainedProperty",
"<",
"S",
">",
">",
"props",
"=",
"new",
"LinkedHashSet",
"<",
"ChainedProperty",
"<",
"S",
">",
">",
"(",
"propCount",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"propCount",
";",
"i",
"++",
")",
"{",
"props",
".",
"add",
"(",
"index",
".",
"getOrderedProperty",
"(",
"i",
")",
".",
"getChainedProperty",
"(",
")",
")",
";",
"}",
"keys",
".",
"add",
"(",
"props",
")",
";",
"}",
"return",
"keys",
";",
"}"
] |
Returns a list of all primary and alternate keys, stripped of ordering.
|
[
"Returns",
"a",
"list",
"of",
"all",
"primary",
"and",
"alternate",
"keys",
"stripped",
"of",
"ordering",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java#L259-L292
|
7,919 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java
|
UnionQueryAnalyzer.pruneKeys
|
private boolean pruneKeys(List<Set<ChainedProperty<S>>> keys, ChainedProperty<S> property) {
boolean result = false;
for (Set<ChainedProperty<S>> key : keys) {
key.remove(property);
if (key.size() == 0) {
result = true;
continue;
}
}
return result;
}
|
java
|
private boolean pruneKeys(List<Set<ChainedProperty<S>>> keys, ChainedProperty<S> property) {
boolean result = false;
for (Set<ChainedProperty<S>> key : keys) {
key.remove(property);
if (key.size() == 0) {
result = true;
continue;
}
}
return result;
}
|
[
"private",
"boolean",
"pruneKeys",
"(",
"List",
"<",
"Set",
"<",
"ChainedProperty",
"<",
"S",
">",
">",
">",
"keys",
",",
"ChainedProperty",
"<",
"S",
">",
"property",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"for",
"(",
"Set",
"<",
"ChainedProperty",
"<",
"S",
">",
">",
"key",
":",
"keys",
")",
"{",
"key",
".",
"remove",
"(",
"property",
")",
";",
"if",
"(",
"key",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"result",
"=",
"true",
";",
"continue",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Removes the given property from all keys, returning true if any key has
zero properties as a result.
|
[
"Removes",
"the",
"given",
"property",
"from",
"all",
"keys",
"returning",
"true",
"if",
"any",
"key",
"has",
"zero",
"properties",
"as",
"a",
"result",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java#L306-L318
|
7,920 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java
|
UnionQueryAnalyzer.splitIntoSubResults
|
private List<IndexedQueryAnalyzer<S>.Result>
splitIntoSubResults(Filter<S> filter, OrderingList<S> ordering, QueryHints hints)
throws SupportException, RepositoryException
{
// Required for split to work.
Filter<S> dnfFilter = filter.disjunctiveNormalForm();
Splitter splitter = new Splitter(ordering, hints);
RepositoryException e = dnfFilter.accept(splitter, null);
if (e != null) {
throw e;
}
List<IndexedQueryAnalyzer<S>.Result> subResults = splitter.mSubResults;
// Check if any sub-result handles nothing. If so, a full scan is the
// best option for the entire query and all sub-results merge into a
// single sub-result. Any sub-results which filter anything and contain
// a join property in the filter are exempt from the merge. This is
// because fewer joins are read than if a full scan is performed for
// the entire query. The resulting union has both a full scan and an
// index scan.
IndexedQueryAnalyzer<S>.Result full = null;
for (IndexedQueryAnalyzer<S>.Result result : subResults) {
if (!result.handlesAnything()) {
full = result;
break;
}
if (!result.getCompositeScore().getFilteringScore().hasAnyMatches()) {
if (full == null) {
// This index is used only for its ordering, and it will be
// tentatively selected as the "full scan". If a result is
// found doesn't use an index for anything, then it becomes
// the "full scan" index.
full = result;
}
}
}
if (full == null) {
// Okay, no full scan needed.
return subResults;
}
List<IndexedQueryAnalyzer<S>.Result> mergedResults =
new ArrayList<IndexedQueryAnalyzer<S>.Result>();
for (IndexedQueryAnalyzer<S>.Result result : subResults) {
if (result == full) {
// Add after everything has been merged into it.
continue;
}
boolean exempt = result.getCompositeScore().getFilteringScore().hasAnyMatches();
if (exempt) {
// Must also have a join in the filter to be exempt.
List<PropertyFilter<S>> subFilters = PropertyFilterList.get(result.getFilter());
joinCheck: {
for (PropertyFilter<S> subFilter : subFilters) {
if (subFilter.getChainedProperty().getChainCount() > 0) {
// A chain implies a join was followed, so result is exempt.
break joinCheck;
}
}
// No joins found, result is not exempt from merging into full scan.
exempt = false;
}
}
if (exempt) {
mergedResults.add(result);
} else {
full = full.mergeRemainderFilter(result.getFilter());
}
}
if (mergedResults.size() == 0) {
// Nothing was exempt. Rather than return a result with a dnf
// filter, return full scan with a simpler reduced filter.
full = full.withRemainderFilter(filter.reduce());
}
mergedResults.add(full);
return mergedResults;
}
|
java
|
private List<IndexedQueryAnalyzer<S>.Result>
splitIntoSubResults(Filter<S> filter, OrderingList<S> ordering, QueryHints hints)
throws SupportException, RepositoryException
{
// Required for split to work.
Filter<S> dnfFilter = filter.disjunctiveNormalForm();
Splitter splitter = new Splitter(ordering, hints);
RepositoryException e = dnfFilter.accept(splitter, null);
if (e != null) {
throw e;
}
List<IndexedQueryAnalyzer<S>.Result> subResults = splitter.mSubResults;
// Check if any sub-result handles nothing. If so, a full scan is the
// best option for the entire query and all sub-results merge into a
// single sub-result. Any sub-results which filter anything and contain
// a join property in the filter are exempt from the merge. This is
// because fewer joins are read than if a full scan is performed for
// the entire query. The resulting union has both a full scan and an
// index scan.
IndexedQueryAnalyzer<S>.Result full = null;
for (IndexedQueryAnalyzer<S>.Result result : subResults) {
if (!result.handlesAnything()) {
full = result;
break;
}
if (!result.getCompositeScore().getFilteringScore().hasAnyMatches()) {
if (full == null) {
// This index is used only for its ordering, and it will be
// tentatively selected as the "full scan". If a result is
// found doesn't use an index for anything, then it becomes
// the "full scan" index.
full = result;
}
}
}
if (full == null) {
// Okay, no full scan needed.
return subResults;
}
List<IndexedQueryAnalyzer<S>.Result> mergedResults =
new ArrayList<IndexedQueryAnalyzer<S>.Result>();
for (IndexedQueryAnalyzer<S>.Result result : subResults) {
if (result == full) {
// Add after everything has been merged into it.
continue;
}
boolean exempt = result.getCompositeScore().getFilteringScore().hasAnyMatches();
if (exempt) {
// Must also have a join in the filter to be exempt.
List<PropertyFilter<S>> subFilters = PropertyFilterList.get(result.getFilter());
joinCheck: {
for (PropertyFilter<S> subFilter : subFilters) {
if (subFilter.getChainedProperty().getChainCount() > 0) {
// A chain implies a join was followed, so result is exempt.
break joinCheck;
}
}
// No joins found, result is not exempt from merging into full scan.
exempt = false;
}
}
if (exempt) {
mergedResults.add(result);
} else {
full = full.mergeRemainderFilter(result.getFilter());
}
}
if (mergedResults.size() == 0) {
// Nothing was exempt. Rather than return a result with a dnf
// filter, return full scan with a simpler reduced filter.
full = full.withRemainderFilter(filter.reduce());
}
mergedResults.add(full);
return mergedResults;
}
|
[
"private",
"List",
"<",
"IndexedQueryAnalyzer",
"<",
"S",
">",
".",
"Result",
">",
"splitIntoSubResults",
"(",
"Filter",
"<",
"S",
">",
"filter",
",",
"OrderingList",
"<",
"S",
">",
"ordering",
",",
"QueryHints",
"hints",
")",
"throws",
"SupportException",
",",
"RepositoryException",
"{",
"// Required for split to work.\r",
"Filter",
"<",
"S",
">",
"dnfFilter",
"=",
"filter",
".",
"disjunctiveNormalForm",
"(",
")",
";",
"Splitter",
"splitter",
"=",
"new",
"Splitter",
"(",
"ordering",
",",
"hints",
")",
";",
"RepositoryException",
"e",
"=",
"dnfFilter",
".",
"accept",
"(",
"splitter",
",",
"null",
")",
";",
"if",
"(",
"e",
"!=",
"null",
")",
"{",
"throw",
"e",
";",
"}",
"List",
"<",
"IndexedQueryAnalyzer",
"<",
"S",
">",
".",
"Result",
">",
"subResults",
"=",
"splitter",
".",
"mSubResults",
";",
"// Check if any sub-result handles nothing. If so, a full scan is the\r",
"// best option for the entire query and all sub-results merge into a\r",
"// single sub-result. Any sub-results which filter anything and contain\r",
"// a join property in the filter are exempt from the merge. This is\r",
"// because fewer joins are read than if a full scan is performed for\r",
"// the entire query. The resulting union has both a full scan and an\r",
"// index scan.\r",
"IndexedQueryAnalyzer",
"<",
"S",
">",
".",
"Result",
"full",
"=",
"null",
";",
"for",
"(",
"IndexedQueryAnalyzer",
"<",
"S",
">",
".",
"Result",
"result",
":",
"subResults",
")",
"{",
"if",
"(",
"!",
"result",
".",
"handlesAnything",
"(",
")",
")",
"{",
"full",
"=",
"result",
";",
"break",
";",
"}",
"if",
"(",
"!",
"result",
".",
"getCompositeScore",
"(",
")",
".",
"getFilteringScore",
"(",
")",
".",
"hasAnyMatches",
"(",
")",
")",
"{",
"if",
"(",
"full",
"==",
"null",
")",
"{",
"// This index is used only for its ordering, and it will be\r",
"// tentatively selected as the \"full scan\". If a result is\r",
"// found doesn't use an index for anything, then it becomes\r",
"// the \"full scan\" index.\r",
"full",
"=",
"result",
";",
"}",
"}",
"}",
"if",
"(",
"full",
"==",
"null",
")",
"{",
"// Okay, no full scan needed.\r",
"return",
"subResults",
";",
"}",
"List",
"<",
"IndexedQueryAnalyzer",
"<",
"S",
">",
".",
"Result",
">",
"mergedResults",
"=",
"new",
"ArrayList",
"<",
"IndexedQueryAnalyzer",
"<",
"S",
">",
".",
"Result",
">",
"(",
")",
";",
"for",
"(",
"IndexedQueryAnalyzer",
"<",
"S",
">",
".",
"Result",
"result",
":",
"subResults",
")",
"{",
"if",
"(",
"result",
"==",
"full",
")",
"{",
"// Add after everything has been merged into it.\r",
"continue",
";",
"}",
"boolean",
"exempt",
"=",
"result",
".",
"getCompositeScore",
"(",
")",
".",
"getFilteringScore",
"(",
")",
".",
"hasAnyMatches",
"(",
")",
";",
"if",
"(",
"exempt",
")",
"{",
"// Must also have a join in the filter to be exempt.\r",
"List",
"<",
"PropertyFilter",
"<",
"S",
">>",
"subFilters",
"=",
"PropertyFilterList",
".",
"get",
"(",
"result",
".",
"getFilter",
"(",
")",
")",
";",
"joinCheck",
":",
"{",
"for",
"(",
"PropertyFilter",
"<",
"S",
">",
"subFilter",
":",
"subFilters",
")",
"{",
"if",
"(",
"subFilter",
".",
"getChainedProperty",
"(",
")",
".",
"getChainCount",
"(",
")",
">",
"0",
")",
"{",
"// A chain implies a join was followed, so result is exempt.\r",
"break",
"joinCheck",
";",
"}",
"}",
"// No joins found, result is not exempt from merging into full scan.\r",
"exempt",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"exempt",
")",
"{",
"mergedResults",
".",
"add",
"(",
"result",
")",
";",
"}",
"else",
"{",
"full",
"=",
"full",
".",
"mergeRemainderFilter",
"(",
"result",
".",
"getFilter",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"mergedResults",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// Nothing was exempt. Rather than return a result with a dnf\r",
"// filter, return full scan with a simpler reduced filter.\r",
"full",
"=",
"full",
".",
"withRemainderFilter",
"(",
"filter",
".",
"reduce",
"(",
")",
")",
";",
"}",
"mergedResults",
".",
"add",
"(",
"full",
")",
";",
"return",
"mergedResults",
";",
"}"
] |
Splits the filter into sub-results and possibly merges them.
|
[
"Splits",
"the",
"filter",
"into",
"sub",
"-",
"results",
"and",
"possibly",
"merges",
"them",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/UnionQueryAnalyzer.java#L347-L435
|
7,921 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/layout/LayoutFactory.java
|
LayoutFactory.layoutFor
|
public Layout layoutFor(Class<? extends Storable> type, int generation)
throws FetchException, FetchNoneException
{
StoredLayout storedLayout =
mLayoutStorage.query("storableTypeName = ? & generation = ?")
.with(type.getName()).with(generation)
.loadOne();
return new Layout(this, storedLayout);
}
|
java
|
public Layout layoutFor(Class<? extends Storable> type, int generation)
throws FetchException, FetchNoneException
{
StoredLayout storedLayout =
mLayoutStorage.query("storableTypeName = ? & generation = ?")
.with(type.getName()).with(generation)
.loadOne();
return new Layout(this, storedLayout);
}
|
[
"public",
"Layout",
"layoutFor",
"(",
"Class",
"<",
"?",
"extends",
"Storable",
">",
"type",
",",
"int",
"generation",
")",
"throws",
"FetchException",
",",
"FetchNoneException",
"{",
"StoredLayout",
"storedLayout",
"=",
"mLayoutStorage",
".",
"query",
"(",
"\"storableTypeName = ? & generation = ?\"",
")",
".",
"with",
"(",
"type",
".",
"getName",
"(",
")",
")",
".",
"with",
"(",
"generation",
")",
".",
"loadOne",
"(",
")",
";",
"return",
"new",
"Layout",
"(",
"this",
",",
"storedLayout",
")",
";",
"}"
] |
Returns the layout for a particular generation of the given type.
@param generation desired generation
@throws FetchNoneException if generation not found
|
[
"Returns",
"the",
"layout",
"for",
"a",
"particular",
"generation",
"of",
"the",
"given",
"type",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java#L347-L355
|
7,922 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/layout/LayoutFactory.java
|
LayoutFactory.annHashCode
|
private static int annHashCode(Annotation ann) {
int hash = 0;
Method[] methods = ann.getClass().getDeclaredMethods();
for (Method m : methods) {
if (m.getReturnType() == null || m.getReturnType() == void.class) {
continue;
}
if (m.getParameterTypes().length != 0) {
continue;
}
String name = m.getName();
if (name.equals("hashCode") ||
name.equals("toString") ||
name.equals("annotationType"))
{
continue;
}
Object value;
try {
value = m.invoke(ann);
} catch (InvocationTargetException e) {
continue;
} catch (IllegalAccessException e) {
continue;
}
hash += (127 * name.hashCode()) ^ annValueHashCode(value);
}
return hash;
}
|
java
|
private static int annHashCode(Annotation ann) {
int hash = 0;
Method[] methods = ann.getClass().getDeclaredMethods();
for (Method m : methods) {
if (m.getReturnType() == null || m.getReturnType() == void.class) {
continue;
}
if (m.getParameterTypes().length != 0) {
continue;
}
String name = m.getName();
if (name.equals("hashCode") ||
name.equals("toString") ||
name.equals("annotationType"))
{
continue;
}
Object value;
try {
value = m.invoke(ann);
} catch (InvocationTargetException e) {
continue;
} catch (IllegalAccessException e) {
continue;
}
hash += (127 * name.hashCode()) ^ annValueHashCode(value);
}
return hash;
}
|
[
"private",
"static",
"int",
"annHashCode",
"(",
"Annotation",
"ann",
")",
"{",
"int",
"hash",
"=",
"0",
";",
"Method",
"[",
"]",
"methods",
"=",
"ann",
".",
"getClass",
"(",
")",
".",
"getDeclaredMethods",
"(",
")",
";",
"for",
"(",
"Method",
"m",
":",
"methods",
")",
"{",
"if",
"(",
"m",
".",
"getReturnType",
"(",
")",
"==",
"null",
"||",
"m",
".",
"getReturnType",
"(",
")",
"==",
"void",
".",
"class",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"m",
".",
"getParameterTypes",
"(",
")",
".",
"length",
"!=",
"0",
")",
"{",
"continue",
";",
"}",
"String",
"name",
"=",
"m",
".",
"getName",
"(",
")",
";",
"if",
"(",
"name",
".",
"equals",
"(",
"\"hashCode\"",
")",
"||",
"name",
".",
"equals",
"(",
"\"toString\"",
")",
"||",
"name",
".",
"equals",
"(",
"\"annotationType\"",
")",
")",
"{",
"continue",
";",
"}",
"Object",
"value",
";",
"try",
"{",
"value",
"=",
"m",
".",
"invoke",
"(",
"ann",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"continue",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"continue",
";",
"}",
"hash",
"+=",
"(",
"127",
"*",
"name",
".",
"hashCode",
"(",
")",
")",
"^",
"annValueHashCode",
"(",
"value",
")",
";",
"}",
"return",
"hash",
";",
"}"
] |
Returns an annotation hash code using a algorithm similar to the
default. The difference is in the handling of class and enum values. The
name is chosen for the hash code component instead of the instance
because it is stable between invocations of the JVM.
|
[
"Returns",
"an",
"annotation",
"hash",
"code",
"using",
"a",
"algorithm",
"similar",
"to",
"the",
"default",
".",
"The",
"difference",
"is",
"in",
"the",
"handling",
"of",
"class",
"and",
"enum",
"values",
".",
"The",
"name",
"is",
"chosen",
"for",
"the",
"hash",
"code",
"component",
"instead",
"of",
"the",
"instance",
"because",
"it",
"is",
"stable",
"between",
"invocations",
"of",
"the",
"JVM",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/layout/LayoutFactory.java#L554-L587
|
7,923 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/MismatchException.java
|
MismatchException.getMessages
|
public List<String> getMessages() {
if (mMessages == null || mMessages.size() == 0) {
mMessages = Collections.singletonList(super.getMessage());
}
return mMessages;
}
|
java
|
public List<String> getMessages() {
if (mMessages == null || mMessages.size() == 0) {
mMessages = Collections.singletonList(super.getMessage());
}
return mMessages;
}
|
[
"public",
"List",
"<",
"String",
">",
"getMessages",
"(",
")",
"{",
"if",
"(",
"mMessages",
"==",
"null",
"||",
"mMessages",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"mMessages",
"=",
"Collections",
".",
"singletonList",
"(",
"super",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"mMessages",
";",
"}"
] |
Multiple error messages may be embedded in a MismatchException.
@return non-null, unmodifiable list of messages
|
[
"Multiple",
"error",
"messages",
"may",
"be",
"embedded",
"in",
"a",
"MismatchException",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/MismatchException.java#L96-L101
|
7,924 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/replicated/ClobReplicationTrigger.java
|
ClobReplicationTrigger.create
|
static <S extends Storable> ClobReplicationTrigger<S> create(Storage<S> masterStorage) {
Map<String, ? extends StorableProperty<S>> properties =
StorableIntrospector.examine(masterStorage.getStorableType()).getDataProperties();
List<String> clobNames = new ArrayList<String>(2);
for (StorableProperty<S> property : properties.values()) {
if (property.getType() == Clob.class) {
clobNames.add(property.getName());
}
}
if (clobNames.size() == 0) {
return null;
}
return new ClobReplicationTrigger<S>(masterStorage,
clobNames.toArray(new String[clobNames.size()]));
}
|
java
|
static <S extends Storable> ClobReplicationTrigger<S> create(Storage<S> masterStorage) {
Map<String, ? extends StorableProperty<S>> properties =
StorableIntrospector.examine(masterStorage.getStorableType()).getDataProperties();
List<String> clobNames = new ArrayList<String>(2);
for (StorableProperty<S> property : properties.values()) {
if (property.getType() == Clob.class) {
clobNames.add(property.getName());
}
}
if (clobNames.size() == 0) {
return null;
}
return new ClobReplicationTrigger<S>(masterStorage,
clobNames.toArray(new String[clobNames.size()]));
}
|
[
"static",
"<",
"S",
"extends",
"Storable",
">",
"ClobReplicationTrigger",
"<",
"S",
">",
"create",
"(",
"Storage",
"<",
"S",
">",
"masterStorage",
")",
"{",
"Map",
"<",
"String",
",",
"?",
"extends",
"StorableProperty",
"<",
"S",
">",
">",
"properties",
"=",
"StorableIntrospector",
".",
"examine",
"(",
"masterStorage",
".",
"getStorableType",
"(",
")",
")",
".",
"getDataProperties",
"(",
")",
";",
"List",
"<",
"String",
">",
"clobNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"2",
")",
";",
"for",
"(",
"StorableProperty",
"<",
"S",
">",
"property",
":",
"properties",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"property",
".",
"getType",
"(",
")",
"==",
"Clob",
".",
"class",
")",
"{",
"clobNames",
".",
"add",
"(",
"property",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"clobNames",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"ClobReplicationTrigger",
"<",
"S",
">",
"(",
"masterStorage",
",",
"clobNames",
".",
"toArray",
"(",
"new",
"String",
"[",
"clobNames",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}"
] |
Returns null if no Clobs need to be replicated.
|
[
"Returns",
"null",
"if",
"no",
"Clobs",
"need",
"to",
"be",
"replicated",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/replicated/ClobReplicationTrigger.java#L52-L70
|
7,925 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableBuilder.java
|
SyntheticStorableBuilder.definePropertyBeanMethods
|
protected boolean definePropertyBeanMethods(ClassFile cf,
SyntheticProperty property)
{
TypeDesc propertyType = TypeDesc.forClass(property.getType());
// Add property get method.
final MethodInfo mi = cf.addMethod(Modifiers.PUBLIC_ABSTRACT,
property.getReadMethodName(),
propertyType,
null);
if (property.getName() != null) {
// Define @Name
Annotation ann = mi.addRuntimeVisibleAnnotation(TypeDesc.forClass(Name.class));
ann.putMemberValue("value", property.getName());
}
if (property.isNullable()) {
mi.addRuntimeVisibleAnnotation(TypeDesc.forClass(Nullable.class));
}
boolean versioned = false;
if (property.isVersion()) {
mi.addRuntimeVisibleAnnotation(TypeDesc.forClass(Version.class));
versioned = true;
}
if (property.getAdapter() != null) {
StorablePropertyAdapter adapter = property.getAdapter();
Annotation ann = mi.addRuntimeVisibleAnnotation
(TypeDesc.forClass(adapter.getAnnotation().getAnnotationType()));
java.lang.annotation.Annotation jann = adapter.getAnnotation().getAnnotation();
if (jann != null) {
new AnnotationBuilder().visit(jann, ann);
}
}
List<String> annotationDescs = property.getAccessorAnnotationDescriptors();
if (annotationDescs != null && annotationDescs.size() > 0) {
for (String desc : annotationDescs) {
new AnnotationDescParser(desc) {
@Override
protected Annotation buildRootAnnotation(TypeDesc rootAnnotationType) {
return mi.addRuntimeVisibleAnnotation(rootAnnotationType);
}
}.parse(null);
}
}
// Add property set method.
cf.addMethod(Modifiers.PUBLIC_ABSTRACT,
property.getWriteMethodName(),
null,
new TypeDesc[] { propertyType });
return versioned;
}
|
java
|
protected boolean definePropertyBeanMethods(ClassFile cf,
SyntheticProperty property)
{
TypeDesc propertyType = TypeDesc.forClass(property.getType());
// Add property get method.
final MethodInfo mi = cf.addMethod(Modifiers.PUBLIC_ABSTRACT,
property.getReadMethodName(),
propertyType,
null);
if (property.getName() != null) {
// Define @Name
Annotation ann = mi.addRuntimeVisibleAnnotation(TypeDesc.forClass(Name.class));
ann.putMemberValue("value", property.getName());
}
if (property.isNullable()) {
mi.addRuntimeVisibleAnnotation(TypeDesc.forClass(Nullable.class));
}
boolean versioned = false;
if (property.isVersion()) {
mi.addRuntimeVisibleAnnotation(TypeDesc.forClass(Version.class));
versioned = true;
}
if (property.getAdapter() != null) {
StorablePropertyAdapter adapter = property.getAdapter();
Annotation ann = mi.addRuntimeVisibleAnnotation
(TypeDesc.forClass(adapter.getAnnotation().getAnnotationType()));
java.lang.annotation.Annotation jann = adapter.getAnnotation().getAnnotation();
if (jann != null) {
new AnnotationBuilder().visit(jann, ann);
}
}
List<String> annotationDescs = property.getAccessorAnnotationDescriptors();
if (annotationDescs != null && annotationDescs.size() > 0) {
for (String desc : annotationDescs) {
new AnnotationDescParser(desc) {
@Override
protected Annotation buildRootAnnotation(TypeDesc rootAnnotationType) {
return mi.addRuntimeVisibleAnnotation(rootAnnotationType);
}
}.parse(null);
}
}
// Add property set method.
cf.addMethod(Modifiers.PUBLIC_ABSTRACT,
property.getWriteMethodName(),
null,
new TypeDesc[] { propertyType });
return versioned;
}
|
[
"protected",
"boolean",
"definePropertyBeanMethods",
"(",
"ClassFile",
"cf",
",",
"SyntheticProperty",
"property",
")",
"{",
"TypeDesc",
"propertyType",
"=",
"TypeDesc",
".",
"forClass",
"(",
"property",
".",
"getType",
"(",
")",
")",
";",
"// Add property get method.\r",
"final",
"MethodInfo",
"mi",
"=",
"cf",
".",
"addMethod",
"(",
"Modifiers",
".",
"PUBLIC_ABSTRACT",
",",
"property",
".",
"getReadMethodName",
"(",
")",
",",
"propertyType",
",",
"null",
")",
";",
"if",
"(",
"property",
".",
"getName",
"(",
")",
"!=",
"null",
")",
"{",
"// Define @Name\r",
"Annotation",
"ann",
"=",
"mi",
".",
"addRuntimeVisibleAnnotation",
"(",
"TypeDesc",
".",
"forClass",
"(",
"Name",
".",
"class",
")",
")",
";",
"ann",
".",
"putMemberValue",
"(",
"\"value\"",
",",
"property",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"property",
".",
"isNullable",
"(",
")",
")",
"{",
"mi",
".",
"addRuntimeVisibleAnnotation",
"(",
"TypeDesc",
".",
"forClass",
"(",
"Nullable",
".",
"class",
")",
")",
";",
"}",
"boolean",
"versioned",
"=",
"false",
";",
"if",
"(",
"property",
".",
"isVersion",
"(",
")",
")",
"{",
"mi",
".",
"addRuntimeVisibleAnnotation",
"(",
"TypeDesc",
".",
"forClass",
"(",
"Version",
".",
"class",
")",
")",
";",
"versioned",
"=",
"true",
";",
"}",
"if",
"(",
"property",
".",
"getAdapter",
"(",
")",
"!=",
"null",
")",
"{",
"StorablePropertyAdapter",
"adapter",
"=",
"property",
".",
"getAdapter",
"(",
")",
";",
"Annotation",
"ann",
"=",
"mi",
".",
"addRuntimeVisibleAnnotation",
"(",
"TypeDesc",
".",
"forClass",
"(",
"adapter",
".",
"getAnnotation",
"(",
")",
".",
"getAnnotationType",
"(",
")",
")",
")",
";",
"java",
".",
"lang",
".",
"annotation",
".",
"Annotation",
"jann",
"=",
"adapter",
".",
"getAnnotation",
"(",
")",
".",
"getAnnotation",
"(",
")",
";",
"if",
"(",
"jann",
"!=",
"null",
")",
"{",
"new",
"AnnotationBuilder",
"(",
")",
".",
"visit",
"(",
"jann",
",",
"ann",
")",
";",
"}",
"}",
"List",
"<",
"String",
">",
"annotationDescs",
"=",
"property",
".",
"getAccessorAnnotationDescriptors",
"(",
")",
";",
"if",
"(",
"annotationDescs",
"!=",
"null",
"&&",
"annotationDescs",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"String",
"desc",
":",
"annotationDescs",
")",
"{",
"new",
"AnnotationDescParser",
"(",
"desc",
")",
"{",
"@",
"Override",
"protected",
"Annotation",
"buildRootAnnotation",
"(",
"TypeDesc",
"rootAnnotationType",
")",
"{",
"return",
"mi",
".",
"addRuntimeVisibleAnnotation",
"(",
"rootAnnotationType",
")",
";",
"}",
"}",
".",
"parse",
"(",
"null",
")",
";",
"}",
"}",
"// Add property set method.\r",
"cf",
".",
"addMethod",
"(",
"Modifiers",
".",
"PUBLIC_ABSTRACT",
",",
"property",
".",
"getWriteMethodName",
"(",
")",
",",
"null",
",",
"new",
"TypeDesc",
"[",
"]",
"{",
"propertyType",
"}",
")",
";",
"return",
"versioned",
";",
"}"
] |
Add the get & set methods for this property
@return true if version property was added
|
[
"Add",
"the",
"get",
"&",
"set",
"methods",
"for",
"this",
"property"
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableBuilder.java#L450-L504
|
7,926 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.assertParameterNotNull
|
public static void assertParameterNotNull(CodeBuilder b, int paramIndex) {
b.loadLocal(b.getParameter(paramIndex));
Label notNull = b.createLabel();
b.ifNullBranch(notNull, false);
throwException(b, IllegalArgumentException.class, null);
notNull.setLocation();
}
|
java
|
public static void assertParameterNotNull(CodeBuilder b, int paramIndex) {
b.loadLocal(b.getParameter(paramIndex));
Label notNull = b.createLabel();
b.ifNullBranch(notNull, false);
throwException(b, IllegalArgumentException.class, null);
notNull.setLocation();
}
|
[
"public",
"static",
"void",
"assertParameterNotNull",
"(",
"CodeBuilder",
"b",
",",
"int",
"paramIndex",
")",
"{",
"b",
".",
"loadLocal",
"(",
"b",
".",
"getParameter",
"(",
"paramIndex",
")",
")",
";",
"Label",
"notNull",
"=",
"b",
".",
"createLabel",
"(",
")",
";",
"b",
".",
"ifNullBranch",
"(",
"notNull",
",",
"false",
")",
";",
"throwException",
"(",
"b",
",",
"IllegalArgumentException",
".",
"class",
",",
"null",
")",
";",
"notNull",
".",
"setLocation",
"(",
")",
";",
"}"
] |
Generate code to throw an exception if a parameter is null
@param b CodeBuilder into which to append the code
@param paramIndex index of the parameter to check
|
[
"Generate",
"code",
"to",
"throw",
"an",
"exception",
"if",
"a",
"parameter",
"is",
"null"
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L55-L61
|
7,927 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.uneraseGenericParameter
|
public static LocalVariable uneraseGenericParameter(
CodeBuilder b, TypeDesc paramType, final int paramIndex)
{
b.loadLocal(b.getParameter(paramIndex));
b.checkCast(paramType);
LocalVariable result = b.createLocalVariable(null, paramType);
b.storeLocal(result);
return result;
}
|
java
|
public static LocalVariable uneraseGenericParameter(
CodeBuilder b, TypeDesc paramType, final int paramIndex)
{
b.loadLocal(b.getParameter(paramIndex));
b.checkCast(paramType);
LocalVariable result = b.createLocalVariable(null, paramType);
b.storeLocal(result);
return result;
}
|
[
"public",
"static",
"LocalVariable",
"uneraseGenericParameter",
"(",
"CodeBuilder",
"b",
",",
"TypeDesc",
"paramType",
",",
"final",
"int",
"paramIndex",
")",
"{",
"b",
".",
"loadLocal",
"(",
"b",
".",
"getParameter",
"(",
"paramIndex",
")",
")",
";",
"b",
".",
"checkCast",
"(",
"paramType",
")",
";",
"LocalVariable",
"result",
"=",
"b",
".",
"createLocalVariable",
"(",
"null",
",",
"paramType",
")",
";",
"b",
".",
"storeLocal",
"(",
"result",
")",
";",
"return",
"result",
";",
"}"
] |
Generate code to create a local variable containing the specified parameter coerced
to the specified type. This is useful for re-interpreting erased generics into
the more specific genericized type.
@param b CodeBuilder into which to append the code
@param paramType the more specific type which was erased during compilation
@param paramIndex index of the parameter to unerase
@return a local variable referencing the type-cast parameter
|
[
"Generate",
"code",
"to",
"create",
"a",
"local",
"variable",
"containing",
"the",
"specified",
"parameter",
"coerced",
"to",
"the",
"specified",
"type",
".",
"This",
"is",
"useful",
"for",
"re",
"-",
"interpreting",
"erased",
"generics",
"into",
"the",
"more",
"specific",
"genericized",
"type",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L73-L81
|
7,928 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.throwException
|
public static void throwException(CodeBuilder b, Class type, String message) {
TypeDesc desc = TypeDesc.forClass(type);
b.newObject(desc);
b.dup();
if (message == null) {
b.invokeConstructor(desc, null);
} else {
b.loadConstant(message);
b.invokeConstructor(desc, new TypeDesc[] {TypeDesc.STRING});
}
b.throwObject();
}
|
java
|
public static void throwException(CodeBuilder b, Class type, String message) {
TypeDesc desc = TypeDesc.forClass(type);
b.newObject(desc);
b.dup();
if (message == null) {
b.invokeConstructor(desc, null);
} else {
b.loadConstant(message);
b.invokeConstructor(desc, new TypeDesc[] {TypeDesc.STRING});
}
b.throwObject();
}
|
[
"public",
"static",
"void",
"throwException",
"(",
"CodeBuilder",
"b",
",",
"Class",
"type",
",",
"String",
"message",
")",
"{",
"TypeDesc",
"desc",
"=",
"TypeDesc",
".",
"forClass",
"(",
"type",
")",
";",
"b",
".",
"newObject",
"(",
"desc",
")",
";",
"b",
".",
"dup",
"(",
")",
";",
"if",
"(",
"message",
"==",
"null",
")",
"{",
"b",
".",
"invokeConstructor",
"(",
"desc",
",",
"null",
")",
";",
"}",
"else",
"{",
"b",
".",
"loadConstant",
"(",
"message",
")",
";",
"b",
".",
"invokeConstructor",
"(",
"desc",
",",
"new",
"TypeDesc",
"[",
"]",
"{",
"TypeDesc",
".",
"STRING",
"}",
")",
";",
"}",
"b",
".",
"throwObject",
"(",
")",
";",
"}"
] |
Generate code to throw an exception with an optional message.
@param b {@link CodeBuilder} to which to add code
@param type type of the object to throw
@param message optional message to provide to the constructor
|
[
"Generate",
"code",
"to",
"throw",
"an",
"exception",
"with",
"an",
"optional",
"message",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L89-L100
|
7,929 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.throwConcatException
|
public static void throwConcatException(CodeBuilder b, Class type, String... messages) {
if (messages == null || messages.length == 0) {
throwException(b, type, null);
return;
}
if (messages.length == 1) {
throwException(b, type, messages[0]);
return;
}
TypeDesc desc = TypeDesc.forClass(type);
b.newObject(desc);
b.dup();
TypeDesc[] params = new TypeDesc[] {TypeDesc.STRING};
for (int i=0; i<messages.length; i++) {
b.loadConstant(String.valueOf(messages[i]));
if (i > 0) {
b.invokeVirtual(TypeDesc.STRING, "concat", TypeDesc.STRING, params);
}
}
b.invokeConstructor(desc, params);
b.throwObject();
}
|
java
|
public static void throwConcatException(CodeBuilder b, Class type, String... messages) {
if (messages == null || messages.length == 0) {
throwException(b, type, null);
return;
}
if (messages.length == 1) {
throwException(b, type, messages[0]);
return;
}
TypeDesc desc = TypeDesc.forClass(type);
b.newObject(desc);
b.dup();
TypeDesc[] params = new TypeDesc[] {TypeDesc.STRING};
for (int i=0; i<messages.length; i++) {
b.loadConstant(String.valueOf(messages[i]));
if (i > 0) {
b.invokeVirtual(TypeDesc.STRING, "concat", TypeDesc.STRING, params);
}
}
b.invokeConstructor(desc, params);
b.throwObject();
}
|
[
"public",
"static",
"void",
"throwConcatException",
"(",
"CodeBuilder",
"b",
",",
"Class",
"type",
",",
"String",
"...",
"messages",
")",
"{",
"if",
"(",
"messages",
"==",
"null",
"||",
"messages",
".",
"length",
"==",
"0",
")",
"{",
"throwException",
"(",
"b",
",",
"type",
",",
"null",
")",
";",
"return",
";",
"}",
"if",
"(",
"messages",
".",
"length",
"==",
"1",
")",
"{",
"throwException",
"(",
"b",
",",
"type",
",",
"messages",
"[",
"0",
"]",
")",
";",
"return",
";",
"}",
"TypeDesc",
"desc",
"=",
"TypeDesc",
".",
"forClass",
"(",
"type",
")",
";",
"b",
".",
"newObject",
"(",
"desc",
")",
";",
"b",
".",
"dup",
"(",
")",
";",
"TypeDesc",
"[",
"]",
"params",
"=",
"new",
"TypeDesc",
"[",
"]",
"{",
"TypeDesc",
".",
"STRING",
"}",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"messages",
".",
"length",
";",
"i",
"++",
")",
"{",
"b",
".",
"loadConstant",
"(",
"String",
".",
"valueOf",
"(",
"messages",
"[",
"i",
"]",
")",
")",
";",
"if",
"(",
"i",
">",
"0",
")",
"{",
"b",
".",
"invokeVirtual",
"(",
"TypeDesc",
".",
"STRING",
",",
"\"concat\"",
",",
"TypeDesc",
".",
"STRING",
",",
"params",
")",
";",
"}",
"}",
"b",
".",
"invokeConstructor",
"(",
"desc",
",",
"params",
")",
";",
"b",
".",
"throwObject",
"(",
")",
";",
"}"
] |
Generate code to throw an exception with a message concatenated at runtime.
@param b {@link CodeBuilder} to which to add code
@param type type of the object to throw
@param messages messages to concat at runtime
|
[
"Generate",
"code",
"to",
"throw",
"an",
"exception",
"with",
"a",
"message",
"concatenated",
"at",
"runtime",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L109-L134
|
7,930 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.definePrepareBridge
|
private static void definePrepareBridge(ClassFile cf, Class leaf, Class returnClass) {
TypeDesc returnType = TypeDesc.forClass(returnClass);
if (isPublicMethodFinal(leaf, PREPARE_METHOD_NAME, returnType, null)) {
// Cannot override.
return;
}
MethodInfo mi = cf.addMethod(Modifiers.PUBLIC.toBridge(true),
PREPARE_METHOD_NAME, returnType, null);
CodeBuilder b = new CodeBuilder(mi);
b.loadThis();
b.invokeVirtual(PREPARE_METHOD_NAME, cf.getType(), null);
b.returnValue(returnType);
}
|
java
|
private static void definePrepareBridge(ClassFile cf, Class leaf, Class returnClass) {
TypeDesc returnType = TypeDesc.forClass(returnClass);
if (isPublicMethodFinal(leaf, PREPARE_METHOD_NAME, returnType, null)) {
// Cannot override.
return;
}
MethodInfo mi = cf.addMethod(Modifiers.PUBLIC.toBridge(true),
PREPARE_METHOD_NAME, returnType, null);
CodeBuilder b = new CodeBuilder(mi);
b.loadThis();
b.invokeVirtual(PREPARE_METHOD_NAME, cf.getType(), null);
b.returnValue(returnType);
}
|
[
"private",
"static",
"void",
"definePrepareBridge",
"(",
"ClassFile",
"cf",
",",
"Class",
"leaf",
",",
"Class",
"returnClass",
")",
"{",
"TypeDesc",
"returnType",
"=",
"TypeDesc",
".",
"forClass",
"(",
"returnClass",
")",
";",
"if",
"(",
"isPublicMethodFinal",
"(",
"leaf",
",",
"PREPARE_METHOD_NAME",
",",
"returnType",
",",
"null",
")",
")",
"{",
"// Cannot override.\r",
"return",
";",
"}",
"MethodInfo",
"mi",
"=",
"cf",
".",
"addMethod",
"(",
"Modifiers",
".",
"PUBLIC",
".",
"toBridge",
"(",
"true",
")",
",",
"PREPARE_METHOD_NAME",
",",
"returnType",
",",
"null",
")",
";",
"CodeBuilder",
"b",
"=",
"new",
"CodeBuilder",
"(",
"mi",
")",
";",
"b",
".",
"loadThis",
"(",
")",
";",
"b",
".",
"invokeVirtual",
"(",
"PREPARE_METHOD_NAME",
",",
"cf",
".",
"getType",
"(",
")",
",",
"null",
")",
";",
"b",
".",
"returnValue",
"(",
"returnType",
")",
";",
"}"
] |
Add a prepare bridge method to the classfile for the given type.
@param cf file to which to add the prepare bridge
@param leaf leaf class
@param returnClass type returned from generated bridge method
@since 1.2
|
[
"Add",
"a",
"prepare",
"bridge",
"method",
"to",
"the",
"classfile",
"for",
"the",
"given",
"type",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L278-L292
|
7,931 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.isPublicMethodFinal
|
public static boolean isPublicMethodFinal(Class clazz, String name,
TypeDesc retType, TypeDesc[] params)
{
if (!clazz.isInterface()) {
Class[] paramClasses;
if (params == null || params.length == 0) {
paramClasses = null;
} else {
paramClasses = new Class[params.length];
for (int i=0; i<params.length; i++) {
paramClasses[i] = params[i].toClass();
}
}
try {
Method existing = clazz.getMethod(name, paramClasses);
if (Modifier.isFinal(existing.getModifiers())) {
if (retType == null) {
retType = TypeDesc.forClass(void.class);
}
if (TypeDesc.forClass(existing.getReturnType()) == retType) {
// Method is already implemented and is final.
return true;
}
}
} catch (NoSuchMethodException e) {
}
}
return false;
}
|
java
|
public static boolean isPublicMethodFinal(Class clazz, String name,
TypeDesc retType, TypeDesc[] params)
{
if (!clazz.isInterface()) {
Class[] paramClasses;
if (params == null || params.length == 0) {
paramClasses = null;
} else {
paramClasses = new Class[params.length];
for (int i=0; i<params.length; i++) {
paramClasses[i] = params[i].toClass();
}
}
try {
Method existing = clazz.getMethod(name, paramClasses);
if (Modifier.isFinal(existing.getModifiers())) {
if (retType == null) {
retType = TypeDesc.forClass(void.class);
}
if (TypeDesc.forClass(existing.getReturnType()) == retType) {
// Method is already implemented and is final.
return true;
}
}
} catch (NoSuchMethodException e) {
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"isPublicMethodFinal",
"(",
"Class",
"clazz",
",",
"String",
"name",
",",
"TypeDesc",
"retType",
",",
"TypeDesc",
"[",
"]",
"params",
")",
"{",
"if",
"(",
"!",
"clazz",
".",
"isInterface",
"(",
")",
")",
"{",
"Class",
"[",
"]",
"paramClasses",
";",
"if",
"(",
"params",
"==",
"null",
"||",
"params",
".",
"length",
"==",
"0",
")",
"{",
"paramClasses",
"=",
"null",
";",
"}",
"else",
"{",
"paramClasses",
"=",
"new",
"Class",
"[",
"params",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"params",
".",
"length",
";",
"i",
"++",
")",
"{",
"paramClasses",
"[",
"i",
"]",
"=",
"params",
"[",
"i",
"]",
".",
"toClass",
"(",
")",
";",
"}",
"}",
"try",
"{",
"Method",
"existing",
"=",
"clazz",
".",
"getMethod",
"(",
"name",
",",
"paramClasses",
")",
";",
"if",
"(",
"Modifier",
".",
"isFinal",
"(",
"existing",
".",
"getModifiers",
"(",
")",
")",
")",
"{",
"if",
"(",
"retType",
"==",
"null",
")",
"{",
"retType",
"=",
"TypeDesc",
".",
"forClass",
"(",
"void",
".",
"class",
")",
";",
"}",
"if",
"(",
"TypeDesc",
".",
"forClass",
"(",
"existing",
".",
"getReturnType",
"(",
")",
")",
"==",
"retType",
")",
"{",
"// Method is already implemented and is final.\r",
"return",
"true",
";",
"}",
"}",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns true if a public final method exists which matches the given
specification.
|
[
"Returns",
"true",
"if",
"a",
"public",
"final",
"method",
"exists",
"which",
"matches",
"the",
"given",
"specification",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L298-L327
|
7,932 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.addValueHashCodeCall
|
public static void addValueHashCodeCall(CodeBuilder b,
TypeDesc valueType,
boolean testForNull,
boolean mixIn)
{
LocalVariable value = null;
if (mixIn) {
value = b.createLocalVariable(null, valueType);
b.storeLocal(value);
// Multiply current hashcode by 31 before adding more to it.
b.loadConstant(31);
b.math(Opcode.IMUL);
b.loadLocal(value);
}
switch (valueType.getTypeCode()) {
case TypeDesc.FLOAT_CODE:
b.invokeStatic(TypeDesc.FLOAT.toObjectType(), "floatToIntBits",
TypeDesc.INT, new TypeDesc[]{TypeDesc.FLOAT});
// Fall through
case TypeDesc.INT_CODE:
case TypeDesc.CHAR_CODE:
case TypeDesc.SHORT_CODE:
case TypeDesc.BYTE_CODE:
case TypeDesc.BOOLEAN_CODE:
if (mixIn) {
b.math(Opcode.IADD);
}
break;
case TypeDesc.DOUBLE_CODE:
b.invokeStatic(TypeDesc.DOUBLE.toObjectType(), "doubleToLongBits",
TypeDesc.LONG, new TypeDesc[]{TypeDesc.DOUBLE});
// Fall through
case TypeDesc.LONG_CODE:
b.dup2();
b.loadConstant(32);
b.math(Opcode.LUSHR);
b.math(Opcode.LXOR);
b.convert(TypeDesc.LONG, TypeDesc.INT);
if (mixIn) {
b.math(Opcode.IADD);
}
break;
case TypeDesc.OBJECT_CODE:
default:
if (testForNull) {
if (value == null) {
value = b.createLocalVariable(null, valueType);
b.storeLocal(value);
b.loadLocal(value);
}
}
if (mixIn) {
Label isNull = b.createLabel();
if (testForNull) {
b.ifNullBranch(isNull, true);
b.loadLocal(value);
}
addValueHashCodeCallTo(b, valueType);
b.math(Opcode.IADD);
if (testForNull) {
isNull.setLocation();
}
} else {
Label cont = b.createLabel();
if (testForNull) {
Label notNull = b.createLabel();
b.ifNullBranch(notNull, false);
b.loadConstant(0);
b.branch(cont);
notNull.setLocation();
b.loadLocal(value);
}
addValueHashCodeCallTo(b, valueType);
if (testForNull) {
cont.setLocation();
}
}
break;
}
}
|
java
|
public static void addValueHashCodeCall(CodeBuilder b,
TypeDesc valueType,
boolean testForNull,
boolean mixIn)
{
LocalVariable value = null;
if (mixIn) {
value = b.createLocalVariable(null, valueType);
b.storeLocal(value);
// Multiply current hashcode by 31 before adding more to it.
b.loadConstant(31);
b.math(Opcode.IMUL);
b.loadLocal(value);
}
switch (valueType.getTypeCode()) {
case TypeDesc.FLOAT_CODE:
b.invokeStatic(TypeDesc.FLOAT.toObjectType(), "floatToIntBits",
TypeDesc.INT, new TypeDesc[]{TypeDesc.FLOAT});
// Fall through
case TypeDesc.INT_CODE:
case TypeDesc.CHAR_CODE:
case TypeDesc.SHORT_CODE:
case TypeDesc.BYTE_CODE:
case TypeDesc.BOOLEAN_CODE:
if (mixIn) {
b.math(Opcode.IADD);
}
break;
case TypeDesc.DOUBLE_CODE:
b.invokeStatic(TypeDesc.DOUBLE.toObjectType(), "doubleToLongBits",
TypeDesc.LONG, new TypeDesc[]{TypeDesc.DOUBLE});
// Fall through
case TypeDesc.LONG_CODE:
b.dup2();
b.loadConstant(32);
b.math(Opcode.LUSHR);
b.math(Opcode.LXOR);
b.convert(TypeDesc.LONG, TypeDesc.INT);
if (mixIn) {
b.math(Opcode.IADD);
}
break;
case TypeDesc.OBJECT_CODE:
default:
if (testForNull) {
if (value == null) {
value = b.createLocalVariable(null, valueType);
b.storeLocal(value);
b.loadLocal(value);
}
}
if (mixIn) {
Label isNull = b.createLabel();
if (testForNull) {
b.ifNullBranch(isNull, true);
b.loadLocal(value);
}
addValueHashCodeCallTo(b, valueType);
b.math(Opcode.IADD);
if (testForNull) {
isNull.setLocation();
}
} else {
Label cont = b.createLabel();
if (testForNull) {
Label notNull = b.createLabel();
b.ifNullBranch(notNull, false);
b.loadConstant(0);
b.branch(cont);
notNull.setLocation();
b.loadLocal(value);
}
addValueHashCodeCallTo(b, valueType);
if (testForNull) {
cont.setLocation();
}
}
break;
}
}
|
[
"public",
"static",
"void",
"addValueHashCodeCall",
"(",
"CodeBuilder",
"b",
",",
"TypeDesc",
"valueType",
",",
"boolean",
"testForNull",
",",
"boolean",
"mixIn",
")",
"{",
"LocalVariable",
"value",
"=",
"null",
";",
"if",
"(",
"mixIn",
")",
"{",
"value",
"=",
"b",
".",
"createLocalVariable",
"(",
"null",
",",
"valueType",
")",
";",
"b",
".",
"storeLocal",
"(",
"value",
")",
";",
"// Multiply current hashcode by 31 before adding more to it.\r",
"b",
".",
"loadConstant",
"(",
"31",
")",
";",
"b",
".",
"math",
"(",
"Opcode",
".",
"IMUL",
")",
";",
"b",
".",
"loadLocal",
"(",
"value",
")",
";",
"}",
"switch",
"(",
"valueType",
".",
"getTypeCode",
"(",
")",
")",
"{",
"case",
"TypeDesc",
".",
"FLOAT_CODE",
":",
"b",
".",
"invokeStatic",
"(",
"TypeDesc",
".",
"FLOAT",
".",
"toObjectType",
"(",
")",
",",
"\"floatToIntBits\"",
",",
"TypeDesc",
".",
"INT",
",",
"new",
"TypeDesc",
"[",
"]",
"{",
"TypeDesc",
".",
"FLOAT",
"}",
")",
";",
"// Fall through\r",
"case",
"TypeDesc",
".",
"INT_CODE",
":",
"case",
"TypeDesc",
".",
"CHAR_CODE",
":",
"case",
"TypeDesc",
".",
"SHORT_CODE",
":",
"case",
"TypeDesc",
".",
"BYTE_CODE",
":",
"case",
"TypeDesc",
".",
"BOOLEAN_CODE",
":",
"if",
"(",
"mixIn",
")",
"{",
"b",
".",
"math",
"(",
"Opcode",
".",
"IADD",
")",
";",
"}",
"break",
";",
"case",
"TypeDesc",
".",
"DOUBLE_CODE",
":",
"b",
".",
"invokeStatic",
"(",
"TypeDesc",
".",
"DOUBLE",
".",
"toObjectType",
"(",
")",
",",
"\"doubleToLongBits\"",
",",
"TypeDesc",
".",
"LONG",
",",
"new",
"TypeDesc",
"[",
"]",
"{",
"TypeDesc",
".",
"DOUBLE",
"}",
")",
";",
"// Fall through\r",
"case",
"TypeDesc",
".",
"LONG_CODE",
":",
"b",
".",
"dup2",
"(",
")",
";",
"b",
".",
"loadConstant",
"(",
"32",
")",
";",
"b",
".",
"math",
"(",
"Opcode",
".",
"LUSHR",
")",
";",
"b",
".",
"math",
"(",
"Opcode",
".",
"LXOR",
")",
";",
"b",
".",
"convert",
"(",
"TypeDesc",
".",
"LONG",
",",
"TypeDesc",
".",
"INT",
")",
";",
"if",
"(",
"mixIn",
")",
"{",
"b",
".",
"math",
"(",
"Opcode",
".",
"IADD",
")",
";",
"}",
"break",
";",
"case",
"TypeDesc",
".",
"OBJECT_CODE",
":",
"default",
":",
"if",
"(",
"testForNull",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"b",
".",
"createLocalVariable",
"(",
"null",
",",
"valueType",
")",
";",
"b",
".",
"storeLocal",
"(",
"value",
")",
";",
"b",
".",
"loadLocal",
"(",
"value",
")",
";",
"}",
"}",
"if",
"(",
"mixIn",
")",
"{",
"Label",
"isNull",
"=",
"b",
".",
"createLabel",
"(",
")",
";",
"if",
"(",
"testForNull",
")",
"{",
"b",
".",
"ifNullBranch",
"(",
"isNull",
",",
"true",
")",
";",
"b",
".",
"loadLocal",
"(",
"value",
")",
";",
"}",
"addValueHashCodeCallTo",
"(",
"b",
",",
"valueType",
")",
";",
"b",
".",
"math",
"(",
"Opcode",
".",
"IADD",
")",
";",
"if",
"(",
"testForNull",
")",
"{",
"isNull",
".",
"setLocation",
"(",
")",
";",
"}",
"}",
"else",
"{",
"Label",
"cont",
"=",
"b",
".",
"createLabel",
"(",
")",
";",
"if",
"(",
"testForNull",
")",
"{",
"Label",
"notNull",
"=",
"b",
".",
"createLabel",
"(",
")",
";",
"b",
".",
"ifNullBranch",
"(",
"notNull",
",",
"false",
")",
";",
"b",
".",
"loadConstant",
"(",
"0",
")",
";",
"b",
".",
"branch",
"(",
"cont",
")",
";",
"notNull",
".",
"setLocation",
"(",
")",
";",
"b",
".",
"loadLocal",
"(",
"value",
")",
";",
"}",
"addValueHashCodeCallTo",
"(",
"b",
",",
"valueType",
")",
";",
"if",
"(",
"testForNull",
")",
"{",
"cont",
".",
"setLocation",
"(",
")",
";",
"}",
"}",
"break",
";",
"}",
"}"
] |
Generates code to compute a hashcode for a value on the stack, consuming
the value. After the code executes, the stack contains an int hashcode.
@param b {@link CodeBuilder} to which to add the code
@param valueType the type of the value
@param testForNull if true and the value is a reference and might be null
@param mixIn if true, stack has an existing hashcode followed by a value
@since 1.2.2
|
[
"Generates",
"code",
"to",
"compute",
"a",
"hashcode",
"for",
"a",
"value",
"on",
"the",
"stack",
"consuming",
"the",
"value",
".",
"After",
"the",
"code",
"executes",
"the",
"stack",
"contains",
"an",
"int",
"hashcode",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L377-L461
|
7,933 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.addEqualsCall
|
public static void addEqualsCall(CodeBuilder b,
String fieldName,
TypeDesc fieldType,
boolean testForNull,
Label fail,
LocalVariable other)
{
b.loadThis();
b.loadField(fieldName, fieldType);
b.loadLocal(other);
b.loadField(fieldName, fieldType);
addValuesEqualCall(b, fieldType, testForNull, fail, false);
}
|
java
|
public static void addEqualsCall(CodeBuilder b,
String fieldName,
TypeDesc fieldType,
boolean testForNull,
Label fail,
LocalVariable other)
{
b.loadThis();
b.loadField(fieldName, fieldType);
b.loadLocal(other);
b.loadField(fieldName, fieldType);
addValuesEqualCall(b, fieldType, testForNull, fail, false);
}
|
[
"public",
"static",
"void",
"addEqualsCall",
"(",
"CodeBuilder",
"b",
",",
"String",
"fieldName",
",",
"TypeDesc",
"fieldType",
",",
"boolean",
"testForNull",
",",
"Label",
"fail",
",",
"LocalVariable",
"other",
")",
"{",
"b",
".",
"loadThis",
"(",
")",
";",
"b",
".",
"loadField",
"(",
"fieldName",
",",
"fieldType",
")",
";",
"b",
".",
"loadLocal",
"(",
"other",
")",
";",
"b",
".",
"loadField",
"(",
"fieldName",
",",
"fieldType",
")",
";",
"addValuesEqualCall",
"(",
"b",
",",
"fieldType",
",",
"testForNull",
",",
"fail",
",",
"false",
")",
";",
"}"
] |
Generates code to compare a field in this object against the same one in a
different instance. Branch to the provided Label if they are not equal.
@param b {@link CodeBuilder} to which to add the code
@param fieldName the name of the field
@param fieldType the type of the field
@param testForNull if true and the values are references, they will be considered
unequal unless neither or both are null. If false, assume neither is null.
@param fail the label to branch to
@param other the other instance to test
|
[
"Generates",
"code",
"to",
"compare",
"a",
"field",
"in",
"this",
"object",
"against",
"the",
"same",
"one",
"in",
"a",
"different",
"instance",
".",
"Branch",
"to",
"the",
"provided",
"Label",
"if",
"they",
"are",
"not",
"equal",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L489-L503
|
7,934 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.addValuesEqualCall
|
public static void addValuesEqualCall(final CodeBuilder b,
final TypeDesc valueType,
final boolean testForNull,
final Label label,
final boolean choice)
{
if (valueType.getTypeCode() != TypeDesc.OBJECT_CODE) {
if (valueType.getTypeCode() == TypeDesc.FLOAT_CODE) {
// Special treatment to handle NaN.
b.invokeStatic(TypeDesc.FLOAT.toObjectType(), "compare", TypeDesc.INT,
new TypeDesc[] {TypeDesc.FLOAT, TypeDesc.FLOAT});
b.ifZeroComparisonBranch(label, choice ? "==" : "!=");
} else if (valueType.getTypeCode() == TypeDesc.DOUBLE_CODE) {
// Special treatment to handle NaN.
b.invokeStatic(TypeDesc.DOUBLE.toObjectType(), "compare", TypeDesc.INT,
new TypeDesc[] {TypeDesc.DOUBLE, TypeDesc.DOUBLE});
b.ifZeroComparisonBranch(label, choice ? "==" : "!=");
} else {
b.ifComparisonBranch(label, choice ? "==" : "!=", valueType);
}
return;
}
if (!testForNull) {
String op = addEqualsCallTo(b, valueType, choice);
b.ifZeroComparisonBranch(label, op);
return;
}
Label isNotNull = b.createLabel();
LocalVariable value = b.createLocalVariable(null, valueType);
b.storeLocal(value);
b.loadLocal(value);
b.ifNullBranch(isNotNull, false);
// First value popped off stack is null. Just test remaining one for null.
b.ifNullBranch(label, choice);
Label cont = b.createLabel();
b.branch(cont);
// First value popped off stack is not null, but second one might be.
isNotNull.setLocation();
if (compareToType(valueType) == null) {
// Call equals method, but swap values so that the second value is
// an argument into the equals method.
b.loadLocal(value);
b.swap();
} else {
// Need to test for second argument too, since compareTo method
// cannot cope with null.
LocalVariable value2 = b.createLocalVariable(null, valueType);
b.storeLocal(value2);
b.loadLocal(value2);
b.ifNullBranch(label, !choice);
// Load both values in preparation for calling compareTo method.
b.loadLocal(value);
b.loadLocal(value2);
}
String op = addEqualsCallTo(b, valueType, choice);
b.ifZeroComparisonBranch(label, op);
cont.setLocation();
}
|
java
|
public static void addValuesEqualCall(final CodeBuilder b,
final TypeDesc valueType,
final boolean testForNull,
final Label label,
final boolean choice)
{
if (valueType.getTypeCode() != TypeDesc.OBJECT_CODE) {
if (valueType.getTypeCode() == TypeDesc.FLOAT_CODE) {
// Special treatment to handle NaN.
b.invokeStatic(TypeDesc.FLOAT.toObjectType(), "compare", TypeDesc.INT,
new TypeDesc[] {TypeDesc.FLOAT, TypeDesc.FLOAT});
b.ifZeroComparisonBranch(label, choice ? "==" : "!=");
} else if (valueType.getTypeCode() == TypeDesc.DOUBLE_CODE) {
// Special treatment to handle NaN.
b.invokeStatic(TypeDesc.DOUBLE.toObjectType(), "compare", TypeDesc.INT,
new TypeDesc[] {TypeDesc.DOUBLE, TypeDesc.DOUBLE});
b.ifZeroComparisonBranch(label, choice ? "==" : "!=");
} else {
b.ifComparisonBranch(label, choice ? "==" : "!=", valueType);
}
return;
}
if (!testForNull) {
String op = addEqualsCallTo(b, valueType, choice);
b.ifZeroComparisonBranch(label, op);
return;
}
Label isNotNull = b.createLabel();
LocalVariable value = b.createLocalVariable(null, valueType);
b.storeLocal(value);
b.loadLocal(value);
b.ifNullBranch(isNotNull, false);
// First value popped off stack is null. Just test remaining one for null.
b.ifNullBranch(label, choice);
Label cont = b.createLabel();
b.branch(cont);
// First value popped off stack is not null, but second one might be.
isNotNull.setLocation();
if (compareToType(valueType) == null) {
// Call equals method, but swap values so that the second value is
// an argument into the equals method.
b.loadLocal(value);
b.swap();
} else {
// Need to test for second argument too, since compareTo method
// cannot cope with null.
LocalVariable value2 = b.createLocalVariable(null, valueType);
b.storeLocal(value2);
b.loadLocal(value2);
b.ifNullBranch(label, !choice);
// Load both values in preparation for calling compareTo method.
b.loadLocal(value);
b.loadLocal(value2);
}
String op = addEqualsCallTo(b, valueType, choice);
b.ifZeroComparisonBranch(label, op);
cont.setLocation();
}
|
[
"public",
"static",
"void",
"addValuesEqualCall",
"(",
"final",
"CodeBuilder",
"b",
",",
"final",
"TypeDesc",
"valueType",
",",
"final",
"boolean",
"testForNull",
",",
"final",
"Label",
"label",
",",
"final",
"boolean",
"choice",
")",
"{",
"if",
"(",
"valueType",
".",
"getTypeCode",
"(",
")",
"!=",
"TypeDesc",
".",
"OBJECT_CODE",
")",
"{",
"if",
"(",
"valueType",
".",
"getTypeCode",
"(",
")",
"==",
"TypeDesc",
".",
"FLOAT_CODE",
")",
"{",
"// Special treatment to handle NaN.\r",
"b",
".",
"invokeStatic",
"(",
"TypeDesc",
".",
"FLOAT",
".",
"toObjectType",
"(",
")",
",",
"\"compare\"",
",",
"TypeDesc",
".",
"INT",
",",
"new",
"TypeDesc",
"[",
"]",
"{",
"TypeDesc",
".",
"FLOAT",
",",
"TypeDesc",
".",
"FLOAT",
"}",
")",
";",
"b",
".",
"ifZeroComparisonBranch",
"(",
"label",
",",
"choice",
"?",
"\"==\"",
":",
"\"!=\"",
")",
";",
"}",
"else",
"if",
"(",
"valueType",
".",
"getTypeCode",
"(",
")",
"==",
"TypeDesc",
".",
"DOUBLE_CODE",
")",
"{",
"// Special treatment to handle NaN.\r",
"b",
".",
"invokeStatic",
"(",
"TypeDesc",
".",
"DOUBLE",
".",
"toObjectType",
"(",
")",
",",
"\"compare\"",
",",
"TypeDesc",
".",
"INT",
",",
"new",
"TypeDesc",
"[",
"]",
"{",
"TypeDesc",
".",
"DOUBLE",
",",
"TypeDesc",
".",
"DOUBLE",
"}",
")",
";",
"b",
".",
"ifZeroComparisonBranch",
"(",
"label",
",",
"choice",
"?",
"\"==\"",
":",
"\"!=\"",
")",
";",
"}",
"else",
"{",
"b",
".",
"ifComparisonBranch",
"(",
"label",
",",
"choice",
"?",
"\"==\"",
":",
"\"!=\"",
",",
"valueType",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"!",
"testForNull",
")",
"{",
"String",
"op",
"=",
"addEqualsCallTo",
"(",
"b",
",",
"valueType",
",",
"choice",
")",
";",
"b",
".",
"ifZeroComparisonBranch",
"(",
"label",
",",
"op",
")",
";",
"return",
";",
"}",
"Label",
"isNotNull",
"=",
"b",
".",
"createLabel",
"(",
")",
";",
"LocalVariable",
"value",
"=",
"b",
".",
"createLocalVariable",
"(",
"null",
",",
"valueType",
")",
";",
"b",
".",
"storeLocal",
"(",
"value",
")",
";",
"b",
".",
"loadLocal",
"(",
"value",
")",
";",
"b",
".",
"ifNullBranch",
"(",
"isNotNull",
",",
"false",
")",
";",
"// First value popped off stack is null. Just test remaining one for null.\r",
"b",
".",
"ifNullBranch",
"(",
"label",
",",
"choice",
")",
";",
"Label",
"cont",
"=",
"b",
".",
"createLabel",
"(",
")",
";",
"b",
".",
"branch",
"(",
"cont",
")",
";",
"// First value popped off stack is not null, but second one might be.\r",
"isNotNull",
".",
"setLocation",
"(",
")",
";",
"if",
"(",
"compareToType",
"(",
"valueType",
")",
"==",
"null",
")",
"{",
"// Call equals method, but swap values so that the second value is\r",
"// an argument into the equals method.\r",
"b",
".",
"loadLocal",
"(",
"value",
")",
";",
"b",
".",
"swap",
"(",
")",
";",
"}",
"else",
"{",
"// Need to test for second argument too, since compareTo method\r",
"// cannot cope with null.\r",
"LocalVariable",
"value2",
"=",
"b",
".",
"createLocalVariable",
"(",
"null",
",",
"valueType",
")",
";",
"b",
".",
"storeLocal",
"(",
"value2",
")",
";",
"b",
".",
"loadLocal",
"(",
"value2",
")",
";",
"b",
".",
"ifNullBranch",
"(",
"label",
",",
"!",
"choice",
")",
";",
"// Load both values in preparation for calling compareTo method.\r",
"b",
".",
"loadLocal",
"(",
"value",
")",
";",
"b",
".",
"loadLocal",
"(",
"value2",
")",
";",
"}",
"String",
"op",
"=",
"addEqualsCallTo",
"(",
"b",
",",
"valueType",
",",
"choice",
")",
";",
"b",
".",
"ifZeroComparisonBranch",
"(",
"label",
",",
"op",
")",
";",
"cont",
".",
"setLocation",
"(",
")",
";",
"}"
] |
Generates code to compare two values on the stack, and branch to the
provided Label if they are not equal. Both values must be of the same
type. If they are floating point values, NaN is considered equal to NaN,
which is inconsistent with the usual treatment for NaN.
<P>The generated instruction consumes both values on the stack.
@param b {@link CodeBuilder} to which to add the code
@param valueType the type of the values
@param testForNull if true and the values are references, they will be considered
unequal unless neither or both are null. If false, assume neither is null.
@param label the label to branch to
@param choice when true, branch to label if values are equal, else
branch to label if values are unequal.
|
[
"Generates",
"code",
"to",
"compare",
"two",
"values",
"on",
"the",
"stack",
"and",
"branch",
"to",
"the",
"provided",
"Label",
"if",
"they",
"are",
"not",
"equal",
".",
"Both",
"values",
"must",
"be",
"of",
"the",
"same",
"type",
".",
"If",
"they",
"are",
"floating",
"point",
"values",
"NaN",
"is",
"considered",
"equal",
"to",
"NaN",
"which",
"is",
"inconsistent",
"with",
"the",
"usual",
"treatment",
"for",
"NaN",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L521-L584
|
7,935 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.initialVersion
|
public static void initialVersion(CodeBuilder b, TypeDesc type, int value)
throws SupportException
{
adjustVersion(b, type, value, false);
}
|
java
|
public static void initialVersion(CodeBuilder b, TypeDesc type, int value)
throws SupportException
{
adjustVersion(b, type, value, false);
}
|
[
"public",
"static",
"void",
"initialVersion",
"(",
"CodeBuilder",
"b",
",",
"TypeDesc",
"type",
",",
"int",
"value",
")",
"throws",
"SupportException",
"{",
"adjustVersion",
"(",
"b",
",",
"type",
",",
"value",
",",
"false",
")",
";",
"}"
] |
Generates code to push an initial version property value on the stack.
@throws SupportException if version type is not supported
|
[
"Generates",
"code",
"to",
"push",
"an",
"initial",
"version",
"property",
"value",
"on",
"the",
"stack",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L685-L689
|
7,936 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.incrementVersion
|
public static void incrementVersion(CodeBuilder b, TypeDesc type)
throws SupportException
{
adjustVersion(b, type, 0, true);
}
|
java
|
public static void incrementVersion(CodeBuilder b, TypeDesc type)
throws SupportException
{
adjustVersion(b, type, 0, true);
}
|
[
"public",
"static",
"void",
"incrementVersion",
"(",
"CodeBuilder",
"b",
",",
"TypeDesc",
"type",
")",
"throws",
"SupportException",
"{",
"adjustVersion",
"(",
"b",
",",
"type",
",",
"0",
",",
"true",
")",
";",
"}"
] |
Generates code to increment a version property value, already on the stack.
@throws SupportException if version type is not supported
|
[
"Generates",
"code",
"to",
"increment",
"a",
"version",
"property",
"value",
"already",
"on",
"the",
"stack",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L696-L700
|
7,937 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.blankValue
|
public static void blankValue(CodeBuilder b, TypeDesc type) {
switch (type.getTypeCode()) {
default:
b.loadNull();
break;
case TypeDesc.BYTE_CODE:
case TypeDesc.CHAR_CODE:
case TypeDesc.SHORT_CODE:
case TypeDesc.INT_CODE:
b.loadConstant(0);
break;
case TypeDesc.BOOLEAN_CODE:
b.loadConstant(false);
break;
case TypeDesc.LONG_CODE:
b.loadConstant(0L);
break;
case TypeDesc.FLOAT_CODE:
b.loadConstant(0.0f);
break;
case TypeDesc.DOUBLE_CODE:
b.loadConstant(0.0);
break;
}
}
|
java
|
public static void blankValue(CodeBuilder b, TypeDesc type) {
switch (type.getTypeCode()) {
default:
b.loadNull();
break;
case TypeDesc.BYTE_CODE:
case TypeDesc.CHAR_CODE:
case TypeDesc.SHORT_CODE:
case TypeDesc.INT_CODE:
b.loadConstant(0);
break;
case TypeDesc.BOOLEAN_CODE:
b.loadConstant(false);
break;
case TypeDesc.LONG_CODE:
b.loadConstant(0L);
break;
case TypeDesc.FLOAT_CODE:
b.loadConstant(0.0f);
break;
case TypeDesc.DOUBLE_CODE:
b.loadConstant(0.0);
break;
}
}
|
[
"public",
"static",
"void",
"blankValue",
"(",
"CodeBuilder",
"b",
",",
"TypeDesc",
"type",
")",
"{",
"switch",
"(",
"type",
".",
"getTypeCode",
"(",
")",
")",
"{",
"default",
":",
"b",
".",
"loadNull",
"(",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"BYTE_CODE",
":",
"case",
"TypeDesc",
".",
"CHAR_CODE",
":",
"case",
"TypeDesc",
".",
"SHORT_CODE",
":",
"case",
"TypeDesc",
".",
"INT_CODE",
":",
"b",
".",
"loadConstant",
"(",
"0",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"BOOLEAN_CODE",
":",
"b",
".",
"loadConstant",
"(",
"false",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"LONG_CODE",
":",
"b",
".",
"loadConstant",
"(",
"0L",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"FLOAT_CODE",
":",
"b",
".",
"loadConstant",
"(",
"0.0f",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"DOUBLE_CODE",
":",
"b",
".",
"loadConstant",
"(",
"0.0",
")",
";",
"break",
";",
"}",
"}"
] |
Generates code to push a blank value to the stack. For objects, it is
null, and for primitive types it is zero or false.
|
[
"Generates",
"code",
"to",
"push",
"a",
"blank",
"value",
"to",
"the",
"stack",
".",
"For",
"objects",
"it",
"is",
"null",
"and",
"for",
"primitive",
"types",
"it",
"is",
"zero",
"or",
"false",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L756-L786
|
7,938 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.bindQueryParam
|
public static TypeDesc bindQueryParam(Class clazz) {
// This method is a bit vestigial. Once upon a time the Query class did
// not support all primitive types.
if (clazz.isPrimitive()) {
TypeDesc type = TypeDesc.forClass(clazz);
switch (type.getTypeCode()) {
case TypeDesc.INT_CODE:
case TypeDesc.LONG_CODE:
case TypeDesc.FLOAT_CODE:
case TypeDesc.DOUBLE_CODE:
case TypeDesc.BOOLEAN_CODE:
case TypeDesc.CHAR_CODE:
case TypeDesc.BYTE_CODE:
case TypeDesc.SHORT_CODE:
return type;
}
}
return TypeDesc.OBJECT;
}
|
java
|
public static TypeDesc bindQueryParam(Class clazz) {
// This method is a bit vestigial. Once upon a time the Query class did
// not support all primitive types.
if (clazz.isPrimitive()) {
TypeDesc type = TypeDesc.forClass(clazz);
switch (type.getTypeCode()) {
case TypeDesc.INT_CODE:
case TypeDesc.LONG_CODE:
case TypeDesc.FLOAT_CODE:
case TypeDesc.DOUBLE_CODE:
case TypeDesc.BOOLEAN_CODE:
case TypeDesc.CHAR_CODE:
case TypeDesc.BYTE_CODE:
case TypeDesc.SHORT_CODE:
return type;
}
}
return TypeDesc.OBJECT;
}
|
[
"public",
"static",
"TypeDesc",
"bindQueryParam",
"(",
"Class",
"clazz",
")",
"{",
"// This method is a bit vestigial. Once upon a time the Query class did\r",
"// not support all primitive types.\r",
"if",
"(",
"clazz",
".",
"isPrimitive",
"(",
")",
")",
"{",
"TypeDesc",
"type",
"=",
"TypeDesc",
".",
"forClass",
"(",
"clazz",
")",
";",
"switch",
"(",
"type",
".",
"getTypeCode",
"(",
")",
")",
"{",
"case",
"TypeDesc",
".",
"INT_CODE",
":",
"case",
"TypeDesc",
".",
"LONG_CODE",
":",
"case",
"TypeDesc",
".",
"FLOAT_CODE",
":",
"case",
"TypeDesc",
".",
"DOUBLE_CODE",
":",
"case",
"TypeDesc",
".",
"BOOLEAN_CODE",
":",
"case",
"TypeDesc",
".",
"CHAR_CODE",
":",
"case",
"TypeDesc",
".",
"BYTE_CODE",
":",
"case",
"TypeDesc",
".",
"SHORT_CODE",
":",
"return",
"type",
";",
"}",
"}",
"return",
"TypeDesc",
".",
"OBJECT",
";",
"}"
] |
Determines which overloaded "with" method on Query should be bound to.
|
[
"Determines",
"which",
"overloaded",
"with",
"method",
"on",
"Query",
"should",
"be",
"bound",
"to",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L791-L809
|
7,939 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.callStringBuilderAppendString
|
public static void callStringBuilderAppendString(CodeBuilder b) {
// Because of JDK1.5 bug which exposes AbstractStringBuilder class,
// cannot use reflection to get method signature.
TypeDesc stringBuilder = TypeDesc.forClass(StringBuilder.class);
b.invokeVirtual(stringBuilder, "append", stringBuilder, new TypeDesc[] {TypeDesc.STRING});
}
|
java
|
public static void callStringBuilderAppendString(CodeBuilder b) {
// Because of JDK1.5 bug which exposes AbstractStringBuilder class,
// cannot use reflection to get method signature.
TypeDesc stringBuilder = TypeDesc.forClass(StringBuilder.class);
b.invokeVirtual(stringBuilder, "append", stringBuilder, new TypeDesc[] {TypeDesc.STRING});
}
|
[
"public",
"static",
"void",
"callStringBuilderAppendString",
"(",
"CodeBuilder",
"b",
")",
"{",
"// Because of JDK1.5 bug which exposes AbstractStringBuilder class,\r",
"// cannot use reflection to get method signature.\r",
"TypeDesc",
"stringBuilder",
"=",
"TypeDesc",
".",
"forClass",
"(",
"StringBuilder",
".",
"class",
")",
";",
"b",
".",
"invokeVirtual",
"(",
"stringBuilder",
",",
"\"append\"",
",",
"stringBuilder",
",",
"new",
"TypeDesc",
"[",
"]",
"{",
"TypeDesc",
".",
"STRING",
"}",
")",
";",
"}"
] |
Appends a String to a StringBuilder. A StringBuilder and String must be
on the stack, and a StringBuilder is left on the stack after the call.
|
[
"Appends",
"a",
"String",
"to",
"a",
"StringBuilder",
".",
"A",
"StringBuilder",
"and",
"String",
"must",
"be",
"on",
"the",
"stack",
"and",
"a",
"StringBuilder",
"is",
"left",
"on",
"the",
"stack",
"after",
"the",
"call",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L815-L820
|
7,940 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.callStringBuilderAppendChar
|
public static void callStringBuilderAppendChar(CodeBuilder b) {
// Because of JDK1.5 bug which exposes AbstractStringBuilder class,
// cannot use reflection to get method signature.
TypeDesc stringBuilder = TypeDesc.forClass(StringBuilder.class);
b.invokeVirtual(stringBuilder, "append", stringBuilder, new TypeDesc[] {TypeDesc.CHAR});
}
|
java
|
public static void callStringBuilderAppendChar(CodeBuilder b) {
// Because of JDK1.5 bug which exposes AbstractStringBuilder class,
// cannot use reflection to get method signature.
TypeDesc stringBuilder = TypeDesc.forClass(StringBuilder.class);
b.invokeVirtual(stringBuilder, "append", stringBuilder, new TypeDesc[] {TypeDesc.CHAR});
}
|
[
"public",
"static",
"void",
"callStringBuilderAppendChar",
"(",
"CodeBuilder",
"b",
")",
"{",
"// Because of JDK1.5 bug which exposes AbstractStringBuilder class,\r",
"// cannot use reflection to get method signature.\r",
"TypeDesc",
"stringBuilder",
"=",
"TypeDesc",
".",
"forClass",
"(",
"StringBuilder",
".",
"class",
")",
";",
"b",
".",
"invokeVirtual",
"(",
"stringBuilder",
",",
"\"append\"",
",",
"stringBuilder",
",",
"new",
"TypeDesc",
"[",
"]",
"{",
"TypeDesc",
".",
"CHAR",
"}",
")",
";",
"}"
] |
Appends a char to a StringBuilder. A StringBuilder and char must be on
the stack, and a StringBuilder is left on the stack after the call.
|
[
"Appends",
"a",
"char",
"to",
"a",
"StringBuilder",
".",
"A",
"StringBuilder",
"and",
"char",
"must",
"be",
"on",
"the",
"stack",
"and",
"a",
"StringBuilder",
"is",
"left",
"on",
"the",
"stack",
"after",
"the",
"call",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L826-L831
|
7,941 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.callStringBuilderLength
|
public static void callStringBuilderLength(CodeBuilder b) {
// Because of JDK1.5 bug which exposes AbstractStringBuilder class,
// cannot use reflection to get method signature.
TypeDesc stringBuilder = TypeDesc.forClass(StringBuilder.class);
b.invokeVirtual(stringBuilder, "length", TypeDesc.INT, null);
}
|
java
|
public static void callStringBuilderLength(CodeBuilder b) {
// Because of JDK1.5 bug which exposes AbstractStringBuilder class,
// cannot use reflection to get method signature.
TypeDesc stringBuilder = TypeDesc.forClass(StringBuilder.class);
b.invokeVirtual(stringBuilder, "length", TypeDesc.INT, null);
}
|
[
"public",
"static",
"void",
"callStringBuilderLength",
"(",
"CodeBuilder",
"b",
")",
"{",
"// Because of JDK1.5 bug which exposes AbstractStringBuilder class,\r",
"// cannot use reflection to get method signature.\r",
"TypeDesc",
"stringBuilder",
"=",
"TypeDesc",
".",
"forClass",
"(",
"StringBuilder",
".",
"class",
")",
";",
"b",
".",
"invokeVirtual",
"(",
"stringBuilder",
",",
"\"length\"",
",",
"TypeDesc",
".",
"INT",
",",
"null",
")",
";",
"}"
] |
Calls length on a StringBuilder on the stack, leaving an int on the stack.
|
[
"Calls",
"length",
"on",
"a",
"StringBuilder",
"on",
"the",
"stack",
"leaving",
"an",
"int",
"on",
"the",
"stack",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L836-L841
|
7,942 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java
|
CodeBuilderUtil.callStringBuilderToString
|
public static void callStringBuilderToString(CodeBuilder b) {
// Because of JDK1.5 bug which exposes AbstractStringBuilder class,
// cannot use reflection to get method signature.
TypeDesc stringBuilder = TypeDesc.forClass(StringBuilder.class);
b.invokeVirtual(stringBuilder, "toString", TypeDesc.STRING, null);
}
|
java
|
public static void callStringBuilderToString(CodeBuilder b) {
// Because of JDK1.5 bug which exposes AbstractStringBuilder class,
// cannot use reflection to get method signature.
TypeDesc stringBuilder = TypeDesc.forClass(StringBuilder.class);
b.invokeVirtual(stringBuilder, "toString", TypeDesc.STRING, null);
}
|
[
"public",
"static",
"void",
"callStringBuilderToString",
"(",
"CodeBuilder",
"b",
")",
"{",
"// Because of JDK1.5 bug which exposes AbstractStringBuilder class,\r",
"// cannot use reflection to get method signature.\r",
"TypeDesc",
"stringBuilder",
"=",
"TypeDesc",
".",
"forClass",
"(",
"StringBuilder",
".",
"class",
")",
";",
"b",
".",
"invokeVirtual",
"(",
"stringBuilder",
",",
"\"toString\"",
",",
"TypeDesc",
".",
"STRING",
",",
"null",
")",
";",
"}"
] |
Calls toString on a StringBuilder. A StringBuilder must be on the stack,
and a String is left on the stack after the call.
|
[
"Calls",
"toString",
"on",
"a",
"StringBuilder",
".",
"A",
"StringBuilder",
"must",
"be",
"on",
"the",
"stack",
"and",
"a",
"String",
"is",
"left",
"on",
"the",
"stack",
"after",
"the",
"call",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/gen/CodeBuilderUtil.java#L858-L863
|
7,943 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/constraints/DisjunctiveConstraint.java
|
DisjunctiveConstraint.create
|
public static <Type> DisjunctiveConstraint<Type> create(
@NonNull final Constraint<Type>[] constraints) {
return new DisjunctiveConstraint<>(constraints);
}
|
java
|
public static <Type> DisjunctiveConstraint<Type> create(
@NonNull final Constraint<Type>[] constraints) {
return new DisjunctiveConstraint<>(constraints);
}
|
[
"public",
"static",
"<",
"Type",
">",
"DisjunctiveConstraint",
"<",
"Type",
">",
"create",
"(",
"@",
"NonNull",
"final",
"Constraint",
"<",
"Type",
">",
"[",
"]",
"constraints",
")",
"{",
"return",
"new",
"DisjunctiveConstraint",
"<>",
"(",
"constraints",
")",
";",
"}"
] |
Creates and returns a constraint, which allows to combine multiple constraints in a
disjunctive manner.
@param <Type>
The type of the values, which should be verified
@param constraints
The single constraints, the constraint should consist of, as an array of the type
{@link Constraint}. The constraints may neither be null, nor empty
@return The constraint, which has been created, as an instance of the class {@link
DisjunctiveConstraint}
|
[
"Creates",
"and",
"returns",
"a",
"constraint",
"which",
"allows",
"to",
"combine",
"multiple",
"constraints",
"in",
"a",
"disjunctive",
"manner",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/constraints/DisjunctiveConstraint.java#L60-L63
|
7,944 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/constraints/DisjunctiveConstraint.java
|
DisjunctiveConstraint.setConstraints
|
public final void setConstraints(@NonNull final Constraint<Type>[] constraints) {
Condition.INSTANCE.ensureNotNull(constraints, "The constraints may not be null");
Condition.INSTANCE.ensureAtLeast(constraints.length, 1, "The constraints may not be empty");
this.constraints = constraints;
}
|
java
|
public final void setConstraints(@NonNull final Constraint<Type>[] constraints) {
Condition.INSTANCE.ensureNotNull(constraints, "The constraints may not be null");
Condition.INSTANCE.ensureAtLeast(constraints.length, 1, "The constraints may not be empty");
this.constraints = constraints;
}
|
[
"public",
"final",
"void",
"setConstraints",
"(",
"@",
"NonNull",
"final",
"Constraint",
"<",
"Type",
">",
"[",
"]",
"constraints",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"constraints",
",",
"\"The constraints may not be null\"",
")",
";",
"Condition",
".",
"INSTANCE",
".",
"ensureAtLeast",
"(",
"constraints",
".",
"length",
",",
"1",
",",
"\"The constraints may not be empty\"",
")",
";",
"this",
".",
"constraints",
"=",
"constraints",
";",
"}"
] |
Sets the single constraints, the constraint should consist of.
@param constraints
The single constraints, which should be set, as an array of the type {@link
Constraint}. The constraints may neither be null, nor empty
|
[
"Sets",
"the",
"single",
"constraints",
"the",
"constraint",
"should",
"consist",
"of",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/constraints/DisjunctiveConstraint.java#L82-L86
|
7,945 |
cose-wg/COSE-JAVA
|
src/main/java/COSE/OneKey.java
|
OneKey.HasAlgorithmID
|
public boolean HasAlgorithmID(AlgorithmID algorithmId) {
CBORObject thisObj = get(KeyKeys.Algorithm);
CBORObject thatObj = (algorithmId == null ? null : algorithmId.AsCBOR());
boolean result;
if (thatObj == null) {
result = (thisObj == null);
} else {
result = thatObj.equals(thisObj);
}
return result;
}
|
java
|
public boolean HasAlgorithmID(AlgorithmID algorithmId) {
CBORObject thisObj = get(KeyKeys.Algorithm);
CBORObject thatObj = (algorithmId == null ? null : algorithmId.AsCBOR());
boolean result;
if (thatObj == null) {
result = (thisObj == null);
} else {
result = thatObj.equals(thisObj);
}
return result;
}
|
[
"public",
"boolean",
"HasAlgorithmID",
"(",
"AlgorithmID",
"algorithmId",
")",
"{",
"CBORObject",
"thisObj",
"=",
"get",
"(",
"KeyKeys",
".",
"Algorithm",
")",
";",
"CBORObject",
"thatObj",
"=",
"(",
"algorithmId",
"==",
"null",
"?",
"null",
":",
"algorithmId",
".",
"AsCBOR",
"(",
")",
")",
";",
"boolean",
"result",
";",
"if",
"(",
"thatObj",
"==",
"null",
")",
"{",
"result",
"=",
"(",
"thisObj",
"==",
"null",
")",
";",
"}",
"else",
"{",
"result",
"=",
"thatObj",
".",
"equals",
"(",
"thisObj",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Compares the key's assigned algorithm with the provided value, indicating if the values are the
same.
@param algorithmId
the algorithm to compare or {@code null} to check for no assignment.
@return {@code true} if the current key has the provided algorithm assigned, or {@code false}
otherwise
|
[
"Compares",
"the",
"key",
"s",
"assigned",
"algorithm",
"with",
"the",
"provided",
"value",
"indicating",
"if",
"the",
"values",
"are",
"the",
"same",
"."
] |
f972b11ab4c9a18f911bc49a15225a6951cf6f63
|
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/OneKey.java#L155-L166
|
7,946 |
cose-wg/COSE-JAVA
|
src/main/java/COSE/OneKey.java
|
OneKey.HasKeyID
|
public boolean HasKeyID(String id) {
CBORObject thatObj = (id == null) ? null : CBORObject.FromObject(id);
CBORObject thisObj = get(KeyKeys.KeyId);
boolean result;
if (thatObj == null) {
result = (thisObj == null);
} else {
result = thatObj.equals(thisObj);
}
return result;
}
|
java
|
public boolean HasKeyID(String id) {
CBORObject thatObj = (id == null) ? null : CBORObject.FromObject(id);
CBORObject thisObj = get(KeyKeys.KeyId);
boolean result;
if (thatObj == null) {
result = (thisObj == null);
} else {
result = thatObj.equals(thisObj);
}
return result;
}
|
[
"public",
"boolean",
"HasKeyID",
"(",
"String",
"id",
")",
"{",
"CBORObject",
"thatObj",
"=",
"(",
"id",
"==",
"null",
")",
"?",
"null",
":",
"CBORObject",
".",
"FromObject",
"(",
"id",
")",
";",
"CBORObject",
"thisObj",
"=",
"get",
"(",
"KeyKeys",
".",
"KeyId",
")",
";",
"boolean",
"result",
";",
"if",
"(",
"thatObj",
"==",
"null",
")",
"{",
"result",
"=",
"(",
"thisObj",
"==",
"null",
")",
";",
"}",
"else",
"{",
"result",
"=",
"thatObj",
".",
"equals",
"(",
"thisObj",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Compares the key's assigned identifier with the provided value, indicating if the values are
the same.
@param id
the identifier to compare or {@code null} to check for no assignment.
@return {@code true} if the current key has the provided identifier assigned, or {@code false}
otherwise
|
[
"Compares",
"the",
"key",
"s",
"assigned",
"identifier",
"with",
"the",
"provided",
"value",
"indicating",
"if",
"the",
"values",
"are",
"the",
"same",
"."
] |
f972b11ab4c9a18f911bc49a15225a6951cf6f63
|
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/OneKey.java#L177-L187
|
7,947 |
cose-wg/COSE-JAVA
|
src/main/java/COSE/OneKey.java
|
OneKey.HasKeyType
|
public boolean HasKeyType(CBORObject keyTypeObj) {
CBORObject thatObj = keyTypeObj;
CBORObject thisObj = get(KeyKeys.KeyType);
boolean result;
if (thatObj == null) {
result = (thisObj == null);
} else {
result = thatObj.equals(thisObj);
}
return result;
}
|
java
|
public boolean HasKeyType(CBORObject keyTypeObj) {
CBORObject thatObj = keyTypeObj;
CBORObject thisObj = get(KeyKeys.KeyType);
boolean result;
if (thatObj == null) {
result = (thisObj == null);
} else {
result = thatObj.equals(thisObj);
}
return result;
}
|
[
"public",
"boolean",
"HasKeyType",
"(",
"CBORObject",
"keyTypeObj",
")",
"{",
"CBORObject",
"thatObj",
"=",
"keyTypeObj",
";",
"CBORObject",
"thisObj",
"=",
"get",
"(",
"KeyKeys",
".",
"KeyType",
")",
";",
"boolean",
"result",
";",
"if",
"(",
"thatObj",
"==",
"null",
")",
"{",
"result",
"=",
"(",
"thisObj",
"==",
"null",
")",
";",
"}",
"else",
"{",
"result",
"=",
"thatObj",
".",
"equals",
"(",
"thisObj",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Compares the key's assigned key type with the provided value, indicating if the values are the
same.
@param keyTypeObj
the key type to compare or {@code null} to check for no assignment.
@return {@code true} if the current key has the provided identifier assigned, or {@code false}
otherwise
|
[
"Compares",
"the",
"key",
"s",
"assigned",
"key",
"type",
"with",
"the",
"provided",
"value",
"indicating",
"if",
"the",
"values",
"are",
"the",
"same",
"."
] |
f972b11ab4c9a18f911bc49a15225a6951cf6f63
|
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/OneKey.java#L198-L208
|
7,948 |
cose-wg/COSE-JAVA
|
src/main/java/COSE/OneKey.java
|
OneKey.HasKeyOp
|
public boolean HasKeyOp(Integer that) {
CBORObject thisObj = get(KeyKeys.Key_Ops);
boolean result;
if (that == null) {
result = (thisObj == null);
} else {
result = false;
if (thisObj.getType() == CBORType.Number) {
if (thisObj.AsInt32() == that) {
result = true;
}
} else if (thisObj.getType() == CBORType.Array) {
for (int i = 0; i < thisObj.size(); i++) {
if ((thisObj.get(i).getType() == CBORType.Number) && (thisObj.get(i).AsInt32() == that)) {
result = true;
break;
}
}
}
}
return result;
}
|
java
|
public boolean HasKeyOp(Integer that) {
CBORObject thisObj = get(KeyKeys.Key_Ops);
boolean result;
if (that == null) {
result = (thisObj == null);
} else {
result = false;
if (thisObj.getType() == CBORType.Number) {
if (thisObj.AsInt32() == that) {
result = true;
}
} else if (thisObj.getType() == CBORType.Array) {
for (int i = 0; i < thisObj.size(); i++) {
if ((thisObj.get(i).getType() == CBORType.Number) && (thisObj.get(i).AsInt32() == that)) {
result = true;
break;
}
}
}
}
return result;
}
|
[
"public",
"boolean",
"HasKeyOp",
"(",
"Integer",
"that",
")",
"{",
"CBORObject",
"thisObj",
"=",
"get",
"(",
"KeyKeys",
".",
"Key_Ops",
")",
";",
"boolean",
"result",
";",
"if",
"(",
"that",
"==",
"null",
")",
"{",
"result",
"=",
"(",
"thisObj",
"==",
"null",
")",
";",
"}",
"else",
"{",
"result",
"=",
"false",
";",
"if",
"(",
"thisObj",
".",
"getType",
"(",
")",
"==",
"CBORType",
".",
"Number",
")",
"{",
"if",
"(",
"thisObj",
".",
"AsInt32",
"(",
")",
"==",
"that",
")",
"{",
"result",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"thisObj",
".",
"getType",
"(",
")",
"==",
"CBORType",
".",
"Array",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"thisObj",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"(",
"thisObj",
".",
"get",
"(",
"i",
")",
".",
"getType",
"(",
")",
"==",
"CBORType",
".",
"Number",
")",
"&&",
"(",
"thisObj",
".",
"get",
"(",
"i",
")",
".",
"AsInt32",
"(",
")",
"==",
"that",
")",
")",
"{",
"result",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Compares the key's assigned key operations with the provided value, indicating if the provided
value was found in the key operation values assigned to the key.
@param that
the integer operation value to attempt to find in the values provided by the key or
{@code null} to check for no assignment.
@return {@code true} if the current key has the provided value assigned, or {@code false}
otherwise
|
[
"Compares",
"the",
"key",
"s",
"assigned",
"key",
"operations",
"with",
"the",
"provided",
"value",
"indicating",
"if",
"the",
"provided",
"value",
"was",
"found",
"in",
"the",
"key",
"operation",
"values",
"assigned",
"to",
"the",
"key",
"."
] |
f972b11ab4c9a18f911bc49a15225a6951cf6f63
|
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/OneKey.java#L220-L241
|
7,949 |
cose-wg/COSE-JAVA
|
src/main/java/COSE/OneKey.java
|
OneKey.PublicKey
|
public OneKey PublicKey()
{
OneKey newKey = new OneKey();
CBORObject val = this.get(KeyKeys.KeyType);
if (val.equals(KeyKeys.KeyType_Octet)) {
return null;
}
else if (val.equals(KeyKeys.KeyType_EC2)) {
newKey.add(KeyKeys.EC2_Curve, get(KeyKeys.EC2_Curve));
newKey.add(KeyKeys.EC2_X, get(KeyKeys.EC2_X));
newKey.add(KeyKeys.EC2_Y, get(KeyKeys.EC2_Y));
}
/*
else if (val.equals(KeyKeys.KeyType_OKP)) {
newKey.add(KeyKeys.OKP_Curve, get(KeyKeys.OKP_Curve));
newKey.add(KeyKeys.OKP_X, get(KeyKeys.OKP_X));
}
*/
else {
return null;
}
// Allow them to use the same underlying public key object
newKey.publicKey = publicKey;
for (CBORObject obj : keyMap.getKeys()) {
val = keyMap.get(obj);
if (obj.getType() == CBORType.Number) {
if (obj.AsInt32() > 0) {
newKey.add(obj, val);
}
}
else if (obj.getType() == CBORType.TextString) {
newKey.add(obj, val);
}
}
return newKey;
}
|
java
|
public OneKey PublicKey()
{
OneKey newKey = new OneKey();
CBORObject val = this.get(KeyKeys.KeyType);
if (val.equals(KeyKeys.KeyType_Octet)) {
return null;
}
else if (val.equals(KeyKeys.KeyType_EC2)) {
newKey.add(KeyKeys.EC2_Curve, get(KeyKeys.EC2_Curve));
newKey.add(KeyKeys.EC2_X, get(KeyKeys.EC2_X));
newKey.add(KeyKeys.EC2_Y, get(KeyKeys.EC2_Y));
}
/*
else if (val.equals(KeyKeys.KeyType_OKP)) {
newKey.add(KeyKeys.OKP_Curve, get(KeyKeys.OKP_Curve));
newKey.add(KeyKeys.OKP_X, get(KeyKeys.OKP_X));
}
*/
else {
return null;
}
// Allow them to use the same underlying public key object
newKey.publicKey = publicKey;
for (CBORObject obj : keyMap.getKeys()) {
val = keyMap.get(obj);
if (obj.getType() == CBORType.Number) {
if (obj.AsInt32() > 0) {
newKey.add(obj, val);
}
}
else if (obj.getType() == CBORType.TextString) {
newKey.add(obj, val);
}
}
return newKey;
}
|
[
"public",
"OneKey",
"PublicKey",
"(",
")",
"{",
"OneKey",
"newKey",
"=",
"new",
"OneKey",
"(",
")",
";",
"CBORObject",
"val",
"=",
"this",
".",
"get",
"(",
"KeyKeys",
".",
"KeyType",
")",
";",
"if",
"(",
"val",
".",
"equals",
"(",
"KeyKeys",
".",
"KeyType_Octet",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"val",
".",
"equals",
"(",
"KeyKeys",
".",
"KeyType_EC2",
")",
")",
"{",
"newKey",
".",
"add",
"(",
"KeyKeys",
".",
"EC2_Curve",
",",
"get",
"(",
"KeyKeys",
".",
"EC2_Curve",
")",
")",
";",
"newKey",
".",
"add",
"(",
"KeyKeys",
".",
"EC2_X",
",",
"get",
"(",
"KeyKeys",
".",
"EC2_X",
")",
")",
";",
"newKey",
".",
"add",
"(",
"KeyKeys",
".",
"EC2_Y",
",",
"get",
"(",
"KeyKeys",
".",
"EC2_Y",
")",
")",
";",
"}",
"/*\n else if (val.equals(KeyKeys.KeyType_OKP)) {\n newKey.add(KeyKeys.OKP_Curve, get(KeyKeys.OKP_Curve));\n newKey.add(KeyKeys.OKP_X, get(KeyKeys.OKP_X));\n }\n */",
"else",
"{",
"return",
"null",
";",
"}",
"// Allow them to use the same underlying public key object",
"newKey",
".",
"publicKey",
"=",
"publicKey",
";",
"for",
"(",
"CBORObject",
"obj",
":",
"keyMap",
".",
"getKeys",
"(",
")",
")",
"{",
"val",
"=",
"keyMap",
".",
"get",
"(",
"obj",
")",
";",
"if",
"(",
"obj",
".",
"getType",
"(",
")",
"==",
"CBORType",
".",
"Number",
")",
"{",
"if",
"(",
"obj",
".",
"AsInt32",
"(",
")",
">",
"0",
")",
"{",
"newKey",
".",
"add",
"(",
"obj",
",",
"val",
")",
";",
"}",
"}",
"else",
"if",
"(",
"obj",
".",
"getType",
"(",
")",
"==",
"CBORType",
".",
"TextString",
")",
"{",
"newKey",
".",
"add",
"(",
"obj",
",",
"val",
")",
";",
"}",
"}",
"return",
"newKey",
";",
"}"
] |
Create a OneKey object with only the public fields. Filters out the
private key fields but leaves all positive number labels and text labels
along with negative number labels that are public fields.
@return public version of the key
|
[
"Create",
"a",
"OneKey",
"object",
"with",
"only",
"the",
"public",
"fields",
".",
"Filters",
"out",
"the",
"private",
"key",
"fields",
"but",
"leaves",
"all",
"positive",
"number",
"labels",
"and",
"text",
"labels",
"along",
"with",
"negative",
"number",
"labels",
"that",
"are",
"public",
"fields",
"."
] |
f972b11ab4c9a18f911bc49a15225a6951cf6f63
|
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/OneKey.java#L621-L659
|
7,950 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/OrderingList.java
|
OrderingList.get
|
public static <S extends Storable> OrderingList<S> get(Class<S> type, String property) {
OrderingList<S> list = emptyList();
if (property != null) {
list = list.concat(type, property);
}
return list;
}
|
java
|
public static <S extends Storable> OrderingList<S> get(Class<S> type, String property) {
OrderingList<S> list = emptyList();
if (property != null) {
list = list.concat(type, property);
}
return list;
}
|
[
"public",
"static",
"<",
"S",
"extends",
"Storable",
">",
"OrderingList",
"<",
"S",
">",
"get",
"(",
"Class",
"<",
"S",
">",
"type",
",",
"String",
"property",
")",
"{",
"OrderingList",
"<",
"S",
">",
"list",
"=",
"emptyList",
"(",
")",
";",
"if",
"(",
"property",
"!=",
"null",
")",
"{",
"list",
"=",
"list",
".",
"concat",
"(",
"type",
",",
"property",
")",
";",
"}",
"return",
"list",
";",
"}"
] |
Returns a canonical instance composed of the given ordering.
@throws IllegalArgumentException if ordering property is not in S
|
[
"Returns",
"a",
"canonical",
"instance",
"composed",
"of",
"the",
"given",
"ordering",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/OrderingList.java#L74-L80
|
7,951 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/OrderingList.java
|
OrderingList.concat
|
public OrderingList<S> concat(OrderingList<S> other) {
if (size() == 0) {
return other;
}
OrderingList<S> newList = this;
if (other.size() > 0) {
for (OrderedProperty<S> property : other) {
newList = newList.concat(property);
}
}
return newList;
}
|
java
|
public OrderingList<S> concat(OrderingList<S> other) {
if (size() == 0) {
return other;
}
OrderingList<S> newList = this;
if (other.size() > 0) {
for (OrderedProperty<S> property : other) {
newList = newList.concat(property);
}
}
return newList;
}
|
[
"public",
"OrderingList",
"<",
"S",
">",
"concat",
"(",
"OrderingList",
"<",
"S",
">",
"other",
")",
"{",
"if",
"(",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"other",
";",
"}",
"OrderingList",
"<",
"S",
">",
"newList",
"=",
"this",
";",
"if",
"(",
"other",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"OrderedProperty",
"<",
"S",
">",
"property",
":",
"other",
")",
"{",
"newList",
"=",
"newList",
".",
"concat",
"(",
"property",
")",
";",
"}",
"}",
"return",
"newList",
";",
"}"
] |
Returns a list which concatenates this one with the other one.
|
[
"Returns",
"a",
"list",
"which",
"concatenates",
"this",
"one",
"with",
"the",
"other",
"one",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/OrderingList.java#L197-L208
|
7,952 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/OrderingList.java
|
OrderingList.reduce
|
public OrderingList<S> reduce() {
if (size() == 0) {
return this;
}
Set<ChainedProperty<S>> seen = new HashSet<ChainedProperty<S>>();
OrderingList<S> newList = emptyList();
for (OrderedProperty<S> property : this) {
ChainedProperty<S> chained = property.getChainedProperty();
if (!seen.contains(chained)) {
newList = newList.concat(property);
seen.add(chained);
}
}
return newList;
}
|
java
|
public OrderingList<S> reduce() {
if (size() == 0) {
return this;
}
Set<ChainedProperty<S>> seen = new HashSet<ChainedProperty<S>>();
OrderingList<S> newList = emptyList();
for (OrderedProperty<S> property : this) {
ChainedProperty<S> chained = property.getChainedProperty();
if (!seen.contains(chained)) {
newList = newList.concat(property);
seen.add(chained);
}
}
return newList;
}
|
[
"public",
"OrderingList",
"<",
"S",
">",
"reduce",
"(",
")",
"{",
"if",
"(",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"Set",
"<",
"ChainedProperty",
"<",
"S",
">",
">",
"seen",
"=",
"new",
"HashSet",
"<",
"ChainedProperty",
"<",
"S",
">",
">",
"(",
")",
";",
"OrderingList",
"<",
"S",
">",
"newList",
"=",
"emptyList",
"(",
")",
";",
"for",
"(",
"OrderedProperty",
"<",
"S",
">",
"property",
":",
"this",
")",
"{",
"ChainedProperty",
"<",
"S",
">",
"chained",
"=",
"property",
".",
"getChainedProperty",
"(",
")",
";",
"if",
"(",
"!",
"seen",
".",
"contains",
"(",
"chained",
")",
")",
"{",
"newList",
"=",
"newList",
".",
"concat",
"(",
"property",
")",
";",
"seen",
".",
"add",
"(",
"chained",
")",
";",
"}",
"}",
"return",
"newList",
";",
"}"
] |
Eliminates redundant ordering properties.
|
[
"Eliminates",
"redundant",
"ordering",
"properties",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/OrderingList.java#L213-L230
|
7,953 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/OrderingList.java
|
OrderingList.reverseDirections
|
public OrderingList<S> reverseDirections() {
if (size() == 0) {
return this;
}
OrderingList<S> reversedList = emptyList();
for (int i=0; i<size(); i++) {
reversedList = reversedList.concat(get(i).reverse());
}
return reversedList;
}
|
java
|
public OrderingList<S> reverseDirections() {
if (size() == 0) {
return this;
}
OrderingList<S> reversedList = emptyList();
for (int i=0; i<size(); i++) {
reversedList = reversedList.concat(get(i).reverse());
}
return reversedList;
}
|
[
"public",
"OrderingList",
"<",
"S",
">",
"reverseDirections",
"(",
")",
"{",
"if",
"(",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"OrderingList",
"<",
"S",
">",
"reversedList",
"=",
"emptyList",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"reversedList",
"=",
"reversedList",
".",
"concat",
"(",
"get",
"(",
"i",
")",
".",
"reverse",
"(",
")",
")",
";",
"}",
"return",
"reversedList",
";",
"}"
] |
Returns this list with all orderings in reverse.
|
[
"Returns",
"this",
"list",
"with",
"all",
"orderings",
"in",
"reverse",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/OrderingList.java#L235-L244
|
7,954 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/OrderingList.java
|
OrderingList.replace
|
public OrderingList<S> replace(int index, OrderedProperty<S> property) {
int size = size();
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException();
}
OrderingList<S> newList = emptyList();
for (int i=0; i<size; i++) {
newList = newList.concat(i == index ? property : get(i));
}
return newList;
}
|
java
|
public OrderingList<S> replace(int index, OrderedProperty<S> property) {
int size = size();
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException();
}
OrderingList<S> newList = emptyList();
for (int i=0; i<size; i++) {
newList = newList.concat(i == index ? property : get(i));
}
return newList;
}
|
[
"public",
"OrderingList",
"<",
"S",
">",
"replace",
"(",
"int",
"index",
",",
"OrderedProperty",
"<",
"S",
">",
"property",
")",
"{",
"int",
"size",
"=",
"size",
"(",
")",
";",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">=",
"size",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"OrderingList",
"<",
"S",
">",
"newList",
"=",
"emptyList",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"newList",
"=",
"newList",
".",
"concat",
"(",
"i",
"==",
"index",
"?",
"property",
":",
"get",
"(",
"i",
")",
")",
";",
"}",
"return",
"newList",
";",
"}"
] |
Returns a list with the given element replaced.
|
[
"Returns",
"a",
"list",
"with",
"the",
"given",
"element",
"replaced",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/OrderingList.java#L249-L259
|
7,955 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/OrderingList.java
|
OrderingList.asArray
|
OrderedProperty<S>[] asArray() {
if (mOrderings == null) {
OrderedProperty<S>[] orderings = new OrderedProperty[mSize];
OrderingList<S> node = this;
for (int i=mSize; --i>=0; ) {
orderings[i] = node.mProperty;
node = node.mParent;
}
mOrderings = orderings;
}
return mOrderings;
}
|
java
|
OrderedProperty<S>[] asArray() {
if (mOrderings == null) {
OrderedProperty<S>[] orderings = new OrderedProperty[mSize];
OrderingList<S> node = this;
for (int i=mSize; --i>=0; ) {
orderings[i] = node.mProperty;
node = node.mParent;
}
mOrderings = orderings;
}
return mOrderings;
}
|
[
"OrderedProperty",
"<",
"S",
">",
"[",
"]",
"asArray",
"(",
")",
"{",
"if",
"(",
"mOrderings",
"==",
"null",
")",
"{",
"OrderedProperty",
"<",
"S",
">",
"[",
"]",
"orderings",
"=",
"new",
"OrderedProperty",
"[",
"mSize",
"]",
";",
"OrderingList",
"<",
"S",
">",
"node",
"=",
"this",
";",
"for",
"(",
"int",
"i",
"=",
"mSize",
";",
"--",
"i",
">=",
"0",
";",
")",
"{",
"orderings",
"[",
"i",
"]",
"=",
"node",
".",
"mProperty",
";",
"node",
"=",
"node",
".",
"mParent",
";",
"}",
"mOrderings",
"=",
"orderings",
";",
"}",
"return",
"mOrderings",
";",
"}"
] |
This method is not public because the array is not a clone.
|
[
"This",
"method",
"is",
"not",
"public",
"because",
"the",
"array",
"is",
"not",
"a",
"clone",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/OrderingList.java#L281-L292
|
7,956 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/OrderingList.java
|
OrderingList.asStringArray
|
String[] asStringArray() {
if (mOrderingStrings == null) {
String[] orderings = new String[mSize];
OrderingList<S> node = this;
for (int i=mSize; --i>=0; ) {
orderings[i] = node.mProperty.toString();
node = node.mParent;
}
mOrderingStrings = orderings;
}
return mOrderingStrings;
}
|
java
|
String[] asStringArray() {
if (mOrderingStrings == null) {
String[] orderings = new String[mSize];
OrderingList<S> node = this;
for (int i=mSize; --i>=0; ) {
orderings[i] = node.mProperty.toString();
node = node.mParent;
}
mOrderingStrings = orderings;
}
return mOrderingStrings;
}
|
[
"String",
"[",
"]",
"asStringArray",
"(",
")",
"{",
"if",
"(",
"mOrderingStrings",
"==",
"null",
")",
"{",
"String",
"[",
"]",
"orderings",
"=",
"new",
"String",
"[",
"mSize",
"]",
";",
"OrderingList",
"<",
"S",
">",
"node",
"=",
"this",
";",
"for",
"(",
"int",
"i",
"=",
"mSize",
";",
"--",
"i",
">=",
"0",
";",
")",
"{",
"orderings",
"[",
"i",
"]",
"=",
"node",
".",
"mProperty",
".",
"toString",
"(",
")",
";",
"node",
"=",
"node",
".",
"mParent",
";",
"}",
"mOrderingStrings",
"=",
"orderings",
";",
"}",
"return",
"mOrderingStrings",
";",
"}"
] |
Returns the orderings as qualified string property names. Each is
prefixed with a '+' or '-'.
<p>This method is not public because the array is not a clone.
|
[
"Returns",
"the",
"orderings",
"as",
"qualified",
"string",
"property",
"names",
".",
"Each",
"is",
"prefixed",
"with",
"a",
"+",
"or",
"-",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/OrderingList.java#L300-L311
|
7,957 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
|
SyntheticStorableReferenceBuilder.getReferenceAccess
|
public SyntheticStorableReferenceAccess<S> getReferenceAccess() {
if (mReferenceAccess == null) {
Class<? extends Storable> referenceClass = mBuilder.getStorableClass();
mReferenceAccess = new SyntheticStorableReferenceAccess<S>
(mMasterStorableClass, referenceClass, this);
}
return mReferenceAccess;
}
|
java
|
public SyntheticStorableReferenceAccess<S> getReferenceAccess() {
if (mReferenceAccess == null) {
Class<? extends Storable> referenceClass = mBuilder.getStorableClass();
mReferenceAccess = new SyntheticStorableReferenceAccess<S>
(mMasterStorableClass, referenceClass, this);
}
return mReferenceAccess;
}
|
[
"public",
"SyntheticStorableReferenceAccess",
"<",
"S",
">",
"getReferenceAccess",
"(",
")",
"{",
"if",
"(",
"mReferenceAccess",
"==",
"null",
")",
"{",
"Class",
"<",
"?",
"extends",
"Storable",
">",
"referenceClass",
"=",
"mBuilder",
".",
"getStorableClass",
"(",
")",
";",
"mReferenceAccess",
"=",
"new",
"SyntheticStorableReferenceAccess",
"<",
"S",
">",
"(",
"mMasterStorableClass",
",",
"referenceClass",
",",
"this",
")",
";",
"}",
"return",
"mReferenceAccess",
";",
"}"
] |
Build and return access to the generated storable reference class.
@since 1.2.1
|
[
"Build",
"and",
"return",
"access",
"to",
"the",
"generated",
"storable",
"reference",
"class",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java#L209-L216
|
7,958 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
|
SyntheticStorableReferenceBuilder.addKeyProperty
|
public SyntheticProperty addKeyProperty(String name, Direction direction) {
StorableProperty<S> prop = mMasterStorableInfo.getAllProperties().get(name);
if (prop == null) {
throw new IllegalArgumentException(name + " is not a property of "
+ mMasterStorableInfo.getName());
}
mPrimaryKey.addProperty(name, direction);
SyntheticProperty result = addProperty(prop);
mUserProps.add(result);
return result;
}
|
java
|
public SyntheticProperty addKeyProperty(String name, Direction direction) {
StorableProperty<S> prop = mMasterStorableInfo.getAllProperties().get(name);
if (prop == null) {
throw new IllegalArgumentException(name + " is not a property of "
+ mMasterStorableInfo.getName());
}
mPrimaryKey.addProperty(name, direction);
SyntheticProperty result = addProperty(prop);
mUserProps.add(result);
return result;
}
|
[
"public",
"SyntheticProperty",
"addKeyProperty",
"(",
"String",
"name",
",",
"Direction",
"direction",
")",
"{",
"StorableProperty",
"<",
"S",
">",
"prop",
"=",
"mMasterStorableInfo",
".",
"getAllProperties",
"(",
")",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"prop",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"name",
"+",
"\" is not a property of \"",
"+",
"mMasterStorableInfo",
".",
"getName",
"(",
")",
")",
";",
"}",
"mPrimaryKey",
".",
"addProperty",
"(",
"name",
",",
"direction",
")",
";",
"SyntheticProperty",
"result",
"=",
"addProperty",
"(",
"prop",
")",
";",
"mUserProps",
".",
"add",
"(",
"result",
")",
";",
"return",
"result",
";",
"}"
] |
Add a property to the primary key which is a member of the Storable type
being referenced by this one.
@param name
|
[
"Add",
"a",
"property",
"to",
"the",
"primary",
"key",
"which",
"is",
"a",
"member",
"of",
"the",
"Storable",
"type",
"being",
"referenced",
"by",
"this",
"one",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java#L243-L255
|
7,959 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
|
SyntheticStorableReferenceBuilder.copyToMasterPrimaryKey
|
@Deprecated
public void copyToMasterPrimaryKey(Storable indexEntry, S master) throws FetchException {
getReferenceAccess().copyToMasterPrimaryKey(indexEntry, master);
}
|
java
|
@Deprecated
public void copyToMasterPrimaryKey(Storable indexEntry, S master) throws FetchException {
getReferenceAccess().copyToMasterPrimaryKey(indexEntry, master);
}
|
[
"@",
"Deprecated",
"public",
"void",
"copyToMasterPrimaryKey",
"(",
"Storable",
"indexEntry",
",",
"S",
"master",
")",
"throws",
"FetchException",
"{",
"getReferenceAccess",
"(",
")",
".",
"copyToMasterPrimaryKey",
"(",
"indexEntry",
",",
"master",
")",
";",
"}"
] |
Sets all the primary key properties of the given master, using the
applicable properties of the given index entry.
@param indexEntry source of property values
@param master master whose primary key properties will be set
@deprecated call getReferenceAccess
|
[
"Sets",
"all",
"the",
"primary",
"key",
"properties",
"of",
"the",
"given",
"master",
"using",
"the",
"applicable",
"properties",
"of",
"the",
"given",
"index",
"entry",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java#L353-L356
|
7,960 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
|
SyntheticStorableReferenceBuilder.copyFromMaster
|
@Deprecated
public void copyFromMaster(Storable indexEntry, S master) throws FetchException {
getReferenceAccess().copyFromMaster(indexEntry, master);
}
|
java
|
@Deprecated
public void copyFromMaster(Storable indexEntry, S master) throws FetchException {
getReferenceAccess().copyFromMaster(indexEntry, master);
}
|
[
"@",
"Deprecated",
"public",
"void",
"copyFromMaster",
"(",
"Storable",
"indexEntry",
",",
"S",
"master",
")",
"throws",
"FetchException",
"{",
"getReferenceAccess",
"(",
")",
".",
"copyFromMaster",
"(",
"indexEntry",
",",
"master",
")",
";",
"}"
] |
Sets all the properties of the given index entry, using the applicable
properties of the given master.
@param indexEntry index entry whose properties will be set
@param master source of property values
@deprecated call getReferenceAccess
|
[
"Sets",
"all",
"the",
"properties",
"of",
"the",
"given",
"index",
"entry",
"using",
"the",
"applicable",
"properties",
"of",
"the",
"given",
"master",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java#L366-L369
|
7,961 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
|
SyntheticStorableReferenceBuilder.isConsistent
|
@Deprecated
public boolean isConsistent(Storable indexEntry, S master) throws FetchException {
return getReferenceAccess().isConsistent(indexEntry, master);
}
|
java
|
@Deprecated
public boolean isConsistent(Storable indexEntry, S master) throws FetchException {
return getReferenceAccess().isConsistent(indexEntry, master);
}
|
[
"@",
"Deprecated",
"public",
"boolean",
"isConsistent",
"(",
"Storable",
"indexEntry",
",",
"S",
"master",
")",
"throws",
"FetchException",
"{",
"return",
"getReferenceAccess",
"(",
")",
".",
"isConsistent",
"(",
"indexEntry",
",",
"master",
")",
";",
"}"
] |
Returns true if the properties of the given index entry match those
contained in the master, excluding any version property. This will
always return true after a call to copyFromMaster.
@param indexEntry
index entry whose properties will be tested
@param master
source of property values
@deprecated call getReferenceAccess
|
[
"Returns",
"true",
"if",
"the",
"properties",
"of",
"the",
"given",
"index",
"entry",
"match",
"those",
"contained",
"in",
"the",
"master",
"excluding",
"any",
"version",
"property",
".",
"This",
"will",
"always",
"return",
"true",
"after",
"a",
"call",
"to",
"copyFromMaster",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java#L382-L385
|
7,962 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
|
SyntheticStorableReferenceBuilder.addSpecialMethods
|
private void addSpecialMethods(ClassFile cf) throws SupportException {
// Generate safe names for special methods.
{
mCopyToMasterPkMethodName =
generateSafeMethodName(mMasterStorableInfo, COPY_TO_MASTER_PK_PREFIX);
mCopyFromMasterMethodName =
generateSafeMethodName(mMasterStorableInfo, COPY_FROM_MASTER_PREFIX);
mIsConsistentMethodName =
generateSafeMethodName(mMasterStorableInfo, IS_CONSISTENT_PREFIX);
}
// Add methods which copies properties between master and index entry.
addCopyMethod(cf, mCopyFromMasterMethodName);
addCopyMethod(cf, mCopyToMasterPkMethodName);
TypeDesc masterStorableType = TypeDesc.forClass(mMasterStorableClass);
// Add a method which tests all properties of index entry object
// against master object, excluding version and derived properties.
{
TypeDesc[] params = new TypeDesc[] {masterStorableType};
MethodInfo mi = cf.addMethod
(Modifiers.PUBLIC, mIsConsistentMethodName, TypeDesc.BOOLEAN, params);
CodeBuilder b = new CodeBuilder(mi);
for (StorableProperty prop : mCommonProps) {
if (prop.isVersion() || prop.isDerived()) {
continue;
}
Label propsAreEqual = b.createLabel();
addPropertyTest(b, prop, b.getParameter(0), propsAreEqual);
propsAreEqual.setLocation();
}
b.loadConstant(true);
b.returnValue(TypeDesc.BOOLEAN);
}
}
|
java
|
private void addSpecialMethods(ClassFile cf) throws SupportException {
// Generate safe names for special methods.
{
mCopyToMasterPkMethodName =
generateSafeMethodName(mMasterStorableInfo, COPY_TO_MASTER_PK_PREFIX);
mCopyFromMasterMethodName =
generateSafeMethodName(mMasterStorableInfo, COPY_FROM_MASTER_PREFIX);
mIsConsistentMethodName =
generateSafeMethodName(mMasterStorableInfo, IS_CONSISTENT_PREFIX);
}
// Add methods which copies properties between master and index entry.
addCopyMethod(cf, mCopyFromMasterMethodName);
addCopyMethod(cf, mCopyToMasterPkMethodName);
TypeDesc masterStorableType = TypeDesc.forClass(mMasterStorableClass);
// Add a method which tests all properties of index entry object
// against master object, excluding version and derived properties.
{
TypeDesc[] params = new TypeDesc[] {masterStorableType};
MethodInfo mi = cf.addMethod
(Modifiers.PUBLIC, mIsConsistentMethodName, TypeDesc.BOOLEAN, params);
CodeBuilder b = new CodeBuilder(mi);
for (StorableProperty prop : mCommonProps) {
if (prop.isVersion() || prop.isDerived()) {
continue;
}
Label propsAreEqual = b.createLabel();
addPropertyTest(b, prop, b.getParameter(0), propsAreEqual);
propsAreEqual.setLocation();
}
b.loadConstant(true);
b.returnValue(TypeDesc.BOOLEAN);
}
}
|
[
"private",
"void",
"addSpecialMethods",
"(",
"ClassFile",
"cf",
")",
"throws",
"SupportException",
"{",
"// Generate safe names for special methods.\r",
"{",
"mCopyToMasterPkMethodName",
"=",
"generateSafeMethodName",
"(",
"mMasterStorableInfo",
",",
"COPY_TO_MASTER_PK_PREFIX",
")",
";",
"mCopyFromMasterMethodName",
"=",
"generateSafeMethodName",
"(",
"mMasterStorableInfo",
",",
"COPY_FROM_MASTER_PREFIX",
")",
";",
"mIsConsistentMethodName",
"=",
"generateSafeMethodName",
"(",
"mMasterStorableInfo",
",",
"IS_CONSISTENT_PREFIX",
")",
";",
"}",
"// Add methods which copies properties between master and index entry.\r",
"addCopyMethod",
"(",
"cf",
",",
"mCopyFromMasterMethodName",
")",
";",
"addCopyMethod",
"(",
"cf",
",",
"mCopyToMasterPkMethodName",
")",
";",
"TypeDesc",
"masterStorableType",
"=",
"TypeDesc",
".",
"forClass",
"(",
"mMasterStorableClass",
")",
";",
"// Add a method which tests all properties of index entry object\r",
"// against master object, excluding version and derived properties.\r",
"{",
"TypeDesc",
"[",
"]",
"params",
"=",
"new",
"TypeDesc",
"[",
"]",
"{",
"masterStorableType",
"}",
";",
"MethodInfo",
"mi",
"=",
"cf",
".",
"addMethod",
"(",
"Modifiers",
".",
"PUBLIC",
",",
"mIsConsistentMethodName",
",",
"TypeDesc",
".",
"BOOLEAN",
",",
"params",
")",
";",
"CodeBuilder",
"b",
"=",
"new",
"CodeBuilder",
"(",
"mi",
")",
";",
"for",
"(",
"StorableProperty",
"prop",
":",
"mCommonProps",
")",
"{",
"if",
"(",
"prop",
".",
"isVersion",
"(",
")",
"||",
"prop",
".",
"isDerived",
"(",
")",
")",
"{",
"continue",
";",
"}",
"Label",
"propsAreEqual",
"=",
"b",
".",
"createLabel",
"(",
")",
";",
"addPropertyTest",
"(",
"b",
",",
"prop",
",",
"b",
".",
"getParameter",
"(",
"0",
")",
",",
"propsAreEqual",
")",
";",
"propsAreEqual",
".",
"setLocation",
"(",
")",
";",
"}",
"b",
".",
"loadConstant",
"(",
"true",
")",
";",
"b",
".",
"returnValue",
"(",
"TypeDesc",
".",
"BOOLEAN",
")",
";",
"}",
"}"
] |
Create methods for copying properties and testing properties.
@throws amazon.carbonado.SupportException
|
[
"Create",
"methods",
"for",
"copying",
"properties",
"and",
"testing",
"properties",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java#L401-L440
|
7,963 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
|
SyntheticStorableReferenceBuilder.generateSafeMethodName
|
private String generateSafeMethodName(StorableInfo info, String prefix) {
Class type = info.getStorableType();
// Try a few times to generate a unique name. There's nothing special
// about choosing 100 as the limit.
int value = 0;
for (int i = 0; i < 100; i++) {
String name = prefix + value;
if (!methodExists(type, name)) {
return name;
}
value = name.hashCode();
}
throw new InternalError("Unable to create unique method name starting with: "
+ prefix);
}
|
java
|
private String generateSafeMethodName(StorableInfo info, String prefix) {
Class type = info.getStorableType();
// Try a few times to generate a unique name. There's nothing special
// about choosing 100 as the limit.
int value = 0;
for (int i = 0; i < 100; i++) {
String name = prefix + value;
if (!methodExists(type, name)) {
return name;
}
value = name.hashCode();
}
throw new InternalError("Unable to create unique method name starting with: "
+ prefix);
}
|
[
"private",
"String",
"generateSafeMethodName",
"(",
"StorableInfo",
"info",
",",
"String",
"prefix",
")",
"{",
"Class",
"type",
"=",
"info",
".",
"getStorableType",
"(",
")",
";",
"// Try a few times to generate a unique name. There's nothing special\r",
"// about choosing 100 as the limit.\r",
"int",
"value",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"100",
";",
"i",
"++",
")",
"{",
"String",
"name",
"=",
"prefix",
"+",
"value",
";",
"if",
"(",
"!",
"methodExists",
"(",
"type",
",",
"name",
")",
")",
"{",
"return",
"name",
";",
"}",
"value",
"=",
"name",
".",
"hashCode",
"(",
")",
";",
"}",
"throw",
"new",
"InternalError",
"(",
"\"Unable to create unique method name starting with: \"",
"+",
"prefix",
")",
";",
"}"
] |
Generates a property name which doesn't clash with any already defined.
|
[
"Generates",
"a",
"property",
"name",
"which",
"doesn",
"t",
"clash",
"with",
"any",
"already",
"defined",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java#L523-L539
|
7,964 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java
|
SyntheticStorableReferenceBuilder.methodExists
|
private boolean methodExists(Class clazz, String name) {
Method[] methods = clazz.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equals(name)) {
return true;
}
}
if (clazz.getSuperclass() != null
&& methodExists(clazz.getSuperclass(), name)) {
return true;
}
Class[] interfaces = clazz.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
if (methodExists(interfaces[i], name)) {
return true;
}
}
return false;
}
|
java
|
private boolean methodExists(Class clazz, String name) {
Method[] methods = clazz.getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equals(name)) {
return true;
}
}
if (clazz.getSuperclass() != null
&& methodExists(clazz.getSuperclass(), name)) {
return true;
}
Class[] interfaces = clazz.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
if (methodExists(interfaces[i], name)) {
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"methodExists",
"(",
"Class",
"clazz",
",",
"String",
"name",
")",
"{",
"Method",
"[",
"]",
"methods",
"=",
"clazz",
".",
"getDeclaredMethods",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"methods",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"methods",
"[",
"i",
"]",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"if",
"(",
"clazz",
".",
"getSuperclass",
"(",
")",
"!=",
"null",
"&&",
"methodExists",
"(",
"clazz",
".",
"getSuperclass",
"(",
")",
",",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"Class",
"[",
"]",
"interfaces",
"=",
"clazz",
".",
"getInterfaces",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"interfaces",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"methodExists",
"(",
"interfaces",
"[",
"i",
"]",
",",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Look for conflicting method names
|
[
"Look",
"for",
"conflicting",
"method",
"names"
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/synthetic/SyntheticStorableReferenceBuilder.java#L544-L565
|
7,965 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/util/AbstractWeakPool.java
|
AbstractWeakPool.remove
|
public V remove(Object key) {
clean();
ValueRef<K, V> valueRef = mValues.remove(key);
V value;
if (valueRef != null && (value = valueRef.get()) != null) {
valueRef.clear();
return value;
}
return null;
}
|
java
|
public V remove(Object key) {
clean();
ValueRef<K, V> valueRef = mValues.remove(key);
V value;
if (valueRef != null && (value = valueRef.get()) != null) {
valueRef.clear();
return value;
}
return null;
}
|
[
"public",
"V",
"remove",
"(",
"Object",
"key",
")",
"{",
"clean",
"(",
")",
";",
"ValueRef",
"<",
"K",
",",
"V",
">",
"valueRef",
"=",
"mValues",
".",
"remove",
"(",
"key",
")",
";",
"V",
"value",
";",
"if",
"(",
"valueRef",
"!=",
"null",
"&&",
"(",
"value",
"=",
"valueRef",
".",
"get",
"(",
")",
")",
"!=",
"null",
")",
"{",
"valueRef",
".",
"clear",
"(",
")",
";",
"return",
"value",
";",
"}",
"return",
"null",
";",
"}"
] |
Manually remove a value, returning the old value.
|
[
"Manually",
"remove",
"a",
"value",
"returning",
"the",
"old",
"value",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/util/AbstractWeakPool.java#L107-L119
|
7,966 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/EmptyQuery.java
|
EmptyQuery.withValues
|
@Override
public Query<S> withValues(Object... values) {
if (values == null || values.length == 0) {
return this;
}
throw error();
}
|
java
|
@Override
public Query<S> withValues(Object... values) {
if (values == null || values.length == 0) {
return this;
}
throw error();
}
|
[
"@",
"Override",
"public",
"Query",
"<",
"S",
">",
"withValues",
"(",
"Object",
"...",
"values",
")",
"{",
"if",
"(",
"values",
"==",
"null",
"||",
"values",
".",
"length",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"throw",
"error",
"(",
")",
";",
"}"
] |
Throws an IllegalStateException unless no values passed in.
|
[
"Throws",
"an",
"IllegalStateException",
"unless",
"no",
"values",
"passed",
"in",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/EmptyQuery.java#L188-L194
|
7,967 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/EmptyQuery.java
|
EmptyQuery.not
|
@Override
public Query<S> not() throws FetchException {
return mFactory.query(null, null, mOrdering, null);
}
|
java
|
@Override
public Query<S> not() throws FetchException {
return mFactory.query(null, null, mOrdering, null);
}
|
[
"@",
"Override",
"public",
"Query",
"<",
"S",
">",
"not",
"(",
")",
"throws",
"FetchException",
"{",
"return",
"mFactory",
".",
"query",
"(",
"null",
",",
"null",
",",
"mOrdering",
",",
"null",
")",
";",
"}"
] |
Returns a query that fetches everything, possibly in a specified order.
|
[
"Returns",
"a",
"query",
"that",
"fetches",
"everything",
"possibly",
"in",
"a",
"specified",
"order",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/EmptyQuery.java#L212-L215
|
7,968 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/validators/DisjunctiveValidator.java
|
DisjunctiveValidator.setValidators
|
@SafeVarargs
public final void setValidators(@NonNull final Validator<Type>... validators) {
Condition.INSTANCE.ensureNotNull(validators, "The validators may not be null");
Condition.INSTANCE.ensureAtLeast(validators.length, 1, "The validators may not be empty");
this.validators = validators;
}
|
java
|
@SafeVarargs
public final void setValidators(@NonNull final Validator<Type>... validators) {
Condition.INSTANCE.ensureNotNull(validators, "The validators may not be null");
Condition.INSTANCE.ensureAtLeast(validators.length, 1, "The validators may not be empty");
this.validators = validators;
}
|
[
"@",
"SafeVarargs",
"public",
"final",
"void",
"setValidators",
"(",
"@",
"NonNull",
"final",
"Validator",
"<",
"Type",
">",
"...",
"validators",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"validators",
",",
"\"The validators may not be null\"",
")",
";",
"Condition",
".",
"INSTANCE",
".",
"ensureAtLeast",
"(",
"validators",
".",
"length",
",",
"1",
",",
"\"The validators may not be empty\"",
")",
";",
"this",
".",
"validators",
"=",
"validators",
";",
"}"
] |
Sets the single validators, the validator should consist of.
@param validators
The single validators, which should be set, as an array of the type {@link
Validator}. The validators may neither be null, nor empty
|
[
"Sets",
"the",
"single",
"validators",
"the",
"validator",
"should",
"consist",
"of",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/validators/DisjunctiveValidator.java#L143-L148
|
7,969 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/spi/TriggerManager.java
|
TriggerManager.selectTypes
|
private int selectTypes(Trigger<? super S> trigger) {
Class<? extends Trigger> triggerClass = trigger.getClass();
int types = 0;
if (overridesOneMethod(triggerClass, INSERT_METHODS)) {
types |= FOR_INSERT;
}
if (overridesOneMethod(triggerClass, UPDATE_METHODS)) {
types |= FOR_UPDATE;
}
if (overridesOneMethod(triggerClass, DELETE_METHODS)) {
types |= FOR_DELETE;
}
if (overridesMethod(triggerClass, AFTER_LOAD_METHOD)) {
types |= FOR_LOAD;
}
return types;
}
|
java
|
private int selectTypes(Trigger<? super S> trigger) {
Class<? extends Trigger> triggerClass = trigger.getClass();
int types = 0;
if (overridesOneMethod(triggerClass, INSERT_METHODS)) {
types |= FOR_INSERT;
}
if (overridesOneMethod(triggerClass, UPDATE_METHODS)) {
types |= FOR_UPDATE;
}
if (overridesOneMethod(triggerClass, DELETE_METHODS)) {
types |= FOR_DELETE;
}
if (overridesMethod(triggerClass, AFTER_LOAD_METHOD)) {
types |= FOR_LOAD;
}
return types;
}
|
[
"private",
"int",
"selectTypes",
"(",
"Trigger",
"<",
"?",
"super",
"S",
">",
"trigger",
")",
"{",
"Class",
"<",
"?",
"extends",
"Trigger",
">",
"triggerClass",
"=",
"trigger",
".",
"getClass",
"(",
")",
";",
"int",
"types",
"=",
"0",
";",
"if",
"(",
"overridesOneMethod",
"(",
"triggerClass",
",",
"INSERT_METHODS",
")",
")",
"{",
"types",
"|=",
"FOR_INSERT",
";",
"}",
"if",
"(",
"overridesOneMethod",
"(",
"triggerClass",
",",
"UPDATE_METHODS",
")",
")",
"{",
"types",
"|=",
"FOR_UPDATE",
";",
"}",
"if",
"(",
"overridesOneMethod",
"(",
"triggerClass",
",",
"DELETE_METHODS",
")",
")",
"{",
"types",
"|=",
"FOR_DELETE",
";",
"}",
"if",
"(",
"overridesMethod",
"(",
"triggerClass",
",",
"AFTER_LOAD_METHOD",
")",
")",
"{",
"types",
"|=",
"FOR_LOAD",
";",
"}",
"return",
"types",
";",
"}"
] |
Determines which operations the given trigger overrides.
|
[
"Determines",
"which",
"operations",
"the",
"given",
"trigger",
"overrides",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/spi/TriggerManager.java#L425-L447
|
7,970 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java
|
JoinedQueryExecutor.build
|
public static <T extends Storable> QueryExecutor<T>
build(RepositoryAccess repoAccess,
ChainedProperty<T> targetToSourceProperty,
Filter<T> targetFilter,
OrderingList<T> targetOrdering,
QueryHints hints)
throws RepositoryException
{
if (targetOrdering == null) {
targetOrdering = OrderingList.emptyList();
}
QueryExecutor<T> executor =
buildJoin(repoAccess, targetToSourceProperty, targetFilter, targetOrdering, hints);
OrderingList<T> handledOrdering = executor.getOrdering();
// Apply sort if any remaining ordering properties.
int handledCount = commonOrderingCount(handledOrdering, targetOrdering);
OrderingList<T> remainderOrdering =
targetOrdering.subList(handledCount, targetOrdering.size());
if (remainderOrdering.size() > 0) {
SortedQueryExecutor.Support<T> support = repoAccess
.storageAccessFor(targetToSourceProperty.getPrimeProperty().getEnclosingType());
executor = new SortedQueryExecutor<T>
(support, executor, handledOrdering, remainderOrdering);
}
return executor;
}
|
java
|
public static <T extends Storable> QueryExecutor<T>
build(RepositoryAccess repoAccess,
ChainedProperty<T> targetToSourceProperty,
Filter<T> targetFilter,
OrderingList<T> targetOrdering,
QueryHints hints)
throws RepositoryException
{
if (targetOrdering == null) {
targetOrdering = OrderingList.emptyList();
}
QueryExecutor<T> executor =
buildJoin(repoAccess, targetToSourceProperty, targetFilter, targetOrdering, hints);
OrderingList<T> handledOrdering = executor.getOrdering();
// Apply sort if any remaining ordering properties.
int handledCount = commonOrderingCount(handledOrdering, targetOrdering);
OrderingList<T> remainderOrdering =
targetOrdering.subList(handledCount, targetOrdering.size());
if (remainderOrdering.size() > 0) {
SortedQueryExecutor.Support<T> support = repoAccess
.storageAccessFor(targetToSourceProperty.getPrimeProperty().getEnclosingType());
executor = new SortedQueryExecutor<T>
(support, executor, handledOrdering, remainderOrdering);
}
return executor;
}
|
[
"public",
"static",
"<",
"T",
"extends",
"Storable",
">",
"QueryExecutor",
"<",
"T",
">",
"build",
"(",
"RepositoryAccess",
"repoAccess",
",",
"ChainedProperty",
"<",
"T",
">",
"targetToSourceProperty",
",",
"Filter",
"<",
"T",
">",
"targetFilter",
",",
"OrderingList",
"<",
"T",
">",
"targetOrdering",
",",
"QueryHints",
"hints",
")",
"throws",
"RepositoryException",
"{",
"if",
"(",
"targetOrdering",
"==",
"null",
")",
"{",
"targetOrdering",
"=",
"OrderingList",
".",
"emptyList",
"(",
")",
";",
"}",
"QueryExecutor",
"<",
"T",
">",
"executor",
"=",
"buildJoin",
"(",
"repoAccess",
",",
"targetToSourceProperty",
",",
"targetFilter",
",",
"targetOrdering",
",",
"hints",
")",
";",
"OrderingList",
"<",
"T",
">",
"handledOrdering",
"=",
"executor",
".",
"getOrdering",
"(",
")",
";",
"// Apply sort if any remaining ordering properties.\r",
"int",
"handledCount",
"=",
"commonOrderingCount",
"(",
"handledOrdering",
",",
"targetOrdering",
")",
";",
"OrderingList",
"<",
"T",
">",
"remainderOrdering",
"=",
"targetOrdering",
".",
"subList",
"(",
"handledCount",
",",
"targetOrdering",
".",
"size",
"(",
")",
")",
";",
"if",
"(",
"remainderOrdering",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"SortedQueryExecutor",
".",
"Support",
"<",
"T",
">",
"support",
"=",
"repoAccess",
".",
"storageAccessFor",
"(",
"targetToSourceProperty",
".",
"getPrimeProperty",
"(",
")",
".",
"getEnclosingType",
"(",
")",
")",
";",
"executor",
"=",
"new",
"SortedQueryExecutor",
"<",
"T",
">",
"(",
"support",
",",
"executor",
",",
"handledOrdering",
",",
"remainderOrdering",
")",
";",
"}",
"return",
"executor",
";",
"}"
] |
Builds and returns a complex joined excutor against a chained property,
supporting multi-way joins. Filtering and ordering may also be supplied,
in order to better distribute work throughout the join.
@param repoAccess used to create query executors for outer and inner loops
@param targetToSourceProperty join property of <i>target</i> type which maps
to instances of <i>source</i> type
@param targetFilter optional filter for fetching <i>target</i> instances
@param targetOrdering optional ordering to apply to <i>target</i> executor
& @param hints optional hints
@throws IllegalArgumentException if any parameter is null or if join
property is not a Storable type
@throws RepositoryException from RepositoryAccess
|
[
"Builds",
"and",
"returns",
"a",
"complex",
"joined",
"excutor",
"against",
"a",
"chained",
"property",
"supporting",
"multi",
"-",
"way",
"joins",
".",
"Filtering",
"and",
"ordering",
"may",
"also",
"be",
"supplied",
"in",
"order",
"to",
"better",
"distribute",
"work",
"throughout",
"the",
"join",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java#L87-L118
|
7,971 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java
|
JoinedQueryExecutor.mostOrdering
|
private static <T extends Storable> OrderingList
mostOrdering(StorableProperty<T> primeTarget, OrderingList<T> targetOrdering)
{
OrderingList handledOrdering = OrderingList.emptyList();
for (OrderedProperty<T> targetProp : targetOrdering) {
ChainedProperty<T> chainedProp = targetProp.getChainedProperty();
if (chainedProp.getPrimeProperty().equals(primeTarget)) {
handledOrdering = handledOrdering
// I hate Java generics. Note the stupid cast. I have finally
// realized the core problem: the wildcard model is broken.
.concat(OrderedProperty
.get((ChainedProperty) chainedProp.tail(),
targetProp.getDirection()));
} else {
break;
}
}
return handledOrdering;
}
|
java
|
private static <T extends Storable> OrderingList
mostOrdering(StorableProperty<T> primeTarget, OrderingList<T> targetOrdering)
{
OrderingList handledOrdering = OrderingList.emptyList();
for (OrderedProperty<T> targetProp : targetOrdering) {
ChainedProperty<T> chainedProp = targetProp.getChainedProperty();
if (chainedProp.getPrimeProperty().equals(primeTarget)) {
handledOrdering = handledOrdering
// I hate Java generics. Note the stupid cast. I have finally
// realized the core problem: the wildcard model is broken.
.concat(OrderedProperty
.get((ChainedProperty) chainedProp.tail(),
targetProp.getDirection()));
} else {
break;
}
}
return handledOrdering;
}
|
[
"private",
"static",
"<",
"T",
"extends",
"Storable",
">",
"OrderingList",
"mostOrdering",
"(",
"StorableProperty",
"<",
"T",
">",
"primeTarget",
",",
"OrderingList",
"<",
"T",
">",
"targetOrdering",
")",
"{",
"OrderingList",
"handledOrdering",
"=",
"OrderingList",
".",
"emptyList",
"(",
")",
";",
"for",
"(",
"OrderedProperty",
"<",
"T",
">",
"targetProp",
":",
"targetOrdering",
")",
"{",
"ChainedProperty",
"<",
"T",
">",
"chainedProp",
"=",
"targetProp",
".",
"getChainedProperty",
"(",
")",
";",
"if",
"(",
"chainedProp",
".",
"getPrimeProperty",
"(",
")",
".",
"equals",
"(",
"primeTarget",
")",
")",
"{",
"handledOrdering",
"=",
"handledOrdering",
"// I hate Java generics. Note the stupid cast. I have finally\r",
"// realized the core problem: the wildcard model is broken.\r",
".",
"concat",
"(",
"OrderedProperty",
".",
"get",
"(",
"(",
"ChainedProperty",
")",
"chainedProp",
".",
"tail",
"(",
")",
",",
"targetProp",
".",
"getDirection",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"return",
"handledOrdering",
";",
"}"
] |
Given a list of chained ordering properties, returns the properties
stripped of the matching chain prefix for the targetToSourceProperty. As
the target ordering is scanned left-to-right, if any property is found
which doesn't match the targetToSourceProperty, the building of the new
list stops. In other words, it returns a consecutive run of matching
properties.
|
[
"Given",
"a",
"list",
"of",
"chained",
"ordering",
"properties",
"returns",
"the",
"properties",
"stripped",
"of",
"the",
"matching",
"chain",
"prefix",
"for",
"the",
"targetToSourceProperty",
".",
"As",
"the",
"target",
"ordering",
"is",
"scanned",
"left",
"-",
"to",
"-",
"right",
"if",
"any",
"property",
"is",
"found",
"which",
"doesn",
"t",
"match",
"the",
"targetToSourceProperty",
"the",
"building",
"of",
"the",
"new",
"list",
"stops",
".",
"In",
"other",
"words",
"it",
"returns",
"a",
"consecutive",
"run",
"of",
"matching",
"properties",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java#L386-L405
|
7,972 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java
|
JoinedQueryExecutor.expectedOrdering
|
private static <T extends Storable> OrderingList<T>
expectedOrdering(StorageAccess<T> access, Filter<T> filter, OrderingList<T> ordering)
{
List<Filter<T>> split;
if (filter == null) {
split = Filter.getOpenFilter(access.getStorableType()).disjunctiveNormalFormSplit();
} else {
split = filter.disjunctiveNormalFormSplit();
}
Comparator comparator = CompositeScore.fullComparator();
CompositeScore bestScore = null;
for (StorableIndex<T> index : access.getAllIndexes()) {
for (Filter<T> sub : split) {
CompositeScore candidateScore = CompositeScore.evaluate(index, sub, ordering);
if (bestScore == null || comparator.compare(candidateScore, bestScore) < 0) {
bestScore = candidateScore;
}
}
}
// Reduce source ordering to that which can be handled for
// free. Otherwise, a sort would be performed which is a waste of time
// if some source results will later be filtered out.
int handledCount = bestScore == null ? 0 : bestScore.getOrderingScore().getHandledCount();
return ordering.subList(0, handledCount);
}
|
java
|
private static <T extends Storable> OrderingList<T>
expectedOrdering(StorageAccess<T> access, Filter<T> filter, OrderingList<T> ordering)
{
List<Filter<T>> split;
if (filter == null) {
split = Filter.getOpenFilter(access.getStorableType()).disjunctiveNormalFormSplit();
} else {
split = filter.disjunctiveNormalFormSplit();
}
Comparator comparator = CompositeScore.fullComparator();
CompositeScore bestScore = null;
for (StorableIndex<T> index : access.getAllIndexes()) {
for (Filter<T> sub : split) {
CompositeScore candidateScore = CompositeScore.evaluate(index, sub, ordering);
if (bestScore == null || comparator.compare(candidateScore, bestScore) < 0) {
bestScore = candidateScore;
}
}
}
// Reduce source ordering to that which can be handled for
// free. Otherwise, a sort would be performed which is a waste of time
// if some source results will later be filtered out.
int handledCount = bestScore == null ? 0 : bestScore.getOrderingScore().getHandledCount();
return ordering.subList(0, handledCount);
}
|
[
"private",
"static",
"<",
"T",
"extends",
"Storable",
">",
"OrderingList",
"<",
"T",
">",
"expectedOrdering",
"(",
"StorageAccess",
"<",
"T",
">",
"access",
",",
"Filter",
"<",
"T",
">",
"filter",
",",
"OrderingList",
"<",
"T",
">",
"ordering",
")",
"{",
"List",
"<",
"Filter",
"<",
"T",
">>",
"split",
";",
"if",
"(",
"filter",
"==",
"null",
")",
"{",
"split",
"=",
"Filter",
".",
"getOpenFilter",
"(",
"access",
".",
"getStorableType",
"(",
")",
")",
".",
"disjunctiveNormalFormSplit",
"(",
")",
";",
"}",
"else",
"{",
"split",
"=",
"filter",
".",
"disjunctiveNormalFormSplit",
"(",
")",
";",
"}",
"Comparator",
"comparator",
"=",
"CompositeScore",
".",
"fullComparator",
"(",
")",
";",
"CompositeScore",
"bestScore",
"=",
"null",
";",
"for",
"(",
"StorableIndex",
"<",
"T",
">",
"index",
":",
"access",
".",
"getAllIndexes",
"(",
")",
")",
"{",
"for",
"(",
"Filter",
"<",
"T",
">",
"sub",
":",
"split",
")",
"{",
"CompositeScore",
"candidateScore",
"=",
"CompositeScore",
".",
"evaluate",
"(",
"index",
",",
"sub",
",",
"ordering",
")",
";",
"if",
"(",
"bestScore",
"==",
"null",
"||",
"comparator",
".",
"compare",
"(",
"candidateScore",
",",
"bestScore",
")",
"<",
"0",
")",
"{",
"bestScore",
"=",
"candidateScore",
";",
"}",
"}",
"}",
"// Reduce source ordering to that which can be handled for\r",
"// free. Otherwise, a sort would be performed which is a waste of time\r",
"// if some source results will later be filtered out.\r",
"int",
"handledCount",
"=",
"bestScore",
"==",
"null",
"?",
"0",
":",
"bestScore",
".",
"getOrderingScore",
"(",
")",
".",
"getHandledCount",
"(",
")",
";",
"return",
"ordering",
".",
"subList",
"(",
"0",
",",
"handledCount",
")",
";",
"}"
] |
Examines the given ordering against available indexes, returning the
ordering that the best index can provide for free.
|
[
"Examines",
"the",
"given",
"ordering",
"against",
"available",
"indexes",
"returning",
"the",
"ordering",
"that",
"the",
"best",
"index",
"can",
"provide",
"for",
"free",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java#L411-L438
|
7,973 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java
|
JoinedQueryExecutor.commonOrderingCount
|
private static <T extends Storable> int
commonOrderingCount(OrderingList<T> orderingA, OrderingList<T> orderingB)
{
int commonCount = Math.min(orderingA.size(), orderingB.size());
for (int i=0; i<commonCount; i++) {
if (!orderingA.get(i).equals(orderingB.get(i))) {
return i;
}
}
return commonCount;
}
|
java
|
private static <T extends Storable> int
commonOrderingCount(OrderingList<T> orderingA, OrderingList<T> orderingB)
{
int commonCount = Math.min(orderingA.size(), orderingB.size());
for (int i=0; i<commonCount; i++) {
if (!orderingA.get(i).equals(orderingB.get(i))) {
return i;
}
}
return commonCount;
}
|
[
"private",
"static",
"<",
"T",
"extends",
"Storable",
">",
"int",
"commonOrderingCount",
"(",
"OrderingList",
"<",
"T",
">",
"orderingA",
",",
"OrderingList",
"<",
"T",
">",
"orderingB",
")",
"{",
"int",
"commonCount",
"=",
"Math",
".",
"min",
"(",
"orderingA",
".",
"size",
"(",
")",
",",
"orderingB",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"commonCount",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"orderingA",
".",
"get",
"(",
"i",
")",
".",
"equals",
"(",
"orderingB",
".",
"get",
"(",
"i",
")",
")",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"commonCount",
";",
"}"
] |
Returns the count of exactly matching properties from the two
orderings. The match must be consecutive and start at the first
property.
|
[
"Returns",
"the",
"count",
"of",
"exactly",
"matching",
"properties",
"from",
"the",
"two",
"orderings",
".",
"The",
"match",
"must",
"be",
"consecutive",
"and",
"start",
"at",
"the",
"first",
"property",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/qe/JoinedQueryExecutor.java#L445-L457
|
7,974 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/filter/FilterValues.java
|
FilterValues.with
|
public FilterValues<S> with(char value) {
PropertyFilterList<S> current = currentProperty();
Object obj;
try {
obj = current.getPropertyFilter().adaptValue(value);
} catch (IllegalArgumentException e) {
throw mismatch(e);
}
return with(current, obj);
}
|
java
|
public FilterValues<S> with(char value) {
PropertyFilterList<S> current = currentProperty();
Object obj;
try {
obj = current.getPropertyFilter().adaptValue(value);
} catch (IllegalArgumentException e) {
throw mismatch(e);
}
return with(current, obj);
}
|
[
"public",
"FilterValues",
"<",
"S",
">",
"with",
"(",
"char",
"value",
")",
"{",
"PropertyFilterList",
"<",
"S",
">",
"current",
"=",
"currentProperty",
"(",
")",
";",
"Object",
"obj",
";",
"try",
"{",
"obj",
"=",
"current",
".",
"getPropertyFilter",
"(",
")",
".",
"adaptValue",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"mismatch",
"(",
"e",
")",
";",
"}",
"return",
"with",
"(",
"current",
",",
"obj",
")",
";",
"}"
] |
Returns a new FilterValues instance with the next blank parameter filled in.
@param value parameter value to fill in
@throws IllegalStateException if no blank parameters
@throws IllegalArgumentException if type doesn't match
|
[
"Returns",
"a",
"new",
"FilterValues",
"instance",
"with",
"the",
"next",
"blank",
"parameter",
"filled",
"in",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/filter/FilterValues.java#L186-L195
|
7,975 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/filter/FilterValues.java
|
FilterValues.withValues
|
public FilterValues<S> withValues(Object... values) {
if (values == null) {
return this;
}
if (values.length > getBlankParameterCount()) {
throw new IllegalStateException("Too many values supplied");
}
FilterValues<S> filterValues = this;
for (Object value : values) {
filterValues = filterValues.with(value);
}
return filterValues;
}
|
java
|
public FilterValues<S> withValues(Object... values) {
if (values == null) {
return this;
}
if (values.length > getBlankParameterCount()) {
throw new IllegalStateException("Too many values supplied");
}
FilterValues<S> filterValues = this;
for (Object value : values) {
filterValues = filterValues.with(value);
}
return filterValues;
}
|
[
"public",
"FilterValues",
"<",
"S",
">",
"withValues",
"(",
"Object",
"...",
"values",
")",
"{",
"if",
"(",
"values",
"==",
"null",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"values",
".",
"length",
">",
"getBlankParameterCount",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Too many values supplied\"",
")",
";",
"}",
"FilterValues",
"<",
"S",
">",
"filterValues",
"=",
"this",
";",
"for",
"(",
"Object",
"value",
":",
"values",
")",
"{",
"filterValues",
"=",
"filterValues",
".",
"with",
"(",
"value",
")",
";",
"}",
"return",
"filterValues",
";",
"}"
] |
Returns a new FilterValues instance with the next blank parameters filled in.
@param values parameter values to fill in; if null or empty, this
FilterValues instance is returned
@throws IllegalStateException if no blank parameters or if too many
parameter values supplied
@throws IllegalArgumentException if type doesn't match
|
[
"Returns",
"a",
"new",
"FilterValues",
"instance",
"with",
"the",
"next",
"blank",
"parameters",
"filled",
"in",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/filter/FilterValues.java#L260-L272
|
7,976 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/filter/FilterValues.java
|
FilterValues.isAssigned
|
public boolean isAssigned(PropertyFilter<S> propFilter) {
if (propFilter.isConstant()) {
return true;
}
Map<PropertyFilter<S>, Object> map = mValueMap;
if (map == null) {
FilterValues<S> prevValues = mPrevValues;
if (prevValues == null) {
return false;
}
if (prevValues.mCurrentProperty.getPreviousRemaining() < 3) {
// Map would have few values in it, so don't bother building it.
do {
if (propFilter == prevValues.mCurrentProperty.getPropertyFilter()) {
return true;
}
prevValues = prevValues.mPrevValues;
} while (prevValues != null);
return false;
}
map = buildValueMap();
}
return map.containsKey(propFilter);
}
|
java
|
public boolean isAssigned(PropertyFilter<S> propFilter) {
if (propFilter.isConstant()) {
return true;
}
Map<PropertyFilter<S>, Object> map = mValueMap;
if (map == null) {
FilterValues<S> prevValues = mPrevValues;
if (prevValues == null) {
return false;
}
if (prevValues.mCurrentProperty.getPreviousRemaining() < 3) {
// Map would have few values in it, so don't bother building it.
do {
if (propFilter == prevValues.mCurrentProperty.getPropertyFilter()) {
return true;
}
prevValues = prevValues.mPrevValues;
} while (prevValues != null);
return false;
}
map = buildValueMap();
}
return map.containsKey(propFilter);
}
|
[
"public",
"boolean",
"isAssigned",
"(",
"PropertyFilter",
"<",
"S",
">",
"propFilter",
")",
"{",
"if",
"(",
"propFilter",
".",
"isConstant",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"Map",
"<",
"PropertyFilter",
"<",
"S",
">",
",",
"Object",
">",
"map",
"=",
"mValueMap",
";",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"FilterValues",
"<",
"S",
">",
"prevValues",
"=",
"mPrevValues",
";",
"if",
"(",
"prevValues",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"prevValues",
".",
"mCurrentProperty",
".",
"getPreviousRemaining",
"(",
")",
"<",
"3",
")",
"{",
"// Map would have few values in it, so don't bother building it.\r",
"do",
"{",
"if",
"(",
"propFilter",
"==",
"prevValues",
".",
"mCurrentProperty",
".",
"getPropertyFilter",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"prevValues",
"=",
"prevValues",
".",
"mPrevValues",
";",
"}",
"while",
"(",
"prevValues",
"!=",
"null",
")",
";",
"return",
"false",
";",
"}",
"map",
"=",
"buildValueMap",
"(",
")",
";",
"}",
"return",
"map",
".",
"containsKey",
"(",
"propFilter",
")",
";",
"}"
] |
Returns true if a value is assigned to the given PropertyFilter.
|
[
"Returns",
"true",
"if",
"a",
"value",
"is",
"assigned",
"to",
"the",
"given",
"PropertyFilter",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/filter/FilterValues.java#L353-L383
|
7,977 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/filter/FilterValues.java
|
FilterValues.getSuppliedValues
|
public Object[] getSuppliedValues() {
FilterValues<S> prevValues = mPrevValues;
if (prevValues == null) {
return NO_VALUES;
}
int i = prevValues.mCurrentProperty.getBlankCount();
if (i == 0) {
return NO_VALUES;
}
Object[] values = new Object[i];
FilterValues filterValues = this;
while (true) {
if (!filterValues.mPrevValues.mCurrentProperty.getPropertyFilter().isConstant()) {
values[--i] = filterValues.mPrevValue;
if (i <= 0) {
break;
}
}
filterValues = prevValues;
prevValues = prevValues.mPrevValues;
}
return values;
}
|
java
|
public Object[] getSuppliedValues() {
FilterValues<S> prevValues = mPrevValues;
if (prevValues == null) {
return NO_VALUES;
}
int i = prevValues.mCurrentProperty.getBlankCount();
if (i == 0) {
return NO_VALUES;
}
Object[] values = new Object[i];
FilterValues filterValues = this;
while (true) {
if (!filterValues.mPrevValues.mCurrentProperty.getPropertyFilter().isConstant()) {
values[--i] = filterValues.mPrevValue;
if (i <= 0) {
break;
}
}
filterValues = prevValues;
prevValues = prevValues.mPrevValues;
}
return values;
}
|
[
"public",
"Object",
"[",
"]",
"getSuppliedValues",
"(",
")",
"{",
"FilterValues",
"<",
"S",
">",
"prevValues",
"=",
"mPrevValues",
";",
"if",
"(",
"prevValues",
"==",
"null",
")",
"{",
"return",
"NO_VALUES",
";",
"}",
"int",
"i",
"=",
"prevValues",
".",
"mCurrentProperty",
".",
"getBlankCount",
"(",
")",
";",
"if",
"(",
"i",
"==",
"0",
")",
"{",
"return",
"NO_VALUES",
";",
"}",
"Object",
"[",
"]",
"values",
"=",
"new",
"Object",
"[",
"i",
"]",
";",
"FilterValues",
"filterValues",
"=",
"this",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"!",
"filterValues",
".",
"mPrevValues",
".",
"mCurrentProperty",
".",
"getPropertyFilter",
"(",
")",
".",
"isConstant",
"(",
")",
")",
"{",
"values",
"[",
"--",
"i",
"]",
"=",
"filterValues",
".",
"mPrevValue",
";",
"if",
"(",
"i",
"<=",
"0",
")",
"{",
"break",
";",
"}",
"}",
"filterValues",
"=",
"prevValues",
";",
"prevValues",
"=",
"prevValues",
".",
"mPrevValues",
";",
"}",
"return",
"values",
";",
"}"
] |
Returns all supplied values in this object. Constant filter values are
not included.
@return new object array
|
[
"Returns",
"all",
"supplied",
"values",
"in",
"this",
"object",
".",
"Constant",
"filter",
"values",
"are",
"not",
"included",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/filter/FilterValues.java#L419-L444
|
7,978 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/filter/FilterValues.java
|
FilterValues.getValuesFor
|
public Object[] getValuesFor(Filter<S> filter) throws IllegalStateException {
// Traverse filter properties in reverse, since the filter likely was
// used to create this FilterValues instance. If so, then no value map
// needs to be constructed.
PropertyFilterList<S> list = filter.getTailPropertyFilterList();
if (list == null) {
return NO_VALUES;
}
int i = list.getPreviousRemaining() + 1;
Object[] values = new Object[i];
FilterValues filterValues = this;
FilterValues<S> prevValues = mPrevValues;
for (; --i >= 0; list = list.getPrevious()) {
PropertyFilter<S> propFilter = list.getPropertyFilter();
Object value;
if (prevValues != null
&& propFilter == prevValues.mCurrentProperty.getPropertyFilter()) {
value = filterValues.mPrevValue;
filterValues = prevValues;
prevValues = prevValues.mPrevValues;
} else {
if (i > 0 || mValueMap != null) {
value = getAssignedValue(propFilter);
} else {
// No need to force value map to be created since this is
// the last property to be processed. Do the same scan operation
// as performed by buildValueMap, except don't save the results.
filterValues = this;
prevValues = mPrevValues;
findValue: {
while (prevValues != null) {
if (propFilter == prevValues.mCurrentProperty.getPropertyFilter()) {
value = filterValues.mPrevValue;
break findValue;
}
filterValues = prevValues;
prevValues = prevValues.mPrevValues;
}
throw valueNotFound(propFilter);
}
}
}
values[i] = value;
}
return values;
}
|
java
|
public Object[] getValuesFor(Filter<S> filter) throws IllegalStateException {
// Traverse filter properties in reverse, since the filter likely was
// used to create this FilterValues instance. If so, then no value map
// needs to be constructed.
PropertyFilterList<S> list = filter.getTailPropertyFilterList();
if (list == null) {
return NO_VALUES;
}
int i = list.getPreviousRemaining() + 1;
Object[] values = new Object[i];
FilterValues filterValues = this;
FilterValues<S> prevValues = mPrevValues;
for (; --i >= 0; list = list.getPrevious()) {
PropertyFilter<S> propFilter = list.getPropertyFilter();
Object value;
if (prevValues != null
&& propFilter == prevValues.mCurrentProperty.getPropertyFilter()) {
value = filterValues.mPrevValue;
filterValues = prevValues;
prevValues = prevValues.mPrevValues;
} else {
if (i > 0 || mValueMap != null) {
value = getAssignedValue(propFilter);
} else {
// No need to force value map to be created since this is
// the last property to be processed. Do the same scan operation
// as performed by buildValueMap, except don't save the results.
filterValues = this;
prevValues = mPrevValues;
findValue: {
while (prevValues != null) {
if (propFilter == prevValues.mCurrentProperty.getPropertyFilter()) {
value = filterValues.mPrevValue;
break findValue;
}
filterValues = prevValues;
prevValues = prevValues.mPrevValues;
}
throw valueNotFound(propFilter);
}
}
}
values[i] = value;
}
return values;
}
|
[
"public",
"Object",
"[",
"]",
"getValuesFor",
"(",
"Filter",
"<",
"S",
">",
"filter",
")",
"throws",
"IllegalStateException",
"{",
"// Traverse filter properties in reverse, since the filter likely was\r",
"// used to create this FilterValues instance. If so, then no value map\r",
"// needs to be constructed.\r",
"PropertyFilterList",
"<",
"S",
">",
"list",
"=",
"filter",
".",
"getTailPropertyFilterList",
"(",
")",
";",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"return",
"NO_VALUES",
";",
"}",
"int",
"i",
"=",
"list",
".",
"getPreviousRemaining",
"(",
")",
"+",
"1",
";",
"Object",
"[",
"]",
"values",
"=",
"new",
"Object",
"[",
"i",
"]",
";",
"FilterValues",
"filterValues",
"=",
"this",
";",
"FilterValues",
"<",
"S",
">",
"prevValues",
"=",
"mPrevValues",
";",
"for",
"(",
";",
"--",
"i",
">=",
"0",
";",
"list",
"=",
"list",
".",
"getPrevious",
"(",
")",
")",
"{",
"PropertyFilter",
"<",
"S",
">",
"propFilter",
"=",
"list",
".",
"getPropertyFilter",
"(",
")",
";",
"Object",
"value",
";",
"if",
"(",
"prevValues",
"!=",
"null",
"&&",
"propFilter",
"==",
"prevValues",
".",
"mCurrentProperty",
".",
"getPropertyFilter",
"(",
")",
")",
"{",
"value",
"=",
"filterValues",
".",
"mPrevValue",
";",
"filterValues",
"=",
"prevValues",
";",
"prevValues",
"=",
"prevValues",
".",
"mPrevValues",
";",
"}",
"else",
"{",
"if",
"(",
"i",
">",
"0",
"||",
"mValueMap",
"!=",
"null",
")",
"{",
"value",
"=",
"getAssignedValue",
"(",
"propFilter",
")",
";",
"}",
"else",
"{",
"// No need to force value map to be created since this is\r",
"// the last property to be processed. Do the same scan operation\r",
"// as performed by buildValueMap, except don't save the results.\r",
"filterValues",
"=",
"this",
";",
"prevValues",
"=",
"mPrevValues",
";",
"findValue",
":",
"{",
"while",
"(",
"prevValues",
"!=",
"null",
")",
"{",
"if",
"(",
"propFilter",
"==",
"prevValues",
".",
"mCurrentProperty",
".",
"getPropertyFilter",
"(",
")",
")",
"{",
"value",
"=",
"filterValues",
".",
"mPrevValue",
";",
"break",
"findValue",
";",
"}",
"filterValues",
"=",
"prevValues",
";",
"prevValues",
"=",
"prevValues",
".",
"mPrevValues",
";",
"}",
"throw",
"valueNotFound",
"(",
"propFilter",
")",
";",
"}",
"}",
"}",
"values",
"[",
"i",
"]",
"=",
"value",
";",
"}",
"return",
"values",
";",
"}"
] |
Returns all values in this object, as required by the given Filter. The
given Filter must be composed only of the same PropertyFilter instances
as used to construct this object. An IllegalStateException will result
otherwise.
@param filter filter must be bound
@return new object array
@throws IllegalStateException if any values are blank
|
[
"Returns",
"all",
"values",
"in",
"this",
"object",
"as",
"required",
"by",
"the",
"given",
"Filter",
".",
"The",
"given",
"Filter",
"must",
"be",
"composed",
"only",
"of",
"the",
"same",
"PropertyFilter",
"instances",
"as",
"used",
"to",
"construct",
"this",
"object",
".",
"An",
"IllegalStateException",
"will",
"result",
"otherwise",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/filter/FilterValues.java#L456-L513
|
7,979 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/filter/FilterValues.java
|
FilterValues.getSuppliedValuesFor
|
public Object[] getSuppliedValuesFor(Filter<S> filter) throws IllegalStateException {
// Traverse filter properties in reverse, since the filter likely was
// used to create this FilterValues instance. If so, then no value map
// needs to be constructed.
PropertyFilterList<S> list = filter.getTailPropertyFilterList();
if (list == null) {
return NO_VALUES;
}
FilterValues<S> prevValues = mPrevValues;
if (prevValues == null) {
return NO_VALUES;
}
int i = list.getPreviousRemaining() + 1;
// Array is sized assuming that no constants are encountered and all
// filters are assigned values. Array is trimmed later if necessary.
int valuesPos = i;
Object[] values = new Object[valuesPos];
FilterValues filterValues = this;
for (; --i >= 0; list = list.getPrevious()) {
PropertyFilter<S> propFilter = list.getPropertyFilter();
Object value;
if (prevValues != null
&& propFilter == prevValues.mCurrentProperty.getPropertyFilter()) {
value = filterValues.mPrevValue;
filterValues = prevValues;
prevValues = prevValues.mPrevValues;
if (propFilter.isConstant()) {
continue;
}
} else {
if (propFilter.isConstant()) {
continue;
}
if (i > 0 || mValueMap != null) {
if (isAssigned(propFilter)) {
value = getAssignedValue(propFilter);
} else {
continue;
}
} else {
// No need to force value map to be created since this is
// the last property to be processed. Do the same scan operation
// as performed by buildValueMap, except don't save the results.
filterValues = this;
prevValues = mPrevValues;
findValue: {
while (prevValues != null) {
if (propFilter == prevValues.mCurrentProperty.getPropertyFilter()) {
value = filterValues.mPrevValue;
break findValue;
}
filterValues = prevValues;
prevValues = prevValues.mPrevValues;
}
continue;
}
}
}
values[--valuesPos] = value;
}
if (valuesPos != 0) {
// Trim array.
int newValuesSize = values.length - valuesPos;
if (newValuesSize == 0) {
values = NO_VALUES;
} else {
Object[] newValues = new Object[newValuesSize];
System.arraycopy(values, valuesPos, newValues, 0, newValuesSize);
values = newValues;
}
}
return values;
}
|
java
|
public Object[] getSuppliedValuesFor(Filter<S> filter) throws IllegalStateException {
// Traverse filter properties in reverse, since the filter likely was
// used to create this FilterValues instance. If so, then no value map
// needs to be constructed.
PropertyFilterList<S> list = filter.getTailPropertyFilterList();
if (list == null) {
return NO_VALUES;
}
FilterValues<S> prevValues = mPrevValues;
if (prevValues == null) {
return NO_VALUES;
}
int i = list.getPreviousRemaining() + 1;
// Array is sized assuming that no constants are encountered and all
// filters are assigned values. Array is trimmed later if necessary.
int valuesPos = i;
Object[] values = new Object[valuesPos];
FilterValues filterValues = this;
for (; --i >= 0; list = list.getPrevious()) {
PropertyFilter<S> propFilter = list.getPropertyFilter();
Object value;
if (prevValues != null
&& propFilter == prevValues.mCurrentProperty.getPropertyFilter()) {
value = filterValues.mPrevValue;
filterValues = prevValues;
prevValues = prevValues.mPrevValues;
if (propFilter.isConstant()) {
continue;
}
} else {
if (propFilter.isConstant()) {
continue;
}
if (i > 0 || mValueMap != null) {
if (isAssigned(propFilter)) {
value = getAssignedValue(propFilter);
} else {
continue;
}
} else {
// No need to force value map to be created since this is
// the last property to be processed. Do the same scan operation
// as performed by buildValueMap, except don't save the results.
filterValues = this;
prevValues = mPrevValues;
findValue: {
while (prevValues != null) {
if (propFilter == prevValues.mCurrentProperty.getPropertyFilter()) {
value = filterValues.mPrevValue;
break findValue;
}
filterValues = prevValues;
prevValues = prevValues.mPrevValues;
}
continue;
}
}
}
values[--valuesPos] = value;
}
if (valuesPos != 0) {
// Trim array.
int newValuesSize = values.length - valuesPos;
if (newValuesSize == 0) {
values = NO_VALUES;
} else {
Object[] newValues = new Object[newValuesSize];
System.arraycopy(values, valuesPos, newValues, 0, newValuesSize);
values = newValues;
}
}
return values;
}
|
[
"public",
"Object",
"[",
"]",
"getSuppliedValuesFor",
"(",
"Filter",
"<",
"S",
">",
"filter",
")",
"throws",
"IllegalStateException",
"{",
"// Traverse filter properties in reverse, since the filter likely was\r",
"// used to create this FilterValues instance. If so, then no value map\r",
"// needs to be constructed.\r",
"PropertyFilterList",
"<",
"S",
">",
"list",
"=",
"filter",
".",
"getTailPropertyFilterList",
"(",
")",
";",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"return",
"NO_VALUES",
";",
"}",
"FilterValues",
"<",
"S",
">",
"prevValues",
"=",
"mPrevValues",
";",
"if",
"(",
"prevValues",
"==",
"null",
")",
"{",
"return",
"NO_VALUES",
";",
"}",
"int",
"i",
"=",
"list",
".",
"getPreviousRemaining",
"(",
")",
"+",
"1",
";",
"// Array is sized assuming that no constants are encountered and all\r",
"// filters are assigned values. Array is trimmed later if necessary.\r",
"int",
"valuesPos",
"=",
"i",
";",
"Object",
"[",
"]",
"values",
"=",
"new",
"Object",
"[",
"valuesPos",
"]",
";",
"FilterValues",
"filterValues",
"=",
"this",
";",
"for",
"(",
";",
"--",
"i",
">=",
"0",
";",
"list",
"=",
"list",
".",
"getPrevious",
"(",
")",
")",
"{",
"PropertyFilter",
"<",
"S",
">",
"propFilter",
"=",
"list",
".",
"getPropertyFilter",
"(",
")",
";",
"Object",
"value",
";",
"if",
"(",
"prevValues",
"!=",
"null",
"&&",
"propFilter",
"==",
"prevValues",
".",
"mCurrentProperty",
".",
"getPropertyFilter",
"(",
")",
")",
"{",
"value",
"=",
"filterValues",
".",
"mPrevValue",
";",
"filterValues",
"=",
"prevValues",
";",
"prevValues",
"=",
"prevValues",
".",
"mPrevValues",
";",
"if",
"(",
"propFilter",
".",
"isConstant",
"(",
")",
")",
"{",
"continue",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"propFilter",
".",
"isConstant",
"(",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"i",
">",
"0",
"||",
"mValueMap",
"!=",
"null",
")",
"{",
"if",
"(",
"isAssigned",
"(",
"propFilter",
")",
")",
"{",
"value",
"=",
"getAssignedValue",
"(",
"propFilter",
")",
";",
"}",
"else",
"{",
"continue",
";",
"}",
"}",
"else",
"{",
"// No need to force value map to be created since this is\r",
"// the last property to be processed. Do the same scan operation\r",
"// as performed by buildValueMap, except don't save the results.\r",
"filterValues",
"=",
"this",
";",
"prevValues",
"=",
"mPrevValues",
";",
"findValue",
":",
"{",
"while",
"(",
"prevValues",
"!=",
"null",
")",
"{",
"if",
"(",
"propFilter",
"==",
"prevValues",
".",
"mCurrentProperty",
".",
"getPropertyFilter",
"(",
")",
")",
"{",
"value",
"=",
"filterValues",
".",
"mPrevValue",
";",
"break",
"findValue",
";",
"}",
"filterValues",
"=",
"prevValues",
";",
"prevValues",
"=",
"prevValues",
".",
"mPrevValues",
";",
"}",
"continue",
";",
"}",
"}",
"}",
"values",
"[",
"--",
"valuesPos",
"]",
"=",
"value",
";",
"}",
"if",
"(",
"valuesPos",
"!=",
"0",
")",
"{",
"// Trim array.\r",
"int",
"newValuesSize",
"=",
"values",
".",
"length",
"-",
"valuesPos",
";",
"if",
"(",
"newValuesSize",
"==",
"0",
")",
"{",
"values",
"=",
"NO_VALUES",
";",
"}",
"else",
"{",
"Object",
"[",
"]",
"newValues",
"=",
"new",
"Object",
"[",
"newValuesSize",
"]",
";",
"System",
".",
"arraycopy",
"(",
"values",
",",
"valuesPos",
",",
"newValues",
",",
"0",
",",
"newValuesSize",
")",
";",
"values",
"=",
"newValues",
";",
"}",
"}",
"return",
"values",
";",
"}"
] |
Returns all supplied values in this object, as required by the given
Filter. Constant filter values are not included. The given Filter must
be composed only of the same PropertyFilter instances as used to
construct this object. An IllegalStateException will result otherwise.
@param filter filter must be bound
@return new object array
|
[
"Returns",
"all",
"supplied",
"values",
"in",
"this",
"object",
"as",
"required",
"by",
"the",
"given",
"Filter",
".",
"Constant",
"filter",
"values",
"are",
"not",
"included",
".",
"The",
"given",
"Filter",
"must",
"be",
"composed",
"only",
"of",
"the",
"same",
"PropertyFilter",
"instances",
"as",
"used",
"to",
"construct",
"this",
"object",
".",
"An",
"IllegalStateException",
"will",
"result",
"otherwise",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/filter/FilterValues.java#L524-L613
|
7,980 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/validators/text/LetterOrNumberValidator.java
|
LetterOrNumberValidator.setCaseSensitivity
|
public final void setCaseSensitivity(@NonNull final Case caseSensitivty) {
Condition.INSTANCE.ensureNotNull(caseSensitivty, "The case sensitivity may not be null");
this.caseSensitivity = caseSensitivty;
}
|
java
|
public final void setCaseSensitivity(@NonNull final Case caseSensitivty) {
Condition.INSTANCE.ensureNotNull(caseSensitivty, "The case sensitivity may not be null");
this.caseSensitivity = caseSensitivty;
}
|
[
"public",
"final",
"void",
"setCaseSensitivity",
"(",
"@",
"NonNull",
"final",
"Case",
"caseSensitivty",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"caseSensitivty",
",",
"\"The case sensitivity may not be null\"",
")",
";",
"this",
".",
"caseSensitivity",
"=",
"caseSensitivty",
";",
"}"
] |
Sets the case sensitivity, which should be used by the validator.
@param caseSensitivty
The case senstivitiy, which should be set, as a value of the enum {@link Case}. The
value may either be <code>UPPERCASE</code>, <code>LOWERCASE</code> or
<code>CASE_INSENSITIVE</code>
|
[
"Sets",
"the",
"case",
"sensitivity",
"which",
"should",
"be",
"used",
"by",
"the",
"validator",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/validators/text/LetterOrNumberValidator.java#L146-L149
|
7,981 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/adapter/ProxySpinnerAdapter.java
|
ProxySpinnerAdapter.inflateHintView
|
private View inflateHintView(@Nullable final ViewGroup parent) {
TextView view = (TextView) LayoutInflater.from(context).inflate(hintViewId, parent, false);
view.setText(hint);
if (hintColor != null) {
view.setTextColor(hintColor);
}
return view;
}
|
java
|
private View inflateHintView(@Nullable final ViewGroup parent) {
TextView view = (TextView) LayoutInflater.from(context).inflate(hintViewId, parent, false);
view.setText(hint);
if (hintColor != null) {
view.setTextColor(hintColor);
}
return view;
}
|
[
"private",
"View",
"inflateHintView",
"(",
"@",
"Nullable",
"final",
"ViewGroup",
"parent",
")",
"{",
"TextView",
"view",
"=",
"(",
"TextView",
")",
"LayoutInflater",
".",
"from",
"(",
"context",
")",
".",
"inflate",
"(",
"hintViewId",
",",
"parent",
",",
"false",
")",
";",
"view",
".",
"setText",
"(",
"hint",
")",
";",
"if",
"(",
"hintColor",
"!=",
"null",
")",
"{",
"view",
".",
"setTextColor",
"(",
"hintColor",
")",
";",
"}",
"return",
"view",
";",
"}"
] |
Inflates and returns the view, which is used to display the hint.
@param parent
The parent view of the view, which should be inflated, as an instance of the class
{@link ViewGroup} or null, if no parent view is available
@return The view, which has been inflated, as an instance of the class {@link View}
|
[
"Inflates",
"and",
"returns",
"the",
"view",
"which",
"is",
"used",
"to",
"display",
"the",
"hint",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/adapter/ProxySpinnerAdapter.java#L73-L82
|
7,982 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/spi/StoragePool.java
|
StoragePool.getStorage
|
public <S extends Storable> Storage<S> getStorage(Class<S> type)
throws MalformedTypeException, SupportException, RepositoryException
{
return (Storage<S>) super.get(type);
}
|
java
|
public <S extends Storable> Storage<S> getStorage(Class<S> type)
throws MalformedTypeException, SupportException, RepositoryException
{
return (Storage<S>) super.get(type);
}
|
[
"public",
"<",
"S",
"extends",
"Storable",
">",
"Storage",
"<",
"S",
">",
"getStorage",
"(",
"Class",
"<",
"S",
">",
"type",
")",
"throws",
"MalformedTypeException",
",",
"SupportException",
",",
"RepositoryException",
"{",
"return",
"(",
"Storage",
"<",
"S",
">",
")",
"super",
".",
"get",
"(",
"type",
")",
";",
"}"
] |
Returns a Storage instance for the given Storable type, which is lazily
created and pooled. If multiple threads are requesting upon the same type
concurrently, at most one thread attempts to lazily create the
Storage. The others wait for it to become available.
|
[
"Returns",
"a",
"Storage",
"instance",
"for",
"the",
"given",
"Storable",
"type",
"which",
"is",
"lazily",
"created",
"and",
"pooled",
".",
"If",
"multiple",
"threads",
"are",
"requesting",
"upon",
"the",
"same",
"type",
"concurrently",
"at",
"most",
"one",
"thread",
"attempts",
"to",
"lazily",
"create",
"the",
"Storage",
".",
"The",
"others",
"wait",
"for",
"it",
"to",
"become",
"available",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/spi/StoragePool.java#L48-L52
|
7,983 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/repo/jdbc/JoinNodeBuilder.java
|
JoinNodeBuilder.captureOrderings
|
public void captureOrderings(OrderingList<?> ordering) {
try {
if (ordering != null) {
for (OrderedProperty<?> orderedProperty : ordering) {
ChainedProperty<?> chained = orderedProperty.getChainedProperty();
if (!chained.isDerived()) {
mRootJoinNode.addJoin(mRepository, chained, mAliasGenerator);
}
}
}
} catch (RepositoryException e) {
throw new UndeclaredThrowableException(e);
}
}
|
java
|
public void captureOrderings(OrderingList<?> ordering) {
try {
if (ordering != null) {
for (OrderedProperty<?> orderedProperty : ordering) {
ChainedProperty<?> chained = orderedProperty.getChainedProperty();
if (!chained.isDerived()) {
mRootJoinNode.addJoin(mRepository, chained, mAliasGenerator);
}
}
}
} catch (RepositoryException e) {
throw new UndeclaredThrowableException(e);
}
}
|
[
"public",
"void",
"captureOrderings",
"(",
"OrderingList",
"<",
"?",
">",
"ordering",
")",
"{",
"try",
"{",
"if",
"(",
"ordering",
"!=",
"null",
")",
"{",
"for",
"(",
"OrderedProperty",
"<",
"?",
">",
"orderedProperty",
":",
"ordering",
")",
"{",
"ChainedProperty",
"<",
"?",
">",
"chained",
"=",
"orderedProperty",
".",
"getChainedProperty",
"(",
")",
";",
"if",
"(",
"!",
"chained",
".",
"isDerived",
"(",
")",
")",
"{",
"mRootJoinNode",
".",
"addJoin",
"(",
"mRepository",
",",
"chained",
",",
"mAliasGenerator",
")",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"RepositoryException",
"e",
")",
"{",
"throw",
"new",
"UndeclaredThrowableException",
"(",
"e",
")",
";",
"}",
"}"
] |
Processes the given property orderings and ensures that they are
part of the JoinNode tree.
@throws UndeclaredThrowableException wraps a RepositoryException
|
[
"Processes",
"the",
"given",
"property",
"orderings",
"and",
"ensures",
"that",
"they",
"are",
"part",
"of",
"the",
"JoinNode",
"tree",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/repo/jdbc/JoinNodeBuilder.java#L64-L77
|
7,984 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/util/AbstractPool.java
|
AbstractPool.get
|
public V get(K key) throws E {
// Quick check without locking.
V value = mValues.get(key);
if (value != null) {
return value;
}
// Check again with key lock held.
Lock lock = mLockPool.get(key);
lock.lock();
try {
value = mValues.get(key);
if (value == null) {
try {
value = create(key);
mValues.put(key, value);
} catch (Exception e) {
// Workaround compiler bug.
org.cojen.util.ThrowUnchecked.fire(e);
}
}
} finally {
lock.unlock();
}
return value;
}
|
java
|
public V get(K key) throws E {
// Quick check without locking.
V value = mValues.get(key);
if (value != null) {
return value;
}
// Check again with key lock held.
Lock lock = mLockPool.get(key);
lock.lock();
try {
value = mValues.get(key);
if (value == null) {
try {
value = create(key);
mValues.put(key, value);
} catch (Exception e) {
// Workaround compiler bug.
org.cojen.util.ThrowUnchecked.fire(e);
}
}
} finally {
lock.unlock();
}
return value;
}
|
[
"public",
"V",
"get",
"(",
"K",
"key",
")",
"throws",
"E",
"{",
"// Quick check without locking.\r",
"V",
"value",
"=",
"mValues",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"return",
"value",
";",
"}",
"// Check again with key lock held.\r",
"Lock",
"lock",
"=",
"mLockPool",
".",
"get",
"(",
"key",
")",
";",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"value",
"=",
"mValues",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"try",
"{",
"value",
"=",
"create",
"(",
"key",
")",
";",
"mValues",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Workaround compiler bug.\r",
"org",
".",
"cojen",
".",
"util",
".",
"ThrowUnchecked",
".",
"fire",
"(",
"e",
")",
";",
"}",
"}",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Returns a value for the given key, which is lazily created and
pooled. If multiple threads are requesting upon the same key
concurrently, at most one thread attempts to lazily create the
value. The others wait for it to become available.
|
[
"Returns",
"a",
"value",
"for",
"the",
"given",
"key",
"which",
"is",
"lazily",
"created",
"and",
"pooled",
".",
"If",
"multiple",
"threads",
"are",
"requesting",
"upon",
"the",
"same",
"key",
"concurrently",
"at",
"most",
"one",
"thread",
"attempts",
"to",
"lazily",
"create",
"the",
"value",
".",
"The",
"others",
"wait",
"for",
"it",
"to",
"become",
"available",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/util/AbstractPool.java#L49-L75
|
7,985 |
cose-wg/COSE-JAVA
|
src/main/java/COSE/Message.java
|
Message.EncodeToCBORObject
|
public CBORObject EncodeToCBORObject() throws CoseException {
CBORObject obj;
obj = EncodeCBORObject();
if (emitTag) {
obj = CBORObject.FromObjectAndTag(obj, messageTag.value);
}
return obj;
}
|
java
|
public CBORObject EncodeToCBORObject() throws CoseException {
CBORObject obj;
obj = EncodeCBORObject();
if (emitTag) {
obj = CBORObject.FromObjectAndTag(obj, messageTag.value);
}
return obj;
}
|
[
"public",
"CBORObject",
"EncodeToCBORObject",
"(",
")",
"throws",
"CoseException",
"{",
"CBORObject",
"obj",
";",
"obj",
"=",
"EncodeCBORObject",
"(",
")",
";",
"if",
"(",
"emitTag",
")",
"{",
"obj",
"=",
"CBORObject",
".",
"FromObjectAndTag",
"(",
"obj",
",",
"messageTag",
".",
"value",
")",
";",
"}",
"return",
"obj",
";",
"}"
] |
Encode the COSE message object to a CBORObject tree. This function call will force cryptographic operations to be executed as needed.
@return CBORObject representing the message.
@throws CoseException
|
[
"Encode",
"the",
"COSE",
"message",
"object",
"to",
"a",
"CBORObject",
"tree",
".",
"This",
"function",
"call",
"will",
"force",
"cryptographic",
"operations",
"to",
"be",
"executed",
"as",
"needed",
"."
] |
f972b11ab4c9a18f911bc49a15225a6951cf6f63
|
https://github.com/cose-wg/COSE-JAVA/blob/f972b11ab4c9a18f911bc49a15225a6951cf6f63/src/main/java/COSE/Message.java#L191-L201
|
7,986 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/constraints/NegateConstraint.java
|
NegateConstraint.create
|
public static final <Type> NegateConstraint<Type> create(
@NonNull final Constraint<Type> constraint) {
return new NegateConstraint<>(constraint);
}
|
java
|
public static final <Type> NegateConstraint<Type> create(
@NonNull final Constraint<Type> constraint) {
return new NegateConstraint<>(constraint);
}
|
[
"public",
"static",
"final",
"<",
"Type",
">",
"NegateConstraint",
"<",
"Type",
">",
"create",
"(",
"@",
"NonNull",
"final",
"Constraint",
"<",
"Type",
">",
"constraint",
")",
"{",
"return",
"new",
"NegateConstraint",
"<>",
"(",
"constraint",
")",
";",
"}"
] |
Creates and returns a constraint, which allows to negate the result of an other constraint.
@param <Type>
The type of the values, which should be verified
@param constraint
The constraint, whose result should be negated, as an instance of the type {@link
Constraint}. The constraint may not be null
@return The constraint, which has been created, as an instance of the class {@link
NegateConstraint}
|
[
"Creates",
"and",
"returns",
"a",
"constraint",
"which",
"allows",
"to",
"negate",
"the",
"result",
"of",
"an",
"other",
"constraint",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/constraints/NegateConstraint.java#L57-L60
|
7,987 |
michael-rapp/AndroidMaterialValidation
|
library/src/main/java/de/mrapp/android/validation/constraints/NegateConstraint.java
|
NegateConstraint.setConstraint
|
public final void setConstraint(@NonNull final Constraint<Type> constraint) {
Condition.INSTANCE.ensureNotNull(constraint, "The constraint may not be null");
this.constraint = constraint;
}
|
java
|
public final void setConstraint(@NonNull final Constraint<Type> constraint) {
Condition.INSTANCE.ensureNotNull(constraint, "The constraint may not be null");
this.constraint = constraint;
}
|
[
"public",
"final",
"void",
"setConstraint",
"(",
"@",
"NonNull",
"final",
"Constraint",
"<",
"Type",
">",
"constraint",
")",
"{",
"Condition",
".",
"INSTANCE",
".",
"ensureNotNull",
"(",
"constraint",
",",
"\"The constraint may not be null\"",
")",
";",
"this",
".",
"constraint",
"=",
"constraint",
";",
"}"
] |
Sets the constraint, whose result should be negated.
@param constraint
The constraint, which should be set, as an instance of the type {@link Constraint}.
The constraint may not be null
|
[
"Sets",
"the",
"constraint",
"whose",
"result",
"should",
"be",
"negated",
"."
] |
ac8693baeac7abddf2e38a47da4c1849d4661a8b
|
https://github.com/michael-rapp/AndroidMaterialValidation/blob/ac8693baeac7abddf2e38a47da4c1849d4661a8b/library/src/main/java/de/mrapp/android/validation/constraints/NegateConstraint.java#L79-L82
|
7,988 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.buildKeyEncoding
|
public LocalVariable buildKeyEncoding(CodeAssembler assembler,
OrderedProperty<S>[] properties,
LocalVariable instanceVar,
Class<?> adapterInstanceClass,
boolean useReadMethods,
LocalVariable partialStartVar,
LocalVariable partialEndVar)
throws SupportException
{
properties = ensureKeyProperties(properties);
return buildEncoding(Mode.KEY, assembler,
extractProperties(properties), extractDirections(properties),
instanceVar, adapterInstanceClass,
useReadMethods,
-1, // no generation support
partialStartVar, partialEndVar);
}
|
java
|
public LocalVariable buildKeyEncoding(CodeAssembler assembler,
OrderedProperty<S>[] properties,
LocalVariable instanceVar,
Class<?> adapterInstanceClass,
boolean useReadMethods,
LocalVariable partialStartVar,
LocalVariable partialEndVar)
throws SupportException
{
properties = ensureKeyProperties(properties);
return buildEncoding(Mode.KEY, assembler,
extractProperties(properties), extractDirections(properties),
instanceVar, adapterInstanceClass,
useReadMethods,
-1, // no generation support
partialStartVar, partialEndVar);
}
|
[
"public",
"LocalVariable",
"buildKeyEncoding",
"(",
"CodeAssembler",
"assembler",
",",
"OrderedProperty",
"<",
"S",
">",
"[",
"]",
"properties",
",",
"LocalVariable",
"instanceVar",
",",
"Class",
"<",
"?",
">",
"adapterInstanceClass",
",",
"boolean",
"useReadMethods",
",",
"LocalVariable",
"partialStartVar",
",",
"LocalVariable",
"partialEndVar",
")",
"throws",
"SupportException",
"{",
"properties",
"=",
"ensureKeyProperties",
"(",
"properties",
")",
";",
"return",
"buildEncoding",
"(",
"Mode",
".",
"KEY",
",",
"assembler",
",",
"extractProperties",
"(",
"properties",
")",
",",
"extractDirections",
"(",
"properties",
")",
",",
"instanceVar",
",",
"adapterInstanceClass",
",",
"useReadMethods",
",",
"-",
"1",
",",
"// no generation support\r",
"partialStartVar",
",",
"partialEndVar",
")",
";",
"}"
] |
Generates bytecode instructions to encode properties. The encoding is
suitable for "key" encoding, which means it is correctly comparable.
<p>Note: if a partialStartVar is provided and this strategy has a key
prefix, the prefix is allocated only if the runtime value of
partialStartVar is zero. Likewise, if a partialEndVar is provided and
this strategy has a key suffix, the suffix is allocated only of the
runtime value of partialEndVar is one less than the property count.
@param assembler code assembler to receive bytecode instructions
@param properties specific properties to encode, defaults to all key
properties if null
@param instanceVar local variable referencing Storable instance,
defaults to "this" if null. If variable type is an Object array, then
property values are read from the runtime value of this array instead
of a Storable instance.
@param adapterInstanceClass class containing static references to
adapter instances - defaults to instanceVar
@param useReadMethods when true, access properties by public read
methods instead of protected fields - should be used if class being
generated doesn't have access to these fields
@param partialStartVar optional variable for supporting partial key
generation. It must be an int, whose runtime value must be less than the
properties array length. It marks the range start of the partial
property range.
@param partialEndVar optional variable for supporting partial key
generation. It must be an int, whose runtime value must be less than or
equal to the properties array length. It marks the range end (exclusive)
of the partial property range.
@return local variable referencing a byte array with encoded key
@throws SupportException if any property type is not supported
@throws IllegalArgumentException if assembler is null, or if instanceVar
is not the correct instance type, or if partial variable types are not
ints
|
[
"Generates",
"bytecode",
"instructions",
"to",
"encode",
"properties",
".",
"The",
"encoding",
"is",
"suitable",
"for",
"key",
"encoding",
"which",
"means",
"it",
"is",
"correctly",
"comparable",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L167-L183
|
7,989 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.buildDataEncoding
|
public LocalVariable buildDataEncoding(CodeAssembler assembler,
StorableProperty<S>[] properties,
LocalVariable instanceVar,
Class<?> adapterInstanceClass,
boolean useReadMethods,
int generation)
throws SupportException
{
properties = ensureDataProperties(properties);
return buildEncoding(Mode.DATA, assembler,
properties, null,
instanceVar, adapterInstanceClass,
useReadMethods, generation, null, null);
}
|
java
|
public LocalVariable buildDataEncoding(CodeAssembler assembler,
StorableProperty<S>[] properties,
LocalVariable instanceVar,
Class<?> adapterInstanceClass,
boolean useReadMethods,
int generation)
throws SupportException
{
properties = ensureDataProperties(properties);
return buildEncoding(Mode.DATA, assembler,
properties, null,
instanceVar, adapterInstanceClass,
useReadMethods, generation, null, null);
}
|
[
"public",
"LocalVariable",
"buildDataEncoding",
"(",
"CodeAssembler",
"assembler",
",",
"StorableProperty",
"<",
"S",
">",
"[",
"]",
"properties",
",",
"LocalVariable",
"instanceVar",
",",
"Class",
"<",
"?",
">",
"adapterInstanceClass",
",",
"boolean",
"useReadMethods",
",",
"int",
"generation",
")",
"throws",
"SupportException",
"{",
"properties",
"=",
"ensureDataProperties",
"(",
"properties",
")",
";",
"return",
"buildEncoding",
"(",
"Mode",
".",
"DATA",
",",
"assembler",
",",
"properties",
",",
"null",
",",
"instanceVar",
",",
"adapterInstanceClass",
",",
"useReadMethods",
",",
"generation",
",",
"null",
",",
"null",
")",
";",
"}"
] |
Generates bytecode instructions to encode properties. The encoding is
suitable for "data" encoding, which means it is not correctly
comparable, but it is more efficient than key encoding. Partial encoding
is not supported.
@param assembler code assembler to receive bytecode instructions
@param properties specific properties to encode, defaults to all non-key
properties if null
@param instanceVar local variable referencing Storable instance,
defaults to "this" if null. If variable type is an Object array, then
property values are read from the runtime value of this array instead
of a Storable instance.
@param adapterInstanceClass class containing static references to
adapter instances - defaults to instanceVar
@param useReadMethods when true, access properties by public read
methods instead of protected fields
@param generation when non-negative, write a storable layout generation
value in one or four bytes. Generation 0..127 is encoded in one byte, and
128..max is encoded in four bytes, with the most significant bit set.
@return local variable referencing a byte array with encoded data
@throws SupportException if any property type is not supported
@throws IllegalArgumentException if assembler is null, or if instanceVar
is not the correct instance type
|
[
"Generates",
"bytecode",
"instructions",
"to",
"encode",
"properties",
".",
"The",
"encoding",
"is",
"suitable",
"for",
"data",
"encoding",
"which",
"means",
"it",
"is",
"not",
"correctly",
"comparable",
"but",
"it",
"is",
"more",
"efficient",
"than",
"key",
"encoding",
".",
"Partial",
"encoding",
"is",
"not",
"supported",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L251-L264
|
7,990 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.buildSerialEncoding
|
public LocalVariable buildSerialEncoding(CodeAssembler assembler,
StorableProperty<S>[] properties)
throws SupportException
{
properties = ensureAllProperties(properties);
return buildEncoding
(Mode.SERIAL, assembler, properties, null, null, null, false, -1, null, null);
}
|
java
|
public LocalVariable buildSerialEncoding(CodeAssembler assembler,
StorableProperty<S>[] properties)
throws SupportException
{
properties = ensureAllProperties(properties);
return buildEncoding
(Mode.SERIAL, assembler, properties, null, null, null, false, -1, null, null);
}
|
[
"public",
"LocalVariable",
"buildSerialEncoding",
"(",
"CodeAssembler",
"assembler",
",",
"StorableProperty",
"<",
"S",
">",
"[",
"]",
"properties",
")",
"throws",
"SupportException",
"{",
"properties",
"=",
"ensureAllProperties",
"(",
"properties",
")",
";",
"return",
"buildEncoding",
"(",
"Mode",
".",
"SERIAL",
",",
"assembler",
",",
"properties",
",",
"null",
",",
"null",
",",
"null",
",",
"false",
",",
"-",
"1",
",",
"null",
",",
"null",
")",
";",
"}"
] |
Generates bytecode instructions to encode properties and their
states. This encoding is suitable for short-term serialization only.
@param assembler code assembler to receive bytecode instructions
@param properties specific properties to decode, defaults to all
properties if null
@return local variable referencing a byte array with encoded data
@throws SupportException if any property type is not supported
@since 1.2
|
[
"Generates",
"bytecode",
"instructions",
"to",
"encode",
"properties",
"and",
"their",
"states",
".",
"This",
"encoding",
"is",
"suitable",
"for",
"short",
"-",
"term",
"serialization",
"only",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L324-L331
|
7,991 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.buildSerialDecoding
|
public void buildSerialDecoding(CodeAssembler assembler,
StorableProperty<S>[] properties,
LocalVariable encodedVar)
throws SupportException
{
properties = ensureAllProperties(properties);
buildDecoding
(Mode.SERIAL, assembler, properties, null, null, null, false, -1, null, encodedVar);
}
|
java
|
public void buildSerialDecoding(CodeAssembler assembler,
StorableProperty<S>[] properties,
LocalVariable encodedVar)
throws SupportException
{
properties = ensureAllProperties(properties);
buildDecoding
(Mode.SERIAL, assembler, properties, null, null, null, false, -1, null, encodedVar);
}
|
[
"public",
"void",
"buildSerialDecoding",
"(",
"CodeAssembler",
"assembler",
",",
"StorableProperty",
"<",
"S",
">",
"[",
"]",
"properties",
",",
"LocalVariable",
"encodedVar",
")",
"throws",
"SupportException",
"{",
"properties",
"=",
"ensureAllProperties",
"(",
"properties",
")",
";",
"buildDecoding",
"(",
"Mode",
".",
"SERIAL",
",",
"assembler",
",",
"properties",
",",
"null",
",",
"null",
",",
"null",
",",
"false",
",",
"-",
"1",
",",
"null",
",",
"encodedVar",
")",
";",
"}"
] |
Generates bytecode instructions to decode properties and their states. A
CorruptEncodingException may be thrown from generated code.
@param assembler code assembler to receive bytecode instructions
@param properties specific properties to decode, defaults to all
properties if null
@param encodedVar required variable, which must be a byte array. At
runtime, it references encoded data.
@throws SupportException if any property type is not supported
@throws IllegalArgumentException if encodedVar is not a byte array
@since 1.2
|
[
"Generates",
"bytecode",
"instructions",
"to",
"decode",
"properties",
"and",
"their",
"states",
".",
"A",
"CorruptEncodingException",
"may",
"be",
"thrown",
"from",
"generated",
"code",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L346-L354
|
7,992 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.isSupported
|
public boolean isSupported(TypeDesc propertyType) {
if (propertyType.toPrimitiveType() != null) {
return true;
}
if (propertyType == TypeDesc.STRING || propertyType == TypeDesc.forClass(byte[].class)) {
return true;
}
Class clazz = propertyType.toClass();
if (clazz != null) {
return Lob.class.isAssignableFrom(clazz) ||
BigInteger.class.isAssignableFrom(clazz) ||
BigDecimal.class.isAssignableFrom(clazz);
}
return false;
}
|
java
|
public boolean isSupported(TypeDesc propertyType) {
if (propertyType.toPrimitiveType() != null) {
return true;
}
if (propertyType == TypeDesc.STRING || propertyType == TypeDesc.forClass(byte[].class)) {
return true;
}
Class clazz = propertyType.toClass();
if (clazz != null) {
return Lob.class.isAssignableFrom(clazz) ||
BigInteger.class.isAssignableFrom(clazz) ||
BigDecimal.class.isAssignableFrom(clazz);
}
return false;
}
|
[
"public",
"boolean",
"isSupported",
"(",
"TypeDesc",
"propertyType",
")",
"{",
"if",
"(",
"propertyType",
".",
"toPrimitiveType",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"propertyType",
"==",
"TypeDesc",
".",
"STRING",
"||",
"propertyType",
"==",
"TypeDesc",
".",
"forClass",
"(",
"byte",
"[",
"]",
".",
"class",
")",
")",
"{",
"return",
"true",
";",
"}",
"Class",
"clazz",
"=",
"propertyType",
".",
"toClass",
"(",
")",
";",
"if",
"(",
"clazz",
"!=",
"null",
")",
"{",
"return",
"Lob",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
"||",
"BigInteger",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
"||",
"BigDecimal",
".",
"class",
".",
"isAssignableFrom",
"(",
"clazz",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns true if the type of the given property type is supported. The
types currently supported are primitives, primitive wrapper objects,
Strings, byte arrays and Lobs.
|
[
"Returns",
"true",
"if",
"the",
"type",
"of",
"the",
"given",
"property",
"type",
"is",
"supported",
".",
"The",
"types",
"currently",
"supported",
"are",
"primitives",
"primitive",
"wrapper",
"objects",
"Strings",
"byte",
"arrays",
"and",
"Lobs",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L377-L391
|
7,993 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.gatherAllDataProperties
|
@SuppressWarnings("unchecked")
protected StorableProperty<S>[] gatherAllDataProperties() {
Map<String, ? extends StorableProperty<S>> map =
StorableIntrospector.examine(mType).getDataProperties();
List<StorableProperty<S>> list = new ArrayList<StorableProperty<S>>(map.size());
for (StorableProperty<S> property : map.values()) {
if (!property.isDerived()) {
list.add(property);
}
}
return list.toArray(new StorableProperty[list.size()]);
}
|
java
|
@SuppressWarnings("unchecked")
protected StorableProperty<S>[] gatherAllDataProperties() {
Map<String, ? extends StorableProperty<S>> map =
StorableIntrospector.examine(mType).getDataProperties();
List<StorableProperty<S>> list = new ArrayList<StorableProperty<S>>(map.size());
for (StorableProperty<S> property : map.values()) {
if (!property.isDerived()) {
list.add(property);
}
}
return list.toArray(new StorableProperty[list.size()]);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"StorableProperty",
"<",
"S",
">",
"[",
"]",
"gatherAllDataProperties",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"?",
"extends",
"StorableProperty",
"<",
"S",
">",
">",
"map",
"=",
"StorableIntrospector",
".",
"examine",
"(",
"mType",
")",
".",
"getDataProperties",
"(",
")",
";",
"List",
"<",
"StorableProperty",
"<",
"S",
">",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"StorableProperty",
"<",
"S",
">",
">",
"(",
"map",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"StorableProperty",
"<",
"S",
">",
"property",
":",
"map",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"!",
"property",
".",
"isDerived",
"(",
")",
")",
"{",
"list",
".",
"add",
"(",
"property",
")",
";",
"}",
"}",
"return",
"list",
".",
"toArray",
"(",
"new",
"StorableProperty",
"[",
"list",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Returns all non-derived data properties for storable.
|
[
"Returns",
"all",
"non",
"-",
"derived",
"data",
"properties",
"for",
"storable",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L456-L470
|
7,994 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.gatherAllProperties
|
@SuppressWarnings("unchecked")
protected StorableProperty<S>[] gatherAllProperties() {
Map<String, ? extends StorableProperty<S>> map =
StorableIntrospector.examine(mType).getAllProperties();
List<StorableProperty<S>> list = new ArrayList<StorableProperty<S>>(map.size());
for (StorableProperty<S> property : map.values()) {
if (!property.isJoin() && !property.isDerived()) {
list.add(property);
}
}
return list.toArray(new StorableProperty[list.size()]);
}
|
java
|
@SuppressWarnings("unchecked")
protected StorableProperty<S>[] gatherAllProperties() {
Map<String, ? extends StorableProperty<S>> map =
StorableIntrospector.examine(mType).getAllProperties();
List<StorableProperty<S>> list = new ArrayList<StorableProperty<S>>(map.size());
for (StorableProperty<S> property : map.values()) {
if (!property.isJoin() && !property.isDerived()) {
list.add(property);
}
}
return list.toArray(new StorableProperty[list.size()]);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"StorableProperty",
"<",
"S",
">",
"[",
"]",
"gatherAllProperties",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"?",
"extends",
"StorableProperty",
"<",
"S",
">",
">",
"map",
"=",
"StorableIntrospector",
".",
"examine",
"(",
"mType",
")",
".",
"getAllProperties",
"(",
")",
";",
"List",
"<",
"StorableProperty",
"<",
"S",
">",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"StorableProperty",
"<",
"S",
">",
">",
"(",
"map",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"StorableProperty",
"<",
"S",
">",
"property",
":",
"map",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"!",
"property",
".",
"isJoin",
"(",
")",
"&&",
"!",
"property",
".",
"isDerived",
"(",
")",
")",
"{",
"list",
".",
"add",
"(",
"property",
")",
";",
"}",
"}",
"return",
"list",
".",
"toArray",
"(",
"new",
"StorableProperty",
"[",
"list",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Returns all non-join, non-derived properties for storable.
|
[
"Returns",
"all",
"non",
"-",
"join",
"non",
"-",
"derived",
"properties",
"for",
"storable",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L475-L489
|
7,995 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.loadBlankValue
|
private void loadBlankValue(CodeAssembler a, TypeDesc type) {
switch (type.getTypeCode()) {
case TypeDesc.OBJECT_CODE:
a.loadNull();
break;
case TypeDesc.LONG_CODE:
a.loadConstant(0L);
break;
case TypeDesc.FLOAT_CODE:
a.loadConstant(0.0f);
break;
case TypeDesc.DOUBLE_CODE:
a.loadConstant(0.0d);
break;
case TypeDesc.INT_CODE: default:
a.loadConstant(0);
break;
}
}
|
java
|
private void loadBlankValue(CodeAssembler a, TypeDesc type) {
switch (type.getTypeCode()) {
case TypeDesc.OBJECT_CODE:
a.loadNull();
break;
case TypeDesc.LONG_CODE:
a.loadConstant(0L);
break;
case TypeDesc.FLOAT_CODE:
a.loadConstant(0.0f);
break;
case TypeDesc.DOUBLE_CODE:
a.loadConstant(0.0d);
break;
case TypeDesc.INT_CODE: default:
a.loadConstant(0);
break;
}
}
|
[
"private",
"void",
"loadBlankValue",
"(",
"CodeAssembler",
"a",
",",
"TypeDesc",
"type",
")",
"{",
"switch",
"(",
"type",
".",
"getTypeCode",
"(",
")",
")",
"{",
"case",
"TypeDesc",
".",
"OBJECT_CODE",
":",
"a",
".",
"loadNull",
"(",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"LONG_CODE",
":",
"a",
".",
"loadConstant",
"(",
"0L",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"FLOAT_CODE",
":",
"a",
".",
"loadConstant",
"(",
"0.0f",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"DOUBLE_CODE",
":",
"a",
".",
"loadConstant",
"(",
"0.0d",
")",
";",
"break",
";",
"case",
"TypeDesc",
".",
"INT_CODE",
":",
"default",
":",
"a",
".",
"loadConstant",
"(",
"0",
")",
";",
"break",
";",
"}",
"}"
] |
Generates code that loads zero, false, or null to the stack.
|
[
"Generates",
"code",
"that",
"loads",
"zero",
"false",
"or",
"null",
"to",
"the",
"stack",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L1447-L1465
|
7,996 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.staticEncodingLength
|
private int staticEncodingLength(GenericPropertyInfo info) {
TypeDesc type = info.getStorageType();
TypeDesc primType = type.toPrimitiveType();
if (primType == null) {
if (info.isLob()) {
// Lob locator is stored as a long.
return 8;
}
} else {
if (info.isNullable()) {
// Type is a primitive wrapper.
switch (primType.getTypeCode()) {
case TypeDesc.BYTE_CODE:
return ~1;
case TypeDesc.BOOLEAN_CODE:
return 1;
case TypeDesc.SHORT_CODE:
case TypeDesc.CHAR_CODE:
return ~1;
case TypeDesc.INT_CODE:
return ~1;
case TypeDesc.FLOAT_CODE:
return 4;
case TypeDesc.LONG_CODE:
return ~1;
case TypeDesc.DOUBLE_CODE:
return 8;
}
} else {
// Type is primitive or a required primitive wrapper.
switch (type.getTypeCode()) {
case TypeDesc.BYTE_CODE:
case TypeDesc.BOOLEAN_CODE:
return 1;
case TypeDesc.SHORT_CODE:
case TypeDesc.CHAR_CODE:
return 2;
case TypeDesc.INT_CODE:
case TypeDesc.FLOAT_CODE:
return 4;
case TypeDesc.LONG_CODE:
case TypeDesc.DOUBLE_CODE:
return 8;
}
}
}
return ~0;
}
|
java
|
private int staticEncodingLength(GenericPropertyInfo info) {
TypeDesc type = info.getStorageType();
TypeDesc primType = type.toPrimitiveType();
if (primType == null) {
if (info.isLob()) {
// Lob locator is stored as a long.
return 8;
}
} else {
if (info.isNullable()) {
// Type is a primitive wrapper.
switch (primType.getTypeCode()) {
case TypeDesc.BYTE_CODE:
return ~1;
case TypeDesc.BOOLEAN_CODE:
return 1;
case TypeDesc.SHORT_CODE:
case TypeDesc.CHAR_CODE:
return ~1;
case TypeDesc.INT_CODE:
return ~1;
case TypeDesc.FLOAT_CODE:
return 4;
case TypeDesc.LONG_CODE:
return ~1;
case TypeDesc.DOUBLE_CODE:
return 8;
}
} else {
// Type is primitive or a required primitive wrapper.
switch (type.getTypeCode()) {
case TypeDesc.BYTE_CODE:
case TypeDesc.BOOLEAN_CODE:
return 1;
case TypeDesc.SHORT_CODE:
case TypeDesc.CHAR_CODE:
return 2;
case TypeDesc.INT_CODE:
case TypeDesc.FLOAT_CODE:
return 4;
case TypeDesc.LONG_CODE:
case TypeDesc.DOUBLE_CODE:
return 8;
}
}
}
return ~0;
}
|
[
"private",
"int",
"staticEncodingLength",
"(",
"GenericPropertyInfo",
"info",
")",
"{",
"TypeDesc",
"type",
"=",
"info",
".",
"getStorageType",
"(",
")",
";",
"TypeDesc",
"primType",
"=",
"type",
".",
"toPrimitiveType",
"(",
")",
";",
"if",
"(",
"primType",
"==",
"null",
")",
"{",
"if",
"(",
"info",
".",
"isLob",
"(",
")",
")",
"{",
"// Lob locator is stored as a long.\r",
"return",
"8",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"info",
".",
"isNullable",
"(",
")",
")",
"{",
"// Type is a primitive wrapper.\r",
"switch",
"(",
"primType",
".",
"getTypeCode",
"(",
")",
")",
"{",
"case",
"TypeDesc",
".",
"BYTE_CODE",
":",
"return",
"~",
"1",
";",
"case",
"TypeDesc",
".",
"BOOLEAN_CODE",
":",
"return",
"1",
";",
"case",
"TypeDesc",
".",
"SHORT_CODE",
":",
"case",
"TypeDesc",
".",
"CHAR_CODE",
":",
"return",
"~",
"1",
";",
"case",
"TypeDesc",
".",
"INT_CODE",
":",
"return",
"~",
"1",
";",
"case",
"TypeDesc",
".",
"FLOAT_CODE",
":",
"return",
"4",
";",
"case",
"TypeDesc",
".",
"LONG_CODE",
":",
"return",
"~",
"1",
";",
"case",
"TypeDesc",
".",
"DOUBLE_CODE",
":",
"return",
"8",
";",
"}",
"}",
"else",
"{",
"// Type is primitive or a required primitive wrapper.\r",
"switch",
"(",
"type",
".",
"getTypeCode",
"(",
")",
")",
"{",
"case",
"TypeDesc",
".",
"BYTE_CODE",
":",
"case",
"TypeDesc",
".",
"BOOLEAN_CODE",
":",
"return",
"1",
";",
"case",
"TypeDesc",
".",
"SHORT_CODE",
":",
"case",
"TypeDesc",
".",
"CHAR_CODE",
":",
"return",
"2",
";",
"case",
"TypeDesc",
".",
"INT_CODE",
":",
"case",
"TypeDesc",
".",
"FLOAT_CODE",
":",
"return",
"4",
";",
"case",
"TypeDesc",
".",
"LONG_CODE",
":",
"case",
"TypeDesc",
".",
"DOUBLE_CODE",
":",
"return",
"8",
";",
"}",
"}",
"}",
"return",
"~",
"0",
";",
"}"
] |
Returns a negative value if encoding is variable. The minimum static
amount is computed from the one's compliment. Of the types with variable
encoding lengths, only for primitives is the minimum static amount
returned more than zero.
|
[
"Returns",
"a",
"negative",
"value",
"if",
"encoding",
"is",
"variable",
".",
"The",
"minimum",
"static",
"amount",
"is",
"computed",
"from",
"the",
"one",
"s",
"compliment",
".",
"Of",
"the",
"types",
"with",
"variable",
"encoding",
"lengths",
"only",
"for",
"primitives",
"is",
"the",
"minimum",
"static",
"amount",
"returned",
"more",
"than",
"zero",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L1473-L1522
|
7,997 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.encodeProperty
|
private int encodeProperty(CodeAssembler a, TypeDesc type, Mode mode, boolean descending) {
TypeDesc[] params = new TypeDesc[] {
type, TypeDesc.forClass(byte[].class), TypeDesc.INT
};
if (type.isPrimitive()) {
if (mode == Mode.KEY && descending) {
a.invokeStatic(KeyEncoder.class.getName(), "encodeDesc", null, params);
} else {
a.invokeStatic(DataEncoder.class.getName(), "encode", null, params);
}
switch (type.getTypeCode()) {
case TypeDesc.BYTE_CODE:
case TypeDesc.BOOLEAN_CODE:
return 1;
case TypeDesc.SHORT_CODE:
case TypeDesc.CHAR_CODE:
return 2;
default:
case TypeDesc.INT_CODE:
case TypeDesc.FLOAT_CODE:
return 4;
case TypeDesc.LONG_CODE:
case TypeDesc.DOUBLE_CODE:
return 8;
}
} else if (type.toPrimitiveType() != null) {
// Type is a primitive wrapper.
int adjust;
TypeDesc retType;
switch (type.toPrimitiveType().getTypeCode()) {
case TypeDesc.BOOLEAN_CODE:
adjust = 1;
retType = null;
break;
case TypeDesc.FLOAT_CODE:
adjust = 4;
retType = null;
break;
case TypeDesc.DOUBLE_CODE:
adjust = 8;
retType = null;
break;
default:
adjust = 0;
retType = TypeDesc.INT;
}
if (mode == Mode.KEY && descending) {
a.invokeStatic(KeyEncoder.class.getName(), "encodeDesc", retType, params);
} else {
a.invokeStatic(DataEncoder.class.getName(), "encode", retType, params);
}
return adjust;
} else {
// Type is a String, byte array, BigInteger or BigDecimal.
if (mode == Mode.KEY) {
if (descending) {
a.invokeStatic
(KeyEncoder.class.getName(), "encodeDesc", TypeDesc.INT, params);
} else {
a.invokeStatic(KeyEncoder.class.getName(), "encode", TypeDesc.INT, params);
}
} else {
a.invokeStatic(DataEncoder.class.getName(), "encode", TypeDesc.INT, params);
}
return 0;
}
}
|
java
|
private int encodeProperty(CodeAssembler a, TypeDesc type, Mode mode, boolean descending) {
TypeDesc[] params = new TypeDesc[] {
type, TypeDesc.forClass(byte[].class), TypeDesc.INT
};
if (type.isPrimitive()) {
if (mode == Mode.KEY && descending) {
a.invokeStatic(KeyEncoder.class.getName(), "encodeDesc", null, params);
} else {
a.invokeStatic(DataEncoder.class.getName(), "encode", null, params);
}
switch (type.getTypeCode()) {
case TypeDesc.BYTE_CODE:
case TypeDesc.BOOLEAN_CODE:
return 1;
case TypeDesc.SHORT_CODE:
case TypeDesc.CHAR_CODE:
return 2;
default:
case TypeDesc.INT_CODE:
case TypeDesc.FLOAT_CODE:
return 4;
case TypeDesc.LONG_CODE:
case TypeDesc.DOUBLE_CODE:
return 8;
}
} else if (type.toPrimitiveType() != null) {
// Type is a primitive wrapper.
int adjust;
TypeDesc retType;
switch (type.toPrimitiveType().getTypeCode()) {
case TypeDesc.BOOLEAN_CODE:
adjust = 1;
retType = null;
break;
case TypeDesc.FLOAT_CODE:
adjust = 4;
retType = null;
break;
case TypeDesc.DOUBLE_CODE:
adjust = 8;
retType = null;
break;
default:
adjust = 0;
retType = TypeDesc.INT;
}
if (mode == Mode.KEY && descending) {
a.invokeStatic(KeyEncoder.class.getName(), "encodeDesc", retType, params);
} else {
a.invokeStatic(DataEncoder.class.getName(), "encode", retType, params);
}
return adjust;
} else {
// Type is a String, byte array, BigInteger or BigDecimal.
if (mode == Mode.KEY) {
if (descending) {
a.invokeStatic
(KeyEncoder.class.getName(), "encodeDesc", TypeDesc.INT, params);
} else {
a.invokeStatic(KeyEncoder.class.getName(), "encode", TypeDesc.INT, params);
}
} else {
a.invokeStatic(DataEncoder.class.getName(), "encode", TypeDesc.INT, params);
}
return 0;
}
}
|
[
"private",
"int",
"encodeProperty",
"(",
"CodeAssembler",
"a",
",",
"TypeDesc",
"type",
",",
"Mode",
"mode",
",",
"boolean",
"descending",
")",
"{",
"TypeDesc",
"[",
"]",
"params",
"=",
"new",
"TypeDesc",
"[",
"]",
"{",
"type",
",",
"TypeDesc",
".",
"forClass",
"(",
"byte",
"[",
"]",
".",
"class",
")",
",",
"TypeDesc",
".",
"INT",
"}",
";",
"if",
"(",
"type",
".",
"isPrimitive",
"(",
")",
")",
"{",
"if",
"(",
"mode",
"==",
"Mode",
".",
"KEY",
"&&",
"descending",
")",
"{",
"a",
".",
"invokeStatic",
"(",
"KeyEncoder",
".",
"class",
".",
"getName",
"(",
")",
",",
"\"encodeDesc\"",
",",
"null",
",",
"params",
")",
";",
"}",
"else",
"{",
"a",
".",
"invokeStatic",
"(",
"DataEncoder",
".",
"class",
".",
"getName",
"(",
")",
",",
"\"encode\"",
",",
"null",
",",
"params",
")",
";",
"}",
"switch",
"(",
"type",
".",
"getTypeCode",
"(",
")",
")",
"{",
"case",
"TypeDesc",
".",
"BYTE_CODE",
":",
"case",
"TypeDesc",
".",
"BOOLEAN_CODE",
":",
"return",
"1",
";",
"case",
"TypeDesc",
".",
"SHORT_CODE",
":",
"case",
"TypeDesc",
".",
"CHAR_CODE",
":",
"return",
"2",
";",
"default",
":",
"case",
"TypeDesc",
".",
"INT_CODE",
":",
"case",
"TypeDesc",
".",
"FLOAT_CODE",
":",
"return",
"4",
";",
"case",
"TypeDesc",
".",
"LONG_CODE",
":",
"case",
"TypeDesc",
".",
"DOUBLE_CODE",
":",
"return",
"8",
";",
"}",
"}",
"else",
"if",
"(",
"type",
".",
"toPrimitiveType",
"(",
")",
"!=",
"null",
")",
"{",
"// Type is a primitive wrapper.\r",
"int",
"adjust",
";",
"TypeDesc",
"retType",
";",
"switch",
"(",
"type",
".",
"toPrimitiveType",
"(",
")",
".",
"getTypeCode",
"(",
")",
")",
"{",
"case",
"TypeDesc",
".",
"BOOLEAN_CODE",
":",
"adjust",
"=",
"1",
";",
"retType",
"=",
"null",
";",
"break",
";",
"case",
"TypeDesc",
".",
"FLOAT_CODE",
":",
"adjust",
"=",
"4",
";",
"retType",
"=",
"null",
";",
"break",
";",
"case",
"TypeDesc",
".",
"DOUBLE_CODE",
":",
"adjust",
"=",
"8",
";",
"retType",
"=",
"null",
";",
"break",
";",
"default",
":",
"adjust",
"=",
"0",
";",
"retType",
"=",
"TypeDesc",
".",
"INT",
";",
"}",
"if",
"(",
"mode",
"==",
"Mode",
".",
"KEY",
"&&",
"descending",
")",
"{",
"a",
".",
"invokeStatic",
"(",
"KeyEncoder",
".",
"class",
".",
"getName",
"(",
")",
",",
"\"encodeDesc\"",
",",
"retType",
",",
"params",
")",
";",
"}",
"else",
"{",
"a",
".",
"invokeStatic",
"(",
"DataEncoder",
".",
"class",
".",
"getName",
"(",
")",
",",
"\"encode\"",
",",
"retType",
",",
"params",
")",
";",
"}",
"return",
"adjust",
";",
"}",
"else",
"{",
"// Type is a String, byte array, BigInteger or BigDecimal.\r",
"if",
"(",
"mode",
"==",
"Mode",
".",
"KEY",
")",
"{",
"if",
"(",
"descending",
")",
"{",
"a",
".",
"invokeStatic",
"(",
"KeyEncoder",
".",
"class",
".",
"getName",
"(",
")",
",",
"\"encodeDesc\"",
",",
"TypeDesc",
".",
"INT",
",",
"params",
")",
";",
"}",
"else",
"{",
"a",
".",
"invokeStatic",
"(",
"KeyEncoder",
".",
"class",
".",
"getName",
"(",
")",
",",
"\"encode\"",
",",
"TypeDesc",
".",
"INT",
",",
"params",
")",
";",
"}",
"}",
"else",
"{",
"a",
".",
"invokeStatic",
"(",
"DataEncoder",
".",
"class",
".",
"getName",
"(",
")",
",",
"\"encode\"",
",",
"TypeDesc",
".",
"INT",
",",
"params",
")",
";",
"}",
"return",
"0",
";",
"}",
"}"
] |
Generates code that calls an encoding method in DataEncoder or
KeyEncoder. Parameters must already be on the stack.
@return 0 if an int amount is pushed onto the stack, or a positive value
if offset adjust amount is constant
|
[
"Generates",
"code",
"that",
"calls",
"an",
"encoding",
"method",
"in",
"DataEncoder",
"or",
"KeyEncoder",
".",
"Parameters",
"must",
"already",
"be",
"on",
"the",
"stack",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L1561-L1633
|
7,998 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.encodeGeneration
|
private void encodeGeneration(CodeAssembler a, LocalVariable encodedVar,
int offset, int generation)
{
if (offset < 0) {
throw new IllegalArgumentException();
}
if (generation < 0) {
return;
}
if (generation < 128) {
a.loadLocal(encodedVar);
a.loadConstant(offset);
a.loadConstant((byte) generation);
a.storeToArray(TypeDesc.BYTE);
} else {
generation |= 0x80000000;
for (int i=0; i<4; i++) {
a.loadLocal(encodedVar);
a.loadConstant(offset + i);
a.loadConstant((byte) (generation >> (8 * (3 - i))));
a.storeToArray(TypeDesc.BYTE);
}
}
}
|
java
|
private void encodeGeneration(CodeAssembler a, LocalVariable encodedVar,
int offset, int generation)
{
if (offset < 0) {
throw new IllegalArgumentException();
}
if (generation < 0) {
return;
}
if (generation < 128) {
a.loadLocal(encodedVar);
a.loadConstant(offset);
a.loadConstant((byte) generation);
a.storeToArray(TypeDesc.BYTE);
} else {
generation |= 0x80000000;
for (int i=0; i<4; i++) {
a.loadLocal(encodedVar);
a.loadConstant(offset + i);
a.loadConstant((byte) (generation >> (8 * (3 - i))));
a.storeToArray(TypeDesc.BYTE);
}
}
}
|
[
"private",
"void",
"encodeGeneration",
"(",
"CodeAssembler",
"a",
",",
"LocalVariable",
"encodedVar",
",",
"int",
"offset",
",",
"int",
"generation",
")",
"{",
"if",
"(",
"offset",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"if",
"(",
"generation",
"<",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"generation",
"<",
"128",
")",
"{",
"a",
".",
"loadLocal",
"(",
"encodedVar",
")",
";",
"a",
".",
"loadConstant",
"(",
"offset",
")",
";",
"a",
".",
"loadConstant",
"(",
"(",
"byte",
")",
"generation",
")",
";",
"a",
".",
"storeToArray",
"(",
"TypeDesc",
".",
"BYTE",
")",
";",
"}",
"else",
"{",
"generation",
"|=",
"0x80000000",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"a",
".",
"loadLocal",
"(",
"encodedVar",
")",
";",
"a",
".",
"loadConstant",
"(",
"offset",
"+",
"i",
")",
";",
"a",
".",
"loadConstant",
"(",
"(",
"byte",
")",
"(",
"generation",
">>",
"(",
"8",
"*",
"(",
"3",
"-",
"i",
")",
")",
")",
")",
";",
"a",
".",
"storeToArray",
"(",
"TypeDesc",
".",
"BYTE",
")",
";",
"}",
"}",
"}"
] |
Generates code that stores a one or four byte generation value into a
byte array referenced by the local variable.
@param encodedVar references a byte array
@param offset offset into byte array
@param generation if less than zero, no code is generated
|
[
"Generates",
"code",
"that",
"stores",
"a",
"one",
"or",
"four",
"byte",
"generation",
"value",
"into",
"a",
"byte",
"array",
"referenced",
"by",
"the",
"local",
"variable",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L1643-L1666
|
7,999 |
Carbonado/Carbonado
|
src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java
|
GenericEncodingStrategy.getLobLocator
|
private void getLobLocator(CodeAssembler a, StorablePropertyInfo info) {
if (!info.isLob()) {
throw new IllegalArgumentException();
}
a.invokeInterface(TypeDesc.forClass(RawSupport.class), "getLocator",
TypeDesc.LONG, new TypeDesc[] {info.getStorageType()});
}
|
java
|
private void getLobLocator(CodeAssembler a, StorablePropertyInfo info) {
if (!info.isLob()) {
throw new IllegalArgumentException();
}
a.invokeInterface(TypeDesc.forClass(RawSupport.class), "getLocator",
TypeDesc.LONG, new TypeDesc[] {info.getStorageType()});
}
|
[
"private",
"void",
"getLobLocator",
"(",
"CodeAssembler",
"a",
",",
"StorablePropertyInfo",
"info",
")",
"{",
"if",
"(",
"!",
"info",
".",
"isLob",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"a",
".",
"invokeInterface",
"(",
"TypeDesc",
".",
"forClass",
"(",
"RawSupport",
".",
"class",
")",
",",
"\"getLocator\"",
",",
"TypeDesc",
".",
"LONG",
",",
"new",
"TypeDesc",
"[",
"]",
"{",
"info",
".",
"getStorageType",
"(",
")",
"}",
")",
";",
"}"
] |
Generates code to get a Lob locator value from RawSupport. RawSupport
instance and Lob instance must be on the stack. Result is a long locator
value on the stack.
|
[
"Generates",
"code",
"to",
"get",
"a",
"Lob",
"locator",
"value",
"from",
"RawSupport",
".",
"RawSupport",
"instance",
"and",
"Lob",
"instance",
"must",
"be",
"on",
"the",
"stack",
".",
"Result",
"is",
"a",
"long",
"locator",
"value",
"on",
"the",
"stack",
"."
] |
eee29b365a61c8f03e1a1dc6bed0692e6b04b1db
|
https://github.com/Carbonado/Carbonado/blob/eee29b365a61c8f03e1a1dc6bed0692e6b04b1db/src/main/java/com/amazon/carbonado/raw/GenericEncodingStrategy.java#L1795-L1801
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.