code stringlengths 130 281k | code_dependency stringlengths 182 306k |
|---|---|
public class class_name {
public synchronized String getString()
{
checkReleased();
String returningString = null;
// Read the length in
short stringLength = receivedBuffer.getShort();
// Allocate the right amount of space for it
byte[] stringBytes = new byte[stringLength];
// And copy the data in
receivedBuffer.get(stringBytes);
// If the length is 1, and the byte is 0x00, then this is null - so do nothing
if (stringLength == 1 && stringBytes[0] == 0)
{
// String is null...
}
else
{
try
{
returningString = new String(stringBytes, stringEncoding);
}
catch (UnsupportedEncodingException e)
{
FFDCFilter.processException(e, CLASS_NAME + ".getString",
CommsConstants.COMMSBYTEBUFFER_GETSTRING_01,
this);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
SibTr.debug(tc, "Unable to encode String: ", e);
SibTr.exception(tc, e);
}
SibTr.error(tc, "UNSUPPORTED_STRING_ENCODING_SICO8005", new Object[] {stringEncoding, e});
throw new SIErrorException(
TraceNLS.getFormattedMessage(CommsConstants.MSG_BUNDLE, "UNSUPPORTED_STRING_ENCODING_SICO8005", new Object[] {stringEncoding, e}, null)
);
}
}
return returningString;
} } | public class class_name {
public synchronized String getString()
{
checkReleased();
String returningString = null;
// Read the length in
short stringLength = receivedBuffer.getShort();
// Allocate the right amount of space for it
byte[] stringBytes = new byte[stringLength];
// And copy the data in
receivedBuffer.get(stringBytes);
// If the length is 1, and the byte is 0x00, then this is null - so do nothing
if (stringLength == 1 && stringBytes[0] == 0)
{
// String is null...
}
else
{
try
{
returningString = new String(stringBytes, stringEncoding); // depends on control dependency: [try], data = [none]
}
catch (UnsupportedEncodingException e)
{
FFDCFilter.processException(e, CLASS_NAME + ".getString",
CommsConstants.COMMSBYTEBUFFER_GETSTRING_01,
this);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
SibTr.debug(tc, "Unable to encode String: ", e); // depends on control dependency: [if], data = [none]
SibTr.exception(tc, e); // depends on control dependency: [if], data = [none]
}
SibTr.error(tc, "UNSUPPORTED_STRING_ENCODING_SICO8005", new Object[] {stringEncoding, e});
throw new SIErrorException(
TraceNLS.getFormattedMessage(CommsConstants.MSG_BUNDLE, "UNSUPPORTED_STRING_ENCODING_SICO8005", new Object[] {stringEncoding, e}, null)
);
} // depends on control dependency: [catch], data = [none]
}
return returningString;
} } |
public class class_name {
public MapConfiguration createOsmMap(int nrOfLevels) {
MapConfiguration configuration = new MapConfigurationImpl();
Bbox bounds = new Bbox(-OSM_HALF_WIDTH, -OSM_HALF_WIDTH, 2 * OSM_HALF_WIDTH, 2 * OSM_HALF_WIDTH);
configuration.setCrs(OSM_EPSG, CrsType.METRIC);
configuration.setHintValue(MapConfiguration.INITIAL_BOUNDS, bounds);
configuration.setMaxBounds(Bbox.ALL);
List<Double> resolutions = new ArrayList<Double>();
for (int i = 0; i < nrOfLevels; i++) {
resolutions.add(OSM_HALF_WIDTH / (OSM_TILE_SIZE * Math.pow(2, i - 1)));
}
configuration.setResolutions(resolutions);
return configuration;
} } | public class class_name {
public MapConfiguration createOsmMap(int nrOfLevels) {
MapConfiguration configuration = new MapConfigurationImpl();
Bbox bounds = new Bbox(-OSM_HALF_WIDTH, -OSM_HALF_WIDTH, 2 * OSM_HALF_WIDTH, 2 * OSM_HALF_WIDTH);
configuration.setCrs(OSM_EPSG, CrsType.METRIC);
configuration.setHintValue(MapConfiguration.INITIAL_BOUNDS, bounds);
configuration.setMaxBounds(Bbox.ALL);
List<Double> resolutions = new ArrayList<Double>();
for (int i = 0; i < nrOfLevels; i++) {
resolutions.add(OSM_HALF_WIDTH / (OSM_TILE_SIZE * Math.pow(2, i - 1))); // depends on control dependency: [for], data = [i]
}
configuration.setResolutions(resolutions);
return configuration;
} } |
public class class_name {
public void marshall(DescribeConfigurationAggregatorsRequest describeConfigurationAggregatorsRequest, ProtocolMarshaller protocolMarshaller) {
if (describeConfigurationAggregatorsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(describeConfigurationAggregatorsRequest.getConfigurationAggregatorNames(), CONFIGURATIONAGGREGATORNAMES_BINDING);
protocolMarshaller.marshall(describeConfigurationAggregatorsRequest.getNextToken(), NEXTTOKEN_BINDING);
protocolMarshaller.marshall(describeConfigurationAggregatorsRequest.getLimit(), LIMIT_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(DescribeConfigurationAggregatorsRequest describeConfigurationAggregatorsRequest, ProtocolMarshaller protocolMarshaller) {
if (describeConfigurationAggregatorsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(describeConfigurationAggregatorsRequest.getConfigurationAggregatorNames(), CONFIGURATIONAGGREGATORNAMES_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(describeConfigurationAggregatorsRequest.getNextToken(), NEXTTOKEN_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(describeConfigurationAggregatorsRequest.getLimit(), LIMIT_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 Word2VecPrediction predictWord2Vec(RowData data) throws PredictException {
validateModelCategory(ModelCategory.WordEmbedding);
if (! (m instanceof WordEmbeddingModel))
throw new PredictException("Model is not of the expected type, class = " + m.getClass().getSimpleName());
final WordEmbeddingModel weModel = (WordEmbeddingModel) m;
final int vecSize = weModel.getVecSize();
HashMap<String, float[]> embeddings = new HashMap<>(data.size());
for (String wordKey : data.keySet()) {
Object value = data.get(wordKey);
if (value instanceof String) {
String word = (String) value;
embeddings.put(wordKey, weModel.transform0(word, new float[vecSize]));
}
}
Word2VecPrediction p = new Word2VecPrediction();
p.wordEmbeddings = embeddings;
return p;
} } | public class class_name {
public Word2VecPrediction predictWord2Vec(RowData data) throws PredictException {
validateModelCategory(ModelCategory.WordEmbedding);
if (! (m instanceof WordEmbeddingModel))
throw new PredictException("Model is not of the expected type, class = " + m.getClass().getSimpleName());
final WordEmbeddingModel weModel = (WordEmbeddingModel) m;
final int vecSize = weModel.getVecSize();
HashMap<String, float[]> embeddings = new HashMap<>(data.size());
for (String wordKey : data.keySet()) {
Object value = data.get(wordKey);
if (value instanceof String) {
String word = (String) value;
embeddings.put(wordKey, weModel.transform0(word, new float[vecSize])); // depends on control dependency: [if], data = [none]
}
}
Word2VecPrediction p = new Word2VecPrediction();
p.wordEmbeddings = embeddings;
return p;
} } |
public class class_name {
public TimeOfDay withChronologyRetainFields(Chronology newChronology) {
newChronology = DateTimeUtils.getChronology(newChronology);
newChronology = newChronology.withUTC();
if (newChronology == getChronology()) {
return this;
} else {
TimeOfDay newTimeOfDay = new TimeOfDay(this, newChronology);
newChronology.validate(newTimeOfDay, getValues());
return newTimeOfDay;
}
} } | public class class_name {
public TimeOfDay withChronologyRetainFields(Chronology newChronology) {
newChronology = DateTimeUtils.getChronology(newChronology);
newChronology = newChronology.withUTC();
if (newChronology == getChronology()) {
return this; // depends on control dependency: [if], data = [none]
} else {
TimeOfDay newTimeOfDay = new TimeOfDay(this, newChronology);
newChronology.validate(newTimeOfDay, getValues()); // depends on control dependency: [if], data = [none]
return newTimeOfDay; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static String[] getFormats() {
JsArrayString tempArr = nativeGetFormats();
if ((tempArr == null) || (tempArr.length() == 0)) {
return null;
}
String[] result = new String[tempArr.length()];
for (int i = 0; i < tempArr.length(); i++) {
result[i] = tempArr.get(i);
}
return result;
} } | public class class_name {
public static String[] getFormats() {
JsArrayString tempArr = nativeGetFormats();
if ((tempArr == null) || (tempArr.length() == 0)) {
return null; // depends on control dependency: [if], data = [none]
}
String[] result = new String[tempArr.length()];
for (int i = 0; i < tempArr.length(); i++) {
result[i] = tempArr.get(i); // depends on control dependency: [for], data = [i]
}
return result;
} } |
public class class_name {
private void sendAlert(byte level, byte description) {
// the connectionState cannot be cs_START
if (connectionState >= cs_CLOSED) {
return;
}
// For initial handshaking, don't send alert message to peer if
// handshaker has not started.
if (connectionState == cs_HANDSHAKE &&
(handshaker == null || !handshaker.started())) {
return;
}
EngineOutputRecord r = new EngineOutputRecord(Record.ct_alert, this);
r.setVersion(protocolVersion);
boolean useDebug = debug != null && Debug.isOn("ssl");
if (useDebug) {
synchronized (System.out) {
System.out.print(threadName());
System.out.print(", SEND " + protocolVersion + " ALERT: ");
if (level == Alerts.alert_fatal) {
System.out.print("fatal, ");
} else if (level == Alerts.alert_warning) {
System.out.print("warning, ");
} else {
System.out.print("<level = " + (0x0ff & level) + ">, ");
}
System.out.println("description = "
+ Alerts.alertDescription(description));
}
}
r.write(level);
r.write(description);
try {
writeRecord(r);
} catch (IOException e) {
if (useDebug) {
System.out.println(threadName() +
", Exception sending alert: " + e);
}
}
} } | public class class_name {
private void sendAlert(byte level, byte description) {
// the connectionState cannot be cs_START
if (connectionState >= cs_CLOSED) {
return; // depends on control dependency: [if], data = [none]
}
// For initial handshaking, don't send alert message to peer if
// handshaker has not started.
if (connectionState == cs_HANDSHAKE &&
(handshaker == null || !handshaker.started())) {
return; // depends on control dependency: [if], data = [none]
}
EngineOutputRecord r = new EngineOutputRecord(Record.ct_alert, this);
r.setVersion(protocolVersion);
boolean useDebug = debug != null && Debug.isOn("ssl");
if (useDebug) {
synchronized (System.out) { // depends on control dependency: [if], data = [none]
System.out.print(threadName());
System.out.print(", SEND " + protocolVersion + " ALERT: ");
if (level == Alerts.alert_fatal) {
System.out.print("fatal, "); // depends on control dependency: [if], data = [none]
} else if (level == Alerts.alert_warning) {
System.out.print("warning, "); // depends on control dependency: [if], data = [none]
} else {
System.out.print("<level = " + (0x0ff & level) + ">, "); // depends on control dependency: [if], data = [none]
}
System.out.println("description = "
+ Alerts.alertDescription(description));
}
}
r.write(level);
r.write(description);
try {
writeRecord(r); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
if (useDebug) {
System.out.println(threadName() +
", Exception sending alert: " + e); // depends on control dependency: [if], data = [none]
}
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public Set<Terminal> get(Construction construction) {
if (construction.isTerminal()) {
Set<Terminal> result = new LinkedHashSet<Terminal>();
result.add((Terminal) construction);
return result;
}
return firstGrammar.get(construction.getName());
} } | public class class_name {
public Set<Terminal> get(Construction construction) {
if (construction.isTerminal()) {
Set<Terminal> result = new LinkedHashSet<Terminal>();
result.add((Terminal) construction); // depends on control dependency: [if], data = [none]
return result; // depends on control dependency: [if], data = [none]
}
return firstGrammar.get(construction.getName());
} } |
public class class_name {
protected void checkBestDistance(KdTree.Node node, P target) {
double distanceSq = distance.distance((P)node.point,target);
// <= because multiple nodes could be at the bestDistanceSq
if( distanceSq <= bestDistanceSq ) {
// see if the node is already in the list. This is possible because there can be multiple trees
for( int i = 0; i < neighbors.size(); i++ ) {
KdTreeResult r = neighbors.get(i);
if( r.node.point == node.point )
return;
}
if( neighbors.size() < searchN ) {
// the list of nearest neighbors isn't full yet so it doesn't know what the distance will be
// so just keep on adding them to the list until it is full
KdTreeResult r = neighbors.grow();
r.distance = distanceSq;
r.node = node;
if( neighbors.size() == searchN ) {
// find the most distant node
bestDistanceSq = 0;
for( int i = 0; i < searchN; i++ ) {
r = neighbors.get(i);
if( r.distance > bestDistanceSq ) {
bestDistanceSq = r.distance;
}
}
}
} else {
// find the most distant neighbor and write over it since we known this node must be closer
// and update the maximum distance
for( int i = 0; i < searchN; i++ ) {
KdTreeResult r = neighbors.get(i);
if( r.distance == bestDistanceSq ) {
r.node = node;
r.distance = distanceSq;
break;
}
}
// If there are multiple points then there can be more than one point with the value of
// 'bestDistanceSq', which is why two searches are required
bestDistanceSq = 0;
for( int i = 0; i < searchN; i++ ) {
KdTreeResult r = neighbors.get(i);
if( r.distance > bestDistanceSq ) {
bestDistanceSq = r.distance;
}
}
}
}
} } | public class class_name {
protected void checkBestDistance(KdTree.Node node, P target) {
double distanceSq = distance.distance((P)node.point,target);
// <= because multiple nodes could be at the bestDistanceSq
if( distanceSq <= bestDistanceSq ) {
// see if the node is already in the list. This is possible because there can be multiple trees
for( int i = 0; i < neighbors.size(); i++ ) {
KdTreeResult r = neighbors.get(i);
if( r.node.point == node.point )
return;
}
if( neighbors.size() < searchN ) {
// the list of nearest neighbors isn't full yet so it doesn't know what the distance will be
// so just keep on adding them to the list until it is full
KdTreeResult r = neighbors.grow();
r.distance = distanceSq; // depends on control dependency: [if], data = [none]
r.node = node; // depends on control dependency: [if], data = [none]
if( neighbors.size() == searchN ) {
// find the most distant node
bestDistanceSq = 0; // depends on control dependency: [if], data = [none]
for( int i = 0; i < searchN; i++ ) {
r = neighbors.get(i); // depends on control dependency: [for], data = [i]
if( r.distance > bestDistanceSq ) {
bestDistanceSq = r.distance; // depends on control dependency: [if], data = [none]
}
}
}
} else {
// find the most distant neighbor and write over it since we known this node must be closer
// and update the maximum distance
for( int i = 0; i < searchN; i++ ) {
KdTreeResult r = neighbors.get(i);
if( r.distance == bestDistanceSq ) {
r.node = node; // depends on control dependency: [if], data = [none]
r.distance = distanceSq; // depends on control dependency: [if], data = [none]
break;
}
}
// If there are multiple points then there can be more than one point with the value of
// 'bestDistanceSq', which is why two searches are required
bestDistanceSq = 0; // depends on control dependency: [if], data = [none]
for( int i = 0; i < searchN; i++ ) {
KdTreeResult r = neighbors.get(i);
if( r.distance > bestDistanceSq ) {
bestDistanceSq = r.distance; // depends on control dependency: [if], data = [none]
}
}
}
}
} } |
public class class_name {
public static void deleteChildrenNotInCollection(Resource resource, ConfigurationCollectionPersistData data) {
Set<String> collectionItemNames = data.getItems().stream()
.map(item -> item.getCollectionItemName())
.collect(Collectors.toSet());
for (Resource child : resource.getChildren()) {
if (!collectionItemNames.contains(child.getName()) && !StringUtils.equals(JCR_CONTENT, child.getName())) {
deletePageOrResource(child);
}
}
} } | public class class_name {
public static void deleteChildrenNotInCollection(Resource resource, ConfigurationCollectionPersistData data) {
Set<String> collectionItemNames = data.getItems().stream()
.map(item -> item.getCollectionItemName())
.collect(Collectors.toSet());
for (Resource child : resource.getChildren()) {
if (!collectionItemNames.contains(child.getName()) && !StringUtils.equals(JCR_CONTENT, child.getName())) {
deletePageOrResource(child); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public BitCounterUncompressed makeNested(DataDescriptor subKey, int n, int row, int replicationCountSize) {
if (subCounters == null)
subCounters = new HashMap<DataDescriptor, BitCounterUncompressed[]>(5); // assumes DataDescriptor.equals is ==
BitCounterUncompressed[] subCounter = subCounters.get(subKey);
if (subCounter == null) {
subCounter = new BitCounterUncompressed[nrows]; // one for each row in this table
subCounters.put(subKey, subCounter);
}
BitCounterUncompressed rc = new BitCounterUncompressed(subKey, n, replicationCountSize);
subCounter[row] = rc;
return rc;
} } | public class class_name {
public BitCounterUncompressed makeNested(DataDescriptor subKey, int n, int row, int replicationCountSize) {
if (subCounters == null)
subCounters = new HashMap<DataDescriptor, BitCounterUncompressed[]>(5); // assumes DataDescriptor.equals is ==
BitCounterUncompressed[] subCounter = subCounters.get(subKey);
if (subCounter == null) {
subCounter = new BitCounterUncompressed[nrows]; // one for each row in this table
// depends on control dependency: [if], data = [none]
subCounters.put(subKey, subCounter);
// depends on control dependency: [if], data = [none]
}
BitCounterUncompressed rc = new BitCounterUncompressed(subKey, n, replicationCountSize);
subCounter[row] = rc;
return rc;
} } |
public class class_name {
public P getPresenter() {
if (presenterFactory != null) {
if (presenter == null && bundle != null)
presenter = PresenterStorage.INSTANCE.getPresenter(bundle.getString(PRESENTER_ID_KEY));
if (presenter == null) {
presenter = presenterFactory.createPresenter();
PresenterStorage.INSTANCE.add(presenter);
presenter.create(bundle == null ? null : bundle.getBundle(PRESENTER_KEY));
}
bundle = null;
}
return presenter;
} } | public class class_name {
public P getPresenter() {
if (presenterFactory != null) {
if (presenter == null && bundle != null)
presenter = PresenterStorage.INSTANCE.getPresenter(bundle.getString(PRESENTER_ID_KEY));
if (presenter == null) {
presenter = presenterFactory.createPresenter(); // depends on control dependency: [if], data = [none]
PresenterStorage.INSTANCE.add(presenter); // depends on control dependency: [if], data = [(presenter]
presenter.create(bundle == null ? null : bundle.getBundle(PRESENTER_KEY)); // depends on control dependency: [if], data = [none]
}
bundle = null; // depends on control dependency: [if], data = [none]
}
return presenter;
} } |
public class class_name {
public RepositoryDTO getOrFindUserRepository(String user, String repositoryName, GitRepoClient repoClient) {
RepositoryDTO repository = getUserRepository(user, repositoryName);
if (repository == null) {
List<RepositoryDTO> repositoryDTOs = repoClient.listRepositories();
updateUserRepositories(repositoryDTOs);
repository = getUserRepository(user, repositoryName);
}
return repository;
} } | public class class_name {
public RepositoryDTO getOrFindUserRepository(String user, String repositoryName, GitRepoClient repoClient) {
RepositoryDTO repository = getUserRepository(user, repositoryName);
if (repository == null) {
List<RepositoryDTO> repositoryDTOs = repoClient.listRepositories();
updateUserRepositories(repositoryDTOs); // depends on control dependency: [if], data = [(repository]
repository = getUserRepository(user, repositoryName); // depends on control dependency: [if], data = [none]
}
return repository;
} } |
public class class_name {
public DescribeServersResult withServers(Server... servers) {
if (this.servers == null) {
setServers(new java.util.ArrayList<Server>(servers.length));
}
for (Server ele : servers) {
this.servers.add(ele);
}
return this;
} } | public class class_name {
public DescribeServersResult withServers(Server... servers) {
if (this.servers == null) {
setServers(new java.util.ArrayList<Server>(servers.length)); // depends on control dependency: [if], data = [none]
}
for (Server ele : servers) {
this.servers.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public void printXMLElement(String name, String[][] attributes)
{
Element element = new DefaultElement(name);
if (attributes != null && attributes.length > 0) {
for (String[] entry : attributes) {
element.addAttribute(entry[0], entry[1]);
}
}
try {
this.xmlWriter.write(element);
} catch (IOException e) {
// TODO: add error log here
}
} } | public class class_name {
public void printXMLElement(String name, String[][] attributes)
{
Element element = new DefaultElement(name);
if (attributes != null && attributes.length > 0) {
for (String[] entry : attributes) {
element.addAttribute(entry[0], entry[1]); // depends on control dependency: [for], data = [entry]
}
}
try {
this.xmlWriter.write(element); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
// TODO: add error log here
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public void removeLayer(Layer layer) {
if (layers.contains(layer)) {
layers.remove(layer);
mapInfo.getLayers().remove(layer.getLayerInfo());
handlerManager.fireEvent(new MapModelChangedEvent(this));
}
} } | public class class_name {
public void removeLayer(Layer layer) {
if (layers.contains(layer)) {
layers.remove(layer); // depends on control dependency: [if], data = [none]
mapInfo.getLayers().remove(layer.getLayerInfo()); // depends on control dependency: [if], data = [none]
handlerManager.fireEvent(new MapModelChangedEvent(this)); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private JBBPTokenizerException checkFieldName(final String name, final int position) {
if (name != null) {
final String normalized = JBBPUtils.normalizeFieldNameOrPath(name);
if (normalized.indexOf('.') >= 0) {
return new JBBPTokenizerException("Field name must not contain '.' char", position);
}
if (normalized.length() > 0) {
if (normalized.equals("_")
|| normalized.equals("$$")
|| normalized.startsWith("$")
|| Character.isDigit(normalized.charAt(0))
) {
return new JBBPTokenizerException("'" + name + "' can't be field name", position);
}
for (int i = 1; i < normalized.length(); i++) {
final char chr = normalized.charAt(i);
if (chr != '_' && !Character.isLetterOrDigit(chr)) {
return new JBBPTokenizerException("Char '" + chr + "' not allowed in name", position);
}
}
}
}
return null;
} } | public class class_name {
private JBBPTokenizerException checkFieldName(final String name, final int position) {
if (name != null) {
final String normalized = JBBPUtils.normalizeFieldNameOrPath(name);
if (normalized.indexOf('.') >= 0) {
return new JBBPTokenizerException("Field name must not contain '.' char", position); // depends on control dependency: [if], data = [none]
}
if (normalized.length() > 0) {
if (normalized.equals("_")
|| normalized.equals("$$")
|| normalized.startsWith("$")
|| Character.isDigit(normalized.charAt(0))
) {
return new JBBPTokenizerException("'" + name + "' can't be field name", position);
}
for (int i = 1; i < normalized.length(); i++) {
final char chr = normalized.charAt(i);
if (chr != '_' && !Character.isLetterOrDigit(chr)) {
return new JBBPTokenizerException("Char '" + chr + "' not allowed in name", position);
} // depends on control dependency: [if], data = []
}
}
}
return null;
} } |
public class class_name {
public BrokerInstance withEndpoints(String... endpoints) {
if (this.endpoints == null) {
setEndpoints(new java.util.ArrayList<String>(endpoints.length));
}
for (String ele : endpoints) {
this.endpoints.add(ele);
}
return this;
} } | public class class_name {
public BrokerInstance withEndpoints(String... endpoints) {
if (this.endpoints == null) {
setEndpoints(new java.util.ArrayList<String>(endpoints.length)); // depends on control dependency: [if], data = [none]
}
for (String ele : endpoints) {
this.endpoints.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public static final int getDateTimeIndex(String entity)
{
if ( entity == null ) {
return -1;
}
int sIdx = entity.indexOf('.');
if ( sIdx == -1 ) {
return DATETIME_NONE;
}
String attr = entity.substring(sIdx+1);
if ( attr.length() < 1 ) {
return DATETIME_NONE;
}
if ( attr.startsWith("y") ) return DATETIME_Y;
if ( attr.startsWith("m") ) return DATETIME_M;
if ( attr.startsWith("d") ) return DATETIME_D;
if ( attr.startsWith("a") ) return DATETIME_A;
if ( attr.startsWith("h") ) return DATETIME_H;
if ( attr.startsWith("i") ) return DATETIME_I;
if ( attr.startsWith("s") ) return DATETIME_S;
return DATETIME_NONE;
} } | public class class_name {
public static final int getDateTimeIndex(String entity)
{
if ( entity == null ) {
return -1; // depends on control dependency: [if], data = [none]
}
int sIdx = entity.indexOf('.');
if ( sIdx == -1 ) {
return DATETIME_NONE; // depends on control dependency: [if], data = [none]
}
String attr = entity.substring(sIdx+1);
if ( attr.length() < 1 ) {
return DATETIME_NONE; // depends on control dependency: [if], data = [none]
}
if ( attr.startsWith("y") ) return DATETIME_Y;
if ( attr.startsWith("m") ) return DATETIME_M;
if ( attr.startsWith("d") ) return DATETIME_D;
if ( attr.startsWith("a") ) return DATETIME_A;
if ( attr.startsWith("h") ) return DATETIME_H;
if ( attr.startsWith("i") ) return DATETIME_I;
if ( attr.startsWith("s") ) return DATETIME_S;
return DATETIME_NONE;
} } |
public class class_name {
@Override
public Authentication attemptAuthentication(HttpServletRequest request,
HttpServletResponse response) throws AuthenticationException, IOException {
OpenIDAuthenticationToken token;
String identity = request.getParameter("openid.identity");
if (!StringUtils.hasText(identity)) {
String claimedIdentity = obtainUsername(request);
try {
String returnToUrl = buildReturnToUrl(request);
String realm = lookupRealm(returnToUrl);
String openIdUrl = consumer.beginConsumption(request, claimedIdentity,
returnToUrl, realm);
if (logger.isDebugEnabled()) {
logger.debug("return_to is '" + returnToUrl + "', realm is '" + realm
+ "'");
logger.debug("Redirecting to " + openIdUrl);
}
response.sendRedirect(openIdUrl);
// Indicate to parent class that authentication is continuing.
return null;
}
catch (OpenIDConsumerException e) {
logger.debug("Failed to consume claimedIdentity: " + claimedIdentity, e);
throw new AuthenticationServiceException(
"Unable to process claimed identity '" + claimedIdentity + "'");
}
}
if (logger.isDebugEnabled()) {
logger.debug("Supplied OpenID identity is " + identity);
}
try {
token = consumer.endConsumption(request);
}
catch (OpenIDConsumerException oice) {
throw new AuthenticationServiceException("Consumer error", oice);
}
token.setDetails(authenticationDetailsSource.buildDetails(request));
// delegate to the authentication provider
Authentication authentication = this.getAuthenticationManager().authenticate(
token);
return authentication;
} } | public class class_name {
@Override
public Authentication attemptAuthentication(HttpServletRequest request,
HttpServletResponse response) throws AuthenticationException, IOException {
OpenIDAuthenticationToken token;
String identity = request.getParameter("openid.identity");
if (!StringUtils.hasText(identity)) {
String claimedIdentity = obtainUsername(request);
try {
String returnToUrl = buildReturnToUrl(request);
String realm = lookupRealm(returnToUrl);
String openIdUrl = consumer.beginConsumption(request, claimedIdentity,
returnToUrl, realm);
if (logger.isDebugEnabled()) {
logger.debug("return_to is '" + returnToUrl + "', realm is '" + realm
+ "'"); // depends on control dependency: [if], data = [none]
logger.debug("Redirecting to " + openIdUrl); // depends on control dependency: [if], data = [none]
}
response.sendRedirect(openIdUrl); // depends on control dependency: [try], data = [none]
// Indicate to parent class that authentication is continuing.
return null; // depends on control dependency: [try], data = [none]
}
catch (OpenIDConsumerException e) {
logger.debug("Failed to consume claimedIdentity: " + claimedIdentity, e);
throw new AuthenticationServiceException(
"Unable to process claimed identity '" + claimedIdentity + "'");
} // depends on control dependency: [catch], data = [none]
}
if (logger.isDebugEnabled()) {
logger.debug("Supplied OpenID identity is " + identity);
}
try {
token = consumer.endConsumption(request);
}
catch (OpenIDConsumerException oice) {
throw new AuthenticationServiceException("Consumer error", oice);
}
token.setDetails(authenticationDetailsSource.buildDetails(request));
// delegate to the authentication provider
Authentication authentication = this.getAuthenticationManager().authenticate(
token);
return authentication;
} } |
public class class_name {
public void marshall(NoiseReducerSpatialFilterSettings noiseReducerSpatialFilterSettings, ProtocolMarshaller protocolMarshaller) {
if (noiseReducerSpatialFilterSettings == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(noiseReducerSpatialFilterSettings.getPostFilterSharpenStrength(), POSTFILTERSHARPENSTRENGTH_BINDING);
protocolMarshaller.marshall(noiseReducerSpatialFilterSettings.getSpeed(), SPEED_BINDING);
protocolMarshaller.marshall(noiseReducerSpatialFilterSettings.getStrength(), STRENGTH_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(NoiseReducerSpatialFilterSettings noiseReducerSpatialFilterSettings, ProtocolMarshaller protocolMarshaller) {
if (noiseReducerSpatialFilterSettings == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(noiseReducerSpatialFilterSettings.getPostFilterSharpenStrength(), POSTFILTERSHARPENSTRENGTH_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(noiseReducerSpatialFilterSettings.getSpeed(), SPEED_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(noiseReducerSpatialFilterSettings.getStrength(), STRENGTH_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 {
protected String getColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean translate)
{
String result = null;
// no translation required, use attribute name
if (!translate)
{
return aPathInfo.column;
}
// BRJ: special alias for the indirection table has no ClassDescriptor
if (aTableAlias.cld == null && M_N_ALIAS.equals(aTableAlias.alias))
{
return getIndirectionTableColName(aTableAlias, aPathInfo.path);
}
// translate attribute name into column name
FieldDescriptor fld = getFieldDescriptor(aTableAlias, aPathInfo);
if (fld != null)
{
m_attrToFld.put(aPathInfo.path, fld);
// added to suport the super reference descriptor
if (!fld.getClassDescriptor().getFullTableName().equals(aTableAlias.table) && aTableAlias.hasJoins())
{
Iterator itr = aTableAlias.joins.iterator();
while (itr.hasNext())
{
Join join = (Join) itr.next();
if (join.right.table.equals(fld.getClassDescriptor().getFullTableName()))
{
result = join.right.alias + "." + fld.getColumnName();
break;
}
}
if (result == null)
{
result = aPathInfo.column;
}
}
else
{
result = aTableAlias.alias + "." + fld.getColumnName();
}
}
else if ("*".equals(aPathInfo.column))
{
result = aPathInfo.column;
}
else
{
// throw new IllegalArgumentException("No Field found for : " + aPathInfo.column);
result = aPathInfo.column;
}
return result;
} } | public class class_name {
protected String getColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean translate)
{
String result = null;
// no translation required, use attribute name
if (!translate)
{
return aPathInfo.column;
// depends on control dependency: [if], data = [none]
}
// BRJ: special alias for the indirection table has no ClassDescriptor
if (aTableAlias.cld == null && M_N_ALIAS.equals(aTableAlias.alias))
{
return getIndirectionTableColName(aTableAlias, aPathInfo.path);
// depends on control dependency: [if], data = [none]
}
// translate attribute name into column name
FieldDescriptor fld = getFieldDescriptor(aTableAlias, aPathInfo);
if (fld != null)
{
m_attrToFld.put(aPathInfo.path, fld);
// depends on control dependency: [if], data = [none]
// added to suport the super reference descriptor
if (!fld.getClassDescriptor().getFullTableName().equals(aTableAlias.table) && aTableAlias.hasJoins())
{
Iterator itr = aTableAlias.joins.iterator();
while (itr.hasNext())
{
Join join = (Join) itr.next();
if (join.right.table.equals(fld.getClassDescriptor().getFullTableName()))
{
result = join.right.alias + "." + fld.getColumnName();
// depends on control dependency: [if], data = [none]
break;
}
}
if (result == null)
{
result = aPathInfo.column;
// depends on control dependency: [if], data = [none]
}
}
else
{
result = aTableAlias.alias + "." + fld.getColumnName();
// depends on control dependency: [if], data = [none]
}
}
else if ("*".equals(aPathInfo.column))
{
result = aPathInfo.column;
// depends on control dependency: [if], data = [none]
}
else
{
// throw new IllegalArgumentException("No Field found for : " + aPathInfo.column);
result = aPathInfo.column;
// depends on control dependency: [if], data = [none]
}
return result;
} } |
public class class_name {
public String[] getMetaInfo(JavaRDD<String> fileRDD, String fieldSeparator) {
String[] headers = null;
int sampleSize = 5;
// sanity check
if (sampleSize < 1) {
mLog.info("DATATYPE_SAMPLE_SIZE must be bigger than 1");
return null;
}
List<String> sampleStr = fileRDD.take(sampleSize);
sampleSize = sampleStr.size(); // actual sample size
mLog.info("Sample size: " + sampleSize);
// create sample list for getting data type
String[] firstSplit = sampleStr.get(0).split(fieldSeparator);
// get header
boolean hasHeader = false;
if (hasHeader) {
headers = firstSplit;
} else {
headers = new String[firstSplit.length];
int size = headers.length;
for (int i = 0; i < size; ) {
headers[i] = "V" + (++i);
}
}
String[][] samples = hasHeader ? (new String[firstSplit.length][sampleSize - 1])
: (new String[firstSplit.length][sampleSize]);
String[] metaInfoArray = new String[firstSplit.length];
int start = hasHeader ? 1 : 0;
for (int j = start; j < sampleSize; j++) {
firstSplit = sampleStr.get(j).split(fieldSeparator);
for (int i = 0; i < firstSplit.length; i++) {
samples[i][j - start] = firstSplit[i];
}
}
boolean doPreferDouble = true;
for (int i = 0; i < samples.length; i++) {
String[] vector = samples[i];
metaInfoArray[i] = headers[i] + " " + determineType(vector, doPreferDouble);
}
return metaInfoArray;
} } | public class class_name {
public String[] getMetaInfo(JavaRDD<String> fileRDD, String fieldSeparator) {
String[] headers = null;
int sampleSize = 5;
// sanity check
if (sampleSize < 1) {
mLog.info("DATATYPE_SAMPLE_SIZE must be bigger than 1"); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
List<String> sampleStr = fileRDD.take(sampleSize);
sampleSize = sampleStr.size(); // actual sample size
mLog.info("Sample size: " + sampleSize);
// create sample list for getting data type
String[] firstSplit = sampleStr.get(0).split(fieldSeparator);
// get header
boolean hasHeader = false;
if (hasHeader) {
headers = firstSplit; // depends on control dependency: [if], data = [none]
} else {
headers = new String[firstSplit.length]; // depends on control dependency: [if], data = [none]
int size = headers.length;
for (int i = 0; i < size; ) {
headers[i] = "V" + (++i); // depends on control dependency: [for], data = [i]
}
}
String[][] samples = hasHeader ? (new String[firstSplit.length][sampleSize - 1])
: (new String[firstSplit.length][sampleSize]);
String[] metaInfoArray = new String[firstSplit.length];
int start = hasHeader ? 1 : 0;
for (int j = start; j < sampleSize; j++) {
firstSplit = sampleStr.get(j).split(fieldSeparator); // depends on control dependency: [for], data = [j]
for (int i = 0; i < firstSplit.length; i++) {
samples[i][j - start] = firstSplit[i]; // depends on control dependency: [for], data = [i]
}
}
boolean doPreferDouble = true;
for (int i = 0; i < samples.length; i++) {
String[] vector = samples[i];
metaInfoArray[i] = headers[i] + " " + determineType(vector, doPreferDouble); // depends on control dependency: [for], data = [i]
}
return metaInfoArray;
} } |
public class class_name {
protected String getDiscoveryResponseURL(String entityBaseURL, String entityAlias) {
if (extendedMetadata != null && extendedMetadata.getIdpDiscoveryResponseURL() != null
&& extendedMetadata.getIdpDiscoveryResponseURL().length() > 0) {
return extendedMetadata.getIdpDiscoveryResponseURL();
} else {
Map<String, String> params = new HashMap<String, String>();
params.put(SAMLEntryPoint.DISCOVERY_RESPONSE_PARAMETER, "true");
return getServerURL(entityBaseURL, entityAlias, getSAMLEntryPointPath(), params);
}
} } | public class class_name {
protected String getDiscoveryResponseURL(String entityBaseURL, String entityAlias) {
if (extendedMetadata != null && extendedMetadata.getIdpDiscoveryResponseURL() != null
&& extendedMetadata.getIdpDiscoveryResponseURL().length() > 0) {
return extendedMetadata.getIdpDiscoveryResponseURL(); // depends on control dependency: [if], data = [none]
} else {
Map<String, String> params = new HashMap<String, String>();
params.put(SAMLEntryPoint.DISCOVERY_RESPONSE_PARAMETER, "true"); // depends on control dependency: [if], data = [none]
return getServerURL(entityBaseURL, entityAlias, getSAMLEntryPointPath(), params); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static double[] minus(final double[] v1, final double[] v2) {
assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
final double[] sub = new double[v1.length];
for(int i = 0; i < v1.length; i++) {
sub[i] = v1[i] - v2[i];
}
return sub;
} } | public class class_name {
public static double[] minus(final double[] v1, final double[] v2) {
assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
final double[] sub = new double[v1.length];
for(int i = 0; i < v1.length; i++) {
sub[i] = v1[i] - v2[i]; // depends on control dependency: [for], data = [i]
}
return sub;
} } |
public class class_name {
public static String binaryToHex(byte[] data, int offset, int length)
{
assert offset < data.length && offset >= 0 : offset + ", " + data.length;
int end = offset + length;
assert end <= data.length && end >= 0 : offset + ", " + length + ", " + data.length;
char[] chars = new char[length*2];
int j = 0;
for (int i = offset; i < end; i++) {
int b = data[i];
chars[j++] = hexDigit(b >>> 4 & 0xF);
chars[j++] = hexDigit(b & 0xF);
}
return new String(chars);
} } | public class class_name {
public static String binaryToHex(byte[] data, int offset, int length)
{
assert offset < data.length && offset >= 0 : offset + ", " + data.length;
int end = offset + length;
assert end <= data.length && end >= 0 : offset + ", " + length + ", " + data.length;
char[] chars = new char[length*2];
int j = 0;
for (int i = offset; i < end; i++) {
int b = data[i];
chars[j++] = hexDigit(b >>> 4 & 0xF); // depends on control dependency: [for], data = [none]
chars[j++] = hexDigit(b & 0xF); // depends on control dependency: [for], data = [none]
}
return new String(chars);
} } |
public class class_name {
private Collection<ImageListEditor<ColumnType>.Entry> getAcceptableEntries(final ColumnType type) {
final Collection<ImageListEditor<ColumnType>.Entry> result = new ArrayList<ImageListEditor<org.dashbuilder.dataset.ColumnType>.Entry>();
if (type != null) {
if (ColumnType.DATE.equals(type)) {
result.add(buildEntry(ColumnType.DATE));
} else if (ColumnType.LABEL.equals(type)) {
result.add(buildEntry(ColumnType.LABEL));
result.add(buildEntry(ColumnType.TEXT));
} else if (ColumnType.TEXT.equals(type)) {
result.add(buildEntry(ColumnType.LABEL));
result.add(buildEntry(ColumnType.TEXT));
} else if (ColumnType.NUMBER.equals(type)) {
result.add(buildEntry(ColumnType.LABEL));
result.add(buildEntry(ColumnType.NUMBER));
}
}
return result;
} } | public class class_name {
private Collection<ImageListEditor<ColumnType>.Entry> getAcceptableEntries(final ColumnType type) {
final Collection<ImageListEditor<ColumnType>.Entry> result = new ArrayList<ImageListEditor<org.dashbuilder.dataset.ColumnType>.Entry>();
if (type != null) {
if (ColumnType.DATE.equals(type)) {
result.add(buildEntry(ColumnType.DATE)); // depends on control dependency: [if], data = [none]
} else if (ColumnType.LABEL.equals(type)) {
result.add(buildEntry(ColumnType.LABEL)); // depends on control dependency: [if], data = [none]
result.add(buildEntry(ColumnType.TEXT)); // depends on control dependency: [if], data = [none]
} else if (ColumnType.TEXT.equals(type)) {
result.add(buildEntry(ColumnType.LABEL)); // depends on control dependency: [if], data = [none]
result.add(buildEntry(ColumnType.TEXT)); // depends on control dependency: [if], data = [none]
} else if (ColumnType.NUMBER.equals(type)) {
result.add(buildEntry(ColumnType.LABEL)); // depends on control dependency: [if], data = [none]
result.add(buildEntry(ColumnType.NUMBER)); // depends on control dependency: [if], data = [none]
}
}
return result;
} } |
public class class_name {
public void addMemberTags(ExecutableElement member, Content methodsContentTree) {
Content tagContent = new ContentBuilder();
TagletManager tagletManager =
configuration.tagletManager;
TagletWriter.genTagOutput(tagletManager, member,
tagletManager.getSerializedFormTaglets(),
writer.getTagletWriterInstance(false), tagContent);
Content dlTags = new HtmlTree(HtmlTag.DL);
dlTags.addContent(tagContent);
methodsContentTree.addContent(dlTags);
if (name(member).compareTo("writeExternal") == 0
&& utils.getSerialDataTrees(member).isEmpty()) {
serialWarning(member, "doclet.MissingSerialDataTag",
utils.getFullyQualifiedName(member.getEnclosingElement()), name(member));
}
} } | public class class_name {
public void addMemberTags(ExecutableElement member, Content methodsContentTree) {
Content tagContent = new ContentBuilder();
TagletManager tagletManager =
configuration.tagletManager;
TagletWriter.genTagOutput(tagletManager, member,
tagletManager.getSerializedFormTaglets(),
writer.getTagletWriterInstance(false), tagContent);
Content dlTags = new HtmlTree(HtmlTag.DL);
dlTags.addContent(tagContent);
methodsContentTree.addContent(dlTags);
if (name(member).compareTo("writeExternal") == 0
&& utils.getSerialDataTrees(member).isEmpty()) {
serialWarning(member, "doclet.MissingSerialDataTag",
utils.getFullyQualifiedName(member.getEnclosingElement()), name(member)); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static ExpiryDate fromAbsolute(long expiryDate) {
long creationTime = System.currentTimeMillis();
long relativeTtl;
try {
relativeTtl = Math.subtractExact(expiryDate, creationTime);
} catch (ArithmeticException exception) {
relativeTtl = Long.MIN_VALUE;
}
return new ExpiryDate(relativeTtl, expiryDate, creationTime);
} } | public class class_name {
public static ExpiryDate fromAbsolute(long expiryDate) {
long creationTime = System.currentTimeMillis();
long relativeTtl;
try {
relativeTtl = Math.subtractExact(expiryDate, creationTime); // depends on control dependency: [try], data = [none]
} catch (ArithmeticException exception) {
relativeTtl = Long.MIN_VALUE;
} // depends on control dependency: [catch], data = [none]
return new ExpiryDate(relativeTtl, expiryDate, creationTime);
} } |
public class class_name {
@Override
public Money[] divideAndRemainder(double divisor) {
if (NumberVerifier.isInfinityAndNotNaN(divisor)) {
Money zero = Money.of(0, getCurrency());
return new Money[]{zero, zero};
}
return divideAndRemainder(new BigDecimal(String.valueOf(divisor)));
} } | public class class_name {
@Override
public Money[] divideAndRemainder(double divisor) {
if (NumberVerifier.isInfinityAndNotNaN(divisor)) {
Money zero = Money.of(0, getCurrency());
return new Money[]{zero, zero}; // depends on control dependency: [if], data = [none]
}
return divideAndRemainder(new BigDecimal(String.valueOf(divisor)));
} } |
public class class_name {
@Override
public IValueNode getValueNode(String language) {
if (language == null) {
return null;
}
return valueNodeMap.get(language);
} } | public class class_name {
@Override
public IValueNode getValueNode(String language) {
if (language == null) {
return null; // depends on control dependency: [if], data = [none]
}
return valueNodeMap.get(language);
} } |
public class class_name {
public void removeSpace(String spaceId) {
// Will throw if bucket does not exist
String bucketName = getBucketName(spaceId);
try {
s3Client.deleteBucket(bucketName);
} catch (AmazonClientException e) {
String err = "Could not delete S3 bucket with name " + bucketName
+ " due to error: " + e.getMessage();
throw new StorageException(err, e, RETRY);
}
} } | public class class_name {
public void removeSpace(String spaceId) {
// Will throw if bucket does not exist
String bucketName = getBucketName(spaceId);
try {
s3Client.deleteBucket(bucketName); // depends on control dependency: [try], data = [none]
} catch (AmazonClientException e) {
String err = "Could not delete S3 bucket with name " + bucketName
+ " due to error: " + e.getMessage();
throw new StorageException(err, e, RETRY);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private Integer getNumberOfDocuments(List<File> inputFiles) throws ResourceInitializationException{
String directory = (String) getConfigParameterValue(PARAM_INPUTDIR);
String filename = directory+"/"+FILE_BASE_SEGMENTATION;
for (File file : inputFiles) {
if (file.getAbsolutePath().equals(filename)){
try {
String line;
BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
while ((line = bf.readLine()) != null){
String docName = (line.split("\t"))[0];
if (!(filenames.contains(docName))){
filenames.add(docName);
}
}
bf.close();
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
}
}
int docCounter = filenames.size();
return docCounter;
} } | public class class_name {
private Integer getNumberOfDocuments(List<File> inputFiles) throws ResourceInitializationException{
String directory = (String) getConfigParameterValue(PARAM_INPUTDIR);
String filename = directory+"/"+FILE_BASE_SEGMENTATION;
for (File file : inputFiles) {
if (file.getAbsolutePath().equals(filename)){
try {
String line;
BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
while ((line = bf.readLine()) != null){
String docName = (line.split("\t"))[0];
if (!(filenames.contains(docName))){
filenames.add(docName); // depends on control dependency: [if], data = [none]
}
}
bf.close(); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
throw new ResourceInitializationException(e);
} // depends on control dependency: [catch], data = [none]
}
}
int docCounter = filenames.size();
return docCounter;
} } |
public class class_name {
public static boolean hasInjectAnnotation(Element element) {
for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
String annotationQualifiedName = annotationMirror.getAnnotationType().toString();
if (annotationQualifiedName.equals(Inject.class.getCanonicalName())) {
return true;
}
if (annotationQualifiedName.equals("com.google.inject.Inject")) {
return true;
}
}
return false;
} } | public class class_name {
public static boolean hasInjectAnnotation(Element element) {
for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
String annotationQualifiedName = annotationMirror.getAnnotationType().toString();
if (annotationQualifiedName.equals(Inject.class.getCanonicalName())) {
return true; // depends on control dependency: [if], data = [none]
}
if (annotationQualifiedName.equals("com.google.inject.Inject")) {
return true;
}
}
return false;
} } |
public class class_name {
public List<MockResponse> enqueue(String... paths) {
if (paths == null) {
return null;
}
List<MockResponse> mockResponseList = new ArrayList<>();
for (String path : paths) {
Fixture fixture = Fixture.parseFrom(path, parser);
MockResponse mockResponse = fixture.toMockResponse();
mockWebServer.enqueue(mockResponse);
mockResponseList.add(mockResponse);
}
return mockResponseList;
} } | public class class_name {
public List<MockResponse> enqueue(String... paths) {
if (paths == null) {
return null; // depends on control dependency: [if], data = [none]
}
List<MockResponse> mockResponseList = new ArrayList<>();
for (String path : paths) {
Fixture fixture = Fixture.parseFrom(path, parser);
MockResponse mockResponse = fixture.toMockResponse();
mockWebServer.enqueue(mockResponse); // depends on control dependency: [for], data = [none]
mockResponseList.add(mockResponse); // depends on control dependency: [for], data = [none]
}
return mockResponseList;
} } |
public class class_name {
Lexeme removeTail(){
Lexeme tail = this.pollLast();
if(this.isEmpty()){
this.pathBegin = -1;
this.pathEnd = -1;
this.payloadLength = 0;
}else{
this.payloadLength -= tail.getLength();
Lexeme newTail = this.peekLast();
this.pathEnd = newTail.getBegin() + newTail.getLength();
}
return tail;
} } | public class class_name {
Lexeme removeTail(){
Lexeme tail = this.pollLast();
if(this.isEmpty()){
this.pathBegin = -1;
// depends on control dependency: [if], data = [none]
this.pathEnd = -1;
// depends on control dependency: [if], data = [none]
this.payloadLength = 0;
// depends on control dependency: [if], data = [none]
}else{
this.payloadLength -= tail.getLength();
// depends on control dependency: [if], data = [none]
Lexeme newTail = this.peekLast();
this.pathEnd = newTail.getBegin() + newTail.getLength();
// depends on control dependency: [if], data = [none]
}
return tail;
} } |
public class class_name {
public static double weightedCoefficient(NumberVector x, NumberVector y, double[] weights) {
final int xdim = x.getDimensionality();
final int ydim = y.getDimensionality();
if(xdim != ydim) {
throw new IllegalArgumentException("Invalid arguments: number vectors differ in dimensionality.");
}
if(xdim != weights.length) {
throw new IllegalArgumentException("Dimensionality doesn't agree to weights.");
}
if(xdim == 0) {
throw new IllegalArgumentException("Empty vector.");
}
// Inlined computation of Pearson correlation, to avoid allocating objects!
// This is a numerically stabilized version, avoiding sum-of-squares.
double sumXX = 0., sumYY = 0., sumXY = 0., sumWe = weights[0];
double sumX = x.doubleValue(0) * sumWe, sumY = y.doubleValue(0) * sumWe;
for(int i = 1; i < xdim; ++i) {
final double xv = x.doubleValue(i), yv = y.doubleValue(i), w = weights[i];
// Delta to previous mean
final double deltaX = xv * sumWe - sumX;
final double deltaY = yv * sumWe - sumY;
// Increment count first
final double oldWe = sumWe; // Convert to double!
sumWe += w;
final double f = w / (sumWe * oldWe);
// Update
sumXX += f * deltaX * deltaX;
sumYY += f * deltaY * deltaY;
// should equal deltaY * neltaX!
sumXY += f * deltaX * deltaY;
// Update sums
sumX += xv * w;
sumY += yv * w;
}
// One or both series were constant:
if(!(sumXX > 0. && sumYY > 0.)) {
return (sumXX == sumYY) ? 1. : 0.;
}
return sumXY / FastMath.sqrt(sumXX * sumYY);
} } | public class class_name {
public static double weightedCoefficient(NumberVector x, NumberVector y, double[] weights) {
final int xdim = x.getDimensionality();
final int ydim = y.getDimensionality();
if(xdim != ydim) {
throw new IllegalArgumentException("Invalid arguments: number vectors differ in dimensionality.");
}
if(xdim != weights.length) {
throw new IllegalArgumentException("Dimensionality doesn't agree to weights.");
}
if(xdim == 0) {
throw new IllegalArgumentException("Empty vector.");
}
// Inlined computation of Pearson correlation, to avoid allocating objects!
// This is a numerically stabilized version, avoiding sum-of-squares.
double sumXX = 0., sumYY = 0., sumXY = 0., sumWe = weights[0];
double sumX = x.doubleValue(0) * sumWe, sumY = y.doubleValue(0) * sumWe;
for(int i = 1; i < xdim; ++i) {
final double xv = x.doubleValue(i), yv = y.doubleValue(i), w = weights[i];
// Delta to previous mean
final double deltaX = xv * sumWe - sumX;
final double deltaY = yv * sumWe - sumY;
// Increment count first
final double oldWe = sumWe; // Convert to double!
sumWe += w; // depends on control dependency: [for], data = [none]
final double f = w / (sumWe * oldWe);
// Update
sumXX += f * deltaX * deltaX; // depends on control dependency: [for], data = [none]
sumYY += f * deltaY * deltaY; // depends on control dependency: [for], data = [none]
// should equal deltaY * neltaX!
sumXY += f * deltaX * deltaY; // depends on control dependency: [for], data = [none]
// Update sums
sumX += xv * w; // depends on control dependency: [for], data = [none]
sumY += yv * w; // depends on control dependency: [for], data = [none]
}
// One or both series were constant:
if(!(sumXX > 0. && sumYY > 0.)) {
return (sumXX == sumYY) ? 1. : 0.; // depends on control dependency: [if], data = [none]
}
return sumXY / FastMath.sqrt(sumXX * sumYY);
} } |
public class class_name {
@Override
public boolean validate(final Problems problems, final String compName, final String model) {
final ParsePosition p = new ParsePosition(0);
try {
NumberFormat.getNumberInstance(this.locale == null ? Locale.getDefault() : this.locale).parse(model, p);
if (model.length() != p.getIndex() || p.getErrorIndex() != -1) {
problems.add(ValidationBundle.getMessage(IsANumberValidator.class, "NOT_A_NUMBER", model, compName)); // NOI18N
return false;
}
} catch (final NumberFormatException nfe) {
problems.add(ValidationBundle.getMessage(IsANumberValidator.class, "NOT_A_NUMBER", model, compName)); // NOI18N
return false;
}
return true;
} } | public class class_name {
@Override
public boolean validate(final Problems problems, final String compName, final String model) {
final ParsePosition p = new ParsePosition(0);
try {
NumberFormat.getNumberInstance(this.locale == null ? Locale.getDefault() : this.locale).parse(model, p); // depends on control dependency: [try], data = [none]
if (model.length() != p.getIndex() || p.getErrorIndex() != -1) {
problems.add(ValidationBundle.getMessage(IsANumberValidator.class, "NOT_A_NUMBER", model, compName)); // NOI18N // depends on control dependency: [if], data = [none]
return false; // depends on control dependency: [if], data = [none]
}
} catch (final NumberFormatException nfe) {
problems.add(ValidationBundle.getMessage(IsANumberValidator.class, "NOT_A_NUMBER", model, compName)); // NOI18N
return false;
} // depends on control dependency: [catch], data = [none]
return true;
} } |
public class class_name {
void computeCellHistograms() {
int width = cellCols* pixelsPerCell;
int height = cellRows* pixelsPerCell;
float angleBinSize = GrlConstants.F_PI/orientationBins;
int indexCell = 0;
for (int i = 0; i < height; i += pixelsPerCell) {
for (int j = 0; j < width; j += pixelsPerCell, indexCell++ ) {
Cell c = cells[indexCell];
c.reset();
for (int k = 0; k < pixelsPerCell; k++) {
int indexPixel = (i+k)*derivX.width+j;
for (int l = 0; l < pixelsPerCell; l++, indexPixel++ ) {
float pixelDX = this.derivX.data[indexPixel];
float pixelDY = this.derivY.data[indexPixel];
// angle from 0 to pi radians
float angle = UtilAngle.atanSafe(pixelDY,pixelDX) + GrlConstants.F_PId2;
// gradient magnitude
float magnitude = (float)Math.sqrt(pixelDX*pixelDX + pixelDY*pixelDY);
// Add the weighted gradient using bilinear interpolation
float findex0 = angle/angleBinSize;
int index0 = (int)findex0;
float weight1 = findex0-index0;
index0 %= orientationBins;
int index1 = (index0+1)%orientationBins;
c.histogram[index0] += magnitude*(1.0f-weight1);
c.histogram[index1] += magnitude*weight1;
}
}
}
}
} } | public class class_name {
void computeCellHistograms() {
int width = cellCols* pixelsPerCell;
int height = cellRows* pixelsPerCell;
float angleBinSize = GrlConstants.F_PI/orientationBins;
int indexCell = 0;
for (int i = 0; i < height; i += pixelsPerCell) {
for (int j = 0; j < width; j += pixelsPerCell, indexCell++ ) {
Cell c = cells[indexCell];
c.reset(); // depends on control dependency: [for], data = [none]
for (int k = 0; k < pixelsPerCell; k++) {
int indexPixel = (i+k)*derivX.width+j;
for (int l = 0; l < pixelsPerCell; l++, indexPixel++ ) {
float pixelDX = this.derivX.data[indexPixel];
float pixelDY = this.derivY.data[indexPixel];
// angle from 0 to pi radians
float angle = UtilAngle.atanSafe(pixelDY,pixelDX) + GrlConstants.F_PId2;
// gradient magnitude
float magnitude = (float)Math.sqrt(pixelDX*pixelDX + pixelDY*pixelDY);
// Add the weighted gradient using bilinear interpolation
float findex0 = angle/angleBinSize;
int index0 = (int)findex0;
float weight1 = findex0-index0;
index0 %= orientationBins; // depends on control dependency: [for], data = [none]
int index1 = (index0+1)%orientationBins;
c.histogram[index0] += magnitude*(1.0f-weight1); // depends on control dependency: [for], data = [none]
c.histogram[index1] += magnitude*weight1; // depends on control dependency: [for], data = [none]
}
}
}
}
} } |
public class class_name {
@Requires({
"isValidPattern(pattern)",
"rule != null"
})
@Ensures({
"rule.equals(get(pattern))",
"!isOverriden(pattern)"
})
public void put(String pattern, R rule) {
String canon = pattern.replace('/', '.');
boolean exact = !canon.endsWith(".*");
if (!exact) {
canon = canon.substring(0, canon.length() - 2);
}
String[] parts = canon.split("\\.");
TernaryNode current = root;
TernaryNode parent = root;
int parentIndex = -1;
for (int i = 0; i < parts.length; ++i) {
TernaryNode next = current.children.get(parts[i]);
if (next == null) {
next = new TernaryNode(null, false);
current.children.put(parts[i], next);
}
if (next.rule != null && !next.exact) {
parent = next;
parentIndex = i;
}
current = next;
}
if (!exact) {
/* Override patterns beginning with this one. */
current.children.clear();
}
if (!rule.equals(parent.rule)) {
current.rule = rule;
current.exact = exact;
} else {
/*
* The new rule we are inserting is already specified through
* inheritance. Remove spurious nodes. This ensures that any
* overriding branch is meaningful; that is, it specifies a rule
* value different from the inherited one.
*/
current = parent;
for (int i = parentIndex + 1; i < parts.length; ++i) {
TernaryNode next = current.children.get(parts[i]);
if (next.rule == null) {
current.children.remove(parts[i]);
break;
}
}
}
} } | public class class_name {
@Requires({
"isValidPattern(pattern)",
"rule != null"
})
@Ensures({
"rule.equals(get(pattern))",
"!isOverriden(pattern)"
})
public void put(String pattern, R rule) {
String canon = pattern.replace('/', '.');
boolean exact = !canon.endsWith(".*");
if (!exact) {
canon = canon.substring(0, canon.length() - 2); // depends on control dependency: [if], data = [none]
}
String[] parts = canon.split("\\.");
TernaryNode current = root;
TernaryNode parent = root;
int parentIndex = -1;
for (int i = 0; i < parts.length; ++i) {
TernaryNode next = current.children.get(parts[i]);
if (next == null) {
next = new TernaryNode(null, false); // depends on control dependency: [if], data = [none]
current.children.put(parts[i], next); // depends on control dependency: [if], data = [none]
}
if (next.rule != null && !next.exact) {
parent = next; // depends on control dependency: [if], data = [none]
parentIndex = i; // depends on control dependency: [if], data = [none]
}
current = next; // depends on control dependency: [for], data = [none]
}
if (!exact) {
/* Override patterns beginning with this one. */
current.children.clear(); // depends on control dependency: [if], data = [none]
}
if (!rule.equals(parent.rule)) {
current.rule = rule; // depends on control dependency: [if], data = [none]
current.exact = exact; // depends on control dependency: [if], data = [none]
} else {
/*
* The new rule we are inserting is already specified through
* inheritance. Remove spurious nodes. This ensures that any
* overriding branch is meaningful; that is, it specifies a rule
* value different from the inherited one.
*/
current = parent; // depends on control dependency: [if], data = [none]
for (int i = parentIndex + 1; i < parts.length; ++i) {
TernaryNode next = current.children.get(parts[i]);
if (next.rule == null) {
current.children.remove(parts[i]); // depends on control dependency: [if], data = [none]
break;
}
}
}
} } |
public class class_name {
public int readInt(int offset, byte[] data)
{
int result = 0;
int i = offset + m_offset;
for (int shiftBy = 0; shiftBy < 32; shiftBy += 8)
{
result |= ((data[i] & 0xff)) << shiftBy;
++i;
}
return result;
} } | public class class_name {
public int readInt(int offset, byte[] data)
{
int result = 0;
int i = offset + m_offset;
for (int shiftBy = 0; shiftBy < 32; shiftBy += 8)
{
result |= ((data[i] & 0xff)) << shiftBy; // depends on control dependency: [for], data = [shiftBy]
++i; // depends on control dependency: [for], data = [none]
}
return result;
} } |
public class class_name {
public DescribeLifecycleHookTypesResult withLifecycleHookTypes(String... lifecycleHookTypes) {
if (this.lifecycleHookTypes == null) {
setLifecycleHookTypes(new com.amazonaws.internal.SdkInternalList<String>(lifecycleHookTypes.length));
}
for (String ele : lifecycleHookTypes) {
this.lifecycleHookTypes.add(ele);
}
return this;
} } | public class class_name {
public DescribeLifecycleHookTypesResult withLifecycleHookTypes(String... lifecycleHookTypes) {
if (this.lifecycleHookTypes == null) {
setLifecycleHookTypes(new com.amazonaws.internal.SdkInternalList<String>(lifecycleHookTypes.length)); // depends on control dependency: [if], data = [none]
}
for (String ele : lifecycleHookTypes) {
this.lifecycleHookTypes.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public void nodeAppRemoved(String nodeName, ResourceType type) {
Set<String> sessions = nodeManager.getNodeSessions(nodeName);
Set<ClusterNode.GrantId> grantsToRevoke =
nodeManager.deleteAppFromNode(nodeName, type);
if (grantsToRevoke == null) {
return;
}
Set<String> affectedSessions = new HashSet<String>();
for (String sessionHandle : sessions) {
try {
if (sessionManager.getSession(sessionHandle).
getTypes().contains(type)) {
affectedSessions.add(sessionHandle);
}
} catch (InvalidSessionHandle ex) {
// ignore
LOG.warn("Found invalid session: " + sessionHandle
+ " while timing out node: " + nodeName);
}
}
handleDeadNode(nodeName, affectedSessions);
handleRevokedGrants(nodeName, grantsToRevoke);
scheduler.notifyScheduler();
} } | public class class_name {
public void nodeAppRemoved(String nodeName, ResourceType type) {
Set<String> sessions = nodeManager.getNodeSessions(nodeName);
Set<ClusterNode.GrantId> grantsToRevoke =
nodeManager.deleteAppFromNode(nodeName, type);
if (grantsToRevoke == null) {
return; // depends on control dependency: [if], data = [none]
}
Set<String> affectedSessions = new HashSet<String>();
for (String sessionHandle : sessions) {
try {
if (sessionManager.getSession(sessionHandle).
getTypes().contains(type)) {
affectedSessions.add(sessionHandle); // depends on control dependency: [if], data = [none]
}
} catch (InvalidSessionHandle ex) {
// ignore
LOG.warn("Found invalid session: " + sessionHandle
+ " while timing out node: " + nodeName);
} // depends on control dependency: [catch], data = [none]
}
handleDeadNode(nodeName, affectedSessions);
handleRevokedGrants(nodeName, grantsToRevoke);
scheduler.notifyScheduler();
} } |
public class class_name {
public ModuleInfoList filter(final ModuleInfoFilter filter) {
final ModuleInfoList moduleInfoFiltered = new ModuleInfoList();
for (final ModuleInfo resource : this) {
if (filter.accept(resource)) {
moduleInfoFiltered.add(resource);
}
}
return moduleInfoFiltered;
} } | public class class_name {
public ModuleInfoList filter(final ModuleInfoFilter filter) {
final ModuleInfoList moduleInfoFiltered = new ModuleInfoList();
for (final ModuleInfo resource : this) {
if (filter.accept(resource)) {
moduleInfoFiltered.add(resource); // depends on control dependency: [if], data = [none]
}
}
return moduleInfoFiltered;
} } |
public class class_name {
public void setAddToPath(boolean isAddToPath) {
if(started) {
throw new IllegalStateException("Cannot set a record route on an already started proxy");
}
if(this.pathURI == null) {
this.pathURI = new SipURIImpl (JainSipUtils.createRecordRouteURI( proxy.getSipFactoryImpl().getSipNetworkInterfaceManager(), null), ModifiableRule.NotModifiable);
}
this.isAddToPath = isAddToPath;
} } | public class class_name {
public void setAddToPath(boolean isAddToPath) {
if(started) {
throw new IllegalStateException("Cannot set a record route on an already started proxy");
}
if(this.pathURI == null) {
this.pathURI = new SipURIImpl (JainSipUtils.createRecordRouteURI( proxy.getSipFactoryImpl().getSipNetworkInterfaceManager(), null), ModifiableRule.NotModifiable); // depends on control dependency: [if], data = [null)]
}
this.isAddToPath = isAddToPath;
} } |
public class class_name {
protected void fireObjectAction (
ObjectActionHandler handler, SceneObject scobj, ActionEvent event)
{
if (handler == null) {
Controller.postAction(event);
} else {
handler.handleAction(scobj, event);
}
} } | public class class_name {
protected void fireObjectAction (
ObjectActionHandler handler, SceneObject scobj, ActionEvent event)
{
if (handler == null) {
Controller.postAction(event); // depends on control dependency: [if], data = [none]
} else {
handler.handleAction(scobj, event); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
@Override
public int indexOf(final Object object) {
if (object instanceof Integer) {
int value = (Integer) object;
if (value >= startIndex && value <= endIndex) {
return value - startIndex;
}
}
return -1;
} } | public class class_name {
@Override
public int indexOf(final Object object) {
if (object instanceof Integer) {
int value = (Integer) object;
if (value >= startIndex && value <= endIndex) {
return value - startIndex; // depends on control dependency: [if], data = [none]
}
}
return -1;
} } |
public class class_name {
public void addAnonymousFunctions() {
TreeSet<SymbolScope> scopes = new TreeSet<>(lexicalScopeOrdering);
for (SymbolScope scope : getAllScopes()) {
if (scope.isLexicalScope()) {
scopes.add(scope);
}
}
for (SymbolScope scope : scopes) {
addAnonymousFunctionsInScope(scope);
}
} } | public class class_name {
public void addAnonymousFunctions() {
TreeSet<SymbolScope> scopes = new TreeSet<>(lexicalScopeOrdering);
for (SymbolScope scope : getAllScopes()) {
if (scope.isLexicalScope()) {
scopes.add(scope); // depends on control dependency: [if], data = [none]
}
}
for (SymbolScope scope : scopes) {
addAnonymousFunctionsInScope(scope); // depends on control dependency: [for], data = [scope]
}
} } |
public class class_name {
@Deprecated
public static String decode(String string)
{
try {
byte[] bytes = Base64.decode(string.toCharArray());
return new String(bytes, DEFAULT_ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
} } | public class class_name {
@Deprecated
public static String decode(String string)
{
try {
byte[] bytes = Base64.decode(string.toCharArray());
return new String(bytes, DEFAULT_ENCODING); // depends on control dependency: [try], data = [none]
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
private String formatVersion(String version) {
if (version == null) {
return version;
}
String[] split = version.split(GERRIT_VERSION_PREFIX);
if (split.length < 2) {
return version.trim();
}
return split[1].trim();
} } | public class class_name {
private String formatVersion(String version) {
if (version == null) {
return version; // depends on control dependency: [if], data = [none]
}
String[] split = version.split(GERRIT_VERSION_PREFIX);
if (split.length < 2) {
return version.trim(); // depends on control dependency: [if], data = [none]
}
return split[1].trim();
} } |
public class class_name {
public void sendTriState(String codeWord) {
if (transmitterPin != null) {
for (int nRepeat = 0; nRepeat < repeatTransmit; nRepeat++) {
for (int i = 0; i < codeWord.length(); ++i) {
switch (codeWord.charAt(i)) {
case '0':
this.sendT0();
break;
case 'F':
this.sendTF();
break;
case '1':
this.sendT1();
break;
}
}
this.sendSync();
}
transmitterPin.low();
}
} } | public class class_name {
public void sendTriState(String codeWord) {
if (transmitterPin != null) {
for (int nRepeat = 0; nRepeat < repeatTransmit; nRepeat++) {
for (int i = 0; i < codeWord.length(); ++i) {
switch (codeWord.charAt(i)) { // depends on control dependency: [for], data = [i]
case '0':
this.sendT0();
break;
case 'F':
this.sendTF();
break;
case '1':
this.sendT1();
break;
}
}
this.sendSync(); // depends on control dependency: [for], data = [none]
}
transmitterPin.low(); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
@Override
public DurationFormatterFactory setPeriodBuilder(PeriodBuilder builder) {
if (builder != this.builder) {
this.builder = builder;
reset();
}
return this;
} } | public class class_name {
@Override
public DurationFormatterFactory setPeriodBuilder(PeriodBuilder builder) {
if (builder != this.builder) {
this.builder = builder; // depends on control dependency: [if], data = [none]
reset(); // depends on control dependency: [if], data = [none]
}
return this;
} } |
public class class_name {
public void undeployed() {
classLoader = null;
if (classLoaderDomain != null) {
classLoaderDomain.clear();
classLoaderDomain = null;
}
if (classPool != null) {
classPool.clean();
classPool = null;
}
if (permissions != null) {
permissions.clear();
permissions = null;
}
} } | public class class_name {
public void undeployed() {
classLoader = null;
if (classLoaderDomain != null) {
classLoaderDomain.clear(); // depends on control dependency: [if], data = [none]
classLoaderDomain = null; // depends on control dependency: [if], data = [none]
}
if (classPool != null) {
classPool.clean(); // depends on control dependency: [if], data = [none]
classPool = null; // depends on control dependency: [if], data = [none]
}
if (permissions != null) {
permissions.clear(); // depends on control dependency: [if], data = [none]
permissions = null; // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
private void initOldAdditionalResources() {
SortedMap<String, String> parameters = new TreeMap<String, String>(m_parameters);
List<String> resources = new ArrayList<String>(m_resources);
String additionalResources;
additionalResources = parameters.get(MODULE_PROPERTY_ADDITIONAL_RESOURCES);
if (additionalResources != null) {
StringTokenizer tok = new StringTokenizer(
additionalResources,
MODULE_PROPERTY_ADDITIONAL_RESOURCES_SEPARATOR);
while (tok.hasMoreTokens()) {
String resource = tok.nextToken().trim();
if ((!"-".equals(resource)) && (!resources.contains(resource))) {
resources.add(resource);
}
}
}
m_resources = resources;
} } | public class class_name {
private void initOldAdditionalResources() {
SortedMap<String, String> parameters = new TreeMap<String, String>(m_parameters);
List<String> resources = new ArrayList<String>(m_resources);
String additionalResources;
additionalResources = parameters.get(MODULE_PROPERTY_ADDITIONAL_RESOURCES);
if (additionalResources != null) {
StringTokenizer tok = new StringTokenizer(
additionalResources,
MODULE_PROPERTY_ADDITIONAL_RESOURCES_SEPARATOR);
while (tok.hasMoreTokens()) {
String resource = tok.nextToken().trim();
if ((!"-".equals(resource)) && (!resources.contains(resource))) {
resources.add(resource); // depends on control dependency: [if], data = [none]
}
}
}
m_resources = resources;
} } |
public class class_name {
public boolean runOptimize() {
boolean hasChanged = false;
for (BitmapDataProvider lowBitmap : highToBitmap.values()) {
if (lowBitmap instanceof RoaringBitmap) {
hasChanged |= ((RoaringBitmap) lowBitmap).runOptimize();
} else if (lowBitmap instanceof MutableRoaringBitmap) {
hasChanged |= ((MutableRoaringBitmap) lowBitmap).runOptimize();
}
}
return hasChanged;
} } | public class class_name {
public boolean runOptimize() {
boolean hasChanged = false;
for (BitmapDataProvider lowBitmap : highToBitmap.values()) {
if (lowBitmap instanceof RoaringBitmap) {
hasChanged |= ((RoaringBitmap) lowBitmap).runOptimize(); // depends on control dependency: [if], data = [none]
} else if (lowBitmap instanceof MutableRoaringBitmap) {
hasChanged |= ((MutableRoaringBitmap) lowBitmap).runOptimize(); // depends on control dependency: [if], data = [none]
}
}
return hasChanged;
} } |
public class class_name {
public boolean isAllBroadcastTables(final Collection<String> logicTableNames) {
if (logicTableNames.isEmpty()) {
return false;
}
for (String each : logicTableNames) {
if (!isBroadcastTable(each)) {
return false;
}
}
return true;
} } | public class class_name {
public boolean isAllBroadcastTables(final Collection<String> logicTableNames) {
if (logicTableNames.isEmpty()) {
return false; // depends on control dependency: [if], data = [none]
}
for (String each : logicTableNames) {
if (!isBroadcastTable(each)) {
return false; // depends on control dependency: [if], data = [none]
}
}
return true;
} } |
public class class_name {
public static base_responses update(nitro_service client, snmpmanager resources[]) throws Exception {
base_responses result = null;
if (resources != null && resources.length > 0) {
snmpmanager updateresources[] = new snmpmanager[resources.length];
for (int i=0;i<resources.length;i++){
updateresources[i] = new snmpmanager();
updateresources[i].ipaddress = resources[i].ipaddress;
updateresources[i].netmask = resources[i].netmask;
updateresources[i].domainresolveretry = resources[i].domainresolveretry;
}
result = update_bulk_request(client, updateresources);
}
return result;
} } | public class class_name {
public static base_responses update(nitro_service client, snmpmanager resources[]) throws Exception {
base_responses result = null;
if (resources != null && resources.length > 0) {
snmpmanager updateresources[] = new snmpmanager[resources.length];
for (int i=0;i<resources.length;i++){
updateresources[i] = new snmpmanager(); // depends on control dependency: [for], data = [i]
updateresources[i].ipaddress = resources[i].ipaddress; // depends on control dependency: [for], data = [i]
updateresources[i].netmask = resources[i].netmask; // depends on control dependency: [for], data = [i]
updateresources[i].domainresolveretry = resources[i].domainresolveretry; // depends on control dependency: [for], data = [i]
}
result = update_bulk_request(client, updateresources);
}
return result;
} } |
public class class_name {
public static String getPreTime(String sj1, String jj) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String mydate1 = "";
try {
Date date1 = format.parse(sj1);
long Time = (date1.getTime() / 1000) + Integer.parseInt(jj) * 60;
date1.setTime(Time * 1000);
mydate1 = format.format(date1);
} catch (Exception e) {
}
return mydate1;
} } | public class class_name {
public static String getPreTime(String sj1, String jj) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String mydate1 = "";
try {
Date date1 = format.parse(sj1);
long Time = (date1.getTime() / 1000) + Integer.parseInt(jj) * 60;
date1.setTime(Time * 1000); // depends on control dependency: [try], data = [none]
mydate1 = format.format(date1); // depends on control dependency: [try], data = [none]
} catch (Exception e) {
} // depends on control dependency: [catch], data = [none]
return mydate1;
} } |
public class class_name {
public static String roleHierarchyFromMap(Map<String, List<String>> roleHierarchyMap) {
Assert.notEmpty(roleHierarchyMap, "roleHierarchyMap cannot be empty");
StringWriter roleHierarchyBuffer = new StringWriter();
PrintWriter roleHierarchyWriter = new PrintWriter(roleHierarchyBuffer);
for (Map.Entry<String, List<String>> roleHierarchyEntry : roleHierarchyMap.entrySet()) {
String role = roleHierarchyEntry.getKey();
List<String> impliedRoles = roleHierarchyEntry.getValue();
Assert.hasLength(role, "role name must be supplied");
Assert.notEmpty(impliedRoles, "implied role name(s) cannot be empty");
for (String impliedRole : impliedRoles) {
String roleMapping = role + " > " + impliedRole;
roleHierarchyWriter.println(roleMapping);
}
}
return roleHierarchyBuffer.toString();
} } | public class class_name {
public static String roleHierarchyFromMap(Map<String, List<String>> roleHierarchyMap) {
Assert.notEmpty(roleHierarchyMap, "roleHierarchyMap cannot be empty");
StringWriter roleHierarchyBuffer = new StringWriter();
PrintWriter roleHierarchyWriter = new PrintWriter(roleHierarchyBuffer);
for (Map.Entry<String, List<String>> roleHierarchyEntry : roleHierarchyMap.entrySet()) {
String role = roleHierarchyEntry.getKey();
List<String> impliedRoles = roleHierarchyEntry.getValue();
Assert.hasLength(role, "role name must be supplied"); // depends on control dependency: [for], data = [none]
Assert.notEmpty(impliedRoles, "implied role name(s) cannot be empty"); // depends on control dependency: [for], data = [none]
for (String impliedRole : impliedRoles) {
String roleMapping = role + " > " + impliedRole;
roleHierarchyWriter.println(roleMapping); // depends on control dependency: [for], data = [none]
}
}
return roleHierarchyBuffer.toString();
} } |
public class class_name {
public int getKerning(char first, char second) {
Map toMap = (Map) ansiKerning.get(new Integer(first));
if (toMap == null) {
return 0;
}
Integer kerning = (Integer) toMap.get(new Integer(second));
if (kerning == null) {
return 0;
}
return Math.round(convertUnitToEm(size, kerning.intValue()));
} } | public class class_name {
public int getKerning(char first, char second) {
Map toMap = (Map) ansiKerning.get(new Integer(first));
if (toMap == null) {
return 0;
// depends on control dependency: [if], data = [none]
}
Integer kerning = (Integer) toMap.get(new Integer(second));
if (kerning == null) {
return 0;
// depends on control dependency: [if], data = [none]
}
return Math.round(convertUnitToEm(size, kerning.intValue()));
} } |
public class class_name {
public void marshall(Route route, ProtocolMarshaller protocolMarshaller) {
if (route == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(route.getApiKeyRequired(), APIKEYREQUIRED_BINDING);
protocolMarshaller.marshall(route.getAuthorizationScopes(), AUTHORIZATIONSCOPES_BINDING);
protocolMarshaller.marshall(route.getAuthorizationType(), AUTHORIZATIONTYPE_BINDING);
protocolMarshaller.marshall(route.getAuthorizerId(), AUTHORIZERID_BINDING);
protocolMarshaller.marshall(route.getModelSelectionExpression(), MODELSELECTIONEXPRESSION_BINDING);
protocolMarshaller.marshall(route.getOperationName(), OPERATIONNAME_BINDING);
protocolMarshaller.marshall(route.getRequestModels(), REQUESTMODELS_BINDING);
protocolMarshaller.marshall(route.getRequestParameters(), REQUESTPARAMETERS_BINDING);
protocolMarshaller.marshall(route.getRouteId(), ROUTEID_BINDING);
protocolMarshaller.marshall(route.getRouteKey(), ROUTEKEY_BINDING);
protocolMarshaller.marshall(route.getRouteResponseSelectionExpression(), ROUTERESPONSESELECTIONEXPRESSION_BINDING);
protocolMarshaller.marshall(route.getTarget(), TARGET_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(Route route, ProtocolMarshaller protocolMarshaller) {
if (route == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(route.getApiKeyRequired(), APIKEYREQUIRED_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getAuthorizationScopes(), AUTHORIZATIONSCOPES_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getAuthorizationType(), AUTHORIZATIONTYPE_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getAuthorizerId(), AUTHORIZERID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getModelSelectionExpression(), MODELSELECTIONEXPRESSION_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getOperationName(), OPERATIONNAME_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getRequestModels(), REQUESTMODELS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getRequestParameters(), REQUESTPARAMETERS_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getRouteId(), ROUTEID_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getRouteKey(), ROUTEKEY_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getRouteResponseSelectionExpression(), ROUTERESPONSESELECTIONEXPRESSION_BINDING); // depends on control dependency: [try], data = [none]
protocolMarshaller.marshall(route.getTarget(), TARGET_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 boolean isValid(String name) {
char[] nameChars = name.toCharArray();
for (int i = 0; i < nameChars.length; i++) {
boolean valid = i == 0 ? Character.isJavaIdentifierStart(nameChars[i]) : Character.isJavaIdentifierPart(nameChars[i]);
if (!valid) {
return valid;
}
}
return true;
} } | public class class_name {
public static boolean isValid(String name) {
char[] nameChars = name.toCharArray();
for (int i = 0; i < nameChars.length; i++) {
boolean valid = i == 0 ? Character.isJavaIdentifierStart(nameChars[i]) : Character.isJavaIdentifierPart(nameChars[i]);
if (!valid) {
return valid; // depends on control dependency: [if], data = [none]
}
}
return true;
} } |
public class class_name {
public static int ordinalIndexOf(String str, String searchStr, int ordinal) {
if (str == null || searchStr == null || ordinal <= 0) {
return INDEX_NOT_FOUND;
}
if (searchStr.length() == 0) {
return 0;
}
int found = 0;
int index = INDEX_NOT_FOUND;
do {
index = str.indexOf(searchStr, index + 1);
if (index < 0) {
return index;
}
found++;
} while (found < ordinal);
return index;
} } | public class class_name {
public static int ordinalIndexOf(String str, String searchStr, int ordinal) {
if (str == null || searchStr == null || ordinal <= 0) {
return INDEX_NOT_FOUND; // depends on control dependency: [if], data = [none]
}
if (searchStr.length() == 0) {
return 0; // depends on control dependency: [if], data = [none]
}
int found = 0;
int index = INDEX_NOT_FOUND;
do {
index = str.indexOf(searchStr, index + 1);
if (index < 0) {
return index; // depends on control dependency: [if], data = [none]
}
found++;
} while (found < ordinal);
return index;
} } |
public class class_name {
public void errorOccurred(SIConnectionLostException exception,
int segmentType,
int requestNumber,
int priority,
Conversation conversation)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "errorOccurred");
// First job is to FFDC
FFDCFilter.processException(exception, CLASS_NAME + ".errorOccurred",
CommsConstants.SERVERTRANSPORTRECEIVELISTENER_ERROR_01, this);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
Object[] debug = { "Segment type : " + segmentType + " (0x" + Integer.toHexString(segmentType) + ")", "Request number: " + requestNumber, "Priority : " + priority};
SibTr.debug(tc, "Received an error in the ProxyReceiveListener", debug);
SibTr.debug(tc, "Primary exception:");
SibTr.exception(tc, exception);
}
// At this point we should notify any connection listeners that the connection
// has failed. If the conversation was null, then we are unable to find out where
// to deliver exceptions, so don't try.
if (conversation !=null)
{
ClientConversationState convState =
(ClientConversationState) conversation.getAttachment();
// If in the unlikely event that we get a JFAP exception before we have
// even initialised properly we are a bit stuffed - so don't even try
if (convState != null)
{
// Otherwise, invoke any callbacks
SICoreConnection conn = convState.getSICoreConnection();
final ProxyQueueConversationGroup proxyQueueGroup = convState.getProxyQueueConversationGroup();
ClientAsynchEventThreadPool.getInstance().dispatchCommsException(conn, proxyQueueGroup, exception);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "errorOccurred");
} } | public class class_name {
public void errorOccurred(SIConnectionLostException exception,
int segmentType,
int requestNumber,
int priority,
Conversation conversation)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "errorOccurred");
// First job is to FFDC
FFDCFilter.processException(exception, CLASS_NAME + ".errorOccurred",
CommsConstants.SERVERTRANSPORTRECEIVELISTENER_ERROR_01, this);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
{
Object[] debug = { "Segment type : " + segmentType + " (0x" + Integer.toHexString(segmentType) + ")", "Request number: " + requestNumber, "Priority : " + priority};
SibTr.debug(tc, "Received an error in the ProxyReceiveListener", debug); // depends on control dependency: [if], data = [none]
SibTr.debug(tc, "Primary exception:"); // depends on control dependency: [if], data = [none]
SibTr.exception(tc, exception); // depends on control dependency: [if], data = [none]
}
// At this point we should notify any connection listeners that the connection
// has failed. If the conversation was null, then we are unable to find out where
// to deliver exceptions, so don't try.
if (conversation !=null)
{
ClientConversationState convState =
(ClientConversationState) conversation.getAttachment();
// If in the unlikely event that we get a JFAP exception before we have
// even initialised properly we are a bit stuffed - so don't even try
if (convState != null)
{
// Otherwise, invoke any callbacks
SICoreConnection conn = convState.getSICoreConnection();
final ProxyQueueConversationGroup proxyQueueGroup = convState.getProxyQueueConversationGroup();
ClientAsynchEventThreadPool.getInstance().dispatchCommsException(conn, proxyQueueGroup, exception); // depends on control dependency: [if], data = [none]
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "errorOccurred");
} } |
public class class_name {
public void setScheduledActionNames(java.util.Collection<String> scheduledActionNames) {
if (scheduledActionNames == null) {
this.scheduledActionNames = null;
return;
}
this.scheduledActionNames = new com.amazonaws.internal.SdkInternalList<String>(scheduledActionNames);
} } | public class class_name {
public void setScheduledActionNames(java.util.Collection<String> scheduledActionNames) {
if (scheduledActionNames == null) {
this.scheduledActionNames = null; // depends on control dependency: [if], data = [none]
return; // depends on control dependency: [if], data = [none]
}
this.scheduledActionNames = new com.amazonaws.internal.SdkInternalList<String>(scheduledActionNames);
} } |
public class class_name {
protected FtpMessage listFiles(ListCommand list, TestContext context) {
String remoteFilePath = Optional.ofNullable(list.getTarget())
.map(ListCommand.Target::getPath)
.map(context::replaceDynamicContentInString)
.orElse("");
try {
List<String> fileNames = new ArrayList<>();
FTPFile[] ftpFiles;
if (StringUtils.hasText(remoteFilePath)) {
ftpFiles = ftpClient.listFiles(remoteFilePath);
} else {
ftpFiles = ftpClient.listFiles(remoteFilePath);
}
for (FTPFile ftpFile : ftpFiles) {
fileNames.add(ftpFile.getName());
}
return FtpMessage.result(ftpClient.getReplyCode(), ftpClient.getReplyString(), fileNames);
} catch (IOException e) {
throw new CitrusRuntimeException(String.format("Failed to list files in path '%s'", remoteFilePath), e);
}
} } | public class class_name {
protected FtpMessage listFiles(ListCommand list, TestContext context) {
String remoteFilePath = Optional.ofNullable(list.getTarget())
.map(ListCommand.Target::getPath)
.map(context::replaceDynamicContentInString)
.orElse("");
try {
List<String> fileNames = new ArrayList<>();
FTPFile[] ftpFiles;
if (StringUtils.hasText(remoteFilePath)) {
ftpFiles = ftpClient.listFiles(remoteFilePath); // depends on control dependency: [if], data = [none]
} else {
ftpFiles = ftpClient.listFiles(remoteFilePath); // depends on control dependency: [if], data = [none]
}
for (FTPFile ftpFile : ftpFiles) {
fileNames.add(ftpFile.getName()); // depends on control dependency: [for], data = [ftpFile]
}
return FtpMessage.result(ftpClient.getReplyCode(), ftpClient.getReplyString(), fileNames); // depends on control dependency: [try], data = [none]
} catch (IOException e) {
throw new CitrusRuntimeException(String.format("Failed to list files in path '%s'", remoteFilePath), e);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
public static YearQuarter from(TemporalAccessor temporal) {
if (temporal instanceof YearQuarter) {
return (YearQuarter) temporal;
}
Objects.requireNonNull(temporal, "temporal");
try {
if (IsoChronology.INSTANCE.equals(Chronology.from(temporal)) == false) {
temporal = LocalDate.from(temporal);
}
// need to use getLong() as JDK Parsed class get() doesn't work properly
int year = Math.toIntExact(temporal.getLong(YEAR));
int qoy = Math.toIntExact(temporal.getLong(QUARTER_OF_YEAR));
return of(year, qoy);
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain YearQuarter from TemporalAccessor: " +
temporal + " of type " + temporal.getClass().getName(), ex);
}
} } | public class class_name {
public static YearQuarter from(TemporalAccessor temporal) {
if (temporal instanceof YearQuarter) {
return (YearQuarter) temporal; // depends on control dependency: [if], data = [none]
}
Objects.requireNonNull(temporal, "temporal");
try {
if (IsoChronology.INSTANCE.equals(Chronology.from(temporal)) == false) {
temporal = LocalDate.from(temporal); // depends on control dependency: [if], data = [none]
}
// need to use getLong() as JDK Parsed class get() doesn't work properly
int year = Math.toIntExact(temporal.getLong(YEAR));
int qoy = Math.toIntExact(temporal.getLong(QUARTER_OF_YEAR));
return of(year, qoy); // depends on control dependency: [try], data = [none]
} catch (DateTimeException ex) {
throw new DateTimeException("Unable to obtain YearQuarter from TemporalAccessor: " +
temporal + " of type " + temporal.getClass().getName(), ex);
} // depends on control dependency: [catch], data = [none]
} } |
public class class_name {
@SuppressWarnings("deprecation")
protected void sendError( int sc, String message, HttpServletRequest request, HttpServletResponse response )
throws IOException
{
if(400 <= sc && sc < 600 && !response.isCommitted()) {
String[] fileNames = new String[] {
"/"+Integer.toString(sc)+".html",
"/"+Integer.toString(sc).subSequence(0, 2)+"x.html",
"/"+Integer.toString(sc).subSequence(0, 1)+"xx.html" };
InputStream errorPageIn = null;
try {
String path = request.getRequestURI();
while(path != null && errorPageIn == null) {
if(path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
for (String fileName : fileNames) {
if ((errorPageIn = contentService.getResourceAsStream(path + fileName)) != null) {
log.trace("Found error page for path {} at {}", path, path + fileName);
break;
}
}
if(errorPageIn == null) {
if(path.length() > 0) {
path = path.substring(0, path.lastIndexOf("/"));
} else {
path = null;
}
}
}
// get the default page.
if (errorPageIn == null) {
for (String fileName : fileNames) {
if((errorPageIn = ErrorPageFilter.class.getResourceAsStream(fileName)) != null) {
log.trace("Found error page at {}", fileName);
break;
}
else
if ((errorPageIn = ErrorPageFilter.class.getResourceAsStream("./"+fileName)) != null) {
log.trace("Found error page at {}", "./"+fileName);
break;
}
}
}
if( errorPageIn == null ) {
log.trace("No error page found.");
if( message == null ) response.sendError(sc);
else response.sendError(sc, message);
return;
}
// set the status code.
if (message != null)
response.setStatus(sc, message);
else
response.setStatus(sc);
// create a UTF-8 reader for the error page content.
response.setContentType(MediaType.TEXT_HTML);
log.trace("Sending error page content to response:{}", response.getClass().getName());
IOUtils.copy(errorPageIn, response.getOutputStream());
log.trace("Done sending error page. {}", sc);
} finally {
IOUtils.closeQuietly(errorPageIn);
IOUtils.closeQuietly(response.getOutputStream());
}
}
else {
if( response.isCommitted() ) log.trace("Response is committed!");
if( message == null ) response.sendError(sc);
else response.sendError(sc, message);
}
} } | public class class_name {
@SuppressWarnings("deprecation")
protected void sendError( int sc, String message, HttpServletRequest request, HttpServletResponse response )
throws IOException
{
if(400 <= sc && sc < 600 && !response.isCommitted()) {
String[] fileNames = new String[] {
"/"+Integer.toString(sc)+".html",
"/"+Integer.toString(sc).subSequence(0, 2)+"x.html",
"/"+Integer.toString(sc).subSequence(0, 1)+"xx.html" };
InputStream errorPageIn = null;
try {
String path = request.getRequestURI();
while(path != null && errorPageIn == null) {
if(path.endsWith("/")) {
path = path.substring(0, path.length() - 1); // depends on control dependency: [if], data = [none]
}
for (String fileName : fileNames) {
if ((errorPageIn = contentService.getResourceAsStream(path + fileName)) != null) {
log.trace("Found error page for path {} at {}", path, path + fileName); // depends on control dependency: [if], data = [none]
break;
}
}
if(errorPageIn == null) {
if(path.length() > 0) {
path = path.substring(0, path.lastIndexOf("/")); // depends on control dependency: [if], data = [none]
} else {
path = null; // depends on control dependency: [if], data = [none]
}
}
}
// get the default page.
if (errorPageIn == null) {
for (String fileName : fileNames) {
if((errorPageIn = ErrorPageFilter.class.getResourceAsStream(fileName)) != null) {
log.trace("Found error page at {}", fileName); // depends on control dependency: [if], data = [none]
break;
}
else
if ((errorPageIn = ErrorPageFilter.class.getResourceAsStream("./"+fileName)) != null) {
log.trace("Found error page at {}", "./"+fileName); // depends on control dependency: [if], data = [none]
break;
}
}
}
if( errorPageIn == null ) {
log.trace("No error page found."); // depends on control dependency: [if], data = [none]
if( message == null ) response.sendError(sc);
else response.sendError(sc, message);
return; // depends on control dependency: [if], data = [none]
}
// set the status code.
if (message != null)
response.setStatus(sc, message);
else
response.setStatus(sc);
// create a UTF-8 reader for the error page content.
response.setContentType(MediaType.TEXT_HTML);
log.trace("Sending error page content to response:{}", response.getClass().getName());
IOUtils.copy(errorPageIn, response.getOutputStream());
log.trace("Done sending error page. {}", sc);
} finally {
IOUtils.closeQuietly(errorPageIn);
IOUtils.closeQuietly(response.getOutputStream());
}
}
else {
if( response.isCommitted() ) log.trace("Response is committed!");
if( message == null ) response.sendError(sc);
else response.sendError(sc, message);
}
} } |
public class class_name {
protected String mergeDefinition(BeanDefinition target, ReconfigBeanDefinitionHolder source) {
if (null == target.getBeanClassName()) {
logger.warn("ingore bean definition {} for without class", source.getBeanName());
return null;
}
// 当类型变化后,删除原有配置
if (null != source.getBeanDefinition().getBeanClassName()
&& !source.getBeanDefinition().getBeanClassName().equals(target.getBeanClassName())) {
target.setBeanClassName(source.getBeanDefinition().getBeanClassName());
for (PropertyValue pv : target.getPropertyValues().getPropertyValues()) {
target.getPropertyValues().removePropertyValue(pv);
}
target.getConstructorArgumentValues().clear();
}
MutablePropertyValues pvs = source.getBeanDefinition().getPropertyValues();
for (PropertyValue pv : pvs.getPropertyValueList()) {
String name = pv.getName();
target.getPropertyValues().addPropertyValue(name, pv.getValue());
logger.debug("config {}.{} = {}", new Object[] { source.getBeanName(), name, pv.getValue() });
}
logger.debug("Reconfig bean {} ", source.getBeanName());
return source.getBeanName();
} } | public class class_name {
protected String mergeDefinition(BeanDefinition target, ReconfigBeanDefinitionHolder source) {
if (null == target.getBeanClassName()) {
logger.warn("ingore bean definition {} for without class", source.getBeanName()); // depends on control dependency: [if], data = [none]
return null; // depends on control dependency: [if], data = [none]
}
// 当类型变化后,删除原有配置
if (null != source.getBeanDefinition().getBeanClassName()
&& !source.getBeanDefinition().getBeanClassName().equals(target.getBeanClassName())) {
target.setBeanClassName(source.getBeanDefinition().getBeanClassName()); // depends on control dependency: [if], data = [source.getBeanDefinition().getBeanClassName()]
for (PropertyValue pv : target.getPropertyValues().getPropertyValues()) {
target.getPropertyValues().removePropertyValue(pv); // depends on control dependency: [for], data = [pv]
}
target.getConstructorArgumentValues().clear(); // depends on control dependency: [if], data = [none]
}
MutablePropertyValues pvs = source.getBeanDefinition().getPropertyValues();
for (PropertyValue pv : pvs.getPropertyValueList()) {
String name = pv.getName();
target.getPropertyValues().addPropertyValue(name, pv.getValue()); // depends on control dependency: [for], data = [pv]
logger.debug("config {}.{} = {}", new Object[] { source.getBeanName(), name, pv.getValue() }); // depends on control dependency: [for], data = [pv]
}
logger.debug("Reconfig bean {} ", source.getBeanName());
return source.getBeanName();
} } |
public class class_name {
private static List<Integer> parseRange(String range, int max) {
List<Integer> idx = new ArrayList<Integer>();
String[] n = range.split(",");
for (String s : n) {
String[] d = s.split("-");
int mi = Integer.parseInt(d[0]);
if (mi < 0 || mi >= max) {
throw new IllegalArgumentException(range);
}
if (d.length == 2) {
if (d[1].equals("*")) {
d[1] = Integer.toString(max - 1);
}
int ma = Integer.parseInt(d[1]);
if (ma <= mi || ma >= max || ma < 0) {
throw new IllegalArgumentException(range);
}
for (int i = mi; i <= ma; i++) {
idx.add(i);
}
} else {
idx.add(mi);
}
}
return idx;
} } | public class class_name {
private static List<Integer> parseRange(String range, int max) {
List<Integer> idx = new ArrayList<Integer>();
String[] n = range.split(",");
for (String s : n) {
String[] d = s.split("-");
int mi = Integer.parseInt(d[0]);
if (mi < 0 || mi >= max) {
throw new IllegalArgumentException(range);
}
if (d.length == 2) {
if (d[1].equals("*")) {
d[1] = Integer.toString(max - 1); // depends on control dependency: [if], data = [none]
}
int ma = Integer.parseInt(d[1]);
if (ma <= mi || ma >= max || ma < 0) {
throw new IllegalArgumentException(range);
}
for (int i = mi; i <= ma; i++) {
idx.add(i); // depends on control dependency: [for], data = [i]
}
} else {
idx.add(mi); // depends on control dependency: [if], data = [none]
}
}
return idx;
} } |
public class class_name {
public static boolean areAttributesLiteral(TagAttribute... attributes)
{
for (TagAttribute attribute : attributes)
{
if (attribute != null && !attribute.isLiteral())
{
// the attribute exists and is not literal
return false;
}
}
// all attributes are literal
return true;
} } | public class class_name {
public static boolean areAttributesLiteral(TagAttribute... attributes)
{
for (TagAttribute attribute : attributes)
{
if (attribute != null && !attribute.isLiteral())
{
// the attribute exists and is not literal
return false; // depends on control dependency: [if], data = [none]
}
}
// all attributes are literal
return true;
} } |
public class class_name {
public List<VarPasswordPair> getGlobalVarPasswordPairs() {
List<VarPasswordPair> r = new ArrayList<VarPasswordPair>(getGlobalVarPasswordPairsList().size());
// deep copy
for(VarPasswordPair varPasswordPair: getGlobalVarPasswordPairsList()) {
r.add((VarPasswordPair) varPasswordPair.clone());
}
return r;
} } | public class class_name {
public List<VarPasswordPair> getGlobalVarPasswordPairs() {
List<VarPasswordPair> r = new ArrayList<VarPasswordPair>(getGlobalVarPasswordPairsList().size());
// deep copy
for(VarPasswordPair varPasswordPair: getGlobalVarPasswordPairsList()) {
r.add((VarPasswordPair) varPasswordPair.clone()); // depends on control dependency: [for], data = [varPasswordPair]
}
return r;
} } |
public class class_name {
public JobScheduleExistsOptions withIfModifiedSince(DateTime ifModifiedSince) {
if (ifModifiedSince == null) {
this.ifModifiedSince = null;
} else {
this.ifModifiedSince = new DateTimeRfc1123(ifModifiedSince);
}
return this;
} } | public class class_name {
public JobScheduleExistsOptions withIfModifiedSince(DateTime ifModifiedSince) {
if (ifModifiedSince == null) {
this.ifModifiedSince = null; // depends on control dependency: [if], data = [none]
} else {
this.ifModifiedSince = new DateTimeRfc1123(ifModifiedSince); // depends on control dependency: [if], data = [(ifModifiedSince]
}
return this;
} } |
public class class_name {
private static void collapseConj(Collection<TypedDependency> list) {
List<TreeGraphNode> govs = new ArrayList<TreeGraphNode>();
// find typed deps of form cc(gov, dep)
for (TypedDependency td : list) {
if (td.reln() == COORDINATION) { // i.e. "cc"
TreeGraphNode gov = td.gov();
GrammaticalRelation conj = conjValue(td.dep().value());
if (DEBUG) {
System.err.println("Set conj to " + conj + " based on " + td);
}
// find other deps of that gov having reln "conj"
boolean foundOne = false;
for (TypedDependency td1 : list) {
if (td1.gov() == gov) {
if (td1.reln() == CONJUNCT) { // i.e., "conj"
// change "conj" to the actual (lexical) conjunction
if (DEBUG) {
System.err.println("Changing " + td1 + " to have relation " + conj);
}
td1.setReln(conj);
foundOne = true;
} else if (td1.reln() == COORDINATION) {
conj = conjValue(td1.dep().value());
if (DEBUG) {
System.err.println("Set conj to " + conj + " based on " + td1);
}
}
}
}
// register to remove cc from this governor
if (foundOne) {
govs.add(gov);
}
}
}
// now remove typed dependencies with reln "cc" if we have successfully
// collapsed
for (Iterator<TypedDependency> iter = list.iterator(); iter.hasNext();) {
TypedDependency td2 = iter.next();
if (td2.reln() == COORDINATION && govs.contains(td2.gov())) {
iter.remove();
}
}
} } | public class class_name {
private static void collapseConj(Collection<TypedDependency> list) {
List<TreeGraphNode> govs = new ArrayList<TreeGraphNode>();
// find typed deps of form cc(gov, dep)
for (TypedDependency td : list) {
if (td.reln() == COORDINATION) { // i.e. "cc"
TreeGraphNode gov = td.gov();
GrammaticalRelation conj = conjValue(td.dep().value());
if (DEBUG) {
System.err.println("Set conj to " + conj + " based on " + td);
// depends on control dependency: [if], data = [none]
}
// find other deps of that gov having reln "conj"
boolean foundOne = false;
for (TypedDependency td1 : list) {
if (td1.gov() == gov) {
if (td1.reln() == CONJUNCT) { // i.e., "conj"
// change "conj" to the actual (lexical) conjunction
if (DEBUG) {
System.err.println("Changing " + td1 + " to have relation " + conj);
// depends on control dependency: [if], data = [none]
}
td1.setReln(conj);
// depends on control dependency: [if], data = [none]
foundOne = true;
// depends on control dependency: [if], data = [none]
} else if (td1.reln() == COORDINATION) {
conj = conjValue(td1.dep().value());
// depends on control dependency: [if], data = [none]
if (DEBUG) {
System.err.println("Set conj to " + conj + " based on " + td1);
// depends on control dependency: [if], data = [none]
}
}
}
}
// register to remove cc from this governor
if (foundOne) {
govs.add(gov);
// depends on control dependency: [if], data = [none]
}
}
}
// now remove typed dependencies with reln "cc" if we have successfully
// collapsed
for (Iterator<TypedDependency> iter = list.iterator(); iter.hasNext();) {
TypedDependency td2 = iter.next();
if (td2.reln() == COORDINATION && govs.contains(td2.gov())) {
iter.remove();
// depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
public NetworkInterface withTagSet(Tag... tagSet) {
if (this.tagSet == null) {
setTagSet(new com.amazonaws.internal.SdkInternalList<Tag>(tagSet.length));
}
for (Tag ele : tagSet) {
this.tagSet.add(ele);
}
return this;
} } | public class class_name {
public NetworkInterface withTagSet(Tag... tagSet) {
if (this.tagSet == null) {
setTagSet(new com.amazonaws.internal.SdkInternalList<Tag>(tagSet.length)); // depends on control dependency: [if], data = [none]
}
for (Tag ele : tagSet) {
this.tagSet.add(ele); // depends on control dependency: [for], data = [ele]
}
return this;
} } |
public class class_name {
public String annotationToHELM2() {
if (!(annotationSection.isEmpty())) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < annotationSection.size(); i++) {
sb.append(annotationSection.get(i).toHELM2() + "|");
}
sb.setLength(sb.length() - 1);
return sb.toString();
}
return "";
} } | public class class_name {
public String annotationToHELM2() {
if (!(annotationSection.isEmpty())) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < annotationSection.size(); i++) {
sb.append(annotationSection.get(i).toHELM2() + "|");
// depends on control dependency: [for], data = [i]
}
sb.setLength(sb.length() - 1);
// depends on control dependency: [if], data = [none]
return sb.toString();
// depends on control dependency: [if], data = [none]
}
return "";
} } |
public class class_name {
@POST
public Response runBackup(final InputStream bodyStream) throws IOException {
File backupDirectory;
if (null != bodyStream) {
final String body = IOUtils.toString(bodyStream).trim();
backupDirectory = new File(body.trim());
if (body.isEmpty()) {
// Backup to a temp directory
backupDirectory = createTempDir();
} else if (!backupDirectory.exists() || !backupDirectory.canWrite()) {
throw new WebApplicationException(
serverError().entity(
"Backup directory does not exist or is not writable: " +
backupDirectory.getAbsolutePath())
.build());
}
} else {
// Backup to a temp directory
backupDirectory = createTempDir();
}
LOGGER.debug("Backing up to: {}", backupDirectory.getAbsolutePath());
final Collection<Throwable> problems = repositoryService.backupRepository(session.getFedoraSession(),
backupDirectory);
if (!problems.isEmpty()) {
LOGGER.error("Problems backing up the repository:");
// Report the problems (we'll just print them out) ...
final String output = problems.stream().map(Throwable::getMessage).peek(LOGGER::error)
.collect(joining("\n"));
throw new WebApplicationException(serverError().entity(output).build());
}
return ok()
.header("Warning", "This endpoint will be moving to an extension module in a future release of Fedora")
.entity(backupDirectory.getCanonicalPath()).build();
} } | public class class_name {
@POST
public Response runBackup(final InputStream bodyStream) throws IOException {
File backupDirectory;
if (null != bodyStream) {
final String body = IOUtils.toString(bodyStream).trim();
backupDirectory = new File(body.trim());
if (body.isEmpty()) {
// Backup to a temp directory
backupDirectory = createTempDir(); // depends on control dependency: [if], data = [none]
} else if (!backupDirectory.exists() || !backupDirectory.canWrite()) {
throw new WebApplicationException(
serverError().entity(
"Backup directory does not exist or is not writable: " +
backupDirectory.getAbsolutePath())
.build());
}
} else {
// Backup to a temp directory
backupDirectory = createTempDir();
}
LOGGER.debug("Backing up to: {}", backupDirectory.getAbsolutePath());
final Collection<Throwable> problems = repositoryService.backupRepository(session.getFedoraSession(),
backupDirectory);
if (!problems.isEmpty()) {
LOGGER.error("Problems backing up the repository:");
// Report the problems (we'll just print them out) ...
final String output = problems.stream().map(Throwable::getMessage).peek(LOGGER::error)
.collect(joining("\n"));
throw new WebApplicationException(serverError().entity(output).build());
}
return ok()
.header("Warning", "This endpoint will be moving to an extension module in a future release of Fedora")
.entity(backupDirectory.getCanonicalPath()).build();
} } |
public class class_name {
public static PgConnectOptions fromEnv() {
PgConnectOptions pgConnectOptions = new PgConnectOptions();
if (getenv("PGHOSTADDR") == null) {
if (getenv("PGHOST") != null) {
pgConnectOptions.setHost(getenv("PGHOST"));
}
} else {
pgConnectOptions.setHost(getenv("PGHOSTADDR"));
}
if (getenv("PGPORT") != null) {
try {
pgConnectOptions.setPort(parseInt(getenv("PGPORT")));
} catch (NumberFormatException e) {
// port will be set to default
}
}
if (getenv("PGDATABASE") != null) {
pgConnectOptions.setDatabase(getenv("PGDATABASE"));
}
if (getenv("PGUSER") != null) {
pgConnectOptions.setUser(getenv("PGUSER"));
}
if (getenv("PGPASSWORD") != null) {
pgConnectOptions.setPassword(getenv("PGPASSWORD"));
}
if (getenv("PGSSLMODE") != null) {
pgConnectOptions.setSslMode(SslMode.of(getenv("PGSSLMODE")));
}
return pgConnectOptions;
} } | public class class_name {
public static PgConnectOptions fromEnv() {
PgConnectOptions pgConnectOptions = new PgConnectOptions();
if (getenv("PGHOSTADDR") == null) {
if (getenv("PGHOST") != null) {
pgConnectOptions.setHost(getenv("PGHOST")); // depends on control dependency: [if], data = [(getenv("PGHOST")]
}
} else {
pgConnectOptions.setHost(getenv("PGHOSTADDR")); // depends on control dependency: [if], data = [(getenv("PGHOSTADDR")]
}
if (getenv("PGPORT") != null) {
try {
pgConnectOptions.setPort(parseInt(getenv("PGPORT"))); // depends on control dependency: [try], data = [none]
} catch (NumberFormatException e) {
// port will be set to default
} // depends on control dependency: [catch], data = [none]
}
if (getenv("PGDATABASE") != null) {
pgConnectOptions.setDatabase(getenv("PGDATABASE")); // depends on control dependency: [if], data = [(getenv("PGDATABASE")]
}
if (getenv("PGUSER") != null) {
pgConnectOptions.setUser(getenv("PGUSER")); // depends on control dependency: [if], data = [(getenv("PGUSER")]
}
if (getenv("PGPASSWORD") != null) {
pgConnectOptions.setPassword(getenv("PGPASSWORD")); // depends on control dependency: [if], data = [(getenv("PGPASSWORD")]
}
if (getenv("PGSSLMODE") != null) {
pgConnectOptions.setSslMode(SslMode.of(getenv("PGSSLMODE"))); // depends on control dependency: [if], data = [(getenv("PGSSLMODE")]
}
return pgConnectOptions;
} } |
public class class_name {
private boolean doesReaderOwnTooManySegments(ReaderGroupState state) {
Map<String, Double> sizesOfAssignemnts = state.getRelativeSizes();
Set<Segment> assignedSegments = state.getSegments(readerId);
if (sizesOfAssignemnts.isEmpty() || assignedSegments == null || assignedSegments.size() <= 1) {
return false;
}
double min = sizesOfAssignemnts.values().stream().min(Double::compareTo).get();
return sizesOfAssignemnts.get(readerId) > min + Math.max(1, state.getNumberOfUnassignedSegments());
} } | public class class_name {
private boolean doesReaderOwnTooManySegments(ReaderGroupState state) {
Map<String, Double> sizesOfAssignemnts = state.getRelativeSizes();
Set<Segment> assignedSegments = state.getSegments(readerId);
if (sizesOfAssignemnts.isEmpty() || assignedSegments == null || assignedSegments.size() <= 1) {
return false; // depends on control dependency: [if], data = [none]
}
double min = sizesOfAssignemnts.values().stream().min(Double::compareTo).get();
return sizesOfAssignemnts.get(readerId) > min + Math.max(1, state.getNumberOfUnassignedSegments());
} } |
public class class_name {
public final EObject ruleXTryCatchFinallyExpression() throws RecognitionException {
EObject current = null;
Token otherlv_1=null;
Token otherlv_4=null;
Token otherlv_6=null;
EObject lv_expression_2_0 = null;
EObject lv_catchClauses_3_0 = null;
EObject lv_finallyExpression_5_0 = null;
EObject lv_finallyExpression_7_0 = null;
enterRule();
try {
// InternalXbaseWithAnnotations.g:5508:2: ( ( () otherlv_1= 'try' ( (lv_expression_2_0= ruleXExpression ) ) ( ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? ) | (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) ) ) ) )
// InternalXbaseWithAnnotations.g:5509:2: ( () otherlv_1= 'try' ( (lv_expression_2_0= ruleXExpression ) ) ( ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? ) | (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) ) ) )
{
// InternalXbaseWithAnnotations.g:5509:2: ( () otherlv_1= 'try' ( (lv_expression_2_0= ruleXExpression ) ) ( ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? ) | (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) ) ) )
// InternalXbaseWithAnnotations.g:5510:3: () otherlv_1= 'try' ( (lv_expression_2_0= ruleXExpression ) ) ( ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? ) | (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) ) )
{
// InternalXbaseWithAnnotations.g:5510:3: ()
// InternalXbaseWithAnnotations.g:5511:4:
{
if ( state.backtracking==0 ) {
current = forceCreateModelElement(
grammarAccess.getXTryCatchFinallyExpressionAccess().getXTryCatchFinallyExpressionAction_0(),
current);
}
}
otherlv_1=(Token)match(input,82,FOLLOW_9); if (state.failed) return current;
if ( state.backtracking==0 ) {
newLeafNode(otherlv_1, grammarAccess.getXTryCatchFinallyExpressionAccess().getTryKeyword_1());
}
// InternalXbaseWithAnnotations.g:5521:3: ( (lv_expression_2_0= ruleXExpression ) )
// InternalXbaseWithAnnotations.g:5522:4: (lv_expression_2_0= ruleXExpression )
{
// InternalXbaseWithAnnotations.g:5522:4: (lv_expression_2_0= ruleXExpression )
// InternalXbaseWithAnnotations.g:5523:5: lv_expression_2_0= ruleXExpression
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXTryCatchFinallyExpressionAccess().getExpressionXExpressionParserRuleCall_2_0());
}
pushFollow(FOLLOW_70);
lv_expression_2_0=ruleXExpression();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElementForParent(grammarAccess.getXTryCatchFinallyExpressionRule());
}
set(
current,
"expression",
lv_expression_2_0,
"org.eclipse.xtext.xbase.Xbase.XExpression");
afterParserOrEnumRuleCall();
}
}
}
// InternalXbaseWithAnnotations.g:5540:3: ( ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? ) | (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) ) )
int alt98=2;
int LA98_0 = input.LA(1);
if ( (LA98_0==85) ) {
alt98=1;
}
else if ( (LA98_0==83) ) {
alt98=2;
}
else {
if (state.backtracking>0) {state.failed=true; return current;}
NoViableAltException nvae =
new NoViableAltException("", 98, 0, input);
throw nvae;
}
switch (alt98) {
case 1 :
// InternalXbaseWithAnnotations.g:5541:4: ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? )
{
// InternalXbaseWithAnnotations.g:5541:4: ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? )
// InternalXbaseWithAnnotations.g:5542:5: ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )?
{
// InternalXbaseWithAnnotations.g:5542:5: ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+
int cnt96=0;
loop96:
do {
int alt96=2;
int LA96_0 = input.LA(1);
if ( (LA96_0==85) ) {
int LA96_2 = input.LA(2);
if ( (synpred44_InternalXbaseWithAnnotations()) ) {
alt96=1;
}
}
switch (alt96) {
case 1 :
// InternalXbaseWithAnnotations.g:5543:6: ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause )
{
// InternalXbaseWithAnnotations.g:5544:6: (lv_catchClauses_3_0= ruleXCatchClause )
// InternalXbaseWithAnnotations.g:5545:7: lv_catchClauses_3_0= ruleXCatchClause
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXTryCatchFinallyExpressionAccess().getCatchClausesXCatchClauseParserRuleCall_3_0_0_0());
}
pushFollow(FOLLOW_71);
lv_catchClauses_3_0=ruleXCatchClause();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElementForParent(grammarAccess.getXTryCatchFinallyExpressionRule());
}
add(
current,
"catchClauses",
lv_catchClauses_3_0,
"org.eclipse.xtext.xbase.Xbase.XCatchClause");
afterParserOrEnumRuleCall();
}
}
}
break;
default :
if ( cnt96 >= 1 ) break loop96;
if (state.backtracking>0) {state.failed=true; return current;}
EarlyExitException eee =
new EarlyExitException(96, input);
throw eee;
}
cnt96++;
} while (true);
// InternalXbaseWithAnnotations.g:5562:5: ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )?
int alt97=2;
int LA97_0 = input.LA(1);
if ( (LA97_0==83) ) {
int LA97_1 = input.LA(2);
if ( (synpred45_InternalXbaseWithAnnotations()) ) {
alt97=1;
}
}
switch (alt97) {
case 1 :
// InternalXbaseWithAnnotations.g:5563:6: ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) )
{
// InternalXbaseWithAnnotations.g:5563:6: ( ( 'finally' )=>otherlv_4= 'finally' )
// InternalXbaseWithAnnotations.g:5564:7: ( 'finally' )=>otherlv_4= 'finally'
{
otherlv_4=(Token)match(input,83,FOLLOW_9); if (state.failed) return current;
if ( state.backtracking==0 ) {
newLeafNode(otherlv_4, grammarAccess.getXTryCatchFinallyExpressionAccess().getFinallyKeyword_3_0_1_0());
}
}
// InternalXbaseWithAnnotations.g:5570:6: ( (lv_finallyExpression_5_0= ruleXExpression ) )
// InternalXbaseWithAnnotations.g:5571:7: (lv_finallyExpression_5_0= ruleXExpression )
{
// InternalXbaseWithAnnotations.g:5571:7: (lv_finallyExpression_5_0= ruleXExpression )
// InternalXbaseWithAnnotations.g:5572:8: lv_finallyExpression_5_0= ruleXExpression
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXTryCatchFinallyExpressionAccess().getFinallyExpressionXExpressionParserRuleCall_3_0_1_1_0());
}
pushFollow(FOLLOW_2);
lv_finallyExpression_5_0=ruleXExpression();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElementForParent(grammarAccess.getXTryCatchFinallyExpressionRule());
}
set(
current,
"finallyExpression",
lv_finallyExpression_5_0,
"org.eclipse.xtext.xbase.Xbase.XExpression");
afterParserOrEnumRuleCall();
}
}
}
}
break;
}
}
}
break;
case 2 :
// InternalXbaseWithAnnotations.g:5592:4: (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) )
{
// InternalXbaseWithAnnotations.g:5592:4: (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) )
// InternalXbaseWithAnnotations.g:5593:5: otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) )
{
otherlv_6=(Token)match(input,83,FOLLOW_9); if (state.failed) return current;
if ( state.backtracking==0 ) {
newLeafNode(otherlv_6, grammarAccess.getXTryCatchFinallyExpressionAccess().getFinallyKeyword_3_1_0());
}
// InternalXbaseWithAnnotations.g:5597:5: ( (lv_finallyExpression_7_0= ruleXExpression ) )
// InternalXbaseWithAnnotations.g:5598:6: (lv_finallyExpression_7_0= ruleXExpression )
{
// InternalXbaseWithAnnotations.g:5598:6: (lv_finallyExpression_7_0= ruleXExpression )
// InternalXbaseWithAnnotations.g:5599:7: lv_finallyExpression_7_0= ruleXExpression
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXTryCatchFinallyExpressionAccess().getFinallyExpressionXExpressionParserRuleCall_3_1_1_0());
}
pushFollow(FOLLOW_2);
lv_finallyExpression_7_0=ruleXExpression();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElementForParent(grammarAccess.getXTryCatchFinallyExpressionRule());
}
set(
current,
"finallyExpression",
lv_finallyExpression_7_0,
"org.eclipse.xtext.xbase.Xbase.XExpression");
afterParserOrEnumRuleCall();
}
}
}
}
}
break;
}
}
}
if ( state.backtracking==0 ) {
leaveRule();
}
}
catch (RecognitionException re) {
recover(input,re);
appendSkippedTokens();
}
finally {
}
return current;
} } | public class class_name {
public final EObject ruleXTryCatchFinallyExpression() throws RecognitionException {
EObject current = null;
Token otherlv_1=null;
Token otherlv_4=null;
Token otherlv_6=null;
EObject lv_expression_2_0 = null;
EObject lv_catchClauses_3_0 = null;
EObject lv_finallyExpression_5_0 = null;
EObject lv_finallyExpression_7_0 = null;
enterRule();
try {
// InternalXbaseWithAnnotations.g:5508:2: ( ( () otherlv_1= 'try' ( (lv_expression_2_0= ruleXExpression ) ) ( ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? ) | (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) ) ) ) )
// InternalXbaseWithAnnotations.g:5509:2: ( () otherlv_1= 'try' ( (lv_expression_2_0= ruleXExpression ) ) ( ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? ) | (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) ) ) )
{
// InternalXbaseWithAnnotations.g:5509:2: ( () otherlv_1= 'try' ( (lv_expression_2_0= ruleXExpression ) ) ( ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? ) | (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) ) ) )
// InternalXbaseWithAnnotations.g:5510:3: () otherlv_1= 'try' ( (lv_expression_2_0= ruleXExpression ) ) ( ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? ) | (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) ) )
{
// InternalXbaseWithAnnotations.g:5510:3: ()
// InternalXbaseWithAnnotations.g:5511:4:
{
if ( state.backtracking==0 ) {
current = forceCreateModelElement(
grammarAccess.getXTryCatchFinallyExpressionAccess().getXTryCatchFinallyExpressionAction_0(),
current); // depends on control dependency: [if], data = [none]
}
}
otherlv_1=(Token)match(input,82,FOLLOW_9); if (state.failed) return current;
if ( state.backtracking==0 ) {
newLeafNode(otherlv_1, grammarAccess.getXTryCatchFinallyExpressionAccess().getTryKeyword_1()); // depends on control dependency: [if], data = [none]
}
// InternalXbaseWithAnnotations.g:5521:3: ( (lv_expression_2_0= ruleXExpression ) )
// InternalXbaseWithAnnotations.g:5522:4: (lv_expression_2_0= ruleXExpression )
{
// InternalXbaseWithAnnotations.g:5522:4: (lv_expression_2_0= ruleXExpression )
// InternalXbaseWithAnnotations.g:5523:5: lv_expression_2_0= ruleXExpression
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXTryCatchFinallyExpressionAccess().getExpressionXExpressionParserRuleCall_2_0()); // depends on control dependency: [if], data = [none]
}
pushFollow(FOLLOW_70);
lv_expression_2_0=ruleXExpression();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElementForParent(grammarAccess.getXTryCatchFinallyExpressionRule()); // depends on control dependency: [if], data = [none]
}
set(
current,
"expression",
lv_expression_2_0,
"org.eclipse.xtext.xbase.Xbase.XExpression");
afterParserOrEnumRuleCall(); // depends on control dependency: [if], data = [none]
}
}
}
// InternalXbaseWithAnnotations.g:5540:3: ( ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? ) | (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) ) )
int alt98=2;
int LA98_0 = input.LA(1);
if ( (LA98_0==85) ) {
alt98=1; // depends on control dependency: [if], data = [none]
}
else if ( (LA98_0==83) ) {
alt98=2; // depends on control dependency: [if], data = [none]
}
else {
if (state.backtracking>0) {state.failed=true; return current;} // depends on control dependency: [if], data = [none] // depends on control dependency: [if], data = [none]
NoViableAltException nvae =
new NoViableAltException("", 98, 0, input);
throw nvae;
}
switch (alt98) {
case 1 :
// InternalXbaseWithAnnotations.g:5541:4: ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? )
{
// InternalXbaseWithAnnotations.g:5541:4: ( ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )? )
// InternalXbaseWithAnnotations.g:5542:5: ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+ ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )?
{
// InternalXbaseWithAnnotations.g:5542:5: ( ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause ) )+
int cnt96=0;
loop96:
do {
int alt96=2;
int LA96_0 = input.LA(1);
if ( (LA96_0==85) ) {
int LA96_2 = input.LA(2);
if ( (synpred44_InternalXbaseWithAnnotations()) ) {
alt96=1; // depends on control dependency: [if], data = [none]
}
}
switch (alt96) {
case 1 :
// InternalXbaseWithAnnotations.g:5543:6: ( 'catch' )=> (lv_catchClauses_3_0= ruleXCatchClause )
{
// InternalXbaseWithAnnotations.g:5544:6: (lv_catchClauses_3_0= ruleXCatchClause )
// InternalXbaseWithAnnotations.g:5545:7: lv_catchClauses_3_0= ruleXCatchClause
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXTryCatchFinallyExpressionAccess().getCatchClausesXCatchClauseParserRuleCall_3_0_0_0()); // depends on control dependency: [if], data = [none]
}
pushFollow(FOLLOW_71);
lv_catchClauses_3_0=ruleXCatchClause();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElementForParent(grammarAccess.getXTryCatchFinallyExpressionRule()); // depends on control dependency: [if], data = [none]
}
add(
current,
"catchClauses",
lv_catchClauses_3_0,
"org.eclipse.xtext.xbase.Xbase.XCatchClause"); // depends on control dependency: [if], data = [none]
afterParserOrEnumRuleCall(); // depends on control dependency: [if], data = [none]
}
}
}
break;
default :
if ( cnt96 >= 1 ) break loop96;
if (state.backtracking>0) {state.failed=true; return current;} // depends on control dependency: [if], data = [none] // depends on control dependency: [if], data = [none]
EarlyExitException eee =
new EarlyExitException(96, input);
throw eee;
}
cnt96++;
} while (true);
// InternalXbaseWithAnnotations.g:5562:5: ( ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) ) )?
int alt97=2;
int LA97_0 = input.LA(1);
if ( (LA97_0==83) ) {
int LA97_1 = input.LA(2);
if ( (synpred45_InternalXbaseWithAnnotations()) ) {
alt97=1; // depends on control dependency: [if], data = [none]
}
}
switch (alt97) {
case 1 :
// InternalXbaseWithAnnotations.g:5563:6: ( ( 'finally' )=>otherlv_4= 'finally' ) ( (lv_finallyExpression_5_0= ruleXExpression ) )
{
// InternalXbaseWithAnnotations.g:5563:6: ( ( 'finally' )=>otherlv_4= 'finally' )
// InternalXbaseWithAnnotations.g:5564:7: ( 'finally' )=>otherlv_4= 'finally'
{
otherlv_4=(Token)match(input,83,FOLLOW_9); if (state.failed) return current;
if ( state.backtracking==0 ) {
newLeafNode(otherlv_4, grammarAccess.getXTryCatchFinallyExpressionAccess().getFinallyKeyword_3_0_1_0()); // depends on control dependency: [if], data = [none]
}
}
// InternalXbaseWithAnnotations.g:5570:6: ( (lv_finallyExpression_5_0= ruleXExpression ) )
// InternalXbaseWithAnnotations.g:5571:7: (lv_finallyExpression_5_0= ruleXExpression )
{
// InternalXbaseWithAnnotations.g:5571:7: (lv_finallyExpression_5_0= ruleXExpression )
// InternalXbaseWithAnnotations.g:5572:8: lv_finallyExpression_5_0= ruleXExpression
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXTryCatchFinallyExpressionAccess().getFinallyExpressionXExpressionParserRuleCall_3_0_1_1_0()); // depends on control dependency: [if], data = [none]
}
pushFollow(FOLLOW_2);
lv_finallyExpression_5_0=ruleXExpression();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElementForParent(grammarAccess.getXTryCatchFinallyExpressionRule()); // depends on control dependency: [if], data = [none]
}
set(
current,
"finallyExpression",
lv_finallyExpression_5_0,
"org.eclipse.xtext.xbase.Xbase.XExpression"); // depends on control dependency: [if], data = [none]
afterParserOrEnumRuleCall(); // depends on control dependency: [if], data = [none]
}
}
}
}
break;
}
}
}
break;
case 2 :
// InternalXbaseWithAnnotations.g:5592:4: (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) )
{
// InternalXbaseWithAnnotations.g:5592:4: (otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) ) )
// InternalXbaseWithAnnotations.g:5593:5: otherlv_6= 'finally' ( (lv_finallyExpression_7_0= ruleXExpression ) )
{
otherlv_6=(Token)match(input,83,FOLLOW_9); if (state.failed) return current;
if ( state.backtracking==0 ) {
newLeafNode(otherlv_6, grammarAccess.getXTryCatchFinallyExpressionAccess().getFinallyKeyword_3_1_0()); // depends on control dependency: [if], data = [none]
}
// InternalXbaseWithAnnotations.g:5597:5: ( (lv_finallyExpression_7_0= ruleXExpression ) )
// InternalXbaseWithAnnotations.g:5598:6: (lv_finallyExpression_7_0= ruleXExpression )
{
// InternalXbaseWithAnnotations.g:5598:6: (lv_finallyExpression_7_0= ruleXExpression )
// InternalXbaseWithAnnotations.g:5599:7: lv_finallyExpression_7_0= ruleXExpression
{
if ( state.backtracking==0 ) {
newCompositeNode(grammarAccess.getXTryCatchFinallyExpressionAccess().getFinallyExpressionXExpressionParserRuleCall_3_1_1_0()); // depends on control dependency: [if], data = [none]
}
pushFollow(FOLLOW_2);
lv_finallyExpression_7_0=ruleXExpression();
state._fsp--;
if (state.failed) return current;
if ( state.backtracking==0 ) {
if (current==null) {
current = createModelElementForParent(grammarAccess.getXTryCatchFinallyExpressionRule()); // depends on control dependency: [if], data = [none]
}
set(
current,
"finallyExpression",
lv_finallyExpression_7_0,
"org.eclipse.xtext.xbase.Xbase.XExpression"); // depends on control dependency: [if], data = [none]
afterParserOrEnumRuleCall(); // depends on control dependency: [if], data = [none]
}
}
}
}
}
break;
}
}
}
if ( state.backtracking==0 ) {
leaveRule(); // depends on control dependency: [if], data = [none]
}
}
catch (RecognitionException re) {
recover(input,re);
appendSkippedTokens();
}
finally {
}
return current;
} } |
public class class_name {
public static byte[] getURLData(final String url) {
final int readBytes = 1000;
URL u;
InputStream is = null;
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
// See http://www.exampledepot.com/egs/javax.net.ssl/TrustAll.html
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
}
}};
// Install the all-trusting trust manager
// FIXME from Lee: This doesn't seem like a wise idea to install an all-trusting cert manager by default
try {
final SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (final Exception ex) {
LOG.error("Unable to install the all-trust SSL Manager", ex);
}
try {
u = new URL(url);
is = u.openStream(); // throws an IOException
int nRead;
byte[] data = new byte[readBytes];
while ((nRead = is.read(data, 0, readBytes)) != -1) {
buffer.write(data, 0, nRead);
}
} catch (final Exception ex) {
LOG.error("Unable to read data from URL", ex);
} finally {
try {
buffer.flush();
if (is != null) is.close();
} catch (final Exception ex) {
LOG.error("Unable to flush and close URL Input Stream", ex);
}
}
return buffer.toByteArray();
} } | public class class_name {
public static byte[] getURLData(final String url) {
final int readBytes = 1000;
URL u;
InputStream is = null;
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
// See http://www.exampledepot.com/egs/javax.net.ssl/TrustAll.html
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
}
}};
// Install the all-trusting trust manager
// FIXME from Lee: This doesn't seem like a wise idea to install an all-trusting cert manager by default
try {
final SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom()); // depends on control dependency: [try], data = [none]
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); // depends on control dependency: [try], data = [none]
} catch (final Exception ex) {
LOG.error("Unable to install the all-trust SSL Manager", ex);
} // depends on control dependency: [catch], data = [none]
try {
u = new URL(url); // depends on control dependency: [try], data = [none]
is = u.openStream(); // throws an IOException // depends on control dependency: [try], data = [none]
int nRead;
byte[] data = new byte[readBytes];
while ((nRead = is.read(data, 0, readBytes)) != -1) {
buffer.write(data, 0, nRead); // depends on control dependency: [while], data = [none]
}
} catch (final Exception ex) {
LOG.error("Unable to read data from URL", ex);
} finally { // depends on control dependency: [catch], data = [none]
try {
buffer.flush(); // depends on control dependency: [try], data = [none]
if (is != null) is.close();
} catch (final Exception ex) {
LOG.error("Unable to flush and close URL Input Stream", ex);
} // depends on control dependency: [catch], data = [none]
}
return buffer.toByteArray();
} } |
public class class_name {
public static Long getSize(final File file){
if ( file!=null && file.exists() ){
return file.length();
}
return null;
} } | public class class_name {
public static Long getSize(final File file){
if ( file!=null && file.exists() ){
return file.length(); // depends on control dependency: [if], data = [none]
}
return null;
} } |
public class class_name {
private void clearDeck(TrackMetadataUpdate update) {
if (hotCache.remove(DeckReference.getDeckReference(update.player, 0)) != null) {
deliverBeatGridUpdate(update.player, null);
}
} } | public class class_name {
private void clearDeck(TrackMetadataUpdate update) {
if (hotCache.remove(DeckReference.getDeckReference(update.player, 0)) != null) {
deliverBeatGridUpdate(update.player, null); // depends on control dependency: [if], data = [null)]
}
} } |
public class class_name {
public Observable<ServiceResponse<ResourceListKeysInner>> regenerateKeysWithServiceResponseAsync(String resourceGroupName, String namespaceName, String authorizationRuleName, String policyKey) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (namespaceName == null) {
throw new IllegalArgumentException("Parameter namespaceName is required and cannot be null.");
}
if (authorizationRuleName == null) {
throw new IllegalArgumentException("Parameter authorizationRuleName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
PolicykeyResource parameters = new PolicykeyResource();
parameters.withPolicyKey(policyKey);
return service.regenerateKeys(resourceGroupName, namespaceName, authorizationRuleName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ResourceListKeysInner>>>() {
@Override
public Observable<ServiceResponse<ResourceListKeysInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<ResourceListKeysInner> clientResponse = regenerateKeysDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
} } | public class class_name {
public Observable<ServiceResponse<ResourceListKeysInner>> regenerateKeysWithServiceResponseAsync(String resourceGroupName, String namespaceName, String authorizationRuleName, String policyKey) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (namespaceName == null) {
throw new IllegalArgumentException("Parameter namespaceName is required and cannot be null.");
}
if (authorizationRuleName == null) {
throw new IllegalArgumentException("Parameter authorizationRuleName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
PolicykeyResource parameters = new PolicykeyResource();
parameters.withPolicyKey(policyKey);
return service.regenerateKeys(resourceGroupName, namespaceName, authorizationRuleName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), parameters, this.client.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ResourceListKeysInner>>>() {
@Override
public Observable<ServiceResponse<ResourceListKeysInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<ResourceListKeysInner> clientResponse = regenerateKeysDelegate(response);
return Observable.just(clientResponse); // depends on control dependency: [try], data = [none]
} catch (Throwable t) {
return Observable.error(t);
} // depends on control dependency: [catch], data = [none]
}
});
} } |
public class class_name {
public static double recall(long tpCount, long fnCount, double edgeCase) {
//Edge case
if (tpCount == 0 && fnCount == 0) {
return edgeCase;
}
return tpCount / (double) (tpCount + fnCount);
} } | public class class_name {
public static double recall(long tpCount, long fnCount, double edgeCase) {
//Edge case
if (tpCount == 0 && fnCount == 0) {
return edgeCase; // depends on control dependency: [if], data = [none]
}
return tpCount / (double) (tpCount + fnCount);
} } |
public class class_name {
public static TvListing parse(InputStream inputStream) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
String line;
List<Channel> channels = new ArrayList<>();
List<Program> programs = new ArrayList<>();
Map<Integer, Integer> channelMap = new HashMap<>();
int defaultDisplayNumber = 0;
while ((line = in.readLine()) != null) {
if (line.startsWith("#EXTINF:")) {
// #EXTINF:0051 tvg-id="blizz.de" group-title="DE Spartensender" tvg-logo="897815.png", [COLOR orangered]blizz TV HD[/COLOR]
String id = null;
String displayName = null;
String displayNumber = null;
int originalNetworkId = 0;
String icon = null;
String[] parts = line.split(",", 2);
if (parts.length == 2) {
for (String part : parts[0].split(" ")) {
if (part.startsWith("#EXTINF:")) {
// Log.d(TAG, "Part: "+part);
displayNumber = part.substring(8).replaceAll("^0+", "");
// Log.d(TAG, "Display Number: "+displayNumber);
if(displayNumber.isEmpty())
displayNumber = defaultDisplayNumber+"";
if(displayNumber.equals("-1"))
displayNumber = defaultDisplayNumber+"";
defaultDisplayNumber++;
originalNetworkId = Integer.parseInt(displayNumber);
} else if (part.startsWith("tvg-id=")) {
int end = part.indexOf("\"", 8);
if (end > 8) {
id = part.substring(8, end);
}
} else if (part.startsWith("tvg-logo=")) {
int end = part.indexOf("\"", 10);
if (end > 10) {
icon = part.substring(10, end);
}
}
}
displayName = parts[1].replaceAll("\\[\\/?(COLOR |)[^\\]]*\\]", "");
}
if (originalNetworkId != 0 && displayName != null) {
Channel channel =
new Channel()
.setChannelId(Integer.parseInt(id))
.setName(displayName)
.setNumber(displayNumber)
.setLogoUrl(icon)
.setOriginalNetworkId(originalNetworkId);
if (channelMap.containsKey(originalNetworkId)) {
int freeChannel = 1;
while(channelMap.containsKey(new Integer(freeChannel))) {
freeChannel++;
}
channelMap.put(freeChannel, channels.size());
channel.setNumber(freeChannel+"");
channels.add(channel);
} else {
channelMap.put(originalNetworkId, channels.size());
channels.add(channel);
}
} else {
Log.d(TAG, "Import failed: "+originalNetworkId+"= "+line);
}
} else if (line.startsWith("http") && channels.size() > 0) {
channels.get(channels.size()-1).setInternalProviderData(line);
} else if(line.startsWith("rtmp") && channels.size() > 0) {
channels.get(channels.size()-1).setInternalProviderData(line);
}
}
TvListing tvl = new TvListing(channels, programs);
Log.d(TAG, "Done parsing");
Log.d(TAG, tvl.toString());
return new TvListing(channels, programs);
} } | public class class_name {
public static TvListing parse(InputStream inputStream) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
String line;
List<Channel> channels = new ArrayList<>();
List<Program> programs = new ArrayList<>();
Map<Integer, Integer> channelMap = new HashMap<>();
int defaultDisplayNumber = 0;
while ((line = in.readLine()) != null) {
if (line.startsWith("#EXTINF:")) {
// #EXTINF:0051 tvg-id="blizz.de" group-title="DE Spartensender" tvg-logo="897815.png", [COLOR orangered]blizz TV HD[/COLOR]
String id = null;
String displayName = null;
String displayNumber = null;
int originalNetworkId = 0;
String icon = null;
String[] parts = line.split(",", 2);
if (parts.length == 2) {
for (String part : parts[0].split(" ")) {
if (part.startsWith("#EXTINF:")) {
// Log.d(TAG, "Part: "+part);
displayNumber = part.substring(8).replaceAll("^0+", ""); // depends on control dependency: [if], data = [none]
// Log.d(TAG, "Display Number: "+displayNumber);
if(displayNumber.isEmpty())
displayNumber = defaultDisplayNumber+"";
if(displayNumber.equals("-1"))
displayNumber = defaultDisplayNumber+"";
defaultDisplayNumber++; // depends on control dependency: [if], data = [none]
originalNetworkId = Integer.parseInt(displayNumber); // depends on control dependency: [if], data = [none]
} else if (part.startsWith("tvg-id=")) {
int end = part.indexOf("\"", 8);
if (end > 8) {
id = part.substring(8, end); // depends on control dependency: [if], data = [none]
}
} else if (part.startsWith("tvg-logo=")) {
int end = part.indexOf("\"", 10);
if (end > 10) {
icon = part.substring(10, end); // depends on control dependency: [if], data = [none]
}
}
}
displayName = parts[1].replaceAll("\\[\\/?(COLOR |)[^\\]]*\\]", ""); // depends on control dependency: [if], data = [none]
}
if (originalNetworkId != 0 && displayName != null) {
Channel channel =
new Channel()
.setChannelId(Integer.parseInt(id))
.setName(displayName)
.setNumber(displayNumber)
.setLogoUrl(icon)
.setOriginalNetworkId(originalNetworkId);
if (channelMap.containsKey(originalNetworkId)) {
int freeChannel = 1;
while(channelMap.containsKey(new Integer(freeChannel))) {
freeChannel++; // depends on control dependency: [while], data = [none]
}
channelMap.put(freeChannel, channels.size()); // depends on control dependency: [if], data = [none]
channel.setNumber(freeChannel+""); // depends on control dependency: [if], data = [none]
channels.add(channel); // depends on control dependency: [if], data = [none]
} else {
channelMap.put(originalNetworkId, channels.size()); // depends on control dependency: [if], data = [none]
channels.add(channel); // depends on control dependency: [if], data = [none]
}
} else {
Log.d(TAG, "Import failed: "+originalNetworkId+"= "+line); // depends on control dependency: [if], data = [none]
}
} else if (line.startsWith("http") && channels.size() > 0) {
channels.get(channels.size()-1).setInternalProviderData(line); // depends on control dependency: [if], data = [none]
} else if(line.startsWith("rtmp") && channels.size() > 0) {
channels.get(channels.size()-1).setInternalProviderData(line); // depends on control dependency: [if], data = [none]
}
}
TvListing tvl = new TvListing(channels, programs);
Log.d(TAG, "Done parsing");
Log.d(TAG, tvl.toString());
return new TvListing(channels, programs);
} } |
public class class_name {
public void closeWebApplicationContext(ServletContext servletContext) {
servletContext.log("Closing Spring root PortletApplicationContext");
try {
if (this.context instanceof ConfigurablePortletApplicationContext) {
((ConfigurablePortletApplicationContext) this.context).close();
}
}
finally {
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
if (ccl == PortletContextLoader.class.getClassLoader()) {
currentContext = null;
}
else if (ccl != null) {
currentContextPerThread.remove(ccl);
}
servletContext.removeAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE);
if (this.parentContextRef != null) {
this.parentContextRef.release();
}
}
} } | public class class_name {
public void closeWebApplicationContext(ServletContext servletContext) {
servletContext.log("Closing Spring root PortletApplicationContext");
try {
if (this.context instanceof ConfigurablePortletApplicationContext) {
((ConfigurablePortletApplicationContext) this.context).close(); // depends on control dependency: [if], data = [none]
}
}
finally {
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
if (ccl == PortletContextLoader.class.getClassLoader()) {
currentContext = null; // depends on control dependency: [if], data = [none]
}
else if (ccl != null) {
currentContextPerThread.remove(ccl); // depends on control dependency: [if], data = [(ccl]
}
servletContext.removeAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE);
if (this.parentContextRef != null) {
this.parentContextRef.release(); // depends on control dependency: [if], data = [none]
}
}
} } |
public class class_name {
private boolean isRedundant(IContextMapping<INode> mapping, IMappingElement<INode> e) {
switch (e.getRelation()) {
case IMappingElement.LESS_GENERAL: {
if (verifyCondition1(mapping, e)) {
return true;
}
break;
}
case IMappingElement.MORE_GENERAL: {
if (verifyCondition2(mapping, e)) {
return true;
}
break;
}
case IMappingElement.DISJOINT: {
if (verifyCondition3(mapping, e)) {
return true;
}
break;
}
case IMappingElement.EQUIVALENCE: {
if (verifyCondition4(mapping, e)) {
return true;
}
break;
}
default: {
return false;
}
}// end switch
return false;
} } | public class class_name {
private boolean isRedundant(IContextMapping<INode> mapping, IMappingElement<INode> e) {
switch (e.getRelation()) {
case IMappingElement.LESS_GENERAL: {
if (verifyCondition1(mapping, e)) {
return true;
// depends on control dependency: [if], data = [none]
}
break;
}
case IMappingElement.MORE_GENERAL: {
if (verifyCondition2(mapping, e)) {
return true;
// depends on control dependency: [if], data = [none]
}
break;
}
case IMappingElement.DISJOINT: {
if (verifyCondition3(mapping, e)) {
return true;
}
break;
}
case IMappingElement.EQUIVALENCE: {
if (verifyCondition4(mapping, e)) {
return true;
}
break;
}
default: {
return false;
}
}// end switch
return false;
} } |
public class class_name {
private Adapter getAdapter(String name) {
List<Adapter> services = getAdapterServices();
if (services != null) {
for (Adapter service : services) {
if (service.getName().equals(name)) {
return service;
}
}
}
Adapter result = new Adapter();
result.setName(name);
services.add(result);
QName qName = new QName(APPLICATION_MANAGEMENT_NAMESPACE, "adapter");
JAXBElement<Adapter> j = new JAXBElement<Adapter>(qName, Adapter.class, result);
application.getServices().getBaseService().add(j);
return result;
} } | public class class_name {
private Adapter getAdapter(String name) {
List<Adapter> services = getAdapterServices();
if (services != null) {
for (Adapter service : services) {
if (service.getName().equals(name)) {
return service; // depends on control dependency: [if], data = [none]
}
}
}
Adapter result = new Adapter();
result.setName(name);
services.add(result);
QName qName = new QName(APPLICATION_MANAGEMENT_NAMESPACE, "adapter");
JAXBElement<Adapter> j = new JAXBElement<Adapter>(qName, Adapter.class, result);
application.getServices().getBaseService().add(j);
return result;
} } |
public class class_name {
public void marshall(GetQueryResultsRequest getQueryResultsRequest, ProtocolMarshaller protocolMarshaller) {
if (getQueryResultsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(getQueryResultsRequest.getQueryId(), QUERYID_BINDING);
} catch (Exception e) {
throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
}
} } | public class class_name {
public void marshall(GetQueryResultsRequest getQueryResultsRequest, ProtocolMarshaller protocolMarshaller) {
if (getQueryResultsRequest == null) {
throw new SdkClientException("Invalid argument passed to marshall(...)");
}
try {
protocolMarshaller.marshall(getQueryResultsRequest.getQueryId(), QUERYID_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 InputStream getInputStream(String strFilename)
{
InputStream streamIn = null;
if ((strFilename != null) && (strFilename.length() > 0))
{
try {
URL url = null;
if (strFilename.indexOf(':') == -1)
if (this.getApplication() != null)
url = this.getApplication().getResourceURL(strFilename, this);
if (url != null)
streamIn = url.openStream();
} catch (Exception ex) {
streamIn = null;
}
}
if (streamIn == null)
streamIn = Util.getInputStream(strFilename, this.getApplication());
return streamIn;
} } | public class class_name {
public InputStream getInputStream(String strFilename)
{
InputStream streamIn = null;
if ((strFilename != null) && (strFilename.length() > 0))
{
try {
URL url = null;
if (strFilename.indexOf(':') == -1)
if (this.getApplication() != null)
url = this.getApplication().getResourceURL(strFilename, this);
if (url != null)
streamIn = url.openStream();
} catch (Exception ex) {
streamIn = null;
} // depends on control dependency: [catch], data = [none]
}
if (streamIn == null)
streamIn = Util.getInputStream(strFilename, this.getApplication());
return streamIn;
} } |
public class class_name {
private static void possiblyFail(float chanceFailure, Random random) {
float value = random.nextFloat();
if (value < chanceFailure) {
LOG.fatal("shouldFail: Failing with value " + value +
" < " + chanceFailure);
System.exit(-1);
}
} } | public class class_name {
private static void possiblyFail(float chanceFailure, Random random) {
float value = random.nextFloat();
if (value < chanceFailure) {
LOG.fatal("shouldFail: Failing with value " + value +
" < " + chanceFailure); // depends on control dependency: [if], data = [none]
System.exit(-1); // depends on control dependency: [if], data = [none]
}
} } |
public class class_name {
public static boolean containsOccurrences(
Multiset<?> superMultiset, Multiset<?> subMultiset) {
checkNotNull(superMultiset);
checkNotNull(subMultiset);
for (Entry<?> entry : subMultiset.entrySet()) {
int superCount = superMultiset.count(entry.getElement());
if (superCount < entry.getCount()) {
return false;
}
}
return true;
} } | public class class_name {
public static boolean containsOccurrences(
Multiset<?> superMultiset, Multiset<?> subMultiset) {
checkNotNull(superMultiset);
checkNotNull(subMultiset);
for (Entry<?> entry : subMultiset.entrySet()) {
int superCount = superMultiset.count(entry.getElement());
if (superCount < entry.getCount()) {
return false; // depends on control dependency: [if], data = [none]
}
}
return true;
} } |
public class class_name {
@Override
public EClass getIfcVertex() {
if (ifcVertexEClass == null) {
ifcVertexEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI).getEClassifiers()
.get(750);
}
return ifcVertexEClass;
} } | public class class_name {
@Override
public EClass getIfcVertex() {
if (ifcVertexEClass == null) {
ifcVertexEClass = (EClass) EPackage.Registry.INSTANCE.getEPackage(Ifc4Package.eNS_URI).getEClassifiers()
.get(750);
// depends on control dependency: [if], data = [none]
}
return ifcVertexEClass;
} } |
public class class_name {
private String translateWildcards(String input)
{
StringBuilder translated = new StringBuilder(input.length());
boolean escaped = false;
for (int i = 0; i < input.length(); i++)
{
if (input.charAt(i) == '\\')
{
if (escaped)
{
translated.append("\\\\");
escaped = false;
}
else
{
escaped = true;
}
}
else if (input.charAt(i) == '*')
{
if (escaped)
{
translated.append('*');
escaped = false;
}
else
{
translated.append('%');
}
}
else if (input.charAt(i) == '?')
{
if (escaped)
{
translated.append('?');
escaped = false;
}
else
{
translated.append('_');
}
}
else if (input.charAt(i) == '%' || input.charAt(i) == '_')
{
// escape every occurrence of '%' and '_'
escaped = false;
translated.append('\\').append(input.charAt(i));
}
else
{
if (escaped)
{
translated.append('\\');
escaped = false;
}
translated.append(input.charAt(i));
}
}
return translated.toString();
} } | public class class_name {
private String translateWildcards(String input)
{
StringBuilder translated = new StringBuilder(input.length());
boolean escaped = false;
for (int i = 0; i < input.length(); i++)
{
if (input.charAt(i) == '\\')
{
if (escaped)
{
translated.append("\\\\"); // depends on control dependency: [if], data = [none]
escaped = false; // depends on control dependency: [if], data = [none]
}
else
{
escaped = true; // depends on control dependency: [if], data = [none]
}
}
else if (input.charAt(i) == '*')
{
if (escaped)
{
translated.append('*'); // depends on control dependency: [if], data = [none]
escaped = false; // depends on control dependency: [if], data = [none]
}
else
{
translated.append('%'); // depends on control dependency: [if], data = [none]
}
}
else if (input.charAt(i) == '?')
{
if (escaped)
{
translated.append('?'); // depends on control dependency: [if], data = [none]
escaped = false; // depends on control dependency: [if], data = [none]
}
else
{
translated.append('_'); // depends on control dependency: [if], data = [none]
}
}
else if (input.charAt(i) == '%' || input.charAt(i) == '_')
{
// escape every occurrence of '%' and '_'
escaped = false; // depends on control dependency: [if], data = [none]
translated.append('\\').append(input.charAt(i)); // depends on control dependency: [if], data = [(input.charAt(i)]
}
else
{
if (escaped)
{
translated.append('\\'); // depends on control dependency: [if], data = [none]
escaped = false; // depends on control dependency: [if], data = [none]
}
translated.append(input.charAt(i)); // depends on control dependency: [if], data = [(input.charAt(i)]
}
}
return translated.toString();
} } |
public class class_name {
@Override
public void draw(final Canvas canvas, final Projection pj) {
if (mPendingFocusChangedEvent && mOnFocusChangeListener != null)
mOnFocusChangeListener.onFocusChanged(this, mFocusedItem);
mPendingFocusChangedEvent = false;
final int size = Math.min(this.mInternalItemList.size(), mDrawnItemsLimit);
if (mInternalItemDisplayedList == null || mInternalItemDisplayedList.length != size) {
mInternalItemDisplayedList = new boolean[size];
}
/* Draw in backward cycle, so the items with the least index are on the front. */
for (int i = size - 1; i >= 0; i--) {
final Item item = getItem(i);
if (item == null) {
continue;
}
pj.toPixels(item.getPoint(), mCurScreenCoords);
calculateItemRect(item, mCurScreenCoords, itemRect);
mInternalItemDisplayedList[i] = onDrawItem(canvas,item, mCurScreenCoords, pj);
}
} } | public class class_name {
@Override
public void draw(final Canvas canvas, final Projection pj) {
if (mPendingFocusChangedEvent && mOnFocusChangeListener != null)
mOnFocusChangeListener.onFocusChanged(this, mFocusedItem);
mPendingFocusChangedEvent = false;
final int size = Math.min(this.mInternalItemList.size(), mDrawnItemsLimit);
if (mInternalItemDisplayedList == null || mInternalItemDisplayedList.length != size) {
mInternalItemDisplayedList = new boolean[size]; // depends on control dependency: [if], data = [none]
}
/* Draw in backward cycle, so the items with the least index are on the front. */
for (int i = size - 1; i >= 0; i--) {
final Item item = getItem(i);
if (item == null) {
continue;
}
pj.toPixels(item.getPoint(), mCurScreenCoords); // depends on control dependency: [for], data = [none]
calculateItemRect(item, mCurScreenCoords, itemRect); // depends on control dependency: [for], data = [none]
mInternalItemDisplayedList[i] = onDrawItem(canvas,item, mCurScreenCoords, pj); // depends on control dependency: [for], data = [i]
}
} } |
public class class_name {
public static Object readNativeValue(Type type, Block block, int position)
{
Class<?> javaType = type.getJavaType();
if (block.isNull(position)) {
return null;
}
if (javaType == long.class) {
return type.getLong(block, position);
}
if (javaType == double.class) {
return type.getDouble(block, position);
}
if (javaType == boolean.class) {
return type.getBoolean(block, position);
}
if (javaType == Slice.class) {
return type.getSlice(block, position);
}
return type.getObject(block, position);
} } | public class class_name {
public static Object readNativeValue(Type type, Block block, int position)
{
Class<?> javaType = type.getJavaType();
if (block.isNull(position)) {
return null; // depends on control dependency: [if], data = [none]
}
if (javaType == long.class) {
return type.getLong(block, position); // depends on control dependency: [if], data = [none]
}
if (javaType == double.class) {
return type.getDouble(block, position); // depends on control dependency: [if], data = [none]
}
if (javaType == boolean.class) {
return type.getBoolean(block, position); // depends on control dependency: [if], data = [none]
}
if (javaType == Slice.class) {
return type.getSlice(block, position); // depends on control dependency: [if], data = [none]
}
return type.getObject(block, position);
} } |
public class class_name {
public static <E> Set<E> retainAbove(Counter<E> counter, double countThreshold) {
Set<E> removed = new HashSet<E>();
for (E key : counter.keySet()) {
if (counter.getCount(key) < countThreshold) {
removed.add(key);
}
}
for (E key : removed) {
counter.remove(key);
}
return removed;
} } | public class class_name {
public static <E> Set<E> retainAbove(Counter<E> counter, double countThreshold) {
Set<E> removed = new HashSet<E>();
for (E key : counter.keySet()) {
if (counter.getCount(key) < countThreshold) {
removed.add(key);
// depends on control dependency: [if], data = [none]
}
}
for (E key : removed) {
counter.remove(key);
// depends on control dependency: [for], data = [key]
}
return removed;
} } |
public class class_name {
private void initializeViews() {
directoryTitle = (TextView) findViewById(R.id.file_directory_title);
addButton = (MaterialFloatingActionButton) findViewById(R.id.file_picker_add_button);
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NameFileDialog nfd = NameFileDialog.newInstance();
nfd.show(getFragmentManager(), "NameDialog");
}
});
if (fabColorId != -1) {
addButton.setButtonColor(getResources().getColor(fabColorId));
}
selectButton = (Button) findViewById(R.id.select_button);
selectButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (requestCode == Request.DIRECTORY) {
if (currentFile.isDirectory()) {
curDirectory = currentFile;
data = new Intent();
data.putExtra(FILE_EXTRA_DATA_PATH, currentFile.getAbsolutePath());
setResult(RESULT_OK, data);
finish();
} else {
Snackbar.make(getWindow().getDecorView(), R.string.file_picker_snackbar_select_directory_message, Snackbar.LENGTH_SHORT).show();
}
} else { //request code is for a file
if (currentFile.isDirectory()) {
curDirectory = currentFile;
new UpdateFilesTask(FilePickerActivity.this).execute(curDirectory);
} else {
if (!TextUtils.isEmpty(mimeType)) {
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
String requiredExtension = "." + mimeTypeMap.getExtensionFromMimeType(mimeType);
if (requiredExtension.equalsIgnoreCase(fileExt(currentFile.toString()))) {
data = new Intent();
data.putExtra(FILE_EXTRA_DATA_PATH, currentFile.getAbsolutePath());
setResult(RESULT_OK, data);
finish();
} else {
Snackbar.make(getWindow().getDecorView(), String.format(getString(R.string.file_picker_snackbar_select_file_ext_message), requiredExtension), Snackbar.LENGTH_SHORT).show();
}
} else {
data = new Intent();
data.putExtra(FILE_EXTRA_DATA_PATH, currentFile.getAbsolutePath());
setResult(RESULT_OK, data);
finish();
}
}
}
}
});
openButton = (Button) findViewById(R.id.open_button);
openButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (currentFile.isDirectory()) {
curDirectory = currentFile;
directoryTitle.setText(curDirectory.getName());
new UpdateFilesTask(FilePickerActivity.this).execute(curDirectory);
} else {
Intent newIntent = new Intent(Intent.ACTION_VIEW);
String file = currentFile.toString();
if (file != null) {
newIntent.setDataAndType(Uri.fromFile(currentFile), mimeType);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(newIntent);
} catch (ActivityNotFoundException e) {
Snackbar.make(getWindow().getDecorView(), R.string.file_picker_snackbar_no_file_type_handler, Snackbar.LENGTH_SHORT).show();
}
} else {
Snackbar.make(getWindow().getDecorView(), R.string.file_picker_snackbar_no_read_type, Snackbar.LENGTH_SHORT).show();
}
}
}
});
buttonContainer = (LinearLayout) findViewById(R.id.button_container);
buttonContainer.setVisibility(View.INVISIBLE);
header = (RelativeLayout) findViewById(R.id.header_container);
} } | public class class_name {
private void initializeViews() {
directoryTitle = (TextView) findViewById(R.id.file_directory_title);
addButton = (MaterialFloatingActionButton) findViewById(R.id.file_picker_add_button);
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NameFileDialog nfd = NameFileDialog.newInstance();
nfd.show(getFragmentManager(), "NameDialog");
}
});
if (fabColorId != -1) {
addButton.setButtonColor(getResources().getColor(fabColorId)); // depends on control dependency: [if], data = [(fabColorId]
}
selectButton = (Button) findViewById(R.id.select_button);
selectButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (requestCode == Request.DIRECTORY) {
if (currentFile.isDirectory()) {
curDirectory = currentFile; // depends on control dependency: [if], data = [none]
data = new Intent(); // depends on control dependency: [if], data = [none]
data.putExtra(FILE_EXTRA_DATA_PATH, currentFile.getAbsolutePath()); // depends on control dependency: [if], data = [none]
setResult(RESULT_OK, data); // depends on control dependency: [if], data = [none]
finish(); // depends on control dependency: [if], data = [none]
} else {
Snackbar.make(getWindow().getDecorView(), R.string.file_picker_snackbar_select_directory_message, Snackbar.LENGTH_SHORT).show(); // depends on control dependency: [if], data = [none]
}
} else { //request code is for a file
if (currentFile.isDirectory()) {
curDirectory = currentFile; // depends on control dependency: [if], data = [none]
new UpdateFilesTask(FilePickerActivity.this).execute(curDirectory); // depends on control dependency: [if], data = [none]
} else {
if (!TextUtils.isEmpty(mimeType)) {
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
String requiredExtension = "." + mimeTypeMap.getExtensionFromMimeType(mimeType);
if (requiredExtension.equalsIgnoreCase(fileExt(currentFile.toString()))) {
data = new Intent(); // depends on control dependency: [if], data = [none]
data.putExtra(FILE_EXTRA_DATA_PATH, currentFile.getAbsolutePath()); // depends on control dependency: [if], data = [none]
setResult(RESULT_OK, data); // depends on control dependency: [if], data = [none]
finish(); // depends on control dependency: [if], data = [none]
} else {
Snackbar.make(getWindow().getDecorView(), String.format(getString(R.string.file_picker_snackbar_select_file_ext_message), requiredExtension), Snackbar.LENGTH_SHORT).show(); // depends on control dependency: [if], data = [none]
}
} else {
data = new Intent(); // depends on control dependency: [if], data = [none]
data.putExtra(FILE_EXTRA_DATA_PATH, currentFile.getAbsolutePath()); // depends on control dependency: [if], data = [none]
setResult(RESULT_OK, data); // depends on control dependency: [if], data = [none]
finish(); // depends on control dependency: [if], data = [none]
}
}
}
}
});
openButton = (Button) findViewById(R.id.open_button);
openButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (currentFile.isDirectory()) {
curDirectory = currentFile; // depends on control dependency: [if], data = [none]
directoryTitle.setText(curDirectory.getName()); // depends on control dependency: [if], data = [none]
new UpdateFilesTask(FilePickerActivity.this).execute(curDirectory); // depends on control dependency: [if], data = [none]
} else {
Intent newIntent = new Intent(Intent.ACTION_VIEW);
String file = currentFile.toString();
if (file != null) {
newIntent.setDataAndType(Uri.fromFile(currentFile), mimeType); // depends on control dependency: [if], data = [none]
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // depends on control dependency: [if], data = [none]
try {
startActivity(newIntent); // depends on control dependency: [try], data = [none]
} catch (ActivityNotFoundException e) {
Snackbar.make(getWindow().getDecorView(), R.string.file_picker_snackbar_no_file_type_handler, Snackbar.LENGTH_SHORT).show();
} // depends on control dependency: [catch], data = [none]
} else {
Snackbar.make(getWindow().getDecorView(), R.string.file_picker_snackbar_no_read_type, Snackbar.LENGTH_SHORT).show(); // depends on control dependency: [if], data = [none]
}
}
}
});
buttonContainer = (LinearLayout) findViewById(R.id.button_container);
buttonContainer.setVisibility(View.INVISIBLE);
header = (RelativeLayout) findViewById(R.id.header_container);
} } |
public class class_name {
private String getFolderAndCreateIfMissing(String inFolder) {
String folder = outputFolder;
if (inFolder != null) {
folder += "/" + inFolder;
}
mkdirs(folder);
return folder;
} } | public class class_name {
private String getFolderAndCreateIfMissing(String inFolder) {
String folder = outputFolder;
if (inFolder != null) {
folder += "/" + inFolder; // depends on control dependency: [if], data = [none]
}
mkdirs(folder);
return folder;
} } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.