code stringlengths 130 281k | code_dependency stringlengths 182 306k |
|---|---|
public class class_name {
public UserListing getAllUsersByJobView(JobView jobViewParam) {
if(this.serviceTicket != null && jobViewParam != null) {
jobViewParam.setServiceTicket(this.serviceTicket);
}
try {
return new UserListing(this.postJson(
jobViewParam,
WS.Path.User.Version1.getAllUsersByJobView()));
} catch (JSONException jsonExcept) {
throw new FluidClientException(jsonExcept.getMessage(),
FluidClientException.ErrorCode.JSON_PARSING);
}
} } | public class class_name {
public UserListing getAllUsersByJobView(JobView jobViewParam) {
if(this.serviceTicket != null && jobViewParam != null) {
jobViewParam.setServiceTicket(this.serviceTicket); // depends on control dependency: [if], data = [(this.serviceTicket]
}
try {
return new UserListing(this.postJson(
jobViewParam,
WS.Path.User.Version1.getAllUsersByJobView())); // depends on control dependency: [try], data = [none]
} catch (JSONException jsonExcept) {
throw new FluidClientException(jsonExcept.getMessage(),
FluidClientException.ErrorCode.JSON_PARSING);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public DescribeEffectiveInstanceAssociationsResult withAssociations(InstanceAssociation... associations) {
if (this.associations == null) {
setAssociations(new com.amazonaws.internal.SdkInternalList<InstanceAssociation>(associations.length));
}
for (InstanceAssociation ele : associations) {
this.associations.add(ele);
}
return this;
} } | public class class_name {
public DescribeEffectiveInstanceAssociationsResult withAssociations(InstanceAssociation... associations) {
if (this.associations == null) {
setAssociations(new com.amazonaws.internal.SdkInternalList<InstanceAssociation>(associations.length)); // depends on control dependency: [if], data = [none]
}
for (InstanceAssociation ele : associations) {
this.associations.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public int read(final byte[] buffer, final int byteOffset, final int byteCount)
throws IOException {
IOUtils.checkOffsetAndCount(buffer, byteOffset, byteCount);
for (int i = 0; i < byteCount; ++i) {
int charAsInt;
try {
charAsInt = this.read();
if (charAsInt == -1) {
return i == 0 ? -1 : i;
}
} catch (final IOException e) {
if (i != 0) {
return i;
}
throw e;
}
buffer[byteOffset + i] = (byte) charAsInt;
}
return byteCount;
} } | public class class_name {
public int read(final byte[] buffer, final int byteOffset, final int byteCount)
throws IOException {
IOUtils.checkOffsetAndCount(buffer, byteOffset, byteCount);
for (int i = 0; i < byteCount; ++i) {
int charAsInt;
try {
charAsInt = this.read();
if (charAsInt == -1) {
return i == 0 ? -1 : i;
}
} catch (final IOException e) {
if (i != 0) {
return i; // depends on control dependency: [if], data = [none]
}
throw e;
}
buffer[byteOffset + i] = (byte) charAsInt;
}
return byteCount;
} } |
public class class_name {
private Object serializeCollection(Collection pArg) {
JSONArray array = new JSONArray();
for (Object value : ((Collection) pArg)) {
array.add(serializeArgumentToJson(value));
}
return array;
} } | public class class_name {
private Object serializeCollection(Collection pArg) {
JSONArray array = new JSONArray();
for (Object value : ((Collection) pArg)) {
array.add(serializeArgumentToJson(value)); // depends on control dependency: [for], data = [value]
}
return array;
} } |
public class class_name {
public Observable<ComapiResult<UploadContentResponse>> uploadContent(@NonNull final String folder, @NonNull final ContentData data) {
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueUploadContent(folder, data);
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription());
} else {
return doUploadContent(token, folder, data.getName(), data);
}
} } | public class class_name {
public Observable<ComapiResult<UploadContentResponse>> uploadContent(@NonNull final String folder, @NonNull final ContentData data) {
final String token = getToken();
if (sessionController.isCreatingSession()) {
return getTaskQueue().queueUploadContent(folder, data); // depends on control dependency: [if], data = [none]
} else if (TextUtils.isEmpty(token)) {
return Observable.error(getSessionStateErrorDescription()); // depends on control dependency: [if], data = [none]
} else {
return doUploadContent(token, folder, data.getName(), data); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void assertContainsSequence(Description description, Collection<?> actual, Object[] sequence) {
checkIsNotNullAndNotEmpty(sequence);
assertNotNull(description, actual);
boolean firstAlreadyFound = false;
int i = 0;
int sequenceSize = sequence.length;
for (Object o : actual) {
if (i >= sequenceSize) {
break;
}
if (!firstAlreadyFound) {
if (!areEqual(o, sequence[i])) {
continue;
}
firstAlreadyFound = true;
i++;
continue;
}
if (areEqual(o, sequence[i++])) {
continue;
}
throw actualDoesNotContainSequence(description, actual, sequence);
}
if (!firstAlreadyFound || i < sequenceSize) {
throw actualDoesNotContainSequence(description, actual, sequence);
}
} } | public class class_name {
public void assertContainsSequence(Description description, Collection<?> actual, Object[] sequence) {
checkIsNotNullAndNotEmpty(sequence);
assertNotNull(description, actual);
boolean firstAlreadyFound = false;
int i = 0;
int sequenceSize = sequence.length;
for (Object o : actual) {
if (i >= sequenceSize) {
break;
}
if (!firstAlreadyFound) {
if (!areEqual(o, sequence[i])) {
continue;
}
firstAlreadyFound = true;
// depends on control dependency: [if], data = [none]
i++;
// depends on control dependency: [if], data = [none]
continue;
}
if (areEqual(o, sequence[i++])) {
continue;
}
throw actualDoesNotContainSequence(description, actual, sequence);
}
if (!firstAlreadyFound || i < sequenceSize) {
throw actualDoesNotContainSequence(description, actual, sequence);
}
} } |
public class class_name {
public boolean isTagPresent(String tagName) {
boolean tagPresent = false;
if (mReadMethod != null) {
tagPresent = mReadMethod.isTagPresent(tagName);
}
if (!tagPresent && mWriteMethod != null) {
tagPresent = mWriteMethod.isTagPresent(tagName);
}
return tagPresent;
} } | public class class_name {
public boolean isTagPresent(String tagName) {
boolean tagPresent = false;
if (mReadMethod != null) {
tagPresent = mReadMethod.isTagPresent(tagName); // depends on control dependency: [if], data = [none]
}
if (!tagPresent && mWriteMethod != null) {
tagPresent = mWriteMethod.isTagPresent(tagName); // depends on control dependency: [if], data = [none]
}
return tagPresent;
} } |
public class class_name {
private void ensureCapacityAndAddPair(KeyValuePair kvp) {
if (lastIndex + 1 < pairs.length) {
pairs[++lastIndex] = kvp;
} else {
pairs = java.util.Arrays.copyOf(pairs, Math.max(pairs.length + (pairs.length >> 1), DEFAULT_SIZE));
pairs[++lastIndex] = kvp;
}
} } | public class class_name {
private void ensureCapacityAndAddPair(KeyValuePair kvp) {
if (lastIndex + 1 < pairs.length) {
pairs[++lastIndex] = kvp; // depends on control dependency: [if], data = [none]
} else {
pairs = java.util.Arrays.copyOf(pairs, Math.max(pairs.length + (pairs.length >> 1), DEFAULT_SIZE)); // depends on control dependency: [if], data = [none]
pairs[++lastIndex] = kvp; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private void processResponseAcknowledgementData(
final AbstractBody req) {
assertLocked();
Long rid = Long.parseLong(req.getAttribute(Attributes.RID));
if (responseAck.equals(Long.valueOf(-1L))) {
// This is the first request
responseAck = rid;
} else {
pendingResponseAcks.add(rid);
// Remove up until the first missing response (or end of queue)
Long whileVal = Long.valueOf(responseAck.longValue() + 1);
while (!pendingResponseAcks.isEmpty()
&& whileVal.equals(pendingResponseAcks.first())) {
responseAck = whileVal;
pendingResponseAcks.remove(whileVal);
whileVal = Long.valueOf(whileVal.longValue() + 1);
}
}
} } | public class class_name {
private void processResponseAcknowledgementData(
final AbstractBody req) {
assertLocked();
Long rid = Long.parseLong(req.getAttribute(Attributes.RID));
if (responseAck.equals(Long.valueOf(-1L))) {
// This is the first request
responseAck = rid; // depends on control dependency: [if], data = [none]
} else {
pendingResponseAcks.add(rid); // depends on control dependency: [if], data = [none]
// Remove up until the first missing response (or end of queue)
Long whileVal = Long.valueOf(responseAck.longValue() + 1);
while (!pendingResponseAcks.isEmpty()
&& whileVal.equals(pendingResponseAcks.first())) {
responseAck = whileVal; // depends on control dependency: [while], data = [none]
pendingResponseAcks.remove(whileVal); // depends on control dependency: [while], data = [none]
whileVal = Long.valueOf(whileVal.longValue() + 1); // depends on control dependency: [while], data = [none]
}
}
} } |
public class class_name {
public CloudwatchLogsExportConfiguration withEnableLogTypes(String... enableLogTypes) {
if (this.enableLogTypes == null) {
setEnableLogTypes(new java.util.ArrayList<String>(enableLogTypes.length));
}
for (String ele : enableLogTypes) {
this.enableLogTypes.add(ele);
}
return this;
} } | public class class_name {
public CloudwatchLogsExportConfiguration withEnableLogTypes(String... enableLogTypes) {
if (this.enableLogTypes == null) {
setEnableLogTypes(new java.util.ArrayList<String>(enableLogTypes.length)); // depends on control dependency: [if], data = [none]
}
for (String ele : enableLogTypes) {
this.enableLogTypes.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
protected String getCommonSuperClassBase(final String type1, final String type2) {
Class<?> c, d;
try {
c = classForName(type1.replace('/', '.'));
d = classForName(type2.replace('/', '.'));
} catch (Exception e) {
throw new RuntimeException(e.toString());
}
if (c.isAssignableFrom(d)) {
return type1;
}
if (d.isAssignableFrom(c)) {
return type2;
}
if (c.isInterface() || d.isInterface()) {
return "java/lang/Object";
} else {
do {
c = c.getSuperclass();
} while (!c.isAssignableFrom(d));
return c.getName().replace('.', '/');
}
} } | public class class_name {
protected String getCommonSuperClassBase(final String type1, final String type2) {
Class<?> c, d;
try {
c = classForName(type1.replace('/', '.')); // depends on control dependency: [try], data = [none]
d = classForName(type2.replace('/', '.')); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new RuntimeException(e.toString());
} // depends on control dependency: [catch], data = [none]
if (c.isAssignableFrom(d)) {
return type1; // depends on control dependency: [if], data = [none]
}
if (d.isAssignableFrom(c)) {
return type2; // depends on control dependency: [if], data = [none]
}
if (c.isInterface() || d.isInterface()) {
return "java/lang/Object"; // depends on control dependency: [if], data = [none]
} else {
do {
c = c.getSuperclass();
} while (!c.isAssignableFrom(d));
return c.getName().replace('.', '/'); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
static public void main(String[] argv)
{
try {
Blocker blocker = (Blocker)Class.forName(BLOCKER_PACKAGE+argv[0]).newInstance();
StringDistanceLearner learner = DistanceLearnerFactory.build( argv[1] );
MatchData data = new MatchData(argv[2]);
MatchExpt expt = new MatchExpt(data,learner,blocker);
for (int i=3; i<argv.length; ) {
String c = argv[i++];
if (c.equals("-display")) {
expt.displayResults(true,System.out);
} else if (c.equals("-dump")) {
expt.dumpResults(System.out);
} else if (c.equals("-shortDisplay")) {
expt.displayResults(false,System.out);
} else if (c.equals("-graph")) {
expt.graphPrecisionRecall(System.out);
} else if (c.equals("-summarize")) {
System.out.println("maxF1:\t" + expt.maxF1());
System.out.println("avgPrec:\t" + expt.averagePrecision());
} else {
throw new RuntimeException("illegal command "+c);
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("\nusage: <blocker> <distanceClass> <matchDataFile> [commands]\n");
}
} } | public class class_name {
static public void main(String[] argv)
{
try {
Blocker blocker = (Blocker)Class.forName(BLOCKER_PACKAGE+argv[0]).newInstance();
StringDistanceLearner learner = DistanceLearnerFactory.build( argv[1] );
MatchData data = new MatchData(argv[2]);
MatchExpt expt = new MatchExpt(data,learner,blocker);
for (int i=3; i<argv.length; ) {
String c = argv[i++];
if (c.equals("-display")) {
expt.displayResults(true,System.out); // depends on control dependency: [if], data = [none]
} else if (c.equals("-dump")) {
expt.dumpResults(System.out); // depends on control dependency: [if], data = [none]
} else if (c.equals("-shortDisplay")) {
expt.displayResults(false,System.out); // depends on control dependency: [if], data = [none]
} else if (c.equals("-graph")) {
expt.graphPrecisionRecall(System.out); // depends on control dependency: [if], data = [none]
} else if (c.equals("-summarize")) {
System.out.println("maxF1:\t" + expt.maxF1()); // depends on control dependency: [if], data = [none]
System.out.println("avgPrec:\t" + expt.averagePrecision()); // depends on control dependency: [if], data = [none]
} else {
throw new RuntimeException("illegal command "+c);
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("\nusage: <blocker> <distanceClass> <matchDataFile> [commands]\n");
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private static boolean checkPresenceAndCloseExtraSections(RadialMenuSection currentSection, RadialMenuSection sectionToOpen) {
if (activeSubSections.size() > 0) {
int idx = activeSubSections.indexOf(sectionToOpen);
if (idx >= 0) { // Do not remove subsection, keep current sub-tree
return true;
} else {
idx = activeSubSections.indexOf(currentSection);
}
for (int i = activeSubSections.size() - 1; i > idx; i--) {
final RadialMenuSection sectionToClose = activeSubSections.get(i);
sectionToClose.hide();
activeSubSections.remove(sectionToClose);
}
}
return false;
} } | public class class_name {
private static boolean checkPresenceAndCloseExtraSections(RadialMenuSection currentSection, RadialMenuSection sectionToOpen) {
if (activeSubSections.size() > 0) {
int idx = activeSubSections.indexOf(sectionToOpen);
if (idx >= 0) { // Do not remove subsection, keep current sub-tree
return true; // depends on control dependency: [if], data = [none]
} else {
idx = activeSubSections.indexOf(currentSection); // depends on control dependency: [if], data = [none]
}
for (int i = activeSubSections.size() - 1; i > idx; i--) {
final RadialMenuSection sectionToClose = activeSubSections.get(i);
sectionToClose.hide(); // depends on control dependency: [for], data = [none]
activeSubSections.remove(sectionToClose); // depends on control dependency: [for], data = [none]
}
}
return false;
} } |
public class class_name {
public String getAsString(Object obj, String propertyName) {
Object o = get(obj, propertyName);
if (o != null) {
return o.toString();
} else {
return "";
}
} } | public class class_name {
public String getAsString(Object obj, String propertyName) {
Object o = get(obj, propertyName);
if (o != null) {
return o.toString(); // depends on control dependency: [if], data = [none]
} else {
return ""; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public java.util.List<ClusterVersion> getClusterVersions() {
if (clusterVersions == null) {
clusterVersions = new com.amazonaws.internal.SdkInternalList<ClusterVersion>();
}
return clusterVersions;
} } | public class class_name {
public java.util.List<ClusterVersion> getClusterVersions() {
if (clusterVersions == null) {
clusterVersions = new com.amazonaws.internal.SdkInternalList<ClusterVersion>(); // depends on control dependency: [if], data = [none]
}
return clusterVersions;
} } |
public class class_name {
public void retractFact(final Object behaviorContext,
final InternalFactHandle factHandle,
final PropagationContext pctx,
final InternalWorkingMemory workingMemory) {
for ( int i = 0; i < behaviors.length; i++ ) {
behaviors[i].retractFact( ((Object[]) behaviorContext)[i],
factHandle,
pctx,
workingMemory );
}
} } | public class class_name {
public void retractFact(final Object behaviorContext,
final InternalFactHandle factHandle,
final PropagationContext pctx,
final InternalWorkingMemory workingMemory) {
for ( int i = 0; i < behaviors.length; i++ ) {
behaviors[i].retractFact( ((Object[]) behaviorContext)[i],
factHandle,
pctx,
workingMemory ); // depends on control dependency: [for], data = [i]
}
} } |
public class class_name {
public ServerSetup[] build(Properties properties) {
List<ServerSetup> serverSetups = new ArrayList<>();
String hostname = properties.getProperty("greenmail.hostname", ServerSetup.getLocalHostAddress());
long serverStartupTimeout =
Long.parseLong(properties.getProperty("greenmail.startup.timeout", "-1"));
// Default setups
addDefaultSetups(hostname, properties, serverSetups);
// Default setups for test
addTestSetups(hostname, properties, serverSetups);
// Default setups
for (String protocol : ServerSetup.PROTOCOLS) {
addSetup(hostname, protocol, properties, serverSetups);
}
for (ServerSetup setup : serverSetups) {
if (properties.containsKey(GREENMAIL_VERBOSE)) {
setup.setVerbose(true);
}
if (serverStartupTimeout >= 0L) {
setup.setServerStartupTimeout(serverStartupTimeout);
}
}
return serverSetups.toArray(new ServerSetup[serverSetups.size()]);
} } | public class class_name {
public ServerSetup[] build(Properties properties) {
List<ServerSetup> serverSetups = new ArrayList<>();
String hostname = properties.getProperty("greenmail.hostname", ServerSetup.getLocalHostAddress());
long serverStartupTimeout =
Long.parseLong(properties.getProperty("greenmail.startup.timeout", "-1"));
// Default setups
addDefaultSetups(hostname, properties, serverSetups);
// Default setups for test
addTestSetups(hostname, properties, serverSetups);
// Default setups
for (String protocol : ServerSetup.PROTOCOLS) {
addSetup(hostname, protocol, properties, serverSetups); // depends on control dependency: [for], data = [protocol]
}
for (ServerSetup setup : serverSetups) {
if (properties.containsKey(GREENMAIL_VERBOSE)) {
setup.setVerbose(true); // depends on control dependency: [if], data = [none]
}
if (serverStartupTimeout >= 0L) {
setup.setServerStartupTimeout(serverStartupTimeout); // depends on control dependency: [if], data = [(serverStartupTimeout]
}
}
return serverSetups.toArray(new ServerSetup[serverSetups.size()]);
} } |
public class class_name {
private void computeIv(byte label) {
for (int i = 0; i < 14; i++) {
ivStore[i] = masterSalt[i];
}
ivStore[7] ^= label;
ivStore[14] = ivStore[15] = 0;
} } | public class class_name {
private void computeIv(byte label) {
for (int i = 0; i < 14; i++) {
ivStore[i] = masterSalt[i];
// depends on control dependency: [for], data = [i]
}
ivStore[7] ^= label;
ivStore[14] = ivStore[15] = 0;
} } |
public class class_name {
public static void enableAllSubsystems(boolean enable) {
if (enable_logging) {
if (enable) {
for (ISubsystem s : SUBSYSTEM.values()) {
mEnabledSubsystems.add(s);
}
} else {
mEnabledSubsystems.clear();
}
}
} } | public class class_name {
public static void enableAllSubsystems(boolean enable) {
if (enable_logging) {
if (enable) {
for (ISubsystem s : SUBSYSTEM.values()) {
mEnabledSubsystems.add(s); // depends on control dependency: [for], data = [s]
}
} else {
mEnabledSubsystems.clear(); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
protected Source convertString2Source(String param) {
Source src;
try {
src = uriResolver.resolve(param, null);
} catch (TransformerException e) {
src = null;
}
if (src == null) {
src = new StreamSource(new File(param));
}
return src;
} } | public class class_name {
protected Source convertString2Source(String param) {
Source src;
try {
src = uriResolver.resolve(param, null); // depends on control dependency: [try], data = [none]
} catch (TransformerException e) {
src = null;
} // depends on control dependency: [catch], data = [none]
if (src == null) {
src = new StreamSource(new File(param)); // depends on control dependency: [if], data = [none]
}
return src;
} } |
public class class_name {
public <T extends Widget & Checkable> boolean uncheck(T checkableWidget) {
if (hasChild(checkableWidget)) {
return checkInternal(checkableWidget, false);
}
return false;
} } | public class class_name {
public <T extends Widget & Checkable> boolean uncheck(T checkableWidget) {
if (hasChild(checkableWidget)) {
return checkInternal(checkableWidget, false); // depends on control dependency: [if], data = [none]
}
return false;
} } |
public class class_name {
public void sendToTagged(String message, String ... labels) {
for (String label : labels) {
sendToTagged(message, label);
}
} } | public class class_name {
public void sendToTagged(String message, String ... labels) {
for (String label : labels) {
sendToTagged(message, label); // depends on control dependency: [for], data = [label]
}
} } |
public class class_name {
public void setHideTime(boolean enable, final boolean useDarkTheme) {
if(enable && !shouldHideTime) {
// hide the time spinner and show a button to show it instead
timeSpinner.setVisibility(GONE);
ImageButton timeButton = (ImageButton) LayoutInflater.from(getContext()).inflate(R.layout.time_button, null);
timeButton.setImageResource(useDarkTheme ? R.drawable.ic_action_time_dark : R.drawable.ic_action_time_light);
timeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setHideTime(false, useDarkTheme);
}
});
this.addView(timeButton);
} else if(!enable && shouldHideTime) {
timeSpinner.setVisibility(VISIBLE);
this.removeViewAt(2);
}
shouldHideTime = enable;
} } | public class class_name {
public void setHideTime(boolean enable, final boolean useDarkTheme) {
if(enable && !shouldHideTime) {
// hide the time spinner and show a button to show it instead
timeSpinner.setVisibility(GONE); // depends on control dependency: [if], data = [none]
ImageButton timeButton = (ImageButton) LayoutInflater.from(getContext()).inflate(R.layout.time_button, null);
timeButton.setImageResource(useDarkTheme ? R.drawable.ic_action_time_dark : R.drawable.ic_action_time_light); // depends on control dependency: [if], data = [none]
timeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setHideTime(false, useDarkTheme);
}
}); // depends on control dependency: [if], data = [none]
this.addView(timeButton); // depends on control dependency: [if], data = [none]
} else if(!enable && shouldHideTime) {
timeSpinner.setVisibility(VISIBLE); // depends on control dependency: [if], data = [none]
this.removeViewAt(2); // depends on control dependency: [if], data = [none]
}
shouldHideTime = enable;
} } |
public class class_name {
private String getRecursiveString() {
final StringBuilder output = new StringBuilder();
// append headers e.g. namespaces and functions
output.append(String.join("\n", getHeaders()));
if (!qvarMapVariable.isEmpty() && addQvarMap) {
output.append(qvarMapVariable).append("\n");
}
output.append("\ndeclare function local:compareApply($rootApply, $depth, $x ) {\n")
.append("(for $child in $x/* return local:compareApply(\n")
.append("if (empty($rootApply) and $child/name() = \"apply\") then $child else $rootApply,\n")
.append("if (empty($rootApply) and $child/name() = \"apply\") then 0 else $depth+1, $child),\n")
.append("if ($x/name() = \"apply\"\n")
.append(" and $x").append(getExactMatchXQuery()).append("\n");
if (!getLengthConstraint().isEmpty()) {
output.append(" and ").append(getLengthConstraint()).append("\n");
}
if (!qvarConstraint.isEmpty()) {
output.append(" and ").append(qvarConstraint).append("\n");
}
output.append(" ) then\n")
.append(getReturnFormat()).append("\n")
.append("else ()\n")
.append(")};\n\n")
.append("for $m in ").append(getPathToRoot()).append(" return\n")
.append("local:compareApply((), 0, $m)");
return output.toString();
} } | public class class_name {
private String getRecursiveString() {
final StringBuilder output = new StringBuilder();
// append headers e.g. namespaces and functions
output.append(String.join("\n", getHeaders()));
if (!qvarMapVariable.isEmpty() && addQvarMap) {
output.append(qvarMapVariable).append("\n"); // depends on control dependency: [if], data = [none]
}
output.append("\ndeclare function local:compareApply($rootApply, $depth, $x ) {\n")
.append("(for $child in $x/* return local:compareApply(\n")
.append("if (empty($rootApply) and $child/name() = \"apply\") then $child else $rootApply,\n")
.append("if (empty($rootApply) and $child/name() = \"apply\") then 0 else $depth+1, $child),\n")
.append("if ($x/name() = \"apply\"\n")
.append(" and $x").append(getExactMatchXQuery()).append("\n");
if (!getLengthConstraint().isEmpty()) {
output.append(" and ").append(getLengthConstraint()).append("\n");
}
if (!qvarConstraint.isEmpty()) {
output.append(" and ").append(qvarConstraint).append("\n");
}
output.append(" ) then\n")
.append(getReturnFormat()).append("\n")
.append("else ()\n")
.append(")};\n\n")
.append("for $m in ").append(getPathToRoot()).append(" return\n")
.append("local:compareApply((), 0, $m)");
return output.toString();
} } |
public class class_name {
public EEnum getObjectOriginIdentifierSystem() {
if (objectOriginIdentifierSystemEEnum == null) {
objectOriginIdentifierSystemEEnum = (EEnum)EPackage.Registry.INSTANCE.getEPackage(AfplibPackage.eNS_URI).getEClassifiers().get(171);
}
return objectOriginIdentifierSystemEEnum;
} } | public class class_name {
public EEnum getObjectOriginIdentifierSystem() {
if (objectOriginIdentifierSystemEEnum == null) {
objectOriginIdentifierSystemEEnum = (EEnum)EPackage.Registry.INSTANCE.getEPackage(AfplibPackage.eNS_URI).getEClassifiers().get(171); // depends on control dependency: [if], data = [none]
}
return objectOriginIdentifierSystemEEnum;
} } |
public class class_name {
public void addAxisReflection(int axis) {
assert (0 < axis && axis <= dim);
// reset inverse transformation - needs recomputation.
inv = null;
// Formal:
// Matrix homTrans = Matrix.unitMatrix(dim + 1);
// homTrans[axis - 1][axis - 1] = -1;
// trans = homTrans.times(trans);
// Faster:
for(int i = 0; i <= dim; i++) {
trans[axis - 1][i] = -trans[axis - 1][i];
}
} } | public class class_name {
public void addAxisReflection(int axis) {
assert (0 < axis && axis <= dim);
// reset inverse transformation - needs recomputation.
inv = null;
// Formal:
// Matrix homTrans = Matrix.unitMatrix(dim + 1);
// homTrans[axis - 1][axis - 1] = -1;
// trans = homTrans.times(trans);
// Faster:
for(int i = 0; i <= dim; i++) {
trans[axis - 1][i] = -trans[axis - 1][i]; // depends on control dependency: [for], data = [i]
}
} } |
public class class_name {
public File getRuntimeDir(String applicationName, boolean strict) {
File base = getRuntimeBase();
if (base == null) {
if (strict)
return null;
base = getCacheBase();
}
return createUserDir(base, applicationName);
} } | public class class_name {
public File getRuntimeDir(String applicationName, boolean strict) {
File base = getRuntimeBase();
if (base == null) {
if (strict)
return null;
base = getCacheBase(); // depends on control dependency: [if], data = [none]
}
return createUserDir(base, applicationName);
} } |
public class class_name {
private void interpretTables(FitDocument documents) {
for (FitTable table : documents.tables()) {
try {
Fixture fixture = getLinkedFixtureWithArgs(table);
fixture.doTable(table);
counts.tally(table.getCounts());
} catch (Throwable e) {
table.exception(e);
counts.exceptions++;
}
}
} } | public class class_name {
private void interpretTables(FitDocument documents) {
for (FitTable table : documents.tables()) {
try {
Fixture fixture = getLinkedFixtureWithArgs(table);
fixture.doTable(table); // depends on control dependency: [try], data = [none]
counts.tally(table.getCounts()); // depends on control dependency: [try], data = [none]
} catch (Throwable e) {
table.exception(e);
counts.exceptions++;
} // depends on control dependency: [catch], data = [none]
}
} } |
public class class_name {
@Deprecated
public static ByteArrayOutputStream launchProcess(
String command, final Map environment, final String workDir,
ExecuteResultHandler resultHandler) throws IOException {
String[] cmdlist = command.split(" ");
CommandLine cmd = new CommandLine(cmdlist[0]);
for (String cmdItem : cmdlist) {
if (!StringUtils.isBlank(cmdItem)) {
cmd.addArgument(cmdItem);
}
}
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(0);
if (!StringUtils.isBlank(workDir)) {
executor.setWorkingDirectory(new File(workDir));
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
PumpStreamHandler streamHandler = new PumpStreamHandler(out, out);
executor.setStreamHandler(streamHandler);
try {
if (resultHandler == null) {
executor.execute(cmd, environment);
} else {
executor.execute(cmd, environment, resultHandler);
}
} catch (ExecuteException ignored) {
}
return out;
} } | public class class_name {
@Deprecated
public static ByteArrayOutputStream launchProcess(
String command, final Map environment, final String workDir,
ExecuteResultHandler resultHandler) throws IOException {
String[] cmdlist = command.split(" ");
CommandLine cmd = new CommandLine(cmdlist[0]);
for (String cmdItem : cmdlist) {
if (!StringUtils.isBlank(cmdItem)) {
cmd.addArgument(cmdItem); // depends on control dependency: [if], data = [none]
}
}
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(0);
if (!StringUtils.isBlank(workDir)) {
executor.setWorkingDirectory(new File(workDir));
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
PumpStreamHandler streamHandler = new PumpStreamHandler(out, out);
executor.setStreamHandler(streamHandler);
try {
if (resultHandler == null) {
executor.execute(cmd, environment); // depends on control dependency: [if], data = [none]
} else {
executor.execute(cmd, environment, resultHandler); // depends on control dependency: [if], data = [none]
}
} catch (ExecuteException ignored) {
}
return out;
} } |
public class class_name {
public void marshall(GrantAccessRequest grantAccessRequest, ProtocolMarshaller protocolMarshaller) {
if (grantAccessRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(grantAccessRequest.getInstanceId(), INSTANCEID_BINDING);
protocolMarshaller.marshall(grantAccessRequest.getValidForInMinutes(), VALIDFORINMINUTES_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(GrantAccessRequest grantAccessRequest, ProtocolMarshaller protocolMarshaller) {
if (grantAccessRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(grantAccessRequest.getInstanceId(), INSTANCEID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(grantAccessRequest.getValidForInMinutes(), VALIDFORINMINUTES_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public static Constructor<?> getFirstParentConstructor(Class<?> klass) {
try {
return getOriginalUnmockedType(klass).getSuperclass().getDeclaredConstructors()[0];
} catch (Exception e) {
throw new ConstructorNotFoundException("Failed to lookup constructor.", e);
}
} } | public class class_name {
public static Constructor<?> getFirstParentConstructor(Class<?> klass) {
try {
return getOriginalUnmockedType(klass).getSuperclass().getDeclaredConstructors()[0]; // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new ConstructorNotFoundException("Failed to lookup constructor.", e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private void resizeValueText() {
double maxWidth = size * 0.86466165;
double fontSize = size * 0.2556391;
valueText.setFont(Fonts.latoLight(fontSize));
if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); }
valueText.relocate((size - valueText.getLayoutBounds().getWidth()) * 0.5, (size - valueText.getLayoutBounds().getHeight()) * 0.5);
} } | public class class_name {
private void resizeValueText() {
double maxWidth = size * 0.86466165;
double fontSize = size * 0.2556391;
valueText.setFont(Fonts.latoLight(fontSize));
if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); } // depends on control dependency: [if], data = [none]
valueText.relocate((size - valueText.getLayoutBounds().getWidth()) * 0.5, (size - valueText.getLayoutBounds().getHeight()) * 0.5);
} } |
public class class_name {
public static void main(String[] args) throws Exception {
int mb = 1024*1024;
//Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();
System.out.println("##### Heap utilization statistics [MB] #####");
//Print used memory
System.out.println("Used Memory:"
+ (runtime.totalMemory() - runtime.freeMemory()) / mb);
//Print free memory
System.out.println("Free Memory:"
+ runtime.freeMemory() / mb);
//Print total available memory
System.out.println("Total Memory:" + runtime.totalMemory() / mb);
//Print Maximum available memory
System.out.println("Max Memory:" + runtime.maxMemory() / mb);
if ( args.length < 1) {
System.err.println("First argument needs to be path to fasta file");
return;
}
File f = new File(args[0]);
if ( ! f.exists()) {
System.err.println("File does not exist " + args[0]);
return;
}
long timeS = System.currentTimeMillis();
// automatically uncompress files using InputStreamProvider
InputStreamProvider isp = new InputStreamProvider();
InputStream inStream = isp.getInputStream(f);
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
inStream,
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
LinkedHashMap<String, ProteinSequence> b;
int nrSeq = 0;
while ((b = fastaReader.process(100)) != null) {
for (String key : b.keySet()) {
nrSeq++;
System.out.println(nrSeq + " : " + key + " " + b.get(key));
if ( nrSeq % 100000 == 0)
System.out.println(nrSeq );
}
}
long timeE = System.currentTimeMillis();
System.out.println("parsed a total of " + nrSeq + " TREMBL sequences! in " + (timeE - timeS));
} } | public class class_name {
public static void main(String[] args) throws Exception {
int mb = 1024*1024;
//Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();
System.out.println("##### Heap utilization statistics [MB] #####");
//Print used memory
System.out.println("Used Memory:"
+ (runtime.totalMemory() - runtime.freeMemory()) / mb);
//Print free memory
System.out.println("Free Memory:"
+ runtime.freeMemory() / mb);
//Print total available memory
System.out.println("Total Memory:" + runtime.totalMemory() / mb);
//Print Maximum available memory
System.out.println("Max Memory:" + runtime.maxMemory() / mb);
if ( args.length < 1) {
System.err.println("First argument needs to be path to fasta file");
return;
}
File f = new File(args[0]);
if ( ! f.exists()) {
System.err.println("File does not exist " + args[0]);
return;
}
long timeS = System.currentTimeMillis();
// automatically uncompress files using InputStreamProvider
InputStreamProvider isp = new InputStreamProvider();
InputStream inStream = isp.getInputStream(f);
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
inStream,
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
LinkedHashMap<String, ProteinSequence> b;
int nrSeq = 0;
while ((b = fastaReader.process(100)) != null) {
for (String key : b.keySet()) {
nrSeq++; // depends on control dependency: [for], data = [none]
System.out.println(nrSeq + " : " + key + " " + b.get(key)); // depends on control dependency: [for], data = [key]
if ( nrSeq % 100000 == 0)
System.out.println(nrSeq );
}
}
long timeE = System.currentTimeMillis();
System.out.println("parsed a total of " + nrSeq + " TREMBL sequences! in " + (timeE - timeS));
} } |
public class class_name {
protected void associateSameDiffWithOpsAndVariables(){
for(SDVariable var : variableMap().values()){
var.setSameDiff(this);
}
// for(DifferentialFunction df : functionInstancesById.values()){
for(SameDiffOp op : ops.values()){
DifferentialFunction df = op.getOp();
df.setSameDiff(this);
//TODO: This is ugly but seemingly necessary
//Finally, also set the SDVariable for each op
//Otherwise: could have an op pointing to this SameDiff instance, but op's SDVariable's sameDiff field pointing
// to another SameDiff instance. At which point, they could fetch shapes and arrays from some other instance
// (i.e., not from this one that is currently executing)
SDVariable[] args = df.args();
if(args != null){
for(SDVariable arg : args){
arg.setSameDiff(this);
}
}
SDVariable[] outputs = df.outputVariables();
if(outputs != null){
for(SDVariable out : outputs){
out.setSameDiff(this);
}
}
}
} } | public class class_name {
protected void associateSameDiffWithOpsAndVariables(){
for(SDVariable var : variableMap().values()){
var.setSameDiff(this); // depends on control dependency: [for], data = [var]
}
// for(DifferentialFunction df : functionInstancesById.values()){
for(SameDiffOp op : ops.values()){
DifferentialFunction df = op.getOp();
df.setSameDiff(this); // depends on control dependency: [for], data = [none]
//TODO: This is ugly but seemingly necessary
//Finally, also set the SDVariable for each op
//Otherwise: could have an op pointing to this SameDiff instance, but op's SDVariable's sameDiff field pointing
// to another SameDiff instance. At which point, they could fetch shapes and arrays from some other instance
// (i.e., not from this one that is currently executing)
SDVariable[] args = df.args();
if(args != null){
for(SDVariable arg : args){
arg.setSameDiff(this); // depends on control dependency: [for], data = [arg]
}
}
SDVariable[] outputs = df.outputVariables();
if(outputs != null){
for(SDVariable out : outputs){
out.setSameDiff(this); // depends on control dependency: [for], data = [out]
}
}
}
} } |
public class class_name {
private JsonElement parseJsonObjectType(JsonSchema schema, JsonElement value)
throws DataConversionException {
JsonSchema valuesWithinDataType = schema.getValuesWithinDataType();
if (schema.isType(MAP)) {
if (Type.isPrimitive(valuesWithinDataType.getType())) {
return value;
}
JsonObject map = new JsonObject();
for (Entry<String, JsonElement> mapEntry : value.getAsJsonObject().entrySet()) {
JsonElement mapValue = mapEntry.getValue();
map.add(mapEntry.getKey(), parse(mapValue, valuesWithinDataType));
}
return map;
} else if (schema.isType(RECORD)) {
JsonSchema schemaArray = valuesWithinDataType.getValuesWithinDataType();
return parse((JsonObject) value, schemaArray);
} else {
return JsonNull.INSTANCE;
}
} } | public class class_name {
private JsonElement parseJsonObjectType(JsonSchema schema, JsonElement value)
throws DataConversionException {
JsonSchema valuesWithinDataType = schema.getValuesWithinDataType();
if (schema.isType(MAP)) {
if (Type.isPrimitive(valuesWithinDataType.getType())) {
return value; // depends on control dependency: [if], data = [none]
}
JsonObject map = new JsonObject();
for (Entry<String, JsonElement> mapEntry : value.getAsJsonObject().entrySet()) {
JsonElement mapValue = mapEntry.getValue();
map.add(mapEntry.getKey(), parse(mapValue, valuesWithinDataType)); // depends on control dependency: [for], data = [mapEntry]
}
return map;
} else if (schema.isType(RECORD)) {
JsonSchema schemaArray = valuesWithinDataType.getValuesWithinDataType();
return parse((JsonObject) value, schemaArray);
} else {
return JsonNull.INSTANCE;
}
} } |
public class class_name {
public static SoapAttachment from(Attachment attachment) {
SoapAttachment soapAttachment = new SoapAttachment();
String contentId = attachment.getContentId();
if (contentId.startsWith("<") && contentId.endsWith(">")) {
contentId = contentId.substring(1, contentId.length() - 1);
}
soapAttachment.setContentId(contentId);
soapAttachment.setContentType(attachment.getContentType());
if (attachment.getContentType().startsWith("text")) {
try {
soapAttachment.setContent(FileUtils.readToString(attachment.getInputStream()).trim());
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to read SOAP attachment content", e);
}
} else {
// Binary content
soapAttachment.setDataHandler(attachment.getDataHandler());
}
soapAttachment.setCharsetName(Citrus.CITRUS_FILE_ENCODING);
return soapAttachment;
} } | public class class_name {
public static SoapAttachment from(Attachment attachment) {
SoapAttachment soapAttachment = new SoapAttachment();
String contentId = attachment.getContentId();
if (contentId.startsWith("<") && contentId.endsWith(">")) {
contentId = contentId.substring(1, contentId.length() - 1); // depends on control dependency: [if], data = [none]
}
soapAttachment.setContentId(contentId);
soapAttachment.setContentType(attachment.getContentType());
if (attachment.getContentType().startsWith("text")) {
try {
soapAttachment.setContent(FileUtils.readToString(attachment.getInputStream()).trim()); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to read SOAP attachment content", e);
} // depends on control dependency: [catch], data = [none]
} else {
// Binary content
soapAttachment.setDataHandler(attachment.getDataHandler()); // depends on control dependency: [if], data = [none]
}
soapAttachment.setCharsetName(Citrus.CITRUS_FILE_ENCODING);
return soapAttachment;
} } |
public class class_name {
public static <T> T callMethod(Class<T> retClass, Class<?> targetClass, Object target, String method, Class[] argClasses, Object[] args) {
try {
Method classMethod = targetClass.getDeclaredMethod(method, argClasses);
return AccessController.doPrivileged(
new SetMethodPrivilegedAction<T>(classMethod, target, args));
} catch (NoSuchMethodException e) {
throw new TransfuseInjectionException("Exception during method injection: NoSuchFieldException", e);
} catch (PrivilegedActionException e) {
throw new TransfuseInjectionException("PrivilegedActionException Exception during field injection", e);
} catch (Exception e) {
throw new TransfuseInjectionException("Exception during field injection", e);
}
} } | public class class_name {
public static <T> T callMethod(Class<T> retClass, Class<?> targetClass, Object target, String method, Class[] argClasses, Object[] args) {
try {
Method classMethod = targetClass.getDeclaredMethod(method, argClasses);
return AccessController.doPrivileged(
new SetMethodPrivilegedAction<T>(classMethod, target, args)); // depends on control dependency: [try], data = [none]
} catch (NoSuchMethodException e) {
throw new TransfuseInjectionException("Exception during method injection: NoSuchFieldException", e);
} catch (PrivilegedActionException e) { // depends on control dependency: [catch], data = [none]
throw new TransfuseInjectionException("PrivilegedActionException Exception during field injection", e);
} catch (Exception e) { // depends on control dependency: [catch], data = [none]
throw new TransfuseInjectionException("Exception during field injection", e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
protected Node createNode(final Node parentNode, final String nodeName, final String nodeType,
final List<String> mixinTypes, final Map<String, String[]> permissions, final boolean isLeaf,
final boolean callSave) throws RepositoryException
{
boolean useParameters = !useParametersOnLeafOnly() || (useParametersOnLeafOnly() && isLeaf);
Node node;
if (nodeType == null || nodeType.isEmpty() || !useParameters)
{
node = parentNode.addNode(nodeName, DEFAULT_NODE_TYPE);
}
else
{
node = parentNode.addNode(nodeName, nodeType);
}
if (node.getIndex() > 1)
{
// The node has already been created by a concurrent session
parentNode.refresh(false);
return parentNode.getNode(nodeName);
}
if (useParameters)
{
if (permissions != null && !permissions.isEmpty())
{
if (node.canAddMixin("exo:privilegeable"))
{
node.addMixin("exo:privilegeable");
}
((ExtendedNode)node).setPermissions(permissions);
}
if (mixinTypes != null)
{
for (int i = 0, length = mixinTypes.size(); i < length; i++)
{
String mixin = mixinTypes.get(i);
if (node.canAddMixin(mixin))
{
node.addMixin(mixin);
}
}
}
}
if (callSave)
{
try
{
parentNode.save();
}
catch (ItemExistsException e)
{
if (LOG.isTraceEnabled())
{
LOG.trace("An exception occurred: " + e.getMessage());
}
parentNode.refresh(false);
// Need to check until the concurrent tx that caused this ItemExistsException is fully committed
while (!parentNode.hasNode(nodeName));
return parentNode.getNode(nodeName);
}
}
return node;
} } | public class class_name {
protected Node createNode(final Node parentNode, final String nodeName, final String nodeType,
final List<String> mixinTypes, final Map<String, String[]> permissions, final boolean isLeaf,
final boolean callSave) throws RepositoryException
{
boolean useParameters = !useParametersOnLeafOnly() || (useParametersOnLeafOnly() && isLeaf);
Node node;
if (nodeType == null || nodeType.isEmpty() || !useParameters)
{
node = parentNode.addNode(nodeName, DEFAULT_NODE_TYPE);
}
else
{
node = parentNode.addNode(nodeName, nodeType);
}
if (node.getIndex() > 1)
{
// The node has already been created by a concurrent session
parentNode.refresh(false);
return parentNode.getNode(nodeName);
}
if (useParameters)
{
if (permissions != null && !permissions.isEmpty())
{
if (node.canAddMixin("exo:privilegeable"))
{
node.addMixin("exo:privilegeable"); // depends on control dependency: [if], data = [none]
}
((ExtendedNode)node).setPermissions(permissions); // depends on control dependency: [if], data = [(permissions]
}
if (mixinTypes != null)
{
for (int i = 0, length = mixinTypes.size(); i < length; i++)
{
String mixin = mixinTypes.get(i);
if (node.canAddMixin(mixin))
{
node.addMixin(mixin); // depends on control dependency: [if], data = [none]
}
}
}
}
if (callSave)
{
try
{
parentNode.save(); // depends on control dependency: [try], data = [none]
}
catch (ItemExistsException e)
{
if (LOG.isTraceEnabled())
{
LOG.trace("An exception occurred: " + e.getMessage()); // depends on control dependency: [if], data = [none]
}
parentNode.refresh(false);
// Need to check until the concurrent tx that caused this ItemExistsException is fully committed
while (!parentNode.hasNode(nodeName));
return parentNode.getNode(nodeName);
} // depends on control dependency: [catch], data = [none]
}
return node;
} } |
public class class_name {
public Paint getPaint(long styleId, FeatureDrawType type) {
Paint paint = null;
FeaturePaint featurePaint = getFeaturePaint(styleId);
if (featurePaint != null) {
paint = featurePaint.getPaint(type);
}
return paint;
} } | public class class_name {
public Paint getPaint(long styleId, FeatureDrawType type) {
Paint paint = null;
FeaturePaint featurePaint = getFeaturePaint(styleId);
if (featurePaint != null) {
paint = featurePaint.getPaint(type); // depends on control dependency: [if], data = [none]
}
return paint;
} } |
public class class_name {
public void createContainerContext(@Observes EventContext<ContainerControlEvent> context) {
ContainerContext containerContext = this.containerContext.get();
ContainerControlEvent event = context.getEvent();
try {
containerContext.activate(event.getContainerName());
context.proceed();
} finally {
containerContext.deactivate();
}
} } | public class class_name {
public void createContainerContext(@Observes EventContext<ContainerControlEvent> context) {
ContainerContext containerContext = this.containerContext.get();
ContainerControlEvent event = context.getEvent();
try {
containerContext.activate(event.getContainerName()); // depends on control dependency: [try], data = [none]
context.proceed(); // depends on control dependency: [try], data = [none]
} finally {
containerContext.deactivate();
}
} } |
public class class_name {
public static String encodedEntry(String bucket, String key) {
String encodedEntry;
if (key != null) {
encodedEntry = UrlSafeBase64.encodeToString(bucket + ":" + key);
} else {
encodedEntry = UrlSafeBase64.encodeToString(bucket);
}
return encodedEntry;
} } | public class class_name {
public static String encodedEntry(String bucket, String key) {
String encodedEntry;
if (key != null) {
encodedEntry = UrlSafeBase64.encodeToString(bucket + ":" + key); // depends on control dependency: [if], data = [none]
} else {
encodedEntry = UrlSafeBase64.encodeToString(bucket); // depends on control dependency: [if], data = [none]
}
return encodedEntry;
} } |
public class class_name {
private boolean doHandleMethodCall(MethodCall<Object> methodCall,
final ServiceMethodHandler serviceMethodHandler) {
if (debug) {
logger.debug("ServiceImpl::doHandleMethodCall() METHOD CALL" + methodCall);
}
if (callbackManager != null) {
if (methodCall.hasCallback() && serviceMethodHandler.couldHaveCallback(methodCall.name())) {
callbackManager.registerCallbacks(methodCall);
}
}
//inputQueueListener.receive(methodCall);
final boolean continueFlag[] = new boolean[1];
methodCall = beforeMethodProcessing(methodCall, continueFlag);
if (continueFlag[0]) {
if (debug) logger.debug("ServiceImpl::doHandleMethodCall() before handling stopped processing");
return false;
}
Response<Object> response = serviceMethodHandler.receiveMethodCall(methodCall);
if (response != ServiceConstants.VOID) {
if (!afterMethodCall.after(methodCall, response)) {
return false;
}
//noinspection unchecked
response = responseObjectTransformer.transform(response);
if (!afterMethodCallAfterTransform.after(methodCall, response)) {
return false;
}
if (debug) {
if (response.body() instanceof Throwable) {
logger.error("Unable to handle call ", ((Throwable) response.body()));
}
}
if (!responseSendQueue.send(response)) {
logger.error("Unable to send response {} for method {} for object {}",
response,
methodCall.name(),
methodCall.objectName());
}
}
return false;
} } | public class class_name {
private boolean doHandleMethodCall(MethodCall<Object> methodCall,
final ServiceMethodHandler serviceMethodHandler) {
if (debug) {
logger.debug("ServiceImpl::doHandleMethodCall() METHOD CALL" + methodCall); // depends on control dependency: [if], data = [none]
}
if (callbackManager != null) {
if (methodCall.hasCallback() && serviceMethodHandler.couldHaveCallback(methodCall.name())) {
callbackManager.registerCallbacks(methodCall); // depends on control dependency: [if], data = [none]
}
}
//inputQueueListener.receive(methodCall);
final boolean continueFlag[] = new boolean[1];
methodCall = beforeMethodProcessing(methodCall, continueFlag);
if (continueFlag[0]) {
if (debug) logger.debug("ServiceImpl::doHandleMethodCall() before handling stopped processing");
return false; // depends on control dependency: [if], data = [none]
}
Response<Object> response = serviceMethodHandler.receiveMethodCall(methodCall);
if (response != ServiceConstants.VOID) {
if (!afterMethodCall.after(methodCall, response)) {
return false; // depends on control dependency: [if], data = [none]
}
//noinspection unchecked
response = responseObjectTransformer.transform(response); // depends on control dependency: [if], data = [(response]
if (!afterMethodCallAfterTransform.after(methodCall, response)) {
return false; // depends on control dependency: [if], data = [none]
}
if (debug) {
if (response.body() instanceof Throwable) {
logger.error("Unable to handle call ", ((Throwable) response.body())); // depends on control dependency: [if], data = [none]
}
}
if (!responseSendQueue.send(response)) {
logger.error("Unable to send response {} for method {} for object {}",
response,
methodCall.name(),
methodCall.objectName()); // depends on control dependency: [if], data = [none]
}
}
return false;
} } |
public class class_name {
private void drawYValues(Graphics2D chartGraphics) {
if (!showYAxisValues) {
return;
}
chartGraphics.setColor(axisValuesColour);
for (int i = 0; i < yValues.length; i++) {
if (i % yAxisValuesFrequency != 0) {
continue;
}
String yValueStr = yValues[i].toString();
chartGraphics.setFont(axisValuesFont);
FontMetrics metrics = chartGraphics.getFontMetrics();
int valueWidth = metrics.stringWidth(yValueStr);
if (yValuesHorizontal) {
// Draw the value with whatever font is now set.
int valueXPos = margin + yAxisLabelSize.height + (yAxisValuesWidthMax - valueWidth);
int valueYPos = heatMapTL.y + (i * cellSize.height) + (cellSize.height / 2)
+ (yAxisValuesAscent / 2);
chartGraphics.drawString(yValueStr, valueXPos, valueYPos);
}
else {
int valueXPos = margin + yAxisLabelSize.height + yAxisValuesAscent;
int valueYPos = heatMapTL.y + (i * cellSize.height) + (cellSize.height / 2)
+ (valueWidth / 2);
// Create 270 degree rotated transform.
AffineTransform transform = chartGraphics.getTransform();
AffineTransform originalTransform = (AffineTransform) transform.clone();
transform.rotate(Math.toRadians(270), valueXPos, valueYPos);
chartGraphics.setTransform(transform);
// Draw the string.
chartGraphics.drawString(yValueStr, valueXPos, valueYPos);
// Revert to original transform before rotation.
chartGraphics.setTransform(originalTransform);
}
}
} } | public class class_name {
private void drawYValues(Graphics2D chartGraphics) {
if (!showYAxisValues) {
return; // depends on control dependency: [if], data = [none]
}
chartGraphics.setColor(axisValuesColour);
for (int i = 0; i < yValues.length; i++) {
if (i % yAxisValuesFrequency != 0) {
continue;
}
String yValueStr = yValues[i].toString();
chartGraphics.setFont(axisValuesFont); // depends on control dependency: [for], data = [none]
FontMetrics metrics = chartGraphics.getFontMetrics();
int valueWidth = metrics.stringWidth(yValueStr);
if (yValuesHorizontal) {
// Draw the value with whatever font is now set.
int valueXPos = margin + yAxisLabelSize.height + (yAxisValuesWidthMax - valueWidth);
int valueYPos = heatMapTL.y + (i * cellSize.height) + (cellSize.height / 2)
+ (yAxisValuesAscent / 2);
chartGraphics.drawString(yValueStr, valueXPos, valueYPos); // depends on control dependency: [if], data = [none]
}
else {
int valueXPos = margin + yAxisLabelSize.height + yAxisValuesAscent;
int valueYPos = heatMapTL.y + (i * cellSize.height) + (cellSize.height / 2)
+ (valueWidth / 2);
// Create 270 degree rotated transform.
AffineTransform transform = chartGraphics.getTransform();
AffineTransform originalTransform = (AffineTransform) transform.clone();
transform.rotate(Math.toRadians(270), valueXPos, valueYPos); // depends on control dependency: [if], data = [none]
chartGraphics.setTransform(transform); // depends on control dependency: [if], data = [none]
// Draw the string.
chartGraphics.drawString(yValueStr, valueXPos, valueYPos); // depends on control dependency: [if], data = [none]
// Revert to original transform before rotation.
chartGraphics.setTransform(originalTransform); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
protected void addNameToApplicationMap(String name) {
String appName = getApplicationName();
// If it is a base metric, the name will be null
if (appName == null)
return;
ConcurrentLinkedQueue<String> list = applicationMap.get(appName);
if (list == null) {
ConcurrentLinkedQueue<String> newList = new ConcurrentLinkedQueue<String>();
list = applicationMap.putIfAbsent(appName, newList);
if (list == null)
list = newList;
}
list.add(name);
} } | public class class_name {
protected void addNameToApplicationMap(String name) {
String appName = getApplicationName();
// If it is a base metric, the name will be null
if (appName == null)
return;
ConcurrentLinkedQueue<String> list = applicationMap.get(appName);
if (list == null) {
ConcurrentLinkedQueue<String> newList = new ConcurrentLinkedQueue<String>();
list = applicationMap.putIfAbsent(appName, newList); // depends on control dependency: [if], data = [none]
if (list == null)
list = newList;
}
list.add(name);
} } |
public class class_name {
@Pure
public RoadSegment getConnectableSegmentToLastPoint(RoadPath path) {
assert path != null;
if (path.isEmpty()) {
return null;
}
RoadConnection last1 = getLastPoint();
RoadConnection first2 = path.getFirstPoint();
RoadConnection last2 = path.getLastPoint();
last1 = last1.getWrappedRoadConnection();
first2 = first2.getWrappedRoadConnection();
last2 = last2.getWrappedRoadConnection();
if (last1.equals(first2)) {
return path.getFirstSegment();
}
if (last1.equals(last2)) {
return path.getLastSegment();
}
return null;
} } | public class class_name {
@Pure
public RoadSegment getConnectableSegmentToLastPoint(RoadPath path) {
assert path != null;
if (path.isEmpty()) {
return null; // depends on control dependency: [if], data = [none]
}
RoadConnection last1 = getLastPoint();
RoadConnection first2 = path.getFirstPoint();
RoadConnection last2 = path.getLastPoint();
last1 = last1.getWrappedRoadConnection();
first2 = first2.getWrappedRoadConnection();
last2 = last2.getWrappedRoadConnection();
if (last1.equals(first2)) {
return path.getFirstSegment(); // depends on control dependency: [if], data = [none]
}
if (last1.equals(last2)) {
return path.getLastSegment(); // depends on control dependency: [if], data = [none]
}
return null;
} } |
public class class_name {
protected void changeTheme() {
currentTheme = getNextTheme(currentTheme);
if (currentTheme != null) {
currentTheme.setLooping(false);
currentTheme.setOnCompletionListener(listener);
currentTheme.setVolume(musicVolume.getPercent());
currentTheme.play();
}
} } | public class class_name {
protected void changeTheme() {
currentTheme = getNextTheme(currentTheme);
if (currentTheme != null) {
currentTheme.setLooping(false); // depends on control dependency: [if], data = [none]
currentTheme.setOnCompletionListener(listener); // depends on control dependency: [if], data = [none]
currentTheme.setVolume(musicVolume.getPercent()); // depends on control dependency: [if], data = [none]
currentTheme.play(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public boolean isCompliantWithRequestAccept(Request request) {
if (producedMediaTypes == null || producedMediaTypes.isEmpty() || request == null
|| request.getHeader(HeaderNames.ACCEPT) == null) {
return true;
} else {
for (MediaType mt : producedMediaTypes) {
if (request.accepts(mt.toString())) {
return true;
}
}
return false;
}
} } | public class class_name {
public boolean isCompliantWithRequestAccept(Request request) {
if (producedMediaTypes == null || producedMediaTypes.isEmpty() || request == null
|| request.getHeader(HeaderNames.ACCEPT) == null) {
return true; // depends on control dependency: [if], data = [none]
} else {
for (MediaType mt : producedMediaTypes) {
if (request.accepts(mt.toString())) {
return true; // depends on control dependency: [if], data = [none]
}
}
return false; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void continueIfExecutionDoesNotAffectNextOperation(Callback<PvmExecutionImpl, Void> dispatching,
Callback<PvmExecutionImpl, Void> continuation,
PvmExecutionImpl execution) {
String lastActivityId = execution.getActivityId();
String lastActivityInstanceId = getActivityInstanceId(execution);
dispatching.callback(execution);
execution = execution.getReplacedBy() != null ? execution.getReplacedBy() : execution;
String currentActivityInstanceId = getActivityInstanceId(execution);
String currentActivityId = execution.getActivityId();
//if execution was canceled or was changed during the dispatch we should not execute the next operation
//since another atomic operation was executed during the dispatching
if (!execution.isCanceled() && isOnSameActivity(lastActivityInstanceId, lastActivityId, currentActivityInstanceId, currentActivityId)) {
continuation.callback(execution);
}
} } | public class class_name {
public void continueIfExecutionDoesNotAffectNextOperation(Callback<PvmExecutionImpl, Void> dispatching,
Callback<PvmExecutionImpl, Void> continuation,
PvmExecutionImpl execution) {
String lastActivityId = execution.getActivityId();
String lastActivityInstanceId = getActivityInstanceId(execution);
dispatching.callback(execution);
execution = execution.getReplacedBy() != null ? execution.getReplacedBy() : execution;
String currentActivityInstanceId = getActivityInstanceId(execution);
String currentActivityId = execution.getActivityId();
//if execution was canceled or was changed during the dispatch we should not execute the next operation
//since another atomic operation was executed during the dispatching
if (!execution.isCanceled() && isOnSameActivity(lastActivityInstanceId, lastActivityId, currentActivityInstanceId, currentActivityId)) {
continuation.callback(execution); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
protected void registerEventHelpers ()
{
try {
_helpers.put(ObjectDestroyedEvent.class, new EventHelper () {
public boolean invoke (DEvent event, DObject target) {
return objectDestroyed(event, target);
}
});
_helpers.put(ObjectAddedEvent.class, new EventHelper() {
public boolean invoke (DEvent event, DObject target) {
return objectAdded(event, target);
}
});
_helpers.put(ObjectRemovedEvent.class, new EventHelper() {
public boolean invoke (DEvent event, DObject target) {
return objectRemoved(event, target);
}
});
} catch (Exception e) {
log.warning("Unable to register event helpers", "error", e);
}
} } | public class class_name {
protected void registerEventHelpers ()
{
try {
_helpers.put(ObjectDestroyedEvent.class, new EventHelper () {
public boolean invoke (DEvent event, DObject target) {
return objectDestroyed(event, target);
}
}); // depends on control dependency: [try], data = [none]
_helpers.put(ObjectAddedEvent.class, new EventHelper() {
public boolean invoke (DEvent event, DObject target) {
return objectAdded(event, target);
}
}); // depends on control dependency: [try], data = [none]
_helpers.put(ObjectRemovedEvent.class, new EventHelper() {
public boolean invoke (DEvent event, DObject target) {
return objectRemoved(event, target);
}
}); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
log.warning("Unable to register event helpers", "error", e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public DataObjectModel hide(String... properties)
{
DataObjectModel view = clone();
view.propertyList = new ArrayList<String>();
view.propertyList.addAll(this.propertyList);
for (String property : properties)
{
view.propertyList.remove(property);
}
return view;
} } | public class class_name {
public DataObjectModel hide(String... properties)
{
DataObjectModel view = clone();
view.propertyList = new ArrayList<String>();
view.propertyList.addAll(this.propertyList);
for (String property : properties)
{
view.propertyList.remove(property);
// depends on control dependency: [for], data = [property]
}
return view;
} } |
public class class_name {
public static int getMonthLength(int year, int month) {
if ((month < 1) || (month > 12)) {
throw new IllegalArgumentException("Invalid month: " + month);
}
if (month == 2) {
return isLeapYear(year) ? 29 : 28;
}
return MONTH_LENGTH[month];
} } | public class class_name {
public static int getMonthLength(int year, int month) {
if ((month < 1) || (month > 12)) {
throw new IllegalArgumentException("Invalid month: " + month);
}
if (month == 2) {
return isLeapYear(year) ? 29 : 28; // depends on control dependency: [if], data = [none]
}
return MONTH_LENGTH[month];
} } |
public class class_name {
public void putHeadCache(Short key, String value) {
if (headerCache == null) {
synchronized (this) {
if (headerCache == null) {
headerCache = new TwoWayMap<Short, String>();
}
}
}
if (headerCache != null && !headerCache.containsKey(key)) {
headerCache.put(key, value);
}
} } | public class class_name {
public void putHeadCache(Short key, String value) {
if (headerCache == null) {
synchronized (this) { // depends on control dependency: [if], data = [none]
if (headerCache == null) {
headerCache = new TwoWayMap<Short, String>(); // depends on control dependency: [if], data = [none]
}
}
}
if (headerCache != null && !headerCache.containsKey(key)) {
headerCache.put(key, value); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static boolean isValid(@Nullable final String hour) {
if (hour == null) {
return true;
}
return PATTERN.matcher(hour).matches();
} } | public class class_name {
public static boolean isValid(@Nullable final String hour) {
if (hour == null) {
return true; // depends on control dependency: [if], data = [none]
}
return PATTERN.matcher(hour).matches();
} } |
public class class_name {
private double scoreSaveEval(Vec x, List<Double> qi)
{
inputKEvals.clear();
inputKEvals.add(k.eval(0, 0, Arrays.asList(x), qi));
double sum = 0;
for(int i = 0; i < alphas.size(); i++)
{
double k_ix = k.eval(i, x, qi, vecs, accelCache);
inputKEvals.add(k_ix);
sum += alphas.getD(i)*k_ix;
}
return sum;
} } | public class class_name {
private double scoreSaveEval(Vec x, List<Double> qi)
{
inputKEvals.clear();
inputKEvals.add(k.eval(0, 0, Arrays.asList(x), qi));
double sum = 0;
for(int i = 0; i < alphas.size(); i++)
{
double k_ix = k.eval(i, x, qi, vecs, accelCache);
inputKEvals.add(k_ix); // depends on control dependency: [for], data = [none]
sum += alphas.getD(i)*k_ix; // depends on control dependency: [for], data = [i]
}
return sum;
} } |
public class class_name {
public Collection<Attribute<?>> getAllAttributes() {
List<Attribute<?>> allAttributes = new ArrayList<Attribute<?>>();
allAttributes.addAll(getAttributes());
Collection<ModelElementType> baseTypes = ModelUtil.calculateAllBaseTypes(this);
for (ModelElementType baseType : baseTypes) {
allAttributes.addAll(baseType.getAttributes());
}
return allAttributes;
} } | public class class_name {
public Collection<Attribute<?>> getAllAttributes() {
List<Attribute<?>> allAttributes = new ArrayList<Attribute<?>>();
allAttributes.addAll(getAttributes());
Collection<ModelElementType> baseTypes = ModelUtil.calculateAllBaseTypes(this);
for (ModelElementType baseType : baseTypes) {
allAttributes.addAll(baseType.getAttributes()); // depends on control dependency: [for], data = [baseType]
}
return allAttributes;
} } |
public class class_name {
public static JSONArray monitorForHA() {
Map<String, Cache> CACHE = Redis.unmodifiableCache();
JSONArray monitors = new JSONArray();
if (CACHE == null || CACHE.isEmpty())
return monitors;
JSONObject monitor = new JSONObject();
monitor.put("application", EnvUtil.getApplication());
monitor.put("nodeId", LocalNodeManager.LOCAL_NODE_ID);
for (Map.Entry<String, Cache> entry : CACHE.entrySet()) {
Cache cache = entry.getValue();
if (cache == null)
continue;
try {
monitor.put("instance", cache.getName());
monitors.add(new JSONObject() {{
putAll(monitor);
put("value", cache.highAvailable() ? 1 : -1);
put("name", "HA");
}});
} catch (Exception e) {
LOG.error(String.format("Jedis Pool: %s (Grafana) monitor 出现异常", entry.getKey()), e);
}
}
return monitors;
} } | public class class_name {
public static JSONArray monitorForHA() {
Map<String, Cache> CACHE = Redis.unmodifiableCache();
JSONArray monitors = new JSONArray();
if (CACHE == null || CACHE.isEmpty())
return monitors;
JSONObject monitor = new JSONObject();
monitor.put("application", EnvUtil.getApplication());
monitor.put("nodeId", LocalNodeManager.LOCAL_NODE_ID);
for (Map.Entry<String, Cache> entry : CACHE.entrySet()) {
Cache cache = entry.getValue();
if (cache == null)
continue;
try {
monitor.put("instance", cache.getName()); // depends on control dependency: [try], data = [none]
monitors.add(new JSONObject() {{
putAll(monitor);
put("value", cache.highAvailable() ? 1 : -1);
put("name", "HA");
}}); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
LOG.error(String.format("Jedis Pool: %s (Grafana) monitor 出现异常", entry.getKey()), e);
} // depends on control dependency: [catch], data = [none]
}
return monitors;
} } |
public class class_name {
private String read(Huff huff, Huff ext, Keep keep) throws JSONException {
Kim kim;
int at = 0;
int allocation = 256;
byte[] bytes = new byte[allocation];
if (bit()) {
return getAndTick(keep, this.bitreader).toString();
}
while (true) {
if (at >= allocation) {
allocation *= 2;
bytes = java.util.Arrays.copyOf(bytes, allocation);
}
int c = huff.read(this.bitreader);
if (c == end) {
break;
}
while ((c & 128) == 128) {
bytes[at] = (byte) c;
at += 1;
c = ext.read(this.bitreader);
}
bytes[at] = (byte) c;
at += 1;
}
if (at == 0) {
return "";
}
kim = new Kim(bytes, at);
keep.register(kim);
return kim.toString();
} } | public class class_name {
private String read(Huff huff, Huff ext, Keep keep) throws JSONException {
Kim kim;
int at = 0;
int allocation = 256;
byte[] bytes = new byte[allocation];
if (bit()) {
return getAndTick(keep, this.bitreader).toString();
}
while (true) {
if (at >= allocation) {
allocation *= 2; // depends on control dependency: [if], data = [none]
bytes = java.util.Arrays.copyOf(bytes, allocation); // depends on control dependency: [if], data = [none]
}
int c = huff.read(this.bitreader);
if (c == end) {
break;
}
while ((c & 128) == 128) {
bytes[at] = (byte) c; // depends on control dependency: [while], data = [none]
at += 1; // depends on control dependency: [while], data = [none]
c = ext.read(this.bitreader); // depends on control dependency: [while], data = [none]
}
bytes[at] = (byte) c;
at += 1;
}
if (at == 0) {
return "";
}
kim = new Kim(bytes, at);
keep.register(kim);
return kim.toString();
} } |
public class class_name {
public void afterLoading(CollectionProxyDefaultImpl colProxy)
{
if (log.isDebugEnabled()) log.debug("loading a proxied collection a collection: " + colProxy);
Collection data = colProxy.getData();
for (Iterator iterator = data.iterator(); iterator.hasNext();)
{
Object o = iterator.next();
if(!isOpen())
{
log.error("Collection proxy materialization outside of a running tx, obj=" + o);
try{throw new Exception("Collection proxy materialization outside of a running tx, obj=" + o);}
catch(Exception e)
{e.printStackTrace();}
}
else
{
Identity oid = getBroker().serviceIdentity().buildIdentity(o);
ClassDescriptor cld = getBroker().getClassDescriptor(ProxyHelper.getRealClass(o));
RuntimeObject rt = new RuntimeObject(o, oid, cld, false, ProxyHelper.isProxy(o));
lockAndRegister(rt, Transaction.READ, isImplicitLocking(), getRegistrationList());
}
}
unregisterFromCollectionProxy(colProxy);
} } | public class class_name {
public void afterLoading(CollectionProxyDefaultImpl colProxy)
{
if (log.isDebugEnabled()) log.debug("loading a proxied collection a collection: " + colProxy);
Collection data = colProxy.getData();
for (Iterator iterator = data.iterator(); iterator.hasNext();)
{
Object o = iterator.next();
if(!isOpen())
{
log.error("Collection proxy materialization outside of a running tx, obj=" + o);
// depends on control dependency: [if], data = [none]
try{throw new Exception("Collection proxy materialization outside of a running tx, obj=" + o);}
catch(Exception e)
{e.printStackTrace();}
// depends on control dependency: [catch], data = [none]
}
else
{
Identity oid = getBroker().serviceIdentity().buildIdentity(o);
ClassDescriptor cld = getBroker().getClassDescriptor(ProxyHelper.getRealClass(o));
RuntimeObject rt = new RuntimeObject(o, oid, cld, false, ProxyHelper.isProxy(o));
lockAndRegister(rt, Transaction.READ, isImplicitLocking(), getRegistrationList());
// depends on control dependency: [if], data = [none]
}
}
unregisterFromCollectionProxy(colProxy);
} } |
public class class_name {
private static void applyAllRecursively(ViewGroup viewGroup, AssetManager assets) {
for (int i = 0, size = viewGroup.getChildCount(); i < size; i++) {
final View childView = viewGroup.getChildAt(i);
if (childView instanceof TextView) {
setTypeface((TextView) childView, assets, false);
} else if (childView instanceof ViewGroup) {
applyAllRecursively((ViewGroup) childView, assets);
}
}
} } | public class class_name {
private static void applyAllRecursively(ViewGroup viewGroup, AssetManager assets) {
for (int i = 0, size = viewGroup.getChildCount(); i < size; i++) {
final View childView = viewGroup.getChildAt(i);
if (childView instanceof TextView) {
setTypeface((TextView) childView, assets, false); // depends on control dependency: [if], data = [none]
} else if (childView instanceof ViewGroup) {
applyAllRecursively((ViewGroup) childView, assets); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
@SuppressWarnings("checkstyle:all")
protected void generateEcoreDocumentationBuilderImpl() {
final TypeReference builder = getEcoreDocumentationBuilderImpl();
StringConcatenationClient content = new StringConcatenationClient() {
@SuppressWarnings("synthetic-access")
@Override
protected void appendTo(TargetStringConcatenation it) {
it.append("/** Build a documentation string."); //$NON-NLS-1$
it.newLine();
it.append(" */"); //$NON-NLS-1$
it.newLine();
it.append("public class "); //$NON-NLS-1$
it.append(builder.getSimpleName());
it.append(" implements "); //$NON-NLS-1$
it.append(getIEcoreDocumentationBuilder());
it.append(" {"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate "); //$NON-NLS-1$
it.append(AbstractRule.class);
it.append(" mlRule;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate "); //$NON-NLS-1$
it.append(AbstractRule.class);
it.append(" slRule;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate String mlStartSymbols;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate String mlEndTagSymbols;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate String slStartSymbols;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Inject.class);
it.newLine();
it.append("\tprivate "); //$NON-NLS-1$
it.append(getIDocumentationFormatter());
it.append(" documentationFormatter;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Inject.class);
it.newLine();
it.append("\tpublic void setGrammarAccess("); //$NON-NLS-1$
it.append(DocumentationBuilderFragment.this.grammarAccessExtensions.getGrammarAccess(getGrammar()));
it.append(" access) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\tthis.mlRule = access.getML_COMMENTRule();"); //$NON-NLS-1$
it.newLine();
it.append("\t\tthis.slRule = access.getSL_COMMENTRule();"); //$NON-NLS-1$
it.newLine();
it.append("\t\tfor ("); //$NON-NLS-1$
it.append(AbstractElement.class);
it.append(" element : (("); //$NON-NLS-1$
it.append(Group.class);
it.append(") this.mlRule.getAlternatives()).getElements()) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tif (element instanceof "); //$NON-NLS-1$
it.append(Keyword.class);
it.append(" && "); //$NON-NLS-1$
it.append(Strings.class);
it.append(".isEmpty(this.mlStartSymbols)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tthis.mlStartSymbols = (("); //$NON-NLS-1$
it.append(Keyword.class);
it.append(") element).getValue();"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t} else if (element instanceof "); //$NON-NLS-1$
it.append(UntilToken.class);
it.append(" && "); //$NON-NLS-1$
it.append(Strings.class);
it.append(".isEmpty(this.mlEndTagSymbols)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tthis.mlEndTagSymbols = (("); //$NON-NLS-1$
it.append(Keyword.class);
it.append(") (("); //$NON-NLS-1$
it.append(UntilToken.class);
it.append(") element).getTerminal()).getValue();"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\t"); //$NON-NLS-1$
it.append(AbstractRule.class);
it.append(" slRule = access.getSL_COMMENTRule();"); //$NON-NLS-1$
it.newLine();
it.append("\t\tfor ("); //$NON-NLS-1$
it.append(AbstractElement.class);
it.append(" element : (("); //$NON-NLS-1$
it.append(Group.class);
it.append(") slRule.getAlternatives()).getElements()) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tif (element instanceof "); //$NON-NLS-1$
it.append(Keyword.class);
it.append(") {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tthis.slStartSymbols = (("); //$NON-NLS-1$
it.append(Keyword.class);
it.append(") element).getValue().trim();"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tbreak;"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Pure.class);
it.newLine();
it.append("\tpublic "); //$NON-NLS-1$
it.append(AbstractRule.class);
it.append(" getMLCommentRule() {"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn this.mlRule;"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Pure.class);
it.newLine();
it.append("\tpublic "); //$NON-NLS-1$
it.append(AbstractRule.class);
it.append(" getSLCommentRule() {"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn this.slRule;"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Pure.class);
it.newLine();
it.append("\tpublic "); //$NON-NLS-1$
it.append(getIDocumentationFormatter());
it.append(" getDocumentationFormatter() {"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn this.documentationFormatter;"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Pure.class);
it.newLine();
it.append("\tpublic boolean isMultilineCommentFor(Class<?> type) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn "); //$NON-NLS-1$
Set<String> multilineCommentedTypes = getCodeBuilderConfig().getMultilineCommentedTypes();
if (multilineCommentedTypes.isEmpty()) {
it.append("false"); //$NON-NLS-1$
} else {
boolean firstTest = true;
for (String typeName : multilineCommentedTypes) {
if (firstTest) {
firstTest = false;
} else {
it.newLine();
it.append("\t\t\t\t|| "); //$NON-NLS-1$
}
TypeReference reference = new TypeReference(typeName);
it.append(reference);
it.append(".class.isAssignableFrom(type)"); //$NON-NLS-1$
}
}
it.append(";"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Pure.class);
it.newLine();
it.append("\tpublic String build(String doc, Class<?> objectType) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\tString givenDocumentation = "); //$NON-NLS-1$
it.append(Strings.class);
it.append(".emptyIfNull(doc).trim();"); //$NON-NLS-1$
it.newLine();
it.append("\t\tStringBuilder documentation = new StringBuilder();"); //$NON-NLS-1$
it.newLine();
it.append("\t\t"); //$NON-NLS-1$
it.append(getIDocumentationFormatter());
it.append(" formatter = getDocumentationFormatter();"); //$NON-NLS-1$
it.newLine();
it.append("\t\tif (isMultilineCommentFor(objectType)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tif (!givenDocumentation.startsWith(this.mlStartSymbols)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tdocumentation.append(this.mlStartSymbols);"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tdocumentation.append(givenDocumentation);"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tif (!givenDocumentation.endsWith(this.mlEndTagSymbols)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tdocumentation.append(this.mlEndTagSymbols);"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\treturn formatter.formatMultilineComment(documentation.toString());"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\tdocumentation.append(\"\\n\");"); //$NON-NLS-1$
it.newLine();
it.append("\t\tif (!givenDocumentation.startsWith(this.slStartSymbols)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tdocumentation.append(this.slStartSymbols);"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\tdocumentation.append(givenDocumentation);"); //$NON-NLS-1$
it.newLine();
it.append("\t\tif (!givenDocumentation.isEmpty() && !isNewLine(givenDocumentation.charAt(givenDocumentation.length() - 1))) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tdocumentation.append(\"\\n\");"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn formatter.formatSinglelineComment(documentation.toString());"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate static boolean isNewLine(char character) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\tif (character == '\\n' || character == '\\r' || character == '\\f') {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\treturn true;"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn ((((1 << "); //$NON-NLS-1$
it.append(Character.class);
it.append(".LINE_SEPARATOR)"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\t| (1 << "); //$NON-NLS-1$
it.append(Character.class);
it.append(".PARAGRAPH_SEPARATOR)) >> "); //$NON-NLS-1$
it.append(Character.class);
it.append(".getType((int) character)) & 1) != 0;"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
}
};
JavaFileAccess createJavaFile = getFileAccessFactory().createJavaFile(builder, content);
createJavaFile.writeTo(getSrcGen());
} } | public class class_name {
@SuppressWarnings("checkstyle:all")
protected void generateEcoreDocumentationBuilderImpl() {
final TypeReference builder = getEcoreDocumentationBuilderImpl();
StringConcatenationClient content = new StringConcatenationClient() {
@SuppressWarnings("synthetic-access")
@Override
protected void appendTo(TargetStringConcatenation it) {
it.append("/** Build a documentation string."); //$NON-NLS-1$
it.newLine();
it.append(" */"); //$NON-NLS-1$
it.newLine();
it.append("public class "); //$NON-NLS-1$
it.append(builder.getSimpleName());
it.append(" implements "); //$NON-NLS-1$
it.append(getIEcoreDocumentationBuilder());
it.append(" {"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate "); //$NON-NLS-1$
it.append(AbstractRule.class);
it.append(" mlRule;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate "); //$NON-NLS-1$
it.append(AbstractRule.class);
it.append(" slRule;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate String mlStartSymbols;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate String mlEndTagSymbols;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate String slStartSymbols;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Inject.class);
it.newLine();
it.append("\tprivate "); //$NON-NLS-1$
it.append(getIDocumentationFormatter());
it.append(" documentationFormatter;"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Inject.class);
it.newLine();
it.append("\tpublic void setGrammarAccess("); //$NON-NLS-1$
it.append(DocumentationBuilderFragment.this.grammarAccessExtensions.getGrammarAccess(getGrammar()));
it.append(" access) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\tthis.mlRule = access.getML_COMMENTRule();"); //$NON-NLS-1$
it.newLine();
it.append("\t\tthis.slRule = access.getSL_COMMENTRule();"); //$NON-NLS-1$
it.newLine();
it.append("\t\tfor ("); //$NON-NLS-1$
it.append(AbstractElement.class);
it.append(" element : (("); //$NON-NLS-1$
it.append(Group.class);
it.append(") this.mlRule.getAlternatives()).getElements()) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tif (element instanceof "); //$NON-NLS-1$
it.append(Keyword.class);
it.append(" && "); //$NON-NLS-1$
it.append(Strings.class);
it.append(".isEmpty(this.mlStartSymbols)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tthis.mlStartSymbols = (("); //$NON-NLS-1$
it.append(Keyword.class);
it.append(") element).getValue();"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t} else if (element instanceof "); //$NON-NLS-1$
it.append(UntilToken.class);
it.append(" && "); //$NON-NLS-1$
it.append(Strings.class);
it.append(".isEmpty(this.mlEndTagSymbols)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tthis.mlEndTagSymbols = (("); //$NON-NLS-1$
it.append(Keyword.class);
it.append(") (("); //$NON-NLS-1$
it.append(UntilToken.class);
it.append(") element).getTerminal()).getValue();"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\t"); //$NON-NLS-1$
it.append(AbstractRule.class);
it.append(" slRule = access.getSL_COMMENTRule();"); //$NON-NLS-1$
it.newLine();
it.append("\t\tfor ("); //$NON-NLS-1$
it.append(AbstractElement.class);
it.append(" element : (("); //$NON-NLS-1$
it.append(Group.class);
it.append(") slRule.getAlternatives()).getElements()) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tif (element instanceof "); //$NON-NLS-1$
it.append(Keyword.class);
it.append(") {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tthis.slStartSymbols = (("); //$NON-NLS-1$
it.append(Keyword.class);
it.append(") element).getValue().trim();"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tbreak;"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Pure.class);
it.newLine();
it.append("\tpublic "); //$NON-NLS-1$
it.append(AbstractRule.class);
it.append(" getMLCommentRule() {"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn this.mlRule;"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Pure.class);
it.newLine();
it.append("\tpublic "); //$NON-NLS-1$
it.append(AbstractRule.class);
it.append(" getSLCommentRule() {"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn this.slRule;"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Pure.class);
it.newLine();
it.append("\tpublic "); //$NON-NLS-1$
it.append(getIDocumentationFormatter());
it.append(" getDocumentationFormatter() {"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn this.documentationFormatter;"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Pure.class);
it.newLine();
it.append("\tpublic boolean isMultilineCommentFor(Class<?> type) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn "); //$NON-NLS-1$
Set<String> multilineCommentedTypes = getCodeBuilderConfig().getMultilineCommentedTypes();
if (multilineCommentedTypes.isEmpty()) {
it.append("false"); //$NON-NLS-1$ // depends on control dependency: [if], data = [none]
} else {
boolean firstTest = true;
for (String typeName : multilineCommentedTypes) {
if (firstTest) {
firstTest = false; // depends on control dependency: [if], data = [none]
} else {
it.newLine(); // depends on control dependency: [if], data = [none]
it.append("\t\t\t\t|| "); //$NON-NLS-1$ // depends on control dependency: [if], data = [none]
}
TypeReference reference = new TypeReference(typeName);
it.append(reference); // depends on control dependency: [for], data = [none]
it.append(".class.isAssignableFrom(type)"); //$NON-NLS-1$ // depends on control dependency: [for], data = [none]
}
}
it.append(";"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\t@"); //$NON-NLS-1$
it.append(Pure.class);
it.newLine();
it.append("\tpublic String build(String doc, Class<?> objectType) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\tString givenDocumentation = "); //$NON-NLS-1$
it.append(Strings.class);
it.append(".emptyIfNull(doc).trim();"); //$NON-NLS-1$
it.newLine();
it.append("\t\tStringBuilder documentation = new StringBuilder();"); //$NON-NLS-1$
it.newLine();
it.append("\t\t"); //$NON-NLS-1$
it.append(getIDocumentationFormatter());
it.append(" formatter = getDocumentationFormatter();"); //$NON-NLS-1$
it.newLine();
it.append("\t\tif (isMultilineCommentFor(objectType)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tif (!givenDocumentation.startsWith(this.mlStartSymbols)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tdocumentation.append(this.mlStartSymbols);"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tdocumentation.append(givenDocumentation);"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tif (!givenDocumentation.endsWith(this.mlEndTagSymbols)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\tdocumentation.append(this.mlEndTagSymbols);"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\treturn formatter.formatMultilineComment(documentation.toString());"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\tdocumentation.append(\"\\n\");"); //$NON-NLS-1$
it.newLine();
it.append("\t\tif (!givenDocumentation.startsWith(this.slStartSymbols)) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tdocumentation.append(this.slStartSymbols);"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\tdocumentation.append(givenDocumentation);"); //$NON-NLS-1$
it.newLine();
it.append("\t\tif (!givenDocumentation.isEmpty() && !isNewLine(givenDocumentation.charAt(givenDocumentation.length() - 1))) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\tdocumentation.append(\"\\n\");"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn formatter.formatSinglelineComment(documentation.toString());"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("\tprivate static boolean isNewLine(char character) {"); //$NON-NLS-1$
it.newLine();
it.append("\t\tif (character == '\\n' || character == '\\r' || character == '\\f') {"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\treturn true;"); //$NON-NLS-1$
it.newLine();
it.append("\t\t}"); //$NON-NLS-1$
it.newLine();
it.append("\t\treturn ((((1 << "); //$NON-NLS-1$
it.append(Character.class);
it.append(".LINE_SEPARATOR)"); //$NON-NLS-1$
it.newLine();
it.append("\t\t\t\t| (1 << "); //$NON-NLS-1$
it.append(Character.class);
it.append(".PARAGRAPH_SEPARATOR)) >> "); //$NON-NLS-1$
it.append(Character.class);
it.append(".getType((int) character)) & 1) != 0;"); //$NON-NLS-1$
it.newLine();
it.append("\t}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
it.append("}"); //$NON-NLS-1$
it.newLineIfNotEmpty();
it.newLine();
}
};
JavaFileAccess createJavaFile = getFileAccessFactory().createJavaFile(builder, content);
createJavaFile.writeTo(getSrcGen());
} } |
public class class_name {
public static StringBuilder build(StringBuilder sb, String app, String id, UserChain.Protocol proto, boolean as) {
boolean mayAs;
if(!(mayAs=sb.length()==0)) {
sb.append(',');
}
sb.append(app);
sb.append(':');
sb.append(id);
sb.append(':');
sb.append(proto.name());
if(as && mayAs) {
sb.append(":AS");
}
return sb;
} } | public class class_name {
public static StringBuilder build(StringBuilder sb, String app, String id, UserChain.Protocol proto, boolean as) {
boolean mayAs;
if(!(mayAs=sb.length()==0)) {
sb.append(','); // depends on control dependency: [if], data = [none]
}
sb.append(app);
sb.append(':');
sb.append(id);
sb.append(':');
sb.append(proto.name());
if(as && mayAs) {
sb.append(":AS"); // depends on control dependency: [if], data = [none]
}
return sb;
} } |
public class class_name {
public synchronized int getDataStartIndex() {
if (dataStartIndex == null) {
dataStartIndex = 1;
// check all the <tr>'s in the <tbody> until we find the 1st <tr> that has <td>'s. Then we know we have a
// row where the data starts. If there are columns in the <tbody>, there will be <th>'s for those rows.
List<WebElement> allRows = null;
String xPath = getXPathBase() + "tr";
try {
allRows = HtmlElementUtils.locateElements(xPath);
} catch (NoSuchElementException e) {
// if there is no tr in this table, then the tbody must be empty, therefore columns are not in the tbody
return 1;
}
if (allRows != null) {
for (WebElement row : allRows) {
if (!row.findElements(By.xpath("td")).isEmpty()) {
break;
}
dataStartIndex++;
}
}
}
return dataStartIndex;
} } | public class class_name {
public synchronized int getDataStartIndex() {
if (dataStartIndex == null) {
dataStartIndex = 1; // depends on control dependency: [if], data = [none]
// check all the <tr>'s in the <tbody> until we find the 1st <tr> that has <td>'s. Then we know we have a
// row where the data starts. If there are columns in the <tbody>, there will be <th>'s for those rows.
List<WebElement> allRows = null;
String xPath = getXPathBase() + "tr";
try {
allRows = HtmlElementUtils.locateElements(xPath); // depends on control dependency: [try], data = [none]
} catch (NoSuchElementException e) {
// if there is no tr in this table, then the tbody must be empty, therefore columns are not in the tbody
return 1;
} // depends on control dependency: [catch], data = [none]
if (allRows != null) {
for (WebElement row : allRows) {
if (!row.findElements(By.xpath("td")).isEmpty()) {
break;
}
dataStartIndex++; // depends on control dependency: [for], data = [none]
}
}
}
return dataStartIndex;
} } |
public class class_name {
public static BinaryAnnotationMappingDeriver getInstance(String path) {
if (instance == null) {
synchronized (LOCK) {
if (instance == null) {
instance = path == null ? new BinaryAnnotationMappingDeriver() :
new BinaryAnnotationMappingDeriver(path);
}
}
}
return instance;
} } | public class class_name {
public static BinaryAnnotationMappingDeriver getInstance(String path) {
if (instance == null) {
synchronized (LOCK) { // depends on control dependency: [if], data = [none]
if (instance == null) {
instance = path == null ? new BinaryAnnotationMappingDeriver() :
new BinaryAnnotationMappingDeriver(path); // depends on control dependency: [if], data = [none]
}
}
}
return instance;
} } |
public class class_name {
private Predicate toOrcPredicate(Expression pred) {
if (pred instanceof Or) {
Predicate c1 = toOrcPredicate(((Or) pred).left());
Predicate c2 = toOrcPredicate(((Or) pred).right());
if (c1 == null || c2 == null) {
return null;
} else {
return new OrcRowInputFormat.Or(c1, c2);
}
} else if (pred instanceof Not) {
Predicate c = toOrcPredicate(((Not) pred).child());
if (c == null) {
return null;
} else {
return new OrcRowInputFormat.Not(c);
}
} else if (pred instanceof BinaryComparison) {
BinaryComparison binComp = (BinaryComparison) pred;
if (!isValid(binComp)) {
// not a valid predicate
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
return null;
}
PredicateLeaf.Type litType = getLiteralType(binComp);
if (litType == null) {
// unsupported literal type
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
return null;
}
boolean literalOnRight = literalOnRight(binComp);
String colName = getColumnName(binComp);
// fetch literal and ensure it is serializable
Object literalObj = getLiteral(binComp);
Serializable literal;
// validate that literal is serializable
if (literalObj instanceof Serializable) {
literal = (Serializable) literalObj;
} else {
LOG.warn("Encountered a non-serializable literal of type {}. " +
"Cannot push predicate [{}] into OrcTableSource. " +
"This is a bug and should be reported.",
literalObj.getClass().getCanonicalName(), pred);
return null;
}
if (pred instanceof EqualTo) {
return new OrcRowInputFormat.Equals(colName, litType, literal);
} else if (pred instanceof NotEqualTo) {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.Equals(colName, litType, literal));
} else if (pred instanceof GreaterThan) {
if (literalOnRight) {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.LessThanEquals(colName, litType, literal));
} else {
return new OrcRowInputFormat.LessThan(colName, litType, literal);
}
} else if (pred instanceof GreaterThanOrEqual) {
if (literalOnRight) {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.LessThan(colName, litType, literal));
} else {
return new OrcRowInputFormat.LessThanEquals(colName, litType, literal);
}
} else if (pred instanceof LessThan) {
if (literalOnRight) {
return new OrcRowInputFormat.LessThan(colName, litType, literal);
} else {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.LessThanEquals(colName, litType, literal));
}
} else if (pred instanceof LessThanOrEqual) {
if (literalOnRight) {
return new OrcRowInputFormat.LessThanEquals(colName, litType, literal);
} else {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.LessThan(colName, litType, literal));
}
} else {
// unsupported predicate
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
return null;
}
} else if (pred instanceof UnaryExpression) {
UnaryExpression unary = (UnaryExpression) pred;
if (!isValid(unary)) {
// not a valid predicate
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
return null;
}
PredicateLeaf.Type colType = toOrcType(((UnaryExpression) pred).child().resultType());
if (colType == null) {
// unsupported type
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
return null;
}
String colName = getColumnName(unary);
if (pred instanceof IsNull) {
return new OrcRowInputFormat.IsNull(colName, colType);
} else if (pred instanceof IsNotNull) {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.IsNull(colName, colType));
} else {
// unsupported predicate
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
return null;
}
} else {
// unsupported predicate
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred);
return null;
}
} } | public class class_name {
private Predicate toOrcPredicate(Expression pred) {
if (pred instanceof Or) {
Predicate c1 = toOrcPredicate(((Or) pred).left());
Predicate c2 = toOrcPredicate(((Or) pred).right());
if (c1 == null || c2 == null) {
return null; // depends on control dependency: [if], data = [none]
} else {
return new OrcRowInputFormat.Or(c1, c2); // depends on control dependency: [if], data = [(c1]
}
} else if (pred instanceof Not) {
Predicate c = toOrcPredicate(((Not) pred).child());
if (c == null) {
return null; // depends on control dependency: [if], data = [none]
} else {
return new OrcRowInputFormat.Not(c); // depends on control dependency: [if], data = [(c]
}
} else if (pred instanceof BinaryComparison) {
BinaryComparison binComp = (BinaryComparison) pred;
if (!isValid(binComp)) {
// not a valid predicate
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
PredicateLeaf.Type litType = getLiteralType(binComp);
if (litType == null) {
// unsupported literal type
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
boolean literalOnRight = literalOnRight(binComp);
String colName = getColumnName(binComp);
// fetch literal and ensure it is serializable
Object literalObj = getLiteral(binComp);
Serializable literal;
// validate that literal is serializable
if (literalObj instanceof Serializable) {
literal = (Serializable) literalObj; // depends on control dependency: [if], data = [none]
} else {
LOG.warn("Encountered a non-serializable literal of type {}. " +
"Cannot push predicate [{}] into OrcTableSource. " +
"This is a bug and should be reported.",
literalObj.getClass().getCanonicalName(), pred); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
if (pred instanceof EqualTo) {
return new OrcRowInputFormat.Equals(colName, litType, literal); // depends on control dependency: [if], data = [none]
} else if (pred instanceof NotEqualTo) {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.Equals(colName, litType, literal)); // depends on control dependency: [if], data = [none]
} else if (pred instanceof GreaterThan) {
if (literalOnRight) {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.LessThanEquals(colName, litType, literal)); // depends on control dependency: [if], data = [none]
} else {
return new OrcRowInputFormat.LessThan(colName, litType, literal); // depends on control dependency: [if], data = [none]
}
} else if (pred instanceof GreaterThanOrEqual) {
if (literalOnRight) {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.LessThan(colName, litType, literal)); // depends on control dependency: [if], data = [none]
} else {
return new OrcRowInputFormat.LessThanEquals(colName, litType, literal); // depends on control dependency: [if], data = [none]
}
} else if (pred instanceof LessThan) {
if (literalOnRight) {
return new OrcRowInputFormat.LessThan(colName, litType, literal); // depends on control dependency: [if], data = [none]
} else {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.LessThanEquals(colName, litType, literal)); // depends on control dependency: [if], data = [none]
}
} else if (pred instanceof LessThanOrEqual) {
if (literalOnRight) {
return new OrcRowInputFormat.LessThanEquals(colName, litType, literal); // depends on control dependency: [if], data = [none]
} else {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.LessThan(colName, litType, literal)); // depends on control dependency: [if], data = [none]
}
} else {
// unsupported predicate
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
} else if (pred instanceof UnaryExpression) {
UnaryExpression unary = (UnaryExpression) pred;
if (!isValid(unary)) {
// not a valid predicate
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
PredicateLeaf.Type colType = toOrcType(((UnaryExpression) pred).child().resultType());
if (colType == null) {
// unsupported type
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
String colName = getColumnName(unary);
if (pred instanceof IsNull) {
return new OrcRowInputFormat.IsNull(colName, colType); // depends on control dependency: [if], data = [none]
} else if (pred instanceof IsNotNull) {
return new OrcRowInputFormat.Not(
new OrcRowInputFormat.IsNull(colName, colType)); // depends on control dependency: [if], data = [none]
} else {
// unsupported predicate
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
} else {
// unsupported predicate
LOG.debug("Unsupported predicate [{}] cannot be pushed into OrcTableSource.", pred); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private String getUserPassword(Object[] args) throws AuthException {
if (args == null)
throw new AuthException("auth error: args is null");
if ((userPasswordPair == null) || userPasswordPair.equals("")) {
try {
StringBuilder sb = new StringBuilder();
if ((args[0] != null) && (args[1] != null)) {
sb.append(args[0]);
sb.append(":");
sb.append(args[1]);
userPasswordPair = sb.toString();
}
} catch (Exception e) {
throw new AuthException("auth error: args is null");
}
}
Debug.logVerbose("[JdonFramework] url param is" + userPasswordPair, module);
return userPasswordPair;
} } | public class class_name {
private String getUserPassword(Object[] args) throws AuthException {
if (args == null)
throw new AuthException("auth error: args is null");
if ((userPasswordPair == null) || userPasswordPair.equals("")) {
try {
StringBuilder sb = new StringBuilder();
if ((args[0] != null) && (args[1] != null)) {
sb.append(args[0]);
// depends on control dependency: [if], data = [none]
sb.append(":");
// depends on control dependency: [if], data = [none]
sb.append(args[1]);
// depends on control dependency: [if], data = [none]
userPasswordPair = sb.toString();
// depends on control dependency: [if], data = [none]
}
} catch (Exception e) {
throw new AuthException("auth error: args is null");
}
// depends on control dependency: [catch], data = [none]
}
Debug.logVerbose("[JdonFramework] url param is" + userPasswordPair, module);
return userPasswordPair;
} } |
public class class_name {
@SuppressWarnings("unchecked")
public <T> T parse(String xml, Class<T> clazz) {
Assert.notNull(clazz);
if (StringUtils.isEmpty(xml)) {
return null;
}
T pojo;
Document document;
// 获取pojo对象的实例
try {
// 没有权限访问该类或者该类(为接口、抽象类)不能实例化时将抛出异常
pojo = clazz.newInstance();
} catch (Exception e) {
log.error("class对象生成失败,请检查代码;失败原因:", e);
throw new RuntimeException(e);
}
// 解析XML
try {
document = parseText(xml);
} catch (Exception e) {
log.error("xml解析错误", e);
return null;
}
// 获取pojo对象的说明
CustomPropertyDescriptor[] propertyDescriptor = BeanUtils.getPropertyDescriptors(clazz);
Element root = document.getRootElement();
for (CustomPropertyDescriptor descript : propertyDescriptor) {
XmlNode xmlNode = descript.getAnnotation(XmlNode.class);
final String fieldName = descript.getName();
//节点名
String nodeName = null;
//属性名
String attributeName = null;
boolean isParent = false;
boolean ignore = false;
if (xmlNode == null) {
nodeName = fieldName;
} else if (!xmlNode.ignore()) {
//如果节点不是被忽略的节点那么继续
//获取节点名称,优先使用注解,如果注解没有设置名称那么使用字段名
nodeName = StringUtils.isEmpty(xmlNode.name()) ? fieldName : xmlNode.name();
log.debug("字段[{}]对应的节点名为:{}", fieldName, nodeName);
//判断节点是否是属性值
if (xmlNode.isAttribute()) {
//如果节点是属性值,那么需要同时设置节点名和属性名,原则上如果是属性的话必须设置节点名,但是为了防止
//用户忘记设置,在用户没有设置的时候使用字段名
if (StringUtils.isEmpty(xmlNode.attributeName())) {
log.warn("字段[{}]是属性值,但是未设置属性名(attributeName字段),将采用字段名作为属性名",
descript.getName());
attributeName = fieldName;
} else {
attributeName = xmlNode.attributeName();
}
if (StringUtils.isEmpty(xmlNode.name())) {
log.debug("该字段是属性值,并且未设置节点名(name字段),设置isParent为true");
isParent = true;
}
} else {
log.debug("字段[{}]对应的是节点");
}
} else {
ignore = true;
}
if (!ignore) {
//获取指定节点名的element
List<Element> nodes = (!StringUtils.isEmpty(attributeName) && isParent)
? Collections.singletonList(root)
: root.elements(nodeName);
//判断是否为空
if (nodes.isEmpty()) {
//如果为空那么将首字母大写后重新获取
nodes = root.elements(StringUtils.toFirstUpperCase(nodeName));
}
if (!nodes.isEmpty()) {
//如果还不为空,那么为pojo赋值
Class<?> type = descript.getRealType();
//开始赋值
//判断字段是否是集合
if (Collection.class.isAssignableFrom(type)) {
//是集合
setValue(nodes, attributeName, pojo, descript);
} else if (Map.class.isAssignableFrom(type)) {
//是Map
log.warn("当前暂时不支持解析map");
} else {
//不是集合,直接赋值
setValue(nodes.get(0), attributeName, pojo, descript);
}
}
}
}
return pojo;
} } | public class class_name {
@SuppressWarnings("unchecked")
public <T> T parse(String xml, Class<T> clazz) {
Assert.notNull(clazz);
if (StringUtils.isEmpty(xml)) {
return null; // depends on control dependency: [if], data = [none]
}
T pojo;
Document document;
// 获取pojo对象的实例
try {
// 没有权限访问该类或者该类(为接口、抽象类)不能实例化时将抛出异常
pojo = clazz.newInstance(); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
log.error("class对象生成失败,请检查代码;失败原因:", e);
throw new RuntimeException(e);
} // depends on control dependency: [catch], data = [none]
// 解析XML
try {
document = parseText(xml); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
log.error("xml解析错误", e);
return null;
} // depends on control dependency: [catch], data = [none]
// 获取pojo对象的说明
CustomPropertyDescriptor[] propertyDescriptor = BeanUtils.getPropertyDescriptors(clazz);
Element root = document.getRootElement();
for (CustomPropertyDescriptor descript : propertyDescriptor) {
XmlNode xmlNode = descript.getAnnotation(XmlNode.class);
final String fieldName = descript.getName();
//节点名
String nodeName = null;
//属性名
String attributeName = null;
boolean isParent = false;
boolean ignore = false;
if (xmlNode == null) {
nodeName = fieldName; // depends on control dependency: [if], data = [none]
} else if (!xmlNode.ignore()) {
//如果节点不是被忽略的节点那么继续
//获取节点名称,优先使用注解,如果注解没有设置名称那么使用字段名
nodeName = StringUtils.isEmpty(xmlNode.name()) ? fieldName : xmlNode.name(); // depends on control dependency: [if], data = [none]
log.debug("字段[{}]对应的节点名为:{}", fieldName, nodeName); // depends on control dependency: [if], data = [none]
//判断节点是否是属性值
if (xmlNode.isAttribute()) {
//如果节点是属性值,那么需要同时设置节点名和属性名,原则上如果是属性的话必须设置节点名,但是为了防止
//用户忘记设置,在用户没有设置的时候使用字段名
if (StringUtils.isEmpty(xmlNode.attributeName())) {
log.warn("字段[{}]是属性值,但是未设置属性名(attributeName字段),将采用字段名作为属性名",
descript.getName()); // depends on control dependency: [if], data = [none]
attributeName = fieldName; // depends on control dependency: [if], data = [none]
} else {
attributeName = xmlNode.attributeName(); // depends on control dependency: [if], data = [none]
}
if (StringUtils.isEmpty(xmlNode.name())) {
log.debug("该字段是属性值,并且未设置节点名(name字段),设置isParent为true"); // depends on control dependency: [if], data = [none]
isParent = true; // depends on control dependency: [if], data = [none]
}
} else {
log.debug("字段[{}]对应的是节点"); // depends on control dependency: [if], data = [none]
}
} else {
ignore = true; // depends on control dependency: [if], data = [none]
}
if (!ignore) {
//获取指定节点名的element
List<Element> nodes = (!StringUtils.isEmpty(attributeName) && isParent)
? Collections.singletonList(root)
: root.elements(nodeName);
//判断是否为空
if (nodes.isEmpty()) {
//如果为空那么将首字母大写后重新获取
nodes = root.elements(StringUtils.toFirstUpperCase(nodeName)); // depends on control dependency: [if], data = [none]
}
if (!nodes.isEmpty()) {
//如果还不为空,那么为pojo赋值
Class<?> type = descript.getRealType();
//开始赋值
//判断字段是否是集合
if (Collection.class.isAssignableFrom(type)) {
//是集合
setValue(nodes, attributeName, pojo, descript); // depends on control dependency: [if], data = [none]
} else if (Map.class.isAssignableFrom(type)) {
//是Map
log.warn("当前暂时不支持解析map"); // depends on control dependency: [if], data = [none]
} else {
//不是集合,直接赋值
setValue(nodes.get(0), attributeName, pojo, descript); // depends on control dependency: [if], data = [none]
}
}
}
}
return pojo;
} } |
public class class_name {
public void checkHttpURL(String document, String userAgent,
ErrorHandler errorHandler)
throws IOException, SAXException {
CookieHandler.setDefault(
new CookieManager(null, CookiePolicy.ACCEPT_ALL));
validator.reset();
httpRes = new PrudentHttpEntityResolver(-1, true, errorHandler);
if (this.allowCss) {
httpRes.setAllowCss(true);
}
httpRes.setAllowHtml(true);
httpRes.setUserAgent(userAgent);
try {
documentInput = (TypedInputSource) httpRes.resolveEntity(null,
document);
String contentType = documentInput.getType();
documentInput.setSystemId(document);
for (String param : contentType.replace(" ", "").split(";")) {
if (param.startsWith("charset=")) {
documentInput.setEncoding(param.split("=", 2)[1]);
break;
}
}
if (documentInput.getType().startsWith("text/css")) {
checkAsCss(documentInput);
} else if (documentInput.getType().startsWith("text/html")) {
checkAsHTML(documentInput);
} else {
checkAsXML(documentInput);
}
} catch (ResourceNotRetrievableException e) {
}
} } | public class class_name {
public void checkHttpURL(String document, String userAgent,
ErrorHandler errorHandler)
throws IOException, SAXException {
CookieHandler.setDefault(
new CookieManager(null, CookiePolicy.ACCEPT_ALL));
validator.reset();
httpRes = new PrudentHttpEntityResolver(-1, true, errorHandler);
if (this.allowCss) {
httpRes.setAllowCss(true);
}
httpRes.setAllowHtml(true);
httpRes.setUserAgent(userAgent);
try {
documentInput = (TypedInputSource) httpRes.resolveEntity(null,
document);
String contentType = documentInput.getType();
documentInput.setSystemId(document);
for (String param : contentType.replace(" ", "").split(";")) {
if (param.startsWith("charset=")) {
documentInput.setEncoding(param.split("=", 2)[1]); // depends on control dependency: [if], data = [none]
break;
}
}
if (documentInput.getType().startsWith("text/css")) {
checkAsCss(documentInput); // depends on control dependency: [if], data = [none]
} else if (documentInput.getType().startsWith("text/html")) {
checkAsHTML(documentInput); // depends on control dependency: [if], data = [none]
} else {
checkAsXML(documentInput); // depends on control dependency: [if], data = [none]
}
} catch (ResourceNotRetrievableException e) {
}
} } |
public class class_name {
private void migrateMembershipTypes() throws Exception
{
Session session = service.getStorageSession();
try
{
if (session.itemExists(membershipTypesStorageOld))
{
NodeIterator iterator = ((ExtendedNode)session.getItem(membershipTypesStorageOld)).getNodesLazily();
MembershipTypeHandlerImpl mth = ((MembershipTypeHandlerImpl)service.getMembershipTypeHandler());
while (iterator.hasNext())
{
Node oldTypeNode = iterator.nextNode();
mth.migrateMembershipType(oldTypeNode);
}
}
}
finally
{
session.logout();
}
} } | public class class_name {
private void migrateMembershipTypes() throws Exception
{
Session session = service.getStorageSession();
try
{
if (session.itemExists(membershipTypesStorageOld))
{
NodeIterator iterator = ((ExtendedNode)session.getItem(membershipTypesStorageOld)).getNodesLazily();
MembershipTypeHandlerImpl mth = ((MembershipTypeHandlerImpl)service.getMembershipTypeHandler());
while (iterator.hasNext())
{
Node oldTypeNode = iterator.nextNode();
mth.migrateMembershipType(oldTypeNode); // depends on control dependency: [while], data = [none]
}
}
}
finally
{
session.logout();
}
} } |
public class class_name {
private void storeArgs(Constructor constructor, Array conArgs) {
Class[] pmt = constructor.getParameterTypes();
Object o = conArgs.get(pmt.length + 1, null);
Constructor[] args;
if (o == null) {
args = new Constructor[1];
conArgs.setEL(pmt.length + 1, args);
}
else {
Constructor[] cs = (Constructor[]) o;
args = new Constructor[cs.length + 1];
for (int i = 0; i < cs.length; i++) {
args[i] = cs[i];
}
conArgs.setEL(pmt.length + 1, args);
}
args[args.length - 1] = constructor;
} } | public class class_name {
private void storeArgs(Constructor constructor, Array conArgs) {
Class[] pmt = constructor.getParameterTypes();
Object o = conArgs.get(pmt.length + 1, null);
Constructor[] args;
if (o == null) {
args = new Constructor[1];
conArgs.setEL(pmt.length + 1, args);
}
else {
Constructor[] cs = (Constructor[]) o;
args = new Constructor[cs.length + 1];
for (int i = 0; i < cs.length; i++) {
args[i] = cs[i]; // depends on control dependency: [for], data = [i]
}
conArgs.setEL(pmt.length + 1, args);
}
args[args.length - 1] = constructor;
} } |
public class class_name {
public void setPassword(final String psw) {
if (StringUtils.isNotBlank(psw)) {
LOGGER.debug("Configured Jasypt password");
jasyptInstance.setPassword(psw);
}
} } | public class class_name {
public void setPassword(final String psw) {
if (StringUtils.isNotBlank(psw)) {
LOGGER.debug("Configured Jasypt password"); // depends on control dependency: [if], data = [none]
jasyptInstance.setPassword(psw); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static Properties getPropertiesFromResource(final String name) throws Throwable {
Properties pr = new Properties();
InputStream is = null;
try {
try {
// The jboss?? way - should work for others as well.
ClassLoader cl = Thread.currentThread().getContextClassLoader();
is = cl.getResourceAsStream(name);
} catch (Throwable clt) {}
if (is == null) {
// Try another way
is = Util.class.getResourceAsStream(name);
}
if (is == null) {
throw new Exception("Unable to load properties file" + name);
}
pr.load(is);
//if (debug) {
// pr.list(System.out);
// Logger.getLogger(Util.class).debug(
// "file.encoding=" + System.getProperty("file.encoding"));
//}
return pr;
} finally {
if (is != null) {
try {
is.close();
} catch (Throwable t1) {}
}
}
} } | public class class_name {
public static Properties getPropertiesFromResource(final String name) throws Throwable {
Properties pr = new Properties();
InputStream is = null;
try {
try {
// The jboss?? way - should work for others as well.
ClassLoader cl = Thread.currentThread().getContextClassLoader();
is = cl.getResourceAsStream(name); // depends on control dependency: [try], data = [none]
} catch (Throwable clt) {} // depends on control dependency: [catch], data = [none]
if (is == null) {
// Try another way
is = Util.class.getResourceAsStream(name); // depends on control dependency: [if], data = [none]
}
if (is == null) {
throw new Exception("Unable to load properties file" + name);
}
pr.load(is);
//if (debug) {
// pr.list(System.out);
// Logger.getLogger(Util.class).debug(
// "file.encoding=" + System.getProperty("file.encoding"));
//}
return pr;
} finally {
if (is != null) {
try {
is.close(); // depends on control dependency: [try], data = [none]
} catch (Throwable t1) {} // depends on control dependency: [catch], data = [none]
}
}
} } |
public class class_name {
@SuppressWarnings("unchecked")
public void copy(Copier from)
{
if(!(from instanceof Topic))
{
return;
}
Topic<T> topic = (Topic<T>)from;
this.name = topic.name;
this.observerMap = topic.observerMap;
} } | public class class_name {
@SuppressWarnings("unchecked")
public void copy(Copier from)
{
if(!(from instanceof Topic))
{
return;
// depends on control dependency: [if], data = [none]
}
Topic<T> topic = (Topic<T>)from;
this.name = topic.name;
this.observerMap = topic.observerMap;
} } |
public class class_name {
private static byte[] getRowKey(final long start_time, final byte[] tsuid) {
if (start_time < 1) {
throw new IllegalArgumentException("The start timestamp has not been set");
}
final long base_time;
if ((start_time & Const.SECOND_MASK) != 0) {
// drop the ms timestamp to seconds to calculate the base timestamp
base_time = ((start_time / 1000) -
((start_time / 1000) % Const.MAX_TIMESPAN));
} else {
base_time = (start_time - (start_time % Const.MAX_TIMESPAN));
}
// if the TSUID is empty, then we're a global annotation. The row key will
// just be an empty byte array of metric width plus the timestamp. We also
// don't salt the global row key (though it has space for salts)
if (tsuid == null || tsuid.length < 1) {
final byte[] row = new byte[Const.SALT_WIDTH() +
TSDB.metrics_width() + Const.TIMESTAMP_BYTES];
Bytes.setInt(row, (int) base_time, Const.SALT_WIDTH() + TSDB.metrics_width());
return row;
}
// otherwise we need to build the row key from the TSUID and start time
final byte[] row = new byte[Const.SALT_WIDTH() + Const.TIMESTAMP_BYTES +
tsuid.length];
System.arraycopy(tsuid, 0, row, Const.SALT_WIDTH(), TSDB.metrics_width());
Bytes.setInt(row, (int) base_time, Const.SALT_WIDTH() + TSDB.metrics_width());
System.arraycopy(tsuid, TSDB.metrics_width(), row,
Const.SALT_WIDTH() + TSDB.metrics_width() + Const.TIMESTAMP_BYTES,
(tsuid.length - TSDB.metrics_width()));
RowKey.prefixKeyWithSalt(row);
return row;
} } | public class class_name {
private static byte[] getRowKey(final long start_time, final byte[] tsuid) {
if (start_time < 1) {
throw new IllegalArgumentException("The start timestamp has not been set");
}
final long base_time;
if ((start_time & Const.SECOND_MASK) != 0) {
// drop the ms timestamp to seconds to calculate the base timestamp
base_time = ((start_time / 1000) -
((start_time / 1000) % Const.MAX_TIMESPAN)); // depends on control dependency: [if], data = [0)]
} else {
base_time = (start_time - (start_time % Const.MAX_TIMESPAN)); // depends on control dependency: [if], data = [none]
}
// if the TSUID is empty, then we're a global annotation. The row key will
// just be an empty byte array of metric width plus the timestamp. We also
// don't salt the global row key (though it has space for salts)
if (tsuid == null || tsuid.length < 1) {
final byte[] row = new byte[Const.SALT_WIDTH() +
TSDB.metrics_width() + Const.TIMESTAMP_BYTES];
Bytes.setInt(row, (int) base_time, Const.SALT_WIDTH() + TSDB.metrics_width()); // depends on control dependency: [if], data = [none]
return row; // depends on control dependency: [if], data = [none]
}
// otherwise we need to build the row key from the TSUID and start time
final byte[] row = new byte[Const.SALT_WIDTH() + Const.TIMESTAMP_BYTES +
tsuid.length];
System.arraycopy(tsuid, 0, row, Const.SALT_WIDTH(), TSDB.metrics_width());
Bytes.setInt(row, (int) base_time, Const.SALT_WIDTH() + TSDB.metrics_width());
System.arraycopy(tsuid, TSDB.metrics_width(), row,
Const.SALT_WIDTH() + TSDB.metrics_width() + Const.TIMESTAMP_BYTES,
(tsuid.length - TSDB.metrics_width()));
RowKey.prefixKeyWithSalt(row);
return row;
} } |
public class class_name {
protected List<CmsProperty> tryAddImageSizeFromSvg(byte[] content, List<CmsProperty> properties) {
if ((content == null) || (content.length == 0)) {
return properties;
}
List<CmsProperty> newProps = properties;
try {
double w = -1, h = -1;
SAXReader reader = new SAXReader();
Document doc = reader.read(new ByteArrayInputStream(content));
Element node = (Element)(doc.selectSingleNode("/svg"));
if (node != null) {
String widthStr = node.attributeValue("width");
String heightStr = node.attributeValue("height");
SvgSize width = SvgSize.parse(widthStr);
SvgSize height = SvgSize.parse(heightStr);
if ((width != null) && (height != null) && Objects.equals(width.getUnit(), height.getUnit())) {
// If width and height are given and have the same units, just interpret them as pixels, otherwise use viewbox
w = width.getSize();
h = height.getSize();
} else {
String viewboxStr = node.attributeValue("viewBox");
if (viewboxStr != null) {
viewboxStr = viewboxStr.replace(",", " ");
String[] viewboxParts = viewboxStr.trim().split(" +");
if (viewboxParts.length == 4) {
w = Double.parseDouble(viewboxParts[2]);
h = Double.parseDouble(viewboxParts[3]);
}
}
}
if ((w > 0) && (h > 0)) {
String propValue = "w:" + (int)Math.round(w) + ",h:" + (int)Math.round(h);
Map<String, CmsProperty> propsMap = properties == null
? new HashMap<>()
: CmsProperty.toObjectMap(properties);
propsMap.put(
CmsPropertyDefinition.PROPERTY_IMAGE_SIZE,
new CmsProperty(CmsPropertyDefinition.PROPERTY_IMAGE_SIZE, null, propValue));
newProps = new ArrayList<>(propsMap.values());
}
}
} catch (Exception e) {
LOG.error("Error while trying to determine size of SVG: " + e.getLocalizedMessage(), e);
}
return newProps;
} } | public class class_name {
protected List<CmsProperty> tryAddImageSizeFromSvg(byte[] content, List<CmsProperty> properties) {
if ((content == null) || (content.length == 0)) {
return properties; // depends on control dependency: [if], data = [none]
}
List<CmsProperty> newProps = properties;
try {
double w = -1, h = -1;
SAXReader reader = new SAXReader();
Document doc = reader.read(new ByteArrayInputStream(content));
Element node = (Element)(doc.selectSingleNode("/svg"));
if (node != null) {
String widthStr = node.attributeValue("width");
String heightStr = node.attributeValue("height");
SvgSize width = SvgSize.parse(widthStr);
SvgSize height = SvgSize.parse(heightStr);
if ((width != null) && (height != null) && Objects.equals(width.getUnit(), height.getUnit())) {
// If width and height are given and have the same units, just interpret them as pixels, otherwise use viewbox
w = width.getSize(); // depends on control dependency: [if], data = [none]
h = height.getSize(); // depends on control dependency: [if], data = [none]
} else {
String viewboxStr = node.attributeValue("viewBox");
if (viewboxStr != null) {
viewboxStr = viewboxStr.replace(",", " "); // depends on control dependency: [if], data = [none]
String[] viewboxParts = viewboxStr.trim().split(" +");
if (viewboxParts.length == 4) {
w = Double.parseDouble(viewboxParts[2]); // depends on control dependency: [if], data = [none]
h = Double.parseDouble(viewboxParts[3]); // depends on control dependency: [if], data = [none]
}
}
}
if ((w > 0) && (h > 0)) {
String propValue = "w:" + (int)Math.round(w) + ",h:" + (int)Math.round(h);
Map<String, CmsProperty> propsMap = properties == null
? new HashMap<>()
: CmsProperty.toObjectMap(properties);
propsMap.put(
CmsPropertyDefinition.PROPERTY_IMAGE_SIZE,
new CmsProperty(CmsPropertyDefinition.PROPERTY_IMAGE_SIZE, null, propValue)); // depends on control dependency: [if], data = [none]
newProps = new ArrayList<>(propsMap.values()); // depends on control dependency: [if], data = [none]
}
}
} catch (Exception e) {
LOG.error("Error while trying to determine size of SVG: " + e.getLocalizedMessage(), e);
}
return newProps;
} } |
public class class_name {
public static void main(String[] urls) throws Exception {
GroovyScriptEngine gse = new GroovyScriptEngine(urls);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while (true) {
System.out.print("groovy> ");
if ((line = br.readLine()) == null || line.equals("quit")) {
break;
}
try {
System.out.println(gse.run(line, new Binding()));
} catch (Exception e) {
e.printStackTrace();
}
}
} } | public class class_name {
public static void main(String[] urls) throws Exception {
GroovyScriptEngine gse = new GroovyScriptEngine(urls);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while (true) {
System.out.print("groovy> ");
if ((line = br.readLine()) == null || line.equals("quit")) {
break;
}
try {
System.out.println(gse.run(line, new Binding())); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
e.printStackTrace();
} // depends on control dependency: [catch], data = [none]
}
} } |
public class class_name {
public static List<String> seg(String text, boolean withPunctuation, char... reserve){
List<String> list = new ArrayList<>();
int start = 0;
char[] array = text.toCharArray();
int len = array.length;
outer:for(int i=0; i<len; i++){
char c = array[i];
for(char t : reserve){
if(c == t){
//保留的标点符号
continue outer;
}
}
if(Punctuation.is(c)){
if(i > start){
list.add(text.substring(start, i));
//下一句开始索引
start = i+1;
}else{
//跳过标点符号
start++;
}
if(withPunctuation){
list.add(Character.toString(c));
}
}
}
if(len - start > 0){
list.add(text.substring(start, len));
}
return list;
} } | public class class_name {
public static List<String> seg(String text, boolean withPunctuation, char... reserve){
List<String> list = new ArrayList<>();
int start = 0;
char[] array = text.toCharArray();
int len = array.length;
outer:for(int i=0; i<len; i++){
char c = array[i];
for(char t : reserve){
if(c == t){
//保留的标点符号
continue outer;
}
}
if(Punctuation.is(c)){
if(i > start){
list.add(text.substring(start, i)); // depends on control dependency: [if], data = [none]
//下一句开始索引
start = i+1; // depends on control dependency: [if], data = [none]
}else{
//跳过标点符号
start++; // depends on control dependency: [if], data = [none]
}
if(withPunctuation){
list.add(Character.toString(c)); // depends on control dependency: [if], data = [none]
}
}
}
if(len - start > 0){
list.add(text.substring(start, len)); // depends on control dependency: [if], data = [none]
}
return list;
} } |
public class class_name {
public Set<String> getSupportedAnnotationTypes() {
SupportedAnnotationTypes sat = this.getClass().getAnnotation(SupportedAnnotationTypes.class);
if (sat == null) {
if (isInitialized())
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING,
"No SupportedAnnotationTypes annotation " +
"found on " + this.getClass().getName() +
", returning an empty set.");
return Collections.emptySet();
}
else
return arrayToSet(sat.value());
} } | public class class_name {
public Set<String> getSupportedAnnotationTypes() {
SupportedAnnotationTypes sat = this.getClass().getAnnotation(SupportedAnnotationTypes.class);
if (sat == null) {
if (isInitialized())
processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING,
"No SupportedAnnotationTypes annotation " +
"found on " + this.getClass().getName() +
", returning an empty set.");
return Collections.emptySet(); // depends on control dependency: [if], data = [none]
}
else
return arrayToSet(sat.value());
} } |
public class class_name {
@Override
public void setValue(Object value) throws WidgetException {
try {
if (value instanceof String) {
boolean selected = false;
List<WebElement> elements = findElements();
for (WebElement we : elements) {
if (we.getAttribute("value").equals(value)) {
we.click();
selected = true;
break;
}
}
if (!selected)
throw new WidgetException("Could not find desired option to select",
getLocator());
} else {
throw new WidgetException("Invalid type. 'value' must be a 'String' type of desired option to select",
getLocator());
}
} catch (Exception e) {
throw new WidgetException("Error while selecting option on radio group", getLocator(),
e);
}
} } | public class class_name {
@Override
public void setValue(Object value) throws WidgetException {
try {
if (value instanceof String) {
boolean selected = false;
List<WebElement> elements = findElements();
for (WebElement we : elements) {
if (we.getAttribute("value").equals(value)) {
we.click(); // depends on control dependency: [if], data = [none]
selected = true; // depends on control dependency: [if], data = [none]
break;
}
}
if (!selected)
throw new WidgetException("Could not find desired option to select",
getLocator());
} else {
throw new WidgetException("Invalid type. 'value' must be a 'String' type of desired option to select",
getLocator());
}
} catch (Exception e) {
throw new WidgetException("Error while selecting option on radio group", getLocator(),
e);
}
} } |
public class class_name {
@Override
public List<?> getRequestValue(final Request request) {
if (isPresent(request)) {
return getNewSelections(request);
} else {
return getValue();
}
} } | public class class_name {
@Override
public List<?> getRequestValue(final Request request) {
if (isPresent(request)) {
return getNewSelections(request); // depends on control dependency: [if], data = [none]
} else {
return getValue(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public void setNodeInfoList(java.util.Collection<NodeInfo> nodeInfoList) {
if (nodeInfoList == null) {
this.nodeInfoList = null;
return;
}
this.nodeInfoList = new java.util.ArrayList<NodeInfo>(nodeInfoList);
} } | public class class_name {
public void setNodeInfoList(java.util.Collection<NodeInfo> nodeInfoList) {
if (nodeInfoList == null) {
this.nodeInfoList = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.nodeInfoList = new java.util.ArrayList<NodeInfo>(nodeInfoList);
} } |
public class class_name {
public void marshall(CheckpointConfigurationDescription checkpointConfigurationDescription, ProtocolMarshaller protocolMarshaller) {
if (checkpointConfigurationDescription == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(checkpointConfigurationDescription.getConfigurationType(), CONFIGURATIONTYPE_BINDING);
protocolMarshaller.marshall(checkpointConfigurationDescription.getCheckpointingEnabled(), CHECKPOINTINGENABLED_BINDING);
protocolMarshaller.marshall(checkpointConfigurationDescription.getCheckpointInterval(), CHECKPOINTINTERVAL_BINDING);
protocolMarshaller.marshall(checkpointConfigurationDescription.getMinPauseBetweenCheckpoints(), MINPAUSEBETWEENCHECKPOINTS_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(CheckpointConfigurationDescription checkpointConfigurationDescription, ProtocolMarshaller protocolMarshaller) {
if (checkpointConfigurationDescription == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(checkpointConfigurationDescription.getConfigurationType(), CONFIGURATIONTYPE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(checkpointConfigurationDescription.getCheckpointingEnabled(), CHECKPOINTINGENABLED_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(checkpointConfigurationDescription.getCheckpointInterval(), CHECKPOINTINTERVAL_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(checkpointConfigurationDescription.getMinPauseBetweenCheckpoints(), MINPAUSEBETWEENCHECKPOINTS_BINDING); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public static String[] getStringArray(String name){
if(getConfiguration().containsKey(name)){
return getConfiguration().getStringArray(name);
}
return null;
} } | public class class_name {
public static String[] getStringArray(String name){
if(getConfiguration().containsKey(name)){
return getConfiguration().getStringArray(name); // depends on control dependency: [if], data = [none]
}
return null;
} } |
public class class_name {
public void closeConnection() {
if (this.manualMode == false && this.dataSource != null) {
MjdbcUtils.closeQuietly(this.conn);
this.conn = null;
}
} } | public class class_name {
public void closeConnection() {
if (this.manualMode == false && this.dataSource != null) {
MjdbcUtils.closeQuietly(this.conn); // depends on control dependency: [if], data = [none]
this.conn = null; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
void updateNeededReplications(BlockInfo blockInfo,
int curReplicasDelta,
int expectedReplicasDelta) {
writeLock();
try {
NumberReplicas repl = countNodes(blockInfo);
int curExpectedReplicas = getReplication(blockInfo);
neededReplications.update(blockInfo,
repl.liveReplicas(),
repl.decommissionedReplicas(),
curExpectedReplicas,
curReplicasDelta, expectedReplicasDelta);
} finally {
writeUnlock();
}
} } | public class class_name {
void updateNeededReplications(BlockInfo blockInfo,
int curReplicasDelta,
int expectedReplicasDelta) {
writeLock();
try {
NumberReplicas repl = countNodes(blockInfo);
int curExpectedReplicas = getReplication(blockInfo);
neededReplications.update(blockInfo,
repl.liveReplicas(),
repl.decommissionedReplicas(),
curExpectedReplicas,
curReplicasDelta, expectedReplicasDelta); // depends on control dependency: [try], data = [none]
} finally {
writeUnlock();
}
} } |
public class class_name {
public static <T> Predicate<T> predicate(CheckedPredicate<T> function, Consumer<Throwable> handler) {
return t -> {
try {
return function.test(t);
}
catch (Throwable e) {
handler.accept(e);
throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
}
};
} } | public class class_name {
public static <T> Predicate<T> predicate(CheckedPredicate<T> function, Consumer<Throwable> handler) {
return t -> {
try {
return function.test(t); // depends on control dependency: [try], data = [none]
}
catch (Throwable e) {
handler.accept(e);
throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
} // depends on control dependency: [catch], data = [none]
};
} } |
public class class_name {
public void moveSourceToDest(LineNumberReader reader, PrintWriter dataOut)
{
try {
String string;
while ((string = reader.readLine()) != null)
{
if (string.indexOf("/*") != -1)
foundComment = true;
if (!foundPackage)
{
if (string.indexOf("package") == -1)
{
if (string.indexOf("/*") != -1)
continue;
if (string.indexOf("*/") != -1)
continue;
if (string.indexOf("opyright") != -1)
continue;
beforePackage = beforePackage + this.convertString(string) + lineSeparator;
continue;
}
else
{
foundPackage = true;
dataOut.write("/*" + lineSeparator);
dataOut.write(beforePackage);
dataOut.write(" * Copyright © 2013 jbundle.org. All rights reserved." + lineSeparator);
dataOut.write(" */" + lineSeparator);
}
}
string = this.convertString(string);
if (string != null)
{
dataOut.write(string + lineSeparator);
}
}
if (!foundPackage)
dataOut.write(beforePackage);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
} } | public class class_name {
public void moveSourceToDest(LineNumberReader reader, PrintWriter dataOut)
{
try {
String string;
while ((string = reader.readLine()) != null)
{
if (string.indexOf("/*") != -1)
foundComment = true;
if (!foundPackage)
{
if (string.indexOf("package") == -1)
{
if (string.indexOf("/*") != -1)
continue;
if (string.indexOf("*/") != -1)
continue;
if (string.indexOf("opyright") != -1)
continue;
beforePackage = beforePackage + this.convertString(string) + lineSeparator; // depends on control dependency: [while], data = [none]
continue;
}
else
{
foundPackage = true;
dataOut.write("/*" + lineSeparator);
dataOut.write(beforePackage);
dataOut.write(" * Copyright © 2013 jbundle.org. All rights reserved." + lineSeparator);
dataOut.write(" */" + lineSeparator);
}
}
string = this.convertString(string);
if (string != null)
{
dataOut.write(string + lineSeparator); // depends on control dependency: [if], data = [(string]
}
}
if (!foundPackage)
dataOut.write(beforePackage);
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
} } |
public class class_name {
public void unregisterEventID(String eventKey) {
properties.remove(eventKey + "_DESCRIPTION");
properties.remove(eventKey);
FileOutputStream out = null;
BufferedReader reader = null;
BufferedWriter writer = null;
try {
out = new FileOutputStream(eventPropertiesPath, true);
final File tempFile = new File(eventPropertiesPath + "temp.properties");
final BufferedReader readerFinal = new BufferedReader(new FileReader(eventPropertiesPath));
final BufferedWriter writerFinal = new BufferedWriter(new FileWriter(tempFile));
doWithLock(out.getChannel(), lock -> {
unlockedReloadFile();
if (getEventID(eventKey) != null) {
return;
}
try {
String currentLine = readerFinal.readLine();
while(currentLine != null) {
String trimmedLine = currentLine.trim();
if(trimmedLine.equals(eventKey + "_DESCRIPTION") || trimmedLine.equals(eventKey)) continue;
writerFinal.write(currentLine + System.getProperty("line.separator"));
currentLine = readerFinal.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
});
reader = readerFinal;
writer = writerFinal;
tempFile.renameTo(new File(eventPropertiesPath));
} catch (IOException e) {
error("Unable find file", e);
} finally {
try {
if (out != null) {
out.close();
}
if (writer != null) {
writer.close();
}
if (reader != null) {
reader.close();
}
} catch (IOException e) {
error("Unable to close lock", e);
}
}
} } | public class class_name {
public void unregisterEventID(String eventKey) {
properties.remove(eventKey + "_DESCRIPTION");
properties.remove(eventKey);
FileOutputStream out = null;
BufferedReader reader = null;
BufferedWriter writer = null;
try {
out = new FileOutputStream(eventPropertiesPath, true);
final File tempFile = new File(eventPropertiesPath + "temp.properties");
final BufferedReader readerFinal = new BufferedReader(new FileReader(eventPropertiesPath));
final BufferedWriter writerFinal = new BufferedWriter(new FileWriter(tempFile));
doWithLock(out.getChannel(), lock -> {
unlockedReloadFile();
if (getEventID(eventKey) != null) {
return; // depends on control dependency: [if], data = [none]
}
try {
String currentLine = readerFinal.readLine();
while(currentLine != null) {
String trimmedLine = currentLine.trim();
if(trimmedLine.equals(eventKey + "_DESCRIPTION") || trimmedLine.equals(eventKey)) continue;
writerFinal.write(currentLine + System.getProperty("line.separator"));
currentLine = readerFinal.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
}); // depends on control dependency: [while], data = [none]
reader = readerFinal; // depends on control dependency: [while], data = [none]
writer = writerFinal; // depends on control dependency: [while], data = [none]
tempFile.renameTo(new File(eventPropertiesPath)); // depends on control dependency: [while], data = [none]
} catch (IOException e) {
error("Unable find file", e);
} finally {
try {
if (out != null) {
out.close(); // depends on control dependency: [if], data = [none]
}
if (writer != null) {
writer.close(); // depends on control dependency: [if], data = [none]
}
if (reader != null) {
reader.close(); // depends on control dependency: [if], data = [none]
}
} catch (IOException e) {
error("Unable to close lock", e);
} // depends on control dependency: [catch], data = [none]
}
} } |
public class class_name {
private static MultiWorkUnit findAndPopBestFitGroup(WorkUnit workUnit, PriorityQueue<MultiWorkUnit> pQueue,
double avgGroupSize) {
List<MultiWorkUnit> fullWorkUnits = Lists.newArrayList();
MultiWorkUnit bestFit = null;
while (!pQueue.isEmpty()) {
MultiWorkUnit candidate = pQueue.poll();
if (getWorkUnitEstSize(candidate) + getWorkUnitEstSize(workUnit) <= avgGroupSize) {
bestFit = candidate;
break;
}
fullWorkUnits.add(candidate);
}
for (MultiWorkUnit fullWorkUnit : fullWorkUnits) {
pQueue.add(fullWorkUnit);
}
return bestFit;
} } | public class class_name {
private static MultiWorkUnit findAndPopBestFitGroup(WorkUnit workUnit, PriorityQueue<MultiWorkUnit> pQueue,
double avgGroupSize) {
List<MultiWorkUnit> fullWorkUnits = Lists.newArrayList();
MultiWorkUnit bestFit = null;
while (!pQueue.isEmpty()) {
MultiWorkUnit candidate = pQueue.poll();
if (getWorkUnitEstSize(candidate) + getWorkUnitEstSize(workUnit) <= avgGroupSize) {
bestFit = candidate; // depends on control dependency: [if], data = [none]
break;
}
fullWorkUnits.add(candidate); // depends on control dependency: [while], data = [none]
}
for (MultiWorkUnit fullWorkUnit : fullWorkUnits) {
pQueue.add(fullWorkUnit); // depends on control dependency: [for], data = [fullWorkUnit]
}
return bestFit;
} } |
public class class_name {
public static synchronized String getEquivalentID(String id, int index) {
String result = "";
if (index >= 0) {
UResourceBundle res = openOlsonResource(null, id);
if (res != null) {
int zoneIdx = -1;
try {
UResourceBundle links = res.get("links");
int[] zones = links.getIntVector();
if (index < zones.length) {
zoneIdx = zones[index];
}
} catch (MissingResourceException ex) {
// throw away
}
if (zoneIdx >= 0) {
String tmp = getZoneID(zoneIdx);
if (tmp != null) {
result = tmp;
}
}
}
}
return result;
} } | public class class_name {
public static synchronized String getEquivalentID(String id, int index) {
String result = "";
if (index >= 0) {
UResourceBundle res = openOlsonResource(null, id);
if (res != null) {
int zoneIdx = -1;
try {
UResourceBundle links = res.get("links");
int[] zones = links.getIntVector();
if (index < zones.length) {
zoneIdx = zones[index]; // depends on control dependency: [if], data = [none]
}
} catch (MissingResourceException ex) {
// throw away
} // depends on control dependency: [catch], data = [none]
if (zoneIdx >= 0) {
String tmp = getZoneID(zoneIdx);
if (tmp != null) {
result = tmp; // depends on control dependency: [if], data = [none]
}
}
}
}
return result;
} } |
public class class_name {
@TCB
static String stripBannedCodeunits(String s) {
int safeLimit = longestPrefixOfGoodCodeunits(s);
if (safeLimit < 0) { return s; }
StringBuilder sb = new StringBuilder(s);
stripBannedCodeunits(sb, safeLimit);
return sb.toString();
} } | public class class_name {
@TCB
static String stripBannedCodeunits(String s) {
int safeLimit = longestPrefixOfGoodCodeunits(s);
if (safeLimit < 0) { return s; } // depends on control dependency: [if], data = [none]
StringBuilder sb = new StringBuilder(s);
stripBannedCodeunits(sb, safeLimit);
return sb.toString();
} } |
public class class_name {
public synchronized void start()
{
_buffer=new ByteArrayISO8859Writer(_bufferSize);
_reopen=false;
if (_started)
return;
if (_out==null && _filename!=null)
{
try
{
RolloverFileOutputStream rfos=
new RolloverFileOutputStream(_filename,_append,_retainDays);
_out=rfos;
}
catch(IOException e){e.printStackTrace();}
}
if (_out==null)
_out=LogStream.STDERR_STREAM;
_started=true;
} } | public class class_name {
public synchronized void start()
{
_buffer=new ByteArrayISO8859Writer(_bufferSize);
_reopen=false;
if (_started)
return;
if (_out==null && _filename!=null)
{
try
{
RolloverFileOutputStream rfos=
new RolloverFileOutputStream(_filename,_append,_retainDays);
_out=rfos; // depends on control dependency: [try], data = [none]
}
catch(IOException e){e.printStackTrace();} // depends on control dependency: [catch], data = [none]
}
if (_out==null)
_out=LogStream.STDERR_STREAM;
_started=true;
} } |
public class class_name {
@UsedByApp
public void bindContacts(JsDisplayListCallback<JsContact> callback) {
if (callback == null) {
return;
}
messenger.getSharedContactList().subscribe(callback, true);
} } | public class class_name {
@UsedByApp
public void bindContacts(JsDisplayListCallback<JsContact> callback) {
if (callback == null) {
return; // depends on control dependency: [if], data = [none]
}
messenger.getSharedContactList().subscribe(callback, true);
} } |
public class class_name {
public static BufferedImage read(File imageFile) {
try {
return ImageIO.read(imageFile);
} catch (IOException e) {
throw new IORuntimeException(e);
}
} } | public class class_name {
public static BufferedImage read(File imageFile) {
try {
return ImageIO.read(imageFile);
// depends on control dependency: [try], data = [none]
} catch (IOException e) {
throw new IORuntimeException(e);
}
// depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private void addRelations(List<RelationHolder> rlHolders, Map<String, Object> values)
{
if (rlHolders != null)
{
for (RelationHolder relation : rlHolders)
{
values.put(relation.getRelationName(), relation.getRelationValue());
}
}
} } | public class class_name {
private void addRelations(List<RelationHolder> rlHolders, Map<String, Object> values)
{
if (rlHolders != null)
{
for (RelationHolder relation : rlHolders)
{
values.put(relation.getRelationName(), relation.getRelationValue()); // depends on control dependency: [for], data = [relation]
}
}
} } |
public class class_name {
public final URIBuilder encodedPath( String encodedPath )
{
if ( this.path.length() > 0 ) {
if ( this.path.charAt( this.path.length() - 1 ) != '/'
&& !encodedPath.startsWith( SEPARATOR ) ) {
// concatenating /a and b/c
this.path.append( SEPARATOR );
} else if ( this.path.charAt( this.path.length() - 1 ) == '/'
&& encodedPath.charAt( 0 ) == '/' ) {
// concatenating /a/ and /b/c
this.path.deleteCharAt( this.path.length() - 1 );
}
}
this.path.append( encodedPath );
return this;
} } | public class class_name {
public final URIBuilder encodedPath( String encodedPath )
{
if ( this.path.length() > 0 ) {
if ( this.path.charAt( this.path.length() - 1 ) != '/'
&& !encodedPath.startsWith( SEPARATOR ) ) {
// concatenating /a and b/c
this.path.append( SEPARATOR ); // depends on control dependency: [if], data = [none]
} else if ( this.path.charAt( this.path.length() - 1 ) == '/'
&& encodedPath.charAt( 0 ) == '/' ) {
// concatenating /a/ and /b/c
this.path.deleteCharAt( this.path.length() - 1 ); // depends on control dependency: [if], data = [none]
}
}
this.path.append( encodedPath );
return this;
} } |
public class class_name {
static void mergeUpdate(HashMappedList rowSet, Row row, Object[] newData,
int[] cols) {
Object[] data = (Object[]) rowSet.get(row);
if (data != null) {
for (int j = 0; j < cols.length; j++) {
data[cols[j]] = newData[cols[j]];
}
} else {
rowSet.add(row, newData);
}
} } | public class class_name {
static void mergeUpdate(HashMappedList rowSet, Row row, Object[] newData,
int[] cols) {
Object[] data = (Object[]) rowSet.get(row);
if (data != null) {
for (int j = 0; j < cols.length; j++) {
data[cols[j]] = newData[cols[j]]; // depends on control dependency: [for], data = [j]
}
} else {
rowSet.add(row, newData); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public List<CmsContainerPageElementPanel> getModelGroups() {
final List<CmsContainerPageElementPanel> result = Lists.newArrayList();
processPageContent(new I_PageContentVisitor() {
public boolean beginContainer(String name, CmsContainer container) {
return true;
}
public void endContainer() {
// do nothing
}
public void handleElement(CmsContainerPageElementPanel element) {
if (element.isModelGroup()) {
result.add(element);
}
}
});
return result;
} } | public class class_name {
public List<CmsContainerPageElementPanel> getModelGroups() {
final List<CmsContainerPageElementPanel> result = Lists.newArrayList();
processPageContent(new I_PageContentVisitor() {
public boolean beginContainer(String name, CmsContainer container) {
return true;
}
public void endContainer() {
// do nothing
}
public void handleElement(CmsContainerPageElementPanel element) {
if (element.isModelGroup()) {
result.add(element); // depends on control dependency: [if], data = [none]
}
}
});
return result;
} } |
public class class_name {
@SuppressWarnings("unchecked")
public static FieldSpec<InjectAnn<?>>[] getInjectSpecs(Class<?> cls) {
FieldSpec<InjectAnn<?>>[] specs = INJECT_SPECS.get(cls);
if (specs == null) {
ArrayList<FieldSpec<InjectAnn<?>>> list = new ArrayList<FieldSpec<InjectAnn<?>>>();
for (Field field : getFieldHierarchy(cls)) {
InjectAnn<?> ann = getInjectAnn(field);
if (ann != null) {
list.add(new FieldSpec<InjectAnn<?>>(field, ann));
}
}
specs = list.toArray(new FieldSpec[list.size()]);
INJECT_SPECS.put(cls, specs);
}
return specs;
} } | public class class_name {
@SuppressWarnings("unchecked")
public static FieldSpec<InjectAnn<?>>[] getInjectSpecs(Class<?> cls) {
FieldSpec<InjectAnn<?>>[] specs = INJECT_SPECS.get(cls);
if (specs == null) {
ArrayList<FieldSpec<InjectAnn<?>>> list = new ArrayList<FieldSpec<InjectAnn<?>>>(); // depends on control dependency: [if], data = [none]
for (Field field : getFieldHierarchy(cls)) {
InjectAnn<?> ann = getInjectAnn(field);
if (ann != null) {
list.add(new FieldSpec<InjectAnn<?>>(field, ann));
}
}
specs = list.toArray(new FieldSpec[list.size()]); // depends on control dependency: [if], data = [none]
INJECT_SPECS.put(cls, specs); // depends on control dependency: [if], data = [none]
}
return specs; // depends on control dependency: [for], data = [none]
} } |
public class class_name {
public void setImagesData(List data) {
if (data == null || data.isEmpty()) {
this.setVisibility(GONE);
return;
} else {
this.setVisibility(VISIBLE);
}
if (mMaxSize > 0 && data.size() > mMaxSize) {
data = data.subList(0, mMaxSize);
}
int[] gridParam = calculateGridParam(data.size());
mRowCount = gridParam[0];
mColumnCount = gridParam[1];
if (mImgDataList == null) {
int i = 0;
while (i < data.size()) {
ImageView iv = getImageView(i);
if (iv == null)
return;
addView(iv, generateDefaultLayoutParams());
i++;
}
} else {
int oldViewCount = mImgDataList.size();
int newViewCount = data.size();
if (oldViewCount > newViewCount) {
removeViews(newViewCount, oldViewCount - newViewCount);
} else if (oldViewCount < newViewCount) {
for (int i = oldViewCount; i < newViewCount; i++) {
ImageView iv = getImageView(i);
if (iv == null) {
return;
}
addView(iv, generateDefaultLayoutParams());
}
}
}
mImgDataList = data;
requestLayout();
} } | public class class_name {
public void setImagesData(List data) {
if (data == null || data.isEmpty()) {
this.setVisibility(GONE); // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
} else {
this.setVisibility(VISIBLE); // depends on control dependency: [if], data = [none]
}
if (mMaxSize > 0 && data.size() > mMaxSize) {
data = data.subList(0, mMaxSize); // depends on control dependency: [if], data = [none]
}
int[] gridParam = calculateGridParam(data.size());
mRowCount = gridParam[0];
mColumnCount = gridParam[1];
if (mImgDataList == null) {
int i = 0;
while (i < data.size()) {
ImageView iv = getImageView(i);
if (iv == null)
return;
addView(iv, generateDefaultLayoutParams()); // depends on control dependency: [while], data = [(i]
i++; // depends on control dependency: [while], data = [none]
}
} else {
int oldViewCount = mImgDataList.size();
int newViewCount = data.size();
if (oldViewCount > newViewCount) {
removeViews(newViewCount, oldViewCount - newViewCount); // depends on control dependency: [if], data = [newViewCount)]
} else if (oldViewCount < newViewCount) {
for (int i = oldViewCount; i < newViewCount; i++) {
ImageView iv = getImageView(i);
if (iv == null) {
return; // depends on control dependency: [if], data = [none]
}
addView(iv, generateDefaultLayoutParams()); // depends on control dependency: [for], data = [none]
}
}
}
mImgDataList = data;
requestLayout();
} } |
public class class_name {
protected void shiftDown(int shift) {
int max = getMaximumVerticalScrollPosition();
if ((m_currentValue + shift) < max) {
setVerticalScrollPosition(m_currentValue + shift);
} else {
setVerticalScrollPosition(max);
}
} } | public class class_name {
protected void shiftDown(int shift) {
int max = getMaximumVerticalScrollPosition();
if ((m_currentValue + shift) < max) {
setVerticalScrollPosition(m_currentValue + shift);
// depends on control dependency: [if], data = [none]
} else {
setVerticalScrollPosition(max);
// depends on control dependency: [if], data = [max)]
}
} } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.